@ai-matrx/api 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/account.d.cts +1 -1
  3. package/dist/account.d.ts +1 -1
  4. package/dist/agents.cjs +11 -11
  5. package/dist/agents.d.cts +1 -1
  6. package/dist/agents.d.ts +1 -1
  7. package/dist/agents.js +1 -1
  8. package/dist/ai.cjs +2 -2
  9. package/dist/ai.d.cts +1 -1
  10. package/dist/ai.d.ts +1 -1
  11. package/dist/ai.js +1 -1
  12. package/dist/apps.cjs +5 -5
  13. package/dist/apps.d.cts +1 -1
  14. package/dist/apps.d.ts +1 -1
  15. package/dist/apps.js +1 -1
  16. package/dist/architecture.cjs +10 -10
  17. package/dist/architecture.d.cts +1 -1
  18. package/dist/architecture.d.ts +1 -1
  19. package/dist/architecture.js +1 -1
  20. package/dist/audio.cjs +4 -4
  21. package/dist/audio.d.cts +1 -1
  22. package/dist/audio.d.ts +1 -1
  23. package/dist/audio.js +1 -1
  24. package/dist/chat.cjs +11 -11
  25. package/dist/chat.d.cts +1 -1
  26. package/dist/chat.d.ts +1 -1
  27. package/dist/chat.js +1 -1
  28. package/dist/{chunk-2FJPWNXG.js → chunk-5BBHAAIG.js} +9 -3
  29. package/dist/{chunk-UO3H55R3.cjs → chunk-NMBDYPFZ.cjs} +9 -3
  30. package/dist/code.cjs +6 -6
  31. package/dist/code.d.cts +1 -1
  32. package/dist/code.d.ts +1 -1
  33. package/dist/code.js +1 -1
  34. package/dist/commerce.d.cts +1 -1
  35. package/dist/commerce.d.ts +1 -1
  36. package/dist/communications.cjs +4 -4
  37. package/dist/communications.d.cts +1 -1
  38. package/dist/communications.d.ts +1 -1
  39. package/dist/communications.js +1 -1
  40. package/dist/computer.cjs +3 -3
  41. package/dist/computer.d.cts +1 -1
  42. package/dist/computer.d.ts +1 -1
  43. package/dist/computer.js +1 -1
  44. package/dist/content.cjs +4 -4
  45. package/dist/content.d.cts +1 -1
  46. package/dist/content.d.ts +1 -1
  47. package/dist/content.js +1 -1
  48. package/dist/crm.cjs +2 -2
  49. package/dist/crm.d.cts +1 -1
  50. package/dist/crm.d.ts +1 -1
  51. package/dist/crm.js +1 -1
  52. package/dist/data.d.cts +1 -1
  53. package/dist/data.d.ts +1 -1
  54. package/dist/education.cjs +4 -4
  55. package/dist/education.d.cts +1 -1
  56. package/dist/education.d.ts +1 -1
  57. package/dist/education.js +1 -1
  58. package/dist/files.cjs +20 -20
  59. package/dist/files.d.cts +1 -1
  60. package/dist/files.d.ts +1 -1
  61. package/dist/files.js +1 -1
  62. package/dist/human-resources.d.cts +1 -1
  63. package/dist/human-resources.d.ts +1 -1
  64. package/dist/{index-Xx6L_pWk.d.cts → index-D_ZjxGwP.d.cts} +5 -0
  65. package/dist/{index-Xx6L_pWk.d.ts → index-D_ZjxGwP.d.ts} +5 -0
  66. package/dist/index.cjs +697 -53
  67. package/dist/index.d.cts +783 -3
  68. package/dist/index.d.ts +783 -3
  69. package/dist/index.js +636 -3
  70. package/dist/integrations.cjs +3 -3
  71. package/dist/integrations.d.cts +1 -1
  72. package/dist/integrations.d.ts +1 -1
  73. package/dist/integrations.js +1 -1
  74. package/dist/intelligence.cjs +19 -8
  75. package/dist/intelligence.d.cts +3 -648
  76. package/dist/intelligence.d.ts +3 -648
  77. package/dist/intelligence.js +14 -3
  78. package/dist/keys.generated-CK_C5UXG.d.cts +658 -0
  79. package/dist/keys.generated-CK_C5UXG.d.ts +658 -0
  80. package/dist/knowledge.cjs +42 -42
  81. package/dist/knowledge.d.cts +1 -1
  82. package/dist/knowledge.d.ts +1 -1
  83. package/dist/knowledge.js +1 -1
  84. package/dist/legal.cjs +6 -6
  85. package/dist/legal.d.cts +1 -1
  86. package/dist/legal.d.ts +1 -1
  87. package/dist/legal.js +1 -1
  88. package/dist/marketing.cjs +76 -76
  89. package/dist/marketing.d.cts +1 -1
  90. package/dist/marketing.d.ts +1 -1
  91. package/dist/marketing.js +1 -1
  92. package/dist/masterwork.cjs +32 -32
  93. package/dist/masterwork.d.cts +1 -1
  94. package/dist/masterwork.d.ts +1 -1
  95. package/dist/masterwork.js +1 -1
  96. package/dist/media.cjs +11 -11
  97. package/dist/media.d.cts +1 -1
  98. package/dist/media.d.ts +1 -1
  99. package/dist/media.js +1 -1
  100. package/dist/platform.cjs +3 -3
  101. package/dist/platform.d.cts +1 -1
  102. package/dist/platform.d.ts +1 -1
  103. package/dist/platform.js +1 -1
  104. package/dist/publish.cjs +7 -7
  105. package/dist/publish.d.cts +1 -1
  106. package/dist/publish.d.ts +1 -1
  107. package/dist/publish.js +1 -1
  108. package/dist/stream.cjs +10 -10
  109. package/dist/stream.d.cts +1 -1
  110. package/dist/stream.d.ts +1 -1
  111. package/dist/stream.js +1 -1
  112. package/dist/web.cjs +26 -26
  113. package/dist/web.d.cts +1 -1
  114. package/dist/web.d.ts +1 -1
  115. package/dist/web.js +1 -1
  116. package/dist/workflows.cjs +13 -13
  117. package/dist/workflows.d.cts +1 -1
  118. package/dist/workflows.d.ts +1 -1
  119. package/dist/workflows.js +1 -1
  120. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { M as MatrxStreamEnvelope, b as MatrxNdjsonIssue, c as MatrxStreamEnvelopeObservation, d as MatrxSseFrame } from './index-Xx6L_pWk.js';
2
- export { A as Api, e as ApiRequestInfo, a as ApiStream, f as AuthTier, g as CONTRACT_SHA256, C as CallOptions, h as CreateApiOptions, D as DEPLOYMENTS, i as DOMAINS, j as DeploymentName, E as Environment, H as HttpMethod, J as JsonOrStream, N as NdjsonEvent, O as OperationArgs, k as OperationDescriptor, l as OrgRule, S as SseEvent, m as StreamKind, n as createApi, o as openJsonOrStream, p as openStream } from './index-Xx6L_pWk.js';
1
+ import { M as MatrxStreamEnvelope, b as MatrxNdjsonIssue, c as MatrxStreamEnvelopeObservation, d as MatrxSseFrame } from './index-D_ZjxGwP.js';
2
+ export { A as Api, e as ApiRequestInfo, a as ApiStream, f as AuthTier, g as CONTRACT_SHA256, C as CallOptions, h as CreateApiOptions, D as DEPLOYMENTS, i as DOMAINS, j as DeploymentName, E as Environment, H as HttpMethod, J as JsonOrStream, N as NdjsonEvent, O as OperationArgs, k as OperationDescriptor, l as OrgRule, S as SseEvent, m as StreamKind, n as createApi, o as openJsonOrStream, p as openStream } from './index-D_ZjxGwP.js';
3
3
  import { CredentialsPort } from '@ai-matrx/auth/credentials';
4
4
  export { API_KEY_PREFIX, CredentialsPort, CredentialsSetting, MATRX_HEADERS, MatrxCredential, MatrxCredentialKind, credentialToHeaders, toCredentialsPort } from '@ai-matrx/auth/credentials';
5
5
  import { ResilientFetchOptions } from './net.js';
6
6
  export { AbortedError, ConnectTimeoutError, HeartbeatTimeoutError, HttpError, NetError, NetErrorCode, NetworkError, OfflineError, ResilientFetchResult, RetryOptions, StreamMonitorOptions, TotalTimeoutError, extractErrorMessage, isNetError, isTransportFailure, monitorStream, resilientFetch, toNetError, withRetry } from './net.js';
7
+ import { g as MandateKey, b as DynamicMandateKey } from './keys.generated-CK_C5UXG.js';
7
8
 
