/** * OrgX API Client * * Communicates with the OrgX server for org snapshots, memory sync, * quality gates, model routing, and entity CRUD. * * Uses native fetch — no external dependencies. */ import type { OrgSnapshot, SyncPayload, SyncResponse, SpawnGuardResult, QualityScore, Entity, EntityListFilters, EmitActivityRequest, EmitActivityResponse, ApplyChangesetRequest, ApplyChangesetResponse, RecordRunOutcomeRequest, RecordRunOutcomeResponse, RecordRunRetroRequest, RecordRunRetroResponse, LiveActivityItem, SessionTreeResponse, HandoffSummary, EntityUpdateResult, CheckpointSummary, RestoreRequest, DelegationPreflightResult, BillingStatus, BillingCheckoutRequest, BillingUrlResult, UsageControlPlaneSummary, KickoffContextRequest, KickoffContextResponse, SkillPack, ClientRuntimeSettingsResponse, ClientRuntimeSettingsUpdateRequest } from "./types.js"; export type DecisionAction = "approve" | "reject"; export type RunAction = "pause" | "resume" | "cancel" | "rollback"; export interface DecisionActionResult { id: string; ok: boolean; entity?: Entity; error?: string; } export interface DecisionMutationInput { note?: string; optionId?: string; } export declare class OrgXClient { private apiKey; private baseUrl; private userId; constructor(apiKey: string, baseUrl: string, userId?: string); setCredentials(input: { apiKey?: string; userId?: string; baseUrl?: string; }): void; getBaseUrl(): string; getUserId(): string; /** * Low-level authenticated request helper. * * This is intentionally part of the public surface so other codebases can * layer additional adapters/endpoints without re-implementing auth header * logic (and drifting from the canonical client contract). */ rawRequest(method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE", path: string, body?: unknown): Promise; private request; private get; private post; private patch; private buildQuery; private unwrapSyncResponse; private executeClientTool; getOrgSnapshot(): Promise; syncMemory(payload: SyncPayload): Promise; getKickoffContext(payload: KickoffContextRequest): Promise; getSkillPack(input?: { name?: string; ifNoneMatch?: string | null; }): Promise<{ ok: true; notModified: true; etag: string | null; pack: null; } | { ok: true; notModified: false; etag: string | null; pack: SkillPack; } | { ok: false; status: number; error: string; }>; getClientAgentRuntimeSettings(input?: { workspaceId?: string | null; /** Legacy alias retained for backward compatibility */ projectId?: string | null; }): Promise; updateClientAgentRuntimeSettings(payload: ClientRuntimeSettingsUpdateRequest): Promise; delegationPreflight(payload: { intent: string; acceptanceCriteria?: string[]; constraints?: string[]; domains?: string[]; }): Promise<{ ok: boolean; data: DelegationPreflightResult; }>; checkSpawnGuard(domain: string, taskId?: string): Promise; recordQuality(score: QualityScore): Promise<{ success: boolean; }>; getMorningBrief(params: { workspace_id: string; session_id?: string; }): Promise>; queryOrgMemory(params: { query: string; scope?: "all" | "artifacts" | "decisions" | "initiatives"; limit?: number; }): Promise>; recommendNextAction(params: { entity_type?: "workspace" | "initiative" | "workstream" | "milestone"; entity_id?: string; workspace_id?: string; command_center_id?: string; limit?: number; cascade?: boolean; }): Promise>; /** * Create an OrgX entity. * POST /api/entities { type, title, summary, status, initiative_id, ... } */ createEntity(type: string, data: Record): Promise; /** * Update an OrgX entity. * PATCH /api/entities { type, id, ...updates } */ updateEntity(type: string, id: string, updates: Record): Promise; /** * Update an OrgX entity and preserve reassignment metadata when present. * PATCH /api/entities { type, id, ...updates } */ updateEntityDetailed(type: string, id: string, updates: Record): Promise; /** * List OrgX entities. * GET /api/entities?type={type}&status={status}&limit={n} */ listEntities(type: string, filters?: EntityListFilters): Promise<{ data: Entity[]; pagination: { total: number; has_more: boolean; }; }>; getBillingStatus(): Promise; createBillingCheckout(payload: BillingCheckoutRequest): Promise; createBillingPortal(): Promise; getUsageControlPlaneSummary(): Promise; getUsageUnified(): Promise; getUsageForecast(): Promise>; emitActivity(payload: EmitActivityRequest): Promise; applyChangeset(payload: ApplyChangesetRequest): Promise; recordRunOutcome(payload: RecordRunOutcomeRequest): Promise; recordRunRetro(payload: RecordRunRetroRequest): Promise; createAgentJob(payload: { initiative_id: string; workstream_id: string; task_id?: string | null; run_id: string; agent_type: string; execution_target: string; worker_name: string; machine_id: string; slice_scope?: string | null; metadata?: Record | null; }): Promise<{ ok: boolean; job_id: string; }>; updateAgentJob(payload: { job_id: string; status: "completed" | "failed" | "cancelled"; error?: string | null; output?: Record | null; }): Promise<{ ok: boolean; }>; queryDispatchPreflight(payload: { initiative_id: string; workstream_id: string; task_id?: string | null; launch_mode: "autopilot" | "manual"; }): Promise<{ dispatch_status: string; block_reasons: Array<{ code: string; message: string; severity: string; overrideable: boolean; }>; recommended_execution_target: string; eligible_workers: Array<{ workerId: string; workerName: string; }>; }>; getLiveSessions(params?: { limit?: number; initiative?: string | null; workspaceId?: string | null; /** @deprecated Use workspaceId */ projectId?: string | null; }): Promise; getLiveActivity(params?: { limit?: number; run?: string | null; since?: string | null; workspaceId?: string | null; /** @deprecated Use workspaceId */ projectId?: string | null; }): Promise<{ activities: LiveActivityItem[]; total: number; }>; getLiveAgents(params?: { initiative?: string | null; includeIdle?: boolean; workspaceId?: string | null; /** @deprecated Use workspaceId */ projectId?: string | null; }): Promise<{ agents: unknown[]; summary: Record; }>; getLiveInitiatives(params?: { id?: string | null; limit?: number; offset?: number; workspaceId?: string | null; /** @deprecated Use workspaceId */ projectId?: string | null; }): Promise<{ initiatives: unknown[]; total: number; pagination?: { limit?: number; offset?: number; has_more?: boolean; }; }>; getHandoffs(): Promise<{ handoffs: HandoffSummary[]; }>; runAction(runId: string, action: RunAction, payload?: { checkpointId?: string; reason?: string; }): Promise<{ ok: boolean; data: { runId: string; action: RunAction; status: string; checkpointId?: string; }; }>; listRunCheckpoints(runId: string): Promise<{ ok: boolean; data: CheckpointSummary[]; }>; createRunCheckpoint(runId: string, payload?: { reason?: string; payload?: Record; }): Promise<{ ok: boolean; data: CheckpointSummary; }>; restoreRunCheckpoint(runId: string, request: RestoreRequest): Promise<{ ok: boolean; data: { runId: string; action: RunAction; status: string; checkpointId?: string; }; }>; getLiveDecisions(params?: { status?: string; limit?: number; workspaceId?: string | null; /** @deprecated Use workspaceId */ projectId?: string | null; }): Promise<{ decisions: Entity[]; total: number; }>; decideDecision(id: string, action: DecisionAction, input?: DecisionMutationInput): Promise; bulkDecideDecisions(ids: string[], action: DecisionAction, input?: DecisionMutationInput): Promise; }