@motebit/protocol 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +4 -2
  2. package/dist/artifact-type.d.ts +144 -0
  3. package/dist/artifact-type.d.ts.map +1 -0
  4. package/dist/artifact-type.js +107 -0
  5. package/dist/artifact-type.js.map +1 -0
  6. package/dist/audience.d.ts +108 -0
  7. package/dist/audience.d.ts.map +1 -0
  8. package/dist/audience.js +104 -0
  9. package/dist/audience.js.map +1 -0
  10. package/dist/co-browse.d.ts +369 -0
  11. package/dist/co-browse.d.ts.map +1 -0
  12. package/dist/co-browse.js +64 -0
  13. package/dist/co-browse.js.map +1 -0
  14. package/dist/computer-use.d.ts +463 -3
  15. package/dist/computer-use.d.ts.map +1 -1
  16. package/dist/computer-use.js +40 -0
  17. package/dist/computer-use.js.map +1 -1
  18. package/dist/event-type.d.ts +62 -0
  19. package/dist/event-type.d.ts.map +1 -0
  20. package/dist/event-type.js +123 -0
  21. package/dist/event-type.js.map +1 -0
  22. package/dist/index.d.ts +257 -20
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +84 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/memory-events.d.ts +13 -0
  27. package/dist/memory-events.d.ts.map +1 -1
  28. package/dist/money.d.ts +33 -0
  29. package/dist/money.d.ts.map +1 -0
  30. package/dist/money.js +41 -0
  31. package/dist/money.js.map +1 -0
  32. package/dist/perception.d.ts +347 -0
  33. package/dist/perception.d.ts.map +1 -0
  34. package/dist/perception.js +9 -0
  35. package/dist/perception.js.map +1 -0
  36. package/dist/retention-policy.d.ts +8 -1
  37. package/dist/retention-policy.d.ts.map +1 -1
  38. package/dist/retention-policy.js +18 -0
  39. package/dist/retention-policy.js.map +1 -1
  40. package/dist/routing.d.ts +266 -0
  41. package/dist/routing.d.ts.map +1 -0
  42. package/dist/routing.js +88 -0
  43. package/dist/routing.js.map +1 -0
  44. package/dist/sensitivity.d.ts +123 -0
  45. package/dist/sensitivity.d.ts.map +1 -0
  46. package/dist/sensitivity.js +154 -0
  47. package/dist/sensitivity.js.map +1 -0
  48. package/dist/settlement-asset.d.ts +92 -0
  49. package/dist/settlement-asset.d.ts.map +1 -0
  50. package/dist/settlement-asset.js +82 -0
  51. package/dist/settlement-asset.js.map +1 -0
  52. package/dist/settlement-mode.d.ts +144 -13
  53. package/dist/settlement-mode.d.ts.map +1 -1
  54. package/dist/settlement-mode.js +45 -1
  55. package/dist/settlement-mode.js.map +1 -1
  56. package/dist/transparency.d.ts +116 -0
  57. package/dist/transparency.d.ts.map +1 -0
  58. package/dist/transparency.js +67 -0
  59. package/dist/transparency.js.map +1 -0
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -37,11 +37,13 @@ const relayFee = PLATFORM_FEE_RATE; // 0.05 — the universal 5% relay fee.
37
37
  - **Identity** — `MotebitIdentity`, `KeySuccessionRecord`, `DeviceRegistration`
38
38
  - **Execution receipts** — `ExecutionReceipt` with nested delegation chains
39
39
  - **Credentials** — W3C VC 2.0 types (`ReputationCredentialSubject`, `TrustCredentialSubject`)
40
- - **Settlement** — `BudgetAllocation`, `SettlementRecord`, `PLATFORM_FEE_RATE`
40
+ - **Settlement** — `BudgetAllocation`, `SettlementRecord`, `PLATFORM_FEE_RATE`; `SettlementMode` closed union (`"relay" | "p2p"`) with `ALL_SETTLEMENT_MODES` for iteration and `isSettlementMode` for narrowing wire-format payloads pulled from discovery / peer-negotiation responses; `SettlementAsset` closed union (`"USDC"` at sub-phase A) with `ALL_SETTLEMENT_ASSETS` for iteration and `isSettlementAsset` for narrowing — the typed vocabulary of stablecoin assets the protocol clears settlement in; `SovereignRail.asset` is structurally tightened to this union so a peer announcing an unknown asset fails closed. **Guest-rail capability marker interfaces** + type guards — `GuestRail` carries `supportsDeposit` / `supportsWithdraw` / `supportsBatch` discriminants; `DepositableGuestRail` / `WithdrawableGuestRail` / `BatchableGuestRail` add the corresponding methods; `isDepositableRail` / `isWithdrawableRail` / `isBatchableRail` narrow at the call site. The marker on `WithdrawableGuestRail` is the structural enforcement of the off-ramp doctrine: rails that don't opt in (e.g., Bridge, treasury-only) cannot drive user-facing withdrawals because `withdraw` does not exist on the base type
41
41
  - **Trust algebra** — semiring operations for delegation-chain trust computation
