opencode-swarm 7.98.1 → 7.99.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 (45) hide show
  1. package/README.md +1 -0
  2. package/dist/cli/{config-doctor-7yrxfa6b.js → config-doctor-9fhfy6p7.js} +2 -2
  3. package/dist/cli/{evidence-summary-service-g4x5e3e3.js → evidence-summary-service-4hs44n2c.js} +6 -6
  4. package/dist/cli/{gate-evidence-nphg8hay.js → gate-evidence-ywys9vfs.js} +4 -4
  5. package/dist/cli/guardrail-explain-ktm6szbm.js +30 -0
  6. package/dist/cli/{guardrail-log-53z1cf46.js → guardrail-log-ya49kpwn.js} +3 -3
  7. package/dist/cli/{index-91qtsbce.js → index-3naa2ajc.js} +1 -1
  8. package/dist/cli/{index-attgb1ma.js → index-4pt2py5p.js} +17 -15
  9. package/dist/cli/{index-sf08zj91.js → index-5fxjagjt.js} +2 -2
  10. package/dist/cli/{index-471qxz9g.js → index-7hnwnw5g.js} +11 -1
  11. package/dist/cli/{index-kv4dd5c5.js → index-9b7qp18e.js} +1 -1
  12. package/dist/cli/{index-hb10a2g8.js → index-f7nma02k.js} +2 -2
  13. package/dist/cli/{index-0rgde8qc.js → index-ft4gehk1.js} +2 -2
  14. package/dist/cli/{index-gnd1280x.js → index-h9ptj4b1.js} +1 -1
  15. package/dist/cli/{index-zgba613y.js → index-hw8r3e5p.js} +1108 -792
  16. package/dist/cli/{index-mh1ej70w.js → index-r8f89sm9.js} +2 -2
  17. package/dist/cli/{index-zy22fg5h.js → index-svf2zjxs.js} +5 -1
  18. package/dist/cli/{index-xchgryg4.js → index-vn263hqt.js} +16 -2
  19. package/dist/cli/{index-fjxjb66n.js → index-vwyjkzgs.js} +3 -3
  20. package/dist/cli/{index-gn8n22th.js → index-we94wkty.js} +19 -3
  21. package/dist/cli/{index-4c5jpmn9.js → index-wwnjw0fb.js} +11 -11
  22. package/dist/cli/{index-5z2e78tv.js → index-xsswhy6k.js} +1 -1
  23. package/dist/cli/index.js +13 -13
  24. package/dist/cli/{knowledge-store-pa58msy5.js → knowledge-store-tsa8ezka.js} +4 -4
  25. package/dist/cli/{pending-delegations-shqbvfjc.js → pending-delegations-c785p5n2.js} +3 -3
  26. package/dist/cli/{pr-subscriptions-2565fpsc.js → pr-subscriptions-fqrzm0tv.js} +4 -4
  27. package/dist/cli/{schema-mygkbbe9.js → schema-nz638xc3.js} +5 -1
  28. package/dist/cli/{skill-generator-3tkwcg4x.js → skill-generator-99rrfwae.js} +5 -5
  29. package/dist/cli/{telemetry-aa1ma1dr.js → telemetry-jm7t8031.js} +1 -1
  30. package/dist/commands/close.d.ts +2 -1
  31. package/dist/commands/costs.d.ts +4 -0
  32. package/dist/commands/index.d.ts +1 -0
  33. package/dist/commands/registry.d.ts +9 -2
  34. package/dist/config/evidence-schema.d.ts +44 -44
  35. package/dist/config/index.d.ts +2 -2
  36. package/dist/config/schema.d.ts +24 -0
  37. package/dist/hooks/system-enhancer.d.ts +1 -1
  38. package/dist/hooks/utils.d.ts +3 -1
  39. package/dist/index.js +2978 -2337
  40. package/dist/plan/manager.d.ts +1 -1
  41. package/dist/services/cost-accounting.d.ts +65 -0
  42. package/dist/state.d.ts +3 -3
  43. package/dist/telemetry.d.ts +2 -1
  44. package/package.json +1 -1
  45. package/dist/cli/guardrail-explain-cm08h4mt.js +0 -30
