@ai-matrx/agents 0.25.3 → 0.25.4

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.
@@ -354,6 +354,22 @@ interface MatrxHttpErrorLike {
354
354
  * `error`) from `detail`, `details`, or the top level. Null when absent.
355
355
  */
356
356
  declare function readMatrxErrorCode(error: unknown): string | null;
357
+ /**
358
+ * The machine code a server message carries as a PREFIX
359
+ * (`"resume_conflict: another run is live"` → `resume_conflict`), for envelope
360
+ * variants that pass the message but map `error` to a generic status word.
361
+ * Only the known resume/turn-lock codes match; null for anything else.
362
+ */
363
+ declare function readMatrxErrorCodeFromMessage(message: string | null | undefined): string | null;
364
+ /**
365
+ * The conversation's own organization id, for scoping a resume/rejoin to the
366
+ * RUN's organization instead of the session's selection. Transport-agnostic:
367
+ * the host injects `read` (a supabase select, a REST call, …) returning the raw
368
+ * `organization_id` (or throwing). Null — with `onUnreadable(reason)` — when it
369
+ * is missing or unreadable, so the caller keeps the active organization and
370
+ * says so.
371
+ */
372
+ declare function readConversationOrganizationId(conversationId: string, read: (conversationId: string) => Promise<unknown>, onUnreadable?: (reason: string | null) => void): Promise<string | null>;
357
373
  /** Where to rejoin a live run, read from a resume door's 409. */
