@ai-matrx/api 0.1.0 → 0.1.1

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 (63) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +4 -0
  3. package/dist/agents.cjs +12 -12
  4. package/dist/agents.js +2 -2
  5. package/dist/ai.cjs +3 -3
  6. package/dist/ai.js +2 -2
  7. package/dist/apps.cjs +6 -6
  8. package/dist/apps.js +2 -2
  9. package/dist/architecture.cjs +11 -11
  10. package/dist/architecture.js +2 -2
  11. package/dist/audio.cjs +5 -5
  12. package/dist/audio.js +2 -2
  13. package/dist/chat.cjs +12 -12
  14. package/dist/chat.js +2 -2
  15. package/dist/{chunk-BMQI7UET.cjs → chunk-5WJLKYH6.cjs} +1 -1
  16. package/dist/{chunk-YUDQWDCM.cjs → chunk-HER22VVH.cjs} +5 -5
  17. package/dist/{chunk-UONBYRE4.js → chunk-TSHL7Z53.js} +1 -1
  18. package/dist/{chunk-AY5N6EA4.js → chunk-VTZKJMSY.js} +1 -1
  19. package/dist/code.cjs +7 -7
  20. package/dist/code.js +2 -2
  21. package/dist/communications.cjs +5 -5
  22. package/dist/communications.js +2 -2
  23. package/dist/computer.cjs +4 -4
  24. package/dist/computer.js +2 -2
  25. package/dist/content.cjs +5 -5
  26. package/dist/content.js +2 -2
  27. package/dist/credentials.cjs +5 -5
  28. package/dist/credentials.js +1 -1
  29. package/dist/crm.cjs +3 -3
  30. package/dist/crm.js +2 -2
  31. package/dist/education.cjs +5 -5
  32. package/dist/education.js +2 -2
  33. package/dist/files.cjs +21 -21
  34. package/dist/files.js +2 -2
  35. package/dist/index.cjs +140 -58
  36. package/dist/index.d.cts +64 -1
  37. package/dist/index.d.ts +64 -1
  38. package/dist/index.js +83 -5
  39. package/dist/integrations.cjs +4 -4
  40. package/dist/integrations.js +2 -2
  41. package/dist/intelligence.cjs +7 -7
  42. package/dist/intelligence.js +2 -2
  43. package/dist/knowledge.cjs +43 -43
  44. package/dist/knowledge.js +2 -2
  45. package/dist/legal.cjs +7 -7
  46. package/dist/legal.js +2 -2
  47. package/dist/marketing.cjs +73 -73
  48. package/dist/marketing.js +2 -2
  49. package/dist/masterwork.cjs +33 -33
  50. package/dist/masterwork.js +2 -2
  51. package/dist/media.cjs +12 -12
  52. package/dist/media.js +2 -2
  53. package/dist/platform.cjs +4 -4
  54. package/dist/platform.js +2 -2
  55. package/dist/publish.cjs +8 -8
  56. package/dist/publish.js +2 -2
  57. package/dist/stream.cjs +11 -11
  58. package/dist/stream.js +2 -2
  59. package/dist/web.cjs +27 -27
  60. package/dist/web.js +2 -2
  61. package/dist/workflows.cjs +13 -13
  62. package/dist/workflows.js +2 -2
  63. package/package.json +5 -4
package/dist/index.d.ts CHANGED
@@ -2003,4 +2003,67 @@ declare function reportProviderSessionFailure(transport: MatrxTransport, failure
2003
2003
  signal?: AbortSignal;
2004
2004
  }): Promise<ProviderSessionFailureVerdict | null>;
2005
2005
 
