@north-light/api 0.0.0 → 0.3.415

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 (251) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +66 -2
  3. package/dist/api/__tests__/deadline.test.d.ts +1 -0
  4. package/dist/api/__tests__/deadline.test.js +46 -0
  5. package/dist/api/__tests__/error-codes.test.d.ts +1 -0
  6. package/dist/api/__tests__/error-codes.test.js +79 -0
  7. package/dist/api/__tests__/integration/client.test.d.ts +1 -0
  8. package/dist/api/__tests__/integration/client.test.js +276 -0
  9. package/dist/api/client.d.ts +521 -0
  10. package/dist/api/client.js +1388 -0
  11. package/dist/api/command-manifest/index.d.ts +3 -0
  12. package/dist/api/command-manifest/index.js +3 -0
  13. package/dist/api/command-manifest/manifest.d.ts +51 -0
  14. package/dist/api/command-manifest/manifest.js +332 -0
  15. package/dist/api/command-manifest/result.d.ts +25 -0
  16. package/dist/api/command-manifest/result.js +97 -0
  17. package/dist/api/command-manifest/schema.d.ts +28 -0
  18. package/dist/api/command-manifest/schema.js +856 -0
  19. package/dist/api/dto/analytics.d.ts +184 -0
  20. package/dist/api/dto/analytics.js +3 -0
  21. package/dist/api/dto/attach.d.ts +22 -0
  22. package/dist/api/dto/attach.js +13 -0
  23. package/dist/api/dto/bash-jobs.d.ts +24 -0
  24. package/dist/api/dto/bash-jobs.js +9 -0
  25. package/dist/api/dto/bash.d.ts +17 -0
  26. package/dist/api/dto/bash.js +1 -0
  27. package/dist/api/dto/broker-ops.d.ts +187 -0
  28. package/dist/api/dto/broker-ops.js +6 -0
  29. package/dist/api/dto/broker-signals.d.ts +25 -0
  30. package/dist/api/dto/broker-signals.js +1 -0
  31. package/dist/api/dto/broker.d.ts +86 -0
  32. package/dist/api/dto/broker.js +20 -0
  33. package/dist/api/dto/canvas.d.ts +359 -0
  34. package/dist/api/dto/canvas.js +2 -0
  35. package/dist/api/dto/chat-inventory.d.ts +56 -0
  36. package/dist/api/dto/chat-inventory.js +11 -0
  37. package/dist/api/dto/common.d.ts +29 -0
  38. package/dist/api/dto/common.js +15 -0
  39. package/dist/api/dto/config.d.ts +46 -0
  40. package/dist/api/dto/config.js +3 -0
  41. package/dist/api/dto/crons.d.ts +164 -0
  42. package/dist/api/dto/crons.js +10 -0
  43. package/dist/api/dto/custom-objects.d.ts +66 -0
  44. package/dist/api/dto/custom-objects.js +1 -0
  45. package/dist/api/dto/delivery.d.ts +71 -0
  46. package/dist/api/dto/delivery.js +7 -0
  47. package/dist/api/dto/docs.d.ts +135 -0
  48. package/dist/api/dto/docs.js +8 -0
  49. package/dist/api/dto/files.d.ts +21 -0
  50. package/dist/api/dto/files.js +1 -0
  51. package/dist/api/dto/focus.d.ts +24 -0
  52. package/dist/api/dto/focus.js +10 -0
  53. package/dist/api/dto/grants.d.ts +28 -0
  54. package/dist/api/dto/grants.js +1 -0
  55. package/dist/api/dto/health.d.ts +116 -0
  56. package/dist/api/dto/health.js +2 -0
  57. package/dist/api/dto/human-requests.d.ts +113 -0
  58. package/dist/api/dto/human-requests.js +4 -0
  59. package/dist/api/dto/human.d.ts +28 -0
  60. package/dist/api/dto/human.js +4 -0
  61. package/dist/api/dto/inbox.d.ts +273 -0
  62. package/dist/api/dto/inbox.js +4 -0
  63. package/dist/api/dto/lifecycle.d.ts +88 -0
  64. package/dist/api/dto/lifecycle.js +3 -0
  65. package/dist/api/dto/limits.d.ts +29 -0
  66. package/dist/api/dto/limits.js +2 -0
  67. package/dist/api/dto/mail.d.ts +44 -0
  68. package/dist/api/dto/mail.js +1 -0
  69. package/dist/api/dto/messages.d.ts +104 -0
  70. package/dist/api/dto/messages.js +2 -0
  71. package/dist/api/dto/model-config.d.ts +25 -0
  72. package/dist/api/dto/model-config.js +1 -0
  73. package/dist/api/dto/modelauth.d.ts +132 -0
  74. package/dist/api/dto/modelauth.js +4 -0
  75. package/dist/api/dto/node-events.d.ts +65 -0
  76. package/dist/api/dto/node-events.js +4 -0
  77. package/dist/api/dto/node-outcomes.d.ts +88 -0
  78. package/dist/api/dto/node-outcomes.js +2 -0
  79. package/dist/api/dto/node-records.d.ts +35 -0
  80. package/dist/api/dto/node-records.js +5 -0
  81. package/dist/api/dto/nodes.d.ts +371 -0
  82. package/dist/api/dto/nodes.js +3 -0
  83. package/dist/api/dto/objects.d.ts +172 -0
  84. package/dist/api/dto/objects.js +5 -0
  85. package/dist/api/dto/profiles.d.ts +117 -0
  86. package/dist/api/dto/profiles.js +4 -0
  87. package/dist/api/dto/recovery.d.ts +104 -0
  88. package/dist/api/dto/recovery.js +1 -0
  89. package/dist/api/dto/reports.d.ts +95 -0
  90. package/dist/api/dto/reports.js +2 -0
  91. package/dist/api/dto/review-comments.d.ts +146 -0
  92. package/dist/api/dto/review-comments.js +5 -0
  93. package/dist/api/dto/reviews.d.ts +113 -0
  94. package/dist/api/dto/reviews.js +5 -0
  95. package/dist/api/dto/run-events.d.ts +295 -0
  96. package/dist/api/dto/run-events.js +6 -0
  97. package/dist/api/dto/structured-requests.d.ts +64 -0
  98. package/dist/api/dto/structured-requests.js +5 -0
  99. package/dist/api/dto/subscriptions.d.ts +14 -0
  100. package/dist/api/dto/subscriptions.js +2 -0
  101. package/dist/api/dto/usage.d.ts +27 -0
  102. package/dist/api/dto/usage.js +1 -0
  103. package/dist/api/dto/worktree.d.ts +55 -0
  104. package/dist/api/dto/worktree.js +6 -0
  105. package/dist/api/error-codes.d.ts +259 -0
  106. package/dist/api/error-codes.js +56 -0
  107. package/dist/api/errors.d.ts +47 -0
  108. package/dist/api/errors.js +66 -0
  109. package/dist/api/index.d.ts +49 -0
  110. package/dist/api/index.js +46 -0
  111. package/dist/api/long-poll.d.ts +59 -0
  112. package/dist/api/long-poll.js +67 -0
  113. package/dist/api/node-transport.d.ts +18 -0
  114. package/dist/api/node-transport.js +105 -0
  115. package/dist/api/plugin-manifest-schema.d.ts +233 -0
  116. package/dist/api/plugin-manifest-schema.js +23 -0
  117. package/dist/api/routes.d.ts +164 -0
  118. package/dist/api/routes.js +197 -0
  119. package/dist/api/runtime-version.d.ts +31 -0
  120. package/dist/api/runtime-version.js +50 -0
  121. package/dist/core/asset-root.d.ts +7 -0
  122. package/dist/core/asset-root.js +18 -0
  123. package/dist/core/canvas/boot-id.d.ts +6 -0
  124. package/dist/core/canvas/boot-id.js +26 -0
  125. package/dist/core/canvas/paths.d.ts +72 -0
  126. package/dist/core/canvas/paths.js +163 -0
  127. package/dist/core/canvas/pid.d.ts +391 -0
  128. package/dist/core/canvas/pid.js +948 -0
  129. package/dist/core/command-plugins/bundle.d.ts +149 -0
  130. package/dist/core/command-plugins/bundle.js +588 -0
  131. package/dist/core/command-plugins/endpoint.d.ts +24 -0
  132. package/dist/core/command-plugins/endpoint.js +51 -0
  133. package/dist/core/config.d.ts +233 -0
  134. package/dist/core/config.js +1120 -0
  135. package/dist/core/env-name.d.ts +6 -0
  136. package/dist/core/env-name.js +9 -0
  137. package/dist/core/errors.d.ts +38 -0
  138. package/dist/core/errors.js +90 -0
  139. package/dist/core/events/emit.d.ts +6 -0
  140. package/dist/core/events/emit.js +42 -0
  141. package/dist/core/events/envelope.d.ts +2 -0
  142. package/dist/core/events/envelope.js +84 -0
  143. package/dist/core/events/errors.d.ts +4 -0
  144. package/dist/core/events/errors.js +69 -0
  145. package/dist/core/events/operation-id.d.ts +4 -0
  146. package/dist/core/events/operation-id.js +24 -0
  147. package/dist/core/events/serialize.d.ts +4 -0
  148. package/dist/core/events/serialize.js +199 -0
  149. package/dist/core/events/source.d.ts +16 -0
  150. package/dist/core/events/source.js +31 -0
  151. package/dist/core/events/types.d.ts +68 -0
  152. package/dist/core/events/types.js +11 -0
  153. package/dist/core/exclusive-lock.d.ts +34 -0
  154. package/dist/core/exclusive-lock.js +197 -0
  155. package/dist/core/fs-utils.d.ts +44 -0
  156. package/dist/core/fs-utils.js +208 -0
  157. package/dist/core/help.d.ts +309 -0
  158. package/dist/core/help.js +406 -0
  159. package/dist/core/human/page-catalog.d.ts +57 -0
  160. package/dist/core/human/page-catalog.js +172 -0
  161. package/dist/core/installed-plugins.d.ts +2 -0
  162. package/dist/core/installed-plugins.js +79 -0
  163. package/dist/core/io.d.ts +122 -0
  164. package/dist/core/io.js +373 -0
  165. package/dist/core/keybindings/attach-control.d.ts +49 -0
  166. package/dist/core/keybindings/attach-control.js +42 -0
  167. package/dist/core/keybindings/catalog.d.ts +18 -0
  168. package/dist/core/keybindings/catalog.js +257 -0
  169. package/dist/core/keybindings/types.d.ts +42 -0
  170. package/dist/core/keybindings/types.js +1 -0
  171. package/dist/core/layout.d.ts +36 -0
  172. package/dist/core/layout.js +112 -0
  173. package/dist/core/locked-file.d.ts +27 -0
  174. package/dist/core/locked-file.js +118 -0
  175. package/dist/core/log.d.ts +9 -0
  176. package/dist/core/log.js +89 -0
  177. package/dist/core/manifest.d.ts +5 -0
  178. package/dist/core/manifest.js +15 -0
  179. package/dist/core/plugin-env.d.ts +8 -0
  180. package/dist/core/plugin-env.js +31 -0
  181. package/dist/core/plugin-extensions.d.ts +29 -0
  182. package/dist/core/plugin-extensions.js +191 -0
  183. package/dist/core/plugin-swap-lock.d.ts +9 -0
  184. package/dist/core/plugin-swap-lock.js +31 -0
  185. package/dist/core/preview-result-path.d.ts +4 -0
  186. package/dist/core/preview-result-path.js +26 -0
  187. package/dist/core/profiles/env-store.d.ts +22 -0
  188. package/dist/core/profiles/env-store.js +163 -0
  189. package/dist/core/profiles/fuzzy-match.d.ts +19 -0
  190. package/dist/core/profiles/fuzzy-match.js +92 -0
  191. package/dist/core/profiles/manifest.d.ts +120 -0
  192. package/dist/core/profiles/manifest.js +529 -0
  193. package/dist/core/rate-limit-scope.d.ts +25 -0
  194. package/dist/core/rate-limit-scope.js +64 -0
  195. package/dist/core/render.d.ts +12 -0
  196. package/dist/core/render.js +138 -0
  197. package/dist/core/resolver.d.ts +14 -0
  198. package/dist/core/resolver.js +111 -0
  199. package/dist/core/runtime/branded-host.d.ts +55 -0
  200. package/dist/core/runtime/branded-host.js +485 -0
  201. package/dist/core/runtime/broker/daemon-ops.d.ts +65 -0
  202. package/dist/core/runtime/broker/daemon-ops.js +177 -0
  203. package/dist/core/runtime/broker/signal-stream.d.ts +30 -0
  204. package/dist/core/runtime/broker/signal-stream.js +149 -0
  205. package/dist/core/scope.d.ts +32 -0
  206. package/dist/core/scope.js +184 -0
  207. package/dist/core/scoped-state/db.d.ts +17 -0
  208. package/dist/core/scoped-state/db.js +247 -0
  209. package/dist/core/scoped-state/migrate.d.ts +8 -0
  210. package/dist/core/scoped-state/migrate.js +187 -0
  211. package/dist/core/scoped-state/paths.d.ts +9 -0
  212. package/dist/core/scoped-state/paths.js +27 -0
  213. package/dist/core/scoped-state/profiles.d.ts +27 -0
  214. package/dist/core/scoped-state/profiles.js +93 -0
  215. package/dist/core/scoped-state/providers.d.ts +24 -0
  216. package/dist/core/scoped-state/providers.js +19 -0
  217. package/dist/core/scoped-state/schema.d.ts +6 -0
  218. package/dist/core/scoped-state/schema.js +43 -0
  219. package/dist/core/scoped-state/settings.d.ts +28 -0
  220. package/dist/core/scoped-state/settings.js +83 -0
  221. package/dist/core/spaces/open-beneath.d.ts +71 -0
  222. package/dist/core/spaces/open-beneath.js +581 -0
  223. package/dist/core/sqlite-statements.d.ts +4 -0
  224. package/dist/core/sqlite-statements.js +17 -0
  225. package/dist/core/subscription-state.d.ts +121 -0
  226. package/dist/core/subscription-state.js +287 -0
  227. package/dist/core/user-settings.d.ts +377 -0
  228. package/dist/core/user-settings.js +458 -0
  229. package/dist/daemon/broker-signals/bus.d.ts +30 -0
  230. package/dist/daemon/broker-signals/bus.js +87 -0
  231. package/dist/daemon/manage.d.ts +176 -0
  232. package/dist/daemon/manage.js +664 -0
  233. package/dist/daemon/pidfile.d.ts +8 -0
  234. package/dist/daemon/pidfile.js +37 -0
  235. package/dist/daemon/startup-policy.d.ts +1 -0
  236. package/dist/daemon/startup-policy.js +1 -0
  237. package/dist/native/linux.d.ts +29 -0
  238. package/dist/native/linux.js +20 -0
  239. package/dist/shared/env.d.ts +116 -0
  240. package/dist/shared/env.js +271 -0
  241. package/dist/shared/generated-context.d.ts +83 -0
  242. package/dist/shared/generated-context.js +235 -0
  243. package/dist/shared/inbox-entry-body.d.ts +22 -0
  244. package/dist/shared/inbox-entry-body.js +116 -0
  245. package/dist/shared/predicates.d.ts +2 -0
  246. package/dist/shared/predicates.js +4 -0
  247. package/dist/shared/working-activity.d.ts +9 -0
  248. package/dist/shared/working-activity.js +27 -0
  249. package/dist/types.d.ts +562 -0
  250. package/dist/types.js +186 -0
  251. package/package.json +46 -5
