@quantiya/codevibe-core 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/cp-5-baseline-invariants.test.d.ts +1 -0
- package/dist/adapter/__tests__/capabilities.test.d.ts +1 -0
- package/dist/adapter/__tests__/contract-conformance.test.d.ts +1 -0
- package/dist/adapter/__tests__/packets.test.d.ts +1 -0
- package/dist/adapter/__tests__/progress.test.d.ts +1 -0
- package/dist/adapter/__tests__/registry.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/claude.smoke.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/codex.smoke.test.d.ts +1 -0
- package/dist/adapter/__tests__/smoke/gemini.smoke.test.d.ts +1 -0
- package/dist/adapter/capabilities.d.ts +68 -0
- package/dist/adapter/index.d.ts +7 -0
- package/dist/adapter/packets.d.ts +129 -0
- package/dist/adapter/progress.d.ts +93 -0
- package/dist/adapter/registry.d.ts +24 -0
- package/dist/adapter/types.d.ts +22 -0
- package/dist/appsync/__tests__/appsync-client-apply-user-decision.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client-classb.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client-planner.test.d.ts +1 -0
- package/dist/appsync/__tests__/appsync-client.test.d.ts +1 -0
- package/dist/appsync/appsync-client.d.ts +412 -0
- package/dist/appsync/index.d.ts +1 -1
- package/dist/appsync/queries.d.ts +15 -0
- package/dist/auth/__tests__/auth-telemetry.test.d.ts +1 -0
- package/dist/auth/auth-telemetry.d.ts +98 -5
- package/dist/companion-mode/__tests__/persist-preference.test.d.ts +1 -0
- package/dist/companion-mode/__tests__/resolve-agent.test.d.ts +1 -0
- package/dist/companion-mode/agent-picker.d.ts +9 -0
- package/dist/companion-mode/index.d.ts +55 -0
- package/dist/companion-mode/persist-preference.d.ts +24 -0
- package/dist/companion-mode/resolve-agent.d.ts +41 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +243 -42
- package/dist/keychain/keychain-manager.d.ts +16 -2
- package/dist/local-executor/__tests__/authority-symlink-fixture.d.ts +15 -0
- package/dist/local-executor/__tests__/authority.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-a-emit.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-b-consumer.integration.test.d.ts +1 -0
- package/dist/local-executor/__tests__/class-b-consumer.test.d.ts +1 -0
- package/dist/local-executor/__tests__/hook-bridge.test.d.ts +1 -0
- package/dist/local-executor/__tests__/local-executor.integration.test.d.ts +1 -0
- package/dist/local-executor/__tests__/spawn.test.d.ts +1 -0
- package/dist/local-executor/__tests__/verification-runner.test.d.ts +1 -0
- package/dist/local-executor/authority.d.ts +29 -0
- package/dist/local-executor/class-a-emit.d.ts +138 -0
- package/dist/local-executor/class-b-consumer.d.ts +121 -0
- package/dist/local-executor/hook-bridge.d.ts +36 -0
- package/dist/local-executor/index.d.ts +8 -0
- package/dist/local-executor/local-executor-impl.d.ts +83 -0
- package/dist/local-executor/spawn.d.ts +6 -0
- package/dist/local-executor/types.d.ts +183 -0
- package/dist/local-executor/verification-gates/build.d.ts +6 -0
- package/dist/local-executor/verification-gates/deploy-preflight.d.ts +6 -0
- package/dist/local-executor/verification-gates/diff-sanity.d.ts +6 -0
- package/dist/local-executor/verification-gates/hostile-grep.d.ts +6 -0
- package/dist/local-executor/verification-gates/lint.d.ts +6 -0
- package/dist/local-executor/verification-gates/shell-runner.d.ts +40 -0
- package/dist/local-executor/verification-gates/source-traceability.d.ts +6 -0
- package/dist/local-executor/verification-gates/tests.d.ts +6 -0
- package/dist/local-executor/verification-gates/typecheck.d.ts +6 -0
- package/dist/local-executor/verification-runner.d.ts +28 -0
- package/dist/orchestration/__tests__/setup-bootstrap.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-failure-recourse.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-save.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-seat-picker.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-telemetry.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-test-agents.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-types.test.d.ts +1 -0
- package/dist/orchestration/__tests__/setup-wizard.test.d.ts +1 -0
- package/dist/orchestration/__tests__/v1-options.test.d.ts +1 -0
- package/dist/orchestration/detect-agents.d.ts +2 -1
- package/dist/orchestration/index.d.ts +1 -0
- package/dist/orchestration/orchestration-cli.d.ts +4 -1
- package/dist/orchestration/setup-bootstrap.d.ts +146 -0
- package/dist/orchestration/setup-failure-recourse.d.ts +23 -0
- package/dist/orchestration/setup-save.d.ts +47 -0
- package/dist/orchestration/setup-seat-picker.d.ts +72 -0
- package/dist/orchestration/setup-telemetry.d.ts +54 -0
- package/dist/orchestration/setup-test-agents.d.ts +108 -0
- package/dist/orchestration/setup-types.d.ts +140 -0
- package/dist/orchestration/setup-wizard.d.ts +57 -0
- package/dist/orchestration/v1-options.d.ts +97 -0
- package/dist/orchestration-shell/__tests__/cli-authority-bridge.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-planner-stack.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-singleton-enforcement.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/cli-stub-session-adapter.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/components.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/emit-shell-event.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/gate-prompts.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/hostile-grep.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/mode-selection.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/process-markers.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/reducer.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-classify-dispatch.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-planner-wiring.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell-signal.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/runOrchestrationShell.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/slash-router.test.d.ts +1 -0
- package/dist/orchestration-shell/__tests__/sticky-preference.test.d.ts +1 -0
- package/dist/orchestration-shell/cli.d.ts +96 -0
- package/dist/orchestration-shell/cli.js +8309 -0
- package/dist/orchestration-shell/cohort-flag.d.ts +16 -0
- package/dist/orchestration-shell/components/CodeVibeLogo.d.ts +2 -0
- package/dist/orchestration-shell/components/ConversationPane.d.ts +7 -0
- package/dist/orchestration-shell/components/GatePromptEntry.d.ts +9 -0
- package/dist/orchestration-shell/components/InputBar.d.ts +41 -0
- package/dist/orchestration-shell/components/OrchestrationApp.d.ts +63 -0
- package/dist/orchestration-shell/components/StatusBar.d.ts +7 -0
- package/dist/orchestration-shell/components/nodes/AdvisoryEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/GateStatusNode.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/PlannerDecisionEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/ReviewerQuorumStatusNode.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/SlashOutputEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/SubagentEventEntry.d.ts +8 -0
- package/dist/orchestration-shell/components/nodes/UserMessageEntry.d.ts +8 -0
- package/dist/orchestration-shell/emit-shell-event.d.ts +64 -0
- package/dist/orchestration-shell/gate-prompts.d.ts +123 -0
- package/dist/orchestration-shell/index.d.ts +100 -0
- package/dist/orchestration-shell/ink-runtime.d.ts +64 -0
- package/dist/orchestration-shell/mode-selection.d.ts +46 -0
- package/dist/orchestration-shell/non-tty-fallback.d.ts +46 -0
- package/dist/orchestration-shell/process-markers.d.ts +12 -0
- package/dist/orchestration-shell/reducer.d.ts +8 -0
- package/dist/orchestration-shell/slash-router.d.ts +45 -0
- package/dist/orchestration-shell/sticky-preference.d.ts +24 -0
- package/dist/orchestration-shell/store.d.ts +17 -0
- package/dist/orchestration-shell/types.d.ts +417 -0
- package/dist/planner/__tests__/cache-clarification-bypass.test.d.ts +1 -0
- package/dist/planner/__tests__/cache.test.d.ts +1 -0
- package/dist/planner/__tests__/client.test.d.ts +1 -0
- package/dist/planner/__tests__/health-machine-transitions.test.d.ts +1 -0
- package/dist/planner/__tests__/types-zod.test.d.ts +1 -0
- package/dist/planner/adapter.d.ts +16 -0
- package/dist/planner/cache.d.ts +35 -0
- package/dist/planner/client.d.ts +103 -0
- package/dist/planner/health-state.d.ts +24 -0
- package/dist/planner/index.d.ts +5 -0
- package/dist/planner/types.d.ts +113 -0
- package/dist/session/__tests__/session-resume-service-keys.test.d.ts +1 -0
- package/dist/session/session-rekey.d.ts +40 -0
- package/dist/session/session-resume.d.ts +25 -0
- package/dist/structural-summary/__tests__/__fixtures__/fixture-helpers.d.ts +11 -0
- package/dist/structural-summary/__tests__/assembler.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/generator.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/language-detect.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/cargo.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/gomod.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/gradle.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/index.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/npm.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/podfile.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/manifest-parsers/pyproject.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/opt-in-store.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/privacy-filter.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/safe-file-read.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/user-ignore-matcher.test.d.ts +1 -0
- package/dist/structural-summary/__tests__/walker.test.d.ts +1 -0
- package/dist/structural-summary/generator.d.ts +8 -0
- package/dist/structural-summary/index.d.ts +7 -0
- package/dist/structural-summary/manifest-parsers/cargo.d.ts +3 -0
- package/dist/structural-summary/manifest-parsers/index.d.ts +7 -0
- package/dist/structural-summary/manifest-parsers/npm.d.ts +3 -0
- package/dist/structural-summary/manifest-parsers/other.d.ts +17 -0
- package/dist/structural-summary/opt-in-store.d.ts +24 -0
- package/dist/structural-summary/privacy-filter.d.ts +110 -0
- package/dist/structural-summary/safe-file-read.d.ts +11 -0
- package/dist/structural-summary/types.d.ts +215 -0
- package/dist/structural-summary/user-ignore-matcher.d.ts +9 -0
- package/dist/structural-summary/walker.d.ts +20 -0
- package/dist/types/events.d.ts +17 -2
- package/package.json +17 -3
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
import type { AuthorityRefusal, AuthorityScope } from './authority';
|
|
3
|
+
export type ProcessRole = 'implementor' | 'reviewer' | 'health_probe' | 'auth_probe' | 'model_probe';
|
|
4
|
+
export type AgentKind = 'CLAUDE' | 'GEMINI' | 'CODEX';
|
|
5
|
+
export type FailureClass = null | 'quota_exhausted' | 'auth_failed' | 'timeout' | 'unavailable' | 'user_aborted';
|
|
6
|
+
export interface SpawnArgs {
|
|
7
|
+
argv: string[];
|
|
8
|
+
workingDir: string;
|
|
9
|
+
role: ProcessRole;
|
|
10
|
+
agentKind?: AgentKind;
|
|
11
|
+
timeoutMs: number | null;
|
|
12
|
+
envOverrides?: Record<string, string>;
|
|
13
|
+
stdinTty?: boolean;
|
|
14
|
+
stdinPayload?: string;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
onProcessSpawned?: ProcessSpawnedHook;
|
|
17
|
+
onProcessExited?: ProcessExitedHook;
|
|
18
|
+
}
|
|
19
|
+
export interface ProcessSpawnedInfo {
|
|
20
|
+
pid: number;
|
|
21
|
+
role: ProcessRole;
|
|
22
|
+
agentKind: AgentKind | undefined;
|
|
23
|
+
spawnedAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ProcessExitedInfo {
|
|
26
|
+
pid: number;
|
|
27
|
+
exitCode: number;
|
|
28
|
+
failureClass: FailureClass;
|
|
29
|
+
exitedAt: string;
|
|
30
|
+
runtimeMs: number;
|
|
31
|
+
}
|
|
32
|
+
export type ProcessSpawnedHook = (info: ProcessSpawnedInfo) => void;
|
|
33
|
+
export type ProcessExitedHook = (info: ProcessExitedInfo) => void;
|
|
34
|
+
export interface SpawnHandleBase {
|
|
35
|
+
pid: number;
|
|
36
|
+
role: ProcessRole;
|
|
37
|
+
agentKind: AgentKind | undefined;
|
|
38
|
+
spawnedAt: string;
|
|
39
|
+
/** Resolves when the child exits, regardless of cause. */
|
|
40
|
+
done: Promise<ProcessExitedInfo>;
|
|
41
|
+
/** Forcibly terminate (SIGKILL + cleanup). Idempotent. */
|
|
42
|
+
abort(): Promise<void>;
|
|
43
|
+
/** Captured stdout/stderr — local-only, never crosses the wire. */
|
|
44
|
+
stdout(): string;
|
|
45
|
+
stderr(): string;
|
|
46
|
+
}
|
|
47
|
+
export interface ImplementorHandle extends SpawnHandleBase {
|
|
48
|
+
kind: 'implementor';
|
|
49
|
+
}
|
|
50
|
+
export interface ReviewerHandle extends SpawnHandleBase {
|
|
51
|
+
kind: 'reviewer';
|
|
52
|
+
}
|
|
53
|
+
export interface ProbeHandle extends SpawnHandleBase {
|
|
54
|
+
kind: 'probe';
|
|
55
|
+
}
|
|
56
|
+
export declare class SpawnArgsInvalid extends Error {
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
readonly offendingKey?: string | undefined;
|
|
59
|
+
constructor(reason: string, offendingKey?: string | undefined);
|
|
60
|
+
}
|
|
61
|
+
export declare const MARKER_ENV_KEYS: {
|
|
62
|
+
readonly CHILD: "CODEVIBE_CHILD_PROCESS";
|
|
63
|
+
readonly ROLE: "CODEVIBE_PROCESS_ROLE";
|
|
64
|
+
readonly QUORUM: "QUORUM_REVIEWER_SUBPROCESS";
|
|
65
|
+
};
|
|
66
|
+
export declare const MARKER_KEY_SET: ReadonlySet<string>;
|
|
67
|
+
export type AuthorityAction = {
|
|
68
|
+
kind: 'Write';
|
|
69
|
+
path: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'Read';
|
|
72
|
+
path: string;
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'Network';
|
|
75
|
+
urlOrHost: string;
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'Command';
|
|
78
|
+
command: string;
|
|
79
|
+
argv: string[];
|
|
80
|
+
};
|
|
81
|
+
export interface SignedEnvelope {
|
|
82
|
+
algorithm: 'ed25519' | 'p384-ecdsa';
|
|
83
|
+
publicKeyId: string;
|
|
84
|
+
signatureB64: string;
|
|
85
|
+
issuedAt: string;
|
|
86
|
+
nonceUlid: string;
|
|
87
|
+
}
|
|
88
|
+
export type ClassBInbound = {
|
|
89
|
+
kind: 'PlannerDecisionApproved';
|
|
90
|
+
signedEnvelope: SignedEnvelope;
|
|
91
|
+
payload: unknown;
|
|
92
|
+
} | {
|
|
93
|
+
kind: 'GateDispatch';
|
|
94
|
+
signedEnvelope: SignedEnvelope;
|
|
95
|
+
payload: unknown;
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'ContinuationOffer';
|
|
98
|
+
signedEnvelope: SignedEnvelope;
|
|
99
|
+
payload: unknown;
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'TaskAuthorized';
|
|
102
|
+
signedEnvelope: SignedEnvelope;
|
|
103
|
+
payload: unknown;
|
|
104
|
+
} | {
|
|
105
|
+
kind: 'PolicyRejection';
|
|
106
|
+
signedEnvelope: SignedEnvelope;
|
|
107
|
+
payload: unknown;
|
|
108
|
+
};
|
|
109
|
+
export type ExecutorError = {
|
|
110
|
+
kind: 'AuthorityRefusal';
|
|
111
|
+
refusal: AuthorityRefusal;
|
|
112
|
+
} | {
|
|
113
|
+
kind: 'SpawnFailed';
|
|
114
|
+
detail: string;
|
|
115
|
+
} | {
|
|
116
|
+
kind: 'SubprocessIo';
|
|
117
|
+
detail: string;
|
|
118
|
+
} | {
|
|
119
|
+
kind: 'SignatureVerification';
|
|
120
|
+
detail: string;
|
|
121
|
+
} | {
|
|
122
|
+
kind: 'MalformedClassB';
|
|
123
|
+
detail: string;
|
|
124
|
+
} | {
|
|
125
|
+
kind: 'PolicyMismatch';
|
|
126
|
+
detail: string;
|
|
127
|
+
};
|
|
128
|
+
export type FileChangeKind = 'Created' | 'Modified' | 'Deleted';
|
|
129
|
+
export type HookEvent = {
|
|
130
|
+
kind: 'ToolUse';
|
|
131
|
+
sessionId: string;
|
|
132
|
+
toolName: string;
|
|
133
|
+
toolInput: unknown;
|
|
134
|
+
timestamp: string;
|
|
135
|
+
} | {
|
|
136
|
+
kind: 'FileChange';
|
|
137
|
+
sessionId: string;
|
|
138
|
+
path: string;
|
|
139
|
+
change: FileChangeKind;
|
|
140
|
+
timestamp: string;
|
|
141
|
+
} | {
|
|
142
|
+
kind: 'ProcessExited';
|
|
143
|
+
sessionId: string;
|
|
144
|
+
pid: number;
|
|
145
|
+
exitCode: number;
|
|
146
|
+
timestamp: string;
|
|
147
|
+
failureClass?: FailureClass | undefined;
|
|
148
|
+
failureSignal?: NodeJS.Signals | undefined;
|
|
149
|
+
} | {
|
|
150
|
+
kind: 'UserPrompt';
|
|
151
|
+
sessionId: string;
|
|
152
|
+
contentB64: string;
|
|
153
|
+
timestamp: string;
|
|
154
|
+
} | {
|
|
155
|
+
kind: 'AssistantText';
|
|
156
|
+
sessionId: string;
|
|
157
|
+
contentB64: string;
|
|
158
|
+
timestamp: string;
|
|
159
|
+
};
|
|
160
|
+
export interface LocalExecutor {
|
|
161
|
+
spawnImplementor(args: SpawnArgs): Promise<ImplementorHandle>;
|
|
162
|
+
spawnReviewer(args: SpawnArgs): Promise<ReviewerHandle>;
|
|
163
|
+
spawnHealthProbe(args: SpawnArgs): Promise<ProbeHandle>;
|
|
164
|
+
/**
|
|
165
|
+
* Single-entrypoint authority gate. Dispatches to `enforceWrite` /
|
|
166
|
+
* `enforceRead` / `enforceNetwork` / `enforceCommand` based on `action.kind`.
|
|
167
|
+
* Throws `AuthorityError` on refusal (master §9:1284).
|
|
168
|
+
*/
|
|
169
|
+
enforceAuthority(action: AuthorityAction): Promise<void>;
|
|
170
|
+
ingestHookEvent(event: HookEvent): Promise<void>;
|
|
171
|
+
/** Read-only view of the current TASK_AUTHORIZED.authorityScope. */
|
|
172
|
+
authorityScope(): Readonly<AuthorityScope>;
|
|
173
|
+
/** CP-1.c STUB; CP-1.e wires real AppSync subscription + signature verification. */
|
|
174
|
+
consumeClassB(packet: ClassBInbound): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
export interface SpawnedProcess {
|
|
177
|
+
child: ChildProcess;
|
|
178
|
+
pid: number;
|
|
179
|
+
role: ProcessRole;
|
|
180
|
+
agentKind: AgentKind | undefined;
|
|
181
|
+
spawnedAt: string;
|
|
182
|
+
spawnedAtMs: number;
|
|
183
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
2
|
+
import type { GateRunResult } from '../verification-runner';
|
|
3
|
+
export declare const VERIFICATION_RUNNER_ROLE = "verification_runner";
|
|
4
|
+
export interface ShellRunArgs {
|
|
5
|
+
/** Command to execute (e.g. "cargo", "npm", "git"). */
|
|
6
|
+
command: string;
|
|
7
|
+
/** Arguments to pass to the command. */
|
|
8
|
+
args: string[];
|
|
9
|
+
/** Working directory — caller (gate wrapper) MUST pass the repo root. */
|
|
10
|
+
cwd: string;
|
|
11
|
+
/** Per-gate timeout budget in milliseconds. Required (LOCK #C3E-4). */
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
/** Optional extra env overrides on top of the marker injection. */
|
|
14
|
+
extraEnv?: Record<string, string>;
|
|
15
|
+
/** Optional clock seam for tests. Defaults to Date.now. */
|
|
16
|
+
nowMs?: () => number;
|
|
17
|
+
/**
|
|
18
|
+
* Test seam — injects a fake spawner. Production callers leave this
|
|
19
|
+
* undefined and the real `child_process.spawn` is used. The seam returns
|
|
20
|
+
* a minimal interface (write events, exit event) so test fixtures
|
|
21
|
+
* don't have to model the full Node ChildProcess surface.
|
|
22
|
+
*/
|
|
23
|
+
spawnFn?: typeof nodeSpawn;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run a single command-line under the verification-runner marker. Returns
|
|
27
|
+
* a `GateRunResult` matching what verification-runner.ts consumes.
|
|
28
|
+
*
|
|
29
|
+
* Captures FULL stdout/stderr (the runner truncates per LOCK #C3E-1) and
|
|
30
|
+
* fires the timeout race per LOCK #C3E-4. On timeout, the subprocess is
|
|
31
|
+
* killed (SIGKILL) and `timedOut: true` is set so the runner can apply
|
|
32
|
+
* the wire-form `exit_code = 124` regardless of what the platform
|
|
33
|
+
* returned for the killed process.
|
|
34
|
+
*
|
|
35
|
+
* NOTE: this primitive does NOT participate in authority enforcement.
|
|
36
|
+
* The orchestration shell establishes the authority scope BEFORE the
|
|
37
|
+
* verification runner is invoked, and the gates themselves operate on
|
|
38
|
+
* the user's own working tree which is implicitly readable.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runShellCommand(args: ShellRunArgs): Promise<GateRunResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ClassAEmitter, ClassAEmitterContext, VerificationGateKind, VerificationResultPayload } from './class-a-emit';
|
|
2
|
+
export declare const DEFAULT_GATE_TIMEOUT_MS = 300000;
|
|
3
|
+
export declare const TIMEOUT_EXIT_CODE = 124;
|
|
4
|
+
export declare const SUMMARY_CAP_BYTES = 4096;
|
|
5
|
+
export interface VerificationGateRequest {
|
|
6
|
+
gateId: string;
|
|
7
|
+
taskId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
gateKinds: VerificationGateKind[];
|
|
10
|
+
cwd: string;
|
|
11
|
+
timeoutMsOverride?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GateRunResult {
|
|
14
|
+
exitCode: number;
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
durationMs: number;
|
|
18
|
+
timedOut?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface VerificationRunnerDeps {
|
|
21
|
+
emitter: ClassAEmitter;
|
|
22
|
+
classAContext: ClassAEmitterContext;
|
|
23
|
+
nowMs?: () => number;
|
|
24
|
+
onResultEmitted?: (result: VerificationResultPayload) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function runVerificationGates(req: VerificationGateRequest, deps: VerificationRunnerDeps): Promise<VerificationResultPayload[]>;
|
|
27
|
+
export declare function truncateUtf8Safe(input: string, maxBytes: number): string;
|
|
28
|
+
export declare const NO_OP_PASS: GateRunResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../logger';
|
|
2
2
|
import { AppSyncClient } from '../appsync';
|
|
3
|
+
import { CapabilityRegistry } from '../adapter/capabilities';
|
|
3
4
|
export type DetectableAgent = 'CLAUDE' | 'GEMINI' | 'CODEX';
|
|
4
5
|
/**
|
|
5
6
|
* Returns the subset of agents present on PATH. Uses `command -v`
|
|
@@ -26,7 +27,7 @@ export declare function detectInstalledAgents(): DetectableAgent[];
|
|
|
26
27
|
* @param log Logger — warn-level when no agents detected, info
|
|
27
28
|
* on success
|
|
28
29
|
*/
|
|
29
|
-
export declare function pushDetectedAgents(client: AppSyncClient, log: Pick<Logger, 'info' | 'warn'
|
|
30
|
+
export declare function pushDetectedAgents(client: AppSyncClient, log: Pick<Logger, 'info' | 'warn'>, capabilityRegistry?: CapabilityRegistry, detectFn?: () => DetectableAgent[]): Promise<void>;
|
|
30
31
|
/**
|
|
31
32
|
* Quorum 2.0 (2f.0.a.6) per-session orchestration CLI override applier.
|
|
32
33
|
* All three plugin wrappers (`codevibe-claude`, `codevibe-gemini`,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { detectInstalledAgents, pushDetectedAgents, applyPerSessionOrchestrationOverride, type DetectableAgent, } from './detect-agents';
|
|
2
2
|
export { runOrchestrationCli } from './orchestration-cli';
|
|
3
|
+
export { V1_ORCHESTRATION_PROMPT_KIND, V1_ORCHESTRATION_OPTIONS, mapOptionNumberToUserDecisionKind, mapOptionToUserDecisionKind, type V1OrchestrationOption, type V1UserDecisionKind, } from './v1-options';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dispatch for the `orchestration` subcommand. Called by runAuthCli
|
|
3
|
-
* when it sees `argv[2] === 'orchestration'`. Supports
|
|
3
|
+
* when it sees `argv[2] === 'orchestration'`. Supports five sub-actions:
|
|
4
4
|
* enable — set orchestrationEnabledDefault = true
|
|
5
5
|
* disable — set orchestrationEnabledDefault = false
|
|
6
6
|
* status — print current policy snapshot + installed agents
|
|
7
7
|
* configure — interactive wizard (toggle + panel customization)
|
|
8
|
+
* setup — Phase 3.a (#190) 3-step locked setup wizard with Test
|
|
9
|
+
* My Agents (locked role taxonomy: architecture /
|
|
10
|
+
* correctness / security)
|
|
8
11
|
*/
|
|
9
12
|
export declare function runOrchestrationCli(argv: string[]): Promise<void>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { AppSyncClient } from '../appsync/appsync-client.js';
|
|
2
|
+
import { DetectableAgent } from './detect-agents.js';
|
|
3
|
+
import { CountBucket, WizardEntry, WizardTier } from './setup-types.js';
|
|
4
|
+
import type { AgentKind } from '../reviewer/types.js';
|
|
5
|
+
import type { UserReviewerPolicySnapshot } from '../types/reviewer.js';
|
|
6
|
+
/**
|
|
7
|
+
* Thrown by `defaultClientFactory` when `authenticateWithStoredTokens`
|
|
8
|
+
* returns false AND the most recent failure kind is `'refresh_network'`
|
|
9
|
+
* (transient 5xx / DNS / socket-reset during the Cognito refresh-token
|
|
10
|
+
* POST). The wizard's `runBootstrap` catch routes this to
|
|
11
|
+
* `subscription_status_network` — same recourse as
|
|
12
|
+
* `getSubscriptionStatus` blowing up, but distinct from a genuine
|
|
13
|
+
* `not_signed_in` (which we still surface as `not_signed_in` so the
|
|
14
|
+
* user is told to re-authenticate).
|
|
15
|
+
*
|
|
16
|
+
* Stage 2 round-1 Codex M1. The error message is intentionally
|
|
17
|
+
* network-shaped so the existing `isNetworkLikeError(message)` regex
|
|
18
|
+
* also matches — defense in depth in case a future caller throws this
|
|
19
|
+
* outside the bootstrap path.
|
|
20
|
+
*/
|
|
21
|
+
export declare class AuthRefreshNetworkError extends Error {
|
|
22
|
+
constructor(cause: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Successful bootstrap output. The wizard's state machine consumes
|
|
26
|
+
* this to seed Step 1 (seat assignment).
|
|
27
|
+
*
|
|
28
|
+
* R1/R2 round-1 finding M1+L3+M6 (resolved 2026-05-08): the
|
|
29
|
+
* authenticated `client` and the user's `email` are exposed here so
|
|
30
|
+
* the wizard can render `✓ Signed in as <email>` per design §1
|
|
31
|
+
* lines 47-50 and avoid double-authenticating before save.
|
|
32
|
+
*/
|
|
33
|
+
export interface BootstrapResult {
|
|
34
|
+
tier: WizardTier;
|
|
35
|
+
/** Pro=2, Max=3. Free can't reach success (tier-gated above). */
|
|
36
|
+
seatBudget: number;
|
|
37
|
+
/** Lower-cased agent kinds detected on PATH, in canonical order. */
|
|
38
|
+
installedAgents: AgentKind[];
|
|
39
|
+
/** Pre-bucketed for telemetry; saved here so Step 1's emit doesn't recompute. */
|
|
40
|
+
installedAgentsBucket: CountBucket;
|
|
41
|
+
/**
|
|
42
|
+
* The authenticated AppSyncClient. Wizard reuses this for the save
|
|
43
|
+
* step rather than re-running `authenticateWithStoredTokens()` —
|
|
44
|
+
* eliminates the auth-evicted-between-bootstrap-and-save telemetry
|
|
45
|
+
* gap (R1 round-1 M1) and the wasteful double-auth (R1 round-1 L3).
|
|
46
|
+
*/
|
|
47
|
+
client: AppSyncClient;
|
|
48
|
+
/**
|
|
49
|
+
* Email of the signed-in user (Cognito `email` claim), or null if
|
|
50
|
+
* the claim is not present. Used by the wizard's bootstrap-summary
|
|
51
|
+
* UI per design §1 lines 47-50.
|
|
52
|
+
*/
|
|
53
|
+
userEmail: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Stage 2 round-1 Codex M2: the user's saved reviewer policy at
|
|
56
|
+
* bootstrap time, so the wizard can pre-populate seat-picker
|
|
57
|
+
* defaults on a re-run instead of always falling back to the
|
|
58
|
+
* tier-default agent / role priority. `null` when the snapshot
|
|
59
|
+
* fetch failed (the wizard then proceeds without saved-defaults —
|
|
60
|
+
* the canonical priority order is the fallback).
|
|
61
|
+
*
|
|
62
|
+
* Fetched via the existing `updateAvailableAgents` mutation, which
|
|
63
|
+
* is idempotent + already called by every plugin startup
|
|
64
|
+
* (`appsync-client.ts:721-724`). The wizard repeating it is safe
|
|
65
|
+
* and avoids introducing a new wire contract just to read three
|
|
66
|
+
* fields back.
|
|
67
|
+
*/
|
|
68
|
+
savedPolicy: UserReviewerPolicySnapshot | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Failure shape — discriminated by `kind`. The wizard surfaces a
|
|
72
|
+
* user-facing message and exits with code 1; telemetry is fired by
|
|
73
|
+
* `runBootstrap()` before the result is returned (so callers don't
|
|
74
|
+
* re-fire on their failure path).
|
|
75
|
+
*/
|
|
76
|
+
export type BootstrapFailure = {
|
|
77
|
+
kind: 'tier_gate_free';
|
|
78
|
+
tier: 'FREE';
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'not_signed_in';
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'subscription_status_network';
|
|
83
|
+
cause: string;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'no_clis_installed';
|
|
86
|
+
};
|
|
87
|
+
export type BootstrapOutput = {
|
|
88
|
+
ok: true;
|
|
89
|
+
result: BootstrapResult;
|
|
90
|
+
} | {
|
|
91
|
+
ok: false;
|
|
92
|
+
failure: BootstrapFailure;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Inputs for `runBootstrap`. Threads the wizard run id through so
|
|
96
|
+
* telemetry events stitch by `wizard_run_id`.
|
|
97
|
+
*
|
|
98
|
+
* `clientFactory` is injected so tests can swap in a mock AppSync
|
|
99
|
+
* client; production passes `defaultClientFactory`.
|
|
100
|
+
*
|
|
101
|
+
* `agentDetector` defaults to `detectInstalledAgents` (the production
|
|
102
|
+
* PATH walk) but is swappable for unit tests.
|
|
103
|
+
*
|
|
104
|
+
* `entry` is threaded in so `runBootstrap` can fire `wizard_started`
|
|
105
|
+
* itself — Stage 2 round-1 Codex M3 moved the emit from the wizard
|
|
106
|
+
* (where it skipped Free / no_clis users) into bootstrap (where it
|
|
107
|
+
* fires post-tier-and-agents-known, before any gate).
|
|
108
|
+
*/
|
|
109
|
+
export interface BootstrapDeps {
|
|
110
|
+
wizardRunId: string;
|
|
111
|
+
clientFactory: () => Promise<AppSyncClient | null>;
|
|
112
|
+
agentDetector: () => DetectableAgent[];
|
|
113
|
+
entry: WizardEntry;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Production client factory. Builds an AppSyncClient and authenticates
|
|
117
|
+
* with stored tokens. Returns null on `'no_tokens'` /
|
|
118
|
+
* `'refresh_auth_rejected'` (the wizard maps both to `not_signed_in`);
|
|
119
|
+
* THROWS `AuthRefreshNetworkError` on `'refresh_network'` so the
|
|
120
|
+
* wizard's `runBootstrap` catch routes the user to
|
|
121
|
+
* `subscription_status_network` instead of mistakenly telling a
|
|
122
|
+
* signed-in user to re-login when their refresh-token POST hit a
|
|
123
|
+
* transient 5xx.
|
|
124
|
+
*
|
|
125
|
+
* Stage 2 round-1 Codex M1: pre-fix, `authenticateWithStoredTokens`
|
|
126
|
+
* returned false on every error path, including network failures
|
|
127
|
+
* inside `callCognitoRefresh`'s catch block; the bootstrap's
|
|
128
|
+
* `isNetworkLikeError` check only ran on caught throws and so never
|
|
129
|
+
* fired in production for refresh-network failures.
|
|
130
|
+
*/
|
|
131
|
+
export declare function defaultClientFactory(): Promise<AppSyncClient | null>;
|
|
132
|
+
/**
|
|
133
|
+
* Run Step 0. Emits `wizard_step_started{step:'bootstrap'}` on entry,
|
|
134
|
+
* then either `wizard_step_completed` on success OR
|
|
135
|
+
* `wizard_step_failed` + `wizard_aborted` on failure. Returns the
|
|
136
|
+
* `BootstrapOutput` in either case so the caller can render UX before
|
|
137
|
+
* exiting.
|
|
138
|
+
*
|
|
139
|
+
* Stage 2 round-1 Codex M3: `wizard_started` is emitted from here,
|
|
140
|
+
* post-tier-and-agents-known, BEFORE the tier-gate / no-CLIs check.
|
|
141
|
+
* Free + no_clis users now fire `wizard_started` (so analytics has
|
|
142
|
+
* the funnel-entry numerator); auth/network bootstrap-aborts skip
|
|
143
|
+
* `wizard_started` (no tier known) and surface as
|
|
144
|
+
* `wizard_aborted{auth_expired | bootstrap_failure}` instead.
|
|
145
|
+
*/
|
|
146
|
+
export declare function runBootstrap(deps: BootstrapDeps): Promise<BootstrapOutput>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PickerIO } from './setup-seat-picker.js';
|
|
2
|
+
export type Step2Choice = 'retry' | 'save_anyway' | 'exit';
|
|
3
|
+
export type Step3Choice = 'retry' | 'exit';
|
|
4
|
+
/**
|
|
5
|
+
* Render the Step 2 recourse menu after a Test My Agents failure.
|
|
6
|
+
* Loops on invalid input. Returns the user's choice. The caller is
|
|
7
|
+
* responsible for emitting `wizard_aborted` if `exit` is chosen.
|
|
8
|
+
*
|
|
9
|
+
* `canSaveAnyway` controls whether the `[s]` option is offered. When
|
|
10
|
+
* false (spawn_failure / timeout), only `[r]` and `[x]` are accepted.
|
|
11
|
+
*/
|
|
12
|
+
export declare function askStep2Recourse(io: PickerIO, canSaveAnyway: boolean): Promise<Step2Choice>;
|
|
13
|
+
/**
|
|
14
|
+
* Render the Step 3 recourse menu after a save failure. The caller's
|
|
15
|
+
* retry loop preserves the in-memory `seats` state so retry is free.
|
|
16
|
+
*
|
|
17
|
+
* `recoverable` honors the §6 outcome table: when false
|
|
18
|
+
* (auth_token_expired), `[r]` is suppressed because retry can only
|
|
19
|
+
* fail again — the user must re-run `codevibe login` and start a new
|
|
20
|
+
* wizard. The recourse menu collapses to a single `[x] exit` choice
|
|
21
|
+
* with a re-auth instruction line. (R1 round-1 M3 / R2 round-1 M4.)
|
|
22
|
+
*/
|
|
23
|
+
export declare function askStep3Recourse(io: PickerIO, recoverable?: boolean): Promise<Step3Choice>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AppSyncClient } from '../appsync/appsync-client.js';
|
|
2
|
+
import { WizardSeatPick, WizardStepFailureReason } from './setup-types.js';
|
|
3
|
+
export type SaveResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
reason: WizardStepFailureReason;
|
|
8
|
+
/**
|
|
9
|
+
* Whether `[r] retry` makes sense for this failure. Network /
|
|
10
|
+
* 5xx / throttle are retryable (transient). auth_token_expired
|
|
11
|
+
* is NOT retryable in-process — the user must re-run `codevibe
|
|
12
|
+
* login` and start a new wizard run.
|
|
13
|
+
*/
|
|
14
|
+
recoverable: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface SaveDeps {
|
|
17
|
+
wizardRunId: string;
|
|
18
|
+
client: AppSyncClient;
|
|
19
|
+
seats: WizardSeatPick[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether the user reached this step via "save anyway" after a
|
|
22
|
+
* Test My Agents warning. Drives the wizard_completed.outcome
|
|
23
|
+
* value at the wizard's terminal exit (`'ok' | 'saved_after_test_warning'`).
|
|
24
|
+
* Not used here — Step 3 just persists; the top-level wizard
|
|
25
|
+
* threads the outcome value into the final `wizard_completed` event.
|
|
26
|
+
*/
|
|
27
|
+
savedAfterTestWarning: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run Step 3. Emits `wizard_step_started{step:'save'}` on entry,
|
|
31
|
+
* `wizard_step_completed` on success, or `wizard_step_failed` with
|
|
32
|
+
* the classified reason. Returns a SaveResult the wizard's recourse
|
|
33
|
+
* loop consumes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function runSave(deps: SaveDeps): Promise<SaveResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Classify a thrown error from `updateReviewerPolicy` into one of the
|
|
38
|
+
* §7 save-step reason codes. Best-effort matching against the AppSync
|
|
39
|
+
* client's error message conventions:
|
|
40
|
+
* - 401 / "Unauthorized" / "Token expired" → auth_token_expired
|
|
41
|
+
* - 429 / "Throttling" / "Rate exceeded" → update_policy_throttle
|
|
42
|
+
* - 5xx / "Internal" / "InternalServerError" → update_policy_5xx
|
|
43
|
+
* - everything else (fetch threw, ECONNRESET, DNS) → update_policy_network
|
|
44
|
+
*
|
|
45
|
+
* Exposed for tests to assert classification mapping.
|
|
46
|
+
*/
|
|
47
|
+
export declare function classifySaveError(err: unknown): WizardStepFailureReason;
|