2006
- export { type ApiTargetLogContext, BackendApiError, type BackendApiErrorData, type BackendErrorCode, type BackendFailureExplanation, type CreateMatrxTransportOptions, type CreateWarmupOptions, CredentialsPort, 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 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, createStreamReplayCursor, createWarmup, describeBackendFailure, encodePathSegment, executeMatrxCall, extractMatrxErrorCode, extractMatrxErrorMessage, fetchWithMatrxProtocolFallback, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, getUserMessage, honestTransportMessage, isBareTransportCode, isCoveredAiPath, isGenericUserMessage, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, isStreamTransportLost, isV2Path, listRuntimeOperationEvents, logApiTarget, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parseMatrxNdjsonResponse, parsePersistedBackendError, parseStreamError, pickServerJobOperation, preconnectServer, providerSessionFailureBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, requestJson, requestStream, requireOrganizationContext, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeOrRejoin, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, streamErrorText, toRunHandle, toV1FallbackUrl, toV2Path, unwrapUpstreamError, withRunOrganization };
2006
+ /**
2007
+ * Browser-held provider sessions report what they spent.
2008
+ *
2009
+ * Realtime voice (OpenAI / xAI) and Cartesia TTS are spent browser -> provider on a
2010
+ * broker-minted ephemeral token, so no server seam sees the money. Every such session reports
2011
+ * the provider's own usage once per billed unit; the server prices it through the AI catalog
2012
+ * (a client never states a cost) and bills the signed-in person in their active organization.
2013
+ *
2014
+ * Server truth: `POST /broker/usage` (`ProviderSessionUsageReport`, `extra="forbid"`). A
2015
+ * `usage_id` bills ONCE — so a repeat send is always safe, which is what lets the reporter
2016
+ * retry freely.
2017
+ *
2018
+ * Two layers:
2019
+ * - `reportProviderSessionUsage(transport, usage)` - one attempt, classified, never throws;
2020
+ * - `createProviderUsageReporter({ send })` - the queue every session uses: retries
2021
+ * transient failures with backoff, drops permanent refusals (4xx), de-duplicates by
2022
+ * `usage_id`, and `flush()` drains it when a session ends.
2023
+ */
2024
+
2025
+ /** One billed unit: a realtime response, a TTS generation, or a slice of session time. */
2026
+ interface ProviderSessionUsage {
2027
+ provider: MatrxClientSessionProvider;
2028
+ model: string;
2029
+ /** The provider's own response / generation id; bills once. */
2030
+ usage_id: string;
2031
+ input_tokens?: number;
2032
+ output_tokens?: number;
2033
+ cached_input_tokens?: number;
2034
+ characters?: number;
2035
+ seconds?: number;
2036
+ }
2037
+ interface ProviderSessionUsageReceipt {
2038
+ billed: boolean;
2039
+ duplicate: boolean;
2040
+ cost_usd: number;
2041
+ }
2042
+ /** `ok` = the server has it (billed or already had it). `retry` = transient. `drop` = refused for good. */
2043
+ type ProviderUsageSendResult = "ok" | "retry" | "drop";
2044
+ /** The body the server accepts — bounded exactly as its model bounds it. */
2045
+ declare function providerSessionUsageBody(usage: ProviderSessionUsage): Record<string, string | number>;
2046
+ /** True when the unit carries nothing the server could price. */
2047
+ declare function isEmptyProviderUsage(usage: ProviderSessionUsage): boolean;
2048
+ /** One attempt over the transport. Never throws; the result says whether to try again. */
2049
+ declare function reportProviderSessionUsage(transport: MatrxTransport, usage: ProviderSessionUsage, options?: {
2050
+ signal?: AbortSignal;
2051
+ }): Promise<ProviderUsageSendResult>;
2052
+ interface ProviderUsageReporterOptions {
2053
+ send: (usage: ProviderSessionUsage) => Promise<ProviderUsageSendResult>;
2054
+ /** Delay before each retry; its length is the retry budget. */
2055
+ retryDelaysMs?: readonly number[];
2056
+ /** Injectable for tests. */
2057
+ sleep?: (ms: number) => Promise<void>;
2058
+ }
2059
+ interface ProviderUsageReporter {
2060
+ /** Queue a unit. Synchronous, never throws. A usage_id already queued or sent is ignored. */
2061
+ report(usage: ProviderSessionUsage): void;
2062
+ /** Resolves when everything queued so far has been delivered or given up on. */
2063
+ flush(): Promise<void>;
2064
+ /** Units still waiting on delivery. */
2065
+ pending(): number;
2066
+ }
2067
+ declare function createProviderUsageReporter(options: ProviderUsageReporterOptions): ProviderUsageReporter;
2068
+
2069
+ export { type ApiTargetLogContext, BackendApiError, type BackendApiErrorData, type BackendErrorCode, type BackendFailureExplanation, type CreateMatrxTransportOptions, type CreateWarmupOptions, CredentialsPort, 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 };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export { monitorStream } from './chunk-YTEOFGFC.js';
2
- import { OrganizationContextError, BackendApiError, parseHttpError, MatrxApiError, applyOrganizationContextHeader, extractMatrxErrorCode, extractMatrxErrorMessage, readMatrxNdjsonStream, readMatrxSseStream, requireOrganizationContext, StreamTransportError } from './chunk-UONBYRE4.js';
3
- export { BackendApiError, CONTRACT_SHA256, DEPLOYMENTS, DOMAINS, MatrxApiError, OrganizationContextError, StreamTransportError, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createApi, createOrganizationOperation, describeBackendFailure, extractMatrxErrorCode, extractMatrxErrorMessage, getUserMessage, isGenericUserMessage, isStreamTransportLost, openJsonOrStream, openStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parsePersistedBackendError, parseStreamError, requireOrganizationContext, unwrapUpstreamError } from './chunk-UONBYRE4.js';
2
+ import { OrganizationContextError, BackendApiError, parseHttpError, MatrxApiError, applyOrganizationContextHeader, extractMatrxErrorCode, extractMatrxErrorMessage, readMatrxNdjsonStream, readMatrxSseStream, requireOrganizationContext, StreamTransportError } from './chunk-TSHL7Z53.js';
3
+ export { BackendApiError, CONTRACT_SHA256, DEPLOYMENTS, DOMAINS, MatrxApiError, OrganizationContextError, StreamTransportError, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createApi, createOrganizationOperation, describeBackendFailure, extractMatrxErrorCode, extractMatrxErrorMessage, getUserMessage, isGenericUserMessage, isStreamTransportLost, openJsonOrStream, openStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parsePersistedBackendError, parseStreamError, requireOrganizationContext, unwrapUpstreamError } from './chunk-TSHL7Z53.js';
4
4
  import { resilientFetch, isNetError, extractErrorMessage } from './chunk-KIEAFMKB.js';
5
5
  export { AbortedError, ConnectTimeoutError, HeartbeatTimeoutError, HttpError, NetError, NetworkError, OfflineError, TotalTimeoutError, extractErrorMessage, isNetError, isTransportFailure, resilientFetch, toNetError, withRetry } from './chunk-KIEAFMKB.js';
6
- import { credentialToHeaders } from './chunk-AY5N6EA4.js';
7
- export { API_KEY_PREFIX, MATRX_HEADERS, credentialToHeaders, toCredentialsPort } from './chunk-AY5N6EA4.js';
6
+ import { credentialToHeaders } from './chunk-VTZKJMSY.js';
7
+ export { API_KEY_PREFIX, MATRX_HEADERS, credentialToHeaders, toCredentialsPort } from './chunk-VTZKJMSY.js';
8
8
  import { formatDurationSeconds } from '@ai-matrx/kit/format';
9
9
 
10
10
  // src/core/protocol.ts
@@ -1665,4 +1665,82 @@ async function reportProviderSessionFailure(transport, failure, options = {}) {
1665
1665
  }
1666
1666
  }
1667
1667
 
