@brightbeamai/chap-coordinator-mcp 0.3.3 → 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 +162 -19
- package/dist/cli.cjs +338 -41
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +341 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +485 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -8
- package/dist/index.d.ts +92 -8
- package/dist/index.js +486 -21
- package/dist/index.js.map +1 -1
- package/dist/schemas.cjs +40 -3
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +1 -1
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +40 -3
- package/dist/schemas.js.map +1 -1
- package/dist/tools.cjs +27 -6
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +17 -1
- package/dist/tools.d.ts +17 -1
- package/dist/tools.js +26 -6
- package/dist/tools.js.map +1 -1
- package/package.json +3 -3
package/dist/schemas.cjs
CHANGED
|
@@ -91,6 +91,18 @@ var SCHEMAS = {
|
|
|
91
91
|
enum: ["shadow", "trial", "production"],
|
|
92
92
|
default: "production",
|
|
93
93
|
description: "Highest mode a task in this workspace may request. A task.create above the ceiling is refused with -32040. The ceiling can be changed afterwards with chap.control.set_mode_ceiling."
|
|
94
|
+
},
|
|
95
|
+
join_policy: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["open", "invite"],
|
|
98
|
+
default: "open",
|
|
99
|
+
description: "Who may join. 'open' admits anyone. 'invite' admits only a participant an admin invited with chap.workspace.invite, and the workspace's first member, which becomes its admin; any other join is refused with -32011. It cannot be changed afterwards."
|
|
100
|
+
},
|
|
101
|
+
review_rule: {
|
|
102
|
+
type: "string",
|
|
103
|
+
pattern: "^(any_one_approves|all_approve|quorum:[1-9][0-9]*)$",
|
|
104
|
+
default: "any_one_approves",
|
|
105
|
+
description: "The rule of every review that task.complete opens here: any_one_approves, all_approve or quorum:<n>. An author cannot open a review of their own review-required task, so this is how a workspace asks for more than one approval. It cannot be changed afterwards."
|
|
94
106
|
}
|
|
95
107
|
},
|
|
96
108
|
additionalProperties: false
|
|
@@ -112,6 +124,26 @@ var SCHEMAS = {
|
|
|
112
124
|
},
|
|
113
125
|
required: ["workspace", "profiles"]
|
|
114
126
|
},
|
|
127
|
+
"chap.workspace.invite": {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
workspace: WORKSPACE_ID,
|
|
131
|
+
from: { ...PARTICIPANT_URI, description: "The admin who invites. Any other sender is refused with -32011." },
|
|
132
|
+
uri: { ...PARTICIPANT_URI, description: "The participant invited. Its scheme must name type, as at a join." },
|
|
133
|
+
type: {
|
|
134
|
+
type: "string",
|
|
135
|
+
enum: ["human", "agent", "service"],
|
|
136
|
+
description: "The kind of participant invited, which the scheme of uri must name. The member takes this type. group: and workspace: URIs name address scopes, which cannot join, and are refused with -32602."
|
|
137
|
+
},
|
|
138
|
+
role: { type: "string", description: "The role the member takes when it joins, whatever role the join names. Only an invitation grants 'admin' after the first member, and only to a human or a service." },
|
|
139
|
+
jwks: {
|
|
140
|
+
type: "object",
|
|
141
|
+
description: "Keys to pin, as {keys: [JWK, ...]}, each with a kid. The join's keys must be among them, and the member holds them. For a member that holds no key in force, the call registers these keys at once: the way back for a member whose keys were all revoked."
|
|
142
|
+
},
|
|
143
|
+
oidc_sub: { type: "string", description: "The OIDC subject whose token admits the invitee: the join must carry an oidc_token for it. Needs a token verifier on the coordinator." }
|
|
144
|
+
},
|
|
145
|
+
required: ["workspace", "from", "uri", "type"]
|
|
146
|
+
},
|
|
115
147
|
"chap.participant.join": {
|
|
116
148
|
type: "object",
|
|
117
149
|
properties: {
|
|
@@ -119,10 +151,10 @@ var SCHEMAS = {
|
|
|
119
151
|
from: PARTICIPANT_URI,
|
|
120
152
|
type: {
|
|
121
153
|
type: "string",
|
|
122
|
-
enum: ["human", "agent", "service"
|
|
123
|
-
description: "The kind of participant. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011."
|
|
154
|
+
enum: ["human", "agent", "service"],
|
|
155
|
+
description: "The kind of participant, which the scheme of from must name: 'agent:' for an agent, and so on. Any other join is refused with -32602, and so is a join of a group: or workspace: URI, which names an address scope. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011. In a workspace that requires signatures, a participant that signs joins with a key."
|
|
124
156
|
},
|
|
125
|
-
role: { type: "string", description: "Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin'
|
|
157
|
+
role: { type: "string", description: "Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin', which changes the profiles, invites, and revokes another member's key. It is granted, never claimed: only the workspace's first member, or a participant an admin's invitation names as admin, may name it at a join, and any other join naming it is refused with -32011. Only a human or a service holds it. An invitation's role replaces the one named here." },
|
|
126
158
|
display_name: { type: "string", description: "Human-readable name for interfaces. Not used in authorisation." }
|
|
127
159
|
},
|
|
128
160
|
required: ["workspace", "from", "type"]
|
|
@@ -238,6 +270,11 @@ var SCHEMAS = {
|
|
|
238
270
|
},
|
|
239
271
|
required: ["workspace", "from", "task_id", "to", "artefact"]
|
|
240
272
|
},
|
|
273
|
+
"chap.review.acknowledge": {
|
|
274
|
+
type: "object",
|
|
275
|
+
properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID },
|
|
276
|
+
required: ["workspace", "from", "task_id"]
|
|
277
|
+
},
|
|
241
278
|
"chap.decide.approve": {
|
|
242
279
|
type: "object",
|
|
243
280
|
properties: {
|
package/dist/schemas.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator-mcp/schemas\n *\n * JSON Schema definitions for each CHAP method, used as the\n * inputSchema for the corresponding MCP tool. Each schema describes\n * the params object that the CHAP envelope would carry; the tool\n * handler wraps the params in a JSON-RPC 2.0 envelope before dispatch.\n *\n * A description here is what an MCP client reads before deciding\n * whether and how to call the tool, so each one states what the\n * coordinator does with the parameter, and names the error code where\n * a constraint is enforced. A parameter that is recorded but not acted\n * on says so; describing an intention the code does not implement is\n * worse than saying nothing.\n *\n * Aligned with CHAP 0.3 (see profiles/*.md) and MCP 2025-11-25.\n */\n\nexport interface JsonSchema {\n type?: string;\n description?: string;\n properties?: Record<string, JsonSchema>;\n required?: string[];\n enum?: string[];\n items?: JsonSchema;\n additionalProperties?: boolean | JsonSchema;\n oneOf?: JsonSchema[];\n default?: unknown;\n /** JSON Schema `pattern`, used where a string has a fixed wire shape. */\n pattern?: string;\n}\n\n// Common reusable fragments.\nconst PARTICIPANT_URI: JsonSchema = {\n type: \"string\",\n description: \"Participant URI, e.g. 'human:alice@example.org' or 'agent:bot@local'.\",\n};\n\nconst WORKSPACE_ID: JsonSchema = {\n type: \"string\",\n description: \"Workspace identifier, e.g. 'wsp_techcorp_support'.\",\n};\n\nconst TASK_ID: JsonSchema = {\n type: \"string\",\n description: \"Task identifier returned by chap.task.create.\",\n};\n\n/**\n * SPECIFICATION.md S7: a number in a CHAP envelope must be an integer.\n * Fractional values travel as decimal strings, so that canonicalisation and\n * therefore the audit hash are identical across implementations. A JSON number\n * with a fractional part is refused at ingress with -32602, so any parameter\n * that is conceptually fractional is declared here as a string.\n */\nconst decimalStringNote = (example: string) =>\n `Written as a decimal string, e.g. \"${example}\". CHAP canonicalisation accepts integers only, so a JSON number with a fractional part is refused with -32602.`;\n\nconst ROUTING_HINTS: JsonSchema = {\n type: \"object\",\n description: \"Signals recorded on the task and read by the routing/1.0 methods: task.route, review.depth and escalate.auto. Recording a hint has no effect on its own; it is consulted only when one of those methods is called.\",\n properties: {\n criticality: {\n type: \"string\",\n enum: [\"low\", \"medium\", \"high\", \"critical\"],\n description: \"How costly a wrong answer would be. The default review-depth policy reads it: 'critical' gives a full review, and 'high' with confidence below 0.7 does the same. The default assignee policy does not read it.\",\n },\n deadline: { type: \"string\", description: \"When the work is needed by, as an ISO 8601 timestamp. Recorded on the task; the coordinator does not act on it.\" },\n risk_tier: { type: \"string\", description: \"Operator-defined risk band, e.g. 'regulated' or 'internal'. No built-in policy reads it; it is available to an operator-supplied routing policy.\" },\n max_cost_usd: { type: \"string\", description: `Budget ceiling for this task in US dollars. ${decimalStringNote(\"12.50\")} No built-in policy reads it.` },\n },\n additionalProperties: true,\n};\n\n/** Free-text justification attached to a decision and kept in the audit log. */\nconst COMMENT: JsonSchema = {\n type: \"string\",\n description: \"The reviewer's note on this decision. Recorded in the audit entry for the decision.\",\n};\n\n/** Workspace-defined labels carried on a decision. */\nconst TAGS: JsonSchema = {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Workspace-defined labels for this decision, e.g. ['tone', 'unsupported-claim']. Recorded in the audit entry. chap.audit.read does not filter on tags, so grouping by tag is done by the reader.\",\n};\n\n/** Binds a decision to the exact artefact the reviewer saw. */\nconst ARTEFACT_DIGEST: JsonSchema = {\n type: \"string\",\n pattern: \"^sha256:[0-9a-f]{64}$\",\n description: \"Optional. SHA-256 over the JCS canonicalisation of the artefact under review, in the form `sha256:<hex>`. When present it binds the decision to the exact content reviewed, and a mismatch is refused with -32074.\",\n};\n\n/** Applies to `output` and `artefact`, which are opaque JSON payloads. */\nconst STRUCTURED_PAYLOAD_NOTE =\n \"Pass a JSON object or array. A JSON-encoded string is parsed back to the structured value before dispatch, so patches in chap.decide.override apply against a real object.\";\n\n// ============================================================\n// Core\n// ============================================================\n\nexport const SCHEMAS: Record<string, JsonSchema> = {\n \"chap.workspace.create\": {\n type: \"object\",\n properties: {\n workspace: { ...WORKSPACE_ID, description: \"Workspace id to create. If omitted, one is generated.\" },\n profiles: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Profile identifiers to enable, e.g. ['core/1.0', 'review/1.0']. Recorded on the workspace. Two profiles change behaviour by being present: modes/1.0, under which a trial-mode task requires review, and audit-scitt/1.0, which turns on the hash-linked chain.\",\n },\n mode: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n default: \"trial\",\n description: \"Default mode for tasks created here. Under modes/1.0 a trial-mode task has review_required set to true whatever the caller passes. 'shadow' and 'production' are recorded on the task and carry no further behaviour in this implementation.\",\n },\n mode_ceiling: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n default: \"production\",\n description: \"Highest mode a task in this workspace may request. A task.create above the ceiling is refused with -32040. The ceiling can be changed afterwards with chap.control.set_mode_ceiling.\",\n },\n },\n additionalProperties: false,\n },\n\n \"chap.workspace.describe\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID },\n required: [\"workspace\"],\n },\n\n \"chap.workspace.set_profiles\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n profiles: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"The complete profile set to enable, replacing the current one. Adding audit-scitt/1.0 to a workspace that already has entries leaves those entries unchained and outside chain verification.\",\n },\n },\n required: [\"workspace\", \"profiles\"],\n },\n\n \"chap.participant.join\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n type: {\n type: \"string\",\n enum: [\"human\", \"agent\", \"service\", \"group\", \"workspace\"],\n description: \"The kind of participant. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011.\",\n },\n role: { type: \"string\", description: \"Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin' permits revoking another member's key.\" },\n display_name: { type: \"string\", description: \"Human-readable name for interfaces. Not used in authorisation.\" },\n },\n required: [\"workspace\", \"from\", \"type\"],\n },\n\n \"chap.participant.leave\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.task.create\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: { ...PARTICIPANT_URI, description: \"The delegator. Must be a workspace member.\" },\n kind: { type: \"string\", description: \"Task kind, e.g. 'draft_response' or 'review'. Free text; the coordinator records it without interpreting it.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who the task is assigned to. Must be a workspace member, and must not be paused: assigning to a paused member is refused with -32063.\" },\n input: { type: \"object\", description: \"Task-specific input payload.\", additionalProperties: true },\n routing_hints: ROUTING_HINTS,\n mode: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n description: \"Mode for this task, defaulting to the workspace mode. A mode above the workspace ceiling is refused with -32040.\",\n },\n review_required: {\n type: \"boolean\",\n description: \"When true, chap.task.complete opens a review instead of completing: the output becomes the artefact under review, and the task reaches 'completed' only on a reviewer decision. chap.task.update cannot complete such a task. Under modes/1.0 a trial-mode task has this set to true whatever is passed here.\",\n },\n deadline: { type: \"string\", description: \"When the task is due, as an ISO 8601 timestamp. Recorded on the task; the coordinator does not act on it.\" },\n idempotency_key: {\n type: \"string\",\n description: \"Caller-chosen key for safe retries. A second create carrying a key already seen in this workspace returns the original task and records nothing further. The workspace retains the 10,000 most recent keys.\",\n },\n },\n required: [\"workspace\", \"from\", \"kind\", \"assignee\", \"input\"],\n },\n\n \"chap.task.update\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n state: {\n type: \"string\",\n enum: [\"in_progress\", \"declined\", \"cancelled\", \"completed\"],\n description: \"The state to move the task to. Only the transitions in SPECIFICATION.md 8.1 are legal from the task's current state; others are refused with -32602. A review opens with chap.review.request, or with chap.task.complete on a task that requires one, so 'review_requested' is not a target here. A task marked review_required cannot be moved to 'completed' here: submit the output with chap.task.complete, which opens the review.\",\n },\n progress_note: { type: \"string\", description: \"Short note on what changed, kept in the task's history.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"state\"],\n },\n\n \"chap.task.complete\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n output: { description: `The task's output artefact. ${STRUCTURED_PAYLOAD_NOTE}` },\n confidence: { type: \"string\", description: `Self-reported confidence in the output, between 0 and 1. ${decimalStringNote(\"0.86\")}` },\n routing_hints: ROUTING_HINTS,\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.audit.read\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n range: {\n type: \"object\",\n description: \"Sequence window to return. Omit for the whole log.\",\n properties: {\n from_seq: { type: \"integer\", description: \"Start sequence number, inclusive.\" },\n to_seq: { type: \"integer\", description: \"End sequence number, exclusive.\" },\n },\n },\n filter: {\n type: \"object\",\n description: \"Narrows the entries returned. Conditions combine with AND, and are applied within the sequence window rather than before it.\",\n properties: {\n method: { type: \"string\", description: \"Return only entries for this CHAP method, e.g. 'decide.override'. Matched in full, without the 'chap.' tool-name prefix.\" },\n from: { type: \"string\", description: \"Return only entries whose actor is this participant URI.\" },\n task_id: { type: \"string\", description: \"Return only entries about this task.\" },\n outcome: {\n type: \"string\",\n enum: [\"accepted\", \"refused\"],\n description: \"Return only accepted calls, or only the refused attempts the coordinator recorded. Omit for both.\",\n },\n },\n },\n },\n required: [\"workspace\"],\n },\n\n // ============================================================\n // review/1.0\n // ============================================================\n\n \"chap.review.request\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n to: {\n oneOf: [PARTICIPANT_URI, { type: \"array\", items: PARTICIPANT_URI }],\n description: \"One or more reviewers, as a single URI string or an array of URI strings. Only a workspace member can go on to decide, so a review addressed elsewhere cannot be closed by its recipient.\",\n },\n rule: {\n type: \"string\",\n enum: [\"any_one_approves\", \"all_approve\", \"quorum:2\", \"quorum:3\"],\n default: \"any_one_approves\",\n description: \"How many of the addressed reviewers must approve before the task completes. quorum:N is accepted for any N of 1 or more. The rule is fixed once the review is open: a later request naming a different one is refused with -32014. Omitting it on a later request leaves the rule alone, which is how reviewers are added to an open review.\",\n },\n artefact: { description: `The draft being submitted for review. ${STRUCTURED_PAYLOAD_NOTE} Re-requesting with the same artefact widens the reviewer set; a different artefact on an open review is refused with -32014.` },\n deadline: { type: \"string\", description: \"When the review is needed by, as an ISO 8601 timestamp. Recorded on the review; the coordinator does not act on it.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"to\", \"artefact\"],\n },\n\n \"chap.decide.approve\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n approved_artefact_digest: ARTEFACT_DIGEST,\n comment: COMMENT,\n tags: TAGS,\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.decide.reject\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n approved_artefact_digest: ARTEFACT_DIGEST,\n comment: COMMENT,\n tags: TAGS,\n request_revision: { type: \"boolean\", description: \"When true the task returns to 'in_progress' rather than 'declined', so the assignee can revise and resubmit.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.decide.override\": {\n type: \"object\",\n properties: {\n approved_artefact_digest: ARTEFACT_DIGEST,\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n diff: {\n type: \"array\",\n description: \"RFC 6902 JSON Patch operations applied to the artefact under review. The patched artefact becomes the task output; a patch that does not apply is refused with -32012.\",\n items: {\n type: \"object\",\n properties: {\n op: { type: \"string\", enum: [\"add\", \"replace\", \"remove\", \"copy\", \"move\", \"test\"], description: \"The patch operation to apply.\" },\n path: { type: \"string\", description: \"JSON Pointer into the artefact, e.g. '/body' or '/items/0/severity'.\" },\n value: { description: \"The new value, for add, replace and test.\" },\n from: { type: \"string\", description: \"Source JSON Pointer, for copy and move.\" },\n },\n required: [\"op\", \"path\"],\n },\n },\n rationale: { type: \"string\", description: \"Why the correction was made. Required on every override and recorded in the audit entry, since the diff shows what changed but not why.\" },\n tags: TAGS,\n policy_refs: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Identifiers of the policies or guidelines this correction applies, e.g. ['policy:no-delivery-promises']. Recorded in the audit entry.\",\n },\n logical_id: {\n type: \"string\",\n description: \"Caller-chosen identifier for the item being decided, stable across revisions and overrides of the same underlying content. Recorded in the audit entry.\",\n },\n intent_preserved: {\n type: \"boolean\",\n description: \"True when the edit refines the decision the draft was making, false when it substitutes a different one. Recorded in the audit entry.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"diff\", \"rationale\"],\n },\n\n \"chap.abstain.declare\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n reason: { type: \"string\", description: \"Why this reviewer is standing aside. Recorded in the audit entry.\" },\n category: {\n type: \"string\",\n enum: [\"conflict_of_interest\", \"insufficient_context\", \"out_of_scope\", \"other\"],\n description: \"The kind of abstention. Recorded in the audit entry.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"reason\"],\n },\n\n \"chap.escalate.raise\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n original_task_id: { ...TASK_ID, description: \"The task being escalated. It moves to 'escalated' and is linked to the successor. A completed, cancelled or superseded task cannot be escalated.\" },\n new_task: {\n type: \"object\",\n description: \"The successor task to open for the escalation target.\",\n properties: {\n kind: { type: \"string\", description: \"Task kind for the successor. Defaults to the original's kind.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who the escalation goes to. Must be a workspace member who is not paused: a paused assignee is refused with -32063.\" },\n input: { type: \"object\", additionalProperties: true, description: \"Input payload for the successor. It defaults to an empty object rather than the original's input, so anything the new assignee needs has to be restated here.\" },\n mode: { type: \"string\", enum: [\"shadow\", \"trial\", \"production\"], description: \"Mode for the successor, defaulting to the original's. A mode above the workspace's current ceiling is refused with -32040, so after the ceiling is lowered a task is escalated by naming a mode within it.\" },\n },\n required: [\"assignee\"],\n },\n },\n required: [\"workspace\", \"from\", \"original_task_id\", \"new_task\"],\n },\n\n // ============================================================\n // whisper/1.0\n // ============================================================\n\n \"chap.whisper.ask\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n to: { type: \"array\", items: PARTICIPANT_URI, description: \"Who is being asked.\" },\n question: { type: \"string\", description: \"The question being put. A whisper is answered on its own, without the recipient opening the task.\" },\n options: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Stable identifier that an answer refers to.\" },\n label: { type: \"string\", description: \"What the option says to the person answering.\" },\n },\n required: [\"id\"],\n },\n description: \"Multiple-choice options. When present, an answer must name one of these ids in answer_option; any other id is refused with -32022.\",\n },\n deadline_ms: { type: \"integer\", description: \"How long the whisper stays open, in milliseconds from now. Once it passes, the whisper lapses and default_if_lapsed is applied.\" },\n default_if_lapsed: { description: \"The value applied if the deadline passes with no answer. Required, so that a lapsed whisper still has a defined outcome.\" },\n urgency: {\n type: \"string\",\n enum: [\"low\", \"medium\", \"high\"],\n default: \"low\",\n description: \"How urgent the question is. Recorded and passed on to the client; it does not change the deadline or the lapse behaviour.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"to\", \"question\", \"deadline_ms\", \"default_if_lapsed\"],\n },\n\n \"chap.whisper.answer\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n whisper_id: { type: \"string\", description: \"Identifier returned by chap.whisper.ask. A whisper that has already been answered is refused with -32020, and one past its deadline with -32021.\" },\n answer_option: { type: \"string\", description: \"The id of the chosen option. Required when the whisper carried options.\" },\n answer: { type: \"string\", description: \"Free-text answer, for a whisper with no options.\" },\n comment: { type: \"string\", description: \"Anything else the answerer wants recorded alongside the answer.\" },\n },\n required: [\"workspace\", \"from\", \"whisper_id\"],\n },\n\n // ============================================================\n // deliberation/1.0\n // ============================================================\n\n \"chap.deliberate.open\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to: { type: \"array\", items: PARTICIPANT_URI, description: \"The participants entitled to vote. A vote from anyone else is refused with -32030.\" },\n task_id: TASK_ID,\n rule: {\n type: \"string\",\n description: \"How the outcome is decided when the deliberation closes: any_one_approves, all_approve, quorum:N, weighted_vote:T or weighted_vote_with_veto:T. An unrecognised rule is refused at open with -32033.\",\n },\n question: { type: \"string\", description: \"What the group is deciding. State it so that a yea or a nay is unambiguous.\" },\n weights: { type: \"object\", additionalProperties: { type: \"integer\" }, description: \"Voter to weight map, read by the weighted rules. A voter with no entry counts as 1. Weights must be integers: a JSON number with a fractional part is refused with -32602.\" },\n veto: { type: \"object\", additionalProperties: { type: \"boolean\" }, description: \"Voter to can-veto map. A veto is honoured only under weighted_vote_with_veto, and only from a voter listed true here.\" },\n deadline: { type: \"string\", description: \"When voting is intended to close, as an ISO 8601 timestamp. Recorded on the deliberation; closing is done by chap.deliberate.close and the coordinator does not close on the deadline.\" },\n },\n required: [\"workspace\", \"from\", \"to\", \"rule\"],\n },\n\n \"chap.deliberate.comment\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. A closed deliberation is refused with -32032.\" },\n comment: { type: \"string\", description: \"The contribution to record. Comments are kept with the deliberation and in the audit log, so the reasoning survives the vote.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\", \"comment\"],\n },\n\n \"chap.deliberate.vote\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. A closed deliberation is refused with -32032, and a second vote from the same voter with -32031.\" },\n vote: { type: \"string\", enum: [\"yea\", \"nay\", \"abstain\"], description: \"This voter's position. An abstention is recorded but counts as neither a yea nor a nay, so under all_approve or quorum:N it withholds the approval those rules need.\" },\n weight: { type: \"integer\", description: \"Recorded with the vote. The tally uses the weights map given at chap.deliberate.open, not this value.\" },\n comment: { type: \"string\", description: \"Why the vote went this way. Recorded with it.\" },\n veto_invoked: { type: \"boolean\", description: \"Blocks the outcome regardless of the tally. Honoured only under weighted_vote_with_veto, and only when the voter is listed true in the veto map given at open.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\", \"vote\"],\n },\n\n \"chap.deliberate.close\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. Closing computes the outcome from the votes cast; closing an already closed deliberation returns the outcome unchanged.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\"],\n },\n\n // ============================================================\n // handoff/1.0\n // ============================================================\n\n \"chap.handoff.propose\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to: { type: \"string\", description: \"Recipient, as a participant URI or a group URI such as 'group:support-team'. A recipient who is not a workspace member is refused with -32052.\" },\n tasks: {\n type: \"array\",\n description: \"The work being handed over, one entry per task. Every task must currently be assigned to the proposer; otherwise the proposal is refused with -32050.\",\n items: {\n type: \"object\",\n properties: {\n task_id: TASK_ID,\n title: { type: \"string\", description: \"Short label for the task.\" },\n status_summary: { type: \"string\", description: \"Where the work has reached, and what has already been tried.\" },\n next_action: { type: \"string\", description: \"What the recipient should do first.\" },\n blockers: { type: \"array\", items: { type: \"string\" }, description: \"What is preventing progress, if anything.\" },\n },\n required: [\"task_id\"],\n },\n },\n summary: { type: \"string\", description: \"Covering note for the handover as a whole, above the per-task detail.\" },\n context_links: { type: \"array\", items: { type: \"string\" }, description: \"URLs to threads, tickets or documents the recipient will need.\" },\n },\n required: [\"workspace\", \"from\", \"to\", \"tasks\"],\n },\n\n \"chap.handoff.accept\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n handoff_id: { type: \"string\", description: \"Identifier returned by chap.handoff.propose. A handoff already accepted or declined is refused with -32051.\" },\n accepted_task_ids: { type: \"array\", items: TASK_ID, description: \"Which of the proposed tasks are being accepted. If omitted, all of them are.\" },\n comment: { type: \"string\", description: \"Anything the recipient wants recorded when taking the work on.\" },\n },\n required: [\"workspace\", \"from\", \"handoff_id\"],\n },\n\n \"chap.handoff.decline\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n handoff_id: { type: \"string\", description: \"Identifier returned by chap.handoff.propose. A handoff already accepted or declined is refused with -32051.\" },\n reason: { type: \"string\", description: \"Why the handover is refused. Recorded so the proposer can route it elsewhere.\" },\n suggested_target: { ...PARTICIPANT_URI, description: \"Who should take it instead, if the decliner knows.\" },\n },\n required: [\"workspace\", \"from\", \"handoff_id\"],\n },\n\n // ============================================================\n // control/1.0\n // ============================================================\n\n \"chap.control.pause\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n scope: {\n type: \"string\",\n enum: [\"task\", \"participant\", \"workspace\"],\n default: \"task\",\n description: \"What the pause applies to. 'task' moves one task to 'paused'; a task that is completed, declined, cancelled or superseded is refused with -32061. 'participant' stops new tasks being assigned to that member and leaves their existing work running. 'workspace' refuses every method except workspace.create, workspace.describe, control.resume, audit.read, participant.join and participant.leave.\",\n },\n task_id: TASK_ID,\n participant_uri: { ...PARTICIPANT_URI, description: \"Whose work to pause, when scope is 'participant'. Must be a workspace member.\" },\n in_flight_policy: {\n type: \"string\",\n enum: [\"allow_to_complete\", \"interrupt\"],\n description: \"Recorded with the request, and echoed back when scope is 'participant'. The coordinator does not act on it: under either value, work already under way is left alone.\",\n },\n reason: { type: \"string\", description: \"Why the pause was applied. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.resume\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n scope: {\n type: \"string\",\n enum: [\"task\", \"participant\", \"workspace\"],\n default: \"task\",\n description: \"What the resume applies to. 'task' returns a paused task to the state it held at the pause; a task that is not paused is refused with -32061. 'participant' allows that member to be assigned tasks again. 'workspace' returns the workspace to active.\",\n },\n task_id: TASK_ID,\n participant_uri: { ...PARTICIPANT_URI, description: \"Whose work to resume, when scope is 'participant'. Must be a workspace member.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.cancel\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: { ...TASK_ID, description: \"The task to cancel. A task that is completed, declined, cancelled or superseded is refused with -32061.\" },\n reason: { type: \"string\", description: \"Why the task was cancelled. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.control.snapshot\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n label: { type: \"string\", description: \"Name for this snapshot, recorded on the artefact. chap.control.rollback identifies a snapshot by its artefact id, not by label.\" },\n include: { type: \"array\", items: { type: \"string\" }, description: \"Which aspects of the workspace to capture. Recognised values are 'members', 'open_tasks', 'mode_ceiling', 'policy' and 'audit'. Defaults to members, open_tasks and mode_ceiling.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.rollback\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to_snapshot_artefact_id: { type: \"string\", description: \"Artefact id returned by chap.control.snapshot. An id with no matching snapshot is refused with -32062.\" },\n what_to_restore: { type: \"array\", items: { type: \"string\" }, description: \"Which captured aspects to apply. Only 'mode_ceiling' and 'members' are restored; the others are held in the snapshot and not reapplied. Restoring members resets role and scopes on members still present, and does not re-add members who have left. Defaults to the snapshot's include list.\" },\n reason: { type: \"string\", description: \"Why the rollback was performed. The rollback is itself an audit entry; earlier entries are not rewritten.\" },\n },\n required: [\"workspace\", \"from\", \"to_snapshot_artefact_id\"],\n },\n\n \"chap.control.supersede\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: { ...TASK_ID, description: \"The task being replaced. It moves to 'superseded' and is linked to the successor rather than deleted.\" },\n successor_task: {\n type: \"object\",\n description: \"The replacement task.\",\n properties: {\n kind: { type: \"string\", description: \"Task kind for the successor. Required.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who takes the replacement on. Defaults to the superseded task's assignee, and must be a workspace member who is not paused.\" },\n input: { type: \"object\", additionalProperties: true, description: \"Input payload for the successor. Defaults to an empty object.\" },\n mode: { type: \"string\", enum: [\"shadow\", \"trial\", \"production\"], description: \"Mode for the successor, defaulting to the superseded task's. A mode above the workspace's current ceiling is refused with -32040.\" },\n review_required: { type: \"boolean\", description: \"Whether completing the successor needs a reviewer decision. A successor of a task that requires review requires it whatever is passed here, and under modes/1.0 so does a trial-mode successor.\" },\n },\n required: [\"kind\"],\n },\n reason: { type: \"string\", description: \"Why the original is being replaced. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"successor_task\"],\n },\n\n \"chap.control.set_mode_ceiling\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n new_ceiling: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n description: \"The highest mode tasks in this workspace may request from now on. Existing tasks keep the mode they were created with. Where the coordinator is configured to enforce step-up authentication this method is one of the privileged ones and a call without step-up is refused with -32402.\",\n },\n reason: { type: \"string\", description: \"Why the ceiling is being changed. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"new_ceiling\"],\n },\n\n // ============================================================\n // routing/1.0\n // ============================================================\n\n \"chap.task.route\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n candidates: { type: \"array\", items: PARTICIPANT_URI, description: \"Candidate assignees. An empty list is refused with -32513. The default policy takes the first candidate that is a workspace member and is not paused, and refuses the call with -32510 when there is none. An operator-supplied routing policy may select on any basis; a choice that is not a member is refused with -32510, and one who is paused with -32063.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"candidates\"],\n },\n\n \"chap.review.depth\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n artefact_routing_hints: {\n type: \"object\",\n description: \"Per-artefact signals such as confidence, model_id and cost_consumed_usd, merged over the task's routing_hints for this call. The default policy reads criticality and confidence. If the merged set is empty the call is refused with -32514. Fractional values are written as decimal strings, e.g. \\\"confidence\\\": \\\"0.86\\\".\",\n additionalProperties: true,\n },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.escalate.auto\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n default_escalation_target: { ...PARTICIPANT_URI, description: \"Who to escalate to when the policy decides to escalate and names no target of its own. It must be a workspace member or a group URI; if the policy escalates with no usable target the call is refused with -32516.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n // ============================================================\n // security-signed/1.0\n // ============================================================\n\n \"chap.participant.rotate_key\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n old_kid: { type: \"string\", description: \"Key id being retired. It is given a valid_until timestamp and stays in the member's key history, so signatures made before the rotation still verify. A key id that is unknown is refused with -32071, and one already revoked with -32072.\" },\n new_jwk: { type: \"object\", additionalProperties: true, description: \"The replacement public key as a JWK. It must carry a 'kid'. Whether the request itself has to be signed with the old key is decided at dispatch, and only where the coordinator is configured to require signatures.\" },\n },\n required: [\"workspace\", \"from\", \"old_kid\", \"new_jwk\"],\n },\n\n \"chap.participant.revoke_key\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n target_uri: { ...PARTICIPANT_URI, description: \"Whose key is being revoked. Revoking another member's key requires the caller to hold the role 'admin'; otherwise the call is refused with -32011.\" },\n kid: { type: \"string\", description: \"Key id to revoke. It is marked revoked with a timestamp and a reason, and signatures presented with it are refused from then on. A key id that is unknown is refused with -32071.\" },\n reason: { type: \"string\", description: \"Why the key was revoked, e.g. 'laptop lost'. Recorded on the key and in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"target_uri\", \"kid\"],\n },\n\n // ============================================================\n // audit-scitt/1.0\n // ============================================================\n\n \"chap.audit.submit_to_scitt\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n range: {\n type: \"object\",\n description: \"Sequence window to anchor. Omit to submit the whole chain.\",\n properties: {\n from_seq: { type: \"integer\", description: \"Start sequence number, inclusive.\" },\n to_seq: { type: \"integer\", description: \"End sequence number, exclusive.\" },\n },\n },\n issuer: { type: \"string\", description: \"Issuer identifier placed on each SCITT signed statement, naming who vouches for the chain. Defaults to 'service:coordinator'. Where no submitter is configured the statements are returned unsigned for the deployment to submit out of band.\" },\n },\n required: [\"workspace\"],\n },\n\n \"chap.audit.verify_receipt\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n receipt: { type: \"object\", additionalProperties: true, description: \"The SCITT receipt to check, as returned by the transparency service. Verification is delegated to a hook supplied by the deployment, and fails closed with -32082 where no hook is configured.\" },\n },\n required: [\"workspace\", \"receipt\"],\n },\n\n \"chap.audit.verify_chain\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI },\n required: [\"workspace\"],\n },\n};\n\n/** Methods that map to MCP tools. Currently: all 39 CHAP methods. */\nexport const TOOL_NAMES = Object.keys(SCHEMAS);\n\n/** Get the JSON Schema for a tool, or null if not a known CHAP method. */\nexport function schemaFor(toolName: string): JsonSchema | null {\n return SCHEMAS[toolName] ?? null;\n}\n\n/** Map an MCP tool name back to its CHAP method name. */\nexport function methodForTool(toolName: string): string | null {\n if (!toolName.startsWith(\"chap.\")) return null;\n return toolName.slice(\"chap.\".length);\n}\n\n// ============================================================\n// Stringified-JSON coercion\n// ============================================================\n//\n// LLM MCP clients (Claude Desktop, Cursor, and others) frequently\n// serialise structured tool arguments as JSON-encoded *strings* rather\n// than as native JSON objects/arrays. For example, an `artefact` that\n// should arrive as { \"draft\": \"...\" } arrives as the string\n// \"{\\\"draft\\\": \\\"...\\\"}\", and a `to` that should be [\"human:me@local\"]\n// arrives as \"[\\\"human:me@local\\\"]\".\n//\n// The CHAP protocol core is deliberately strict: it stores artefacts\n// and applies JSON Patches against whatever it receives. A stringified\n// object therefore (a) pollutes the audit log with the wrong type and\n// (b) makes object-path patches in decide.override impossible, because\n// there is no object to traverse.\n//\n// We fix this at the adapter boundary, leaving the protocol core\n// untouched. Before an argument is wrapped in a CHAP envelope, any\n// string value whose schema admits a non-string type is JSON-parsed\n// when (and only when) it parses cleanly to a type the schema allows.\n// Plain strings that the schema accepts as strings (participant URIs,\n// task ids, rationales) are never touched, so a bare \"human:me@local\"\n// passed to a string|array `to` field is preserved as-is.\n\n/** True if the schema admits `object` as a value type. */\nfunction admitsType(schema: JsonSchema | undefined, t: \"object\" | \"array\"): boolean {\n if (!schema) return false;\n if (schema.type === t) return true;\n if (schema.oneOf) return schema.oneOf.some((s) => admitsType(s, t));\n // A field declared with neither `type` nor `oneOf` (e.g. `output`,\n // `artefact`) is an opaque payload: it admits any JSON value, so we\n // allow coercion to both object and array for it.\n if (schema.type === undefined && !schema.oneOf && !schema.enum) return true;\n return false;\n}\n\n/**\n * Coerce a single argument value against its parameter schema. Returns\n * the parsed value when the string is stringified JSON the schema\n * accepts; otherwise returns the value unchanged.\n */\nfunction coerceValue(value: unknown, schema: JsonSchema | undefined): unknown {\n if (typeof value !== \"string\") return value;\n const trimmed = value.trim();\n if (trimmed.length === 0) return value;\n const looksLikeObject = trimmed.startsWith(\"{\");\n const looksLikeArray = trimmed.startsWith(\"[\");\n if (!looksLikeObject && !looksLikeArray) return value;\n\n const wantObject = looksLikeObject && admitsType(schema, \"object\");\n const wantArray = looksLikeArray && admitsType(schema, \"array\");\n if (!wantObject && !wantArray) return value;\n\n try {\n const parsed = JSON.parse(value);\n // Only accept the parse if its type is one the schema admits. This\n // guards against, say, a string that happens to start with \"[\" but\n // is meant to be a literal string in a string-only field.\n if (Array.isArray(parsed) && admitsType(schema, \"array\")) return parsed;\n if (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)\n && admitsType(schema, \"object\")) return parsed;\n return value;\n } catch {\n // Not valid JSON: leave it for the coordinator to validate/reject.\n return value;\n }\n}\n\n/**\n * Normalise the arguments object for a tool call, coercing any\n * stringified-JSON values whose parameter schema admits a structured\n * type. Unknown keys (not in the schema) are passed through untouched.\n *\n * This is a pure function: it returns a new object and does not mutate\n * its input. Coordinator dispatch sees correctly-typed params, so the\n * audit log records the right shapes and decide.override patches apply\n * against real objects.\n */\nexport function coerceToolArgs(\n toolName: string,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n const schema = schemaFor(toolName);\n const props = schema?.properties;\n if (!props) return args;\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n out[key] = coerceValue(value, props[key]);\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCA,IAAM,kBAA8B;AAAA,EAClC,MAAM;AAAA,EACN,aAAa;AACf;AAEA,IAAM,eAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,aAAa;AACf;AAEA,IAAM,UAAsB;AAAA,EAC1B,MAAM;AAAA,EACN,aAAa;AACf;AASA,IAAM,oBAAoB,CAAC,YACzB,sCAAsC,OAAO;AAE/C,IAAM,gBAA4B;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY;AAAA,IACV,aAAa;AAAA,MACX,MAAM;AAAA,MACN,MAAM,CAAC,OAAO,UAAU,QAAQ,UAAU;AAAA,MAC1C,aAAa;AAAA,IACf;AAAA,IACA,UAAa,EAAE,MAAM,UAAU,aAAa,kHAAkH;AAAA,IAC9J,WAAa,EAAE,MAAM,UAAU,aAAa,mJAAmJ;AA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.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator-mcp/schemas\n *\n * JSON Schema definitions for each CHAP method, used as the\n * inputSchema for the corresponding MCP tool. Each schema describes\n * the params object that the CHAP envelope would carry; the tool\n * handler wraps the params in a JSON-RPC 2.0 envelope before dispatch.\n *\n * A description here is what an MCP client reads before deciding\n * whether and how to call the tool, so each one states what the\n * coordinator does with the parameter, and names the error code where\n * a constraint is enforced. A parameter that is recorded but not acted\n * on says so; describing an intention the code does not implement is\n * worse than saying nothing.\n *\n * Aligned with CHAP 0.3 (see profiles/*.md) and MCP 2025-11-25.\n */\n\nexport interface JsonSchema {\n type?: string;\n description?: string;\n properties?: Record<string, JsonSchema>;\n required?: string[];\n enum?: string[];\n items?: JsonSchema;\n additionalProperties?: boolean | JsonSchema;\n oneOf?: JsonSchema[];\n default?: unknown;\n /** JSON Schema `pattern`, used where a string has a fixed wire shape. */\n pattern?: string;\n}\n\n// Common reusable fragments.\nconst PARTICIPANT_URI: JsonSchema = {\n type: \"string\",\n description: \"Participant URI, e.g. 'human:alice@example.org' or 'agent:bot@local'.\",\n};\n\nconst WORKSPACE_ID: JsonSchema = {\n type: \"string\",\n description: \"Workspace identifier, e.g. 'wsp_techcorp_support'.\",\n};\n\nconst TASK_ID: JsonSchema = {\n type: \"string\",\n description: \"Task identifier returned by chap.task.create.\",\n};\n\n/**\n * SPECIFICATION.md S7: a number in a CHAP envelope must be an integer.\n * Fractional values travel as decimal strings, so that canonicalisation and\n * therefore the audit hash are identical across implementations. A JSON number\n * with a fractional part is refused at ingress with -32602, so any parameter\n * that is conceptually fractional is declared here as a string.\n */\nconst decimalStringNote = (example: string) =>\n `Written as a decimal string, e.g. \"${example}\". CHAP canonicalisation accepts integers only, so a JSON number with a fractional part is refused with -32602.`;\n\nconst ROUTING_HINTS: JsonSchema = {\n type: \"object\",\n description: \"Signals recorded on the task and read by the routing/1.0 methods: task.route, review.depth and escalate.auto. Recording a hint has no effect on its own; it is consulted only when one of those methods is called.\",\n properties: {\n criticality: {\n type: \"string\",\n enum: [\"low\", \"medium\", \"high\", \"critical\"],\n description: \"How costly a wrong answer would be. The default review-depth policy reads it: 'critical' gives a full review, and 'high' with confidence below 0.7 does the same. The default assignee policy does not read it.\",\n },\n deadline: { type: \"string\", description: \"When the work is needed by, as an ISO 8601 timestamp. Recorded on the task; the coordinator does not act on it.\" },\n risk_tier: { type: \"string\", description: \"Operator-defined risk band, e.g. 'regulated' or 'internal'. No built-in policy reads it; it is available to an operator-supplied routing policy.\" },\n max_cost_usd: { type: \"string\", description: `Budget ceiling for this task in US dollars. ${decimalStringNote(\"12.50\")} No built-in policy reads it.` },\n },\n additionalProperties: true,\n};\n\n/** Free-text justification attached to a decision and kept in the audit log. */\nconst COMMENT: JsonSchema = {\n type: \"string\",\n description: \"The reviewer's note on this decision. Recorded in the audit entry for the decision.\",\n};\n\n/** Workspace-defined labels carried on a decision. */\nconst TAGS: JsonSchema = {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Workspace-defined labels for this decision, e.g. ['tone', 'unsupported-claim']. Recorded in the audit entry. chap.audit.read does not filter on tags, so grouping by tag is done by the reader.\",\n};\n\n/** Binds a decision to the exact artefact the reviewer saw. */\nconst ARTEFACT_DIGEST: JsonSchema = {\n type: \"string\",\n pattern: \"^sha256:[0-9a-f]{64}$\",\n description: \"Optional. SHA-256 over the JCS canonicalisation of the artefact under review, in the form `sha256:<hex>`. When present it binds the decision to the exact content reviewed, and a mismatch is refused with -32074.\",\n};\n\n/** Applies to `output` and `artefact`, which are opaque JSON payloads. */\nconst STRUCTURED_PAYLOAD_NOTE =\n \"Pass a JSON object or array. A JSON-encoded string is parsed back to the structured value before dispatch, so patches in chap.decide.override apply against a real object.\";\n\n// ============================================================\n// Core\n// ============================================================\n\nexport const SCHEMAS: Record<string, JsonSchema> = {\n \"chap.workspace.create\": {\n type: \"object\",\n properties: {\n workspace: { ...WORKSPACE_ID, description: \"Workspace id to create. If omitted, one is generated.\" },\n profiles: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Profile identifiers to enable, e.g. ['core/1.0', 'review/1.0']. Recorded on the workspace. Two profiles change behaviour by being present: modes/1.0, under which a trial-mode task requires review, and audit-scitt/1.0, which turns on the hash-linked chain.\",\n },\n mode: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n default: \"trial\",\n description: \"Default mode for tasks created here. Under modes/1.0 a trial-mode task has review_required set to true whatever the caller passes. 'shadow' and 'production' are recorded on the task and carry no further behaviour in this implementation.\",\n },\n mode_ceiling: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n default: \"production\",\n description: \"Highest mode a task in this workspace may request. A task.create above the ceiling is refused with -32040. The ceiling can be changed afterwards with chap.control.set_mode_ceiling.\",\n },\n join_policy: {\n type: \"string\",\n enum: [\"open\", \"invite\"],\n default: \"open\",\n description: \"Who may join. 'open' admits anyone. 'invite' admits only a participant an admin invited with chap.workspace.invite, and the workspace's first member, which becomes its admin; any other join is refused with -32011. It cannot be changed afterwards.\",\n },\n review_rule: {\n type: \"string\",\n pattern: \"^(any_one_approves|all_approve|quorum:[1-9][0-9]*)$\",\n default: \"any_one_approves\",\n description: \"The rule of every review that task.complete opens here: any_one_approves, all_approve or quorum:<n>. An author cannot open a review of their own review-required task, so this is how a workspace asks for more than one approval. It cannot be changed afterwards.\",\n },\n },\n additionalProperties: false,\n },\n\n \"chap.workspace.describe\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID },\n required: [\"workspace\"],\n },\n\n \"chap.workspace.set_profiles\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n profiles: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"The complete profile set to enable, replacing the current one. Adding audit-scitt/1.0 to a workspace that already has entries leaves those entries unchained and outside chain verification.\",\n },\n },\n required: [\"workspace\", \"profiles\"],\n },\n\n \"chap.workspace.invite\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: { ...PARTICIPANT_URI, description: \"The admin who invites. Any other sender is refused with -32011.\" },\n uri: { ...PARTICIPANT_URI, description: \"The participant invited. Its scheme must name type, as at a join.\" },\n type: {\n type: \"string\",\n enum: [\"human\", \"agent\", \"service\"],\n description: \"The kind of participant invited, which the scheme of uri must name. The member takes this type. group: and workspace: URIs name address scopes, which cannot join, and are refused with -32602.\",\n },\n role: { type: \"string\", description: \"The role the member takes when it joins, whatever role the join names. Only an invitation grants 'admin' after the first member, and only to a human or a service.\" },\n jwks: {\n type: \"object\",\n description: \"Keys to pin, as {keys: [JWK, ...]}, each with a kid. The join's keys must be among them, and the member holds them. For a member that holds no key in force, the call registers these keys at once: the way back for a member whose keys were all revoked.\",\n },\n oidc_sub: { type: \"string\", description: \"The OIDC subject whose token admits the invitee: the join must carry an oidc_token for it. Needs a token verifier on the coordinator.\" },\n },\n required: [\"workspace\", \"from\", \"uri\", \"type\"],\n },\n\n \"chap.participant.join\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n type: {\n type: \"string\",\n enum: [\"human\", \"agent\", \"service\"],\n description: \"The kind of participant, which the scheme of from must name: 'agent:' for an agent, and so on. Any other join is refused with -32602, and so is a join of a group: or workspace: URI, which names an address scope. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011. In a workspace that requires signatures, a participant that signs joins with a key.\",\n },\n role: { type: \"string\", description: \"Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin', which changes the profiles, invites, and revokes another member's key. It is granted, never claimed: only the workspace's first member, or a participant an admin's invitation names as admin, may name it at a join, and any other join naming it is refused with -32011. Only a human or a service holds it. An invitation's role replaces the one named here.\" },\n display_name: { type: \"string\", description: \"Human-readable name for interfaces. Not used in authorisation.\" },\n },\n required: [\"workspace\", \"from\", \"type\"],\n },\n\n \"chap.participant.leave\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.task.create\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: { ...PARTICIPANT_URI, description: \"The delegator. Must be a workspace member.\" },\n kind: { type: \"string\", description: \"Task kind, e.g. 'draft_response' or 'review'. Free text; the coordinator records it without interpreting it.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who the task is assigned to. Must be a workspace member, and must not be paused: assigning to a paused member is refused with -32063.\" },\n input: { type: \"object\", description: \"Task-specific input payload.\", additionalProperties: true },\n routing_hints: ROUTING_HINTS,\n mode: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n description: \"Mode for this task, defaulting to the workspace mode. A mode above the workspace ceiling is refused with -32040.\",\n },\n review_required: {\n type: \"boolean\",\n description: \"When true, chap.task.complete opens a review instead of completing: the output becomes the artefact under review, and the task reaches 'completed' only on a reviewer decision. chap.task.update cannot complete such a task. Under modes/1.0 a trial-mode task has this set to true whatever is passed here.\",\n },\n deadline: { type: \"string\", description: \"When the task is due, as an ISO 8601 timestamp. Recorded on the task; the coordinator does not act on it.\" },\n idempotency_key: {\n type: \"string\",\n description: \"Caller-chosen key for safe retries. A second create carrying a key already seen in this workspace returns the original task and records nothing further. The workspace retains the 10,000 most recent keys.\",\n },\n },\n required: [\"workspace\", \"from\", \"kind\", \"assignee\", \"input\"],\n },\n\n \"chap.task.update\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n state: {\n type: \"string\",\n enum: [\"in_progress\", \"declined\", \"cancelled\", \"completed\"],\n description: \"The state to move the task to. Only the transitions in SPECIFICATION.md 8.1 are legal from the task's current state; others are refused with -32602. A review opens with chap.review.request, or with chap.task.complete on a task that requires one, so 'review_requested' is not a target here. A task marked review_required cannot be moved to 'completed' here: submit the output with chap.task.complete, which opens the review.\",\n },\n progress_note: { type: \"string\", description: \"Short note on what changed, kept in the task's history.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"state\"],\n },\n\n \"chap.task.complete\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n output: { description: `The task's output artefact. ${STRUCTURED_PAYLOAD_NOTE}` },\n confidence: { type: \"string\", description: `Self-reported confidence in the output, between 0 and 1. ${decimalStringNote(\"0.86\")}` },\n routing_hints: ROUTING_HINTS,\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.audit.read\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n range: {\n type: \"object\",\n description: \"Sequence window to return. Omit for the whole log.\",\n properties: {\n from_seq: { type: \"integer\", description: \"Start sequence number, inclusive.\" },\n to_seq: { type: \"integer\", description: \"End sequence number, exclusive.\" },\n },\n },\n filter: {\n type: \"object\",\n description: \"Narrows the entries returned. Conditions combine with AND, and are applied within the sequence window rather than before it.\",\n properties: {\n method: { type: \"string\", description: \"Return only entries for this CHAP method, e.g. 'decide.override'. Matched in full, without the 'chap.' tool-name prefix.\" },\n from: { type: \"string\", description: \"Return only entries whose actor is this participant URI.\" },\n task_id: { type: \"string\", description: \"Return only entries about this task.\" },\n outcome: {\n type: \"string\",\n enum: [\"accepted\", \"refused\"],\n description: \"Return only accepted calls, or only the refused attempts the coordinator recorded. Omit for both.\",\n },\n },\n },\n },\n required: [\"workspace\"],\n },\n\n // ============================================================\n // review/1.0\n // ============================================================\n\n \"chap.review.request\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID,\n from: PARTICIPANT_URI,\n task_id: TASK_ID,\n to: {\n oneOf: [PARTICIPANT_URI, { type: \"array\", items: PARTICIPANT_URI }],\n description: \"One or more reviewers, as a single URI string or an array of URI strings. Only a workspace member can go on to decide, so a review addressed elsewhere cannot be closed by its recipient.\",\n },\n rule: {\n type: \"string\",\n enum: [\"any_one_approves\", \"all_approve\", \"quorum:2\", \"quorum:3\"],\n default: \"any_one_approves\",\n description: \"How many of the addressed reviewers must approve before the task completes. quorum:N is accepted for any N of 1 or more. The rule is fixed once the review is open: a later request naming a different one is refused with -32014. Omitting it on a later request leaves the rule alone, which is how reviewers are added to an open review.\",\n },\n artefact: { description: `The draft being submitted for review. ${STRUCTURED_PAYLOAD_NOTE} Re-requesting with the same artefact widens the reviewer set; a different artefact on an open review is refused with -32014.` },\n deadline: { type: \"string\", description: \"When the review is needed by, as an ISO 8601 timestamp. Recorded on the review; the coordinator does not act on it.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"to\", \"artefact\"],\n },\n\n \"chap.review.acknowledge\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.decide.approve\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n approved_artefact_digest: ARTEFACT_DIGEST,\n comment: COMMENT,\n tags: TAGS,\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.decide.reject\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n approved_artefact_digest: ARTEFACT_DIGEST,\n comment: COMMENT,\n tags: TAGS,\n request_revision: { type: \"boolean\", description: \"When true the task returns to 'in_progress' rather than 'declined', so the assignee can revise and resubmit.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.decide.override\": {\n type: \"object\",\n properties: {\n approved_artefact_digest: ARTEFACT_DIGEST,\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n diff: {\n type: \"array\",\n description: \"RFC 6902 JSON Patch operations applied to the artefact under review. The patched artefact becomes the task output; a patch that does not apply is refused with -32012.\",\n items: {\n type: \"object\",\n properties: {\n op: { type: \"string\", enum: [\"add\", \"replace\", \"remove\", \"copy\", \"move\", \"test\"], description: \"The patch operation to apply.\" },\n path: { type: \"string\", description: \"JSON Pointer into the artefact, e.g. '/body' or '/items/0/severity'.\" },\n value: { description: \"The new value, for add, replace and test.\" },\n from: { type: \"string\", description: \"Source JSON Pointer, for copy and move.\" },\n },\n required: [\"op\", \"path\"],\n },\n },\n rationale: { type: \"string\", description: \"Why the correction was made. Required on every override and recorded in the audit entry, since the diff shows what changed but not why.\" },\n tags: TAGS,\n policy_refs: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Identifiers of the policies or guidelines this correction applies, e.g. ['policy:no-delivery-promises']. Recorded in the audit entry.\",\n },\n logical_id: {\n type: \"string\",\n description: \"Caller-chosen identifier for the item being decided, stable across revisions and overrides of the same underlying content. Recorded in the audit entry.\",\n },\n intent_preserved: {\n type: \"boolean\",\n description: \"True when the edit refines the decision the draft was making, false when it substitutes a different one. Recorded in the audit entry.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"diff\", \"rationale\"],\n },\n\n \"chap.abstain.declare\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n reason: { type: \"string\", description: \"Why this reviewer is standing aside. Recorded in the audit entry.\" },\n category: {\n type: \"string\",\n enum: [\"conflict_of_interest\", \"insufficient_context\", \"out_of_scope\", \"other\"],\n description: \"The kind of abstention. Recorded in the audit entry.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"reason\"],\n },\n\n \"chap.escalate.raise\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n original_task_id: { ...TASK_ID, description: \"The task being escalated. It moves to 'escalated' and is linked to the successor. A completed, cancelled or superseded task cannot be escalated.\" },\n new_task: {\n type: \"object\",\n description: \"The successor task to open for the escalation target.\",\n properties: {\n kind: { type: \"string\", description: \"Task kind for the successor. Defaults to the original's kind.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who the escalation goes to. Must be a workspace member who is not paused: a paused assignee is refused with -32063.\" },\n input: { type: \"object\", additionalProperties: true, description: \"Input payload for the successor. It defaults to an empty object rather than the original's input, so anything the new assignee needs has to be restated here.\" },\n mode: { type: \"string\", enum: [\"shadow\", \"trial\", \"production\"], description: \"Mode for the successor, defaulting to the original's. A mode above the workspace's current ceiling is refused with -32040, so after the ceiling is lowered a task is escalated by naming a mode within it.\" },\n },\n required: [\"assignee\"],\n },\n },\n required: [\"workspace\", \"from\", \"original_task_id\", \"new_task\"],\n },\n\n // ============================================================\n // whisper/1.0\n // ============================================================\n\n \"chap.whisper.ask\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID,\n to: { type: \"array\", items: PARTICIPANT_URI, description: \"Who is being asked.\" },\n question: { type: \"string\", description: \"The question being put. A whisper is answered on its own, without the recipient opening the task.\" },\n options: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Stable identifier that an answer refers to.\" },\n label: { type: \"string\", description: \"What the option says to the person answering.\" },\n },\n required: [\"id\"],\n },\n description: \"Multiple-choice options. When present, an answer must name one of these ids in answer_option; any other id is refused with -32022.\",\n },\n deadline_ms: { type: \"integer\", description: \"How long the whisper stays open, in milliseconds from now. Once it passes, the whisper lapses and default_if_lapsed is applied.\" },\n default_if_lapsed: { description: \"The value applied if the deadline passes with no answer. Required, so that a lapsed whisper still has a defined outcome.\" },\n urgency: {\n type: \"string\",\n enum: [\"low\", \"medium\", \"high\"],\n default: \"low\",\n description: \"How urgent the question is. Recorded and passed on to the client; it does not change the deadline or the lapse behaviour.\",\n },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"to\", \"question\", \"deadline_ms\", \"default_if_lapsed\"],\n },\n\n \"chap.whisper.answer\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n whisper_id: { type: \"string\", description: \"Identifier returned by chap.whisper.ask. A whisper that has already been answered is refused with -32020, and one past its deadline with -32021.\" },\n answer_option: { type: \"string\", description: \"The id of the chosen option. Required when the whisper carried options.\" },\n answer: { type: \"string\", description: \"Free-text answer, for a whisper with no options.\" },\n comment: { type: \"string\", description: \"Anything else the answerer wants recorded alongside the answer.\" },\n },\n required: [\"workspace\", \"from\", \"whisper_id\"],\n },\n\n // ============================================================\n // deliberation/1.0\n // ============================================================\n\n \"chap.deliberate.open\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to: { type: \"array\", items: PARTICIPANT_URI, description: \"The participants entitled to vote. A vote from anyone else is refused with -32030.\" },\n task_id: TASK_ID,\n rule: {\n type: \"string\",\n description: \"How the outcome is decided when the deliberation closes: any_one_approves, all_approve, quorum:N, weighted_vote:T or weighted_vote_with_veto:T. An unrecognised rule is refused at open with -32033.\",\n },\n question: { type: \"string\", description: \"What the group is deciding. State it so that a yea or a nay is unambiguous.\" },\n weights: { type: \"object\", additionalProperties: { type: \"integer\" }, description: \"Voter to weight map, read by the weighted rules. A voter with no entry counts as 1. Weights must be integers: a JSON number with a fractional part is refused with -32602.\" },\n veto: { type: \"object\", additionalProperties: { type: \"boolean\" }, description: \"Voter to can-veto map. A veto is honoured only under weighted_vote_with_veto, and only from a voter listed true here.\" },\n deadline: { type: \"string\", description: \"When voting is intended to close, as an ISO 8601 timestamp. Recorded on the deliberation; closing is done by chap.deliberate.close and the coordinator does not close on the deadline.\" },\n },\n required: [\"workspace\", \"from\", \"to\", \"rule\"],\n },\n\n \"chap.deliberate.comment\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. A closed deliberation is refused with -32032.\" },\n comment: { type: \"string\", description: \"The contribution to record. Comments are kept with the deliberation and in the audit log, so the reasoning survives the vote.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\", \"comment\"],\n },\n\n \"chap.deliberate.vote\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. A closed deliberation is refused with -32032, and a second vote from the same voter with -32031.\" },\n vote: { type: \"string\", enum: [\"yea\", \"nay\", \"abstain\"], description: \"This voter's position. An abstention is recorded but counts as neither a yea nor a nay, so under all_approve or quorum:N it withholds the approval those rules need.\" },\n weight: { type: \"integer\", description: \"Recorded with the vote. The tally uses the weights map given at chap.deliberate.open, not this value.\" },\n comment: { type: \"string\", description: \"Why the vote went this way. Recorded with it.\" },\n veto_invoked: { type: \"boolean\", description: \"Blocks the outcome regardless of the tally. Honoured only under weighted_vote_with_veto, and only when the voter is listed true in the veto map given at open.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\", \"vote\"],\n },\n\n \"chap.deliberate.close\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n deliberation_id: { type: \"string\", description: \"Identifier returned by chap.deliberate.open. Closing computes the outcome from the votes cast; closing an already closed deliberation returns the outcome unchanged.\" },\n },\n required: [\"workspace\", \"from\", \"deliberation_id\"],\n },\n\n // ============================================================\n // handoff/1.0\n // ============================================================\n\n \"chap.handoff.propose\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to: { type: \"string\", description: \"Recipient, as a participant URI or a group URI such as 'group:support-team'. A recipient who is not a workspace member is refused with -32052.\" },\n tasks: {\n type: \"array\",\n description: \"The work being handed over, one entry per task. Every task must currently be assigned to the proposer; otherwise the proposal is refused with -32050.\",\n items: {\n type: \"object\",\n properties: {\n task_id: TASK_ID,\n title: { type: \"string\", description: \"Short label for the task.\" },\n status_summary: { type: \"string\", description: \"Where the work has reached, and what has already been tried.\" },\n next_action: { type: \"string\", description: \"What the recipient should do first.\" },\n blockers: { type: \"array\", items: { type: \"string\" }, description: \"What is preventing progress, if anything.\" },\n },\n required: [\"task_id\"],\n },\n },\n summary: { type: \"string\", description: \"Covering note for the handover as a whole, above the per-task detail.\" },\n context_links: { type: \"array\", items: { type: \"string\" }, description: \"URLs to threads, tickets or documents the recipient will need.\" },\n },\n required: [\"workspace\", \"from\", \"to\", \"tasks\"],\n },\n\n \"chap.handoff.accept\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n handoff_id: { type: \"string\", description: \"Identifier returned by chap.handoff.propose. A handoff already accepted or declined is refused with -32051.\" },\n accepted_task_ids: { type: \"array\", items: TASK_ID, description: \"Which of the proposed tasks are being accepted. If omitted, all of them are.\" },\n comment: { type: \"string\", description: \"Anything the recipient wants recorded when taking the work on.\" },\n },\n required: [\"workspace\", \"from\", \"handoff_id\"],\n },\n\n \"chap.handoff.decline\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n handoff_id: { type: \"string\", description: \"Identifier returned by chap.handoff.propose. A handoff already accepted or declined is refused with -32051.\" },\n reason: { type: \"string\", description: \"Why the handover is refused. Recorded so the proposer can route it elsewhere.\" },\n suggested_target: { ...PARTICIPANT_URI, description: \"Who should take it instead, if the decliner knows.\" },\n },\n required: [\"workspace\", \"from\", \"handoff_id\"],\n },\n\n // ============================================================\n // control/1.0\n // ============================================================\n\n \"chap.control.pause\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n scope: {\n type: \"string\",\n enum: [\"task\", \"participant\", \"workspace\"],\n default: \"task\",\n description: \"What the pause applies to. 'task' moves one task to 'paused'; a task that is completed, declined, cancelled or superseded is refused with -32061. 'participant' stops new tasks being assigned to that member and leaves their existing work running. 'workspace' refuses every method except workspace.create, workspace.describe, control.resume, audit.read, participant.join and participant.leave.\",\n },\n task_id: TASK_ID,\n participant_uri: { ...PARTICIPANT_URI, description: \"Whose work to pause, when scope is 'participant'. Must be a workspace member.\" },\n in_flight_policy: {\n type: \"string\",\n enum: [\"allow_to_complete\", \"interrupt\"],\n description: \"Recorded with the request, and echoed back when scope is 'participant'. The coordinator does not act on it: under either value, work already under way is left alone.\",\n },\n reason: { type: \"string\", description: \"Why the pause was applied. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.resume\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n scope: {\n type: \"string\",\n enum: [\"task\", \"participant\", \"workspace\"],\n default: \"task\",\n description: \"What the resume applies to. 'task' returns a paused task to the state it held at the pause; a task that is not paused is refused with -32061. 'participant' allows that member to be assigned tasks again. 'workspace' returns the workspace to active.\",\n },\n task_id: TASK_ID,\n participant_uri: { ...PARTICIPANT_URI, description: \"Whose work to resume, when scope is 'participant'. Must be a workspace member.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.cancel\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: { ...TASK_ID, description: \"The task to cancel. A task that is completed, declined, cancelled or superseded is refused with -32061.\" },\n reason: { type: \"string\", description: \"Why the task was cancelled. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.control.snapshot\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n label: { type: \"string\", description: \"Name for this snapshot, recorded on the artefact. chap.control.rollback identifies a snapshot by its artefact id, not by label.\" },\n include: { type: \"array\", items: { type: \"string\" }, description: \"Which aspects of the workspace to capture. Recognised values are 'members', 'open_tasks', 'mode_ceiling', 'policy' and 'audit'. Defaults to members, open_tasks and mode_ceiling.\" },\n },\n required: [\"workspace\", \"from\"],\n },\n\n \"chap.control.rollback\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n to_snapshot_artefact_id: { type: \"string\", description: \"Artefact id returned by chap.control.snapshot. An id with no matching snapshot is refused with -32062.\" },\n what_to_restore: { type: \"array\", items: { type: \"string\" }, description: \"Which captured aspects to apply. Only 'mode_ceiling' and 'members' are restored; the others are held in the snapshot and not reapplied. Restoring members resets role and scopes on members still present, and does not re-add members who have left. Defaults to the snapshot's include list.\" },\n reason: { type: \"string\", description: \"Why the rollback was performed. The rollback is itself an audit entry; earlier entries are not rewritten.\" },\n },\n required: [\"workspace\", \"from\", \"to_snapshot_artefact_id\"],\n },\n\n \"chap.control.supersede\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: { ...TASK_ID, description: \"The task being replaced. It moves to 'superseded' and is linked to the successor rather than deleted.\" },\n successor_task: {\n type: \"object\",\n description: \"The replacement task.\",\n properties: {\n kind: { type: \"string\", description: \"Task kind for the successor. Required.\" },\n assignee: { ...PARTICIPANT_URI, description: \"Who takes the replacement on. Defaults to the superseded task's assignee, and must be a workspace member who is not paused.\" },\n input: { type: \"object\", additionalProperties: true, description: \"Input payload for the successor. Defaults to an empty object.\" },\n mode: { type: \"string\", enum: [\"shadow\", \"trial\", \"production\"], description: \"Mode for the successor, defaulting to the superseded task's. A mode above the workspace's current ceiling is refused with -32040.\" },\n review_required: { type: \"boolean\", description: \"Whether completing the successor needs a reviewer decision. A successor of a task that requires review requires it whatever is passed here, and under modes/1.0 so does a trial-mode successor.\" },\n },\n required: [\"kind\"],\n },\n reason: { type: \"string\", description: \"Why the original is being replaced. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"successor_task\"],\n },\n\n \"chap.control.set_mode_ceiling\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n new_ceiling: {\n type: \"string\",\n enum: [\"shadow\", \"trial\", \"production\"],\n description: \"The highest mode tasks in this workspace may request from now on. Existing tasks keep the mode they were created with. Where the coordinator is configured to enforce step-up authentication this method is one of the privileged ones and a call without step-up is refused with -32402.\",\n },\n reason: { type: \"string\", description: \"Why the ceiling is being changed. Recorded in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"new_ceiling\"],\n },\n\n // ============================================================\n // routing/1.0\n // ============================================================\n\n \"chap.task.route\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n candidates: { type: \"array\", items: PARTICIPANT_URI, description: \"Candidate assignees. An empty list is refused with -32513. The default policy takes the first candidate that is a workspace member and is not paused, and refuses the call with -32510 when there is none. An operator-supplied routing policy may select on any basis; a choice that is not a member is refused with -32510, and one who is paused with -32063.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\", \"candidates\"],\n },\n\n \"chap.review.depth\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n artefact_routing_hints: {\n type: \"object\",\n description: \"Per-artefact signals such as confidence, model_id and cost_consumed_usd, merged over the task's routing_hints for this call. The default policy reads criticality and confidence. If the merged set is empty the call is refused with -32514. Fractional values are written as decimal strings, e.g. \\\"confidence\\\": \\\"0.86\\\".\",\n additionalProperties: true,\n },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n \"chap.escalate.auto\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n task_id: TASK_ID,\n default_escalation_target: { ...PARTICIPANT_URI, description: \"Who to escalate to when the policy decides to escalate and names no target of its own. It must be a workspace member or a group URI; if the policy escalates with no usable target the call is refused with -32516.\" },\n },\n required: [\"workspace\", \"from\", \"task_id\"],\n },\n\n // ============================================================\n // security-signed/1.0\n // ============================================================\n\n \"chap.participant.rotate_key\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n old_kid: { type: \"string\", description: \"Key id being retired. It is given a valid_until timestamp and stays in the member's key history, so signatures made before the rotation still verify. A key id that is unknown is refused with -32071, and one already revoked with -32072.\" },\n new_jwk: { type: \"object\", additionalProperties: true, description: \"The replacement public key as a JWK. It must carry a 'kid'. Whether the request itself has to be signed with the old key is decided at dispatch, and only where the coordinator is configured to require signatures.\" },\n },\n required: [\"workspace\", \"from\", \"old_kid\", \"new_jwk\"],\n },\n\n \"chap.participant.revoke_key\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n target_uri: { ...PARTICIPANT_URI, description: \"Whose key is being revoked. Revoking another member's key requires the caller to hold the role 'admin'; otherwise the call is refused with -32011.\" },\n kid: { type: \"string\", description: \"Key id to revoke. It is marked revoked with a timestamp and a reason, and signatures presented with it are refused from then on. A key id that is unknown is refused with -32071.\" },\n reason: { type: \"string\", description: \"Why the key was revoked, e.g. 'laptop lost'. Recorded on the key and in the audit entry.\" },\n },\n required: [\"workspace\", \"from\", \"target_uri\", \"kid\"],\n },\n\n // ============================================================\n // audit-scitt/1.0\n // ============================================================\n\n \"chap.audit.submit_to_scitt\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n range: {\n type: \"object\",\n description: \"Sequence window to anchor. Omit to submit the whole chain.\",\n properties: {\n from_seq: { type: \"integer\", description: \"Start sequence number, inclusive.\" },\n to_seq: { type: \"integer\", description: \"End sequence number, exclusive.\" },\n },\n },\n issuer: { type: \"string\", description: \"Issuer identifier placed on each SCITT signed statement, naming who vouches for the chain. Defaults to 'service:coordinator'. Where no submitter is configured the statements are returned unsigned for the deployment to submit out of band.\" },\n },\n required: [\"workspace\"],\n },\n\n \"chap.audit.verify_receipt\": {\n type: \"object\",\n properties: {\n workspace: WORKSPACE_ID, from: PARTICIPANT_URI,\n receipt: { type: \"object\", additionalProperties: true, description: \"The SCITT receipt to check, as returned by the transparency service. Verification is delegated to a hook supplied by the deployment, and fails closed with -32082 where no hook is configured.\" },\n },\n required: [\"workspace\", \"receipt\"],\n },\n\n \"chap.audit.verify_chain\": {\n type: \"object\",\n properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI },\n required: [\"workspace\"],\n },\n};\n\n/** Methods that map to MCP tools: every CHAP method the coordinators implement. */\nexport const TOOL_NAMES = Object.keys(SCHEMAS);\n\n/** Get the JSON Schema for a tool, or null if not a known CHAP method. */\nexport function schemaFor(toolName: string): JsonSchema | null {\n return SCHEMAS[toolName] ?? null;\n}\n\n/** Map an MCP tool name back to its CHAP method name. */\nexport function methodForTool(toolName: string): string | null {\n if (!toolName.startsWith(\"chap.\")) return null;\n return toolName.slice(\"chap.\".length);\n}\n\n// ============================================================\n// Stringified-JSON coercion\n// ============================================================\n//\n// LLM MCP clients (Claude Desktop, Cursor, and others) frequently\n// serialise structured tool arguments as JSON-encoded *strings* rather\n// than as native JSON objects/arrays. For example, an `artefact` that\n// should arrive as { \"draft\": \"...\" } arrives as the string\n// \"{\\\"draft\\\": \\\"...\\\"}\", and a `to` that should be [\"human:me@local\"]\n// arrives as \"[\\\"human:me@local\\\"]\".\n//\n// The CHAP protocol core is deliberately strict: it stores artefacts\n// and applies JSON Patches against whatever it receives. A stringified\n// object therefore (a) pollutes the audit log with the wrong type and\n// (b) makes object-path patches in decide.override impossible, because\n// there is no object to traverse.\n//\n// We fix this at the adapter boundary, leaving the protocol core\n// untouched. Before an argument is wrapped in a CHAP envelope, any\n// string value whose schema admits a non-string type is JSON-parsed\n// when (and only when) it parses cleanly to a type the schema allows.\n// Plain strings that the schema accepts as strings (participant URIs,\n// task ids, rationales) are never touched, so a bare \"human:me@local\"\n// passed to a string|array `to` field is preserved as-is.\n\n/** True if the schema admits `object` as a value type. */\nfunction admitsType(schema: JsonSchema | undefined, t: \"object\" | \"array\"): boolean {\n if (!schema) return false;\n if (schema.type === t) return true;\n if (schema.oneOf) return schema.oneOf.some((s) => admitsType(s, t));\n // A field declared with neither `type` nor `oneOf` (e.g. `output`,\n // `artefact`) is an opaque payload: it admits any JSON value, so we\n // allow coercion to both object and array for it.\n if (schema.type === undefined && !schema.oneOf && !schema.enum) return true;\n return false;\n}\n\n/**\n * Coerce a single argument value against its parameter schema. Returns\n * the parsed value when the string is stringified JSON the schema\n * accepts; otherwise returns the value unchanged.\n */\nfunction coerceValue(value: unknown, schema: JsonSchema | undefined): unknown {\n if (typeof value !== \"string\") return value;\n const trimmed = value.trim();\n if (trimmed.length === 0) return value;\n const looksLikeObject = trimmed.startsWith(\"{\");\n const looksLikeArray = trimmed.startsWith(\"[\");\n if (!looksLikeObject && !looksLikeArray) return value;\n\n const wantObject = looksLikeObject && admitsType(schema, \"object\");\n const wantArray = looksLikeArray && admitsType(schema, \"array\");\n if (!wantObject && !wantArray) return value;\n\n try {\n const parsed = JSON.parse(value);\n // Only accept the parse if its type is one the schema admits. This\n // guards against, say, a string that happens to start with \"[\" but\n // is meant to be a literal string in a string-only field.\n if (Array.isArray(parsed) && admitsType(schema, \"array\")) return parsed;\n if (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)\n && admitsType(schema, \"object\")) return parsed;\n return value;\n } catch {\n // Not valid JSON: leave it for the coordinator to validate/reject.\n return value;\n }\n}\n\n/**\n * Normalise the arguments object for a tool call, coercing any\n * stringified-JSON values whose parameter schema admits a structured\n * type. Unknown keys (not in the schema) are passed through untouched.\n *\n * This is a pure function: it returns a new object and does not mutate\n * its input. Coordinator dispatch sees correctly-typed params, so the\n * audit log records the right shapes and decide.override patches apply\n * against real objects.\n */\nexport function coerceToolArgs(\n toolName: string,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n const schema = schemaFor(toolName);\n const props = schema?.properties;\n if (!props) return args;\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(args)) {\n out[key] = coerceValue(value, props[key]);\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCA,IAAM,kBAA8B;AAAA,EAClC,MAAM;AAAA,EACN,aAAa;AACf;AAEA,IAAM,eAA2B;AAAA,EAC/B,MAAM;AAAA,EACN,aAAa;AACf;AAEA,IAAM,UAAsB;AAAA,EAC1B,MAAM;AAAA,EACN,aAAa;AACf;AASA,IAAM,oBAAoB,CAAC,YACzB,sCAAsC,OAAO;AAE/C,IAAM,gBAA4B;AAAA,EAChC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY;AAAA,IACV,aAA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S,UAAa,CAAC,OAAO,SAAS,CAAC,OAAO,KAAM,QAAO;AACvE,SAAO;AACT;AAOA,SAAS,YAAY,OAAgB,QAAyC;AAC5E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,kBAAkB,QAAQ,WAAW,GAAG;AAC9C,QAAM,iBAAkB,QAAQ,WAAW,GAAG;AAC9C,MAAI,CAAC,mBAAmB,CAAC,eAAgB,QAAO;AAEhD,QAAM,aAAa,mBAAmB,WAAW,QAAQ,QAAQ;AACjE,QAAM,YAAa,kBAAmB,WAAW,QAAQ,OAAO;AAChE,MAAI,CAAC,cAAc,CAAC,UAAW,QAAO;AAEtC,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,KAAK;AAI/B,QAAI,MAAM,QAAQ,MAAM,KAAK,WAAW,QAAQ,OAAO,EAAG,QAAO;AACjE,QAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,KACnE,WAAW,QAAQ,QAAQ,EAAG,QAAO;AAC5C,WAAO;AAAA,EACT,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAYO,SAAS,eACd,UACA,MACyB;AACzB,QAAM,SAAS,UAAU,QAAQ;AACjC,QAAM,QAAQ,QAAQ;AACtB,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,MAA+B,CAAC;AACtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,QAAI,GAAG,IAAI,YAAY,OAAO,MAAM,GAAG,CAAC;AAAA,EAC1C;AACA,SAAO;AACT;","names":[]}
|
package/dist/schemas.d.cts
CHANGED
|
@@ -29,7 +29,7 @@ interface JsonSchema {
|
|
|
29
29
|
pattern?: string;
|
|
30
30
|
}
|
|
31
31
|
declare const SCHEMAS: Record<string, JsonSchema>;
|
|
32
|
-
/** Methods that map to MCP tools
|
|
32
|
+
/** Methods that map to MCP tools: every CHAP method the coordinators implement. */
|
|
33
33
|
declare const TOOL_NAMES: string[];
|
|
34
34
|
/** Get the JSON Schema for a tool, or null if not a known CHAP method. */
|
|
35
35
|
declare function schemaFor(toolName: string): JsonSchema | null;
|
package/dist/schemas.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ interface JsonSchema {
|
|
|
29
29
|
pattern?: string;
|
|
30
30
|
}
|
|
31
31
|
declare const SCHEMAS: Record<string, JsonSchema>;
|
|
32
|
-
/** Methods that map to MCP tools
|
|
32
|
+
/** Methods that map to MCP tools: every CHAP method the coordinators implement. */
|
|
33
33
|
declare const TOOL_NAMES: string[];
|
|
34
34
|
/** Get the JSON Schema for a tool, or null if not a known CHAP method. */
|
|
35
35
|
declare function schemaFor(toolName: string): JsonSchema | null;
|
package/dist/schemas.js
CHANGED
|
@@ -63,6 +63,18 @@ var SCHEMAS = {
|
|
|
63
63
|
enum: ["shadow", "trial", "production"],
|
|
64
64
|
default: "production",
|
|
65
65
|
description: "Highest mode a task in this workspace may request. A task.create above the ceiling is refused with -32040. The ceiling can be changed afterwards with chap.control.set_mode_ceiling."
|
|
66
|
+
},
|
|
67
|
+
join_policy: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["open", "invite"],
|
|
70
|
+
default: "open",
|
|
71
|
+
description: "Who may join. 'open' admits anyone. 'invite' admits only a participant an admin invited with chap.workspace.invite, and the workspace's first member, which becomes its admin; any other join is refused with -32011. It cannot be changed afterwards."
|
|
72
|
+
},
|
|
73
|
+
review_rule: {
|
|
74
|
+
type: "string",
|
|
75
|
+
pattern: "^(any_one_approves|all_approve|quorum:[1-9][0-9]*)$",
|
|
76
|
+
default: "any_one_approves",
|
|
77
|
+
description: "The rule of every review that task.complete opens here: any_one_approves, all_approve or quorum:<n>. An author cannot open a review of their own review-required task, so this is how a workspace asks for more than one approval. It cannot be changed afterwards."
|
|
66
78
|
}
|
|
67
79
|
},
|
|
68
80
|
additionalProperties: false
|
|
@@ -84,6 +96,26 @@ var SCHEMAS = {
|
|
|
84
96
|
},
|
|
85
97
|
required: ["workspace", "profiles"]
|
|
86
98
|
},
|
|
99
|
+
"chap.workspace.invite": {
|
|
100
|
+
type: "object",
|
|
101
|
+
properties: {
|
|
102
|
+
workspace: WORKSPACE_ID,
|
|
103
|
+
from: { ...PARTICIPANT_URI, description: "The admin who invites. Any other sender is refused with -32011." },
|
|
104
|
+
uri: { ...PARTICIPANT_URI, description: "The participant invited. Its scheme must name type, as at a join." },
|
|
105
|
+
type: {
|
|
106
|
+
type: "string",
|
|
107
|
+
enum: ["human", "agent", "service"],
|
|
108
|
+
description: "The kind of participant invited, which the scheme of uri must name. The member takes this type. group: and workspace: URIs name address scopes, which cannot join, and are refused with -32602."
|
|
109
|
+
},
|
|
110
|
+
role: { type: "string", description: "The role the member takes when it joins, whatever role the join names. Only an invitation grants 'admin' after the first member, and only to a human or a service." },
|
|
111
|
+
jwks: {
|
|
112
|
+
type: "object",
|
|
113
|
+
description: "Keys to pin, as {keys: [JWK, ...]}, each with a kid. The join's keys must be among them, and the member holds them. For a member that holds no key in force, the call registers these keys at once: the way back for a member whose keys were all revoked."
|
|
114
|
+
},
|
|
115
|
+
oidc_sub: { type: "string", description: "The OIDC subject whose token admits the invitee: the join must carry an oidc_token for it. Needs a token verifier on the coordinator." }
|
|
116
|
+
},
|
|
117
|
+
required: ["workspace", "from", "uri", "type"]
|
|
118
|
+
},
|
|
87
119
|
"chap.participant.join": {
|
|
88
120
|
type: "object",
|
|
89
121
|
properties: {
|
|
@@ -91,10 +123,10 @@ var SCHEMAS = {
|
|
|
91
123
|
from: PARTICIPANT_URI,
|
|
92
124
|
type: {
|
|
93
125
|
type: "string",
|
|
94
|
-
enum: ["human", "agent", "service"
|
|
95
|
-
description: "The kind of participant. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011."
|
|
126
|
+
enum: ["human", "agent", "service"],
|
|
127
|
+
description: "The kind of participant, which the scheme of from must name: 'agent:' for an agent, and so on. Any other join is refused with -32602, and so is a join of a group: or workspace: URI, which names an address scope. Only members of type 'human' are eligible for the review that chap.task.complete opens on a task marked review_required, and a completion with no eligible human is refused with -32011. In a workspace that requires signatures, a participant that signs joins with a key."
|
|
96
128
|
},
|
|
97
|
-
role: { type: "string", description: "Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin'
|
|
129
|
+
role: { type: "string", description: "Operator-defined role, e.g. 'reviewer' or 'drafter'. One value is read by the coordinator: 'admin', which changes the profiles, invites, and revokes another member's key. It is granted, never claimed: only the workspace's first member, or a participant an admin's invitation names as admin, may name it at a join, and any other join naming it is refused with -32011. Only a human or a service holds it. An invitation's role replaces the one named here." },
|
|
98
130
|
display_name: { type: "string", description: "Human-readable name for interfaces. Not used in authorisation." }
|
|
99
131
|
},
|
|
100
132
|
required: ["workspace", "from", "type"]
|
|
@@ -210,6 +242,11 @@ var SCHEMAS = {
|
|
|
210
242
|
},
|
|
211
243
|
required: ["workspace", "from", "task_id", "to", "artefact"]
|
|
212
244
|
},
|
|
245
|
+
"chap.review.acknowledge": {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: { workspace: WORKSPACE_ID, from: PARTICIPANT_URI, task_id: TASK_ID },
|
|
248
|
+
required: ["workspace", "from", "task_id"]
|
|
249
|
+
},
|
|
213
250
|
"chap.decide.approve": {
|
|
214
251
|
type: "object",
|
|
215
252
|
properties: {
|