@desplega.ai/agent-swarm 1.155.1 → 1.156.0

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 (107) hide show
  1. package/dist/{acp-adapter-fqsedz9y.js → acp-adapter-c1msptrw.js} +1 -1
  2. package/dist/{actions-by3qdvvk.js → actions-wd41qtdc.js} +19 -18
  3. package/dist/{app-99hz4k80.js → app-tz2qrnah.js} +7 -6
  4. package/dist/{assistant-18hve126.js → assistant-c3q1zj2t.js} +20 -19
  5. package/dist/{boot-reembed-zm7dmkqt.js → boot-reembed-0be1krkm.js} +9 -8
  6. package/dist/{boot-reembed-gv4gkq87.js → boot-reembed-r00j03f3.js} +8 -7
  7. package/dist/{boot-scrub-logs-f42mskp2.js → boot-scrub-logs-9j4hd0vw.js} +6 -5
  8. package/dist/{claude-adapter-thxafssy.js → claude-adapter-112w28qc.js} +11 -10
  9. package/dist/{claude-managed-setup-7da6qnmx.js → claude-managed-setup-60g8aazx.js} +2 -1
  10. package/dist/{claude-sdk-session-ww42x2t2.js → claude-sdk-session-k7pb5kfz.js} +11 -10
  11. package/dist/{cli-nw6z69ye.js → cli-005pze6s.js} +1 -1
  12. package/dist/{cli-967j85jf.js → cli-08n8jxcw.js} +2 -2
  13. package/dist/{cli-60cwjbsn.js → cli-24w39x6n.js} +175 -24
  14. package/dist/{cli-bg3d9v8z.js → cli-28wkjpdp.js} +2 -2
  15. package/dist/{cli-6265kmdz.js → cli-3gmcwfyx.js} +1 -1
  16. package/dist/{cli-k85m894w.js → cli-7j2098n5.js} +2 -2
  17. package/dist/{cli-vnyd306v.js → cli-7pgcpcrg.js} +1 -1
  18. package/dist/{cli-h4jrts5n.js → cli-7vj52450.js} +139 -57
  19. package/dist/{cli-gy9ctpmm.js → cli-865swy5p.js} +1 -1
  20. package/dist/{cli-66k89bhx.js → cli-90x9ewbz.js} +1 -1
  21. package/dist/{cli-pbsk349d.js → cli-9pyah9c4.js} +82 -29
  22. package/dist/{cli-p2hxs01b.js → cli-9w4ex8vh.js} +2 -2
  23. package/dist/{cli-03jn5306.js → cli-b05d7szr.js} +5 -5
  24. package/dist/cli-cqt19wg6.js +92 -0
  25. package/dist/{cli-1msp3k1h.js → cli-cw9zck8j.js} +1 -1
  26. package/dist/{cli-dnpg5yrw.js → cli-ggm92wcn.js} +4 -4
  27. package/dist/{cli-fb79s4p1.js → cli-h0wdadsx.js} +2 -0
  28. package/dist/{cli-rqbvtc1v.js → cli-hc2fkhdv.js} +2 -2
  29. package/dist/{cli-82w25rb4.js → cli-jk26c1sz.js} +1 -1
  30. package/dist/{cli-x3xn5y1p.js → cli-mx3bzbv8.js} +4 -4
  31. package/dist/{cli-cbm9ftfn.js → cli-n6zq3kbd.js} +1 -1
  32. package/dist/{cli-1fypa20m.js → cli-nbp6m6gp.js} +2 -2
  33. package/dist/{cli-kz0xtztz.js → cli-nyqza443.js} +4 -4
  34. package/dist/{cli-vdd537x3.js → cli-s8hpxeg4.js} +3 -3
  35. package/dist/{cli-79vvw6e7.js → cli-szcyv1mm.js} +1 -1
  36. package/dist/{cli-j1gcxf46.js → cli-t1cd3mhp.js} +1 -1
  37. package/dist/{cli-6rgnj7rs.js → cli-tjmghmm5.js} +1 -1
  38. package/dist/{cli-jmbz691m.js → cli-tp0d7vzb.js} +5 -5
  39. package/dist/{cli-czbmash2.js → cli-tt9k8r35.js} +1 -1
  40. package/dist/{cli-ntqdjgtp.js → cli-vhjwh6cz.js} +13 -1
  41. package/dist/{cli-gwha4avb.js → cli-xa4j64zh.js} +6 -6
  42. package/dist/{cli-2gjxfg9n.js → cli-y8bfxjtw.js} +21 -20
  43. package/dist/{cli-dnp8dq8y.js → cli-y95wp3tg.js} +1 -1
  44. package/dist/cli.js +14 -14
  45. package/dist/{codex-adapter-3b6r5n1c.js → codex-adapter-g4tj1f2g.js} +6 -5
  46. package/dist/{codex-hook-afd466wk.js → codex-hook-9hptmdhj.js} +2 -2
  47. package/dist/{codex-login-8rwg7vdn.js → codex-login-x3jk4etn.js} +2 -1
  48. package/dist/{codex-session-runner-1eepz35q.js → codex-session-runner-ad8ha7zt.js} +6 -5
  49. package/dist/{commands-3ryb64pj.js → commands-z3gd8ppc.js} +6 -5
  50. package/dist/{db-efjt4fwn.js → db-bezm97r9.js} +18 -5
  51. package/dist/{dispatcher-8vmkfxsh.js → dispatcher-a97hc33y.js} +18 -17
  52. package/dist/{dsh-adapter-k0twh6xp.js → dsh-adapter-1dwg97zv.js} +2 -2
  53. package/dist/{handlers-n1p7kpt3.js → handlers-wtdy1x02.js} +21 -20
  54. package/dist/{hook-frca1cmv.js → hook-7edgmzng.js} +9 -8
  55. package/dist/{hook-13hfpvqx.js → hook-fvs58a5b.js} +10 -9
  56. package/dist/{http-czpm03y6.js → http-phnf93hp.js} +197 -55
  57. package/dist/{index-jxsk850z.js → index-1fktvwxc.js} +13 -12
  58. package/dist/{index-mfqv15hj.js → index-50jxgw0d.js} +18 -17
  59. package/dist/{index-cbrwzzq1.js → index-7jwk7nsm.js} +19 -18
  60. package/dist/{index-2mw4vc58.js → index-7x131mmf.js} +18 -17
  61. package/dist/{index-ayydfsax.js → index-yp8rasxk.js} +8 -7
  62. package/dist/{keepalive-qxpq5wqz.js → keepalive-nnz07ebd.js} +8 -7
  63. package/dist/{lead-ybh9mf8g.js → lead-mg7qcgww.js} +27 -26
  64. package/dist/{maintenance-z5xb15gt.js → maintenance-ywmnqrpx.js} +9 -8
  65. package/dist/{oauth-refresh-sweep-k89c5081.js → oauth-refresh-sweep-c63sqfs1.js} +7 -6
  66. package/dist/{onboard-hw2agvbp.js → onboard-2zj8sqkq.js} +2 -2
  67. package/dist/{otel-impl-fwfz8r5y.js → otel-impl-jgdfm26f.js} +1 -1
  68. package/dist/{pi-mono-adapter-bn004cee.js → pi-mono-adapter-2b7mw16r.js} +4 -3
  69. package/dist/{pricing-refresh-y978f0jw.js → pricing-refresh-3whntb69.js} +8 -7
  70. package/dist/{rbac-roles-r4gb80zd.js → rbac-roles-3zptcc3p.js} +6 -5
  71. package/dist/{rbac-roles-sp257r0x.js → rbac-roles-3zw68x72.js} +7 -6
  72. package/dist/{render-v2-gzx9dkx8.js → render-v2-dbvpyysc.js} +17 -6
  73. package/dist/{seed-pricing-59s5cqw7.js → seed-pricing-ncgxz1r2.js} +7 -6
  74. package/dist/{setup-hj6wr8rt.js → setup-qwx0j8z9.js} +2 -2
  75. package/dist/{work-objects-pxkkejb4.js → work-objects-sjbcmvep.js} +21 -20
  76. package/dist/{worker-yw7xsr4n.js → worker-xezqdkb7.js} +27 -26
  77. package/openapi.json +291 -4
  78. package/package.json +1 -1
  79. package/src/be/db.ts +318 -19
  80. package/src/be/migrations/162_slack_outcome_delivery_abandon.sql +14 -0
  81. package/src/be/migrations/164_usage_cover_index_and_key_plans.sql +22 -0
  82. package/src/commands/runner.ts +1 -0
  83. package/src/http/api-keys.ts +116 -3
  84. package/src/http/session-data.ts +34 -4
  85. package/src/http/usage-cache.ts +32 -0
  86. package/src/prompts/session-templates.ts +4 -4
  87. package/src/providers/codex-oauth/auth-json.ts +4 -1
  88. package/src/providers/codex-oauth/flow.ts +7 -0
  89. package/src/scheduler/deferred-task-waits.ts +41 -6
  90. package/src/slack/render-v2.ts +228 -71
  91. package/src/tasks/worker-follow-up.ts +73 -0
  92. package/src/tests/base-prompt.test.ts +12 -5
  93. package/src/tests/codex-oauth.test.ts +31 -0
  94. package/src/tests/db-task-read-contract.test.ts +8 -0
  95. package/src/tests/db-task-write-contract.test.ts +8 -0
  96. package/src/tests/deferred-wake-follow-up.test.ts +199 -0
  97. package/src/tests/docs-index-footprint.test.js +3 -3
  98. package/src/tests/entrypoint-acp-target-binary.test.ts +341 -0
  99. package/src/tests/script-connections.test.ts +3 -0
  100. package/src/tests/session-costs.test.ts +113 -0
  101. package/src/tests/slack-render-v2.test.ts +475 -2
  102. package/src/tools/defer-task.ts +1 -1
  103. package/src/tools/store-progress.ts +1 -1
  104. package/src/types.ts +4 -0
  105. package/src/utils/credentials.ts +2 -0
  106. package/src/utils/subscription-plans.ts +138 -0
  107. package/templates/skills/scheduling/content.md +1 -1