1668
- export { MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, MATRX_UI_ONLY_BODY_FIELDS, RUN_OUTPUT_KINDS, RUN_STREAM_LIFETIME_BACKSTOP_MS, RUN_WAIT_KNOB_FEATURE, TERMINAL_MATRX_RUNTIME_STATUSES, V2_COVERED_AI_PATH_TEMPLATES, WARM_PATH, aiVersionPathOverrides, applyAiApiVersion, applyDesktopTargetToRequestBody, bareStatusSentence, buildMatrxRequestBody, buildMatrxRequestUrl, buildQuery, buildSafeRequestLog, continueEphemeralConversationStart, continueStoredConversationStart, createMatrxTransport, createStreamReplayCursor, createWarmup, encodePathSegment, executeMatrxCall, fetchWithMatrxProtocolFallback, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, honestTransportMessage, isBareTransportCode, isCoveredAiPath, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, isV2Path, listRuntimeOperationEvents, logApiTarget, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseMatrxNdjsonResponse, pickServerJobOperation, preconnectServer, providerSessionFailureBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, requestJson, requestStream, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeOrRejoin, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, streamErrorText, toRunHandle, toV1FallbackUrl, toV2Path, withRunOrganization };
1668
+ // src/core/provider-usage.ts
1669
+ var TOKEN_MAX = 5e7;
1670
+ var clip2 = (value, max) => value.length > max ? value.slice(0, max) : value;
1671
+ var count = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.min(Math.floor(value), TOKEN_MAX) : 0;
1672
+ function providerSessionUsageBody(usage) {
1673
+ const seconds = typeof usage.seconds === "number" && Number.isFinite(usage.seconds) && usage.seconds > 0 ? Math.min(usage.seconds, 86400) : 0;
1674
+ return {
1675
+ provider: usage.provider,
1676
+ model: clip2(usage.model, 200),
1677
+ usage_id: clip2(usage.usage_id, 200),
1678
+ input_tokens: count(usage.input_tokens),
1679
+ output_tokens: count(usage.output_tokens),
1680
+ cached_input_tokens: count(usage.cached_input_tokens),
1681
+ characters: count(usage.characters),
1682
+ seconds
1683
+ };
1684
+ }
1685
+ function isEmptyProviderUsage(usage) {
1686
+ return !usage.usage_id?.trim() || !usage.model?.trim() || count(usage.input_tokens) === 0 && count(usage.output_tokens) === 0 && count(usage.cached_input_tokens) === 0 && count(usage.characters) === 0 && !(typeof usage.seconds === "number" && usage.seconds > 0);
1687
+ }
1688
+ async function reportProviderSessionUsage(transport, usage, options = {}) {
1689
+ try {
1690
+ await requestJson(transport, "/broker/usage", {
1691
+ method: "POST",
1692
+ body: providerSessionUsageBody(usage),
1693
+ ...options.signal ? { signal: options.signal } : {}
1694
+ });
1695
+ return "ok";
1696
+ } catch (error) {
1697
+ if (error instanceof MatrxApiError) {
1698
+ const status = error.status;
1699
+ if (status >= 400 && status < 500 && status !== 401 && status !== 408 && status !== 425 && status !== 429) {
1700
+ console.warn(`[provider-usage] server refused ${usage.provider} usage ${usage.usage_id} (${status})`);
1701
+ return "drop";
1702
+ }
1703
+ }
1704
+ return "retry";
1705
+ }
1706
+ }
1707
+ var DEFAULT_RETRY_DELAYS_MS = [1e3, 4e3, 15e3, 6e4, 18e4];
1708
+ function createProviderUsageReporter(options) {
1709
+ const delays = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS;
1710
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
1711
+ const seen = /* @__PURE__ */ new Set();
1712
+ const inflight = /* @__PURE__ */ new Set();
1713
+ async function deliver(usage) {
1714
+ for (let attempt2 = 0; ; attempt2 += 1) {
1715
+ let result;
1716
+ try {
1717
+ result = await options.send(usage);
1718
+ } catch {
1719
+ result = "retry";
1720
+ }
1721
+ if (result !== "retry") return;
1722
+ if (attempt2 >= delays.length) {
1723
+ console.warn(`[provider-usage] gave up delivering ${usage.provider} usage ${usage.usage_id}`);
1724
+ seen.delete(`${usage.provider}:${usage.usage_id}`);
1725
+ return;
1726
+ }
1727
+ await sleep(delays[attempt2] ?? 0);
1728
+ }
1729
+ }
1730
+ return {
1731
+ report(usage) {
1732
+ if (isEmptyProviderUsage(usage)) return;
1733
+ const key = `${usage.provider}:${usage.usage_id}`;
1734
+ if (seen.has(key)) return;
1735
+ seen.add(key);
1736
+ const task = deliver(usage).finally(() => inflight.delete(task));
1737
+ inflight.add(task);
1738
+ },
1739
+ async flush() {
1740
+ while (inflight.size > 0) await Promise.all([...inflight]);
1741
+ },
1742
+ pending: () => inflight.size
1743
+ };
1744
+ }
1745
+
1746
+ export { MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, MATRX_UI_ONLY_BODY_FIELDS, RUN_OUTPUT_KINDS, RUN_STREAM_LIFETIME_BACKSTOP_MS, RUN_WAIT_KNOB_FEATURE, TERMINAL_MATRX_RUNTIME_STATUSES, V2_COVERED_AI_PATH_TEMPLATES, WARM_PATH, aiVersionPathOverrides, applyAiApiVersion, applyDesktopTargetToRequestBody, bareStatusSentence, buildMatrxRequestBody, buildMatrxRequestUrl, buildQuery, buildSafeRequestLog, continueEphemeralConversationStart, continueStoredConversationStart, createMatrxTransport, createProviderUsageReporter, createStreamReplayCursor, createWarmup, encodePathSegment, executeMatrxCall, fetchWithMatrxProtocolFallback, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, honestTransportMessage, isBareTransportCode, isCoveredAiPath, isEmptyProviderUsage, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, isV2Path, listRuntimeOperationEvents, logApiTarget, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseMatrxNdjsonResponse, pickServerJobOperation, preconnectServer, providerSessionFailureBody, providerSessionUsageBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, reportProviderSessionUsage, requestJson, requestStream, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeOrRejoin, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, streamErrorText, toRunHandle, toV1FallbackUrl, toV2Path, withRunOrganization };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYUDQWDCM_cjs = require('./chunk-YUDQWDCM.cjs');
3
+ var chunkHER22VVH_cjs = require('./chunk-HER22VVH.cjs');
4
4
  require('./chunk-2SXAAKGV.cjs');
5
- require('./chunk-BMQI7UET.cjs');
5
+ require('./chunk-5WJLKYH6.cjs');
6
6
 
7
7
  // src/generated/integrations.ts
8
8
  var $ebayAccountDeletionChallenge = { m: "GET", p: "/ebay/account-deletion", d: "aidream", a: "guest", o: "optional", n: "integrations.ebay_account_deletion_challenge" };
