sealbridge 0.4.2 → 0.5.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 (115) hide show
  1. package/README.ja.md +4 -2
  2. package/README.md +6 -2
  3. package/dist/cli/dist/accept.d.ts +2 -1
  4. package/dist/cli/dist/accept.js +18 -7
  5. package/dist/cli/dist/accept.js.map +1 -1
  6. package/dist/cli/dist/index.js +46 -13
  7. package/dist/cli/dist/index.js.map +1 -1
  8. package/dist/cli/dist/invite-links.d.ts +14 -0
  9. package/dist/cli/dist/invite-links.js +263 -0
  10. package/dist/cli/dist/invite-links.js.map +1 -0
  11. package/dist/cli/dist/invite-output.d.ts +1 -1
  12. package/dist/cli/dist/invite-output.js +3 -2
  13. package/dist/cli/dist/invite-output.js.map +1 -1
  14. package/dist/cli/dist/network.js +16 -23
  15. package/dist/cli/dist/network.js.map +1 -1
  16. package/dist/cli/dist/receipt.d.ts +12 -2
  17. package/dist/cli/dist/receipt.js +6 -5
  18. package/dist/cli/dist/receipt.js.map +1 -1
  19. package/dist/cli/dist/sdk.d.ts +6 -4
  20. package/dist/cli/dist/sdk.js +3 -2
  21. package/dist/cli/dist/sdk.js.map +1 -1
  22. package/dist/examples/two-owner-demo/dist/run-demo.js +3 -1
  23. package/dist/examples/two-owner-demo/dist/run-demo.js.map +1 -1
  24. package/dist/package.json +1 -1
  25. package/dist/packages/core/dist/context-grant.d.ts +13 -0
  26. package/dist/packages/core/dist/context-grant.js +65 -0
  27. package/dist/packages/core/dist/context-grant.js.map +1 -0
  28. package/dist/packages/core/dist/delegation.d.ts +17 -0
  29. package/dist/packages/core/dist/delegation.js +126 -0
  30. package/dist/packages/core/dist/delegation.js.map +1 -0
  31. package/dist/packages/core/dist/edge.d.ts +2 -0
  32. package/dist/packages/core/dist/edge.js +2 -0
  33. package/dist/packages/core/dist/edge.js.map +1 -1
  34. package/dist/packages/core/dist/index.d.ts +4 -0
  35. package/dist/packages/core/dist/index.js +4 -0
  36. package/dist/packages/core/dist/index.js.map +1 -1
  37. package/dist/packages/core/dist/invite-link.d.ts +72 -0
  38. package/dist/packages/core/dist/invite-link.js +225 -0
  39. package/dist/packages/core/dist/invite-link.js.map +1 -0
  40. package/dist/packages/core/dist/invite-sas.d.ts +7 -0
  41. package/dist/packages/core/dist/invite-sas.js +15 -0
  42. package/dist/packages/core/dist/invite-sas.js.map +1 -0
  43. package/dist/packages/core/dist/relay-auth.d.ts +1 -1
  44. package/dist/packages/core/dist/relay-auth.js +1 -1
  45. package/dist/packages/core/dist/relay-auth.js.map +1 -1
  46. package/dist/packages/core/dist/schema.d.ts +1 -1
  47. package/dist/packages/core/dist/schema.js +4 -0
  48. package/dist/packages/core/dist/schema.js.map +1 -1
  49. package/dist/packages/core/dist/types.d.ts +52 -0
  50. package/dist/packages/ledger/dist/index.d.ts +70 -2
  51. package/dist/packages/ledger/dist/index.js +404 -26
  52. package/dist/packages/ledger/dist/index.js.map +1 -1
  53. package/dist/packages/relay/dist/fetch.js +4 -0
  54. package/dist/packages/relay/dist/fetch.js.map +1 -1
  55. package/dist/packages/relay/dist/invites.d.ts +42 -0
  56. package/dist/packages/relay/dist/invites.js +347 -0
  57. package/dist/packages/relay/dist/invites.js.map +1 -0
  58. package/dist/packages/relay/dist/worker.d.ts +3 -0
  59. package/dist/packages/relay/dist/worker.js +21 -0
  60. package/dist/packages/relay/dist/worker.js.map +1 -1
  61. package/dist/packages/runtime/dist/a2a.js +1 -1
  62. package/dist/packages/runtime/dist/adapter.d.ts +1 -0
  63. package/dist/packages/runtime/dist/approval-providers.d.ts +4 -0
  64. package/dist/packages/runtime/dist/approval-providers.js +3 -0
  65. package/dist/packages/runtime/dist/approval-providers.js.map +1 -1
  66. package/dist/packages/runtime/dist/connection-persistence.d.ts +1 -1
  67. package/dist/packages/runtime/dist/context-grant-audit.d.ts +8 -0
  68. package/dist/packages/runtime/dist/context-grant-audit.js +41 -0
  69. package/dist/packages/runtime/dist/context-grant-audit.js.map +1 -0
  70. package/dist/packages/runtime/dist/delegation.d.ts +37 -0
  71. package/dist/packages/runtime/dist/delegation.js +125 -0
  72. package/dist/packages/runtime/dist/delegation.js.map +1 -0
  73. package/dist/packages/runtime/dist/gateway.d.ts +1 -0
  74. package/dist/packages/runtime/dist/gateway.js.map +1 -1
  75. package/dist/packages/runtime/dist/index.d.ts +2 -0
  76. package/dist/packages/runtime/dist/index.js +2 -0
  77. package/dist/packages/runtime/dist/index.js.map +1 -1
  78. package/dist/packages/runtime/dist/mcp-server.js +22 -8
  79. package/dist/packages/runtime/dist/mcp-server.js.map +1 -1
  80. package/dist/packages/runtime/dist/mcp-tool-catalog.js +44 -5
  81. package/dist/packages/runtime/dist/mcp-tool-catalog.js.map +1 -1
  82. package/dist/packages/runtime/dist/session-audit.d.ts +6 -1
  83. package/dist/packages/runtime/dist/session-audit.js +35 -4
  84. package/dist/packages/runtime/dist/session-audit.js.map +1 -1
  85. package/dist/packages/runtime/dist/session.d.ts +21 -1
  86. package/dist/packages/runtime/dist/session.js +427 -62
  87. package/dist/packages/runtime/dist/session.js.map +1 -1
  88. package/dist/packages/runtime/dist/task-journal.d.ts +10 -1
  89. package/dist/packages/runtime/dist/task-journal.js +26 -1
  90. package/dist/packages/runtime/dist/task-journal.js.map +1 -1
  91. package/dist/packages/runtime/dist/verifier.d.ts +5 -2
  92. package/dist/packages/runtime/dist/verifier.js +14 -4
  93. package/dist/packages/runtime/dist/verifier.js.map +1 -1
  94. package/dist/spec/audit-entry.schema.json +25 -1
  95. package/dist/spec/audit-evidence.schema.json +179 -0
  96. package/dist/spec/audit-file-record.schema.json +177 -0
  97. package/dist/spec/audit-interruption.schema.json +110 -0
  98. package/dist/spec/context-grant-audit-payload.schema.json +24 -0
  99. package/dist/spec/context-grant.schema.json +146 -0
  100. package/dist/spec/delegation-attachment.schema.json +167 -0
  101. package/dist/spec/delegation-link.schema.json +141 -0
  102. package/dist/spec/examples/context-pooling/approval_redelegation/sample-delegation-attachment.json +413 -0
  103. package/dist/spec/examples/context-pooling/hand_over/sample-context-grant.json +18 -0
  104. package/dist/spec/examples/context-pooling/hand_over/sample-task-manifest.0.2.0.json +94 -0
  105. package/dist/spec/examples/context-pooling/sample-context-grant-audit-payload.json +4 -0
  106. package/dist/spec/examples/context-pooling/view_only/sample-context-grant.json +18 -0
  107. package/dist/spec/examples/context-pooling/view_only/sample-task-manifest.0.2.0.json +94 -0
  108. package/dist/spec/examples/sample-audit-evidence.json +138 -0
  109. package/dist/spec/examples/sample-audit-file-record.json +31 -0
  110. package/dist/spec/examples/sample-audit-interruption.json +29 -0
  111. package/dist/spec/task-manifest.0.2.0.schema.json +87 -1
  112. package/docs/context-grants.md +221 -0
  113. package/docs/sdk.ja.md +4 -0
  114. package/docs/sdk.md +4 -0
  115. package/package.json +3 -2
