opencode-swarm 7.154.1 → 7.154.3

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 (79) hide show
  1. package/dist/background/completion-observer.d.ts +10 -1
  2. package/dist/background/pending-delegations.d.ts +47 -0
  3. package/dist/cli/coder-settlement-7c9h07f5.js +54 -0
  4. package/dist/cli/{config-doctor-keasv3r8.js → config-doctor-8zjz6dej.js} +2 -2
  5. package/dist/cli/{core-7aj5g3f4.js → core-dn8bn81g.js} +2 -2
  6. package/dist/cli/{curation-policy-a6tve11y.js → curation-policy-2jkbybw7.js} +4 -4
  7. package/dist/cli/{curator-drift-h57z6tm3.js → curator-drift-g6w4ga1q.js} +2 -2
  8. package/dist/cli/{curator-llm-factory-cr5ckwbd.js → curator-llm-factory-mxdjw6kz.js} +33 -31
  9. package/dist/cli/{curator-anz136hr.js → curator-v12rhct2.js} +33 -31
  10. package/dist/cli/{evidence-summary-service-6tgme7p3.js → evidence-summary-service-zzvvcaa9.js} +11 -11
  11. package/dist/cli/{gate-evidence-36nfx4vb.js → gate-evidence-16jkjre9.js} +6 -6
  12. package/dist/cli/{guardrail-explain-frb5xd5h.js → guardrail-explain-11fx66cx.js} +34 -32
  13. package/dist/cli/{guardrail-log-fvma65xm.js → guardrail-log-ahvfn58c.js} +3 -3
  14. package/dist/cli/{guardrail-reset-3qk6k334.js → guardrail-reset-zp5xe0n5.js} +33 -31
  15. package/dist/cli/{hive-promoter-v3dhtzfa.js → hive-promoter-k6y06jj8.js} +33 -31
  16. package/dist/cli/{index-c809a69b.js → index-0f4b9ywa.js} +2 -2
  17. package/dist/cli/{index-akm1dbr9.js → index-2rgm3hgq.js} +4 -4
  18. package/dist/cli/{index-1sjnqsc8.js → index-4dt91x6e.js} +1 -1
  19. package/dist/cli/{index-qm8b3aaj.js → index-4n557t8w.js} +3 -3
  20. package/dist/cli/{index-h7pamys0.js → index-6vcrkz80.js} +4 -4
  21. package/dist/cli/{index-wqp8kk0w.js → index-7fyv62b2.js} +11 -12
  22. package/dist/cli/{index-zak84bqr.js → index-7qky94rr.js} +1 -1
  23. package/dist/cli/{index-bmkxc6sa.js → index-94e20w95.js} +2 -2
  24. package/dist/cli/{index-wxpemcdj.js → index-9nw6z98k.js} +35 -33
  25. package/dist/cli/{index-4r46q7tk.js → index-a6xjn2zt.js} +5 -5
  26. package/dist/cli/{index-107cv0dr.js → index-bhjkxasn.js} +1 -1
  27. package/dist/cli/{index-97q41ds3.js → index-ckp0z9d4.js} +2 -2
  28. package/dist/cli/{index-sx5f2fq9.js → index-d7r6y724.js} +4 -4
  29. package/dist/cli/index-ddszzne4.js +42 -0
  30. package/dist/cli/{index-4cgee5vh.js → index-dtn0pne5.js} +20 -1
  31. package/dist/cli/{index-9wzgztj9.js → index-ed13peqr.js} +1 -1
  32. package/dist/cli/{index-tmgbwgsm.js → index-env8fk17.js} +1 -1
  33. package/dist/cli/{index-9znypky4.js → index-g1bh7980.js} +3 -3
  34. package/dist/cli/{index-p17hs70t.js → index-gbkdj7ay.js} +2 -2
  35. package/dist/cli/{index-9xev69y4.js → index-kck2gtxk.js} +228 -2
  36. package/dist/cli/{index-r0yavfvm.js → index-m0fy8jra.js} +2309 -2920
  37. package/dist/cli/{index-wmxke5se.js → index-n7nnz0jp.js} +6 -6
  38. package/dist/cli/{index-xsbf2mmf.js → index-q0prhdds.js} +7 -7
  39. package/dist/cli/{index-3md256qr.js → index-qdnmnq65.js} +1 -1
  40. package/dist/cli/{index-y7gyhe13.js → index-qxj63890.js} +1 -1
  41. package/dist/cli/{index-50cy1a3p.js → index-s23q9v6t.js} +6 -6
  42. package/dist/cli/{index-0vss7vdg.js → index-s5p8ryar.js} +1 -1
  43. package/dist/cli/{index-yy4yps8w.js → index-v6xkgxts.js} +2 -2
  44. package/dist/cli/{index-garsang6.js → index-vntggpez.js} +2 -2
  45. package/dist/cli/{index-155pbsan.js → index-wkagbmpt.js} +1 -1
  46. package/dist/cli/{index-fz9xcq6z.js → index-y3kw1zpm.js} +2 -1
  47. package/dist/cli/index-ymgsmjba.js +875 -0
  48. package/dist/cli/{index-2ppbt5cf.js → index-zak50rve.js} +1 -1
  49. package/dist/cli/index.js +33 -31
  50. package/dist/cli/{knowledge-escalator-1gjv97hj.js → knowledge-escalator-yew2fbxb.js} +11 -11
  51. package/dist/cli/{knowledge-events-94hfvp85.js → knowledge-events-zfg423hp.js} +9 -9
  52. package/dist/cli/{knowledge-link-fs8hgh4h.js → knowledge-link-ydv6shg2.js} +3 -3
  53. package/dist/cli/{knowledge-store-g7grbt7h.js → knowledge-store-zcv9stzz.js} +4 -4
  54. package/dist/cli/{knowledge-validator-ep0ym1e4.js → knowledge-validator-q68wx2bf.js} +6 -6
  55. package/dist/cli/{pending-delegations-0pf2dtwx.js → pending-delegations-yet1rza6.js} +15 -2
  56. package/dist/cli/{pr-subscriptions-e70phj71.js → pr-subscriptions-mp7fyh1r.js} +3 -3
  57. package/dist/cli/{runner-b7pskcxb.js → runner-s89ja08q.js} +4 -4
  58. package/dist/cli/{scan-cursor-8zps8v46.js → scan-cursor-38bzfhwf.js} +5 -5
  59. package/dist/cli/{schema-8sx9jp7v.js → schema-9hqyt4t6.js} +1 -1
  60. package/dist/cli/{scope-persistence-zacyjnx9.js → scope-persistence-dd9s9q2b.js} +6 -6
  61. package/dist/cli/{skill-generator-xs5n5j4k.js → skill-generator-b28ezazm.js} +13 -13
  62. package/dist/cli/{worktree-collision-ownership-yjk5ya71.js → worktree-collision-ownership-zw65t2p9.js} +9 -8
  63. package/dist/cli/{worktree-isolation-cpf6b8ns.js → worktree-isolation-0ag393t0.js} +33 -31
  64. package/dist/evaluation/contracts.d.ts +4 -4
  65. package/dist/evaluation/gate-ground-truth.d.ts +1 -1
  66. package/dist/hooks/final-context-accounting.d.ts +60 -0
  67. package/dist/hooks/index.d.ts +1 -0
  68. package/dist/hooks/knowledge-injector.d.ts +1 -1
  69. package/dist/hooks/system-enhancer.d.ts +13 -0
  70. package/dist/hooks/utils.d.ts +11 -0
  71. package/dist/index.js +561 -556
  72. package/dist/services/compaction-service.d.ts +9 -3
  73. package/dist/services/context-budget-service.d.ts +7 -3
  74. package/dist/services/injection-budget.d.ts +103 -26
  75. package/dist/state.d.ts +69 -0
  76. package/dist/summaries/summarizer.d.ts +34 -3
  77. package/dist/utils/canonical-root.d.ts +2 -0
  78. package/dist/workflow/coder-settlement.d.ts +14 -0
  79. package/package.json +2 -1
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Final context accounting (#2107 §3).
3
+ *
4
+ * ONE final accounting step, run after every injector has contributed and after
5
+ * `consolidateSystemMessagesInPlace` — the last structure-mutating handler in
6
+ * the `experimental.chat.messages.transform` chain. It measures the actual
7
+ * final model-visible surface exactly once:
8
+ *
9
+ * - `output.messages` (post-consolidation; carries every messages-chain
10
+ * injection: knowledge, memory recall, the advisory block) via
11
+ * `computeContextUsage`, which prefers provider-reported token usage when the
12
+ * latest assistant message carries it;
13
+ * - PLUS the system chain's `output.system` content (system-enhancer banners,
14
+ * context capsules, the swarm-command banner). Those bytes live in a separate
15
+ * output structure the messages chain never sees and consolidation never
16
+ * merges (docs/context-map.md; engineering-invariants § v6.85.1), so they are
17
+ * added from the per-turn injection ledger's `surface: 'system'` emissions.
18
+ * Messages-surface producers are attribution-only — their bytes are already
19
+ * inside the measurement and are NEVER added again.
20
+ *
21
+ * The limit is resolved through the exact same ladder physical pruning uses
22
+ * (`resolveModelLimit` with `context_budget.model_limits` overrides and the
23
+ * live `model.limit.context` relayed from the system.transform hook), so the
24
+ * warning/critical thresholds here are the same thresholds, against the same
25
+ * denominator, that `context-budget.ts` enforces. A 128K–1M-window model can
26
+ * no longer receive a warning computed against a phantom denominator.
27
+ *
28
+ * The warning this step emits is bounded, advisory-only (it never removes
29
+ * content and says so), suppressed to once per session per band, and its own
30
+ * token cost is included in the recorded total AND recorded as a ledger
31
+ * emission — it cannot escape accounting. Fail-open by design: an accounting
32
+ * failure must never break request composition. The step is registered
33
+ * inside the plugin's single composeHandlers chain for messages.transform
34
+ * (one handler per hook type is all the host allows), which wraps it in
35
+ * safeHook; the inner try/catch below is the intentional first-line
36
+ * fail-open and logs the failure itself, so the outer wrapper is only a
37
+ * redundant backstop, never the primary swallowing layer.
38
+ */
39
+ import type { PluginConfig } from '../config/index.js';
40
+ import type { MessageWithParts } from './knowledge-types.js';
41
+ interface FinalAccountingOptions {
42
+ config: PluginConfig;
43
+ /** Same seam createContextBudgetHandler uses: resolves the
44
+ * configured target model for an agent name. */
45
+ resolveAgentModelFn?: (agentName: string) => string | undefined;
46
+ }
47
+ /**
48
+ * One-shot-per-band warning suppression (#2107 §3), backed by the
49
+ * session-keyed `finalAccountingWarningBandsBySession` map in state.ts so
50
+ * `resetSwarmState` covers it (AGENTS.md invariant 8). Deliberately NOT
51
+ * reset on compaction: "once per session per band" mirrors the
52
+ * established contextPressureWarningSent one-shot pattern; the compaction
53
+ * tiers have their own per-session hysteresis.
54
+ */
55
+ /** Test seam: clear warning-suppression state. */
56
+ export declare function _resetFinalAccountingState(): void;
57
+ export declare function createFinalContextAccountingStep(options: FinalAccountingOptions): (input: unknown, output: {
58
+ messages?: MessageWithParts[];
59
+ }) => Promise<void>;
60
+ export {};
@@ -8,6 +8,7 @@ export { createDelegationGateHook, outputLooksLikeBackgroundRunning, } from './d
8
8
  export { createDelegationSanitizerHook } from './delegation-sanitizer';
