@quantiya/codevibe-core 1.0.23 → 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 +278 -1
- package/dist/appsync/index.d.ts +1 -1
- package/dist/appsync/queries.d.ts +8 -0
- package/dist/audit-keys/__tests__/audit-keys-parity.test.d.ts +1 -0
- package/dist/audit-keys/index.d.ts +41 -0
- package/dist/auth/__tests__/auth-telemetry.test.d.ts +1 -0
- package/dist/auth/auth-telemetry.d.ts +29 -8
- 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 +13 -1
- package/dist/index.js +253 -33
- 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 +57 -0
- package/dist/orchestration/index.d.ts +3 -0
- package/dist/orchestration/orchestration-cli.d.ts +12 -0
- 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/reviewer/__tests__/integration.test.d.ts +1 -0
- package/dist/reviewer/__tests__/mocks.test.d.ts +1 -0
- package/dist/reviewer/__tests__/output-parser.test.d.ts +1 -0
- package/dist/reviewer/__tests__/registry.test.d.ts +1 -0
- package/dist/reviewer/__tests__/subprocess.test.d.ts +1 -0
- package/dist/reviewer/index.d.ts +15 -0
- package/dist/reviewer/mocks.d.ts +80 -0
- package/dist/reviewer/output-parser.d.ts +95 -0
- package/dist/reviewer/provider.d.ts +153 -0
- package/dist/reviewer/providers/__tests__/claude-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/claude.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/codex-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/codex.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/gemini-live-smoke.test.d.ts +1 -0
- package/dist/reviewer/providers/__tests__/gemini.test.d.ts +1 -0
- package/dist/reviewer/providers/claude.d.ts +59 -0
- package/dist/reviewer/providers/codex.d.ts +67 -0
- package/dist/reviewer/providers/common.d.ts +25 -0
- package/dist/reviewer/providers/gemini.d.ts +108 -0
- package/dist/reviewer/registry.d.ts +87 -0
- package/dist/reviewer/subprocess.d.ts +117 -0
- package/dist/reviewer/types.d.ts +101 -0
- package/dist/session/__tests__/session-resume-service-keys.test.d.ts +1 -0
- package/dist/session/session-resume.d.ts +24 -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/dist/types/index.d.ts +1 -0
- package/dist/types/reviewer.d.ts +67 -0
- package/dist/types/session.d.ts +16 -0
- package/package.json +22 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthorityScope } from '../authority';
|
|
2
|
+
export interface SymlinkBypassFixture {
|
|
3
|
+
tmpRoot: string;
|
|
4
|
+
insideScope: string;
|
|
5
|
+
outsideScope: string;
|
|
6
|
+
outsideTarget: string;
|
|
7
|
+
attemptViaSymlink: string;
|
|
8
|
+
scope: AuthorityScope;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateSymlinkBypassFixtureOptions {
|
|
11
|
+
parentMissing?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function createSymlinkBypassFixture(options?: CreateSymlinkBypassFixtureOptions): Promise<SymlinkBypassFixture>;
|
|
14
|
+
export declare function cleanupFixture(fixture: SymlinkBypassFixture): Promise<void>;
|
|
15
|
+
export declare function makeEmptyExpiredScope(): AuthorityScope;
|
|
@@ -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,29 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
export interface AuthorityScope {
|
|
3
|
+
writeScopes: string[];
|
|
4
|
+
readScopes: string[];
|
|
5
|
+
networkAllowed: boolean;
|
|
6
|
+
commandAllowlist: string[];
|
|
7
|
+
expiresAt: string;
|
|
8
|
+
}
|
|
9
|
+
export type AuthorityRefusalCategory = 'authority_scope_conflict' | 'signature_invalid' | 'ulid_replay' | 'policy_rejection';
|
|
10
|
+
export interface AuthorityRefusal {
|
|
11
|
+
category: AuthorityRefusalCategory;
|
|
12
|
+
detail: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class AuthorityError extends Error {
|
|
15
|
+
readonly refusal: AuthorityRefusal;
|
|
16
|
+
constructor(refusal: AuthorityRefusal);
|
|
17
|
+
}
|
|
18
|
+
export declare class FileNotFound extends Error {
|
|
19
|
+
readonly canonicalPath: string;
|
|
20
|
+
constructor(canonicalPath: string, cause?: unknown);
|
|
21
|
+
}
|
|
22
|
+
export declare function enforceWrite(scope: AuthorityScope, p: string): Promise<string>;
|
|
23
|
+
export declare function safeWriteFile(scope: AuthorityScope, p: string, data: Buffer | string, options?: Parameters<typeof fs.writeFile>[2]): Promise<void>;
|
|
24
|
+
export declare function enforceRead(scope: AuthorityScope, p: string): Promise<string>;
|
|
25
|
+
export declare function safeReadFile(scope: AuthorityScope, p: string, options?: {
|
|
26
|
+
encoding?: BufferEncoding;
|
|
27
|
+
}): Promise<string | Buffer>;
|
|
28
|
+
export declare function enforceNetwork(scope: AuthorityScope): void;
|
|
29
|
+
export declare function enforceCommand(scope: AuthorityScope, argv: string[]): void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { AdapterProgressEnvelope } from '../adapter/progress';
|
|
2
|
+
import { AuthorityRefusal, AuthorityRefusalCategory } from './authority';
|
|
3
|
+
import { AgentKind, FailureClass, ProcessRole } from './types';
|
|
4
|
+
export type ExecutionEventKind = 'PROCESS_SPAWNED' | 'TOOL_USE' | 'FILE_CHANGE' | 'VERIFICATION_RUN' | 'PROCESS_EXITED';
|
|
5
|
+
export type ClassAMessageType = 'EXECUTION_EVENT' | 'EXECUTOR_REFUSAL' | 'VERIFICATION_RESULT' | 'ADAPTER_PROGRESS';
|
|
6
|
+
export interface ClassAEnvelope {
|
|
7
|
+
messageVersion: 1;
|
|
8
|
+
messageType: ClassAMessageType;
|
|
9
|
+
messageId: string;
|
|
10
|
+
taskId: string;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
userId: string;
|
|
13
|
+
tenantId: string;
|
|
14
|
+
deviceId: string;
|
|
15
|
+
occurredAt: string;
|
|
16
|
+
payload: unknown;
|
|
17
|
+
signature?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ProcessSpawnedPayload {
|
|
20
|
+
kind: 'PROCESS_SPAWNED';
|
|
21
|
+
processRole: ProcessRole;
|
|
22
|
+
pid: number;
|
|
23
|
+
adapter: AgentKind;
|
|
24
|
+
}
|
|
25
|
+
export interface ToolUsePayload {
|
|
26
|
+
kind: 'TOOL_USE';
|
|
27
|
+
toolName: string;
|
|
28
|
+
bounded: boolean;
|
|
29
|
+
toolInputDigest: string;
|
|
30
|
+
}
|
|
31
|
+
export interface FileChangePayload {
|
|
32
|
+
kind: 'FILE_CHANGE';
|
|
33
|
+
repoPath: string;
|
|
34
|
+
changeSummary: {
|
|
35
|
+
added: number;
|
|
36
|
+
modified: number;
|
|
37
|
+
deleted: number;
|
|
38
|
+
};
|
|
39
|
+
diffDigest: string;
|
|
40
|
+
}
|
|
41
|
+
export interface VerificationRunPayload {
|
|
42
|
+
kind: 'VERIFICATION_RUN';
|
|
43
|
+
check: string;
|
|
44
|
+
passed: boolean;
|
|
45
|
+
runtimeMs: number;
|
|
46
|
+
}
|
|
47
|
+
export interface ProcessExitedPayload {
|
|
48
|
+
kind: 'PROCESS_EXITED';
|
|
49
|
+
pid: number;
|
|
50
|
+
exitCode: number;
|
|
51
|
+
failureClass: FailureClass;
|
|
52
|
+
}
|
|
53
|
+
export interface ExecutorRefusalPayload {
|
|
54
|
+
refusedMessageId: string;
|
|
55
|
+
refusalCategory: AuthorityRefusalCategory;
|
|
56
|
+
refusalDetail: string;
|
|
57
|
+
recommendedRecovery: 'reauthorize_locally' | 'abort_task' | 'ask_user' | 'retry_after_resync';
|
|
58
|
+
}
|
|
59
|
+
export type VerificationGateKind = 'build' | 'tests' | 'lint' | 'typecheck' | 'hostile_grep' | 'source_traceability' | 'diff_sanity' | 'deploy_preflight';
|
|
60
|
+
export interface VerificationResultPayload {
|
|
61
|
+
gate_kind: VerificationGateKind;
|
|
62
|
+
status: 'PASS' | 'FAIL';
|
|
63
|
+
exit_code: number;
|
|
64
|
+
stdout_summary_truncated: string;
|
|
65
|
+
stderr_summary_truncated: string;
|
|
66
|
+
duration_ms: number;
|
|
67
|
+
}
|
|
68
|
+
export interface ClassASink {
|
|
69
|
+
emit(envelope: ClassAEnvelope): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export declare class LocalStubSink implements ClassASink {
|
|
72
|
+
private readonly logPath;
|
|
73
|
+
constructor(logPath: string);
|
|
74
|
+
emit(envelope: ClassAEnvelope): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export interface ClassAEmitterContext {
|
|
77
|
+
taskId: string;
|
|
78
|
+
sessionId: string;
|
|
79
|
+
userId: string;
|
|
80
|
+
tenantId: string;
|
|
81
|
+
deviceId: string;
|
|
82
|
+
}
|
|
83
|
+
export declare const DEFAULT_DEDUPE_CAP = 10000;
|
|
84
|
+
export declare function isValidUlid(s: string): boolean;
|
|
85
|
+
export interface EmitterLogger {
|
|
86
|
+
debug(msg: string, meta?: Record<string, unknown>): void;
|
|
87
|
+
}
|
|
88
|
+
export declare class ClassAEmitter {
|
|
89
|
+
private readonly sink;
|
|
90
|
+
private readonly cap;
|
|
91
|
+
private readonly logger?;
|
|
92
|
+
private readonly seenUlids;
|
|
93
|
+
private readonly messageIdFactory;
|
|
94
|
+
constructor(sink: ClassASink, seenUlids?: Set<string>, cap?: number, logger?: EmitterLogger | undefined, messageIdFactory?: () => string);
|
|
95
|
+
emitProcessSpawned(ctx: ClassAEmitterContext, args: {
|
|
96
|
+
pid: number;
|
|
97
|
+
processRole: ProcessRole;
|
|
98
|
+
adapter: AgentKind;
|
|
99
|
+
occurredAt?: string;
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
emitToolUse(ctx: ClassAEmitterContext, args: {
|
|
102
|
+
toolName: string;
|
|
103
|
+
toolInputDigest: string;
|
|
104
|
+
bounded?: boolean;
|
|
105
|
+
occurredAt?: string;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
emitFileChange(ctx: ClassAEmitterContext, args: {
|
|
108
|
+
repoPath: string;
|
|
109
|
+
changeSummary: FileChangePayload['changeSummary'];
|
|
110
|
+
diffDigest: string;
|
|
111
|
+
occurredAt?: string;
|
|
112
|
+
}): Promise<void>;
|
|
113
|
+
emitVerificationRun(ctx: ClassAEmitterContext, args: {
|
|
114
|
+
check: string;
|
|
115
|
+
passed: boolean;
|
|
116
|
+
runtimeMs: number;
|
|
117
|
+
occurredAt?: string;
|
|
118
|
+
}): Promise<void>;
|
|
119
|
+
emitProcessExited(ctx: ClassAEmitterContext, args: {
|
|
120
|
+
pid: number;
|
|
121
|
+
exitCode: number;
|
|
122
|
+
failureClass: FailureClass;
|
|
123
|
+
occurredAt?: string;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
emitExecutorRefusal(ctx: ClassAEmitterContext, args: {
|
|
126
|
+
refusal: AuthorityRefusal;
|
|
127
|
+
refusedMessageId: string;
|
|
128
|
+
recommendedRecovery?: ExecutorRefusalPayload['recommendedRecovery'];
|
|
129
|
+
occurredAt?: string;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
submitVerificationResultClassAEvent(ctx: ClassAEmitterContext, payload: VerificationResultPayload, occurredAt?: string): Promise<void>;
|
|
132
|
+
submitAdapterProgressClassAEvent(ctx: ClassAEmitterContext, envelope: AdapterProgressEnvelope, occurredAt?: string): Promise<void>;
|
|
133
|
+
private emitExecutionEvent;
|
|
134
|
+
private buildEnvelope;
|
|
135
|
+
private dispatchWithDedupe;
|
|
136
|
+
/** @internal */
|
|
137
|
+
get seenUlidsForTests(): ReadonlySet<string>;
|
|
138
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { AuthorityScope } from './authority';
|
|
2
|
+
import { ClassAEmitter, ClassAEmitterContext } from './class-a-emit';
|
|
3
|
+
import { EmitShellEventFn } from './hook-bridge';
|
|
4
|
+
import { ClassBInbound } from './types';
|
|
5
|
+
export type ClassBVerificationResult = {
|
|
6
|
+
ok: true;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
reason: 'malformed_envelope' | 'algorithm_unsupported';
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* CP-1.e signature-verification STUB per design §4.1.
|
|
13
|
+
*
|
|
14
|
+
* Returns `{ ok: false }` on:
|
|
15
|
+
* - missing/empty `signedEnvelope` or `signatureB64`
|
|
16
|
+
* - unsupported `algorithm` (only `ed25519` / `p384-ecdsa` per CP-0 §2.3 enum)
|
|
17
|
+
* - missing/empty `publicKeyId`
|
|
18
|
+
* - missing/malformed `nonceUlid` (must be 26-char ULID)
|
|
19
|
+
*
|
|
20
|
+
* Returns `{ ok: true }` for every structurally-well-formed envelope. CP-2
|
|
21
|
+
* Stage A replaces the implementation with real signature verification but
|
|
22
|
+
* preserves this exact return-type contract (LOCK #E1-1 stability).
|
|
23
|
+
*/
|
|
24
|
+
export declare function verifyClassBSignature(envelope: ClassBInbound): ClassBVerificationResult;
|
|
25
|
+
export declare const INBOUND_REPLAY_CAP = 10000;
|
|
26
|
+
export declare const INBOUND_REPLAY_TTL_MS: number;
|
|
27
|
+
/**
|
|
28
|
+
* INBOUND ULID-replay registry per design §5.1 + CP-0 §2.5 invariant #5.
|
|
29
|
+
*
|
|
30
|
+
* SCOPE DISAMBIGUATION (LOCK inherited from CP-1.c §6.2):
|
|
31
|
+
* - OUTBOUND emitter dedupe = `ClassAEmitter.seenUlids` (CP-1.c scope).
|
|
32
|
+
* - INBOUND consumer replay refusal = this class (CP-1.e scope).
|
|
33
|
+
*
|
|
34
|
+
* Bounded memory: 10K LRU entries × 24h TTL. Sweep is O(n) worst case but
|
|
35
|
+
* amortizes O(1) per insert because JS Map iterates in insertion order — a
|
|
36
|
+
* single non-expired entry means all subsequent ones are non-expired.
|
|
37
|
+
*/
|
|
38
|
+
export declare class UlidReplayRegistry {
|
|
39
|
+
private readonly cap;
|
|
40
|
+
private readonly ttlMs;
|
|
41
|
+
private readonly nowMs;
|
|
42
|
+
private readonly seenAt;
|
|
43
|
+
constructor(cap?: number, ttlMs?: number, nowMs?: () => number);
|
|
44
|
+
/**
|
|
45
|
+
* Returns `true` if the ULID is a replay (already seen within the active
|
|
46
|
+
* window). On `false`, the ULID is inserted and the registry is swept for
|
|
47
|
+
* expired entries + cap overflow.
|
|
48
|
+
*/
|
|
49
|
+
checkAndInsert(ulid: string): boolean;
|
|
50
|
+
private sweepExpired;
|
|
51
|
+
/** Test-only — exposes seen-set size. */
|
|
52
|
+
get sizeForTests(): number;
|
|
53
|
+
}
|
|
54
|
+
export interface ClassBConsumerState {
|
|
55
|
+
/** Last received PlannerDecisionApproved per taskId; CP-2 reads. */
|
|
56
|
+
plannerDecisionByTask: Map<string, Extract<ClassBInbound, {
|
|
57
|
+
kind: 'PlannerDecisionApproved';
|
|
58
|
+
}>>;
|
|
59
|
+
/** Last received GateDispatch per gateRunId; CP-2 reads. */
|
|
60
|
+
gateDispatchByRun: Map<string, Extract<ClassBInbound, {
|
|
61
|
+
kind: 'GateDispatch';
|
|
62
|
+
}>>;
|
|
63
|
+
/** Last received ContinuationOffer per handoffId; CP-2 reads. */
|
|
64
|
+
continuationOfferByHandoff: Map<string, Extract<ClassBInbound, {
|
|
65
|
+
kind: 'ContinuationOffer';
|
|
66
|
+
}>>;
|
|
67
|
+
}
|
|
68
|
+
export interface ClassBConsumerDeps {
|
|
69
|
+
emitter: ClassAEmitter;
|
|
70
|
+
emitShellEvent: EmitShellEventFn;
|
|
71
|
+
getContext: () => ClassAEmitterContext;
|
|
72
|
+
/** Called on TaskAuthorized to mutate the LocalExecutorImpl's authority scope (CP-0 §2.5 invariant #6). */
|
|
73
|
+
advanceAuthorityScope: (newScope: AuthorityScope, taskId: string) => void;
|
|
74
|
+
/** Called on PolicyRejection to surface the rejection to the user (LOCK C4-3 user-visible channel). */
|
|
75
|
+
notifyPolicyRejection?: (detail: string, category: string, recommendedRecovery: string) => void;
|
|
76
|
+
/** Test seam for deterministic UlidReplayRegistry behavior. */
|
|
77
|
+
replayRegistry?: UlidReplayRegistry;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Class B inbound consumer per design §6.1.
|
|
81
|
+
*
|
|
82
|
+
* Single-entrypoint `consume(packet)` enforces LOCK #E3-1 ordering:
|
|
83
|
+
* 1. verify (LOCK #E1-1 — refuses signature_invalid via Class A audit)
|
|
84
|
+
* 2. replay-check (LOCK #E2-1 — refuses ulid_replay via Class A audit)
|
|
85
|
+
* 3. per-kind dispatch (5 locked variants per CP-0 §2.F.9-§2.F.13)
|
|
86
|
+
*
|
|
87
|
+
* Reverse ordering would let a tampered-but-replayed envelope advance state —
|
|
88
|
+
* explicitly forbidden by LOCK #E3-1.
|
|
89
|
+
*/
|
|
90
|
+
export declare class ClassBConsumer {
|
|
91
|
+
private readonly deps;
|
|
92
|
+
private readonly state;
|
|
93
|
+
private readonly replayRegistry;
|
|
94
|
+
constructor(deps: ClassBConsumerDeps);
|
|
95
|
+
consume(packet: ClassBInbound): Promise<void>;
|
|
96
|
+
private handlePlannerDecisionApproved;
|
|
97
|
+
private handleGateDispatch;
|
|
98
|
+
private handleContinuationOffer;
|
|
99
|
+
private handleTaskAuthorized;
|
|
100
|
+
private handlePolicyRejection;
|
|
101
|
+
/**
|
|
102
|
+
* Constructs an AuthorityRefusal with one of the LOCK #E4-1 widened category
|
|
103
|
+
* literals and emits an EXECUTOR_REFUSAL via the CP-1.c emitter. Audit-only:
|
|
104
|
+
* the user-visible NOTIFICATION channel is reserved for PolicyRejection (the
|
|
105
|
+
* only Class B variant that surfaces hosted policy decisions to the user).
|
|
106
|
+
*
|
|
107
|
+
* `recommendedRecovery` is derived per-category to match CP-0 §2.F.14 fixture
|
|
108
|
+
* row literals verbatim on the wire (was Codex Stage-2 r1 H-1 — emitter
|
|
109
|
+
* default `'reauthorize_locally'` is correct for `authority_scope_conflict`
|
|
110
|
+
* (CP-1.c authority paths) but wrong for the CP-1.e Class-B variants):
|
|
111
|
+
* - signature_invalid → 'retry_after_resync' (CP-0 fixture line 458)
|
|
112
|
+
* - ulid_replay → 'abort_task' (CP-0 fixture line 486)
|
|
113
|
+
* - policy_rejection → 'ask_user' (consumer of policy reject)
|
|
114
|
+
* - authority_scope_conflict → 'reauthorize_locally' (inherited CP-1.c default)
|
|
115
|
+
*/
|
|
116
|
+
private refuseWithCategory;
|
|
117
|
+
/** Test-only — exposes cached-decision registry for §6.4 assertions. */
|
|
118
|
+
get stateForTests(): Readonly<ClassBConsumerState>;
|
|
119
|
+
/** Test-only — exposes replay registry for §5.3 / §6.4 introspection. */
|
|
120
|
+
get replayRegistryForTests(): UlidReplayRegistry;
|
|
121
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthorityError, AuthorityScope } from './authority';
|
|
2
|
+
import { ClassAEmitter, ClassAEmitterContext } from './class-a-emit';
|
|
3
|
+
import { AgentKind, HookEvent } from './types';
|
|
4
|
+
export type EmitShellEventFn = (args: {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
type: 'USER_PROMPT' | 'ASSISTANT_RESPONSE' | 'INTERACTIVE_PROMPT' | 'LOCAL_AUTHORITY_REFUSAL' | 'NOTIFICATION';
|
|
7
|
+
content?: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
export interface HookBridgeDeps {
|
|
12
|
+
emitter: ClassAEmitter;
|
|
13
|
+
emitShellEvent: EmitShellEventFn;
|
|
14
|
+
getAuthorityScope: () => AuthorityScope;
|
|
15
|
+
getCurrentTaskId: () => string | null;
|
|
16
|
+
getContextWithoutTask: () => Omit<ClassAEmitterContext, 'taskId'>;
|
|
17
|
+
adapter: AgentKind;
|
|
18
|
+
}
|
|
19
|
+
export declare class HookBridge {
|
|
20
|
+
private readonly deps;
|
|
21
|
+
constructor(deps: HookBridgeDeps);
|
|
22
|
+
ingest(event: HookEvent): Promise<void>;
|
|
23
|
+
private translateToolUse;
|
|
24
|
+
private translateFileChange;
|
|
25
|
+
private translateProcessExited;
|
|
26
|
+
private translateUserPrompt;
|
|
27
|
+
private translateAssistantText;
|
|
28
|
+
bridgeAuthorityRefusal(err: AuthorityError, args: {
|
|
29
|
+
refusedMessageId: string;
|
|
30
|
+
shellContent: string;
|
|
31
|
+
shellMetadata?: Record<string, unknown>;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
private contextOrNull;
|
|
34
|
+
/** @internal */
|
|
35
|
+
get adapterForTests(): AgentKind;
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AuthorityError, AuthorityRefusal, AuthorityRefusalCategory, AuthorityScope, FileNotFound, enforceCommand, enforceNetwork, enforceRead, enforceWrite, safeReadFile, safeWriteFile, } from './authority';
|
|
2
|
+
export { spawnHealthProbe, spawnImplementor, spawnReviewer } from './spawn';
|
|
3
|
+
export { AgentKind, AuthorityAction, ClassBInbound, ExecutorError, FailureClass, FileChangeKind, HookEvent, ImplementorHandle, LocalExecutor, ProbeHandle, ProcessExitedInfo, ProcessRole, ProcessSpawnedInfo, ReviewerHandle, SignedEnvelope, SpawnArgs, SpawnArgsInvalid, SpawnHandleBase, } from './types';
|
|
4
|
+
export { EmitShellEventFn, HookBridge, HookBridgeDeps, } from './hook-bridge';
|
|
5
|
+
export { LocalExecutorImpl, LocalExecutorImplDeps, makeEmptyScope, } from './local-executor-impl';
|
|
6
|
+
export { ClassAEmitter, ClassAEmitterContext, ClassAEnvelope, ClassAMessageType, ClassASink, DEFAULT_DEDUPE_CAP, EmitterLogger, ExecutionEventKind, ExecutorRefusalPayload, FileChangePayload, LocalStubSink, ProcessExitedPayload, ProcessSpawnedPayload, ToolUsePayload, VerificationGateKind, VerificationResultPayload, VerificationRunPayload, isValidUlid, } from './class-a-emit';
|
|
7
|
+
export { DEFAULT_GATE_TIMEOUT_MS, GateRunResult, SUMMARY_CAP_BYTES, TIMEOUT_EXIT_CODE, VerificationGateRequest, VerificationRunnerDeps, runVerificationGates, truncateUtf8Safe, } from './verification-runner';
|
|
8
|
+
export { ClassBConsumer, ClassBConsumerDeps, ClassBConsumerState, ClassBVerificationResult, INBOUND_REPLAY_CAP, INBOUND_REPLAY_TTL_MS, UlidReplayRegistry, verifyClassBSignature, } from './class-b-consumer';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AuthorityScope } from './authority';
|
|
2
|
+
import { ClassAEmitter, ClassAEmitterContext, ClassASink } from './class-a-emit';
|
|
3
|
+
import { EmitShellEventFn } from './hook-bridge';
|
|
4
|
+
import { AgentKind, AuthorityAction, ClassBInbound, HookEvent, ImplementorHandle, LocalExecutor, ProbeHandle, ReviewerHandle, SpawnArgs } from './types';
|
|
5
|
+
export interface LocalExecutorImplDeps {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
initialScope?: AuthorityScope;
|
|
8
|
+
baseCtx: Omit<ClassAEmitterContext, 'taskId'>;
|
|
9
|
+
adapter: AgentKind;
|
|
10
|
+
sink?: ClassASink;
|
|
11
|
+
emitShellEvent: EmitShellEventFn;
|
|
12
|
+
logger?: {
|
|
13
|
+
warn: (msg: string, meta?: Record<string, unknown>) => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function makeEmptyScope(): AuthorityScope;
|
|
17
|
+
export declare class LocalExecutorImpl implements LocalExecutor {
|
|
18
|
+
private scope;
|
|
19
|
+
private taskId;
|
|
20
|
+
private readonly emitter;
|
|
21
|
+
private readonly bridge;
|
|
22
|
+
private readonly classBConsumer;
|
|
23
|
+
private readonly emitShellEvent;
|
|
24
|
+
private readonly baseCtx;
|
|
25
|
+
private readonly adapter;
|
|
26
|
+
private readonly sessionId;
|
|
27
|
+
constructor(deps: LocalExecutorImplDeps);
|
|
28
|
+
/**
|
|
29
|
+
* Single-entrypoint authority gate per master §9:1284. Dispatches to the
|
|
30
|
+
* underlying `authority.ts` primitive based on `action.kind`. Throws
|
|
31
|
+
* `AuthorityError` on refusal — caller (orchestration shell or hook bridge)
|
|
32
|
+
* is responsible for routing to `bridgeAuthorityErrorToShellRefusal` /
|
|
33
|
+
* `HookBridge.bridgeAuthorityRefusal` per LOCK #C4-3.
|
|
34
|
+
*/
|
|
35
|
+
enforceAuthority(action: AuthorityAction): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Read-only view of the current authority scope per master §9:1286.
|
|
38
|
+
* Returns a deep-frozen copy so callers cannot mutate the LE's state.
|
|
39
|
+
*/
|
|
40
|
+
authorityScope(): Readonly<AuthorityScope>;
|
|
41
|
+
enforceCommand(argv: string[]): void;
|
|
42
|
+
enforceNetwork(): void;
|
|
43
|
+
enforceWrite(p: string): Promise<string>;
|
|
44
|
+
enforceRead(p: string): Promise<string>;
|
|
45
|
+
safeWriteFile(p: string, data: Buffer | string): Promise<void>;
|
|
46
|
+
safeReadFile(p: string, opts?: {
|
|
47
|
+
encoding?: BufferEncoding;
|
|
48
|
+
}): Promise<string | Buffer>;
|
|
49
|
+
spawnImplementor(args: SpawnArgs): Promise<ImplementorHandle>;
|
|
50
|
+
spawnReviewer(args: SpawnArgs): Promise<ReviewerHandle>;
|
|
51
|
+
spawnHealthProbe(args: SpawnArgs): Promise<ProbeHandle>;
|
|
52
|
+
private spawnWithLifecycle;
|
|
53
|
+
ingestHookEvent(event: HookEvent): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Single-entrypoint inbound Class B dispatch per master §9:1287.
|
|
56
|
+
* Delegates to `ClassBConsumer.consume` which enforces LOCK #E3-1
|
|
57
|
+
* (verify → replay-check → dispatch) and per-kind handlers per CP-0
|
|
58
|
+
* §2.F.9-§2.F.13.
|
|
59
|
+
*
|
|
60
|
+
* TaskAuthorized advances authority scope + taskId atomically via the DI
|
|
61
|
+
* closure wired in the constructor (CP-0 §2.5 invariant #6).
|
|
62
|
+
*/
|
|
63
|
+
consumeClassB(packet: ClassBInbound): Promise<void>;
|
|
64
|
+
/** Set the active taskId (production: CP-1.e on TASK_AUTHORIZED). */
|
|
65
|
+
setActiveTaskId(taskId: string | null): void;
|
|
66
|
+
/** Replace the active authority scope (production: CP-1.e on TASK_AUTHORIZED). */
|
|
67
|
+
setAuthorityScope(scope: AuthorityScope): void;
|
|
68
|
+
/** Expose emitter for §8.5 integration test introspection. */
|
|
69
|
+
get emitterForTests(): ClassAEmitter;
|
|
70
|
+
private contextOrNull;
|
|
71
|
+
/**
|
|
72
|
+
* Context resolver for ClassBConsumer emit paths (refusals + PolicyRejection).
|
|
73
|
+
* Class B inbound packets MAY arrive before a TaskAuthorized has set
|
|
74
|
+
* `this.taskId` (in fact, TaskAuthorized is the variant that SETS it). For
|
|
75
|
+
* the signature_invalid / ulid_replay / policy_rejection / malformed
|
|
76
|
+
* refusal-audit emit path we still need a valid envelope context, so we
|
|
77
|
+
* fall back to `pending` when no task is active. CP-2 may refine this; for
|
|
78
|
+
* CP-1.e the audit emit always succeeds with a deterministic placeholder.
|
|
79
|
+
*/
|
|
80
|
+
private contextOrFallback;
|
|
81
|
+
}
|
|
82
|
+
/** @internal */
|
|
83
|
+
export declare function __resetSessionRegistryForTests(): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthorityScope } from './authority';
|
|
2
|
+
import { ImplementorHandle, ProbeHandle, ReviewerHandle, SpawnArgs, SpawnHandleBase } from './types';
|
|
3
|
+
export declare function spawnImplementor(scope: AuthorityScope, args: SpawnArgs): Promise<ImplementorHandle>;
|
|
4
|
+
export declare function spawnReviewer(scope: AuthorityScope, args: SpawnArgs): Promise<ReviewerHandle>;
|
|
5
|
+
export declare function spawnHealthProbe(scope: AuthorityScope, args: SpawnArgs): Promise<ProbeHandle>;
|
|
6
|
+
export declare function spawnSubprocess(scope: AuthorityScope, args: SpawnArgs): Promise<SpawnHandleBase>;
|
|
@@ -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
|
+
}
|