@@ -0,0 +1,138 @@
1
+ {
2
+ "entries": [
3
+ {
4
+ "body": {
5
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
6
+ "seq": 0,
7
+ "prevEntryHash": null,
8
+ "actorDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
9
+ "receiverDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
10
+ "eventType": "PROPOSE",
11
+ "payload": {
12
+ "proposal": {
13
+ "payload": {
14
+ "protocolVersion": "0.2.0",
15
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
16
+ "createdAt": "2026-11-05T00:00:00.000Z",
17
+ "deadline": "2026-11-05T00:10:00.000Z",
18
+ "requester": {
19
+ "ownerDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
20
+ "agentDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk"
21
+ },
22
+ "worker": {
23
+ "ownerDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
24
+ "agentDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD"
25
+ },
26
+ "task": {
27
+ "title": "Sample interruption",
28
+ "description": "Worker-only observation of a PROPOSE prefix",
29
+ "acceptanceCriteria": [
30
+ {
31
+ "id": "ac_schema",
32
+ "description": "Output satisfies the agreed JSON schema",
33
+ "required": true
34
+ }
35
+ ]
36
+ },
37
+ "io": {
38
+ "inputSchema": {},
39
+ "outputSchema": {}
40
+ },
41
+ "verification": {
42
+ "mode": "hybrid",
43
+ "requireUsageReceipt": true,
44
+ "requireExecutionAttestation": true,
45
+ "maxRetries": 0
46
+ },
47
+ "budget": {
48
+ "costBearer": "worker_byok",
49
+ "maxInputTokens": 50000,
50
+ "maxOutputTokens": 10000,
51
+ "maxToolInvocations": 10,
52
+ "maxWallClockSeconds": 60,
53
+ "onOverrun": "hard_stop"
54
+ },
55
+ "permissions": {
56
+ "maxDelegationDepth": 0,
57
+ "grantedCapabilities": []
58
+ },
59
+ "sandboxPolicy": {
60
+ "isolationLevel": "subprocess_restricted",
61
+ "networkAccess": "none",
62
+ "filesystemScope": "ephemeral_workspace_only"
63
+ },
64
+ "hitlPolicy": {
65
+ "requiredGates": [
66
+ "GATE_CONTRACT_ACCEPT",
67
+ "GATE_DELIVERY_ACCEPT"
68
+ ]
69
+ }
70
+ },
71
+ "signature": {
72
+ "signerDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
73
+ "canonicalization": "RFC8785-JCS",
74
+ "payloadDigest": "sha256:abf8b10ee34ed8774fe4b4f9634fd2a46f02b9c574204f4d93f7fd496b7d5595",
75
+ "signedAt": "2026-11-05T00:00:00.000Z",
76
+ "signature": "ed25519:Bnu3IQj4_w9_Tr-x72xh_CcylwfKDl2CYsuQKCworMebRxVqFFFyGAGTlDk3m9kSyQk4Cc0cfo934Tm8fbYBCA"
77
+ }
78
+ },
79
+ "input": {},
80
+ "capabilityChains": []
81
+ }
82
+ },
83
+ "entryHash": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
84
+ "actorSignature": {
85
+ "signerDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
86
+ "canonicalization": "RFC8785-JCS",
87
+ "payloadDigest": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
88
+ "signedAt": "2026-11-05T12:08:18.830Z",
89
+ "signature": "ed25519:gcjAXj9pEsUQXQ4nixpSDqaFFjf1De2ayIt6XTIuSwVTrFMPmofMRZYbRbWcF4gMiz9_wqVVzArIjOmQ6JEYCw"
90
+ },
91
+ "counterSignature": {
92
+ "payload": {
93
+ "type": "AckReceipt",
94
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
95
+ "entryHash": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
96
+ "actorDid": "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
97
+ "receiverDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD"
98
+ },
99
+ "signature": {
100
+ "signerDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
101
+ "canonicalization": "RFC8785-JCS",
102
+ "payloadDigest": "sha256:5981ecd15643250116b0655697bea324505e496b428797d6447f3314b014f166",
103
+ "signedAt": "2026-11-05T12:08:18.831Z",
104
+ "signature": "ed25519:XqX00TUcPJOkZjzFcyFHx7_hCCWgL5gZ5AglBkO1yfIjTNlWHu5U_a45H-tR1wx72RQVd4ShZT5ZVVLW7w53BA"
105
+ }
106
+ }
107
+ }
108
+ ],
109
+ "interruption": {
110
+ "payload": {
111
+ "type": "AuditInterruption",
112
+ "formatVersion": 1,
113
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
114
+ "actors": [
115
+ "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
116
+ "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD"
117
+ ],
118
+ "seq": 1,
119
+ "prevEntryHash": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
120
+ "acknowledgedPrefix": {
121
+ "count": 1,
122
+ "lastSeq": 0,
123
+ "head": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
124
+ "entriesDigest": "sha256:4fb32f5f4591aba0759f49b85d839277f17ba15261446c40aa92bc54f9c34602"
125
+ },
126
+ "phase": "OWNER_APPROVAL",
127
+ "reason": "SESSION_TIMEOUT",
128
+ "observedAt": "2026-11-05T00:01:00.000Z"
129
+ },
130
+ "signature": {
131
+ "signerDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
132
+ "canonicalization": "RFC8785-JCS",
133
+ "payloadDigest": "sha256:9b3e500d642b0731f02ac523f976f6854e623a7c1cfcd5396f2bbb21f0167b06",
134
+ "signedAt": "2026-11-05T00:01:00.000Z",
135
+ "signature": "ed25519:vn43o4hIZCRT5R_8xjCeT-MLibvv9kLVrgzmj-LIa9N019cCWBGL6tkVEJGGXFMVBthvrPB4tgR9Qq0iOpdGDg"
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "interruption": {
3
+ "payload": {
4
+ "type": "AuditInterruption",
5
+ "formatVersion": 1,
6
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
7
+ "actors": [
8
+ "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
9
+ "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD"
10
+ ],
11
+ "seq": 1,
12
+ "prevEntryHash": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
13
+ "acknowledgedPrefix": {
14
+ "count": 1,
15
+ "lastSeq": 0,
16
+ "head": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
17
+ "entriesDigest": "sha256:4fb32f5f4591aba0759f49b85d839277f17ba15261446c40aa92bc54f9c34602"
18
+ },
19
+ "phase": "OWNER_APPROVAL",
20
+ "reason": "SESSION_TIMEOUT",
21
+ "observedAt": "2026-11-05T00:01:00.000Z"
22
+ },
23
+ "signature": {
24
+ "signerDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
25
+ "canonicalization": "RFC8785-JCS",
26
+ "payloadDigest": "sha256:9b3e500d642b0731f02ac523f976f6854e623a7c1cfcd5396f2bbb21f0167b06",
27
+ "signedAt": "2026-11-05T00:01:00.000Z",
28
+ "signature": "ed25519:vn43o4hIZCRT5R_8xjCeT-MLibvv9kLVrgzmj-LIa9N019cCWBGL6tkVEJGGXFMVBthvrPB4tgR9Qq0iOpdGDg"
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "payload": {
3
+ "type": "AuditInterruption",
4
+ "formatVersion": 1,
5
+ "taskId": "task_58ba4c65aebe441ca9d2b3f253fea677",
6
+ "actors": [
7
+ "did:key:z6Mkj6gKgj855yaUZd1FS1CcBv7C5VWSv9eJmmLfuxt3Ppqk",
8
+ "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD"
9
+ ],
10
+ "seq": 1,
11
+ "prevEntryHash": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
12
+ "acknowledgedPrefix": {
13
+ "count": 1,
14
+ "lastSeq": 0,
15
+ "head": "sha256:533936cbbede60ba3617394ed7b99babd3a56109cc5139db011ba56b780f0e51",
16
+ "entriesDigest": "sha256:4fb32f5f4591aba0759f49b85d839277f17ba15261446c40aa92bc54f9c34602"
17
+ },
18
+ "phase": "OWNER_APPROVAL",
19
+ "reason": "SESSION_TIMEOUT",
20
+ "observedAt": "2026-11-05T00:01:00.000Z"
21
+ },
22
+ "signature": {
23
+ "signerDid": "did:key:z6Mkvo3zuWyhTjVCMZMTVERfBUvyQM372AnuN1XvHVE61CfD",
24
+ "canonicalization": "RFC8785-JCS",
25
+ "payloadDigest": "sha256:9b3e500d642b0731f02ac523f976f6854e623a7c1cfcd5396f2bbb21f0167b06",
26
+ "signedAt": "2026-11-05T00:01:00.000Z",
27
+ "signature": "ed25519:vn43o4hIZCRT5R_8xjCeT-MLibvv9kLVrgzmj-LIa9N019cCWBGL6tkVEJGGXFMVBthvrPB4tgR9Qq0iOpdGDg"
28
+ }
29
+ }
@@ -20,6 +20,7 @@
20
20
  "hitlPolicy"
21
21
  ],
22
22
  "properties": {
23
+ "contextGrant": { "$ref": "https://acp-spec.local/schemas/v0.2/context-grant.schema.json" },
23
24
  "protocolVersion": {
24
25
  "type": "string",
25
26
  "const": "0.2.0",
@@ -418,5 +419,90 @@
418
419
  }
419
420
  }
420
421
  }
421
- }
422
+ },
423
+ "allOf": [
424
+ {
425
+ "if": {
426
+ "required": ["contextGrant"],
427
+ "properties": {
428
+ "contextGrant": {
429
+ "properties": {
430
+ "deliveryMode": { "enum": ["view_only", "hand_over"] }
431
+ }
432
+ }
433
+ }
434
+ },
435
+ "then": {
436
+ "properties": {
437
+ "permissions": {
438
+ "properties": {
439
+ "maxDelegationDepth": {
440
+ "const": 0
441
+ }
442
+ }
443
+ }
444
+ },
445
+ "allOf": [
446
+ {
447
+ "if": {
448
+ "properties": {
449
+ "contextGrant": {
450
+ "properties": {
451
+ "deliveryMode": {
452
+ "const": "view_only"
453
+ }
454
+ }
455
+ }
456
+ }
457
+ },
458
+ "then": {
459
+ "properties": {
460
+ "sandboxPolicy": {
461
+ "properties": {
462
+ "filesystemScope": {
463
+ "const": "ephemeral_workspace_only"
464
+ }
465
+ }
466
+ }
467
+ }
468
+ }
469
+ }
470
+ ]
471
+ }
472
+ },
473
+ {
474
+ "if": {
475
+ "required": [
476
+ "contextGrant"
477
+ ],
478
+ "properties": {
479
+ "contextGrant": {
480
+ "properties": {
481
+ "deliveryMode": {
482
+ "const": "approval_redelegation"
483
+ }
484
+ }
485
+ }
486
+ }
487
+ },
488
+ "then": {
489
+ "properties": {
490
+ "permissions": {
491
+ "properties": {
492
+ "maxDelegationDepth": {
493
+ "const": 1
494
+ }
495
+ }
496
+ },
497
+ "sandboxPolicy": {
498
+ "properties": {
499
+ "filesystemScope": {
500
+ "const": "ephemeral_workspace_only"
501
+ }
502
+ }
503
+ }
504
+ }
505
+ }
506
+ }
507
+ ]
422
508
  }