@@ -3,13 +3,13 @@ import {
3
3
  atomicWriteFile,
4
4
  taskEvidencePath,
5
5
  withTaskEvidenceLock
6
- } from "./index-kv4dd5c5.js";
6
+ } from "./index-9b7qp18e.js";
7
7
  import {
8
8
  exports_external
9
9
  } from "./index-293f68mj.js";
10
10
  import {
11
11
  telemetry
12
- } from "./index-xchgryg4.js";
12
+ } from "./index-vn263hqt.js";
13
13
 
14
14
  // src/gate-evidence.ts
15
15
  import { mkdirSync, readFileSync, realpathSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  ALL_AGENT_NAMES,
4
4
  PluginConfigSchema,
5
5
  stripKnownSwarmPrefix
6
- } from "./index-471qxz9g.js";
6
+ } from "./index-7hnwnw5g.js";
7
7
  import {
8
8
  log
9
9
  } from "./index-zgwm4ryv.js";
@@ -599,6 +599,10 @@ function validateConfigKey(path2, value) {
599
599
  emitObjectTypeMismatch("context_budget", value, findings);
600
600
  break;
601
601
  }
602
+ case "pricing": {
603
+ emitObjectTypeMismatch("pricing", value, findings);
604
+ break;
605
+ }
602
606
  case "guardrails": {
603
607
  emitObjectTypeMismatch("guardrails", value, findings);
604
608
  break;
@@ -110,8 +110,22 @@ var telemetry = {
110
110
  delegationBegin(sessionId, agentName, taskId) {
111
111
  _internals.emit("delegation_begin", { sessionId, agentName, taskId });
112
112
  },
113
- delegationEnd(sessionId, agentName, taskId, result) {
114
- _internals.emit("delegation_end", { sessionId, agentName, taskId, result });
113
+ delegationEnd(sessionId, agentName, taskId, result, costFields) {
114
+ _internals.emit("delegation_end", {
115
+ sessionId,
116
+ agentName,
117
+ taskId,
118
+ result,
119
+ tokens_input: costFields?.tokens_input ?? 0,
120
+ tokens_output: costFields?.tokens_output ?? 0,
121
+ tokens_reasoning: costFields?.tokens_reasoning ?? 0,
122
+ tokens_cache: costFields?.tokens_cache ?? 0,
123
+ cost_usd: costFields?.cost_usd ?? null,
124
+ cost_source: costFields?.cost_source ?? "unavailable",
125
+ model: costFields?.model,
126
+ gate: costFields?.gate,
127
+ retry_index: costFields?.retry_index
128
+ });
115
129
  },
116
130
  taskStateChanged(sessionId, taskId, newState, oldState) {
117
131
  _internals.emit("task_state_changed", {
@@ -10,17 +10,17 @@ import {
10
10
  resolveSwarmRejectedPath,
11
11
  rewriteKnowledge,
12
12
  transactKnowledge
13
- } from "./index-hb10a2g8.js";
13
+ } from "./index-f7nma02k.js";
14
14
  import {
15
15
  atomicWriteFile
16
- } from "./index-kv4dd5c5.js";
16
+ } from "./index-9b7qp18e.js";
17
17
  import {
18
18
  init_logger,
19
19
  warn
20
20
  } from "./index-zgwm4ryv.js";
21
21
  import {
22
22
  require_proper_lockfile
23
- } from "./index-91qtsbce.js";
23
+ } from "./index-3naa2ajc.js";
24
24
  import {
25
25
  __require,
26
26
  __toESM
@@ -14,7 +14,13 @@ import {
14
14
 
15
15
  // src/hooks/utils.ts
16
16
  import * as path from "path";
17
- var _internals = { safeHook, composeHandlers, validateSwarmPath, readSwarmFileAsync };
17
+ var _internals = {
18
+ safeHook,
19
+ composeHandlers,
20
+ validateSwarmPath,
21
+ readSwarmFileAsync,
22
+ readCachedTextFile
23
+ };
18
24
  function safeHook(fn) {
19
25
  return async (input, output) => {
20
26
  try {
@@ -67,13 +73,23 @@ function validateSwarmPath(directory, filename) {
67
73
  }
68
74
  return resolved;
69
75
  }
70
- async function readSwarmFileAsync(directory, filename) {
76
+ async function readSwarmFileAsync(directory, filename, cache) {
77
+ if (cache !== undefined) {
78
+ const key = `${directory}::${filename}`;
79
+ const cached = cache.get(key);
80
+ if (cached !== undefined) {
81
+ return cached;
82
+ }
83
+ const promise = readSwarmFileAsync(directory, filename);
84
+ cache.set(key, promise);
85
+ return promise;
86
+ }
71
87
  const maxAttempts = 5;
72
88
  const retryDelayMs = 10;
73
89
  for (let attempt = 0;attempt < maxAttempts; attempt++) {
74
90
  try {
75
91
  const resolvedPath = _internals.validateSwarmPath(directory, filename);
76
- return await readCachedTextFile(resolvedPath, async () => {
92
+ return await _internals.readCachedTextFile(resolvedPath, async () => {
77
93
  const file = bunFile(resolvedPath);
78
94
  return await file.text();
79
95
  });
@@ -4,11 +4,11 @@ import {
4
4
  readTaskEvidence,
5
5
  readTaskEvidenceRaw,
6
6
  sanitizeTaskId
7
- } from "./index-mh1ej70w.js";
7
+ } from "./index-r8f89sm9.js";
8
8
  import {
9
9
  readSwarmFileAsync,
10
10
  validateSwarmPath
11
- } from "./index-gn8n22th.js";
11
+ } from "./index-we94wkty.js";
12
12
  import {
13
13
  readCachedParsedFile
14
14
  } from "./index-jtqkh8jf.js";
@@ -20,7 +20,7 @@ import {
20
20
  } from "./index-zgwm4ryv.js";
21
21
  import {
22
22
  withEvidenceLock
23
- } from "./index-91qtsbce.js";
23
+ } from "./index-3naa2ajc.js";
24
24
  import {
25
25
  ZodError,
26
26
  exports_external
@@ -31,7 +31,7 @@ import {
31
31
  } from "./index-b9v501fr.js";
32
32
  import {
33
33
  emit
34
- } from "./index-xchgryg4.js";
34
+ } from "./index-vn263hqt.js";
35
35
 
36
36
  // src/plan/manager.ts
37
37
  import {
@@ -2162,8 +2162,8 @@ function extractPlanHashFromMarkdown(markdown) {
2162
2162
  const match = markdown.match(/<!--\s*PLAN_HASH:\s*(\S+)\s*-->/);
2163
2163
  return match ? match[1] : null;
2164
2164
  }
2165
- async function isPlanMdInSync(directory, plan) {
2166
- const planMdContent = await readSwarmFileAsync(directory, "plan.md");
2165
+ async function isPlanMdInSync(directory, plan, cache) {
2166
+ const planMdContent = await readSwarmFileAsync(directory, "plan.md", cache);
2167
2167
  if (planMdContent === null) {
2168
2168
  return false;
2169
2169
  }
@@ -2197,8 +2197,8 @@ ${markdown}`;
2197
2197
  } catch {}
2198
2198
  }
2199
2199
  }
2200
- async function loadPlan(directory) {
2201
- const planJsonContent = await readSwarmFileAsync(directory, "plan.json");
2200
+ async function loadPlan(directory, cache) {
2201
+ const planJsonContent = await readSwarmFileAsync(directory, "plan.json", cache);
2202
2202
  if (planJsonContent !== null) {
2203
2203
  if (planJsonContent.includes("\x00") || planJsonContent.includes("\uFFFD")) {
2204
2204
  warn("Plan rejected: .swarm/plan.json contains null bytes or invalid encoding");
@@ -2208,7 +2208,7 @@ async function loadPlan(directory) {
2208
2208
  if (validated === null) {
2209
2209
  warn("[loadPlan] plan.json disappeared during cached parse. Falling back to plan.md migration or ledger recovery.");
2210
2210
  } else {
2211
- const inSync = await isPlanMdInSync(directory, validated);
2211
+ const inSync = await isPlanMdInSync(directory, validated, cache);
2212
2212
  if (!inSync) {
2213
2213
  try {
2214
2214
  await _internals4.regeneratePlanMarkdown(directory, validated);
@@ -2331,7 +2331,7 @@ async function loadPlan(directory) {
2331
2331
  }
2332
2332
  }
2333
2333
  }
2334
- const planMdContent2 = await readSwarmFileAsync(directory, "plan.md");
2334
+ const planMdContent2 = await readSwarmFileAsync(directory, "plan.md", cache);
2335
2335
  if (planMdContent2 !== null) {
2336
2336
  const migrated = migrateLegacyPlan(planMdContent2);
2337
2337
  const { removedCount } = await savePlanWithAutoAcknowledgedRemovals(directory, migrated, "load_plan_migration_from_md", "migrate legacy plan.md to plan.json");
@@ -2346,7 +2346,7 @@ async function loadPlan(directory) {
2346
2346
  }
2347
2347
  }
2348
2348
  }
2349
- const planMdContent = await readSwarmFileAsync(directory, "plan.md");
2349
+ const planMdContent = await readSwarmFileAsync(directory, "plan.md", cache);
2350
2350
  if (planMdContent !== null) {
2351
2351
  const migrated = migrateLegacyPlan(planMdContent);
2352
2352
  await savePlan(directory, migrated);
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  stripKnownSwarmPrefix
4
- } from "./index-471qxz9g.js";
4
+ } from "./index-7hnwnw5g.js";
5
5
  import {
6
6
  init_logger,
7
7
  warn
package/dist/cli/index.js CHANGED
@@ -7,30 +7,30 @@ import {
7
7
  getPluginLockFilePaths,
8
8
  package_default,
9
9
  resolveCommand
10
- } from "./index-zgba613y.js";
11
- import"./index-5z2e78tv.js";
10
+ } from "./index-hw8r3e5p.js";
11
+ import"./index-xsswhy6k.js";
12
12
  import"./index-2a6ppa65.js";
13
- import"./index-fjxjb66n.js";
14
- import"./index-hb10a2g8.js";
15
- import"./index-zy22fg5h.js";
13
+ import"./index-vwyjkzgs.js";
14
+ import"./index-f7nma02k.js";
15
+ import"./index-svf2zjxs.js";
16
16
  import {
17
17
  DEFAULT_AGENT_CONFIGS
18
- } from "./index-471qxz9g.js";
19
- import"./index-4c5jpmn9.js";
18
+ } from "./index-7hnwnw5g.js";
19
+ import"./index-wwnjw0fb.js";
20
20
  import"./index-adz3nk9b.js";
21
21
  import"./index-v4fcn4tr.js";
22
- import"./index-mh1ej70w.js";
23
- import"./index-kv4dd5c5.js";
24
- import"./index-sf08zj91.js";
25
- import"./index-gn8n22th.js";
22
+ import"./index-r8f89sm9.js";
23
+ import"./index-9b7qp18e.js";
24
+ import"./index-5fxjagjt.js";
25
+ import"./index-we94wkty.js";
26
26
  import"./index-jtqkh8jf.js";
27
27
  import"./index-5e4e2hvv.js";
28
28
  import"./index-p0arc26j.js";
29
29
  import"./index-zgwm4ryv.js";
30
- import"./index-91qtsbce.js";
30
+ import"./index-3naa2ajc.js";
31
31
  import"./index-293f68mj.js";
32
32
  import"./index-b9v501fr.js";
33
- import"./index-xchgryg4.js";
33
+ import"./index-vn263hqt.js";
34
34
  import"./index-a76rekgs.js";
35
35
 
36
36
  // src/cli/index.ts
@@ -32,12 +32,12 @@ import {
32
32
  transactFile,
33
33
  transactKnowledge,
34
34
  wordBigrams
35
- } from "./index-hb10a2g8.js";
36
- import"./index-kv4dd5c5.js";
35
+ } from "./index-f7nma02k.js";
36
+ import"./index-9b7qp18e.js";
37
37
  import"./index-jtqkh8jf.js";
38
- import"./index-91qtsbce.js";
38
+ import"./index-3naa2ajc.js";
39
39
  import"./index-b9v501fr.js";
40
- import"./index-xchgryg4.js";
40
+ import"./index-vn263hqt.js";
41
41
  import"./index-a76rekgs.js";
42
42
  export {
43
43
  wordBigrams,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-gn8n22th.js";
4
+ } from "./index-we94wkty.js";
5
5
  import"./index-jtqkh8jf.js";
6
6
  import"./index-5e4e2hvv.js";
7
7
  import"./index-p0arc26j.js";
@@ -11,12 +11,12 @@ import {
11
11
  } from "./index-zgwm4ryv.js";
12
12
  import {
13
13
  withEvidenceLock
14
- } from "./index-91qtsbce.js";
14
+ } from "./index-3naa2ajc.js";
15
15
  import {
16
16
  exports_external
17
17
  } from "./index-293f68mj.js";
18
18
  import"./index-b9v501fr.js";
19
- import"./index-xchgryg4.js";
19
+ import"./index-vn263hqt.js";
20
20
  import"./index-a76rekgs.js";
21
21
 
22
22
  // src/background/pending-delegations.ts
@@ -9,16 +9,16 @@ import {
9
9
  sweepStale,
10
10
  unsubscribe,
11
11
  updateSnapshot
12
- } from "./index-sf08zj91.js";
13
- import"./index-gn8n22th.js";
12
+ } from "./index-5fxjagjt.js";
13
+ import"./index-we94wkty.js";
14
14
  import"./index-jtqkh8jf.js";
15
15
  import"./index-5e4e2hvv.js";
16
16
  import"./index-p0arc26j.js";
17
17
  import"./index-zgwm4ryv.js";
18
- import"./index-91qtsbce.js";
18
+ import"./index-3naa2ajc.js";
19
19
  import"./index-293f68mj.js";
20
20
  import"./index-b9v501fr.js";
21
- import"./index-xchgryg4.js";
21
+ import"./index-vn263hqt.js";
22
22
  import"./index-a76rekgs.js";
23
23
  export {
24
24
  updateSnapshot,
@@ -47,6 +47,7 @@ import {
47
47
  LeanTurboStrategyConfigSchema,
48
48
  LintConfigSchema,
49
49
  MemoryConfigSchema,
50
+ ModelPricingConfigSchema,
50
51
  ParallelizationConfigSchema,
51
52
  PhaseCompleteConfigSchema,
52
53
  PipelineConfigSchema,
@@ -54,6 +55,7 @@ import {
54
55
  PlanCursorConfigSchema,
55
56
  PluginConfigSchema,
56
57
  PrMonitorConfigSchema,
58
+ PricingConfigSchema,
57
59
  PrmConfigSchema,
58
60
  QualityBudgetConfigSchema,
59
61
  RepoGraphConfigSchema,
@@ -83,7 +85,7 @@ import {
83
85
  resolveGeneratedAgentRole,
84
86
  resolveGuardrailsConfig,
85
87
  stripKnownSwarmPrefix
86
- } from "./index-471qxz9g.js";
88
+ } from "./index-7hnwnw5g.js";
87
89
  import"./index-p0arc26j.js";
88
90
  import"./index-293f68mj.js";
89
91
  import"./index-a76rekgs.js";
@@ -117,6 +119,7 @@ export {
117
119
  RepoGraphConfigSchema,
118
120
  QualityBudgetConfigSchema,
119
121
  PrmConfigSchema,
122
+ PricingConfigSchema,
120
123
  PrMonitorConfigSchema,
121
124
  PluginConfigSchema,
122
125
  PlanCursorConfigSchema,
@@ -124,6 +127,7 @@ export {
124
127
  PipelineConfigSchema,
125
128
  PhaseCompleteConfigSchema,
126
129
  ParallelizationConfigSchema,
130
+ ModelPricingConfigSchema,
127
131
  MemoryConfigSchema,
128
132
  LintConfigSchema,
129
133
  LeanTurboStrategyConfigSchema,
@@ -27,14 +27,14 @@ import {
27
27
  retireSkill,
28
28
  sanitizeSlug,
29
29
  selectCandidateEntries
30
- } from "./index-fjxjb66n.js";
31
- import"./index-hb10a2g8.js";
32
- import"./index-kv4dd5c5.js";
30
+ } from "./index-vwyjkzgs.js";
31
+ import"./index-f7nma02k.js";
32
+ import"./index-9b7qp18e.js";
33
33
  import"./index-jtqkh8jf.js";
34
34
  import"./index-zgwm4ryv.js";
35
- import"./index-91qtsbce.js";
35
+ import"./index-3naa2ajc.js";
36
36
  import"./index-b9v501fr.js";
37
- import"./index-xchgryg4.js";
37
+ import"./index-vn263hqt.js";
38
38
  import"./index-a76rekgs.js";
39
39
  export {
40
40
  selectCandidateEntries,
@@ -8,7 +8,7 @@ import {
8
8
  resetTelemetryForTesting,
9
9
  rotateTelemetryIfNeeded,
10
10
  telemetry
11
- } from "./index-xchgryg4.js";
11
+ } from "./index-vn263hqt.js";
12
12
  import"./index-a76rekgs.js";
13
13
  export {
14
14
  telemetry,
@@ -8,7 +8,7 @@ import { checkHivePromotions } from '../hooks/hive-promoter';
8
8
  import { curateAndStoreSwarm } from '../hooks/knowledge-curator';
9
9
  import { closePlanTerminalState } from '../plan/manager';
10
10
  import { type SessionReflectionResult } from '../services/session-reflection';
11
- import { resetSwarmStatePreservingSingletons } from '../state';
11
+ import { endAgentSession, resetSwarmStatePreservingSingletons } from '../state';
12
12
  interface PlanPhase {
13
13
  id: number;
14
14
  name: string;
@@ -197,5 +197,6 @@ export declare const _internals: {
197
197
  runAlignStage: typeof runAlignStage;
198
198
  archiveEvidence: typeof archiveEvidence;
199
199
  closePlanTerminalState: typeof closePlanTerminalState;
200
+ endAgentSession: typeof endAgentSession;
200
201
  };
201
202
  export {};
@@ -0,0 +1,4 @@
1
+ import { type CostSummary } from '../services/cost-accounting.js';
2
+ export declare function handleCostsCommand(directory: string, args: string[]): Promise<string>;
3
+ export declare function renderCostSummary(summary: CostSummary): string;
4
+ export declare function formatUsd(value: number): string;
@@ -16,6 +16,7 @@ export { COMMAND_NAME_SET, COMMAND_NAMES } from './command-names.js';
16
16
  export { handleConcurrencyCommand } from './concurrency';
17
17
  export { handleConfigCommand } from './config';
18
18
  export { handleConsolidateCommand } from './consolidate';
19
+ export { handleCostsCommand } from './costs';
19
20
  export { handleCouncilCommand } from './council';
20
21
  export { handleCurateCommand } from './curate';
21
22
  export { handleDarkMatterCommand } from './dark-matter';
@@ -199,8 +199,15 @@ export declare const COMMAND_REGISTRY: {
199
199
  };
200
200
  readonly benchmark: {
201
201
  readonly handler: (ctx: CommandContext) => Promise<string>;
202
- readonly description: "Show performance metrics [--cumulative] [--ci-gate]";
203
- readonly args: "--cumulative, --ci-gate";
202
+ readonly description: "Show performance metrics [--cumulative] [--ci-gate] [--max-cost-usd <n>]";
203
+ readonly args: "--cumulative, --ci-gate, --max-cost-usd <n>";
204
+ readonly category: "diagnostics";
205
+ readonly toolPolicy: "agent";
206
+ };
207
+ readonly costs: {
208
+ readonly handler: (ctx: CommandContext) => Promise<string>;
209
+ readonly description: "Show per-agent and per-task token/cost telemetry [--json]";
210
+ readonly args: "--json";
204
211
  readonly category: "diagnostics";
205
212
  readonly toolPolicy: "agent";
206
213
  };