@harness-control/protocol 0.1.0

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.
Files changed (49) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +16 -0
  3. package/dist/bin/conformance.d.ts +3 -0
  4. package/dist/bin/conformance.js +11 -0
  5. package/dist/bin/generate-json-schema.d.ts +3 -0
  6. package/dist/bin/generate-json-schema.js +12 -0
  7. package/dist/conformance.d.ts +42 -0
  8. package/dist/conformance.js +217 -0
  9. package/dist/index.d.ts +6761 -0
  10. package/dist/index.js +1931 -0
  11. package/dist/json-schema.d.ts +19 -0
  12. package/dist/json-schema.js +128 -0
  13. package/dist/pairing.d.ts +59 -0
  14. package/dist/pairing.js +42 -0
  15. package/dist/session-reducer.d.ts +36 -0
  16. package/dist/session-reducer.js +96 -0
  17. package/fixtures/conformance/invalid/arbitrary-event-family.json +13 -0
  18. package/fixtures/conformance/invalid/local-action-lease-binding-mismatch.json +51 -0
  19. package/fixtures/conformance/invalid/local-action-missing-turn-id.json +21 -0
  20. package/fixtures/conformance/invalid/local-action-patch-missing-base-hash.json +53 -0
  21. package/fixtures/conformance/invalid/local-action-shell-missing-approval.json +56 -0
  22. package/fixtures/conformance/invalid/mcp-stdio-attachment.json +27 -0
  23. package/fixtures/conformance/invalid/session-snapshot-unsafe-omission.json +26 -0
  24. package/fixtures/conformance/invalid/terminal-turn-missing-final-output.json +16 -0
  25. package/fixtures/conformance/invalid/unknown-payload-field.json +14 -0
  26. package/fixtures/conformance/invalid/unknown-top-level-field.json +14 -0
  27. package/fixtures/conformance/valid/command-ack.json +11 -0
  28. package/fixtures/conformance/valid/extension-event.json +18 -0
  29. package/fixtures/conformance/valid/host-hello.json +22 -0
  30. package/fixtures/conformance/valid/host-replay-unavailable.json +15 -0
  31. package/fixtures/conformance/valid/local-action-dev-server-start.json +67 -0
  32. package/fixtures/conformance/valid/local-action-dev-server-stop.json +54 -0
  33. package/fixtures/conformance/valid/local-action-error.json +40 -0
  34. package/fixtures/conformance/valid/local-action-filesystem-list.json +54 -0
  35. package/fixtures/conformance/valid/local-action-filesystem-patch.json +55 -0
  36. package/fixtures/conformance/valid/local-action-filesystem-read.json +53 -0
  37. package/fixtures/conformance/valid/local-action-filesystem-write.json +55 -0
  38. package/fixtures/conformance/valid/local-action-git-diff.json +53 -0
  39. package/fixtures/conformance/valid/local-action-git-status.json +53 -0
  40. package/fixtures/conformance/valid/local-action-response.json +49 -0
  41. package/fixtures/conformance/valid/local-action-shell-exec.json +63 -0
  42. package/fixtures/conformance/valid/provider-event.json +18 -0
  43. package/fixtures/conformance/valid/session-snapshot-request.json +9 -0
  44. package/fixtures/conformance/valid/session-snapshot.json +28 -0
  45. package/fixtures/conformance/valid/session-start-with-leases.json +80 -0
  46. package/fixtures/conformance/valid/session-start-with-runner-stdio-profile.json +27 -0
  47. package/fixtures/conformance/valid/turn-completed.json +30 -0
  48. package/package.json +61 -0
  49. package/schemas/hcp-message.schema.json +18667 -0