@@ -3403,11 +3403,11 @@ function bingIntegrationsDisconnect(api, args, options) {
3403
3403
  }
3404
3404
  var $importNotionZip = { m: "POST", p: "/notion-import/zip", d: "aidream", a: "user", o: "required", s: "ndjson", n: "integrations.import_notion_zip" };
3405
3405
  function importNotionZip(api, args, options) {
3406
- return chunkYUDQWDCM_cjs.openStream(api, $importNotionZip, args, options);
3406
+ return chunkHER22VVH_cjs.openStream(api, $importNotionZip, args, options);
3407
3407
  }
3408
3408
  var $importNotionConnected = { m: "POST", p: "/notion-import/connected", d: "aidream", a: "user", o: "required", s: "ndjson", n: "integrations.import_notion_connected" };
3409
3409
  function importNotionConnected(api, args, options) {
3410
- return chunkYUDQWDCM_cjs.openStream(api, $importNotionConnected, args, options);
3410
+ return chunkHER22VVH_cjs.openStream(api, $importNotionConnected, args, options);
3411
3411
  }
3412
3412
  var TABLE = {
3413
3413
  "GET /ebay/account-deletion": $ebayAccountDeletionChallenge,
@@ -1,6 +1,6 @@
1
- import { openStream } from './chunk-UONBYRE4.js';
1
+ import { openStream } from './chunk-TSHL7Z53.js';
2
2
  import './chunk-KIEAFMKB.js';
3
- import './chunk-AY5N6EA4.js';
3
+ import './chunk-VTZKJMSY.js';
4
4
 
5
5
  // src/generated/integrations.ts
6
6
  var $ebayAccountDeletionChallenge = { m: "GET", p: "/ebay/account-deletion", d: "aidream", a: "guest", o: "optional", n: "integrations.ebay_account_deletion_challenge" };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYUDQWDCM_cjs = require('./chunk-YUDQWDCM.cjs');
3
+ var chunkHER22VVH_cjs = require('./chunk-HER22VVH.cjs');
4
4
  require('./chunk-2SXAAKGV.cjs');
5
- require('./chunk-BMQI7UET.cjs');
5
+ require('./chunk-5WJLKYH6.cjs');
6
6
 
7
7
  // src/intelligence/keys.generated.ts
8
8
  var MANDATE_KEYS_META = {
@@ -705,7 +705,7 @@ function getAgentCalibration(api, args, options) {
705
705
  }
706
706
  var $createDecision = { m: "POST", p: "/ai/decisions", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.create_decision" };
707
707
  function createDecision(api, args, options) {
708
- return chunkYUDQWDCM_cjs.openStream(api, $createDecision, args, options);
708
+ return chunkHER22VVH_cjs.openStream(api, $createDecision, args, options);
709
709
  }
710
710
  var $readDecision = { m: "GET", p: "/ai/decisions/{execution_id}", d: "aidream", a: "guest", o: "required", n: "intelligence.read_decision" };
711
711
  function readDecision(api, args, options) {
@@ -849,11 +849,11 @@ function triggerDrain(api, args, options) {
849
849
  }
850
850
  var $runInitial = { m: "POST", p: "/agent-iteration/run-initial", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.run_initial" };
851
851
  function runInitial(api, args, options) {
852
- return chunkYUDQWDCM_cjs.openStream(api, $runInitial, args, options);
852
+ return chunkHER22VVH_cjs.openStream(api, $runInitial, args, options);
853
853
  }
854
854
  var $runFeedback = { m: "POST", p: "/agent-iteration/feedback", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.run_feedback" };
855
855
  function runFeedback(api, args, options) {
856
- return chunkYUDQWDCM_cjs.openStream(api, $runFeedback, args, options);
856
+ return chunkHER22VVH_cjs.openStream(api, $runFeedback, args, options);
857
857
  }
858
858
  var $commitChoice = { m: "POST", p: "/agent-iteration/commit-choice", d: "aidream", a: "guest", o: "required", n: "intelligence.commit_choice" };
859
859
  function commitChoice(api, args, options) {
@@ -1009,7 +1009,7 @@ function getMandateRun(api, args, options) {
1009
1009
  }
1010
1010
  var $replayMandateRun = { m: "POST", p: "/mandates/runs/{conversation_id}/replay", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.replay_mandate_run" };
1011
1011
  function replayMandateRun(api, args, options) {
1012
- return chunkYUDQWDCM_cjs.openStream(api, $replayMandateRun, args, options);
1012
+ return chunkHER22VVH_cjs.openStream(api, $replayMandateRun, args, options);
1013
1013
  }
1014
1014
  var $getMandateRunResult = { m: "GET", p: "/mandates/runs/{request_id}/result", d: "aidream", a: "guest", o: "optional", n: "intelligence.get_mandate_run_result" };
1015
1015
  function getMandateRunResult(api, args, options) {
@@ -1017,7 +1017,7 @@ function getMandateRunResult(api, args, options) {
1017
1017
  }
1018
1018
  var $answerMandateRun = { m: "POST", p: "/mandates/runs/{request_id}/answer", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.answer_mandate_run" };
1019
1019
  function answerMandateRun(api, args, options) {
1020
- return chunkYUDQWDCM_cjs.openStream(api, $answerMandateRun, args, options);
1020
+ return chunkHER22VVH_cjs.openStream(api, $answerMandateRun, args, options);
1021
1021
  }
1022
1022
  var $getMandateRuns = { m: "GET", p: "/mandates/{mandate_key}/runs", d: "aidream", a: "guest", o: "optional", n: "intelligence.get_mandate_runs" };
1023
1023
  function getMandateRuns(api, args, options) {
@@ -1,6 +1,6 @@
1
- import { openStream } from './chunk-UONBYRE4.js';
1
+ import { openStream } from './chunk-TSHL7Z53.js';
2
2
  import './chunk-KIEAFMKB.js';
3
- import './chunk-AY5N6EA4.js';
3
+ import './chunk-VTZKJMSY.js';
4
4
 
5
5
  // src/intelligence/keys.generated.ts
6
6
  var MANDATE_KEYS_META = {
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYUDQWDCM_cjs = require('./chunk-YUDQWDCM.cjs');
3
+ var chunkHER22VVH_cjs = require('./chunk-HER22VVH.cjs');
4
4
  require('./chunk-2SXAAKGV.cjs');
5
- require('./chunk-BMQI7UET.cjs');
5
+ require('./chunk-5WJLKYH6.cjs');
6
6
 
7
7
  // src/generated/knowledge.ts
8
8
  var $getSetupFacts = { m: "GET", p: "/news/setup/facts", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_setup_facts" };
@@ -11,7 +11,7 @@ function getSetupFacts(api, args, options) {
11
11
  }
12
12
  var $proposeSetup = { m: "POST", p: "/news/setup/propose", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.propose_setup" };
13
13
  function proposeSetup(api, args, options) {
14
- return chunkYUDQWDCM_cjs.openStream(api, $proposeSetup, args, options);
14
+ return chunkHER22VVH_cjs.openStream(api, $proposeSetup, args, options);
15
15
  }
16
16
  var $resumeCostPause = { m: "POST", p: "/news/cost/resume", d: "aidream", a: "guest", o: "required", n: "knowledge.resume_cost_pause" };
17
17
  function resumeCostPause(api, args, options) {
@@ -35,7 +35,7 @@ function processYoutubeVideo(api, args, options) {
35
35
  }
36
36
  var $streamYoutubeVideoAnalysis = { m: "POST", p: "/research/youtube/videos/{video_id}/process/stream", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stream_youtube_video_analysis" };
37
37
  function streamYoutubeVideoAnalysis(api, args, options) {
38
- return chunkYUDQWDCM_cjs.openStream(api, $streamYoutubeVideoAnalysis, args, options);
38
+ return chunkHER22VVH_cjs.openStream(api, $streamYoutubeVideoAnalysis, args, options);
39
39
  }
40
40
  var $enrichYoutubeVideoComments = { m: "POST", p: "/research/youtube/videos/{video_id}/comments", d: "aidream", a: "guest", o: "required", n: "knowledge.enrich_youtube_video_comments" };
41
41
  function enrichYoutubeVideoComments(api, args, options) {
@@ -71,7 +71,7 @@ function findSourcesByUrl(api, args, options) {
71
71
  }
72
72
  var $suggestSetup = { m: "POST", p: "/research/suggest", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.suggest_setup" };
73
73
  function suggestSetup(api, args, options) {
74
- return chunkYUDQWDCM_cjs.openStream(api, $suggestSetup, args, options);
74
+ return chunkHER22VVH_cjs.openStream(api, $suggestSetup, args, options);
75
75
  }
76
76
  var $listTopics = { m: "GET", p: "/research/projects/{project_id}/topics", d: "aidream", a: "guest", o: "optional", n: "knowledge.list_topics" };
77
77
  function listTopics(api, args, options) {
@@ -127,15 +127,15 @@ function reorderKeywords(api, args, options) {
127
127
  }
128
128
  var $triggerSearch = { m: "POST", p: "/research/topics/{topic_id}/search", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.trigger_search" };
129
129
  function triggerSearch(api, args, options) {
130
- return chunkYUDQWDCM_cjs.openStream(api, $triggerSearch, args, options);
130
+ return chunkHER22VVH_cjs.openStream(api, $triggerSearch, args, options);
131
131
  }
132
132
  var $triggerScrape = { m: "POST", p: "/research/topics/{topic_id}/scrape", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.trigger_scrape" };
133
133
  function triggerScrape(api, args, options) {
134
- return chunkYUDQWDCM_cjs.openStream(api, $triggerScrape, args, options);
134
+ return chunkHER22VVH_cjs.openStream(api, $triggerScrape, args, options);
135
135
  }
136
136
  var $rescrapeSource = { m: "POST", p: "/research/topics/{topic_id}/sources/{source_id}/rescrape", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rescrape_source" };
137
137
  function rescrapeSource(api, args, options) {
138
- return chunkYUDQWDCM_cjs.openStream(api, $rescrapeSource, args, options);
138
+ return chunkHER22VVH_cjs.openStream(api, $rescrapeSource, args, options);
139
139
  }
140
140
  var $getSources = { m: "GET", p: "/research/topics/{topic_id}/sources", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_sources" };
141
141
  function getSources(api, args, options) {
@@ -167,27 +167,27 @@ function editContent(api, args, options) {
167
167
  }
168
168
  var $analyzeSource = { m: "POST", p: "/research/topics/{topic_id}/sources/{source_id}/analyze", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.analyze_source" };
169
169
  function analyzeSource(api, args, options) {
170
- return chunkYUDQWDCM_cjs.openStream(api, $analyzeSource, args, options);
170
+ return chunkHER22VVH_cjs.openStream(api, $analyzeSource, args, options);
171
171
  }
172
172
  var $retryAnalysis = { m: "POST", p: "/research/topics/{topic_id}/analyses/{analysis_id}/retry", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.retry_analysis" };
173
173
  function retryAnalysis(api, args, options) {
174
- return chunkYUDQWDCM_cjs.openStream(api, $retryAnalysis, args, options);
174
+ return chunkHER22VVH_cjs.openStream(api, $retryAnalysis, args, options);
175
175
  }
176
176
  var $retryAllFailedAnalyses = { m: "POST", p: "/research/topics/{topic_id}/retry-failed", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.retry_all_failed_analyses" };
177
177
  function retryAllFailedAnalyses(api, args, options) {
178
- return chunkYUDQWDCM_cjs.openStream(api, $retryAllFailedAnalyses, args, options);
178
+ return chunkHER22VVH_cjs.openStream(api, $retryAllFailedAnalyses, args, options);
179
179
  }
180
180
  var $analyzeAll = { m: "POST", p: "/research/topics/{topic_id}/analyze-all", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.analyze_all" };
181
181
  function analyzeAll(api, args, options) {
182
- return chunkYUDQWDCM_cjs.openStream(api, $analyzeAll, args, options);
182
+ return chunkHER22VVH_cjs.openStream(api, $analyzeAll, args, options);
183
183
  }
184
184
  var $rankSourceAuthority = { m: "POST", p: "/research/topics/{topic_id}/sources/rank-authority", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rank_source_authority" };
185
185
  function rankSourceAuthority(api, args, options) {
186
- return chunkYUDQWDCM_cjs.openStream(api, $rankSourceAuthority, args, options);
186
+ return chunkHER22VVH_cjs.openStream(api, $rankSourceAuthority, args, options);
187
187
  }
188
188
  var $generateTagSuggestions = { m: "POST", p: "/research/topics/{topic_id}/generate-tag-suggestions", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.generate_tag_suggestions" };
189
189
  function generateTagSuggestions(api, args, options) {
190
- return chunkYUDQWDCM_cjs.openStream(api, $generateTagSuggestions, args, options);
190
+ return chunkHER22VVH_cjs.openStream(api, $generateTagSuggestions, args, options);
191
191
  }
192
192
  var $applyTagSuggestionsRoute = { m: "POST", p: "/research/topics/{topic_id}/apply-tag-suggestions", d: "aidream", a: "guest", o: "required", n: "knowledge.apply_tag_suggestions_route" };
193
193
  function applyTagSuggestionsRoute(api, args, options) {
@@ -211,19 +211,19 @@ function promoteTopicExperts(api, args, options) {
211
211
  }
212
212
  var $scoreSources = { m: "POST", p: "/research/topics/{topic_id}/score-sources", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.score_sources" };
213
213
  function scoreSources(api, args, options) {
214
- return chunkYUDQWDCM_cjs.openStream(api, $scoreSources, args, options);
214
+ return chunkHER22VVH_cjs.openStream(api, $scoreSources, args, options);
215
215
  }
216
216
  var $runAutoTag = { m: "POST", p: "/research/topics/{topic_id}/auto-tag", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.run_auto_tag" };
217
217
  function runAutoTag(api, args, options) {
218
- return chunkYUDQWDCM_cjs.openStream(api, $runAutoTag, args, options);
218
+ return chunkHER22VVH_cjs.openStream(api, $runAutoTag, args, options);
219
219
  }
220
220
  var $runAutoConsolidate = { m: "POST", p: "/research/topics/{topic_id}/auto-consolidate", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.run_auto_consolidate" };
221
221
  function runAutoConsolidate(api, args, options) {
222
- return chunkYUDQWDCM_cjs.openStream(api, $runAutoConsolidate, args, options);
222
+ return chunkHER22VVH_cjs.openStream(api, $runAutoConsolidate, args, options);
223
223
  }
224
224
  var $synthesize = { m: "POST", p: "/research/topics/{topic_id}/synthesize", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.synthesize" };
225
225
  function synthesize(api, args, options) {
226
- return chunkYUDQWDCM_cjs.openStream(api, $synthesize, args, options);
226
+ return chunkHER22VVH_cjs.openStream(api, $synthesize, args, options);
227
227
  }
228
228
  var $getSynthesis = { m: "GET", p: "/research/topics/{topic_id}/synthesis", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_synthesis" };
229
229
  function getSynthesis(api, args, options) {
@@ -243,7 +243,7 @@ function setTopicRefreshSchedule(api, args, options) {
243
243
  }
244
244
  var $runPipeline = { m: "POST", p: "/research/topics/{topic_id}/run", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.run_pipeline" };
245
245
  function runPipeline(api, args, options) {
246
- return chunkYUDQWDCM_cjs.openStream(api, $runPipeline, args, options);
246
+ return chunkHER22VVH_cjs.openStream(api, $runPipeline, args, options);
247
247
  }
248
248
  var $getTags = { m: "GET", p: "/research/topics/{topic_id}/tags", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_tags" };
249
249
  function getTags(api, args, options) {
@@ -267,11 +267,11 @@ function assignTagsToSource(api, args, options) {
267
267
  }
268
268
  var $consolidateTag = { m: "POST", p: "/research/topics/{topic_id}/tags/{tag_id}/consolidate", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.consolidate_tag" };
269
269
  function consolidateTag(api, args, options) {
270
- return chunkYUDQWDCM_cjs.openStream(api, $consolidateTag, args, options);
270
+ return chunkHER22VVH_cjs.openStream(api, $consolidateTag, args, options);
271
271
  }
272
272
  var $suggestTags = { m: "POST", p: "/research/topics/{topic_id}/sources/{source_id}/suggest-tags", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.suggest_tags" };
273
273
  function suggestTags(api, args, options) {
274
- return chunkYUDQWDCM_cjs.openStream(api, $suggestTags, args, options);
274
+ return chunkHER22VVH_cjs.openStream(api, $suggestTags, args, options);
275
275
  }
276
276
  var $getDocument = { m: "GET", p: "/research/topics/{topic_id}/document", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_document" };
277
277
  function getDocument(api, args, options) {
@@ -279,7 +279,7 @@ function getDocument(api, args, options) {
279
279
  }
280
280
  var $generateDocument = { m: "POST", p: "/research/topics/{topic_id}/document", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.generate_document" };
281
281
  function generateDocument(api, args, options) {
282
- return chunkYUDQWDCM_cjs.openStream(api, $generateDocument, args, options);
282
+ return chunkHER22VVH_cjs.openStream(api, $generateDocument, args, options);
283
283
  }
284
284
  var $getDocumentVersions = { m: "GET", p: "/research/topics/{topic_id}/document/versions", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_document_versions" };
285
285
  function getDocumentVersions(api, args, options) {
@@ -335,7 +335,7 @@ function exportDocument(api, args, options) {
335
335
  }
336
336
  var $runExtractionStream = { m: "POST", p: "/page-extraction/runs/stream", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.run_extraction_stream" };
337
337
  function runExtractionStream(api, args, options) {
338
- return chunkYUDQWDCM_cjs.openStream(api, $runExtractionStream, args, options);
338
+ return chunkHER22VVH_cjs.openStream(api, $runExtractionStream, args, options);
339
339
  }
340
340
  var $retryPageRun = { m: "POST", p: "/page-extraction/page-runs/{page_run_id}/retry", d: "aidream", a: "guest", o: "required", n: "knowledge.retry_page_run" };
341
341
  function retryPageRun(api, args, options) {
@@ -347,11 +347,11 @@ function cancelRun(api, args, options) {
347
347
  }
348
348
  var $indexRunIntoRag = { m: "POST", p: "/page-extraction/runs/{run_id}/index", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.index_run_into_rag" };
349
349
  function indexRunIntoRag(api, args, options) {
350
- return chunkYUDQWDCM_cjs.openStream(api, $indexRunIntoRag, args, options);
350
+ return chunkHER22VVH_cjs.openStream(api, $indexRunIntoRag, args, options);
351
351
  }
352
352
  var $knowledgeSearch = { m: "POST", p: "/knowledge/search", d: "aidream", a: "guest", o: "optional", s: "ndjson", n: "knowledge.knowledge_search" };
353
353
  function knowledgeSearch(api, args, options) {
354
- return chunkYUDQWDCM_cjs.openStream(api, $knowledgeSearch, args, options);
354
+ return chunkHER22VVH_cjs.openStream(api, $knowledgeSearch, args, options);
355
355
  }
356
356
  var $knowledgeView = { m: "POST", p: "/knowledge/view", d: "aidream", a: "guest", o: "required", n: "knowledge.knowledge_view" };
357
357
  function knowledgeView(api, args, options) {
@@ -359,27 +359,27 @@ function knowledgeView(api, args, options) {
359
359
  }
360
360
  var $ragSearchEndpoint = { m: "POST", p: "/rag/search", d: "aidream", a: "guest", o: "optional", s: "ndjson", n: "knowledge.rag_search_endpoint" };
361
361
  function ragSearchEndpoint(api, args, options) {
362
- return chunkYUDQWDCM_cjs.openStream(api, $ragSearchEndpoint, args, options);
362
+ return chunkHER22VVH_cjs.openStream(api, $ragSearchEndpoint, args, options);
363
363
  }
364
364
  var $ragSearchStream = { m: "POST", p: "/rag/search/stream", d: "aidream", a: "guest", o: "optional", s: "ndjson", n: "knowledge.rag_search_stream" };
365
365
  function ragSearchStream(api, args, options) {
366
- return chunkYUDQWDCM_cjs.openStream(api, $ragSearchStream, args, options);
366
+ return chunkHER22VVH_cjs.openStream(api, $ragSearchStream, args, options);
367
367
  }
368
368
  var $ragIngestEndpoint = { m: "POST", p: "/rag/ingest", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rag_ingest_endpoint" };
369
369
  function ragIngestEndpoint(api, args, options) {
370
- return chunkYUDQWDCM_cjs.openStream(api, $ragIngestEndpoint, args, options);
370
+ return chunkHER22VVH_cjs.openStream(api, $ragIngestEndpoint, args, options);
371
371
  }
372
372
  var $ragIngestConversation = { m: "POST", p: "/rag/conversations/{conversation_id}/ingest", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rag_ingest_conversation" };
373
373
  function ragIngestConversation(api, args, options) {
374
- return chunkYUDQWDCM_cjs.openStream(api, $ragIngestConversation, args, options);
374
+ return chunkHER22VVH_cjs.openStream(api, $ragIngestConversation, args, options);
375
375
  }
376
376
  var $ragIngestStream = { m: "POST", p: "/rag/ingest/stream", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rag_ingest_stream" };
377
377
  function ragIngestStream(api, args, options) {
378
- return chunkYUDQWDCM_cjs.openStream(api, $ragIngestStream, args, options);
378
+ return chunkHER22VVH_cjs.openStream(api, $ragIngestStream, args, options);
379
379
  }
380
380
  var $ragVerifyEndpoint = { m: "POST", p: "/rag/verify", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.rag_verify_endpoint" };
381
381
  function ragVerifyEndpoint(api, args, options) {
382
- return chunkYUDQWDCM_cjs.openStream(api, $ragVerifyEndpoint, args, options);
382
+ return chunkHER22VVH_cjs.openStream(api, $ragVerifyEndpoint, args, options);
383
383
  }
384
384
  var $ragHealth = { m: "GET", p: "/rag/health", d: "aidream", a: "guest", o: "optional", n: "knowledge.rag_health" };
385
385
  function ragHealth(api, args, options) {
@@ -439,7 +439,7 @@ function unsubscribeLibraryEp(api, args, options) {
439
439
  }
440
440
  var $ingestLibraryStoreDocument = { m: "POST", p: "/rag/library/stores/{store_id}/ingest", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.ingest_library_store_document" };
441
441
  function ingestLibraryStoreDocument(api, args, options) {
442
- return chunkYUDQWDCM_cjs.openStream(api, $ingestLibraryStoreDocument, args, options);
442
+ return chunkHER22VVH_cjs.openStream(api, $ingestLibraryStoreDocument, args, options);
443
443
  }
444
444
  var $listLibraryDocuments = { m: "GET", p: "/rag/library", d: "aidream", a: "guest", o: "optional", n: "knowledge.list_library_documents" };
445
445
  function listLibraryDocuments(api, args, options) {
@@ -475,7 +475,7 @@ function bulkDeleteLibraryDocuments(api, args, options) {
475
475
  }
476
476
  var $reprocessLibraryDocument = { m: "POST", p: "/rag/library/{processed_document_id}/reprocess", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.reprocess_library_document" };
477
477
  function reprocessLibraryDocument(api, args, options) {
478
- return chunkYUDQWDCM_cjs.openStream(api, $reprocessLibraryDocument, args, options);
478
+ return chunkHER22VVH_cjs.openStream(api, $reprocessLibraryDocument, args, options);
479
479
  }
480
480
  var $testSearchLibraryDocument = { m: "POST", p: "/rag/library/{processed_document_id}/test-search", d: "aidream", a: "guest", o: "optional", n: "knowledge.test_search_library_document" };
481
481
  function testSearchLibraryDocument(api, args, options) {
@@ -503,23 +503,23 @@ function getLibraryStagesStatus(api, args, options) {
503
503
  }
504
504
  var $stageExtract = { m: "POST", p: "/rag/library/{processed_document_id}/extract", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stage_extract" };
505
505
  function stageExtract(api, args, options) {
506
- return chunkYUDQWDCM_cjs.openStream(api, $stageExtract, args, options);
506
+ return chunkHER22VVH_cjs.openStream(api, $stageExtract, args, options);
507
507
  }
508
508
  var $stageClean = { m: "POST", p: "/rag/library/{processed_document_id}/clean", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stage_clean" };
509
509
  function stageClean(api, args, options) {
510
- return chunkYUDQWDCM_cjs.openStream(api, $stageClean, args, options);
510
+ return chunkHER22VVH_cjs.openStream(api, $stageClean, args, options);
511
511
  }
512
512
  var $stageChunk = { m: "POST", p: "/rag/library/{processed_document_id}/chunk", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stage_chunk" };
513
513
  function stageChunk(api, args, options) {
514
- return chunkYUDQWDCM_cjs.openStream(api, $stageChunk, args, options);
514
+ return chunkHER22VVH_cjs.openStream(api, $stageChunk, args, options);
515
515
  }
516
516
  var $stageEmbed = { m: "POST", p: "/rag/library/{processed_document_id}/embed", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stage_embed" };
517
517
  function stageEmbed(api, args, options) {
518
- return chunkYUDQWDCM_cjs.openStream(api, $stageEmbed, args, options);
518
+ return chunkHER22VVH_cjs.openStream(api, $stageEmbed, args, options);
519
519
  }
520
520
  var $stageRunAll = { m: "POST", p: "/rag/library/{processed_document_id}/run-all", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.stage_run_all" };
521
521
  function stageRunAll(api, args, options) {
522
- return chunkYUDQWDCM_cjs.openStream(api, $stageRunAll, args, options);
522
+ return chunkHER22VVH_cjs.openStream(api, $stageRunAll, args, options);
523
523
  }
524
524
  var $prepareDerivationRebuild = { m: "POST", p: "/rag/library/{processed_document_id}/derive/{kind}/rebuild-preview", d: "aidream", a: "guest", o: "required", n: "knowledge.prepare_derivation_rebuild" };
525
525
  function prepareDerivationRebuild(api, args, options) {
@@ -527,7 +527,7 @@ function prepareDerivationRebuild(api, args, options) {
527
527
  }
528
528
  var $deriveStream = { m: "POST", p: "/rag/library/{processed_document_id}/derive/{kind}", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.derive_stream" };
529
529
  function deriveStream(api, args, options) {
530
- return chunkYUDQWDCM_cjs.openStream(api, $deriveStream, args, options);
530
+ return chunkHER22VVH_cjs.openStream(api, $deriveStream, args, options);
531
531
  }
532
532
  var $listDerivations = { m: "GET", p: "/rag/library/{processed_document_id}/derivations", d: "aidream", a: "guest", o: "optional", n: "knowledge.list_derivations" };
533
533
  function listDerivations(api, args, options) {
@@ -543,7 +543,7 @@ function cancelDeriveRun(api, args, options) {
543
543
  }
544
544
  var $triggerSweep = { m: "POST", p: "/rag/sweeps", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.trigger_sweep" };
545
545
  function triggerSweep(api, args, options) {
546
- return chunkYUDQWDCM_cjs.openStream(api, $triggerSweep, args, options);
546
+ return chunkHER22VVH_cjs.openStream(api, $triggerSweep, args, options);
547
547
  }
548
548
  var $overview = { m: "GET", p: "/rag/admin/overview", d: "aidream", a: "admin", o: "exempt", n: "knowledge.overview" };
549
549
  function overview(api, args, options) {
@@ -631,7 +631,7 @@ function adminSearchLabDiagnose(api, args, options) {
631
631
  }
632
632
  var $adminSearchLabDiagnoseStream = { m: "POST", p: "/admin/rag/search-lab/diagnose/stream", d: "aidream", a: "admin", o: "exempt", s: "ndjson", n: "knowledge.admin_search_lab_diagnose_stream" };
633
633
  function adminSearchLabDiagnoseStream(api, args, options) {
634
- return chunkYUDQWDCM_cjs.openStream(api, $adminSearchLabDiagnoseStream, args, options);
634
+ return chunkHER22VVH_cjs.openStream(api, $adminSearchLabDiagnoseStream, args, options);
635
635
  }
636
636
  var $getGraph = { m: "GET", p: "/kg/graph", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_graph" };
637
637
  function getGraph(api, args, options) {
@@ -655,7 +655,7 @@ function diagnoseEndpoint(api, args, options) {
655
655
  }
656
656
  var $diagnoseStreamEndpoint = { m: "POST", p: "/rag/search-lab/diagnose/stream", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.diagnose_stream_endpoint" };
657
657
  function diagnoseStreamEndpoint(api, args, options) {
658
- return chunkYUDQWDCM_cjs.openStream(api, $diagnoseStreamEndpoint, args, options);
658
+ return chunkHER22VVH_cjs.openStream(api, $diagnoseStreamEndpoint, args, options);
659
659
  }
660
660
  var $agentToolSearchEndpoint = { m: "POST", p: "/rag/search-lab/tool/search", d: "aidream", a: "guest", o: "required", n: "knowledge.agent_tool_search_endpoint" };
661
661
  function agentToolSearchEndpoint(api, args, options) {
@@ -679,7 +679,7 @@ function readExport(api, args, options) {
679
679
  }
680
680
  var $indexExport = { m: "POST", p: "/media/libraries/{library_id}/index", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "knowledge.index_export" };
681
681
  function indexExport(api, args, options) {
682
- return chunkYUDQWDCM_cjs.openStream(api, $indexExport, args, options);
682
+ return chunkHER22VVH_cjs.openStream(api, $indexExport, args, options);
683
683
  }
684
684
  var $listItems = { m: "GET", p: "/media/libraries/{library_id}/items", d: "aidream", a: "guest", o: "optional", n: "knowledge.list_items" };
685
685
  function listItems(api, args, options) {
package/dist/knowledge.js CHANGED
@@ -1,6 +1,6 @@
1
- import { openStream } from './chunk-UONBYRE4.js';
1
+ import { openStream } from './chunk-TSHL7Z53.js';
2
2
  import './chunk-KIEAFMKB.js';
3
- import './chunk-AY5N6EA4.js';
3
+ import './chunk-VTZKJMSY.js';
4
4
 
5
5
  // src/generated/knowledge.ts
6
6
  var $getSetupFacts = { m: "GET", p: "/news/setup/facts", d: "aidream", a: "guest", o: "optional", n: "knowledge.get_setup_facts" };