@wrongstack/core 0.313.0 → 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 +84 -6391
- 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 +98 -4874
- package/dist/chronicle/sink.d.ts +13 -0
- package/dist/chronicle/sqlite-journal.d.ts +20 -2
- package/dist/chunk-25LSLC3G.js +334 -0
- package/dist/chunk-27QIURLN.js +1073 -0
- package/dist/chunk-2FK4WTFF.js +207 -0
- package/dist/chunk-2YU4WVBW.js +134 -0
- package/dist/chunk-3AGWVSS7.js +4608 -0
- package/dist/chunk-3BDV7RL3.js +211 -0
- package/dist/chunk-3ECENVHL.js +325 -0
- package/dist/chunk-3XPVB7BA.js +135 -0
- package/dist/chunk-45WI72ZB.js +16884 -0
- package/dist/chunk-4BMVPOHO.js +3748 -0
- package/dist/chunk-4I7HGVVA.js +363 -0
- package/dist/chunk-4LCZVJVF.js +317 -0
- package/dist/chunk-4SJNS7OB.js +217 -0
- package/dist/chunk-4VWO3ZXL.js +342 -0
- package/dist/chunk-57GEWK5X.js +26 -0
- package/dist/chunk-5BMIE7QG.js +46 -0
- package/dist/chunk-5S437PRC.js +50 -0
- package/dist/chunk-5XDUGTKN.js +511 -0
- package/dist/chunk-5YPSXQXM.js +1443 -0
- package/dist/chunk-6FHWXLPT.js +10 -0
- package/dist/chunk-6H5GEOET.js +2406 -0
- package/dist/chunk-6NWEVFEL.js +151 -0
- package/dist/chunk-AYW5YINX.js +58 -0
- package/dist/chunk-B4AMLZPB.js +9 -0
- package/dist/chunk-B7F4WVP4.js +65 -0
- package/dist/chunk-BJHVULHO.js +55 -0
- package/dist/chunk-BPBKKBUK.js +2085 -0
- package/dist/chunk-BYD345OX.js +589 -0
- package/dist/chunk-C27KDLOX.js +279 -0
- package/dist/chunk-CU546ESW.js +597 -0
- package/dist/chunk-DLHHXUAM.js +172 -0
- package/dist/chunk-DOTHQSJ2.js +429 -0
- package/dist/chunk-DYLPMV4Q.js +711 -0
- package/dist/chunk-EODDVJBM.js +82 -0
- package/dist/chunk-F3JWNST7.js +361 -0
- package/dist/chunk-FC2ZGRF3.js +140 -0
- package/dist/chunk-FCBTO76Z.js +5786 -0
- package/dist/chunk-FHZVFYSL.js +396 -0
- package/dist/chunk-FNXVT7HF.js +52 -0
- package/dist/chunk-FWNLEZYG.js +259 -0
- package/dist/chunk-FXQLIX3K.js +211 -0
- package/dist/chunk-G5S3S5ZN.js +38 -0
- package/dist/chunk-GDQ7CZRQ.js +116 -0
- package/dist/chunk-GJJGJB2R.js +1374 -0
- package/dist/chunk-GTCU6DZ3.js +1 -0
- package/dist/chunk-HA4ZYA6T.js +178 -0
- package/dist/chunk-HI3JGZR2.js +188 -0
- package/dist/chunk-HMLIGAU7.js +395 -0
- package/dist/chunk-HXKZ7OBQ.js +303 -0
- package/dist/chunk-I7DALG7J.js +292 -0
- package/dist/chunk-IRUTEHCE.js +960 -0
- package/dist/chunk-IYFBFX34.js +86 -0
- package/dist/chunk-J2WRWR37.js +1104 -0
- package/dist/chunk-JFPJ6LLQ.js +129 -0
- package/dist/chunk-JMULFFLN.js +9 -0
- package/dist/chunk-JO4MGB6Z.js +1264 -0
- package/dist/chunk-JVKB2TBL.js +48 -0
- package/dist/chunk-JX7VBZDK.js +31 -0
- package/dist/chunk-K6BXGITA.js +931 -0
- package/dist/chunk-KDQJCT2J.js +45 -0
- package/dist/chunk-KJ2ZTQSL.js +47 -0
- package/dist/chunk-KZMSZV32.js +187 -0
- package/dist/chunk-LA7CLDRW.js +129 -0
- package/dist/chunk-LHOA5DWA.js +28 -0
- package/dist/chunk-LSMMOS2Z.js +119 -0
- package/dist/chunk-LX5QWLBL.js +27 -0
- package/dist/chunk-LXWCMQNJ.js +789 -0
- package/dist/chunk-M27LIEKV.js +2829 -0
- package/dist/chunk-MJPHJRAL.js +663 -0
- package/dist/chunk-MTL4O5YR.js +228 -0
- package/dist/chunk-NDBIPFNY.js +102 -0
- package/dist/chunk-NEMIWEXC.js +1199 -0
- package/dist/chunk-NHJ75HXY.js +1 -0
- package/dist/chunk-NIOAGFPB.js +1510 -0
- package/dist/chunk-NS52ISWS.js +355 -0
- package/dist/chunk-NSOFPKGT.js +5352 -0
- package/dist/chunk-NVIZG63R.js +757 -0
- package/dist/chunk-O37BQ65S.js +21 -0
- package/dist/chunk-OOYZPOXM.js +308 -0
- package/dist/chunk-OSGLYW5J.js +28 -0
- package/dist/chunk-PFCMSSUF.js +1640 -0
- package/dist/chunk-PFZO3C6H.js +14 -0
- package/dist/chunk-PGRVXIMY.js +158 -0
- package/dist/chunk-PHH7LD45.js +113 -0
- package/dist/chunk-PISBFBJN.js +109 -0
- package/dist/chunk-POOOIWE5.js +9 -0
- package/dist/chunk-PQNS3U7Z.js +1240 -0
- package/dist/chunk-QSTSJOCK.js +402 -0
- package/dist/chunk-RFQMOKWK.js +282 -0
- package/dist/chunk-RJIZEJ42.js +30 -0
- package/dist/chunk-RTOTNK3P.js +484 -0
- package/dist/chunk-RXKSDUAU.js +1172 -0
- package/dist/chunk-S45JPKQN.js +3317 -0
- package/dist/chunk-SAFHACFA.js +152 -0
- package/dist/chunk-SQJVFEBV.js +41 -0
- package/dist/chunk-SVT4RNTR.js +49 -0
- package/dist/chunk-SWUFN7XM.js +43 -0
- package/dist/chunk-SXMVYC5H.js +174 -0
- package/dist/chunk-SZ6AYUIZ.js +23 -0
- package/dist/chunk-TBRL2RCC.js +9 -0
- package/dist/chunk-TCCHINEF.js +655 -0
- package/dist/chunk-THEGTRAG.js +316 -0
- package/dist/chunk-TR4LQE7L.js +2256 -0
- package/dist/chunk-TRT2HRWZ.js +18 -0
- package/dist/chunk-TWJMGXCI.js +900 -0
- package/dist/chunk-U45AXT5D.js +1023 -0
- package/dist/chunk-U4FWBSO3.js +509 -0
- package/dist/chunk-UBGDX6FI.js +147 -0
- package/dist/chunk-UJILKYES.js +75 -0
- package/dist/chunk-ULMAQV3T.js +234 -0
- package/dist/chunk-VVBP6KGT.js +9 -0
- package/dist/chunk-W5VITDM2.js +168 -0
- package/dist/chunk-WAHQVNWT.js +194 -0
- package/dist/chunk-WBPVKEEE.js +227 -0
- package/dist/chunk-WGGYRBXH.js +5434 -0
- package/dist/chunk-WLYKU45P.js +5770 -0
- package/dist/chunk-WP7BVANJ.js +53 -0
- package/dist/chunk-WQQON3SV.js +473 -0
- package/dist/chunk-WQTOVMGV.js +119 -0
- package/dist/chunk-XBDP4QPW.js +7 -0
- package/dist/chunk-XEBHSJLT.js +103 -0
- package/dist/chunk-XF4VUMKW.js +231 -0
- package/dist/chunk-XQ2ECNK3.js +1 -0
- package/dist/chunk-Y5YXDM7D.js +74 -0
- package/dist/chunk-YOPAUVU4.js +2588 -0
- package/dist/chunk-YPT4A46F.js +362 -0
- package/dist/chunk-YWXT3JNM.js +425 -0
- package/dist/chunk-YY6APYUM.js +49 -0
- package/dist/chunk-Z2IJUO45.js +691 -0
- package/dist/chunk-ZHZ2Y2DH.js +1643 -0
- package/dist/chunk-ZT7JNIGX.js +152 -0
- 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 +184 -6269
- 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 +402 -34324
- 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 +48 -3276
- 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 +41 -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 +15 -2
- package/dist/core/context.d.ts +22 -3
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +239 -12360
- package/dist/core/model-ref.js +5 -23
- package/dist/core/provider-runner.d.ts +36 -1
- 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 +50 -1087
- 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.d.ts +1 -1
- package/dist/execution/index.js +1615 -21895
- package/dist/execution/model-runtime.d.ts +0 -7
- package/dist/execution/parallel-eternal-engine.d.ts +7 -7
- package/dist/execution/prompt-enhancer.js +16 -535
- package/dist/execution/retry-policy.d.ts +31 -1
- package/dist/extension/index.js +7 -311
- package/dist/goal/index.js +33 -3435
- package/dist/hooks/index.js +14 -1138
- package/dist/hq/index.js +114 -5139
- package/dist/hq/persistence/event-log.d.ts +0 -1
- package/dist/hq/persistence.d.ts +4 -4
- package/dist/hq/protocol.js +21 -668
- package/dist/hq/publisher.d.ts +2 -0
- package/dist/index.d.ts +14 -11
- package/dist/index.js +1502 -92655
- package/dist/infrastructure/index.d.ts +4 -4
- package/dist/infrastructure/index.js +504 -5230
- 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 +22 -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 +14 -992
- package/dist/mailbox-attach.d.ts +1 -1
- package/dist/models/index.js +41 -1117
- package/dist/notifications/index.js +3 -108
- package/dist/observability/event-bridge.d.ts +25 -5
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +477 -631
- package/dist/observability/tool-usage-source.d.ts +65 -0
- package/dist/plugin/index.d.ts +5 -0
- package/dist/plugin/index.js +600 -14835
- package/dist/plugins/auto-review-plugin.d.ts +3 -2
- package/dist/plugins/review-finding-commands.d.ts +0 -8
- package/dist/plugins/review-finding-store.js +22 -0
- package/dist/plugins/review-finding-types.js +19 -0
- package/dist/plugins/review-report-integration.js +21 -0
- package/dist/plugins/review-report-store.js +20 -0
- package/dist/plugins/review-report-types.js +13 -0
- package/dist/prompts/index.js +14 -948
- package/dist/registry/index.js +9 -822
- package/dist/registry/tool-registry.d.ts +59 -9
- package/dist/registry-7N4O3E7W.js +14 -0
- package/dist/replay/index.js +6 -84
- package/dist/security/capabilities.d.ts +6 -0
- package/dist/security/file-permissions.d.ts +1 -1
- package/dist/security/index.js +161 -2235
- 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 +41 -2103
- package/dist/session-catalog/project-server.js +59 -1435
- 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 +35 -1578
- 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 +198 -15601
- 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 +10 -676
- package/dist/tools/fallback-manage-tools.d.ts +6 -4
- package/dist/tools/index.js +52 -9590
- package/dist/tools/model-tier-set-tool.d.ts +66 -0
- package/dist/types/agent-bridge.d.ts +2 -1
- package/dist/types/config/autonomy.d.ts +5 -0
- 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/ui.d.ts +1 -1
- 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 +20 -1
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js +131 -1342
- package/dist/types/multi-agent.d.ts +43 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/provider-runner.d.ts +8 -0
- 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 +8 -144
- 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/error.js +3 -4
- package/dist/utils/expect-defined.js +3 -9
- package/dist/utils/heap-watchdog.js +6 -706
- package/dist/utils/index.js +271 -5685
- package/dist/utils/message-invariants.d.ts +4 -1
- package/dist/utils/regex-guard.d.ts +1 -1
- package/dist/utils/sage-output-block.js +5 -42
- 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 +46 -0
- package/dist/wiring/proxy-rewrite.js +24 -121
- package/dist/worktree/index.js +6 -887
- 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/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
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { MailboxMessageType } from './mailbox-type-properties.js';
|
|
2
1
|
import type { MailboxAudience, MailboxMessage, MailboxSessionAffinity, MailboxTaskContext } from './mailbox-message-types.js';
|
|
3
|
-
|
|
4
|
-
export { expandMailboxCapabilities, hasMailboxCapability, MAILBOX_CAPABILITY_IMPLICATIONS, type MailboxActorContext, type MailboxAuthMode, type MailboxCapability, type MailboxPrincipalKind, } from './mailbox-auth-types.js';
|
|
5
|
-
export { isActionRequiredForActor, isMailboxLeader, isMailboxMessageVisibleTo, isMailboxReceiptRecordV2, isMailboxSenderInFamily, mailboxIdentityBase, normalizeRecipient, SESSION_RECIPIENT_PREFIX, sessionRecipient, validateSendType, } from './mailbox-predicates.js';
|
|
2
|
+
import type { MailboxMessageType } from './mailbox-type-properties.js';
|
|
6
3
|
import type { MailboxSessionAffinityContext } from './mailbox-session-sync.js';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
4
|
+
export type { MailboxActorContext, MailboxAuthMode, MailboxCapability, MailboxPrincipalKind, } from './mailbox-auth-types.js';
|
|
5
|
+
export { expandMailboxCapabilities, hasMailboxCapability, MAILBOX_CAPABILITY_IMPLICATIONS } from './mailbox-auth-types.js';
|
|
6
|
+
export { isActionRequiredForActor, isMailboxLeader, isMailboxMessageVisibleTo, isMailboxReceiptRecordV2, isMailboxSenderInFamily, mailboxIdentityBase, normalizeRecipient, SESSION_RECIPIENT_PREFIX, sessionRecipient, validateSendType, } from './mailbox-predicates.js';
|
|
7
|
+
export type { MailboxMessageType } from './mailbox-type-properties.js';
|
|
8
|
+
export { MAILBOX_TYPE_PROPERTIES } from './mailbox-type-properties.js';
|
|
9
|
+
export type { MailboxSessionAffinityContext } from './mailbox-session-sync.js';
|
|
10
|
+
export type { ActorMailboxMessage, MailboxAudience, MailboxLegacyReportSessionAffinity, MailboxMessage, MailboxReceiptRecordV2, MailboxScopedSessionAffinity, MailboxSessionAffinity, MailboxTaskContext, ReadReceipts, } from './mailbox-message-types.js';
|
|
11
|
+
export { acceptMailboxMessageForSession, acceptMailboxMessageForSessionSync } from './mailbox-session-sync.js';
|
|
9
12
|
export interface RegisteredAgent {
|
|
10
13
|
agentId: string;
|
|
11
14
|
sessionId: string;
|
|
@@ -145,6 +148,21 @@ export interface AgentHeartbeatInput {
|
|
|
145
148
|
currentTask?: string | undefined;
|
|
146
149
|
iterations?: number | undefined;
|
|
147
150
|
toolCalls?: number | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Identity fields, carried so a heartbeat can REBUILD a pruned row.
|
|
153
|
+
*
|
|
154
|
+
* A registry row is deleted once it is older than AGENT_STALE_MS — either by
|
|
155
|
+
* the agent's own prune or by any observer calling getAgentStatuses(). Without
|
|
156
|
+
* these, `heartbeat` can only refresh a row that still exists, so a live agent
|
|
157
|
+
* that lost its row stays invisible forever (it never calls registerAgent
|
|
158
|
+
* again). They are optional to keep the RPC wire-compatible: a caller that
|
|
159
|
+
* omits them gets the previous refresh-only behavior.
|
|
160
|
+
*/
|
|
161
|
+
sessionId?: string | undefined;
|
|
162
|
+
name?: string | undefined;
|
|
163
|
+
role?: string | undefined;
|
|
164
|
+
pid?: number | undefined;
|
|
165
|
+
source?: 'cli' | 'webui' | 'mcp' | 'acp' | 'http' | undefined;
|
|
148
166
|
}
|
|
149
167
|
export interface PurgeOptions {
|
|
150
168
|
completedMaxAgeMs?: number | undefined;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leader tier self-switching policy.
|
|
3
|
+
*
|
|
4
|
+
* The leader may notice mid-session that it is doing cheap work on an
|
|
5
|
+
* expensive model (or the reverse) and want to move itself to another tier.
|
|
6
|
+
* That is genuinely useful and genuinely dangerous, so every decision goes
|
|
7
|
+
* through the pure guards in this module.
|
|
8
|
+
*
|
|
9
|
+
* Why guards at all — a tier switch is NOT free:
|
|
10
|
+
*
|
|
11
|
+
* 1. It invalidates the provider prompt cache. The next turn re-reads the
|
|
12
|
+
* whole conversation at full input price on the new model. A switch that
|
|
13
|
+
* saves $0.002/turn but costs $0.40 to re-warm is a loss, and a switch
|
|
14
|
+
* that happens every time a heuristic wobbles across a threshold is a
|
|
15
|
+
* permanent tax. Hence {@link ModelTierLeaderConfig.dwellTurns} and the
|
|
16
|
+
* break-even test.
|
|
17
|
+
* 2. A downgrade can land on a model with a SMALLER context window. If the
|
|
18
|
+
* conversation already exceeds it, the session is stranded. Hence the
|
|
19
|
+
* context-fill gate.
|
|
20
|
+
* 3. Spending authority belongs to the user. The leader may never raise
|
|
21
|
+
* itself above `maxTier`, and in the default 'propose' mode it may not
|
|
22
|
+
* switch at all without a human accepting.
|
|
23
|
+
*
|
|
24
|
+
* Everything here is pure: prices, window sizes and turn counts are injected,
|
|
25
|
+
* so the policy is unit-testable and holds no I/O or layer dependencies.
|
|
26
|
+
*/
|
|
27
|
+
import type { Config, ModelTierLeaderMode } from '../types/config.js';
|
|
28
|
+
/** Per-1M-token prices and window for one model, as published by models.dev. */
|
|
29
|
+
export interface TierModelEconomics {
|
|
30
|
+
/** USD per 1M uncached input tokens. */
|
|
31
|
+
inputPerMTok?: number | undefined;
|
|
32
|
+
/** USD per 1M output tokens. */
|
|
33
|
+
outputPerMTok?: number | undefined;
|
|
34
|
+
/** USD per 1M cache-read input tokens. */
|
|
35
|
+
cacheReadPerMTok?: number | undefined;
|
|
36
|
+
/** USD per 1M cache-write input tokens. */
|
|
37
|
+
cacheWritePerMTok?: number | undefined;
|
|
38
|
+
/** Context window in tokens. */
|
|
39
|
+
maxContext?: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface LeaderTierSwitchRequest {
|
|
42
|
+
/** Tier the leader is on now (undefined when it has never been set). */
|
|
43
|
+
fromTier?: string | undefined;
|
|
44
|
+
/** Tier the leader wants to move to. */
|
|
45
|
+
toTier: string;
|
|
46
|
+
/** Current conversation size in tokens — what a switch would have to re-read. */
|
|
47
|
+
contextTokens: number;
|
|
48
|
+
/** Turns elapsed since the last tier switch. Large when there has been none. */
|
|
49
|
+
turnsSinceSwitch: number;
|
|
50
|
+
/** Economics of the current and target models. */
|
|
51
|
+
economics: {
|
|
52
|
+
from: TierModelEconomics;
|
|
53
|
+
to: TierModelEconomics;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* How many further turns to amortize the re-warm cost over. Defaults to the
|
|
57
|
+
* configured `dwellTurns`, which is the minimum the session is committed to
|
|
58
|
+
* staying on the new tier anyway — deliberately conservative.
|
|
59
|
+
*/
|
|
60
|
+
projectedTurns?: number | undefined;
|
|
61
|
+
}
|
|
62
|
+
export type LeaderTierRefusalCode = 'disabled' | 'same-tier' | 'unknown-tier' | 'dwell' | 'context-window' | 'ceiling' | 'not-worth-it';
|
|
63
|
+
export interface LeaderTierEconomicsSummary {
|
|
64
|
+
/** One-off cost of re-reading the context on the target model. */
|
|
65
|
+
reWarmCostUsd: number;
|
|
66
|
+
/** Per-turn context cost on the current model. */
|
|
67
|
+
stayCostPerTurnUsd: number;
|
|
68
|
+
/** Per-turn context cost on the target model. */
|
|
69
|
+
switchCostPerTurnUsd: number;
|
|
70
|
+
/** Net saving over `projectedTurns`, after paying the re-warm cost. */
|
|
71
|
+
projectedSavingsUsd: number;
|
|
72
|
+
/** True when the target is cheaper per input token than the current model. */
|
|
73
|
+
isDowngrade: boolean;
|
|
74
|
+
}
|
|
75
|
+
export type LeaderTierVerdict = {
|
|
76
|
+
allowed: true;
|
|
77
|
+
/** 'auto' means apply now; 'propose' means ask a human first. */
|
|
78
|
+
mode: Extract<ModelTierLeaderMode, 'auto' | 'propose'>;
|
|
79
|
+
economics: LeaderTierEconomicsSummary;
|
|
80
|
+
reason: string;
|
|
81
|
+
} | {
|
|
82
|
+
allowed: false;
|
|
83
|
+
code: LeaderTierRefusalCode;
|
|
84
|
+
economics?: LeaderTierEconomicsSummary | undefined;
|
|
85
|
+
reason: string;
|
|
86
|
+
};
|
|
87
|
+
/** The leader policy with every default resolved to a concrete value. */
|
|
88
|
+
export interface ResolvedLeaderTierPolicy {
|
|
89
|
+
mode: ModelTierLeaderMode;
|
|
90
|
+
dwellTurns: number;
|
|
91
|
+
minSavingsUsd: number;
|
|
92
|
+
maxContextFillForSwitch: number;
|
|
93
|
+
maxTier?: string | undefined;
|
|
94
|
+
}
|
|
95
|
+
/** Read the leader policy with defaults applied. */
|
|
96
|
+
export declare function leaderTierPolicy(config: Config): ResolvedLeaderTierPolicy;
|
|
97
|
+
/**
|
|
98
|
+
* Rank of a tier within the configured ladder. Config declaration order IS the
|
|
99
|
+
* ladder — the first declared level is the cheapest rung. Ranking by name would
|
|
100
|
+
* mean guessing at user-defined level names, and ranking by live price would
|
|
101
|
+
* make a ceiling flip whenever a provider changed its price list.
|
|
102
|
+
*/
|
|
103
|
+
export declare function tierRank(config: Config, tier: string | undefined): number;
|
|
104
|
+
/**
|
|
105
|
+
* Cost model for the switch.
|
|
106
|
+
*
|
|
107
|
+
* `contextTokens` is the quantity that actually matters: it is re-read on every
|
|
108
|
+
* turn, cached on the current model and uncached on the first turn of the new
|
|
109
|
+
* one. Output tokens are not modeled — they do not change with the switch
|
|
110
|
+
* decision and would only add noise to the comparison.
|
|
111
|
+
*/
|
|
112
|
+
export declare function evaluateSwitchEconomics(request: LeaderTierSwitchRequest, projectedTurns: number): LeaderTierEconomicsSummary;
|
|
113
|
+
/**
|
|
114
|
+
* The full decision. Returns whether the switch may happen, and — in 'propose'
|
|
115
|
+
* mode — that a human has to accept it first.
|
|
116
|
+
*
|
|
117
|
+
* Guard order is deliberate: the cheap structural checks run before the
|
|
118
|
+
* economics, so a refusal reason is always the most fundamental one rather than
|
|
119
|
+
* whichever gate happened to be evaluated first.
|
|
120
|
+
*/
|
|
121
|
+
export declare function evaluateLeaderTierSwitch(config: Config, request: LeaderTierSwitchRequest): LeaderTierVerdict;
|
|
122
|
+
//# sourceMappingURL=model-tier-leader.d.ts.map
|
|
@@ -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
|
|
@@ -173,6 +196,10 @@ export declare class ProviderModelStatusTracker {
|
|
|
173
196
|
* kind is `auth` (no point retrying ever).
|
|
174
197
|
*/
|
|
175
198
|
isAvailable(providerId: string, model: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Manually unblock/reset a provider/model pair (e.g. after a manual model switch or key update).
|
|
201
|
+
*/
|
|
202
|
+
unblock(providerId: string, model: string): void;
|
|
176
203
|
/**
|
|
177
204
|
* Check if a (providerId, model) pair is currently rate-limited.
|
|
178
205
|
* This is a stronger signal than just `!isAvailable()` — it tells
|
|
@@ -201,6 +228,8 @@ export declare class ProviderModelStatusTracker {
|
|
|
201
228
|
/**
|
|
202
229
|
* Release one entry for an immediate half-open probe on its next real use.
|
|
203
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.
|
|
204
233
|
*/
|
|
205
234
|
retryNow(providerId: string, model: string): boolean;
|
|
206
235
|
/**
|
|
@@ -244,6 +273,13 @@ export declare class ProviderModelStatusTracker {
|
|
|
244
273
|
getSnapshot(): ProviderStatusSnapshot;
|
|
245
274
|
/** Restore non-expired waiting-room entries from a previous process. */
|
|
246
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;
|
|
247
283
|
private getOrCreate;
|
|
248
284
|
private freezeStatus;
|
|
249
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;
|
|
@@ -48,8 +48,21 @@ export declare class Agent {
|
|
|
48
48
|
* conversation or racing abort signals.
|
|
49
49
|
*/
|
|
50
50
|
private _runInProgress;
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Dedup window for byte-identical consecutive inputs. Only accidental
|
|
53
|
+
* back-to-back duplicates fall inside it — terminal \r\n re-entrancy,
|
|
54
|
+
* stuck-key bursts, client auto-resubmit loops. A deliberate re-send later
|
|
55
|
+
* (the classic "continue" nudge after a model switch, or retyping the same
|
|
56
|
+
* instruction after a failed run) must always execute.
|
|
57
|
+
*/
|
|
58
|
+
static readonly INPUT_DEDUP_WINDOW_MS = 1500;
|
|
59
|
+
/**
|
|
60
|
+
* SHA-256 + submission time of the last committed input content. The pair
|
|
61
|
+
* powers burst-only dedup: identical text skips a run solely when it lands
|
|
62
|
+
* within {@link Agent.INPUT_DEDUP_WINDOW_MS} of the previous submission.
|
|
63
|
+
*/
|
|
52
64
|
private _lastInputHash;
|
|
65
|
+
private _lastInputHashAt;
|
|
53
66
|
constructor(init: AgentInit);
|
|
54
67
|
get logger(): Logger;
|
|
55
68
|
get retry(): RetryPolicy;
|
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
|