@north-light/api 0.0.0-stage → 0.3.414

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 (247) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +66 -2
  3. package/dist/api/__tests__/error-codes.test.d.ts +1 -0
  4. package/dist/api/__tests__/error-codes.test.js +79 -0
  5. package/dist/api/__tests__/integration/client.test.d.ts +1 -0
  6. package/dist/api/__tests__/integration/client.test.js +276 -0
  7. package/dist/api/client.d.ts +501 -0
  8. package/dist/api/client.js +1281 -0
  9. package/dist/api/command-manifest/index.d.ts +3 -0
  10. package/dist/api/command-manifest/index.js +3 -0
  11. package/dist/api/command-manifest/manifest.d.ts +51 -0
  12. package/dist/api/command-manifest/manifest.js +332 -0
  13. package/dist/api/command-manifest/result.d.ts +25 -0
  14. package/dist/api/command-manifest/result.js +97 -0
  15. package/dist/api/command-manifest/schema.d.ts +28 -0
  16. package/dist/api/command-manifest/schema.js +856 -0
  17. package/dist/api/dto/analytics.d.ts +184 -0
  18. package/dist/api/dto/analytics.js +3 -0
  19. package/dist/api/dto/attach.d.ts +22 -0
  20. package/dist/api/dto/attach.js +13 -0
  21. package/dist/api/dto/bash-jobs.d.ts +24 -0
  22. package/dist/api/dto/bash-jobs.js +9 -0
  23. package/dist/api/dto/bash.d.ts +17 -0
  24. package/dist/api/dto/bash.js +1 -0
  25. package/dist/api/dto/broker-ops.d.ts +187 -0
  26. package/dist/api/dto/broker-ops.js +6 -0
  27. package/dist/api/dto/broker-signals.d.ts +25 -0
  28. package/dist/api/dto/broker-signals.js +1 -0
  29. package/dist/api/dto/broker.d.ts +86 -0
  30. package/dist/api/dto/broker.js +20 -0
  31. package/dist/api/dto/canvas.d.ts +359 -0
  32. package/dist/api/dto/canvas.js +2 -0
  33. package/dist/api/dto/chat-inventory.d.ts +56 -0
  34. package/dist/api/dto/chat-inventory.js +11 -0
  35. package/dist/api/dto/common.d.ts +29 -0
  36. package/dist/api/dto/common.js +15 -0
  37. package/dist/api/dto/config.d.ts +46 -0
  38. package/dist/api/dto/config.js +3 -0
  39. package/dist/api/dto/crons.d.ts +158 -0
  40. package/dist/api/dto/crons.js +10 -0
  41. package/dist/api/dto/custom-objects.d.ts +66 -0
  42. package/dist/api/dto/custom-objects.js +1 -0
  43. package/dist/api/dto/delivery.d.ts +71 -0
  44. package/dist/api/dto/delivery.js +7 -0
  45. package/dist/api/dto/docs.d.ts +135 -0
  46. package/dist/api/dto/docs.js +8 -0
  47. package/dist/api/dto/files.d.ts +21 -0
  48. package/dist/api/dto/files.js +1 -0
  49. package/dist/api/dto/focus.d.ts +24 -0
  50. package/dist/api/dto/focus.js +10 -0
  51. package/dist/api/dto/grants.d.ts +28 -0
  52. package/dist/api/dto/grants.js +1 -0
  53. package/dist/api/dto/health.d.ts +116 -0
  54. package/dist/api/dto/health.js +2 -0
  55. package/dist/api/dto/human-requests.d.ts +113 -0
  56. package/dist/api/dto/human-requests.js +4 -0
  57. package/dist/api/dto/human.d.ts +28 -0
  58. package/dist/api/dto/human.js +4 -0
  59. package/dist/api/dto/inbox.d.ts +273 -0
  60. package/dist/api/dto/inbox.js +4 -0
  61. package/dist/api/dto/lifecycle.d.ts +88 -0
  62. package/dist/api/dto/lifecycle.js +3 -0
  63. package/dist/api/dto/limits.d.ts +29 -0
  64. package/dist/api/dto/limits.js +2 -0
  65. package/dist/api/dto/mail.d.ts +44 -0
  66. package/dist/api/dto/mail.js +1 -0
  67. package/dist/api/dto/messages.d.ts +104 -0
  68. package/dist/api/dto/messages.js +2 -0
  69. package/dist/api/dto/model-config.d.ts +25 -0
  70. package/dist/api/dto/model-config.js +1 -0
  71. package/dist/api/dto/modelauth.d.ts +132 -0
  72. package/dist/api/dto/modelauth.js +4 -0
  73. package/dist/api/dto/node-events.d.ts +65 -0
  74. package/dist/api/dto/node-events.js +4 -0
  75. package/dist/api/dto/node-outcomes.d.ts +88 -0
  76. package/dist/api/dto/node-outcomes.js +2 -0
  77. package/dist/api/dto/node-records.d.ts +35 -0
  78. package/dist/api/dto/node-records.js +5 -0
  79. package/dist/api/dto/nodes.d.ts +371 -0
  80. package/dist/api/dto/nodes.js +3 -0
  81. package/dist/api/dto/objects.d.ts +172 -0
  82. package/dist/api/dto/objects.js +5 -0
  83. package/dist/api/dto/profiles.d.ts +117 -0
  84. package/dist/api/dto/profiles.js +4 -0
  85. package/dist/api/dto/recovery.d.ts +104 -0
  86. package/dist/api/dto/recovery.js +1 -0
  87. package/dist/api/dto/reports.d.ts +95 -0
  88. package/dist/api/dto/reports.js +2 -0
  89. package/dist/api/dto/review-comments.d.ts +146 -0
  90. package/dist/api/dto/review-comments.js +5 -0
  91. package/dist/api/dto/reviews.d.ts +113 -0
  92. package/dist/api/dto/reviews.js +5 -0
  93. package/dist/api/dto/run-events.d.ts +295 -0
  94. package/dist/api/dto/run-events.js +6 -0
  95. package/dist/api/dto/structured-requests.d.ts +64 -0
  96. package/dist/api/dto/structured-requests.js +5 -0
  97. package/dist/api/dto/subscriptions.d.ts +14 -0
  98. package/dist/api/dto/subscriptions.js +2 -0
  99. package/dist/api/dto/worktree.d.ts +55 -0
  100. package/dist/api/dto/worktree.js +6 -0
  101. package/dist/api/error-codes.d.ts +259 -0
  102. package/dist/api/error-codes.js +56 -0
  103. package/dist/api/errors.d.ts +47 -0
  104. package/dist/api/errors.js +66 -0
  105. package/dist/api/index.d.ts +48 -0
  106. package/dist/api/index.js +45 -0
  107. package/dist/api/long-poll.d.ts +59 -0
  108. package/dist/api/long-poll.js +67 -0
  109. package/dist/api/node-transport.d.ts +18 -0
  110. package/dist/api/node-transport.js +105 -0
  111. package/dist/api/plugin-manifest-schema.d.ts +233 -0
  112. package/dist/api/plugin-manifest-schema.js +23 -0
  113. package/dist/api/routes.d.ts +164 -0
  114. package/dist/api/routes.js +197 -0
  115. package/dist/api/runtime-version.d.ts +31 -0
  116. package/dist/api/runtime-version.js +50 -0
  117. package/dist/core/asset-root.d.ts +7 -0
  118. package/dist/core/asset-root.js +18 -0
  119. package/dist/core/canvas/boot-id.d.ts +6 -0
  120. package/dist/core/canvas/boot-id.js +26 -0
  121. package/dist/core/canvas/paths.d.ts +72 -0
  122. package/dist/core/canvas/paths.js +163 -0
  123. package/dist/core/canvas/pid.d.ts +391 -0
  124. package/dist/core/canvas/pid.js +948 -0
  125. package/dist/core/command-plugins/bundle.d.ts +149 -0
  126. package/dist/core/command-plugins/bundle.js +588 -0
  127. package/dist/core/command-plugins/endpoint.d.ts +24 -0
  128. package/dist/core/command-plugins/endpoint.js +51 -0
  129. package/dist/core/config.d.ts +233 -0
  130. package/dist/core/config.js +1120 -0
  131. package/dist/core/env-name.d.ts +6 -0
  132. package/dist/core/env-name.js +9 -0
  133. package/dist/core/errors.d.ts +38 -0
  134. package/dist/core/errors.js +90 -0
  135. package/dist/core/events/emit.d.ts +6 -0
  136. package/dist/core/events/emit.js +42 -0
  137. package/dist/core/events/envelope.d.ts +2 -0
  138. package/dist/core/events/envelope.js +84 -0
  139. package/dist/core/events/errors.d.ts +4 -0
  140. package/dist/core/events/errors.js +69 -0
  141. package/dist/core/events/operation-id.d.ts +4 -0
  142. package/dist/core/events/operation-id.js +24 -0
  143. package/dist/core/events/serialize.d.ts +4 -0
  144. package/dist/core/events/serialize.js +199 -0
  145. package/dist/core/events/source.d.ts +16 -0
  146. package/dist/core/events/source.js +31 -0
  147. package/dist/core/events/types.d.ts +68 -0
  148. package/dist/core/events/types.js +11 -0
  149. package/dist/core/exclusive-lock.d.ts +34 -0
  150. package/dist/core/exclusive-lock.js +197 -0
  151. package/dist/core/fs-utils.d.ts +44 -0
  152. package/dist/core/fs-utils.js +208 -0
  153. package/dist/core/help.d.ts +309 -0
  154. package/dist/core/help.js +406 -0
  155. package/dist/core/human/page-catalog.d.ts +57 -0
  156. package/dist/core/human/page-catalog.js +172 -0
  157. package/dist/core/installed-plugins.d.ts +2 -0
  158. package/dist/core/installed-plugins.js +79 -0
  159. package/dist/core/io.d.ts +122 -0
  160. package/dist/core/io.js +373 -0
  161. package/dist/core/keybindings/attach-control.d.ts +49 -0
  162. package/dist/core/keybindings/attach-control.js +42 -0
  163. package/dist/core/keybindings/catalog.d.ts +18 -0
  164. package/dist/core/keybindings/catalog.js +257 -0
  165. package/dist/core/keybindings/types.d.ts +42 -0
  166. package/dist/core/keybindings/types.js +1 -0
  167. package/dist/core/layout.d.ts +34 -0
  168. package/dist/core/layout.js +106 -0
  169. package/dist/core/locked-file.d.ts +27 -0
  170. package/dist/core/locked-file.js +118 -0
  171. package/dist/core/log.d.ts +9 -0
  172. package/dist/core/log.js +89 -0
  173. package/dist/core/manifest.d.ts +5 -0
  174. package/dist/core/manifest.js +15 -0
  175. package/dist/core/plugin-env.d.ts +8 -0
  176. package/dist/core/plugin-env.js +31 -0
  177. package/dist/core/plugin-extensions.d.ts +29 -0
  178. package/dist/core/plugin-extensions.js +191 -0
  179. package/dist/core/plugin-swap-lock.d.ts +9 -0
  180. package/dist/core/plugin-swap-lock.js +31 -0
  181. package/dist/core/preview-result-path.d.ts +4 -0
  182. package/dist/core/preview-result-path.js +26 -0
  183. package/dist/core/profiles/env-store.d.ts +22 -0
  184. package/dist/core/profiles/env-store.js +163 -0
  185. package/dist/core/profiles/fuzzy-match.d.ts +19 -0
  186. package/dist/core/profiles/fuzzy-match.js +92 -0
  187. package/dist/core/profiles/manifest.d.ts +120 -0
  188. package/dist/core/profiles/manifest.js +529 -0
  189. package/dist/core/rate-limit-scope.d.ts +25 -0
  190. package/dist/core/rate-limit-scope.js +64 -0
  191. package/dist/core/render.d.ts +12 -0
  192. package/dist/core/render.js +138 -0
  193. package/dist/core/resolver.d.ts +14 -0
  194. package/dist/core/resolver.js +111 -0
  195. package/dist/core/runtime/branded-host.d.ts +55 -0
  196. package/dist/core/runtime/branded-host.js +485 -0
  197. package/dist/core/runtime/broker/daemon-ops.d.ts +65 -0
  198. package/dist/core/runtime/broker/daemon-ops.js +177 -0
  199. package/dist/core/runtime/broker/signal-stream.d.ts +30 -0
  200. package/dist/core/runtime/broker/signal-stream.js +149 -0
  201. package/dist/core/scope.d.ts +32 -0
  202. package/dist/core/scope.js +184 -0
  203. package/dist/core/scoped-state/db.d.ts +17 -0
  204. package/dist/core/scoped-state/db.js +247 -0
  205. package/dist/core/scoped-state/migrate.d.ts +8 -0
  206. package/dist/core/scoped-state/migrate.js +187 -0
  207. package/dist/core/scoped-state/paths.d.ts +9 -0
  208. package/dist/core/scoped-state/paths.js +27 -0
  209. package/dist/core/scoped-state/profiles.d.ts +27 -0
  210. package/dist/core/scoped-state/profiles.js +93 -0
  211. package/dist/core/scoped-state/providers.d.ts +24 -0
  212. package/dist/core/scoped-state/providers.js +19 -0
  213. package/dist/core/scoped-state/schema.d.ts +6 -0
  214. package/dist/core/scoped-state/schema.js +43 -0
  215. package/dist/core/scoped-state/settings.d.ts +28 -0
  216. package/dist/core/scoped-state/settings.js +83 -0
  217. package/dist/core/spaces/open-beneath.d.ts +71 -0
  218. package/dist/core/spaces/open-beneath.js +581 -0
  219. package/dist/core/sqlite-statements.d.ts +4 -0
  220. package/dist/core/sqlite-statements.js +17 -0
  221. package/dist/core/subscription-state.d.ts +121 -0
  222. package/dist/core/subscription-state.js +287 -0
  223. package/dist/core/user-settings.d.ts +377 -0
  224. package/dist/core/user-settings.js +458 -0
  225. package/dist/daemon/broker-signals/bus.d.ts +30 -0
  226. package/dist/daemon/broker-signals/bus.js +87 -0
  227. package/dist/daemon/manage.d.ts +176 -0
  228. package/dist/daemon/manage.js +664 -0
  229. package/dist/daemon/pidfile.d.ts +8 -0
  230. package/dist/daemon/pidfile.js +37 -0
  231. package/dist/daemon/startup-policy.d.ts +1 -0
  232. package/dist/daemon/startup-policy.js +1 -0
  233. package/dist/native/linux.d.ts +29 -0
  234. package/dist/native/linux.js +20 -0
  235. package/dist/shared/env.d.ts +116 -0
  236. package/dist/shared/env.js +271 -0
  237. package/dist/shared/generated-context.d.ts +83 -0
  238. package/dist/shared/generated-context.js +235 -0
  239. package/dist/shared/inbox-entry-body.d.ts +22 -0
  240. package/dist/shared/inbox-entry-body.js +116 -0
  241. package/dist/shared/predicates.d.ts +2 -0
  242. package/dist/shared/predicates.js +4 -0
  243. package/dist/shared/working-activity.d.ts +9 -0
  244. package/dist/shared/working-activity.js +27 -0
  245. package/dist/types.d.ts +562 -0
  246. package/dist/types.js +186 -0
  247. package/package.json +47 -4
