@mastra/factory 0.24.0-alpha.7 → 0.24.0-alpha.9

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 (125) hide show
  1. package/dist/boards/review.d.ts.map +1 -1
  2. package/dist/boards/review.js +21 -1
  3. package/dist/boards/review.js.map +1 -1
  4. package/dist/boards/work-transition-policy.d.ts.map +1 -1
  5. package/dist/boards/work-transition-policy.js +2 -1
  6. package/dist/boards/work-transition-policy.js.map +1 -1
  7. package/dist/factory.d.ts.map +1 -1
  8. package/dist/factory.js +91 -13
  9. package/dist/factory.js.map +1 -1
  10. package/dist/integrations/github/rules.d.ts.map +1 -1
  11. package/dist/integrations/github/rules.js +26 -22
  12. package/dist/integrations/github/rules.js.map +1 -1
  13. package/dist/integrations/github/sandbox.d.ts +2 -3
  14. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  15. package/dist/integrations/github/sandbox.js +78 -7
  16. package/dist/integrations/github/sandbox.js.map +1 -1
  17. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  18. package/dist/integrations/gitlab/rules.js +28 -21
  19. package/dist/integrations/gitlab/rules.js.map +1 -1
  20. package/dist/integrations/slack/integration.d.ts.map +1 -1
  21. package/dist/integrations/slack/integration.js +33 -6
  22. package/dist/integrations/slack/integration.js.map +1 -1
  23. package/dist/integrations/slack/slack.d.ts.map +1 -1
  24. package/dist/integrations/slack/slack.js +25 -24
  25. package/dist/integrations/slack/slack.js.map +1 -1
  26. package/dist/routes/attention-activity.d.ts.map +1 -1
  27. package/dist/routes/attention-activity.js +5 -2
  28. package/dist/routes/attention-activity.js.map +1 -1
  29. package/dist/routes/attention-providers.d.ts +0 -1
  30. package/dist/routes/attention-providers.d.ts.map +1 -1
  31. package/dist/routes/attention-providers.js +5 -6
  32. package/dist/routes/attention-providers.js.map +1 -1
  33. package/dist/routes/config.d.ts +4 -0
  34. package/dist/routes/config.d.ts.map +1 -1
  35. package/dist/routes/config.js +20 -6
  36. package/dist/routes/config.js.map +1 -1
  37. package/dist/routes/provider-credentials.d.ts +2 -1
  38. package/dist/routes/provider-credentials.d.ts.map +1 -1
  39. package/dist/routes/provider-credentials.js +6 -2
  40. package/dist/routes/provider-credentials.js.map +1 -1
  41. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  42. package/dist/rules/dispatch-errors.js +12 -0
  43. package/dist/rules/dispatch-errors.js.map +1 -1
  44. package/dist/rules/dispatcher.d.ts.map +1 -1
  45. package/dist/rules/dispatcher.js +42 -3
  46. package/dist/rules/dispatcher.js.map +1 -1
  47. package/dist/session/channel-reply-processor.d.ts +35 -0
  48. package/dist/session/channel-reply-processor.d.ts.map +1 -0
  49. package/dist/session/channel-reply-processor.js +46 -0
  50. package/dist/session/channel-reply-processor.js.map +1 -0
  51. package/dist/session/channel-session-link-processor.d.ts +39 -0
  52. package/dist/session/channel-session-link-processor.d.ts.map +1 -0
  53. package/dist/session/channel-session-link-processor.js +99 -0
  54. package/dist/session/channel-session-link-processor.js.map +1 -0
  55. package/dist/session/factory-session.d.ts +4 -0
  56. package/dist/session/factory-session.d.ts.map +1 -1
  57. package/dist/session/factory-session.js +1 -0
  58. package/dist/session/factory-session.js.map +1 -1
  59. package/dist/session/reply-credential-processor.d.ts.map +1 -1
  60. package/dist/session/reply-credential-processor.js +4 -6
  61. package/dist/session/reply-credential-processor.js.map +1 -1
  62. package/dist/session/run-audit.d.ts +24 -0
  63. package/dist/session/run-audit.d.ts.map +1 -1
  64. package/dist/session/run-audit.js +93 -7
  65. package/dist/session/run-audit.js.map +1 -1
  66. package/dist/session/source-control-tools.d.ts.map +1 -1
  67. package/dist/session/source-control-tools.js.map +1 -1
  68. package/dist/storage/domains/source-control/base.d.ts +7 -0
  69. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  70. package/dist/storage/domains/source-control/base.js +12 -0
  71. package/dist/storage/domains/source-control/base.js.map +1 -1
  72. package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
  73. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  74. package/dist/storage/domains/source-control/inmemory.js +8 -0
  75. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  76. package/dist/storage/domains/work-items/base.d.ts +2 -2
  77. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  78. package/dist/storage/domains/work-items/base.js +5 -0
  79. package/dist/storage/domains/work-items/base.js.map +1 -1
  80. package/dist/tools/approval-tools.d.ts +1 -1
  81. package/dist/tools/approval-tools.d.ts.map +1 -1
  82. package/dist/tools/approval-tools.js +3 -1
  83. package/dist/tools/approval-tools.js.map +1 -1
  84. package/dist/tools/deliver.d.ts +16 -2
  85. package/dist/tools/deliver.d.ts.map +1 -1
  86. package/dist/tools/deliver.js +12 -2
  87. package/dist/tools/deliver.js.map +1 -1
  88. package/dist/tools/index.d.ts +6 -5
  89. package/dist/tools/index.d.ts.map +1 -1
  90. package/dist/tools/index.js +9 -12
  91. package/dist/tools/index.js.map +1 -1
  92. package/dist/tools/messaging-tools.d.ts +1 -1
  93. package/dist/tools/messaging-tools.d.ts.map +1 -1
  94. package/dist/tools/messaging-tools.js +84 -3
  95. package/dist/tools/messaging-tools.js.map +1 -1
  96. package/dist/tools/permissions.d.ts.map +1 -1
  97. package/dist/tools/permissions.js +3 -0
  98. package/dist/tools/permissions.js.map +1 -1
  99. package/dist/tools/read-tools.d.ts +3 -0
  100. package/dist/tools/read-tools.d.ts.map +1 -1
  101. package/dist/tools/read-tools.js +16 -8
  102. package/dist/tools/read-tools.js.map +1 -1
  103. package/dist/tools/reports.d.ts.map +1 -1
  104. package/dist/tools/reports.js +3 -1
  105. package/dist/tools/reports.js.map +1 -1
  106. package/dist/tools/scope.d.ts +6 -0
  107. package/dist/tools/scope.d.ts.map +1 -1
  108. package/dist/tools/scope.js +10 -1
  109. package/dist/tools/scope.js.map +1 -1
  110. package/dist/tools/session-tools.d.ts +1 -1
  111. package/dist/tools/session-tools.d.ts.map +1 -1
  112. package/dist/tools/session-tools.js +11 -7
  113. package/dist/tools/session-tools.js.map +1 -1
  114. package/dist/tools/sessions-state-processor.d.ts +5 -1
  115. package/dist/tools/sessions-state-processor.d.ts.map +1 -1
  116. package/dist/tools/sessions-state-processor.js +32 -48
  117. package/dist/tools/sessions-state-processor.js.map +1 -1
  118. package/dist/tools/side-sessions.d.ts +53 -0
  119. package/dist/tools/side-sessions.d.ts.map +1 -0
  120. package/dist/tools/side-sessions.js +83 -0
  121. package/dist/tools/side-sessions.js.map +1 -0
  122. package/dist/tools/work-item-tools.d.ts.map +1 -1
  123. package/dist/tools/work-item-tools.js +45 -25
  124. package/dist/tools/work-item-tools.js.map +1 -1
  125. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"provider-credentials.js","names":[],"sources":["../../src/routes/provider-credentials.ts"],"sourcesContent":["/**\n * Per-request model-provider credential context.\n *\n * The provider config/OAuth routes serve two deployment shapes:\n *\n * - **Local** (no web auth adapter): credentials live in the server-global\n * file-backed `AuthStorage` (`auth.json`) — unchanged TUI behavior.\n * - **Tenant** (auth adapter active): credentials live in the\n * `model-credentials` factory storage domain, scoped per `(orgId, userId)`\n * with optional org-wide rows (`userId` absent).\n *\n * `resolveCredentialContext` decides which shape a request is in: an\n * authenticated user always gets the tenant path; an unauthenticated request\n * is rejected when auth is enabled and falls back to local otherwise.\n */\n\nimport type { Context } from 'hono';\n\nimport { factoryUserOrgId } from '../auth.js';\nimport type {\n CredentialRecord,\n LoginSessionKind,\n ModelCredentialsStorage,\n} from '../storage/domains/credentials/base.js';\nimport type { RouteAuth } from './route.js';\n\n/**\n * OAuth credentials are stored under the credential id, which differs from the\n * catalog provider id for OpenAI (`openai-codex`) and Kimi (`kimi-for-coding`).\n * Tenant rows use the same keying so one lookup serves both OAuth tokens and\n * API keys, and match what model resolution reads.\n */\nexport { getCredentialProviderId as getAuthProviderId } from '@mastra/code-sdk/providers/model-ids';\n\n/**\n * Providers that support a browser-driven OAuth sign-in flow, keyed by\n * *catalog* provider id (what the routes and settings UI use). All flows need\n * no inbound connection to the server: Anthropic uses paste-code PKCE, the\n * rest use RFC 8628-style device codes. `subscription` names the plan the\n * sign-in bills, as shown under a reply.\n */\nexport const WEB_OAUTH_PROVIDERS: Readonly<Record<string, { flow: LoginSessionKind; subscription: string }>> = {\n anthropic: { flow: 'paste-code', subscription: 'Claude Pro/Max' },\n openai: { flow: 'device-code', subscription: 'ChatGPT Plus/Pro' },\n 'github-copilot': { flow: 'device-code', subscription: 'GitHub Copilot' },\n xai: { flow: 'device-code', subscription: 'SuperGrok/X Premium+' },\n};\n\nexport type CredentialContext =\n | { mode: 'local' }\n | { mode: 'tenant'; storage: ModelCredentialsStorage; orgId: string; userId: string };\n\n/**\n * The tenant credentials domain, when registered and ready. `undefined` means\n * the factory never ran (no handle threaded in) or the domain's init failed\n * (fail-soft — callers report the feature unavailable instead of crashing).\n */\nexport async function getTenantCredentialsStorage(\n credentials: ModelCredentialsStorage | undefined,\n): Promise<ModelCredentialsStorage | undefined> {\n if (!credentials) return undefined;\n try {\n await credentials.ensureReady();\n } catch {\n return undefined;\n }\n return credentials;\n}\n\n/**\n * Org key for tenant rows. Personal accounts get an org bootstrapped by the\n * auth adapter (`ensureOrg`); if one still isn't present, scope rows under a\n * per-user synthetic org so credentials never become server-global.\n */\nexport function tenantOrgId(tenant: { orgId?: string; userId: string }): string {\n return tenant.orgId ?? factoryUserOrgId({ id: tenant.userId }) ?? `user:${tenant.userId}`;\n}\n\n/**\n * Resolve the credential context for a request, or a ready-to-return error\n * response. Mutating credential routes call this and hard-fail (401/503)\n * when the tenant path is required but unavailable.\n */\nexport async function resolveCredentialContext({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialContext | { response: Response }> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) {\n // When an auth provider is active, credential operations always require a\n // signed-in caller — otherwise one anonymous request could write keys for\n // everyone. Without a provider this is a single-user local server.\n if (auth.enabled()) return { response: c.json({ error: 'unauthorized' }, 401) };\n return { mode: 'local' };\n }\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) {\n return {\n response: c.json(\n {\n error: 'credentials_unavailable',\n message: 'Tenant credential storage is unavailable — the app database is not configured or failed to start.',\n },\n 503,\n ),\n };\n }\n return { mode: 'tenant', storage, orgId: tenantOrgId(tenant), userId: tenant.userId };\n}\n\n/**\n * List the caller's tenant credential records for provider listing, or\n * `undefined` in local mode (caller should fall back to `AuthStorage`).\n * Read-only and degradation-friendly: an authenticated caller with the domain\n * unavailable gets an empty list (sources show `env`/`none`) instead of a 503\n * so the settings page still renders.\n */\nexport async function listTenantCredentialsForRequest({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialRecord[] | undefined> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return auth.enabled() ? [] : undefined;\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) return [];\n return storage.listCredentials(tenantOrgId(tenant), tenant.userId);\n}\n"],"mappings":";;;;;;;;;;AAyCA,MAAa,sBAAkG;CAC7G,WAAW;EAAE,MAAM;EAAc,cAAc;CAAiB;CAChE,QAAQ;EAAE,MAAM;EAAe,cAAc;CAAmB;CAChE,kBAAkB;EAAE,MAAM;EAAe,cAAc;CAAiB;CACxE,KAAK;EAAE,MAAM;EAAe,cAAc;CAAuB;AACnE;;;;;;AAWA,eAAsB,4BACpB,aAC8C;CAC9C,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,IAAI;EACF,MAAM,YAAY,YAAY;CAChC,QAAQ;EACN;CACF;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAoD;CAC9E,OAAO,OAAO,SAAS,iBAAiB,EAAE,IAAI,OAAO,OAAO,CAAC,KAAK,QAAQ,OAAO;AACnF;;;;;;AAOA,eAAsB,yBAAyB,EAC7C,GACA,MACA,eAMsD;CACtD,MAAM,KAAK,WAAW,CAAC;CACvB,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5B,IAAI,CAAC,QAAQ;EAIX,IAAI,KAAK,QAAQ,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,eAAe,GAAG,GAAG,EAAE;EAC9E,OAAO,EAAE,MAAM,QAAQ;CACzB;CACA,MAAM,UAAU,MAAM,4BAA4B,WAAW;CAC7D,IAAI,CAAC,SACH,OAAO,EACL,UAAU,EAAE,KACV;EACE,OAAO;EACP,SAAS;CACX,GACA,GACF,EACF;CAEF,OAAO;EAAE,MAAM;EAAU;EAAS,OAAO,YAAY,MAAM;EAAG,QAAQ,OAAO;CAAO;AACtF;;;;;;;;AASA,eAAsB,gCAAgC,EACpD,GACA,MACA,eAM0C;CAC1C,MAAM,KAAK,WAAW,CAAC;CACvB,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5B,IAAI,CAAC,QAAQ,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAA;CAC1C,MAAM,UAAU,MAAM,4BAA4B,WAAW;CAC7D,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,OAAO,QAAQ,gBAAgB,YAAY,MAAM,GAAG,OAAO,MAAM;AACnE"}