9
9
  export { createDelegationTrackerHook } from './delegation-tracker';
10
10
  export { extractCurrentPhase, extractCurrentPhaseFromPlan, extractCurrentTask, extractCurrentTaskFromPlan, extractDecisions, extractIncompleteTasks, extractIncompleteTasksFromPlan, extractPatterns, } from './extractors';
11
+ export { createFinalContextAccountingStep } from './final-context-accounting';
11
12
  export { createFullAutoInterceptHook } from './full-auto-intercept';
12
13
  export { checkFileAuthority, createGuardrailsHooks, DEFAULT_AGENT_AUTHORITY_RULES, } from './guardrails';
13
14
  export { classifyMessage, classifyMessages, containsPlanContent, getCompletedToolOutputs, getToolNames, getToolParts, isDuplicateToolRead, isStaleError, isToolResult, MessagePriority, type MessagePriorityType, type MessageWithParts, } from './message-priority';
@@ -99,7 +99,7 @@ export declare function matchesDelegateScope(entry: Pick<RankedEntry, 'applies_t
99
99
  /** Inserts the knowledge block just before the last user message (recency position). */
100
100
  declare function injectKnowledgeMessage(output: {
101
101
  messages?: MessageWithParts[];
102
- }, text: string): void;
102
+ }, text: string, sessionId?: string): void;
103
103
  /**
104
104
  * Creates a knowledge injection hook that injects relevant knowledge into the
105
105
  * architect's message context at phase start. Supports caching for re-injection
@@ -6,6 +6,7 @@
6
6
  * Reads plan.md and injects phase context into the system prompt.
7
7
  */
