@brightbeamai/chap-coordinator 0.3.4 → 0.3.5
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/README.md +54 -8
- package/dist/{api-59aU01Bs.d.cts → api-CjZQnj63.d.cts} +128 -14
- package/dist/{api-CxciGFHA.d.ts → api-DG0VFGVr.d.ts} +128 -14
- package/dist/api.cjs +3 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +3 -1
- package/dist/api.js.map +1 -1
- package/dist/index.cjs +1336 -219
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +1336 -219
- package/dist/index.js.map +1 -1
- package/dist/jsonrpc.cjs +1 -0
- package/dist/jsonrpc.cjs.map +1 -1
- package/dist/jsonrpc.d.cts +1 -0
- package/dist/jsonrpc.d.ts +1 -0
- package/dist/jsonrpc.js +1 -0
- package/dist/jsonrpc.js.map +1 -1
- package/dist/methods.cjs.map +1 -1
- package/dist/methods.d.cts +36 -3
- package/dist/methods.d.ts +36 -3
- package/dist/storage/sqlite.cjs +81 -19
- package/dist/storage/sqlite.cjs.map +1 -1
- package/dist/storage/sqlite.d.cts +19 -9
- package/dist/storage/sqlite.d.ts +19 -9
- package/dist/storage/sqlite.js +81 -19
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/storage/store.cjs +20 -15
- package/dist/storage/store.cjs.map +1 -1
- package/dist/storage/store.d.cts +24 -6
- package/dist/storage/store.d.ts +24 -6
- package/dist/storage/store.js +20 -15
- package/dist/storage/store.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +56 -1
- package/dist/types.d.ts +56 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/api.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["/**\n * Typed method facade for the Coordinator.\n *\n * Replaces the verbose dispatch pattern:\n *\n * const env = await coord.dispatch({\n * jsonrpc: \"2.0\", id: \"x\",\n * method: \"task.create\",\n * params: { workspace, from, kind, input }\n * });\n * const taskId = env.result.task_id;\n *\n * with namespace-grouped calls that autocomplete and type-check:\n *\n * const { task_id } = coord.api.task.create({ workspace, from, kind, input });\n *\n * Every method on the facade calls `dispatch(envelope)` internally with\n * an auto-generated envelope id, so the audit chain semantics, profile\n * gates, and signature checks all run identically.\n *\n * On dispatch error, the facade throws a `CoordinatorError` carrying the\n * JSON-RPC error code and message. Callers expecting `error` objects on\n * the wire can still use `dispatch()` directly.\n */\n\nimport type { Coordinator } from \"./coordinator.js\";\nimport type { Envelope } from \"./types.js\";\nimport type {\n MethodName, MethodParams, MethodResult,\n} from \"./methods.js\";\n\nexport class CoordinatorError extends Error {\n readonly code: number;\n readonly data?: unknown;\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"CoordinatorError\";\n this.code = code;\n this.data = data;\n }\n}\n\n/**\n * Single-call helper. Type-safe wrapper around `coord.dispatch()`.\n * Throws CoordinatorError if dispatch returns an error response.\n */\nexport function call<M extends MethodName>(\n coord: Coordinator,\n method: M,\n params: MethodParams<M>,\n): MethodResult<M> {\n const envelope: Envelope = {\n jsonrpc: \"2.0\",\n id: coord.ids.envelopeId(),\n method,\n params: params as unknown as Record<string, unknown>,\n };\n const out = coord.dispatch(envelope);\n if (out.error) {\n throw new CoordinatorError(out.error.code, out.error.message, out.error.data);\n }\n return out.result as MethodResult<M>;\n}\n\n// ============================================================\n// Namespace-grouped facades\n// ============================================================\n//\n// Each namespace facade is a small object exposing one method per\n// CHAP verb. Implementations are one-liners that delegate to call().\n// The pattern is verbose but autocompletes well and type-checks\n// param shape and result shape from one declaration in methods.ts.\n\nexport function makeApi(coord: Coordinator) {\n const c = <M extends MethodName>(m: M, p: MethodParams<M>) => call(coord, m, p);\n\n return {\n workspace: {\n create: (p: MethodParams<\"workspace.create\">) => c(\"workspace.create\", p),\n describe: (p: MethodParams<\"workspace.describe\">) => c(\"workspace.describe\", p),\n set_profiles: (p: MethodParams<\"workspace.set_profiles\">) => c(\"workspace.set_profiles\", p),\n },\n participant: {\n join: (p: MethodParams<\"participant.join\">) => c(\"participant.join\", p),\n leave: (p: MethodParams<\"participant.leave\">) => c(\"participant.leave\", p),\n rotate_key: (p: MethodParams<\"participant.rotate_key\">) => c(\"participant.rotate_key\", p),\n revoke_key: (p: MethodParams<\"participant.revoke_key\">) => c(\"participant.revoke_key\", p),\n },\n task: {\n create: (p: MethodParams<\"task.create\">) => c(\"task.create\", p),\n update: (p: MethodParams<\"task.update\">) => c(\"task.update\", p),\n complete: (p: MethodParams<\"task.complete\">) => c(\"task.complete\", p),\n route: (p: MethodParams<\"task.route\">) => c(\"task.route\", p),\n },\n review: {\n request:
|
|
1
|
+
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["/**\n * Typed method facade for the Coordinator.\n *\n * Replaces the verbose dispatch pattern:\n *\n * const env = await coord.dispatch({\n * jsonrpc: \"2.0\", id: \"x\",\n * method: \"task.create\",\n * params: { workspace, from, kind, input }\n * });\n * const taskId = env.result.task_id;\n *\n * with namespace-grouped calls that autocomplete and type-check:\n *\n * const { task_id } = coord.api.task.create({ workspace, from, kind, input });\n *\n * Every method on the facade calls `dispatch(envelope)` internally with\n * an auto-generated envelope id, so the audit chain semantics, profile\n * gates, and signature checks all run identically.\n *\n * On dispatch error, the facade throws a `CoordinatorError` carrying the\n * JSON-RPC error code and message. Callers expecting `error` objects on\n * the wire can still use `dispatch()` directly.\n */\n\nimport type { Coordinator } from \"./coordinator.js\";\nimport type { Envelope } from \"./types.js\";\nimport type {\n MethodName, MethodParams, MethodResult,\n} from \"./methods.js\";\n\nexport class CoordinatorError extends Error {\n readonly code: number;\n readonly data?: unknown;\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"CoordinatorError\";\n this.code = code;\n this.data = data;\n }\n}\n\n/**\n * Single-call helper. Type-safe wrapper around `coord.dispatch()`.\n * Throws CoordinatorError if dispatch returns an error response.\n */\nexport function call<M extends MethodName>(\n coord: Coordinator,\n method: M,\n params: MethodParams<M>,\n): MethodResult<M> {\n const envelope: Envelope = {\n jsonrpc: \"2.0\",\n id: coord.ids.envelopeId(),\n method,\n params: params as unknown as Record<string, unknown>,\n };\n const out = coord.dispatch(envelope);\n if (out.error) {\n throw new CoordinatorError(out.error.code, out.error.message, out.error.data);\n }\n return out.result as MethodResult<M>;\n}\n\n// ============================================================\n// Namespace-grouped facades\n// ============================================================\n//\n// Each namespace facade is a small object exposing one method per\n// CHAP verb. Implementations are one-liners that delegate to call().\n// The pattern is verbose but autocompletes well and type-checks\n// param shape and result shape from one declaration in methods.ts.\n\nexport function makeApi(coord: Coordinator) {\n const c = <M extends MethodName>(m: M, p: MethodParams<M>) => call(coord, m, p);\n\n return {\n workspace: {\n create: (p: MethodParams<\"workspace.create\">) => c(\"workspace.create\", p),\n describe: (p: MethodParams<\"workspace.describe\">) => c(\"workspace.describe\", p),\n set_profiles: (p: MethodParams<\"workspace.set_profiles\">) => c(\"workspace.set_profiles\", p),\n invite: (p: MethodParams<\"workspace.invite\">) => c(\"workspace.invite\", p),\n },\n participant: {\n join: (p: MethodParams<\"participant.join\">) => c(\"participant.join\", p),\n leave: (p: MethodParams<\"participant.leave\">) => c(\"participant.leave\", p),\n rotate_key: (p: MethodParams<\"participant.rotate_key\">) => c(\"participant.rotate_key\", p),\n revoke_key: (p: MethodParams<\"participant.revoke_key\">) => c(\"participant.revoke_key\", p),\n },\n task: {\n create: (p: MethodParams<\"task.create\">) => c(\"task.create\", p),\n update: (p: MethodParams<\"task.update\">) => c(\"task.update\", p),\n complete: (p: MethodParams<\"task.complete\">) => c(\"task.complete\", p),\n route: (p: MethodParams<\"task.route\">) => c(\"task.route\", p),\n },\n review: {\n request: (p: MethodParams<\"review.request\">) => c(\"review.request\", p),\n acknowledge: (p: MethodParams<\"review.acknowledge\">) => c(\"review.acknowledge\", p),\n depth: (p: MethodParams<\"review.depth\">) => c(\"review.depth\", p),\n },\n decide: {\n approve: (p: MethodParams<\"decide.approve\">) => c(\"decide.approve\", p),\n reject: (p: MethodParams<\"decide.reject\">) => c(\"decide.reject\", p),\n override: (p: MethodParams<\"decide.override\">) => c(\"decide.override\", p),\n },\n abstain: {\n declare: (p: MethodParams<\"abstain.declare\">) => c(\"abstain.declare\", p),\n },\n escalate: {\n raise: (p: MethodParams<\"escalate.raise\">) => c(\"escalate.raise\", p),\n auto: (p: MethodParams<\"escalate.auto\">) => c(\"escalate.auto\", p),\n },\n whisper: {\n ask: (p: MethodParams<\"whisper.ask\">) => c(\"whisper.ask\", p),\n answer: (p: MethodParams<\"whisper.answer\">) => c(\"whisper.answer\", p),\n },\n deliberate: {\n open: (p: MethodParams<\"deliberate.open\">) => c(\"deliberate.open\", p),\n comment: (p: MethodParams<\"deliberate.comment\">) => c(\"deliberate.comment\", p),\n vote: (p: MethodParams<\"deliberate.vote\">) => c(\"deliberate.vote\", p),\n close: (p: MethodParams<\"deliberate.close\">) => c(\"deliberate.close\", p),\n },\n handoff: {\n propose: (p: MethodParams<\"handoff.propose\">) => c(\"handoff.propose\", p),\n accept: (p: MethodParams<\"handoff.accept\">) => c(\"handoff.accept\", p),\n decline: (p: MethodParams<\"handoff.decline\">) => c(\"handoff.decline\", p),\n },\n control: {\n pause: (p: MethodParams<\"control.pause\">) => c(\"control.pause\", p),\n resume: (p: MethodParams<\"control.resume\">) => c(\"control.resume\", p),\n cancel: (p: MethodParams<\"control.cancel\">) => c(\"control.cancel\", p),\n supersede: (p: MethodParams<\"control.supersede\">) => c(\"control.supersede\", p),\n snapshot: (p: MethodParams<\"control.snapshot\">) => c(\"control.snapshot\", p),\n rollback: (p: MethodParams<\"control.rollback\">) => c(\"control.rollback\", p),\n set_mode_ceiling: (p: MethodParams<\"control.set_mode_ceiling\">) => c(\"control.set_mode_ceiling\", p),\n },\n audit: {\n read: (p: MethodParams<\"audit.read\">) => c(\"audit.read\", p),\n submit_to_scitt: (p: MethodParams<\"audit.submit_to_scitt\">) => c(\"audit.submit_to_scitt\", p),\n verify_receipt: (p: MethodParams<\"audit.verify_receipt\">) => c(\"audit.verify_receipt\", p),\n verify_chain: (p: MethodParams<\"audit.verify_chain\">) => c(\"audit.verify_chain\", p),\n },\n };\n}\n\nexport type CoordinatorApi = ReturnType<typeof makeApi>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EACT,YAAY,MAAc,SAAiB,MAAgB;AACzD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAMO,SAAS,KACd,OACA,QACA,QACiB;AACjB,QAAM,WAAqB;AAAA,IACzB,SAAS;AAAA,IACT,IAAI,MAAM,IAAI,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACA,QAAM,MAAM,MAAM,SAAS,QAAQ;AACnC,MAAI,IAAI,OAAO;AACb,UAAM,IAAI,iBAAiB,IAAI,MAAM,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM,IAAI;AAAA,EAC9E;AACA,SAAO,IAAI;AACb;AAWO,SAAS,QAAQ,OAAoB;AAC1C,QAAM,IAAI,CAAuB,GAAM,MAAuB,KAAK,OAAO,GAAG,CAAC;AAE9E,SAAO;AAAA,IACL,WAAW;AAAA,MACT,QAAc,CAAC,MAA8C,EAAE,oBAAoB,CAAC;AAAA,MACpF,UAAc,CAAC,MAA8C,EAAE,sBAAsB,CAAC;AAAA,MACtF,cAAc,CAAC,MAA8C,EAAE,0BAA0B,CAAC;AAAA,MAC1F,QAAc,CAAC,MAA8C,EAAE,oBAAoB,CAAC;AAAA,IACtF;AAAA,IACA,aAAa;AAAA,MACX,MAAY,CAAC,MAA8C,EAAE,oBAAoB,CAAC;AA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A,MAC7E,MAAS,CAAC,MAA0C,EAAE,mBAAmB,CAAC;AAAA,MAC1E,OAAS,CAAC,MAA0C,EAAE,oBAAoB,CAAC;AAAA,IAC7E;AAAA,IACA,SAAS;AAAA,MACP,SAAS,CAAC,MAAuC,EAAE,mBAAmB,CAAC;AAAA,MACvE,QAAS,CAAC,MAAuC,EAAE,kBAAkB,CAAC;AAAA,MACtE,SAAS,CAAC,MAAuC,EAAE,mBAAmB,CAAC;AAAA,IACzE;AAAA,IACA,SAAS;AAAA,MACP,OAAmB,CAAC,MAAiD,EAAE,iBAAiB,CAAC;AAAA,MACzF,QAAmB,CAAC,MAAiD,EAAE,kBAAkB,CAAC;AAAA,MAC1F,QAAmB,CAAC,MAAiD,EAAE,kBAAkB,CAAC;AAAA,MAC1F,WAAmB,CAAC,MAAiD,EAAE,qBAAqB,CAAC;AAAA,MAC7F,UAAmB,CAAC,MAAiD,EAAE,oBAAoB,CAAC;AAAA,MAC5F,UAAmB,CAAC,MAAiD,EAAE,oBAAoB,CAAC;AAAA,MAC5F,kBAAmB,CAAC,MAAiD,EAAE,4BAA4B,CAAC;AAAA,IACtG;AAAA,IACA,OAAO;AAAA,MACL,MAAiB,CAAC,MAA6C,EAAE,cAAc,CAAC;AAAA,MAChF,iBAAiB,CAAC,MAA6C,EAAE,yBAAyB,CAAC;AAAA,MAC3F,gBAAiB,CAAC,MAA6C,EAAE,wBAAwB,CAAC;AAAA,MAC1F,cAAiB,CAAC,MAA6C,EAAE,sBAAsB,CAAC;AAAA,IAC1F;AAAA,EACF;AACF;","names":[]}
|
package/dist/api.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './methods.cjs';
|
|
2
|
-
export { b as CoordinatorApi, c as CoordinatorError, g as call, m as makeApi } from './api-
|
|
2
|
+
export { b as CoordinatorApi, c as CoordinatorError, g as call, m as makeApi } from './api-CjZQnj63.cjs';
|
|
3
3
|
import './types.cjs';
|
|
4
4
|
import './storage/store.cjs';
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './methods.js';
|
|
2
|
-
export { b as CoordinatorApi, c as CoordinatorError, g as call, m as makeApi } from './api-
|
|
2
|
+
export { b as CoordinatorApi, c as CoordinatorError, g as call, m as makeApi } from './api-DG0VFGVr.js';
|
|
3
3
|
import './types.js';
|
|
4
4
|
import './storage/store.js';
|
package/dist/api.js
CHANGED
|
@@ -28,7 +28,8 @@ function makeApi(coord) {
|
|
|
28
28
|
workspace: {
|
|
29
29
|
create: (p) => c("workspace.create", p),
|
|
30
30
|
describe: (p) => c("workspace.describe", p),
|
|
31
|
-
set_profiles: (p) => c("workspace.set_profiles", p)
|
|
31
|
+
set_profiles: (p) => c("workspace.set_profiles", p),
|
|
32
|
+
invite: (p) => c("workspace.invite", p)
|
|
32
33
|
},
|
|
33
34
|
participant: {
|
|
34
35
|
join: (p) => c("participant.join", p),
|
|
@@ -44,6 +45,7 @@ function makeApi(coord) {
|
|
|
44
45
|
},
|
|
45
46
|
review: {
|
|
46
47
|
request: (p) => c("review.request", p),
|
|
48
|
+
acknowledge: (p) => c("review.acknowledge", p),
|
|
47
49
|
depth: (p) => c("review.depth", p)
|
|
48
50
|
},
|
|
49
51
|
decide: {
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["/**\n * Typed method facade for the Coordinator.\n *\n * Replaces the verbose dispatch pattern:\n *\n * const env = await coord.dispatch({\n * jsonrpc: \"2.0\", id: \"x\",\n * method: \"task.create\",\n * params: { workspace, from, kind, input }\n * });\n * const taskId = env.result.task_id;\n *\n * with namespace-grouped calls that autocomplete and type-check:\n *\n * const { task_id } = coord.api.task.create({ workspace, from, kind, input });\n *\n * Every method on the facade calls `dispatch(envelope)` internally with\n * an auto-generated envelope id, so the audit chain semantics, profile\n * gates, and signature checks all run identically.\n *\n * On dispatch error, the facade throws a `CoordinatorError` carrying the\n * JSON-RPC error code and message. Callers expecting `error` objects on\n * the wire can still use `dispatch()` directly.\n */\n\nimport type { Coordinator } from \"./coordinator.js\";\nimport type { Envelope } from \"./types.js\";\nimport type {\n MethodName, MethodParams, MethodResult,\n} from \"./methods.js\";\n\nexport class CoordinatorError extends Error {\n readonly code: number;\n readonly data?: unknown;\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"CoordinatorError\";\n this.code = code;\n this.data = data;\n }\n}\n\n/**\n * Single-call helper. Type-safe wrapper around `coord.dispatch()`.\n * Throws CoordinatorError if dispatch returns an error response.\n */\nexport function call<M extends MethodName>(\n coord: Coordinator,\n method: M,\n params: MethodParams<M>,\n): MethodResult<M> {\n const envelope: Envelope = {\n jsonrpc: \"2.0\",\n id: coord.ids.envelopeId(),\n method,\n params: params as unknown as Record<string, unknown>,\n };\n const out = coord.dispatch(envelope);\n if (out.error) {\n throw new CoordinatorError(out.error.code, out.error.message, out.error.data);\n }\n return out.result as MethodResult<M>;\n}\n\n// ============================================================\n// Namespace-grouped facades\n// ============================================================\n//\n// Each namespace facade is a small object exposing one method per\n// CHAP verb. Implementations are one-liners that delegate to call().\n// The pattern is verbose but autocompletes well and type-checks\n// param shape and result shape from one declaration in methods.ts.\n\nexport function makeApi(coord: Coordinator) {\n const c = <M extends MethodName>(m: M, p: MethodParams<M>) => call(coord, m, p);\n\n return {\n workspace: {\n create: (p: MethodParams<\"workspace.create\">) => c(\"workspace.create\", p),\n describe: (p: MethodParams<\"workspace.describe\">) => c(\"workspace.describe\", p),\n set_profiles: (p: MethodParams<\"workspace.set_profiles\">) => c(\"workspace.set_profiles\", p),\n },\n participant: {\n join: (p: MethodParams<\"participant.join\">) => c(\"participant.join\", p),\n leave: (p: MethodParams<\"participant.leave\">) => c(\"participant.leave\", p),\n rotate_key: (p: MethodParams<\"participant.rotate_key\">) => c(\"participant.rotate_key\", p),\n revoke_key: (p: MethodParams<\"participant.revoke_key\">) => c(\"participant.revoke_key\", p),\n },\n task: {\n create: (p: MethodParams<\"task.create\">) => c(\"task.create\", p),\n update: (p: MethodParams<\"task.update\">) => c(\"task.update\", p),\n complete: (p: MethodParams<\"task.complete\">) => c(\"task.complete\", p),\n route: (p: MethodParams<\"task.route\">) => c(\"task.route\", p),\n },\n review: {\n request:
|
|
1
|
+
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["/**\n * Typed method facade for the Coordinator.\n *\n * Replaces the verbose dispatch pattern:\n *\n * const env = await coord.dispatch({\n * jsonrpc: \"2.0\", id: \"x\",\n * method: \"task.create\",\n * params: { workspace, from, kind, input }\n * });\n * const taskId = env.result.task_id;\n *\n * with namespace-grouped calls that autocomplete and type-check:\n *\n * const { task_id } = coord.api.task.create({ workspace, from, kind, input });\n *\n * Every method on the facade calls `dispatch(envelope)` internally with\n * an auto-generated envelope id, so the audit chain semantics, profile\n * gates, and signature checks all run identically.\n *\n * On dispatch error, the facade throws a `CoordinatorError` carrying the\n * JSON-RPC error code and message. Callers expecting `error` objects on\n * the wire can still use `dispatch()` directly.\n */\n\nimport type { Coordinator } from \"./coordinator.js\";\nimport type { Envelope } from \"./types.js\";\nimport type {\n MethodName, MethodParams, MethodResult,\n} from \"./methods.js\";\n\nexport class CoordinatorError extends Error {\n readonly code: number;\n readonly data?: unknown;\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"CoordinatorError\";\n this.code = code;\n this.data = data;\n }\n}\n\n/**\n * Single-call helper. Type-safe wrapper around `coord.dispatch()`.\n * Throws CoordinatorError if dispatch returns an error response.\n */\nexport function call<M extends MethodName>(\n coord: Coordinator,\n method: M,\n params: MethodParams<M>,\n): MethodResult<M> {\n const envelope: Envelope = {\n jsonrpc: \"2.0\",\n id: coord.ids.envelopeId(),\n method,\n params: params as unknown as Record<string, unknown>,\n };\n const out = coord.dispatch(envelope);\n if (out.error) {\n throw new CoordinatorError(out.error.code, out.error.message, out.error.data);\n }\n return out.result as MethodResult<M>;\n}\n\n// ============================================================\n// Namespace-grouped facades\n// ============================================================\n//\n// Each namespace facade is a small object exposing one method per\n// CHAP verb. Implementations are one-liners that delegate to call().\n// The pattern is verbose but autocompletes well and type-checks\n// param shape and result shape from one declaration in methods.ts.\n\nexport function makeApi(coord: Coordinator) {\n const c = <M extends MethodName>(m: M, p: MethodParams<M>) => call(coord, m, p);\n\n return {\n workspace: {\n create: (p: MethodParams<\"workspace.create\">) => c(\"workspace.create\", p),\n describe: (p: MethodParams<\"workspace.describe\">) => c(\"workspace.describe\", p),\n set_profiles: (p: MethodParams<\"workspace.set_profiles\">) => c(\"workspace.set_profiles\", p),\n invite: (p: MethodParams<\"workspace.invite\">) => c(\"workspace.invite\", p),\n },\n participant: {\n join: (p: MethodParams<\"participant.join\">) => c(\"participant.join\", p),\n leave: (p: MethodParams<\"participant.leave\">) => c(\"participant.leave\", p),\n rotate_key: (p: MethodParams<\"participant.rotate_key\">) => c(\"participant.rotate_key\", p),\n revoke_key: (p: MethodParams<\"participant.revoke_key\">) => c(\"participant.revoke_key\", p),\n },\n task: {\n create: (p: MethodParams<\"task.create\">) => c(\"task.create\", p),\n update: (p: MethodParams<\"task.update\">) => c(\"task.update\", p),\n complete: (p: MethodParams<\"task.complete\">) => c(\"task.complete\", p),\n route: (p: MethodParams<\"task.route\">) => c(\"task.route\", p),\n },\n review: {\n request: (p: MethodParams<\"review.request\">) => c(\"review.request\", p),\n acknowledge: (p: MethodParams<\"review.acknowledge\">) => c(\"review.acknowledge\", p),\n depth: (p: MethodParams<\"review.depth\">) => c(\"review.depth\", p),\n },\n decide: {\n approve: (p: MethodParams<\"decide.approve\">) => c(\"decide.approve\", p),\n reject: (p: MethodParams<\"decide.reject\">) => c(\"decide.reject\", p),\n override: (p: MethodParams<\"decide.override\">) => c(\"decide.override\", p),\n },\n abstain: {\n declare: (p: MethodParams<\"abstain.declare\">) => c(\"abstain.declare\", p),\n },\n escalate: {\n raise: (p: MethodParams<\"escalate.raise\">) => c(\"escalate.raise\", p),\n auto: (p: MethodParams<\"escalate.auto\">) => c(\"escalate.auto\", p),\n },\n whisper: {\n ask: (p: MethodParams<\"whisper.ask\">) => c(\"whisper.ask\", p),\n answer: (p: MethodParams<\"whisper.answer\">) => c(\"whisper.answer\", p),\n },\n deliberate: {\n open: (p: MethodParams<\"deliberate.open\">) => c(\"deliberate.open\", p),\n comment: (p: MethodParams<\"deliberate.comment\">) => c(\"deliberate.comment\", p),\n vote: (p: MethodParams<\"deliberate.vote\">) => c(\"deliberate.vote\", p),\n close: (p: MethodParams<\"deliberate.close\">) => c(\"deliberate.close\", p),\n },\n handoff: {\n propose: (p: MethodParams<\"handoff.propose\">) => c(\"handoff.propose\", p),\n accept: (p: MethodParams<\"handoff.accept\">) => c(\"handoff.accept\", p),\n decline: (p: MethodParams<\"handoff.decline\">) => c(\"handoff.decline\", p),\n },\n control: {\n pause: (p: MethodParams<\"control.pause\">) => c(\"control.pause\", p),\n resume: (p: MethodParams<\"control.resume\">) => c(\"control.resume\", p),\n cancel: (p: MethodParams<\"control.cancel\">) => c(\"control.cancel\", p),\n supersede: (p: MethodParams<\"control.supersede\">) => c(\"control.supersede\", p),\n snapshot: (p: MethodParams<\"control.snapshot\">) => c(\"control.snapshot\", p),\n rollback: (p: MethodParams<\"control.rollback\">) => c(\"control.rollback\", p),\n set_mode_ceiling: (p: MethodParams<\"control.set_mode_ceiling\">) => c(\"control.set_mode_ceiling\", p),\n },\n audit: {\n read: (p: MethodParams<\"audit.read\">) => c(\"audit.read\", p),\n submit_to_scitt: (p: MethodParams<\"audit.submit_to_scitt\">) => c(\"audit.submit_to_scitt\", p),\n verify_receipt: (p: MethodParams<\"audit.verify_receipt\">) => c(\"audit.verify_receipt\", p),\n verify_chain: (p: MethodParams<\"audit.verify_chain\">) => c(\"audit.verify_chain\", p),\n },\n };\n}\n\nexport type CoordinatorApi = ReturnType<typeof makeApi>;\n"],"mappings":";AA+BO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EACjC;AAAA,EACA;AAAA,EACT,YAAY,MAAc,SAAiB,MAAgB;AACzD,UA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