@culture.dev/agents 0.0.0-stage → 0.15.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/LICENSE +201 -0
- package/README.md +59 -2
- package/dist/contract-schemas/agent.json +128 -0
- package/dist/contract-schemas/allowlist.json +25 -0
- package/dist/contract-schemas/api.json +501 -0
- package/dist/contract-schemas/capabilities.json +208 -0
- package/dist/contract-schemas/common.json +123 -0
- package/dist/contract-schemas/control-action.json +279 -0
- package/dist/contract-schemas/error.json +269 -0
- package/dist/contract-schemas/event.json +316 -0
- package/dist/contract-schemas/run.json +336 -0
- package/dist/contract-schemas/session.json +77 -0
- package/dist/contract-schemas/version.json +22 -0
- package/dist/src/contract/api.d.ts +41 -0
- package/dist/src/contract/api.js +35 -0
- package/dist/src/contract/api.js.map +1 -0
- package/dist/src/contract/errors.d.ts +21 -0
- package/dist/src/contract/errors.js +25 -0
- package/dist/src/contract/errors.js.map +1 -0
- package/dist/src/contract/generated/agent.d.ts +31 -0
- package/dist/src/contract/generated/agent.js +3 -0
- package/dist/src/contract/generated/agent.js.map +1 -0
- package/dist/src/contract/generated/allowlist.d.ts +10 -0
- package/dist/src/contract/generated/allowlist.js +3 -0
- package/dist/src/contract/generated/allowlist.js.map +1 -0
- package/dist/src/contract/generated/capabilities.d.ts +46 -0
- package/dist/src/contract/generated/capabilities.js +3 -0
- package/dist/src/contract/generated/capabilities.js.map +1 -0
- package/dist/src/contract/generated/common.d.ts +40 -0
- package/dist/src/contract/generated/common.js +3 -0
- package/dist/src/contract/generated/common.js.map +1 -0
- package/dist/src/contract/generated/control-action.d.ts +73 -0
- package/dist/src/contract/generated/control-action.js +3 -0
- package/dist/src/contract/generated/control-action.js.map +1 -0
- package/dist/src/contract/generated/error.d.ts +25 -0
- package/dist/src/contract/generated/error.js +3 -0
- package/dist/src/contract/generated/error.js.map +1 -0
- package/dist/src/contract/generated/event.d.ts +80 -0
- package/dist/src/contract/generated/event.js +3 -0
- package/dist/src/contract/generated/event.js.map +1 -0
- package/dist/src/contract/generated/index.d.ts +81 -0
- package/dist/src/contract/generated/index.js +3 -0
- package/dist/src/contract/generated/index.js.map +1 -0
- package/dist/src/contract/generated/run.d.ts +63 -0
- package/dist/src/contract/generated/run.js +3 -0
- package/dist/src/contract/generated/run.js.map +1 -0
- package/dist/src/contract/generated/session.d.ts +12 -0
- package/dist/src/contract/generated/session.js +3 -0
- package/dist/src/contract/generated/session.js.map +1 -0
- package/dist/src/contract/generated/version.d.ts +9 -0
- package/dist/src/contract/generated/version.js +3 -0
- package/dist/src/contract/generated/version.js.map +1 -0
- package/dist/src/contract/ids.d.ts +36 -0
- package/dist/src/contract/ids.js +85 -0
- package/dist/src/contract/ids.js.map +1 -0
- package/dist/src/contract/index.d.ts +17 -0
- package/dist/src/contract/index.js +13 -0
- package/dist/src/contract/index.js.map +1 -0
- package/dist/src/contract/run-state.d.ts +13 -0
- package/dist/src/contract/run-state.js +24 -0
- package/dist/src/contract/run-state.js.map +1 -0
- package/dist/src/contract/schemas.d.ts +18 -0
- package/dist/src/contract/schemas.js +37 -0
- package/dist/src/contract/schemas.js.map +1 -0
- package/dist/src/contract/validate.d.ts +17 -0
- package/dist/src/contract/validate.js +68 -0
- package/dist/src/contract/validate.js.map +1 -0
- package/dist/src/daemon/allowlist.d.ts +23 -0
- package/dist/src/daemon/allowlist.js +57 -0
- package/dist/src/daemon/allowlist.js.map +1 -0
- package/dist/src/daemon/daemon.d.ts +31 -0
- package/dist/src/daemon/daemon.js +141 -0
- package/dist/src/daemon/daemon.js.map +1 -0
- package/dist/src/daemon/errors.d.ts +14 -0
- package/dist/src/daemon/errors.js +26 -0
- package/dist/src/daemon/errors.js.map +1 -0
- package/dist/src/daemon/harness-catalog.d.ts +11 -0
- package/dist/src/daemon/harness-catalog.js +21 -0
- package/dist/src/daemon/harness-catalog.js.map +1 -0
- package/dist/src/daemon/http.d.ts +15 -0
- package/dist/src/daemon/http.js +76 -0
- package/dist/src/daemon/http.js.map +1 -0
- package/dist/src/daemon/lock.d.ts +47 -0
- package/dist/src/daemon/lock.js +167 -0
- package/dist/src/daemon/lock.js.map +1 -0
- package/dist/src/daemon/main.d.ts +32 -0
- package/dist/src/daemon/main.js +204 -0
- package/dist/src/daemon/main.js.map +1 -0
- package/dist/src/daemon/paths.d.ts +29 -0
- package/dist/src/daemon/paths.js +26 -0
- package/dist/src/daemon/paths.js.map +1 -0
- package/dist/src/daemon/ports.d.ts +58 -0
- package/dist/src/daemon/ports.js +2 -0
- package/dist/src/daemon/ports.js.map +1 -0
- package/dist/src/daemon/routes.d.ts +15 -0
- package/dist/src/daemon/routes.js +259 -0
- package/dist/src/daemon/routes.js.map +1 -0
- package/dist/src/daemon/sse.d.ts +8 -0
- package/dist/src/daemon/sse.js +56 -0
- package/dist/src/daemon/sse.js.map +1 -0
- package/dist/src/harness/availability.d.ts +9 -0
- package/dist/src/harness/availability.js +52 -0
- package/dist/src/harness/availability.js.map +1 -0
- package/dist/src/harness/claude-code/agent.d.ts +4 -0
- package/dist/src/harness/claude-code/agent.js +33 -0
- package/dist/src/harness/claude-code/agent.js.map +1 -0
- package/dist/src/harness/claude-code/backend.d.ts +48 -0
- package/dist/src/harness/claude-code/backend.js +83 -0
- package/dist/src/harness/claude-code/backend.js.map +1 -0
- package/dist/src/harness/claude-code/capabilities.d.ts +7 -0
- package/dist/src/harness/claude-code/capabilities.js +11 -0
- package/dist/src/harness/claude-code/capabilities.js.map +1 -0
- package/dist/src/harness/claude-code/index.d.ts +15 -0
- package/dist/src/harness/claude-code/index.js +20 -0
- package/dist/src/harness/claude-code/index.js.map +1 -0
- package/dist/src/harness/claude-code/map.d.ts +30 -0
- package/dist/src/harness/claude-code/map.js +108 -0
- package/dist/src/harness/claude-code/map.js.map +1 -0
- package/dist/src/harness/common/capabilities.d.ts +34 -0
- package/dist/src/harness/common/capabilities.js +60 -0
- package/dist/src/harness/common/capabilities.js.map +1 -0
- package/dist/src/harness/common/guard.d.ts +18 -0
- package/dist/src/harness/common/guard.js +31 -0
- package/dist/src/harness/common/guard.js.map +1 -0
- package/dist/src/harness/common/processes.d.ts +21 -0
- package/dist/src/harness/common/processes.js +46 -0
- package/dist/src/harness/common/processes.js.map +1 -0
- package/dist/src/harness/common/queue.d.ts +20 -0
- package/dist/src/harness/common/queue.js +76 -0
- package/dist/src/harness/common/queue.js.map +1 -0
- package/dist/src/harness/common/run-driver.d.ts +88 -0
- package/dist/src/harness/common/run-driver.js +317 -0
- package/dist/src/harness/common/run-driver.js.map +1 -0
- package/dist/src/harness/common/sandbox-workspace.d.ts +72 -0
- package/dist/src/harness/common/sandbox-workspace.js +155 -0
- package/dist/src/harness/common/sandbox-workspace.js.map +1 -0
- package/dist/src/harness/common/text.d.ts +9 -0
- package/dist/src/harness/common/text.js +49 -0
- package/dist/src/harness/common/text.js.map +1 -0
- package/dist/src/harness/common/types.d.ts +111 -0
- package/dist/src/harness/common/types.js +2 -0
- package/dist/src/harness/common/types.js.map +1 -0
- package/dist/src/harness/config.d.ts +43 -0
- package/dist/src/harness/config.js +200 -0
- package/dist/src/harness/config.js.map +1 -0
- package/dist/src/harness/index.d.ts +21 -0
- package/dist/src/harness/index.js +89 -0
- package/dist/src/harness/index.js.map +1 -0
- package/dist/src/harness/opencode/backend.d.ts +37 -0
- package/dist/src/harness/opencode/backend.js +114 -0
- package/dist/src/harness/opencode/backend.js.map +1 -0
- package/dist/src/harness/opencode/capabilities.d.ts +8 -0
- package/dist/src/harness/opencode/capabilities.js +11 -0
- package/dist/src/harness/opencode/capabilities.js.map +1 -0
- package/dist/src/harness/opencode/client.d.ts +70 -0
- package/dist/src/harness/opencode/client.js +189 -0
- package/dist/src/harness/opencode/client.js.map +1 -0
- package/dist/src/harness/opencode/index.d.ts +13 -0
- package/dist/src/harness/opencode/index.js +19 -0
- package/dist/src/harness/opencode/index.js.map +1 -0
- package/dist/src/harness/opencode/lines.d.ts +14 -0
- package/dist/src/harness/opencode/lines.js +99 -0
- package/dist/src/harness/opencode/lines.js.map +1 -0
- package/dist/src/harness/opencode/map.d.ts +13 -0
- package/dist/src/harness/opencode/map.js +84 -0
- package/dist/src/harness/opencode/map.js.map +1 -0
- package/dist/src/harness/opencode/turn.d.ts +23 -0
- package/dist/src/harness/opencode/turn.js +143 -0
- package/dist/src/harness/opencode/turn.js.map +1 -0
- package/dist/src/harness/reclaim.d.ts +13 -0
- package/dist/src/harness/reclaim.js +18 -0
- package/dist/src/harness/reclaim.js.map +1 -0
- package/dist/src/harness/stub/backend.d.ts +11 -0
- package/dist/src/harness/stub/backend.js +125 -0
- package/dist/src/harness/stub/backend.js.map +1 -0
- package/dist/src/harness/stub/index.d.ts +18 -0
- package/dist/src/harness/stub/index.js +21 -0
- package/dist/src/harness/stub/index.js.map +1 -0
- package/dist/src/harness/stub/workspace.d.ts +29 -0
- package/dist/src/harness/stub/workspace.js +92 -0
- package/dist/src/harness/stub/workspace.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/runs/agents.d.ts +10 -0
- package/dist/src/runs/agents.js +49 -0
- package/dist/src/runs/agents.js.map +1 -0
- package/dist/src/runs/control.d.ts +31 -0
- package/dist/src/runs/control.js +105 -0
- package/dist/src/runs/control.js.map +1 -0
- package/dist/src/runs/index.d.ts +8 -0
- package/dist/src/runs/index.js +7 -0
- package/dist/src/runs/index.js.map +1 -0
- package/dist/src/runs/ports.d.ts +31 -0
- package/dist/src/runs/ports.js +5 -0
- package/dist/src/runs/ports.js.map +1 -0
- package/dist/src/runs/scan.d.ts +38 -0
- package/dist/src/runs/scan.js +149 -0
- package/dist/src/runs/scan.js.map +1 -0
- package/dist/src/runs/service.d.ts +70 -0
- package/dist/src/runs/service.js +239 -0
- package/dist/src/runs/service.js.map +1 -0
- package/dist/src/sandbox/harness-session.d.ts +11 -0
- package/dist/src/sandbox/harness-session.js +170 -0
- package/dist/src/sandbox/harness-session.js.map +1 -0
- package/dist/src/sandbox/host-command.d.ts +19 -0
- package/dist/src/sandbox/host-command.js +41 -0
- package/dist/src/sandbox/host-command.js.map +1 -0
- package/dist/src/sandbox/index.d.ts +11 -0
- package/dist/src/sandbox/index.js +15 -0
- package/dist/src/sandbox/index.js.map +1 -0
- package/dist/src/sandbox/naming.d.ts +49 -0
- package/dist/src/sandbox/naming.js +106 -0
- package/dist/src/sandbox/naming.js.map +1 -0
- package/dist/src/sandbox/openshell-client.d.ts +81 -0
- package/dist/src/sandbox/openshell-client.js +49 -0
- package/dist/src/sandbox/openshell-client.js.map +1 -0
- package/dist/src/sandbox/policy.d.ts +26 -0
- package/dist/src/sandbox/policy.js +100 -0
- package/dist/src/sandbox/policy.js.map +1 -0
- package/dist/src/sandbox/run-sandbox.d.ts +38 -0
- package/dist/src/sandbox/run-sandbox.js +247 -0
- package/dist/src/sandbox/run-sandbox.js.map +1 -0
- package/dist/src/sandbox/run-sandboxes.d.ts +18 -0
- package/dist/src/sandbox/run-sandboxes.js +225 -0
- package/dist/src/sandbox/run-sandboxes.js.map +1 -0
- package/dist/src/sandbox/timeout.d.ts +12 -0
- package/dist/src/sandbox/timeout.js +39 -0
- package/dist/src/sandbox/timeout.js.map +1 -0
- package/dist/src/sandbox/types.d.ts +125 -0
- package/dist/src/sandbox/types.js +15 -0
- package/dist/src/sandbox/types.js.map +1 -0
- package/dist/src/sandbox/worktree.d.ts +72 -0
- package/dist/src/sandbox/worktree.js +157 -0
- package/dist/src/sandbox/worktree.js.map +1 -0
- package/dist/src/store/derive.d.ts +39 -0
- package/dist/src/store/derive.js +68 -0
- package/dist/src/store/derive.js.map +1 -0
- package/dist/src/store/event-log.d.ts +79 -0
- package/dist/src/store/event-log.js +202 -0
- package/dist/src/store/event-log.js.map +1 -0
- package/dist/src/store/files.d.ts +51 -0
- package/dist/src/store/files.js +103 -0
- package/dist/src/store/files.js.map +1 -0
- package/dist/src/store/index.d.ts +15 -0
- package/dist/src/store/index.js +11 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/store/liveness.d.ts +61 -0
- package/dist/src/store/liveness.js +150 -0
- package/dist/src/store/liveness.js.map +1 -0
- package/dist/src/store/run-store.d.ts +67 -0
- package/dist/src/store/run-store.js +211 -0
- package/dist/src/store/run-store.js.map +1 -0
- package/dist/src/util/sequence.d.ts +58 -0
- package/dist/src/util/sequence.js +119 -0
- package/dist/src/util/sequence.js.map +1 -0
- package/dist/src/worker/control.d.ts +60 -0
- package/dist/src/worker/control.js +205 -0
- package/dist/src/worker/control.js.map +1 -0
- package/dist/src/worker/delivery.d.ts +17 -0
- package/dist/src/worker/delivery.js +43 -0
- package/dist/src/worker/delivery.js.map +1 -0
- package/dist/src/worker/driver.d.ts +88 -0
- package/dist/src/worker/driver.js +6 -0
- package/dist/src/worker/driver.js.map +1 -0
- package/dist/src/worker/fake-driver.d.ts +65 -0
- package/dist/src/worker/fake-driver.js +123 -0
- package/dist/src/worker/fake-driver.js.map +1 -0
- package/dist/src/worker/index.d.ts +15 -0
- package/dist/src/worker/index.js +11 -0
- package/dist/src/worker/index.js.map +1 -0
- package/dist/src/worker/main.d.ts +1 -0
- package/dist/src/worker/main.js +57 -0
- package/dist/src/worker/main.js.map +1 -0
- package/dist/src/worker/retained.d.ts +13 -0
- package/dist/src/worker/retained.js +40 -0
- package/dist/src/worker/retained.js.map +1 -0
- package/dist/src/worker/run-loop.d.ts +63 -0
- package/dist/src/worker/run-loop.js +325 -0
- package/dist/src/worker/run-loop.js.map +1 -0
- package/dist/src/worker/spawn.d.ts +68 -0
- package/dist/src/worker/spawn.js +201 -0
- package/dist/src/worker/spawn.js.map +1 -0
- package/image/Dockerfile +81 -0
- package/image/build.sh +62 -0
- package/image/pnpm-shim.sh +25 -0
- package/package.json +54 -4
- package/policy/profiles/culture-agents-claude-subscription.yaml +59 -0
- package/policy/profiles/culture-agents-local-gateway.yaml +49 -0
- package/policy/run-sandbox.policy.json +10 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Agent, AgentList } from "./agent.js";
|
|
2
|
+
import type { Allowlist } from "./allowlist.js";
|
|
3
|
+
import type { Capabilities, CapabilityName, Capability, Deferred, CapabilitySet, CapabilitiesList } from "./capabilities.js";
|
|
4
|
+
import type { Common, MeshNode, Suffix, MeshId, Ulid, RunId, SessionId, ActionId, HarnessId, Timestamp, NullableTimestamp, RepoPath, IdempotencyKey, Cursor, ApiVersion, CallerText, GitSha, Principal, Extension } from "./common.js";
|
|
5
|
+
import type { ControlAction, ActionKind, ActionRecord, SubmitRequest, SubmitResponse, SteerRequest, CancelRequest, PauseRequest, ResumeRequest, AnswerRequest, AcceptedResponse } from "./control-action.js";
|
|
6
|
+
import type { ErrorResponse, ErrorCode, ErrorBody } from "./error.js";
|
|
7
|
+
import type { RunEvent, EventKind, StateData, OutputData, ControlData, RefusedData, ErrorData, EventPage } from "./event.js";
|
|
8
|
+
import type { Run, RunState, ActiveState, TerminalState, RunList, RunResult } from "./run.js";
|
|
9
|
+
import type { Session } from "./session.js";
|
|
10
|
+
import type { Version } from "./version.js";
|
|
11
|
+
export type { Agent, AgentList } from "./agent.js";
|
|
12
|
+
export type { Allowlist } from "./allowlist.js";
|
|
13
|
+
export type { Capabilities, CapabilityName, Capability, Deferred, CapabilitySet, CapabilitiesList } from "./capabilities.js";
|
|
14
|
+
export type { Common, MeshNode, Suffix, MeshId, Ulid, RunId, SessionId, ActionId, HarnessId, Timestamp, NullableTimestamp, RepoPath, IdempotencyKey, Cursor, ApiVersion, CallerText, GitSha, Principal, Extension } from "./common.js";
|
|
15
|
+
export type { ControlAction, ActionKind, ActionRecord, SubmitRequest, SubmitResponse, SteerRequest, CancelRequest, PauseRequest, ResumeRequest, AnswerRequest, AcceptedResponse } from "./control-action.js";
|
|
16
|
+
export type { ErrorResponse, ErrorCode, ErrorBody } from "./error.js";
|
|
17
|
+
export type { RunEvent, EventKind, StateData, OutputData, ControlData, RefusedData, ErrorData, EventPage } from "./event.js";
|
|
18
|
+
export type { Run, RunState, ActiveState, TerminalState, RunList, RunResult } from "./run.js";
|
|
19
|
+
export type { Session } from "./session.js";
|
|
20
|
+
export type { Version } from "./version.js";
|
|
21
|
+
/** Schema target (`<file stem>` or `<file stem>#<$defs name>`) to its payload type. */
|
|
22
|
+
export interface SchemaTypes {
|
|
23
|
+
"agent": Agent;
|
|
24
|
+
"agent#agent_list": AgentList;
|
|
25
|
+
"allowlist": Allowlist;
|
|
26
|
+
"capabilities": Capabilities;
|
|
27
|
+
"capabilities#capability_name": CapabilityName;
|
|
28
|
+
"capabilities#capability": Capability;
|
|
29
|
+
"capabilities#deferred": Deferred;
|
|
30
|
+
"capabilities#capability_set": CapabilitySet;
|
|
31
|
+
"capabilities#capabilities_list": CapabilitiesList;
|
|
32
|
+
"common": Common;
|
|
33
|
+
"common#node": MeshNode;
|
|
34
|
+
"common#suffix": Suffix;
|
|
35
|
+
"common#mesh_id": MeshId;
|
|
36
|
+
"common#ulid": Ulid;
|
|
37
|
+
"common#run_id": RunId;
|
|
38
|
+
"common#session_id": SessionId;
|
|
39
|
+
"common#action_id": ActionId;
|
|
40
|
+
"common#harness_id": HarnessId;
|
|
41
|
+
"common#timestamp": Timestamp;
|
|
42
|
+
"common#nullable_timestamp": NullableTimestamp;
|
|
43
|
+
"common#repo_path": RepoPath;
|
|
44
|
+
"common#idempotency_key": IdempotencyKey;
|
|
45
|
+
"common#cursor": Cursor;
|
|
46
|
+
"common#api_version": ApiVersion;
|
|
47
|
+
"common#text": CallerText;
|
|
48
|
+
"common#git_sha": GitSha;
|
|
49
|
+
"common#principal": Principal;
|
|
50
|
+
"common#extension": Extension;
|
|
51
|
+
"control-action": ControlAction;
|
|
52
|
+
"control-action#action_kind": ActionKind;
|
|
53
|
+
"control-action#action_record": ActionRecord;
|
|
54
|
+
"control-action#submit_request": SubmitRequest;
|
|
55
|
+
"control-action#submit_response": SubmitResponse;
|
|
56
|
+
"control-action#steer_request": SteerRequest;
|
|
57
|
+
"control-action#cancel_request": CancelRequest;
|
|
58
|
+
"control-action#pause_request": PauseRequest;
|
|
59
|
+
"control-action#resume_request": ResumeRequest;
|
|
60
|
+
"control-action#answer_request": AnswerRequest;
|
|
61
|
+
"control-action#accepted_response": AcceptedResponse;
|
|
62
|
+
"error": ErrorResponse;
|
|
63
|
+
"error#code": ErrorCode;
|
|
64
|
+
"error#error": ErrorBody;
|
|
65
|
+
"event": RunEvent;
|
|
66
|
+
"event#kind": EventKind;
|
|
67
|
+
"event#state_data": StateData;
|
|
68
|
+
"event#output_data": OutputData;
|
|
69
|
+
"event#control_data": ControlData;
|
|
70
|
+
"event#refused_data": RefusedData;
|
|
71
|
+
"event#error_data": ErrorData;
|
|
72
|
+
"event#event_page": EventPage;
|
|
73
|
+
"run": Run;
|
|
74
|
+
"run#state": RunState;
|
|
75
|
+
"run#active_state": ActiveState;
|
|
76
|
+
"run#terminal_state": TerminalState;
|
|
77
|
+
"run#run_list": RunList;
|
|
78
|
+
"run#run_result": RunResult;
|
|
79
|
+
"session": Session;
|
|
80
|
+
"version": Version;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/contract/generated/index.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CallerText, Cursor, Extension, GitSha, HarnessId, IdempotencyKey, MeshId, NullableTimestamp, Principal, RepoPath, RunId, SessionId, Timestamp } from "./common.js";
|
|
2
|
+
import type { ErrorBody } from "./error.js";
|
|
3
|
+
/** One submitted unit of work executed by one agent through one harness. State is authoritative only as read from the run's on-disk event log or its live worker (README: state machine, restart). */
|
|
4
|
+
export type Run = {
|
|
5
|
+
id: RunId;
|
|
6
|
+
agent_id: MeshId;
|
|
7
|
+
session_id: SessionId;
|
|
8
|
+
harness: HarnessId;
|
|
9
|
+
repo: RepoPath;
|
|
10
|
+
task: CallerText;
|
|
11
|
+
/** The principal that submitted the run (the submit request's caller). */
|
|
12
|
+
owner: Principal;
|
|
13
|
+
idempotency_key: IdempotencyKey | null;
|
|
14
|
+
deadline: NullableTimestamp;
|
|
15
|
+
state: RunState;
|
|
16
|
+
/** Human-readable reason for the current state, or null. */
|
|
17
|
+
state_reason: string | null;
|
|
18
|
+
terminal: boolean;
|
|
19
|
+
created_at: Timestamp;
|
|
20
|
+
updated_at: Timestamp;
|
|
21
|
+
/** When the harness session started; null until the run first enters `running`. */
|
|
22
|
+
started_at: NullableTimestamp;
|
|
23
|
+
ended_at: NullableTimestamp;
|
|
24
|
+
/** Cursor of the newest event in the run's event log. */
|
|
25
|
+
cursor: Cursor;
|
|
26
|
+
/** True when this core can deliver steer and cancel to the run's worker. False for every terminal run and for a run whose worker survived a core restart (D1 cannot reconnect). */
|
|
27
|
+
live_control: boolean;
|
|
28
|
+
/** PID of the run's worker process, or null once no worker is known. */
|
|
29
|
+
worker_pid: number | null;
|
|
30
|
+
/** Host branch holding the run's commits, `runs/<run_id>`, or null when there are none yet. At most 132 characters: `runs/` and a run id of at most 127. */
|
|
31
|
+
branch: string | null;
|
|
32
|
+
extension?: Extension;
|
|
33
|
+
};
|
|
34
|
+
/** Run state. Legal transitions are in api.json `state_machine` and README. */
|
|
35
|
+
export type RunState = "queued" | "running" | "cancelling" | "succeeded" | "failed" | "cancelled" | "timed_out" | "unknown";
|
|
36
|
+
export type ActiveState = "queued" | "running" | "cancelling";
|
|
37
|
+
export type TerminalState = "succeeded" | "failed" | "cancelled" | "timed_out" | "unknown";
|
|
38
|
+
/** Response of GET /v1/runs: newest first by created_at. */
|
|
39
|
+
export type RunList = {
|
|
40
|
+
runs: Run[];
|
|
41
|
+
};
|
|
42
|
+
/** Response of GET /v1/runs/{run_id}/result; only served for a terminal run. */
|
|
43
|
+
export type RunResult = {
|
|
44
|
+
run_id: RunId;
|
|
45
|
+
state: TerminalState;
|
|
46
|
+
/** The harness's final assistant text, or null if it produced none. */
|
|
47
|
+
summary: string | null;
|
|
48
|
+
branch: string | null;
|
|
49
|
+
/** Commits on `branch`, oldest first. Empty when there are none. */
|
|
50
|
+
commits: GitSha[];
|
|
51
|
+
ended_at: Timestamp;
|
|
52
|
+
error: ErrorBody | null;
|
|
53
|
+
} & (({
|
|
54
|
+
state: "failed";
|
|
55
|
+
} & {
|
|
56
|
+
error: ErrorBody;
|
|
57
|
+
}) | ({
|
|
58
|
+
state: "succeeded";
|
|
59
|
+
} & {
|
|
60
|
+
error: null;
|
|
61
|
+
}) | ({
|
|
62
|
+
state: Exclude<TerminalState, "failed" | "succeeded">;
|
|
63
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../src/contract/generated/run.ts"],"names":[],"mappings":"AAAA,wFAAwF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HarnessId, MeshId, NullableTimestamp, RunId, SessionId, Timestamp } from "./common.js";
|
|
2
|
+
/** A harness conversation that one or more runs execute in. In D1 every submit opens a new session holding exactly that run, and the session closes when the run reaches a terminal state; continuing a session is the deferred capability `continue_session`. */
|
|
3
|
+
export type Session = {
|
|
4
|
+
id: SessionId;
|
|
5
|
+
agent_id: MeshId;
|
|
6
|
+
harness: HarnessId;
|
|
7
|
+
/** Runs in this session, oldest first. */
|
|
8
|
+
run_ids: RunId[];
|
|
9
|
+
state: "open" | "closed";
|
|
10
|
+
created_at: Timestamp;
|
|
11
|
+
closed_at: NullableTimestamp;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/contract/generated/session.ts"],"names":[],"mappings":"AAAA,4FAA4F"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiVersion, MeshNode } from "./common.js";
|
|
2
|
+
/** Response of GET /v1/version, the first call a client makes on connect (README: versioning). */
|
|
3
|
+
export type Version = {
|
|
4
|
+
api_version: ApiVersion;
|
|
5
|
+
/** The core package's own release version (semver); informational, never used for compatibility. */
|
|
6
|
+
core_version: string;
|
|
7
|
+
/** The node this core runs on; the `<node>` of every agent it can execute in D1. */
|
|
8
|
+
node: MeshNode;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/contract/generated/version.ts"],"names":[],"mappings":"AAAA,4FAA4F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ActionId, MeshId, RunId, SessionId } from "./generated/index.js";
|
|
2
|
+
export type ScopedKind = "run" | "ses" | "act";
|
|
3
|
+
export interface MeshIdParts {
|
|
4
|
+
node: string;
|
|
5
|
+
/** The agent suffix (culture.yaml `suffix`). */
|
|
6
|
+
agent: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ScopedIdParts extends MeshIdParts {
|
|
9
|
+
kind: ScopedKind;
|
|
10
|
+
/** `<node>-<agent>`, the executing agent. */
|
|
11
|
+
agentId: MeshId;
|
|
12
|
+
ulid: string;
|
|
13
|
+
}
|
|
14
|
+
/** Build a mesh id `<node>-<agent>`; throws if either part breaks its pattern. */
|
|
15
|
+
export declare function buildMeshId(node: string, agent: string): MeshId;
|
|
16
|
+
/** Split a mesh id at its first hyphen (the node has no hyphen); null when it does not match. */
|
|
17
|
+
export declare function parseMeshId(id: string): MeshIdParts | null;
|
|
18
|
+
/** `<node>-<agent>.run.<ULID>`, where the agent is the executing agent's mesh id. */
|
|
19
|
+
export declare const buildRunId: (agentId: string, ulid: string) => RunId;
|
|
20
|
+
/** `<node>-<agent>.ses.<ULID>`. */
|
|
21
|
+
export declare const buildSessionId: (agentId: string, ulid: string) => SessionId;
|
|
22
|
+
/** `<node>-<agent>.act.<ULID>`, using the run's agent. */
|
|
23
|
+
export declare const buildActionId: (agentId: string, ulid: string) => ActionId;
|
|
24
|
+
/** Parse a run, session or action id; null when it matches none of the documented forms. */
|
|
25
|
+
export declare function parseScopedId(id: string): ScopedIdParts | null;
|
|
26
|
+
export declare const isRunId: (id: string) => id is RunId;
|
|
27
|
+
export declare const isSessionId: (id: string) => id is SessionId;
|
|
28
|
+
export declare const isActionId: (id: string) => id is ActionId;
|
|
29
|
+
/** A run's host branch: `runs/<run_id>`. */
|
|
30
|
+
export declare function runBranch(runId: RunId): string;
|
|
31
|
+
/**
|
|
32
|
+
* A fresh ULID (48-bit millisecond time, 80 random bits). Not monotonic within one
|
|
33
|
+
* millisecond; ids are assigned by the core and never reused, and 80 random bits make a
|
|
34
|
+
* collision negligible.
|
|
35
|
+
*/
|
|
36
|
+
export declare function newUlid(timeMs?: number): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
// Patterns mirror contract/common.json (the schemas stay authoritative: a test asserts
|
|
3
|
+
// these agree with the `pattern` of the matching $defs on every documented example).
|
|
4
|
+
const NODE = /^[a-z0-9]{1,32}$/;
|
|
5
|
+
const SUFFIX = /^[a-z0-9_]+(-[a-z0-9_]+)*$/;
|
|
6
|
+
const ULID = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
7
|
+
const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
8
|
+
/** Build a mesh id `<node>-<agent>`; throws if either part breaks its pattern. */
|
|
9
|
+
export function buildMeshId(node, agent) {
|
|
10
|
+
if (!NODE.test(node))
|
|
11
|
+
throw new RangeError(`invalid node: ${JSON.stringify(node)}`);
|
|
12
|
+
if (!SUFFIX.test(agent))
|
|
13
|
+
throw new RangeError(`invalid agent suffix: ${JSON.stringify(agent)}`);
|
|
14
|
+
const id = `${node}-${agent}`;
|
|
15
|
+
if (id.length > 96)
|
|
16
|
+
throw new RangeError("mesh id is longer than 96 characters");
|
|
17
|
+
return id;
|
|
18
|
+
}
|
|
19
|
+
/** Split a mesh id at its first hyphen (the node has no hyphen); null when it does not match. */
|
|
20
|
+
export function parseMeshId(id) {
|
|
21
|
+
const cut = id.indexOf("-");
|
|
22
|
+
if (cut < 1 || id.length > 96)
|
|
23
|
+
return null;
|
|
24
|
+
const node = id.slice(0, cut);
|
|
25
|
+
const agent = id.slice(cut + 1);
|
|
26
|
+
return NODE.test(node) && SUFFIX.test(agent) ? { node, agent } : null;
|
|
27
|
+
}
|
|
28
|
+
function build(kind, agentId, ulid) {
|
|
29
|
+
if (parseMeshId(agentId) === null)
|
|
30
|
+
throw new RangeError(`invalid agent id: ${JSON.stringify(agentId)}`);
|
|
31
|
+
if (!ULID.test(ulid))
|
|
32
|
+
throw new RangeError(`invalid ULID: ${JSON.stringify(ulid)}`);
|
|
33
|
+
return `${agentId}.${kind}.${ulid}`;
|
|
34
|
+
}
|
|
35
|
+
/** `<node>-<agent>.run.<ULID>`, where the agent is the executing agent's mesh id. */
|
|
36
|
+
export const buildRunId = (agentId, ulid) => build("run", agentId, ulid);
|
|
37
|
+
/** `<node>-<agent>.ses.<ULID>`. */
|
|
38
|
+
export const buildSessionId = (agentId, ulid) => build("ses", agentId, ulid);
|
|
39
|
+
/** `<node>-<agent>.act.<ULID>`, using the run's agent. */
|
|
40
|
+
export const buildActionId = (agentId, ulid) => build("act", agentId, ulid);
|
|
41
|
+
/** Parse a run, session or action id; null when it matches none of the documented forms. */
|
|
42
|
+
export function parseScopedId(id) {
|
|
43
|
+
const m = /^(.+)\.(run|ses|act)\.([^.]+)$/.exec(id);
|
|
44
|
+
if (!m)
|
|
45
|
+
return null;
|
|
46
|
+
const agentId = m[1];
|
|
47
|
+
const ulid = m[3];
|
|
48
|
+
const mesh = parseMeshId(agentId);
|
|
49
|
+
if (mesh === null || !ULID.test(ulid))
|
|
50
|
+
return null;
|
|
51
|
+
return { ...mesh, kind: m[2], agentId, ulid };
|
|
52
|
+
}
|
|
53
|
+
const isKind = (kind) => (id) => parseScopedId(id)?.kind === kind;
|
|
54
|
+
export const isRunId = (id) => isKind("run")(id);
|
|
55
|
+
export const isSessionId = (id) => isKind("ses")(id);
|
|
56
|
+
export const isActionId = (id) => isKind("act")(id);
|
|
57
|
+
/** A run's host branch: `runs/<run_id>`. */
|
|
58
|
+
export function runBranch(runId) {
|
|
59
|
+
return `runs/${runId}`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A fresh ULID (48-bit millisecond time, 80 random bits). Not monotonic within one
|
|
63
|
+
* millisecond; ids are assigned by the core and never reused, and 80 random bits make a
|
|
64
|
+
* collision negligible.
|
|
65
|
+
*/
|
|
66
|
+
export function newUlid(timeMs = Date.now()) {
|
|
67
|
+
if (!Number.isInteger(timeMs) || timeMs < 0 || timeMs >= 2 ** 48)
|
|
68
|
+
throw new RangeError("ULID time out of range");
|
|
69
|
+
let out = "";
|
|
70
|
+
let t = timeMs;
|
|
71
|
+
for (let i = 0; i < 10; i++) {
|
|
72
|
+
out = CROCKFORD[t % 32] + out;
|
|
73
|
+
t = Math.floor(t / 32);
|
|
74
|
+
}
|
|
75
|
+
const rand = randomBytes(10);
|
|
76
|
+
let bits = 0n;
|
|
77
|
+
for (const b of rand)
|
|
78
|
+
bits = (bits << 8n) | BigInt(b);
|
|
79
|
+
for (let i = 0; i < 16; i++) {
|
|
80
|
+
out += CROCKFORD[Number(bits & 31n)];
|
|
81
|
+
bits >>= 5n;
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/contract/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,uFAAuF;AACvF,qFAAqF;AACrF,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAChC,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAC5C,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAiBrD,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,KAAa;IACrD,IAAI,CAAC,IAAI,CAAC,IAAI,CA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AC,IAAI,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;QACrC,IAAI,KAAK,EAAE,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contract module: types, validation and small rules for the control-plane API.
|
|
3
|
+
* Types are generated from contract/*.json (`npm run gen:contract`); validation reads the
|
|
4
|
+
* same schema files. See contract/README.md for the semantics.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./generated/index.js";
|
|
7
|
+
export { SCHEMA_BASE, loadSchemaFiles, schemaDir } from "./schemas.js";
|
|
8
|
+
export type { SchemaDocument } from "./schemas.js";
|
|
9
|
+
export { ContractValidationError } from "./errors.js";
|
|
10
|
+
export type { ValidationIssue } from "./errors.js";
|
|
11
|
+
export { assertValid, schemaNames, validate } from "./validate.js";
|
|
12
|
+
export type { SchemaName, ValidationResult } from "./validate.js";
|
|
13
|
+
export { API_VERSION_HEADER, apiVersion, errorCodes, exitCodeFor, httpStatusFor, isCompatible, parseApiVersion, retryableFor, } from "./api.js";
|
|
14
|
+
export type { ApiVersion } from "./api.js";
|
|
15
|
+
export { canTransition, initialState, isActive, isTerminal, nextStates, runStates } from "./run-state.js";
|
|
16
|
+
export { buildActionId, buildMeshId, buildRunId, buildSessionId, isActionId, isRunId, isSessionId, newUlid, parseMeshId, parseScopedId, runBranch, } from "./ids.js";
|
|
17
|
+
export type { MeshIdParts, ScopedIdParts, ScopedKind } from "./ids.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contract module: types, validation and small rules for the control-plane API.
|
|
3
|
+
* Types are generated from contract/*.json (`npm run gen:contract`); validation reads the
|
|
4
|
+
* same schema files. See contract/README.md for the semantics.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./generated/index.js";
|
|
7
|
+
export { SCHEMA_BASE, loadSchemaFiles, schemaDir } from "./schemas.js";
|
|
8
|
+
export { ContractValidationError } from "./errors.js";
|
|
9
|
+
export { assertValid, schemaNames, validate } from "./validate.js";
|
|
10
|
+
export { API_VERSION_HEADER, apiVersion, errorCodes, exitCodeFor, httpStatusFor, isCompatible, parseApiVersion, retryableFor, } from "./api.js";
|
|
11
|
+
export { canTransition, initialState, isActive, isTerminal, nextStates, runStates } from "./run-state.js";
|
|
12
|
+
export { buildActionId, buildMeshId, buildRunId, buildSessionId, isActionId, isRunId, isSessionId, newUlid, parseMeshId, parseScopedId, runBranch, } from "./ids.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,EACX,aAAa,EACb,SAAS,GACV,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RunState } from "./generated/index.js";
|
|
2
|
+
/** The state of a run's first event (`null` -> `queued`). */
|
|
3
|
+
export declare const initialState: RunState;
|
|
4
|
+
/** Every run state. */
|
|
5
|
+
export declare const runStates: RunState[];
|
|
6
|
+
/** Terminal states are final: no event follows and nothing changes them. */
|
|
7
|
+
export declare function isTerminal(state: RunState): boolean;
|
|
8
|
+
/** Active states: `queued`, `running`, `cancelling`. */
|
|
9
|
+
export declare function isActive(state: RunState): boolean;
|
|
10
|
+
/** States reachable from `from` in one step; `null` means "no state yet" and allows only `queued`. */
|
|
11
|
+
export declare function nextStates(from: RunState | null): readonly RunState[];
|
|
12
|
+
/** Whether `from` -> `to` is a legal transition (`from` is `null` for a run's first event). */
|
|
13
|
+
export declare function canTransition(from: RunState | null, to: RunState): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { api } from "./api.js";
|
|
2
|
+
/** The state of a run's first event (`null` -> `queued`). */
|
|
3
|
+
export const initialState = api.state_machine.initial;
|
|
4
|
+
/** Every run state. */
|
|
5
|
+
export const runStates = Object.keys(api.state_machine.transitions);
|
|
6
|
+
const terminal = new Set(api.state_machine.terminal);
|
|
7
|
+
const active = new Set(api.state_machine.active);
|
|
8
|
+
/** Terminal states are final: no event follows and nothing changes them. */
|
|
9
|
+
export function isTerminal(state) {
|
|
10
|
+
return terminal.has(state);
|
|
11
|
+
}
|
|
12
|
+
/** Active states: `queued`, `running`, `cancelling`. */
|
|
13
|
+
export function isActive(state) {
|
|
14
|
+
return active.has(state);
|
|
15
|
+
}
|
|
16
|
+
/** States reachable from `from` in one step; `null` means "no state yet" and allows only `queued`. */
|
|
17
|
+
export function nextStates(from) {
|
|
18
|
+
return from === null ? [initialState] : api.state_machine.transitions[from];
|
|
19
|
+
}
|
|
20
|
+
/** Whether `from` -> `to` is a legal transition (`from` is `null` for a run's first event). */
|
|
21
|
+
export function canTransition(from, to) {
|
|
22
|
+
return nextStates(from).includes(to);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=run-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../../src/contract/run-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAa,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC;AAEhE,uBAAuB;AACvB,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAe,CAAC;AAElF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAW,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AAC/D,MAAM,MAAM,GAAG,IAAI,GAAG,CAAW,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAE3D,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,KAAe;IACxC,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,QAAQ,CAAC,KAAe;IACtC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,IAAqB;IAC9C,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,IAAqB,EAAE,EAAY;IAC/D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Base of every schema `$id` (api.json `schema_base`). An identifier only, never fetched. */
|
|
2
|
+
export declare const SCHEMA_BASE = "https://culture.dev/contract/agents/";
|
|
3
|
+
/**
|
|
4
|
+
* Where the schema files live at run time: `dist/contract-schemas/`, populated from the
|
|
5
|
+
* repo's `contract/` directory by the build (scripts/copy-contract-schemas.mjs) and shipped
|
|
6
|
+
* in the npm package. Resolved relative to the compiled module, so it works from a checkout
|
|
7
|
+
* and from an installed package alike. Override with `CULTURE_AGENTS_CONTRACT_DIR` (tests,
|
|
8
|
+
* or running straight against `contract/`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function schemaDir(): URL;
|
|
11
|
+
/** A parsed JSON Schema document. */
|
|
12
|
+
export type SchemaDocument = Record<string, unknown> & {
|
|
13
|
+
$id: string;
|
|
14
|
+
};
|
|
15
|
+
/** Every schema file (all `contract/*.json` except the `api.json` index), by file name. */
|
|
16
|
+
export declare function loadSchemaFiles(dir?: URL): Map<string, SchemaDocument>;
|
|
17
|
+
/** Parse one JSON file from the schema directory (used for `api.json`). */
|
|
18
|
+
export declare function loadJson(file: string, dir?: URL): unknown;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
/** Base of every schema `$id` (api.json `schema_base`). An identifier only, never fetched. */
|
|
3
|
+
export const SCHEMA_BASE = "https://culture.dev/contract/agents/";
|
|
4
|
+
/**
|
|
5
|
+
* Where the schema files live at run time: `dist/contract-schemas/`, populated from the
|
|
6
|
+
* repo's `contract/` directory by the build (scripts/copy-contract-schemas.mjs) and shipped
|
|
7
|
+
* in the npm package. Resolved relative to the compiled module, so it works from a checkout
|
|
8
|
+
* and from an installed package alike. Override with `CULTURE_AGENTS_CONTRACT_DIR` (tests,
|
|
9
|
+
* or running straight against `contract/`).
|
|
10
|
+
*/
|
|
11
|
+
export function schemaDir() {
|
|
12
|
+
const override = process.env["CULTURE_AGENTS_CONTRACT_DIR"];
|
|
13
|
+
if (override)
|
|
14
|
+
return new URL(`file://${override.replace(/\/?$/, "/")}`);
|
|
15
|
+
return new URL("../../contract-schemas/", import.meta.url);
|
|
16
|
+
}
|
|
17
|
+
/** Code-unit order: the order `sort()` uses when it is given no comparator. */
|
|
18
|
+
function byCodeUnit(a, b) {
|
|
19
|
+
if (a < b)
|
|
20
|
+
return -1;
|
|
21
|
+
return a > b ? 1 : 0;
|
|
22
|
+
}
|
|
23
|
+
/** Every schema file (all `contract/*.json` except the `api.json` index), by file name. */
|
|
24
|
+
export function loadSchemaFiles(dir = schemaDir()) {
|
|
25
|
+
const out = new Map();
|
|
26
|
+
for (const file of readdirSync(dir).sort(byCodeUnit)) {
|
|
27
|
+
if (!file.endsWith(".json") || file === "api.json")
|
|
28
|
+
continue;
|
|
29
|
+
out.set(file, JSON.parse(readFileSync(new URL(file, dir), "utf8")));
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** Parse one JSON file from the schema directory (used for `api.json`). */
|
|
34
|
+
export function loadJson(file, dir = schemaDir()) {
|
|
35
|
+
return JSON.parse(readFileSync(new URL(file, dir), "utf8"));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/contract/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEpD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,sCAAsC,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC5D,IAAI,QAAQ;QAAE,OAAO,IAAI,GAAG,CAAC,UAAU,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACxE,OAAO,IAAI,GAAG,CAAC,yBAAyB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC;AAKD,+EAA+E;AAC/E,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,eAAe,CAAC,MAAW,SAAS,EAAE;IACpD,MAAM,GAAG,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,UAAU;YAAE,SAAS;QAC7D,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAmB,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,MAAW,SAAS,EAAE;IAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ValidationIssue } from "./errors.js";
|
|
2
|
+
import type { SchemaTypes } from "./generated/index.js";
|
|
3
|
+
/** A validation target: `<file stem>` (the file's root schema) or `<file stem>#<$defs name>`. */
|
|
4
|
+
export type SchemaName = keyof SchemaTypes;
|
|
5
|
+
export type ValidationResult<N extends SchemaName> = {
|
|
6
|
+
ok: true;
|
|
7
|
+
value: SchemaTypes[N];
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
issues: ValidationIssue[];
|
|
11
|
+
};
|
|
12
|
+
/** Validate `value` against a contract schema target, returning the typed value or the issues. */
|
|
13
|
+
export declare function validate<N extends SchemaName>(name: N, value: unknown): ValidationResult<N>;
|
|
14
|
+
/** Like `validate`, but throws `ContractValidationError` (code `invalid`, with the failing path). */
|
|
15
|
+
export declare function assertValid<N extends SchemaName>(name: N, value: unknown): SchemaTypes[N];
|
|
16
|
+
/** Every validation target, in schema order. */
|
|
17
|
+
export declare function schemaNames(): SchemaName[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
2
|
+
import { ContractValidationError } from "./errors.js";
|
|
3
|
+
import { SCHEMA_BASE, loadSchemaFiles } from "./schemas.js";
|
|
4
|
+
let ajv;
|
|
5
|
+
const compiled = new Map();
|
|
6
|
+
function instance() {
|
|
7
|
+
if (ajv)
|
|
8
|
+
return ajv;
|
|
9
|
+
// allErrors so a caller sees every violation; strict stays on except for the layered if/then subschemas, which
|
|
10
|
+
// deliberately omit `type` (constraints on an already-typed object).
|
|
11
|
+
const created = new Ajv2020({ allErrors: true, strict: true, strictRequired: false, strictTypes: false });
|
|
12
|
+
for (const schema of loadSchemaFiles().values())
|
|
13
|
+
created.addSchema(schema);
|
|
14
|
+
ajv = created;
|
|
15
|
+
return created;
|
|
16
|
+
}
|
|
17
|
+
function targetRef(name) {
|
|
18
|
+
const [stem, def] = name.split("#");
|
|
19
|
+
const fragment = def === undefined ? "" : `#/$defs/${def}`;
|
|
20
|
+
return `${SCHEMA_BASE}${stem}.json${fragment}`;
|
|
21
|
+
}
|
|
22
|
+
function validatorFor(name) {
|
|
23
|
+
let fn = compiled.get(name);
|
|
24
|
+
if (!fn) {
|
|
25
|
+
fn = instance().compile({ $ref: targetRef(name) });
|
|
26
|
+
compiled.set(name, fn);
|
|
27
|
+
}
|
|
28
|
+
return fn;
|
|
29
|
+
}
|
|
30
|
+
// Combinator keywords restate a failure found deeper; list the specific issues first.
|
|
31
|
+
const WRAPPERS = new Set(["if", "not", "anyOf", "oneOf", "allOf"]);
|
|
32
|
+
function toIssues(errors) {
|
|
33
|
+
const ordered = [...(errors ?? [])].sort((a, b) => Number(WRAPPERS.has(a.keyword)) - Number(WRAPPERS.has(b.keyword)));
|
|
34
|
+
return ordered.map((e) => {
|
|
35
|
+
let path = e.instancePath;
|
|
36
|
+
if (e.keyword === "required")
|
|
37
|
+
path += `/${String(e.params.missingProperty)}`;
|
|
38
|
+
if (e.keyword === "additionalProperties")
|
|
39
|
+
path += `/${String(e.params.additionalProperty)}`;
|
|
40
|
+
return { path, keyword: e.keyword, message: e.message ?? "invalid" };
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Validate `value` against a contract schema target, returning the typed value or the issues. */
|
|
44
|
+
export function validate(name, value) {
|
|
45
|
+
const fn = validatorFor(name);
|
|
46
|
+
if (fn(value))
|
|
47
|
+
return { ok: true, value: value };
|
|
48
|
+
return { ok: false, issues: toIssues(fn.errors) };
|
|
49
|
+
}
|
|
50
|
+
/** Like `validate`, but throws `ContractValidationError` (code `invalid`, with the failing path). */
|
|
51
|
+
export function assertValid(name, value) {
|
|
52
|
+
const result = validate(name, value);
|
|
53
|
+
if (!result.ok)
|
|
54
|
+
throw new ContractValidationError(name, result.issues);
|
|
55
|
+
return result.value;
|
|
56
|
+
}
|
|
57
|
+
/** Every validation target, in schema order. */
|
|
58
|
+
export function schemaNames() {
|
|
59
|
+
const names = [];
|
|
60
|
+
for (const [file, schema] of loadSchemaFiles()) {
|
|
61
|
+
const stem = file.replace(/\.json$/, "");
|
|
62
|
+
names.push(stem);
|
|
63
|
+
for (const def of Object.keys(schema["$defs"] ?? {}))
|
|
64
|
+
names.push(`${stem}#${def}`);
|
|
65
|
+
}
|
|
66
|
+
return names;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/contract/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EAAE,uBAAuB,EAAwB,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAS5D,IAAI,GAAwB,CAAC;AAC7B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;AAErD,SAAS,QAAQ;IACf,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,+GAA+G;IAC/G,qEAAqE;IACrE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1G,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3E,GAAG,GAAG,OAAO,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,EAAE,CAAC;IAC3D,OAAO,GAAG,WAAW,GAAG,IAAI,QAAQ,QAAQ,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,YAAY,CAAC,IAAgB;IACpC,IAAI,EAAE,GAAG,QAAQ,CAAC,GAAG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js";
|
|
2
|
+
/** Why the list is what it is, for a future `doctor` check. */
|
|
3
|
+
export type AllowlistStatus = "ok" | "missing" | "invalid" | "unreadable";
|
|
4
|
+
export interface AllowlistState {
|
|
5
|
+
path: string;
|
|
6
|
+
status: AllowlistStatus;
|
|
7
|
+
/** Entries in force: empty unless status is `ok`. */
|
|
8
|
+
entries: Allowlist["entries"];
|
|
9
|
+
/** Human-readable cause when status is not `ok` or `missing`. */
|
|
10
|
+
detail: string | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read and validate the allow-list file. A missing file is an empty list; a file that does not validate
|
|
14
|
+
* (or cannot be read or parsed) also counts as empty and is reported through `status` (README: authorization).
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadAllowlist(path: string): AllowlistState;
|
|
17
|
+
/** Canonical (realpath) form of a repository path, or null when it cannot be resolved. */
|
|
18
|
+
export declare function canonicalRepo(repo: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Exact match of agent, harness and canonical repo against the entries. Entry repos are canonicalized
|
|
21
|
+
* the same way; there are no wildcards. Returns the request's canonical repo on a match, else null.
|
|
22
|
+
*/
|
|
23
|
+
export declare function matchAllowlist(entries: Allowlist["entries"], request: Pick<SubmitRequest, "agent_id" | "harness" | "repo">): string | null;
|