@@ -17,7 +17,7 @@ import {
17
17
  normalizeAssetKey,
18
18
  parseAssetKey,
19
19
  parseModelTier
20
- } from "./cli-fb79s4p1.js";
20
+ } from "./cli-h0wdadsx.js";
21
21
  import {
22
22
  IdentityFieldBudgetError,
23
23
  checkIdentityFieldBudget,
@@ -30,7 +30,7 @@ import {
30
30
  init_templates,
31
31
  matchesDefaultClaudeMd,
32
32
  matchesDefaultIdentityMd
33
- } from "./cli-6265kmdz.js";
33
+ } from "./cli-3gmcwfyx.js";
34
34
  import {
35
35
  configureDbResolver,
36
36
  getAllTemplateDefinitions,
@@ -40,7 +40,7 @@ import {
40
40
  init_steering_enabled,
41
41
  isSteeringEnabled,
42
42
  registerTemplate
43
- } from "./cli-dnpg5yrw.js";
43
+ } from "./cli-ggm92wcn.js";
44
44
  import {
45
45
  deriveProviderFromKeyType,
46
46
  init_credentials
@@ -53,6 +53,11 @@ import {
53
53
  activeModelBlock,
54
54
  init_model_rate_limit_windows
55
55
  } from "./cli-de1396j2.js";
56
+ import {
57
+ SUBSCRIPTION_KEY_TYPES,
58
+ estimateClaudePlan,
59
+ init_subscription_plans
60
+ } from "./cli-cqt19wg6.js";
56
61
  import {
57
62
  init_env_flag,
58
63
  isEnvFlagEnabled
@@ -72,7 +77,7 @@ import {
72
77
  import {
73
78
  init_package,
74
79
  package_default
75
- } from "./cli-gy9ctpmm.js";
80
+ } from "./cli-865swy5p.js";
76
81
  import {
77
82
  init_secret_scrubber,
78
83
  registerVolatileSecret,
@@ -4607,6 +4612,7 @@ __export(exports_db, {
4607
4612
  SKILL_FILE_LIMITS: () => SKILL_FILE_LIMITS,
4608
4613
  UNATTRIBUTED_USER_ID: () => UNATTRIBUTED_USER_ID,
4609
4614
  __resetSqliteVecExtensionPathCacheForTests: () => __resetSqliteVecExtensionPathCacheForTests,
4615
+ abandonSlackOutcomeDelivery: () => abandonSlackOutcomeDelivery,
4610
4616
  acceptTask: () => acceptTask,
4611
4617
  assignUnassignedTaskPending: () => assignUnassignedTaskPending,
4612
4618
  autoEncryptLegacyPlaintextSecrets: () => autoEncryptLegacyPlaintextSecrets,
@@ -4801,6 +4807,7 @@ __export(exports_db, {
4801
4807
  getLogsByAgentId: () => getLogsByAgentId,
4802
4808
  getLogsByEventType: () => getLogsByEventType,
4803
4809
  getLogsByTaskId: () => getLogsByTaskId,
4810
+ getLogsByTaskIdAndEventType: () => getLogsByTaskIdAndEventType,
4804
4811
  getLogsByTaskIdChronological: () => getLogsByTaskIdChronological,
4805
4812
  getMcpServerById: () => getMcpServerById,
4806
4813
  getMcpServerByName: () => getMcpServerByName,
@@ -4901,6 +4908,7 @@ __export(exports_db, {
4901
4908
  getUnassignedTasksCount: () => getUnassignedTasksCount,
4902
4909
  getUnreadInboxMessages: () => getUnreadInboxMessages,
4903
4910
  getUnreadMessages: () => getUnreadMessages,
4911
+ getUsageDataVersion: () => getUsageDataVersion,
4904
4912
  getUserById: () => getUserById,
4905
4913
  getWaitStateById: () => getWaitStateById,
4906
4914
  getWaitStateByStepId: () => getWaitStateByStepId,
@@ -4932,6 +4940,7 @@ __export(exports_db, {
4932
4940
  isExtensionAgent: () => isExtensionAgent,
4933
4941
  isPendingSlackMessage: () => isPendingSlackMessage,
4934
4942
  isPoolAffinityEnforcementEnabled: () => isPoolAffinityEnforcementEnabled,
4943
+ isSettledSlackMessage: () => isSettledSlackMessage,
4935
4944
  isSqliteVecAvailable: () => isSqliteVecAvailable,
4936
4945
  listAgentsWithCredStatusByProvider: () => listAgentsWithCredStatusByProvider,
4937
4946
  listAllMetrics: () => listAllMetrics,
@@ -4975,6 +4984,7 @@ __export(exports_db, {
4975
4984
  moveTaskFromBacklog: () => moveTaskFromBacklog,
4976
4985
  moveTaskToBacklog: () => moveTaskToBacklog,
4977
4986
  normalizeSkillFilePath: () => normalizeSkillFilePath,
4987
+ noteSlackOutcomeDeliveryFailure: () => noteSlackOutcomeDeliveryFailure,
4978
4988
  overwriteTerminalTaskResultText: () => overwriteTerminalTaskResultText,
4979
4989
  pauseTask: () => pauseTask,
4980
4990
  postMessage: () => postMessage,
@@ -5011,6 +5021,7 @@ __export(exports_db, {
5011
5021
  searchSkills: () => searchSkills,
5012
5022
  setAgentHarnessProvider: () => setAgentHarnessProvider,
5013
5023
  setApiKeyName: () => setApiKeyName,
5024
+ setApiKeyPlan: () => setApiKeyPlan,
5014
5025
  setBudgetRefusalFollowUpTaskId: () => setBudgetRefusalFollowUpTaskId,
5015
5026
  setFavorite: () => setFavorite,
5016
5027
  setSlackMessageTracking: () => setSlackMessageTracking,
@@ -5129,6 +5140,9 @@ async function ensureSlackDelegationActivation() {
5129
5140
  function isPendingSlackMessage(record) {
5130
5141
  return record.ts.startsWith(PENDING_SLACK_MESSAGE_TS_PREFIX);
5131
5142
  }
5143
+ function isSettledSlackMessage(record) {
5144
+ return !!record.finalizedAt || !!record.deliveryAbandonedAt;
5145
+ }
5132
5146
  function rowToSlackMessage(row) {
5133
5147
  return {
5134
5148
  id: row.id,
@@ -5144,6 +5158,9 @@ function rowToSlackMessage(row) {
5144
5158
  conclusionKind: row.conclusion_kind ?? undefined,
5145
5159
  deferralResolvedAt: row.deferral_resolved_at ?? undefined,
5146
5160
  deferralAbandonedAt: row.deferral_abandoned_at ?? undefined,
5161
+ deliveryAttempts: row.delivery_attempts,
5162
+ deliveryAbandonedAt: row.delivery_abandoned_at ?? undefined,
5163
+ deliveryLastError: row.delivery_last_error ?? undefined,
5147
5164
  createdAt: row.created_at,
5148
5165
  updatedAt: row.updated_at
5149
5166
  };
@@ -5301,6 +5318,26 @@ async function markSlackDeferralResolved(id, options = {}) {
5301
5318
  const now = new Date().toISOString();
5302
5319
  await getDbClient().run("UPDATE slack_messages SET deferral_resolved_at = ?, deferral_abandoned_at = ? WHERE id = ?", [now, options.abandoned ? now : null, id]);
5303
5320
  }
5321
+ async function noteSlackOutcomeDeliveryFailure(taskId, lastError) {
5322
+ const now = new Date().toISOString();
5323
+ const row = await getDbClient().get(`UPDATE slack_messages SET
5324
+ delivery_attempts = delivery_attempts + 1,
5325
+ delivery_last_error = ?,
5326
+ updated_at = ?
5327
+ WHERE task_id = ? AND kind = 'outcome' AND delivery_abandoned_at IS NULL
5328
+ RETURNING *`, [lastError.slice(0, 500), now, taskId]);
5329
+ return row ? rowToSlackMessage(row) : null;
5330
+ }
5331
+ async function abandonSlackOutcomeDelivery(taskId, lastError) {
5332
+ const now = new Date().toISOString();
5333
+ const row = await getDbClient().get(`UPDATE slack_messages SET
5334
+ delivery_abandoned_at = ?,
5335
+ delivery_last_error = ?,
5336
+ updated_at = ?
5337
+ WHERE task_id = ? AND kind = 'outcome' AND delivery_abandoned_at IS NULL
5338
+ RETURNING *`, [now, lastError.slice(0, 500), now, taskId]);
5339
+ return row ? rowToSlackMessage(row) : null;
5340
+ }
5304
5341
  async function getSlackTreeMessages() {
5305
5342
  const rows = await getDbClient().query(`SELECT tree.*
5306
5343
  FROM slack_messages tree
@@ -5319,7 +5356,7 @@ async function getSlackTreeMessages() {
5319
5356
  SELECT 1 FROM slack_messages outcome
5320
5357
  WHERE outcome.kind = 'outcome'
5321
5358
  AND outcome.task_id = task.id
5322
- AND outcome.finalized_at IS NOT NULL
5359
+ AND (outcome.finalized_at IS NOT NULL OR outcome.delivery_abandoned_at IS NOT NULL)
5323
5360
  )
5324
5361
  )
5325
5362
  OR
@@ -5345,7 +5382,7 @@ async function getSlackTreeMessages() {
5345
5382
  AND outcome.thread_ts = tree.thread_ts
5346
5383
  AND task.createdAt >= state.activated_at
5347
5384
  AND (
5348
- outcome.finalized_at IS NULL
5385
+ (outcome.finalized_at IS NULL AND outcome.delivery_abandoned_at IS NULL)
5349
5386
  OR outcome.updated_at > tree.updated_at
5350
5387
  )
5351
5388
  )
@@ -6123,6 +6160,10 @@ async function getLogsByTaskId(taskId, limit = 200) {
6123
6160
  const rows = await getDbClient().query("SELECT * FROM agent_log WHERE taskId = ? ORDER BY createdAt DESC LIMIT ?", [taskId, limit]);
6124
6161
  return rows.map(rowToAgentLog);
6125
6162
  }
6163
+ async function getLogsByTaskIdAndEventType(taskId, eventType) {
6164
+ const rows = await getDbClient().query("SELECT * FROM agent_log WHERE taskId = ? AND eventType = ? ORDER BY createdAt ASC", [taskId, eventType]);
6165
+ return rows.map(rowToAgentLog);
6166
+ }
6126
6167
  async function getLogsByTaskIdChronological(taskId) {
6127
6168
  const rows = await getDbClient().query("SELECT * FROM agent_log WHERE taskId = ? ORDER BY createdAt ASC", [taskId]);
6128
6169
  return rows.map(rowToAgentLog);
@@ -7632,6 +7673,7 @@ async function getSessionCostsFiltered(opts) {
7632
7673
  }
7633
7674
  async function getSessionCostSummary(opts) {
7634
7675
  const from = "FROM session_costs sc LEFT JOIN agent_tasks t ON t.id = sc.taskId";
7676
+ const fromHf = `${from} LEFT JOIN human_free_tasks hf ON hf.id = t.id`;
7635
7677
  const conditions = [];
7636
7678
  const params = [];
7637
7679
  if (opts.startDate) {
@@ -7653,6 +7695,10 @@ async function getSessionCostSummary(opts) {
7653
7695
  params.push(opts.userId);
7654
7696
  }
7655
7697
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
7698
+ const classify = opts.userId !== undefined;
7699
+ const withHf = classify ? `WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}` : "";
7700
+ const scopedFrom = classify ? fromHf : from;
7701
+ const subscriptionSql = `t.credentialKeyType IN (${SUBSCRIPTION_KEY_TYPES.map((k) => `'${k}'`).join(", ")})`;
7656
7702
  const totalsRow = await getDbClient().get(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
7657
7703
  SELECT
7658
7704
  COALESCE(SUM(sc.totalCostUsd), 0) as totalCostUsd,
@@ -7668,8 +7714,10 @@ async function getSessionCostSummary(opts) {
7668
7714
  THEN sc.totalCostUsd ELSE 0 END), 0) as attributableCostUsd,
7669
7715
  COALESCE(SUM(CASE WHEN ${HUMAN_FREE_SQL}
7670
7716
  THEN sc.totalCostUsd ELSE 0 END), 0) as excludedCostUsd,
7671
- COUNT(DISTINCT CASE WHEN ${HUMAN_FREE_SQL} THEN t.id END) as excludedTaskCount
7672
- ${from} ${where}`, params);
7717
+ COUNT(DISTINCT CASE WHEN ${HUMAN_FREE_SQL} THEN t.id END) as excludedTaskCount,
7718
+ COALESCE(SUM(CASE WHEN ${subscriptionSql}
7719
+ THEN sc.totalCostUsd ELSE 0 END), 0) as subscriptionCostUsd
7720
+ ${fromHf} ${where}`, params);
7673
7721
  const totals = totalsRow ? {
7674
7722
  ...totalsRow,
7675
7723
  avgCostPerSession: totalsRow.totalSessions > 0 ? totalsRow.totalCostUsd / totalsRow.totalSessions : 0
@@ -7685,25 +7733,28 @@ async function getSessionCostSummary(opts) {
7685
7733
  attributedCostUsd: 0,
7686
7734
  attributableCostUsd: 0,
7687
7735
  excludedCostUsd: 0,
7688
- excludedTaskCount: 0
7736
+ excludedTaskCount: 0,
7737
+ subscriptionCostUsd: 0
7689
7738
  };
7690
7739
  const groupBy = opts.groupBy ?? "both";
7691
7740
  let daily = [];
7692
7741
  if (groupBy === "day" || groupBy === "both") {
7693
- daily = await getDbClient().query(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
7742
+ daily = await getDbClient().query(`${withHf}
7694
7743
  SELECT
7695
7744
  DATE(sc.createdAt) as date,
7696
7745
  COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
7697
7746
  COALESCE(SUM(sc.inputTokens), 0) as inputTokens,
7698
7747
  COALESCE(SUM(sc.outputTokens), 0) as outputTokens,
7699
- COUNT(*) as sessions
7700
- ${from} ${where}
7748
+ COUNT(*) as sessions,
7749
+ COALESCE(SUM(CASE WHEN ${subscriptionSql} THEN sc.totalCostUsd ELSE 0 END), 0)
7750
+ as subscriptionCostUsd
7751
+ ${scopedFrom} ${where}
7701
7752
  GROUP BY DATE(sc.createdAt)
7702
7753
  ORDER BY date ASC`, params);
7703
7754
  }
7704
7755
  let byAgent = [];
7705
7756
  if (groupBy === "agent" || groupBy === "both") {
7706
- byAgent = await getDbClient().query(`WITH RECURSIVE ${HUMAN_FREE_TASKS_CTE}
7757
+ byAgent = await getDbClient().query(`${withHf}
7707
7758
  SELECT
7708
7759
  sc.agentId as agentId,
7709
7760
  COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
@@ -7711,7 +7762,7 @@ async function getSessionCostSummary(opts) {
7711
7762
  COALESCE(SUM(sc.outputTokens), 0) as outputTokens,
7712
7763
  COUNT(*) as sessions,
7713
7764
  COALESCE(SUM(sc.durationMs), 0) as durationMs
7714
- ${from} ${where}
7765
+ ${scopedFrom} ${where}
7715
7766
  GROUP BY sc.agentId
7716
7767
  ORDER BY costUsd DESC`, params);
7717
7768
  }
@@ -7725,11 +7776,62 @@ async function getSessionCostSummary(opts) {
7725
7776
  COALESCE(SUM(sc.outputTokens), 0) as outputTokens,
7726
7777
  COUNT(DISTINCT sc.taskId) as tasks,
7727
7778
  COALESCE(SUM(sc.durationMs), 0) as durationMs
7728
- ${from} ${where}
7779
+ ${fromHf} ${where}
7729
7780
  GROUP BY CASE WHEN ${HUMAN_FREE_SQL} THEN NULL ELSE t.requestedByUserId END
7730
7781
  ORDER BY costUsd DESC`, params);
7731
7782
  }
7732
- return { totals, daily, byAgent, byUser };
7783
+ let byCredential = [];
7784
+ if (groupBy === "both") {
7785
+ const rows = await getDbClient().query(`${withHf}
7786
+ SELECT
7787
+ t.credentialKeyType as keyType,
7788
+ t.credentialKeySuffix as keySuffix,
7789
+ COALESCE(SUM(sc.totalCostUsd), 0) as costUsd,
7790
+ COALESCE(SUM(sc.inputTokens), 0) as inputTokens,
7791
+ COALESCE(SUM(sc.outputTokens), 0) as outputTokens,
7792
+ COUNT(*) as sessions,
7793
+ MIN(sc.createdAt) as firstSessionAt,
7794
+ MAX(sc.createdAt) as lastSessionAt
7795
+ ${scopedFrom} ${where}
7796
+ GROUP BY t.credentialKeyType, t.credentialKeySuffix
7797
+ ORDER BY costUsd DESC`, params);
7798
+ const labels = await getCredentialLabels();
7799
+ byCredential = rows.map((row) => {
7800
+ const label = row.keyType && row.keySuffix ? labels.get(credentialKey(row.keyType, row.keySuffix)) : undefined;
7801
+ return {
7802
+ ...row,
7803
+ name: label?.name ?? null,
7804
+ subscription: row.keyType !== null && SUBSCRIPTION_KEY_TYPES.includes(row.keyType),
7805
+ plan: label?.plan ?? null,
7806
+ planSource: label?.planSource ?? null
7807
+ };
7808
+ });
7809
+ }
7810
+ return { totals, daily, byAgent, byUser, byCredential };
7811
+ }
7812
+ function credentialKey(keyType, keySuffix) {
7813
+ return `${keyType}:${keySuffix}`;
7814
+ }
7815
+ async function getCredentialLabels() {
7816
+ const rows = await getDbClient().query(`SELECT keyType, keySuffix, name, plan, planSource FROM api_key_status
7817
+ ORDER BY CASE planSource WHEN 'manual' THEN 0 WHEN 'detected' THEN 1 WHEN 'estimated' THEN 2 ELSE 3 END,
7818
+ updatedAt DESC`);
7819
+ const labels = new Map;
7820
+ for (const row of rows) {
7821
+ const key = credentialKey(row.keyType, row.keySuffix);
7822
+ const seen = labels.get(key);
7823
+ if (!seen) {
7824
+ labels.set(key, { name: row.name, plan: row.plan, planSource: row.planSource });
7825
+ } else if (!seen.name && row.name) {
7826
+ seen.name = row.name;
7827
+ }
7828
+ }
7829
+ return labels;
7830
+ }
7831
+ async function getUsageDataVersion() {
7832
+ const row = await getDbClient().get(`SELECT COALESCE((SELECT MAX(rowid) FROM session_costs), 0) || ':' ||
7833
+ COALESCE((SELECT MAX(rowid) FROM agent_tasks), 0) as version`);
7834
+ return row?.version ?? "0:0";
7733
7835
  }
7734
7836
  async function getAttributionByPerson(opts) {
7735
7837
  const conditions = ["t.requestedByUserId IS NOT NULL"];
@@ -7805,7 +7907,9 @@ async function getAttributionByPerson(opts) {
7805
7907
  LEFT JOIN shipped_roots s ON s.rootId = t.id
7806
7908
  GROUP BY t.requestedByUserId`, params);
7807
7909
  const reachRows = await getDbClient().query(`WITH RECURSIVE report_tasks AS (
7808
- SELECT t.*
7910
+ -- Only the columns read below: a task row carries its full prompt and output.
7911
+ SELECT t.id, t.agentId, t.vcsRepo, t.source, t.parentTaskId, t.requestedByUserId,
7912
+ t.requestedByUserIdInherited, t.taskType, t.tags, t.workflowRunId
7809
7913
  FROM agent_tasks t
7810
7914
  ${where}
7811
7915
  ),
@@ -11088,7 +11192,7 @@ async function getAvailableKeyIndices(keyType, totalKeys, scope = "global", scop
11088
11192
  earliestModelResetAt: earliestModelResetsAtSec !== undefined ? new Date(earliestModelResetsAtSec * 1000).toISOString() : null
11089
11193
  };
11090
11194
  }
11091
- async function recordKeyUsage(keyType, keySuffix, keyIndex, taskId, scope = "global", scopeId = null) {
11195
+ async function recordKeyUsage(keyType, keySuffix, keyIndex, taskId, scope = "global", scopeId = null, plan = null) {
11092
11196
  const now = new Date().toISOString();
11093
11197
  const client = getDbClient();
11094
11198
  const effectiveScopeId = scopeId ?? "";
@@ -11101,9 +11205,27 @@ async function recordKeyUsage(keyType, keySuffix, keyIndex, taskId, scope = "glo
11101
11205
  totalUsageCount = totalUsageCount + 1,
11102
11206
  keyIndex = excluded.keyIndex,
11103
11207
  updatedAt = excluded.updatedAt`, [keyType, keySuffix, keyIndex, scope, effectiveScopeId, now, provider, now]);
11208
+ let planChanged = false;
11209
+ if (plan) {
11210
+ const result = await client.run(`UPDATE api_key_status SET plan = ?, planSource = 'detected'
11211
+ WHERE keyType = ? AND keySuffix = ? AND COALESCE(planSource, '') != 'manual'
11212
+ AND (plan IS NOT ? OR planSource IS NOT 'detected')`, [plan, keyType, keySuffix, plan]);
11213
+ planChanged = result.changes > 0;
11214
+ }
11104
11215
  if (taskId) {
11105
11216
  await client.run("UPDATE agent_tasks SET credentialKeySuffix = ?, credentialKeyType = ? WHERE id = ?", [keySuffix, keyType, taskId]);
11106
11217
  }
11218
+ return { planChanged };
11219
+ }
11220
+ async function setApiKeyPlan(keyType, keySuffix, plan) {
11221
+ const now = new Date().toISOString();
11222
+ const result = plan ? await getDbClient().run(`UPDATE api_key_status SET plan = ?, planSource = 'manual', updatedAt = ?
11223
+ WHERE keyType = ? AND keySuffix = ?`, [plan, now, keyType, keySuffix]) : await getDbClient().run(`UPDATE api_key_status
11224
+ SET plan = CASE WHEN planSource = 'manual' THEN NULL ELSE plan END,
11225
+ planSource = CASE WHEN planSource = 'manual' THEN NULL ELSE planSource END,
11226
+ updatedAt = ?
11227
+ WHERE keyType = ? AND keySuffix = ?`, [now, keyType, keySuffix]);
11228
+ return result.changes > 0;
11107
11229
  }
11108
11230
  async function markKeyRateLimited(keyType, keySuffix, keyIndex, rateLimitedUntil, scope = "global", scopeId = null) {
11109
11231
  const now = new Date().toISOString();
@@ -11135,14 +11257,15 @@ function mergeRateLimitWindowTelemetry(stored, reported) {
11135
11257
  }
11136
11258
  async function recordKeyRateLimitWindows(keyType, keySuffix, keyIndex, windows, scope = "global", scopeId = null) {
11137
11259
  if (Object.keys(windows).length === 0)
11138
- return;
11260
+ return { planChanged: false };
11139
11261
  const now = new Date().toISOString();
11140
11262
  const effectiveScopeId = scopeId ?? "";
11141
11263
  const provider = deriveProviderFromKeyType(keyType);
11142
- await getDbClient().transaction(async (tx) => {
11264
+ const merged = await getDbClient().transaction(async (tx) => {
11143
11265
  const existing = await tx.get(`SELECT rateLimitWindows FROM api_key_status
11144
11266
  WHERE keyType = ? AND keySuffix = ? AND scope = ? AND scopeId = ?`, [keyType, keySuffix, scope, effectiveScopeId]);
11145
- const serialized = JSON.stringify(mergeRateLimitWindowTelemetry(parseRateLimitWindowsJson(existing?.rateLimitWindows), windows));
11267
+ const mergedWindows = mergeRateLimitWindowTelemetry(parseRateLimitWindowsJson(existing?.rateLimitWindows), windows);
11268
+ const serialized = JSON.stringify(mergedWindows);
11146
11269
  await tx.run(`INSERT INTO api_key_status (keyType, keySuffix, keyIndex, scope, scopeId, rateLimitWindows, provider, updatedAt)
11147
11270
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)
11148
11271
  ON CONFLICT(keyType, keySuffix, scope, scopeId)
@@ -11151,7 +11274,33 @@ async function recordKeyRateLimitWindows(keyType, keySuffix, keyIndex, windows,
11151
11274
  keyIndex = excluded.keyIndex,
11152
11275
  provider = excluded.provider,
11153
11276
  updatedAt = excluded.updatedAt`, [keyType, keySuffix, keyIndex, scope, effectiveScopeId, serialized, provider, now]);
11277
+ return mergedWindows;
11154
11278
  });
11279
+ const planChanged = keyType === "CLAUDE_CODE_OAUTH_TOKEN" && await refreshEstimatedClaudePlan(keySuffix, merged);
11280
+ return { planChanged };
11281
+ }
11282
+ async function refreshEstimatedClaudePlan(keySuffix, windows) {
11283
+ const week = windows.seven_day;
11284
+ if (!week?.utilization || !week.resetsAt)
11285
+ return false;
11286
+ const client = getDbClient();
11287
+ const stronger = await client.get(`SELECT 1 as found FROM api_key_status
11288
+ WHERE keyType = 'CLAUDE_CODE_OAUTH_TOKEN' AND keySuffix = ? AND planSource IN ('manual', 'detected')
11289
+ LIMIT 1`, [keySuffix]);
11290
+ if (stronger)
11291
+ return false;
11292
+ const windowStart = new Date((week.resetsAt - WEEK_SECONDS) * 1000).toISOString();
11293
+ const spend = await client.get(`SELECT COALESCE(SUM(sc.totalCostUsd), 0) as spendUsd
11294
+ FROM session_costs sc JOIN agent_tasks t ON t.id = sc.taskId
11295
+ WHERE t.credentialKeyType = 'CLAUDE_CODE_OAUTH_TOKEN' AND t.credentialKeySuffix = ?
11296
+ AND sc.createdAt >= ?`, [keySuffix, windowStart]);
11297
+ const plan = estimateClaudePlan(week.utilization, spend?.spendUsd ?? 0);
11298
+ if (!plan)
11299
+ return false;
11300
+ const result = await client.run(`UPDATE api_key_status SET plan = ?, planSource = 'estimated'
11301
+ WHERE keyType = 'CLAUDE_CODE_OAUTH_TOKEN' AND keySuffix = ?
11302
+ AND COALESCE(planSource, 'estimated') = 'estimated' AND plan IS NOT ?`, [plan, keySuffix, plan]);
11303
+ return result.changes > 0;
11155
11304
  }
11156
11305
  async function setApiKeyName(keyType, keySuffix, name, scope = "global", scopeId = null) {
11157
11306
  const result = await getDbClient().run(`UPDATE api_key_status
@@ -12351,7 +12500,7 @@ END`, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID =
12351
12500
  JOIN human_free_tasks parent ON child.parentTaskId = parent.id
12352
12501
  WHERE child.requestedByUserId IS NULL
12353
12502
  OR child.requestedByUserIdInherited = 1
12354
- )`, HUMAN_FREE_SQL = "EXISTS (SELECT 1 FROM human_free_tasks WHERE id = t.id)", ROOT_HUMAN_FREE_SQL = `(
12503
+ )`, HUMAN_FREE_SQL = "hf.id IS NOT NULL", ROOT_HUMAN_FREE_SQL = `(
12355
12504
  COALESCE(t.taskType, '') IN ('heartbeat', 'heartbeat-checklist', 'boot-triage')
12356
12505
  OR COALESCE(t.tags, '[]') LIKE '%"heartbeat"%'
12357
12506
  OR (COALESCE(t.source, '') = 'schedule' AND t.requestedByUserId IS NULL)
@@ -12366,7 +12515,7 @@ END`, ELIGIBILITY_SCAN_BATCH_SIZE, ELIGIBILITY_SCAN_CAP, UNATTRIBUTED_USER_ID =
12366
12515
  AND run.created_by IS NULL
12367
12516
  )
12368
12517
  )
12369
- )`, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", KvTypeCollisionError;
12518
+ )`, SCHEDULE_TEMPLATE_PREVIEW_LENGTH = 280, RESERVED_CONFIG_PLACEHOLDER = "[reserved key stored in swarm_config; delete this row]", SKILL_FILE_LIMITS, BINARY_SKILL_FILE_PLACEHOLDER = "[binary file - not synced]", SKILL_SLIM_COLUMNS = "id, name, description, type, scope, ownerAgentId, sourceUrl, sourceRepo, sourcePath, sourceBranch, sourceHash, isComplex, allowedTools, model, effort, context, agent, disableModelInvocation, userInvocable, version, isEnabled, systemDefault, createdAt, lastUpdatedAt, lastFetchedAt, '' as content", WEEK_SECONDS, KvTypeCollisionError;
12370
12519
  var init_db = __esm(() => {
12371
12520
  init_package();
12372
12521
  init_key();
@@ -12382,6 +12531,7 @@ var init_db = __esm(() => {
12382
12531
  init_model_rate_limit_windows();
12383
12532
  init_request_auth_context();
12384
12533
  init_secret_scrubber();
12534
+ init_subscription_plans();
12385
12535
  init_asset_key_audit();
12386
12536
  init_crypto();
12387
12537
  init_date_utils();
@@ -12438,6 +12588,7 @@ var init_db = __esm(() => {
12438
12588
  maxTotalBytes: Number(process.env.SKILL_FILES_MAX_TOTAL_BYTES ?? 10 * 1024 * 1024),
12439
12589
  maxFileBytes: Number(process.env.SKILL_FILES_MAX_FILE_BYTES ?? 500 * 1024)
12440
12590
  };
12591
+ WEEK_SECONDS = 7 * 24 * 3600;
12441
12592
  KvTypeCollisionError = class KvTypeCollisionError extends Error {
12442
12593
  existingType;
12443
12594
  constructor(existingType) {
@@ -12448,4 +12599,4 @@ var init_db = __esm(() => {
12448
12599
  };
12449
12600
  });
12450
12601
 
12451
- export { slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, telemetry, emitIntegrationConnected, init_telemetry, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, isInTransaction, init_db_client, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
12602
+ export { slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, _resolveIntegrationType, _resolveIntegrationProvider, initTelemetry, telemetry, emitIntegrationConnected, init_telemetry, HeartbeatExpiryError, init_heartbeat_expiry, beginRequestAuthScope, setRequestAuth, getRequestAuth, getCurrentRequestAuth, runWithoutRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, isInTransaction, init_db_client, getPromptTemplateDefaultDrift, init_default_drift, init_templates2 as init_templates, isSqliteVecAvailable, resolveSqliteVecExtensionPath, __resetSqliteVecExtensionPathCacheForTests, initDb, getDb, closeDb, getDbClient, updateAgentCredentialState, updateAgentCredentialMissing, createAgent, getAgentById, EXTENSION_AGENT_ROLE, NOT_EXTENSION_AGENT_SQL, isExtensionAgent, extensionAgentAssignmentError, ReservedAgentRoleError, reservedRoleViolation, ExtensionAgentAssignmentError, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, getTaskById, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getPendingSlackRelayTasks, markSlackRelayAttempted, markSlackRelayDelivered, markFinalizedSlackRelaysDelivered, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, onTaskStarted, init_task_lifecycle_events, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, updateTaskClaudeSessionId, updateTaskTitle, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, SLACK_REACTION_DEFAULTS, SLACK_REACTION_CONFIG_KEYS, reactionName, init_reaction_shortcode, parseTaskToolManifest, selectTaskTools, init_task_tool_manifest, isInternalConfigKey, internalConfigKeyError, isReservedConfigKey, reservedKeyError, MAX_DB_RETENTION_DAYS, DB_RETENTION_TUNING_BOUNDS, validateConfigValue, init_swarm_config_guard, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, getSlackDelegationActivatedAt, ensureSlackDelegationActivation, isPendingSlackMessage, isSettledSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getResolvableDeferralOutcomes, markSlackDeferralResolved, noteSlackOutcomeDeliveryFailure, abandonSlackOutcomeDelivery, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, updateTaskVcs, insertTaskAttachment, recordTaskPullRequestAttachments, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdAndEventType, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, promoteDraftTask, refreshDraftTaskLease, promoteAbandonedDraftTasks, releaseStaleReviewingTasks, releaseStaleOfferedTasksForOfflineAgents, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getUsageDataVersion, getAttributionByPerson, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, emitBuiltInIntegrationConnectedOnce, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, cancelPendingApprovalRequestsForRun, listCancelledApprovalRequestsForRun, listCancelledApprovalRequestsForStep, claimApprovalCancellationNotification, completeApprovalCancellationNotificationClaim, releaseApprovalCancellationNotificationClaim, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, emitMcpServerConnectedTelemetry, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, setApiKeyPlan, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getReadyAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, claimKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, updateScriptRunIfNotTerminal, updateScriptRunIfRunning, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
@@ -4,11 +4,11 @@ import {
4
4
  getEmbeddingProvider,
5
5
  init_embedding,
6
6
  serializeEmbedding
7
- } from "./cli-967j85jf.js";
7
+ } from "./cli-08n8jxcw.js";
8
8
  import {
9
9
  getDbClient,
10
10
  init_db
11
- } from "./cli-60cwjbsn.js";
11
+ } from "./cli-24w39x6n.js";
12
12
  import {
13
13
  init_secret_scrubber,
14
14
  scrubSecrets
@@ -6,7 +6,7 @@ import {
6
6
  isSteeringEnabled,
7
7
  registerTemplate,
8
8
  resolveTemplateAsync
9
- } from "./cli-dnpg5yrw.js";
9
+ } from "./cli-ggm92wcn.js";
10
10
  import {
11
11
  getSlackConfiguration,
12
12
  init_config
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runStopHookSessionSummarySubprocess
3
- } from "./cli-03jn5306.js";
3
+ } from "./cli-b05d7szr.js";
4
4
  import {
5
5
  fetchInstalledMcpServers
6
6
  } from "./cli-tng3131n.js";
@@ -822,7 +822,7 @@ class ClaudeAdapter {
822
822
  if (transport === "sdk" && isClaudeBridgeEffective(sourceEnv)) {
823
823
  throw new Error("CLAUDE_TRANSPORT=sdk cannot run with an effective Claude Bridge configuration. Select CLI transport or disable the bridge.");
824
824
  }
825
- const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-ww42x2t2.js") : undefined;
825
+ const claudeSdk = transport === "sdk" ? await import("./claude-sdk-session-k7pb5kfz.js") : undefined;
826
826
  claudeSdk?.validateClaudeSdkAdditionalArgs([
827
827
  ...claudeBinaryArgv.slice(1),
828
828
  ...config.additionalArgs ?? []
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_package,
3
3
  package_default
4
- } from "./cli-gy9ctpmm.js";
4
+ } from "./cli-865swy5p.js";
5
5
 
6
6
  // src/commands/shared/client-config.ts
7
7
  init_package();