@quantiya/codevibe-core 2.0.8 → 2.0.10
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/__tests__/gate-ux-regressions.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client-flag-locator.test.d.ts +1 -0
- package/dist/appsync/__tests__/dispose-watcher-socket.test.d.ts +1 -0
- package/dist/appsync/appsync-client.d.ts +62 -0
- package/dist/auth/__tests__/keychain-cli-nudge.test.d.ts +1 -0
- package/dist/auth/keychain-cli.d.ts +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +523 -351
- package/dist/keychain/__tests__/migrate-nudge.test.d.ts +1 -0
- package/dist/keychain/keychain-migrate.d.ts +17 -0
- package/dist/keychain/migrate-nudge.d.ts +38 -0
- package/dist/local-executor/__tests__/protocol-backlog-wiring.test.d.ts +1 -0
- package/dist/local-executor/__tests__/protocol-backlog.test.d.ts +1 -0
- package/dist/local-executor/__tests__/workspace-cleanup-audit.test.d.ts +1 -0
- package/dist/local-executor/anchored-fs.d.ts +7 -0
- package/dist/local-executor/bounded-directory.d.ts +14 -0
- package/dist/local-executor/process-identity.d.ts +30 -0
- package/dist/local-executor/process-tree.d.ts +1 -1
- package/dist/local-executor/protocol-backlog.d.ts +62 -0
- package/dist/local-executor/workspace-cleanup-audit.d.ts +3 -0
- package/dist/local-executor/workspace-materializer.d.ts +23 -2
- package/dist/local-executor/workspace-shadow.d.ts +9 -0
- package/dist/local-model/manager.d.ts +1 -1
- package/dist/orchestration-shell/__tests__/direct-file-delete.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/flag-command.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/halt-message-wire-content.test.d.ts +1 -0
- package/dist/orchestration-shell/audit-browser.d.ts +54 -1
- package/dist/orchestration-shell/audit-runner.d.ts +2 -3
- package/dist/orchestration-shell/cli.d.ts +12 -2
- package/dist/orchestration-shell/cli.js +2867 -1500
- package/dist/orchestration-shell/context-items.d.ts +3 -0
- package/dist/orchestration-shell/direct-file-delete.d.ts +22 -0
- package/dist/orchestration-shell/flag-command.d.ts +81 -0
- package/dist/orchestration-shell/gate-prompts.d.ts +41 -0
- package/dist/orchestration-shell/index.d.ts +31 -6
- package/dist/orchestration-shell/quorum-loop.d.ts +64 -4
- package/dist/orchestration-shell/task-progress.d.ts +6 -0
- package/dist/orchestration-shell/types.d.ts +58 -0
- package/dist/orchestration-shell/workspace-shutdown.d.ts +20 -0
- package/dist/reduced-trust-notice.d.ts +44 -0
- package/dist/reviewer/providers/codex.d.ts +5 -3
- package/dist/reviewer/token-usage.d.ts +41 -12
- package/dist/reviewer/types.d.ts +3 -0
- package/dist/substrate/__tests__/command-runner.test.d.ts +1 -0
- package/dist/substrate/types.d.ts +8 -0
- package/dist/tool-activity/consolidator.d.ts +7 -0
- package/dist/tool-activity/ledger.d.ts +33 -13
- package/dist/track-presentation.d.ts +2 -0
- package/dist/track-presentation.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* [P2-0] Clamp an UNTYPED token field (from agent CLI JSON) to
|
|
3
|
-
*
|
|
4
|
-
* object / `NaN` / negative / fractional
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* QuorumLoop `addTaskTokens`) gates on this, so a malformed field contributes 0,
|
|
9
|
-
* never corrupts the accumulator.
|
|
2
|
+
* [P2-0] Clamp an UNTYPED token field (from agent CLI JSON) to the same finite,
|
|
3
|
+
* bounded INTEGER contract the runtime persists. Token fields come from untyped
|
|
4
|
+
* agent JSON — a string / object / `NaN` / negative / fractional / over-contract
|
|
5
|
+
* value would poison the per-task accumulator or fabricate usage. Malformed
|
|
6
|
+
* fields contribute 0 to legacy additive counters and canonical snapshots mark
|
|
7
|
+
* reported invalid fields as `usage_invalid`.
|
|
10
8
|
*/
|
|
11
9
|
export declare function finiteToken(n: unknown): number;
|
|
10
|
+
export type InvocationUsageAvailability = 'complete' | 'partial' | 'unavailable';
|
|
11
|
+
export interface InvocationUsageSnapshot {
|
|
12
|
+
/** Prompt/input tokens. `cachedInputTokens` is a subset, not an addend. */
|
|
13
|
+
inputTokens: number | null;
|
|
14
|
+
/** Output/completion tokens. */
|
|
15
|
+
outputTokens: number | null;
|
|
16
|
+
/** Cached input token subset when the provider exposes it. */
|
|
17
|
+
cachedInputTokens: number | null;
|
|
18
|
+
/** Backward-compatible aggregate: input + output, never cache-added. */
|
|
19
|
+
totalTokens: number | null;
|
|
20
|
+
/** End-to-end invocation elapsed time when known. */
|
|
21
|
+
elapsedMs: number | null;
|
|
22
|
+
availability: InvocationUsageAvailability;
|
|
23
|
+
/** Closed reason label when availability is unavailable/partial. */
|
|
24
|
+
unavailableReason: string | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function tokenFieldAvailable(value: unknown): value is number;
|
|
27
|
+
export declare function usageSnapshotFromParts(args: {
|
|
28
|
+
inputTokens: number;
|
|
29
|
+
outputTokens: number;
|
|
30
|
+
cachedInputTokens?: number;
|
|
31
|
+
elapsedMs?: number | null;
|
|
32
|
+
inputTokensAvailable?: boolean;
|
|
33
|
+
outputTokensAvailable?: boolean;
|
|
34
|
+
cachedInputTokensAvailable?: boolean;
|
|
35
|
+
}): InvocationUsageSnapshot;
|
|
36
|
+
export declare function unavailableUsageSnapshot(reason: string, elapsedMs?: number | null): InvocationUsageSnapshot;
|
|
12
37
|
/**
|
|
13
38
|
* Locate the FIRST balanced top-level `{...}` in `stdout` that parses to an object
|
|
14
39
|
* with `type === 'result'` — Claude may emit non-JSON warning / MCP lines before
|
|
@@ -31,12 +56,16 @@ export declare function firstResultEnvelope(stdout: string): Record<string, unkn
|
|
|
31
56
|
* • `is_error === true` OR `result` not a non-empty string → `{ text:'', tokens:
|
|
32
57
|
* undefined }`. The CALLER treats an empty/failed result as an agent FAILURE
|
|
33
58
|
* (reviewer ESCALATE / resolver human-gate — same as today), NOT a silent pass.
|
|
34
|
-
* • else → `{ text: result, tokens:
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
59
|
+
* • else → `{ text: result, tokens: totalTokens || undefined }`. `finiteToken`
|
|
60
|
+
* clamps absent/malformed usage to 0 (no `TypeError`, no `NaN`). Claude's
|
|
61
|
+
* documented input total is uncached input plus cache-write/cache-read
|
|
62
|
+
* buckets, while `cachedInputTokens` remains the cached subset. The older
|
|
63
|
+
* `cached_input_tokens` alias is intentionally ignored unless backed by
|
|
64
|
+
* documented Claude result-envelope evidence.
|
|
38
65
|
*/
|
|
66
|
+
export declare function extractClaudeUsageSnapshot(stdout: string, elapsedMs?: number | null): InvocationUsageSnapshot;
|
|
39
67
|
export declare function unwrapClaudeJson(stdout: string): {
|
|
40
68
|
text: string;
|
|
41
69
|
tokens?: number;
|
|
70
|
+
usage: InvocationUsageSnapshot;
|
|
42
71
|
};
|
package/dist/reviewer/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InvocationUsageSnapshot } from './token-usage.js';
|
|
1
2
|
/**
|
|
2
3
|
* Agent kinds the reviewer subprocess layer can spawn.
|
|
3
4
|
*
|
|
@@ -101,4 +102,6 @@ export interface ReviewerVerdict {
|
|
|
101
102
|
latency_ms: number | null;
|
|
102
103
|
/** ISO 8601 UTC timestamp string when the reviewer returned the verdict. */
|
|
103
104
|
submitted_at: string;
|
|
105
|
+
/** Canonical input/output/cache/elapsed usage snapshot. Additive post-launch. */
|
|
106
|
+
usage?: InvocationUsageSnapshot;
|
|
104
107
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -136,6 +136,14 @@ export interface SubstrateProc {
|
|
|
136
136
|
readonly stdin: Writable | null;
|
|
137
137
|
readonly stdout: Readable | null;
|
|
138
138
|
readonly stderr: Readable | null;
|
|
139
|
+
/**
|
|
140
|
+
* The host command runner advertises this only when the returned process is
|
|
141
|
+
* itself wrapped by CodeVibe's authenticated POSIX process host. The Local
|
|
142
|
+
* Executor must then await that host's cleanup proof before retiring a
|
|
143
|
+
* workspace. Docker-backed substrate processes omit it because the
|
|
144
|
+
* container, rather than a host POSIX group, owns their lifecycle.
|
|
145
|
+
*/
|
|
146
|
+
readonly hostProcessTreeOwnership?: "posix-host";
|
|
139
147
|
kill(signal?: NodeJS.Signals): boolean;
|
|
140
148
|
on(event: "close" | "error" | "exit", cb: (...a: unknown[]) => void): this;
|
|
141
149
|
}
|
|
@@ -48,6 +48,13 @@ export interface ToolActivityTransport {
|
|
|
48
48
|
* undecryptable generation forever (a liveness/G2 failure on key rotation).
|
|
49
49
|
*/
|
|
50
50
|
export declare function isSessionKeyStaleError(err: unknown): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* True only when the backend has proved that this session generation can never
|
|
53
|
+
* accept another event. These errors settle the durable window terminally;
|
|
54
|
+
* key rotation, contention, throttling, networking, and unknown failures remain
|
|
55
|
+
* retryable so recoverable tool activity is never discarded.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isTerminalSessionError(err: unknown): boolean;
|
|
51
58
|
export interface ToolActivityConsolidatorOptions {
|
|
52
59
|
agent: string;
|
|
53
60
|
/** The backend session id bound into each window's envelope (X2a routing). */
|
|
@@ -12,13 +12,13 @@ export declare const LedgerEntrySchema: z.ZodObject<{
|
|
|
12
12
|
* rewind falls back to session start, which is still SAFE.
|
|
13
13
|
*/
|
|
14
14
|
byteOffset: z.ZodNumber;
|
|
15
|
-
state: z.ZodEnum<["durably-outboxed", "acked"]>;
|
|
15
|
+
state: z.ZodEnum<["durably-outboxed", "acked", "terminal"]>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
state: "durably-outboxed" | "acked";
|
|
17
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
18
18
|
byteOffset: number;
|
|
19
19
|
clientEventId: string;
|
|
20
20
|
}, {
|
|
21
|
-
state: "durably-outboxed" | "acked";
|
|
21
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
22
22
|
byteOffset: number;
|
|
23
23
|
clientEventId: string;
|
|
24
24
|
}>;
|
|
@@ -36,30 +36,37 @@ export declare const LedgerFileSchema: z.ZodObject<{
|
|
|
36
36
|
* rewind falls back to session start, which is still SAFE.
|
|
37
37
|
*/
|
|
38
38
|
byteOffset: z.ZodNumber;
|
|
39
|
-
state: z.ZodEnum<["durably-outboxed", "acked"]>;
|
|
39
|
+
state: z.ZodEnum<["durably-outboxed", "acked", "terminal"]>;
|
|
40
40
|
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
state: "durably-outboxed" | "acked";
|
|
41
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
42
42
|
byteOffset: number;
|
|
43
43
|
clientEventId: string;
|
|
44
44
|
}, {
|
|
45
|
-
state: "durably-outboxed" | "acked";
|
|
45
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
46
46
|
byteOffset: number;
|
|
47
47
|
clientEventId: string;
|
|
48
48
|
}>>;
|
|
49
|
+
/**
|
|
50
|
+
* Permanently rejected outbox windows. Optional for backwards compatibility
|
|
51
|
+
* with version-1 ledgers written before per-window terminal authority existed.
|
|
52
|
+
*/
|
|
53
|
+
terminalClientEventIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
49
54
|
}, "strip", z.ZodTypeAny, {
|
|
50
55
|
entries: Record<string, {
|
|
51
|
-
state: "durably-outboxed" | "acked";
|
|
56
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
52
57
|
byteOffset: number;
|
|
53
58
|
clientEventId: string;
|
|
54
59
|
}>;
|
|
55
60
|
version: 1;
|
|
61
|
+
terminalClientEventIds: string[];
|
|
56
62
|
}, {
|
|
57
63
|
entries: Record<string, {
|
|
58
|
-
state: "durably-outboxed" | "acked";
|
|
64
|
+
state: "terminal" | "durably-outboxed" | "acked";
|
|
59
65
|
byteOffset: number;
|
|
60
66
|
clientEventId: string;
|
|
61
67
|
}>;
|
|
62
68
|
version: 1;
|
|
69
|
+
terminalClientEventIds?: string[] | undefined;
|
|
63
70
|
}>;
|
|
64
71
|
export type LedgerFile = z.infer<typeof LedgerFileSchema>;
|
|
65
72
|
/**
|
|
@@ -111,7 +118,9 @@ export declare class ToolActivityLedger {
|
|
|
111
118
|
private readonly logger;
|
|
112
119
|
private readonly rootDir;
|
|
113
120
|
private entries;
|
|
121
|
+
private terminalWindows;
|
|
114
122
|
private loaded;
|
|
123
|
+
private mutationChain;
|
|
115
124
|
constructor(opts: ToolActivityLedgerOptions);
|
|
116
125
|
private filePath;
|
|
117
126
|
private legacyOwnedFilePath;
|
|
@@ -133,7 +142,7 @@ export declare class ToolActivityLedger {
|
|
|
133
142
|
* rebuildability) — used after a ledger loss so a still-pending window is not
|
|
134
143
|
* re-observed as new. The outbox does not carry per-occurrence byteOffsets, so
|
|
135
144
|
* they default to 0 (rewind falls back to the safe session-start bound).
|
|
136
|
-
* Never DOWNGRADES an existing `acked` entry.
|
|
145
|
+
* Never DOWNGRADES an existing `acked` or `terminal` entry.
|
|
137
146
|
*/
|
|
138
147
|
rebuildFromOutbox(outboxEntries: ToolActivityOutboxEnvelope[]): void;
|
|
139
148
|
/**
|
|
@@ -168,7 +177,9 @@ export declare class ToolActivityLedger {
|
|
|
168
177
|
* (`entries`/`owned`) deferral is permanent, so the cursor advances freely.
|
|
169
178
|
*/
|
|
170
179
|
isLegacyInFlight(id: string): boolean;
|
|
171
|
-
getState(id: string): 'durably-outboxed' | 'acked' | undefined;
|
|
180
|
+
getState(id: string): 'durably-outboxed' | 'acked' | 'terminal' | undefined;
|
|
181
|
+
/** True when a window has been durably settled as permanently undeliverable. */
|
|
182
|
+
isTerminalWindow(clientEventId: string): boolean;
|
|
172
183
|
/**
|
|
173
184
|
* Unique `clientEventId`s still in the `durably-outboxed` state (sealed, not yet
|
|
174
185
|
* acked). The §4.5 N4 startup cross-check compares these against the surviving
|
|
@@ -192,6 +203,11 @@ export declare class ToolActivityLedger {
|
|
|
192
203
|
markDurablyOutboxed(occurrences: OccurrenceRef[], clientEventId: string): Promise<void>;
|
|
193
204
|
/** Mark every id of an acked window `acked` (retained for the pruning horizon). */
|
|
194
205
|
markAcked(clientEventId: string): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Mark every id of a permanently rejected window `terminal`. This must be
|
|
208
|
+
* persisted before its outbox file is pruned so restart cannot resend it.
|
|
209
|
+
*/
|
|
210
|
+
markTerminal(clientEventId: string, invocationIds?: string[]): Promise<void>;
|
|
195
211
|
/**
|
|
196
212
|
* Crash-ordered repair step (2) (§4.5 V3/W2): DEMOTE/remove every mapping
|
|
197
213
|
* referencing a quarantined or missing `clientEventId` so its occurrences are
|
|
@@ -265,10 +281,14 @@ export declare class ToolActivityLedger {
|
|
|
265
281
|
/** Test/diagnostic: a snapshot of the in-memory legacy IN-FLIGHT id set. */
|
|
266
282
|
legacyInFlightSnapshot(): string[];
|
|
267
283
|
/**
|
|
268
|
-
* Bound ledger growth: drop `acked` entries whose
|
|
269
|
-
* BELOW a safe horizon (§4.5 — max(replay cursor,
|
|
270
|
-
* prunes `durably-outboxed`
|
|
284
|
+
* Bound ledger growth: drop settled (`acked` or `terminal`) entries whose
|
|
285
|
+
* source position is strictly BELOW a safe horizon (§4.5 — max(replay cursor,
|
|
286
|
+
* Stop turn-start)). Never prunes `durably-outboxed` or a terminal tombstone
|
|
287
|
+
* whose outbox file still exists: the latter may be an interrupted prune and
|
|
288
|
+
* must remain terminal across restart. Persists if anything changed.
|
|
271
289
|
*/
|
|
272
290
|
prune(beforeByteOffset: number): Promise<void>;
|
|
291
|
+
private mutateAndPersist;
|
|
292
|
+
private outboxEntryExists;
|
|
273
293
|
private persist;
|
|
274
294
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED