@0xmaxma/claude-gateway 2.0.4 → 2.0.6
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/README.md +10 -1
- package/dist/agent/builtin-commands.d.ts +1 -1
- package/dist/agent/builtin-commands.d.ts.map +1 -1
- package/dist/agent/builtin-commands.js +3 -2
- package/dist/agent/builtin-commands.js.map +1 -1
- package/dist/agent/runner.d.ts +123 -9
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +215 -182
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/session-compaction-scheduler.d.ts +22 -0
- package/dist/agent/session-compaction-scheduler.d.ts.map +1 -0
- package/dist/agent/session-compaction-scheduler.js +40 -0
- package/dist/agent/session-compaction-scheduler.js.map +1 -0
- package/dist/agent/skill-learning/index.d.ts.map +1 -1
- package/dist/agent/skill-learning/index.js +27 -8
- package/dist/agent/skill-learning/index.js.map +1 -1
- package/dist/agent/skill-learning/reviewer.d.ts +3 -1
- package/dist/agent/skill-learning/reviewer.d.ts.map +1 -1
- package/dist/agent/skill-learning/reviewer.js +6 -2
- package/dist/agent/skill-learning/reviewer.js.map +1 -1
- package/dist/agent/turn-stream.d.ts +3 -1
- package/dist/agent/turn-stream.d.ts.map +1 -1
- package/dist/agent/turn-stream.js +8 -4
- package/dist/agent/turn-stream.js.map +1 -1
- package/dist/api/gateway-router.d.ts +2 -0
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +323 -16
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/memory-activity.d.ts +18 -0
- package/dist/api/memory-activity.d.ts.map +1 -0
- package/dist/api/memory-activity.js +97 -0
- package/dist/api/memory-activity.js.map +1 -0
- package/dist/api/router.js +11 -11
- package/dist/api/router.js.map +1 -1
- package/dist/api/slack-webhook-router.js +1 -1
- package/dist/api/slack-webhook-router.js.map +1 -1
- package/dist/api/voice-router.d.ts +1 -0
- package/dist/api/voice-router.d.ts.map +1 -1
- package/dist/api/voice-router.js +129 -7
- package/dist/api/voice-router.js.map +1 -1
- package/dist/config/claude-settings.d.ts +14 -0
- package/dist/config/claude-settings.d.ts.map +1 -1
- package/dist/config/claude-settings.js +20 -0
- package/dist/config/claude-settings.js.map +1 -1
- package/dist/orchestration/agent-cli-session.d.ts +46 -0
- package/dist/orchestration/agent-cli-session.d.ts.map +1 -0
- package/dist/orchestration/agent-cli-session.js +121 -0
- package/dist/orchestration/agent-cli-session.js.map +1 -0
- package/dist/orchestration/agent-tool-schemas.d.ts +6 -0
- package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -0
- package/dist/orchestration/agent-tool-schemas.js +23 -0
- package/dist/orchestration/agent-tool-schemas.js.map +1 -0
- package/dist/orchestration/bridge.d.ts +6 -3
- package/dist/orchestration/bridge.d.ts.map +1 -1
- package/dist/orchestration/bridge.js +31 -14
- package/dist/orchestration/bridge.js.map +1 -1
- package/dist/orchestration/browser-voice.d.ts +14 -0
- package/dist/orchestration/browser-voice.d.ts.map +1 -0
- package/dist/orchestration/browser-voice.js +30 -0
- package/dist/orchestration/browser-voice.js.map +1 -0
- package/dist/orchestration/compact-measurements.d.ts +21 -0
- package/dist/orchestration/compact-measurements.d.ts.map +1 -0
- package/dist/orchestration/compact-measurements.js +62 -0
- package/dist/orchestration/compact-measurements.js.map +1 -0
- package/dist/orchestration/config.d.ts +4 -0
- package/dist/orchestration/config.d.ts.map +1 -1
- package/dist/orchestration/config.js +1 -1
- package/dist/orchestration/config.js.map +1 -1
- package/dist/orchestration/context-delivery.d.ts +32 -0
- package/dist/orchestration/context-delivery.d.ts.map +1 -0
- package/dist/orchestration/context-delivery.js +101 -0
- package/dist/orchestration/context-delivery.js.map +1 -0
- package/dist/orchestration/context-footprint.d.ts +14 -0
- package/dist/orchestration/context-footprint.d.ts.map +1 -0
- package/dist/orchestration/context-footprint.js +57 -0
- package/dist/orchestration/context-footprint.js.map +1 -0
- package/dist/orchestration/conversation-intake.d.ts +10 -6
- package/dist/orchestration/conversation-intake.d.ts.map +1 -1
- package/dist/orchestration/conversation-intake.js +22 -8
- package/dist/orchestration/conversation-intake.js.map +1 -1
- package/dist/orchestration/dashboard-charts.d.ts +32 -0
- package/dist/orchestration/dashboard-charts.d.ts.map +1 -0
- package/dist/orchestration/dashboard-charts.js +77 -0
- package/dist/orchestration/dashboard-charts.js.map +1 -0
- package/dist/orchestration/dashboard-reader-worker.d.ts +2 -0
- package/dist/orchestration/dashboard-reader-worker.d.ts.map +1 -0
- package/dist/orchestration/dashboard-reader-worker.js +173 -0
- package/dist/orchestration/dashboard-reader-worker.js.map +1 -0
- package/dist/orchestration/dashboard-reader.d.ts +15 -0
- package/dist/orchestration/dashboard-reader.d.ts.map +1 -0
- package/dist/orchestration/dashboard-reader.js +87 -0
- package/dist/orchestration/dashboard-reader.js.map +1 -0
- package/dist/orchestration/decision-context.d.ts +15 -0
- package/dist/orchestration/decision-context.d.ts.map +1 -0
- package/dist/orchestration/decision-context.js +57 -0
- package/dist/orchestration/decision-context.js.map +1 -0
- package/dist/orchestration/display-stream.d.ts +21 -2
- package/dist/orchestration/display-stream.d.ts.map +1 -1
- package/dist/orchestration/display-stream.js +61 -8
- package/dist/orchestration/display-stream.js.map +1 -1
- package/dist/orchestration/inference-errors.d.ts.map +1 -1
- package/dist/orchestration/inference-errors.js +19 -21
- package/dist/orchestration/inference-errors.js.map +1 -1
- package/dist/orchestration/mutation-recovery.d.ts +13 -0
- package/dist/orchestration/mutation-recovery.d.ts.map +1 -0
- package/dist/orchestration/mutation-recovery.js +49 -0
- package/dist/orchestration/mutation-recovery.js.map +1 -0
- package/dist/orchestration/native-compact.d.ts +8 -0
- package/dist/orchestration/native-compact.d.ts.map +1 -0
- package/dist/orchestration/native-compact.js +33 -0
- package/dist/orchestration/native-compact.js.map +1 -0
- package/dist/orchestration/notification-mailbox.d.ts +3 -1
- package/dist/orchestration/notification-mailbox.d.ts.map +1 -1
- package/dist/orchestration/notification-mailbox.js +4 -2
- package/dist/orchestration/notification-mailbox.js.map +1 -1
- package/dist/orchestration/process-turn.d.ts +16 -2
- package/dist/orchestration/process-turn.d.ts.map +1 -1
- package/dist/orchestration/process-turn.js +78 -14
- package/dist/orchestration/process-turn.js.map +1 -1
- package/dist/orchestration/progress-review.d.ts +8 -18
- package/dist/orchestration/progress-review.d.ts.map +1 -1
- package/dist/orchestration/progress-review.js +12 -14
- package/dist/orchestration/progress-review.js.map +1 -1
- package/dist/orchestration/provider-message.d.ts +7 -0
- package/dist/orchestration/provider-message.d.ts.map +1 -0
- package/dist/orchestration/provider-message.js +63 -0
- package/dist/orchestration/provider-message.js.map +1 -0
- package/dist/orchestration/response-errors.d.ts +6 -0
- package/dist/orchestration/response-errors.d.ts.map +1 -0
- package/dist/orchestration/response-errors.js +88 -0
- package/dist/orchestration/response-errors.js.map +1 -0
- package/dist/orchestration/response-schema.d.ts +33 -0
- package/dist/orchestration/response-schema.d.ts.map +1 -0
- package/dist/orchestration/response-schema.js +61 -0
- package/dist/orchestration/response-schema.js.map +1 -0
- package/dist/orchestration/runtime.d.ts +79 -0
- package/dist/orchestration/runtime.d.ts.map +1 -1
- package/dist/orchestration/runtime.js +415 -68
- package/dist/orchestration/runtime.js.map +1 -1
- package/dist/orchestration/session-compaction.d.ts +59 -0
- package/dist/orchestration/session-compaction.d.ts.map +1 -0
- package/dist/orchestration/session-compaction.js +212 -0
- package/dist/orchestration/session-compaction.js.map +1 -0
- package/dist/orchestration/skills.d.ts.map +1 -1
- package/dist/orchestration/skills.js +3 -2
- package/dist/orchestration/skills.js.map +1 -1
- package/dist/orchestration/source-policy.d.ts +1 -1
- package/dist/orchestration/source-policy.d.ts.map +1 -1
- package/dist/orchestration/source-policy.js +1 -1
- package/dist/orchestration/speech.d.ts +15 -17
- package/dist/orchestration/speech.d.ts.map +1 -1
- package/dist/orchestration/speech.js +90 -30
- package/dist/orchestration/speech.js.map +1 -1
- package/dist/orchestration/store.d.ts +2 -0
- package/dist/orchestration/store.d.ts.map +1 -1
- package/dist/orchestration/store.js +16 -1
- package/dist/orchestration/store.js.map +1 -1
- package/dist/orchestration/tasks/driver.d.ts.map +1 -1
- package/dist/orchestration/tasks/driver.js +8 -3
- package/dist/orchestration/tasks/driver.js.map +1 -1
- package/dist/orchestration/tasks/pool.d.ts.map +1 -1
- package/dist/orchestration/tasks/pool.js +8 -4
- package/dist/orchestration/tasks/pool.js.map +1 -1
- package/dist/orchestration/tasks/service.d.ts +48 -1
- package/dist/orchestration/tasks/service.d.ts.map +1 -1
- package/dist/orchestration/tasks/service.js +41 -17
- package/dist/orchestration/tasks/service.js.map +1 -1
- package/dist/orchestration/token-ledger.d.ts +132 -0
- package/dist/orchestration/token-ledger.d.ts.map +1 -0
- package/dist/orchestration/token-ledger.js +233 -0
- package/dist/orchestration/token-ledger.js.map +1 -0
- package/dist/orchestration/token-usage.d.ts +46 -0
- package/dist/orchestration/token-usage.d.ts.map +1 -0
- package/dist/orchestration/token-usage.js +102 -0
- package/dist/orchestration/token-usage.js.map +1 -0
- package/dist/orchestration/tool-activity.d.ts.map +1 -1
- package/dist/orchestration/tool-activity.js +5 -3
- package/dist/orchestration/tool-activity.js.map +1 -1
- package/dist/orchestration/tool-name.d.ts +10 -0
- package/dist/orchestration/tool-name.d.ts.map +1 -0
- package/dist/orchestration/tool-name.js +14 -0
- package/dist/orchestration/tool-name.js.map +1 -0
- package/dist/orchestration/transcript-checkpoint.d.ts +14 -0
- package/dist/orchestration/transcript-checkpoint.d.ts.map +1 -0
- package/dist/orchestration/transcript-checkpoint.js +83 -0
- package/dist/orchestration/transcript-checkpoint.js.map +1 -0
- package/dist/orchestration/unanswered-inputs.d.ts +6 -0
- package/dist/orchestration/unanswered-inputs.d.ts.map +1 -0
- package/dist/orchestration/unanswered-inputs.js +18 -0
- package/dist/orchestration/unanswered-inputs.js.map +1 -0
- package/dist/session/process.d.ts +10 -0
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +91 -9
- package/dist/session/process.js.map +1 -1
- package/dist/session/request-tool-capture.d.ts +31 -0
- package/dist/session/request-tool-capture.d.ts.map +1 -0
- package/dist/session/request-tool-capture.js +194 -0
- package/dist/session/request-tool-capture.js.map +1 -0
- package/dist/session/runtime-profile.d.ts +7 -3
- package/dist/session/runtime-profile.d.ts.map +1 -1
- package/dist/session/runtime-profile.js +3 -1
- package/dist/session/runtime-profile.js.map +1 -1
- package/dist/session/store.d.ts +7 -0
- package/dist/session/store.d.ts.map +1 -1
- package/dist/session/store.js +27 -0
- package/dist/session/store.js.map +1 -1
- package/dist/shell/tailer.d.ts +7 -5
- package/dist/shell/tailer.d.ts.map +1 -1
- package/dist/shell/tailer.js +6 -17
- package/dist/shell/tailer.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/cli-viewer-ui.js +1 -1
- package/dist/ui/dashboard-charts.d.ts +3 -0
- package/dist/ui/dashboard-charts.d.ts.map +1 -0
- package/dist/ui/dashboard-charts.js +130 -0
- package/dist/ui/dashboard-charts.js.map +1 -0
- package/dist/ui/dashboard-client.d.ts +3 -0
- package/dist/ui/dashboard-client.d.ts.map +1 -0
- package/dist/ui/dashboard-client.js +184 -0
- package/dist/ui/dashboard-client.js.map +1 -0
- package/dist/ui/dashboard-controls.d.ts +4 -0
- package/dist/ui/dashboard-controls.d.ts.map +1 -0
- package/dist/ui/dashboard-controls.js +27 -0
- package/dist/ui/dashboard-controls.js.map +1 -0
- package/dist/ui/dashboard-presentation.d.ts +12 -0
- package/dist/ui/dashboard-presentation.d.ts.map +1 -0
- package/dist/ui/dashboard-presentation.js +62 -0
- package/dist/ui/dashboard-presentation.js.map +1 -0
- package/dist/ui/dashboard-range.d.ts +5 -0
- package/dist/ui/dashboard-range.d.ts.map +1 -0
- package/dist/ui/dashboard-range.js +36 -0
- package/dist/ui/dashboard-range.js.map +1 -0
- package/dist/ui/dashboard-theme.d.ts +6 -0
- package/dist/ui/dashboard-theme.d.ts.map +1 -0
- package/dist/ui/dashboard-theme.js +562 -0
- package/dist/ui/dashboard-theme.js.map +1 -0
- package/dist/ui/memory-activity.d.ts +4 -0
- package/dist/ui/memory-activity.d.ts.map +1 -0
- package/dist/ui/memory-activity.js +115 -0
- package/dist/ui/memory-activity.js.map +1 -0
- package/dist/ui/token-report-client.d.ts +3 -0
- package/dist/ui/token-report-client.d.ts.map +1 -0
- package/dist/ui/token-report-client.js +34 -0
- package/dist/ui/token-report-client.js.map +1 -0
- package/dist/ui/token-report.d.ts +90 -0
- package/dist/ui/token-report.d.ts.map +1 -0
- package/dist/ui/token-report.js +203 -0
- package/dist/ui/token-report.js.map +1 -0
- package/dist/ui/web-ui.d.ts +1 -1
- package/dist/ui/web-ui.d.ts.map +1 -1
- package/dist/ui/web-ui.js +129 -409
- package/dist/ui/web-ui.js.map +1 -1
- package/dist/voice/replay.d.ts +8 -0
- package/dist/voice/replay.d.ts.map +1 -0
- package/dist/voice/replay.js +48 -0
- package/dist/voice/replay.js.map +1 -0
- package/dist/voice/session.d.ts +9 -0
- package/dist/voice/session.d.ts.map +1 -1
- package/dist/voice/session.js +72 -14
- package/dist/voice/session.js.map +1 -1
- package/mcp/lazy-connector.test.ts +58 -0
- package/mcp/lazy-connector.ts +67 -0
- package/mcp/lazy-tools.test.ts +152 -0
- package/mcp/lazy-tools.ts +41 -0
- package/mcp/server.ts +53 -34
- package/mcp/tools/discord/commands.ts +2 -0
- package/mcp/tools/tasks/module.ts +1 -12
- package/mcp/tools/telegram/receiver-server.ts +45 -31
- package/mcp/tools/telegram/session-browser.ts +10 -0
- package/package.json +2 -1
- package/resource/dashboard/OFL.txt +93 -0
- package/resource/dashboard/poppins-300.woff2 +0 -0
- package/resource/dashboard/poppins-400.woff2 +0 -0
- package/resource/dashboard/poppins-500.woff2 +0 -0
- package/resource/dashboard/poppins-600.woff2 +0 -0
|
@@ -16,6 +16,8 @@ export interface OrchestrationConfig {
|
|
|
16
16
|
idleTimeoutMs?: number;
|
|
17
17
|
startupTimeoutMs?: number;
|
|
18
18
|
firstResponseTimeoutMs?: number;
|
|
19
|
+
/** Per-compaction deadline for agents and workers, independent of first-token wait. */
|
|
20
|
+
compactionTimeoutMs?: number;
|
|
19
21
|
maxDecisionDurationMs?: number;
|
|
20
22
|
preemptionGraceMs?: number;
|
|
21
23
|
maxPendingInputs?: number;
|
|
@@ -95,6 +97,7 @@ export declare const ORCHESTRATION_DEFAULTS: {
|
|
|
95
97
|
idleTimeoutMs: number;
|
|
96
98
|
startupTimeoutMs: number;
|
|
97
99
|
firstResponseTimeoutMs: number;
|
|
100
|
+
compactionTimeoutMs: number;
|
|
98
101
|
maxDecisionDurationMs: number;
|
|
99
102
|
preemptionGraceMs: number;
|
|
100
103
|
maxPendingInputs: number;
|
|
@@ -199,6 +202,7 @@ export declare function resolveOrchestrationConfig(config?: OrchestrationConfig,
|
|
|
199
202
|
decisionTimeoutMs: number;
|
|
200
203
|
startupTimeoutMs: number;
|
|
201
204
|
firstResponseTimeoutMs: number;
|
|
205
|
+
compactionTimeoutMs: number;
|
|
202
206
|
maxDecisionDurationMs: number;
|
|
203
207
|
preemptionGraceMs: number;
|
|
204
208
|
maxPendingInputs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/orchestration/config.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE;QACb,OAAO,CAAC,EAAE,SAAS,CAAC;QACpB,2EAA2E;QAC3E,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,6EAA6E;QAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,kBAAkB,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAAC;QAChE,iFAAiF;QACjF,iBAAiB,CAAC,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AAM,EAAE;kBACd,MAAM;;EAmFpB"}
|
|
@@ -11,7 +11,7 @@ exports.ORCHESTRATION_DEFAULTS = {
|
|
|
11
11
|
enabled: false,
|
|
12
12
|
channels: ['api'],
|
|
13
13
|
conversation: { backend: 'inherit', semanticIntake: false, intakeWaitMs: 2000, maxActiveSessions: 2, notificationPolicy: 'existing_receive_path',
|
|
14
|
-
decisionTimeoutMs: 120000, idleTimeoutMs: 120000, startupTimeoutMs: 120000, firstResponseTimeoutMs: 120000, maxDecisionDurationMs: 600000, preemptionGraceMs: 250, maxPendingInputs: 100 },
|
|
14
|
+
decisionTimeoutMs: 120000, idleTimeoutMs: 120000, startupTimeoutMs: 120000, firstResponseTimeoutMs: 120000, compactionTimeoutMs: 300000, maxDecisionDurationMs: 600000, preemptionGraceMs: 250, maxPendingInputs: 100 },
|
|
15
15
|
tasks: { maxConcurrentPerAgent: 10, maxConcurrentPerConversation: 10, workerIdleTtlMs: 600000, maxQueuedPerConversation: 20,
|
|
16
16
|
maxQueuedPerAgent: 100, defaultTimeoutMs: 1800000, idleTimeoutMs: 300000, maxDurationMs: 0, questionReminderMs: 600000, progressStaleMs: 180000, progressNotifyCooldownMs: 300000, repeatedToolThreshold: 6, interruptAckTimeoutMs: 5000, workspaceMode: 'host', projectRoot: '', resourceRetentionDays: 7 },
|
|
17
17
|
events: { retentionDays: 7, maxSubscriberBufferBytes: 1048576 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/orchestration/config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/orchestration/config.ts"],"names":[],"mappings":";;;AA+FA,oCAaC;AACD,gEAmCC;AAhJD,4DAAsE;AACtE,4CAAiD;AACjD,mCAA6C;AAC7C,+BAAkC;AAmErB,QAAA,sBAAsB,GAAG;IACpC,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,YAA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AI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,0BAAkB,CAAC,gBAAgB,EAAE,iDAAiD,CAAC,CAAC;IAC/S,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OrchestrationStore } from './store';
|
|
2
|
+
export interface ContextDeliveryScope {
|
|
3
|
+
conversationId: string;
|
|
4
|
+
principalId: string;
|
|
5
|
+
bindingId: string;
|
|
6
|
+
cliSessionId: string;
|
|
7
|
+
resume: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ContextDeliveryPlan {
|
|
10
|
+
readonly fresh: boolean;
|
|
11
|
+
/** Select complete changed/new values and stage their fingerprints. */
|
|
12
|
+
select<T>(bucket: string, items: T[], key: (value: T) => string): T[];
|
|
13
|
+
includes(bucket: string, key: string): boolean;
|
|
14
|
+
mark(bucket: string, key: string, value: unknown): void;
|
|
15
|
+
/** Canonical reference whose image bytes were supplied to this CLI context. */
|
|
16
|
+
imageReference(ref: string): string | undefined;
|
|
17
|
+
/** Stage an image reference; return the prior canonical ref if its bytes are known. */
|
|
18
|
+
rememberImage(ref: string, digest: string): string | undefined;
|
|
19
|
+
/** Call only after successful, noninterrupted CLI completion. False means stale. */
|
|
20
|
+
commit(): boolean;
|
|
21
|
+
/** A compact boundary forgets delivery knowledge, never canonical history. */
|
|
22
|
+
invalidate(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Durable knowledge of what this CLI context has seen; contains no prompt payloads. */
|
|
25
|
+
export declare class ContextDelivery {
|
|
26
|
+
private readonly store;
|
|
27
|
+
constructor(store: OrchestrationStore);
|
|
28
|
+
/** A CLI transcript can serve several channel conversations in one session. */
|
|
29
|
+
invalidateConversation(conversationId: string): void;
|
|
30
|
+
begin(scope: ContextDeliveryScope): ContextDeliveryPlan;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=context-delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-delivery.d.ts","sourceRoot":"","sources":["../../src/orchestration/context-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAG1D,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAAC;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACxD,+EAA+E;IAC/E,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChD,uFAAuF;IACvF,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC/D,oFAAoF;IACpF,MAAM,IAAI,OAAO,CAAC;IAClB,8EAA8E;IAC9E,UAAU,IAAI,IAAI,CAAC;CACpB;AAED,wFAAwF;AACxF,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,kBAAkB;IAatD,+EAA+E;IAC/E,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAYpD,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,mBAAmB;CA+DxD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextDelivery = void 0;
|
|
4
|
+
const store_1 = require("./store");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/** Durable knowledge of what this CLI context has seen; contains no prompt payloads. */
|
|
7
|
+
class ContextDelivery {
|
|
8
|
+
constructor(store) {
|
|
9
|
+
this.store = store;
|
|
10
|
+
store.run(`CREATE TABLE IF NOT EXISTS context_delivery(
|
|
11
|
+
conversation_id TEXT NOT NULL REFERENCES conversations(id),
|
|
12
|
+
principal_id TEXT NOT NULL,
|
|
13
|
+
binding_id TEXT NOT NULL REFERENCES conversation_bindings(id),
|
|
14
|
+
cli_session_id TEXT NOT NULL,
|
|
15
|
+
revision INTEGER NOT NULL,
|
|
16
|
+
fingerprints_json TEXT NOT NULL,
|
|
17
|
+
PRIMARY KEY(conversation_id,principal_id,binding_id))`);
|
|
18
|
+
store.run(`CREATE TABLE IF NOT EXISTS context_delivery_generations(
|
|
19
|
+
conversation_id TEXT PRIMARY KEY REFERENCES conversations(id),generation INTEGER NOT NULL)`);
|
|
20
|
+
}
|
|
21
|
+
/** A CLI transcript can serve several channel conversations in one session. */
|
|
22
|
+
invalidateConversation(conversationId) {
|
|
23
|
+
this.store.transaction(() => {
|
|
24
|
+
const conversations = this.store.all(`SELECT id FROM conversations WHERE agent_session_id=
|
|
25
|
+
(SELECT agent_session_id FROM conversations WHERE id=?)`, conversationId);
|
|
26
|
+
for (const row of conversations) {
|
|
27
|
+
this.store.run(`INSERT INTO context_delivery_generations VALUES(?,1)
|
|
28
|
+
ON CONFLICT(conversation_id) DO UPDATE SET generation=generation+1`, row.id);
|
|
29
|
+
this.store.run("UPDATE context_delivery SET revision=revision+1,fingerprints_json='[]' WHERE conversation_id=?", row.id);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
begin(scope) {
|
|
34
|
+
const { conversationId, principalId, bindingId, cliSessionId, resume } = scope;
|
|
35
|
+
const store = this.store;
|
|
36
|
+
store.assertMember(conversationId, principalId);
|
|
37
|
+
if (!store.get('SELECT id FROM conversation_bindings WHERE id=? AND conversation_id=?', bindingId, conversationId))
|
|
38
|
+
throw new types_1.OrchestrationError('ACCESS_DENIED');
|
|
39
|
+
if (!cliSessionId)
|
|
40
|
+
throw new types_1.OrchestrationError('INVALID_INPUT');
|
|
41
|
+
const ids = [conversationId, principalId, bindingId];
|
|
42
|
+
const row = store.get('SELECT * FROM context_delivery WHERE conversation_id=? AND principal_id=? AND binding_id=?', ...ids);
|
|
43
|
+
const revision = row ? Number(row.revision) : 0;
|
|
44
|
+
const generation = Number(store.get('SELECT generation FROM context_delivery_generations WHERE conversation_id=?', conversationId)?.generation ?? 0);
|
|
45
|
+
const fresh = !resume || row?.cli_session_id !== cliSessionId || row.fingerprints_json === '[]';
|
|
46
|
+
// Existing installations have no checkpoint: replay once, then remember only
|
|
47
|
+
// the data delivered by the successful turn. A failed bootstrap writes nothing.
|
|
48
|
+
const hashes = new Map(resume && row?.cli_session_id === cliSessionId
|
|
49
|
+
? JSON.parse(String(row.fingerprints_json)) : []);
|
|
50
|
+
const entryKey = (bucket, key) => JSON.stringify([bucket, key]);
|
|
51
|
+
let closed = false;
|
|
52
|
+
return {
|
|
53
|
+
fresh,
|
|
54
|
+
select(bucket, items, key) {
|
|
55
|
+
return items.filter(value => {
|
|
56
|
+
const id = entryKey(bucket, key(value)), hash = (0, store_1.payloadHash)(value);
|
|
57
|
+
if (hashes.get(id) === hash)
|
|
58
|
+
return false;
|
|
59
|
+
hashes.set(id, hash);
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
includes: (bucket, key) => hashes.has(entryKey(bucket, key)),
|
|
64
|
+
mark: (bucket, key, value) => { hashes.set(entryKey(bucket, key), (0, store_1.payloadHash)(value)); },
|
|
65
|
+
imageReference: ref => hashes.get(entryKey('image-ref', ref)),
|
|
66
|
+
rememberImage(ref, digest) {
|
|
67
|
+
const prior = hashes.get(entryKey('image-digest-ref', digest));
|
|
68
|
+
const canonical = prior ?? ref;
|
|
69
|
+
hashes.set(entryKey('image-digest-ref', digest), canonical);
|
|
70
|
+
hashes.set(entryKey('image-ref', ref), canonical);
|
|
71
|
+
return prior;
|
|
72
|
+
},
|
|
73
|
+
commit() {
|
|
74
|
+
if (closed)
|
|
75
|
+
return false;
|
|
76
|
+
closed = true;
|
|
77
|
+
return store.transaction(() => {
|
|
78
|
+
if (Number(store.get('SELECT generation FROM context_delivery_generations WHERE conversation_id=?', conversationId)?.generation ?? 0) !== generation)
|
|
79
|
+
return false;
|
|
80
|
+
const serialized = JSON.stringify([...hashes]);
|
|
81
|
+
const result = row
|
|
82
|
+
? store.run(`UPDATE context_delivery SET cli_session_id=?,revision=revision+1,fingerprints_json=?
|
|
83
|
+
WHERE conversation_id=? AND principal_id=? AND binding_id=? AND revision=?`, cliSessionId, serialized, ...ids, revision)
|
|
84
|
+
: store.run('INSERT OR IGNORE INTO context_delivery VALUES(?,?,?,?,1,?)', ...ids, cliSessionId, serialized);
|
|
85
|
+
return Number(result.changes) === 1;
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
invalidate() {
|
|
89
|
+
closed = true;
|
|
90
|
+
// Keep a revision tombstone even if no successful turn has committed yet;
|
|
91
|
+
// otherwise an older bootstrap plan could resurrect pre-compact knowledge.
|
|
92
|
+
store.run(`INSERT INTO context_delivery VALUES(?,?,?,?,1,'[]')
|
|
93
|
+
ON CONFLICT(conversation_id,principal_id,binding_id) DO UPDATE SET
|
|
94
|
+
revision=context_delivery.revision+1,fingerprints_json='[]'`, ...ids, cliSessionId);
|
|
95
|
+
hashes.clear();
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.ContextDelivery = ContextDelivery;
|
|
101
|
+
//# sourceMappingURL=context-delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-delivery.js","sourceRoot":"","sources":["../../src/orchestration/context-delivery.ts"],"names":[],"mappings":";;;AAAA,mCAA0D;AAC1D,mCAA6C;AA0B7C,wFAAwF;AACxF,MAAa,eAAe;IAC1B,YAA6B,KAAyB;QAAzB,UAAK,GAAL,KAAK,CAAoB;QACpD,KAAK,CAAC,GAAG,CAAC;;;;;;;4DAO8C,CAAC,CAAC;QAC1D,KAAK,CAAC,GAAG,CAAC;iGACmF,CAAC,CAAC;IACjG,CAAC;IAED,+EAA+E;IAC/E,sBAAsB,CAAC,cAAsB;QAC3C,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;YAC1B,MAAM,aAAa,GAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gEACuB,EAAC,cAAc,CAAC,CAAC;YAC3E,KAAI,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;gBAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;6EACsD,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/E,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gGAAgG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3H,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAA2B;QAC/B,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,CA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ACD,MAAM;gBACJ,IAAI,MAAM;oBAAE,OAAO,KAAK,CAAC;gBACzB,MAAM,GAAG,IAAI,CAAC;gBACd,OAAO,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;oBAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,6EAA6E,EAAE,cAAc,CAAC,EAAE,UAAU,IAAI,CAAC,CAAC,KAAK,UAAU;wBAAE,OAAO,KAAK,CAAC;oBACnK,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;oBAC/C,MAAM,MAAM,GAAG,GAAG;wBAChB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;2FACmE,EAC7E,YAAY,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,QAAQ,CAAC;wBAC7C,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,4DAA4D,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;oBAC9G,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;YACL,CAAC;YACD,UAAU;gBACR,MAAM,GAAG,IAAI,CAAC;gBACd,0EAA0E;gBAC1E,2EAA2E;gBAC3E,KAAK,CAAC,GAAG,CAAC;;sEAEoD,EAAE,GAAG,GAAG,EAAE,YAAY,CAAC,CAAC;gBACtF,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AA1FD,0CA0FC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function referenceTokens(text: string): number;
|
|
2
|
+
export interface ContextFootprint {
|
|
3
|
+
observedAt: number;
|
|
4
|
+
rows: Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
tokens: number | null;
|
|
7
|
+
characters: number | null;
|
|
8
|
+
hasContent?: boolean;
|
|
9
|
+
note: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/** Run in the dashboard reader thread. Never launch a CLI/model or return file content. */
|
|
13
|
+
export declare function contextFootprint(workspace: string | undefined): ContextFootprint;
|
|
14
|
+
//# sourceMappingURL=context-footprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-footprint.d.ts","sourceRoot":"","sources":["../../src/orchestration/context-footprint.ts"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AACD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC;QAAC,IAAI,EAAC,MAAM,CAAC;QAAA,MAAM,EAAC,MAAM,GAAC,IAAI,CAAC;QAAA,UAAU,EAAC,MAAM,GAAC,IAAI,CAAC;QAAA,UAAU,CAAC,EAAC,OAAO,CAAC;QAAA,IAAI,EAAC,MAAM,CAAA;KAAC,CAAC,CAAC;CACtG;AACD,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,gBAAgB,CA2BhF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.referenceTokens = referenceTokens;
|
|
4
|
+
exports.contextFootprint = contextFootprint;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const js_tiktoken_1 = require("js-tiktoken");
|
|
8
|
+
const agent_tool_schemas_1 = require("./agent-tool-schemas");
|
|
9
|
+
const cache = new Map();
|
|
10
|
+
let encoder;
|
|
11
|
+
function referenceTokens(text) {
|
|
12
|
+
encoder ?? (encoder = (0, js_tiktoken_1.getEncoding)('cl100k_base'));
|
|
13
|
+
return encoder.encode(text, [], []).length;
|
|
14
|
+
}
|
|
15
|
+
/** Run in the dashboard reader thread. Never launch a CLI/model or return file content. */
|
|
16
|
+
function contextFootprint(workspace) {
|
|
17
|
+
if (!workspace)
|
|
18
|
+
return { observedAt: Date.now(), rows: [] };
|
|
19
|
+
const key = workspace, previous = cache.get(key);
|
|
20
|
+
if (previous && Date.now() - previous.at < 30000)
|
|
21
|
+
return previous.value;
|
|
22
|
+
const rows = [];
|
|
23
|
+
const read = (name) => {
|
|
24
|
+
try {
|
|
25
|
+
const filename = (0, path_1.join)(workspace, name);
|
|
26
|
+
if ((0, fs_1.statSync)(filename).size > 1024 * 1024)
|
|
27
|
+
return undefined;
|
|
28
|
+
return (0, fs_1.readFileSync)(filename, 'utf8');
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const add = (name, text, note) => rows.push({ name, tokens: text === undefined ? null : referenceTokens(text), characters: text === undefined ? null : [...text].length, hasContent: Boolean(text?.trim()), note });
|
|
35
|
+
const composed = read('CLAUDE.md');
|
|
36
|
+
add('CLAUDE.md · composed workspace context', composed, 'Current generated file after workspace budgets. Parent total; do not add its sections again. Not the complete CLI prompt.');
|
|
37
|
+
const labels = { 'AGENT IDENTITY': 'AGENTS.md', 'IDENTITY': 'IDENTITY.md', 'SOUL': 'SOUL.md', 'USER PROFILE': 'USER.md', 'LONG-TERM MEMORY': 'MEMORY.md', 'HEARTBEAT CONFIG': 'HEARTBEAT.md', 'AVAILABLE SKILLS': 'Skill catalog', 'MEMORY RULE': 'Memory rules', 'MEMORY RETRIEVAL': 'Memory retrieval instructions' };
|
|
38
|
+
if (composed) {
|
|
39
|
+
const markers = [...composed.matchAll(/^--- ([A-Z -]+) ---\n/gm)];
|
|
40
|
+
for (let i = 0; i < markers.length; i++) {
|
|
41
|
+
const marker = markers[i], name = labels[marker[1]] || marker[1];
|
|
42
|
+
const text = composed.slice(marker.index + marker[0].length, markers[i + 1]?.index ?? composed.length);
|
|
43
|
+
add('↳ ' + name, text, 'Section found in generated CLAUDE.md; includes section whitespace. Boundary tokenization can differ from parent total.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const name of ['AGENTS.md', 'IDENTITY.md', 'SOUL.md', 'USER.md', 'MEMORY.md', 'HEARTBEAT.md'])
|
|
47
|
+
add(name + ' · source file', read(name), 'Current file on disk before budget/index/truncation. Reference only; not added to composed context.');
|
|
48
|
+
// Every agent tool is declared on every turn, so the measured schema cost does not
|
|
49
|
+
// depend on any feature flag. Filtering one out here would under-report the real prefix.
|
|
50
|
+
add('Agent gateway tool schemas (' + agent_tool_schemas_1.AGENT_TASK_TOOLS.length + ')', JSON.stringify(agent_tool_schemas_1.AGENT_TASK_TOOLS), 'Current host Agent MCP definitions: name, description and inputSchema. Excludes native CLI tools, worker tools and provider framing.');
|
|
51
|
+
const value = { observedAt: Date.now(), rows };
|
|
52
|
+
if (cache.size >= 32)
|
|
53
|
+
cache.delete(cache.keys().next().value);
|
|
54
|
+
cache.set(key, { at: Date.now(), value });
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=context-footprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-footprint.js","sourceRoot":"","sources":["../../src/orchestration/context-footprint.ts"],"names":[],"mappings":";;AAOA,0CAGC;AAMD,4CA2BC;AA3CD,2BAA4C;AAC5C,+BAA4B;AAC5B,6CAA0C;AAC1C,6DAAwD;AAExD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+C,CAAC;AACrE,IAAI,OAAmD,CAAC;AACxD,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,KAAP,OAAO,GAAK,IAAA,yBAAW,EAAC,aAAa,CAAC,EAAC;IACvC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;AAC7C,CAAC;AAKD,2FAA2F;AAC3F,SAAgB,gBAAgB,CAAC,SAA6B;IAC5D,IAAI,CAAC,SAAS;QAAE,OAAO,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AAC,qCAAgB,CAAC,MAAM,GAAC,GAAG,EAAC,IAAI,CAAC,SAAS,CAAC,qCAAgB,CAAC,EAAC,sIAAsI,CAAC,CAAC;IACxO,MAAM,KAAK,GAAC,EAAC,UAAU,EAAC,IAAI,CAAC,GAAG,EAAE,EAAC,IAAI,EAAC,CAAC;IACzC,IAAG,KAAK,CAAC,IAAI,IAAE,EAAE;QAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAM,CAAC,CAAC;IAC3D,KAAK,CAAC,GAAG,CAAC,GAAG,EAAC,EAAC,EAAE,EAAC,IAAI,CAAC,GAAG,EAAE,EAAC,KAAK,EAAC,CAAC,CAAC;IAAA,OAAO,KAAK,CAAC;AACpD,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { OrchestrationStore } from './store';
|
|
2
2
|
import { CommandContext } from './types';
|
|
3
3
|
export interface IntakeChoice {
|
|
4
|
-
mode: 'ready' | 'wait' | 'update';
|
|
4
|
+
mode: 'ready' | 'wait' | 'update' | 'resolve';
|
|
5
|
+
resolution?: string;
|
|
5
6
|
acknowledgement?: string;
|
|
6
7
|
preparation?: string;
|
|
7
8
|
clarification?: string;
|
|
8
9
|
task_id?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare const INTAKE_OVERLAY = "Use conversation_intake only for executable work, incomplete materials, or amendments to an existing task. Greetings, introductions, casual conversation and questions you can answer directly need one normal answer: do not call conversation_intake or emit a separate acknowledgement for them.\nBefore any work mutation, use conversation_intake to decide how to handle the user's latest input together with pending materials and current tasks.\nready: the requested executable action and required material are complete. Supply a brief, specific acknowledgement addressed directly to the user, in their language and your existing persona. This text is immediately displayed to the user and speech is attempted when enabled; it is not a private classification, instruction to yourself, or reasoning field. Do not add a waiting period. A successful acknowledgement permits dispatch even when audio is unavailable. If a task tool fails, explain the failure and never claim work started without a successful receipt.\nwait: the user is supplying materials without an action, promises an attachment that has not arrived, or says the instruction will follow. Inspect available images now. Preserve useful facts in preparation, clearly distinguishing observed contents from instructions. Supply one short clarification to ask only if no further input arrives for the configured intake wait interval. Do not speculate about unavailable link contents. End this turn without user-facing text; the gateway owns the waiting timer. Each new item will be read as it arrives.\nupdate: the user changes or supplements a specific existing task. Supply its exact task_id and acknowledge the change; use task_update/task_answer, not an independent duplicate. If the target is ambiguous, ask a precise question instead of guessing.\nNever create work merely to acknowledge material. A complete instruction arriving after materials is ready now; do not request another waiting interval. Preserve all unchanged requirements and refer to the original input/attachment IDs. Urgent stop or prohibition may call task_cancel before acknowledgement; do not delay fencing unsafe work for speech playback.";
|
|
11
|
+
export declare const INTAKE_OVERLAY = "Use conversation_intake only for executable work, incomplete materials, or amendments to an existing task. Greetings, introductions, casual conversation and questions you can answer directly need one normal answer: do not call conversation_intake or emit a separate acknowledgement for them.\nPending deferredDispatch means an earlier authorized task command did not commit because newer input arrived. Reconcile it with the latest user messages now: dispatch the still-authorized work (including queued continuations), or use mode=resolve with a concrete resolution explaining cancellation, replacement, or why no work remains. After committing the corresponding work, call mode=resolve with its task_id and a resolution explaining how it fulfills the pending request. Unrelated task receipts do not resolve it. A casual reply or acknowledgement does not resolve it. NEW_INPUT_PENDING applies only to that earlier turn, not a permanent execution outage. Never blindly replay a deferred command against changed instructions.\nBefore any work mutation, use conversation_intake to decide how to handle the user's latest input together with pending materials and current tasks.\nready: the requested executable action and required material are complete. Supply a brief, specific acknowledgement addressed directly to the user, in their language and your existing persona. This text is immediately displayed to the user and speech is attempted when enabled; it is not a private classification, instruction to yourself, or reasoning field. Do not add a waiting period. A successful acknowledgement permits dispatch even when audio is unavailable. If a task tool fails, explain the failure and never claim work started without a successful receipt.\nwait: the user is supplying materials without an action, promises an attachment that has not arrived, or says the instruction will follow. Inspect available images now. Preserve useful facts in preparation, clearly distinguishing observed contents from instructions. Supply one short clarification to ask only if no further input arrives for the configured intake wait interval. Do not speculate about unavailable link contents. End this turn without user-facing text; the gateway owns the waiting timer. Each new item will be read as it arrives.\nupdate: the user changes or supplements a specific existing task. Supply its exact task_id and acknowledge the change; use task_update/task_answer, not an independent duplicate. If the target is ambiguous, ask a precise question instead of guessing.\nNever create work merely to acknowledge material. A complete instruction arriving after materials is ready now; do not request another waiting interval. Preserve all unchanged requirements and refer to the original input/attachment IDs. Urgent stop or prohibition may call task_cancel before acknowledgement; do not delay fencing unsafe work for speech playback.";
|
|
11
12
|
/** Durable preparation is scoped by conversation AND authenticated principal.
|
|
12
13
|
* Source inputs remain canonical; this cache only supplements their full contents. */
|
|
13
14
|
export declare class ConversationIntake {
|
|
@@ -15,16 +16,19 @@ export declare class ConversationIntake {
|
|
|
15
16
|
constructor(store: OrchestrationStore);
|
|
16
17
|
context(conversationId: string, principalId: string, bindingId?: string): any;
|
|
17
18
|
touch(inputId: string): void;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
consume
|
|
19
|
+
/** Persist interrupted admission without replaying an uncommitted command. */
|
|
20
|
+
deferDispatch(inputId: string): void;
|
|
21
|
+
/** Direct replies consume materials, but not unresolved deferred work. */
|
|
22
|
+
consume(inputId: string, dispatchResolved?: boolean): void;
|
|
21
23
|
choose(context: CommandContext, choice: IntakeChoice): {
|
|
24
|
+
deferredDispatch?: boolean | undefined;
|
|
25
|
+
resolution: string;
|
|
22
26
|
acknowledgement: string;
|
|
23
27
|
clarification: string;
|
|
24
28
|
preparation: string;
|
|
25
29
|
inputIds: string[];
|
|
26
30
|
preparedInputSeq: string | number | null;
|
|
27
|
-
mode: "ready" | "wait" | "update";
|
|
31
|
+
mode: "ready" | "wait" | "update" | "resolve";
|
|
28
32
|
task_id?: string;
|
|
29
33
|
};
|
|
30
34
|
due(waitMs?: number, now?: number): import("./store").Row[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-intake.d.ts","sourceRoot":"","sources":["../../src/orchestration/conversation-intake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AA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6 +4,7 @@ exports.ConversationIntake = exports.INTAKE_OVERLAY = void 0;
|
|
|
4
4
|
const store_1 = require("./store");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
exports.INTAKE_OVERLAY = `Use conversation_intake only for executable work, incomplete materials, or amendments to an existing task. Greetings, introductions, casual conversation and questions you can answer directly need one normal answer: do not call conversation_intake or emit a separate acknowledgement for them.
|
|
7
|
+
Pending deferredDispatch means an earlier authorized task command did not commit because newer input arrived. Reconcile it with the latest user messages now: dispatch the still-authorized work (including queued continuations), or use mode=resolve with a concrete resolution explaining cancellation, replacement, or why no work remains. After committing the corresponding work, call mode=resolve with its task_id and a resolution explaining how it fulfills the pending request. Unrelated task receipts do not resolve it. A casual reply or acknowledgement does not resolve it. NEW_INPUT_PENDING applies only to that earlier turn, not a permanent execution outage. Never blindly replay a deferred command against changed instructions.
|
|
7
8
|
Before any work mutation, use conversation_intake to decide how to handle the user's latest input together with pending materials and current tasks.
|
|
8
9
|
ready: the requested executable action and required material are complete. Supply a brief, specific acknowledgement addressed directly to the user, in their language and your existing persona. This text is immediately displayed to the user and speech is attempted when enabled; it is not a private classification, instruction to yourself, or reasoning field. Do not add a waiting period. A successful acknowledgement permits dispatch even when audio is unavailable. If a task tool fails, explain the failure and never claim work started without a successful receipt.
|
|
9
10
|
wait: the user is supplying materials without an action, promises an attachment that has not arrived, or says the instruction will follow. Inspect available images now. Preserve useful facts in preparation, clearly distinguishing observed contents from instructions. Supply one short clarification to ask only if no further input arrives for the configured intake wait interval. Do not speculate about unavailable link contents. End this turn without user-facing text; the gateway owns the waiting timer. Each new item will be read as it arrives.
|
|
@@ -35,14 +36,21 @@ class ConversationIntake {
|
|
|
35
36
|
this.store.run(`UPDATE conversation_intake SET latest_input_seq=?,last_received_at=?
|
|
36
37
|
WHERE conversation_id=? AND principal_id=? AND binding_id=? AND latest_input_seq<?`, input.input_seq, input.created_at, input.conversation_id, input.principal_id, input.binding_id, input.input_seq);
|
|
37
38
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/** Persist interrupted admission without replaying an uncommitted command. */
|
|
40
|
+
deferDispatch(inputId) {
|
|
41
|
+
const input = this.store.get('SELECT * FROM conversation_inputs WHERE id=?', inputId);
|
|
42
|
+
if (!input)
|
|
43
|
+
throw new types_1.OrchestrationError('INPUT_NOT_FOUND');
|
|
44
|
+
this.store.run(`UPDATE conversation_intake SET data_json=json_set(data_json,'$.deferredDispatch',json('true'))
|
|
45
|
+
WHERE conversation_id=? AND principal_id=? AND binding_id=?`, input.conversation_id, input.principal_id, input.binding_id);
|
|
46
|
+
}
|
|
47
|
+
/** Direct replies consume materials, but not unresolved deferred work. */
|
|
48
|
+
consume(inputId, dispatchResolved = false) {
|
|
41
49
|
const input = this.store.get('SELECT * FROM conversation_inputs WHERE id=?', inputId);
|
|
42
50
|
if (!input)
|
|
43
51
|
throw new types_1.OrchestrationError('INPUT_NOT_FOUND');
|
|
44
52
|
this.store.run(`DELETE FROM conversation_intake WHERE conversation_id=? AND principal_id=?
|
|
45
|
-
AND binding_id=? AND latest_input_seq
|
|
53
|
+
AND binding_id=? AND latest_input_seq<=? AND (? OR COALESCE(json_extract(data_json,'$.deferredDispatch'),0)=0)`, input.conversation_id, input.principal_id, input.binding_id, input.input_seq, dispatchResolved ? 1 : 0);
|
|
46
54
|
}
|
|
47
55
|
choose(context, choice) {
|
|
48
56
|
this.store.assertMember(context.conversationId, context.principalId);
|
|
@@ -50,11 +58,11 @@ class ConversationIntake {
|
|
|
50
58
|
const input = this.store.get('SELECT * FROM conversation_inputs WHERE id=? AND conversation_id=? AND principal_id=?', context.inputId, context.conversationId, context.principalId);
|
|
51
59
|
if (!decision || !input)
|
|
52
60
|
throw new types_1.OrchestrationError('STALE_DECISION');
|
|
53
|
-
if (!['ready', 'wait', 'update'].includes(choice.mode))
|
|
61
|
+
if (!['ready', 'wait', 'update', 'resolve'].includes(choice.mode))
|
|
54
62
|
throw new types_1.OrchestrationError('INVALID_INPUT');
|
|
55
|
-
const acknowledgement = choice.mode !== 'wait' ? (0, store_1.boundedText)(choice.acknowledgement ?? '', 600) : '';
|
|
63
|
+
const acknowledgement = choice.mode !== 'wait' && choice.mode !== 'resolve' ? (0, store_1.boundedText)(choice.acknowledgement ?? '', 600) : '';
|
|
56
64
|
const clarification = choice.mode === 'wait' ? (0, store_1.boundedText)(choice.clarification ?? '', 600) : '';
|
|
57
|
-
if ((choice.mode !== 'wait' && !acknowledgement.trim()) || (choice.mode === 'wait' && !clarification.trim()))
|
|
65
|
+
if ((choice.mode !== 'wait' && choice.mode !== 'resolve' && !acknowledgement.trim()) || (choice.mode === 'wait' && !clarification.trim()))
|
|
58
66
|
throw new types_1.OrchestrationError('INTAKE_MESSAGE_REQUIRED');
|
|
59
67
|
const preparation = choice.preparation?.trim() ? (0, store_1.boundedText)(choice.preparation, 12000) : '';
|
|
60
68
|
if (choice.mode === 'update') {
|
|
@@ -69,7 +77,13 @@ class ConversationIntake {
|
|
|
69
77
|
const inputIds = [...new Set([...(previous?.inputIds ?? []), context.inputId])];
|
|
70
78
|
if (inputIds.length > 100)
|
|
71
79
|
throw new types_1.OrchestrationError('INTAKE_TOO_MANY_INPUTS');
|
|
72
|
-
const
|
|
80
|
+
const resolution = choice.mode === 'resolve' ? (0, store_1.boundedText)(choice.resolution ?? '', 2000).trim() : '';
|
|
81
|
+
if (choice.mode === 'resolve' && (!resolution || !previous?.deferredDispatch))
|
|
82
|
+
throw new types_1.OrchestrationError('INVALID_INPUT');
|
|
83
|
+
if (choice.mode === 'resolve' && choice.task_id && !this.store.get("SELECT action_id FROM task_commands WHERE conversation_id=? AND principal_id=? AND decision_id=? AND task_id=? AND command_type IN ('spawn','update','answer') LIMIT 1", context.conversationId, context.principalId, context.decisionId, choice.task_id))
|
|
84
|
+
throw new types_1.OrchestrationError('INTAKE_RESOLUTION_UNCOMMITTED');
|
|
85
|
+
const data = { ...choice, resolution, acknowledgement, clarification, preparation, inputIds, preparedInputSeq: input.input_seq,
|
|
86
|
+
...(previous?.deferredDispatch ? { deferredDispatch: true } : {}) };
|
|
73
87
|
this.store.run(`INSERT INTO conversation_intake (conversation_id,principal_id,binding_id,mode,data_json,
|
|
74
88
|
latest_input_seq,last_received_at,clarified_seq,decision_id) VALUES(?,?,?,?,?,?,?,?,?)
|
|
75
89
|
ON CONFLICT(conversation_id,principal_id) DO UPDATE SET binding_id=excluded.binding_id,mode=excluded.mode,data_json=excluded.data_json,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-intake.js","sourceRoot":"","sources":["../../src/orchestration/conversation-intake.ts"],"names":[],"mappings":";;;AAAA,mCAA0D;AAC1D,mCAA6D;
|
|
1
|
+
{"version":3,"file":"conversation-intake.js","sourceRoot":"","sources":["../../src/orchestration/conversation-intake.ts"],"names":[],"mappings":";;;AAAA,mCAA0D;AAC1D,mCAA6D;AAUhD,QAAA,cAAc,GAAG;;;;;;2WAM6U,CAAC;AAE5W;sFACsF;AACtF,MAAa,kBAAkB;IAC7B,YAAoB,KAAyB;QAAzB,UAAK,GAAL,KAAK,CAAoB;QAC3C,KAAK,CAAC,GAAG,CAAC;;;;;iDAKmC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,CAAC,cAAsB,EAAE,WAAmB,EAAE,SAAkB;QACrE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,8EAA8E,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;QACxI,IAAI,GAAG,IAAI,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QACrF,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,E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xH,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/J,OAAO,IAAI,CAAC;IACd,CAAC;IACD,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;;;;;;;4IAOkH,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACzJ,CAAC;CACF;AAhFD,gDAgFC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
/** Aggregate projected measurements in the isolated reader, never transcripts on the event loop. */
|
|
3
|
+
export declare function readDashboardCharts(db: DatabaseSync, scope: string, timezone: string, now: number): {
|
|
4
|
+
reuseComparison: {
|
|
5
|
+
today: {
|
|
6
|
+
fresh: number;
|
|
7
|
+
write: number;
|
|
8
|
+
read: number;
|
|
9
|
+
measuredTurns: number;
|
|
10
|
+
missingTurns: number;
|
|
11
|
+
};
|
|
12
|
+
yesterday: {
|
|
13
|
+
fresh: number;
|
|
14
|
+
write: number;
|
|
15
|
+
read: number;
|
|
16
|
+
measuredTurns: number;
|
|
17
|
+
missingTurns: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
buckets: any[];
|
|
21
|
+
models: any[];
|
|
22
|
+
agent: number;
|
|
23
|
+
worker: number;
|
|
24
|
+
reuse: {
|
|
25
|
+
fresh: number;
|
|
26
|
+
write: number;
|
|
27
|
+
read: number;
|
|
28
|
+
measuredTurns: number;
|
|
29
|
+
missingTurns: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=dashboard-charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-charts.d.ts","sourceRoot":"","sources":["../../src/orchestration/dashboard-charts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;aAMJ,GAAG,EAAE;YAAgB,GAAG,EAAE;;;;;;;;;;EAoDvH"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readDashboardCharts = readDashboardCharts;
|
|
4
|
+
const dashboard_range_1 = require("../ui/dashboard-range");
|
|
5
|
+
/** Aggregate projected measurements in the isolated reader, never transcripts on the event loop. */
|
|
6
|
+
function readDashboardCharts(db, scope, timezone, now) {
|
|
7
|
+
const since = (0, dashboard_range_1.dashboardSince)(scope, now, timezone);
|
|
8
|
+
const today = (0, dashboard_range_1.dashboardSince)('24h', now, timezone);
|
|
9
|
+
const yesterday = (0, dashboard_range_1.dashboardSince)('24h', today - 1, timezone);
|
|
10
|
+
const dayReuse = () => ({ fresh: 0, write: 0, read: 0, measuredTurns: 0, missingTurns: 0 });
|
|
11
|
+
const exists = (name) => !!db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(name);
|
|
12
|
+
const empty = { reuseComparison: { today: dayReuse(), yesterday: dayReuse() }, buckets: [], models: [], agent: 0, worker: 0,
|
|
13
|
+
reuse: { fresh: 0, write: 0, read: 0, measuredTurns: 0, missingTurns: 0 } };
|
|
14
|
+
if (!exists('token_turns'))
|
|
15
|
+
return empty;
|
|
16
|
+
// Older ledgers may have only part of the lightweight projection: fall back per row.
|
|
17
|
+
const projected = exists('token_turn_metrics');
|
|
18
|
+
const payload = projected ? 'COALESCE(m.payload_json,t.payload_json)' : 't.payload_json';
|
|
19
|
+
const join = projected ? 'LEFT JOIN token_turn_metrics m ON m.id=t.id' : '';
|
|
20
|
+
const clock = new Intl.DateTimeFormat('en-CA', { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', hourCycle: 'h23' });
|
|
21
|
+
db.function('dashboard_chart_bucket', (at) => {
|
|
22
|
+
const parts = clock.formatToParts(Number(at));
|
|
23
|
+
const part = (type) => parts.find(p => p.type === type).value;
|
|
24
|
+
return scope === '24h' ? part('hour') : part('year') + '-' + part('month') + '-' + part('day');
|
|
25
|
+
});
|
|
26
|
+
const rows = db.prepare(`WITH turns AS (
|
|
27
|
+
SELECT t.role, t.started_at>=? in_period, CASE WHEN t.started_at>=? THEN 1 WHEN t.started_at>=? THEN 0 ELSE -1 END comparison_day, dashboard_chart_bucket(t.started_at) bucket,
|
|
28
|
+
json_extract(${payload},'$.model') model, json_extract(${payload},'$.usage') usage
|
|
29
|
+
FROM token_turns t ${join} WHERE t.started_at>=? AND t.started_at<=?
|
|
30
|
+
), measured AS (
|
|
31
|
+
SELECT *, json_extract(usage,'$.totalTokens') total,
|
|
32
|
+
json_extract(usage,'$.inputTokens') fresh,
|
|
33
|
+
json_extract(usage,'$.cacheCreationTokens') cache_write,
|
|
34
|
+
json_extract(usage,'$.cacheReadTokens') cache_read FROM turns
|
|
35
|
+
) SELECT role,bucket,model,in_period,comparison_day,SUM(total) tokens,
|
|
36
|
+
SUM(CASE WHEN fresh>=0 AND cache_write>=0 AND cache_read>=0 THEN fresh ELSE 0 END) fresh,
|
|
37
|
+
SUM(CASE WHEN fresh>=0 AND cache_write>=0 AND cache_read>=0 THEN cache_write ELSE 0 END) cache_write,
|
|
38
|
+
SUM(CASE WHEN fresh>=0 AND cache_write>=0 AND cache_read>=0 THEN cache_read ELSE 0 END) cache_read,
|
|
39
|
+
SUM(CASE WHEN fresh>=0 AND cache_write>=0 AND cache_read>=0 THEN 1 ELSE 0 END) measured,
|
|
40
|
+
SUM(CASE WHEN fresh>=0 AND cache_write>=0 AND cache_read>=0 THEN 0 ELSE 1 END) missing
|
|
41
|
+
FROM measured GROUP BY role,bucket,model,in_period,comparison_day ORDER BY bucket`).all(since, today, yesterday, Math.min(since, yesterday), now);
|
|
42
|
+
const buckets = new Map();
|
|
43
|
+
const models = new Map();
|
|
44
|
+
for (const row of rows) {
|
|
45
|
+
if (row.role !== 'agent' && row.role !== 'worker')
|
|
46
|
+
continue;
|
|
47
|
+
if (row.comparison_day === 0 || row.comparison_day === 1) {
|
|
48
|
+
const day = empty.reuseComparison[row.comparison_day === 1 ? 'today' : 'yesterday'];
|
|
49
|
+
day.fresh += Number(row.fresh);
|
|
50
|
+
day.write += Number(row.cache_write);
|
|
51
|
+
day.read += Number(row.cache_read);
|
|
52
|
+
day.measuredTurns += Number(row.measured);
|
|
53
|
+
day.missingTurns += Number(row.missing);
|
|
54
|
+
}
|
|
55
|
+
if (!row.in_period)
|
|
56
|
+
continue;
|
|
57
|
+
const key = String(row.bucket);
|
|
58
|
+
const bucket = buckets.get(key) ?? { key, agent: 0, worker: 0, fresh: 0, write: 0, read: 0 };
|
|
59
|
+
const tokens = Number(row.tokens ?? 0);
|
|
60
|
+
bucket[row.role] += tokens;
|
|
61
|
+
bucket.fresh += Number(row.fresh);
|
|
62
|
+
bucket.write += Number(row.cache_write);
|
|
63
|
+
bucket.read += Number(row.cache_read);
|
|
64
|
+
buckets.set(key, bucket);
|
|
65
|
+
empty[row.role] += tokens;
|
|
66
|
+
const model = typeof row.model === 'string' && row.model ? row.model : 'Unspecified model';
|
|
67
|
+
if (tokens > 0)
|
|
68
|
+
models.set(model, (models.get(model) ?? 0) + tokens);
|
|
69
|
+
empty.reuse.fresh += Number(row.fresh);
|
|
70
|
+
empty.reuse.write += Number(row.cache_write);
|
|
71
|
+
empty.reuse.read += Number(row.cache_read);
|
|
72
|
+
empty.reuse.measuredTurns += Number(row.measured);
|
|
73
|
+
empty.reuse.missingTurns += Number(row.missing);
|
|
74
|
+
}
|
|
75
|
+
return { ...empty, buckets: [...buckets.values()], models: [...models].map(([name, tokens]) => ({ name, tokens })).sort((a, b) => b.tokens - a.tokens || a.name.localeCompare(b.name)) };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=dashboard-charts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-charts.js","sourceRoot":"","sources":["../../src/orchestration/dashboard-charts.ts"],"names":[],"mappings":";;AAIA,kDA0DC;AA9DD,2DAAuD;AAGvD,oGAAoG;AACpG,SAAgB,mBAAmB,CAAC,EAAgB,EAAE,KAAa,EAAE,QAAgB,EAAE,GAAW;IAChG,MAAM,KAAK,GAAG,IAAA,gCAAc,EAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,IAAA,gCAAc,EAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,IAAA,gCAAc,EAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAC,CAAC,EAAE,KAAK,EAAC,CAAC,EAAE,IAAI,EAAC,CAAC,EAAE,aAAa,EAAC,CAAC,EAAE,YAAY,EAAC,CAAC,EAAE,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,2DAA2D,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrH,MAAM,KAAK,GAAG,EAAE,eAAe,EAAE,EAAE,KAAK,EAAC,QAAQ,EAAE,EAAE,SAAS,EAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAW,EAAE,MAAM,EAAE,EAAW,EAAE,KAAK,EAA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