358
374
  interface MatrxLiveRunRejoin {
359
375
  /** The live request (`GET /runtime/operations/{id}`); null for doors outside the spine (SEO). */
@@ -731,4 +747,4 @@ declare function listUserPendingToolCalls(transport: MatrxTransport, options?: {
731
747
  signal?: AbortSignal;
732
748
  }): Promise<MatrxPendingCallSummary[]>;
733
749
 
734
- export { type CreateMatrxTransportOptions, FollowRuntimeOperationToEndOptions, type FollowUnavailableRejoinOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxClientSessionProvider, type MatrxClientToolResult, type MatrxFollowedOutcome, type MatrxHttpErrorLike, MatrxJsonObject, MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxPendingCallSummary, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxRequestInfo, MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, MatrxRuntimeExecutionStatus, MatrxRuntimeOperationEvent, MatrxStreamCallOptions, type MatrxToolResultsResponse, MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportTarget, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type SettleRunPickupOptions, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, followUnavailableRejoin, followWorkflowRunEvents, isCoveredAiPath, isLiveStreamUnavailable, isResumeConflict, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, openMatrxStream, providerSessionFailureBody, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, reportProviderSessionFailure, requireOrganizationContext, resumeOrRejoin, runtimeOperationRejoinPath, settleRunPickup, streamErrorText, submitAgentToolResults, toV1FallbackUrl, toV2Path, withRunOrganization };
750
+ export { type CreateMatrxTransportOptions, FollowRuntimeOperationToEndOptions, type FollowUnavailableRejoinOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxClientSessionProvider, type MatrxClientToolResult, type MatrxFollowedOutcome, type MatrxHttpErrorLike, MatrxJsonObject, MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxPendingCallSummary, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxRequestInfo, MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, MatrxRuntimeExecutionStatus, MatrxRuntimeOperationEvent, MatrxStreamCallOptions, type MatrxToolResultsResponse, MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportTarget, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type SettleRunPickupOptions, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, followUnavailableRejoin, followWorkflowRunEvents, isCoveredAiPath, isLiveStreamUnavailable, isResumeConflict, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, openMatrxStream, providerSessionFailureBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, reportProviderSessionFailure, requireOrganizationContext, resumeOrRejoin, runtimeOperationRejoinPath, settleRunPickup, streamErrorText, submitAgentToolResults, toV1FallbackUrl, toV2Path, withRunOrganization };
@@ -354,6 +354,22 @@ interface MatrxHttpErrorLike {
354
354
  * `error`) from `detail`, `details`, or the top level. Null when absent.
355
355
  */
356
356
  declare function readMatrxErrorCode(error: unknown): string | null;
357
+ /**
358
+ * The machine code a server message carries as a PREFIX
359
+ * (`"resume_conflict: another run is live"` → `resume_conflict`), for envelope
360
+ * variants that pass the message but map `error` to a generic status word.
361
+ * Only the known resume/turn-lock codes match; null for anything else.
362
+ */
363
+ declare function readMatrxErrorCodeFromMessage(message: string | null | undefined): string | null;
364
+ /**
365
+ * The conversation's own organization id, for scoping a resume/rejoin to the
366
+ * RUN's organization instead of the session's selection. Transport-agnostic:
367
+ * the host injects `read` (a supabase select, a REST call, …) returning the raw
368
+ * `organization_id` (or throwing). Null — with `onUnreadable(reason)` — when it
369
+ * is missing or unreadable, so the caller keeps the active organization and
370
+ * says so.
371
+ */
372
+ declare function readConversationOrganizationId(conversationId: string, read: (conversationId: string) => Promise<unknown>, onUnreadable?: (reason: string | null) => void): Promise<string | null>;
357
373
  /** Where to rejoin a live run, read from a resume door's 409. */
358
374
  interface MatrxLiveRunRejoin {
359
375
  /** The live request (`GET /runtime/operations/{id}`); null for doors outside the spine (SEO). */
@@ -731,4 +747,4 @@ declare function listUserPendingToolCalls(transport: MatrxTransport, options?: {
731
747
  signal?: AbortSignal;
732
748
  }): Promise<MatrxPendingCallSummary[]>;
733
749
 
734
- export { type CreateMatrxTransportOptions, FollowRuntimeOperationToEndOptions, type FollowUnavailableRejoinOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxClientSessionProvider, type MatrxClientToolResult, type MatrxFollowedOutcome, type MatrxHttpErrorLike, MatrxJsonObject, MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxPendingCallSummary, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxRequestInfo, MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, MatrxRuntimeExecutionStatus, MatrxRuntimeOperationEvent, MatrxStreamCallOptions, type MatrxToolResultsResponse, MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportTarget, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type SettleRunPickupOptions, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, followUnavailableRejoin, followWorkflowRunEvents, isCoveredAiPath, isLiveStreamUnavailable, isResumeConflict, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, openMatrxStream, providerSessionFailureBody, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, reportProviderSessionFailure, requireOrganizationContext, resumeOrRejoin, runtimeOperationRejoinPath, settleRunPickup, streamErrorText, submitAgentToolResults, toV1FallbackUrl, toV2Path, withRunOrganization };
750
+ export { type CreateMatrxTransportOptions, FollowRuntimeOperationToEndOptions, type FollowUnavailableRejoinOptions, MATRX_AI_API_VERSION_DEFAULT, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, type MatrxAiApiVersion, MatrxApiError, type MatrxCallError, type MatrxClientSessionProvider, type MatrxClientToolResult, type MatrxFollowedOutcome, type MatrxHttpErrorLike, MatrxJsonObject, MatrxJsonValue, type MatrxLiveRunRejoin, type MatrxLiveStreamUnavailable, type MatrxPendingCallSummary, type MatrxProtocolDowngrade, type MatrxProtocolFallbackOptions, type MatrxRequestInfo, MatrxRunHandle, type MatrxRunPickup, type MatrxRunPickupSettlement, MatrxRuntimeExecutionStatus, MatrxRuntimeOperationEvent, MatrxStreamCallOptions, type MatrxToolResultsResponse, MatrxTransport, type MatrxTransportDiagnostics, type MatrxTransportTarget, OrganizationContextError, type OrganizationContextErrorCode, type OrganizationOperation, type ProviderSessionFailure, type ProviderSessionFailureVerdict, type ResumeOrRejoinOptions, type ResumeOrRejoinOutcome, type SettleRunPickupOptions, V2_COVERED_AI_PATH_TEMPLATES, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createMatrxTransport, createOrganizationOperation, fetchWithMatrxProtocolFallback, followUnavailableRejoin, followWorkflowRunEvents, isCoveredAiPath, isLiveStreamUnavailable, isResumeConflict, isV2Path, listConversationPendingToolCalls, listUserPendingToolCalls, normalizeMatrxError, openMatrxStream, providerSessionFailureBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, reportProviderSessionFailure, requireOrganizationContext, resumeOrRejoin, runtimeOperationRejoinPath, settleRunPickup, streamErrorText, submitAgentToolResults, toV1FallbackUrl, toV2Path, withRunOrganization };
@@ -965,6 +965,30 @@ function readMatrxErrorCode(error) {
965
965
  }
966
966
  return null;
967
967
  }
968
+ var PREFIXED_ERROR_CODES = [
969
+ "resume_conflict",
970
+ "not_resumable",
971
+ "outstanding_delegated_calls",
972
+ "user_request_not_found",
973
+ "run_in_flight"
974
+ ];
975
+ function readMatrxErrorCodeFromMessage(message) {
976
+ if (typeof message !== "string") return null;
977
+ for (const code of PREFIXED_ERROR_CODES) {
978
+ if (message.startsWith(`${code}:`)) return code;
979
+ }
980
+ return null;
981
+ }
982
+ async function readConversationOrganizationId(conversationId, read, onUnreadable) {
983
+ try {
984
+ const value = await read(conversationId);
985
+ if (typeof value === "string" && value.trim()) return value;
986
+ onUnreadable?.(null);
987
+ } catch (error) {
988
+ onUnreadable?.(error instanceof Error ? error.message : String(error));
989
+ }
990
+ return null;
991
+ }
968
992
  function firstString(candidates, key) {
969
993
  for (const candidate of candidates) {
970
994
  const value = nonBlank(candidate[key]);
@@ -1438,10 +1462,12 @@ export {
1438
1462
  normalizeMatrxError,
1439
1463
  openMatrxStream,
1440
1464
  providerSessionFailureBody,
1465
+ readConversationOrganizationId,
1441
1466
  readLiveRunRejoin,
1442
1467
  readLiveRunRequestId,
1443
1468
  readLiveStreamUnavailable,
1444
1469
  readMatrxErrorCode,
1470
+ readMatrxErrorCodeFromMessage,
1445
1471
  rejoinRuntimeOperation,
1446
1472
  reportProviderSessionFailure,
1447
1473
  requireOrganizationContext,