42
- - **Policy** — `ToolDefinition`, `PolicyDecision`, `RiskLevel`, `SensitivityLevel`
42
+ - **Policy** — `ToolDefinition`, `PolicyDecision`, `RiskLevel`, `SensitivityLevel` (the 5-tier privacy ladder, the most load-bearing closed registry; `ALL_SENSITIVITY_LEVELS` for iteration, `isSensitivityLevel` for narrowing unknown payloads, `rankSensitivity` / `maxSensitivity` / `sensitivityPermits` for the algebra)
43
+ - **Event-log vocabulary** — `EventType` closed enum (59 entries spanning identity / memory / goals / approvals / plans / consolidation / co-browse / agents); `ALL_EVENT_TYPES` for iteration, `isEventType` for narrowing wire-format payloads pulled from sync peers or federation
43
44
  - **Storage adapters** — pluggable persistence contracts for any backend
44
45
  - **Cryptosuite registry** — `SuiteId` union for crypto-agile wire artifacts
46
+ - **Auto-router registry** — `TaskShape` closed union (`ALL_TASK_SHAPES`, `isTaskShape`) for the model-selection primitive; named constants `QUICK_TASK_SHAPE`, `CHAT_TASK_SHAPE`, `REASONING_TASK_SHAPE`, `CODE_TASK_SHAPE`, `RESEARCH_TASK_SHAPE`, `CREATIVE_TASK_SHAPE`, `MATH_TASK_SHAPE`. Paired with `ProviderCapability` + `RoutingConstraint` + `RoutingDecision` types consumed by `@motebit/policy::dispatchRouting`
45
47
 