@@ -0,0 +1,63 @@
1
+ {
2
+ "id": "message-local-shell-exec",
3
+ "type": "local.action.request",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "request_id": "local-action-shell-1",
8
+ "action": "local.shell.exec",
9
+ "issued_at": "2026-01-01T00:00:01.000Z",
10
+ "attribution": {
11
+ "session_id": "session-1",
12
+ "turn_id": "turn-1",
13
+ "workspace_id": "workspace-1",
14
+ "provider_instance_id": "provider-1",
15
+ "run_id": "run-1"
16
+ },
17
+ "lease": {
18
+ "lease_id": "local-lease-shell",
19
+ "capability_id": "shell",
20
+ "scope": "workspace",
21
+ "run_id": "run-1",
22
+ "hcp_session_id": "session-1",
23
+ "execution_host_id": "host-1",
24
+ "provider_instance_id": "provider-1",
25
+ "workspace_id": "workspace-1",
26
+ "expires_at": "2026-01-01T01:00:00.000Z"
27
+ },
28
+ "sandbox": {
29
+ "mode": "workspace_write",
30
+ "workspace_root": "/tmp/workspace",
31
+ "cwd": "/tmp/workspace",
32
+ "requires_workspace_containment": true
33
+ },
34
+ "approval": {
35
+ "status": "approved",
36
+ "request_id": "approval-1",
37
+ "action_hash": "sha256:action",
38
+ "decision": "accept",
39
+ "actor_id": "user-1",
40
+ "approved_at": "2026-01-01T00:00:02.000Z"
41
+ },
42
+ "output_limits": {
43
+ "stdout_bytes": 65536,
44
+ "stderr_bytes": 65536
45
+ },
46
+ "cancellation": {
47
+ "cancellable": true,
48
+ "timeout_ms": 60000,
49
+ "token": "cancel-shell-1"
50
+ },
51
+ "audit": {
52
+ "started_event_type": "local_capability.action.started",
53
+ "completed_event_type": "local_capability.action.completed",
54
+ "failed_event_type": "local_capability.action.failed"
55
+ },
56
+ "input": {
57
+ "executable": "npm",
58
+ "argv": ["test"],
59
+ "cwd": "/tmp/workspace",
60
+ "use_shell": false
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "id": "message-provider-event",
3
+ "type": "harness.event",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "session_id": "session-1",
8
+ "sequence": 2,
9
+ "event_type": "provider.codex.native_event",
10
+ "created_at": "2026-01-01T00:00:02.000Z",
11
+ "data": {
12
+ "summary": "Native provider event",
13
+ "fields": {
14
+ "provider_event_id": "evt-1"
15
+ }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "message-session-snapshot-request",
3
+ "type": "harness.session.snapshot.request",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "session_id": "session-1"
8
+ }
9
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "id": "message-session-snapshot",
3
+ "type": "harness.session.snapshot",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:01.000Z",
6
+ "payload": {
7
+ "command_id": "message-session-snapshot-request",
8
+ "session_id": "session-1",
9
+ "generated_at": "2026-01-01T00:00:01.000Z",
10
+ "completeness": "complete",
11
+ "omission_semantics": "replace",
12
+ "from_sequence": 1,
13
+ "through_sequence": 1,
14
+ "events": [
15
+ {
16
+ "session_id": "session-1",
17
+ "sequence": 1,
18
+ "event_type": "session.started",
19
+ "created_at": "2026-01-01T00:00:00.500Z",
20
+ "data": {
21
+ "provider_instance_id": "provider-1",
22
+ "workspace_id": "workspace-1"
23
+ }
24
+ }
25
+ ],
26
+ "tombstones": []
27
+ }
28
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "id": "message-session-start",
3
+ "type": "harness.session.start",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "session_id": "session-1",
8
+ "workspace_id": "workspace-1",
9
+ "provider_instance_id": "provider-1",
10
+ "driver_kind": "codex",
11
+ "cwd": "/tmp/workspace",
12
+ "sandbox_mode": "workspace_write",
13
+ "approval_policy": "ask",
14
+ "continue_session": false,
15
+ "model_selection": {
16
+ "model": "gpt-5.3-codex"
17
+ },
18
+ "workspace_preflight": {
19
+ "workspace_id": "workspace-1",
20
+ "expected_branch": "main",
21
+ "allow_dirty_worktree": true
22
+ },
23
+ "local_capability_lease": {
24
+ "lease_id": "local-lease-1",
25
+ "org_id": "org-1",
26
+ "actor_id": "user-1",
27
+ "workflow_id": "workflow-1",
28
+ "run_id": "run-1",
29
+ "node_id": "node-harness",
30
+ "hcp_session_id": "session-1",
31
+ "execution_host_id": "host-local",
32
+ "provider_instance_id": "provider-1",
33
+ "workspace_id": "workspace-1",
34
+ "issued_at": "2026-01-01T00:00:00.000Z",
35
+ "expires_at": "2026-01-01T01:00:00.000Z",
36
+ "policy_version": "policy-2026-01-01",
37
+ "capabilities": [
38
+ {
39
+ "id": "filesystem",
40
+ "scopes": ["workspace_read", "workspace_write"]
41
+ },
42
+ {
43
+ "id": "shell",
44
+ "scopes": ["workspace"],
45
+ "approval_policy": "ask",
46
+ "command_policy": {
47
+ "allowed_executables": ["npm"],
48
+ "denied_executables": ["rm"],
49
+ "cwd_policy": "selected_workspace_only",
50
+ "env_policy": "minimal",
51
+ "allow_shell": false,
52
+ "timeout_seconds": 60,
53
+ "network_policy": "inherit"
54
+ }
55
+ }
56
+ ]
57
+ },
58
+ "mcp_servers": [
59
+ {
60
+ "name": "linear",
61
+ "transport": "streamable_http",
62
+ "url": "https://example.com/mcp/linear",
63
+ "headers": {
64
+ "Authorization": "Bearer lease-token"
65
+ },
66
+ "lease_id": "mcp-lease-1",
67
+ "proof_of_possession": {
68
+ "scheme": "runner_signed_request",
69
+ "key_id": "proof-key-1",
70
+ "required_headers": [
71
+ "x-hcp-session-id",
72
+ "x-hcp-host-id",
73
+ "x-hcp-proof-signature",
74
+ "x-hcp-proof-nonce"
75
+ ]
76
+ }
77
+ }
78
+ ]
79
+ }
80
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "id": "message-runner-stdio-profile",
3
+ "type": "harness.session.start",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "session_id": "session-stdio-1",
8
+ "workspace_id": "workspace-1",
9
+ "provider_instance_id": "provider-1",
10
+ "driver_kind": "codex",
11
+ "cwd": "/tmp/workspace",
12
+ "sandbox_mode": "workspace_write",
13
+ "approval_policy": "ask",
14
+ "continue_session": false,
15
+ "model_selection": {
16
+ "model": "gpt-5.3-codex"
17
+ },
18
+ "mcp_servers": [
19
+ {
20
+ "name": "local-tools",
21
+ "transport": "runner_stdio_profile",
22
+ "profile_id": "sample-tools",
23
+ "allowed_tools": ["echo"]
24
+ }
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "id": "message-turn-completed",
3
+ "type": "harness.event",
4
+ "version": "hcp.v0",
5
+ "sent_at": "2026-01-01T00:00:00.000Z",
6
+ "payload": {
7
+ "session_id": "session-1",
8
+ "turn_id": "turn-1",
9
+ "sequence": 4,
10
+ "event_type": "turn.completed",
11
+ "created_at": "2026-01-01T00:00:04.000Z",
12
+ "data": {
13
+ "status": "accepted",
14
+ "final_output": {
15
+ "final_text": "Done.",
16
+ "changed_files": [
17
+ {
18
+ "path": "README.md",
19
+ "change_type": "modified"
20
+ }
21
+ ],
22
+ "usage": {
23
+ "input_tokens": 10,
24
+ "output_tokens": 5,
25
+ "total_tokens": 15
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@harness-control/protocol",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "hcp-protocol-conformance": "./dist/bin/conformance.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ },
16
+ "./conformance": {
17
+ "types": "./dist/conformance.d.ts",
18
+ "import": "./dist/conformance.js"
19
+ },
20
+ "./json-schema": {
21
+ "types": "./dist/json-schema.d.ts",
22
+ "import": "./dist/json-schema.js"
23
+ },
24
+ "./schema.json": {
25
+ "default": "./schemas/hcp-message.schema.json"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -b && npm run schema:generate",
31
+ "check": "tsc -b --pretty false",
32
+ "conformance": "tsx src/bin/conformance.ts --fixtures fixtures/conformance",
33
+ "schema:generate": "tsx src/bin/generate-json-schema.ts",
34
+ "test": "tsx --test src/**/*.test.ts test/**/*.test.ts"
35
+ },
36
+ "dependencies": {
37
+ "zod": "^4.4.3"
38
+ },
39
+ "description": "Types, validation, JSON Schema and reducers for Harness Control Protocol",
40
+ "engines": {
41
+ "node": ">=22"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/qazisaad/harness-control-protocol.git",
49
+ "directory": "packages/hcp-protocol"
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "!dist/**/*.test.*",
54
+ "!dist/**/test/**",
55
+ "!dist/**/*.map",
56
+ "README.md",
57
+ "LICENSE",
58
+ "schemas",
59
+ "fixtures/conformance"
60
+ ]
61
+ }