@brightbeamai/chap-coordinator 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jsonrpc.cjs CHANGED
@@ -37,6 +37,7 @@ var E = {
37
37
  NOT_AUTHORISED: -32011,
38
38
  PATCH_FAILED: -32012,
39
39
  REVIEW_LAPSED: -32013,
40
+ REVIEW_ALREADY_OPEN: -32014,
40
41
  // whisper/1.0 profile (profiles/whisper.md S6)
41
42
  WHISPER_ALREADY_ANSWERED: -32020,
42
43
  WHISPER_LAPSED: -32021,
@@ -63,6 +64,7 @@ var E = {
63
64
  SIG_KEY_NOT_FOUND: -32071,
64
65
  SIG_KEY_REVOKED: -32072,
65
66
  SIG_ROTATION_KEY_MISMATCH: -32073,
67
+ SIG_ARTEFACT_DIGEST_MISMATCH: -32074,
66
68
  // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)
67
69
  SCITT_UNREACHABLE: -32080,
68
70
  SCITT_STATEMENT_REJECTED: -32081,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/jsonrpc.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator/jsonrpc\n *\n * Error codes (JSON-RPC standard + CHAP private range) and helpers.\n *\n * Error code allocations come directly from each profile spec. See\n * profiles/*.md for the authoritative definitions.\n */\n\nexport const E = {\n // JSON-RPC 2.0 standard\n PARSE: -32700,\n REQUEST: -32600,\n METHOD: -32601,\n PARAMS: -32602,\n INTERNAL: -32603,\n\n // review/1.0 profile\n NOT_REVIEWABLE: -32010,\n NOT_AUTHORISED: -32011,\n PATCH_FAILED: -32012,\n REVIEW_LAPSED: -32013,\n\n // whisper/1.0 profile (profiles/whisper.md S6)\n WHISPER_ALREADY_ANSWERED: -32020,\n WHISPER_LAPSED: -32021,\n WHISPER_OPTION_NOT_IN_SET: -32022,\n\n // deliberation/1.0 profile (profiles/deliberation.md S5)\n DELIB_VOTER_NOT_IN_LIST: -32030,\n DELIB_ALREADY_VOTED: -32031,\n DELIB_CLOSED_OR_LAPSED: -32032,\n DELIB_UNKNOWN_RULE: -32033,\n\n // modes/1.0 profile (profiles/modes.md S6)\n MODE_CEILING_EXCEEDED: -32040,\n MODE_STEP_UP_REQUIRED: -32041,\n\n // handoff/1.0 profile (profiles/handoff.md S6)\n HANDOFF_TASKS_NOT_ASSIGNED_TO_PROPOSER: -32050,\n HANDOFF_ALREADY_RESOLVED: -32051,\n HANDOFF_RECIPIENT_NOT_MEMBER: -32052,\n\n // control/1.0 profile (profiles/control.md S6)\n CONTROL_STEP_UP_REQUIRED: -32060,\n CONTROL_NOT_AUTHORISED: -32061,\n CONTROL_SNAPSHOT_NOT_FOUND: -32062,\n CONTROL_WORKSPACE_PAUSED: -32063,\n\n // security-signed/1.0 profile (profiles/security-signed.md S7)\n SIG_VERIFY_FAILED: -32070,\n SIG_KEY_NOT_FOUND: -32071,\n SIG_KEY_REVOKED: -32072,\n SIG_ROTATION_KEY_MISMATCH: -32073,\n\n // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)\n SCITT_UNREACHABLE: -32080,\n SCITT_STATEMENT_REJECTED: -32081,\n SCITT_RECEIPT_INVALID: -32082,\n\n // identity-oidc/1.0 profile (profiles/identity-oidc.md S8)\n OIDC_STEP_UP_REQUIRED: -32402,\n OIDC_TOKEN_INVALID: -32403,\n OIDC_CNF_MISMATCH: -32404,\n OIDC_SCOPE_MISSING: -32405,\n\n // identity-vc/1.0 profile (profiles/identity-vc.md S8)\n VC_VP_INVALID: -32410,\n VC_HOLDER_BINDING_INVALID: -32411,\n VC_CREDENTIAL_REVOKED: -32412,\n VC_SCHEMA_UNKNOWN: -32413,\n\n // routing/1.0 profile (profiles/routing.md S3-S5)\n ROUTING_NO_ELIGIBLE_ASSIGNEE: -32510,\n ROUTING_POLICY_VIOLATION: -32511,\n ROUTING_AUTO_ESCALATION_TRIGGERED: -32512,\n ROUTING_CANDIDATES_EMPTY: -32513,\n ROUTING_DEPTH_NOT_APPLICABLE: -32514,\n ROUTING_POLICY_UNREACHABLE: -32515,\n ROUTING_ESC_TARGET_UNAVAILABLE: -32516,\n} as const;\n\nexport function rpcError(code: number, message: string, data?: unknown) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\nexport function isValidEnvelope(env: unknown): boolean {\n if (typeof env !== \"object\" || env === null) return false;\n const e = env as Record<string, unknown>;\n return e.jsonrpc === \"2.0\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,IAAI;AAAA;AAAA,EAEf,OAAU;AAAA,EACV,SAAU;AAAA,EACV,QAAU;AAAA,EACV,QAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAgB;AAAA,EAChB,eAAgB;AAAA;AAAA,EAGhB,0BAA6B;AAAA,EAC7B,gBAA6B;AAAA,EAC7B,2BAA6B;AAAA;AAAA,EAG7B,yBAAyB;AAAA,EACzB,qBAAyB;AAAA,EACzB,wBAAyB;AAAA,EACzB,oBAAyB;AAAA;AAAA,EAGzB,uBAAyB;AAAA,EACzB,uBAAyB;AAAA;AAAA,EAGzB,wCAAwC;AAAA,EACxC,0BAAwC;AAAA,EACxC,8BAAwC;AAAA;AAAA,EAGxC,0BAA6B;AAAA,EAC7B,wBAA6B;AAAA,EAC7B,4BAA6B;AAAA,EAC7B,0BAA6B;AAAA;AAAA,EAG7B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC3B,iBAA2B;AAAA,EAC3B,2BAA2B;AAAA;AAAA,EAG3B,mBAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,uBAA0B;AAAA;AAAA,EAG1B,uBAAuB;AAAA,EACvB,oBAAuB;AAAA,EACvB,mBAAuB;AAAA,EACvB,oBAAuB;AAAA;AAAA,EAGvB,eAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,uBAA2B;AAAA,EAC3B,mBAA2B;AAAA;AAAA,EAG3B,8BAAgC;AAAA,EAChC,0BAAgC;AAAA,EAChC,mCAAmC;AAAA,EACnC,0BAAgC;AAAA,EAChC,8BAAgC;AAAA,EAChC,4BAAgC;AAAA,EAChC,gCAAgC;AAClC;AAEO,SAAS,SAAS,MAAc,SAAiB,MAAgB;AACtE,SAAO,EAAE,MAAM,SAAS,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC,EAAG;AAClE;AAEO,SAAS,gBAAgB,KAAuB;AACrD,MAAI,OAAO,QAAQ,YAAY,QAAQ,KAAM,QAAO;AACpD,QAAM,IAAI;AACV,SAAO,EAAE,YAAY;AACvB;","names":[]}
1
+ {"version":3,"sources":["../src/jsonrpc.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator/jsonrpc\n *\n * Error codes (JSON-RPC standard + CHAP private range) and helpers.\n *\n * Error code allocations come directly from each profile spec. See\n * profiles/*.md for the authoritative definitions.\n */\n\nexport const E = {\n // JSON-RPC 2.0 standard\n PARSE: -32700,\n REQUEST: -32600,\n METHOD: -32601,\n PARAMS: -32602,\n INTERNAL: -32603,\n\n // review/1.0 profile\n NOT_REVIEWABLE: -32010,\n NOT_AUTHORISED: -32011,\n PATCH_FAILED: -32012,\n REVIEW_LAPSED: -32013,\n REVIEW_ALREADY_OPEN: -32014,\n\n // whisper/1.0 profile (profiles/whisper.md S6)\n WHISPER_ALREADY_ANSWERED: -32020,\n WHISPER_LAPSED: -32021,\n WHISPER_OPTION_NOT_IN_SET: -32022,\n\n // deliberation/1.0 profile (profiles/deliberation.md S5)\n DELIB_VOTER_NOT_IN_LIST: -32030,\n DELIB_ALREADY_VOTED: -32031,\n DELIB_CLOSED_OR_LAPSED: -32032,\n DELIB_UNKNOWN_RULE: -32033,\n\n // modes/1.0 profile (profiles/modes.md S6)\n MODE_CEILING_EXCEEDED: -32040,\n MODE_STEP_UP_REQUIRED: -32041,\n\n // handoff/1.0 profile (profiles/handoff.md S6)\n HANDOFF_TASKS_NOT_ASSIGNED_TO_PROPOSER: -32050,\n HANDOFF_ALREADY_RESOLVED: -32051,\n HANDOFF_RECIPIENT_NOT_MEMBER: -32052,\n\n // control/1.0 profile (profiles/control.md S6)\n CONTROL_STEP_UP_REQUIRED: -32060,\n CONTROL_NOT_AUTHORISED: -32061,\n CONTROL_SNAPSHOT_NOT_FOUND: -32062,\n CONTROL_WORKSPACE_PAUSED: -32063,\n\n // security-signed/1.0 profile (profiles/security-signed.md S7)\n SIG_VERIFY_FAILED: -32070,\n SIG_KEY_NOT_FOUND: -32071,\n SIG_KEY_REVOKED: -32072,\n SIG_ROTATION_KEY_MISMATCH: -32073,\n SIG_ARTEFACT_DIGEST_MISMATCH: -32074,\n\n // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)\n SCITT_UNREACHABLE: -32080,\n SCITT_STATEMENT_REJECTED: -32081,\n SCITT_RECEIPT_INVALID: -32082,\n\n // identity-oidc/1.0 profile (profiles/identity-oidc.md S8)\n OIDC_STEP_UP_REQUIRED: -32402,\n OIDC_TOKEN_INVALID: -32403,\n OIDC_CNF_MISMATCH: -32404,\n OIDC_SCOPE_MISSING: -32405,\n\n // identity-vc/1.0 profile (profiles/identity-vc.md S8)\n VC_VP_INVALID: -32410,\n VC_HOLDER_BINDING_INVALID: -32411,\n VC_CREDENTIAL_REVOKED: -32412,\n VC_SCHEMA_UNKNOWN: -32413,\n\n // routing/1.0 profile (profiles/routing.md S3-S5)\n ROUTING_NO_ELIGIBLE_ASSIGNEE: -32510,\n ROUTING_POLICY_VIOLATION: -32511,\n ROUTING_AUTO_ESCALATION_TRIGGERED: -32512,\n ROUTING_CANDIDATES_EMPTY: -32513,\n ROUTING_DEPTH_NOT_APPLICABLE: -32514,\n ROUTING_POLICY_UNREACHABLE: -32515,\n ROUTING_ESC_TARGET_UNAVAILABLE: -32516,\n} as const;\n\nexport function rpcError(code: number, message: string, data?: unknown) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\nexport function isValidEnvelope(env: unknown): boolean {\n if (typeof env !== \"object\" || env === null) return false;\n const e = env as Record<string, unknown>;\n return e.jsonrpc === \"2.0\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,IAAI;AAAA;AAAA,EAEf,OAAU;AAAA,EACV,SAAU;AAAA,EACV,QAAU;AAAA,EACV,QAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAgB;AAAA,EAChB,eAAgB;AAAA,EAChB,qBAAqB;AAAA;AAAA,EAGrB,0BAA6B;AAAA,EAC7B,gBAA6B;AAAA,EAC7B,2BAA6B;AAAA;AAAA,EAG7B,yBAAyB;AAAA,EACzB,qBAAyB;AAAA,EACzB,wBAAyB;AAAA,EACzB,oBAAyB;AAAA;AAAA,EAGzB,uBAAyB;AAAA,EACzB,uBAAyB;AAAA;AAAA,EAGzB,wCAAwC;AAAA,EACxC,0BAAwC;AAAA,EACxC,8BAAwC;AAAA;AAAA,EAGxC,0BAA6B;AAAA,EAC7B,wBAA6B;AAAA,EAC7B,4BAA6B;AAAA,EAC7B,0BAA6B;AAAA;AAAA,EAG7B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC3B,iBAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,8BAA8B;AAAA;AAAA,EAG9B,mBAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,uBAA0B;AAAA;AAAA,EAG1B,uBAAuB;AAAA,EACvB,oBAAuB;AAAA,EACvB,mBAAuB;AAAA,EACvB,oBAAuB;AAAA;AAAA,EAGvB,eAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,uBAA2B;AAAA,EAC3B,mBAA2B;AAAA;AAAA,EAG3B,8BAAgC;AAAA,EAChC,0BAAgC;AAAA,EAChC,mCAAmC;AAAA,EACnC,0BAAgC;AAAA,EAChC,8BAAgC;AAAA,EAChC,4BAAgC;AAAA,EAChC,gCAAgC;AAClC;AAEO,SAAS,SAAS,MAAc,SAAiB,MAAgB;AACtE,SAAO,EAAE,MAAM,SAAS,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC,EAAG;AAClE;AAEO,SAAS,gBAAgB,KAAuB;AACrD,MAAI,OAAO,QAAQ,YAAY,QAAQ,KAAM,QAAO;AACpD,QAAM,IAAI;AACV,SAAO,EAAE,YAAY;AACvB;","names":[]}
@@ -16,6 +16,7 @@ declare const E: {
16
16
  readonly NOT_AUTHORISED: -32011;
17
17
  readonly PATCH_FAILED: -32012;
18
18
  readonly REVIEW_LAPSED: -32013;
19
+ readonly REVIEW_ALREADY_OPEN: -32014;
19
20
  readonly WHISPER_ALREADY_ANSWERED: -32020;
20
21
  readonly WHISPER_LAPSED: -32021;
21
22
  readonly WHISPER_OPTION_NOT_IN_SET: -32022;
@@ -36,6 +37,7 @@ declare const E: {
36
37
  readonly SIG_KEY_NOT_FOUND: -32071;
37
38
  readonly SIG_KEY_REVOKED: -32072;
38
39
  readonly SIG_ROTATION_KEY_MISMATCH: -32073;
40
+ readonly SIG_ARTEFACT_DIGEST_MISMATCH: -32074;
39
41
  readonly SCITT_UNREACHABLE: -32080;
40
42
  readonly SCITT_STATEMENT_REJECTED: -32081;
41
43
  readonly SCITT_RECEIPT_INVALID: -32082;
package/dist/jsonrpc.d.ts CHANGED
@@ -16,6 +16,7 @@ declare const E: {
16
16
  readonly NOT_AUTHORISED: -32011;
17
17
  readonly PATCH_FAILED: -32012;
18
18
  readonly REVIEW_LAPSED: -32013;
19
+ readonly REVIEW_ALREADY_OPEN: -32014;
19
20
  readonly WHISPER_ALREADY_ANSWERED: -32020;
20
21
  readonly WHISPER_LAPSED: -32021;
21
22
  readonly WHISPER_OPTION_NOT_IN_SET: -32022;
@@ -36,6 +37,7 @@ declare const E: {
36
37
  readonly SIG_KEY_NOT_FOUND: -32071;
37
38
  readonly SIG_KEY_REVOKED: -32072;
38
39
  readonly SIG_ROTATION_KEY_MISMATCH: -32073;
40
+ readonly SIG_ARTEFACT_DIGEST_MISMATCH: -32074;
39
41
  readonly SCITT_UNREACHABLE: -32080;
40
42
  readonly SCITT_STATEMENT_REJECTED: -32081;
41
43
  readonly SCITT_RECEIPT_INVALID: -32082;
package/dist/jsonrpc.js CHANGED
@@ -11,6 +11,7 @@ var E = {
11
11
  NOT_AUTHORISED: -32011,
12
12
  PATCH_FAILED: -32012,
13
13
  REVIEW_LAPSED: -32013,
14
+ REVIEW_ALREADY_OPEN: -32014,
14
15
  // whisper/1.0 profile (profiles/whisper.md S6)
15
16
  WHISPER_ALREADY_ANSWERED: -32020,
16
17
  WHISPER_LAPSED: -32021,
@@ -37,6 +38,7 @@ var E = {
37
38
  SIG_KEY_NOT_FOUND: -32071,
38
39
  SIG_KEY_REVOKED: -32072,
39
40
  SIG_ROTATION_KEY_MISMATCH: -32073,
41
+ SIG_ARTEFACT_DIGEST_MISMATCH: -32074,
40
42
  // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)
41
43
  SCITT_UNREACHABLE: -32080,
42
44
  SCITT_STATEMENT_REJECTED: -32081,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/jsonrpc.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator/jsonrpc\n *\n * Error codes (JSON-RPC standard + CHAP private range) and helpers.\n *\n * Error code allocations come directly from each profile spec. See\n * profiles/*.md for the authoritative definitions.\n */\n\nexport const E = {\n // JSON-RPC 2.0 standard\n PARSE: -32700,\n REQUEST: -32600,\n METHOD: -32601,\n PARAMS: -32602,\n INTERNAL: -32603,\n\n // review/1.0 profile\n NOT_REVIEWABLE: -32010,\n NOT_AUTHORISED: -32011,\n PATCH_FAILED: -32012,\n REVIEW_LAPSED: -32013,\n\n // whisper/1.0 profile (profiles/whisper.md S6)\n WHISPER_ALREADY_ANSWERED: -32020,\n WHISPER_LAPSED: -32021,\n WHISPER_OPTION_NOT_IN_SET: -32022,\n\n // deliberation/1.0 profile (profiles/deliberation.md S5)\n DELIB_VOTER_NOT_IN_LIST: -32030,\n DELIB_ALREADY_VOTED: -32031,\n DELIB_CLOSED_OR_LAPSED: -32032,\n DELIB_UNKNOWN_RULE: -32033,\n\n // modes/1.0 profile (profiles/modes.md S6)\n MODE_CEILING_EXCEEDED: -32040,\n MODE_STEP_UP_REQUIRED: -32041,\n\n // handoff/1.0 profile (profiles/handoff.md S6)\n HANDOFF_TASKS_NOT_ASSIGNED_TO_PROPOSER: -32050,\n HANDOFF_ALREADY_RESOLVED: -32051,\n HANDOFF_RECIPIENT_NOT_MEMBER: -32052,\n\n // control/1.0 profile (profiles/control.md S6)\n CONTROL_STEP_UP_REQUIRED: -32060,\n CONTROL_NOT_AUTHORISED: -32061,\n CONTROL_SNAPSHOT_NOT_FOUND: -32062,\n CONTROL_WORKSPACE_PAUSED: -32063,\n\n // security-signed/1.0 profile (profiles/security-signed.md S7)\n SIG_VERIFY_FAILED: -32070,\n SIG_KEY_NOT_FOUND: -32071,\n SIG_KEY_REVOKED: -32072,\n SIG_ROTATION_KEY_MISMATCH: -32073,\n\n // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)\n SCITT_UNREACHABLE: -32080,\n SCITT_STATEMENT_REJECTED: -32081,\n SCITT_RECEIPT_INVALID: -32082,\n\n // identity-oidc/1.0 profile (profiles/identity-oidc.md S8)\n OIDC_STEP_UP_REQUIRED: -32402,\n OIDC_TOKEN_INVALID: -32403,\n OIDC_CNF_MISMATCH: -32404,\n OIDC_SCOPE_MISSING: -32405,\n\n // identity-vc/1.0 profile (profiles/identity-vc.md S8)\n VC_VP_INVALID: -32410,\n VC_HOLDER_BINDING_INVALID: -32411,\n VC_CREDENTIAL_REVOKED: -32412,\n VC_SCHEMA_UNKNOWN: -32413,\n\n // routing/1.0 profile (profiles/routing.md S3-S5)\n ROUTING_NO_ELIGIBLE_ASSIGNEE: -32510,\n ROUTING_POLICY_VIOLATION: -32511,\n ROUTING_AUTO_ESCALATION_TRIGGERED: -32512,\n ROUTING_CANDIDATES_EMPTY: -32513,\n ROUTING_DEPTH_NOT_APPLICABLE: -32514,\n ROUTING_POLICY_UNREACHABLE: -32515,\n ROUTING_ESC_TARGET_UNAVAILABLE: -32516,\n} as const;\n\nexport function rpcError(code: number, message: string, data?: unknown) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\nexport function isValidEnvelope(env: unknown): boolean {\n if (typeof env !== \"object\" || env === null) return false;\n const e = env as Record<string, unknown>;\n return e.jsonrpc === \"2.0\";\n}\n"],"mappings":";AASO,IAAM,IAAI;AAAA;AAAA,EAEf,OAAU;AAAA,EACV,SAAU;AAAA,EACV,QAAU;AAAA,EACV,QAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAgB;AAAA,EAChB,eAAgB;AAAA;AAAA,EAGhB,0BAA6B;AAAA,EAC7B,gBAA6B;AAAA,EAC7B,2BAA6B;AAAA;AAAA,EAG7B,yBAAyB;AAAA,EACzB,qBAAyB;AAAA,EACzB,wBAAyB;AAAA,EACzB,oBAAyB;AAAA;AAAA,EAGzB,uBAAyB;AAAA,EACzB,uBAAyB;AAAA;AAAA,EAGzB,wCAAwC;AAAA,EACxC,0BAAwC;AAAA,EACxC,8BAAwC;AAAA;AAAA,EAGxC,0BAA6B;AAAA,EAC7B,wBAA6B;AAAA,EAC7B,4BAA6B;AAAA,EAC7B,0BAA6B;AAAA;AAAA,EAG7B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC3B,iBAA2B;AAAA,EAC3B,2BAA2B;AAAA;AAAA,EAG3B,mBAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,uBAA0B;AAAA;AAAA,EAG1B,uBAAuB;AAAA,EACvB,oBAAuB;AAAA,EACvB,mBAAuB;AAAA,EACvB,oBAAuB;AAAA;AAAA,EAGvB,eAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,uBAA2B;AAAA,EAC3B,mBAA2B;AAAA;AAAA,EAG3B,8BAAgC;AAAA,EAChC,0BAAgC;AAAA,EAChC,mCAAmC;AAAA,EACnC,0BAAgC;AAAA,EAChC,8BAAgC;AAAA,EAChC,4BAAgC;AAAA,EAChC,gCAAgC;AAClC;AAEO,SAAS,SAAS,MAAc,SAAiB,MAAgB;AACtE,SAAO,EAAE,MAAM,SAAS,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC,EAAG;AAClE;AAEO,SAAS,gBAAgB,KAAuB;AACrD,MAAI,OAAO,QAAQ,YAAY,QAAQ,KAAM,QAAO;AACpD,QAAM,IAAI;AACV,SAAO,EAAE,YAAY;AACvB;","names":[]}
1
+ {"version":3,"sources":["../src/jsonrpc.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator/jsonrpc\n *\n * Error codes (JSON-RPC standard + CHAP private range) and helpers.\n *\n * Error code allocations come directly from each profile spec. See\n * profiles/*.md for the authoritative definitions.\n */\n\nexport const E = {\n // JSON-RPC 2.0 standard\n PARSE: -32700,\n REQUEST: -32600,\n METHOD: -32601,\n PARAMS: -32602,\n INTERNAL: -32603,\n\n // review/1.0 profile\n NOT_REVIEWABLE: -32010,\n NOT_AUTHORISED: -32011,\n PATCH_FAILED: -32012,\n REVIEW_LAPSED: -32013,\n REVIEW_ALREADY_OPEN: -32014,\n\n // whisper/1.0 profile (profiles/whisper.md S6)\n WHISPER_ALREADY_ANSWERED: -32020,\n WHISPER_LAPSED: -32021,\n WHISPER_OPTION_NOT_IN_SET: -32022,\n\n // deliberation/1.0 profile (profiles/deliberation.md S5)\n DELIB_VOTER_NOT_IN_LIST: -32030,\n DELIB_ALREADY_VOTED: -32031,\n DELIB_CLOSED_OR_LAPSED: -32032,\n DELIB_UNKNOWN_RULE: -32033,\n\n // modes/1.0 profile (profiles/modes.md S6)\n MODE_CEILING_EXCEEDED: -32040,\n MODE_STEP_UP_REQUIRED: -32041,\n\n // handoff/1.0 profile (profiles/handoff.md S6)\n HANDOFF_TASKS_NOT_ASSIGNED_TO_PROPOSER: -32050,\n HANDOFF_ALREADY_RESOLVED: -32051,\n HANDOFF_RECIPIENT_NOT_MEMBER: -32052,\n\n // control/1.0 profile (profiles/control.md S6)\n CONTROL_STEP_UP_REQUIRED: -32060,\n CONTROL_NOT_AUTHORISED: -32061,\n CONTROL_SNAPSHOT_NOT_FOUND: -32062,\n CONTROL_WORKSPACE_PAUSED: -32063,\n\n // security-signed/1.0 profile (profiles/security-signed.md S7)\n SIG_VERIFY_FAILED: -32070,\n SIG_KEY_NOT_FOUND: -32071,\n SIG_KEY_REVOKED: -32072,\n SIG_ROTATION_KEY_MISMATCH: -32073,\n SIG_ARTEFACT_DIGEST_MISMATCH: -32074,\n\n // audit-scitt/1.0 profile (profiles/audit-scitt.md S8)\n SCITT_UNREACHABLE: -32080,\n SCITT_STATEMENT_REJECTED: -32081,\n SCITT_RECEIPT_INVALID: -32082,\n\n // identity-oidc/1.0 profile (profiles/identity-oidc.md S8)\n OIDC_STEP_UP_REQUIRED: -32402,\n OIDC_TOKEN_INVALID: -32403,\n OIDC_CNF_MISMATCH: -32404,\n OIDC_SCOPE_MISSING: -32405,\n\n // identity-vc/1.0 profile (profiles/identity-vc.md S8)\n VC_VP_INVALID: -32410,\n VC_HOLDER_BINDING_INVALID: -32411,\n VC_CREDENTIAL_REVOKED: -32412,\n VC_SCHEMA_UNKNOWN: -32413,\n\n // routing/1.0 profile (profiles/routing.md S3-S5)\n ROUTING_NO_ELIGIBLE_ASSIGNEE: -32510,\n ROUTING_POLICY_VIOLATION: -32511,\n ROUTING_AUTO_ESCALATION_TRIGGERED: -32512,\n ROUTING_CANDIDATES_EMPTY: -32513,\n ROUTING_DEPTH_NOT_APPLICABLE: -32514,\n ROUTING_POLICY_UNREACHABLE: -32515,\n ROUTING_ESC_TARGET_UNAVAILABLE: -32516,\n} as const;\n\nexport function rpcError(code: number, message: string, data?: unknown) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\nexport function isValidEnvelope(env: unknown): boolean {\n if (typeof env !== \"object\" || env === null) return false;\n const e = env as Record<string, unknown>;\n return e.jsonrpc === \"2.0\";\n}\n"],"mappings":";AASO,IAAM,IAAI;AAAA;AAAA,EAEf,OAAU;AAAA,EACV,SAAU;AAAA,EACV,QAAU;AAAA,EACV,QAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAGV,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAgB;AAAA,EAChB,eAAgB;AAAA,EAChB,qBAAqB;AAAA;AAAA,EAGrB,0BAA6B;AAAA,EAC7B,gBAA6B;AAAA,EAC7B,2BAA6B;AAAA;AAAA,EAG7B,yBAAyB;AAAA,EACzB,qBAAyB;AAAA,EACzB,wBAAyB;AAAA,EACzB,oBAAyB;AAAA;AAAA,EAGzB,uBAAyB;AAAA,EACzB,uBAAyB;AAAA;AAAA,EAGzB,wCAAwC;AAAA,EACxC,0BAAwC;AAAA,EACxC,8BAAwC;AAAA;AAAA,EAGxC,0BAA6B;AAAA,EAC7B,wBAA6B;AAAA,EAC7B,4BAA6B;AAAA,EAC7B,0BAA6B;AAAA;AAAA,EAG7B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC3B,iBAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,8BAA8B;AAAA;AAAA,EAG9B,mBAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,uBAA0B;AAAA;AAAA,EAG1B,uBAAuB;AAAA,EACvB,oBAAuB;AAAA,EACvB,mBAAuB;AAAA,EACvB,oBAAuB;AAAA;AAAA,EAGvB,eAA2B;AAAA,EAC3B,2BAA2B;AAAA,EAC3B,uBAA2B;AAAA,EAC3B,mBAA2B;AAAA;AAAA,EAG3B,8BAAgC;AAAA,EAChC,0BAAgC;AAAA,EAChC,mCAAmC;AAAA,EACnC,0BAAgC;AAAA,EAChC,8BAAgC;AAAA,EAChC,4BAAgC;AAAA,EAChC,gCAAgC;AAClC;AAEO,SAAS,SAAS,MAAc,SAAiB,MAAgB;AACtE,SAAO,EAAE,MAAM,SAAS,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC,EAAG;AAClE;AAEO,SAAS,gBAAgB,KAAuB;AACrD,MAAI,OAAO,QAAQ,YAAY,QAAQ,KAAM,QAAO;AACpD,QAAM,IAAI;AACV,SAAO,EAAE,YAAY;AACvB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/methods.ts"],"sourcesContent":["/**\n * Typed method definitions.\n *\n * Every CHAP method that ships in either reference implementation\n * gets a typed `Params` and `Result` shape here. The Coordinator's\n * typed facade (`coord.workspace.create`, `coord.task.complete`, …)\n * uses these types so callers get autocomplete and compile-time\n * checking without having to remember field names.\n *\n * These types are hand-maintained against the canonical JSON Schemas\n * under `schemas/`. A future revision will generate this file from\n * the schemas automatically; for now the source of truth remains\n * the running tests under `tests/`.\n *\n * Scope: 39 method handlers shipped by both v0.2 reference\n * implementations (Core + every shipped profile). Spec-only methods\n * are excluded - they would mislead callers into thinking the local\n * Coordinator can dispatch them.\n */\n\nimport type {\n ArtefactId, JsonPatchOp, ParticipantUri, TaskId,\n Workspace, WorkspaceId,\n} from \"./types.js\";\n\n// ---- shared building blocks ---------------------------------------\n\nexport interface WorkspaceParam { workspace: WorkspaceId }\nexport interface ActorParam { from: ParticipantUri }\nexport interface TaskParam { task_id: TaskId }\n\nexport interface OkResult { ok: true }\n\n// ============================================================\n// workspace.*\n// ============================================================\n\nexport interface WorkspaceCreateParams extends Partial<WorkspaceParam> {\n profiles?: string[];\n routing_policy_uri?: string;\n mode?: \"shadow\" | \"trial\" | \"production\";\n mode_ceiling?: \"shadow\" | \"trial\" | \"production\";\n}\nexport interface WorkspaceCreateResult { workspace: WorkspaceId }\n\nexport interface WorkspaceDescribeParams extends WorkspaceParam {}\nexport interface WorkspaceDescribeResult { workspace: Workspace }\n\nexport interface WorkspaceSetProfilesParams extends WorkspaceParam, ActorParam {\n profiles: string[];\n}\nexport type WorkspaceSetProfilesResult = OkResult;\n\n// ============================================================\n// participant.*\n// ============================================================\n\nexport interface ParticipantJoinParams extends WorkspaceParam, ActorParam {\n type: \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n role?: string;\n scopes?: string[];\n capabilities?: Record<string, unknown>;\n oidc_token?: unknown;\n vc?: unknown;\n pubkey?: unknown;\n}\nexport type ParticipantJoinResult = OkResult;\n\nexport interface ParticipantLeaveParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ParticipantLeaveResult = OkResult;\n\nexport interface ParticipantRotateKeyParams extends WorkspaceParam, ActorParam {\n pubkey: unknown;\n reason?: string;\n}\nexport type ParticipantRotateKeyResult = OkResult;\n\nexport interface ParticipantRevokeKeyParams extends WorkspaceParam, ActorParam {\n kid: string;\n reason?: string;\n}\nexport type ParticipantRevokeKeyResult = OkResult;\n\n// ============================================================\n// task.*\n// ============================================================\n\nexport interface TaskCreateParams extends WorkspaceParam, ActorParam {\n kind: string;\n input: unknown;\n assignee?: ParticipantUri;\n to?: ParticipantUri; // alias for assignee\n routing_hints?: Record<string, unknown>;\n deadline?: string;\n}\nexport interface TaskCreateResult { task_id: TaskId }\n\nexport interface TaskUpdateParams extends WorkspaceParam, ActorParam, TaskParam {\n state?: string;\n output?: unknown;\n progress?: Record<string, unknown>;\n}\nexport type TaskUpdateResult = OkResult;\n\nexport interface TaskCompleteParams extends WorkspaceParam, ActorParam, TaskParam {\n output?: unknown;\n confidence?: number | string;\n}\nexport type TaskCompleteResult = OkResult;\n\n// ============================================================\n// review.* and decide.*\n// ============================================================\n\nexport interface ReviewRequestParams extends WorkspaceParam, ActorParam, TaskParam {\n artefact: unknown;\n to: ParticipantUri | ParticipantUri[];\n rule?: string;\n deadline?: string;\n}\nexport interface ReviewRequestResult { state: string; review_id: TaskId }\n\nexport interface DecideApproveParams extends WorkspaceParam, ActorParam, TaskParam {\n rationale?: string;\n}\nexport type DecideApproveResult = OkResult;\n\nexport interface DecideRejectParams extends WorkspaceParam, ActorParam, TaskParam {\n rationale: string;\n category?: string;\n}\nexport type DecideRejectResult = OkResult;\n\nexport interface DecideOverrideParams extends WorkspaceParam, ActorParam, TaskParam {\n diff: JsonPatchOp[];\n rationale: string;\n tags?: string[];\n policy_refs?: string[];\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n based_on_artefact?: unknown;\n}\nexport interface DecideOverrideResult {\n state: \"completed\";\n override_artefact_id: ArtefactId;\n applied: unknown;\n}\n\nexport interface AbstainDeclareParams extends WorkspaceParam, ActorParam, TaskParam {\n category: string;\n rationale?: string;\n}\nexport type AbstainDeclareResult = OkResult;\n\nexport interface EscalateRaiseParams extends WorkspaceParam, ActorParam, TaskParam {\n to?: ParticipantUri;\n rationale?: string;\n}\nexport interface EscalateRaiseResult { ok: true; to?: ParticipantUri }\n\n// ============================================================\n// whisper.* (whisper/1.0)\n// ============================================================\n\nexport interface WhisperAskParams extends WorkspaceParam, ActorParam, TaskParam {\n to: ParticipantUri;\n question: string;\n options?: string[];\n default_on_lapse?: string;\n lapse_ms?: number;\n}\nexport interface WhisperAskResult { whisper_id: string }\n\nexport interface WhisperAnswerParams extends WorkspaceParam, ActorParam {\n whisper_id: string;\n answer: string;\n}\nexport type WhisperAnswerResult = OkResult;\n\n// ============================================================\n// deliberate.* (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberateOpenParams extends WorkspaceParam, ActorParam, TaskParam {\n rule: Record<string, unknown>;\n proposition: unknown;\n voters: ParticipantUri[];\n}\nexport interface DeliberateOpenResult { deliberation_id: string }\n\nexport interface DeliberateCommentParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n text: string;\n}\nexport type DeliberateCommentResult = OkResult;\n\nexport interface DeliberateVoteParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n rationale?: string;\n}\nexport type DeliberateVoteResult = OkResult;\n\nexport interface DeliberateCloseParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n}\nexport interface DeliberateCloseResult { outcome: \"approved\" | \"rejected\" | \"no_quorum\" }\n\n// ============================================================\n// handoff.* (handoff/1.0)\n// ============================================================\n\nexport interface HandoffProposeParams extends WorkspaceParam, ActorParam {\n to: ParticipantUri;\n task_ids: TaskId[];\n summary: string;\n active_constraints?: Record<string, unknown>;\n}\nexport interface HandoffProposeResult { handoff_id: string }\n\nexport interface HandoffAcceptParams extends WorkspaceParam, ActorParam {\n handoff_id: string;\n}\nexport type HandoffAcceptResult = OkResult;\n\nexport interface HandoffDeclineParams extends WorkspaceParam, ActorParam {\n handoff_id: string;\n reason?: string;\n}\nexport type HandoffDeclineResult = OkResult;\n\n// ============================================================\n// control.* (control/1.0)\n// ============================================================\n\nexport interface ControlPauseParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ControlPauseResult = OkResult;\n\nexport interface ControlResumeParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ControlResumeResult = OkResult;\n\nexport interface ControlCancelParams extends WorkspaceParam, ActorParam, TaskParam {\n reason?: string;\n}\nexport type ControlCancelResult = OkResult;\n\nexport interface ControlSupersedeParams extends WorkspaceParam, ActorParam, TaskParam {\n replacement: unknown;\n logical_id?: string;\n intent_preserved?: boolean;\n reason?: string;\n}\nexport interface ControlSupersedeResult { artefact_id: ArtefactId }\n\nexport interface ControlSnapshotParams extends WorkspaceParam, ActorParam {\n label?: string;\n}\nexport interface ControlSnapshotResult { snapshot_id: string }\n\nexport interface ControlRollbackParams extends WorkspaceParam, ActorParam {\n snapshot_id: string;\n reason?: string;\n}\nexport type ControlRollbackResult = OkResult;\n\nexport interface ControlSetModeCeilingParams extends WorkspaceParam, ActorParam {\n ceiling: \"shadow\" | \"trial\" | \"production\";\n}\nexport type ControlSetModeCeilingResult = OkResult;\n\n// ============================================================\n// routing.* (routing/1.0)\n// ============================================================\n\nexport interface TaskRouteParams extends WorkspaceParam, ActorParam, TaskParam {\n candidates: ParticipantUri[];\n}\nexport interface TaskRouteResult {\n selected: ParticipantUri;\n rationale: Record<string, unknown>;\n}\n\nexport interface ReviewDepthParams extends WorkspaceParam, ActorParam, TaskParam {\n artefact?: unknown;\n hints?: Record<string, unknown>;\n}\nexport interface ReviewDepthResult {\n depth: \"skip\" | \"spot_check\" | \"full\" | \"escalated\";\n sampling_probability?: number;\n rationale: Record<string, unknown>;\n}\n\nexport interface EscalateAutoParams extends WorkspaceParam, ActorParam, TaskParam {\n hints?: Record<string, unknown>;\n}\nexport interface EscalateAutoResult {\n escalated: boolean;\n to?: ParticipantUri;\n triggered_rule?: Record<string, unknown>;\n}\n\n// ============================================================\n// audit.* (Core + audit-scitt/1.0)\n// ============================================================\n\nexport interface AuditReadParams extends WorkspaceParam {\n from_seq?: number;\n limit?: number;\n}\nexport interface AuditReadResult { entries: unknown[] }\n\nexport interface AuditSubmitToScittParams extends WorkspaceParam, ActorParam {\n seq: number;\n statement?: Record<string, unknown>;\n}\nexport interface AuditSubmitToScittResult { receipt: Record<string, unknown> }\n\nexport interface AuditVerifyReceiptParams extends WorkspaceParam {\n receipt: Record<string, unknown>;\n}\nexport interface AuditVerifyReceiptResult { valid: boolean }\n\nexport interface AuditVerifyChainParams extends WorkspaceParam {\n from_seq?: number;\n to_seq?: number;\n}\nexport interface AuditVerifyChainResult {\n valid: boolean;\n breaks?: number[];\n}\n\n// ============================================================\n// Method-name → {params, result} map (single source of truth)\n// ============================================================\n\nexport interface MethodTable {\n \"workspace.create\": { params: WorkspaceCreateParams, result: WorkspaceCreateResult };\n \"workspace.describe\": { params: WorkspaceDescribeParams, result: WorkspaceDescribeResult };\n \"workspace.set_profiles\": { params: WorkspaceSetProfilesParams, result: WorkspaceSetProfilesResult };\n\n \"participant.join\": { params: ParticipantJoinParams, result: ParticipantJoinResult };\n \"participant.leave\": { params: ParticipantLeaveParams, result: ParticipantLeaveResult };\n \"participant.rotate_key\": { params: ParticipantRotateKeyParams, result: ParticipantRotateKeyResult };\n \"participant.revoke_key\": { params: ParticipantRevokeKeyParams, result: ParticipantRevokeKeyResult };\n\n \"task.create\": { params: TaskCreateParams, result: TaskCreateResult };\n \"task.update\": { params: TaskUpdateParams, result: TaskUpdateResult };\n \"task.complete\": { params: TaskCompleteParams, result: TaskCompleteResult };\n\n \"review.request\": { params: ReviewRequestParams, result: ReviewRequestResult };\n \"decide.approve\": { params: DecideApproveParams, result: DecideApproveResult };\n \"decide.reject\": { params: DecideRejectParams, result: DecideRejectResult };\n \"decide.override\": { params: DecideOverrideParams, result: DecideOverrideResult };\n \"abstain.declare\": { params: AbstainDeclareParams, result: AbstainDeclareResult };\n \"escalate.raise\": { params: EscalateRaiseParams, result: EscalateRaiseResult };\n\n \"whisper.ask\": { params: WhisperAskParams, result: WhisperAskResult };\n \"whisper.answer\": { params: WhisperAnswerParams, result: WhisperAnswerResult };\n\n \"deliberate.open\": { params: DeliberateOpenParams, result: DeliberateOpenResult };\n \"deliberate.comment\": { params: DeliberateCommentParams, result: DeliberateCommentResult };\n \"deliberate.vote\": { params: DeliberateVoteParams, result: DeliberateVoteResult };\n \"deliberate.close\": { params: DeliberateCloseParams, result: DeliberateCloseResult };\n\n \"handoff.propose\": { params: HandoffProposeParams, result: HandoffProposeResult };\n \"handoff.accept\": { params: HandoffAcceptParams, result: HandoffAcceptResult };\n \"handoff.decline\": { params: HandoffDeclineParams, result: HandoffDeclineResult };\n\n \"control.pause\": { params: ControlPauseParams, result: ControlPauseResult };\n \"control.resume\": { params: ControlResumeParams, result: ControlResumeResult };\n \"control.cancel\": { params: ControlCancelParams, result: ControlCancelResult };\n \"control.supersede\": { params: ControlSupersedeParams, result: ControlSupersedeResult };\n \"control.snapshot\": { params: ControlSnapshotParams, result: ControlSnapshotResult };\n \"control.rollback\": { params: ControlRollbackParams, result: ControlRollbackResult };\n \"control.set_mode_ceiling\": { params: ControlSetModeCeilingParams, result: ControlSetModeCeilingResult };\n\n \"task.route\": { params: TaskRouteParams, result: TaskRouteResult };\n \"review.depth\": { params: ReviewDepthParams, result: ReviewDepthResult };\n \"escalate.auto\": { params: EscalateAutoParams, result: EscalateAutoResult };\n\n \"audit.read\": { params: AuditReadParams, result: AuditReadResult };\n \"audit.submit_to_scitt\": { params: AuditSubmitToScittParams, result: AuditSubmitToScittResult };\n \"audit.verify_receipt\": { params: AuditVerifyReceiptParams, result: AuditVerifyReceiptResult };\n \"audit.verify_chain\": { params: AuditVerifyChainParams, result: AuditVerifyChainResult };\n}\n\nexport type MethodName = keyof MethodTable;\nexport type MethodParams<M extends MethodName> = MethodTable[M][\"params\"];\nexport type MethodResult<M extends MethodName> = MethodTable[M][\"result\"];\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/methods.ts"],"sourcesContent":["/**\n * Typed method definitions.\n *\n * Every CHAP method that ships in either reference implementation\n * gets a typed `Params` and `Result` shape here. The Coordinator's\n * typed facade (`coord.workspace.create`, `coord.task.complete`, …)\n * uses these types so callers get autocomplete and compile-time\n * checking without having to remember field names.\n *\n * These types are hand-maintained against the canonical JSON Schemas\n * under `schemas/`. A future revision will generate this file from\n * the schemas automatically; for now the source of truth remains\n * the running tests under `tests/`.\n *\n * Scope: 39 method handlers shipped by both v0.2 reference\n * implementations (Core + every shipped profile). Spec-only methods\n * are excluded - they would mislead callers into thinking the local\n * Coordinator can dispatch them.\n */\n\nimport type {\n ArtefactId, JsonPatchOp, ParticipantUri, TaskId,\n Workspace, WorkspaceId,\n} from \"./types.js\";\n\n// ---- shared building blocks ---------------------------------------\n\nexport interface WorkspaceParam { workspace: WorkspaceId }\nexport interface ActorParam { from: ParticipantUri }\nexport interface TaskParam { task_id: TaskId }\n\nexport interface OkResult { ok: true }\n\n// ============================================================\n// workspace.*\n// ============================================================\n\nexport interface WorkspaceCreateParams extends Partial<WorkspaceParam> {\n profiles?: string[];\n routing_policy_uri?: string;\n mode?: \"shadow\" | \"trial\" | \"production\";\n mode_ceiling?: \"shadow\" | \"trial\" | \"production\";\n}\nexport interface WorkspaceCreateResult { workspace: WorkspaceId }\n\nexport interface WorkspaceDescribeParams extends WorkspaceParam {}\nexport interface WorkspaceDescribeResult { workspace: Workspace }\n\nexport interface WorkspaceSetProfilesParams extends WorkspaceParam, ActorParam {\n profiles: string[];\n}\nexport type WorkspaceSetProfilesResult = OkResult;\n\n// ============================================================\n// participant.*\n// ============================================================\n\nexport interface ParticipantJoinParams extends WorkspaceParam, ActorParam {\n type: \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n role?: string;\n scopes?: string[];\n capabilities?: Record<string, unknown>;\n oidc_token?: unknown;\n vc?: unknown;\n pubkey?: unknown;\n}\nexport type ParticipantJoinResult = OkResult;\n\nexport interface ParticipantLeaveParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ParticipantLeaveResult = OkResult;\n\nexport interface ParticipantRotateKeyParams extends WorkspaceParam, ActorParam {\n pubkey: unknown;\n reason?: string;\n}\nexport type ParticipantRotateKeyResult = OkResult;\n\nexport interface ParticipantRevokeKeyParams extends WorkspaceParam, ActorParam {\n kid: string;\n reason?: string;\n}\nexport type ParticipantRevokeKeyResult = OkResult;\n\n// ============================================================\n// task.*\n// ============================================================\n\nexport interface TaskCreateParams extends WorkspaceParam, ActorParam {\n kind: string;\n input: unknown;\n assignee?: ParticipantUri;\n to?: ParticipantUri; // alias for assignee\n routing_hints?: Record<string, unknown>;\n deadline?: string;\n idempotency_key?: string;\n}\nexport interface TaskCreateResult { task_id: TaskId }\n\nexport interface TaskUpdateParams extends WorkspaceParam, ActorParam, TaskParam {\n state?: string;\n output?: unknown;\n progress?: Record<string, unknown>;\n}\nexport type TaskUpdateResult = OkResult;\n\nexport interface TaskCompleteParams extends WorkspaceParam, ActorParam, TaskParam {\n output?: unknown;\n confidence?: number | string;\n}\nexport type TaskCompleteResult = OkResult;\n\n// ============================================================\n// review.* and decide.*\n// ============================================================\n\nexport interface ReviewRequestParams extends WorkspaceParam, ActorParam, TaskParam {\n artefact: unknown;\n to: ParticipantUri | ParticipantUri[];\n rule?: string;\n deadline?: string;\n}\nexport interface ReviewRequestResult { state: string; review_id: TaskId }\n\nexport interface DecideApproveParams extends WorkspaceParam, ActorParam, TaskParam {\n rationale?: string;\n}\nexport type DecideApproveResult = OkResult;\n\nexport interface DecideRejectParams extends WorkspaceParam, ActorParam, TaskParam {\n rationale: string;\n category?: string;\n}\nexport type DecideRejectResult = OkResult;\n\nexport interface DecideOverrideParams extends WorkspaceParam, ActorParam, TaskParam {\n diff: JsonPatchOp[];\n rationale: string;\n tags?: string[];\n policy_refs?: string[];\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n based_on_artefact?: unknown;\n}\nexport interface DecideOverrideResult {\n state: \"completed\";\n override_artefact_id: ArtefactId;\n applied: unknown;\n}\n\nexport interface AbstainDeclareParams extends WorkspaceParam, ActorParam, TaskParam {\n category: string;\n rationale?: string;\n}\nexport type AbstainDeclareResult = OkResult;\n\nexport interface EscalateRaiseParams extends WorkspaceParam, ActorParam, TaskParam {\n to?: ParticipantUri;\n rationale?: string;\n}\nexport interface EscalateRaiseResult { ok: true; to?: ParticipantUri }\n\n// ============================================================\n// whisper.* (whisper/1.0)\n// ============================================================\n\nexport interface WhisperAskParams extends WorkspaceParam, ActorParam, TaskParam {\n to: ParticipantUri;\n question: string;\n options?: string[];\n default_on_lapse?: string;\n lapse_ms?: number;\n}\nexport interface WhisperAskResult { whisper_id: string }\n\nexport interface WhisperAnswerParams extends WorkspaceParam, ActorParam {\n whisper_id: string;\n answer: string;\n}\nexport type WhisperAnswerResult = OkResult;\n\n// ============================================================\n// deliberate.* (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberateOpenParams extends WorkspaceParam, ActorParam, TaskParam {\n rule: Record<string, unknown>;\n proposition: unknown;\n voters: ParticipantUri[];\n}\nexport interface DeliberateOpenResult { deliberation_id: string }\n\nexport interface DeliberateCommentParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n text: string;\n}\nexport type DeliberateCommentResult = OkResult;\n\nexport interface DeliberateVoteParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n rationale?: string;\n}\nexport type DeliberateVoteResult = OkResult;\n\nexport interface DeliberateCloseParams extends WorkspaceParam, ActorParam {\n deliberation_id: string;\n}\nexport interface DeliberateCloseResult { outcome: \"approved\" | \"rejected\" | \"no_quorum\" }\n\n// ============================================================\n// handoff.* (handoff/1.0)\n// ============================================================\n\nexport interface HandoffProposeParams extends WorkspaceParam, ActorParam {\n to: ParticipantUri;\n task_ids: TaskId[];\n summary: string;\n active_constraints?: Record<string, unknown>;\n}\nexport interface HandoffProposeResult { handoff_id: string }\n\nexport interface HandoffAcceptParams extends WorkspaceParam, ActorParam {\n handoff_id: string;\n}\nexport type HandoffAcceptResult = OkResult;\n\nexport interface HandoffDeclineParams extends WorkspaceParam, ActorParam {\n handoff_id: string;\n reason?: string;\n}\nexport type HandoffDeclineResult = OkResult;\n\n// ============================================================\n// control.* (control/1.0)\n// ============================================================\n\nexport interface ControlPauseParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ControlPauseResult = OkResult;\n\nexport interface ControlResumeParams extends WorkspaceParam, ActorParam {\n reason?: string;\n}\nexport type ControlResumeResult = OkResult;\n\nexport interface ControlCancelParams extends WorkspaceParam, ActorParam, TaskParam {\n reason?: string;\n}\nexport type ControlCancelResult = OkResult;\n\nexport interface ControlSupersedeParams extends WorkspaceParam, ActorParam, TaskParam {\n replacement: unknown;\n logical_id?: string;\n intent_preserved?: boolean;\n reason?: string;\n}\nexport interface ControlSupersedeResult { artefact_id: ArtefactId }\n\nexport interface ControlSnapshotParams extends WorkspaceParam, ActorParam {\n label?: string;\n}\nexport interface ControlSnapshotResult { snapshot_id: string }\n\nexport interface ControlRollbackParams extends WorkspaceParam, ActorParam {\n snapshot_id: string;\n reason?: string;\n}\nexport type ControlRollbackResult = OkResult;\n\nexport interface ControlSetModeCeilingParams extends WorkspaceParam, ActorParam {\n ceiling: \"shadow\" | \"trial\" | \"production\";\n}\nexport type ControlSetModeCeilingResult = OkResult;\n\n// ============================================================\n// routing.* (routing/1.0)\n// ============================================================\n\nexport interface TaskRouteParams extends WorkspaceParam, ActorParam, TaskParam {\n candidates: ParticipantUri[];\n}\nexport interface TaskRouteResult {\n selected: ParticipantUri;\n rationale: Record<string, unknown>;\n}\n\nexport interface ReviewDepthParams extends WorkspaceParam, ActorParam, TaskParam {\n artefact?: unknown;\n hints?: Record<string, unknown>;\n}\nexport interface ReviewDepthResult {\n depth: \"skip\" | \"spot_check\" | \"full\" | \"escalated\";\n sampling_probability?: number;\n rationale: Record<string, unknown>;\n}\n\nexport interface EscalateAutoParams extends WorkspaceParam, ActorParam, TaskParam {\n hints?: Record<string, unknown>;\n}\nexport interface EscalateAutoResult {\n escalated: boolean;\n to?: ParticipantUri;\n triggered_rule?: Record<string, unknown>;\n}\n\n// ============================================================\n// audit.* (Core + audit-scitt/1.0)\n// ============================================================\n\nexport interface AuditReadParams extends WorkspaceParam {\n from_seq?: number;\n limit?: number;\n}\nexport interface AuditReadResult { entries: unknown[] }\n\nexport interface AuditSubmitToScittParams extends WorkspaceParam, ActorParam {\n seq: number;\n statement?: Record<string, unknown>;\n}\nexport interface AuditSubmitToScittResult { receipt: Record<string, unknown> }\n\nexport interface AuditVerifyReceiptParams extends WorkspaceParam {\n receipt: Record<string, unknown>;\n}\nexport interface AuditVerifyReceiptResult { valid: boolean }\n\nexport interface AuditVerifyChainParams extends WorkspaceParam {\n /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */\n from_seq?: number;\n /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */\n to_seq?: number;\n}\n/**\n * The verdict of a local prev_hash chain replay.\n *\n * `status` is terminal and the three outcomes are mutually exclusive: a\n * broken chain is a JSON-RPC error, an unevaluated range is\n * `not_evaluated`, and `verified` requires complete coverage. A caller\n * reading `ok` alone therefore fails closed on a range that was never\n * checked, instead of taking a pass over entries no evidence covers.\n */\nexport interface AuditVerifyChainResult {\n status: \"verified\" | \"not_evaluated\";\n /** True only when `status` is \"verified\". Never true beside a gap. */\n ok: boolean;\n /** Present only when `status` is \"not_evaluated\". */\n reason?: \"unchained_prefix\";\n entries_total: number;\n entries_checked: number;\n entries_unchecked: number;\n /** Seq of the first entry inside coverage; null when nothing was checked. */\n checked_from_seq: number | null;\n chain_head: string;\n}\n\n// ============================================================\n// Method-name → {params, result} map (single source of truth)\n// ============================================================\n\nexport interface MethodTable {\n \"workspace.create\": { params: WorkspaceCreateParams, result: WorkspaceCreateResult };\n \"workspace.describe\": { params: WorkspaceDescribeParams, result: WorkspaceDescribeResult };\n \"workspace.set_profiles\": { params: WorkspaceSetProfilesParams, result: WorkspaceSetProfilesResult };\n\n \"participant.join\": { params: ParticipantJoinParams, result: ParticipantJoinResult };\n \"participant.leave\": { params: ParticipantLeaveParams, result: ParticipantLeaveResult };\n \"participant.rotate_key\": { params: ParticipantRotateKeyParams, result: ParticipantRotateKeyResult };\n \"participant.revoke_key\": { params: ParticipantRevokeKeyParams, result: ParticipantRevokeKeyResult };\n\n \"task.create\": { params: TaskCreateParams, result: TaskCreateResult };\n \"task.update\": { params: TaskUpdateParams, result: TaskUpdateResult };\n \"task.complete\": { params: TaskCompleteParams, result: TaskCompleteResult };\n\n \"review.request\": { params: ReviewRequestParams, result: ReviewRequestResult };\n \"decide.approve\": { params: DecideApproveParams, result: DecideApproveResult };\n \"decide.reject\": { params: DecideRejectParams, result: DecideRejectResult };\n \"decide.override\": { params: DecideOverrideParams, result: DecideOverrideResult };\n \"abstain.declare\": { params: AbstainDeclareParams, result: AbstainDeclareResult };\n \"escalate.raise\": { params: EscalateRaiseParams, result: EscalateRaiseResult };\n\n \"whisper.ask\": { params: WhisperAskParams, result: WhisperAskResult };\n \"whisper.answer\": { params: WhisperAnswerParams, result: WhisperAnswerResult };\n\n \"deliberate.open\": { params: DeliberateOpenParams, result: DeliberateOpenResult };\n \"deliberate.comment\": { params: DeliberateCommentParams, result: DeliberateCommentResult };\n \"deliberate.vote\": { params: DeliberateVoteParams, result: DeliberateVoteResult };\n \"deliberate.close\": { params: DeliberateCloseParams, result: DeliberateCloseResult };\n\n \"handoff.propose\": { params: HandoffProposeParams, result: HandoffProposeResult };\n \"handoff.accept\": { params: HandoffAcceptParams, result: HandoffAcceptResult };\n \"handoff.decline\": { params: HandoffDeclineParams, result: HandoffDeclineResult };\n\n \"control.pause\": { params: ControlPauseParams, result: ControlPauseResult };\n \"control.resume\": { params: ControlResumeParams, result: ControlResumeResult };\n \"control.cancel\": { params: ControlCancelParams, result: ControlCancelResult };\n \"control.supersede\": { params: ControlSupersedeParams, result: ControlSupersedeResult };\n \"control.snapshot\": { params: ControlSnapshotParams, result: ControlSnapshotResult };\n \"control.rollback\": { params: ControlRollbackParams, result: ControlRollbackResult };\n \"control.set_mode_ceiling\": { params: ControlSetModeCeilingParams, result: ControlSetModeCeilingResult };\n\n \"task.route\": { params: TaskRouteParams, result: TaskRouteResult };\n \"review.depth\": { params: ReviewDepthParams, result: ReviewDepthResult };\n \"escalate.auto\": { params: EscalateAutoParams, result: EscalateAutoResult };\n\n \"audit.read\": { params: AuditReadParams, result: AuditReadResult };\n \"audit.submit_to_scitt\": { params: AuditSubmitToScittParams, result: AuditSubmitToScittResult };\n \"audit.verify_receipt\": { params: AuditVerifyReceiptParams, result: AuditVerifyReceiptResult };\n \"audit.verify_chain\": { params: AuditVerifyChainParams, result: AuditVerifyChainResult };\n}\n\nexport type MethodName = keyof MethodTable;\nexport type MethodParams<M extends MethodName> = MethodTable[M][\"params\"];\nexport type MethodResult<M extends MethodName> = MethodTable[M][\"result\"];\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -81,6 +81,7 @@ interface TaskCreateParams extends WorkspaceParam, ActorParam {
81
81
  to?: ParticipantUri;
82
82
  routing_hints?: Record<string, unknown>;
83
83
  deadline?: string;
84
+ idempotency_key?: string;
84
85
  }
85
86
  interface TaskCreateResult {
86
87
  task_id: TaskId;
@@ -283,12 +284,32 @@ interface AuditVerifyReceiptResult {
283
284
  valid: boolean;
284
285
  }
285
286
  interface AuditVerifyChainParams extends WorkspaceParam {
287
+ /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */
286
288
  from_seq?: number;
289
+ /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */
287
290
  to_seq?: number;
288
291
  }
292
+ /**
293
+ * The verdict of a local prev_hash chain replay.
294
+ *
295
+ * `status` is terminal and the three outcomes are mutually exclusive: a
296
+ * broken chain is a JSON-RPC error, an unevaluated range is
297
+ * `not_evaluated`, and `verified` requires complete coverage. A caller
298
+ * reading `ok` alone therefore fails closed on a range that was never
299
+ * checked, instead of taking a pass over entries no evidence covers.
300
+ */
289
301
  interface AuditVerifyChainResult {
290
- valid: boolean;
291
- breaks?: number[];
302
+ status: "verified" | "not_evaluated";
303
+ /** True only when `status` is "verified". Never true beside a gap. */
304
+ ok: boolean;
305
+ /** Present only when `status` is "not_evaluated". */
306
+ reason?: "unchained_prefix";
307
+ entries_total: number;
308
+ entries_checked: number;
309
+ entries_unchecked: number;
310
+ /** Seq of the first entry inside coverage; null when nothing was checked. */
311
+ checked_from_seq: number | null;
312
+ chain_head: string;
292
313
  }
293
314
  interface MethodTable {
294
315
  "workspace.create": {
package/dist/methods.d.ts CHANGED
@@ -81,6 +81,7 @@ interface TaskCreateParams extends WorkspaceParam, ActorParam {
81
81
  to?: ParticipantUri;
82
82
  routing_hints?: Record<string, unknown>;
83
83
  deadline?: string;
84
+ idempotency_key?: string;
84
85
  }
85
86
  interface TaskCreateResult {
86
87
  task_id: TaskId;
@@ -283,12 +284,32 @@ interface AuditVerifyReceiptResult {
283
284
  valid: boolean;
284
285
  }
285
286
  interface AuditVerifyChainParams extends WorkspaceParam {
287
+ /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */
286
288
  from_seq?: number;
289
+ /** Not implemented. Supplying either is refused; see SPECIFICATION.md 10.2. */
287
290
  to_seq?: number;
288
291
  }
292
+ /**
293
+ * The verdict of a local prev_hash chain replay.
294
+ *
295
+ * `status` is terminal and the three outcomes are mutually exclusive: a
296
+ * broken chain is a JSON-RPC error, an unevaluated range is
297
+ * `not_evaluated`, and `verified` requires complete coverage. A caller
298
+ * reading `ok` alone therefore fails closed on a range that was never
299
+ * checked, instead of taking a pass over entries no evidence covers.
300
+ */
289
301
  interface AuditVerifyChainResult {
290
- valid: boolean;
291
- breaks?: number[];
302
+ status: "verified" | "not_evaluated";
303
+ /** True only when `status` is "verified". Never true beside a gap. */
304
+ ok: boolean;
305
+ /** Present only when `status` is "not_evaluated". */
306
+ reason?: "unchained_prefix";
307
+ entries_total: number;
308
+ entries_checked: number;
309
+ entries_unchecked: number;
310
+ /** Seq of the first entry inside coverage; null when nothing was checked. */
311
+ checked_from_seq: number | null;
312
+ chain_head: string;
292
313
  }
293
314
  interface MethodTable {
294
315
  "workspace.create": {
@@ -23,6 +23,8 @@ __export(sqlite_exports, {
23
23
  SqliteStore: () => SqliteStore
24
24
  });
25
25
  module.exports = __toCommonJS(sqlite_exports);
26
+ var import_node_module = require("module");
27
+ var import_meta = {};
26
28
  var SqliteStore = class {
27
29
  db;
28
30
  stmtLoad;
@@ -31,10 +33,11 @@ var SqliteStore = class {
31
33
  constructor(path, options = {}) {
32
34
  let Database;
33
35
  try {
34
- Database = require("better-sqlite3");
36
+ Database = (0, import_node_module.createRequire)(import_meta.url)("better-sqlite3");
35
37
  } catch (err) {
38
+ const detail = err instanceof Error ? `: ${err.message.split("\n")[0]}` : "";
36
39
  throw new Error(
37
- "SqliteStore requires the `better-sqlite3` package. Install it with `npm install better-sqlite3` or use MemoryStore for non-persistent workloads."
40
+ `SqliteStore requires the \`better-sqlite3\` package. Install it with \`npm install better-sqlite3\` or use MemoryStore for non-persistent workloads${detail}`
38
41
  );
39
42
  }
40
43
  this.db = new Database(path);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/sqlite.ts"],"sourcesContent":["/**\n * SQLite-backed store using better-sqlite3.\n *\n * Schema:\n * CREATE TABLE chap_workspaces (\n * id TEXT PRIMARY KEY,\n * data TEXT NOT NULL, -- JSON.stringify of snapshot\n * version INTEGER NOT NULL,\n * updated_at TEXT NOT NULL -- ISO-8601\n * )\n *\n * Usage:\n * import { Coordinator } from \"@brightbeamai/chap-coordinator\";\n * import { SqliteStore } from \"@brightbeamai/chap-coordinator/storage/sqlite\";\n *\n * const coord = new Coordinator({\n * store: new SqliteStore(\"./chap.db\"),\n * });\n *\n * Pass `\":memory:\"` for an in-memory SQLite instance (faster than the\n * MemoryStore for tests that need transactional semantics).\n *\n * better-sqlite3 is declared as an optionalDependency. If the binary\n * cannot be built (rare on Linux/macOS, common on locked-down CI), the\n * SqliteStore import will throw with a clear message and applications\n * can fall back to MemoryStore or another implementation.\n */\n\nimport type { Store, WorkspaceRecord } from \"./store.js\";\n\n// better-sqlite3 has no published types in its own package, but the\n// `@types/better-sqlite3` package provides them. We require a structural\n// subset so the file type-checks even if the typings are absent.\ninterface SqliteDatabase {\n exec(sql: string): unknown;\n prepare(sql: string): SqliteStatement;\n pragma(name: string, options?: { simple?: boolean }): unknown;\n close(): void;\n}\ninterface SqliteStatement {\n run(...params: unknown[]): { changes: number; lastInsertRowid: number | bigint };\n get(...params: unknown[]): unknown;\n all(...params: unknown[]): unknown[];\n}\n\nexport interface SqliteStoreOptions {\n /**\n * Enable WAL journal mode for better concurrent-read performance.\n * Default true. Set false for `:memory:` databases or when the\n * filesystem does not support WAL (some network filesystems).\n */\n wal?: boolean;\n}\n\nexport class SqliteStore implements Store {\n readonly db: SqliteDatabase;\n private readonly stmtLoad: SqliteStatement;\n private readonly stmtSave: SqliteStatement;\n private readonly stmtDelete: SqliteStatement;\n\n constructor(path: string, options: SqliteStoreOptions = {}) {\n let Database: new (path: string) => SqliteDatabase;\n try {\n // require() is used so the dependency stays optional. ESM consumers\n // can still load this file; the actual import is dynamic.\n Database = require(\"better-sqlite3\");\n } catch (err) {\n throw new Error(\n \"SqliteStore requires the `better-sqlite3` package. \" +\n \"Install it with `npm install better-sqlite3` \" +\n \"or use MemoryStore for non-persistent workloads.\",\n );\n }\n\n this.db = new Database(path);\n if (path !== \":memory:\" && options.wal !== false) {\n this.db.pragma(\"journal_mode = WAL\");\n }\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS chap_workspaces (\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n version INTEGER NOT NULL,\n updated_at TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS idx_chap_workspaces_updated_at\n ON chap_workspaces (updated_at);\n `);\n\n this.stmtLoad = this.db.prepare(\n \"SELECT id, data, version, updated_at FROM chap_workspaces\",\n );\n this.stmtSave = this.db.prepare(\n \"INSERT INTO chap_workspaces (id, data, version, updated_at) \" +\n \"VALUES (?, ?, ?, ?) \" +\n \"ON CONFLICT(id) DO UPDATE SET \" +\n \"data = excluded.data, \" +\n \"version = excluded.version, \" +\n \"updated_at = excluded.updated_at\",\n );\n this.stmtDelete = this.db.prepare(\n \"DELETE FROM chap_workspaces WHERE id = ?\",\n );\n }\n\n load(): WorkspaceRecord[] {\n const rows = this.stmtLoad.all() as Array<{\n id: string;\n data: string;\n version: number;\n updated_at: string;\n }>;\n const out: WorkspaceRecord[] = [];\n for (const r of rows) {\n try {\n out.push({ id: r.id, data: JSON.parse(r.data), version: r.version, updated_at: r.updated_at });\n } catch {\n // A single unreadable row must not discard every other workspace; skip it.\n }\n }\n return out;\n }\n\n save(record: WorkspaceRecord): void {\n this.stmtSave.run(\n record.id,\n JSON.stringify(record.data),\n record.version,\n record.updated_at,\n );\n }\n\n delete(id: string): void {\n this.stmtDelete.run(id);\n }\n\n close(): void {\n this.db.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDO,IAAM,cAAN,MAAmC;AAAA,EAC/B;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,MAAc,UAA8B,CAAC,GAAG;AAC1D,QAAI;AACJ,QAAI;AAGF,iBAAW,QAAQ,gBAAgB;AAAA,IACrC,SAAS,KAAK;AACZ,YAAM,IAAI;AAAA,QACR;AAAA,MAGF;AAAA,IACF;AAEA,SAAK,KAAK,IAAI,SAAS,IAAI;AAC3B,QAAI,SAAS,cAAc,QAAQ,QAAQ,OAAO;AAChD,WAAK,GAAG,OAAO,oBAAoB;AAAA,IACrC;AACA,SAAK,GAAG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KASZ;AAED,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IACF;AACA,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IAMF;AACA,SAAK,aAAa,KAAK,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAA0B;AACxB,UAAM,OAAO,KAAK,SAAS,IAAI;AAM/B,UAAM,MAAyB,CAAC;AAChC,eAAW,KAAK,MAAM;AACpB,UAAI;AACF,YAAI,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,KAAK,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,YAAY,EAAE,WAAW,CAAC;AAAA,MAC/F,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,SAAS;AAAA,MACZ,OAAO;AAAA,MACP,KAAK,UAAU,OAAO,IAAI;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,WAAW,IAAI,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/storage/sqlite.ts"],"sourcesContent":["/**\n * SQLite-backed store using better-sqlite3.\n *\n * Schema:\n * CREATE TABLE chap_workspaces (\n * id TEXT PRIMARY KEY,\n * data TEXT NOT NULL, -- JSON.stringify of snapshot\n * version INTEGER NOT NULL,\n * updated_at TEXT NOT NULL -- ISO-8601\n * )\n *\n * Usage:\n * import { Coordinator } from \"@brightbeamai/chap-coordinator\";\n * import { SqliteStore } from \"@brightbeamai/chap-coordinator/storage/sqlite\";\n *\n * const coord = new Coordinator({\n * store: new SqliteStore(\"./chap.db\"),\n * });\n *\n * Pass `\":memory:\"` for an in-memory SQLite instance (faster than the\n * MemoryStore for tests that need transactional semantics).\n *\n * better-sqlite3 is declared as an optionalDependency. If the binary\n * cannot be built (rare on Linux/macOS, common on locked-down CI), the\n * SqliteStore import will throw with a clear message and applications\n * can fall back to MemoryStore or another implementation.\n */\n\nimport { createRequire } from \"node:module\";\nimport type { Store, WorkspaceRecord } from \"./store.js\";\n\n// better-sqlite3 has no published types in its own package, but the\n// `@types/better-sqlite3` package provides them. We require a structural\n// subset so the file type-checks even if the typings are absent.\ninterface SqliteDatabase {\n exec(sql: string): unknown;\n prepare(sql: string): SqliteStatement;\n pragma(name: string, options?: { simple?: boolean }): unknown;\n close(): void;\n}\ninterface SqliteStatement {\n run(...params: unknown[]): { changes: number; lastInsertRowid: number | bigint };\n get(...params: unknown[]): unknown;\n all(...params: unknown[]): unknown[];\n}\n\nexport interface SqliteStoreOptions {\n /**\n * Enable WAL journal mode for better concurrent-read performance.\n * Default true. Set false for `:memory:` databases or when the\n * filesystem does not support WAL (some network filesystems).\n */\n wal?: boolean;\n}\n\nexport class SqliteStore implements Store {\n readonly db: SqliteDatabase;\n private readonly stmtLoad: SqliteStatement;\n private readonly stmtSave: SqliteStatement;\n private readonly stmtDelete: SqliteStatement;\n\n constructor(path: string, options: SqliteStoreOptions = {}) {\n let Database: new (path: string) => SqliteDatabase;\n try {\n // Resolved at construction so the dependency stays optional: importing\n // this module costs nothing if you never build a SqliteStore.\n //\n // createRequire rather than a bare require(). A bare one is undefined in\n // an ES module, so from source it threw ReferenceError and this catch\n // reported the dependency as missing when it was installed. The bundled\n // build masked it by shimming require, which is why it went unnoticed.\n Database = createRequire(import.meta.url)(\"better-sqlite3\");\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message.split(\"\\n\")[0]}` : \"\";\n throw new Error(\n \"SqliteStore requires the `better-sqlite3` package. \" +\n \"Install it with `npm install better-sqlite3` \" +\n `or use MemoryStore for non-persistent workloads${detail}`,\n );\n }\n\n this.db = new Database(path);\n if (path !== \":memory:\" && options.wal !== false) {\n this.db.pragma(\"journal_mode = WAL\");\n }\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS chap_workspaces (\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n version INTEGER NOT NULL,\n updated_at TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS idx_chap_workspaces_updated_at\n ON chap_workspaces (updated_at);\n `);\n\n this.stmtLoad = this.db.prepare(\n \"SELECT id, data, version, updated_at FROM chap_workspaces\",\n );\n this.stmtSave = this.db.prepare(\n \"INSERT INTO chap_workspaces (id, data, version, updated_at) \" +\n \"VALUES (?, ?, ?, ?) \" +\n \"ON CONFLICT(id) DO UPDATE SET \" +\n \"data = excluded.data, \" +\n \"version = excluded.version, \" +\n \"updated_at = excluded.updated_at\",\n );\n this.stmtDelete = this.db.prepare(\n \"DELETE FROM chap_workspaces WHERE id = ?\",\n );\n }\n\n load(): WorkspaceRecord[] {\n const rows = this.stmtLoad.all() as Array<{\n id: string;\n data: string;\n version: number;\n updated_at: string;\n }>;\n const out: WorkspaceRecord[] = [];\n for (const r of rows) {\n try {\n out.push({ id: r.id, data: JSON.parse(r.data), version: r.version, updated_at: r.updated_at });\n } catch {\n // A single unreadable row must not discard every other workspace; skip it.\n }\n }\n return out;\n }\n\n save(record: WorkspaceRecord): void {\n this.stmtSave.run(\n record.id,\n JSON.stringify(record.data),\n record.version,\n record.updated_at,\n );\n }\n\n delete(id: string): void {\n this.stmtDelete.run(id);\n }\n\n close(): void {\n this.db.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BA,yBAA8B;AA5B9B;AAuDO,IAAM,cAAN,MAAmC;AAAA,EAC/B;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,MAAc,UAA8B,CAAC,GAAG;AAC1D,QAAI;AACJ,QAAI;AAQF,qBAAW,kCAAc,YAAY,GAAG,EAAE,gBAAgB;AAAA,IAC5D,SAAS,KAAK;AACZ,YAAM,SAAS,eAAe,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK;AAC1E,YAAM,IAAI;AAAA,QACR,sJAEkD,MAAM;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,KAAK,IAAI,SAAS,IAAI;AAC3B,QAAI,SAAS,cAAc,QAAQ,QAAQ,OAAO;AAChD,WAAK,GAAG,OAAO,oBAAoB;AAAA,IACrC;AACA,SAAK,GAAG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KASZ;AAED,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IACF;AACA,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IAMF;AACA,SAAK,aAAa,KAAK,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAA0B;AACxB,UAAM,OAAO,KAAK,SAAS,IAAI;AAM/B,UAAM,MAAyB,CAAC;AAChC,eAAW,KAAK,MAAM;AACpB,UAAI;AACF,YAAI,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,KAAK,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,YAAY,EAAE,WAAW,CAAC;AAAA,MAC/F,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,SAAS;AAAA,MACZ,OAAO;AAAA,MACP,KAAK,UAAU,OAAO,IAAI;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,WAAW,IAAI,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
@@ -1,11 +1,5 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/storage/sqlite.ts
2
+ import { createRequire } from "module";
9
3
  var SqliteStore = class {
10
4
  db;
11
5
  stmtLoad;
@@ -14,10 +8,11 @@ var SqliteStore = class {
14
8
  constructor(path, options = {}) {
15
9
  let Database;
16
10
  try {
17
- Database = __require("better-sqlite3");
11
+ Database = createRequire(import.meta.url)("better-sqlite3");
18
12
  } catch (err) {
13
+ const detail = err instanceof Error ? `: ${err.message.split("\n")[0]}` : "";
19
14
  throw new Error(
20
- "SqliteStore requires the `better-sqlite3` package. Install it with `npm install better-sqlite3` or use MemoryStore for non-persistent workloads."
15
+ `SqliteStore requires the \`better-sqlite3\` package. Install it with \`npm install better-sqlite3\` or use MemoryStore for non-persistent workloads${detail}`
21
16
  );
22
17
  }
23
18
  this.db = new Database(path);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/sqlite.ts"],"sourcesContent":["/**\n * SQLite-backed store using better-sqlite3.\n *\n * Schema:\n * CREATE TABLE chap_workspaces (\n * id TEXT PRIMARY KEY,\n * data TEXT NOT NULL, -- JSON.stringify of snapshot\n * version INTEGER NOT NULL,\n * updated_at TEXT NOT NULL -- ISO-8601\n * )\n *\n * Usage:\n * import { Coordinator } from \"@brightbeamai/chap-coordinator\";\n * import { SqliteStore } from \"@brightbeamai/chap-coordinator/storage/sqlite\";\n *\n * const coord = new Coordinator({\n * store: new SqliteStore(\"./chap.db\"),\n * });\n *\n * Pass `\":memory:\"` for an in-memory SQLite instance (faster than the\n * MemoryStore for tests that need transactional semantics).\n *\n * better-sqlite3 is declared as an optionalDependency. If the binary\n * cannot be built (rare on Linux/macOS, common on locked-down CI), the\n * SqliteStore import will throw with a clear message and applications\n * can fall back to MemoryStore or another implementation.\n */\n\nimport type { Store, WorkspaceRecord } from \"./store.js\";\n\n// better-sqlite3 has no published types in its own package, but the\n// `@types/better-sqlite3` package provides them. We require a structural\n// subset so the file type-checks even if the typings are absent.\ninterface SqliteDatabase {\n exec(sql: string): unknown;\n prepare(sql: string): SqliteStatement;\n pragma(name: string, options?: { simple?: boolean }): unknown;\n close(): void;\n}\ninterface SqliteStatement {\n run(...params: unknown[]): { changes: number; lastInsertRowid: number | bigint };\n get(...params: unknown[]): unknown;\n all(...params: unknown[]): unknown[];\n}\n\nexport interface SqliteStoreOptions {\n /**\n * Enable WAL journal mode for better concurrent-read performance.\n * Default true. Set false for `:memory:` databases or when the\n * filesystem does not support WAL (some network filesystems).\n */\n wal?: boolean;\n}\n\nexport class SqliteStore implements Store {\n readonly db: SqliteDatabase;\n private readonly stmtLoad: SqliteStatement;\n private readonly stmtSave: SqliteStatement;\n private readonly stmtDelete: SqliteStatement;\n\n constructor(path: string, options: SqliteStoreOptions = {}) {\n let Database: new (path: string) => SqliteDatabase;\n try {\n // require() is used so the dependency stays optional. ESM consumers\n // can still load this file; the actual import is dynamic.\n Database = require(\"better-sqlite3\");\n } catch (err) {\n throw new Error(\n \"SqliteStore requires the `better-sqlite3` package. \" +\n \"Install it with `npm install better-sqlite3` \" +\n \"or use MemoryStore for non-persistent workloads.\",\n );\n }\n\n this.db = new Database(path);\n if (path !== \":memory:\" && options.wal !== false) {\n this.db.pragma(\"journal_mode = WAL\");\n }\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS chap_workspaces (\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n version INTEGER NOT NULL,\n updated_at TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS idx_chap_workspaces_updated_at\n ON chap_workspaces (updated_at);\n `);\n\n this.stmtLoad = this.db.prepare(\n \"SELECT id, data, version, updated_at FROM chap_workspaces\",\n );\n this.stmtSave = this.db.prepare(\n \"INSERT INTO chap_workspaces (id, data, version, updated_at) \" +\n \"VALUES (?, ?, ?, ?) \" +\n \"ON CONFLICT(id) DO UPDATE SET \" +\n \"data = excluded.data, \" +\n \"version = excluded.version, \" +\n \"updated_at = excluded.updated_at\",\n );\n this.stmtDelete = this.db.prepare(\n \"DELETE FROM chap_workspaces WHERE id = ?\",\n );\n }\n\n load(): WorkspaceRecord[] {\n const rows = this.stmtLoad.all() as Array<{\n id: string;\n data: string;\n version: number;\n updated_at: string;\n }>;\n const out: WorkspaceRecord[] = [];\n for (const r of rows) {\n try {\n out.push({ id: r.id, data: JSON.parse(r.data), version: r.version, updated_at: r.updated_at });\n } catch {\n // A single unreadable row must not discard every other workspace; skip it.\n }\n }\n return out;\n }\n\n save(record: WorkspaceRecord): void {\n this.stmtSave.run(\n record.id,\n JSON.stringify(record.data),\n record.version,\n record.updated_at,\n );\n }\n\n delete(id: string): void {\n this.stmtDelete.run(id);\n }\n\n close(): void {\n this.db.close();\n }\n}\n"],"mappings":";;;;;;;;AAsDO,IAAM,cAAN,MAAmC;AAAA,EAC/B;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,MAAc,UAA8B,CAAC,GAAG;AAC1D,QAAI;AACJ,QAAI;AAGF,iBAAW,UAAQ,gBAAgB;AAAA,IACrC,SAAS,KAAK;AACZ,YAAM,IAAI;AAAA,QACR;AAAA,MAGF;AAAA,IACF;AAEA,SAAK,KAAK,IAAI,SAAS,IAAI;AAC3B,QAAI,SAAS,cAAc,QAAQ,QAAQ,OAAO;AAChD,WAAK,GAAG,OAAO,oBAAoB;AAAA,IACrC;AACA,SAAK,GAAG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KASZ;AAED,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IACF;AACA,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IAMF;AACA,SAAK,aAAa,KAAK,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAA0B;AACxB,UAAM,OAAO,KAAK,SAAS,IAAI;AAM/B,UAAM,MAAyB,CAAC;AAChC,eAAW,KAAK,MAAM;AACpB,UAAI;AACF,YAAI,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,KAAK,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,YAAY,EAAE,WAAW,CAAC;AAAA,MAC/F,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,SAAS;AAAA,MACZ,OAAO;AAAA,MACP,KAAK,UAAU,OAAO,IAAI;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,WAAW,IAAI,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/storage/sqlite.ts"],"sourcesContent":["/**\n * SQLite-backed store using better-sqlite3.\n *\n * Schema:\n * CREATE TABLE chap_workspaces (\n * id TEXT PRIMARY KEY,\n * data TEXT NOT NULL, -- JSON.stringify of snapshot\n * version INTEGER NOT NULL,\n * updated_at TEXT NOT NULL -- ISO-8601\n * )\n *\n * Usage:\n * import { Coordinator } from \"@brightbeamai/chap-coordinator\";\n * import { SqliteStore } from \"@brightbeamai/chap-coordinator/storage/sqlite\";\n *\n * const coord = new Coordinator({\n * store: new SqliteStore(\"./chap.db\"),\n * });\n *\n * Pass `\":memory:\"` for an in-memory SQLite instance (faster than the\n * MemoryStore for tests that need transactional semantics).\n *\n * better-sqlite3 is declared as an optionalDependency. If the binary\n * cannot be built (rare on Linux/macOS, common on locked-down CI), the\n * SqliteStore import will throw with a clear message and applications\n * can fall back to MemoryStore or another implementation.\n */\n\nimport { createRequire } from \"node:module\";\nimport type { Store, WorkspaceRecord } from \"./store.js\";\n\n// better-sqlite3 has no published types in its own package, but the\n// `@types/better-sqlite3` package provides them. We require a structural\n// subset so the file type-checks even if the typings are absent.\ninterface SqliteDatabase {\n exec(sql: string): unknown;\n prepare(sql: string): SqliteStatement;\n pragma(name: string, options?: { simple?: boolean }): unknown;\n close(): void;\n}\ninterface SqliteStatement {\n run(...params: unknown[]): { changes: number; lastInsertRowid: number | bigint };\n get(...params: unknown[]): unknown;\n all(...params: unknown[]): unknown[];\n}\n\nexport interface SqliteStoreOptions {\n /**\n * Enable WAL journal mode for better concurrent-read performance.\n * Default true. Set false for `:memory:` databases or when the\n * filesystem does not support WAL (some network filesystems).\n */\n wal?: boolean;\n}\n\nexport class SqliteStore implements Store {\n readonly db: SqliteDatabase;\n private readonly stmtLoad: SqliteStatement;\n private readonly stmtSave: SqliteStatement;\n private readonly stmtDelete: SqliteStatement;\n\n constructor(path: string, options: SqliteStoreOptions = {}) {\n let Database: new (path: string) => SqliteDatabase;\n try {\n // Resolved at construction so the dependency stays optional: importing\n // this module costs nothing if you never build a SqliteStore.\n //\n // createRequire rather than a bare require(). A bare one is undefined in\n // an ES module, so from source it threw ReferenceError and this catch\n // reported the dependency as missing when it was installed. The bundled\n // build masked it by shimming require, which is why it went unnoticed.\n Database = createRequire(import.meta.url)(\"better-sqlite3\");\n } catch (err) {\n const detail = err instanceof Error ? `: ${err.message.split(\"\\n\")[0]}` : \"\";\n throw new Error(\n \"SqliteStore requires the `better-sqlite3` package. \" +\n \"Install it with `npm install better-sqlite3` \" +\n `or use MemoryStore for non-persistent workloads${detail}`,\n );\n }\n\n this.db = new Database(path);\n if (path !== \":memory:\" && options.wal !== false) {\n this.db.pragma(\"journal_mode = WAL\");\n }\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS chap_workspaces (\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n version INTEGER NOT NULL,\n updated_at TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS idx_chap_workspaces_updated_at\n ON chap_workspaces (updated_at);\n `);\n\n this.stmtLoad = this.db.prepare(\n \"SELECT id, data, version, updated_at FROM chap_workspaces\",\n );\n this.stmtSave = this.db.prepare(\n \"INSERT INTO chap_workspaces (id, data, version, updated_at) \" +\n \"VALUES (?, ?, ?, ?) \" +\n \"ON CONFLICT(id) DO UPDATE SET \" +\n \"data = excluded.data, \" +\n \"version = excluded.version, \" +\n \"updated_at = excluded.updated_at\",\n );\n this.stmtDelete = this.db.prepare(\n \"DELETE FROM chap_workspaces WHERE id = ?\",\n );\n }\n\n load(): WorkspaceRecord[] {\n const rows = this.stmtLoad.all() as Array<{\n id: string;\n data: string;\n version: number;\n updated_at: string;\n }>;\n const out: WorkspaceRecord[] = [];\n for (const r of rows) {\n try {\n out.push({ id: r.id, data: JSON.parse(r.data), version: r.version, updated_at: r.updated_at });\n } catch {\n // A single unreadable row must not discard every other workspace; skip it.\n }\n }\n return out;\n }\n\n save(record: WorkspaceRecord): void {\n this.stmtSave.run(\n record.id,\n JSON.stringify(record.data),\n record.version,\n record.updated_at,\n );\n }\n\n delete(id: string): void {\n this.stmtDelete.run(id);\n }\n\n close(): void {\n this.db.close();\n }\n}\n"],"mappings":";AA4BA,SAAS,qBAAqB;AA2BvB,IAAM,cAAN,MAAmC;AAAA,EAC/B;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,MAAc,UAA8B,CAAC,GAAG;AAC1D,QAAI;AACJ,QAAI;AAQF,iBAAW,cAAc,YAAY,GAAG,EAAE,gBAAgB;AAAA,IAC5D,SAAS,KAAK;AACZ,YAAM,SAAS,eAAe,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK;AAC1E,YAAM,IAAI;AAAA,QACR,sJAEkD,MAAM;AAAA,MAC1D;AAAA,IACF;AAEA,SAAK,KAAK,IAAI,SAAS,IAAI;AAC3B,QAAI,SAAS,cAAc,QAAQ,QAAQ,OAAO;AAChD,WAAK,GAAG,OAAO,oBAAoB;AAAA,IACrC;AACA,SAAK,GAAG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KASZ;AAED,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IACF;AACA,SAAK,WAAW,KAAK,GAAG;AAAA,MACtB;AAAA,IAMF;AACA,SAAK,aAAa,KAAK,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAA0B;AACxB,UAAM,OAAO,KAAK,SAAS,IAAI;AAM/B,UAAM,MAAyB,CAAC;AAChC,eAAW,KAAK,MAAM;AACpB,UAAI;AACF,YAAI,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,KAAK,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,YAAY,EAAE,WAAW,CAAC;AAAA,MAC/F,QAAQ;AAAA,MAER;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,SAAS;AAAA,MACZ,OAAO;AAAA,MACP,KAAK,UAAU,OAAO,IAAI;AAAA,MAC1B,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,WAAW,IAAI,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/store.ts"],"sourcesContent":["/**\n * Pluggable persistence for the Coordinator.\n *\n * A Store persists workspace state between process restarts. Coordinators\n * call `store.save(workspaceId, snapshot)` after every mutation that\n * appends to the audit chain, and `store.load()` on startup to restore.\n *\n * Two implementations ship in-tree:\n * - MemoryStore (default, no persistence; existing behaviour)\n * - SqliteStore (real SQLite via better-sqlite3, opt-in)\n *\n * Third-party stores (Postgres, Redis, etc.) implement this interface.\n *\n * Stores hold per-workspace JSON snapshots, not a decomposed relational\n * model. The Coordinator's snapshot/restore methods produce JSON-safe\n * payloads; this is fast for workspaces in the low-thousands of audit\n * entries and trades query flexibility for simplicity. Production\n * deployments needing rich query semantics should project the audit log\n * into their own analytics store via the `onAudit` listener.\n */\n\nexport interface WorkspaceRecord {\n /** Workspace identifier. */\n id: string;\n /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */\n data: unknown;\n /** Monotonically increasing version for optimistic concurrency. */\n version: number;\n /** Wall-clock timestamp of the last write, ISO-8601. */\n updated_at: string;\n}\n\nexport interface Store {\n /** Load all workspace records into memory. Called once on coordinator start. */\n load(): Promise<WorkspaceRecord[]> | WorkspaceRecord[];\n\n /** Persist one workspace record. Called after every mutation. */\n save(record: WorkspaceRecord): Promise<void> | void;\n\n /** Remove one workspace. Used by `workspace.delete` semantics (not in v0.2). */\n delete(id: string): Promise<void> | void;\n\n /** Release resources. Idempotent. */\n close?(): Promise<void> | void;\n}\n\n/**\n * In-memory store. Default behaviour: no persistence, fast tests.\n * State lives in a Map; closing it discards everything.\n */\nexport class MemoryStore implements Store {\n private records = new Map<string, WorkspaceRecord>();\n\n load(): WorkspaceRecord[] {\n return Array.from(this.records.values());\n }\n\n save(record: WorkspaceRecord): void {\n this.records.set(record.id, record);\n }\n\n delete(id: string): void {\n this.records.delete(id);\n }\n\n close(): void {\n this.records.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDO,IAAM,cAAN,MAAmC;AAAA,EAChC,UAAU,oBAAI,IAA6B;AAAA,EAEnD,OAA0B;AACxB,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;AAAA,EACpC;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,QAAQ,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/storage/store.ts"],"sourcesContent":["/**\n * Pluggable persistence for the Coordinator.\n *\n * A Store persists workspace state between process restarts. Coordinators\n * call `store.save(workspaceId, snapshot)` after every mutation that\n * appends to the audit chain, and `store.load()` on startup to restore.\n *\n * Two implementations ship in-tree:\n * - MemoryStore (default, no persistence; existing behaviour)\n * - SqliteStore (real SQLite via better-sqlite3, opt-in)\n *\n * Third-party stores (Postgres, Redis, etc.) implement this interface.\n *\n * Concurrency model\n * -----------------\n *\n * A Coordinator is a **single-writer** component: dispatch is serial, workspace\n * state is held in memory, and each chain link is computed from the head the\n * instance holds. This interface is a persistence mechanism, not a\n * concurrency-control one. `save` is an unconditional write and no\n * implementation rejects a stale record.\n *\n * Running two or more Coordinator instances against one shared store is\n * therefore not supported. A stale instance's write replaces a newer one\n * wholesale: entries written by the other instance are lost, the chain is\n * re-linked from the surviving head, and `audit.verify_chain` still reports\n * `ok`, because the surviving chain is internally consistent. The loss is\n * silent and CHAP's own verification will not reveal it.\n *\n * If you need more than one instance, serialise writes above the Coordinator by\n * partitioning workspaces so no workspace is ever written by two, or by holding\n * an external lock. See SPECIFICATION.md section 10.3.\n *\n * Stores hold per-workspace JSON snapshots, not a decomposed relational\n * model. The Coordinator's snapshot/restore methods produce JSON-safe\n * payloads; this is fast for workspaces in the low-thousands of audit\n * entries and trades query flexibility for simplicity. Production\n * deployments needing rich query semantics should project the audit log\n * into their own analytics store via the `onAudit` listener.\n */\n\nexport interface WorkspaceRecord {\n /** Workspace identifier. */\n id: string;\n /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */\n data: unknown;\n /**\n * Incremented on each save. Recorded for diagnostics and for stores that\n * want it; it is NOT enforced. Nothing here performs a compare-and-swap,\n * so this field does not give you optimistic concurrency. See the\n * concurrency model in this module's header.\n */\n version: number;\n /** Wall-clock timestamp of the last write, ISO-8601. */\n updated_at: string;\n}\n\nexport interface Store {\n /** Load all workspace records into memory. Called once on coordinator start. */\n load(): Promise<WorkspaceRecord[]> | WorkspaceRecord[];\n\n /** Persist one workspace record. Called after every mutation. */\n save(record: WorkspaceRecord): Promise<void> | void;\n\n /** Remove one workspace. Used by `workspace.delete` semantics (not in v0.2). */\n delete(id: string): Promise<void> | void;\n\n /** Release resources. Idempotent. */\n close?(): Promise<void> | void;\n}\n\n/**\n * In-memory store. Default behaviour: no persistence, fast tests.\n * State lives in a Map; closing it discards everything.\n */\nexport class MemoryStore implements Store {\n private records = new Map<string, WorkspaceRecord>();\n\n load(): WorkspaceRecord[] {\n return Array.from(this.records.values());\n }\n\n save(record: WorkspaceRecord): void {\n this.records.set(record.id, record);\n }\n\n delete(id: string): void {\n this.records.delete(id);\n }\n\n close(): void {\n this.records.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2EO,IAAM,cAAN,MAAmC;AAAA,EAChC,UAAU,oBAAI,IAA6B;AAAA,EAEnD,OAA0B;AACxB,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;AAAA,EACpC;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,QAAQ,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;","names":[]}
@@ -11,6 +11,26 @@
11
11
  *
12
12
  * Third-party stores (Postgres, Redis, etc.) implement this interface.
13
13
  *
14
+ * Concurrency model
15
+ * -----------------
16
+ *
17
+ * A Coordinator is a **single-writer** component: dispatch is serial, workspace
18
+ * state is held in memory, and each chain link is computed from the head the
19
+ * instance holds. This interface is a persistence mechanism, not a
20
+ * concurrency-control one. `save` is an unconditional write and no
21
+ * implementation rejects a stale record.
22
+ *
23
+ * Running two or more Coordinator instances against one shared store is
24
+ * therefore not supported. A stale instance's write replaces a newer one
25
+ * wholesale: entries written by the other instance are lost, the chain is
26
+ * re-linked from the surviving head, and `audit.verify_chain` still reports
27
+ * `ok`, because the surviving chain is internally consistent. The loss is
28
+ * silent and CHAP's own verification will not reveal it.
29
+ *
30
+ * If you need more than one instance, serialise writes above the Coordinator by
31
+ * partitioning workspaces so no workspace is ever written by two, or by holding
32
+ * an external lock. See SPECIFICATION.md section 10.3.
33
+ *
14
34
  * Stores hold per-workspace JSON snapshots, not a decomposed relational
15
35
  * model. The Coordinator's snapshot/restore methods produce JSON-safe
16
36
  * payloads; this is fast for workspaces in the low-thousands of audit
@@ -23,7 +43,12 @@ interface WorkspaceRecord {
23
43
  id: string;
24
44
  /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */
25
45
  data: unknown;
26
- /** Monotonically increasing version for optimistic concurrency. */
46
+ /**
47
+ * Incremented on each save. Recorded for diagnostics and for stores that
48
+ * want it; it is NOT enforced. Nothing here performs a compare-and-swap,
49
+ * so this field does not give you optimistic concurrency. See the
50
+ * concurrency model in this module's header.
51
+ */
27
52
  version: number;
28
53
  /** Wall-clock timestamp of the last write, ISO-8601. */
29
54
  updated_at: string;
@@ -11,6 +11,26 @@
11
11
  *
12
12
  * Third-party stores (Postgres, Redis, etc.) implement this interface.
13
13
  *
14
+ * Concurrency model
15
+ * -----------------
16
+ *
17
+ * A Coordinator is a **single-writer** component: dispatch is serial, workspace
18
+ * state is held in memory, and each chain link is computed from the head the
19
+ * instance holds. This interface is a persistence mechanism, not a
20
+ * concurrency-control one. `save` is an unconditional write and no
21
+ * implementation rejects a stale record.
22
+ *
23
+ * Running two or more Coordinator instances against one shared store is
24
+ * therefore not supported. A stale instance's write replaces a newer one
25
+ * wholesale: entries written by the other instance are lost, the chain is
26
+ * re-linked from the surviving head, and `audit.verify_chain` still reports
27
+ * `ok`, because the surviving chain is internally consistent. The loss is
28
+ * silent and CHAP's own verification will not reveal it.
29
+ *
30
+ * If you need more than one instance, serialise writes above the Coordinator by
31
+ * partitioning workspaces so no workspace is ever written by two, or by holding
32
+ * an external lock. See SPECIFICATION.md section 10.3.
33
+ *
14
34
  * Stores hold per-workspace JSON snapshots, not a decomposed relational
15
35
  * model. The Coordinator's snapshot/restore methods produce JSON-safe
16
36
  * payloads; this is fast for workspaces in the low-thousands of audit
@@ -23,7 +43,12 @@ interface WorkspaceRecord {
23
43
  id: string;
24
44
  /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */
25
45
  data: unknown;
26
- /** Monotonically increasing version for optimistic concurrency. */
46
+ /**
47
+ * Incremented on each save. Recorded for diagnostics and for stores that
48
+ * want it; it is NOT enforced. Nothing here performs a compare-and-swap,
49
+ * so this field does not give you optimistic concurrency. See the
50
+ * concurrency model in this module's header.
51
+ */
27
52
  version: number;
28
53
  /** Wall-clock timestamp of the last write, ISO-8601. */
29
54
  updated_at: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/store.ts"],"sourcesContent":["/**\n * Pluggable persistence for the Coordinator.\n *\n * A Store persists workspace state between process restarts. Coordinators\n * call `store.save(workspaceId, snapshot)` after every mutation that\n * appends to the audit chain, and `store.load()` on startup to restore.\n *\n * Two implementations ship in-tree:\n * - MemoryStore (default, no persistence; existing behaviour)\n * - SqliteStore (real SQLite via better-sqlite3, opt-in)\n *\n * Third-party stores (Postgres, Redis, etc.) implement this interface.\n *\n * Stores hold per-workspace JSON snapshots, not a decomposed relational\n * model. The Coordinator's snapshot/restore methods produce JSON-safe\n * payloads; this is fast for workspaces in the low-thousands of audit\n * entries and trades query flexibility for simplicity. Production\n * deployments needing rich query semantics should project the audit log\n * into their own analytics store via the `onAudit` listener.\n */\n\nexport interface WorkspaceRecord {\n /** Workspace identifier. */\n id: string;\n /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */\n data: unknown;\n /** Monotonically increasing version for optimistic concurrency. */\n version: number;\n /** Wall-clock timestamp of the last write, ISO-8601. */\n updated_at: string;\n}\n\nexport interface Store {\n /** Load all workspace records into memory. Called once on coordinator start. */\n load(): Promise<WorkspaceRecord[]> | WorkspaceRecord[];\n\n /** Persist one workspace record. Called after every mutation. */\n save(record: WorkspaceRecord): Promise<void> | void;\n\n /** Remove one workspace. Used by `workspace.delete` semantics (not in v0.2). */\n delete(id: string): Promise<void> | void;\n\n /** Release resources. Idempotent. */\n close?(): Promise<void> | void;\n}\n\n/**\n * In-memory store. Default behaviour: no persistence, fast tests.\n * State lives in a Map; closing it discards everything.\n */\nexport class MemoryStore implements Store {\n private records = new Map<string, WorkspaceRecord>();\n\n load(): WorkspaceRecord[] {\n return Array.from(this.records.values());\n }\n\n save(record: WorkspaceRecord): void {\n this.records.set(record.id, record);\n }\n\n delete(id: string): void {\n this.records.delete(id);\n }\n\n close(): void {\n this.records.clear();\n }\n}\n"],"mappings":";AAkDO,IAAM,cAAN,MAAmC;AAAA,EAChC,UAAU,oBAAI,IAA6B;AAAA,EAEnD,OAA0B;AACxB,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;AAAA,EACpC;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,QAAQ,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/storage/store.ts"],"sourcesContent":["/**\n * Pluggable persistence for the Coordinator.\n *\n * A Store persists workspace state between process restarts. Coordinators\n * call `store.save(workspaceId, snapshot)` after every mutation that\n * appends to the audit chain, and `store.load()` on startup to restore.\n *\n * Two implementations ship in-tree:\n * - MemoryStore (default, no persistence; existing behaviour)\n * - SqliteStore (real SQLite via better-sqlite3, opt-in)\n *\n * Third-party stores (Postgres, Redis, etc.) implement this interface.\n *\n * Concurrency model\n * -----------------\n *\n * A Coordinator is a **single-writer** component: dispatch is serial, workspace\n * state is held in memory, and each chain link is computed from the head the\n * instance holds. This interface is a persistence mechanism, not a\n * concurrency-control one. `save` is an unconditional write and no\n * implementation rejects a stale record.\n *\n * Running two or more Coordinator instances against one shared store is\n * therefore not supported. A stale instance's write replaces a newer one\n * wholesale: entries written by the other instance are lost, the chain is\n * re-linked from the surviving head, and `audit.verify_chain` still reports\n * `ok`, because the surviving chain is internally consistent. The loss is\n * silent and CHAP's own verification will not reveal it.\n *\n * If you need more than one instance, serialise writes above the Coordinator by\n * partitioning workspaces so no workspace is ever written by two, or by holding\n * an external lock. See SPECIFICATION.md section 10.3.\n *\n * Stores hold per-workspace JSON snapshots, not a decomposed relational\n * model. The Coordinator's snapshot/restore methods produce JSON-safe\n * payloads; this is fast for workspaces in the low-thousands of audit\n * entries and trades query flexibility for simplicity. Production\n * deployments needing rich query semantics should project the audit log\n * into their own analytics store via the `onAudit` listener.\n */\n\nexport interface WorkspaceRecord {\n /** Workspace identifier. */\n id: string;\n /** JSON-serialisable payload produced by `Coordinator.snapshot()`. */\n data: unknown;\n /**\n * Incremented on each save. Recorded for diagnostics and for stores that\n * want it; it is NOT enforced. Nothing here performs a compare-and-swap,\n * so this field does not give you optimistic concurrency. See the\n * concurrency model in this module's header.\n */\n version: number;\n /** Wall-clock timestamp of the last write, ISO-8601. */\n updated_at: string;\n}\n\nexport interface Store {\n /** Load all workspace records into memory. Called once on coordinator start. */\n load(): Promise<WorkspaceRecord[]> | WorkspaceRecord[];\n\n /** Persist one workspace record. Called after every mutation. */\n save(record: WorkspaceRecord): Promise<void> | void;\n\n /** Remove one workspace. Used by `workspace.delete` semantics (not in v0.2). */\n delete(id: string): Promise<void> | void;\n\n /** Release resources. Idempotent. */\n close?(): Promise<void> | void;\n}\n\n/**\n * In-memory store. Default behaviour: no persistence, fast tests.\n * State lives in a Map; closing it discards everything.\n */\nexport class MemoryStore implements Store {\n private records = new Map<string, WorkspaceRecord>();\n\n load(): WorkspaceRecord[] {\n return Array.from(this.records.values());\n }\n\n save(record: WorkspaceRecord): void {\n this.records.set(record.id, record);\n }\n\n delete(id: string): void {\n this.records.delete(id);\n }\n\n close(): void {\n this.records.clear();\n }\n}\n"],"mappings":";AA2EO,IAAM,cAAN,MAAmC;AAAA,EAChC,UAAU,oBAAI,IAA6B;AAAA,EAEnD,OAA0B;AACxB,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AAAA,EAEA,KAAK,QAA+B;AAClC,SAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;AAAA,EACpC;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,QAAQ,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,QAAQ,MAAM;AAAA,EACrB;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n vc_holder?: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n ts: string;\n by: ParticipantUri;\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n envelope: Envelope;\n prev_hash?: string;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n members: Map<ParticipantUri, Member>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwWO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n oidc_acr?: string;\n vc_holder?: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n ts: string;\n by: ParticipantUri;\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n envelope: Envelope;\n prev_hash?: string;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n min_acr?: string;\n members: Map<ParticipantUri, Member>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n // task.create idempotency: caller-supplied key -> task_id.\n idempotency_keys: Record<string, TaskId>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4WO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
package/dist/types.d.cts CHANGED
@@ -60,6 +60,7 @@ interface Member {
60
60
  paused: boolean;
61
61
  oidc_sub?: string;
62
62
  oidc_auth_time?: number;
63
+ oidc_acr?: string;
63
64
  vc_holder?: string;
64
65
  }
65
66
  interface TaskRoutingHints {
@@ -264,6 +265,7 @@ interface Workspace {
264
265
  mode_ceiling: Mode;
265
266
  routing_policy_uri?: string;
266
267
  step_up_window_sec: number;
268
+ min_acr?: string;
267
269
  members: Map<ParticipantUri, Member>;
268
270
  tasks: Map<TaskId, Task>;
269
271
  overrides: Map<ArtefactId, OverrideArtefact>;
@@ -272,6 +274,7 @@ interface Workspace {
272
274
  handoffs: Map<string, Handoff>;
273
275
  snapshots: Map<ArtefactId, SnapshotArtefact>;
274
276
  route_decisions: Map<ArtefactId, RouteDecisionArtefact>;
277
+ idempotency_keys: Record<string, TaskId>;
275
278
  audit: AuditEntry[];
276
279
  chain_head?: string;
277
280
  chain_enabled: boolean;