@crouter/api 0.3.377

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 (112) hide show
  1. package/README.md +67 -0
  2. package/dist/api/__tests__/error-codes.test.d.ts +1 -0
  3. package/dist/api/__tests__/error-codes.test.js +78 -0
  4. package/dist/api/__tests__/integration/client.test.d.ts +1 -0
  5. package/dist/api/__tests__/integration/client.test.js +179 -0
  6. package/dist/api/client.d.ts +467 -0
  7. package/dist/api/client.js +1179 -0
  8. package/dist/api/command-manifest/index.d.ts +3 -0
  9. package/dist/api/command-manifest/index.js +3 -0
  10. package/dist/api/command-manifest/manifest.d.ts +51 -0
  11. package/dist/api/command-manifest/manifest.js +332 -0
  12. package/dist/api/command-manifest/result.d.ts +25 -0
  13. package/dist/api/command-manifest/result.js +97 -0
  14. package/dist/api/command-manifest/schema.d.ts +28 -0
  15. package/dist/api/command-manifest/schema.js +856 -0
  16. package/dist/api/dto/analytics.d.ts +184 -0
  17. package/dist/api/dto/analytics.js +3 -0
  18. package/dist/api/dto/attach.d.ts +22 -0
  19. package/dist/api/dto/attach.js +13 -0
  20. package/dist/api/dto/bash-jobs.d.ts +24 -0
  21. package/dist/api/dto/bash-jobs.js +9 -0
  22. package/dist/api/dto/bash.d.ts +17 -0
  23. package/dist/api/dto/bash.js +1 -0
  24. package/dist/api/dto/broker-ops.d.ts +187 -0
  25. package/dist/api/dto/broker-ops.js +6 -0
  26. package/dist/api/dto/broker-signals.d.ts +25 -0
  27. package/dist/api/dto/broker-signals.js +1 -0
  28. package/dist/api/dto/broker.d.ts +86 -0
  29. package/dist/api/dto/broker.js +20 -0
  30. package/dist/api/dto/canvas.d.ts +359 -0
  31. package/dist/api/dto/canvas.js +2 -0
  32. package/dist/api/dto/chat-inventory.d.ts +56 -0
  33. package/dist/api/dto/chat-inventory.js +11 -0
  34. package/dist/api/dto/common.d.ts +29 -0
  35. package/dist/api/dto/common.js +15 -0
  36. package/dist/api/dto/config.d.ts +36 -0
  37. package/dist/api/dto/config.js +3 -0
  38. package/dist/api/dto/crons.d.ts +150 -0
  39. package/dist/api/dto/crons.js +10 -0
  40. package/dist/api/dto/custom-objects.d.ts +66 -0
  41. package/dist/api/dto/custom-objects.js +1 -0
  42. package/dist/api/dto/delivery.d.ts +71 -0
  43. package/dist/api/dto/delivery.js +7 -0
  44. package/dist/api/dto/docs.d.ts +135 -0
  45. package/dist/api/dto/docs.js +8 -0
  46. package/dist/api/dto/files.d.ts +21 -0
  47. package/dist/api/dto/files.js +1 -0
  48. package/dist/api/dto/focus.d.ts +24 -0
  49. package/dist/api/dto/focus.js +10 -0
  50. package/dist/api/dto/grants.d.ts +14 -0
  51. package/dist/api/dto/grants.js +1 -0
  52. package/dist/api/dto/health.d.ts +106 -0
  53. package/dist/api/dto/health.js +2 -0
  54. package/dist/api/dto/human-requests.d.ts +113 -0
  55. package/dist/api/dto/human-requests.js +4 -0
  56. package/dist/api/dto/human.d.ts +28 -0
  57. package/dist/api/dto/human.js +4 -0
  58. package/dist/api/dto/inbox.d.ts +273 -0
  59. package/dist/api/dto/inbox.js +4 -0
  60. package/dist/api/dto/lifecycle.d.ts +88 -0
  61. package/dist/api/dto/lifecycle.js +3 -0
  62. package/dist/api/dto/mail.d.ts +44 -0
  63. package/dist/api/dto/mail.js +1 -0
  64. package/dist/api/dto/messages.d.ts +88 -0
  65. package/dist/api/dto/messages.js +2 -0
  66. package/dist/api/dto/model-config.d.ts +25 -0
  67. package/dist/api/dto/model-config.js +1 -0
  68. package/dist/api/dto/modelauth.d.ts +132 -0
  69. package/dist/api/dto/modelauth.js +4 -0
  70. package/dist/api/dto/node-events.d.ts +65 -0
  71. package/dist/api/dto/node-events.js +4 -0
  72. package/dist/api/dto/node-outcomes.d.ts +88 -0
  73. package/dist/api/dto/node-outcomes.js +2 -0
  74. package/dist/api/dto/node-records.d.ts +35 -0
  75. package/dist/api/dto/node-records.js +5 -0
  76. package/dist/api/dto/nodes.d.ts +368 -0
  77. package/dist/api/dto/nodes.js +3 -0
  78. package/dist/api/dto/objects.d.ts +172 -0
  79. package/dist/api/dto/objects.js +5 -0
  80. package/dist/api/dto/profiles.d.ts +117 -0
  81. package/dist/api/dto/profiles.js +4 -0
  82. package/dist/api/dto/recovery.d.ts +104 -0
  83. package/dist/api/dto/recovery.js +1 -0
  84. package/dist/api/dto/reports.d.ts +93 -0
  85. package/dist/api/dto/reports.js +2 -0
  86. package/dist/api/dto/review-comments.d.ts +146 -0
  87. package/dist/api/dto/review-comments.js +5 -0
  88. package/dist/api/dto/reviews.d.ts +113 -0
  89. package/dist/api/dto/reviews.js +5 -0
  90. package/dist/api/dto/run-events.d.ts +293 -0
  91. package/dist/api/dto/run-events.js +6 -0
  92. package/dist/api/dto/subscriptions.d.ts +14 -0
  93. package/dist/api/dto/subscriptions.js +2 -0
  94. package/dist/api/dto/worktree.d.ts +55 -0
  95. package/dist/api/dto/worktree.js +6 -0
  96. package/dist/api/error-codes.d.ts +254 -0
  97. package/dist/api/error-codes.js +54 -0
  98. package/dist/api/errors.d.ts +47 -0
  99. package/dist/api/errors.js +66 -0
  100. package/dist/api/index.d.ts +42 -0
  101. package/dist/api/index.js +41 -0
  102. package/dist/api/node-transport.d.ts +18 -0
  103. package/dist/api/node-transport.js +105 -0
  104. package/dist/api/plugin-manifest-schema.d.ts +233 -0
  105. package/dist/api/plugin-manifest-schema.js +23 -0
  106. package/dist/api/routes.d.ts +160 -0
  107. package/dist/api/routes.js +193 -0
  108. package/dist/shared/generated-context.d.ts +79 -0
  109. package/dist/shared/generated-context.js +232 -0
  110. package/dist/shared/predicates.d.ts +2 -0
  111. package/dist/shared/predicates.js +4 -0
  112. package/package.json +49 -0
