@brightbeamai/chap-coordinator 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 +54 -8
- package/dist/{api-59aU01Bs.d.cts → api-CjZQnj63.d.cts} +128 -14
- package/dist/{api-CxciGFHA.d.ts → api-DG0VFGVr.d.ts} +128 -14
- package/dist/api.cjs +3 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +3 -1
- package/dist/api.js.map +1 -1
- package/dist/index.cjs +1578 -276
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +1577 -276
- package/dist/index.js.map +1 -1
- package/dist/jsonrpc.cjs +1 -0
- package/dist/jsonrpc.cjs.map +1 -1
- package/dist/jsonrpc.d.cts +1 -0
- package/dist/jsonrpc.d.ts +1 -0
- package/dist/jsonrpc.js +1 -0
- package/dist/jsonrpc.js.map +1 -1
- package/dist/methods.cjs.map +1 -1
- package/dist/methods.d.cts +36 -3
- package/dist/methods.d.ts +36 -3
- package/dist/patch.cjs +195 -61
- package/dist/patch.cjs.map +1 -1
- package/dist/patch.d.cts +16 -2
- package/dist/patch.d.ts +16 -2
- package/dist/patch.js +194 -61
- package/dist/patch.js.map +1 -1
- package/dist/storage/sqlite.cjs +81 -19
- package/dist/storage/sqlite.cjs.map +1 -1
- package/dist/storage/sqlite.d.cts +19 -9
- package/dist/storage/sqlite.d.ts +19 -9
- package/dist/storage/sqlite.js +81 -19
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/storage/store.cjs +20 -15
- package/dist/storage/store.cjs.map +1 -1
- package/dist/storage/store.d.cts +24 -6
- package/dist/storage/store.d.ts +24 -6
- package/dist/storage/store.js +20 -15
- package/dist/storage/store.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +56 -1
- package/dist/types.d.ts +56 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n oidc_acr?: string;\n vc_holder?: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n produced_at: string;\n produced_by: ParticipantUri;\n content_hash: string;\n content: {\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n };\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n paused_from?: TaskState;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n /** The accepted call. Absent on a refusal entry. */\n envelope?: Envelope;\n /**\n * The refused call, as received. Present only on a refusal entry, and held\n * here rather than under `envelope` so a reader keyed on `envelope` passes\n * the refusal by instead of replaying it (SPECIFICATION 10.1).\n */\n request?: Envelope;\n /** Present only on a refusal entry. */\n outcome?: RefusalOutcome;\n prev_hash?: string;\n}\n\n/** Why a recorded call did not take effect. */\nexport interface RefusalOutcome {\n status: \"refused\";\n /** The error code the caller was answered with. */\n code: number;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n min_acr?: string;\n members: Map<ParticipantUri, Member>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n // task.create idempotency: caller-supplied key -> task_id.\n idempotency_keys: Record<string, TaskId>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgYO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\n\n/**\n * Which calls a workspace that requires signatures verifies: every call, or\n * every call except an unsigned one from an agent member.\n */\nexport type SignaturePolicy = \"all\" | \"humans\";\n/**\n * Who may join a workspace: anyone (\"open\"), or only a participant an admin\n * invited with workspace.invite, and the first member (\"invite\").\n */\nexport type JoinPolicy = \"open\" | \"invite\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n oidc_acr?: string;\n vc_holder?: string;\n}\n\n/**\n * An admin's invitation to join (workspace.invite), held until the invitee\n * joins. The member takes its type and role; where it pins keys, the join's\n * keys are among them and the member holds them; where it names an OIDC\n * subject, the invitee joins with a token for that subject.\n */\nexport interface Invitation {\n uri: ParticipantUri;\n type: ParticipantType;\n role?: string;\n jwks?: { keys: Jwk[] };\n oidc_sub?: string;\n invited_by: ParticipantUri;\n invited_at: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n produced_at: string;\n produced_by: ParticipantUri;\n content_hash: string;\n content: {\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n };\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n /**\n * Who made the work under review: the task's assignee, then the member\n * that completed it. None of them may decide the review.\n */\n authors: ParticipantUri[];\n /**\n * The reviewers who have said they began this round, in the order they\n * did (review.acknowledge). A new round starts with none.\n */\n acknowledgements: { reviewer: ParticipantUri; ts: string }[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n /**\n * The authors of the work carried on from before: those of the task a\n * successor replaces, through escalate.raise or control.supersede, and\n * the members task.route or handoff.accept moved the task from. They\n * count among the authors of any review of this task.\n */\n prior_authors?: ParticipantUri[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n paused_from?: TaskState;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n /** The accepted call. Absent on a refusal entry. */\n envelope?: Envelope;\n /**\n * The refused call, as received. Present only on a refusal entry, and held\n * here rather than under `envelope` so a reader keyed on `envelope` passes\n * the refusal by instead of replaying it (SPECIFICATION 10.1).\n */\n request?: Envelope;\n /** Present only on a refusal entry. */\n outcome?: RefusalOutcome;\n prev_hash?: string;\n}\n\n/** Why a recorded call did not take effect. */\nexport interface RefusalOutcome {\n status: \"refused\";\n /** The error code the caller was answered with. */\n code: number;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n min_acr?: string;\n /** Which calls are verified where the workspace requires signatures. */\n signature_policy: SignaturePolicy;\n /** Who may join. */\n join_policy: JoinPolicy;\n /** The rule of a review that opens on task.complete; any_one_approves when unset. */\n review_rule?: string;\n members: Map<ParticipantUri, Member>;\n /** Invitations not yet taken up, by the URI each admits. */\n invitations: Map<ParticipantUri, Invitation>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n // task.create idempotency: caller-supplied key -> task_id.\n idempotency_keys: Record<string, TaskId>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAobO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
|
package/dist/types.d.cts
CHANGED
|
@@ -26,6 +26,16 @@ interface Envelope {
|
|
|
26
26
|
sig?: string;
|
|
27
27
|
}
|
|
28
28
|
type Mode = "shadow" | "trial" | "production";
|
|
29
|
+
/**
|
|
30
|
+
* Which calls a workspace that requires signatures verifies: every call, or
|
|
31
|
+
* every call except an unsigned one from an agent member.
|
|
32
|
+
*/
|
|
33
|
+
type SignaturePolicy = "all" | "humans";
|
|
34
|
+
/**
|
|
35
|
+
* Who may join a workspace: anyone ("open"), or only a participant an admin
|
|
36
|
+
* invited with workspace.invite, and the first member ("invite").
|
|
37
|
+
*/
|
|
38
|
+
type JoinPolicy = "open" | "invite";
|
|
29
39
|
type WorkspaceState = "active" | "paused" | "closed";
|
|
30
40
|
type PauseScope = "task" | "participant" | "workspace";
|
|
31
41
|
type TaskState = "created" | "in_progress" | "review_requested" | "completed" | "declined" | "abstained" | "escalated" | "superseded" | "paused" | "cancelled";
|
|
@@ -63,6 +73,23 @@ interface Member {
|
|
|
63
73
|
oidc_acr?: string;
|
|
64
74
|
vc_holder?: string;
|
|
65
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* An admin's invitation to join (workspace.invite), held until the invitee
|
|
78
|
+
* joins. The member takes its type and role; where it pins keys, the join's
|
|
79
|
+
* keys are among them and the member holds them; where it names an OIDC
|
|
80
|
+
* subject, the invitee joins with a token for that subject.
|
|
81
|
+
*/
|
|
82
|
+
interface Invitation {
|
|
83
|
+
uri: ParticipantUri;
|
|
84
|
+
type: ParticipantType;
|
|
85
|
+
role?: string;
|
|
86
|
+
jwks?: {
|
|
87
|
+
keys: Jwk[];
|
|
88
|
+
};
|
|
89
|
+
oidc_sub?: string;
|
|
90
|
+
invited_by: ParticipantUri;
|
|
91
|
+
invited_at: string;
|
|
92
|
+
}
|
|
66
93
|
interface TaskRoutingHints {
|
|
67
94
|
criticality?: "low" | "medium" | "high" | "critical";
|
|
68
95
|
deadline?: string;
|
|
@@ -238,6 +265,19 @@ interface Task {
|
|
|
238
265
|
rule: string;
|
|
239
266
|
deadline?: string;
|
|
240
267
|
decisions: ReviewDecision[];
|
|
268
|
+
/**
|
|
269
|
+
* Who made the work under review: the task's assignee, then the member
|
|
270
|
+
* that completed it. None of them may decide the review.
|
|
271
|
+
*/
|
|
272
|
+
authors: ParticipantUri[];
|
|
273
|
+
/**
|
|
274
|
+
* The reviewers who have said they began this round, in the order they
|
|
275
|
+
* did (review.acknowledge). A new round starts with none.
|
|
276
|
+
*/
|
|
277
|
+
acknowledgements: {
|
|
278
|
+
reviewer: ParticipantUri;
|
|
279
|
+
ts: string;
|
|
280
|
+
}[];
|
|
241
281
|
};
|
|
242
282
|
history: {
|
|
243
283
|
ts: string;
|
|
@@ -245,6 +285,13 @@ interface Task {
|
|
|
245
285
|
state: TaskState;
|
|
246
286
|
note?: string;
|
|
247
287
|
}[];
|
|
288
|
+
/**
|
|
289
|
+
* The authors of the work carried on from before: those of the task a
|
|
290
|
+
* successor replaces, through escalate.raise or control.supersede, and
|
|
291
|
+
* the members task.route or handoff.accept moved the task from. They
|
|
292
|
+
* count among the authors of any review of this task.
|
|
293
|
+
*/
|
|
294
|
+
prior_authors?: ParticipantUri[];
|
|
248
295
|
supersedes?: TaskId;
|
|
249
296
|
superseded_by?: TaskId;
|
|
250
297
|
parent?: TaskId;
|
|
@@ -285,7 +332,15 @@ interface Workspace {
|
|
|
285
332
|
routing_policy_uri?: string;
|
|
286
333
|
step_up_window_sec: number;
|
|
287
334
|
min_acr?: string;
|
|
335
|
+
/** Which calls are verified where the workspace requires signatures. */
|
|
336
|
+
signature_policy: SignaturePolicy;
|
|
337
|
+
/** Who may join. */
|
|
338
|
+
join_policy: JoinPolicy;
|
|
339
|
+
/** The rule of a review that opens on task.complete; any_one_approves when unset. */
|
|
340
|
+
review_rule?: string;
|
|
288
341
|
members: Map<ParticipantUri, Member>;
|
|
342
|
+
/** Invitations not yet taken up, by the URI each admits. */
|
|
343
|
+
invitations: Map<ParticipantUri, Invitation>;
|
|
289
344
|
tasks: Map<TaskId, Task>;
|
|
290
345
|
overrides: Map<ArtefactId, OverrideArtefact>;
|
|
291
346
|
whispers: Map<string, WhisperPrompt>;
|
|
@@ -306,4 +361,4 @@ type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;
|
|
|
306
361
|
/** True iff mode `a` is <= ceiling. */
|
|
307
362
|
declare function modeLE(a: Mode, ceiling: Mode): boolean;
|
|
308
363
|
|
|
309
|
-
export { type ArtefactId, type ArtefactRoutingHints, type AuditEntry, type AuditListener, type Deliberation, type DeliberationVote, type Envelope, type Handoff, type HandoffTaskItem, type JsonPatchOp, type Jwk, type KeyRecord, type Member, type Mode, type OverrideArtefact, type ParticipantType, type ParticipantUri, type PauseScope, type RefusalOutcome, type ReviewDecision, type RouteDecisionArtefact, type SnapshotArtefact, type Task, type TaskId, type TaskRoutingHints, type TaskState, type WhisperPrompt, type Workspace, type WorkspaceId, type WorkspaceState, modeLE };
|
|
364
|
+
export { type ArtefactId, type ArtefactRoutingHints, type AuditEntry, type AuditListener, type Deliberation, type DeliberationVote, type Envelope, type Handoff, type HandoffTaskItem, type Invitation, type JoinPolicy, type JsonPatchOp, type Jwk, type KeyRecord, type Member, type Mode, type OverrideArtefact, type ParticipantType, type ParticipantUri, type PauseScope, type RefusalOutcome, type ReviewDecision, type RouteDecisionArtefact, type SignaturePolicy, type SnapshotArtefact, type Task, type TaskId, type TaskRoutingHints, type TaskState, type WhisperPrompt, type Workspace, type WorkspaceId, type WorkspaceState, modeLE };
|
package/dist/types.d.ts
CHANGED
|
@@ -26,6 +26,16 @@ interface Envelope {
|
|
|
26
26
|
sig?: string;
|
|
27
27
|
}
|
|
28
28
|
type Mode = "shadow" | "trial" | "production";
|
|
29
|
+
/**
|
|
30
|
+
* Which calls a workspace that requires signatures verifies: every call, or
|
|
31
|
+
* every call except an unsigned one from an agent member.
|
|
32
|
+
*/
|
|
33
|
+
type SignaturePolicy = "all" | "humans";
|
|
34
|
+
/**
|
|
35
|
+
* Who may join a workspace: anyone ("open"), or only a participant an admin
|
|
36
|
+
* invited with workspace.invite, and the first member ("invite").
|
|
37
|
+
*/
|
|
38
|
+
type JoinPolicy = "open" | "invite";
|
|
29
39
|
type WorkspaceState = "active" | "paused" | "closed";
|
|
30
40
|
type PauseScope = "task" | "participant" | "workspace";
|
|
31
41
|
type TaskState = "created" | "in_progress" | "review_requested" | "completed" | "declined" | "abstained" | "escalated" | "superseded" | "paused" | "cancelled";
|
|
@@ -63,6 +73,23 @@ interface Member {
|
|
|
63
73
|
oidc_acr?: string;
|
|
64
74
|
vc_holder?: string;
|
|
65
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* An admin's invitation to join (workspace.invite), held until the invitee
|
|
78
|
+
* joins. The member takes its type and role; where it pins keys, the join's
|
|
79
|
+
* keys are among them and the member holds them; where it names an OIDC
|
|
80
|
+
* subject, the invitee joins with a token for that subject.
|
|
81
|
+
*/
|
|
82
|
+
interface Invitation {
|
|
83
|
+
uri: ParticipantUri;
|
|
84
|
+
type: ParticipantType;
|
|
85
|
+
role?: string;
|
|
86
|
+
jwks?: {
|
|
87
|
+
keys: Jwk[];
|
|
88
|
+
};
|
|
89
|
+
oidc_sub?: string;
|
|
90
|
+
invited_by: ParticipantUri;
|
|
91
|
+
invited_at: string;
|
|
92
|
+
}
|
|
66
93
|
interface TaskRoutingHints {
|
|
67
94
|
criticality?: "low" | "medium" | "high" | "critical";
|
|
68
95
|
deadline?: string;
|
|
@@ -238,6 +265,19 @@ interface Task {
|
|
|
238
265
|
rule: string;
|
|
239
266
|
deadline?: string;
|
|
240
267
|
decisions: ReviewDecision[];
|
|
268
|
+
/**
|
|
269
|
+
* Who made the work under review: the task's assignee, then the member
|
|
270
|
+
* that completed it. None of them may decide the review.
|
|
271
|
+
*/
|
|
272
|
+
authors: ParticipantUri[];
|
|
273
|
+
/**
|
|
274
|
+
* The reviewers who have said they began this round, in the order they
|
|
275
|
+
* did (review.acknowledge). A new round starts with none.
|
|
276
|
+
*/
|
|
277
|
+
acknowledgements: {
|
|
278
|
+
reviewer: ParticipantUri;
|
|
279
|
+
ts: string;
|
|
280
|
+
}[];
|
|
241
281
|
};
|
|
242
282
|
history: {
|
|
243
283
|
ts: string;
|
|
@@ -245,6 +285,13 @@ interface Task {
|
|
|
245
285
|
state: TaskState;
|
|
246
286
|
note?: string;
|
|
247
287
|
}[];
|
|
288
|
+
/**
|
|
289
|
+
* The authors of the work carried on from before: those of the task a
|
|
290
|
+
* successor replaces, through escalate.raise or control.supersede, and
|
|
291
|
+
* the members task.route or handoff.accept moved the task from. They
|
|
292
|
+
* count among the authors of any review of this task.
|
|
293
|
+
*/
|
|
294
|
+
prior_authors?: ParticipantUri[];
|
|
248
295
|
supersedes?: TaskId;
|
|
249
296
|
superseded_by?: TaskId;
|
|
250
297
|
parent?: TaskId;
|
|
@@ -285,7 +332,15 @@ interface Workspace {
|
|
|
285
332
|
routing_policy_uri?: string;
|
|
286
333
|
step_up_window_sec: number;
|
|
287
334
|
min_acr?: string;
|
|
335
|
+
/** Which calls are verified where the workspace requires signatures. */
|
|
336
|
+
signature_policy: SignaturePolicy;
|
|
337
|
+
/** Who may join. */
|
|
338
|
+
join_policy: JoinPolicy;
|
|
339
|
+
/** The rule of a review that opens on task.complete; any_one_approves when unset. */
|
|
340
|
+
review_rule?: string;
|
|
288
341
|
members: Map<ParticipantUri, Member>;
|
|
342
|
+
/** Invitations not yet taken up, by the URI each admits. */
|
|
343
|
+
invitations: Map<ParticipantUri, Invitation>;
|
|
289
344
|
tasks: Map<TaskId, Task>;
|
|
290
345
|
overrides: Map<ArtefactId, OverrideArtefact>;
|
|
291
346
|
whispers: Map<string, WhisperPrompt>;
|
|
@@ -306,4 +361,4 @@ type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;
|
|
|
306
361
|
/** True iff mode `a` is <= ceiling. */
|
|
307
362
|
declare function modeLE(a: Mode, ceiling: Mode): boolean;
|
|
308
363
|
|
|
309
|
-
export { type ArtefactId, type ArtefactRoutingHints, type AuditEntry, type AuditListener, type Deliberation, type DeliberationVote, type Envelope, type Handoff, type HandoffTaskItem, type JsonPatchOp, type Jwk, type KeyRecord, type Member, type Mode, type OverrideArtefact, type ParticipantType, type ParticipantUri, type PauseScope, type RefusalOutcome, type ReviewDecision, type RouteDecisionArtefact, type SnapshotArtefact, type Task, type TaskId, type TaskRoutingHints, type TaskState, type WhisperPrompt, type Workspace, type WorkspaceId, type WorkspaceState, modeLE };
|
|
364
|
+
export { type ArtefactId, type ArtefactRoutingHints, type AuditEntry, type AuditListener, type Deliberation, type DeliberationVote, type Envelope, type Handoff, type HandoffTaskItem, type Invitation, type JoinPolicy, type JsonPatchOp, type Jwk, type KeyRecord, type Member, type Mode, type OverrideArtefact, type ParticipantType, type ParticipantUri, type PauseScope, type RefusalOutcome, type ReviewDecision, type RouteDecisionArtefact, type SignaturePolicy, type SnapshotArtefact, type Task, type TaskId, type TaskRoutingHints, type TaskState, type WhisperPrompt, type Workspace, type WorkspaceId, type WorkspaceState, modeLE };
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n oidc_acr?: string;\n vc_holder?: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n produced_at: string;\n produced_by: ParticipantUri;\n content_hash: string;\n content: {\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n };\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n paused_from?: TaskState;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n /** The accepted call. Absent on a refusal entry. */\n envelope?: Envelope;\n /**\n * The refused call, as received. Present only on a refusal entry, and held\n * here rather than under `envelope` so a reader keyed on `envelope` passes\n * the refusal by instead of replaying it (SPECIFICATION 10.1).\n */\n request?: Envelope;\n /** Present only on a refusal entry. */\n outcome?: RefusalOutcome;\n prev_hash?: string;\n}\n\n/** Why a recorded call did not take effect. */\nexport interface RefusalOutcome {\n status: \"refused\";\n /** The error code the caller was answered with. */\n code: number;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n min_acr?: string;\n members: Map<ParticipantUri, Member>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n // task.create idempotency: caller-supplied key -> task_id.\n idempotency_keys: Record<string, TaskId>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";AAgYO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @brightbeamai/chap-coordinator. type vocabulary\n *\n * Wire-shape and in-memory types for the Coordinator. The schemas at\n * schemas/ are the normative wire types; these mirror them in\n * TypeScript for in-process use.\n */\n\nexport type ParticipantUri = string;\nexport type WorkspaceId = string;\nexport type TaskId = string;\nexport type ArtefactId = string;\n\nexport type ParticipantType = \"human\" | \"agent\" | \"service\" | \"group\" | \"workspace\";\n\nexport interface Envelope {\n jsonrpc: \"2.0\";\n id?: string | number;\n method?: string;\n params?: Record<string, unknown>;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n /** security-signed/1.0: top-level signature, signed over JCS of the\n * envelope with this field removed. Form: ``ed25519:<kid>:<b64>``. */\n sig?: string;\n}\n\nexport type Mode = \"shadow\" | \"trial\" | \"production\";\n\n/**\n * Which calls a workspace that requires signatures verifies: every call, or\n * every call except an unsigned one from an agent member.\n */\nexport type SignaturePolicy = \"all\" | \"humans\";\n/**\n * Who may join a workspace: anyone (\"open\"), or only a participant an admin\n * invited with workspace.invite, and the first member (\"invite\").\n */\nexport type JoinPolicy = \"open\" | \"invite\";\nexport type WorkspaceState = \"active\" | \"paused\" | \"closed\";\nexport type PauseScope = \"task\" | \"participant\" | \"workspace\";\n\nexport type TaskState =\n | \"created\"\n | \"in_progress\"\n | \"review_requested\"\n | \"completed\"\n | \"declined\"\n | \"abstained\"\n | \"escalated\"\n | \"superseded\"\n | \"paused\"\n | \"cancelled\";\n\n// ============================================================\n// Key records (security-signed/1.0)\n// ============================================================\n\nexport interface Jwk {\n kty: \"OKP\";\n crv: \"Ed25519\";\n kid: string;\n x: string;\n use?: string;\n alg?: string;\n}\n\n/** A participant's JWK plus the validity window. Lookup by\n * (participant, kid, ts) so historical envelopes verify across\n * rotation per security-signed/1.0 S3-S5. */\nexport interface KeyRecord {\n jwk: Jwk;\n kid: string;\n valid_from: string; // ISO timestamp; inclusive\n valid_until?: string; // ISO timestamp; exclusive; absent = unbounded\n revoked_at?: string;\n revoked_reason?: string;\n}\n\n// ============================================================\n// Participants\n// ============================================================\n\nexport interface Member {\n uri: ParticipantUri;\n type: ParticipantType;\n role: string;\n joined: string;\n display_name?: string;\n capabilities?: Record<string, unknown>;\n scopes?: string[];\n keys: KeyRecord[];\n paused: boolean; // control.pause scope=participant\n oidc_sub?: string;\n oidc_auth_time?: number; // unix seconds\n oidc_acr?: string;\n vc_holder?: string;\n}\n\n/**\n * An admin's invitation to join (workspace.invite), held until the invitee\n * joins. The member takes its type and role; where it pins keys, the join's\n * keys are among them and the member holds them; where it names an OIDC\n * subject, the invitee joins with a token for that subject.\n */\nexport interface Invitation {\n uri: ParticipantUri;\n type: ParticipantType;\n role?: string;\n jwks?: { keys: Jwk[] };\n oidc_sub?: string;\n invited_by: ParticipantUri;\n invited_at: string;\n}\n\n// ============================================================\n// Routing hints\n// ============================================================\n\nexport interface TaskRoutingHints {\n criticality?: \"low\" | \"medium\" | \"high\" | \"critical\";\n deadline?: string;\n max_cost_usd?: number;\n risk_tier?: string;\n [extra: string]: unknown;\n}\n\nexport interface ArtefactRoutingHints {\n confidence?: number | string;\n model_id?: string;\n cost_consumed_usd?: number;\n latency_ms?: number;\n [extra: string]: unknown;\n}\n\n// ============================================================\n// JSON Patch (RFC 6902)\n// ============================================================\n\nexport interface JsonPatchOp {\n op: \"add\" | \"replace\" | \"remove\" | \"copy\" | \"move\" | \"test\";\n path: string;\n value?: unknown;\n from?: string;\n}\n\n// ============================================================\n// Override artefact (review/1.0)\n// ============================================================\n\nexport interface OverrideArtefact {\n id: ArtefactId;\n task_id: TaskId;\n reviewer: ParticipantUri;\n based_on_artefact: unknown;\n diff: JsonPatchOp[];\n result: unknown;\n rationale: string;\n tags: string[];\n policy_refs: string[];\n ts: string;\n logical_id?: string;\n instance_id?: string;\n intent_preserved?: boolean;\n}\n\n// ============================================================\n// Route decision artefact (routing/1.0)\n// ============================================================\n\nexport interface RouteDecisionArtefact {\n id: ArtefactId;\n kind: \"route_decision\";\n decision_type: \"task.route\" | \"review.depth\" | \"escalate.auto\";\n outcome: unknown;\n produced_by: ParticipantUri;\n produced_at: string;\n task?: TaskId;\n policy_id?: string;\n hints_observed: Record<string, unknown>;\n rationale: string;\n // Auxiliary fields per decision_type:\n // task.route: alternatives_considered\n // review.depth: sampling_probability\n // escalate.auto: escalation_target\n [extra: string]: unknown;\n}\n\n// ============================================================\n// Snapshot artefact (control/1.0)\n// ============================================================\n\nexport interface SnapshotArtefact {\n id: ArtefactId;\n kind: \"snapshot\";\n produced_at: string;\n produced_by: ParticipantUri;\n content_hash: string;\n content: {\n workspace: WorkspaceId;\n audit_seq: number;\n label?: string;\n include: string[];\n state: Record<string, unknown>;\n };\n}\n\n// ============================================================\n// Whisper (whisper/1.0)\n// ============================================================\n\nexport interface WhisperPrompt {\n id: ArtefactId;\n task_id: TaskId;\n asker: ParticipantUri;\n askee: ParticipantUri[];\n question: string;\n options?: Array<{ id: string; label?: string }>;\n asked_at: string;\n deadline_ms: number;\n default_if_lapsed: unknown;\n urgency: \"low\" | \"medium\" | \"high\";\n state: \"pending\" | \"answered\" | \"lapsed\";\n answered_at?: string;\n answered_by?: ParticipantUri;\n answer_option?: string;\n answer_text?: string;\n comment?: string;\n default_applied?: unknown;\n}\n\n// ============================================================\n// Deliberation (deliberation/1.0)\n// ============================================================\n\nexport interface DeliberationVote {\n ts: string;\n voter: ParticipantUri;\n vote: \"yea\" | \"nay\" | \"abstain\";\n weight?: number;\n comment?: string;\n veto_invoked?: boolean;\n}\n\nexport interface Deliberation {\n id: string;\n task_id?: TaskId;\n opener: ParticipantUri;\n participants: ParticipantUri[];\n rule: string; // raw rule string\n question?: string;\n weights?: Record<ParticipantUri, number>;\n veto?: Record<ParticipantUri, boolean>;\n deadline?: string;\n state: \"open\" | \"closed\" | \"lapsed\";\n comments: { ts: string; from: ParticipantUri; text: string }[];\n votes: DeliberationVote[];\n outcome?: {\n outcome: \"approved\" | \"rejected\" | \"error\";\n rule: string;\n tally?: { yea: number; nay: number };\n vetoes?: ParticipantUri[];\n reason?: string;\n };\n opened_at: string;\n}\n\n// ============================================================\n// Handoff (handoff/1.0)\n// ============================================================\n\nexport interface HandoffTaskItem {\n task_id: TaskId;\n title?: string;\n status_summary?: string;\n next_action?: string;\n blockers?: string[];\n}\n\nexport interface Handoff {\n id: string;\n proposer: ParticipantUri;\n recipient: ParticipantUri; // single URI or \"group:...\"\n proposed_at: string;\n tasks: HandoffTaskItem[];\n summary?: string;\n context_links: string[];\n state: \"proposed\" | \"accepted\" | \"declined\";\n resolved_at?: string;\n accepted_by?: ParticipantUri;\n accepted_task_ids?: TaskId[];\n accept_comment?: string;\n decline_reason?: string;\n decline_suggested_target?: ParticipantUri;\n}\n\n// ============================================================\n// Review decision (review/1.0)\n// ============================================================\n\nexport interface ReviewDecision {\n reviewer: ParticipantUri;\n kind: \"approve\" | \"reject\" | \"override\" | \"abstain\";\n ts: string;\n comment?: string;\n tags?: string[];\n override_artefact_id?: ArtefactId;\n abstain_category?: string;\n}\n\n// ============================================================\n// Task\n// ============================================================\n\nexport interface Task {\n id: TaskId;\n kind: string;\n state: TaskState;\n assignee: ParticipantUri;\n delegator: ParticipantUri;\n input: Record<string, unknown>;\n output?: unknown;\n confidence?: number | string;\n deadline?: string;\n created_at: string;\n updated_at: string;\n mode: Mode;\n review_required?: boolean;\n routing_hints?: TaskRoutingHints;\n artefact_routing_hints?: ArtefactRoutingHints;\n review?: {\n requested_at: string;\n requested_to: ParticipantUri[];\n rule: string;\n deadline?: string;\n decisions: ReviewDecision[];\n /**\n * Who made the work under review: the task's assignee, then the member\n * that completed it. None of them may decide the review.\n */\n authors: ParticipantUri[];\n /**\n * The reviewers who have said they began this round, in the order they\n * did (review.acknowledge). A new round starts with none.\n */\n acknowledgements: { reviewer: ParticipantUri; ts: string }[];\n };\n history: { ts: string; from: ParticipantUri; state: TaskState; note?: string }[];\n /**\n * The authors of the work carried on from before: those of the task a\n * successor replaces, through escalate.raise or control.supersede, and\n * the members task.route or handoff.accept moved the task from. They\n * count among the authors of any review of this task.\n */\n prior_authors?: ParticipantUri[];\n supersedes?: TaskId;\n superseded_by?: TaskId;\n parent?: TaskId;\n paused: boolean;\n paused_from?: TaskState;\n /** Transient: holds the artefact passed to review.request so\n * decide.override can use it as the patch base. */\n pending_artefact?: unknown;\n}\n\n// ============================================================\n// Audit\n// ============================================================\n\nexport interface AuditEntry {\n seq: number;\n arrived: string;\n /** The accepted call. Absent on a refusal entry. */\n envelope?: Envelope;\n /**\n * The refused call, as received. Present only on a refusal entry, and held\n * here rather than under `envelope` so a reader keyed on `envelope` passes\n * the refusal by instead of replaying it (SPECIFICATION 10.1).\n */\n request?: Envelope;\n /** Present only on a refusal entry. */\n outcome?: RefusalOutcome;\n prev_hash?: string;\n}\n\n/** Why a recorded call did not take effect. */\nexport interface RefusalOutcome {\n status: \"refused\";\n /** The error code the caller was answered with. */\n code: number;\n}\n\n// ============================================================\n// Workspace\n// ============================================================\n\nexport interface Workspace {\n id: WorkspaceId;\n created: string;\n state: WorkspaceState;\n profiles: string[];\n mode: Mode;\n mode_ceiling: Mode;\n routing_policy_uri?: string;\n step_up_window_sec: number;\n min_acr?: string;\n /** Which calls are verified where the workspace requires signatures. */\n signature_policy: SignaturePolicy;\n /** Who may join. */\n join_policy: JoinPolicy;\n /** The rule of a review that opens on task.complete; any_one_approves when unset. */\n review_rule?: string;\n members: Map<ParticipantUri, Member>;\n /** Invitations not yet taken up, by the URI each admits. */\n invitations: Map<ParticipantUri, Invitation>;\n tasks: Map<TaskId, Task>;\n overrides: Map<ArtefactId, OverrideArtefact>;\n whispers: Map<string, WhisperPrompt>;\n deliberations: Map<string, Deliberation>;\n handoffs: Map<string, Handoff>;\n snapshots: Map<ArtefactId, SnapshotArtefact>;\n route_decisions: Map<ArtefactId, RouteDecisionArtefact>;\n // task.create idempotency: caller-supplied key -> task_id.\n idempotency_keys: Record<string, TaskId>;\n audit: AuditEntry[];\n chain_head?: string;\n chain_enabled: boolean;\n}\n\n/**\n * Listener callback invoked synchronously when an envelope is appended\n * to the workspace audit log.\n */\nexport type AuditListener = (workspace: Workspace, entry: AuditEntry) => void;\n\n/** True iff mode `a` is <= ceiling. */\nexport function modeLE(a: Mode, ceiling: Mode): boolean {\n const order: Record<Mode, number> = { shadow: 0, trial: 1, production: 2 };\n return order[a] <= order[ceiling];\n}\n"],"mappings":";AAobO,SAAS,OAAO,GAAS,SAAwB;AACtD,QAAM,QAA8B,EAAE,QAAQ,GAAG,OAAO,GAAG,YAAY,EAAE;AACzE,SAAO,MAAM,CAAC,KAAK,MAAM,OAAO;AAClC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightbeamai/chap-coordinator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Collaborative Human-Agent Protocol (CHAP): reference TypeScript implementation. Coordinator with Core + every shipped profile, plus pluggable storage and typed method facade.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Brightbeam AI <oss@brightbeam.com>",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"type": "module",
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=22"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|