@@ -0,0 +1,221 @@
1
+ # Context grants (CP1 and CP5a)
2
+
3
+ `TaskManifest.contextGrant` is an optional 0.2.0 contract property for a
4
+ sender's selected context. Existing manifests without it remain valid in both
5
+ supported versions. No protocol version, peer floor, or release clock changes.
6
+ A peer with the older closed 0.2.0 schema will reject this optional extension;
7
+ use it only with CP1-capable peers. There is no automatic downgrade that strips
8
+ the grant.
9
+
10
+ | Delivery mode | Delegation depth | Retention declaration | Input retention |
11
+ | --- | --- | --- | --- |
12
+ | `view_only` (builder default) | 0 | `ephemeral_view` | false |
13
+ | `hand_over` | 0 | `keep_deliverable` | false |
14
+ | `approval_redelegation` (explicit opt-in) | 1 | either; default `ephemeral_view` | false |
15
+
16
+ `hand_over` permits keeping the agreed, accepted deliverable. It does not permit
17
+ keeping the input selection. CP5a enables `approval_redelegation` only with the
18
+ owner decision and host prerequisites described below. Desktop controls are outside this slice.
19
+
20
+ ## Build and validate
21
+
22
+ ```ts
23
+ import { buildTaskManifest, validateManifest, validateContextGrantUse } from 'sealbridge/sdk';
24
+
25
+ const manifest = buildTaskManifest({
26
+ ownerDid, workerDid, title: 'Production feasibility',
27
+ description: 'Review selected dimensions and material.',
28
+ contextGrant: {
29
+ selectors: ['$.items[*]'],
30
+ fieldsAllowed: ['dimensions', 'material'],
31
+ fieldsDenied: ['customerName'],
32
+ angle: 'Report feasibility and missing dimensions.',
33
+ // Optional: deliveryMode: 'hand_over'
34
+ },
35
+ });
36
+ validateManifest(manifest);
37
+ validateContextGrantUse(manifest, selectedInput);
38
+ ```
39
+
40
+ The opt-in builder defaults to `view_only`, 24 hours from manifest `createdAt`,
41
+ 64 KiB, the mode's retention declaration, and `inputRetentionAllowed: false`.
42
+ It does not change default manifests. `RequesterClient.delegate` also accepts
43
+ these builder options as `contextGrant`; a supplied `manifest` is authoritative.
44
+
45
+ Selectors are non-empty opaque strings describing the sender's selection.
46
+ CP1 does not define a selector language, fetch source data, or filter input.
47
+ The sender must construct the selection before submitting it. Allowed and denied
48
+ field identifiers are compared literally; any identical identifier in both lists
49
+ is refused. Empty selectors, blank angles, unknown grant properties (including a
50
+ second `maxDelegationDepth`), and mismatched depth, retention or filesystem scope
51
+ are refused. `view_only` requires the existing
52
+ `filesystemScope: ephemeral_workspace_only` declaration. The builder uses that
53
+ scope for both modes. CP1 refuses `inputRetentionAllowed: true` in either mode.
54
+ A worker configured with the persistent plaintext `inboxPath` refuses grants.
55
+
56
+ The schema caps `maxBytes` at 65,536. Live use checks the UTF-8 byte length of the
57
+ entire JSON-serialized inline input, including JSON syntax, against that limit.
58
+ This is an input limit, not a promise that envelope overhead fits every relay's
59
+ configured admission cap. CP1 does not add attachment transfer or source access.
60
+ `expiresAt` must be after manifest `createdAt` and at most seven days after it.
61
+ Live proposal, acceptance and execution handoff additionally reject expired
62
+ grants, including expiry during owner review. Historical contract verification
63
+ checks the declared interval without consulting the current clock. Expiry does
64
+ not extend the task deadline or prove deletion. Existing execution timeouts still
65
+ control a running adapter.
66
+
67
+ `outputSchema` in a grant is an optional declaration. CP1 does not add angle or
68
+ grant-output verification; existing `io.outputSchema` behavior continues.
69
+
70
+ ## Audit lifecycle
71
+
72
+ Context events are `CONTEXT_GRANT`, `CONTEXT_MODE`, `CONTEXT_OPENED`,
73
+ `CONTEXT_DISCARDED`, and `CONTEXT_DELETION_ATTEMPTED`. Each payload contains only
74
+ `{ grantDigest, deliveryMode }`, with the digest computed over the exact grant
75
+ using the existing canonical JSON digest. Extra lifecycle payload fields are
76
+ rejected by the audit-entry schema.
77
+
78
+ The worker records grant and mode after proposal admission, opened after contract
79
+ approval, and discarded on a subsequent terminal failure where its audit channel
80
+ is still available. Pending intake is not recorded as discarded. On normal
81
+ execution completion it attempts the existing temporary workspace cleanup before
82
+ delivery and records deletion attempted before the bilateral checkpoint. The
83
+ event describes an attempt, including cleanup failures; the existing cleanup
84
+ error callback still reports residual files. Existing cancellation and failure
85
+ cleanup paths remain; they do not claim a deletion event after a sealed or
86
+ unavailable audit channel. Pre-admission refusals have no new bilateral entries.
87
+
88
+ For grant-bearing sessions, proposal audit payloads contain proposal/manifest
89
+ and frame digests plus the grant digest and mode, rather than the manifest and
90
+ input. Acceptance audit payloads contain digests, worker identity, and the
91
+ worker's signed acceptance proof, rather than the full contract. The encrypted
92
+ wire frames still carry the complete signed contract. Replay/recovery verifies
93
+ the compact evidence against the supplied manifest. Sessions without a grant
94
+ keep their existing audit payloads. Depth-zero delivery and progress evidence retain their
95
+ existing shapes and may contain application data; CP1 is not a general content
96
+ scrubber for adapter output.
97
+
98
+ AuditInterruption local format 1 remains limited to one acknowledged PROPOSE
99
+ containing the full signed manifest. Compact grant proposals and their lifecycle
100
+ entries are outside that scope, including when `auditInterruptionFormat: 1` is
101
+ enabled on the worker. Grant sessions keep their existing lifecycle and recovery
102
+ behavior; sessions without grants retain format-1 interruption closure. The
103
+ interruption verifier's manifest and prefix checks are unchanged.
104
+
105
+ Embedders can use `appendContextGrantAuditEvent(append, eventType, grant)` from
106
+ `sealbridge/sdk` for an actual local lifecycle action. The append port owns
107
+ signing, countersigning and persistence; for example, it can call an existing
108
+ `BilateralLedger.append`. The helper never appends a grant body. Do not report
109
+ opened or deletion attempted unless the corresponding action occurred.
110
+
111
+ The filesystem and retention fields are contract declarations. A temporary
112
+ workspace cleanup attempt does not prove erasure of copies, provider records,
113
+ held input, owner-managed files, or application logs. CP1 adds neither a deletion
114
+ proof nor a deliverable storage UI.
115
+
116
+ Schemas: [ContextGrant](../spec/context-grant.schema.json),
117
+ [audit payload](../spec/context-grant-audit-payload.schema.json),
118
+ [manifest 0.2.0](../spec/task-manifest.0.2.0.schema.json).
119
+ Examples: [view only](../spec/examples/context-pooling/view_only/sample-task-manifest.0.2.0.json),
120
+ [hand over](../spec/examples/context-pooling/hand_over/sample-task-manifest.0.2.0.json).
121
+
122
+
123
+ ## CP5a: one approved child edge
124
+
125
+ For A → B → C, A explicitly selects `approval_redelegation` on A → B at depth 1.
126
+ The builder adds the existing `GATE_SUB_DELEGATION`. B can dispatch separate
127
+ B → C tasks with strictly narrower `view_only` grants at depth 0. Only one
128
+ edge is supported; siblings are independent one-edge chains.
129
+
130
+ The root requires protocol 0.2.0, `ephemeral_workspace_only`, and absent/false
131
+ input retention. Both root retention declarations remain available. No required
132
+ manifest field or protocol version changes. Use this mode only with a known
133
+ CP5a worker: version 0.2.0 alone does not advertise support. C receives an ordinary
134
+ CP1 task; its host handles inspection and owner opening.
135
+
136
+ ### Host configuration and owner decisions
137
+
138
+ ```ts
139
+ import { WorkerNode, RequesterClient } from 'sealbridge/sdk';
140
+
141
+ const childRequester = new RequesterClient({
142
+ owner: bOwner, relay, approvalProvider: bOwnerDecisionProvider,
143
+ });
144
+ const worker = new WorkerNode({
145
+ owner: bOwner, relay, adapter, auditPath,
146
+ approvalProvider: bOwnerDecisionProvider,
147
+ redelegation: { requester: childRequester, ownerApprovalProvider: bOwnerDecisionProvider },
148
+ });
149
+ // Inside an admitted root adapter:
150
+ const partial = await context.redelegate!({
151
+ to: cInvitation, manifest: fullyBuiltChildManifest, input: alreadySelectedJson,
152
+ });
153
+ ```
154
+
155
+ The worker needs `auditPath` for its durable journal and a requester using B's
156
+ same owner identity. Configure ordinary connection and inspection policy
157
+ separately. The child method exists only during an admitted approval-mode root.
158
+ `ChildDelegationRequest` accepts `to`, optional `relay`, complete `manifest`,
159
+ selected JSON `input`, and optional `auditPath`. Resolve saved references before
160
+ calling. Capability chains, automatic approval/retry flags and supplied proofs
161
+ are not accepted. The helper adds no root identifiers or parent input to C's
162
+ frames; owner-supplied child content can still disclose them.
163
+
164
+ A approves the exact root manifest/input/worker target before send. B separately
165
+ opens the root, approves each child manifest/input/owner target, and reviews its
166
+ result. A reviews the final root delivery. These live boundaries require a
167
+ provider declaring `ownerDecision: true` and fresh target-bound owner receipts.
168
+ Interactive CLI and MCP form providers declare it; webhooks declare it in
169
+ owner-decision response mode. Policy providers cannot operate this mode. The
170
+ marker is a host assertion, not independent evidence of a physical human action.
171
+
172
+ ### Link checks and delivery
173
+
174
+ `createDelegationLink` signs after authenticated child acceptance and copies the
175
+ actual child limits. `verifyDelegationChain` checks signed contracts, task IDs,
176
+ owner continuity, digests, timestamps and remaining depth without consulting
177
+ today's clock. `assertDelegationAttenuation` compares declarations literally:
178
+ child selectors must be a nonempty subset, parent allowed fields cannot widen,
179
+ denied fields persist, and selectors or allowed fields must strictly narrow.
180
+ Reducing only bytes, budget or depth is insufficient. Parent grant `outputSchema`
181
+ is preserved. Numeric budgets, deadline, expiry and bytes cannot increase;
182
+ other budget fields, sandbox policy and verification policy must be equal.
183
+ Child capabilities are empty. These are per-task ceilings; sibling budgets are
184
+ not added together. The checks do not establish semantic provenance, interpret
185
+ selectors, verify an angle, prove erasure or establish child-output acceptance.
186
+
187
+ The host persists approved attempts before dispatch and accepted proofs before
188
+ parent delivery, retaining proofs even when later child execution fails. It
189
+ waits for managed children and attaches every issued proof; unresolved attempts,
190
+ duplicate IDs, invalid proofs and empty attachments prevent delivery. Restart
191
+ uses existing terminal recovery and does not replay child sends. An otherwise
192
+ valid subset cannot reveal an out-of-band sibling to A.
193
+
194
+ `Delivery.delegation` contains `{ parentContract, children }`, with each child
195
+ `{ link, childContract }`. The optional attachment is required for depth-one
196
+ contracts carrying a ContextGrant. Contracts without a ContextGrant keep their
197
+ origin/main delivery, verification, recovery and retained-result behavior at
198
+ all existing depths, including depth one without proof. CP1 depth-zero grants
199
+ keep their ordinary path; attaching CP5a evidence to them is refused. There is
200
+ no signed empty-child alternative: B cancels/rejects if it cannot produce a
201
+ linked child; A may explicitly submit a fresh depth-zero task.
202
+
203
+ Full signed parent and child contracts disclose selectors, angles, task text,
204
+ limits and owner DIDs to A. B reviews that disclosure before dispatch. Proof and
205
+ new journal fields add no raw input or child artifact body. Existing application
206
+ records and relay byte limits still apply; proofs are never stripped to fit.
207
+
208
+ `verifyDelegationAttachment(attachment, trustedContract)` checks every sibling
209
+ against the exact root. Live verification runs before output checks, callbacks
210
+ and owner review, adding `delegation_chain` only for the grant-bearing depth-one
211
+ path. Direct live verification also requires `ownerDecision: true`. Final review
212
+ includes verified child owner DIDs and proof digests. Recovery binds the embedded
213
+ root to retained proposal/acceptance evidence; historical expiry is not a new
214
+ refusal. Existing hashes and checkpoints retain the delivery attachment, and
215
+ version-1 task journals retain optional child-attempt state. `verifyAudit`
216
+ continues to check ledger hashes/signatures only.
217
+
218
+ Diagnostics are `DELEGATION_PROOF_REQUIRED`, `DELEGATION_INVALID`, and
219
+ `DELEGATION_APPROVAL_REQUIRED`. Schemas: [link](../spec/delegation-link.schema.json)
220
+ and [attachment](../spec/delegation-attachment.schema.json). See the
221
+ [complete attachment example](../spec/examples/context-pooling/approval_redelegation/sample-delegation-attachment.json).
package/docs/sdk.ja.md CHANGED
@@ -136,3 +136,7 @@ JSON の metadata・イベントを受け取ります。`now`・`transportFactor
136
136
  無指定時の policy-auto の既定値は変わりません。送信前の承認と最終検収は別です。
137
137
  接続の審査には別の `connectionReview` を使います。[MCP の説明](../README.ja.md)も
138
138
  参照してください。
139
+
140
+ ## 監査の中断証拠
141
+
142
+ `parseJsonl` / `verifyAudit` は双方署名の形式専用を維持します。`parseAuditJsonl` / `verifyAuditEvidence` は `AuditEvidence`(`AuditBundle | InterruptedAuditBundle`)を扱い、ワーカー単独の形式 1 の終端は、外部ピンが一致しても `UNILATERALLY_CLOSED`・`valid:false` です。`createAuditInterruption`・対応ストア・関連公開型も `sealbridge/sdk` から利用できます。[保存形式・ピン・永続化・依頼者との照合規則(英語)](audit-interruption.md)を参照してください。
package/docs/sdk.md CHANGED
@@ -143,3 +143,7 @@ existing CLI lifecycle. For host-owned streams, construct `AcpMcpServer`, call
143
143
  inject an `approvalProvider`; the unflagged policy-auto default is unchanged.
144
144
  Approval before sending and final verification remain separate. Connection review
145
145
  is a separate `connectionReview` option. See [MCP integration](../README.md#mcp-live-progress-revocation-and-quorum).
146
+
147
+ ## Audit evidence
148
+
149
+ `parseJsonl` / `verifyAudit` retain their bilateral-only contracts. Use `parseAuditJsonl` / `verifyAuditEvidence` for the `AuditEvidence` union (`AuditBundle | InterruptedAuditBundle`). Worker-only format-1 terminals return `UNILATERALLY_CLOSED` with `valid:false`, even with matching external pins; ordinary result APIs still require bilateral bundles. `createAuditInterruption`, the interruption-aware stores, and public evidence types are exported from `sealbridge/sdk`. See [storage, pins, durability, and requester comparison rules](audit-interruption.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sealbridge",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -65,7 +65,8 @@
65
65
  "README.md",
66
66
  "README.ja.md",
67
67
  "docs/sdk.md",
68
- "docs/sdk.ja.md"
68
+ "docs/sdk.ja.md",
69
+ "docs/context-grants.md"
69
70
  ],
70
71
  "publishConfig": {
71
72
  "access": "public"