@north-light/api 0.0.0 → 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 +46 -5
@@ -0,0 +1,371 @@
1
+ import type { Cursor, ExitIntentDTO, IsoTime, LifecycleDTO, ModeDTO, NodeIdDTO, NodeStatusDTO, TerminalReasonDTO } from './common.js';
2
+ import type { ReportDTO } from './reports.js';
3
+ import type { NodeOutcomeDTO, NodeOutcomeSummaryDTO, RegisterOutcomeDeliveryRequest } from './node-outcomes.js';
4
+ import type { FaultLink, FaultKind, FaultRetry, FaultProviderError } from './recovery.js';
5
+ /** `GET /v1/nodes/{id}/subject` — the node-config subject substrate gate
6
+ * predicates evaluate against. Mirrors `NodeConfigSubject`; this narrow
7
+ * endpoint exists so a CLI process (a `crtr canvas read` of a document) can
8
+ * gate-check its delivery rules without reaching canvas state. */
9
+ export interface NodeSubjectDTO {
10
+ kind: string;
11
+ mode: ModeDTO;
12
+ lifecycle: LifecycleDTO;
13
+ hasManager: boolean;
14
+ cwd: string;
15
+ scope: 'user' | 'project';
16
+ orchestration: {
17
+ depth: number;
18
+ };
19
+ profile: string | null;
20
+ /** Effective run scopes; a null row resolves to the full runtime vocabulary. */
21
+ scopes: readonly string[];
22
+ /** Handles of the repos enclosing `cwd`, nearest first. */
23
+ repo: readonly string[];
24
+ }
25
+ /** `POST /v1/nodes` body. Carries the full immediate spawn recipe. */
26
+ export interface CreateNodeRequest {
27
+ /** Persona kind. Omit to resolve the selected profile's `default_kind`, then `general`. */
28
+ kind?: string;
29
+ prompt?: string;
30
+ profile?: string;
31
+ mode?: ModeDTO;
32
+ /** The directory the create came from. It is what the daemon selects a
33
+ * profile from when the request neither names one nor inherits one from a
34
+ * parent, and — for a node with no `pin_cwd` and no spawner to inherit from —
35
+ * where the node lands. */
36
+ cwd?: string;
37
+ /** Pin the node to this exact directory, overriding both the spawner's
38
+ * directory and the launch cwd. See `crtr node new --cwd`. */
39
+ pin_cwd?: string;
40
+ /** Display name (tmux window + resume picker). Defaults to the kind. */
41
+ name?: string;
42
+ /** Caller-supplied short description, preserved against automatic naming. */
43
+ description?: string;
44
+ parent?: NodeIdDTO | null;
45
+ /** Node that created this request; absent for an external process. */
46
+ creator?: NodeIdDTO;
47
+ /** Per-run allow-list. Absent inherits everything. Some scopes are recorded but not enforced in beta: llm, files:<dir>, net, provider groups, and peers. */
48
+ scopes?: string[];
49
+ /** Sticky isolation; a child cannot turn off an isolated run. */
50
+ isolated?: boolean;
51
+ root?: boolean;
52
+ /** Lifecycle of the new node. Roots default to `resident`; managed children
53
+ * default to `terminal`. Use `resident` for a child that remains wakeable
54
+ * without owing a final, or `terminal` for a bounded worker that must
55
+ * finalize. */
56
+ root_lifecycle?: LifecycleDTO;
57
+ /** Worktree branch name, or true for an auto-named managed worktree. */
58
+ worktree?: string | boolean;
59
+ fork_from?: string;
60
+ model?: string;
61
+ situational_context?: string;
62
+ no_kickoff?: boolean;
63
+ output_schema?: string;
64
+ /** Wall-clock bound from spawn, e.g. "45m", "2h", "1h30m". Expiry cancels the node and synthesizes a failure outcome with reason 'deadline_exceeded'. */
65
+ deadline?: string;
66
+ /** Arm outcome delivery atomically with node birth. */
67
+ outcome_delivery?: RegisterOutcomeDeliveryRequest;
68
+ /** Spawn AT this exact node id instead of a runtime-minted one — format-
69
+ * validated and duplicate-rejected server-side (`NodeIdConflictError` →
70
+ * HTTP 409 `node_id_exists`). See `crtr node new --node-id`. */
71
+ node_id?: string;
72
+ /** Opaque key generated once per create attempt. A repeated key returns the
73
+ * node created by its first served request. */
74
+ request_key?: string;
75
+ /** Serve this create from the warm pool when a pre-booted spare matches the
76
+ * request's frozen launch tuple (kind, mode, resolved cwd, profile, model,
77
+ * situational_context) — answering in milliseconds instead of waiting out a
78
+ * full engine boot. Only a bare root with no kickoff qualifies; anything the
79
+ * pool cannot honor (or an empty pool) falls back to an ordinary cold spawn,
80
+ * so the flag never fails a create, it only ever makes it faster. */
81
+ prefer_warm?: boolean;
82
+ }
83
+ /** The list/queryable projection of a node — the indexed row columns. */
84
+ export interface NodeSummaryDTO {
85
+ node_id: NodeIdDTO;
86
+ name: string;
87
+ /** Generated first-task description, absent when the node is not yet named.
88
+ * Paired with `name` it forms the full display label, so a roster consumer
89
+ * builds it without a per-node metadata fetch. */
90
+ description?: string;
91
+ /** How many times the node has been (re)launched; absent on a pre-v38 row. */
92
+ cycles?: number;
93
+ kind: string;
94
+ mode: ModeDTO;
95
+ lifecycle: LifecycleDTO;
96
+ status: NodeStatusDTO;
97
+ cwd: string;
98
+ host_kind: 'tmux' | 'broker' | null;
99
+ profile_id: string | null;
100
+ /** Per-run allow-list; null inherits everything. */
101
+ scopes: string[] | null;
102
+ isolated: boolean;
103
+ /** App that owns this node's agent folder. */
104
+ grantee: string;
105
+ /** Whether the node's profile is currently paused. */
106
+ profile_paused: boolean;
107
+ parent: NodeIdDTO | null;
108
+ created: IsoTime;
109
+ intent: ExitIntentDTO;
110
+ waiting_for: NodeIdDTO | null;
111
+ frozen_at: IsoTime | null;
112
+ terminal_reason: TerminalReasonDTO | null;
113
+ pi_pid: number | null;
114
+ /** Launch-time process identity paired with `pi_pid`, or null when absent. */
115
+ pi_pid_identity: string | null;
116
+ /** Current tmux placement cache. Local tmux callers re-check the pane itself before acting. */
117
+ window: string | null;
118
+ tmux_session: string | null;
119
+ pane: string | null;
120
+ /** Basename of the canonical final report, or null when this node has not finalized. */
121
+ final_report: string | null;
122
+ finalized_at: IsoTime | null;
123
+ deadline_at: IsoTime | null;
124
+ /** Cumulative input tokens reported by the broker telemetry producer. */
125
+ telemetry_tokens_in?: number | null;
126
+ /** Latest context-window token gauge reported by the broker. */
127
+ telemetry_context_tokens?: number | null;
128
+ /** Latest tool summary reported by the broker. */
129
+ telemetry_last_activity?: string | null;
130
+ /** Timestamp of the latest broker telemetry update. */
131
+ telemetry_updated_at?: IsoTime | null;
132
+ outcome: NodeOutcomeSummaryDTO | null;
133
+ fault?: NodeFaultDTO | null;
134
+ streaming?: boolean;
135
+ /** Present only when requested with `include=activity`. */
136
+ activity?: NodeActivityDTO;
137
+ }
138
+ /** Optional per-node activity payload for a list response. Reports are the
139
+ * stored push entries, newest first; `final_report` follows the row's canonical
140
+ * final-report basename rather than merely selecting the newest final-tier file. */
141
+ export interface NodeActivityDTO {
142
+ latest_report: ReportDTO | null;
143
+ final_report: ReportDTO | null;
144
+ pending_human_count: number;
145
+ }
146
+ /** The spine + subscription edges of a node (absorbs `managers`/`paths` reads). */
147
+ export interface NodeEdgesDTO {
148
+ /** Spine parent (my manager); null for a root. */
149
+ parent: NodeIdDTO | null;
150
+ /** Provenance — who spawned me. */
151
+ spawned_by: NodeIdDTO | null;
152
+ /** Publishers I subscribe to. */
153
+ subscribes_to: NodeIdDTO[];
154
+ /** Subscribers to my output (my managers). */
155
+ subscribers: NodeIdDTO[];
156
+ /** Children I spawned. */
157
+ children: NodeIdDTO[];
158
+ }
159
+ /** Absolute filesystem paths for a node (absorbs the `paths` read). */
160
+ export interface NodePathsDTO {
161
+ node_dir: string;
162
+ context_dir: string;
163
+ meta_path: string;
164
+ transcript_path: string;
165
+ view_socket: string;
166
+ }
167
+ /** A node's managed git worktree, if any. */
168
+ export interface NodeWorktreeDTO {
169
+ state: 'open' | 'closed' | 'abandoned';
170
+ /** Pending cleanup must be run manually after the owner exits. */
171
+ cleanup?: 'pending' | 'complete';
172
+ path: string;
173
+ branch: string;
174
+ repo_root: string;
175
+ base_ref: string;
176
+ base_sha: string;
177
+ created: IsoTime;
178
+ closed?: IsoTime;
179
+ abandoned?: {
180
+ branch: string;
181
+ tip_sha: string;
182
+ at: IsoTime;
183
+ by: string;
184
+ };
185
+ }
186
+ /** Immutable companion provenance and fork coordinates. Present only on a
187
+ * daemon-spawned companion node: a `review/companion` node for a human review
188
+ * (`kind` absent or `review`), or — for a page ticket's feedback conversation
189
+ * (`kind: 'page_feedback'`, review_id = ticket id, target_file = the page
190
+ * source) — a fork of the sending node itself, spawned with its kind. */
191
+ export interface NodeReviewBindingDTO {
192
+ kind?: 'review' | 'page_feedback';
193
+ review_id: string;
194
+ origin_node_id: string;
195
+ branch_file: string;
196
+ target_file: string;
197
+ }
198
+ /** The active fault projection shown by node inspection. */
199
+ export interface NodeFaultDTO {
200
+ link: FaultLink;
201
+ op: string;
202
+ kind: FaultKind;
203
+ retry: FaultRetry;
204
+ message: string;
205
+ since: IsoTime;
206
+ operation_id: string;
207
+ anchorEntryId?: string;
208
+ providerError?: FaultProviderError;
209
+ }
210
+ /** The full node view — summary ∪ identity extras ∪ edges ∪ paths. Returned by
211
+ * `GET /v1/nodes/{id}` and by the create/lifecycle actions that yield a node. */
212
+ export interface NodeDetailDTO extends Omit<NodeSummaryDTO, 'outcome'> {
213
+ outcome: NodeOutcomeDTO | null;
214
+ /** Node that created this node, or null when an external process did. */
215
+ creator: NodeIdDTO | null;
216
+ /** The namer's prose form of `description` — sentence case, punctuation intact
217
+ * (`NodeMeta.title`). What a surface showing this node to a person reads;
218
+ * absent on a node named before titles existed. */
219
+ title?: string;
220
+ /** The Nerd Font glyph the namer chose for this node's work, when it has one
221
+ * (`NodeMeta.icon`). Rendered ahead of the label by surfaces that want it. */
222
+ icon?: string;
223
+ /** Approximate context-window token load of the node's live/last session,
224
+ * used by the orchestrator yield-nudge (`childFollowUp`). Null when unknown
225
+ * (never launched, or no token accounting yet). */
226
+ context_tokens?: number | null;
227
+ pi_session_id?: string | null;
228
+ /** The node's durable model override (`NodeMeta.model_override`), or null when
229
+ * it runs on the kind/profile default. Surfaced so `node config --model`
230
+ * can report the resolved model after a patch. */
231
+ model_override?: string | null;
232
+ /** Absolute path to pi's session `.jsonl`, captured at session_start
233
+ * (`NodeMeta.pi_session_file`). Distinct from `paths.transcript_path` (the
234
+ * crtr-owned transcript mirror). Used to resume or fork the node's pi session
235
+ * and shown by the Inspector. */
236
+ pi_session_file?: string | null;
237
+ /** Immutable review-companion provenance — present only on nodes of kind
238
+ * `review/companion`. Four fields capture the invocation-time fork
239
+ * coordinates without duplicating the full review record. */
240
+ review_binding?: NodeReviewBindingDTO | null;
241
+ edges: NodeEdgesDTO;
242
+ paths: NodePathsDTO;
243
+ worktree?: NodeWorktreeDTO | null;
244
+ /** Present only on a `POST /promote` response — the roadmap/goal facts the
245
+ * promote primitive returns beyond the node meta (spec §6.2). A plain detail
246
+ * read omits them. */
247
+ roadmap_written?: boolean;
248
+ /** The node's roadmap document ref (`<node>/roadmap`). */
249
+ roadmap_ref?: string;
250
+ goal_path?: string;
251
+ }
252
+ /** `GET /v1/nodes` optional payloads. */
253
+ export type NodeListInclude = 'activity';
254
+ /** `GET /v1/nodes` query filters. Filters compose; `parent` selects direct
255
+ * children while `under` selects a whole subtree. */
256
+ export interface ListNodesQuery {
257
+ status?: NodeStatusDTO;
258
+ lifecycle?: LifecycleDTO;
259
+ kind?: string;
260
+ mode?: ModeDTO;
261
+ /** Exact profile id. */
262
+ profile_id?: string;
263
+ /** Profile-id prefix, for callers that own a namespaced profile family. */
264
+ profile_prefix?: string;
265
+ /** Restrict to direct children of this node. Mutually exclusive with `top_level`. */
266
+ parent?: NodeIdDTO;
267
+ /** Restrict to nodes without a parent. */
268
+ top_level?: boolean;
269
+ /** Restrict to the subtree under this node. */
270
+ under?: NodeIdDTO;
271
+ /** Only nodes with a dangling/hanging manager edge. */
272
+ hanging?: boolean;
273
+ /** Opt into richer per-node payloads that require filesystem reads. */
274
+ include?: NodeListInclude;
275
+ }
276
+ /** `GET /v1/nodes/{id}/snapshot` — the node's reconstructed broker snapshot
277
+ * (`readNodeSnapshot`): the message log, aggregate stats, and current engine
278
+ * state, plus the node's registered command set. */
279
+ export interface NodeSnapshotDTO {
280
+ node_id: NodeIdDTO;
281
+ snapshot: {
282
+ messages: unknown[];
283
+ messageIds?: string[];
284
+ messageVisibility: Array<'visible' | 'internal'>;
285
+ turnVisibility: 'visible' | 'internal';
286
+ stats: unknown;
287
+ state: Record<string, unknown>;
288
+ display: {
289
+ statuses: Record<string, string>;
290
+ widgets: Record<string, {
291
+ lines: string[];
292
+ placement: 'aboveEditor' | 'belowEditor';
293
+ }>;
294
+ title?: string;
295
+ };
296
+ queued?: {
297
+ steering: string[];
298
+ followUp: string[];
299
+ };
300
+ toolGroupSummaries?: Record<string, unknown>;
301
+ workingActivity?: string;
302
+ };
303
+ commands: {
304
+ name: string;
305
+ description: string;
306
+ source: string;
307
+ }[];
308
+ captured_at: IsoTime;
309
+ }
310
+ /** `GET /v1/nodes/{id}/messages` query. `cursor` walks backward from the
311
+ * newest messages; each returned page remains chronological. */
312
+ export interface NodeMessagesQuery {
313
+ cursor?: Cursor;
314
+ limit?: number;
315
+ }
316
+ /** `GET /v1/nodes/{id}/messages` — a backward-paged window over the node's
317
+ * cycle-flattened visible history. */
318
+ export interface NodeMessagesPageDTO {
319
+ node_id: NodeIdDTO;
320
+ /** pi AgentMessage[] JSON, chronological ascending within this page. */
321
+ messages: unknown[];
322
+ /** Stable session-entry ids aligned 1:1 with `messages`. */
323
+ message_ids?: string[];
324
+ /** Presentation visibility aligned 1:1 with `messages`. */
325
+ message_visibility: Array<'visible' | 'internal'>;
326
+ /** Opaque cursor toward older messages; null at the start of the session. */
327
+ next_cursor: Cursor | null;
328
+ captured_at: IsoTime;
329
+ }
330
+ /** `GET /v1/nodes/{id}/session` — the node's conversation exactly as it ran:
331
+ * the raw session `.jsonl` bytes plus the assembled system prompt. Unlike
332
+ * `NodeSnapshotDTO` nothing is reconstructed or flattened, so every
333
+ * session-tree entry, cycle, branch, and custom message role survives. This is
334
+ * what an export/download wants; `/snapshot` is what a renderer wants. */
335
+ export interface NodeSessionDTO {
336
+ node_id: NodeIdDTO;
337
+ /** Absolute path (inside the node's host) of the file the bytes came from. */
338
+ session_file: string;
339
+ /** Verbatim `.jsonl` contents. */
340
+ session_jsonl: string;
341
+ /** Assembled system prompt as last captured, or `null` if never written. */
342
+ system_prompt: string | null;
343
+ captured_at: IsoTime;
344
+ }
345
+ /** `GET /v1/nodes/{id}/transcript` query. */
346
+ export interface TranscriptQuery {
347
+ limit?: number;
348
+ cursor?: Cursor;
349
+ }
350
+ /** `GET /v1/nodes/{id}/transcript` result. The reader (`transcriptMarkdown`)
351
+ * renders the whole conversation as a single markdown document. */
352
+ export interface TranscriptDTO {
353
+ node_id: NodeIdDTO;
354
+ markdown: string;
355
+ }
356
+ /** One context root visible to a node — its own dir plus each publisher it
357
+ * subscribes to (the shared-document roster). */
358
+ export interface ContextRootDTO {
359
+ node_id: NodeIdDTO;
360
+ label: string;
361
+ dir: string;
362
+ /** True for the node's own context root. */
363
+ self: boolean;
364
+ /** Count of context files plus report documents for the root. */
365
+ files: number;
366
+ }
367
+ /** `GET /v1/nodes/{id}/context` result (the listing; the nvim popup stays local). */
368
+ export interface ContextListDTO {
369
+ node_id: NodeIdDTO;
370
+ roots: ContextRootDTO[];
371
+ }
@@ -0,0 +1,3 @@
1
+ // Node resource DTOs (spec §6.2): create request, summary/detail projections,
2
+ // list query, and the node read-endpoint shapes.
3
+ export {};
@@ -0,0 +1,172 @@
1
+ export declare const PRIVACY_LEVELS_DTO: readonly ["public", "friends", "private"];
2
+ export type PrivacyName = typeof PRIVACY_LEVELS_DTO[number];
3
+ export type OwnerTypeName = 'person' | 'app' | 'repo' | 'profile' | 'node' | 'document' | 'job';
4
+ export interface ObjectOwnerDTO {
5
+ id: string;
6
+ type: OwnerTypeName;
7
+ handle: string;
8
+ }
9
+ export interface ObjectDTO {
10
+ id: string;
11
+ /** The object's kind name: `document`, `node`, `job`, `person`, `app`, `repo`, `profile`, or a later kind. */
12
+ type: string;
13
+ kind: string | null;
14
+ owner: ObjectOwnerDTO | null;
15
+ privacy: PrivacyName;
16
+ name: string;
17
+ preview: string;
18
+ created_at: string;
19
+ deleted_at: string | null;
20
+ }
21
+ export interface DocHeadDTO {
22
+ rev_id: string;
23
+ number: number;
24
+ author_id: string | null;
25
+ created_at: string;
26
+ }
27
+ /** Optional document fields a `--fields` read returns. */
28
+ export interface DocFieldsDTO {
29
+ why_it_exists?: string | null;
30
+ unlisted?: boolean;
31
+ lint_ignore?: string[];
32
+ extensions?: Record<string, Record<string, unknown>>;
33
+ rules?: import('./docs.js').DeliveryRuleDTO[];
34
+ }
35
+ /** `data` of a document read. */
36
+ export interface DocumentReadData {
37
+ summary: string | null;
38
+ revision: number;
39
+ heads: DocHeadDTO[];
40
+ /** One body per head, in `heads` order. */
41
+ bodies: string[];
42
+ needs_merge: boolean;
43
+ /** Documents named under it, then the documents it links to not already in your context at preview, each once. */
44
+ listing?: ObjectDTO[];
45
+ /** One `<auto-loaded-context>` block: enclosing listings and documents the read's `document-read` rules delivered. */
46
+ attachments?: string;
47
+ fields?: DocFieldsDTO;
48
+ }
49
+ /** `data` of a node read. */
50
+ export interface NodeReadData {
51
+ status: string;
52
+ mandate_first_line: string;
53
+ children: ObjectDTO[];
54
+ owned: ObjectDTO[];
55
+ jobs: ObjectDTO[];
56
+ }
57
+ /** `data` of a job read. */
58
+ export interface JobReadData {
59
+ command: string;
60
+ status: string;
61
+ exit_code: number | null;
62
+ log_path: string;
63
+ }
64
+ /** `data` of a person, app, repo or profile read. */
65
+ export interface OwnerReadData {
66
+ handle: string;
67
+ display_name: string;
68
+ identity: {
69
+ scheme: string;
70
+ external_id: string;
71
+ };
72
+ }
73
+ /** A live object: `text` is exactly what `crtr canvas read` prints; `data` holds the kind's
74
+ * structured fields (for the built-in kinds, the `*ReadData` shapes above). */
75
+ export interface ObjectLiveReadDTO {
76
+ state: 'object';
77
+ type: string;
78
+ object: ObjectDTO;
79
+ text: string;
80
+ data: Record<string, unknown>;
81
+ }
82
+ /** A pointer to a deleted object resolves to that object (§8); an answer, not an error. */
83
+ export interface ObjectDeletedDTO {
84
+ state: 'deleted';
85
+ deleted: ObjectDTO;
86
+ }
87
+ /** The name's first segment is no handle on this runtime; the object may live on another runtime. */
88
+ export interface ObjectRemoteDTO {
89
+ state: 'remote';
90
+ remote: string;
91
+ }
92
+ export type ObjectReadDTO = ObjectLiveReadDTO | ObjectDeletedDTO | ObjectRemoteDTO;
93
+ export interface ObjectReadQuery {
94
+ fields?: boolean;
95
+ }
96
+ export interface ObjectListRequest {
97
+ /** A kind name. */
98
+ type?: string;
99
+ kind?: string;
100
+ /** An owner ref (name or id). */
101
+ owner?: string;
102
+ privacy?: PrivacyName;
103
+ /** Name prefix. */
104
+ name?: string;
105
+ deleted?: boolean;
106
+ limit?: number;
107
+ cursor?: string;
108
+ }
109
+ export interface ObjectListItemDTO extends ObjectDTO {
110
+ summary?: string | null;
111
+ /** A document's rule count. */
112
+ rules?: number;
113
+ }
114
+ export interface ObjectListDTO {
115
+ items: ObjectListItemDTO[];
116
+ next_cursor: string | null;
117
+ }
118
+ export interface ObjectSearchRequest {
119
+ text: string;
120
+ body?: boolean;
121
+ grep?: string;
122
+ /** A kind name. */
123
+ type?: string;
124
+ kind?: string;
125
+ owner?: string;
126
+ limit?: number;
127
+ }
128
+ export interface ObjectSearchHitDTO {
129
+ object: ObjectListItemDTO;
130
+ matches?: Array<{
131
+ line: number;
132
+ text: string;
133
+ }>;
134
+ }
135
+ export interface ObjectSearchDTO {
136
+ items: ObjectSearchHitDTO[];
137
+ }
138
+ export type ListenDeliveryName = 'interrupt' | 'steer' | 'after-turn' | 'next-turn';
139
+ /** `{"<level 1-10>": delivery}` */
140
+ export type ListenConfigDTO = Record<string, ListenDeliveryName>;
141
+ export interface WatchRequest {
142
+ patterns?: string[];
143
+ config?: ListenConfigDTO;
144
+ filter?: Record<string, unknown>;
145
+ watcher?: string;
146
+ }
147
+ export interface UnwatchQuery {
148
+ pattern?: string;
149
+ watcher?: string;
150
+ }
151
+ export interface WatchResultDTO {
152
+ object: ObjectDTO;
153
+ patterns: string[];
154
+ }
155
+ export interface UnwatchResultDTO {
156
+ object: ObjectDTO;
157
+ removed: number;
158
+ }
159
+ export type EdgeTypeName = 'acted-on' | 'links-to' | 'watches';
160
+ export interface EdgesQuery {
161
+ type?: EdgeTypeName;
162
+ direction?: 'out' | 'in';
163
+ }
164
+ export interface EdgeDTO {
165
+ type: EdgeTypeName;
166
+ src: ObjectDTO;
167
+ dst: ObjectDTO;
168
+ written_as?: string;
169
+ }
170
+ export interface EdgesDTO {
171
+ items: EdgeDTO[];
172
+ }
@@ -0,0 +1,5 @@
1
+ // Canvas object DTOs — the `/v1/objects` shared verbs (read, list, search,
2
+ // watch, unwatch, edges) over documents, nodes, jobs and owners.
3
+ //
4
+ // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
5
+ export const PRIVACY_LEVELS_DTO = ['public', 'friends', 'private'];
@@ -0,0 +1,117 @@
1
+ /** The disclosure ladder, lowest to highest. Index order is the ordering. */
2
+ export declare const PROFILE_PROJECT_MEMORY_VALUES: readonly ["none", "name", "preview", "content"];
3
+ /** How much of an owner's documents automatic delivery may disclose. */
4
+ export type ProfileProjectMemory = (typeof PROFILE_PROJECT_MEMORY_VALUES)[number];
5
+ /** One project directory in a profile's purview. */
6
+ export interface ProfileProject {
7
+ /** Absolute, real-path-resolved directory. */
8
+ path: string;
9
+ }
10
+ /** Per-owner cap on automatic `boot` and `workspace-open` delivery, keyed by
11
+ * owner handle (repo, profile, app, `user`, plugin). An absent owner is
12
+ * uncapped (`content`); a node's own documents are never capped. */
13
+ export type DeliveryLimits = Record<string, ProfileProjectMemory>;
14
+ /** `PUT /v1/profiles/{name}` body — idempotent ensure. Every field applies
15
+ * only at create; an existing same-named profile is returned untouched. */
16
+ export interface EnsureProfileRequest {
17
+ /** Project directories in the profile's purview. */
18
+ projects?: ProfileProject[];
19
+ /** Persona kind for node creates under the profile that omit kind. */
20
+ default_kind?: string;
21
+ /** Profile facts (identity, role); each entry reaches every broker
22
+ * launched under the profile as `CRTR_PROFILE_META_<KEY>` env. */
23
+ metadata?: Record<string, string>;
24
+ }
25
+ /** `POST /v1/profiles` body — create a profile of the caller's app. A name the
26
+ * caller's app already holds is refused. */
27
+ export interface CreateProfileRequest extends EnsureProfileRequest {
28
+ name: string;
29
+ }
30
+ /** `PATCH /v1/profiles/{name}` body — each present field changes one fact of a
31
+ * profile the caller's app holds. */
32
+ export interface UpdateProfileRequest {
33
+ name?: string;
34
+ default_kind?: string;
35
+ /** Append a project; a path already listed is left in place. */
36
+ add_project?: ProfileProject;
37
+ /** Set the automatic delivery limit for one owner handle; `content` removes it. */
38
+ set_delivery_limit?: {
39
+ owner: string;
40
+ level: ProfileProjectMemory;
41
+ };
42
+ /** Remove the project at this path; the directory need not still exist. */
43
+ remove_project?: string;
44
+ }
45
+ /** `GET /v1/profiles/{name}/env` — stored env var names, never values. */
46
+ export interface ProfileEnvNamesDTO {
47
+ profile_id: string;
48
+ names: string[];
49
+ }
50
+ /** `PUT /v1/profiles/{name}/env/{var}` body. */
51
+ export interface SetProfileEnvRequest {
52
+ value: string;
53
+ }
54
+ /** `PUT` / `DELETE /v1/profiles/{name}/env/{var}` result. */
55
+ export interface ProfileEnvChangeDTO {
56
+ profile_id: string;
57
+ /** PUT: the name was newly added. DELETE: a stored value was removed. */
58
+ changed: boolean;
59
+ }
60
+ /** `PATCH /v1/profiles/{name}/metadata` body. Merges `set` and removes `unset`. */
61
+ export interface UpdateProfileMetadataRequest {
62
+ set?: Record<string, string>;
63
+ unset?: string[];
64
+ }
65
+ /** The daemon-owned result of pausing or resuming one profile. */
66
+ export interface ProfilePauseResultDTO {
67
+ profile_id: string;
68
+ paused_at: string | null;
69
+ }
70
+ /** `DELETE /v1/profiles/{name}` body. Destructive deletion is never implicit. */
71
+ export interface DeleteProfileRequest {
72
+ force: boolean;
73
+ /** Preserve nodes and human history while removing their profile identity. */
74
+ detach?: boolean;
75
+ /** The invoking broker, when the request came from a node-owned CLI process. */
76
+ caller_node_id?: string | null;
77
+ }
78
+ export type DeleteProfileMode = 'deleted' | 'detached';
79
+ /** The completed deletion, or the accepted plan when the invoking node is part of it. */
80
+ export interface DeleteProfileResultDTO {
81
+ profile_id: string;
82
+ name: string;
83
+ mode: DeleteProfileMode;
84
+ nodes: number;
85
+ crons: number;
86
+ tickets: number;
87
+ reviews: number;
88
+ default_pins: number;
89
+ /** True only when crtrd acknowledged the response before tearing down its caller. */
90
+ accepted?: true;
91
+ grace_ms?: number;
92
+ }
93
+ /** A profile projection. */
94
+ export interface ProfileDTO {
95
+ /** Stable profile-directory id (`<slug>-<id>`). */
96
+ id: string;
97
+ /** Owning app, including for profiles shared with the caller. */
98
+ app: string;
99
+ name: string;
100
+ projects: ProfileProject[];
101
+ /** Per-owner delivery caps; empty when the profile sets none. */
102
+ delivery_limits: DeliveryLimits;
103
+ /** ISO timestamp when the profile was paused, or null while active. */
104
+ paused_at: string | null;
105
+ /** Default node kind when a create omits kind; `general` when absent on the manifest. */
106
+ default_kind: string;
107
+ /** Stored profile facts; empty when the manifest carries none. */
108
+ metadata: Record<string, string>;
109
+ /** The directory this profile is pinned as default for, if any. */
110
+ default_dir?: string | null;
111
+ /** ISO timestamp the profile was created. */
112
+ created_at: string;
113
+ /** ISO timestamp of the most recent selection, or null if never selected. */
114
+ last_used_at: string | null;
115
+ /** Absolute path of the profile's directory under its app's space (the legacy location of its pre-canvas markdown; the profile's documents live in the canvas). */
116
+ memory_path: string;
117
+ }
@@ -0,0 +1,4 @@
1
+ // Profile DTOs (spec §6.6). Profile deletion crosses profile, canvas, cron,
2
+ // inbox, and review state, so every consumer routes it through crtrd.
3
+ /** The disclosure ladder, lowest to highest. Index order is the ordering. */
4
+ export const PROFILE_PROJECT_MEMORY_VALUES = ['none', 'name', 'preview', 'content'];