@crouter/api 0.3.377

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +67 -0
  2. package/dist/api/__tests__/error-codes.test.d.ts +1 -0
  3. package/dist/api/__tests__/error-codes.test.js +78 -0
  4. package/dist/api/__tests__/integration/client.test.d.ts +1 -0
  5. package/dist/api/__tests__/integration/client.test.js +179 -0
  6. package/dist/api/client.d.ts +467 -0
  7. package/dist/api/client.js +1179 -0
  8. package/dist/api/command-manifest/index.d.ts +3 -0
  9. package/dist/api/command-manifest/index.js +3 -0
  10. package/dist/api/command-manifest/manifest.d.ts +51 -0
  11. package/dist/api/command-manifest/manifest.js +332 -0
  12. package/dist/api/command-manifest/result.d.ts +25 -0
  13. package/dist/api/command-manifest/result.js +97 -0
  14. package/dist/api/command-manifest/schema.d.ts +28 -0
  15. package/dist/api/command-manifest/schema.js +856 -0
  16. package/dist/api/dto/analytics.d.ts +184 -0
  17. package/dist/api/dto/analytics.js +3 -0
  18. package/dist/api/dto/attach.d.ts +22 -0
  19. package/dist/api/dto/attach.js +13 -0
  20. package/dist/api/dto/bash-jobs.d.ts +24 -0
  21. package/dist/api/dto/bash-jobs.js +9 -0
  22. package/dist/api/dto/bash.d.ts +17 -0
  23. package/dist/api/dto/bash.js +1 -0
  24. package/dist/api/dto/broker-ops.d.ts +187 -0
  25. package/dist/api/dto/broker-ops.js +6 -0
  26. package/dist/api/dto/broker-signals.d.ts +25 -0
  27. package/dist/api/dto/broker-signals.js +1 -0
  28. package/dist/api/dto/broker.d.ts +86 -0
  29. package/dist/api/dto/broker.js +20 -0
  30. package/dist/api/dto/canvas.d.ts +359 -0
  31. package/dist/api/dto/canvas.js +2 -0
  32. package/dist/api/dto/chat-inventory.d.ts +56 -0
  33. package/dist/api/dto/chat-inventory.js +11 -0
  34. package/dist/api/dto/common.d.ts +29 -0
  35. package/dist/api/dto/common.js +15 -0
  36. package/dist/api/dto/config.d.ts +36 -0
  37. package/dist/api/dto/config.js +3 -0
  38. package/dist/api/dto/crons.d.ts +150 -0
  39. package/dist/api/dto/crons.js +10 -0
  40. package/dist/api/dto/custom-objects.d.ts +66 -0
  41. package/dist/api/dto/custom-objects.js +1 -0
  42. package/dist/api/dto/delivery.d.ts +71 -0
  43. package/dist/api/dto/delivery.js +7 -0
  44. package/dist/api/dto/docs.d.ts +135 -0
  45. package/dist/api/dto/docs.js +8 -0
  46. package/dist/api/dto/files.d.ts +21 -0
  47. package/dist/api/dto/files.js +1 -0
  48. package/dist/api/dto/focus.d.ts +24 -0
  49. package/dist/api/dto/focus.js +10 -0
  50. package/dist/api/dto/grants.d.ts +14 -0
  51. package/dist/api/dto/grants.js +1 -0
  52. package/dist/api/dto/health.d.ts +106 -0
  53. package/dist/api/dto/health.js +2 -0
  54. package/dist/api/dto/human-requests.d.ts +113 -0
  55. package/dist/api/dto/human-requests.js +4 -0
  56. package/dist/api/dto/human.d.ts +28 -0
  57. package/dist/api/dto/human.js +4 -0
  58. package/dist/api/dto/inbox.d.ts +273 -0
  59. package/dist/api/dto/inbox.js +4 -0
  60. package/dist/api/dto/lifecycle.d.ts +88 -0
  61. package/dist/api/dto/lifecycle.js +3 -0
  62. package/dist/api/dto/mail.d.ts +44 -0
  63. package/dist/api/dto/mail.js +1 -0
  64. package/dist/api/dto/messages.d.ts +88 -0
  65. package/dist/api/dto/messages.js +2 -0
  66. package/dist/api/dto/model-config.d.ts +25 -0
  67. package/dist/api/dto/model-config.js +1 -0
  68. package/dist/api/dto/modelauth.d.ts +132 -0
  69. package/dist/api/dto/modelauth.js +4 -0
  70. package/dist/api/dto/node-events.d.ts +65 -0
  71. package/dist/api/dto/node-events.js +4 -0
  72. package/dist/api/dto/node-outcomes.d.ts +88 -0
  73. package/dist/api/dto/node-outcomes.js +2 -0
  74. package/dist/api/dto/node-records.d.ts +35 -0
  75. package/dist/api/dto/node-records.js +5 -0
  76. package/dist/api/dto/nodes.d.ts +368 -0
  77. package/dist/api/dto/nodes.js +3 -0
  78. package/dist/api/dto/objects.d.ts +172 -0
  79. package/dist/api/dto/objects.js +5 -0
  80. package/dist/api/dto/profiles.d.ts +117 -0
  81. package/dist/api/dto/profiles.js +4 -0
  82. package/dist/api/dto/recovery.d.ts +104 -0
  83. package/dist/api/dto/recovery.js +1 -0
  84. package/dist/api/dto/reports.d.ts +93 -0
  85. package/dist/api/dto/reports.js +2 -0
  86. package/dist/api/dto/review-comments.d.ts +146 -0
  87. package/dist/api/dto/review-comments.js +5 -0
  88. package/dist/api/dto/reviews.d.ts +113 -0
  89. package/dist/api/dto/reviews.js +5 -0
  90. package/dist/api/dto/run-events.d.ts +293 -0
  91. package/dist/api/dto/run-events.js +6 -0
  92. package/dist/api/dto/subscriptions.d.ts +14 -0
  93. package/dist/api/dto/subscriptions.js +2 -0
  94. package/dist/api/dto/worktree.d.ts +55 -0
  95. package/dist/api/dto/worktree.js +6 -0
  96. package/dist/api/error-codes.d.ts +254 -0
  97. package/dist/api/error-codes.js +54 -0
  98. package/dist/api/errors.d.ts +47 -0
  99. package/dist/api/errors.js +66 -0
  100. package/dist/api/index.d.ts +42 -0
  101. package/dist/api/index.js +41 -0
  102. package/dist/api/node-transport.d.ts +18 -0
  103. package/dist/api/node-transport.js +105 -0
  104. package/dist/api/plugin-manifest-schema.d.ts +233 -0
  105. package/dist/api/plugin-manifest-schema.js +23 -0
  106. package/dist/api/routes.d.ts +160 -0
  107. package/dist/api/routes.js +193 -0
  108. package/dist/shared/generated-context.d.ts +79 -0
  109. package/dist/shared/generated-context.js +232 -0
  110. package/dist/shared/predicates.d.ts +2 -0
  111. package/dist/shared/predicates.js +4 -0
  112. package/package.json +49 -0