@@ -0,0 +1,233 @@
1
+ /** How prominently a node surfaces in ancestor `-h` listings. Default 'normal'. */
2
+ export type ManifestTier = 'normal' | 'common' | 'important';
3
+ /** Root-entry prose for a top-level branch — what every agent reads before it
4
+ * has engaged the command at all. Required on a plugin's top-level branch. */
5
+ export interface ManifestRootEntry {
6
+ concept: string;
7
+ description: string;
8
+ whenToUse: string;
9
+ }
10
+ /** The shape of one output value, without a name: the element of an `array`.
11
+ * `type` is a free type name; a trailing ` | null` marks it nullable and the
12
+ * remainder is its base type, which decides the structural keys it may carry. */
13
+ export interface ManifestFieldShape {
14
+ type: string;
15
+ /** Inline semantic constraint — bounds, enum, token caps. */
16
+ constraint: string;
17
+ /** Named members; only when the base type is `object`. */
18
+ children?: ManifestField[];
19
+ /** Element shape; only when the base type is `array`. */
20
+ items?: ManifestFieldShape;
21
+ /** The allowed values; required, and only valid, when the base type is `enum`. */
22
+ values?: string[];
23
+ }
24
+ /** One declared output field of a leaf's result. Base type `file` marks the
25
+ * leaf's one file output: valid only as a top-level field, at most one per leaf. */
26
+ export interface ManifestField extends ManifestFieldShape {
27
+ name: string;
28
+ required: boolean;
29
+ }
30
+ /** How a local file named by a `path` param is encoded into the request: 'text'
31
+ * as UTF-8, 'base64' as the base64 of its raw bytes. The path string itself
32
+ * never crosses the wire. */
33
+ export type ManifestFileEncoding = 'text' | 'base64';
34
+ export interface ManifestPositionalParam {
35
+ kind: 'positional';
36
+ name: string;
37
+ /** Display hint only; always parsed as string. `file` names a file argument
38
+ * a capability-provider call carries; locally it is sent as the string typed. */
39
+ type?: 'string' | 'path' | 'file';
40
+ required: boolean;
41
+ constraint: string;
42
+ /** Collect every remaining positional token into an array, in argv order.
43
+ * Only an `in: 'body'` REST mapping can carry an array. */
44
+ repeatable?: boolean;
45
+ /** Valid only on a `path` param. */
46
+ encoding?: ManifestFileEncoding;
47
+ /** See {@link ManifestFlagParam.defaultFromEnv}. */
48
+ defaultFromEnv?: string;
49
+ }
50
+ export interface ManifestFlagParam {
51
+ kind: 'flag';
52
+ name: string;
53
+ /** 'bool' flags take no value — presence is true. 'file' names a file
54
+ * argument a capability-provider call carries; locally it is sent as the
55
+ * string typed, never read from disk (that is `path` with `encoding`). */
56
+ type: 'string' | 'int' | 'bool' | 'path' | 'enum' | 'file';
57
+ /** Required, and only valid, when type is 'enum'. */
58
+ choices?: string[];
59
+ required: boolean;
60
+ constraint: string;
61
+ default?: string | number | boolean;
62
+ /** Repeat the flag to accumulate an array value. Valid only on string/int/enum,
63
+ * only with an `in: 'body'` REST mapping, and never alongside `default`. */
64
+ repeatable?: boolean;
65
+ /** Valid only on a `path` flag. */
66
+ encoding?: ManifestFileEncoding;
67
+ /** UPPER_SNAKE_CASE environment variable on the CALLING machine whose value
68
+ * fills this param when the caller omits it. An env-sourced value counts as
69
+ * SUPPLIED — it satisfies `required` and ships on the wire — unlike a static
70
+ * `default`, which does neither. Valid only on string/path params, never
71
+ * alongside `default` or `repeatable`. */
72
+ defaultFromEnv?: string;
73
+ }
74
+ /** Raw stdin content blob — piped text, not parsed as JSON. */
75
+ export interface ManifestStdinParam {
76
+ kind: 'stdin';
77
+ name: string;
78
+ required: boolean;
79
+ constraint: string;
80
+ }
81
+ /** `--context-file PATH`: reads and JSON-parses the file at PATH. */
82
+ export interface ManifestContextFileParam {
83
+ kind: 'context-file';
84
+ name: string;
85
+ required: boolean;
86
+ constraint: string;
87
+ /** Description of the expected JSON shape. */
88
+ shape?: string;
89
+ }
90
+ export type ManifestInputParam = ManifestPositionalParam | ManifestFlagParam | ManifestStdinParam | ManifestContextFileParam;
91
+ export type RestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
92
+ export type RestParamPlacement = 'path' | 'query' | 'body' | 'header';
93
+ export interface RestParamMapping {
94
+ in: RestParamPlacement;
95
+ /** Rename for query/body; required for header; forbidden for path. */
96
+ as?: string;
97
+ }
98
+ export interface RestMapping {
99
+ method: RestMethod;
100
+ /** Absolute path template; each `{param}` placeholder names an `in: 'path'` param. */
101
+ path: string;
102
+ /** Default false. true means the response is an NDJSON stream relayed verbatim. */
103
+ streaming?: boolean;
104
+ /** Constant body fields merged into the request body verbatim (e.g. the `op`
105
+ * discriminator on a single-endpoint invoke surface) — never sourced from a
106
+ * declared param, and forbidden on GET. */
107
+ body?: Record<string, string | number | boolean>;
108
+ /** When set, every `in: 'body'` param value nests under this key instead of
109
+ * sitting top-level (`bodyRoot: 'args'` → `{ args: { name, url } }`);
110
+ * `body` constants stay top-level regardless. Forbidden on GET. */
111
+ bodyRoot?: string;
112
+ /** Keyed by declared param name; every declared param appears exactly once. */
113
+ params: Record<string, RestParamMapping>;
114
+ }
115
+ export interface ManifestTimeouts {
116
+ connectMs?: number;
117
+ requestMs?: number;
118
+ streamIdleMs?: number;
119
+ }
120
+ /** Exec transport only: forward every argv token after this branch to an
121
+ * external binary instead of parsing children. `bin` is either a bare PATH
122
+ * command or a plugin-root-relative executable path. A passthrough branch is
123
+ * childless by construction; an HTTP manifest rejects it, because an HTTP
124
+ * transport must not name a local binary to execute. */
125
+ export interface ManifestPassthrough {
126
+ bin: string;
127
+ installHint: string;
128
+ }
129
+ export interface ManifestLeafBase {
130
+ kind: 'leaf';
131
+ name: string;
132
+ description: string;
133
+ whenToUse: string;
134
+ tier?: ManifestTier;
135
+ summary: string;
136
+ params: ManifestInputParam[];
137
+ output: ManifestField[];
138
+ /** Non-empty; `["None. Read-only."]` for a read-only leaf. Read-only, so a
139
+ * server assembling a manifest may hand over a frozen or `as const` list. */
140
+ effects: readonly string[];
141
+ }
142
+ /** Exec-transport leaf. */
143
+ export interface ManifestExecLeaf extends ManifestLeafBase {
144
+ outputKind: 'object';
145
+ }
146
+ /** HTTP-transport leaf; `outputKind` derives from `rest.streaming`. */
147
+ export interface ManifestHttpLeaf extends ManifestLeafBase {
148
+ rest: RestMapping;
149
+ /** The capability-provider tool group this leaf belongs to, matching
150
+ * `[A-Za-z0-9_-]{1,64}`; the scope that admits it is `<provider>:<group>`.
151
+ * Required on every leaf of a bundle carrying a `provider` block; ignored by
152
+ * local dispatch. */
153
+ group?: string;
154
+ }
155
+ export type ManifestLeaf = ManifestExecLeaf | ManifestHttpLeaf;
156
+ export interface ManifestBranch<L extends ManifestLeafBase = ManifestLeaf> {
157
+ kind: 'branch';
158
+ name: string;
159
+ description: string;
160
+ whenToUse: string;
161
+ tier?: ManifestTier;
162
+ /** Required on a top-level branch, forbidden on a nested one. */
163
+ rootEntry?: ManifestRootEntry;
164
+ /** Allows the nearest repository fragment to contribute children below this
165
+ * top-level branch. */
166
+ extensible?: true;
167
+ summary: string;
168
+ model?: string;
169
+ /** Exec dialect only, and the type says so rather than leaving it to the
170
+ * runtime validator: an HTTP-transport manifest naming a local binary to run
171
+ * is the one shape a served manifest must never be able to express. `never`
172
+ * on the HTTP leaf dialect makes `passthrough: {...}` a compile error in a
173
+ * `ManifestBranch<ManifestHttpLeaf>`, and the conditional distributes over
174
+ * the default union so a plain `ManifestBranch` still accepts it. */
175
+ passthrough?: L extends ManifestExecLeaf ? ManifestPassthrough : never;
176
+ children: ManifestNode<L>[];
177
+ }
178
+ /** A branch or a leaf. The parameter fixes which leaf dialect the whole subtree
179
+ * may use, so an HTTP manifest cannot smuggle an exec leaf into a child slot. */
180
+ export type ManifestNode<L extends ManifestLeafBase = ManifestLeaf> = ManifestBranch<L> | L;
181
+ /** One mount point in the manifest's self-contained forest. */
182
+ export interface ManifestMount<L extends ManifestLeafBase = ManifestLeaf> {
183
+ /** `[]` mounts `node` as a new top-level command; a non-empty path names a
184
+ * branch this manifest already contributes or an extensible core branch.
185
+ * `human` is currently the only extensible core branch. */
186
+ parent: string[];
187
+ node: ManifestNode<L>;
188
+ }
189
+ /**
190
+ * A whole `commands.json` for an HTTP-transport plugin whose endpoint and auth
191
+ * live in the bundle's `bundle.json` rather than the manifest.
192
+ */
193
+ export interface HttpPluginCommandManifest {
194
+ schemaVersion: 1;
195
+ /** The plugin's integer major version (≥ 1). Omitted means 1 for a plugin
196
+ * installed locally; a capability-provider bundle declares it. */
197
+ version?: number;
198
+ /** Overrides the registration endpoint as the base for every leaf's REST path. */
199
+ baseUrl?: string;
200
+ timeouts?: ManifestTimeouts;
201
+ mounts: ManifestMount<ManifestHttpLeaf>[];
202
+ /** Core command path (space-joined, e.g. "cron add") → product addendum
203
+ * appended to that command's help, rendered by crtr as an attributed
204
+ * `<plugin-help plugin="...">` block after the core body. Append-only by
205
+ * contract: an addendum adds product meaning beneath substrate help, never
206
+ * replaces it. A key naming no core command path fails validation at guest
207
+ * install. */
208
+ helpAddenda?: Record<string, string>;
209
+ }
210
+ /**
211
+ * The one field a plugin's HTTP backend adds to an error envelope to say the
212
+ * client parsed this call from an out-of-date description of its commands.
213
+ *
214
+ * crtr acts on it by refetching that plugin's bundle and re-running the
215
+ * caller's ORIGINAL argv against the refreshed command tree, exactly once. Two
216
+ * preconditions follow from that, and a server that cannot meet both must not
217
+ * set the field:
218
+ *
219
+ * 1. The manifest the server serves at its bundle endpoint must already
220
+ * describe the operation it is complaining about. A refetch that hands back
221
+ * the same description turns the retry into a second identical failure.
222
+ * 2. The original call must be safe to send again. crtr replays the argv, not
223
+ * the request, but a leaf that already committed a side effect before the
224
+ * backend rejected the op would commit it twice.
225
+ *
226
+ * Declared here, in the format both sides compile against, so the field name
227
+ * has one owner: rename it and every reader and writer fails to build. A type
228
+ * rather than a value — a const would force a CJS consumer to `require()` an
229
+ * ESM module.
230
+ */
231
+ export interface ManifestStaleEnvelope {
232
+ manifest_stale?: true;
233
+ }
@@ -0,0 +1,23 @@
1
+ // The command-plugin manifest wire format — the exact JSON shape crtr's manifest
2
+ // validator accepts in a plugin bundle's `commands.json`.
3
+ //
4
+ // This is the canonical, cross-repo declaration of that format. It is published
5
+ // as `@crouter/api/plugin-manifest` so a server that SERVES a plugin
6
+ // bundle (crouter cloud serves the `cloud` plugin over an authenticated
7
+ // endpoint) compiles its manifest against the same types crtr validates it with,
8
+ // instead of hand-mirroring them and discovering drift at guest install time.
9
+ //
10
+ // Types only. This file imports nothing — not even Node built-ins — so consuming
11
+ // it costs a dependent nothing at runtime.
12
+ //
13
+ // Relationship to `src/core/help.ts`: these param and output types are the
14
+ // JSON-expressible SUBSET of that module's `InputParam` and `Field`. A validated
15
+ // manifest node's params flow straight into `defineLeaf`'s help descriptor
16
+ // (`src/core/command-plugins/compose.ts`), so that assignment is what keeps the
17
+ // two in step — widen a type here beyond what `help.ts` accepts and the build
18
+ // fails at that site. Fields that cannot survive a JSON round trip (a flag's
19
+ // `focusedHelp`, whose `dynamicState` is a function) are deliberately absent.
20
+ //
21
+ // Validators for this format live in `src/api/command-manifest/`, which imports
22
+ // these types rather than redeclaring them.
23
+ export {};
@@ -0,0 +1,160 @@
1
+ /** The single API version constant; every versioned path prepends it. */
2
+ export declare const API_VERSION = "v1";
3
+ /** Route path builders. Keys mirror the spec §6 route table. */
4
+ export declare const routes: {
5
+ readonly healthz: () => string;
6
+ readonly status: () => string;
7
+ readonly daemonRestart: () => string;
8
+ readonly daemonMigrate: () => string;
9
+ readonly daemonAdmit: () => string;
10
+ readonly nodes: () => string;
11
+ readonly reviveAll: () => string;
12
+ readonly node: (id: string) => string;
13
+ readonly nodeMemoryReads: (id: string) => string;
14
+ readonly nodeOutcome: (id: string) => string;
15
+ readonly nodeOutcomeDelivery: (id: string) => string;
16
+ readonly nodeEvents: (id: string) => string;
17
+ readonly nodeSnapshot: (id: string) => string;
18
+ readonly nodeSubject: (id: string) => string;
19
+ readonly nodeSession: (id: string) => string;
20
+ readonly nodeChatInventory: (id: string) => string;
21
+ readonly prospectiveChatInventory: () => string;
22
+ readonly nodeTranscript: (id: string) => string;
23
+ readonly nodeContext: (id: string) => string;
24
+ readonly nodeReports: (id: string) => string;
25
+ readonly nodeResult: (id: string) => string;
26
+ readonly nodeJobs: (id: string) => string;
27
+ readonly nodeJob: (id: string, jobId: string) => string;
28
+ readonly nodeJobBackground: (id: string, jobId: string) => string;
29
+ readonly nodeDelivery: (id: string) => string;
30
+ readonly deliveryDryRun: () => string;
31
+ readonly nodeMessages: (id: string) => string;
32
+ readonly nodeInterrupt: (id: string) => string;
33
+ readonly nodeFork: (id: string) => string;
34
+ readonly nodeRevive: (id: string) => string;
35
+ readonly nodeRelaunchRoot: (id: string) => string;
36
+ readonly nodeBrokerSessionBound: (id: string) => string;
37
+ readonly nodeBrokerSettle: (id: string) => string;
38
+ readonly nodeBrokerParkComplete: (id: string) => string;
39
+ readonly nodeBrokerParkActivity: (id: string) => string;
40
+ readonly nodeBrokerTelemetry: (id: string) => string;
41
+ readonly nodeLog: (id: string) => string;
42
+ readonly nodeTelemetry: (id: string) => string;
43
+ readonly nodeRecap: (id: string) => string;
44
+ readonly nodeInboxReport: (id: string) => string;
45
+ readonly nodePassiveMessage: (id: string) => string;
46
+ readonly nodePushedFinal: (id: string) => string;
47
+ readonly nodeMailClaim: (id: string) => string;
48
+ readonly nodeMailAcknowledge: (id: string) => string;
49
+ readonly nodeBrokerModel: (id: string) => string;
50
+ readonly nodeBrokerExtensionState: (id: string) => string;
51
+ readonly nodeBrokerSignals: (id: string) => string;
52
+ readonly nodeBrokerGeneratedName: (id: string) => string;
53
+ readonly nodeBrokerPersonaAck: (id: string) => string;
54
+ readonly brokerTurn: (id: string) => string;
55
+ readonly brokerProviderRetry: (id: string) => string;
56
+ readonly brokerFault: (id: string) => string;
57
+ readonly brokerRecovery: (id: string) => string;
58
+ readonly nodeFault: (id: string) => string;
59
+ readonly nodeClose: (id: string) => string;
60
+ readonly nodeRecycle: (id: string) => string;
61
+ readonly nodeDemote: (id: string) => string;
62
+ readonly nodePromote: (id: string) => string;
63
+ readonly nodeYield: (id: string) => string;
64
+ readonly nodeWait: (id: string) => string;
65
+ readonly nodeConfig: (id: string) => string;
66
+ readonly kinds: () => string;
67
+ readonly nodeWorktreeClose: (id: string) => string;
68
+ readonly nodeWorktreeAbandon: (id: string) => string;
69
+ readonly quarantinedWorktrees: () => string;
70
+ readonly spaces: () => string;
71
+ readonly nodeAttach: (id: string) => string;
72
+ readonly focuses: () => string;
73
+ readonly focusByNode: () => string;
74
+ readonly focusByPane: () => string;
75
+ readonly focus: (focusId: string) => string;
76
+ readonly nodeSubscriptions: (id: string) => string;
77
+ readonly nodeSubscription: (id: string, target: string) => string;
78
+ readonly crons: () => string;
79
+ readonly cron: (cronId: string) => string;
80
+ readonly cronPause: (cronId: string) => string;
81
+ readonly cronResume: (cronId: string) => string;
82
+ readonly cronRun: (cronId: string) => string;
83
+ readonly cronsPoke: () => string;
84
+ readonly canvasAttention: () => string;
85
+ readonly canvasAttentionCounts: () => string;
86
+ readonly canvasHistorySearch: () => string;
87
+ readonly canvasHistoryGrep: () => string;
88
+ readonly canvasHistoryRead: () => string;
89
+ readonly canvasHistoryStats: () => string;
90
+ readonly canvasSnapshot: () => string;
91
+ readonly canvasRoster: () => string;
92
+ readonly canvasBrowse: () => string;
93
+ readonly canvasAnalytics: () => string;
94
+ readonly canvasGraph: () => string;
95
+ readonly canvasPrune: () => string;
96
+ readonly humanReviews: () => string;
97
+ readonly humanReview: (reviewId: string) => string;
98
+ readonly humanReviewSubmit: (reviewId: string) => string;
99
+ readonly humanReviewCancel: (reviewId: string) => string;
100
+ readonly humanReviewDocument: (reviewId: string) => string;
101
+ readonly humanReviewComments: (reviewId: string) => string;
102
+ readonly humanReviewCommentEvents: (reviewId: string) => string;
103
+ readonly humanReviewCommentRanges: (reviewId: string) => string;
104
+ readonly humanComment: (commentId: string) => string;
105
+ readonly humanCommentEdit: (commentId: string) => string;
106
+ readonly humanCommentResolve: (commentId: string) => string;
107
+ readonly humanCommentReopen: (commentId: string) => string;
108
+ readonly humanCommentDelete: (commentId: string) => string;
109
+ readonly humanCommentFork: (commentId: string) => string;
110
+ readonly humanInbox: () => string;
111
+ readonly humanInboxTicket: (ticketId: string) => string;
112
+ readonly humanInboxRespond: (ticketId: string) => string;
113
+ readonly humanInboxProgress: (ticketId: string) => string;
114
+ readonly humanInboxResponse: (ticketId: string) => string;
115
+ readonly humanInboxCancel: (ticketId: string) => string;
116
+ readonly humanInboxFeedbackResolve: (ticketId: string, commentId: string) => string;
117
+ readonly humanRequests: () => string;
118
+ readonly humanComponents: () => string;
119
+ readonly humanRequest: (requestId: string) => string;
120
+ readonly humanRequestReplace: (requestId: string) => string;
121
+ readonly humanRequestRespond: (requestId: string) => string;
122
+ readonly humanRequestDismiss: (requestId: string) => string;
123
+ readonly humanRequestCancel: (requestId: string) => string;
124
+ readonly profiles: () => string;
125
+ readonly profile: (name: string) => string;
126
+ readonly profilePause: (name: string) => string;
127
+ readonly profileResume: (name: string) => string;
128
+ readonly profileMetadata: (name: string) => string;
129
+ readonly appEnv: () => string;
130
+ readonly appEnvVar: (variable: string) => string;
131
+ readonly profileEnv: (name: string) => string;
132
+ readonly profileEnvVar: (name: string, variable: string) => string;
133
+ readonly modelAuths: () => string;
134
+ readonly modelAuthReadiness: () => string;
135
+ readonly modelAuth: (provider: string) => string;
136
+ readonly modelAuthFlows: () => string;
137
+ readonly modelAuthFlow: (flowId: string) => string;
138
+ readonly modelAuthFlowComplete: (flowId: string) => string;
139
+ readonly modelAuthFlowCancel: (flowId: string) => string;
140
+ readonly filePeek: () => string;
141
+ readonly fileWrite: () => string;
142
+ readonly fileList: () => string;
143
+ readonly bash: () => string;
144
+ readonly objects: () => string;
145
+ readonly object: (ref: string) => string;
146
+ readonly objectsSearch: () => string;
147
+ readonly objectWatch: (ref: string) => string;
148
+ readonly customObjects: () => string;
149
+ readonly customObject: (ref: string) => string;
150
+ readonly customObjectEvents: (ref: string) => string;
151
+ readonly customObjectDeliveries: (ref: string) => string;
152
+ readonly customObjectAck: (ref: string) => string;
153
+ readonly objectEdges: (ref: string) => string;
154
+ readonly docs: () => string;
155
+ readonly doc: (ref: string) => string;
156
+ readonly docMove: (ref: string) => string;
157
+ readonly docHistory: (ref: string) => string;
158
+ readonly docsLint: () => string;
159
+ readonly documentsReconcilePackages: () => string;
160
+ };
@@ -0,0 +1,193 @@
1
+ // API version + route path builders (spec §4.1). Every route is prefixed `/v1`
2
+ // EXCEPT `GET /healthz`, which stays unversioned so any-version probes (incl.
3
+ // the P2 provisioning ladder) can reach it. A version mismatch surfaces as a
4
+ // 404 — there is no negotiation, no Accept-header versioning, no compat shim.
5
+ //
6
+ // These builders carry NO logic — they are pure string constructors. Every
7
+ // interpolated param (node id, target, cron id, profile name, provider) MUST
8
+ // be a pre-validated single path segment (e.g. `isSafeNodeId`-gated ids;
9
+ // upstream-constrained names) — nothing here parses, encodes, or branches, so a
10
+ // param carrying `/` or `..` would corrupt the path.
11
+ //
12
+ // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
13
+ /** The single API version constant; every versioned path prepends it. */
14
+ export const API_VERSION = 'v1';
15
+ const V = `/${API_VERSION}`;
16
+ /** Route path builders. Keys mirror the spec §6 route table. */
17
+ export const routes = {
18
+ // Health / status
19
+ healthz: () => '/healthz',
20
+ status: () => `${V}/status`,
21
+ daemonRestart: () => `${V}/daemon/restart`,
22
+ daemonMigrate: () => `${V}/daemon/migrate`,
23
+ daemonAdmit: () => `${V}/daemon/admit`,
24
+ // Nodes — collection + item
25
+ nodes: () => `${V}/nodes`,
26
+ reviveAll: () => `${V}/nodes/revive-all`,
27
+ node: (id) => `${V}/nodes/${id}`,
28
+ nodeMemoryReads: (id) => `${V}/nodes/${id}/memory-reads`,
29
+ nodeOutcome: (id) => `${V}/nodes/${id}/outcome`,
30
+ nodeOutcomeDelivery: (id) => `${V}/nodes/${id}/outcome-delivery`,
31
+ nodeEvents: (id) => `${V}/nodes/${id}/events`,
32
+ // Node reads
33
+ nodeSnapshot: (id) => `${V}/nodes/${id}/snapshot`,
34
+ nodeSubject: (id) => `${V}/nodes/${id}/subject`,
35
+ nodeSession: (id) => `${V}/nodes/${id}/session`,
36
+ nodeChatInventory: (id) => `${V}/nodes/${id}/chat-inventory`,
37
+ prospectiveChatInventory: () => `${V}/prospective-chat-inventory`,
38
+ nodeTranscript: (id) => `${V}/nodes/${id}/transcript`,
39
+ nodeContext: (id) => `${V}/nodes/${id}/context`,
40
+ nodeReports: (id) => `${V}/nodes/${id}/reports`,
41
+ nodeResult: (id) => `${V}/nodes/${id}/result`,
42
+ nodeJobs: (id) => `${V}/nodes/${id}/jobs`,
43
+ nodeJob: (id, jobId) => `${V}/nodes/${id}/jobs/${jobId}`,
44
+ nodeJobBackground: (id, jobId) => `${V}/nodes/${id}/jobs/${jobId}/background`,
45
+ nodeDelivery: (id) => `${V}/nodes/${id}/delivery`,
46
+ deliveryDryRun: () => `${V}/delivery/dry-run`,
47
+ // Node messages / feed
48
+ nodeMessages: (id) => `${V}/nodes/${id}/messages`,
49
+ nodeInterrupt: (id) => `${V}/nodes/${id}/interrupt`,
50
+ // Node lifecycle actions
51
+ nodeFork: (id) => `${V}/nodes/${id}/fork`,
52
+ nodeRevive: (id) => `${V}/nodes/${id}/revive`,
53
+ nodeRelaunchRoot: (id) => `${V}/nodes/${id}/relaunch-root`,
54
+ nodeBrokerSessionBound: (id) => `${V}/nodes/${id}/broker/session-bound`,
55
+ nodeBrokerSettle: (id) => `${V}/nodes/${id}/broker/settle`,
56
+ nodeBrokerParkComplete: (id) => `${V}/nodes/${id}/broker/park-complete`,
57
+ nodeBrokerParkActivity: (id) => `${V}/nodes/${id}/broker/park-activity`,
58
+ nodeBrokerTelemetry: (id) => `${V}/nodes/${id}/broker/telemetry`,
59
+ nodeLog: (id) => `${V}/nodes/${id}/records/log`,
60
+ nodeTelemetry: (id) => `${V}/nodes/${id}/records/telemetry`,
61
+ nodeRecap: (id) => `${V}/nodes/${id}/records/recap`,
62
+ nodeInboxReport: (id) => `${V}/nodes/${id}/records/inbox`,
63
+ nodePassiveMessage: (id) => `${V}/nodes/${id}/records/passive`,
64
+ nodePushedFinal: (id) => `${V}/nodes/${id}/records/pushed-final`,
65
+ nodeMailClaim: (id) => `${V}/nodes/${id}/mail/claim`,
66
+ nodeMailAcknowledge: (id) => `${V}/nodes/${id}/mail/acknowledge`,
67
+ nodeBrokerModel: (id) => `${V}/nodes/${id}/broker/model`,
68
+ nodeBrokerExtensionState: (id) => `${V}/nodes/${id}/broker/extension-state`,
69
+ nodeBrokerSignals: (id) => `${V}/nodes/${id}/broker/signals`,
70
+ nodeBrokerGeneratedName: (id) => `${V}/nodes/${id}/broker/generated-name`,
71
+ nodeBrokerPersonaAck: (id) => `${V}/nodes/${id}/broker/persona-ack`,
72
+ brokerTurn: (id) => `${V}/broker/${id}/turn`,
73
+ brokerProviderRetry: (id) => `${V}/broker/${id}/provider-retry`,
74
+ brokerFault: (id) => `${V}/broker/${id}/fault`,
75
+ brokerRecovery: (id) => `${V}/broker/${id}/recovery`,
76
+ nodeFault: (id) => `${V}/nodes/${id}/fault`,
77
+ nodeClose: (id) => `${V}/nodes/${id}/close`,
78
+ nodeRecycle: (id) => `${V}/nodes/${id}/recycle`,
79
+ nodeDemote: (id) => `${V}/nodes/${id}/demote`,
80
+ nodePromote: (id) => `${V}/nodes/${id}/promote`,
81
+ nodeYield: (id) => `${V}/nodes/${id}/yield`,
82
+ nodeWait: (id) => `${V}/nodes/${id}/wait`,
83
+ nodeConfig: (id) => `${V}/nodes/${id}/config`,
84
+ kinds: () => `${V}/kinds`,
85
+ nodeWorktreeClose: (id) => `${V}/nodes/${id}/worktree/close`,
86
+ nodeWorktreeAbandon: (id) => `${V}/nodes/${id}/worktree/abandon`,
87
+ quarantinedWorktrees: () => `${V}/worktrees/quarantined`,
88
+ spaces: () => `${V}/spaces`,
89
+ nodeAttach: (id) => `${V}/nodes/${id}/attach`,
90
+ // Focuses (viewer registry — the canvas.db `focuses` table)
91
+ focuses: () => `${V}/focuses`,
92
+ focusByNode: () => `${V}/focuses/by-node`,
93
+ focusByPane: () => `${V}/focuses/by-pane`,
94
+ focus: (focusId) => `${V}/focuses/${focusId}`,
95
+ // Subscriptions
96
+ nodeSubscriptions: (id) => `${V}/nodes/${id}/subscriptions`,
97
+ nodeSubscription: (id, target) => `${V}/nodes/${id}/subscriptions/${target}`,
98
+ // Crons (the cron-spec scheduler)
99
+ crons: () => `${V}/crons`,
100
+ cron: (cronId) => `${V}/crons/${cronId}`,
101
+ cronPause: (cronId) => `${V}/crons/${cronId}/pause`,
102
+ cronResume: (cronId) => `${V}/crons/${cronId}/resume`,
103
+ cronRun: (cronId) => `${V}/crons/${cronId}/run`,
104
+ cronsPoke: () => `${V}/crons/poke`,
105
+ // Canvas maintenance / reads
106
+ canvasAttention: () => `${V}/canvas/attention`,
107
+ canvasAttentionCounts: () => `${V}/canvas/attention/counts`,
108
+ canvasHistorySearch: () => `${V}/canvas/history/search`,
109
+ canvasHistoryGrep: () => `${V}/canvas/history/grep`,
110
+ canvasHistoryRead: () => `${V}/canvas/history/read`,
111
+ canvasHistoryStats: () => `${V}/canvas/history/stats`,
112
+ canvasSnapshot: () => `${V}/canvas/snapshot`,
113
+ canvasRoster: () => `${V}/canvas/roster`,
114
+ canvasBrowse: () => `${V}/canvas/browse`,
115
+ canvasAnalytics: () => `${V}/canvas/analytics`,
116
+ canvasGraph: () => `${V}/canvas/graph`,
117
+ canvasPrune: () => `${V}/canvas/prune`,
118
+ // Daemon-owned document reviews and comments. All interpolated ids are
119
+ // guarded by `CrtrClient` before they reach these pure builders.
120
+ humanReviews: () => `${V}/human/reviews`,
121
+ humanReview: (reviewId) => `${V}/human/reviews/${reviewId}`,
122
+ humanReviewSubmit: (reviewId) => `${V}/human/reviews/${reviewId}/submit`,
123
+ humanReviewCancel: (reviewId) => `${V}/human/reviews/${reviewId}/cancel`,
124
+ humanReviewDocument: (reviewId) => `${V}/human/reviews/${reviewId}/document`,
125
+ humanReviewComments: (reviewId) => `${V}/human/reviews/${reviewId}/comments`,
126
+ humanReviewCommentEvents: (reviewId) => `${V}/human/reviews/${reviewId}/comment-events`,
127
+ humanReviewCommentRanges: (reviewId) => `${V}/human/reviews/${reviewId}/comment-ranges`,
128
+ humanComment: (commentId) => `${V}/human/comments/${commentId}`,
129
+ humanCommentEdit: (commentId) => `${V}/human/comments/${commentId}/edit`,
130
+ humanCommentResolve: (commentId) => `${V}/human/comments/${commentId}/resolve`,
131
+ humanCommentReopen: (commentId) => `${V}/human/comments/${commentId}/reopen`,
132
+ humanCommentDelete: (commentId) => `${V}/human/comments/${commentId}/delete`,
133
+ humanCommentFork: (commentId) => `${V}/human/comments/${commentId}/fork`,
134
+ // Humanloop inbox (crouter cloud crouter-inbox v1, inbox-contract.md §A)
135
+ humanInbox: () => `${V}/human/inbox`,
136
+ humanInboxTicket: (ticketId) => `${V}/human/inbox/${ticketId}`,
137
+ humanInboxRespond: (ticketId) => `${V}/human/inbox/${ticketId}/respond`,
138
+ humanInboxProgress: (ticketId) => `${V}/human/inbox/${ticketId}/progress`,
139
+ humanInboxResponse: (ticketId) => `${V}/human/inbox/${ticketId}/response`,
140
+ humanInboxCancel: (ticketId) => `${V}/human/inbox/${ticketId}/cancel`,
141
+ humanInboxFeedbackResolve: (ticketId, commentId) => `${V}/human/inbox/${ticketId}/feedback-comments/${commentId}/resolve`,
142
+ // Durable programmatic human requests. A request id is separate from the
143
+ // opaque inbox ticket id used by `/v1/human/inbox`.
144
+ humanRequests: () => `${V}/human/requests`,
145
+ humanComponents: () => `${V}/human/components`,
146
+ humanRequest: (requestId) => `${V}/human/requests/${requestId}`,
147
+ humanRequestReplace: (requestId) => `${V}/human/requests/${requestId}/replace`,
148
+ humanRequestRespond: (requestId) => `${V}/human/requests/${requestId}/respond`,
149
+ humanRequestDismiss: (requestId) => `${V}/human/requests/${requestId}/dismiss`,
150
+ humanRequestCancel: (requestId) => `${V}/human/requests/${requestId}/cancel`,
151
+ // Profiles (deletion is daemon-owned because it crosses canvas state)
152
+ profiles: () => `${V}/profiles`,
153
+ profile: (name) => `${V}/profiles/${name}`,
154
+ profilePause: (name) => `${V}/profiles/${name}/pause`,
155
+ profileResume: (name) => `${V}/profiles/${name}/resume`,
156
+ profileMetadata: (name) => `${V}/profiles/${name}/metadata`,
157
+ appEnv: () => `${V}/apps/self/env`,
158
+ appEnvVar: (variable) => `${V}/apps/self/env/${encodeURIComponent(variable)}`,
159
+ profileEnv: (name) => `${V}/profiles/${name}/env`,
160
+ profileEnvVar: (name, variable) => `${V}/profiles/${name}/env/${variable}`,
161
+ // Model auth
162
+ modelAuths: () => `${V}/model-auth`,
163
+ modelAuthReadiness: () => `${V}/model-auth/readiness`,
164
+ modelAuth: (provider) => `${V}/model-auth/${provider}`,
165
+ modelAuthFlows: () => `${V}/model-auth/flows`,
166
+ modelAuthFlow: (flowId) => `${V}/model-auth/flows/${encodeURIComponent(flowId)}`,
167
+ modelAuthFlowComplete: (flowId) => `${V}/model-auth/flows/${encodeURIComponent(flowId)}/complete`,
168
+ modelAuthFlowCancel: (flowId) => `${V}/model-auth/flows/${encodeURIComponent(flowId)}/cancel`,
169
+ // Host file read (browser file-peek panel). The absolute path rides as a
170
+ // `path` query param, not a path segment — it is not a single safe segment.
171
+ filePeek: () => `${V}/files/peek`,
172
+ fileWrite: () => `${V}/files/write`,
173
+ fileList: () => `${V}/files/list`,
174
+ bash: () => `${V}/bash`,
175
+ // Canvas objects and documents. A ref (name or id) may contain `/`, so it is
176
+ // always one percent-encoded path segment.
177
+ objects: () => `${V}/objects`,
178
+ object: (ref) => `${V}/objects/${encodeURIComponent(ref)}`,
179
+ objectsSearch: () => `${V}/objects/search`,
180
+ objectWatch: (ref) => `${V}/objects/${encodeURIComponent(ref)}/watch`,
181
+ customObjects: () => `${V}/custom-objects`,
182
+ customObject: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}`,
183
+ customObjectEvents: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/events`,
184
+ customObjectDeliveries: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/deliveries`,
185
+ customObjectAck: (ref) => `${V}/custom-objects/${encodeURIComponent(ref)}/deliveries/ack`,
186
+ objectEdges: (ref) => `${V}/objects/${encodeURIComponent(ref)}/edges`,
187
+ docs: () => `${V}/docs`,
188
+ doc: (ref) => `${V}/docs/${encodeURIComponent(ref)}`,
189
+ docMove: (ref) => `${V}/docs/${encodeURIComponent(ref)}/move`,
190
+ docHistory: (ref) => `${V}/docs/${encodeURIComponent(ref)}/history`,
191
+ docsLint: () => `${V}/docs/lint`,
192
+ documentsReconcilePackages: () => `${V}/documents/reconcile-packages`,
193
+ };