@wrongstack/core 0.313.1 → 0.316.1
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.
- package/dist/chronicle/index.js +31 -31
- package/dist/chronicle/legacy-journal-import.d.ts +0 -6
- package/dist/chronicle/metrics-ingest.d.ts +14 -0
- package/dist/chronicle/metrics-schema.d.ts +10 -1
- package/dist/chronicle/metrics-store.d.ts +20 -2
- package/dist/chronicle/project-server.js +39 -31
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/{chunk-WOEZV3Q4.js → chunk-25LSLC3G.js} +2 -1
- package/dist/{chunk-AI4LLQ2U.js → chunk-27QIURLN.js} +229 -12
- package/dist/{chunk-I45KAW2N.js → chunk-3AGWVSS7.js} +38 -450
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/{chunk-NFAYHPRH.js → chunk-3ECENVHL.js} +10 -8
- package/dist/{chunk-FW5LDDMJ.js → chunk-45WI72ZB.js} +1576 -1156
- package/dist/{chunk-AT4V4XGI.js → chunk-4BMVPOHO.js} +539 -313
- package/dist/{chunk-YBUJCZ57.js → chunk-4I7HGVVA.js} +17 -5
- package/dist/{chunk-JVGPR3TS.js → chunk-4LCZVJVF.js} +7 -55
- package/dist/{chunk-4ZHTKJHM.js → chunk-4SJNS7OB.js} +36 -2
- package/dist/{chunk-AD7ZFZCS.js → chunk-5BMIE7QG.js} +3 -3
- package/dist/{chunk-IQ35HMQL.js → chunk-5YPSXQXM.js} +71 -24
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/{chunk-FIV4IJL7.js → chunk-6H5GEOET.js} +163 -20
- package/dist/{chunk-VB3H5WWB.js → chunk-6NWEVFEL.js} +2 -2
- package/dist/{chunk-E6I5RXVK.js → chunk-AYW5YINX.js} +2 -2
- package/dist/{chunk-DEIQMBD2.js → chunk-B7F4WVP4.js} +2 -2
- package/dist/{chunk-XQ2XGIBF.js → chunk-BPBKKBUK.js} +6 -7
- package/dist/{chunk-K4YUNKU7.js → chunk-BYD345OX.js} +2 -2
- package/dist/{chunk-LZDDLNCZ.js → chunk-C27KDLOX.js} +4 -4
- package/dist/{chunk-6AKOTGLM.js → chunk-CU546ESW.js} +7 -7
- package/dist/{chunk-ZZ4V3WIZ.js → chunk-DLHHXUAM.js} +10 -1
- package/dist/{chunk-BAKVJLEV.js → chunk-DOTHQSJ2.js} +28 -16
- package/dist/{chunk-KBZGE6LN.js → chunk-DYLPMV4Q.js} +4 -3
- package/dist/{chunk-52RTVH4M.js → chunk-F3JWNST7.js} +2 -2
- package/dist/{chunk-WEBMSQP2.js → chunk-FC2ZGRF3.js} +21 -4
- package/dist/{chunk-FHAMQS7Q.js → chunk-FCBTO76Z.js} +76 -146
- package/dist/{chunk-4LJJYBAU.js → chunk-FHZVFYSL.js} +9 -1
- package/dist/{chunk-W4A6QA3D.js → chunk-FWNLEZYG.js} +4 -3
- package/dist/{chunk-OJZEX73F.js → chunk-GDQ7CZRQ.js} +5 -1
- package/dist/{chunk-QVOVMXJR.js → chunk-GJJGJB2R.js} +32 -9
- package/dist/{chunk-4XV6IR37.js → chunk-HI3JGZR2.js} +7 -6
- package/dist/{chunk-FSWCWSTS.js → chunk-HMLIGAU7.js} +26 -26
- package/dist/{chunk-PFXFQQRT.js → chunk-HXKZ7OBQ.js} +7 -43
- package/dist/{chunk-2FQL4PDC.js → chunk-I7DALG7J.js} +5 -5
- package/dist/{chunk-GM54GJBU.js → chunk-IRUTEHCE.js} +3 -3
- package/dist/{chunk-TYW2GI5I.js → chunk-J2WRWR37.js} +40 -13
- package/dist/{chunk-ZEHUCJHY.js → chunk-JFPJ6LLQ.js} +2 -2
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/{chunk-RD6DEE36.js → chunk-JO4MGB6Z.js} +94 -8
- package/dist/{chunk-5DSMEVA4.js → chunk-K6BXGITA.js} +7 -7
- package/dist/{chunk-O74MJHXU.js → chunk-KZMSZV32.js} +2 -2
- package/dist/{chunk-GFJOMSHG.js → chunk-LA7CLDRW.js} +6 -2
- package/dist/{chunk-M2WF6AXG.js → chunk-LSMMOS2Z.js} +7 -3
- package/dist/{chunk-ASX6AW36.js → chunk-LXWCMQNJ.js} +3 -3
- package/dist/{chunk-WZO23AWO.js → chunk-M27LIEKV.js} +72 -22
- package/dist/{chunk-JTHKOYWU.js → chunk-MJPHJRAL.js} +15 -15
- package/dist/{chunk-G5AAKEEZ.js → chunk-MTL4O5YR.js} +5 -5
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/{chunk-ZYU2YOJ6.js → chunk-NIOAGFPB.js} +29 -15
- package/dist/{chunk-Y2GE5TSI.js → chunk-NS52ISWS.js} +2 -2
- package/dist/{chunk-UIWONWVG.js → chunk-NSOFPKGT.js} +541 -148
- package/dist/{chunk-RCQYT2I4.js → chunk-NVIZG63R.js} +2 -2
- package/dist/{chunk-EPC3GZD4.js → chunk-OOYZPOXM.js} +2 -2
- package/dist/{chunk-7ZHZE5EO.js → chunk-OSGLYW5J.js} +2 -2
- package/dist/{chunk-CE4ZOCOI.js → chunk-PFCMSSUF.js} +9 -9
- package/dist/{chunk-GFXZTHNI.js → chunk-PGRVXIMY.js} +5 -5
- package/dist/{chunk-JJPMWPB6.js → chunk-PISBFBJN.js} +6 -6
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/{chunk-5RP3QTRL.js → chunk-PQNS3U7Z.js} +20 -3
- package/dist/{chunk-3E244UDA.js → chunk-QSTSJOCK.js} +52 -6
- package/dist/{chunk-YUPMXOGP.js → chunk-RFQMOKWK.js} +3 -3
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/{chunk-SN2DQRL6.js → chunk-RXKSDUAU.js} +7 -7
- package/dist/{chunk-T3KGZBU5.js → chunk-S45JPKQN.js} +189 -43
- package/dist/{chunk-YNCVSFGF.js → chunk-SAFHACFA.js} +4 -1
- package/dist/{chunk-KI4L2DUL.js → chunk-TCCHINEF.js} +114 -19
- package/dist/{chunk-AWNQ6ED6.js → chunk-THEGTRAG.js} +7 -2
- package/dist/{chunk-2KKODIQU.js → chunk-TR4LQE7L.js} +15 -15
- package/dist/{chunk-GPQ3NJPR.js → chunk-TWJMGXCI.js} +3 -3
- package/dist/{chunk-H72H4XDU.js → chunk-U45AXT5D.js} +9 -9
- package/dist/{chunk-62V2AFVG.js → chunk-U4FWBSO3.js} +160 -73
- package/dist/{chunk-A455ATZB.js → chunk-UBGDX6FI.js} +8 -1
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/{chunk-KSJ5UTP7.js → chunk-ULMAQV3T.js} +84 -4
- package/dist/{chunk-CB2HFKTP.js → chunk-VVBP6KGT.js} +1 -1
- package/dist/{chunk-RPOA7IAE.js → chunk-W5VITDM2.js} +43 -25
- package/dist/{chunk-QRTG4XTI.js → chunk-WAHQVNWT.js} +7 -1
- package/dist/{chunk-SQP64RCS.js → chunk-WGGYRBXH.js} +3019 -2976
- package/dist/{chunk-K3G6JBUC.js → chunk-WLYKU45P.js} +679 -141
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/{chunk-GAZEWQEZ.js → chunk-XF4VUMKW.js} +2 -2
- package/dist/{chunk-PAAWLLZX.js → chunk-Y5YXDM7D.js} +2 -2
- package/dist/{chunk-65RDIOR2.js → chunk-YOPAUVU4.js} +162 -44
- package/dist/{chunk-FFSX2QDQ.js → chunk-YPT4A46F.js} +3 -3
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/{chunk-EFEHDQGY.js → chunk-ZHZ2Y2DH.js} +64 -10
- package/dist/{chunk-CQQL4ZOQ.js → chunk-ZT7JNIGX.js} +4 -3
- package/dist/coordination/agent-monitor.d.ts +9 -1
- package/dist/coordination/agent-subagent-runner.d.ts +1 -1
- package/dist/coordination/agents/agent-prompts.d.ts +8 -0
- package/dist/coordination/agents/index.d.ts +33 -1
- package/dist/coordination/agents/index.js +52 -22
- package/dist/coordination/agents/phase3-wave1-platform.d.ts +1 -3
- package/dist/coordination/agents/phase3-wave2-meta.d.ts +1 -3
- package/dist/coordination/agents/phase8-wave3-products.d.ts +1 -3
- package/dist/coordination/agents/phase9-wave4-platform-meta.d.ts +1 -3
- package/dist/coordination/agents/project-agent-identity.d.ts +11 -11
- package/dist/coordination/agents/types.d.ts +13 -2
- package/dist/coordination/brain-monitor.d.ts +30 -7
- package/dist/coordination/collab-debug.d.ts +1 -1
- package/dist/coordination/collab-pause.d.ts +1 -1
- package/dist/coordination/delegate-tool.d.ts +7 -5
- package/dist/coordination/director-kanban-queue-helpers.d.ts +1 -0
- package/dist/coordination/director-options.d.ts +7 -0
- package/dist/coordination/director-spawn-model.d.ts +17 -0
- package/dist/coordination/director-tools.d.ts +2 -2
- package/dist/coordination/director.d.ts +12 -0
- package/dist/coordination/dispatcher.d.ts +8 -0
- package/dist/coordination/fleet-bus.d.ts +35 -4
- package/dist/coordination/fleet-supervisor.d.ts +10 -2
- package/dist/coordination/fleet.d.ts +16 -7
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +86 -49
- package/dist/coordination/kanban-dispatch-port.d.ts +2 -2
- package/dist/coordination/mailbox-http-router.d.ts +4 -3
- package/dist/coordination/mailbox-http-validation.d.ts +1 -1
- package/dist/coordination/mailbox-project-server.js +15 -15
- package/dist/coordination/mailbox-types.d.ts +24 -6
- package/dist/coordination/model-tier-leader.d.ts +122 -0
- package/dist/coordination/model-tier.d.ts +122 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +24 -0
- package/dist/coordination/origin-session.d.ts +16 -0
- package/dist/coordination/provider-status-tracker.d.ts +37 -5
- package/dist/coordination/session-note-hub.d.ts +44 -0
- package/dist/coordination/session-note-tool.d.ts +10 -0
- package/dist/core/agent.d.ts +1 -1
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +130 -38
- package/dist/core/request-conversation-binding.d.ts +37 -0
- package/dist/core/session-notes.d.ts +25 -0
- package/dist/core/system-prompt-builder.d.ts +11 -2
- package/dist/core/system-prompt-variants.d.ts +78 -0
- package/dist/design/index.js +3 -3
- package/dist/execution/auto-compaction-middleware.d.ts +11 -0
- package/dist/execution/autonomy-brain.d.ts +2 -1
- package/dist/execution/autonomy-prompt-contributor.d.ts +7 -2
- package/dist/execution/compaction-core.d.ts +4 -4
- package/dist/execution/eternal-autonomy.d.ts +1 -1
- package/dist/execution/index.js +138 -129
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/extension/index.js +3 -3
- package/dist/goal/index.js +6 -6
- package/dist/hooks/index.js +3 -3
- package/dist/hq/index.js +14 -12
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +728 -635
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +281 -260
- package/dist/infrastructure/token-counter.d.ts +9 -0
- package/dist/kernel/events/agent-events.d.ts +77 -3
- package/dist/kernel/events/brain-events.d.ts +12 -0
- package/dist/kernel/events/provider-events.d.ts +7 -1
- package/dist/kernel/events/session-events.d.ts +14 -0
- package/dist/kernel/events/tool-events.d.ts +13 -0
- package/dist/kernel/index.js +4 -4
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +10 -9
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +459 -351
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +66 -50
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/{review-finding-store-DKAV3AS6.js → plugins/review-finding-store.js} +7 -6
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/{review-report-store-OWY3EC3N.js → plugins/review-report-store.js} +7 -6
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +5 -5
- package/dist/registry/index.js +3 -3
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/{registry-R23UBE7H.js → registry-7N4O3E7W.js} +5 -5
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +47 -33
- package/dist/security/permission-policy.d.ts +12 -1
- package/dist/security/secret-scrubber.d.ts +15 -0
- package/dist/session-catalog/index.d.ts +1 -0
- package/dist/session-catalog/index.js +19 -14
- package/dist/session-catalog/project-server.js +30 -13
- package/dist/session-catalog/protocol.d.ts +32 -1
- package/dist/session-catalog/registry.d.ts +17 -1
- package/dist/session-catalog/session-agents.d.ts +56 -0
- package/dist/session-catalog/store-rebuild.d.ts +14 -0
- package/dist/session-catalog/store-schema.d.ts +26 -0
- package/dist/session-catalog/store.d.ts +27 -1
- package/dist/session-note-attach.d.ts +9 -0
- package/dist/skills/index.js +5 -5
- package/dist/statusline/index.d.ts +43 -0
- package/dist/statusline/index.js +102 -0
- package/dist/storage/board-store-port.d.ts +2 -2
- package/dist/storage/config-loader/in-project-policy.d.ts +29 -0
- package/dist/storage/config-loader.d.ts +3 -2
- package/dist/storage/file-session-writer.d.ts +4 -2
- package/dist/storage/goal-coordination.d.ts +6 -1
- package/dist/storage/goal-kanban.d.ts +4 -1
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +76 -61
- package/dist/storage/input-history-store.d.ts +2 -4
- package/dist/storage/memory-curator.d.ts +133 -0
- package/dist/storage/session-agent-attribution.d.ts +39 -0
- package/dist/storage/session-doctor.d.ts +109 -0
- package/dist/storage/session-event-bridge.d.ts +5 -7
- package/dist/storage/session-outcome.d.ts +42 -0
- package/dist/storage/session-recovery.d.ts +55 -0
- package/dist/storage/session-store/load-session-data.d.ts +11 -0
- package/dist/storage/session-store/prune-helpers.d.ts +1 -1
- package/dist/storage/session-store/resume-session.d.ts +0 -2
- package/dist/storage/session-store/types.d.ts +8 -0
- package/dist/storage/session-store.d.ts +3 -3
- package/dist/storage/session-summary-tracker.d.ts +8 -1
- package/dist/storage/session-write-buffer.d.ts +18 -0
- package/dist/storage/session-writer-truncate.d.ts +2 -0
- package/dist/tasking/index.js +2 -2
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +21 -21
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- package/dist/types/config/mcp-features.d.ts +7 -0
- package/dist/types/config/model-tiers.d.ts +148 -0
- package/dist/types/config/root.d.ts +9 -0
- package/dist/types/config/tools.d.ts +73 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/default-config.d.ts +6 -0
- package/dist/types/errors.d.ts +2 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +25 -15
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/provider.d.ts +15 -0
- package/dist/types/runtime-capability-manifest.d.ts +1 -1
- package/dist/types/secret-scrubber.d.ts +15 -0
- package/dist/types/session-markers.d.ts +37 -10
- package/dist/types/session-markers.js +1 -1
- package/dist/types/session-timeline.d.ts +197 -0
- package/dist/types/session-timeline.js +12 -0
- package/dist/types/session.d.ts +172 -11
- package/dist/types/system-prompt.d.ts +27 -0
- package/dist/utils/config-backup.d.ts +9 -1
- package/dist/utils/heap-watchdog.js +2 -2
- package/dist/utils/index.js +50 -48
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- package/dist/utils/socket-path.d.ts +1 -1
- package/dist/utils/token-estimate.d.ts +6 -2
- package/dist/utils/wstack-paths.d.ts +2 -0
- package/dist/wiring/proxy-rewrite.d.ts +28 -0
- package/dist/wiring/proxy-rewrite.js +7 -1
- package/dist/worktree/index.js +2 -2
- package/instructions/agents/explore-companion.md +45 -18
- package/instructions/agents/memory-curator.md +34 -22
- package/instructions/coordination/director-preamble.md +12 -7
- package/instructions/coordination/subagent-baseline.md +26 -5
- package/instructions/leader-after-task.md +4 -1
- package/instructions/llm/chimera-review.md +30 -9
- package/instructions/llm/memory-curator.md +31 -0
- package/instructions/sections/tool/delegation-compact.md +2 -0
- package/instructions/sections/tool/delegation-full.md +5 -1
- package/instructions/sections/tool/mailbox-compact.md +5 -1
- package/instructions/sections/tool/mailbox-full.md +3 -0
- package/instructions/sections/tool/session-note-compact.md +3 -0
- package/instructions/sections/tool/session-note-full.md +15 -0
- package/instructions/system-lite.md +9 -4
- package/instructions/system-pro.md +66 -143
- package/instructions/system.md +73 -175
- package/package.json +32 -4
- package/dist/chunk-2BUUIMQB.js +0 -225
- package/dist/chunk-FAYRX2AD.js +0 -13
- package/dist/chunk-H5E77KUJ.js +0 -15
- package/dist/chunk-M7BS2K6U.js +0 -1
- package/dist/coordination/agents.d.ts +0 -8
- package/dist/coordination/transport.d.ts +0 -2
- package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +0 -28
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model tier resolution — the deterministic "how expensive should this job be?"
|
|
3
|
+
* layer that sits on top of the existing fallback-profile and model-matrix
|
|
4
|
+
* primitives.
|
|
5
|
+
*
|
|
6
|
+
* A tier binds three things that were previously configured independently:
|
|
7
|
+
*
|
|
8
|
+
* fallbackProfile → which models, in what failover order
|
|
9
|
+
* budget → maxCostUsd / maxIterations / maxToolCalls / timeoutMs
|
|
10
|
+
* modelRuntime → reasoning effort, cache ttl, generation params
|
|
11
|
+
*
|
|
12
|
+
* Everything here is deterministic: no LLM call, no scoring, no heuristic over
|
|
13
|
+
* task text. A tier is chosen by an explicit argument, or by a table lookup
|
|
14
|
+
* with the SAME precedence the model matrix already uses (exact role → the
|
|
15
|
+
* role's phase → the `*` default). That precedence is deliberately identical so
|
|
16
|
+
* a reader only has to learn one rule for both tables.
|
|
17
|
+
*
|
|
18
|
+
* Fail-safe by construction: an unconfigured or unknown tier resolves to
|
|
19
|
+
* `undefined` rather than to an invented model id, and callers then fall
|
|
20
|
+
* through to their existing behavior (matrix → session). A tier can only ever
|
|
21
|
+
* ADD a decision the config actually expresses.
|
|
22
|
+
*/
|
|
23
|
+
import type { Config, ModelTierLevel, ModelTiersConfig } from '../types/config.js';
|
|
24
|
+
import type { SubagentConfig } from '../types/multi-agent.js';
|
|
25
|
+
import type { ResolvedModelTarget } from './model-matrix.js';
|
|
26
|
+
/** Fallback default when the config names no default tier. */
|
|
27
|
+
export declare const DEFAULT_TIER_ID = "standard";
|
|
28
|
+
/** Where a tier decision came from. Mirrors `ModelMatrixResolutionSource`. */
|
|
29
|
+
export type ModelTierSource = 'explicit' | 'role' | 'phase' | 'default' | 'config-default';
|
|
30
|
+
export interface ModelTierDecision {
|
|
31
|
+
/** The chosen tier id. */
|
|
32
|
+
tier: string;
|
|
33
|
+
/** Which rung of the ladder produced it. */
|
|
34
|
+
source: ModelTierSource;
|
|
35
|
+
/** The routing key that matched, when the decision came from the table. */
|
|
36
|
+
key?: string | undefined;
|
|
37
|
+
/** True when the tier id has a configured level backing it. */
|
|
38
|
+
configured: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ModelTierBudget {
|
|
41
|
+
maxCostUsd?: number | undefined;
|
|
42
|
+
maxIterations?: number | undefined;
|
|
43
|
+
maxToolCalls?: number | undefined;
|
|
44
|
+
maxTokens?: number | undefined;
|
|
45
|
+
timeoutMs?: number | undefined;
|
|
46
|
+
}
|
|
47
|
+
export interface ResolvedTierTarget extends ResolvedModelTarget {
|
|
48
|
+
tier: string;
|
|
49
|
+
source: ModelTierSource;
|
|
50
|
+
/** Budget fields declared by the level, if any. */
|
|
51
|
+
budget: ModelTierBudget;
|
|
52
|
+
}
|
|
53
|
+
/** The tier config, normalized. Returns undefined when the layer is off. */
|
|
54
|
+
export declare function activeTierConfig(config: Config): ModelTiersConfig | undefined;
|
|
55
|
+
/** All configured level ids, in config order. Empty when the layer is off. */
|
|
56
|
+
export declare function listTierIds(config: Config): string[];
|
|
57
|
+
/** The configured level for a tier id, or undefined. */
|
|
58
|
+
export declare function tierLevel(config: Config, tier: string | undefined): ModelTierLevel | undefined;
|
|
59
|
+
/** True when `tier` names a level this config actually defines. */
|
|
60
|
+
export declare function isConfiguredTier(config: Config, tier: string | undefined): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Deterministic tier ladder.
|
|
63
|
+
*
|
|
64
|
+
* 1. `explicit` — the tool/task/caller named a tier outright.
|
|
65
|
+
* 2. `role` — routing[<roster role>].
|
|
66
|
+
* 3. `phase` — routing[<the role's phase>].
|
|
67
|
+
* 4. `default` — the routing table's `*` entry.
|
|
68
|
+
* 5. config default (`modelTiers.default`), else {@link DEFAULT_TIER_ID}.
|
|
69
|
+
*
|
|
70
|
+
* An explicit tier naming no configured level is still returned (with
|
|
71
|
+
* `configured: false`) rather than silently rewritten — callers surface it as
|
|
72
|
+
* an error instead of quietly running the job at the wrong expense.
|
|
73
|
+
*/
|
|
74
|
+
export declare function classifyTier(config: Config, input?: {
|
|
75
|
+
role?: string | undefined;
|
|
76
|
+
tier?: string | undefined;
|
|
77
|
+
}): ModelTierDecision | undefined;
|
|
78
|
+
/** Extract only the budget fields a level declares. */
|
|
79
|
+
export declare function tierBudget(level: ModelTierLevel | undefined): ModelTierBudget;
|
|
80
|
+
/**
|
|
81
|
+
* Expand a level into a concrete model target by reusing the model-matrix
|
|
82
|
+
* expander. A level IS a matrix entry plus a budget, so the profile-as-primary
|
|
83
|
+
* semantics (chain[0] primary, remainder failover) come for free and stay
|
|
84
|
+
* identical between the two tables.
|
|
85
|
+
*/
|
|
86
|
+
export declare function tierModelTarget(config: Config, level: ModelTierLevel | undefined): ResolvedModelTarget | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Full resolution: classify, then expand. Returns undefined when the layer is
|
|
89
|
+
* off or the chosen tier has no configured level — in both cases the caller
|
|
90
|
+
* keeps whatever it already resolved.
|
|
91
|
+
*/
|
|
92
|
+
export declare function resolveTier(config: Config, input?: {
|
|
93
|
+
role?: string | undefined;
|
|
94
|
+
tier?: string | undefined;
|
|
95
|
+
}): ResolvedTierTarget | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Apply a resolved tier to a subagent config.
|
|
98
|
+
*
|
|
99
|
+
* Model fields are FILL-ONLY: an explicit `delegate({ model })` or a `/setmodel`
|
|
100
|
+
* role pin is a decision the user already made, and a tier is only a default.
|
|
101
|
+
*
|
|
102
|
+
* Spend budgets are different, and getting this wrong makes the whole feature
|
|
103
|
+
* pointless. By the time a spawn reaches here, `applyRosterBudget` /
|
|
104
|
+
* `instantiateRosterConfig` have ALREADY populated every budget field with the
|
|
105
|
+
* role's generous default — so a fill-only rule would mean a 'budget' tier
|
|
106
|
+
* changes the model but never the spend ceiling, which is not a budget at all.
|
|
107
|
+
* The rule is therefore:
|
|
108
|
+
*
|
|
109
|
+
* - caller-pinned (`cfg.budgetPins`) → never touched; a number the user typed wins.
|
|
110
|
+
* - unset → set from the tier.
|
|
111
|
+
* - set by a roster/generic default → TIGHTENED to the tier value (min), never raised.
|
|
112
|
+
*
|
|
113
|
+
* Tightening only, never raising: a tier must not be able to silently grant a
|
|
114
|
+
* worker more money than its role was designed to spend.
|
|
115
|
+
*
|
|
116
|
+
* `timeoutMs` is excluded from tightening on purpose. Clamping a wall-clock
|
|
117
|
+
* budget down is the exact shape of the bug that once capped 10-hour roster
|
|
118
|
+
* agents at ~4 minutes, and a cost label is not a good reason to kill a
|
|
119
|
+
* long-running job mid-flight. It stays fill-only.
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyTierToSubagentConfig(cfg: SubagentConfig, resolved: ResolvedTierTarget | undefined): void;
|
|
122
|
+
//# sourceMappingURL=model-tier.d.ts.map
|
|
@@ -53,6 +53,30 @@ export declare class DefaultMultiAgentCoordinator extends EventEmitter implement
|
|
|
53
53
|
private readonly terminating;
|
|
54
54
|
constructor(config: MultiAgentConfig, options?: MultiAgentCoordinatorOptions);
|
|
55
55
|
private currentSessionId;
|
|
56
|
+
/**
|
|
57
|
+
* The session that owns a subagent — its spawn-time stamp.
|
|
58
|
+
*
|
|
59
|
+
* Every per-subagent emission routes through here instead of
|
|
60
|
+
* `currentSessionId()`. The fallback covers ids the coordinator never
|
|
61
|
+
* spawned (a caller reporting `completeTask` for an unknown worker); a
|
|
62
|
+
* subagent this coordinator created always has its own stamp.
|
|
63
|
+
*/
|
|
64
|
+
sessionOf(subagentId: string): string;
|
|
65
|
+
/** Every subagent this coordinator holds for one session. */
|
|
66
|
+
subagentIdsForSession(sessionId: string): string[];
|
|
67
|
+
/**
|
|
68
|
+
* Stop every subagent belonging to ONE session, and drop that session's
|
|
69
|
+
* still-queued tasks.
|
|
70
|
+
*
|
|
71
|
+
* This is what a tab's Stop button needs. `stopAll()` is the wrong tool with
|
|
72
|
+
* four tabs live — it would kill three other tabs' work — and until subagents
|
|
73
|
+
* carried a session stamp there was no way to express the narrower intent, so
|
|
74
|
+
* stopping a run left its workers grinding on in the background.
|
|
75
|
+
*
|
|
76
|
+
* Pending tasks pinned to those subagents are drained as aborted so anything
|
|
77
|
+
* awaiting them (the delegate tool, report-back) resolves instead of hanging.
|
|
78
|
+
*/
|
|
79
|
+
stopSession(sessionId: string): Promise<void>;
|
|
56
80
|
/**
|
|
57
81
|
* Replace the runner after construction. Used when the runner depends
|
|
58
82
|
* on infrastructure (e.g. FleetBus) that isn't available until after
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `callerSessionId` — which conversation is asking?
|
|
3
|
+
*
|
|
4
|
+
* Spawning tools run inside the caller's `Context`, and the answer they need
|
|
5
|
+
* is the run-pinned session: with several tabs sharing one process, the host's
|
|
6
|
+
* own writer names the session it booted with, not the one that just called
|
|
7
|
+
* `delegate`. The pinned id is set for the whole run (see `Agent.run`), so it
|
|
8
|
+
* survives a tab switch mid-run — which the live reading does not.
|
|
9
|
+
*
|
|
10
|
+
* The parameter is typed loosely on purpose: tool `execute` receives an opaque
|
|
11
|
+
* context, and a few hosts pass partial stand-ins.
|
|
12
|
+
*
|
|
13
|
+
* @module origin-session
|
|
14
|
+
*/
|
|
15
|
+
export declare function callerSessionId(ctx: unknown, fallback?: string): string | undefined;
|
|
16
|
+
//# sourceMappingURL=origin-session.d.ts.map
|
|
@@ -22,9 +22,12 @@
|
|
|
22
22
|
* | Metric | Threshold | Action |
|
|
23
23
|
* |--------|-----------|--------|
|
|
24
24
|
* | consecutive failures ≥ 2 | → `degraded` for 30 s |
|
|
25
|
-
* | rate-limit hits ≥ 1 | → `blocked` for
|
|
26
|
-
* | consecutive failures ≥ 5 | → `blocked` for
|
|
27
|
-
* |
|
|
25
|
+
* | rate-limit hits ≥ 1 | → `blocked` for 2 min |
|
|
26
|
+
* | consecutive failures ≥ 5 | → `blocked` for 2 min |
|
|
27
|
+
* | quota exhaustion (1st) | → `blocked` for 15 min |
|
|
28
|
+
* | quota exhaustion (repeat) | → `blocked` 30 min, then capped at 1 h |
|
|
29
|
+
* | quota reset time published | → `blocked` until exactly that time |
|
|
30
|
+
* | success streak ≥ 3 | → back to `healthy` (also resets quota escalation) |
|
|
28
31
|
* | `blocked` timeout elapses | → back to `healthy` |
|
|
29
32
|
*
|
|
30
33
|
* - **Error history**: keeps the last N errors per pair, with session id,
|
|
@@ -98,16 +101,28 @@ export interface ProviderStatusTrackerConfig {
|
|
|
98
101
|
*/
|
|
99
102
|
blockAfterFailures?: number;
|
|
100
103
|
/**
|
|
101
|
-
* Duration (ms) the provider stays `blocked
|
|
104
|
+
* Duration (ms) the provider stays `blocked` for ordinary failures
|
|
105
|
+
* (rate-limit threshold, consecutive-failure threshold). These are
|
|
106
|
+
* transient — short cooldowns re-probe quickly instead of parking a
|
|
107
|
+
* recoverable model for minutes. Default: 120_000 (2 min).
|
|
102
108
|
*/
|
|
103
109
|
blockDurationMs?: number;
|
|
104
110
|
/**
|
|
105
|
-
* Cooldown for
|
|
111
|
+
* Cooldown for the FIRST exhausted-credit/quota response when the
|
|
106
112
|
* provider does not publish a reset hint. These failures enter the waiting
|
|
107
113
|
* room immediately instead of consuming the ordinary rate-limit threshold.
|
|
114
|
+
* Repeated quota blocks escalate via {@link quotaBlockEscalationMs}.
|
|
108
115
|
* Default: 900_000 (15 min).
|
|
109
116
|
*/
|
|
110
117
|
quotaBlockDurationMs?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Escalating cooldowns (ms) for REPEATED quota blocks: each time a quota
|
|
120
|
+
* block expires and the next result is quota-exhausted again, the next
|
|
121
|
+
* tier applies; the last entry caps the escalation. A recorded success
|
|
122
|
+
* (or manual unblock/clear) resets the ladder. Default:
|
|
123
|
+
* [1_800_000, 3_600_000] — 2nd block 30 min, 3rd+ blocks 1 h max.
|
|
124
|
+
*/
|
|
125
|
+
quotaBlockEscalationMs?: number[];
|
|
111
126
|
/**
|
|
112
127
|
* Consecutive successes needed to leave `degraded` or `blocked` and return
|
|
113
128
|
* to `healthy` (if the timeout hasn't already cleared it). Default: 3.
|
|
@@ -159,6 +174,14 @@ export declare class ProviderModelStatusTracker {
|
|
|
159
174
|
agentId?: string | undefined;
|
|
160
175
|
retryAfterMs?: number | undefined;
|
|
161
176
|
}): ProviderModelState;
|
|
177
|
+
/**
|
|
178
|
+
* Quarantine fan-out expiry: the fixed quota cooldown, never the
|
|
179
|
+
* hint-extended trigger expiry. A weekly-cap reset time applies to the
|
|
180
|
+
* model that published it; sibling models (and unseen pairs behind the
|
|
181
|
+
* provider-wide gate) re-open after the base cooldown so one misclassified
|
|
182
|
+
* or hint-stretched failure cannot silence a whole provider for hours.
|
|
183
|
+
*/
|
|
184
|
+
private fanOutExpiryFor;
|
|
162
185
|
/**
|
|
163
186
|
* Mark every other tracked pair on the same provider as blocked with the
|
|
164
187
|
* same expiry as the triggering pair. Only pairs already known to the
|
|
@@ -205,6 +228,8 @@ export declare class ProviderModelStatusTracker {
|
|
|
205
228
|
/**
|
|
206
229
|
* Release one entry for an immediate half-open probe on its next real use.
|
|
207
230
|
* History and totals are retained so operators do not lose diagnostics.
|
|
231
|
+
* The quota escalation streak is also retained on purpose: a probe that
|
|
232
|
+
* fails with quota exhaustion again keeps climbing the ladder.
|
|
208
233
|
*/
|
|
209
234
|
retryNow(providerId: string, model: string): boolean;
|
|
210
235
|
/**
|
|
@@ -248,6 +273,13 @@ export declare class ProviderModelStatusTracker {
|
|
|
248
273
|
getSnapshot(): ProviderStatusSnapshot;
|
|
249
274
|
/** Restore non-expired waiting-room entries from a previous process. */
|
|
250
275
|
restoreSnapshot(value: unknown): number;
|
|
276
|
+
/**
|
|
277
|
+
* Cooldown for the Nth consecutive quota block: the base duration for the
|
|
278
|
+
* first block, then the escalation ladder for repeats, capped at the last
|
|
279
|
+
* ladder entry. A provider-published reset hint bypasses this entirely
|
|
280
|
+
* (the pair is closed until that exact time instead).
|
|
281
|
+
*/
|
|
282
|
+
private quotaBlockDurationForStreak;
|
|
251
283
|
private getOrCreate;
|
|
252
284
|
private freezeStatus;
|
|
253
285
|
private emitStatusChanged;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionNoteHub — in-process, same-session delivery for agent notes.
|
|
3
|
+
*
|
|
4
|
+
* Mailbox is the durable, cross-session letter. This hub is the live talk
|
|
5
|
+
* channel: register an inbox per running agent, post a note, the recipient
|
|
6
|
+
* folds it at its next iteration. Fail-closed on session id. No disk, no
|
|
7
|
+
* capability.mail, no wait.
|
|
8
|
+
*
|
|
9
|
+
* @module session-note-hub
|
|
10
|
+
*/
|
|
11
|
+
import type { EventBus } from '../kernel/events.js';
|
|
12
|
+
import type { SessionNote, SessionNoteKind } from '../core/session-notes.js';
|
|
13
|
+
export interface SessionNotePost {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
from: string;
|
|
16
|
+
/** `leader`, a live agent id, `@session`, or `*` (session-local broadcast). */
|
|
17
|
+
to: string;
|
|
18
|
+
kind: SessionNoteKind;
|
|
19
|
+
body: string;
|
|
20
|
+
subject?: string | undefined;
|
|
21
|
+
/** Observability bus (typically the leader/session bus). */
|
|
22
|
+
events?: EventBus | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionNoteInbox {
|
|
25
|
+
sessionId: string | (() => string | undefined);
|
|
26
|
+
agentId: string;
|
|
27
|
+
aliases?: readonly string[] | undefined;
|
|
28
|
+
deliver: (note: SessionNote) => void;
|
|
29
|
+
/** First bus registered for a session is used to emit `session.note`. */
|
|
30
|
+
events?: EventBus | undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface SessionNotePostResult {
|
|
33
|
+
delivered: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class SessionNoteHub {
|
|
36
|
+
private readonly inboxes;
|
|
37
|
+
private readonly buses;
|
|
38
|
+
register(inbox: SessionNoteInbox): () => void;
|
|
39
|
+
post(input: SessionNotePost): SessionNotePostResult;
|
|
40
|
+
}
|
|
41
|
+
/** Process-wide hub. Agent loops register; tools and hosts post. */
|
|
42
|
+
export declare const sessionNoteHub: SessionNoteHub;
|
|
43
|
+
export declare function postSessionNote(input: SessionNotePost): SessionNotePostResult;
|
|
44
|
+
//# sourceMappingURL=session-note-hub.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `session_note` — same-session, in-process talk between the leader and
|
|
3
|
+
* live agents. Not mailbox: nothing is persisted, other sessions never
|
|
4
|
+
* see it, and `coordination.mail` is not required.
|
|
5
|
+
*
|
|
6
|
+
* @module session-note-tool
|
|
7
|
+
*/
|
|
8
|
+
import type { Tool } from '../types/tool.js';
|
|
9
|
+
export declare function makeSessionNoteTool(): Tool;
|
|
10
|
+
//# sourceMappingURL=session-note-tool.d.ts.map
|
package/dist/core/agent.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { Tool } from '../types/tool.js';
|
|
|
14
14
|
import type { ToolExecutorLike } from '../types/tool-executor.js';
|
|
15
15
|
import { type AgentInit, type AgentInput, type AgentPipelines, type ResolvedLoopDetectionConfig, type RunResult } from './agent-types.js';
|
|
16
16
|
import type { Context, RunOptions } from './context.js';
|
|
17
|
-
export { type AgentInit, type AgentInput, type AgentPipelines, createDefaultPipelines, DEFAULT_MAX_ITERATIONS, normalizeInput, type ResolvedLoopDetectionConfig, type RunResult,
|
|
17
|
+
export { type AgentInit, type AgentInput, type AgentPipelines, createDefaultPipelines, DEFAULT_MAX_ITERATIONS, normalizeInput, type ResolvedLoopDetectionConfig, resolveLoopDetection, type RunResult, type ToolCallPipelinePayload, type UserInputPayload, } from './agent-types.js';
|
|
18
18
|
export declare class Agent {
|
|
19
19
|
readonly container: Container;
|
|
20
20
|
readonly tools: ToolRegistry;
|
package/dist/core/context.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { TextBlock } from '../types/blocks.js';
|
|
2
|
+
import type { AgentContext, ContextMessageLimits, TodoItem } from '../types/context.js';
|
|
2
3
|
import type { ContextEvidenceState } from '../types/context-evidence.js';
|
|
3
4
|
import type { FileEventRecord } from '../types/file-event-record.js';
|
|
4
5
|
import type { Message } from '../types/messages.js';
|
|
5
6
|
import type { Provider, Usage } from '../types/provider.js';
|
|
7
|
+
import type { RunEnv } from '../types/run-env.js';
|
|
6
8
|
import type { SessionEvent, SessionWriter } from '../types/session.js';
|
|
7
9
|
import type { TokenCounter } from '../types/token-counter.js';
|
|
8
10
|
import type { Tool } from '../types/tool.js';
|
|
9
|
-
import type { AgentContext, ContextMessageLimits } from '../types/context.js';
|
|
10
|
-
import type { RunEnv } from '../types/run-env.js';
|
|
11
11
|
import { ConversationState } from './conversation-state.js';
|
|
12
|
-
import type { TodoItem } from '../types/context.js';
|
|
13
12
|
export type { TodoItem };
|
|
14
13
|
export interface RunOptions {
|
|
15
14
|
signal?: AbortSignal | undefined;
|
|
@@ -321,9 +320,11 @@ export declare class Context implements RunEnv, AgentContext {
|
|
|
321
320
|
event: SessionEvent;
|
|
322
321
|
bytes: number;
|
|
323
322
|
writer: SessionWriter;
|
|
323
|
+
attempts?: number;
|
|
324
324
|
}>;
|
|
325
325
|
_conversationJournalBytes: number;
|
|
326
326
|
_conversationJournalDrain: Promise<void> | null;
|
|
327
|
+
_conversationJournalLastError: Error | null;
|
|
327
328
|
private static readonly CONVERSATION_JOURNAL_MAX_EVENTS;
|
|
328
329
|
private static readonly CONVERSATION_JOURNAL_MAX_BYTES;
|
|
329
330
|
private static readonly MAX_FILE_EVENTS;
|
|
@@ -500,4 +501,22 @@ export declare class Context implements RunEnv, AgentContext {
|
|
|
500
501
|
* `session` may be missing despite the non-optional type.
|
|
501
502
|
*/
|
|
502
503
|
export declare function resolveEventSessionId(ctx: AgentContext): string;
|
|
504
|
+
/**
|
|
505
|
+
* Session that OWNS this agent — the conversation a surface is showing.
|
|
506
|
+
*
|
|
507
|
+
* Different question from {@link resolveEventSessionId}, which answers "where
|
|
508
|
+
* do this run's journal events go". A subagent spawned with `sessionsRoot`
|
|
509
|
+
* configured (the real CLI always configures it) is handed its own journal, so
|
|
510
|
+
* both `ctx.session.id` and the run-pinned id name a private transcript that no
|
|
511
|
+
* tab is subscribed to. Anything routed BETWEEN agents of one conversation —
|
|
512
|
+
* mailbox identity and registration, `@session` recipient normalisation,
|
|
513
|
+
* `session_note` inboxes — has to key off the spawning conversation instead, or
|
|
514
|
+
* a worker's report reaches nobody.
|
|
515
|
+
*
|
|
516
|
+
* `meta.sessionId` is that spawn-time stamp, fixed for the worker's lifetime
|
|
517
|
+
* (deliberately not a live read of the host's session, which moves whenever the
|
|
518
|
+
* user switches tabs). Leaders carry no stamp and fall through to the event id,
|
|
519
|
+
* which for them is the same session and follows resume / session.new.
|
|
520
|
+
*/
|
|
521
|
+
export declare function resolveOwningSessionId(ctx: AgentContext): string;
|
|
503
522
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Agent, type RunResult, type UserInputPayload, } from './agent.js';
|
|
2
2
|
export { type AgentInit, type AgentInput, type AgentPipelines, createDefaultPipelines, type ToolCallPipelinePayload, } from './agent-types.js';
|
|
3
3
|
export { buildBtwBlock, consumeBtwNotes, pendingBtwCount, setBtwNote, } from './btw.js';
|
|
4
|
+
export { buildSessionNoteBlock, consumeSessionNotes, enqueueSessionNote, pendingSessionNoteCount, type SessionNote, type SessionNoteKind, } from './session-notes.js';
|
|
4
5
|
export { Context, type ContextInit, type ProviderMemoryEvidence, type RunOptions, type TodoItem, } from './context.js';
|
|
5
6
|
export { type ContinuationInput, type ContinuationSource, detectContinueIntent, type ResolvedContinuation, resolveContinuation, } from './continue-intent.js';
|
|
6
7
|
export { ConversationState, type ReadonlyConversationState, type StateChange, type StateChangeHandler, wrapAsState, } from './conversation-state.js';
|
|
@@ -16,4 +17,5 @@ export { runProviderWithRetry } from './provider-runner.js';
|
|
|
16
17
|
export { setQueuedMessagesSnapshot } from './queued-messages.js';
|
|
17
18
|
export { buildIdentityLayer, DefaultSystemPromptBuilder, type DefaultSystemPromptBuilderOptions, type SystemBlockSource, } from './system-prompt-builder.js';
|
|
18
19
|
export { type DomainGlossaryOptions, renderDomainGlossary, } from './system-prompt-glossary.js';
|
|
20
|
+
export { countSystemPromptTokens, isSystemInstructionVariant, persistSystemPromptVariant, readSavedSystemPromptVariant, SYSTEM_PROMPT_VARIANT_OPTIONS, SYSTEM_PROMPT_VARIANTS, type SystemPromptVariantPaths, systemPromptVariantLabel, } from './system-prompt-variants.js';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent,
|
|
3
3
|
InputBuilder,
|
|
4
|
+
buildSessionNoteBlock,
|
|
5
|
+
consumeSessionNotes,
|
|
4
6
|
createDefaultPipelines,
|
|
5
7
|
detectContinueIntent,
|
|
8
|
+
enqueueSessionNote,
|
|
9
|
+
pendingSessionNoteCount,
|
|
6
10
|
resolveContinuation,
|
|
7
11
|
setQueuedMessagesSnapshot
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-YOPAUVU4.js";
|
|
13
|
+
import "../chunk-RFQMOKWK.js";
|
|
14
|
+
import "../chunk-NIOAGFPB.js";
|
|
10
15
|
import "../chunk-Z2IJUO45.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-MTL4O5YR.js";
|
|
17
|
+
import "../chunk-HXKZ7OBQ.js";
|
|
18
|
+
import "../chunk-WP7BVANJ.js";
|
|
19
|
+
import "../chunk-JO4MGB6Z.js";
|
|
20
|
+
import "../chunk-PQNS3U7Z.js";
|
|
21
|
+
import "../chunk-IRUTEHCE.js";
|
|
22
|
+
import "../chunk-FWNLEZYG.js";
|
|
18
23
|
import {
|
|
19
24
|
buildBtwBlock,
|
|
20
25
|
consumeBtwNotes,
|
|
@@ -28,27 +33,18 @@ import {
|
|
|
28
33
|
runProviderWithRetry,
|
|
29
34
|
runtimeFallbackChain,
|
|
30
35
|
smartDefaultFallbackChain
|
|
31
|
-
} from "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
36
|
+
} from "../chunk-U45AXT5D.js";
|
|
37
|
+
import "../chunk-4SJNS7OB.js";
|
|
38
|
+
import "../chunk-Y5YXDM7D.js";
|
|
34
39
|
import "../chunk-HA4ZYA6T.js";
|
|
35
|
-
import "../chunk-A455ATZB.js";
|
|
36
40
|
import {
|
|
37
41
|
FallbackProfileManager,
|
|
38
42
|
evaluateModelCalendar
|
|
39
43
|
} from "../chunk-WQQON3SV.js";
|
|
40
44
|
import "../chunk-2YU4WVBW.js";
|
|
41
|
-
import "../chunk-
|
|
42
|
-
import "../chunk-
|
|
43
|
-
import "../chunk-
|
|
44
|
-
import {
|
|
45
|
-
formatModelRef,
|
|
46
|
-
normalizeModelRef,
|
|
47
|
-
parseModelRef
|
|
48
|
-
} from "../chunk-RJIZEJ42.js";
|
|
49
|
-
import {
|
|
50
|
-
isFallbackWorthy
|
|
51
|
-
} from "../chunk-NFAYHPRH.js";
|
|
45
|
+
import "../chunk-QSTSJOCK.js";
|
|
46
|
+
import "../chunk-6FHWXLPT.js";
|
|
47
|
+
import "../chunk-UBGDX6FI.js";
|
|
52
48
|
import {
|
|
53
49
|
DefaultSystemPromptBuilder,
|
|
54
50
|
MAX_PENDING_NEXT_STEPS,
|
|
@@ -62,33 +58,46 @@ import {
|
|
|
62
58
|
renderInstructionLayer,
|
|
63
59
|
renderNextStepsBlock,
|
|
64
60
|
writePendingNextSteps
|
|
65
|
-
} from "../chunk-
|
|
61
|
+
} from "../chunk-M27LIEKV.js";
|
|
66
62
|
import "../chunk-XEBHSJLT.js";
|
|
67
|
-
import "../chunk-
|
|
68
|
-
import "../chunk-
|
|
69
|
-
import "../chunk-4XV6IR37.js";
|
|
63
|
+
import "../chunk-6NWEVFEL.js";
|
|
64
|
+
import "../chunk-LSMMOS2Z.js";
|
|
70
65
|
import "../chunk-4VWO3ZXL.js";
|
|
71
66
|
import {
|
|
72
67
|
Context,
|
|
73
68
|
ConversationState,
|
|
74
69
|
wrapAsState
|
|
75
|
-
} from "../chunk-
|
|
76
|
-
import "../chunk-
|
|
77
|
-
import
|
|
70
|
+
} from "../chunk-ZHZ2Y2DH.js";
|
|
71
|
+
import "../chunk-HI3JGZR2.js";
|
|
72
|
+
import {
|
|
73
|
+
estimateTextTokens
|
|
74
|
+
} from "../chunk-HMLIGAU7.js";
|
|
78
75
|
import "../chunk-TRT2HRWZ.js";
|
|
79
76
|
import "../chunk-LX5QWLBL.js";
|
|
80
|
-
import "../chunk-
|
|
81
|
-
import
|
|
77
|
+
import "../chunk-POOOIWE5.js";
|
|
78
|
+
import {
|
|
79
|
+
atomicWrite
|
|
80
|
+
} from "../chunk-OSGLYW5J.js";
|
|
81
|
+
import "../chunk-FC2ZGRF3.js";
|
|
82
|
+
import "../chunk-THEGTRAG.js";
|
|
82
83
|
import "../chunk-SVT4RNTR.js";
|
|
83
|
-
import "../chunk-
|
|
84
|
-
import "../chunk-
|
|
85
|
-
import
|
|
84
|
+
import "../chunk-SAFHACFA.js";
|
|
85
|
+
import "../chunk-NS52ISWS.js";
|
|
86
|
+
import {
|
|
87
|
+
formatModelRef,
|
|
88
|
+
normalizeModelRef,
|
|
89
|
+
parseModelRef
|
|
90
|
+
} from "../chunk-RJIZEJ42.js";
|
|
91
|
+
import {
|
|
92
|
+
isFallbackWorthy
|
|
93
|
+
} from "../chunk-3ECENVHL.js";
|
|
94
|
+
import "../chunk-VVBP6KGT.js";
|
|
86
95
|
import "../chunk-KJ2ZTQSL.js";
|
|
87
96
|
import "../chunk-B4AMLZPB.js";
|
|
97
|
+
import "../chunk-PFZO3C6H.js";
|
|
88
98
|
import "../chunk-O37BQ65S.js";
|
|
89
|
-
import "../chunk-
|
|
99
|
+
import "../chunk-25LSLC3G.js";
|
|
90
100
|
import "../chunk-TBRL2RCC.js";
|
|
91
|
-
import "../chunk-PFZO3C6H.js";
|
|
92
101
|
|
|
93
102
|
// src/core/fallback-doctor.ts
|
|
94
103
|
function diagnoseFallbackConfig(config, tracker, opts) {
|
|
@@ -287,6 +296,78 @@ function simulateFallbackFailover(config, opts = {}) {
|
|
|
287
296
|
summary
|
|
288
297
|
});
|
|
289
298
|
}
|
|
299
|
+
|
|
300
|
+
// src/core/system-prompt-variants.ts
|
|
301
|
+
import * as fs from "node:fs/promises";
|
|
302
|
+
var SYSTEM_PROMPT_VARIANT_OPTIONS = [
|
|
303
|
+
{ variant: "lite", label: "Lite", hint: "leanest - best for small context windows" },
|
|
304
|
+
{ variant: "default", label: "Standard", hint: "balanced - the default" },
|
|
305
|
+
{ variant: "pro", label: "Pro", hint: "most detailed guidance - uses more tokens" }
|
|
306
|
+
];
|
|
307
|
+
var SYSTEM_PROMPT_VARIANTS = SYSTEM_PROMPT_VARIANT_OPTIONS.map((o) => o.variant);
|
|
308
|
+
var VALID_VARIANTS = new Set(SYSTEM_PROMPT_VARIANTS);
|
|
309
|
+
function isSystemInstructionVariant(value) {
|
|
310
|
+
return typeof value === "string" && VALID_VARIANTS.has(value);
|
|
311
|
+
}
|
|
312
|
+
function systemPromptVariantLabel(variant) {
|
|
313
|
+
return SYSTEM_PROMPT_VARIANT_OPTIONS.find((o) => o.variant === variant)?.label ?? variant;
|
|
314
|
+
}
|
|
315
|
+
async function countSystemPromptTokens(paths) {
|
|
316
|
+
const counts = {};
|
|
317
|
+
for (const variant of SYSTEM_PROMPT_VARIANTS) {
|
|
318
|
+
const bundle = await loadInstructionBundle({
|
|
319
|
+
globalDir: paths.globalDir,
|
|
320
|
+
projectDir: paths.projectDir,
|
|
321
|
+
systemVariant: variant
|
|
322
|
+
});
|
|
323
|
+
const identity = buildIdentityLayer(
|
|
324
|
+
bundle.system?.identity,
|
|
325
|
+
bundle.system?.identitySource,
|
|
326
|
+
void 0
|
|
327
|
+
);
|
|
328
|
+
counts[variant] = estimateTextTokens(identity);
|
|
329
|
+
}
|
|
330
|
+
return counts;
|
|
331
|
+
}
|
|
332
|
+
async function readSavedSystemPromptVariant(configPath) {
|
|
333
|
+
let raw;
|
|
334
|
+
try {
|
|
335
|
+
raw = await fs.readFile(configPath, "utf8");
|
|
336
|
+
} catch {
|
|
337
|
+
return void 0;
|
|
338
|
+
}
|
|
339
|
+
try {
|
|
340
|
+
const parsed = JSON.parse(raw);
|
|
341
|
+
const variant = parsed.systemPrompt?.variant;
|
|
342
|
+
return isSystemInstructionVariant(variant) ? variant : void 0;
|
|
343
|
+
} catch {
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async function persistSystemPromptVariant(configPath, variant) {
|
|
348
|
+
let fileExists = false;
|
|
349
|
+
try {
|
|
350
|
+
await fs.access(configPath);
|
|
351
|
+
fileExists = true;
|
|
352
|
+
} catch {
|
|
353
|
+
}
|
|
354
|
+
let existing = {};
|
|
355
|
+
try {
|
|
356
|
+
const raw = await fs.readFile(configPath, "utf8");
|
|
357
|
+
existing = JSON.parse(raw);
|
|
358
|
+
} catch (err) {
|
|
359
|
+
if (fileExists) {
|
|
360
|
+
throw new Error(
|
|
361
|
+
`Refusing to overwrite corrupt config at ${configPath} (${err.message}). Fix or move the file aside before retrying.`,
|
|
362
|
+
{ cause: err }
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
existing = {};
|
|
366
|
+
}
|
|
367
|
+
const systemPrompt = existing.systemPrompt ?? {};
|
|
368
|
+
existing.systemPrompt = { ...systemPrompt, variant };
|
|
369
|
+
await atomicWrite(configPath, JSON.stringify(existing, null, 2), { mode: 384 });
|
|
370
|
+
}
|
|
290
371
|
export {
|
|
291
372
|
Agent,
|
|
292
373
|
Context,
|
|
@@ -295,24 +376,34 @@ export {
|
|
|
295
376
|
FallbackProfileManager,
|
|
296
377
|
InputBuilder,
|
|
297
378
|
MAX_PENDING_NEXT_STEPS,
|
|
379
|
+
SYSTEM_PROMPT_VARIANTS,
|
|
380
|
+
SYSTEM_PROMPT_VARIANT_OPTIONS,
|
|
298
381
|
buildBtwBlock,
|
|
299
382
|
buildIdentityLayer,
|
|
383
|
+
buildSessionNoteBlock,
|
|
300
384
|
clearPendingNextSteps,
|
|
301
385
|
consumeBtwNotes,
|
|
386
|
+
consumeSessionNotes,
|
|
387
|
+
countSystemPromptTokens,
|
|
302
388
|
createDefaultPipelines,
|
|
303
389
|
createFallbackModelExtension,
|
|
304
390
|
detectContinueIntent,
|
|
305
391
|
diagnoseFallbackConfig,
|
|
306
392
|
effectiveFallbackChain,
|
|
393
|
+
enqueueSessionNote,
|
|
307
394
|
fallbackProfileChain,
|
|
308
395
|
formatModelRef,
|
|
309
396
|
hasNextStepsTag,
|
|
397
|
+
isSystemInstructionVariant,
|
|
310
398
|
loadInstructionBundle,
|
|
311
399
|
maybeAppendPendingNextSteps,
|
|
312
400
|
normalizeModelRef,
|
|
313
401
|
parseModelRef,
|
|
314
402
|
pendingBtwCount,
|
|
403
|
+
pendingSessionNoteCount,
|
|
404
|
+
persistSystemPromptVariant,
|
|
315
405
|
readPendingNextSteps,
|
|
406
|
+
readSavedSystemPromptVariant,
|
|
316
407
|
renderDomainGlossary,
|
|
317
408
|
renderInstructionLayer,
|
|
318
409
|
renderNextStepsBlock,
|
|
@@ -323,6 +414,7 @@ export {
|
|
|
323
414
|
setQueuedMessagesSnapshot,
|
|
324
415
|
simulateFallbackFailover,
|
|
325
416
|
smartDefaultFallbackChain,
|
|
417
|
+
systemPromptVariantLabel,
|
|
326
418
|
wrapAsState,
|
|
327
419
|
writePendingNextSteps
|
|
328
420
|
};
|