@@ -0,0 +1,164 @@
1
+ import type { IsoTime, NodeIdDTO } from './common.js';
2
+ export type CronScopeDTO = 'profile' | 'global';
3
+ export type CronOverlapDTO = 'skip' | 'queue' | 'replace';
4
+ export type CronOnOutputDTO = 'silent' | 'on-failure' | 'always' | 'on-change';
5
+ export type CronStateDTO = 'active' | 'paused';
6
+ export type CronRunStateDTO = 'idle' | 'running';
7
+ /** Is this a safe single path segment for `routes.cron*()` interpolation?
8
+ * Cron ids are server-minted UUIDs, but the route builders carry no logic, so
9
+ * every interpolated id is gated here first (the `isSafeNodeId` discipline). */
10
+ export declare function isSafeCronId(id: string): boolean;
11
+ /** The last settled run, carried on every cron projection so `cron list` shows
12
+ * recent health without a `cron show` per row. Null until the first run. */
13
+ export interface CronLastRunDTO {
14
+ /** When the run settled (UTC). */
15
+ finished: IsoTime | null;
16
+ /** -1 = timeout kill; null = no exit observed (process error / skip marker). */
17
+ exit_code: number | null;
18
+ /** What the sink did with the output, or why it didn't. */
19
+ delivered: string | null;
20
+ }
21
+ /** A cron row projection (`GET /v1/crons`). */
22
+ export interface CronDTO {
23
+ cron_id: string;
24
+ /** Agent-legible label; how the cron shows in list. */
25
+ name: string;
26
+ /** Provenance only — the node that armed it, if any; never a cascade anchor. */
27
+ created_by: NodeIdDTO | null;
28
+ /** The bash command each fire runs. */
29
+ command: string;
30
+ /** The grant the cron runs under (checked at every fire, call and birth); null only for the terminal on a runtime with no issuer. */
31
+ grant_id: string | null;
32
+ /** The scopes the cron is bounded to; null = the grant's whole current set (a person-armed terminal cron). */
33
+ scopes: string[] | null;
34
+ /** The run of the node that armed it, when a node did. */
35
+ origin_run_id: string | null;
36
+ /** The shell and any spawned node stay isolated when armed from an isolated node. */
37
+ isolated: boolean;
38
+ /** Next occurrence (UTC). */
39
+ fire_at: IsoTime;
40
+ /** Recur JSON (interval or cron); null for a one-shot. */
41
+ recur: string | null;
42
+ /** IANA zone for a calendar cadence; null otherwise. */
43
+ tz: string | null;
44
+ /** Clock bound; the row is deleted when passed. Null = no bound. */
45
+ expires_at: IsoTime | null;
46
+ /** Opt-in node coupling (cascades on that node's deletion); null = detached. */
47
+ anchor_node: NodeIdDTO | null;
48
+ cancel_on_wake: boolean;
49
+ /** Execution context, snapshotted at arm time. */
50
+ cwd: string;
51
+ profile: string | null;
52
+ scope: CronScopeDTO;
53
+ /** Names of the extra env vars snapshotted onto the row — KEYS ONLY: the
54
+ * values are the caller's to know and may be secrets. */
55
+ env_keys: string[];
56
+ run_timeout_s: number;
57
+ overlap: CronOverlapDTO;
58
+ on_output: CronOnOutputDTO;
59
+ /** Where deliveries go — the raw sink spec (`node:<id>` | `spawn:<kind>` |
60
+ * `human`), or null when the disposition never delivers. */
61
+ sink: string | null;
62
+ tier: string;
63
+ state: CronStateDTO;
64
+ /** True while the row is parked by the exit-75 owed-gate disposition: the
65
+ * last scheduled run declared "owed but not currently eligible", so the
66
+ * occurrence was not spent. A daemon poke re-dues it now; otherwise a
67
+ * recurring row re-checks at its natural `fire_at` slot (the backstop) and
68
+ * a held one-shot waits for a poke until `expires_at` deletes it. `state`
69
+ * stays honest (active|paused) — renderers derive; an active held row must
70
+ * never present as paused. */
71
+ held: boolean;
72
+ run_state: CronRunStateDTO;
73
+ /** Recent health: the most recent settled run, or null if it never ran. */
74
+ last_run: CronLastRunDTO | null;
75
+ created: IsoTime;
76
+ updated: IsoTime;
77
+ }
78
+ /** `GET /v1/crons` query. `profile` is the CALLER's profile, which is what
79
+ * scoping means here: a profile-scoped cron belongs to its profile, a global
80
+ * one is canvas-home-wide. Omitting `profile` means the caller stands outside
81
+ * every profile (a plain shell, or a provenance read such as "which crons did
82
+ * node X arm") and sees the whole canvas home. This is a namespacing
83
+ * boundary between profiles, not a security boundary. */
84
+ export interface ListCronsQuery {
85
+ profile?: string;
86
+ }
87
+ /** Caller identity for the per-cron routes (show/pause/resume/run/cancel).
88
+ * Same rule as `ListCronsQuery`: a cron outside the caller's scope is 404,
89
+ * and an absent profile sees everything. */
90
+ export interface CronScopeQuery {
91
+ profile?: string | null;
92
+ }
93
+ /** Cancellation-only query. `run_id` is set automatically inside a cron run,
94
+ * letting crtrd distinguish a run ending itself from an external cancellation
95
+ * that must terminate an in-flight process. */
96
+ export interface CancelCronQuery extends CronScopeQuery {
97
+ run_id?: string;
98
+ }
99
+ /** One settled run-log entry (`GET /v1/crons/:cronId`, `POST /v1/crons/:cronId/run`). */
100
+ export interface CronRunDTO {
101
+ run_id: string;
102
+ started: IsoTime;
103
+ finished: IsoTime | null;
104
+ duration_ms: number | null;
105
+ /** null = no exit observed (spawn/process error, or a skip marker); -1 = timeout kill. */
106
+ exit_code: number | null;
107
+ stdout_head: string | null;
108
+ stderr_head: string | null;
109
+ /** What the sink did with this run's output, or why it didn't. */
110
+ delivered: string | null;
111
+ }
112
+ /** `POST /v1/crons/poke` — the bare daemon-level eligibility poke. Re-dues
113
+ * every held active cron now; paused rows keep their held state. Idempotent
114
+ * and free when nothing is held. */
115
+ export interface PokeCronsResult {
116
+ /** How many held rows were re-dued — for the caller's log line. */
117
+ unparked: number;
118
+ /** The poke receipt instant (UTC). */
119
+ at: IsoTime;
120
+ }
121
+ /** `GET /v1/crons/:cronId` — one cron with its run-log ring (most recent first). */
122
+ export interface CronShowDTO {
123
+ cron: CronDTO;
124
+ runs: CronRunDTO[];
125
+ }
126
+ /** `POST /v1/crons` — arm one cron. The CLI resolves timing client-side
127
+ * (parseWhen/parseCadence) and sends the settled `fire_at`/`recur`/`tz`;
128
+ * the server mints the cron_id and applies spec defaults for everything
129
+ * omitted. */
130
+ export interface ArmCronRequest {
131
+ name: string;
132
+ command: string;
133
+ fire_at: IsoTime;
134
+ recur?: string | null;
135
+ tz?: string | null;
136
+ created_by?: NodeIdDTO | null;
137
+ isolated?: boolean;
138
+ /** Execution context, snapshotted at arm time — chosen by the client, else
139
+ * inherited from the creating node; never re-resolved at run time. Omitted
140
+ * means the daemon's default: the cron's own folder for an isolated
141
+ * cron, else the app's files directory. A runtime whose cron runs are
142
+ * sandboxed refuses (400 `cwd_not_mounted`) a chosen cwd the run's mounts do
143
+ * not reach, so a cron is never armed with a directory it cannot start in. */
144
+ cwd?: string;
145
+ /** `cwd` is the caller's own current directory rather than a choice. A
146
+ * sandboxed runtime then replaces it with the default when the run cannot
147
+ * reach it, instead of refusing. */
148
+ cwd_is_default?: boolean;
149
+ /** Extra env for every run, as a JSON object of string values. */
150
+ env_json?: string | null;
151
+ profile?: string | null;
152
+ /** `profile` (default when a profile is resolved) requires a profile. */
153
+ scope?: CronScopeDTO;
154
+ on_output?: CronOnOutputDTO;
155
+ /** Raw sink spec: `node:<id>` | `spawn:<kind>` | `human`. Required by the
156
+ * always/on-change dispositions; meaningless otherwise. */
157
+ sink?: string | null;
158
+ tier?: string;
159
+ expires_at?: IsoTime | null;
160
+ anchor_node?: NodeIdDTO | null;
161
+ cancel_on_wake?: boolean;
162
+ run_timeout_s?: number;
163
+ overlap?: CronOverlapDTO;
164
+ }
@@ -0,0 +1,10 @@
1
+ // Cron DTOs (the cron-spec scheduler — arm/list/show/run/pause/resume/cancel).
2
+ /** Is this a safe single path segment for `routes.cron*()` interpolation?
3
+ * Cron ids are server-minted UUIDs, but the route builders carry no logic, so
4
+ * every interpolated id is gated here first (the `isSafeNodeId` discipline). */
5
+ export function isSafeCronId(id) {
6
+ return typeof id === 'string'
7
+ && id !== '' && id !== '.' && id !== '..'
8
+ && !/[\\/\0\s?#%]/u.test(id)
9
+ && Buffer.byteLength(id, 'utf8') <= 128;
10
+ }
@@ -0,0 +1,66 @@
1
+ export interface CustomEventSpecDTO {
2
+ level: number;
3
+ supersedes?: boolean;
4
+ }
5
+ export type CustomReceiverDTO = 'queue' | {
6
+ url: string;
7
+ } | {
8
+ argv: string[];
9
+ cwd: string;
10
+ };
11
+ export interface RegisterCustomObjectRequestDTO {
12
+ kind: string;
13
+ name: string;
14
+ owner?: string;
15
+ description: string;
16
+ events: Record<string, CustomEventSpecDTO>;
17
+ receiver?: CustomReceiverDTO;
18
+ rotate_token?: boolean;
19
+ }
20
+ export interface RegisterCustomObjectResponseDTO {
21
+ id: string;
22
+ name: string;
23
+ token?: string;
24
+ }
25
+ export interface PublishCustomObjectRequestDTO {
26
+ event: string;
27
+ summary: string;
28
+ state?: unknown;
29
+ cause?: string;
30
+ }
31
+ export interface PublishCustomObjectResponseDTO {
32
+ message_id: string | null;
33
+ delivered: number;
34
+ depth: number;
35
+ }
36
+ /** Pending deliveries replay on every connection until acknowledged, regardless of `after`. Blank-line heartbeats arrive every 15 seconds. */
37
+ export interface QueueLineDTO {
38
+ /** Acknowledge this delivery by its delivery_id. */
39
+ delivery_id: string;
40
+ /** The source event id to pass as `publish({ cause: line.message_id })` when reacting. */
41
+ message_id: string;
42
+ /** Durable ordering number, not an acknowledgement checkpoint. */
43
+ seq: number;
44
+ event: string;
45
+ level: number;
46
+ object: {
47
+ id: string;
48
+ type: string;
49
+ name: string;
50
+ owner: string | null;
51
+ };
52
+ actor: string | null;
53
+ attrs: Record<string, unknown>;
54
+ summary?: string;
55
+ state?: unknown;
56
+ pointer?: string;
57
+ depth: number;
58
+ created_at: string;
59
+ }
60
+ export interface AckCustomDeliveriesRequestDTO {
61
+ delivery_ids: string[];
62
+ }
63
+ export interface AckCustomDeliveriesResponseDTO {
64
+ acknowledged: number;
65
+ unknown?: string[];
66
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import type { NodeSubjectDTO } from './nodes.js';
2
+ export type DeliveryActivity = 'boot' | 'system-prompt' | 'compact' | 'persona' | 'file-read' | 'command' | 'pre-command' | 'slash-command' | 'names'
3
+ /** Dry run only: a live node's workspace-open arrives inside its boot. */
4
+ | 'workspace-open'
5
+ /** Dry run only: what reading the document named by `subject` delivers alongside it. */
6
+ | 'document-read';
7
+ export interface DeliveryRequest {
8
+ expected_execution_id?: string;
9
+ activity: DeliveryActivity;
10
+ subject?: string;
11
+ inherited?: boolean;
12
+ dry_run?: boolean;
13
+ subject_override?: Partial<NodeSubjectDTO>;
14
+ }
15
+ /** A node that does not exist, for `POST /v1/delivery/dry-run`. Unset fields
16
+ * come from `node` when one is named, else from defaults. */
17
+ export interface HypotheticalNodeDTO {
18
+ cwd?: string;
19
+ /** Profile id or name; null for no profile. Defaults to the profile pinned to `cwd`. */
20
+ profile?: string | null;
21
+ grantee?: string;
22
+ kind?: string;
23
+ mode?: 'base' | 'orchestrator';
24
+ lifecycle?: 'terminal' | 'resident';
25
+ has_manager?: boolean;
26
+ depth?: number;
27
+ }
28
+ /** `POST /v1/delivery/dry-run` — a person's dry run of one delivery activity,
29
+ * for a live node (`node`), a node that does not exist (`hypothetical`), or a
30
+ * live node dialled away from (both). Writes nothing. */
31
+ export interface DeliveryDryRunRequest {
32
+ activity: DeliveryActivity;
33
+ subject?: string;
34
+ node?: string;
35
+ hypothetical?: HypotheticalNodeDTO;
36
+ subject_override?: Partial<NodeSubjectDTO>;
37
+ }
38
+ /** One resolvable inline memory reference — the broker's `RefMeta`. Metadata
39
+ * only, never the document body or its source path. */
40
+ export interface DeliveryRefDTO {
41
+ name: string;
42
+ kind: 'knowledge' | 'preference';
43
+ scope: 'node' | 'project' | 'profile' | 'user' | 'builtin';
44
+ shortForm: string;
45
+ gatewayVisible: boolean;
46
+ }
47
+ export interface DeliveryCommandDTO {
48
+ name: string;
49
+ command_name: string;
50
+ description: string;
51
+ canonical_body: string;
52
+ execution_body: string;
53
+ }
54
+ export interface DeliveryResponse {
55
+ content: string;
56
+ inherited?: boolean;
57
+ commands?: DeliveryCommandDTO[];
58
+ blocks?: string[];
59
+ execution_body?: string;
60
+ refs?: DeliveryRefDTO[];
61
+ names?: string[];
62
+ plan?: unknown;
63
+ }
64
+ export interface BackgroundedJobRequest {
65
+ command: string;
66
+ job_dir: string;
67
+ log_path: string;
68
+ }
69
+ export interface BackgroundedJobDTO {
70
+ id: string;
71
+ }
@@ -0,0 +1,7 @@
1
+ // Delivery DTOs — `POST /v1/nodes/:id/delivery`, the broker's one route for
2
+ // rule-driven document delivery, plus the backgrounded-job record route.
3
+ //
4
+ // PURITY (spec §3.1): Node built-ins + `src/api/*` only (type-only imports).
5
+ // Never reach into src/core here: the publish-api job compiles this package
6
+ // alone, and core modules pull in workspace packages it does not build.
7
+ export {};
@@ -0,0 +1,135 @@
1
+ import type { ObjectDTO, PrivacyName } from './objects.js';
2
+ export declare const RULE_ON: readonly ["boot", "workspace-open", "file-read", "document-read", "command", "pre-command", "slash-command"];
3
+ export type RuleOnName = typeof RULE_ON[number];
4
+ export declare const RULE_DELIVER: readonly ["name", "preview", "content"];
5
+ export type RuleDeliverName = typeof RULE_DELIVER[number];
6
+ export interface DeliveryRuleDTO {
7
+ on: RuleOnName;
8
+ match?: string[];
9
+ match_frontmatter?: Record<string, unknown>;
10
+ if?: unknown;
11
+ deliver: RuleDeliverName;
12
+ }
13
+ /** The `--owner` value: whose document it is. */
14
+ export type DocOwnerFlag = 'node' | 'user' | 'profile' | `profile:${string}` | 'app' | 'repo' | `repo:${string}`;
15
+ export declare const DOC_KINDS: readonly ["knowledge", "preference"];
16
+ export type DocKindName = typeof DOC_KINDS[number];
17
+ export interface DocWriteRequest {
18
+ name: string;
19
+ body: string;
20
+ preview: string;
21
+ owner?: DocOwnerFlag;
22
+ kind?: DocKindName;
23
+ summary?: string;
24
+ privacy?: PrivacyName;
25
+ rules?: DeliveryRuleDTO[];
26
+ why_it_exists?: string;
27
+ unlisted?: boolean;
28
+ lint_ignore?: string[];
29
+ extensions?: Record<string, Record<string, unknown>>;
30
+ /** The caller's cwd, for `--owner repo` resolution. */
31
+ cwd?: string;
32
+ }
33
+ /** `name` is canonical: `<owner-handle>/<name>`. */
34
+ /** `unresolved_links`: names that match nothing in the writer's view. `remote_links`: names whose
35
+ * first segment is no owner on this runtime — on another runtime, or misspelled. */
36
+ export interface DocLinkReportDTO {
37
+ unresolved_links?: string[];
38
+ remote_links?: string[];
39
+ }
40
+ export interface DocWrittenDTO extends DocLinkReportDTO {
41
+ id: string;
42
+ name: string;
43
+ }
44
+ export declare const DOC_UNSET_FIELDS: readonly ["summary", "why_it_exists", "unlisted", "lint_ignore", "extensions", "rules"];
45
+ export type DocUnsetField = typeof DOC_UNSET_FIELDS[number];
46
+ export interface DocEditRequest {
47
+ body?: string;
48
+ replace?: Array<{
49
+ old: string;
50
+ new: string;
51
+ }>;
52
+ rationale: string;
53
+ /** The heads key the edit was made from. Absent → the caller's last read of the document. */
54
+ base?: string;
55
+ verbatim?: boolean;
56
+ preview?: string;
57
+ summary?: string;
58
+ privacy?: PrivacyName;
59
+ rules?: DeliveryRuleDTO[];
60
+ why_it_exists?: string;
61
+ unlisted?: boolean;
62
+ lint_ignore?: string[];
63
+ extensions?: Record<string, Record<string, unknown>>;
64
+ unset?: DocUnsetField[];
65
+ }
66
+ export interface DocEditedDTO extends DocLinkReportDTO {
67
+ id: string;
68
+ name: string;
69
+ revision: number;
70
+ }
71
+ /** Body of the 409 `stale_revision` error's `details`. */
72
+ export interface DocStaleDTO {
73
+ stale: {
74
+ revision: number;
75
+ heads_key: string;
76
+ };
77
+ }
78
+ export interface DocMoveRequest {
79
+ new_name?: string;
80
+ owner?: DocOwnerFlag;
81
+ cwd?: string;
82
+ }
83
+ export interface DocMovedDTO {
84
+ id: string;
85
+ name: string;
86
+ }
87
+ export interface DocDeletedDTO {
88
+ id: string;
89
+ name: string;
90
+ }
91
+ export interface DocHistoryQuery {
92
+ diff?: number;
93
+ }
94
+ export interface DocRevisionDTO {
95
+ rev_id: string;
96
+ number: number;
97
+ author_id: string | null;
98
+ rationale: string | null;
99
+ verbatim: boolean;
100
+ created_at: string;
101
+ parents: string[];
102
+ }
103
+ export interface DocHistoryDTO {
104
+ object: ObjectDTO;
105
+ revisions: DocRevisionDTO[];
106
+ diff?: string;
107
+ }
108
+ export interface DocLintRequest {
109
+ owner?: DocOwnerFlag;
110
+ cwd?: string;
111
+ }
112
+ export interface DocLintFindingDTO {
113
+ name: string;
114
+ severity: 'error' | 'warning';
115
+ rule: string;
116
+ message: string;
117
+ }
118
+ export interface DocLintDTO {
119
+ findings: DocLintFindingDTO[];
120
+ }
121
+ export interface ReconcilePackagesDTO {
122
+ created: number;
123
+ updated: number;
124
+ deleted: number;
125
+ /** plugins whose handle another owner holds; their documents are not on the canvas */
126
+ conflicts: Array<{
127
+ plugin: string;
128
+ message: string;
129
+ }>;
130
+ /** package files that are not documents (unparseable frontmatter, a name another file holds) */
131
+ invalid: Array<{
132
+ path: string;
133
+ error: string;
134
+ }>;
135
+ }
@@ -0,0 +1,8 @@
1
+ // Document DTOs — the `/v1/docs` write verbs behind `crtr doc`, plus the
2
+ // package-document reconcile route.
3
+ //
4
+ // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
5
+ export const RULE_ON = ['boot', 'workspace-open', 'file-read', 'document-read', 'command', 'pre-command', 'slash-command'];
6
+ export const RULE_DELIVER = ['name', 'preview', 'content'];
7
+ export const DOC_KINDS = ['knowledge', 'preference'];
8
+ export const DOC_UNSET_FIELDS = ['summary', 'why_it_exists', 'unlisted', 'lint_ignore', 'extensions', 'rules'];
@@ -0,0 +1,21 @@
1
+ export type FileEncoding = 'utf8' | 'base64';
2
+ export interface FilePeekDTO {
3
+ path: string;
4
+ content: string;
5
+ truncated: boolean;
6
+ }
7
+ export interface FileWriteDTO {
8
+ path: string;
9
+ bytes_written: number;
10
+ }
11
+ export interface FileEntryDTO {
12
+ name: string;
13
+ type: 'file' | 'dir' | 'other';
14
+ size: number;
15
+ modified: string;
16
+ }
17
+ export interface FileListDTO {
18
+ path: string;
19
+ entries: FileEntryDTO[];
20
+ truncated: boolean;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { NodeIdDTO } from './common.js';
2
+ /** One viewer row: a node's single on-screen pane in a tmux session. */
3
+ export interface FocusDTO {
4
+ focus_id: string;
5
+ pane: string | null;
6
+ session: string | null;
7
+ node_id: NodeIdDTO;
8
+ }
9
+ /** `POST /v1/focuses` body — register a viewer pane as a node's focus row.
10
+ * UNIQUE(node_id): returns the existing row (no insert) when the pane or node
11
+ * is already registered. `window` is accepted for the call contract but not
12
+ * stored (the table keys on pane + session). */
13
+ export interface RegisterFocusRequest {
14
+ node_id: NodeIdDTO;
15
+ pane: string;
16
+ session: string | null;
17
+ window: string | null;
18
+ }
19
+ /** `PATCH /v1/focuses/{focus_id}` body — re-point a viewer row's pane + its
20
+ * derived session cache after the pane moves. */
21
+ export interface SetFocusPaneRequest {
22
+ pane: string | null;
23
+ session: string | null;
24
+ }
@@ -0,0 +1,10 @@
1
+ // Focus DTOs (the viewer registry — canvas.db `focuses` table). A FOCUS is one
2
+ // durable on-screen viewport bound to one node (UNIQUE node_id ⇒ ≤1 per node).
3
+ // The wire shape mirrors the internal `FocusRow` 1:1 — the registry is a flat
4
+ // pane↔node binding with no projection to reshape.
5
+ //
6
+ // The reads GC lazily server-side (a row whose pane is gone is pruned on read),
7
+ // so a returned row is always live. The mutations are the tmux-driven CLI
8
+ // surfaces' (surface-tmux-spread, focus placement) writes: the tmux verbs run
9
+ // LOCALLY in the caller's session; only the canvas.db focus rows route here.
10
+ export {};
@@ -0,0 +1,28 @@
1
+ /** A provider's setup state for the account (directory spec, "Provider setup state"). */
2
+ export type SetupState = 'not_started' | 'pending' | 'ready' | 'failed';
3
+ /** One provider the grantee requires, as the directory's grant sync carried it. */
4
+ export interface ProviderDependency {
5
+ state: SetupState;
6
+ /** The provider's own sentence for `pending` and `failed` (its `message_pending` / `message_failed`); absent for `not_started` and `ready`. */
7
+ message?: string;
8
+ /** Absolute URL of the directory's setup page for this provider and this app (`<issuer>/connect/setup/<provider>?client_id=<grantee>`); the app may append `return_to` (its own registered redirect origin) so Continue brings the person back. */
9
+ next: string;
10
+ }
11
+ export interface GrantGetDTO {
12
+ sub: string;
13
+ grantee: string;
14
+ client_id: string;
15
+ grant: string;
16
+ exp: number;
17
+ rev: number;
18
+ resolved_scopes: {
19
+ scope: string;
20
+ mode: 'always' | 'ask';
21
+ }[];
22
+ spend_cap: number | null;
23
+ payer: 'user';
24
+ /** `{ <provider id>: ProviderDependency }` as the directory's grant sync carried it; `{}` when the grantee has none. The daemon performs no `requires` check: an app follows this with the SDK grant watch (`oauth.watchGrants`, or `grant.get` with `wait`/`since`) and refuses its own operation with `provider_setup_pending`. When an entry's `state` is not `ready`, show its `message` (the provider's own sentence, when it has one) and send the person to its `next` (the directory's setup page) — never copy the provider's prose into the app. */
25
+ dependencies: Record<string, ProviderDependency>;
26
+ /** Opaque; changes exactly when `rev`, `resolved_scopes`, `spend_cap`, `payer` or `dependencies` changes (never on a periodic sync alone or a new token). Pass it back as `since` with `wait` to hold the read until it changes. */
27
+ version: string;
28
+ }
@@ -0,0 +1 @@
1
+ export {};