@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,104 @@
1
+ export type FaultLink = 'pi→provider' | 'viewer↔broker' | 'relay↔broker' | 'viewer↔crtrd' | 'daemon→node' | 'crtr→pi';
2
+ export type FaultKind = 'rate-limit' | 'overloaded' | 'connection' | 'auth' | 'protocol' | 'context-overflow' | 'other' | 'wedged' | 'model-not-found';
3
+ export interface FaultRetry {
4
+ disposition: 'auto' | 'manual' | 'fatal';
5
+ by?: 'sdk' | 'daemon' | 'client';
6
+ attempt?: number;
7
+ max?: number;
8
+ nextAt?: string;
9
+ }
10
+ export interface FaultProviderError {
11
+ provider: string;
12
+ model: string;
13
+ status?: number;
14
+ code?: string | number;
15
+ errno?: string;
16
+ body?: string;
17
+ causes?: Array<{
18
+ message?: string;
19
+ status?: number;
20
+ code?: string | number;
21
+ errno?: string;
22
+ body?: string;
23
+ }>;
24
+ ratelimit?: {
25
+ scope?: string;
26
+ claim?: string;
27
+ account?: string;
28
+ model?: string;
29
+ headers: Record<string, string>;
30
+ };
31
+ }
32
+ export interface RecoveryFaultDTO {
33
+ fault_id: string;
34
+ link: FaultLink;
35
+ op: string;
36
+ kind: FaultKind;
37
+ retry: FaultRetry;
38
+ message: string;
39
+ since: string;
40
+ operation_id: string;
41
+ anchor_entry_id?: string;
42
+ provider_error?: FaultProviderError;
43
+ }
44
+ export interface ExecutionExitDiagnosticDTO {
45
+ schema: 'crtr.execution-exit-diagnostic/v1';
46
+ transport_poison: {
47
+ consecutive_passes: number;
48
+ routes: string[];
49
+ };
50
+ }
51
+ export interface BrokerTurnResultDTO {
52
+ applied: boolean;
53
+ fault_link: FaultLink | null;
54
+ }
55
+ export interface BrokerTurnRequest {
56
+ expected_execution_id: string;
57
+ event: 'started' | 'progress' | 'closed' | 'interrupted' | 'exit-diagnostic';
58
+ end_reason?: 'settled' | 'teardown-aborted';
59
+ exit_diagnostic?: ExecutionExitDiagnosticDTO;
60
+ }
61
+ export interface BrokerFaultInputDTO {
62
+ link: FaultLink;
63
+ op: string;
64
+ kind: FaultKind;
65
+ retry: FaultRetry;
66
+ message: string;
67
+ operation_id?: string;
68
+ since?: string;
69
+ anchor_entry_id?: string;
70
+ provider_error?: FaultProviderError;
71
+ }
72
+ export interface BrokerFaultResultDTO {
73
+ fault: RecoveryFaultDTO | null;
74
+ }
75
+ export interface BrokerFaultRequest {
76
+ expected_execution_id: string;
77
+ op: 'record' | 'clear';
78
+ link?: FaultLink;
79
+ preserve_episode?: boolean;
80
+ input?: BrokerFaultInputDTO;
81
+ }
82
+ export interface BrokerProviderRetryResultDTO {
83
+ applied: boolean;
84
+ episode: RecoveryStateDTO['episode'];
85
+ }
86
+ export interface BrokerProviderRetryRequest {
87
+ expected_execution_id: string;
88
+ op: 'record-pending' | 'admit' | 'reopen' | 'invalidate' | 'clear';
89
+ session_id: string;
90
+ fault_id?: string;
91
+ retry?: FaultRetry;
92
+ input?: BrokerFaultInputDTO;
93
+ }
94
+ export interface RecoveryStateDTO {
95
+ fault: RecoveryFaultDTO | null;
96
+ episode: {
97
+ state: 'pending' | 'admitted' | 'invalidated';
98
+ session_id: string | null;
99
+ fault: RecoveryFaultDTO;
100
+ } | null;
101
+ }
102
+ export interface NodeFaultClearResultDTO {
103
+ cleared: boolean;
104
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ import type { IsoTime, NodeIdDTO } from './common.js';
2
+ /** Report kind — `crtr push {update,final}`; legacy `urgent` rows remain readable. */
3
+ export type ReportTierDTO = 'update' | 'urgent' | 'final';
4
+ /** Delivery urgency for an update report's subscriber fan-out. */
5
+ export type ReportDeliveryTierDTO = 'deferred' | 'normal' | 'urgent';
6
+ /** `POST /v1/nodes/{id}/reports` body ({id} = the reporting node).
7
+ * `tier` is the stored report kind; `delivery_tier` is the optional inbox
8
+ * delivery urgency for an update's subscriber fan-out. */
9
+ export interface PushReportRequest {
10
+ tier: ReportTierDTO;
11
+ delivery_tier?: ReportDeliveryTierDTO;
12
+ body: string;
13
+ }
14
+ /** Result of a push. `transitioned` is present only for `final`, which drives a
15
+ * server-side lifecycle transition. */
16
+ export interface PushReportResultDTO {
17
+ /** The written report document's ref, `<node-id>/reports/<name>`. */
18
+ report: string;
19
+ /** Subscriber node ids that received an inbox entry. */
20
+ notified: NodeIdDTO[];
21
+ transitioned?: {
22
+ from: string;
23
+ to: string;
24
+ };
25
+ /** Present (and true) only for a `final` push that closes the reporting
26
+ * node's managed-worktree record without `node worktree close`. An existing
27
+ * checkout must be clean with its tip contained in the local base and stays
28
+ * pending cleanup; a missing checkout must be proven delivered. Work not
29
+ * proven delivered blocks with an `open_managed_worktree` error. */
30
+ worktree_auto_dropped?: boolean;
31
+ /** Present only alongside `worktree_auto_dropped`: the closed managed-worktree path; an existing checkout remains until pending cleanup. */
32
+ worktree_auto_dropped_path?: string;
33
+ }
34
+ /** Why a node declined a structured result. `reason` is one plain sentence
35
+ * for a reader; `code` is an opaque token the requester classifies on and
36
+ * validates itself — crouter only carries it; `retryable` is the node's
37
+ * claim that the same request could succeed later. */
38
+ export interface DeclinedResultDTO {
39
+ reason: string;
40
+ code: string;
41
+ retryable: boolean;
42
+ }
43
+ /** `POST /v1/nodes/{id}/result` body ({id} = the submitting node). `request_id`
44
+ * identifies the pending structured request. Either `value` is validated
45
+ * against that request's schema — any JSON value (including null) is legal
46
+ * input — or a decline carries the reason sentence, requester-classified
47
+ * code, and retry claim. A decline records a `failure` outcome with reason
48
+ * `declined` carrying all three and clears the request without validating
49
+ * anything. */
50
+ export type SubmitResultRequest = {
51
+ request_id: string;
52
+ } & ({
53
+ value: unknown;
54
+ } | {
55
+ decline: string;
56
+ code: string;
57
+ retryable: boolean;
58
+ });
59
+ /** Result of a structured-result submission (`crtr push result`). Terminal
60
+ * mode reuses the final-push machinery, so `transitioned` and the managed-worktree
61
+ * closure fields carry the same meaning as on PushReportResultDTO. */
62
+ export interface SubmitResultDTO {
63
+ /** Which request this answered: `terminal` finished the node; `oneoff` left it working. */
64
+ mode: 'terminal' | 'oneoff';
65
+ /** Absolute path of the recorded artifact: context/result.json for an
66
+ * answered request, context/declined.json for a declined one. */
67
+ result_path: string;
68
+ /** Present only when the request was declined. */
69
+ declined?: DeclinedResultDTO;
70
+ /** Ref of the report document pushed alongside the result, `<node-id>/reports/<name>`. */
71
+ report: string;
72
+ /** Subscriber node ids that received an inbox entry. */
73
+ notified: NodeIdDTO[];
74
+ transitioned?: {
75
+ from: string;
76
+ to: string;
77
+ };
78
+ worktree_auto_dropped?: boolean;
79
+ worktree_auto_dropped_path?: string;
80
+ }
81
+ /** `GET /v1/nodes/{id}/reports` query filters. */
82
+ export interface ReportsQuery {
83
+ tier?: ReportTierDTO;
84
+ limit?: number;
85
+ }
86
+ /** A single stored report document. */
87
+ export interface ReportDTO {
88
+ /** Document name under the node, `reports/<compact-ts>-<uuid8>-<kind>`. */
89
+ name: string;
90
+ /** Document object id. */
91
+ id: string;
92
+ tier: ReportTierDTO;
93
+ body: string;
94
+ created: IsoTime;
95
+ }
@@ -0,0 +1,2 @@
1
+ // Push / report DTOs (spec §7.4).
2
+ export {};
@@ -0,0 +1,146 @@
1
+ import type { IsoTime, NodeIdDTO } from './common.js';
2
+ export type ReviewCommentStatusDTO = 'open' | 'resolved' | 'deleted';
3
+ export type ReviewCommentDeliverDTO = 'wake' | 'quiet';
4
+ export type ReviewCommentAnchorStateDTO = 'live' | 'detached';
5
+ /** Caller-supplied source location for a comment or range remap. */
6
+ export interface ReviewCommentAnchorDTO {
7
+ line: number;
8
+ end_line: number;
9
+ col_start?: number;
10
+ col_end?: number;
11
+ quote?: string;
12
+ }
13
+ /** Daemon-derived current comment projection. */
14
+ export interface ReviewCommentDTO {
15
+ comment_id: string;
16
+ review_id: string;
17
+ status: ReviewCommentStatusDTO;
18
+ revision: number;
19
+ text: string;
20
+ anchor: ReviewCommentAnchorDTO;
21
+ anchor_state: ReviewCommentAnchorStateDTO;
22
+ anchor_line_text: string;
23
+ anchor_doc_hash: string;
24
+ author: {
25
+ kind: 'human' | 'node';
26
+ node_id?: NodeIdDTO;
27
+ };
28
+ updated_by: {
29
+ kind: 'human' | 'node';
30
+ node_id?: NodeIdDTO;
31
+ };
32
+ created_at: IsoTime;
33
+ updated_at: IsoTime;
34
+ resolved_at?: IsoTime;
35
+ deleted_at?: IsoTime;
36
+ created_seq: number;
37
+ }
38
+ /** Caller-supplied body for comment creation. `doc_hash` is supplied by a rendered terminal surface; agent CLI creation omits it and the daemon verifies its current coordinate base instead. */
39
+ export interface CreateReviewCommentRequest {
40
+ text: string;
41
+ anchor: ReviewCommentAnchorDTO;
42
+ doc_hash?: string;
43
+ actor_node_id?: NodeIdDTO | null;
44
+ deliver?: ReviewCommentDeliverDTO;
45
+ }
46
+ /** Caller-supplied body for comment text changes. */
47
+ export interface EditReviewCommentRequest {
48
+ text: string;
49
+ actor_node_id?: NodeIdDTO | null;
50
+ deliver?: ReviewCommentDeliverDTO;
51
+ if_revision?: number;
52
+ }
53
+ /** Caller-supplied body for comment state changes. */
54
+ export interface ReviewCommentActionRequest {
55
+ actor_node_id?: NodeIdDTO | null;
56
+ deliver?: ReviewCommentDeliverDTO;
57
+ if_revision?: number;
58
+ }
59
+ /** Daemon-derived best-effort companion-notification result. */
60
+ export interface ReviewCommentDeliveryDTO {
61
+ attempted: boolean;
62
+ target_node_id?: NodeIdDTO;
63
+ status: 'delivered' | 'skipped' | 'failed';
64
+ via?: 'engine' | 'inbox';
65
+ woke: boolean;
66
+ reason?: 'capacity_frozen';
67
+ error?: string;
68
+ }
69
+ /** Daemon-derived result of one comment mutation. */
70
+ export interface ReviewCommentMutationDTO {
71
+ comment: ReviewCommentDTO;
72
+ changed: boolean;
73
+ delivery?: ReviewCommentDeliveryDTO;
74
+ }
75
+ /** Caller-supplied filter for a review's comment projection. */
76
+ export interface ListReviewCommentsQuery {
77
+ status?: ReviewCommentStatusDTO | 'all';
78
+ actor_node_id?: NodeIdDTO | null;
79
+ }
80
+ /** Daemon-derived comment list. */
81
+ export interface ReviewCommentListDTO {
82
+ review_id: string;
83
+ comments: ReviewCommentDTO[];
84
+ }
85
+ /** Daemon-derived one-comment projection and audit history. */
86
+ export interface ReviewCommentDetailDTO {
87
+ comment: ReviewCommentDTO;
88
+ events: ReviewCommentEventDTO[];
89
+ }
90
+ /** Caller-supplied cursor/limit for the append-only review audit. */
91
+ export interface ReadReviewCommentEventsQuery {
92
+ since_seq?: number;
93
+ limit?: number;
94
+ }
95
+ /** Daemon-derived page of append-only review comment events. */
96
+ export interface ReviewCommentEventsDTO {
97
+ review_id: string;
98
+ events: ReviewCommentEventDTO[];
99
+ next_since_seq: number | null;
100
+ }
101
+ /** Daemon-derived append-only comment audit event. */
102
+ export interface ReviewCommentEventDTO {
103
+ seq: number;
104
+ review_id: string;
105
+ comment_id: string;
106
+ kind: 'created' | 'edited' | 'resolved' | 'reopened' | 'deleted' | 'reanchored' | 'notified' | 'notify_failed';
107
+ state_change: boolean;
108
+ revision_after: number | null;
109
+ actor: {
110
+ kind: 'human' | 'node' | 'system';
111
+ node_id?: NodeIdDTO;
112
+ };
113
+ at: IsoTime;
114
+ operation_id: string;
115
+ payload?: unknown;
116
+ }
117
+ /** Caller-supplied replacement location for one nondeleted comment. */
118
+ export type ReviewCommentRangeEntryDTO = {
119
+ comment_id: string;
120
+ anchor: ReviewCommentAnchorDTO;
121
+ } | {
122
+ comment_id: string;
123
+ detached: true;
124
+ };
125
+ /** Caller-supplied atomic full-set range remap body. */
126
+ export interface ReviewCommentRangeBatchRequest {
127
+ from_doc_hash: string;
128
+ to_doc_hash: string;
129
+ entries: ReviewCommentRangeEntryDTO[];
130
+ }
131
+ /** Daemon-derived result of an atomic full-set range remap. */
132
+ export interface ReviewCommentRangeBatchResultDTO {
133
+ review_id: string;
134
+ anchor_base_sha256: string;
135
+ updated: number;
136
+ detached: number;
137
+ unchanged: number;
138
+ }
139
+ /** Daemon-derived result of forking the review companion onto one comment. */
140
+ export interface ReviewCommentForkDTO {
141
+ comment_id: string;
142
+ /** The newborn fork of the review companion. */
143
+ node_id: NodeIdDTO;
144
+ /** Where the fork runs, so a caller can place a viewer for it. */
145
+ cwd: string;
146
+ }
@@ -0,0 +1,5 @@
1
+ // Daemon-owned review comment DTOs. These are HTTP wire contracts only.
2
+ //
3
+ // PURITY: imports remain within `src/api/*`; daemon/store types do not cross
4
+ // this boundary.
5
+ export {};
@@ -0,0 +1,113 @@
1
+ import type { IsoTime, NodeIdDTO } from './common.js';
2
+ import type { FeedbackResultDTO } from './human.js';
3
+ export type ReviewOriginKindDTO = 'ticket' | 'inline';
4
+ /** `binding` is intentionally never exposed over the API. */
5
+ export type ReviewStateDTO = 'open' | 'approved' | 'canceled';
6
+ /** Caller-supplied body for `POST /v1/human/reviews`. */
7
+ export interface CreateReviewRequest {
8
+ /** Caller-selected review origin. */
9
+ origin_kind: ReviewOriginKindDTO;
10
+ /** Caller-selected node whose persisted session is forked. */
11
+ origin_node_id: NodeIdDTO;
12
+ /** The document to review, as a canvas ref (`[[ ]]` optional) — required for ticket reviews,
13
+ * and the alternative to `file` for inline ones. The daemon reads it as the caller, snapshots
14
+ * its head to `<review_dir>/document.md`, and on submit saves the reviewed text as a new
15
+ * revision (refused as `stale_revision` if it moved). */
16
+ document?: string;
17
+ /** Inline reviews of a file: an absolute path; the daemon canonicalizes and validates it.
18
+ * An inline review takes exactly one of `file` or `document`. */
19
+ file?: string;
20
+ /** Caller-minted invocation key; the daemon enforces its uniqueness. */
21
+ idempotency_key: string;
22
+ /** Caller-supplied ticket subtitle; required for ticket origins. */
23
+ subtitle?: string;
24
+ /** Caller-supplied ticket-only projection destination. */
25
+ output_path?: string;
26
+ }
27
+ /** Daemon-derived canonical review projection. */
28
+ export interface ReviewDTO {
29
+ /** Daemon-minted opaque review identity. */
30
+ review_id: string;
31
+ /** Daemon-recorded origin kind. */
32
+ origin_kind: ReviewOriginKindDTO;
33
+ /** Daemon-recorded originating node. */
34
+ origin_node_id: NodeIdDTO;
35
+ /** Daemon-owned directory containing the review branch and terminal result. */
36
+ review_dir: string;
37
+ /** Daemon-preallocated companion node. */
38
+ companion_node_id: NodeIdDTO;
39
+ /** Daemon-canonicalized reviewed file path (for a document review, its `document.md` snapshot). */
40
+ file: string;
41
+ /** The reviewed document's `<owner>/<name>`, for a document review. */
42
+ document?: string;
43
+ /** Daemon lifecycle state; never `binding`. */
44
+ state: ReviewStateDTO;
45
+ /** Daemon capture timestamp. */
46
+ created: IsoTime;
47
+ /** Daemon open timestamp, after the companion binds. */
48
+ opened_at?: IsoTime;
49
+ /** When the human submitted a review whose companion was still working. The
50
+ * review remains `open` until the companion goes quiet. */
51
+ submit_requested_at?: IsoTime;
52
+ /** Daemon source-read status at projection time. */
53
+ source_missing: boolean;
54
+ /** Daemon-owned current comment-coordinate source digest. */
55
+ anchor_base_sha256: string;
56
+ /** Daemon approval timestamp. */
57
+ approved_at?: IsoTime;
58
+ /** Daemon comparison of approval bytes to the invocation baseline. */
59
+ changed?: boolean;
60
+ /** Daemon snapshot count at approval. */
61
+ comments_total?: number;
62
+ /** Daemon unresolved-comment count at approval. */
63
+ comments_unresolved?: number;
64
+ /** Daemon cancellation timestamp. */
65
+ canceled_at?: IsoTime;
66
+ /** Daemon-recorded caller cancellation reason. */
67
+ cancel_reason?: string;
68
+ /** Daemon-recorded cancellation actor. */
69
+ cancel_actor?: string;
70
+ /** Daemon-owned immutable result projection path. */
71
+ result_path?: string;
72
+ /** Daemon-recorded approval delivery error, when delivery failed after commit. */
73
+ delivery_error?: string;
74
+ /** Daemon-recorded result projection error, when publication failed after commit. */
75
+ projection_error?: string;
76
+ }
77
+ /** Caller-supplied optional filters for `GET /v1/human/reviews`. */
78
+ export interface ListReviewsQuery {
79
+ state?: ReviewStateDTO;
80
+ origin_node_id?: NodeIdDTO;
81
+ file?: string;
82
+ }
83
+ /** Daemon-derived review list. */
84
+ export interface ReviewListDTO {
85
+ reviews: ReviewDTO[];
86
+ }
87
+ /** Daemon-derived result of review approval, which may still be waiting on the
88
+ * review's companion. */
89
+ export interface ReviewSubmitResultDTO {
90
+ review: ReviewDTO;
91
+ /** Immutable approval result; absent while the approval awaits the companion. */
92
+ result?: FeedbackResultDTO;
93
+ outcome: 'settled' | 'already_settled' | 'awaiting_companion';
94
+ }
95
+ /** Daemon-derived result of terminal review cancellation. */
96
+ export interface ReviewCancelResultDTO {
97
+ review: ReviewDTO;
98
+ outcome: 'settled' | 'already_settled';
99
+ }
100
+ /** Caller-supplied optional cancellation context. */
101
+ export interface CancelReviewRequest {
102
+ reason?: string;
103
+ actor?: string;
104
+ /** Recipient surfaces send `dismissed`; a requester withdrawal defaults to `canceled`. */
105
+ disposition?: 'canceled' | 'dismissed';
106
+ }
107
+ /** Daemon-derived coordinate base for the terminal review surface. */
108
+ export interface ReviewDocumentBaseDTO {
109
+ review_id: string;
110
+ anchor_base_sha256: string;
111
+ anchor_base_text: string;
112
+ file: string;
113
+ }
@@ -0,0 +1,5 @@
1
+ // Canonical daemon-owned review DTOs. These are HTTP wire contracts only.
2
+ //
3
+ // PURITY: imports remain within `src/api/*`; daemon/store types do not cross
4
+ // this boundary.
5
+ export {};