@@ -0,0 +1,105 @@
1
+ // The Node-only half of `@north-light/api`: crtrd's default unix
2
+ // socket path, a `fetch` implementation that speaks it, and `localClient()` —
3
+ // the one-line way to get a `CrtrClient` bound to the owner's own daemon.
4
+ //
5
+ // This is a SEPARATE package entry (`@north-light/api/node`) from the
6
+ // root so a browser bundle that imports the root never resolves `node:http`,
7
+ // `node:os`, or `node:path`. Import from here, never re-export it off the root.
8
+ import { request as httpRequest } from 'node:http';
9
+ import { homedir } from 'node:os';
10
+ import { join } from 'node:path';
11
+ import { CrtrClient } from './client.js';
12
+ /** Filesystem/scope constants mirrored from `core/types.ts` (`CRTR_DIR_NAME`)
13
+ * and `core/canvas/paths.ts` (`crtrHome`/`apiSocketPath`). Duplicated — not
14
+ * imported — to keep the exported `/api` contract dependency-light; the two
15
+ * MUST agree on the resolved socket path. */
16
+ const CRTR_DIR_NAME = '.crouter';
17
+ const SOCKET_BASENAME = 'api.sock';
18
+ const LOCAL_SOCKET_FETCH = Symbol.for('@north-light/api/local-socket-fetch');
19
+ /** Resolve crtrd's default unix socket path the same way `apiSocketPath()` does,
20
+ * via Node built-ins only (no `core/canvas/paths.ts` import). */
21
+ export function defaultSocketPath() {
22
+ const relay = process.env['CRTR_API_SOCKET'];
23
+ if (relay)
24
+ return relay;
25
+ // Read CRTR_HOME directly (as `envHomeOverride()` does): importing
26
+ // shared/env.ts would pull @north-light/identity into this
27
+ // zero-dependency package.
28
+ const override = process.env['CRTR_HOME'];
29
+ const root = override !== undefined && override !== '' ? override : join(homedir(), CRTR_DIR_NAME);
30
+ return join(process.platform === 'linux' ? '/run/crtr' : join(root, 'runtime'), SOCKET_BASENAME);
31
+ }
32
+ /** A standard `fetch` bound to one unix socket, built on `node:http` with
33
+ * `{ socketPath }`. The returned `Response`'s body is a live `ReadableStream`
34
+ * fed as bytes arrive — never buffered before the caller sees headers —
35
+ * which is what lets `CrtrClient` serve a streaming route (SSE) later without
36
+ * a second transport. Connection failures are wrapped as `TypeError('fetch
37
+ * failed', { cause })`, matching the shape native `fetch` throws, so
38
+ * `CrtrClient`'s cold-socket/interrupted-request classification (`err.cause.code`)
39
+ * reads identically off either transport. */
40
+ export function socketFetch(socketPath) {
41
+ const fetchOverSocket = function (input, init = {}) {
42
+ const url = input instanceof URL ? input : new URL(typeof input === 'string' ? input : input.url);
43
+ const method = init.method ?? 'GET';
44
+ const headers = {};
45
+ if (init.headers !== undefined) {
46
+ for (const [name, value] of new Headers(init.headers).entries())
47
+ headers[name] = value;
48
+ }
49
+ const payload = typeof init.body === 'string' ? init.body : undefined;
50
+ if (payload !== undefined)
51
+ headers['content-length'] = String(Buffer.byteLength(payload));
52
+ return new Promise((resolvePromise, reject) => {
53
+ const req = httpRequest({ socketPath, path: url.pathname + url.search, method, headers }, (res) => {
54
+ const body = new ReadableStream({
55
+ start(controller) {
56
+ res.on('data', (chunk) => controller.enqueue(new Uint8Array(chunk)));
57
+ res.on('end', () => controller.close());
58
+ res.on('error', (err) => controller.error(err));
59
+ },
60
+ cancel() {
61
+ res.destroy();
62
+ },
63
+ });
64
+ const responseHeaders = new Headers();
65
+ for (const [name, value] of Object.entries(res.headers)) {
66
+ if (value === undefined)
67
+ continue;
68
+ for (const one of Array.isArray(value) ? value : [value])
69
+ responseHeaders.append(name, one);
70
+ }
71
+ const status = res.statusCode ?? 0;
72
+ resolvePromise(new Response(status === 204 ? null : body, { status, statusText: res.statusMessage, headers: responseHeaders }));
73
+ });
74
+ req.on('error', (err) => reject(new TypeError('fetch failed', { cause: err })));
75
+ const signal = init.signal;
76
+ const abort = () => {
77
+ req.destroy();
78
+ reject(signal?.reason ?? new DOMException('The operation was aborted.', 'AbortError'));
79
+ };
80
+ if (signal !== null && signal !== undefined) {
81
+ if (signal.aborted) {
82
+ abort();
83
+ return;
84
+ }
85
+ signal.addEventListener('abort', abort, { once: true });
86
+ }
87
+ if (payload !== undefined)
88
+ req.write(payload);
89
+ req.end();
90
+ });
91
+ };
92
+ fetchOverSocket[LOCAL_SOCKET_FETCH] = true;
93
+ return fetchOverSocket;
94
+ }
95
+ /** Construct a client bound to the default local socket with autostart on.
96
+ * Without `onColdSocket`, a cold socket fails with `daemon_unavailable`. */
97
+ export function localClient(opts = {}) {
98
+ const { socketPath, ...rest } = opts;
99
+ return new CrtrClient({
100
+ baseUrl: 'http://localhost',
101
+ fetch: socketFetch(socketPath ?? defaultSocketPath()),
102
+ autostart: true,
103
+ ...rest,
104
+ });
105
+ }
@@ -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 `@north-light/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,164 @@
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 due: () => string;
8
+ readonly daemonRestart: () => string;
9
+ readonly daemonMigrate: () => string;
10
+ readonly daemonAdmit: () => string;
11
+ readonly nodes: () => string;
12
+ readonly reviveAll: () => string;
13
+ readonly node: (id: string) => string;
14
+ readonly nodeMemoryReads: (id: string) => string;
15
+ readonly nodeOutcome: (id: string) => string;
16
+ readonly nodeOutcomeDelivery: (id: string) => string;
17
+ readonly nodeEvents: (id: string) => string;
18
+ readonly nodeSnapshot: (id: string) => string;
19
+ readonly nodeSubject: (id: string) => string;
20
+ readonly nodeSession: (id: string) => string;
21
+ readonly nodeChatInventory: (id: string) => string;
22
+ readonly prospectiveChatInventory: () => string;
23
+ readonly nodeTranscript: (id: string) => string;
24
+ readonly nodeContext: (id: string) => string;
25
+ readonly nodeReports: (id: string) => string;
26
+ readonly nodeResult: (id: string) => string;
27
+ readonly nodeJobs: (id: string) => string;
28
+ readonly nodeJob: (id: string, jobId: string) => string;
29
+ readonly nodeJobBackground: (id: string, jobId: string) => string;
30
+ readonly nodeDelivery: (id: string) => string;
31
+ readonly deliveryDryRun: () => string;
32
+ readonly deliveryRetry: (id: string) => string;
33
+ readonly nodeMessages: (id: string) => string;
34
+ readonly nodeInterrupt: (id: string) => string;
35
+ readonly nodeFork: (id: string) => string;
36
+ readonly nodeRevive: (id: string) => string;
37
+ readonly nodeRelaunchRoot: (id: string) => string;
38
+ readonly nodeBrokerSessionBound: (id: string) => string;
39
+ readonly nodeBrokerSettle: (id: string) => string;
40
+ readonly nodeBrokerParkComplete: (id: string) => string;
41
+ readonly nodeBrokerParkActivity: (id: string) => string;
42
+ readonly nodeBrokerTelemetry: (id: string) => string;
43
+ readonly nodeLog: (id: string) => string;
44
+ readonly nodeTelemetry: (id: string) => string;
45
+ readonly nodeRecap: (id: string) => string;
46
+ readonly nodeInboxReport: (id: string) => string;
47
+ readonly nodePassiveMessage: (id: string) => string;
48
+ readonly nodePushedFinal: (id: string) => string;
49
+ readonly nodeMailClaim: (id: string) => string;
50
+ readonly nodeMailAcknowledge: (id: string) => string;
51
+ readonly nodeBrokerModel: (id: string) => string;
52
+ readonly nodeBrokerExtensionState: (id: string) => string;
53
+ readonly nodeBrokerSignals: (id: string) => string;
54
+ readonly nodeBrokerGeneratedName: (id: string) => string;
55
+ readonly nodeBrokerPersonaAck: (id: string) => string;
56
+ readonly brokerTurn: (id: string) => string;
57
+ readonly brokerProviderRetry: (id: string) => string;
58
+ readonly brokerFault: (id: string) => string;
59
+ readonly brokerRecovery: (id: string) => string;
60
+ readonly nodeFault: (id: string) => string;
61
+ readonly nodeClose: (id: string) => string;
62
+ readonly nodeRecycle: (id: string) => string;
63
+ readonly nodeDemote: (id: string) => string;
64
+ readonly nodePromote: (id: string) => string;
65
+ readonly nodeYield: (id: string) => string;
66
+ readonly nodeWait: (id: string) => string;
67
+ readonly nodeConfig: (id: string) => string;
68
+ readonly kinds: () => string;
69
+ readonly nodeWorktreeClose: (id: string) => string;
70
+ readonly nodeWorktreeAbandon: (id: string) => string;
71
+ readonly quarantinedWorktrees: () => string;
72
+ readonly spaces: () => string;
73
+ readonly limits: () => string;
74
+ readonly limitsApp: (app: string) => string;
75
+ readonly nodeAttach: (id: string) => string;
76
+ readonly focuses: () => string;
77
+ readonly focusByNode: () => string;
78
+ readonly focusByPane: () => string;
79
+ readonly focus: (focusId: string) => string;
80
+ readonly nodeSubscriptions: (id: string) => string;
81
+ readonly nodeSubscription: (id: string, target: string) => string;
82
+ readonly crons: () => string;
83
+ readonly cron: (cronId: string) => string;
84
+ readonly cronPause: (cronId: string) => string;
85
+ readonly cronResume: (cronId: string) => string;
86
+ readonly cronRun: (cronId: string) => string;
87
+ readonly cronsPoke: () => string;
88
+ readonly canvasAttention: () => string;
89
+ readonly canvasAttentionCounts: () => string;
90
+ readonly canvasHistorySearch: () => string;
91
+ readonly canvasHistoryGrep: () => string;
92
+ readonly canvasHistoryRead: () => string;
93
+ readonly canvasHistoryStats: () => string;
94
+ readonly canvasSnapshot: () => string;
95
+ readonly canvasRoster: () => string;
96
+ readonly canvasBrowse: () => string;
97
+ readonly canvasAnalytics: () => string;
98
+ readonly canvasGraph: () => string;
99
+ readonly canvasPrune: () => string;
100
+ readonly humanReviews: () => string;
101
+ readonly humanReview: (reviewId: string) => string;
102
+ readonly humanReviewSubmit: (reviewId: string) => string;
103
+ readonly humanReviewCancel: (reviewId: string) => string;
104
+ readonly humanReviewDocument: (reviewId: string) => string;
105
+ readonly humanReviewComments: (reviewId: string) => string;
106
+ readonly humanReviewCommentEvents: (reviewId: string) => string;
107
+ readonly humanReviewCommentRanges: (reviewId: string) => string;
108
+ readonly humanComment: (commentId: string) => string;
109
+ readonly humanCommentEdit: (commentId: string) => string;
110
+ readonly humanCommentResolve: (commentId: string) => string;
111
+ readonly humanCommentReopen: (commentId: string) => string;
112
+ readonly humanCommentDelete: (commentId: string) => string;
113
+ readonly humanCommentFork: (commentId: string) => string;
114
+ readonly humanInbox: () => string;
115
+ readonly humanInboxTicket: (ticketId: string) => string;
116
+ readonly humanInboxRespond: (ticketId: string) => string;
117
+ readonly humanInboxProgress: (ticketId: string) => string;
118
+ readonly humanInboxResponse: (ticketId: string) => string;
119
+ readonly humanInboxCancel: (ticketId: string) => string;
120
+ readonly humanInboxFeedbackResolve: (ticketId: string, commentId: string) => string;
121
+ readonly humanRequests: () => string;
122
+ readonly humanComponents: () => string;
123
+ readonly humanRequest: (requestId: string) => string;
124
+ readonly humanRequestReplace: (requestId: string) => string;
125
+ readonly humanRequestRespond: (requestId: string) => string;
126
+ readonly humanRequestDismiss: (requestId: string) => string;
127
+ readonly humanRequestCancel: (requestId: string) => string;
128
+ readonly profiles: () => string;
129
+ readonly profile: (name: string) => string;
130
+ readonly profilePause: (name: string) => string;
131
+ readonly profileResume: (name: string) => string;
132
+ readonly profileMetadata: (name: string) => string;
133
+ readonly appEnv: () => string;
134
+ readonly appEnvVar: (variable: string) => string;
135
+ readonly profileEnv: (name: string) => string;
136
+ readonly profileEnvVar: (name: string, variable: string) => string;
137
+ readonly modelAuths: () => string;
138
+ readonly modelAuthReadiness: () => string;
139
+ readonly modelAuth: (provider: string) => string;
140
+ readonly modelAuthFlows: () => string;
141
+ readonly modelAuthFlow: (flowId: string) => string;
142
+ readonly modelAuthFlowComplete: (flowId: string) => string;
143
+ readonly modelAuthFlowCancel: (flowId: string) => string;
144
+ readonly filePeek: () => string;
145
+ readonly fileWrite: () => string;
146
+ readonly fileList: () => string;
147
+ readonly bash: () => string;
148
+ readonly objects: () => string;
149
+ readonly object: (ref: string) => string;
150
+ readonly objectsSearch: () => string;
151
+ readonly objectWatch: (ref: string) => string;
152
+ readonly customObjects: () => string;
153
+ readonly customObject: (ref: string) => string;
154
+ readonly customObjectEvents: (ref: string) => string;
155
+ readonly customObjectDeliveries: (ref: string) => string;
156
+ readonly customObjectAck: (ref: string) => string;
157
+ readonly objectEdges: (ref: string) => string;
158
+ readonly docs: () => string;
159
+ readonly doc: (ref: string) => string;
160
+ readonly docMove: (ref: string) => string;
161
+ readonly docHistory: (ref: string) => string;
162
+ readonly docsLint: () => string;
163
+ readonly documentsReconcilePackages: () => string;
164
+ };