@@ -0,0 +1,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'];
@@ -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,93 @@
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). Either the
44
+ * structured result to validate against the node's pending output schema —
45
+ * `value` must be present; any JSON value (including null) is legal input to
46
+ * validation — or a decline: `decline` is the reason sentence, `code` the
47
+ * requester-classified token, `retryable` the node's retry claim. A decline
48
+ * records a `failure` outcome with reason `declined` carrying all three and
49
+ * clears the request without validating anything. */
50
+ export type SubmitResultRequest = {
51
+ value: unknown;
52
+ } | {
53
+ decline: string;
54
+ code: string;
55
+ retryable: boolean;
56
+ };
57
+ /** Result of a structured-result submission (`crtr push result`). Terminal
58
+ * mode reuses the final-push machinery, so `transitioned` and the managed-worktree
59
+ * closure fields carry the same meaning as on PushReportResultDTO. */
60
+ export interface SubmitResultDTO {
61
+ /** Which request this answered: `terminal` finished the node; `oneoff` left it working. */
62
+ mode: 'terminal' | 'oneoff';
63
+ /** Absolute path of the recorded artifact: context/result.json for an
64
+ * answered request, context/declined.json for a declined one. */
65
+ result_path: string;
66
+ /** Present only when the request was declined. */
67
+ declined?: DeclinedResultDTO;
68
+ /** Ref of the report document pushed alongside the result, `<node-id>/reports/<name>`. */
69
+ report: string;
70
+ /** Subscriber node ids that received an inbox entry. */
71
+ notified: NodeIdDTO[];
72
+ transitioned?: {
73
+ from: string;
74
+ to: string;
75
+ };
76
+ worktree_auto_dropped?: boolean;
77
+ worktree_auto_dropped_path?: string;
78
+ }
79
+ /** `GET /v1/nodes/{id}/reports` query filters. */
80
+ export interface ReportsQuery {
81
+ tier?: ReportTierDTO;
82
+ limit?: number;
83
+ }
84
+ /** A single stored report document. */
85
+ export interface ReportDTO {
86
+ /** Document name under the node, `reports/<compact-ts>-<uuid8>-<kind>`. */
87
+ name: string;
88
+ /** Document object id. */
89
+ id: string;
90
+ tier: ReportTierDTO;
91
+ body: string;
92
+ created: IsoTime;
93
+ }
@@ -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 {};