@gajae-code/coding-agent 0.2.5 → 0.3.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/CHANGELOG.md +28 -0
- package/dist/types/async/job-manager.d.ts +91 -2
- package/dist/types/cli/args.d.ts +1 -1
- package/dist/types/commands/deep-interview.d.ts +3 -0
- package/dist/types/commands/harness.d.ts +37 -0
- package/dist/types/config/keybindings.d.ts +5 -0
- package/dist/types/config/settings-schema.d.ts +10 -4
- package/dist/types/config/settings.d.ts +2 -0
- package/dist/types/debug/crash-diagnostics.d.ts +45 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/deep-interview/render-middleware.d.ts +6 -0
- package/dist/types/eval/py/executor.d.ts +2 -0
- package/dist/types/eval/py/kernel.d.ts +2 -0
- package/dist/types/exec/bash-executor.d.ts +10 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +1 -0
- package/dist/types/extensibility/extensions/types.d.ts +6 -0
- package/dist/types/extensibility/shared-events.d.ts +1 -0
- package/dist/types/gjc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -0
- package/dist/types/gjc-runtime/state-graph.d.ts +4 -0
- package/dist/types/gjc-runtime/state-migrations.d.ts +33 -0
- package/dist/types/gjc-runtime/state-renderer.d.ts +65 -0
- package/dist/types/gjc-runtime/state-runtime.d.ts +2 -0
- package/dist/types/gjc-runtime/state-schema.d.ts +317 -0
- package/dist/types/gjc-runtime/state-validation.d.ts +6 -0
- package/dist/types/gjc-runtime/state-writer.d.ts +147 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +81 -7
- package/dist/types/gjc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/gjc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
- package/dist/types/harness-control-plane/finalize.d.ts +47 -0
- package/dist/types/harness-control-plane/frame-mapper.d.ts +29 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +46 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipts.d.ts +88 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +19 -0
- package/dist/types/harness-control-plane/storage.d.ts +53 -0
- package/dist/types/harness-control-plane/types.d.ts +162 -0
- package/dist/types/hooks/skill-keywords.d.ts +2 -1
- package/dist/types/hooks/skill-state.d.ts +23 -29
- package/dist/types/internal-urls/agent-protocol.d.ts +2 -2
- package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
- package/dist/types/internal-urls/registry-helpers.d.ts +8 -7
- package/dist/types/internal-urls/types.d.ts +4 -0
- package/dist/types/lsp/index.d.ts +10 -10
- package/dist/types/modes/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +44 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/custom-editor.d.ts +6 -0
- package/dist/types/modes/components/hook-selector.d.ts +1 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
- package/dist/types/modes/components/status-line/types.d.ts +2 -0
- package/dist/types/modes/components/status-line.d.ts +2 -0
- package/dist/types/modes/controllers/input-controller.d.ts +1 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -0
- package/dist/types/modes/index.d.ts +1 -0
- package/dist/types/modes/interactive-mode.d.ts +2 -0
- package/dist/types/modes/jobs-observer.d.ts +57 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -16
- package/dist/types/modes/rpc/host-uris.d.ts +1 -38
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +20 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +24 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +46 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +44 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/types.d.ts +2 -0
- package/dist/types/sdk.d.ts +4 -0
- package/dist/types/session/agent-session.d.ts +19 -1
- package/dist/types/skill-state/active-state.d.ts +2 -0
- package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +1 -1
- package/dist/types/skill-state/workflow-state-contract.d.ts +25 -2
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/task/executor.d.ts +3 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +5 -0
- package/dist/types/task/receipt.d.ts +85 -0
- package/dist/types/task/spawn-gate.d.ts +38 -0
- package/dist/types/task/types.d.ts +198 -14
- package/dist/types/tools/cron.d.ts +6 -0
- package/dist/types/tools/index.d.ts +2 -0
- package/dist/types/tools/path-utils.d.ts +1 -0
- package/dist/types/tools/subagent.d.ts +26 -1
- package/package.json +7 -7
- package/scripts/build-binary.ts +7 -0
- package/src/async/job-manager.ts +334 -6
- package/src/cli/args.ts +9 -2
- package/src/cli/auth-broker-cli.ts +1 -0
- package/src/cli/config-cli.ts +10 -2
- package/src/cli.ts +2 -0
- package/src/commands/deep-interview.ts +1 -0
- package/src/commands/harness.ts +862 -0
- package/src/commands/launch.ts +2 -2
- package/src/commands/state.ts +2 -1
- package/src/commands/team.ts +54 -39
- package/src/config/keybindings.ts +6 -0
- package/src/config/settings-schema.ts +13 -3
- package/src/config/settings.ts +5 -0
- package/src/dap/client.ts +17 -3
- package/src/debug/crash-diagnostics.ts +223 -0
- package/src/debug/runtime-gauges.ts +20 -0
- package/src/deep-interview/render-middleware.ts +372 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
- package/src/defaults/gjc/skills/ralplan/SKILL.md +31 -2
- package/src/defaults/gjc/skills/team/SKILL.md +47 -21
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +106 -13
- package/src/eval/py/executor.ts +21 -1
- package/src/eval/py/kernel.ts +15 -0
- package/src/exec/bash-executor.ts +41 -0
- package/src/extensibility/custom-tools/types.ts +1 -0
- package/src/extensibility/extensions/types.ts +6 -0
- package/src/extensibility/shared-events.ts +1 -0
- package/src/gjc-runtime/cli-write-receipt.ts +31 -0
- package/src/gjc-runtime/deep-interview-runtime.ts +98 -42
- package/src/gjc-runtime/goal-mode-request.ts +11 -3
- package/src/gjc-runtime/ralplan-runtime.ts +235 -43
- package/src/gjc-runtime/state-graph.ts +86 -0
- package/src/gjc-runtime/state-migrations.ts +179 -0
- package/src/gjc-runtime/state-renderer.ts +345 -0
- package/src/gjc-runtime/state-runtime.ts +1155 -46
- package/src/gjc-runtime/state-schema.ts +192 -0
- package/src/gjc-runtime/state-validation.ts +49 -0
- package/src/gjc-runtime/state-writer.ts +749 -0
- package/src/gjc-runtime/team-runtime.ts +1255 -189
- package/src/gjc-runtime/ultragoal-runtime.ts +460 -43
- package/src/gjc-runtime/workflow-command-ref.ts +239 -0
- package/src/gjc-runtime/workflow-manifest.generated.json +1601 -0
- package/src/gjc-runtime/workflow-manifest.ts +427 -0
- package/src/harness-control-plane/classifier.ts +128 -0
- package/src/harness-control-plane/control-endpoint.ts +148 -0
- package/src/harness-control-plane/finalize.ts +222 -0
- package/src/harness-control-plane/frame-mapper.ts +286 -0
- package/src/harness-control-plane/operate.ts +225 -0
- package/src/harness-control-plane/owner.ts +600 -0
- package/src/harness-control-plane/preserve.ts +102 -0
- package/src/harness-control-plane/receipts.ts +216 -0
- package/src/harness-control-plane/rpc-adapter.ts +276 -0
- package/src/harness-control-plane/seams.ts +39 -0
- package/src/harness-control-plane/session-lease.ts +388 -0
- package/src/harness-control-plane/state-machine.ts +98 -0
- package/src/harness-control-plane/storage.ts +257 -0
- package/src/harness-control-plane/types.ts +214 -0
- package/src/hooks/skill-keywords.ts +4 -2
- package/src/hooks/skill-state.ts +197 -64
- package/src/internal-urls/agent-protocol.ts +68 -21
- package/src/internal-urls/artifact-protocol.ts +12 -17
- package/src/internal-urls/docs-index.generated.ts +3 -2
- package/src/internal-urls/registry-helpers.ts +19 -16
- package/src/internal-urls/types.ts +4 -0
- package/src/lsp/client.ts +18 -2
- package/src/main.ts +21 -5
- package/src/modes/bridge/auth.ts +41 -0
- package/src/modes/bridge/bridge-client-bridge.ts +47 -0
- package/src/modes/bridge/bridge-mode.ts +520 -0
- package/src/modes/bridge/bridge-ui-context.ts +200 -0
- package/src/modes/bridge/event-stream.ts +70 -0
- package/src/modes/components/assistant-message.ts +5 -1
- package/src/modes/components/custom-editor.ts +101 -0
- package/src/modes/components/hook-selector.ts +133 -20
- package/src/modes/components/jobs-overlay-model.ts +109 -0
- package/src/modes/components/jobs-overlay.ts +172 -0
- package/src/modes/components/status-line/presets.ts +7 -5
- package/src/modes/components/status-line/segments.ts +25 -0
- package/src/modes/components/status-line/types.ts +2 -0
- package/src/modes/components/status-line.ts +9 -1
- package/src/modes/controllers/event-controller.ts +71 -6
- package/src/modes/controllers/extension-ui-controller.ts +43 -1
- package/src/modes/controllers/input-controller.ts +105 -9
- package/src/modes/controllers/selector-controller.ts +31 -1
- package/src/modes/index.ts +1 -0
- package/src/modes/interactive-mode.ts +28 -0
- package/src/modes/jobs-observer.ts +204 -0
- package/src/modes/rpc/host-tools.ts +1 -186
- package/src/modes/rpc/host-uris.ts +1 -235
- package/src/modes/rpc/rpc-client.ts +25 -10
- package/src/modes/rpc/rpc-mode.ts +12 -381
- package/src/modes/shared/agent-wire/command-dispatch.ts +341 -0
- package/src/modes/shared/agent-wire/command-validation.ts +131 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +108 -0
- package/src/modes/shared/agent-wire/handshake.ts +117 -0
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
- package/src/modes/shared/agent-wire/protocol.ts +96 -0
- package/src/modes/shared/agent-wire/responses.ts +17 -0
- package/src/modes/shared/agent-wire/scopes.ts +89 -0
- package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
- package/src/modes/shared/agent-wire/ui-result.ts +48 -0
- package/src/modes/types.ts +2 -0
- package/src/prompts/agents/executor.md +13 -0
- package/src/prompts/tools/subagent.md +39 -4
- package/src/prompts/tools/task-summary.md +3 -9
- package/src/prompts/tools/task.md +5 -1
- package/src/sdk.ts +8 -0
- package/src/session/agent-session.ts +445 -71
- package/src/session/session-manager.ts +13 -1
- package/src/skill-state/active-state.ts +58 -65
- package/src/skill-state/deep-interview-mutation-guard.ts +114 -17
- package/src/skill-state/initial-phase.ts +2 -0
- package/src/skill-state/workflow-state-contract.ts +33 -4
- package/src/skill-state/workflow-state-version.ts +3 -0
- package/src/slash-commands/builtin-registry.ts +8 -0
- package/src/task/executor.ts +79 -13
- package/src/task/id.ts +33 -0
- package/src/task/index.ts +376 -74
- package/src/task/output-manager.ts +5 -4
- package/src/task/receipt.ts +297 -0
- package/src/task/render.ts +54 -134
- package/src/task/spawn-gate.ts +132 -0
- package/src/task/types.ts +104 -10
- package/src/tools/ask.ts +88 -27
- package/src/tools/ast-edit.ts +1 -0
- package/src/tools/ast-grep.ts +1 -0
- package/src/tools/bash.ts +1 -1
- package/src/tools/cron.ts +48 -0
- package/src/tools/find.ts +4 -1
- package/src/tools/index.ts +2 -0
- package/src/tools/path-utils.ts +3 -2
- package/src/tools/read.ts +1 -0
- package/src/tools/search.ts +1 -0
- package/src/tools/skill.ts +6 -1
- package/src/tools/subagent.ts +423 -79
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
|
|
2
|
+
export type CommandRefVisibility = "public" | "hidden" | "planned";
|
|
3
|
+
export type CommandRefIncludeWhen = "implemented-only" | "planned";
|
|
4
|
+
export interface CommandRefCommand {
|
|
5
|
+
tokens: string[];
|
|
6
|
+
rendered: string;
|
|
7
|
+
visibility: CommandRefVisibility;
|
|
8
|
+
includeWhen: CommandRefIncludeWhen;
|
|
9
|
+
note?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CommandRefExample {
|
|
12
|
+
label?: string;
|
|
13
|
+
bytes: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CommandRefBridge {
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
rendered: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CommandRefBlock {
|
|
21
|
+
skill: CanonicalGjcWorkflowSkill;
|
|
22
|
+
blockId: string;
|
|
23
|
+
sourcePath: string;
|
|
24
|
+
renderOrder: number;
|
|
25
|
+
markers: {
|
|
26
|
+
start: string;
|
|
27
|
+
end: string;
|
|
28
|
+
};
|
|
29
|
+
commands: CommandRefCommand[];
|
|
30
|
+
examples: CommandRefExample[];
|
|
31
|
+
aliasesAndBridges: CommandRefBridge[];
|
|
32
|
+
notes: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface RenderedCommandRefBlock {
|
|
35
|
+
skill: CanonicalGjcWorkflowSkill;
|
|
36
|
+
blockId: string;
|
|
37
|
+
markers: CommandRefBlock["markers"];
|
|
38
|
+
bytes: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const WORKFLOW_COMMAND_REF_BLOCKS: readonly CommandRefBlock[];
|
|
41
|
+
export declare function listCommandRefBlocks(skill?: CanonicalGjcWorkflowSkill): CommandRefBlock[];
|
|
42
|
+
export declare function renderCommandRefBlock(skill: CanonicalGjcWorkflowSkill, blockId?: string): RenderedCommandRefBlock;
|
|
43
|
+
export declare function isCanonicalGjcWorkflowSkill(value: string): value is CanonicalGjcWorkflowSkill;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript is the authoritative source of truth for GJC workflow manifests.
|
|
3
|
+
* Any JSON manifest projection is derived from this module and must never be
|
|
4
|
+
* hand-edited.
|
|
5
|
+
*/
|
|
6
|
+
import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
|
|
7
|
+
export interface WorkflowState {
|
|
8
|
+
id: string;
|
|
9
|
+
initial?: boolean;
|
|
10
|
+
terminal?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkflowTransition {
|
|
13
|
+
from: string;
|
|
14
|
+
to: string;
|
|
15
|
+
verb: string;
|
|
16
|
+
}
|
|
17
|
+
export interface WorkflowVerb {
|
|
18
|
+
name: string;
|
|
19
|
+
planned?: boolean;
|
|
20
|
+
/** Invocation surface that exposes this verb in the real CLI parser. */
|
|
21
|
+
surface?: "state-action" | "command-positional" | "command-flag";
|
|
22
|
+
}
|
|
23
|
+
export interface TypedArgSpec {
|
|
24
|
+
name: string;
|
|
25
|
+
type: "string" | "number" | "boolean" | "enum" | "object";
|
|
26
|
+
enumValues?: string[];
|
|
27
|
+
required?: boolean;
|
|
28
|
+
appliesToVerbs?: string[];
|
|
29
|
+
planned?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface RetentionPolicy {
|
|
32
|
+
category: string;
|
|
33
|
+
keep?: number;
|
|
34
|
+
maxAgeDays?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface SkillManifest {
|
|
37
|
+
skill: CanonicalGjcWorkflowSkill;
|
|
38
|
+
states: WorkflowState[];
|
|
39
|
+
initialState: string;
|
|
40
|
+
terminalStates: string[];
|
|
41
|
+
transitions: WorkflowTransition[];
|
|
42
|
+
verbs: WorkflowVerb[];
|
|
43
|
+
typedArgs: TypedArgSpec[];
|
|
44
|
+
retention: RetentionPolicy[];
|
|
45
|
+
hudFields: string[];
|
|
46
|
+
graphLabel: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const WORKFLOW_MANIFEST: Record<CanonicalGjcWorkflowSkill, SkillManifest>;
|
|
49
|
+
export declare function getSkillManifest(skill: CanonicalGjcWorkflowSkill): SkillManifest;
|
|
50
|
+
export declare function isKnownWorkflowState(skill: CanonicalGjcWorkflowSkill, state: string): boolean;
|
|
51
|
+
export declare function isValidTransition(skill: CanonicalGjcWorkflowSkill, from: string, to: string): boolean;
|
|
52
|
+
export declare function listVerbs(skill: CanonicalGjcWorkflowSkill): string[];
|
|
53
|
+
export declare function typedArgsFor(skill: CanonicalGjcWorkflowSkill, verb: string): TypedArgSpec[];
|
|
54
|
+
export declare function serializeManifestProjection(): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic recovery classifier (pure).
|
|
3
|
+
*
|
|
4
|
+
* Maps a bounded {@link Observation} + remaining retry budget to exactly one
|
|
5
|
+
* {@link RecoveryDecision}. Encodes the plan's hard data-loss invariants:
|
|
6
|
+
* - dirty deltas are NEVER `restart-clean`; they map to `restart-preserve-delta`.
|
|
7
|
+
* - unknown deltas are NEVER destructive; they map to `human-check`.
|
|
8
|
+
* - a deleted/mismatched worktree maps to `human-check` (never recreate over unknown data).
|
|
9
|
+
* `send-enter` is intentionally never emitted: it is unsupported for the gajae-code
|
|
10
|
+
* RPC adapter in v1 (no blind key injection).
|
|
11
|
+
*/
|
|
12
|
+
import type { ClassifyInput, RecoveryDecision } from "./types";
|
|
13
|
+
export declare function classifyRecovery(input: ClassifyInput): RecoveryDecision;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session control endpoint — a Unix domain socket served by the RuntimeOwner so
|
|
3
|
+
* stateless `gjc harness` CLI calls can route owner-routed primitives (submit, observe,
|
|
4
|
+
* recover, retire) to the live owner. One JSON request line in, one JSON response line out.
|
|
5
|
+
*
|
|
6
|
+
* The owner is the only listener; clients connect per call. When no socket is reachable
|
|
7
|
+
* the caller falls back to the no-owner behavior (read-only observe, owner-not-live submit).
|
|
8
|
+
*
|
|
9
|
+
* FIFO fallback (for platforms/paths where AF_UNIX is unavailable or path-length limited)
|
|
10
|
+
* is a documented seam tracked as an ADR follow-up.
|
|
11
|
+
*/
|
|
12
|
+
export interface EndpointRequest {
|
|
13
|
+
verb: string;
|
|
14
|
+
input: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export type EndpointHandler = (req: EndpointRequest) => Promise<unknown>;
|
|
17
|
+
export declare class ControlServer {
|
|
18
|
+
#private;
|
|
19
|
+
readonly socketPath: string;
|
|
20
|
+
private readonly handler;
|
|
21
|
+
constructor(socketPath: string, handler: EndpointHandler);
|
|
22
|
+
listen(): Promise<void>;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class EndpointUnreachableError extends Error {
|
|
26
|
+
readonly socketPath: string;
|
|
27
|
+
readonly reason: string;
|
|
28
|
+
constructor(socketPath: string, reason?: string);
|
|
29
|
+
}
|
|
30
|
+
/** Call the owner's control endpoint. Rejects with {@link EndpointUnreachableError} when no owner listens or responds. */
|
|
31
|
+
export declare function callEndpoint(socketPath: string, req: EndpointRequest, timeoutMs?: number): Promise<unknown>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface ValidationCommandSpec {
|
|
2
|
+
name: string;
|
|
3
|
+
command: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ValidationRun {
|
|
6
|
+
exactCommand: string;
|
|
7
|
+
cwd: string;
|
|
8
|
+
exitStatus: number;
|
|
9
|
+
pass: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface FinalizeChecks {
|
|
12
|
+
runValidation(spec: ValidationCommandSpec): Promise<ValidationRun>;
|
|
13
|
+
resolveCommit(): Promise<string | null>;
|
|
14
|
+
commitOnBranch(commit: string, branch: string): Promise<boolean>;
|
|
15
|
+
prOrIssue(): Promise<{
|
|
16
|
+
prUrl: string | null;
|
|
17
|
+
issueArtifact: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface FinalizeOptions {
|
|
21
|
+
root: string;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
workspace: string;
|
|
24
|
+
branch: string;
|
|
25
|
+
requireTests?: boolean;
|
|
26
|
+
requireCommit?: boolean;
|
|
27
|
+
requirePr?: boolean;
|
|
28
|
+
validationCommands?: ValidationCommandSpec[];
|
|
29
|
+
checks: FinalizeChecks;
|
|
30
|
+
clock?: () => number;
|
|
31
|
+
}
|
|
32
|
+
export interface FinalizeResult {
|
|
33
|
+
completed: boolean;
|
|
34
|
+
receiptPath: string | null;
|
|
35
|
+
validation: {
|
|
36
|
+
name: string;
|
|
37
|
+
valid: boolean;
|
|
38
|
+
exitStatus: number;
|
|
39
|
+
}[];
|
|
40
|
+
commitHash: string | null;
|
|
41
|
+
prUrl: string | null;
|
|
42
|
+
issueArtifact: string | null;
|
|
43
|
+
blockers: string[];
|
|
44
|
+
}
|
|
45
|
+
export declare function runFinalize(opts: FinalizeOptions): Promise<FinalizeResult>;
|
|
46
|
+
/** Real checks: git for commit/branch, gh for PR, Bun.spawn for validation commands. */
|
|
47
|
+
export declare function defaultFinalizeChecks(workspace: string): FinalizeChecks;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure mapping from `gjc --mode rpc` event frames (docs/rpc.md) to bounded owner event kinds
|
|
3
|
+
* and {@link ObservedSignal}s. The owner feeds raw frames through this mapper and emits the
|
|
4
|
+
* result via its single-writer #emit — the mapper itself performs NO IO and NO appends.
|
|
5
|
+
*
|
|
6
|
+
* Hard rule: evidence is BOUNDED — only ids, names, categories, statuses, cursors, timestamps,
|
|
7
|
+
* and short codes/messages. Never assistant text, message deltas, command output, or raw args.
|
|
8
|
+
*/
|
|
9
|
+
import type { ObservedSignal } from "./types";
|
|
10
|
+
export interface MappedFrame {
|
|
11
|
+
/** Owner event kind (rpc_*). */
|
|
12
|
+
kind: string;
|
|
13
|
+
/** Bounded observed signal, or null when the frame carries no user-facing signal. */
|
|
14
|
+
signal: ObservedSignal | null;
|
|
15
|
+
/** Bounded evidence — ids/names/statuses/cursors/timestamps/short codes only. */
|
|
16
|
+
evidence: Record<string, unknown>;
|
|
17
|
+
/** Severity for the emitted event. */
|
|
18
|
+
severity: "info" | "warn" | "critical";
|
|
19
|
+
/** Never-drop frames (must be enqueued in order, never coalesced away). */
|
|
20
|
+
semantic: boolean;
|
|
21
|
+
/** Coalescing key for high-frequency non-semantic frames (message id / tool id); null otherwise. */
|
|
22
|
+
coalesceKey: string | null;
|
|
23
|
+
}
|
|
24
|
+
export declare function isTestRunnerTool(toolName?: unknown, command?: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Map a single RPC frame. Returns null for frames that carry no observability value
|
|
27
|
+
* (or that the adapter handles itself: `ready`, `response`).
|
|
28
|
+
*/
|
|
29
|
+
export declare function mapRpcFrame(frame: Record<string, unknown>): MappedFrame | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type FinalizeChecks, type FinalizeResult, type ValidationCommandSpec } from "./finalize";
|
|
2
|
+
import { type PreserveResult } from "./preserve";
|
|
3
|
+
import { type HarnessRpc } from "./rpc-adapter";
|
|
4
|
+
import { type HarnessLifecycle, type Observation, type RecoveryClassification, type RetryBudget, type Severity } from "./types";
|
|
5
|
+
export interface OperateOptions {
|
|
6
|
+
root: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
workspace: string;
|
|
9
|
+
branch: string;
|
|
10
|
+
rpc: HarnessRpc;
|
|
11
|
+
/** Factory used to (re)create the RPC subprocess on restart recovery. Defaults to reusing `rpc`. */
|
|
12
|
+
rpcFactory?: () => HarnessRpc;
|
|
13
|
+
/** Bounded observation provider (scripted in tests; real = git + rpc state). */
|
|
14
|
+
observe: () => Promise<Observation>;
|
|
15
|
+
/** Real dirty-worktree preservation; injectable for tests. Defaults to git stash/diff capture. */
|
|
16
|
+
preserve?: (workspace: string) => PreserveResult;
|
|
17
|
+
finalizeChecks: FinalizeChecks;
|
|
18
|
+
validationCommands?: ValidationCommandSpec[];
|
|
19
|
+
retryBudget?: Partial<RetryBudget>;
|
|
20
|
+
acceptanceTimeoutMs?: number;
|
|
21
|
+
maxIterations?: number;
|
|
22
|
+
/** Injected event emitter. Production owner calls must pass the lease-guarded single-writer #emit. */
|
|
23
|
+
emit: (severity: Severity, kind: string, evidence: Record<string, unknown>) => Promise<void>;
|
|
24
|
+
clock?: () => number;
|
|
25
|
+
}
|
|
26
|
+
export interface OperateResult {
|
|
27
|
+
completed: boolean;
|
|
28
|
+
lifecycle: HarnessLifecycle;
|
|
29
|
+
iterations: number;
|
|
30
|
+
classifications: RecoveryClassification[];
|
|
31
|
+
vanishReceiptIds: string[];
|
|
32
|
+
finalize?: FinalizeResult;
|
|
33
|
+
blockers: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function operate(goal: string, opts: OperateOptions): Promise<OperateResult>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RuntimeOwner — the detached per-session process that makes live control honest.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - hold the {@link SessionLease} (single writer),
|
|
6
|
+
* - own the {@link HarnessRpc} subprocess (injected; real `GajaeCodeRpc` in prod, fake in tests),
|
|
7
|
+
* - serve owner-routed primitives over the {@link ControlServer} endpoint,
|
|
8
|
+
* - be the SOLE writer of the severity event stream,
|
|
9
|
+
* - heartbeat the lease.
|
|
10
|
+
*
|
|
11
|
+
* Stateless `gjc harness` CLI calls reach the owner via {@link resolveOwner} + the endpoint.
|
|
12
|
+
*/
|
|
13
|
+
import { type FinalizeChecks, type ValidationCommandSpec } from "./finalize";
|
|
14
|
+
import type { HarnessRpc } from "./rpc-adapter";
|
|
15
|
+
import { type SessionLease } from "./session-lease";
|
|
16
|
+
export interface OwnerOptions {
|
|
17
|
+
root: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
rpc: HarnessRpc;
|
|
20
|
+
ownerId?: string;
|
|
21
|
+
ttlMs?: number;
|
|
22
|
+
heartbeatMs?: number;
|
|
23
|
+
acceptanceTimeoutMs?: number;
|
|
24
|
+
clock?: () => number;
|
|
25
|
+
finalizeChecks?: FinalizeChecks;
|
|
26
|
+
validationCommands?: ValidationCommandSpec[];
|
|
27
|
+
}
|
|
28
|
+
export interface OwnerStartInfo {
|
|
29
|
+
ownerId: string;
|
|
30
|
+
socketPath: string;
|
|
31
|
+
leaseEpoch: number;
|
|
32
|
+
}
|
|
33
|
+
export declare class RuntimeOwner {
|
|
34
|
+
#private;
|
|
35
|
+
readonly ownerId: string;
|
|
36
|
+
constructor(opts: OwnerOptions);
|
|
37
|
+
start(): Promise<OwnerStartInfo>;
|
|
38
|
+
stop(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export interface ResolvedOwner {
|
|
41
|
+
live: boolean;
|
|
42
|
+
socketPath: string | null;
|
|
43
|
+
lease: SessionLease | null;
|
|
44
|
+
}
|
|
45
|
+
/** Determine whether a live owner currently holds the session (for CLI routing). */
|
|
46
|
+
export declare function resolveOwner(root: string, sessionId: string): Promise<ResolvedOwner>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GitDelta } from "./types";
|
|
2
|
+
export interface UntrackedEntry {
|
|
3
|
+
path: string;
|
|
4
|
+
size: number;
|
|
5
|
+
sha256: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PreserveResult {
|
|
8
|
+
gitDelta: GitDelta;
|
|
9
|
+
trackedDiff: string;
|
|
10
|
+
trackedDiffSha256: string;
|
|
11
|
+
untrackedManifest: UntrackedEntry[];
|
|
12
|
+
stashRef: string | null;
|
|
13
|
+
snapshotComplete: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Capture + snapshot a (possibly dirty) worktree without mutating it. Safe to call on a clean
|
|
17
|
+
* tree (returns empty evidence). Never deletes, resets, or cleans.
|
|
18
|
+
*/
|
|
19
|
+
export declare function preserveDirtyWorktree(workspace: string): PreserveResult;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { GitDelta, ReceiptFamily, RecoveryClassification } from "./types";
|
|
2
|
+
export interface ReceiptSubject {
|
|
3
|
+
workspace: string;
|
|
4
|
+
branch: string | null;
|
|
5
|
+
head: string | null;
|
|
6
|
+
commit: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface ReceiptEnvelope<E = Record<string, unknown>> {
|
|
9
|
+
receiptId: string;
|
|
10
|
+
schemaVersion: number;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
family: ReceiptFamily;
|
|
13
|
+
valid: boolean;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
source: string;
|
|
16
|
+
subject: ReceiptSubject;
|
|
17
|
+
evidence: E;
|
|
18
|
+
/** Hashes of out-of-line artifacts (diff patches, validation logs) folded into the receipt hash. */
|
|
19
|
+
artifactHashes: Record<string, string>;
|
|
20
|
+
sha256: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const RECEIPT_SCHEMA_VERSION: 1;
|
|
23
|
+
export declare function sha256Hex(input: string): string;
|
|
24
|
+
export interface BuildReceiptInput<E> {
|
|
25
|
+
receiptId: string;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
family: ReceiptFamily;
|
|
28
|
+
source: string;
|
|
29
|
+
subject: ReceiptSubject;
|
|
30
|
+
evidence: E;
|
|
31
|
+
artifactHashes?: Record<string, string>;
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
valid?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildReceipt<E>(input: BuildReceiptInput<E>): ReceiptEnvelope<E>;
|
|
36
|
+
export interface ValidationOutcome {
|
|
37
|
+
valid: boolean;
|
|
38
|
+
reasons: string[];
|
|
39
|
+
}
|
|
40
|
+
/** Recompute the hash and run structural family checks. Fail-closed. */
|
|
41
|
+
export declare function validateReceipt(receipt: ReceiptEnvelope<unknown>): ValidationOutcome;
|
|
42
|
+
export interface VanishEvidence {
|
|
43
|
+
classification: RecoveryClassification;
|
|
44
|
+
gitDelta: GitDelta;
|
|
45
|
+
gitStatusPorcelain: string;
|
|
46
|
+
untrackedManifest: {
|
|
47
|
+
path: string;
|
|
48
|
+
size: number;
|
|
49
|
+
sha256: string;
|
|
50
|
+
}[];
|
|
51
|
+
preservation: "snapshot" | "stash" | "block";
|
|
52
|
+
stashRef: string | null;
|
|
53
|
+
snapshotComplete: boolean;
|
|
54
|
+
forbiddenActions: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface PromptAcceptanceEvidence {
|
|
57
|
+
promptSha256: string;
|
|
58
|
+
rpcCommandId: string;
|
|
59
|
+
preSubmitState: {
|
|
60
|
+
isStreaming: boolean;
|
|
61
|
+
steeringQueueDepth: number;
|
|
62
|
+
followupQueueDepth: number;
|
|
63
|
+
};
|
|
64
|
+
preSubmitCursor: number;
|
|
65
|
+
agentStartCursor: number;
|
|
66
|
+
acceptedAt: string;
|
|
67
|
+
singleFlight: true;
|
|
68
|
+
}
|
|
69
|
+
export interface ValidationEvidence {
|
|
70
|
+
command: string;
|
|
71
|
+
exactCommand: string;
|
|
72
|
+
cwd: string;
|
|
73
|
+
exitStatus: number;
|
|
74
|
+
pass: boolean;
|
|
75
|
+
commitUnderTest: string | null;
|
|
76
|
+
}
|
|
77
|
+
export interface CompletionEvidence {
|
|
78
|
+
finalCommit: string;
|
|
79
|
+
branch: string;
|
|
80
|
+
prUrl: string | null;
|
|
81
|
+
issueArtifact: string | null;
|
|
82
|
+
requiredValidationReceiptIds: string[];
|
|
83
|
+
finalLifecycle: string;
|
|
84
|
+
finalizedAt: string;
|
|
85
|
+
blockers: string[];
|
|
86
|
+
}
|
|
87
|
+
/** Classifications that MUST have a valid `vanish` receipt before the action proceeds. */
|
|
88
|
+
export declare function requiresVanishBeforeAction(classification: RecoveryClassification): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface RpcStateSnapshot {
|
|
2
|
+
isStreaming: boolean;
|
|
3
|
+
steeringQueueDepth: number;
|
|
4
|
+
followupQueueDepth: number;
|
|
5
|
+
}
|
|
6
|
+
/** Abstract handle to a live gajae-code RPC session. */
|
|
7
|
+
export interface HarnessRpc {
|
|
8
|
+
getState(): Promise<RpcStateSnapshot>;
|
|
9
|
+
/** Send a prompt; resolves with the RPC command id and whether it was acked. Does NOT await agent_start. */
|
|
10
|
+
sendPrompt(prompt: string): Promise<{
|
|
11
|
+
commandId: string;
|
|
12
|
+
ack: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
/** Monotonic count of events observed so far (the acceptance cursor). */
|
|
15
|
+
eventCursor(): number;
|
|
16
|
+
/** Resolve when an `agent_start` event arrives strictly after `afterCursor`, else null on timeout. */
|
|
17
|
+
waitForAgentStart(afterCursor: number, timeoutMs: number): Promise<{
|
|
18
|
+
cursor: number;
|
|
19
|
+
} | null>;
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
/** Subscribe to parsed event frames (non-ready, non-response), fired AFTER the cursor advances. Returns unsubscribe. */
|
|
22
|
+
onEventFrame?(listener: (frame: Record<string, unknown>) => void): () => void;
|
|
23
|
+
/** Whether the underlying RPC subprocess is still alive. */
|
|
24
|
+
isLive?(): boolean;
|
|
25
|
+
/** ISO timestamp of the last observed event frame, or null. */
|
|
26
|
+
lastFrameAt?(): string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface AcceptanceResult {
|
|
29
|
+
accepted: boolean;
|
|
30
|
+
reason: string;
|
|
31
|
+
commandId: string | null;
|
|
32
|
+
preSubmitCursor: number;
|
|
33
|
+
agentStartCursor: number | null;
|
|
34
|
+
preSubmitState: RpcStateSnapshot;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Single-flight acceptance: idle + empty-queue pre-state, ack, then the NEXT
|
|
38
|
+
* `agent_start` after the pre-submit cursor within `timeoutMs`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function singleFlightAccept(rpc: HarnessRpc, prompt: string, timeoutMs: number): Promise<AcceptanceResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Real adapter: spawns `gjc --mode rpc --session-dir <dir>` and speaks the JSONL
|
|
43
|
+
* protocol from docs/rpc.md. Verified end-to-end in the M10 suite.
|
|
44
|
+
*/
|
|
45
|
+
export declare class GajaeCodeRpc implements HarnessRpc {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(opts: {
|
|
48
|
+
sessionDir: string;
|
|
49
|
+
command?: string[];
|
|
50
|
+
cwd?: string;
|
|
51
|
+
env?: NodeJS.ProcessEnv;
|
|
52
|
+
});
|
|
53
|
+
onEventFrame(listener: (frame: Record<string, unknown>) => void): () => void;
|
|
54
|
+
isLive(): boolean;
|
|
55
|
+
lastFrameAt(): string | null;
|
|
56
|
+
getState(): Promise<RpcStateSnapshot>;
|
|
57
|
+
sendPrompt(prompt: string): Promise<{
|
|
58
|
+
commandId: string;
|
|
59
|
+
ack: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
eventCursor(): number;
|
|
62
|
+
waitForAgentStart(afterCursor: number, timeoutMs: number): Promise<{
|
|
63
|
+
cursor: number;
|
|
64
|
+
} | null>;
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v1 seams (M11). The control plane is harness-agnostic by design, but v1 ships ONLY the
|
|
3
|
+
* gajae-code adapter. Other harnesses and transports are explicit, designed-not-built seams
|
|
4
|
+
* that fail closed with a clear `seam_unsupported_in_v1` signal rather than silently degrading.
|
|
5
|
+
*/
|
|
6
|
+
import type { Harness } from "./types";
|
|
7
|
+
export declare const SUPPORTED_HARNESSES: readonly Harness[];
|
|
8
|
+
export declare const DEFERRED_SEAMS: readonly ["codex-adapter", "omx-adapter", "remote-transport", "global-daemon", "capability-token-auth", "web-viewer", "fleet-control-plane", "rich-tui-coview"];
|
|
9
|
+
export type DeferredSeam = (typeof DEFERRED_SEAMS)[number];
|
|
10
|
+
export declare function isHarnessSupported(harness: string): harness is Harness;
|
|
11
|
+
export interface UnsupportedSeamResult {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: string;
|
|
14
|
+
evidence: {
|
|
15
|
+
seam: true;
|
|
16
|
+
name: string;
|
|
17
|
+
supported: readonly Harness[];
|
|
18
|
+
deferred: readonly string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare function unsupportedSeam(name: string): UnsupportedSeamResult;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface SessionLease {
|
|
2
|
+
ownerId: string;
|
|
3
|
+
sessionId: string;
|
|
4
|
+
pid: number;
|
|
5
|
+
leaseTokenHash: string;
|
|
6
|
+
endpoint: {
|
|
7
|
+
kind: "unix-socket" | "fifo";
|
|
8
|
+
path: string;
|
|
9
|
+
} | null;
|
|
10
|
+
eventsPath: string;
|
|
11
|
+
heartbeatAt: string;
|
|
12
|
+
expiresAt: string;
|
|
13
|
+
leaseEpoch: number;
|
|
14
|
+
writer: {
|
|
15
|
+
ownerId: string;
|
|
16
|
+
leaseEpoch: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class LeaseError extends Error {
|
|
20
|
+
readonly code: string;
|
|
21
|
+
constructor(message: string, code: string);
|
|
22
|
+
}
|
|
23
|
+
export type LeaseStatus = "missing" | "live" | "expiredAlive" | "dead" | "epermAlive";
|
|
24
|
+
type PidStatus = "alive" | "dead" | "eperm";
|
|
25
|
+
export declare function readLease(root: string, sessionId: string): Promise<SessionLease | null>;
|
|
26
|
+
export declare function isExpired(lease: SessionLease, clock?: () => number): boolean;
|
|
27
|
+
export declare function classifyLeaseStatus(lease: SessionLease | null, opts?: {
|
|
28
|
+
clock?: () => number;
|
|
29
|
+
probe?: (pid: number) => PidStatus;
|
|
30
|
+
}): LeaseStatus;
|
|
31
|
+
/** Liveness probe via signal 0. Defaults to the real process table; injectable for tests. */
|
|
32
|
+
export declare function isOwnerAlive(pid: number, probe?: (pid: number) => boolean): boolean;
|
|
33
|
+
export declare function isStale(lease: SessionLease, opts?: {
|
|
34
|
+
clock?: () => number;
|
|
35
|
+
probe?: (pid: number) => boolean;
|
|
36
|
+
}): boolean;
|
|
37
|
+
export interface AcquireOptions {
|
|
38
|
+
ownerId: string;
|
|
39
|
+
pid: number;
|
|
40
|
+
endpoint?: SessionLease["endpoint"];
|
|
41
|
+
eventsPath: string;
|
|
42
|
+
ttlMs: number;
|
|
43
|
+
clock?: () => number;
|
|
44
|
+
probe?: (pid: number) => boolean | PidStatus;
|
|
45
|
+
}
|
|
46
|
+
export interface AcquiredLease {
|
|
47
|
+
lease: SessionLease;
|
|
48
|
+
token: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Acquire (or take over a stale) lease. Fails closed with `lease_held` when a live,
|
|
52
|
+
* unexpired lease is held by a different owner. Re-acquiring as the current owner refreshes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function acquireLease(root: string, sessionId: string, opts: AcquireOptions): Promise<AcquiredLease>;
|
|
55
|
+
/** Refresh the lease expiry. Only the recorded owner may heartbeat (single-writer). */
|
|
56
|
+
export declare function heartbeat(root: string, sessionId: string, ownerId: string, ttlMs: number, clock?: () => number): Promise<SessionLease>;
|
|
57
|
+
/** Whether `ownerId` is the live, unexpired single writer permitted to append events. */
|
|
58
|
+
export declare function canWriteEvents(lease: SessionLease, ownerId: string, clock?: () => number): boolean;
|
|
59
|
+
/** Release the lease (owner shutdown). Only the holder may release. */
|
|
60
|
+
export declare function releaseLease(root: string, sessionId: string, ownerId: string): Promise<void>;
|
|
61
|
+
export declare function reapDeadOwnerArtifacts(root: string, sessionId: string, expectedOwnerId: string, expectedEpoch: number, opts?: {
|
|
62
|
+
clock?: () => number;
|
|
63
|
+
probe?: (pid: number) => PidStatus;
|
|
64
|
+
}): Promise<boolean>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle state machine + the universal `{state, evidence, nextAllowedActions}` contract.
|
|
3
|
+
*
|
|
4
|
+
* `nextAllowedActions` is the forcing function: it tells the caller exactly which
|
|
5
|
+
* primitives are currently permitted and, when not, why. Owner-routed verbs
|
|
6
|
+
* (`submit`) report `owner-not-live` when no `RuntimeOwner` holds the session lease.
|
|
7
|
+
*/
|
|
8
|
+
import type { HarnessLifecycle, NextAllowedAction, PrimitiveResponse, SessionState, SessionStateView } from "./types";
|
|
9
|
+
export declare function isTerminal(lifecycle: HarnessLifecycle): boolean;
|
|
10
|
+
export declare function canTransition(from: HarnessLifecycle, to: HarnessLifecycle): boolean;
|
|
11
|
+
export declare function assertTransition(from: HarnessLifecycle, to: HarnessLifecycle): void;
|
|
12
|
+
/**
|
|
13
|
+
* Derive the permitted next actions for a session given its lifecycle and whether
|
|
14
|
+
* a live owner currently holds the lease.
|
|
15
|
+
*/
|
|
16
|
+
export declare function nextAllowedActions(lifecycle: HarnessLifecycle, ownerLive: boolean): NextAllowedAction[];
|
|
17
|
+
export declare function buildStateView(state: SessionState, ownerLive: boolean): SessionStateView;
|
|
18
|
+
/** Build the universal contract response carried by every primitive. */
|
|
19
|
+
export declare function buildResponse<E extends Record<string, unknown>>(state: SessionState, ownerLive: boolean, evidence: E, ok?: boolean): PrimitiveResponse<E>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EventEnvelope, ReceiptFamily, SessionState } from "./types";
|
|
2
|
+
export declare const MAX_UNIX_SOCKET_PATH_BYTES = 100;
|
|
3
|
+
export declare function controlSocketPath(root: string, sessionId: string, env?: NodeJS.ProcessEnv): string;
|
|
4
|
+
export declare class StorageError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(message: string, code: string);
|
|
7
|
+
}
|
|
8
|
+
/** Resolve the harness state root from explicit value, env, or cwd default. */
|
|
9
|
+
export declare function resolveHarnessRoot(opts?: {
|
|
10
|
+
root?: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function assertSafeSessionId(id: string): void;
|
|
15
|
+
export declare function generateSessionId(prefix?: string): string;
|
|
16
|
+
export interface SessionPaths {
|
|
17
|
+
dir: string;
|
|
18
|
+
state: string;
|
|
19
|
+
lease: string;
|
|
20
|
+
events: string;
|
|
21
|
+
receiptsIndex: string;
|
|
22
|
+
receiptsDir: string;
|
|
23
|
+
artifactsDir: string;
|
|
24
|
+
controlSock: string;
|
|
25
|
+
controlFifo: string;
|
|
26
|
+
gjcSessionDir: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function sessionPaths(root: string, sessionId: string): SessionPaths;
|
|
29
|
+
export declare function readSessionState(root: string, sessionId: string): Promise<SessionState | null>;
|
|
30
|
+
export declare function writeSessionState(root: string, state: SessionState): Promise<void>;
|
|
31
|
+
export declare function sessionExists(root: string, sessionId: string): Promise<boolean>;
|
|
32
|
+
/** Append a single severity envelope to events.jsonl. Single-writer discipline is the owner's job (M3). */
|
|
33
|
+
export declare function appendEvent(root: string, sessionId: string, envelope: EventEnvelope): Promise<void>;
|
|
34
|
+
/** Read events from cursor (exclusive). Tail-only: never mutates the log. */
|
|
35
|
+
export declare function readEvents(root: string, sessionId: string, fromCursor?: number): Promise<EventEnvelope[]>;
|
|
36
|
+
export interface ReceiptIndexEntry {
|
|
37
|
+
receiptId: string;
|
|
38
|
+
family: ReceiptFamily;
|
|
39
|
+
valid: boolean;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
path: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Persist a receipt immutably. Fails closed if the receipt id already exists,
|
|
45
|
+
* then appends an index entry to receipts.jsonl.
|
|
46
|
+
*/
|
|
47
|
+
export declare function writeReceiptImmutable(root: string, sessionId: string, family: ReceiptFamily, receiptId: string, value: {
|
|
48
|
+
receiptId: string;
|
|
49
|
+
family: ReceiptFamily;
|
|
50
|
+
valid: boolean;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
}): Promise<ReceiptIndexEntry>;
|
|
53
|
+
export declare function readReceiptIndex(root: string, sessionId: string, family?: ReceiptFamily): Promise<ReceiptIndexEntry[]>;
|