8
8
  import type { PluginConfig } from '../config';
9
+ import type { RuntimePlan } from '../config/plan-schema';
9
10
  /**
10
11
  * Build the [spec-drift] advisory injected into the model's system prompt
11
12
  * after every loadPlan whenever spec staleness is detected (issue #853
@@ -29,6 +30,9 @@ export declare function buildSpecDriftAdvisory(args: {
29
30
  source: string;
30
31
  };
31
32
  }): string;
33
+ declare function maybeAppendSpecDriftAdvisory(output: {
34
+ system: string[];
35
+ }, directory: string, plan: RuntimePlan | null, sessionId?: string): void;
32
36
  /**
33
37
  * Build a retrospective injection string for the architect system message.
34
38
  * Tier 1: direct phase-scoped lookup for same-plan previous phase.
@@ -51,3 +55,12 @@ export type ArchitectMode = 'DISCOVER' | 'PLAN' | 'EXECUTE' | 'PHASE-WRAP' | 'UN
51
55
  * @returns The current architect mode based on plan state
52
56
  */
53
57
  export declare function detectArchitectMode(directory: string, cache?: Map<string, Promise<string | null>>): Promise<ArchitectMode>;
58
+ /**
59
+ * Tier-0 test seam (knowledge-injector precedent): exposes the spec-drift
60
+ * advisory helper so the #2107 §2 attribution test can drive its direct
61
+ * output.system push and assert the ledger emission is recorded exactly once.
62
+ */
63
+ export declare const _test_exports: {
64
+ maybeAppendSpecDriftAdvisory: typeof maybeAppendSpecDriftAdvisory;
65
+ };
66
+ export {};
@@ -77,5 +77,16 @@ export declare function composeBlockingHandlers<I, O>(...fns: Array<HookHandler<
77
77
  */
78
78
  export declare function validateSwarmPath(directory: string, filename: string): string;
79
79
  export declare function readSwarmFileAsync(directory: string, filename: string, cache?: Map<string, Promise<string | null>>): Promise<string | null>;
80
+ /**
81
+ * Estimate tokens from a character count using the canonical heuristic.
82
+ * This is the single sanctioned numeric form (issue #2107 §1).
83
+ */
84
+ export declare function estimateTokensFromCharCount(chars: number): number;
85
+ /**
86
+ * Inverse of the canonical estimator: the character budget that corresponds to a
87
+ * token budget. Floor, so the result never overruns the token budget when converted
88
+ * back with `estimateTokensFromCharCount`.
89
+ */
90
+ export declare function estimateCharsForTokens(tokens: number): number;
80
91
  export declare function estimateTokens(text: string): number;
81
92
  export {};