46
48
  Product-level types (state vectors, creature behavior, rendering spec) live in [`@motebit/sdk`](https://www.npmjs.com/package/@motebit/sdk), which re-exports everything here plus the product vocabulary.
47
49
 
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Content-artifact types — the closed registry of `artifact_type` claim
3
+ * values for the C2PA-shape content-provenance primitive
4
+ * (`ContentArtifactManifest` in `@motebit/crypto`).
5
+ *
6
+ * Provenance binding (per `docs/doctrine/self-attesting-system.md` and
7
+ * `docs/doctrine/nist-alignment.md` §8) requires every signed motebit
8
+ * artifact to carry a producer-declared category so a verifier can
9
+ * route, audit, or display the artifact without parsing its bytes.
10
+ * Pre-registry, the category was a free string in the manifest —
11
+ * a typo at a producer site (`artifact_type: "audit_trail"` instead
12
+ * of `"audit-trail"`) became a verifier-side classification miss
13
+ * with no compile-time signal. Locking the registry as a closed
14
+ * union makes the typo a compile error AND a CI error.
15
+ *
16
+ * **Closed registry shape** — same closure pattern as `TokenAudience`,
17
+ * `SuiteId`, `SettlementRail`, `ToolMode`, `ComputerActionKind`. The
18
+ * `ContentArtifactType` literal union is the wire law; named
19
+ * constants are the developer ergonomics. The drift gate
20
+ * `check-artifact-type-canonical` scans every `artifact_type:
21
+ * "<literal>"` and `artifactType: "<literal>"` call against
22
+ * `ALL_CONTENT_ARTIFACT_TYPES`.
23
+ *
24
+ * Adding a category is intentional protocol-level work: a new entry
25
+ * here, a new producer site, the doctrine reference at
26
+ * `docs/doctrine/nist-alignment.md` §8 updated. Same governance as
27
+ * cryptosuite agility (`SuiteId` registry) and audience binding
28
+ * (`TokenAudience` registry).
29
+ *
30
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
31
+ */
32
+ /**
33
+ * The closed set of content-artifact categories motebit currently
34
+ * signs. The first twelve cover the state-export endpoints at
35
+ * `services/relay/src/state-export.ts` (relay-assembled bundles
36
+ * the relay signs as a witness over its database state per the
37
+ * recognition note in `docs/doctrine/nist-alignment.md` §8). The
38
+ * thirteenth — `goal-result` — is the **first non-relay-state-export
39
+ * consumer**: a motebit-direct, per-fire artifact that the motebit
40
+ * itself signs as the producer (the agent's own work product, not
41
+ * a relay-assembled bundle). The expansion is doctrinally aligned —
42
+ * the registry's stated semantic is "content-artifact category for
43
+ * C2PA-shape provenance," not "relay state-export bundle." Goals
44
+ * is the first arc to prove the registry generalizes; future
45
+ * motebit-direct artifacts (chat-bundle exports, generated documents,
46
+ * tool-call-result bundles) compose against the same shape.
47
+ *
48
+ * - `state-snapshot` — relay's stored state vector for a motebit
49
+ * (`/api/v1/state/:motebitId`)
50
+ * - `memory-export` — memory-graph snapshot (nodes + edges) with
51
+ * optional sensitivity redaction (`/api/v1/memory/:motebitId`)
52
+ * - `goal-list` — motebit's declared goals
53
+ * (`/api/v1/goals/:motebitId`)
54
+ * - `conversation-list` — conversation index for a motebit
55
+ * (`/api/v1/conversations/:motebitId`)
56
+ * - `conversation-messages` — message history for a specific
57
+ * conversation
58
+ * (`/api/v1/conversations/:motebitId/:conversationId/messages`)
59
+ * - `device-list` — registered devices for a motebit
60
+ * (`/api/v1/devices/:motebitId`)
61
+ * - `audit-trail` — `ToolAuditEntry[]` for a motebit's session
62
+ * window (`/api/v1/audit/:motebitId`)
63
+ * - `plan-list` — plans for a motebit, each carrying its steps
64
+ * (`/api/v1/plans/:motebitId`)
65
+ * - `plan-detail` — a single plan with its steps
66
+ * (`/api/v1/plans/:motebitId/:planId`)
67
+ * - `gradient-history` — intelligence-gradient snapshots
68
+ * (`/api/v1/gradient/:motebitId`)
69
+ * - `sync-pull` — event-log pull beyond a clock cursor
70
+ * (`/api/v1/sync/:motebitId/pull`)
71
+ * - `execution-ledger` — execution timeline for a goal, including
72
+ * inner motebit-signed delegation receipt summaries; the
73
+ * canonical layered-signing consumer
74
+ * (`/api/v1/execution/:motebitId/:goalId`)
75
+ * - `goal-result` — per-fire content motebit produced for a
76
+ * scheduled goal. Producer = motebit identity (not relay).
77
+ * Doctrine: `docs/doctrine/goal-results.md` §"The three
78
+ * categories" — the artifact category's cryptographic
79
+ * provenance envelope. Bound to the fire via `invocation`
80
+ * (goal_id + execution-receipt id when present).
81
+ *
82
+ * Adding an endpoint is intentional protocol-level work: a new
83
+ * `ContentArtifactType` entry here, a new named constant, a new
84
+ * `ALL_CONTENT_ARTIFACT_TYPES` member, gate-side `CANONICAL_ARTIFACT_TYPES`
85
+ * update in `scripts/check-artifact-type-canonical.ts`. Drift gate
86
+ * `check-state-export-signed` enforces that every new `app.get(...)`
87
+ * in `services/relay/src/state-export.ts` emits a manifest before
88
+ * returning — that gate scopes only to relay state-export endpoints,
89
+ * not to motebit-direct consumers like `goal-result`, which the
90
+ * runtime signs at fire-time through its own helper.
91
+ */
92
+ export type ContentArtifactType = "state-snapshot" | "memory-export" | "goal-list" | "conversation-list" | "conversation-messages" | "device-list" | "audit-trail" | "plan-list" | "plan-detail" | "gradient-history" | "sync-pull" | "execution-ledger" | "goal-result";
93
+ /** Relay's stored state-vector snapshot for a motebit. */
94
+ export declare const STATE_SNAPSHOT_ARTIFACT: ContentArtifactType;
95
+ /** Relay-assembled memory-graph snapshot (nodes + edges). */
96
+ export declare const MEMORY_EXPORT_ARTIFACT: ContentArtifactType;
97
+ /** Relay-assembled goal list for a motebit. */
98
+ export declare const GOAL_LIST_ARTIFACT: ContentArtifactType;
99
+ /** Relay-assembled conversation index for a motebit. */
100
+ export declare const CONVERSATION_LIST_ARTIFACT: ContentArtifactType;
101
+ /** Relay-assembled message history for a specific conversation. */
102
+ export declare const CONVERSATION_MESSAGES_ARTIFACT: ContentArtifactType;
103
+ /** Relay-assembled list of devices registered to a motebit. */
104
+ export declare const DEVICE_LIST_ARTIFACT: ContentArtifactType;
105
+ /** Relay-assembled tool-audit-trail export. */
106
+ export declare const AUDIT_TRAIL_ARTIFACT: ContentArtifactType;
107
+ /** Relay-assembled list of plans for a motebit, each with embedded steps. */
108
+ export declare const PLAN_LIST_ARTIFACT: ContentArtifactType;
109
+ /** Relay-assembled single-plan export with its steps. */
110
+ export declare const PLAN_DETAIL_ARTIFACT: ContentArtifactType;
111
+ /** Relay-assembled intelligence-gradient-history export. */
112
+ export declare const GRADIENT_HISTORY_ARTIFACT: ContentArtifactType;
113
+ /** Relay-assembled event-log pull beyond a `version_clock` cursor. */
114
+ export declare const SYNC_PULL_ARTIFACT: ContentArtifactType;
115
+ /**
116
+ * Relay-assembled execution-timeline export with embedded motebit-signed
117
+ * delegation receipts. Canonical layered-signing consumer — outer relay
118
+ * manifest attests bundle assembly, inner motebit signatures pass through
119
+ * byte-identical. See `spec/execution-ledger-v1.md`.
120
+ */
121
+ export declare const EXECUTION_LEDGER_ARTIFACT: ContentArtifactType;
122
+ /**
123
+ * Per-fire artifact bytes for a scheduled goal — the content motebit
124
+ * produced when the goal cadence fired (or the user invoked
125
+ * `runNow`). First non-relay-state-export consumer of the registry:
126
+ * the motebit identity signs as producer, not the relay. Doctrine:
127
+ * `docs/doctrine/goal-results.md` §"The three categories" — the
128
+ * artifact category's cryptographic provenance envelope.
129
+ */
130
+ export declare const GOAL_RESULT_ARTIFACT: ContentArtifactType;
131
+ /**
132
+ * Canonical iteration order, frozen. Consumers that need to iterate
133
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
134
+ * union rather than `string[]`.
135
+ */
136
+ export declare const ALL_CONTENT_ARTIFACT_TYPES: readonly ContentArtifactType[];
137
+ /**
138
+ * Type guard — narrows `unknown` to `ContentArtifactType`. Drift-gate-driven
139
+ * literal scanners use this to validate strings; verifiers that want to
140
+ * dispatch on category call this before the switch so an unchecked cast
141
+ * is a fail-open path the gate will flag.
142
+ */
143
+ export declare function isContentArtifactType(value: unknown): value is ContentArtifactType;
144
+ //# sourceMappingURL=artifact-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-type.d.ts","sourceRoot":"","sources":["../src/artifact-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,MAAM,mBAAmB,GAC3B,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,mBAAmB,GACnB,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,WAAW,GACX,aAAa,GACb,kBAAkB,GAClB,WAAW,GACX,kBAAkB,GAClB,aAAa,CAAC;AAUlB,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,EAAE,mBAAsC,CAAC;AAE7E,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,EAAE,mBAAqC,CAAC;AAE3E,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE,wDAAwD;AACxD,eAAO,MAAM,0BAA0B,EAAE,mBAAyC,CAAC;AAEnF,mEAAmE;AACnE,eAAO,MAAM,8BAA8B,EAAE,mBAA6C,CAAC;AAE3F,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,+CAA+C;AAC/C,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAEvE,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,EAAE,mBAAwC,CAAC;AAEjF,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,EAAE,mBAAiC,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAAwC,CAAC;AAEjF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,mBAAmC,CAAC;AAIvE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,mBAAmB,EAcnE,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAIlF"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Content-artifact types — the closed registry of `artifact_type` claim
3
+ * values for the C2PA-shape content-provenance primitive
4
+ * (`ContentArtifactManifest` in `@motebit/crypto`).
5
+ *
6
+ * Provenance binding (per `docs/doctrine/self-attesting-system.md` and
7
+ * `docs/doctrine/nist-alignment.md` §8) requires every signed motebit
8
+ * artifact to carry a producer-declared category so a verifier can
9
+ * route, audit, or display the artifact without parsing its bytes.
10
+ * Pre-registry, the category was a free string in the manifest —
11
+ * a typo at a producer site (`artifact_type: "audit_trail"` instead
12
+ * of `"audit-trail"`) became a verifier-side classification miss
13
+ * with no compile-time signal. Locking the registry as a closed
14
+ * union makes the typo a compile error AND a CI error.
15
+ *
16
+ * **Closed registry shape** — same closure pattern as `TokenAudience`,
17
+ * `SuiteId`, `SettlementRail`, `ToolMode`, `ComputerActionKind`. The
18
+ * `ContentArtifactType` literal union is the wire law; named
19
+ * constants are the developer ergonomics. The drift gate
20
+ * `check-artifact-type-canonical` scans every `artifact_type:
21
+ * "<literal>"` and `artifactType: "<literal>"` call against
22
+ * `ALL_CONTENT_ARTIFACT_TYPES`.
23
+ *
24
+ * Adding a category is intentional protocol-level work: a new entry
25
+ * here, a new producer site, the doctrine reference at
26
+ * `docs/doctrine/nist-alignment.md` §8 updated. Same governance as
27
+ * cryptosuite agility (`SuiteId` registry) and audience binding
28
+ * (`TokenAudience` registry).
29
+ *
30
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
31
+ */
32
+ // === Named constants — same value, narrower type ============================
33
+ //
34
+ // Callers that import these get `ContentArtifactType` typing without the
35
+ // union being inferred from a string-literal at every site. Two ergonomic
36
+ // shapes: pass a constant (`EXECUTION_LEDGER_ARTIFACT`) for documentation +
37
+ // grep affordance, or inline the literal — the union narrowing catches typos
38
+ // in either case.
39
+ /** Relay's stored state-vector snapshot for a motebit. */
40
+ export const STATE_SNAPSHOT_ARTIFACT = "state-snapshot";
41
+ /** Relay-assembled memory-graph snapshot (nodes + edges). */
42
+ export const MEMORY_EXPORT_ARTIFACT = "memory-export";
43
+ /** Relay-assembled goal list for a motebit. */
44
+ export const GOAL_LIST_ARTIFACT = "goal-list";
45
+ /** Relay-assembled conversation index for a motebit. */
46
+ export const CONVERSATION_LIST_ARTIFACT = "conversation-list";
47
+ /** Relay-assembled message history for a specific conversation. */
48
+ export const CONVERSATION_MESSAGES_ARTIFACT = "conversation-messages";
49
+ /** Relay-assembled list of devices registered to a motebit. */
50
+ export const DEVICE_LIST_ARTIFACT = "device-list";
51
+ /** Relay-assembled tool-audit-trail export. */
52
+ export const AUDIT_TRAIL_ARTIFACT = "audit-trail";
53
+ /** Relay-assembled list of plans for a motebit, each with embedded steps. */
54
+ export const PLAN_LIST_ARTIFACT = "plan-list";
55
+ /** Relay-assembled single-plan export with its steps. */
56
+ export const PLAN_DETAIL_ARTIFACT = "plan-detail";
57
+ /** Relay-assembled intelligence-gradient-history export. */
58
+ export const GRADIENT_HISTORY_ARTIFACT = "gradient-history";
59
+ /** Relay-assembled event-log pull beyond a `version_clock` cursor. */
60
+ export const SYNC_PULL_ARTIFACT = "sync-pull";
61
+ /**
62
+ * Relay-assembled execution-timeline export with embedded motebit-signed
63
+ * delegation receipts. Canonical layered-signing consumer — outer relay
64
+ * manifest attests bundle assembly, inner motebit signatures pass through
65
+ * byte-identical. See `spec/execution-ledger-v1.md`.
66
+ */
67
+ export const EXECUTION_LEDGER_ARTIFACT = "execution-ledger";
68
+ /**
69
+ * Per-fire artifact bytes for a scheduled goal — the content motebit
70
+ * produced when the goal cadence fired (or the user invoked
71
+ * `runNow`). First non-relay-state-export consumer of the registry:
72
+ * the motebit identity signs as producer, not the relay. Doctrine:
73
+ * `docs/doctrine/goal-results.md` §"The three categories" — the
74
+ * artifact category's cryptographic provenance envelope.
75
+ */
76
+ export const GOAL_RESULT_ARTIFACT = "goal-result";
77
+ // === Iteration + type guard =================================================
78
+ /**
79
+ * Canonical iteration order, frozen. Consumers that need to iterate
80
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
81
+ * union rather than `string[]`.
82
+ */
83
+ export const ALL_CONTENT_ARTIFACT_TYPES = Object.freeze([
84
+ "state-snapshot",
85
+ "memory-export",
86
+ "goal-list",
87
+ "conversation-list",
88
+ "conversation-messages",
89
+ "device-list",
90
+ "audit-trail",
91
+ "plan-list",
92
+ "plan-detail",
93
+ "gradient-history",
94
+ "sync-pull",
95
+ "execution-ledger",
96
+ "goal-result",
97
+ ]);
98
+ /**
99
+ * Type guard — narrows `unknown` to `ContentArtifactType`. Drift-gate-driven
100
+ * literal scanners use this to validate strings; verifiers that want to
101
+ * dispatch on category call this before the switch so an unchecked cast
102
+ * is a fail-open path the gate will flag.
103
+ */
104
+ export function isContentArtifactType(value) {
105
+ return (typeof value === "string" && ALL_CONTENT_ARTIFACT_TYPES.includes(value));
106
+ }
107
+ //# sourceMappingURL=artifact-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-type.js","sourceRoot":"","sources":["../src/artifact-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA6EH,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,kBAAkB;AAElB,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAwB,gBAAgB,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAwB,eAAe,CAAC;AAE3E,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE,wDAAwD;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAwB,mBAAmB,CAAC;AAEnF,mEAAmE;AACnE,MAAM,CAAC,MAAM,8BAA8B,GAAwB,uBAAuB,CAAC;AAE3F,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE,yDAAyD;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,yBAAyB,GAAwB,kBAAkB,CAAC;AAEjF,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAwB,WAAW,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,kBAAkB,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwB,aAAa,CAAC;AAEvE,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAmC,MAAM,CAAC,MAAM,CAAC;IACtF,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,aAAa;IACb,aAAa;IACb,WAAW;IACX,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,kBAAkB;IAClB,aAAa;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAK,0BAAgD,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC/F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Token audiences — the closed registry of `aud` claim values for the
3
+ * audience-bound signed-token primitive (`SignedTokenPayload`).
4
+ *
5
+ * Audience binding (per `docs/doctrine/security-boundaries.md` and
6
+ * `services/relay/CLAUDE.md` Rule 5) prevents cross-endpoint replay:
7
+ * a token minted for one purpose cannot be reused for another. Every
8
+ * signed bearer in motebit carries `aud`; verifiers reject a missing
9
+ * or unexpected value fail-closed.
10
+ *
11
+ * **Closed registry shape** — same closure pattern as `SuiteId`,
12
+ * `SettlementRail`, `ToolMode`, `ComputerActionKind`. The `TokenAudience`
13
+ * literal union is the wire law; named constants are the developer
14
+ * ergonomics. A typo at a signing site (`"task:sumbit"`) is rejected
15
+ * by the union narrowing AND by the `check-audience-canonical` drift
16
+ * gate, which scans every `aud: "<literal>"` and
17
+ * `createSyncToken("<literal>")` call against `ALL_TOKEN_AUDIENCES`.
18
+ *
19
+ * Adding an audience is intentional protocol-level work: a new entry
20
+ * here, a new caller-or-route registration, a doctrine update at
21
+ * `services/relay/CLAUDE.md` Rule 5. Renaming a literal is a wire
22
+ * break (verifiers reject the old value); deletions break running
23
+ * deployments. Same-shape decisions as cryptosuite agility.
24
+ *
25
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
26
+ */
27
+ /**
28
+ * The closed set of audience identifiers motebit currently uses.
29
+ *
30
+ * Categories (organizational; the union is flat):
31
+ *
32
+ * **Multi-device + identity lifecycle**
33
+ * - `sync` — websocket sync + general relay state operations
34
+ * - `device:auth` — per-device auth headers on relay calls
35
+ * - `pair` — device-pairing flow (claim, transfer)
36
+ * - `rotate-key` — key rotation requests
37
+ * - `push:register` — push-notification token registration
38
+ *
39
+ * **Task routing**
40
+ * - `task:submit` — submitting a task to a peer via the relay
41
+ * - `admin:query` — admin-bound read paths (transparency, etc.)
42
+ * - `proposal` — collaborative proposal lifecycle
43
+ *
44
+ * **Virtual accounts (the relay-mediated economic loop)**
45
+ * - `account:balance` — read balance
46
+ * - `account:deposit` — deposit endpoint (Stripe / x402 / Solana)
47
+ * - `account:withdraw` — withdraw endpoint
48
+ * - `account:withdrawals` — list withdrawals
49
+ * - `account:checkout` — Stripe checkout session create
50
+ *
51
+ * **Browser-sandbox dispatcher token (relay-mediated auth)**
52
+ * - `browser-sandbox-grant` — motebit→relay grant request
53
+ * - `browser-sandbox` — relay→motebit→sandbox dispatcher token
54
+ */
55
+ export type TokenAudience = "sync" | "device:auth" | "pair" | "rotate-key" | "push:register" | "task:submit" | "admin:query" | "proposal" | "account:balance" | "account:deposit" | "account:withdraw" | "account:withdrawals" | "account:checkout" | "browser-sandbox-grant" | "browser-sandbox";
56
+ /** Multi-device sync + general relay state operations. */
57
+ export declare const SYNC_AUDIENCE: TokenAudience;
58
+ /** Per-device auth headers on relay calls. Apps mint this for ad-hoc reads. */
59
+ export declare const DEVICE_AUTH_AUDIENCE: TokenAudience;
60
+ /** Device-pairing flow — claim + transfer. */
61
+ export declare const PAIR_AUDIENCE: TokenAudience;
62
+ /** Key rotation requests against the relay. */
63
+ export declare const ROTATE_KEY_AUDIENCE: TokenAudience;
64
+ /** Push-notification token registration (APNs / FCM). */
65
+ export declare const PUSH_REGISTER_AUDIENCE: TokenAudience;
66
+ /** Submitting a task to a peer via the relay. */
67
+ export declare const TASK_SUBMIT_AUDIENCE: TokenAudience;
68
+ /** Admin-bound read paths (transparency, etc.). */
69
+ export declare const ADMIN_QUERY_AUDIENCE: TokenAudience;
70
+ /** Collaborative proposal lifecycle. */
71
+ export declare const PROPOSAL_AUDIENCE: TokenAudience;
72
+ /** Read virtual-account balance. */
73
+ export declare const ACCOUNT_BALANCE_AUDIENCE: TokenAudience;
74
+ /** Deposit endpoint (Stripe / x402 / Solana). */
75
+ export declare const ACCOUNT_DEPOSIT_AUDIENCE: TokenAudience;
76
+ /** Withdraw endpoint. */
77
+ export declare const ACCOUNT_WITHDRAW_AUDIENCE: TokenAudience;
78
+ /** List withdrawals (history). */
79
+ export declare const ACCOUNT_WITHDRAWALS_AUDIENCE: TokenAudience;
80
+ /** Stripe checkout session create. */
81
+ export declare const ACCOUNT_CHECKOUT_AUDIENCE: TokenAudience;
82
+ /**
83
+ * Audience for the motebit-signed grant request to the relay's
84
+ * `POST /api/v1/browser-sandbox/token` endpoint. Verified by the relay
85
+ * via `verifySignedTokenForDevice`.
86
+ */
87
+ export declare const BROWSER_SANDBOX_GRANT_AUDIENCE: TokenAudience;
88
+ /**
89
+ * Audience for the relay-signed sandbox token. Verified by
90
+ * `services/browser-sandbox` against the pinned relay public key.
91
+ *
92
+ * See `spec/computer-use-v1.md` §8.2 for the wire-format binding.
93
+ */
94
+ export declare const BROWSER_SANDBOX_AUDIENCE: TokenAudience;
95
+ /**
96
+ * Canonical iteration order, frozen. Consumers that need to iterate
97
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
98
+ * union rather than `string[]`.
99
+ */
100
+ export declare const ALL_TOKEN_AUDIENCES: readonly TokenAudience[];
101
+ /**
102
+ * Type guard — narrows `unknown` to `TokenAudience`. Drift-gate-driven
103
+ * audience-string scanners use this to validate literals; verifiers
104
+ * call this before dispatch so an unchecked cast is a fail-open path
105
+ * the gate will flag.
106
+ */
107
+ export declare function isTokenAudience(value: unknown): value is TokenAudience;
108
+ //# sourceMappingURL=audience.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,aAAa,GACb,MAAM,GACN,YAAY,GACZ,eAAe,GACf,aAAa,GACb,aAAa,GACb,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GAClB,qBAAqB,GACrB,kBAAkB,GAClB,uBAAuB,GACvB,iBAAiB,CAAC;AAStB,0DAA0D;AAC1D,eAAO,MAAM,aAAa,EAAE,aAAsB,CAAC;AAEnD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,aAAa,EAAE,aAAsB,CAAC;AAEnD,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,EAAE,aAA4B,CAAC;AAE/D,yDAAyD;AACzD,eAAO,MAAM,sBAAsB,EAAE,aAA+B,CAAC;AAErE,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,EAAE,aAA6B,CAAC;AAEjE,wCAAwC;AACxC,eAAO,MAAM,iBAAiB,EAAE,aAA0B,CAAC;AAE3D,oCAAoC;AACpC,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAEzE,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAEzE,yBAAyB;AACzB,eAAO,MAAM,yBAAyB,EAAE,aAAkC,CAAC;AAE3E,kCAAkC;AAClC,eAAO,MAAM,4BAA4B,EAAE,aAAqC,CAAC;AAEjF,sCAAsC;AACtC,eAAO,MAAM,yBAAyB,EAAE,aAAkC,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAAuC,CAAC;AAErF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAAiC,CAAC;AAIzE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,aAAa,EAgBtD,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Token audiences — the closed registry of `aud` claim values for the
3
+ * audience-bound signed-token primitive (`SignedTokenPayload`).
4
+ *
5
+ * Audience binding (per `docs/doctrine/security-boundaries.md` and
6
+ * `services/relay/CLAUDE.md` Rule 5) prevents cross-endpoint replay:
7
+ * a token minted for one purpose cannot be reused for another. Every
8
+ * signed bearer in motebit carries `aud`; verifiers reject a missing
9
+ * or unexpected value fail-closed.
10
+ *
11
+ * **Closed registry shape** — same closure pattern as `SuiteId`,
12
+ * `SettlementRail`, `ToolMode`, `ComputerActionKind`. The `TokenAudience`
13
+ * literal union is the wire law; named constants are the developer
14
+ * ergonomics. A typo at a signing site (`"task:sumbit"`) is rejected
15
+ * by the union narrowing AND by the `check-audience-canonical` drift
16
+ * gate, which scans every `aud: "<literal>"` and
17
+ * `createSyncToken("<literal>")` call against `ALL_TOKEN_AUDIENCES`.
18
+ *
19
+ * Adding an audience is intentional protocol-level work: a new entry
20
+ * here, a new caller-or-route registration, a doctrine update at
21
+ * `services/relay/CLAUDE.md` Rule 5. Renaming a literal is a wire
22
+ * break (verifiers reject the old value); deletions break running
23
+ * deployments. Same-shape decisions as cryptosuite agility.
24
+ *
25
+ * Permissive floor (Apache-2.0), type-only, zero runtime deps.
26
+ */
27
+ // === Named constants — same value, narrower type ============================
28
+ //
29
+ // Callers that import these get `TokenAudience` typing without the union
30
+ // being inferred from a string-literal at every site. Two ergonomic shapes:
31
+ // pass a constant (`SYNC_AUDIENCE`) for documentation + grep affordance, or
32
+ // inline the literal — the union narrowing catches typos in either case.
33
+ /** Multi-device sync + general relay state operations. */
34
+ export const SYNC_AUDIENCE = "sync";
35
+ /** Per-device auth headers on relay calls. Apps mint this for ad-hoc reads. */
36
+ export const DEVICE_AUTH_AUDIENCE = "device:auth";
37
+ /** Device-pairing flow — claim + transfer. */
38
+ export const PAIR_AUDIENCE = "pair";
39
+ /** Key rotation requests against the relay. */
40
+ export const ROTATE_KEY_AUDIENCE = "rotate-key";
41
+ /** Push-notification token registration (APNs / FCM). */
42
+ export const PUSH_REGISTER_AUDIENCE = "push:register";
43
+ /** Submitting a task to a peer via the relay. */
44
+ export const TASK_SUBMIT_AUDIENCE = "task:submit";
45
+ /** Admin-bound read paths (transparency, etc.). */
46
+ export const ADMIN_QUERY_AUDIENCE = "admin:query";
47
+ /** Collaborative proposal lifecycle. */
48
+ export const PROPOSAL_AUDIENCE = "proposal";
49
+ /** Read virtual-account balance. */
50
+ export const ACCOUNT_BALANCE_AUDIENCE = "account:balance";
51
+ /** Deposit endpoint (Stripe / x402 / Solana). */
52
+ export const ACCOUNT_DEPOSIT_AUDIENCE = "account:deposit";
53
+ /** Withdraw endpoint. */
54
+ export const ACCOUNT_WITHDRAW_AUDIENCE = "account:withdraw";
55
+ /** List withdrawals (history). */
56
+ export const ACCOUNT_WITHDRAWALS_AUDIENCE = "account:withdrawals";
57
+ /** Stripe checkout session create. */
58
+ export const ACCOUNT_CHECKOUT_AUDIENCE = "account:checkout";
59
+ /**
60
+ * Audience for the motebit-signed grant request to the relay's
61
+ * `POST /api/v1/browser-sandbox/token` endpoint. Verified by the relay
62
+ * via `verifySignedTokenForDevice`.
63
+ */
64
+ export const BROWSER_SANDBOX_GRANT_AUDIENCE = "browser-sandbox-grant";
65
+ /**
66
+ * Audience for the relay-signed sandbox token. Verified by
67
+ * `services/browser-sandbox` against the pinned relay public key.
68
+ *
69
+ * See `spec/computer-use-v1.md` §8.2 for the wire-format binding.
70
+ */
71
+ export const BROWSER_SANDBOX_AUDIENCE = "browser-sandbox";
72
+ // === Iteration + type guard =================================================
73
+ /**
74
+ * Canonical iteration order, frozen. Consumers that need to iterate
75
+ * (drift gates, tooling, docs) use this so TypeScript sees the narrow
76
+ * union rather than `string[]`.
77
+ */
78
+ export const ALL_TOKEN_AUDIENCES = Object.freeze([
79
+ "sync",
80
+ "device:auth",
81
+ "pair",
82
+ "rotate-key",
83
+ "push:register",
84
+ "task:submit",
85
+ "admin:query",
86
+ "proposal",
87
+ "account:balance",
88
+ "account:deposit",
89
+ "account:withdraw",
90
+ "account:withdrawals",
91
+ "account:checkout",
92
+ "browser-sandbox-grant",
93
+ "browser-sandbox",
94
+ ]);
95
+ /**
96
+ * Type guard — narrows `unknown` to `TokenAudience`. Drift-gate-driven
97
+ * audience-string scanners use this to validate literals; verifiers
98
+ * call this before dispatch so an unchecked cast is a fail-open path
99
+ * the gate will flag.
100
+ */
101
+ export function isTokenAudience(value) {
102
+ return typeof value === "string" && ALL_TOKEN_AUDIENCES.includes(value);
103
+ }
104
+ //# sourceMappingURL=audience.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AA+CH,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AAEzE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAkB,YAAY,CAAC;AAE/D,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAkB,eAAe,CAAC;AAErE,iDAAiD;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,mDAAmD;AACnD,MAAM,CAAC,MAAM,oBAAoB,GAAkB,aAAa,CAAC;AAEjE,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAkB,UAAU,CAAC;AAE3D,oCAAoC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,iDAAiD;AACjD,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,yBAAyB;AACzB,MAAM,CAAC,MAAM,yBAAyB,GAAkB,kBAAkB,CAAC;AAE3E,kCAAkC;AAClC,MAAM,CAAC,MAAM,4BAA4B,GAAkB,qBAAqB,CAAC;AAEjF,sCAAsC;AACtC,MAAM,CAAC,MAAM,yBAAyB,GAAkB,kBAAkB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAkB,uBAAuB,CAAC;AAErF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkB,iBAAiB,CAAC;AAEzE,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA6B,MAAM,CAAC,MAAM,CAAC;IACzE,MAAM;IACN,aAAa;IACb,MAAM;IACN,YAAY;IACZ,eAAe;IACf,aAAa;IACb,aAAa;IACb,UAAU;IACV,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,kBAAkB;IAClB,uBAAuB;IACvB,iBAAiB;CAClB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,mBAAyC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjG,CAAC"}