8
9
  /**
9
10
  * `@ai-matrx/agents/matrx` — the Matrx transport port.
@@ -2066,4 +2067,783 @@ interface ProviderUsageReporter {
2066
2067
  }
2067
2068
  declare function createProviderUsageReporter(options: ProviderUsageReporterOptions): ProviderUsageReporter;
2068
2069
 
2069
- export { type ApiTargetLogContext, BackendApiError, type BackendApiErrorData, type BackendErrorCode, type BackendFailureExplanation, type CreateMatrxTransportOptions, type CreateWarmupOptions, type EndpointOverrideConfig, type ExecuteMatrxCallHooks, type ExecuteMatrxCallRequest, type FollowRuntimeOperationOptions, type FollowRuntimeOperationToEndOptions, type FollowRuntimeOperationToEndResult, type FollowServerJobOptions, type FollowUnavailableRejoinOptions, type JsonRequestOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, MATRX_UI_ONLY_BODY_FIELDS, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxCallResult, type MatrxCallScope, type MatrxChatMessage, type MatrxClientSessionProvider, type MatrxConversationStart, type MatrxEphemeralConversation, type MatrxFollowedOutcome, type MatrxHttpErrorLike, type MatrxHttpMethod, type MatrxJsonObject, type MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxOperationEventsPage, type MatrxOperationFollowEvent, type MatrxOperationStatusResponse, type MatrxOperationsByLinkResponse, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxQueryParams, type MatrxRequestInfo, type MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, type MatrxRuntimeExecutionStatus, type MatrxRuntimeOperationEvent, type MatrxRuntimeOperationView, type MatrxStoredConversationContinue, type MatrxStoredConversationCreate, type MatrxStreamCallOptions, type MatrxStreamCursorStamp, type MatrxStreamIds, type MatrxStreamParse, type MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportRequest, type MatrxTransportTarget, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ParseMatrxNdjsonResponseHooks, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ProviderSessionUsage, type ProviderSessionUsageReceipt, type ProviderUsageReporter, type ProviderUsageReporterOptions, type ProviderUsageSendResult, type QueryValue, RUN_OUTPUT_KINDS, RUN_STREAM_LIFETIME_BACKSTOP_MS, RUN_WAIT_KNOB_FEATURE, ResilientFetchOptions, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type RunOutputKind, type RunWait, type RunWaitKnobReader, type SendMatrxRequestOptions, type ServerJobFinalStatus, type ServerJobOutcome, type ServerJobPath, type ServerJobStatus, type ServerJobTarget, type SettleRunPickupOptions, type StreamReplayCursor, type StreamReplayCursorOptions, type StreamRequestOptions, StreamTransportError, TERMINAL_MATRX_RUNTIME_STATUSES, type UpstreamErrorPayload, V2_COVERED_AI_PATH_TEMPLATES, WARM_PATH, type WarmItem, type WarmReason, type Warmup, aiVersionPathOverrides, applyAiApiVersion, applyDesktopTargetToRequestBody, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, bareStatusSentence, buildMatrxRequestBody, buildMatrxRequestUrl, buildQuery, buildSafeRequestLog, continueEphemeralConversationStart, continueStoredConversationStart, createMatrxTransport, createOrganizationOperation, createProviderUsageReporter, createStreamReplayCursor, createWarmup, describeBackendFailure, encodePathSegment, executeMatrxCall, extractMatrxErrorCode, extractMatrxErrorMessage, fetchWithMatrxProtocolFallback, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, getUserMessage, honestTransportMessage, isBareTransportCode, isCoveredAiPath, isEmptyProviderUsage, isGenericUserMessage, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, isStreamTransportLost, isV2Path, listRuntimeOperationEvents, logApiTarget, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parseMatrxNdjsonResponse, parsePersistedBackendError, parseStreamError, pickServerJobOperation, preconnectServer, providerSessionFailureBody, providerSessionUsageBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, reportProviderSessionUsage, requestJson, requestStream, requireOrganizationContext, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeOrRejoin, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, streamErrorText, toRunHandle, toV1FallbackUrl, toV2Path, unwrapUpstreamError, withRunOrganization };
2070
+ /**
2071
+ * Agent run lifecycle against the AI Matrx API — start, continue, resume,
2072
+ * cancel — over the `MatrxTransport` port, with every streaming response
2073
+ * parsed through the package's ONE NDJSON wire kernel (`stream/ndjson`).
2074
+ *
2075
+ * Server truth (verified against aidream source):
2076
+ * - `POST /ai/agents/{agent_id}` — start (`aidream/api/routers/agents.py`)
2077
+ * - `POST /ai/conversations/{conversation_id}` — continue (`aidream/api/routers/conversations.py`)
2078
+ * - `POST /ai/conversations/{conversation_id}/resume` — resume after
2079
+ * client-delegated tool suspension (same router)
2080
+ * - `POST /ai/cancel/{request_id}?mode=interrupt` — cancel (`aidream/api/routers/cancel.py`)
2081
+ *
2082
+ * Response headers arrive before the body: `X-Conversation-ID` and
2083
+ * `X-Request-ID` are surfaced on the run handle immediately. `X-Request-ID`
2084
+ * is the ONLY id the server accepts for cancel — a client-local id means
2085
+ * nothing to it.
2086
+ *
2087
+ * Host policy stays out: no retry, no store, no timeouts, no persistence
2088
+ * (C10: no-persistence). Cancellation is the caller's `AbortSignal`; a client
2089
+ * disconnect never stops server work (`detach_on_disconnect`).
2090
+ */
2091
+
2092
+ /**
2093
+ * Stable identity of the durable entity whose saved context owns a run —
2094
+ * the server reloads the row and uses ITS scope (`ContextAnchor`,
2095
+ * `aidream/services/conversation_context/scope.py`).
2096
+ */
2097
+ interface MatrxContextAnchor {
2098
+ resource_type: string;
2099
+ resource_id: string;
2100
+ }
2101
+ /**
2102
+ * Scope and source fields shared by every scoped request
2103
+ * (`ScopedRequest` / `AcceptsInjectedScope` server-side). All optional here;
2104
+ * the start request narrows `organization_id` to required.
2105
+ */
2106
+ interface MatrxRequestScope {
2107
+ organization_id?: string;
2108
+ project_id?: string | null;
2109
+ task_id?: string | null;
2110
+ /** Active context-scope ids from the client's global picker (membership-validated server-side). */
2111
+ scope_ids?: string[] | null;
2112
+ /** Active scope-TYPE ids — a type-level selection with no specific scope chosen. */
2113
+ active_scope_type_ids?: string[] | null;
2114
+ context_anchor?: MatrxContextAnchor | null;
2115
+ /** Stable application slug that initiated the request. */
2116
+ source_app?: string | null;
2117
+ /** Stable feature slug within the source application. */
2118
+ source_feature?: string | null;
2119
+ /** "user" = a person directly triggered this; "auto" = client automation; omit for API callers. */
2120
+ initiation?: "user" | "auto" | null;
2121
+ /** Specific connected desktop instance allowed to claim delegated local tools. */
2122
+ target_instance_id?: string | null;
2123
+ }
2124
+ /**
2125
+ * Fields shared by start/continue turn requests (tool injection, client
2126
+ * capability envelope, context object). The complex bags (`tools`, `client`,
2127
+ * `user`, `config_overrides`) are typed as JSON objects — their authoritative
2128
+ * schemas are the server's Pydantic models and the generated API types;
2129
+ * this package stays payload-agnostic about them by design.
2130
+ */
2131
+ interface MatrxTurnFields {
2132
+ /** What the human typed (string), or structured input parts. Never smuggle machine content here. */
2133
+ user_input?: string | MatrxJsonValue[] | null;
2134
+ /** Per-run model/config overrides (LLMParams shape). */
2135
+ config_overrides?: MatrxJsonObject | null;
2136
+ debug?: boolean;
2137
+ /** Additive tool specs merged into the agent's resolved tool set. */
2138
+ tools?: MatrxJsonObject[];
2139
+ /** When set, becomes the agent's ENTIRE tool set for the turn. */
2140
+ tools_replace?: MatrxJsonObject[] | null;
2141
+ /** Client capability envelope (`ClientContext`). */
2142
+ client?: MatrxJsonObject | null;
2143
+ /** Per-request user-level tool inclusion/exclusion overrides. */
2144
+ user?: MatrxJsonObject | null;
2145
+ /** Per-route context object, free-form by design. */
2146
+ context?: MatrxJsonObject;
2147
+ writable_variables?: string[];
2148
+ allow_context_create?: boolean;
2149
+ /** Request-snapshot capture override (tri-state; omit for the platform default). */
2150
+ snapshot?: boolean | null;
2151
+ }
2152
+ /**
2153
+ * `POST /ai/agents/{agent_id}` body (`AgentStartRequest` server-side).
2154
+ * The conversation-start triple is required by construction; `organization_id`
2155
+ * is required (the server 422s a blank one — it never manufactures an org).
2156
+ * `stream` is not accepted here: this client is the streaming path and always
2157
+ * sends `stream: true`.
2158
+ */
2159
+ type MatrxAgentStartRequest = MatrxConversationStart & Omit<MatrxRequestScope, "organization_id"> & MatrxTurnFields & {
2160
+ organization_id: string;
2161
+ /** Variable name → value map filling the agent's declared variables. */
2162
+ variables?: MatrxJsonObject | null;
2163
+ /** Run the versions table row instead of the live agent row. */
2164
+ is_version?: boolean;
2165
+ max_iterations?: number;
2166
+ max_retries_per_iteration?: number;
2167
+ };
2168
+ /**
2169
+ * `POST /ai/mandates/{mandate_key}` uses the exact saved-agent start body.
2170
+ * The server resolves the mandate's holder, binding, and configuration; a
2171
+ * client must offer only the declared variables and human input here.
2172
+ */
2173
+ type MatrxMandateStartRequest = MatrxAgentStartRequest;
2174
+ /** `POST /ai/conversations/{id}` body (`ConversationContinueRequest` server-side). */
2175
+ type MatrxConversationContinueRequest = MatrxRequestScope & MatrxTurnFields & {
2176
+ /** Re-run the conversation's current persisted state (recovery after a failed turn); omit `user_input`. */
2177
+ retry?: boolean;
2178
+ };
2179
+ /**
2180
+ * `POST /ai/conversations/{id}/resume` body (`ResumeRequest` server-side) —
2181
+ * the shipped durable continuation after client-delegated tool calls were
2182
+ * answered via `POST /tool_results` while the original stream was gone.
2183
+ * `user_request_id` is optional: when omitted the server resolves the turn
2184
+ * from the conversation's newest answered client-delegated tool call.
2185
+ * Re-send fresh `context` here — a resumed loop is otherwise context-blind.
2186
+ */
2187
+ type MatrxConversationResumeRequest = MatrxRequestScope & {
2188
+ user_request_id?: string | null;
2189
+ config_overrides?: MatrxJsonObject | null;
2190
+ debug?: boolean;
2191
+ tools?: MatrxJsonObject[];
2192
+ tools_replace?: MatrxJsonObject[] | null;
2193
+ client?: MatrxJsonObject | null;
2194
+ user?: MatrxJsonObject | null;
2195
+ context?: MatrxJsonObject;
2196
+ writable_variables?: string[];
2197
+ allow_context_create?: boolean;
2198
+ };
2199
+ /** `POST /ai/cancel/{request_id}` response (`CancelResponse` server-side). */
2200
+ interface MatrxCancelResponse {
2201
+ status: string;
2202
+ request_id: string;
2203
+ spine_executions_signalled: string[];
2204
+ }
2205
+ /** Start an agent run: `POST /ai/agents/{agent_id}` (NDJSON stream). */
2206
+ declare function startAgentRun(transport: MatrxTransport, agentId: string, request: MatrxAgentStartRequest, options?: MatrxStreamCallOptions): Promise<MatrxRunHandle>;
2207
+ /**
2208
+ * Start a declared mandate: `POST /ai/mandates/{mandate_key}` (NDJSON
2209
+ * stream). This is deliberately separate from `startAgentRun`: callers name
2210
+ * the mandate and never resolve or echo its holder/configuration themselves.
2211
+ */
2212
+ declare function startMandateRun(transport: MatrxTransport, mandateKey: string, request: MatrxMandateStartRequest, options?: MatrxStreamCallOptions): Promise<MatrxRunHandle>;
2213
+ /** Continue a stored conversation: `POST /ai/conversations/{id}` (NDJSON stream). */
2214
+ declare function continueAgentConversation(transport: MatrxTransport, conversationId: string, request: MatrxConversationContinueRequest, options?: MatrxStreamCallOptions): Promise<MatrxRunHandle>;
2215
+ /**
2216
+ * Resume a suspended loop after delegated tool answers landed:
2217
+ * `POST /ai/conversations/{id}/resume` (NDJSON stream). A 409
2218
+ * (`resume_conflict`) means another resume holds the run claim — retrying is
2219
+ * host policy.
2220
+ */
2221
+ declare function resumeAgentConversation(transport: MatrxTransport, conversationId: string, request?: MatrxConversationResumeRequest, options?: MatrxStreamCallOptions): Promise<MatrxRunHandle>;
2222
+ /**
2223
+ * Stop a running request at its next iteration boundary:
2224
+ * `POST /ai/cancel/{request_id}`. Cooperative and best-effort — the in-flight
2225
+ * provider call finishes by design, and everything already streamed persists.
2226
+ * `mode: "interrupt"` = stop-and-fork: the tail after the last clean boundary
2227
+ * persists hidden so the user's follow-up replies to what they actually saw.
2228
+ * The id must be the server's `X-Request-ID`.
2229
+ */
2230
+ declare function cancelAgentRun(transport: MatrxTransport, requestId: string, options?: {
2231
+ mode?: "cancel" | "interrupt";
2232
+ signal?: AbortSignal;
2233
+ }): Promise<MatrxCancelResponse>;
2234
+ /**
2235
+ * A run that terminated unsuccessfully: the server emitted a fatal `error`
2236
+ * event, or the `user_request` completion settled `failed`/`cancelled`.
2237
+ */
2238
+ declare class MatrxRunError extends Error {
2239
+ readonly name = "MatrxRunError";
2240
+ /** The verbatim `error` event payload, when one fired. */
2241
+ readonly errorPayload: Record<string, unknown> | null;
2242
+ /** The `user_request` completion status (`"failed"` | `"cancelled"`), when that was the trigger. */
2243
+ readonly completionStatus: string | null;
2244
+ /** Text streamed before the failure — partial content never vanishes. */
2245
+ readonly partialText: string;
2246
+ constructor(args: {
2247
+ message: string;
2248
+ errorPayload?: Record<string, unknown> | null;
2249
+ completionStatus?: string | null;
2250
+ partialText?: string;
2251
+ });
2252
+ }
2253
+ interface MatrxCompletedRun {
2254
+ /** Accumulated `chunk` text (falls back to the completion's `result.output`). */
2255
+ text: string;
2256
+ requestId: string | null;
2257
+ conversationId: string | null;
2258
+ /** The `user_request` completion payload, verbatim, when one arrived. */
2259
+ completion: Record<string, unknown> | null;
2260
+ }
2261
+ interface RunAgentToCompletionOptions extends MatrxStreamCallOptions {
2262
+ /** Live progress: the full accumulated text after each chunk. */
2263
+ onChunk?: (fullText: string) => void;
2264
+ /** Every normalized envelope, before this helper interprets it. */
2265
+ onEvent?: (envelope: MatrxStreamEnvelope) => void;
2266
+ }
2267
+ /**
2268
+ * Run an agent end-to-end and resolve with its full text output — the
2269
+ * package-level equivalent of the simplest existing host path
2270
+ * (`useRunAgent`): accumulate `chunk` text, treat a fatal `error` event or a
2271
+ * `failed`/`cancelled` `user_request` completion as a thrown `MatrxRunError`,
2272
+ * and fall back to the completion's `result.output` when no text streamed.
2273
+ *
2274
+ * The caller still owns the conversation-start triple on `request` — a
2275
+ * one-shot run typically uses `newEphemeralConversationStart()`.
2276
+ */
2277
+ declare function runAgentToCompletion(transport: MatrxTransport, agentId: string, request: MatrxAgentStartRequest, options?: RunAgentToCompletionOptions): Promise<MatrxCompletedRun>;
2278
+
2279
+ /**
2280
+ * Delegated client tools — submit results and discover pending calls.
2281
+ *
2282
+ * Server truth (verified against aidream source,
2283
+ * `aidream/api/routers/conversations.py` + `aidream/services/ai_execution/
2284
+ * tool_results.py`):
2285
+ * - `POST /ai/conversations/{id}/tool_results` — durable, idempotent submit.
2286
+ * A delegated tool call HARD-SUSPENDS the loop; when the last outstanding
2287
+ * delegated row for the user_request resolves, the response carries
2288
+ * `continuation_needed: true` and the owning `user_request_id` — the signal
2289
+ * to open `resumeAgentConversation`. `continuation_needed` is best-effort:
2290
+ * parallel submits can both see `true`; `/resume` takes an atomic run claim
2291
+ * and the loser gets a 409.
2292
+ * - `GET /ai/conversations/{id}/pending_calls` — delegated calls awaiting the
2293
+ * user in one conversation (rows survive disconnects and reloads).
2294
+ * - `GET /ai/user/pending_calls` — every pending call for this user; an
2295
+ * optional `instance_id` atomically claims them for a desktop instance.
2296
+ *
2297
+ * A 404 from the submit means EVERY call_id was unknown (duplicate/expired);
2298
+ * partial success returns 200 with `not_found` populated. Batching, retries,
2299
+ * and the resume handoff are host policy — this module is the wire.
2300
+ */
2301
+
2302
+ /** One client tool answer (`ClientToolResult` server-side). */
2303
+ interface MatrxClientToolResult {
2304
+ call_id: string;
2305
+ tool_name: string;
2306
+ /** Tool output — inherently polymorphic; recursive JSON by design. */
2307
+ output?: MatrxJsonValue | null;
2308
+ is_error?: boolean;
2309
+ error_message?: string | null;
2310
+ /** Client-measured execution time in ms. */
2311
+ duration_ms?: number | null;
2312
+ }
2313
+ /** `POST /tool_results` response (`ToolResultsResponse` server-side). */
2314
+ interface MatrxToolResultsResponse {
2315
+ resolved: string[];
2316
+ already_resolved: string[];
2317
+ not_found: string[];
2318
+ /** True when the original stream is gone and no delegated calls remain — open `/resume`. */
2319
+ continuation_needed: boolean;
2320
+ user_request_id: string | null;
2321
+ conversation_id: string;
2322
+ }
2323
+ /** One delegated call awaiting an answer (`PendingCallSummary` server-side). */
2324
+ interface MatrxPendingCallSummary {
2325
+ id: string;
2326
+ call_id: string;
2327
+ conversation_id: string;
2328
+ user_request_id: string | null;
2329
+ message_id: string | null;
2330
+ tool_name: string;
2331
+ /** Tool-call argument bag — schema is per-tool (its input_schema). */
2332
+ arguments: MatrxJsonObject;
2333
+ iteration: number;
2334
+ created_at: string | null;
2335
+ expires_at: string | null;
2336
+ target_instance_id: string | null;
2337
+ claimed_by_instance_id: string | null;
2338
+ claim_expires_at: string | null;
2339
+ execution_authorization: MatrxJsonObject | null;
2340
+ }
2341
+ /**
2342
+ * Submit client tool results: `POST /ai/conversations/{id}/tool_results`.
2343
+ * Idempotent — duplicate submits return 200 with the ids in
2344
+ * `already_resolved`. Throws `MatrxApiError` (status 404) when every call_id
2345
+ * was unknown or expired; the stream stays alive in that case.
2346
+ */
2347
+ declare function submitAgentToolResults(transport: MatrxTransport, conversationId: string, results: MatrxClientToolResult[], options?: {
2348
+ instanceId?: string;
2349
+ signal?: AbortSignal;
2350
+ }): Promise<MatrxToolResultsResponse>;
2351
+ /**
2352
+ * Discover delegated calls awaiting the user in one conversation:
2353
+ * `GET /ai/conversations/{id}/pending_calls`. Safe to call on every
2354
+ * conversation load; a non-empty list should be surfaced exactly as if the
2355
+ * original stream had delivered the `tool_delegated` events live.
2356
+ */
2357
+ declare function listConversationPendingToolCalls(transport: MatrxTransport, conversationId: string, options?: {
2358
+ signal?: AbortSignal;
2359
+ }): Promise<MatrxPendingCallSummary[]>;
2360
+ /**
2361
+ * Discover every delegated call awaiting this user across all conversations:
2362
+ * `GET /ai/user/pending_calls`. Passing `instanceId` atomically CLAIMS the
2363
+ * calls for that desktop instance — only pass it from a client that will
2364
+ * actually execute them.
2365
+ */
2366
+ declare function listUserPendingToolCalls(transport: MatrxTransport, options?: {
2367
+ instanceId?: string;
2368
+ signal?: AbortSignal;
2369
+ }): Promise<MatrxPendingCallSummary[]>;
2370
+
2371
+ /**
2372
+ * `@ai-matrx/agents/matrx` — every AI Matrx server endpoint path, by feature
2373
+ * area (matching the server's router structure). Paths only, rooted at the
2374
+ * host (`/ai/...`, `/health`); the HOST owns the base URL.
2375
+ *
2376
+ * Moved from matrx-frontend `lib/api/endpoints.ts` (chat-package independence
2377
+ * P9); the app re-exports it. The production origin and the per-environment
2378
+ * base URLs stay in the host (they are environment values).
2379
+ */
2380
+
2381
+ /**
2382
+ * All backend API endpoint paths.
2383
+ *
2384
+ * Organized by feature area matching the backend router structure.
2385
+ * Use these constants everywhere instead of hardcoded strings.
2386
+ *
2387
+ * Auth tiers:
2388
+ * - Public: No auth required
2389
+ * - Guest OK: Fingerprint or JWT token
2390
+ * - Authenticated: Valid JWT token required
2391
+ * - Admin: Valid JWT token + admin role
2392
+ */
2393
+ declare const ENDPOINTS: {
2394
+ /** AI endpoints — chat, agents, conversations */
2395
+ readonly ai: {
2396
+ /**
2397
+ * POST — Manual-mode execution (Builder + ephemeral conversations).
2398
+ * POST /ai/manual
2399
+ *
2400
+ * Accepts full message history in `messages` on every call. Used by:
2401
+ * • Builder — reads the LIVE agent definition (incl. unsaved edits) and
2402
+ * sends it as the system instruction + priming messages.
2403
+ * • Ephemeral conversations (turn 2+) — no DB row exists, so the client
2404
+ * is the source of truth for history; sends it with each turn.
2405
+ *
2406
+ * `conversation_id` is optional in the body (for labeling/storage only);
2407
+ * pair with `is_new:false, store:false` for fully stateless runs.
2408
+ *
2409
+ * NOTE: this replaces the legacy `/ai/chat` endpoint. The canonical
2410
+ * client-side vocabulary is `manual` (see ConversationInvocation.routing
2411
+ * .apiEndpointMode). The legacy `chat` alias below stays for one
2412
+ * migration cycle.
2413
+ */
2414
+ readonly manual: "/ai/manual";
2415
+ /** @deprecated Use `ENDPOINTS.ai.manual`. Kept for one migration cycle. */
2416
+ readonly chat: "/ai/manual";
2417
+ /**
2418
+ * POST — Start a new agent conversation (Guest OK)
2419
+ * POST /ai/agents/{agentId}
2420
+ * Never send conversation_id — the server generates it and returns it in the stream.
2421
+ */
2422
+ readonly agentStart: (agentId: string) => `/ai/agents/${string}`;
2423
+ /**
2424
+ * POST — THE MANDATE DOOR. Start a new conversation by MANDATE KEY, not by
2425
+ * agent id (Guest OK).
2426
+ * POST /ai/mandates/{mandateKey}
2427
+ *
2428
+ * Body is the SAME `AgentStartRequest` as `agentStart`. The server resolves
2429
+ * the principal (bearer/fingerprint) → system default → org binding → user
2430
+ * binding, applies the binding's `config_overrides`, provision consumption
2431
+ * and variable mapping, and then runs the IDENTICAL downstream pipeline
2432
+ * (`_run_mandated_agent` → `_run_agent`). A rebind therefore changes which
2433
+ * agent answers with NO client deploy — which is the entire point.
2434
+ *
2435
+ * Never send mandate-derived `config_overrides` on this path: the server
2436
+ * treats request config as the EXPLICIT layer that WINS over the binding,
2437
+ * so echoing a client-resolved binding back would re-fork resolution.
2438
+ *
2439
+ * 404 `{code: "mandate_unfulfilled"}` when the mandate cannot be resolved —
2440
+ * surfaced verbatim, never swallowed into a client-side re-resolve.
2441
+ */
2442
+ readonly mandateStart: (mandateKey: MandateKey | DynamicMandateKey) => "/ai/mandates/agent_apps.prompt_app_dev" | "/ai/mandates/agent_factory.build" | "/ai/mandates/agent_factory.contract" | "/ai/mandates/agent_factory.instructions" | "/ai/mandates/agent_factory.proof_review" | "/ai/mandates/agent_factory.structure_builder" | "/ai/mandates/agent_factory.system_plan" | "/ai/mandates/agent_factory.tool_choice" | "/ai/mandates/agent_studio.chat_brief" | "/ai/mandates/ai.translation_cell_draft" | "/ai/mandates/alchemy.prepare_content" | "/ai/mandates/ambient.page_guidance" | "/ai/mandates/ambient.spoken_summary" | "/ai/mandates/applets.build" | "/ai/mandates/applets.fix" | "/ai/mandates/audio.live_music" | "/ai/mandates/audio.speech" | "/ai/mandates/brand.voice_rewrite" | "/ai/mandates/chat.cx_default" | "/ai/mandates/chat.default_new_chat" | "/ai/mandates/chat.quick_audio_plan" | "/ai/mandates/chat.quick_fair_news" | "/ai/mandates/chat.quick_flashcards" | "/ai/mandates/chat.quick_image" | "/ai/mandates/chat.quick_org_chart" | "/ai/mandates/chat.quick_research" | "/ai/mandates/chat.quick_showcase" | "/ai/mandates/chat.quick_writing_partner" | "/ai/mandates/chat.response_mode_brainstorm" | "/ai/mandates/chat.response_mode_data" | "/ai/mandates/chat.response_mode_research" | "/ai/mandates/chat.response_mode_video" | "/ai/mandates/checks.cleanup_bakeoff.answer" | "/ai/mandates/checks.cleanup_bakeoff.judge" | "/ai/mandates/checks.finding_disposition" | "/ai/mandates/checks.finding_disposition_review" | "/ai/mandates/cms.content_writing" | "/ai/mandates/cms.publish_review" | "/ai/mandates/cms.seo_metadata" | "/ai/mandates/cms.site_editing" | "/ai/mandates/cms.theme_design" | "/ai/mandates/code_editor.code_edit" | "/ai/mandates/code_editor.dynamic_context_edit" | "/ai/mandates/code_editor.prompt_app_ui_edit" | "/ai/mandates/coding_session.conversation_responder" | "/ai/mandates/coding_session.managed_translation_reference" | "/ai/mandates/commerce_intake.assess_value" | "/ai/mandates/commerce_intake.extract_vision" | "/ai/mandates/commerce_intake.grading" | "/ai/mandates/commerce_intake.instant_analysis" | "/ai/mandates/commerce_intake.refute_no_value" | "/ai/mandates/commerce_intake.research_product" | "/ai/mandates/commerce_intake.segment_photos" | "/ai/mandates/commerce_intake.verify_enrichment" | "/ai/mandates/content_gate.section_relevance_decision" | "/ai/mandates/content_ir.component_artisan" | "/ai/mandates/content_ir.kind_architect" | "/ai/mandates/content_ir.kind_component_builder" | "/ai/mandates/content_ir.kind_creator" | "/ai/mandates/content_plan.branch_purpose" | "/ai/mandates/content_plan.brief_writer" | "/ai/mandates/content_plan.deepen_page" | "/ai/mandates/content_plan.entity_attacher" | "/ai/mandates/content_plan.entity_curator" | "/ai/mandates/content_plan.family_namer" | "/ai/mandates/content_plan.keyword_strategist" | "/ai/mandates/content_plan.merge_wave" | "/ai/mandates/content_plan.p3_family" | "/ai/mandates/content_plan.p4_write" | "/ai/mandates/content_plan.p5_review" | "/ai/mandates/content_plan.p6_build" | "/ai/mandates/content_plan.p6_build.about" | "/ai/mandates/content_plan.p6_build.blog" | "/ai/mandates/content_plan.p6_build.comparison" | "/ai/mandates/content_plan.p6_build.contact" | "/ai/mandates/content_plan.p6_build.faq" | "/ai/mandates/content_plan.p6_build.guide" | "/ai/mandates/content_plan.p6_build.home" | "/ai/mandates/content_plan.p6_build.index" | "/ai/mandates/content_plan.p6_build.location" | "/ai/mandates/content_plan.p6_build.pillar" | "/ai/mandates/content_plan.p6_build.pricing" | "/ai/mandates/content_plan.p6_build.service" | "/ai/mandates/content_plan.plan_reviewer" | "/ai/mandates/content_plan.research_wave.audience_journey" | "/ai/mandates/content_plan.research_wave.competitor_coverage" | "/ai/mandates/content_plan.research_wave.keyword_value" | "/ai/mandates/content_plan.route_picker" | "/ai/mandates/content_plan.shape_planner" | "/ai/mandates/conversation.action_auditor" | "/ai/mandates/conversation.decision_ledger" | "/ai/mandates/conversation.drift_auditor" | "/ai/mandates/conversation.label_agent_run" | "/ai/mandates/conversation.label_chat" | "/ai/mandates/conversation.outcome_summarizer" | "/ai/mandates/conversation.vision_extractor" | "/ai/mandates/conversation.vision_interviewer" | "/ai/mandates/crm.journalist_beat_analyst" | "/ai/mandates/crm.media_list_ranker" | "/ai/mandates/crm.outreach_draft_reviewer" | "/ai/mandates/crm.outreach_fact_check" | "/ai/mandates/crm.outreach_personalization_coach" | "/ai/mandates/crm.outreach_personalization_writer" | "/ai/mandates/crm.outreach_pitch_writer" | "/ai/mandates/crm.outreach_recipient_shortlister" | "/ai/mandates/crm.outreach_reply_drafter" | "/ai/mandates/crm.outreach_strategy" | "/ai/mandates/crm.party_kind_judge" | "/ai/mandates/crm.save_contact" | "/ai/mandates/data.formula_writing" | "/ai/mandates/data.page_guidance" | "/ai/mandates/data.row_action" | "/ai/mandates/data.table_chat" | "/ai/mandates/desktop.cloud_chat" | "/ai/mandates/dictionary.workspace_guide" | "/ai/mandates/distillation.timeline_distiller" | "/ai/mandates/distillation.timeline_unfolder" | "/ai/mandates/docproc.content_structure" | "/ai/mandates/education.admin_guidance" | "/ai/mandates/education.analytics_narrate" | "/ai/mandates/education.audio_study_guidance" | "/ai/mandates/education.card_image_generator" | "/ai/mandates/education.card_image_prompt_writer" | "/ai/mandates/education.card_image_qc_judge" | "/ai/mandates/education.card_image_web_source" | "/ai/mandates/education.classes_guidance" | "/ai/mandates/education.creator_guidance" | "/ai/mandates/education.data_guidance" | "/ai/mandates/education.exam_prep_guidance" | "/ai/mandates/education.family_guidance" | "/ai/mandates/education.fastfire_guidance" | "/ai/mandates/education.features_guidance" | "/ai/mandates/education.flashcards_guidance" | "/ai/mandates/education.game_guidance" | "/ai/mandates/education.grade_handwritten" | "/ai/mandates/education.grade_work_guidance" | "/ai/mandates/education.kit_title" | "/ai/mandates/education.learn_guidance" | "/ai/mandates/education.levels_guidance" | "/ai/mandates/education.library_guidance" | "/ai/mandates/education.media_guidance" | "/ai/mandates/education.memory_generate" | "/ai/mandates/education.memory_guidance" | "/ai/mandates/education.memory_hint" | "/ai/mandates/education.mind_maps_guidance" | "/ai/mandates/education.mindmap_generate" | "/ai/mandates/education.notes_generate" | "/ai/mandates/education.notes_guidance" | "/ai/mandates/education.offline_guidance" | "/ai/mandates/education.page_guidance" | "/ai/mandates/education.plan_generate" | "/ai/mandates/education.planner_guidance" | "/ai/mandates/education.practice_oral_guidance" | "/ai/mandates/education.practice_tests_guidance" | "/ai/mandates/education.progress_guidance" | "/ai/mandates/education.quiz_deepen_item" | "/ai/mandates/education.quiz_generate" | "/ai/mandates/education.quiz_generate_from_source" | "/ai/mandates/education.quizzes_guidance" | "/ai/mandates/education.spoken_practice_design" | "/ai/mandates/education.spoken_practice_design_language" | "/ai/mandates/education.spoken_practice_grade" | "/ai/mandates/education.spoken_practice_grade_pronunciation" | "/ai/mandates/education.spoken_practice_review" | "/ai/mandates/education.start_guidance" | "/ai/mandates/education.study_aids_guidance" | "/ai/mandates/education.study_pack_flashcards" | "/ai/mandates/education.study_pack_lessons" | "/ai/mandates/education.study_pack_notes" | "/ai/mandates/education.study_pack_quiz" | "/ai/mandates/education.study_pack_v2_flashcards" | "/ai/mandates/education.study_pack_v2_lessons" | "/ai/mandates/education.study_pack_v2_notes" | "/ai/mandates/education.study_pack_v2_quiz" | "/ai/mandates/education.subjects_guidance" | "/ai/mandates/education.summaries_guidance" | "/ai/mandates/education.summarize" | "/ai/mandates/education.tutor_guidance" | "/ai/mandates/education.tutor_message" | "/ai/mandates/education.voice_tutor" | "/ai/mandates/evaluators.comparative_judge" | "/ai/mandates/evaluators.rubric_judge" | "/ai/mandates/extend.browser_chat" | "/ai/mandates/extend.pattern_from_data" | "/ai/mandates/extend.structured_extractor" | "/ai/mandates/feedback.item_triage_decision" | "/ai/mandates/flashcards.enrich_card" | "/ai/mandates/flashcards.expand_card" | "/ai/mandates/flashcards.fix_giveaway_cards" | "/ai/mandates/flashcards.generate_cards" | "/ai/mandates/flashcards.generate_from_source" | "/ai/mandates/flashcards.grade_spoken" | "/ai/mandates/flashcards.grade_typed_answer" | "/ai/mandates/flashcards.help_live" | "/ai/mandates/flashcards.helper_tts" | "/ai/mandates/flashcards.make_quiz_items" | "/ai/mandates/flashcards.micro_coach" | "/ai/mandates/flashcards.review_batch" | "/ai/mandates/flashcards.spoken_front_tts" | "/ai/mandates/flashcards.verify_against_source" | "/ai/mandates/foundry.planner" | "/ai/mandates/google.channel_video_plan" | "/ai/mandates/google.desk_work" | "/ai/mandates/google.traffic_change_explanation" | "/ai/mandates/growth_loop.quality_analyze" | "/ai/mandates/growth_loop.quality_brief" | "/ai/mandates/growth_loop.quality_crawl" | "/ai/mandates/growth_loop.quality_fill" | "/ai/mandates/growth_loop.quality_measure" | "/ai/mandates/growth_loop.quality_plan" | "/ai/mandates/growth_loop.quality_publish" | "/ai/mandates/growth_loop.quality_realize" | "/ai/mandates/growth_loop.quality_research" | "/ai/mandates/growth_loop.quality_serve" | "/ai/mandates/growth_loop.quality_suggest" | "/ai/mandates/growth_loop.quality_writeback" | "/ai/mandates/growth_loop.supervisor" | "/ai/mandates/hindsight.crystallizer" | "/ai/mandates/hindsight.replay_judge" | "/ai/mandates/hindsight.reviewer" | "/ai/mandates/human_decisions.fallback_decider" | "/ai/mandates/image.generate" | "/ai/mandates/image_pipeline.concept" | "/ai/mandates/image_pipeline.prompt_write" | "/ai/mandates/image_pipeline.qc_judge" | "/ai/mandates/iteration.architect" | "/ai/mandates/iteration.diagnostic" | "/ai/mandates/iteration.root_cause" | "/ai/mandates/iteration.thinking_display" | "/ai/mandates/kg.cluster_namer" | "/ai/mandates/kg.ner_extractor" | "/ai/mandates/knowledge.document_verifier" | "/ai/mandates/knowledge.qa_generator" | "/ai/mandates/knowledge.section_summarizer" | "/ai/mandates/local.answer_question" | "/ai/mandates/local.chat_persona_brainstorm" | "/ai/mandates/local.chat_persona_code_review" | "/ai/mandates/local.chat_persona_explain_simply" | "/ai/mandates/local.chat_persona_helpful" | "/ai/mandates/local.chat_persona_spoken_replies" | "/ai/mandates/local.chat_persona_summarize" | "/ai/mandates/local.chat_persona_transcript_polish" | "/ai/mandates/local.cloud_chat" | "/ai/mandates/local.cloud_chat_reply" | "/ai/mandates/local.confidential_chat" | "/ai/mandates/local.explain_code" | "/ai/mandates/local.extract_action_items" | "/ai/mandates/local.improve_writing" | "/ai/mandates/local.polish_style_action_items" | "/ai/mandates/local.polish_style_bullets" | "/ai/mandates/local.polish_style_custom" | "/ai/mandates/local.polish_style_formal" | "/ai/mandates/local.polish_style_light_cleanup" | "/ai/mandates/local.polish_style_meeting_notes" | "/ai/mandates/local.polish_style_standard" | "/ai/mandates/local.polish_transcript" | "/ai/mandates/local.raw_completion" | "/ai/mandates/local.summarize_text" | "/ai/mandates/local.tool_calling_chat" | "/ai/mandates/make.describe_template" | "/ai/mandates/mandate_outcome.goal_clause_extraction" | "/ai/mandates/mandate_outcome.goal_fitness_decision" | "/ai/mandates/mandates.holder_draft" | "/ai/mandates/marketing.endowment_analysis" | "/ai/mandates/marketing.endowment_portfolio" | "/ai/mandates/marketing.image_prompt" | "/ai/mandates/marketing.page_image" | "/ai/mandates/marketing.page_image_all_in_one" | "/ai/mandates/marketing.video_metadata" | "/ai/mandates/masterwork.approach_selector" | "/ai/mandates/masterwork.audition_judge" | "/ai/mandates/masterwork.bad_draft" | "/ai/mandates/masterwork.bad_example_probe" | "/ai/mandates/masterwork.case_oracle" | "/ai/mandates/masterwork.checkup_auditor" | "/ai/mandates/masterwork.coherence_partner" | "/ai/mandates/masterwork.conductor" | "/ai/mandates/masterwork.corpus_cleaner" | "/ai/mandates/masterwork.corpus_synthesizer" | "/ai/mandates/masterwork.counterparty" | "/ai/mandates/masterwork.critique_distiller" | "/ai/mandates/masterwork.draft_triage" | "/ai/mandates/masterwork.drip_distiller" | "/ai/mandates/masterwork.drip_question" | "/ai/mandates/masterwork.elicitation_judge" | "/ai/mandates/masterwork.exception_hunter" | "/ai/mandates/masterwork.exemplar_distiller" | "/ai/mandates/masterwork.faithfulness_judge" | "/ai/mandates/masterwork.intake_designer" | "/ai/mandates/masterwork.markup_distiller" | "/ai/mandates/masterwork.meeting_scavenger" | "/ai/mandates/masterwork.monologue_distiller" | "/ai/mandates/masterwork.outcome_judge" | "/ai/mandates/masterwork.pairwise_judge" | "/ai/mandates/masterwork.prediction_boundary" | "/ai/mandates/masterwork.prediction_distiller" | "/ai/mandates/masterwork.relationship_auditor" | "/ai/mandates/masterwork.rule_improver" | "/ai/mandates/masterwork.rulebook_auditor" | "/ai/mandates/masterwork.scout" | "/ai/mandates/masterwork.sealed_case_oracle" | "/ai/mandates/masterwork.sort_case_writer" | "/ai/mandates/masterwork.sort_distiller" | "/ai/mandates/masterwork.source_distiller" | "/ai/mandates/masterwork.teach_back_distiller" | "/ai/mandates/masterwork.teach_back_explainer" | "/ai/mandates/masterwork.template.chief_edit" | "/ai/mandates/masterwork.template.chief_generate" | "/ai/mandates/masterwork.template.editor" | "/ai/mandates/masterwork.template.maker" | "/ai/mandates/masterwork.timeline_distiller" | "/ai/mandates/masterwork.timeline_segmenter" | "/ai/mandates/masterwork.transcript_distiller" | "/ai/mandates/masterwork.transcript_shortlister" | "/ai/mandates/masterwork.triad_distiller" | "/ai/mandates/masterwork.triad_generator" | "/ai/mandates/masterwork.understudy" | "/ai/mandates/masterwork.unfolding_judge" | "/ai/mandates/masterworks.bench.a2_loop" | "/ai/mandates/masterworks.bench.calibration_decoy" | "/ai/mandates/masterworks.bench.consensus" | "/ai/mandates/masterworks.bench.extract" | "/ai/mandates/masterworks.bench.judge" | "/ai/mandates/masterworks.bench.panel" | "/ai/mandates/masterworks.bench.raw_arm" | "/ai/mandates/masterworks.vanilla_arm.answer_from_facts" | "/ai/mandates/masterworks.vanilla_arm.best_work" | "/ai/mandates/masterworks.vanilla_arm.outcome_case" | "/ai/mandates/masterworks.vanilla_arm.professional_help" | "/ai/mandates/media.youtube_analyzer" | "/ai/mandates/media_catalog.item_vetting_decision" | "/ai/mandates/meet.agenda_draft" | "/ai/mandates/meet.caption_translation" | "/ai/mandates/meet.live_intelligence" | "/ai/mandates/meet.live_notes" | "/ai/mandates/meet.pre_meeting_brief" | "/ai/mandates/meet.transcription" | "/ai/mandates/meet.wrap_up" | "/ai/mandates/memory.observer" | "/ai/mandates/memory.reflector" | "/ai/mandates/mermaid.diagram_editing" | "/ai/mandates/messaging.action_item_extraction" | "/ai/mandates/messaging.conversation_catch_up" | "/ai/mandates/messaging.conversation_summary" | "/ai/mandates/messaging.reply_drafting" | "/ai/mandates/messenger.answer_anything" | "/ai/mandates/models.availability_probe" | "/ai/mandates/ner.deep_chunk_extractor" | "/ai/mandates/ner.document_orienter" | "/ai/mandates/ner.entity_canonicalizer" | "/ai/mandates/ner.finisher" | "/ai/mandates/ner.item_proposer" | "/ai/mandates/ner.magic_moment_detector" | "/ai/mandates/ner.scope_proposer" | "/ai/mandates/ner.scope_slot_filler" | "/ai/mandates/ner.suggestion_reviewer" | "/ai/mandates/ner.sweep_scope_discoverer" | "/ai/mandates/ner.sweep_scope_reference_finder" | "/ai/mandates/ner.sweep_value_miner" | "/ai/mandates/news.angles" | "/ai/mandates/news.coarse_relevance" | "/ai/mandates/news.monitor_setup_proposer" | "/ai/mandates/news.report" | "/ai/mandates/news.story_origin" | "/ai/mandates/news.triage" | "/ai/mandates/notes.organizer" | "/ai/mandates/notes.page_guidance" | "/ai/mandates/observability.tool_trace_pattern_detection" | "/ai/mandates/observability.tool_trace_triage" | "/ai/mandates/orchestras.role_describer" | "/ai/mandates/orchestration.tool_failure_standoff_decision" | "/ai/mandates/org_chart.seat_job_suggester" | "/ai/mandates/pdf.chunk_clean_ocr_text" | "/ai/mandates/pdf.chunk_flashcards_json" | "/ai/mandates/pdf.chunk_flashcards_typescript" | "/ai/mandates/pdf.content_cleaner" | "/ai/mandates/personal_staff.escalation" | "/ai/mandates/personal_staff.front_line" | "/ai/mandates/podcast.audience_adapter" | "/ai/mandates/podcast.audio_dialogue" | "/ai/mandates/podcast.audio_english" | "/ai/mandates/podcast.audio_persian" | "/ai/mandates/podcast.chapter_marker" | "/ai/mandates/podcast.content_extractor" | "/ai/mandates/podcast.deep_research" | "/ai/mandates/podcast.image_v1" | "/ai/mandates/podcast.image_v2" | "/ai/mandates/podcast.image_v3" | "/ai/mandates/podcast.image_v4" | "/ai/mandates/podcast.image_v5" | "/ai/mandates/podcast.image_v6_feature" | "/ai/mandates/podcast.image_v6_feature_prompt" | "/ai/mandates/podcast.live_rewrite" | "/ai/mandates/podcast.metadata" | "/ai/mandates/podcast.multihost_script" | "/ai/mandates/podcast.post_prep_expansion" | "/ai/mandates/podcast.post_prep_fact_checking" | "/ai/mandates/podcast.post_prep_summarization" | "/ai/mandates/podcast.post_prep_translation" | "/ai/mandates/podcast.race_frontier" | "/ai/mandates/podcast.relevance_gate" | "/ai/mandates/podcast.roundtable_script" | "/ai/mandates/podcast.script_educational" | "/ai/mandates/podcast.script_news" | "/ai/mandates/podcast.script_persian" | "/ai/mandates/podcast.solo_script" | "/ai/mandates/podcast.title_optimizer" | "/ai/mandates/podcast.video_v1" | "/ai/mandates/podcast.video_v2" | "/ai/mandates/podcast_client.blog_writer" | "/ai/mandates/podcast_client.show_notes" | "/ai/mandates/podcast_client.topic_ideas" | "/ai/mandates/podcast_client.web_content_extractor" | "/ai/mandates/podcast_client.youtube_research" | "/ai/mandates/product_capture.instant_analysis" | "/ai/mandates/projects.creation_guide" | "/ai/mandates/proof_runs.judge" | "/ai/mandates/purpose.writer" | "/ai/mandates/rag.chunk_contextualizer" | "/ai/mandates/rag.grounded_synthesis" | "/ai/mandates/rag.grounding_claim_extract" | "/ai/mandates/rag.grounding_judge" | "/ai/mandates/rag.hyde_generator" | "/ai/mandates/rag.image_caption" | "/ai/mandates/rag.pdf_page_cleaner" | "/ai/mandates/rag.query_expander" | "/ai/mandates/rag_kinds.grounded_synthesis" | "/ai/mandates/records.enrichment" | "/ai/mandates/research.auto_tagger" | "/ai/mandates/research.condenser_1" | "/ai/mandates/research.condenser_2" | "/ai/mandates/research.coverage_audit" | "/ai/mandates/research.cross_cutting_tags" | "/ai/mandates/research.document_assembly" | "/ai/mandates/research.keyword_synthesis" | "/ai/mandates/research.report" | "/ai/mandates/research.report_updater" | "/ai/mandates/research.source_authority" | "/ai/mandates/research.source_triage_decision" | "/ai/mandates/research.structured_page_summary" | "/ai/mandates/research.suggest_setup" | "/ai/mandates/research.tag_consolidation" | "/ai/mandates/research.topic_deep_research" | "/ai/mandates/research_client.output_blog" | "/ai/mandates/research_client.output_brand_card" | "/ai/mandates/research_client.output_brand_profile" | "/ai/mandates/research_client.output_competitive_landscape" | "/ai/mandates/research_client.output_gap_analysis" | "/ai/mandates/research_client.output_literature_review" | "/ai/mandates/research_client.output_reputation_business" | "/ai/mandates/research_client.output_reputation_personal" | "/ai/mandates/research_client.output_seo" | "/ai/mandates/research_client.output_slides" | "/ai/mandates/scraper.fact_check" | "/ai/mandates/scraper.keyword_analysis" | "/ai/mandates/scraper.page_fetch_verdict" | "/ai/mandates/seo.ai_visibility_blind_question_writer" | "/ai/mandates/seo.ai_visibility_buyer_jobs" | "/ai/mandates/seo.ai_visibility_decision_analyst" | "/ai/mandates/seo.ai_visibility_evidence_icp" | "/ai/mandates/seo.ai_visibility_panel_designer" | "/ai/mandates/seo.ai_visibility_panel_report" | "/ai/mandates/seo.ai_visibility_question_architect" | "/ai/mandates/seo.ai_visibility_question_qa" | "/ai/mandates/seo.ai_visibility_writing_audit" | "/ai/mandates/seo.backlink_analysis" | "/ai/mandates/seo.backlink_context_assessor" | "/ai/mandates/seo.backlink_work_planner" | "/ai/mandates/seo.business_model_verdict" | "/ai/mandates/seo.competitor_classifier" | "/ai/mandates/seo.competitor_opportunity_autopsy" | "/ai/mandates/seo.competitor_page_autopsy" | "/ai/mandates/seo.coverage_analyst" | "/ai/mandates/seo.digital_pr_reputation_adjudicator" | "/ai/mandates/seo.evidence_workbench" | "/ai/mandates/seo.finding_fixer" | "/ai/mandates/seo.guidelines_drafter" | "/ai/mandates/seo.ideal_customer_profile" | "/ai/mandates/seo.keyword_classifier" | "/ai/mandates/seo.keyword_expander" | "/ai/mandates/seo.keyword_researcher" | "/ai/mandates/seo.keyword_serp_intent_analyst" | "/ai/mandates/seo.landscape_brief" | "/ai/mandates/seo.map_author" | "/ai/mandates/seo.map_curation" | "/ai/mandates/seo.money_map" | "/ai/mandates/seo.offering_extraction" | "/ai/mandates/seo.offering_valuation" | "/ai/mandates/seo.page_analyzer" | "/ai/mandates/seo.page_intent_proposer" | "/ai/mandates/seo.page_keyword_mapper" | "/ai/mandates/seo.page_mapper" | "/ai/mandates/seo.press_calendar_planner" | "/ai/mandates/seo.press_clip_reviewer" | "/ai/mandates/seo.press_headlines" | "/ai/mandates/seo.press_moment_researcher" | "/ai/mandates/seo.press_newsworthiness_check" | "/ai/mandates/seo.press_source_request_responder" | "/ai/mandates/seo.press_story_analyst" | "/ai/mandates/seo.press_strategist" | "/ai/mandates/seo.reputation_crisis_holding" | "/ai/mandates/seo.session_rule_writer" | "/ai/mandates/seo.session_stamp_proposer" | "/ai/mandates/seo.site_intake" | "/ai/mandates/seo.site_link_authority_router" | "/ai/mandates/seo.site_strategist" | "/ai/mandates/seo.starter_pack_proposer" | "/ai/mandates/seo.strategy.site_brief.generate" | "/ai/mandates/seo.topic_assigner" | "/ai/mandates/seo.topic_curation" | "/ai/mandates/shapes.write_picker_description" | "/ai/mandates/sms.owner_beta" | "/ai/mandates/social.post_breakdown" | "/ai/mandates/spaces.ask_page" | "/ai/mandates/spaces.autofill" | "/ai/mandates/spaces.build" | "/ai/mandates/spaces.design_database" | "/ai/mandates/spaces.move_in" | "/ai/mandates/spaces.writing_assist" | "/ai/mandates/start_page.maintainer" | "/ai/mandates/surfaces_client.binding_mapper" | "/ai/mandates/table.ask" | "/ai/mandates/table.column_fill" | "/ai/mandates/tasks.triage" | "/ai/mandates/tool_viz.component_generator" | "/ai/mandates/tools.summarize_content" | "/ai/mandates/transcript_studio.document_edit" | "/ai/mandates/transcript_studio.scribe_live" | "/ai/mandates/transcripts.clean_with_context" | "/ai/mandates/transcripts.clean_with_context_variable" | "/ai/mandates/transcripts.clean_without_context" | "/ai/mandates/vision_interview.adversary" | "/ai/mandates/vision_interview.amplifier" | "/ai/mandates/vision_interview.answer_tracker" | "/ai/mandates/vision_interview.archaeologist" | "/ai/mandates/vision_interview.architect" | "/ai/mandates/vision_interview.cartographer" | "/ai/mandates/vision_interview.requirements_author" | "/ai/mandates/vision_interview.scribe" | "/ai/mandates/vision_interview.sounding_board" | "/ai/mandates/vision_interview.transcript_cleaner" | "/ai/mandates/vision_interview.vision_author" | "/ai/mandates/voice.communicator" | "/ai/mandates/voice.gemini_live" | "/ai/mandates/voice.intro" | "/ai/mandates/voice.owner_beta" | "/ai/mandates/war_room.master" | "/ai/mandates/war_room.room" | "/ai/mandates/war_room.thread" | "/ai/mandates/web.endpoint_family_judge" | "/ai/mandates/workflow.complex_research.keyword_synthesis" | "/ai/mandates/workflow.complex_research.page_summary" | "/ai/mandates/workflow.complex_research.report" | "/ai/mandates/workflow.conductor" | "/ai/mandates/workflow.deep_research.keyword_synthesis" | "/ai/mandates/workflow.extract_namer" | "/ai/mandates/workflow.plan_design" | "/ai/mandates/workflow.plan_input_kind_authoring" | "/ai/mandates/workflow.plan_node_type_recommender" | "/ai/mandates/workflow.plan_notes_writer" | "/ai/mandates/workflow.plan_output_kind_authoring" | "/ai/mandates/workflow.recovery_advisor" | "/ai/mandates/workflow.run_assist_suggester" | "/ai/mandates/workflow.step_intelligence" | "/ai/mandates/workflow.steward" | "/ai/mandates/workflow.steward.agent_run" | "/ai/mandates/workflow.steward.data" | "/ai/mandates/workflow.steward.decision" | "/ai/mandates/workflow.steward.user_input" | "/ai/mandates/workflow.wizard.agent_run" | `/ai/mandates/${DynamicMandateKey}`;
2443
+ /**
2444
+ * POST — Continue any existing conversation (Guest OK)
2445
+ * POST /ai/conversations/{conversationId}
2446
+ * Conversation ID in URL. Just send user_input in the body.
2447
+ */
2448
+ readonly conversationContinue: (conversationId: string) => `/ai/conversations/${string}`;
2449
+ /**
2450
+ * POST — Pre-warm a conversation's server cache. No body. No auth.
2451
+ * POST /ai/conversations/{conversationId}/warm
2452
+ * Fire when user navigates to a conversation page.
2453
+ */
2454
+ readonly conversationWarm: (conversationId: string) => `/ai/conversations/${string}/warm`;
2455
+ /**
2456
+ * POST — Pre-warm an agent's server cache. No auth. (public endpoint)
2457
+ * POST /ai/agents/{agentId}/warm
2458
+ * Optional body: `{ source: "prompt" | "builtin" | "prompt_version" | "builtin_version" }`
2459
+ */
2460
+ readonly agentWarm: (agentId: string) => `/ai/agents/${string}/warm`;
2461
+ /**
2462
+ * POST — Start a new prompt conversation (Guest OK)
2463
+ * POST /ai/prompts/{promptId}
2464
+ * Body: PromptStartRequest — user_input, variables, stream, debug, client_tools, etc.
2465
+ * Never send conversation_id — the server generates it and returns it in the stream.
2466
+ */
2467
+ readonly promptStart: (promptId: string) => `/ai/prompts/${string}`;
2468
+ /**
2469
+ * POST — Pre-warm a prompt's server cache. No auth. (public endpoint)
2470
+ * POST /ai/prompts/{promptId}/warm
2471
+ * Optional body: `{ source: string | null }`
2472
+ */
2473
+ readonly promptWarm: (promptId: string) => `/ai/prompts/${string}/warm`;
2474
+ /**
2475
+ * POST — Start a new block-streaming agent session (Guest OK)
2476
+ * POST /ai/agents-blocks/{agentId}
2477
+ * Same as agentStart but emits 'content_block' NDJSON events instead of raw 'chunk' events.
2478
+ */
2479
+ readonly agentBlocksStart: (agentId: string) => `/ai/agents-blocks/${string}`;
2480
+ /**
2481
+ * POST — Pre-warm a block-streaming agent (Public)
2482
+ * POST /ai/agents-blocks/{agentId}/warm
2483
+ * Optional body: `{ source: "prompt" | "builtin" | "prompt_version" | "builtin_version" }`
2484
+ */
2485
+ readonly agentBlocksWarm: (agentId: string) => `/ai/agents-blocks/${string}/warm`;
2486
+ /** POST — Cancel a running request by request_id (Authenticated) */
2487
+ readonly cancel: (requestId: string) => `/ai/cancel/${string}`;
2488
+ };
2489
+ /** Block processing test endpoints — Guest OK */
2490
+ readonly blockProcessing: {
2491
+ /** POST — Process raw text/markdown → structured blocks (JSON response) */
2492
+ readonly process: "/utilities/block-processing/process";
2493
+ /** POST — Process raw text/markdown → block events (NDJSON stream, simulates live agent) */
2494
+ readonly processStream: "/utilities/block-processing/process/stream";
2495
+ };
2496
+ /** CX-data endpoints — conversation/message data (Authenticated) */
2497
+ readonly cx: {
2498
+ /**
2499
+ * GET — Snapshot of "what the model is currently seeing" for a conversation.
2500
+ * GET /cx/conversations/{conversationId}/context-state
2501
+ * Initial hydration for the Model Context tab; live updates come via
2502
+ * CONTEXT_STATE / CONTEXT_TRIMMED stream events after each turn.
2503
+ */
2504
+ readonly contextState: (conversationId: string) => `/cx/conversations/${string}/context-state`;
2505
+ };
2506
+ /** CMS server work — authenticated. CMS row CRUD stays direct-to-Supabase. */
2507
+ readonly cms: {
2508
+ /** POST — Canonical matrx-content-guard validation before CMS writes. */
2509
+ readonly validate: "/cms/validate";
2510
+ /**
2511
+ * POST — THE decision door for a queued content exception
2512
+ * (`features/approvals/cms-door.ts`). The exception id is the idempotency
2513
+ * key; the server finds its queue row and replays the ordinary human write
2514
+ * path. Nothing else decides these — the CMS's own review route is gone.
2515
+ */
2516
+ readonly approveException: (exceptionId: string) => `/cms/exceptions/${string}/approve`;
2517
+ readonly rejectException: (exceptionId: string) => `/cms/exceptions/${string}/reject`;
2518
+ /**
2519
+ * POST `{page_id}` — the publish writing check for a page's FINAL text (the
2520
+ * same gate the server publish seam runs). `allowed=false` carries the
2521
+ * must-fix list and the three settings that lift the block.
2522
+ */
2523
+ readonly publishCheck: "/cms/publish-check";
2524
+ };
2525
+ /** Tool testing endpoints — Authenticated */
2526
+ readonly tools: {
2527
+ /** GET — List available tools (?category=) */
2528
+ readonly testList: "/tools/test/list";
2529
+ /** GET — Get tool details by name */
2530
+ readonly testDetail: (toolName: string) => `/tools/test/${string}`;
2531
+ /** POST — Create/reuse test session */
2532
+ readonly testSession: "/tools/test/session";
2533
+ /** POST — Execute tool test with streaming */
2534
+ readonly testExecute: "/tools/test/execute";
2535
+ /**
2536
+ * POST `{tool_name, arguments, spend_approval_id?}` — a SCREEN runs one
2537
+ * screen-callable tool as the signed-in person (no agent, no conversation).
2538
+ * `status`: `ok` (the tool's own envelope in `output`), `needs_approval`
2539
+ * (`approval` carries the approve_spend ask and its form render; call again
2540
+ * with `spend_approval_id`), or `error`. 403 for a tool not declared
2541
+ * `screen_callable`.
2542
+ */
2543
+ readonly screenRun: "/tools/screen-run";
2544
+ };
2545
+ /** Scraper endpoints — Authenticated */
2546
+ readonly scraper: {
2547
+ /** POST — Quick scrape URLs */
2548
+ readonly quickScrape: "/scraper/quick-scrape";
2549
+ /** POST — Search keywords */
2550
+ readonly search: "/scraper/search";
2551
+ /** POST — Search and scrape combined */
2552
+ readonly searchAndScrape: "/scraper/search-and-scrape";
2553
+ /** POST — Search and scrape with limits */
2554
+ readonly searchAndScrapeLimited: "/scraper/search-and-scrape-limited";
2555
+ };
2556
+ /** Utility endpoints — Guest OK */
2557
+ readonly utilities: {
2558
+ /** @deprecated Use ENDPOINTS.pdf.extractText instead */
2559
+ readonly pdfExtractText: "/utilities/pdf/extract-text";
2560
+ };
2561
+ /**
2562
+ * PDF extraction, manipulation, and document management — Authenticated.
2563
+ * Most JSON endpoints accept a unified source via `MediaRef` (preferred for
2564
+ * cloud files via `cld_id`), `file`, `url`, or `local_path`. See
2565
+ * `features/pdf-extractor/types.ts` for the full type re-exports.
2566
+ *
2567
+ * NOTE: list/detail endpoints below are kept for backwards compatibility
2568
+ * but the workspace now reads `processed_documents` directly from Supabase
2569
+ * for the sidebar list and the on-click detail (the old `extracted_documents`
2570
+ * facade view was retired 2026-06-11). Loading hundreds of full `content`
2571
+ * rows from Python was making the window take 2+ minutes to open.
2572
+ */
2573
+ readonly pdf: {
2574
+ /**
2575
+ * POST — Compress PDF (multipart file upload). Query params:
2576
+ * - `level` (1..5): minimum quality tier. 1=lossless, 5=max compression.
2577
+ * - `max_size_mb` (optional float): absolute upper bound on output size;
2578
+ * when set, the server escalates `level` one tier at a time until the
2579
+ * output fits (or tier 5 is reached). Omit for "honour level exactly."
2580
+ * Response headers include `X-Compression-Level-Used` and
2581
+ * `X-Compression-Cap-Satisfied` so the caller can see what actually ran.
2582
+ */
2583
+ readonly compress: "/utilities/pdf/compress";
2584
+ /** POST — Single-file text extraction (stateless multipart, NDJSON streaming).
2585
+ * Emits `pdf_extract_started` / `pdf_page_extracted` / `pdf_extract_complete`
2586
+ * data events; the complete event carries the old `{ filename, text_content }`
2587
+ * body. Consume via `streamPdfExtractText` (features/pdf-extractor/service/streamPdf.ts). */
2588
+ readonly extractText: "/utilities/pdf/extract-text";
2589
+ /** POST — Batch extraction with NDJSON streaming (saves to DB + storage). */
2590
+ readonly batchExtract: "/utilities/pdf/batch-extract";
2591
+ /**
2592
+ * POST — Phone-scanner assembly (NDJSON streaming): ordered photos
2593
+ * (optional quad + rotation) + PDFs → ONE user-visible PDF, extracted
2594
+ * + handed to the content pipeline. Terminal `data` event carries
2595
+ * `{ file_id, doc_id, page_count }`.
2596
+ */
2597
+ readonly fromImages: "/utilities/pdf/from-images";
2598
+ /** POST — Text extraction from a remote source (MediaRef / url; NDJSON streaming,
2599
+ * same events as `extractText`). Consume via `streamPdfExtractTextRemote`. */
2600
+ readonly extractTextRemote: "/utilities/pdf/extract-text-remote";
2601
+ /** POST — Table extraction. Returns `PdfResult`. */
2602
+ readonly extractTables: "/utilities/pdf/extract-tables";
2603
+ /** POST — Extract pages into a new PDF. Returns PDF blob. */
2604
+ readonly extractPages: "/utilities/pdf/extract-pages";
2605
+ /** POST — Crop pages (with `crop_box`). Returns PDF blob. */
2606
+ readonly cropPages: "/utilities/pdf/crop-pages";
2607
+ /** POST — Rotate pages. Returns PDF blob. */
2608
+ readonly rotatePages: "/utilities/pdf/rotate-pages";
2609
+ /** POST — Delete pages. Returns PDF blob. */
2610
+ readonly deletePages: "/utilities/pdf/delete-pages";
2611
+ /** POST — Merge multiple PDFs. Returns PDF blob. */
2612
+ readonly merge: "/utilities/pdf/merge";
2613
+ /** POST — Split PDF into parts (`parts` or `max_pages_per_part`). Returns ZIP blob. */
2614
+ readonly split: "/utilities/pdf/split";
2615
+ /** POST — Process a PDF with AI agents (single-pass / chunk / reassembly). Streams JSONL. */
2616
+ readonly processWithAi: "/utilities/pdf/process-with-ai";
2617
+ /** POST — Full pipeline: extract → chunk → AI → reassembly. Streams JSONL with `PdfPipelineOptions`. */
2618
+ readonly fullPipeline: "/utilities/pdf/full-pipeline";
2619
+ /** POST — AI content cleaning on an already-extracted document (NDJSON streaming). */
2620
+ readonly cleanContent: (docId: string) => `/utilities/pdf/clean-content/${string}`;
2621
+ /** @deprecated — Read `processed_documents` directly from Supabase with metadata-only projection. */
2622
+ readonly documents: "/utilities/pdf/documents";
2623
+ /** @deprecated — Read `processed_documents` directly from Supabase. */
2624
+ readonly document: (docId: string) => `/utilities/pdf/documents/${string}`;
2625
+ /** POST — Render one page to an image blob (PNG/JPEG/WebP/TIFF). */
2626
+ readonly renderPage: "/utilities/pdf/render-page";
2627
+ /** POST — Render every page; returns a ZIP of per-page images. */
2628
+ readonly renderAll: "/utilities/pdf/render-all";
2629
+ /** POST — Cover thumbnail at `max_side` px. */
2630
+ readonly renderThumbnail: "/utilities/pdf/render-thumbnail";
2631
+ /** POST — Reorder pages by `new_order`. Returns PDF blob. */
2632
+ readonly reorderPages: "/utilities/pdf/reorder-pages";
2633
+ /** POST — Insert pages from `source_*` into target. Returns PDF blob. */
2634
+ readonly insertPages: "/utilities/pdf/insert-pages";
2635
+ /** POST — Duplicate pages inline (`count` copies). Returns PDF blob. */
2636
+ readonly duplicatePages: "/utilities/pdf/duplicate-pages";
2637
+ /** GET — Studio preset catalog. Returns `PdfStudioCatalog`. */
2638
+ readonly studioPresets: "/utilities/pdf/studio/presets";
2639
+ /** POST — Studio dispatcher; image blob or ZIP depending on preset. */
2640
+ readonly studioRender: "/utilities/pdf/studio/render";
2641
+ /** POST — Detect headers / footers / watermarks / recurring side notes. Returns `RepeatedRegionsReport`. */
2642
+ readonly detectRepeatedRegions: "/utilities/pdf/detect-repeated-regions";
2643
+ /** POST — Detect + strip repeated regions from per-page text. Returns `StripRepeatedRegionsResultSchema`. */
2644
+ readonly stripRepeatedRegions: "/utilities/pdf/strip-repeated-regions";
2645
+ /** POST — Classify every page (cover / TOC / body / exhibit / signature / billing / ...). Returns `LayoutClassificationReport`. */
2646
+ readonly classifyPages: "/utilities/pdf/classify-pages";
2647
+ /** POST — Multi-column → linear reading order. Returns `ReadingOrderReport`. */
2648
+ readonly extractReadingOrder: "/utilities/pdf/extract-reading-order";
2649
+ /** GET — Builtin redaction pattern catalog (SSN / email / phone / MRN / ...). */
2650
+ readonly redactPatterns: "/utilities/pdf/redact/patterns";
2651
+ /** POST — Redact one or more page-anchored rectangles. PDF blob or persisted JSON. */
2652
+ readonly redactRegions: "/utilities/pdf/redact-regions";
2653
+ /** POST — Redact every regex match (builtin id or raw pattern). PDF blob or persisted JSON. */
2654
+ readonly redactPattern: "/utilities/pdf/redact-pattern";
2655
+ /** POST — Detect repeated regions then redact selected/all. PDF blob or persisted JSON. */
2656
+ readonly redactRepeatedRegions: "/utilities/pdf/redact-repeated-regions";
2657
+ /** POST — Wipe /Info + XMP metadata + thumbnails. */
2658
+ readonly stripMetadata: "/utilities/pdf/strip-metadata";
2659
+ /** POST — Granular composite scrub (metadata / attachments / JS / flatten). */
2660
+ readonly scrub: "/utilities/pdf/scrub";
2661
+ /** POST — Bake annotations + widgets into page content. */
2662
+ readonly flattenAnnotations: "/utilities/pdf/flatten-annotations";
2663
+ };
2664
+ /**
2665
+ * Per-page AI extraction — fan out an agent across pages of a document and
2666
+ * persist structured results anchored to source page numbers. See
2667
+ * `features/page-extraction/FEATURE.md` for the data model.
2668
+ */
2669
+ readonly pageExtraction: {
2670
+ /** POST — Run extraction across pages (NDJSON streaming, per-page events). */
2671
+ readonly runStream: "/page-extraction/runs/stream";
2672
+ /** POST — Retry one failed page-run (replaces its results). */
2673
+ readonly retryPageRun: (pageRunId: string) => `/page-extraction/page-runs/${string}/retry`;
2674
+ /** POST — Cancel an in-flight run. */
2675
+ readonly cancelRun: (runId: string) => `/page-extraction/runs/${string}/cancel`;
2676
+ };
2677
+ /** Test/admin endpoints — Admin only */
2678
+ readonly tests: {
2679
+ /** GET/POST — Example endpoints */
2680
+ readonly examples: "/tests/examples";
2681
+ /** GET — Stream text test */
2682
+ readonly streamText: "/tests/stream/text";
2683
+ };
2684
+ /** Media processing endpoints — Authenticated */
2685
+ readonly media: {
2686
+ /**
2687
+ * POST — Upload podcast video → extract cover frame, render podcast
2688
+ * variants, returns URLs + Asset envelope. Image-only uploads now go
2689
+ * through {@link ENDPOINTS.assets.upload} with `preset="podcast"`.
2690
+ */
2691
+ readonly uploadPodcastVideo: "/media/podcast/upload-video";
2692
+ /**
2693
+ * POST — stream the spoken transcript of a captioned YouTube video as
2694
+ * text. Body: `{ youtube_url }`. Reuses the "YouTube Video Transcription
2695
+ * Analysis" agent server-side (quiet run, no chat clutter). Streams NDJSON:
2696
+ * the transcript arrives as chunk text (`accumulatedText`); a captionless
2697
+ * video yields a non-fatal warning + empty text so callers stay honest.
2698
+ */
2699
+ readonly youtubeTranscript: "/media/youtube/transcript";
2700
+ };
2701
+ /**
2702
+ * Content-processing orchestrator — the interactive counterpart to the
2703
+ * automatic post-upload hook. Triggers extract→clean→chunk→embed→NER for an
2704
+ * already-uploaded `cld_files` row and streams typed progress (NDJSON). The
2705
+ * terminal `data` event carries a `ContentProcessingResult`
2706
+ * (`signature: "ContentProcessingResult"`) with `status` + `processed_document_id`.
2707
+ * Today's content types: `"pdf"` (default) and `"office"` (docx/pptx/xlsx —
2708
+ * pure-python extraction, no LibreOffice/OCR; already-clean markdown so the
2709
+ * LLM clean stage is skipped). The extracted text itself is NOT in the
2710
+ * stream — read `docproc.processed_documents.content` directly via
2711
+ * `docprocDb(supabase)` (canonical direct-Supabase read) once the run
2712
+ * completes.
2713
+ */
2714
+ readonly contentProcessing: {
2715
+ readonly process: (cldFileId: string) => `/content-processing/${string}`;
2716
+ };
2717
+ /**
2718
+ * Unified asset (image / media) upload + render-variants pipeline.
2719
+ *
2720
+ * One endpoint family handles every media upload in the platform. The
2721
+ * server renders preset variants (cover, OG, thumbnail, avatar sizes,
2722
+ * favicons, etc.) and returns the canonical {@link Asset} envelope —
2723
+ * see `features/files/types.ts` for the wire shape.
2724
+ *
2725
+ * Preset → variant key map (high level):
2726
+ * - raw → only `original`
2727
+ * - podcast → cover_url (3000²), cover_sd_url (1400²) + social baseline
2728
+ * - social → og_url, square_url, portrait_url, story_url, yt_thumbnail_url + baseline
2729
+ * - web → hero_url, og_url, card_url, touch_icon_url, pwa_icon_url, thumbnail_url + baseline
2730
+ * - email → header_url, square_url (no baseline)
2731
+ * - logo → logo_lg_url, logo_md_url, logo_sm_url + baseline
2732
+ * - avatar → avatar_xl/lg/md/sm/xs_url (no baseline)
2733
+ * - favicon → favicon_android/apple_touch/32/16_url (no baseline)
2734
+ *
2735
+ * Authenticated. See `features/files/api/assets.ts` for the typed
2736
+ * client wrapper.
2737
+ */
2738
+ readonly assets: {
2739
+ /** POST — multipart upload + render preset variants. */
2740
+ readonly upload: "/assets";
2741
+ /** GET — read the canonical Asset envelope for an upload's master file. */
2742
+ readonly detail: (fileId: string) => `/assets/${string}`;
2743
+ /** PATCH — change sharing / metadata. */
2744
+ readonly patch: (fileId: string) => `/assets/${string}`;
2745
+ /** POST — render more variants (idempotent). */
2746
+ readonly addVariants: (fileId: string) => `/assets/${string}/variants`;
2747
+ /** GET — list every server-known preset. */
2748
+ readonly presets: "/assets/presets";
2749
+ /**
2750
+ * GET — convert any cld_files row to an Asset envelope. The
2751
+ * click-to-render primitive: hand any file_id, get back URLs +
2752
+ * variants the FE can render directly.
2753
+ */
2754
+ readonly forFile: (fileId: string) => `/files/${string}/asset`;
2755
+ /**
2756
+ * POST — no-persist preview rendering (E.16, matrx-utils v1.1.0).
2757
+ * Accepts a `MediaRef` source + variants[]. Returns either base64
2758
+ * `data_url` (≤256 KB) or a 5-min `ephemeral_url`. Replaces the
2759
+ * deleted Next.js Sharp route at app/api/images/studio/process.
2760
+ */
2761
+ readonly preview: "/assets/preview";
2762
+ /**
2763
+ * POST — multipart variant of {@link preview}. Render directly without
2764
+ * a prior `cld_files` row. Useful for Image Studio drag-and-drop
2765
+ * preview before commit-to-save.
2766
+ */
2767
+ readonly previewMultipart: "/assets/preview/multipart";
2768
+ /**
2769
+ * POST — no-persist PDF compression (E.17). Accepts a `MediaRef` source.
2770
+ * Returns `data_url` (≤256 KB) or a 5-min `ephemeral_url`.
2771
+ * Replaces the deleted Next.js route at app/api/pdf/compress.
2772
+ */
2773
+ readonly pdfCompress: "/assets/pdf-compress";
2774
+ /** POST — multipart variant of {@link pdfCompress}. */
2775
+ readonly pdfCompressMultipart: "/assets/pdf-compress/multipart";
2776
+ };
2777
+ /** Health endpoints — Public (aligned with types/python-generated OpenAPI) */
2778
+ readonly health: {
2779
+ /** GET — Basic health check */
2780
+ readonly check: "/health";
2781
+ /** GET — Detailed health with component status */
2782
+ readonly detailed: "/health/detailed";
2783
+ /** GET — Liveness (process up; no I/O) */
2784
+ readonly live: "/health/live";
2785
+ /** GET — Readiness (deps initialized; use for deploy probes) */
2786
+ readonly ready: "/health/ready";
2787
+ };
2788
+ /** Research endpoints — Authenticated */
2789
+ readonly research: {
2790
+ /** POST — Initialize research config */
2791
+ readonly init: "/research/init";
2792
+ /** GET — List templates */
2793
+ readonly templatesList: "/research/templates/list";
2794
+ /** POST — Create template */
2795
+ readonly templatesCreate: "/research/templates";
2796
+ /** GET — Template detail */
2797
+ readonly templateDetail: (templateId: string) => `/research/templates/${string}`;
2798
+ /** GET — Extension scrape queue */
2799
+ readonly extensionScrapeQueue: "/research/extension/scrape-queue";
2800
+ /** GET — Research state / PATCH — Update config */
2801
+ readonly state: (projectId: string) => `/research/${string}`;
2802
+ /** POST — Suggest setup */
2803
+ readonly suggest: (projectId: string) => `/research/${string}/suggest`;
2804
+ /** POST — Run full pipeline (streaming) */
2805
+ readonly run: (projectId: string) => `/research/${string}/run`;
2806
+ /** POST — Trigger search (streaming) */
2807
+ readonly search: (projectId: string) => `/research/${string}/search`;
2808
+ /** POST — Trigger scrape (streaming) */
2809
+ readonly scrape: (projectId: string) => `/research/${string}/scrape`;
2810
+ /** POST — Analyze all sources (streaming) */
2811
+ readonly analyzeAll: (projectId: string) => `/research/${string}/analyze-all`;
2812
+ /** POST — Synthesize */
2813
+ readonly synthesize: (projectId: string) => `/research/${string}/synthesize`;
2814
+ /** GET — Keywords */
2815
+ readonly keywords: (projectId: string) => `/research/${string}/keywords`;
2816
+ /** GET — Sources */
2817
+ readonly sources: (projectId: string) => `/research/${string}/sources`;
2818
+ /** GET — Tags */
2819
+ readonly tags: (projectId: string) => `/research/${string}/tags`;
2820
+ /** GET/POST — Document */
2821
+ readonly document: (projectId: string) => `/research/${string}/document`;
2822
+ /** GET — Costs */
2823
+ readonly costs: (projectId: string) => `/research/${string}/costs`;
2824
+ };
2825
+ /**
2826
+ * ACTION REQUESTS — `platform.action_request`. An agent asks the person it
2827
+ * works for for ONE thing; they answer on `/q/<token>` and the parked turn
2828
+ * resumes.
2829
+ *
2830
+ * All three sit on aidream's PUBLIC router at the BARE prefix (no `/api`,
2831
+ * no version), because the person tapping them has no account in the general
2832
+ * case. They are POSTs deliberately — the token would otherwise sit in a URL,
2833
+ * which means in the access log and in every proxy between here and it.
2834
+ *
2835
+ * Reached ONLY from `features/action-requests/service.ts` (server lane): the
2836
+ * `Authorization` header is what separates a signed-in completion from a
2837
+ * bearer one, so the decision to send it belongs where the session cookie is.
2838
+ */
2839
+ readonly actionRequests: {
2840
+ /** POST — what the page draws. MUTATES NOTHING. */
2841
+ readonly open: "/action-requests/open";
2842
+ /** POST — the answer. */
2843
+ readonly complete: "/action-requests/complete";
2844
+ /** POST — "text me a new link". Rate-limited in the database. */
2845
+ readonly remint: "/action-requests/remint";
2846
+ };
2847
+ };
2848
+
2849
+ export { type ApiTargetLogContext, BackendApiError, type BackendApiErrorData, type BackendErrorCode, type BackendFailureExplanation, type CreateMatrxTransportOptions, type CreateWarmupOptions, ENDPOINTS, type EndpointOverrideConfig, type ExecuteMatrxCallHooks, type ExecuteMatrxCallRequest, type FollowRuntimeOperationOptions, type FollowRuntimeOperationToEndOptions, type FollowRuntimeOperationToEndResult, type FollowServerJobOptions, type FollowUnavailableRejoinOptions, type JsonRequestOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, MATRX_UI_ONLY_BODY_FIELDS, type MatrxAgentStartRequest, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxCallResult, type MatrxCallScope, type MatrxCancelResponse, type MatrxChatMessage, type MatrxClientSessionProvider, type MatrxClientToolResult, type MatrxCompletedRun, type MatrxContextAnchor, type MatrxConversationContinueRequest, type MatrxConversationResumeRequest, type MatrxConversationStart, type MatrxEphemeralConversation, type MatrxFollowedOutcome, type MatrxHttpErrorLike, type MatrxHttpMethod, type MatrxJsonObject, type MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxMandateStartRequest, type MatrxOperationEventsPage, type MatrxOperationFollowEvent, type MatrxOperationStatusResponse, type MatrxOperationsByLinkResponse, type MatrxPendingCallSummary, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxQueryParams, type MatrxRequestInfo, type MatrxRequestScope, MatrxRunError, type MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, type MatrxRuntimeExecutionStatus, type MatrxRuntimeOperationEvent, type MatrxRuntimeOperationView, type MatrxStoredConversationContinue, type MatrxStoredConversationCreate, type MatrxStreamCallOptions, type MatrxStreamCursorStamp, type MatrxStreamIds, type MatrxStreamParse, type MatrxToolResultsResponse, type MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportRequest, type MatrxTransportTarget, type MatrxTurnFields, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ParseMatrxNdjsonResponseHooks, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ProviderSessionUsage, type ProviderSessionUsageReceipt, type ProviderUsageReporter, type ProviderUsageReporterOptions, type ProviderUsageSendResult, type QueryValue, RUN_OUTPUT_KINDS, RUN_STREAM_LIFETIME_BACKSTOP_MS, RUN_WAIT_KNOB_FEATURE, ResilientFetchOptions, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type RunAgentToCompletionOptions, type RunOutputKind, type RunWait, type RunWaitKnobReader, type SendMatrxRequestOptions, type ServerJobFinalStatus, type ServerJobOutcome, type ServerJobPath, type ServerJobStatus, type ServerJobTarget, type SettleRunPickupOptions, type StreamReplayCursor, type StreamReplayCursorOptions, type StreamRequestOptions, StreamTransportError, TERMINAL_MATRX_RUNTIME_STATUSES, type UpstreamErrorPayload, V2_COVERED_AI_PATH_TEMPLATES, WARM_PATH, type WarmItem, type WarmReason, type Warmup, aiVersionPathOverrides, applyAiApiVersion, applyDesktopTargetToRequestBody, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, bareStatusSentence, buildMatrxRequestBody, buildMatrxRequestUrl, buildQuery, buildSafeRequestLog, cancelAgentRun, continueAgentConversation, continueEphemeralConversationStart, continueStoredConversationStart, createMatrxTransport, createOrganizationOperation, createProviderUsageReporter, createStreamReplayCursor, createWarmup, describeBackendFailure, encodePathSegment, executeMatrxCall, extractMatrxErrorCode, extractMatrxErrorMessage, fetchWithMatrxProtocolFallback, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, getUserMessage, honestTransportMessage, isBareTransportCode, isCoveredAiPath, isEmptyProviderUsage, isGenericUserMessage, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, isStreamTransportLost, isV2Path, listConversationPendingToolCalls, listRuntimeOperationEvents, listUserPendingToolCalls, logApiTarget, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parseMatrxNdjsonResponse, parsePersistedBackendError, parseStreamError, pickServerJobOperation, preconnectServer, providerSessionFailureBody, providerSessionUsageBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, reportProviderSessionUsage, requestJson, requestStream, requireOrganizationContext, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeAgentConversation, resumeOrRejoin, runAgentToCompletion, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, startAgentRun, startMandateRun, streamErrorText, submitAgentToolResults, toRunHandle, toV1FallbackUrl, toV2Path, unwrapUpstreamError, withRunOrganization };