@quantiya/codevibe-core 2.0.7 → 2.0.9
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/appsync/__tests__/dispose-watcher-socket.test.d.ts +1 -0
- package/dist/appsync/__tests__/refresh-open-prompt-ttl-chunk.test.d.ts +1 -0
- package/dist/appsync/appsync-client.d.ts +232 -30
- package/dist/appsync/queries.d.ts +2 -0
- package/dist/auth/__tests__/keychain-cli-nudge.test.d.ts +1 -0
- package/dist/auth/__tests__/keychain-cli.test.d.ts +1 -0
- package/dist/auth/keychain-cli.d.ts +14 -0
- package/dist/companion-mode/index.d.ts +14 -0
- package/dist/credential-broker/oauth-account-lock.d.ts +47 -1
- package/dist/crypto/__tests__/open-prompt-id.test.d.ts +1 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/open-prompt-id.d.ts +36 -0
- package/dist/e1/__tests__/prompt-raise.test.d.ts +1 -0
- package/dist/e1/index.d.ts +2 -0
- package/dist/e1/prompt-raise.d.ts +65 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4652 -252
- package/dist/keychain/__tests__/keychain-manager.test.d.ts +1 -0
- package/dist/keychain/__tests__/keychain-migrate.test.d.ts +1 -0
- package/dist/keychain/__tests__/migrate-nudge.test.d.ts +1 -0
- package/dist/keychain/keychain-backend.d.ts +105 -0
- package/dist/keychain/keychain-manager.d.ts +17 -3
- package/dist/keychain/keychain-migrate.d.ts +63 -0
- package/dist/keychain/migrate-nudge.d.ts +38 -0
- package/dist/local-executor/__tests__/anchored-fs.test.d.ts +1 -0
- package/dist/local-executor/__tests__/bounded-directory.test.d.ts +1 -0
- package/dist/local-executor/__tests__/bounded-output.test.d.ts +1 -0
- package/dist/local-executor/__tests__/durable-directory.test.d.ts +1 -0
- package/dist/local-executor/__tests__/hosted-class-a-sink.test.d.ts +1 -0
- package/dist/local-executor/__tests__/process-identity.test.d.ts +1 -0
- package/dist/local-executor/__tests__/process-tree.test.d.ts +1 -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__/publication-authority-capability.test.d.ts +1 -0
- package/dist/local-executor/__tests__/snapshot-merge.test.d.ts +1 -0
- package/dist/local-executor/__tests__/workspace-authority-fixture.d.ts +3 -0
- package/dist/local-executor/__tests__/workspace-authority.test.d.ts +1 -0
- package/dist/local-executor/__tests__/workspace-cleanup-audit.test.d.ts +1 -0
- package/dist/local-executor/__tests__/workspace-materializer.test.d.ts +1 -0
- package/dist/local-executor/agentic-disposable-repo.d.ts +23 -6
- package/dist/local-executor/agentic-resolve.d.ts +16 -0
- package/dist/local-executor/anchored-fs.d.ts +250 -0
- package/dist/local-executor/bounded-directory.d.ts +78 -0
- package/dist/local-executor/bounded-helper.d.ts +22 -0
- package/dist/local-executor/bounded-output.d.ts +11 -0
- package/dist/local-executor/class-a-emit.d.ts +13 -1
- package/dist/local-executor/durable-directory.d.ts +25 -0
- package/dist/local-executor/durable-store.d.ts +217 -25
- package/dist/local-executor/hosted-class-a-sink.d.ts +27 -0
- package/dist/local-executor/index.d.ts +3 -2
- package/dist/local-executor/local-executor-impl.d.ts +159 -69
- package/dist/local-executor/process-identity.d.ts +46 -0
- package/dist/local-executor/process-tree.d.ts +123 -0
- package/dist/local-executor/protocol-backlog.d.ts +62 -0
- package/dist/local-executor/revert-reconcile.d.ts +4 -0
- package/dist/local-executor/revert-runner.d.ts +14 -1
- package/dist/local-executor/snapshot-merge.d.ts +124 -0
- package/dist/local-executor/task-group-types.d.ts +7 -6
- package/dist/local-executor/team-execution-flag.d.ts +2 -2
- package/dist/local-executor/track-registry.d.ts +2 -0
- package/dist/local-executor/types.d.ts +33 -2
- package/dist/local-executor/verification-gates/build.d.ts +5 -0
- package/dist/local-executor/verification-gates/deploy-preflight.d.ts +2 -0
- package/dist/local-executor/verification-gates/diff-sanity.d.ts +12 -0
- package/dist/local-executor/verification-gates/hostile-grep.d.ts +2 -0
- package/dist/local-executor/verification-gates/lint.d.ts +2 -0
- package/dist/local-executor/verification-gates/shell-runner.d.ts +5 -0
- package/dist/local-executor/verification-gates/source-traceability.d.ts +2 -0
- package/dist/local-executor/verification-gates/tests.d.ts +3 -0
- package/dist/local-executor/verification-gates/typecheck.d.ts +3 -0
- package/dist/local-executor/verification-runner.d.ts +6 -0
- package/dist/local-executor/workspace-authority.d.ts +45 -0
- package/dist/local-executor/workspace-cleanup-audit.d.ts +3 -0
- package/dist/local-executor/workspace-materializer.d.ts +48 -0
- package/dist/local-executor/workspace-shadow.d.ts +380 -85
- package/dist/orchestration-shell/__tests__/advisory-attachment-journal.test.d.ts +1 -0
- 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/__tests__/planner-offer-e1.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/workspace-shutdown.test.d.ts +1 -0
- package/dist/orchestration-shell/advisory-attachment-journal.d.ts +165 -0
- package/dist/orchestration-shell/attachments.d.ts +47 -58
- package/dist/orchestration-shell/audit-browser.d.ts +54 -1
- package/dist/orchestration-shell/bounded-shutdown.d.ts +6 -0
- package/dist/orchestration-shell/cli.d.ts +10 -0
- package/dist/orchestration-shell/cli.js +38355 -27300
- package/dist/orchestration-shell/context-items.d.ts +3 -0
- package/dist/orchestration-shell/declared-test-runner.d.ts +21 -2
- package/dist/orchestration-shell/direct-file-delete.d.ts +22 -0
- package/dist/orchestration-shell/emit-shell-event.d.ts +7 -0
- package/dist/orchestration-shell/explicit-tty-exit.d.ts +1 -2
- package/dist/orchestration-shell/flag-command.d.ts +81 -0
- package/dist/orchestration-shell/gate-decision-submit.d.ts +11 -0
- package/dist/orchestration-shell/gate-prompts.d.ts +116 -0
- package/dist/orchestration-shell/index.d.ts +34 -6
- package/dist/orchestration-shell/planner-offer-e1.d.ts +97 -0
- package/dist/orchestration-shell/quorum-loop.d.ts +312 -61
- package/dist/orchestration-shell/reducer.d.ts +9 -0
- package/dist/orchestration-shell/task-progress.d.ts +18 -4
- package/dist/orchestration-shell/team-decompose.d.ts +10 -10
- package/dist/orchestration-shell/types.d.ts +90 -2
- package/dist/orchestration-shell/workspace-shutdown.d.ts +47 -0
- package/dist/reviewer/output-parser.d.ts +19 -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 +6 -0
- package/dist/reviewer/verdict-classifier.d.ts +1 -0
- package/dist/session/session-rekey.d.ts +4 -3
- package/dist/substrate/__tests__/command-runner.test.d.ts +1 -0
- package/dist/substrate/command-runner.d.ts +2 -0
- package/dist/substrate/docker.d.ts +7 -32
- package/dist/substrate/index.d.ts +0 -1
- package/dist/substrate/sandbox-exec.d.ts +0 -13
- package/dist/substrate/types.d.ts +15 -2
- package/dist/substrate-launch/__tests__/reviewer-credential-preflight.test.d.ts +1 -0
- package/dist/substrate-launch/engage-substrate.d.ts +3 -0
- package/dist/substrate-launch/index.d.ts +2 -0
- package/dist/substrate-launch/reviewer-credential-preflight.d.ts +50 -0
- package/dist/test-publication-authority-setup.d.ts +1 -0
- package/dist/tool-activity/replay-cursor.d.ts +42 -8
- package/dist/track-presentation.d.ts +2 -0
- package/dist/track-presentation.test.d.ts +1 -0
- package/dist/types/encryption.d.ts +5 -0
- package/dist/types/events.d.ts +5 -0
- package/package.json +3 -3
- package/dist/substrate/git-proxy.d.ts +0 -35
- /package/dist/{substrate/__tests__/git-proxy.test.d.ts → appsync/__tests__/appsync-client-flag-locator.test.d.ts} +0 -0
|
@@ -81,6 +81,8 @@ export interface ContextItem {
|
|
|
81
81
|
prev_hash: string | null;
|
|
82
82
|
/** Typed payload per kind. */
|
|
83
83
|
body: unknown;
|
|
84
|
+
/** Non-rendered counters/locator metadata; excluded from semantic content ids. */
|
|
85
|
+
telemetry?: unknown;
|
|
84
86
|
/** ISO timestamp the item was authored (corpus-ready, §4.1). */
|
|
85
87
|
authored_at: string;
|
|
86
88
|
}
|
|
@@ -91,6 +93,7 @@ export interface ContextItemDraft {
|
|
|
91
93
|
sensitivity: ContextItemSensitivity;
|
|
92
94
|
visible_to: ContextItemProjectionRole[];
|
|
93
95
|
body: unknown;
|
|
96
|
+
telemetry?: unknown;
|
|
94
97
|
task_id?: string;
|
|
95
98
|
track_id?: string;
|
|
96
99
|
refs?: string[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Dirent, Stats } from 'node:fs';
|
|
2
2
|
import type { runShellCommand } from '../local-executor/verification-gates/shell-runner';
|
|
3
3
|
import type { ShadowDiffFile } from '../local-executor/workspace-shadow';
|
|
4
|
+
import type { ProcessCleanupOwner } from '../local-executor/process-tree';
|
|
5
|
+
import { type WorkspaceRootAuthority } from '../local-executor/workspace-authority';
|
|
4
6
|
/** Default per-file wall-clock budget for a declared-test `node` run. */
|
|
5
7
|
export declare const DECLARED_TEST_TIMEOUT_MS = 300000;
|
|
6
8
|
/**
|
|
@@ -20,6 +22,9 @@ export interface DeclaredTestResult {
|
|
|
20
22
|
ranCount: number;
|
|
21
23
|
/** Never-written declared file / empty-or-JS-less declared dir (§3.D, VISIBLE). */
|
|
22
24
|
skipped: string[];
|
|
25
|
+
/** False means the caller must retain the test cwd. */
|
|
26
|
+
workspaceCleanupSafe?: false;
|
|
27
|
+
workspaceCleanupOwner?: ProcessCleanupOwner;
|
|
23
28
|
}
|
|
24
29
|
export interface RunDeclaredTestSurfacesArgs {
|
|
25
30
|
/** cwd holding the agent's changes (the shadow root). */
|
|
@@ -37,8 +42,8 @@ export interface RunDeclaredTestSurfacesArgs {
|
|
|
37
42
|
realpath: (p: string) => Promise<string>;
|
|
38
43
|
/** Injected — file/dir discriminate on the resolved target. */
|
|
39
44
|
stat: (p: string) => Promise<Stats>;
|
|
40
|
-
/**
|
|
41
|
-
readdir
|
|
45
|
+
/** @internal test-only directory expansion seam; production streams via opendir. */
|
|
46
|
+
readdir?: (p: string) => Promise<Dirent[]>;
|
|
42
47
|
/**
|
|
43
48
|
* Injected (#609) — read a file's UTF-8 contents (nearest-`package.json` framework detection).
|
|
44
49
|
* A throw (ENOENT / EISDIR / unreadable) is TOTAL-handled by `detectFramework` (→ keep walking up,
|
|
@@ -47,6 +52,20 @@ export interface RunDeclaredTestSurfacesArgs {
|
|
|
47
52
|
readFile: (p: string) => Promise<string>;
|
|
48
53
|
/** Default `DECLARED_TEST_TIMEOUT_MS`. */
|
|
49
54
|
timeoutMs?: number;
|
|
55
|
+
/** Cooperative session-shutdown cancellation for spawned test processes. */
|
|
56
|
+
signal?: AbortSignal;
|
|
57
|
+
/** Exact snapshot incarnation selected before declared-test discovery. */
|
|
58
|
+
shadowRootAuthority?: WorkspaceRootAuthority;
|
|
59
|
+
/** @internal deterministic root-replacement seam after initial validation. */
|
|
60
|
+
afterAuthorityCheck?: () => Promise<void> | void;
|
|
61
|
+
/** @internal deterministic A→B→A restoration before the final check. */
|
|
62
|
+
beforeAuthorityCompletion?: () => Promise<void> | void;
|
|
63
|
+
/** @internal deterministic root replacement immediately before framework discovery. */
|
|
64
|
+
beforeFrameworkDiscovery?: () => Promise<void> | void;
|
|
65
|
+
/** @internal helper-held missing-intermediate authority seam. */
|
|
66
|
+
beforeClassificationMissing?: () => Promise<void> | void;
|
|
67
|
+
/** @internal helper-held missing-leaf completion seam. */
|
|
68
|
+
beforeClassificationCompletion?: () => Promise<void> | void;
|
|
50
69
|
}
|
|
51
70
|
/**
|
|
52
71
|
* Canonicalize a declared scope / diff path for comparison: collapse backslashes to
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface DirectFileDeleteRequest {
|
|
2
|
+
paths: string[];
|
|
3
|
+
}
|
|
4
|
+
export interface DirectFileDeleteResult {
|
|
5
|
+
deleted: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Recognize only a closed, deterministic delete request. Anything ambiguous
|
|
9
|
+
* remains on the ordinary planner/implementor path.
|
|
10
|
+
*
|
|
11
|
+
* Supported examples:
|
|
12
|
+
* Delete only a.txt.
|
|
13
|
+
* Please delete only `a file.txt` and `b.txt`.
|
|
14
|
+
* Delete only a.txt. Do not create, modify, or delete any other file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseDirectFileDeleteRequest(text: string): DirectFileDeleteRequest | null;
|
|
17
|
+
/**
|
|
18
|
+
* Delete only the explicitly named regular files. All targets are validated
|
|
19
|
+
* before the first mutation; each unlink is bound to the captured parent and
|
|
20
|
+
* file incarnation and directory-fsynced by the anchored helper.
|
|
21
|
+
*/
|
|
22
|
+
export declare function executeDirectFileDelete(cwd: string, request: DirectFileDeleteRequest): Promise<DirectFileDeleteResult>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppSyncClient } from '../appsync';
|
|
2
2
|
import { type Session } from '../types';
|
|
3
|
+
import type { E1ProducerKind } from '../e1';
|
|
3
4
|
/**
|
|
4
5
|
* §3 LOCK lines 173-181. Names + per-type metadata shapes are part of
|
|
5
6
|
* the Stage A contract. CP-1.a ships the union; CP-1.b/c/d add call
|
|
@@ -34,6 +35,12 @@ export interface ShellEventEmit {
|
|
|
34
35
|
writerEventNonce?: string;
|
|
35
36
|
/** Proven local key mismatch: emit the safe legacy joined fallback. */
|
|
36
37
|
disableWriterAttestation?: boolean;
|
|
38
|
+
ownerToken?: string;
|
|
39
|
+
promptId?: string;
|
|
40
|
+
producerKind?: E1ProducerKind;
|
|
41
|
+
mobileActionable?: boolean;
|
|
42
|
+
resolvedPromptId?: string;
|
|
43
|
+
resolutionAt?: string;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Test seam — allows the unit tests to swap the AppSync client without
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AppSyncClient } from '../appsync';
|
|
2
|
+
import { type AuditBrowserModel } from './audit-browser';
|
|
3
|
+
import type { AuditFlagIndex } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Build the session-scoped flag index from a just-rendered `/audit` browser
|
|
6
|
+
* model. Called at the `/audit <task-id>` dispatch site on a successful
|
|
7
|
+
* render; the entrypoint retains the result via `AUDIT_FLAG_INDEX_RETAINED`
|
|
8
|
+
* (last render wins — the reducer carries the `flagged` set forward).
|
|
9
|
+
* Shape-only: coordinates + wire kind + the precomputed flaggable bit; the
|
|
10
|
+
* decrypted payload never leaves the render.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildAuditFlagIndex(taskId: string, model: AuditBrowserModel): AuditFlagIndex;
|
|
13
|
+
/**
|
|
14
|
+
* The minimal AppSync surface `/flag` needs — the existing
|
|
15
|
+
* `recordExecutionEvent` Class-A method (D4: the full plumbing below it
|
|
16
|
+
* already exists). Narrowed so tests inject a stub without the full client.
|
|
17
|
+
*/
|
|
18
|
+
export type FlagAppSyncClient = Pick<AppSyncClient, 'recordExecutionEvent'>;
|
|
19
|
+
export interface RunFlagCommandDeps {
|
|
20
|
+
/** The authenticated AppSync client. */
|
|
21
|
+
appsyncClient: FlagAppSyncClient;
|
|
22
|
+
/** The retained last-rendered `/audit` index (null → never rendered). */
|
|
23
|
+
index: AuditFlagIndex | null;
|
|
24
|
+
/** The `/flag <entry-id>` argument. */
|
|
25
|
+
entryId: string;
|
|
26
|
+
/** Optional free-text note (encrypted into the flag payload; never logged). */
|
|
27
|
+
note?: string;
|
|
28
|
+
/** The shell session (locator/emit scoping + session-key lookup). */
|
|
29
|
+
sessionId: string;
|
|
30
|
+
/** Test seam — defaults to `keychainManager.getSessionKey(sessionId)`. */
|
|
31
|
+
getSessionKeyFn?: (sessionId: string) => Promise<string | null>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The outcome of a `/flag` run. Every arm carries a ready-to-render `line`;
|
|
35
|
+
* `runFlagCommand` NEVER throws (mirrors `runAuditBrowser`).
|
|
36
|
+
*/
|
|
37
|
+
export type RunFlagCommandResult = {
|
|
38
|
+
kind: 'no_index';
|
|
39
|
+
line: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'unknown_entry';
|
|
42
|
+
line: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'not_flaggable';
|
|
45
|
+
line: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'missing_seq';
|
|
48
|
+
line: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'already_flagged';
|
|
51
|
+
line: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'no_session_key';
|
|
54
|
+
line: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'flagged';
|
|
57
|
+
entryId: string;
|
|
58
|
+
line: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'server_rejected';
|
|
61
|
+
line: string;
|
|
62
|
+
reason: string;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'error';
|
|
65
|
+
line: string;
|
|
66
|
+
reason: string;
|
|
67
|
+
};
|
|
68
|
+
/** `/flag` before any `/audit <task-id>` render — nothing to resolve against. */
|
|
69
|
+
export declare const FLAG_NO_INDEX_LINE: string;
|
|
70
|
+
/**
|
|
71
|
+
* Run `/flag <entry-id>`: retained-index resolve → client approve-subset
|
|
72
|
+
* check → locator + dedup-key construction → Class-A `FLAG_BAD_APPROVAL`
|
|
73
|
+
* emit with locator forwarding. Returns a discriminated result the shell
|
|
74
|
+
* renders; the CALLER dispatches `AUDIT_FLAG_RECORDED` on the `flagged` arm
|
|
75
|
+
* (the runner stays store-free, like `runAuditBrowser`).
|
|
76
|
+
*/
|
|
77
|
+
export declare function runFlagCommand(deps: RunFlagCommandDeps): Promise<RunFlagCommandResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Render a `RunFlagCommandResult` as the inline `/flag` shell output line.
|
|
80
|
+
*/
|
|
81
|
+
export declare function renderFlagResultText(result: RunFlagCommandResult): string;
|
|
@@ -152,6 +152,11 @@ export interface GroupDecisionSubmitDeps {
|
|
|
152
152
|
* after an accept-family COMMIT. ABSENT → no-op (tests).
|
|
153
153
|
*/
|
|
154
154
|
markAccepted?: (taskGroupId: string) => Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Accept-family finalizer: retire PREPARED/APPLIED authority by exact base or
|
|
157
|
+
* post-image proof before marking accepted or clearing reviewed bundles.
|
|
158
|
+
*/
|
|
159
|
+
finalizeAcceptedGroup: (taskGroupId: string) => Promise<void>;
|
|
155
160
|
/**
|
|
156
161
|
* HIGH-1 / LOCK #589-J — persist the CLAIMED-but-not-COMMITted decision to the
|
|
157
162
|
* durable record, called IMMEDIATELY after the CLAIM phase mints `claimToken`
|
|
@@ -170,6 +175,12 @@ export interface GroupDecisionSubmitDeps {
|
|
|
170
175
|
* (so a later reconcile never re-drives it). ABSENT → no-op (tests).
|
|
171
176
|
*/
|
|
172
177
|
clearPendingDecision?: (taskGroupId: string) => Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Reclaim terminal durable group bytes after COMMIT, convergence, lifecycle
|
|
180
|
+
* transition, reissue (when requested), and pending-decision removal. The
|
|
181
|
+
* durable store rechecks every crash-authority predicate before deleting.
|
|
182
|
+
*/
|
|
183
|
+
gcTerminalGroup?: (taskGroupId: string) => Promise<void>;
|
|
173
184
|
/**
|
|
174
185
|
* Drive the per-track render flip through the SAME `emitGroupConvergence`
|
|
175
186
|
* chokepoint (D2): accept-family → tracks stay/flip `Passed`; reject-family →
|
|
@@ -429,12 +429,72 @@ export interface ReviewSummaryRoundModel {
|
|
|
429
429
|
/** Aggregated REVISE seat findings (the auto-revision driver), or null. */
|
|
430
430
|
readonly reviseNotes: string | null;
|
|
431
431
|
}
|
|
432
|
+
export interface ReviewSummaryTerminalModel {
|
|
433
|
+
readonly schemaVersion: number;
|
|
434
|
+
readonly requirements: {
|
|
435
|
+
readonly problem: string;
|
|
436
|
+
readonly expectedOutputs: ReadonlyArray<string>;
|
|
437
|
+
};
|
|
438
|
+
readonly implementors: ReadonlyArray<{
|
|
439
|
+
readonly agent: string;
|
|
440
|
+
readonly trackIndex: number | null;
|
|
441
|
+
readonly taskId: string;
|
|
442
|
+
}>;
|
|
443
|
+
readonly reviewQuorum: {
|
|
444
|
+
readonly seats: ReadonlyArray<{
|
|
445
|
+
readonly seatId: number;
|
|
446
|
+
readonly role: string;
|
|
447
|
+
readonly agent: string;
|
|
448
|
+
}>;
|
|
449
|
+
readonly roundCount: number;
|
|
450
|
+
readonly revisionCount: number;
|
|
451
|
+
};
|
|
452
|
+
readonly mergeGate: {
|
|
453
|
+
readonly applicable: boolean;
|
|
454
|
+
readonly outcome: string;
|
|
455
|
+
readonly resolution: string | null;
|
|
456
|
+
};
|
|
457
|
+
readonly durations: {
|
|
458
|
+
readonly taskElapsedMs: number | null;
|
|
459
|
+
readonly reviewerElapsedMs: number | null;
|
|
460
|
+
readonly availability: string;
|
|
461
|
+
};
|
|
462
|
+
readonly tokenUsage: {
|
|
463
|
+
readonly knownTotal: number | null;
|
|
464
|
+
readonly knownInput: number | null;
|
|
465
|
+
readonly knownOutput: number | null;
|
|
466
|
+
readonly knownCachedInput: number | null;
|
|
467
|
+
readonly availability: string;
|
|
468
|
+
readonly unavailableRoles: ReadonlyArray<string>;
|
|
469
|
+
readonly invocations: ReadonlyArray<ReviewSummaryTokenInvocationModel>;
|
|
470
|
+
};
|
|
471
|
+
readonly residualRisks: ReadonlyArray<string>;
|
|
472
|
+
}
|
|
473
|
+
export interface ReviewSummaryTokenInvocationModel {
|
|
474
|
+
readonly role: string;
|
|
475
|
+
readonly agent: string;
|
|
476
|
+
readonly taskId: string | null;
|
|
477
|
+
readonly trackIndex: number | null;
|
|
478
|
+
readonly round: number | null;
|
|
479
|
+
readonly gateId: string | null;
|
|
480
|
+
readonly seatId: number | null;
|
|
481
|
+
readonly reviewerRole: string | null;
|
|
482
|
+
readonly inputTokens: number | null;
|
|
483
|
+
readonly outputTokens: number | null;
|
|
484
|
+
readonly cachedInputTokens: number | null;
|
|
485
|
+
readonly totalTokens: number | null;
|
|
486
|
+
readonly elapsedMs: number | null;
|
|
487
|
+
readonly availability: string;
|
|
488
|
+
readonly unavailableReason: string | null;
|
|
489
|
+
}
|
|
432
490
|
/**
|
|
433
491
|
* The fully-extracted, render-ready per-round review summary model. PURE
|
|
434
492
|
* function of the decrypted summary. `null`-attached (entry has no
|
|
435
493
|
* `reviewSummary`) → the panel renders nothing extra (fail-open base prompt).
|
|
436
494
|
*/
|
|
437
495
|
export interface ReviewSummaryPanelModel {
|
|
496
|
+
/** Additive P15 schema-v2 terminal header; null for legacy schema v1. */
|
|
497
|
+
readonly terminal: ReviewSummaryTerminalModel | null;
|
|
438
498
|
readonly rounds: ReadonlyArray<ReviewSummaryRoundModel>;
|
|
439
499
|
/** finalOutcome display value (proceed | auto_revise | escalate). */
|
|
440
500
|
readonly finalOutcome: string;
|
|
@@ -448,6 +508,61 @@ export interface ReviewSummaryPanelModel {
|
|
|
448
508
|
* object degrades to an empty/safe model, never throws.
|
|
449
509
|
*/
|
|
450
510
|
export interface DecryptedReviewSummaryInput {
|
|
511
|
+
readonly schemaVersion?: number;
|
|
512
|
+
readonly requirements?: {
|
|
513
|
+
readonly problem?: string;
|
|
514
|
+
readonly expectedOutputs?: ReadonlyArray<string>;
|
|
515
|
+
};
|
|
516
|
+
readonly implementors?: ReadonlyArray<{
|
|
517
|
+
readonly agent?: string;
|
|
518
|
+
readonly trackIndex?: number;
|
|
519
|
+
readonly taskId?: string;
|
|
520
|
+
}>;
|
|
521
|
+
readonly reviewQuorum?: {
|
|
522
|
+
readonly seats?: ReadonlyArray<{
|
|
523
|
+
readonly seatId?: number;
|
|
524
|
+
readonly role?: string;
|
|
525
|
+
readonly agent?: string;
|
|
526
|
+
}>;
|
|
527
|
+
readonly roundCount?: number;
|
|
528
|
+
readonly revisionCount?: number;
|
|
529
|
+
};
|
|
530
|
+
readonly mergeGate?: {
|
|
531
|
+
readonly applicable?: boolean;
|
|
532
|
+
readonly outcome?: string;
|
|
533
|
+
readonly resolution?: string;
|
|
534
|
+
};
|
|
535
|
+
readonly durations?: {
|
|
536
|
+
readonly taskElapsedMs?: number;
|
|
537
|
+
readonly reviewerElapsedMs?: number;
|
|
538
|
+
readonly availability?: string;
|
|
539
|
+
};
|
|
540
|
+
readonly tokenUsage?: {
|
|
541
|
+
readonly knownTotal?: number;
|
|
542
|
+
readonly knownInput?: number;
|
|
543
|
+
readonly knownOutput?: number;
|
|
544
|
+
readonly knownCachedInput?: number;
|
|
545
|
+
readonly availability?: string;
|
|
546
|
+
readonly unavailableRoles?: ReadonlyArray<string>;
|
|
547
|
+
readonly invocations?: ReadonlyArray<{
|
|
548
|
+
readonly role?: string;
|
|
549
|
+
readonly agent?: string;
|
|
550
|
+
readonly taskId?: string;
|
|
551
|
+
readonly trackIndex?: number;
|
|
552
|
+
readonly round?: number;
|
|
553
|
+
readonly gateId?: string;
|
|
554
|
+
readonly seatId?: number;
|
|
555
|
+
readonly reviewerRole?: string;
|
|
556
|
+
readonly inputTokens?: number;
|
|
557
|
+
readonly outputTokens?: number;
|
|
558
|
+
readonly cachedInputTokens?: number;
|
|
559
|
+
readonly totalTokens?: number;
|
|
560
|
+
readonly elapsedMs?: number;
|
|
561
|
+
readonly availability?: string;
|
|
562
|
+
readonly unavailableReason?: string;
|
|
563
|
+
}>;
|
|
564
|
+
};
|
|
565
|
+
readonly residualRisks?: ReadonlyArray<string>;
|
|
451
566
|
readonly rounds?: ReadonlyArray<{
|
|
452
567
|
readonly round?: number;
|
|
453
568
|
readonly proposal?: string;
|
|
@@ -458,6 +573,7 @@ export interface DecryptedReviewSummaryInput {
|
|
|
458
573
|
readonly decision?: string;
|
|
459
574
|
readonly reasoning?: string;
|
|
460
575
|
readonly suggestedChanges?: ReadonlyArray<string>;
|
|
576
|
+
readonly residualObservations?: ReadonlyArray<string>;
|
|
461
577
|
}>;
|
|
462
578
|
readonly outcome?: string;
|
|
463
579
|
readonly reviseNotes?: string;
|
|
@@ -2,14 +2,16 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
2
2
|
import { AppSyncClient } from '../appsync';
|
|
3
3
|
import { Session } from '../types';
|
|
4
4
|
import { OrchestrationStore } from './store';
|
|
5
|
+
import { AdvisoryAttachmentJournal } from './advisory-attachment-journal';
|
|
5
6
|
import type { ImageAttachment } from './types';
|
|
6
|
-
import { type GroupDecisionSubmitDeps } from './gate-decision-submit';
|
|
7
|
+
import { type GateDecisionSubmitDeps, type GroupDecisionSubmitDeps } from './gate-decision-submit';
|
|
7
8
|
import { type ContinuationCliResult, type ContinuationCliDeps } from './slash-routes/continuation';
|
|
8
9
|
import { loadReviewerWizardData } from './slash-routes/reviewers';
|
|
9
10
|
import { createShellEventEmitter } from './emit-shell-event';
|
|
10
11
|
import { type AgentMentionIntent, type CommandIntentTarget } from './command-intent';
|
|
11
12
|
import { type BrainstormPanelActiveAgent } from './brainstorm-quorum';
|
|
12
13
|
import { type RunAuditBrowserResult } from './audit-runner';
|
|
14
|
+
import { type RunFlagCommandResult } from './flag-command';
|
|
13
15
|
import { Tier } from './types';
|
|
14
16
|
import type { ConversationEntry, PendingClarification } from './types';
|
|
15
17
|
import { type GatePromptEnvelope, type DecryptedReviewSummaryInput } from './gate-prompts';
|
|
@@ -22,6 +24,7 @@ import type { LocalGemmaAdvisoryRunner } from '../planner/local-advisory';
|
|
|
22
24
|
import type { LocalExecutor } from '../local-executor';
|
|
23
25
|
import type { WorkItemInput, DisjointnessRejection, RevertManifestStore } from '../local-executor';
|
|
24
26
|
import type { QuorumLoop } from './quorum-loop';
|
|
27
|
+
import { type InvocationUsageSnapshot } from '../reviewer/token-usage';
|
|
25
28
|
import { ensureFreshContextStore } from './context-store';
|
|
26
29
|
import type { EnsureFreshResult } from './context-store';
|
|
27
30
|
import { contextItemOccurrence, type ContextDurabilityReceipt } from './context-items';
|
|
@@ -43,6 +46,8 @@ export interface RunOrchestrationShellArgs {
|
|
|
43
46
|
* teardown `finally` is armed; until then the admitting CLI owns retirement.
|
|
44
47
|
*/
|
|
45
48
|
acceptSessionLifecycleOwnership?: () => void;
|
|
49
|
+
/** @internal isolated durable advisory-attachment authority for tests. */
|
|
50
|
+
advisoryAttachmentJournal?: AdvisoryAttachmentJournal;
|
|
46
51
|
/**
|
|
47
52
|
* CP-1.b IMPL r2 H-3 — Optional planner adapter. When supplied,
|
|
48
53
|
* `runOrchestrationShell` binds the active session via
|
|
@@ -228,6 +233,7 @@ export { compactSessionContext, maybeFireCompactionSafetyValve, rehydrateSession
|
|
|
228
233
|
export { routeSlashCommand, applySlashOutput, type SlashOutput, type ShellAction, } from './slash-router';
|
|
229
234
|
export { buildAuditBrowserModel, routeAuditEntry, auditKindLabel, auditKindCopy, renderAuditBrowserText, renderAuditEntryText, ENTRY_DETAILS_UNAVAILABLE, NO_AUDIT_ENTRIES, AUDIT_LOG_TOO_LARGE, AUDIT_LOG_TITLE, AUDIT_BROWSER_MAX_HEADLINE, WIRE_PUBLIC_PLAINTEXT_KINDS, type AuditBrowserModel, type AuditEntryModel, type AuditReviewerVerdictModel, type AuditTaskAuthorizedModel, type DecryptContentFn, } from './audit-browser';
|
|
230
235
|
export { runAuditBrowser, renderAuditResultText, AUDIT_BROWSER_UPGRADE_HINT, type RunAuditBrowserResult, type RunAuditBrowserDeps, } from './audit-runner';
|
|
236
|
+
export { buildAuditFlagIndex, runFlagCommand, renderFlagResultText, FLAG_NO_INDEX_LINE, type RunFlagCommandResult, type RunFlagCommandDeps, type FlagAppSyncClient, } from './flag-command';
|
|
231
237
|
export { AuditLogPanel } from './components/AuditLogPanel';
|
|
232
238
|
export { reducer } from './reducer';
|
|
233
239
|
export { createOrchestrationStore, type OrchestrationStore } from './store';
|
|
@@ -382,7 +388,18 @@ export declare function handleSubscribedEvent(event: Event, store: Orchestration
|
|
|
382
388
|
* and DROPS (never crashes the shell, never submits ciphertext). Async — the sync
|
|
383
389
|
* subscription callback fires-and-forgets via `void`; every throw is caught here.
|
|
384
390
|
*/
|
|
385
|
-
export declare function routeMobileUserPrompt(event: Event, sessionKeyResolver: ((sessionId: string) => Promise<string | null>) | undefined, submit: (text: string, images?: string[], options?: ShellSubmitOptions) => Promise<void>, updateEventStatus?: (input: UpdateEventStatusInput) => Promise<unknown>): Promise<
|
|
391
|
+
export declare function routeMobileUserPrompt(event: Event, sessionKeyResolver: ((sessionId: string) => Promise<string | null>) | undefined, submit: (text: string, images?: string[], options?: ShellSubmitOptions) => Promise<void>, updateEventStatus?: (input: UpdateEventStatusInput) => Promise<unknown>): Promise<boolean>;
|
|
392
|
+
/**
|
|
393
|
+
* Route a mobile composer reply through the desktop's canonical gate state
|
|
394
|
+
* machine. Mobile always transports the text as an encrypted `USER_PROMPT`;
|
|
395
|
+
* only the desktop that owns the live prompt interprets it as a numbered
|
|
396
|
+
* option, a required note, `/cancel`, or ordinary free text.
|
|
397
|
+
*
|
|
398
|
+
* Returns `true` only when the active gate consumed the input. A non-numeric
|
|
399
|
+
* line against an awaiting-number gate remains an ordinary prompt and returns
|
|
400
|
+
* `false`, matching the desktop TTY behavior.
|
|
401
|
+
*/
|
|
402
|
+
export declare function routeMobileGatePromptInput(deps: GateDecisionSubmitDeps, text: string): Promise<boolean>;
|
|
386
403
|
/**
|
|
387
404
|
* Build the single `(event) => void` callback the AppSync events subscription
|
|
388
405
|
* invokes. Routes each delivered event to exactly ONE handler:
|
|
@@ -787,6 +804,14 @@ export interface HandleShellUserInputDeps extends StructuralSummaryRunDeps {
|
|
|
787
804
|
* rewrite without live fetch / decrypt.
|
|
788
805
|
*/
|
|
789
806
|
runAuditBrowserFn?: (taskId: string) => Promise<RunAuditBrowserResult>;
|
|
807
|
+
/**
|
|
808
|
+
* O1 C1 (#652) — Test seam for the async `/flag <entry-id>` dispatch.
|
|
809
|
+
* Defaults to `runFlagCommand` over `args.appsyncClient` + the retained
|
|
810
|
+
* `store` flag index + `args.session.sessionId`. Tests inject a stub to
|
|
811
|
+
* drive the PENDING-marker rewrite (+ the `AUDIT_FLAG_RECORDED` dispatch
|
|
812
|
+
* on the `flagged` arm) without live emit / keychain I/O.
|
|
813
|
+
*/
|
|
814
|
+
runFlagCommandFn?: (entryId: string, note?: string) => Promise<RunFlagCommandResult>;
|
|
790
815
|
/**
|
|
791
816
|
* CP-4 §4.2 — Test seam for the pre-classify context-store refresh. Defaults
|
|
792
817
|
* to the real `ensureFreshContextStore` (probe → recompute-if-stale → persist
|
|
@@ -840,10 +865,12 @@ export interface HandleShellUserInputDeps extends StructuralSummaryRunDeps {
|
|
|
840
865
|
* could overlap and interleave the clarification state machine
|
|
841
866
|
* (USER_INPUT bookkeeping + classify + PLANNER_DECISION), corrupting it.
|
|
842
867
|
*
|
|
843
|
-
* Slash commands (`text.startsWith('/')`, matching
|
|
844
|
-
* routing) bypass the queue: they're fast, never
|
|
845
|
-
* never touch clarification state, and include
|
|
846
|
-
* responsive instead of waiting behind a slow/hung
|
|
868
|
+
* Slash commands (`text.trimStart().startsWith('/')`, matching
|
|
869
|
+
* `handleShellUserInput`'s own routing) bypass the queue: they're fast, never
|
|
870
|
+
* trigger a planner classify, never touch clarification state, and include
|
|
871
|
+
* `/quit` — so they must stay responsive instead of waiting behind a slow/hung
|
|
872
|
+
* planner turn. Leading paste whitespace is presentation noise, not permission
|
|
873
|
+
* to reinterpret an explicit command as natural language.
|
|
847
874
|
*
|
|
848
875
|
* The returned function preserves the caller-visible contract: it returns the
|
|
849
876
|
* promise for THIS submission's processing (so an awaiting caller still gets the
|
|
@@ -933,6 +960,7 @@ export interface BrainstormTurnOwnership {
|
|
|
933
960
|
authorAgent: BrainstormPanelActiveAgent;
|
|
934
961
|
status: 'completed' | 'quota_walled' | 'failed';
|
|
935
962
|
boundedBody: string;
|
|
963
|
+
usage: InvocationUsageSnapshot;
|
|
936
964
|
}>;
|
|
937
965
|
prompt: {
|
|
938
966
|
kind: 'legacy_joined';
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ShellEventEmit, ShellEventEmitResult } from './emit-shell-event';
|
|
2
|
+
/** The run-scoped shell emitter (`createShellEventEmitter(...)`). */
|
|
3
|
+
export type ShellEmitter = (args: ShellEventEmit) => Promise<ShellEventEmitResult>;
|
|
4
|
+
/** The run-scoped `openPrompts` TTL co-refresh transport (§3.1). */
|
|
5
|
+
export type OpenPromptTtlRefresher = (promptIds: string[]) => Promise<string[]>;
|
|
6
|
+
/** Everything the ledger needs to (re-)emit an offer raise. */
|
|
7
|
+
export interface PlannerOfferRaiseContext {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
/** The offer question — the INTERACTIVE_PROMPT content (re-raised verbatim). */
|
|
10
|
+
content: string;
|
|
11
|
+
/** The offer payload — the INTERACTIVE_PROMPT metadata (re-raised verbatim). */
|
|
12
|
+
metadata: Record<string, unknown>;
|
|
13
|
+
agentType?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The core CORE_OFFER producer ledger + durable-ledger refresh loop. A single
|
|
18
|
+
* instance lives per process (one orchestration shell per process); `beginRun`
|
|
19
|
+
* re-binds the transports + resets state for a fresh run.
|
|
20
|
+
*/
|
|
21
|
+
export declare class PlannerOfferE1Ledger {
|
|
22
|
+
/** Open offers, keyed by the offer's stable `conversationEntryId` (§6a-4). */
|
|
23
|
+
private readonly raises;
|
|
24
|
+
/** promptIds whose raise emit is un-acked → retry-until-ack (mirrors the plugins'
|
|
25
|
+
* `e1NeedsReRaise`). */
|
|
26
|
+
private readonly needsReRaise;
|
|
27
|
+
/** promptIds whose resolution emit is un-acked → retry-until-ack (F-C4). */
|
|
28
|
+
private readonly pendingResolutions;
|
|
29
|
+
private timer;
|
|
30
|
+
private emit;
|
|
31
|
+
private refreshTtl;
|
|
32
|
+
private readonly refreshMs;
|
|
33
|
+
private draining;
|
|
34
|
+
constructor(opts?: {
|
|
35
|
+
refreshMs?: number;
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Install the run-scoped TTL-refresh transport and RESET all per-run state. Call
|
|
39
|
+
* once at shell start; a re-run (tests) gets a clean ledger + no stale timer.
|
|
40
|
+
*/
|
|
41
|
+
beginRun(refreshTtl: OpenPromptTtlRefresher): void;
|
|
42
|
+
/**
|
|
43
|
+
* F-C1 — raise (or re-present) a planner offer and INSPECT the emit result. On a
|
|
44
|
+
* transient failure (`{emitted:false}` or a throw) PARK the promptId for
|
|
45
|
+
* retry-until-ack. First presentation mints a fresh secret + committed promptId;
|
|
46
|
+
* a re-present across turns reuses it (stable id → the backend re-raises on the
|
|
47
|
+
* `ownerToken=:token` branch, no duplicate row). Never throws.
|
|
48
|
+
*/
|
|
49
|
+
raiseOffer(emit: ShellEmitter, conversationEntryId: string, ctx: PlannerOfferRaiseContext): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* F-C4 — resolve an offer: emit the SIGNED resolution NOTIFICATION so its
|
|
52
|
+
* `openPrompts` row exact-clears, retried-until-ack. The ledger identity is moved
|
|
53
|
+
* OUT of the open-offer set (stops refresh/re-raise) INTO the pending-resolution
|
|
54
|
+
* set and is NOT dropped until the clear is backend-acknowledged (or is proven
|
|
55
|
+
* un-attestable → over-nag to TTL). A no-op if the offer never raised a row (a
|
|
56
|
+
* pre-E1 in-flight offer). Never throws.
|
|
57
|
+
*/
|
|
58
|
+
resolveOffer(emit: ShellEmitter, conversationEntryId: string, sessionId: string): Promise<void>;
|
|
59
|
+
/** Stop the refresh timer (shell teardown). Idempotent. */
|
|
60
|
+
stopTimer(): void;
|
|
61
|
+
/** Is there a LIVE open-offer ledger entry for this entryId? (content-key floor) */
|
|
62
|
+
hasOpenOffer(conversationEntryId: string): boolean;
|
|
63
|
+
/** The committed promptId for an open offer (undefined once resolved/absent). */
|
|
64
|
+
promptIdFor(conversationEntryId: string): string | undefined;
|
|
65
|
+
isParkedForReRaise(promptId: string): boolean;
|
|
66
|
+
hasPendingResolution(promptId: string): boolean;
|
|
67
|
+
/** Run ONE refresh tick synchronously (the interval calls this; exposed for tests). */
|
|
68
|
+
runTick(): Promise<void>;
|
|
69
|
+
private getOrCreateEntry;
|
|
70
|
+
private buildRaiseEmit;
|
|
71
|
+
/**
|
|
72
|
+
* Emit ONE offer raise + park on failure (F-C1). ACK (`{emitted:true}`) clears any
|
|
73
|
+
* retry flag; `{emitted:false}` or a throw parks the promptId so a later tick
|
|
74
|
+
* re-emits until the backend writes the row.
|
|
75
|
+
*/
|
|
76
|
+
private emitRaise;
|
|
77
|
+
/**
|
|
78
|
+
* Emit ONE resolution + retry-until-ack (F-C4). ACK (`{emitted:true}`) drops the
|
|
79
|
+
* identity (the row exact-cleared, or the conditional Delete no-op'd for an
|
|
80
|
+
* already-gone row — both acknowledged). A transient `{emitted:false}` keeps the
|
|
81
|
+
* identity for the next tick; a terminal/un-attestable reason (or the retry cap)
|
|
82
|
+
* gives up → the row over-nags to its own TTL.
|
|
83
|
+
*/
|
|
84
|
+
private emitResolution;
|
|
85
|
+
/** Retry every parked raise whose ledger entry is still open (F-C1 drain). */
|
|
86
|
+
private drainReRaises;
|
|
87
|
+
/** Retry every un-acked resolution; give up past the attempt cap (F-C4 drain). */
|
|
88
|
+
private drainResolutions;
|
|
89
|
+
/**
|
|
90
|
+
* §3.1 — co-refresh the OPEN offers' `openPrompts` row TTLs; FULL-re-raise any
|
|
91
|
+
* promptId the backend reports as already aged-out (return-driven re-raise, §6a-4).
|
|
92
|
+
*/
|
|
93
|
+
private refreshOpenTtls;
|
|
94
|
+
private findOpenEntryByPromptId;
|
|
95
|
+
private ensureTimer;
|
|
96
|
+
private maybeStopTimer;
|
|
97
|
+
}
|