1
+ {"version":3,"file":"provider-credentials.js","names":[],"sources":["../../src/routes/provider-credentials.ts"],"sourcesContent":["/**\n * Per-request model-provider credential context.\n *\n * The provider config/OAuth routes serve two deployment shapes:\n *\n * - **Local** (no web auth adapter): credentials live in the server-global\n * file-backed `AuthStorage` (`auth.json`) — unchanged TUI behavior.\n * - **Tenant** (auth adapter active): credentials live in the\n * `model-credentials` factory storage domain, scoped per `(orgId, userId)`\n * with optional org-wide rows (`userId` absent).\n *\n * `resolveCredentialContext` decides which shape a request is in: an\n * authenticated user always gets the tenant path; an unauthenticated request\n * is rejected when auth is enabled and falls back to local otherwise.\n */\n\nimport type { Context } from 'hono';\n\nimport { factoryUserOrgId } from '../auth.js';\nimport { providerDisplayName } from '../provider-display-name.js';\nimport type {\n CredentialRecord,\n LoginSessionKind,\n ModelCredentialsStorage,\n} from '../storage/domains/credentials/base.js';\nimport type { RouteAuth } from './route.js';\n\n/**\n * OAuth credentials are stored under the credential id, which differs from the\n * catalog provider id for OpenAI (`openai-codex`) and Kimi (`kimi-for-coding`).\n * Tenant rows use the same keying so one lookup serves both OAuth tokens and\n * API keys, and match what model resolution reads.\n */\nexport { getCredentialProviderId as getAuthProviderId } from '@mastra/code-sdk/providers/model-ids';\n\n/**\n * Providers that support a browser-driven OAuth sign-in flow, keyed by\n * *catalog* provider id (what the routes and settings UI use). All flows need\n * no inbound connection to the server: Anthropic uses paste-code PKCE, the\n * rest use RFC 8628-style device codes. `subscription` names the plan the\n * sign-in bills, as shown under a reply and in the composer.\n */\nexport const WEB_OAUTH_PROVIDERS: Readonly<Record<string, { flow: LoginSessionKind; subscription: string }>> = {\n anthropic: { flow: 'paste-code', subscription: 'Claude Pro/Max' },\n openai: { flow: 'device-code', subscription: 'ChatGPT Plus/Pro' },\n 'github-copilot': { flow: 'device-code', subscription: 'GitHub Copilot' },\n xai: { flow: 'device-code', subscription: 'SuperGrok/X Premium+' },\n};\n\nexport function credentialLabel(provider: string, credentialType: CredentialRecord['credential']['type']) {\n return credentialType === 'api_key'\n ? `${providerDisplayName(provider)} API key`\n : WEB_OAUTH_PROVIDERS[provider]?.subscription;\n}\n\nexport type CredentialContext =\n | { mode: 'local' }\n | { mode: 'tenant'; storage: ModelCredentialsStorage; orgId: string; userId: string };\n\n/**\n * The tenant credentials domain, when registered and ready. `undefined` means\n * the factory never ran (no handle threaded in) or the domain's init failed\n * (fail-soft — callers report the feature unavailable instead of crashing).\n */\nexport async function getTenantCredentialsStorage(\n credentials: ModelCredentialsStorage | undefined,\n): Promise<ModelCredentialsStorage | undefined> {\n if (!credentials) return undefined;\n try {\n await credentials.ensureReady();\n } catch {\n return undefined;\n }\n return credentials;\n}\n\n/**\n * Org key for tenant rows. Personal accounts get an org bootstrapped by the\n * auth adapter (`ensureOrg`); if one still isn't present, scope rows under a\n * per-user synthetic org so credentials never become server-global.\n */\nexport function tenantOrgId(tenant: { orgId?: string; userId: string }): string {\n return tenant.orgId ?? factoryUserOrgId({ id: tenant.userId }) ?? `user:${tenant.userId}`;\n}\n\n/**\n * Resolve the credential context for a request, or a ready-to-return error\n * response. Mutating credential routes call this and hard-fail (401/503)\n * when the tenant path is required but unavailable.\n */\nexport async function resolveCredentialContext({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialContext | { response: Response }> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) {\n // When an auth provider is active, credential operations always require a\n // signed-in caller — otherwise one anonymous request could write keys for\n // everyone. Without a provider this is a single-user local server.\n if (auth.enabled()) return { response: c.json({ error: 'unauthorized' }, 401) };\n return { mode: 'local' };\n }\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) {\n return {\n response: c.json(\n {\n error: 'credentials_unavailable',\n message: 'Tenant credential storage is unavailable — the app database is not configured or failed to start.',\n },\n 503,\n ),\n };\n }\n return { mode: 'tenant', storage, orgId: tenantOrgId(tenant), userId: tenant.userId };\n}\n\n/**\n * List the caller's tenant credential records for provider listing, or\n * `undefined` in local mode (caller should fall back to `AuthStorage`).\n * Read-only and degradation-friendly: an authenticated caller with the domain\n * unavailable gets an empty list (sources show `env`/`none`) instead of a 503\n * so the settings page still renders.\n */\nexport async function listTenantCredentialsForRequest({\n c,\n auth,\n credentials,\n}: {\n c: Context;\n auth: RouteAuth;\n /** Tenant credential domain handle; absent in local (no-DB) mode. */\n credentials?: ModelCredentialsStorage;\n}): Promise<CredentialRecord[] | undefined> {\n await auth.ensureUser(c);\n const tenant = auth.tenant(c);\n if (!tenant) return auth.enabled() ? [] : undefined;\n const storage = await getTenantCredentialsStorage(credentials);\n if (!storage) return [];\n return storage.listCredentials(tenantOrgId(tenant), tenant.userId);\n}\n"],"mappings":";;;;;;;;;;;AA0CA,MAAa,sBAAkG;CAC7G,WAAW;EAAE,MAAM;EAAc,cAAc;CAAiB;CAChE,QAAQ;EAAE,MAAM;EAAe,cAAc;CAAmB;CAChE,kBAAkB;EAAE,MAAM;EAAe,cAAc;CAAiB;CACxE,KAAK;EAAE,MAAM;EAAe,cAAc;CAAuB;AACnE;AAEA,SAAgB,gBAAgB,UAAkB,gBAAwD;CACxG,OAAO,mBAAmB,YACtB,GAAG,oBAAoB,QAAQ,EAAE,YACjC,oBAAoB,SAAS,EAAE;AACrC;;;;;;AAWA,eAAsB,4BACpB,aAC8C;CAC9C,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,IAAI;EACF,MAAM,YAAY,YAAY;CAChC,QAAQ;EACN;CACF;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAoD;CAC9E,OAAO,OAAO,SAAS,iBAAiB,EAAE,IAAI,OAAO,OAAO,CAAC,KAAK,QAAQ,OAAO;AACnF;;;;;;AAOA,eAAsB,yBAAyB,EAC7C,GACA,MACA,eAMsD;CACtD,MAAM,KAAK,WAAW,CAAC;CACvB,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5B,IAAI,CAAC,QAAQ;EAIX,IAAI,KAAK,QAAQ,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,eAAe,GAAG,GAAG,EAAE;EAC9E,OAAO,EAAE,MAAM,QAAQ;CACzB;CACA,MAAM,UAAU,MAAM,4BAA4B,WAAW;CAC7D,IAAI,CAAC,SACH,OAAO,EACL,UAAU,EAAE,KACV;EACE,OAAO;EACP,SAAS;CACX,GACA,GACF,EACF;CAEF,OAAO;EAAE,MAAM;EAAU;EAAS,OAAO,YAAY,MAAM;EAAG,QAAQ,OAAO;CAAO;AACtF;;;;;;;;AASA,eAAsB,gCAAgC,EACpD,GACA,MACA,eAM0C;CAC1C,MAAM,KAAK,WAAW,CAAC;CACvB,MAAM,SAAS,KAAK,OAAO,CAAC;CAC5B,IAAI,CAAC,QAAQ,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAA;CAC1C,MAAM,UAAU,MAAM,4BAA4B,WAAW;CAC7D,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,OAAO,QAAQ,gBAAgB,YAAY,MAAM,GAAG,OAAO,MAAM;AACnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch-errors.d.ts","sourceRoot":"","sources":["../../src/rules/dispatch-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,uCAAuC,CAAC;AAE/C,UAAU,8BAA8B;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AA2BD,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,0BAA0B;gBAAhC,IAAI,EAAE,0BAA0B,EACzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAErF;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gCAAgC,GAAG,IAAI,GAC5C,8BAA8B,CAEhC"}
1
+ {"version":3,"file":"dispatch-errors.d.ts","sourceRoot":"","sources":["../../src/rules/dispatch-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,uCAAuC,CAAC;AAE/C,UAAU,8BAA8B;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AA+BD,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,0BAA0B;gBAAhC,IAAI,EAAE,0BAA0B,EACzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAErF;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gCAAgC,GAAG,IAAI,GAC5C,8BAA8B,CAEhC"}
@@ -72,6 +72,18 @@ const FAILURE_METADATA = {
72
72
  canRetry: false,
73
73
  label: "Run configuration rejected by provider"
74
74
  },
75
+ run_credentials_unavailable: {
76
+ canRetry: true,
77
+ label: "Model credentials unavailable for the run"
78
+ },
79
+ run_user_unauthenticated: {
80
+ canRetry: false,
81
+ label: "Run started without an authenticated user"
82
+ },
83
+ run_failed: {
84
+ canRetry: true,
85
+ label: "Agent run ended in error"
86
+ },
75
87
  unknown: {
76
88
  canRetry: true,
77
89
  label: "Factory automation failed"
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch-errors.js","names":[],"sources":["../../src/rules/dispatch-errors.ts"],"sourcesContent":["import type {\n FactoryDispatchFailureCode,\n StoredFactoryDispatchFailureCode,\n} from '../storage/domains/work-items/base.js';\n\ninterface FactoryDispatchFailureMetadata {\n canRetry: boolean;\n label: string;\n}\n\nconst FAILURE_METADATA = {\n session_unavailable: { canRetry: true, label: 'Factory session unavailable' },\n source_control_missing: { canRetry: true, label: 'Source-control connection unavailable' },\n source_repository_missing: { canRetry: true, label: 'Source repository unavailable' },\n source_repository_ambiguous: { canRetry: true, label: 'Choose a repository for this work item' },\n unsupported_provider_item: { canRetry: false, label: 'Unsupported provider work item' },\n notification_delivery_failed: { canRetry: true, label: 'Factory message delivery failed' },\n run_terminal_event_missing: { canRetry: false, label: 'Agent run terminal event was not observed' },\n skill_delivery_ambiguous: { canRetry: false, label: 'Factory skill delivery could not be confirmed' },\n run_overdue: { canRetry: false, label: 'Agent run is overdue' },\n repository_git_missing: { canRetry: false, label: 'Git is unavailable in the workspace' },\n repository_egress_blocked: { canRetry: false, label: 'Repository network access is blocked' },\n repository_clone_failed: { canRetry: true, label: 'Repository clone failed' },\n repository_pull_failed: { canRetry: true, label: 'Repository update failed' },\n repository_push_failed: { canRetry: true, label: 'Repository push failed' },\n repository_commit_failed: { canRetry: true, label: 'Repository commit failed' },\n repository_cli_missing: { canRetry: false, label: 'GitHub CLI is unavailable in the workspace' },\n repository_pr_failed: { canRetry: true, label: 'Pull request creation failed' },\n run_configuration_invalid: { canRetry: false, label: 'Run configuration rejected by provider' },\n unknown: { canRetry: true, label: 'Factory automation failed' },\n // Retired: no path writes these any more, stored rows still read through here.\n plan_awaiting_approval: { canRetry: false, label: 'Plan waiting for review' },\n run_awaiting_input: { canRetry: false, label: 'Agent is waiting for an answer' },\n} satisfies Record<StoredFactoryDispatchFailureCode, FactoryDispatchFailureMetadata>;\n\nexport class FactoryDispatchError extends Error {\n constructor(\n readonly code: FactoryDispatchFailureCode,\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = 'FactoryDispatchError';\n }\n}\n\nexport function factoryDispatchFailureCode(error: unknown): FactoryDispatchFailureCode {\n return error instanceof FactoryDispatchError ? error.code : 'unknown';\n}\n\nexport function factoryDispatchFailureMetadata(\n code: StoredFactoryDispatchFailureCode | null,\n): FactoryDispatchFailureMetadata {\n return code === null ? FAILURE_METADATA.unknown : FAILURE_METADATA[code];\n}\n"],"mappings":";AAUA,MAAM,mBAAmB;CACvB,qBAAqB;EAAE,UAAU;EAAM,OAAO;CAA8B;CAC5E,wBAAwB;EAAE,UAAU;EAAM,OAAO;CAAwC;CACzF,2BAA2B;EAAE,UAAU;EAAM,OAAO;CAAgC;CACpF,6BAA6B;EAAE,UAAU;EAAM,OAAO;CAAyC;CAC/F,2BAA2B;EAAE,UAAU;EAAO,OAAO;CAAiC;CACtF,8BAA8B;EAAE,UAAU;EAAM,OAAO;CAAkC;CACzF,4BAA4B;EAAE,UAAU;EAAO,OAAO;CAA4C;CAClG,0BAA0B;EAAE,UAAU;EAAO,OAAO;CAAgD;CACpG,aAAa;EAAE,UAAU;EAAO,OAAO;CAAuB;CAC9D,wBAAwB;EAAE,UAAU;EAAO,OAAO;CAAsC;CACxF,2BAA2B;EAAE,UAAU;EAAO,OAAO;CAAuC;CAC5F,yBAAyB;EAAE,UAAU;EAAM,OAAO;CAA0B;CAC5E,wBAAwB;EAAE,UAAU;EAAM,OAAO;CAA2B;CAC5E,wBAAwB;EAAE,UAAU;EAAM,OAAO;CAAyB;CAC1E,0BAA0B;EAAE,UAAU;EAAM,OAAO;CAA2B;CAC9E,wBAAwB;EAAE,UAAU;EAAO,OAAO;CAA6C;CAC/F,sBAAsB;EAAE,UAAU;EAAM,OAAO;CAA+B;CAC9E,2BAA2B;EAAE,UAAU;EAAO,OAAO;CAAyC;CAC9F,SAAS;EAAE,UAAU;EAAM,OAAO;CAA4B;CAE9D,wBAAwB;EAAE,UAAU;EAAO,OAAO;CAA0B;CAC5E,oBAAoB;EAAE,UAAU;EAAO,OAAO;CAAiC;AACjF;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAEnC;CADX,YACE,MACA,SACA,SACA;EACA,MAAM,SAAS,OAAO;EAJb,KAAA,OAAA;EAKT,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,2BAA2B,OAA4C;CACrF,OAAO,iBAAiB,uBAAuB,MAAM,OAAO;AAC9D;AAEA,SAAgB,+BACd,MACgC;CAChC,OAAO,SAAS,OAAO,iBAAiB,UAAU,iBAAiB;AACrE"}
1
+ {"version":3,"file":"dispatch-errors.js","names":[],"sources":["../../src/rules/dispatch-errors.ts"],"sourcesContent":["import type {\n FactoryDispatchFailureCode,\n StoredFactoryDispatchFailureCode,\n} from '../storage/domains/work-items/base.js';\n\ninterface FactoryDispatchFailureMetadata {\n canRetry: boolean;\n label: string;\n}\n\nconst FAILURE_METADATA = {\n session_unavailable: { canRetry: true, label: 'Factory session unavailable' },\n source_control_missing: { canRetry: true, label: 'Source-control connection unavailable' },\n source_repository_missing: { canRetry: true, label: 'Source repository unavailable' },\n source_repository_ambiguous: { canRetry: true, label: 'Choose a repository for this work item' },\n unsupported_provider_item: { canRetry: false, label: 'Unsupported provider work item' },\n notification_delivery_failed: { canRetry: true, label: 'Factory message delivery failed' },\n run_terminal_event_missing: { canRetry: false, label: 'Agent run terminal event was not observed' },\n skill_delivery_ambiguous: { canRetry: false, label: 'Factory skill delivery could not be confirmed' },\n run_overdue: { canRetry: false, label: 'Agent run is overdue' },\n repository_git_missing: { canRetry: false, label: 'Git is unavailable in the workspace' },\n repository_egress_blocked: { canRetry: false, label: 'Repository network access is blocked' },\n repository_clone_failed: { canRetry: true, label: 'Repository clone failed' },\n repository_pull_failed: { canRetry: true, label: 'Repository update failed' },\n repository_push_failed: { canRetry: true, label: 'Repository push failed' },\n repository_commit_failed: { canRetry: true, label: 'Repository commit failed' },\n repository_cli_missing: { canRetry: false, label: 'GitHub CLI is unavailable in the workspace' },\n repository_pr_failed: { canRetry: true, label: 'Pull request creation failed' },\n run_configuration_invalid: { canRetry: false, label: 'Run configuration rejected by provider' },\n run_credentials_unavailable: { canRetry: true, label: 'Model credentials unavailable for the run' },\n // The run's request carries no user, so every retry fails the same way; a person has to start it.\n run_user_unauthenticated: { canRetry: false, label: 'Run started without an authenticated user' },\n run_failed: { canRetry: true, label: 'Agent run ended in error' },\n unknown: { canRetry: true, label: 'Factory automation failed' },\n // Retired: no path writes these any more, stored rows still read through here.\n plan_awaiting_approval: { canRetry: false, label: 'Plan waiting for review' },\n run_awaiting_input: { canRetry: false, label: 'Agent is waiting for an answer' },\n} satisfies Record<StoredFactoryDispatchFailureCode, FactoryDispatchFailureMetadata>;\n\nexport class FactoryDispatchError extends Error {\n constructor(\n readonly code: FactoryDispatchFailureCode,\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = 'FactoryDispatchError';\n }\n}\n\nexport function factoryDispatchFailureCode(error: unknown): FactoryDispatchFailureCode {\n return error instanceof FactoryDispatchError ? error.code : 'unknown';\n}\n\nexport function factoryDispatchFailureMetadata(\n code: StoredFacto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YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,qBAAqB,EAAE;QAAE,IAAI,EAAE,qBAAqB,CAAA;KAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnH,6BAA6B,CAAC,EAAE,CAAC,KAAK,EAAE;QACtC,KAAK,EAAE,MAAM,CAAC;QACd,gBAAgB,EAAE,MAAM,CAAC;QACzB,QAAQ,EAAE,OAAO,CAAC,qBAAqB,EAAE;YAAE,IAAI,EAAE,sBAAsB,CAAA;SAAE,CAAC,CAAC;KAC5E,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,mCAAmC,CAAC,EAAE,MAAM,CAAC;CAC9C;AA+JD,qBAAa,yBAAyB;;gBAkCxB,OAAO,EAAE,gCAAgC;IA8BrD,KAAK,IAAI,IAAI;IAOP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrB,OAAO,CAAC,GAAG,OAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAyqC/C;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;CAY7B,CAAC"}
@@ -37,7 +37,28 @@ const RECONCILE_INTERVAL_MS = 3e4;
37
37
  /** The card moved on before this run could act; it settles as superseded, not succeeded. */
38
38
  var FactoryDecisionSuperseded = class extends Error {};
39
39
  /** A run that ran and ended in error; the session's own listener reports it to followers. */
40
- var RunEndedInError = class extends Error {};
40
+ var RunEndedInError = class extends FactoryDispatchError {};
41
+ const CREDENTIAL_RESOLUTION_FAILURE = "tenant model credential policy could not be resolved";
42
+ const NO_AUTHENTICATED_USER = "the request has no authenticated user";
43
+ function httpStatus(error) {
44
+ if (!error || typeof error !== "object") return void 0;
45
+ if ("statusCode" in error && typeof error.statusCode === "number") return error.statusCode;
46
+ return "status" in error && typeof error.status === "number" ? error.status : void 0;
47
+ }
48
+ function causeOf(error) {
49
+ return error && typeof error === "object" && "cause" in error ? error.cause : void 0;
50
+ }
51
+ function runErrorCode(error, message) {
52
+ const lower = message.toLowerCase();
53
+ if (lower.includes(CREDENTIAL_RESOLUTION_FAILURE)) return lower.includes(NO_AUTHENTICATED_USER) ? "run_user_unauthenticated" : "run_credentials_unavailable";
54
+ const status = httpStatus(error) ?? httpStatus(causeOf(error));
55
+ return status === 401 || status === 403 ? "run_credentials_unavailable" : "run_failed";
56
+ }
57
+ function runErrorFailure(label, error) {
58
+ const cause = (error instanceof Error ? error.message : String(error ?? "")).trim();
59
+ if (!cause) return new RunEndedInError("run_failed", `${label} ended in error.`);
60
+ return new RunEndedInError(runErrorCode(error, cause), `${label} ended in error: ${cause}`);
61
+ }
41
62
  function isTerminalFailure(attempts, failureCode) {
42
63
  return attempts >= MAX_ATTEMPTS || !factoryDispatchFailureMetadata(failureCode).canRetry;
43
64
  }
@@ -59,10 +80,12 @@ function watchRun(session, { timeoutMs, approvePlans, onAgentEnd, label, runStil
59
80
  let supersededAtEnd;
60
81
  let parked;
61
82
  let omFailure;
83
+ let runError;
62
84
  const arm = () => {
63
85
  endReason = void 0;
64
86
  supersededAtEnd = void 0;
65
87
  omFailure = void 0;
88
+ runError = void 0;
66
89
  agentEnd = new Promise((resolve) => {
67
90
  resolveAgentEnd = resolve;
68
91
  });
@@ -75,6 +98,10 @@ function watchRun(session, { timeoutMs, approvePlans, onAgentEnd, label, runStil
75
98
  resolveAgentEnd();
76
99
  return;
77
100
  }
101
+ if (event.type === "error") {
102
+ runError = event.error;
103
+ return;
104
+ }
78
105
  if (event.type === "om_observation_failed" || event.type === "om_buffering_failed") {
79
106
  if (event.error) omFailure = event.error;
80
107
  return;
@@ -119,7 +146,7 @@ function watchRun(session, { timeoutMs, approvePlans, onAgentEnd, label, runStil
119
146
  observed = await wait();
120
147
  }
121
148
  if (!observed) throw new FactoryDispatchError("run_terminal_event_missing", `${label} terminal event was not observed before timeout.`);
122
- if (endReason === "error") throw new RunEndedInError(`${label} ended in error.`);
149
+ if (endReason === "error") throw runErrorFailure(label, runError);
123
150
  if (endReason === "aborted") {
124
151
  if (omFailure) {
125
152
  if (isPermanentProviderRejection(omFailure)) throw new FactoryDispatchError("run_configuration_invalid", `${label} was aborted by an observational-memory failure that will not succeed on retry: ${omFailure}`);
@@ -164,8 +191,20 @@ function factoryRequestContext(input) {
164
191
  function positiveMs(value, fallback) {
165
192
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
166
193
  }
194
+ const KEY_SHAPED_TOKEN = /\b(?:sk-[A-Za-z0-9_-]{3,}|gh[pousr]_[A-Za-z0-9]{10,}|github_pat_[A-Za-z0-9_]{10,}|xox[abprs]-[A-Za-z0-9-]{10,})/g;
195
+ function looksLikeSecret(token) {
196
+ return /[A-Z]/.test(token) && /[a-z]/.test(token) && /\d/.test(token) && /[A-Za-z0-9]{16,}/.test(token);
197
+ }
198
+ function redactSecretRun(token) {
199
+ if (looksLikeSecret(token) && !token.split("/").some((piece) => /^[A-Za-z][a-z]+$/.test(piece))) return "[redacted]";
200
+ return token.replace(/[A-Za-z0-9_+=-]{24,}/g, (piece) => looksLikeSecret(piece) || isGroupedKey(piece) ? "[redacted]" : piece);
201
+ }
202
+ function isGroupedKey(token) {
203
+ const groups = token.split(/[-_]/);
204
+ return groups.length >= 4 && groups.every((group) => /[A-Z]/.test(group) && /[a-z]/.test(group) && /\d/.test(group));
205
+ }
167
206
  function sanitizeDispatchError(error) {
168
- return (error instanceof Error ? error.message : String(error)).replace(/\b(?:bearer|token|api[-_ ]?key|authorization)\s*[:=]?\s*[^\s,;]+/gi, "[redacted]").slice(0, MAX_ERROR_LENGTH);
207
+ return (error instanceof Error ? error.message : String(error)).replace(KEY_SHAPED_TOKEN, "[redacted]").replace(/\b[A-Za-z0-9_+=/-]{24,}/g, redactSecretRun).replace(/\b(?:bearer|token|api[-_ ]?key|authorization)\s*[:=]?\s*(?:bearer\s+)?[^\s,;]+/gi, "[redacted]").slice(0, MAX_ERROR_LENGTH);
169
208
  }
170
209
  function retryAt(now, attempts) {
171
210
  return new Date(now.getTime() + Math.min(1e3 * 2 ** Math.max(0, attempts - 1), MAX_BACKOFF_MS));