@north-light/crouter-api 0.3.282 → 0.3.284

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.
@@ -1,15 +1,16 @@
1
1
  import type { DaemonRestartDTO, HealthDTO, StatusDTO } from './dto/health.js';
2
2
  import type { BashJobStatusDTO, BashJobStopResultDTO } from './dto/bash-jobs.js';
3
3
  import type { ArtifactListDTO, ArtifactsQuery, ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSubjectDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
4
+ import type { NodeOutcomeResponseDTO, OutcomeDeliveryDTO, RegisterOutcomeDeliveryRequest } from './dto/node-outcomes.js';
4
5
  import type { InterruptResultDTO, MessageResultDTO, SendMessageRequest } from './dto/messages.js';
5
- import type { PushReportRequest, PushReportResultDTO, ReportDTO, ReportsQuery } from './dto/reports.js';
6
+ import type { PushReportRequest, PushReportResultDTO, ReportDTO, ReportsQuery, SubmitResultDTO, SubmitResultRequest } from './dto/reports.js';
6
7
  import type { CloseRequest, CloseResultDTO, PromoteRequest, RelaunchRootResultDTO, ReviveRequest, ReviveResultDTO, WaitRequest, YieldRequest } from './dto/lifecycle.js';
7
8
  import type { SubscribeRequest, SubscriptionDTO } from './dto/subscriptions.js';
8
9
  import type { FocusDTO, RegisterFocusRequest, SetFocusPaneRequest } from './dto/focus.js';
9
10
  import { type ArmCronRequest, type CancelCronQuery, type CronDTO, type CronRunDTO, type CronScopeQuery, type CronShowDTO, type ListCronsQuery, type PokeCronsResult } from './dto/crons.js';
10
11
  import type { NodeConfigPatch } from './dto/config.js';
11
12
  import type { AttachEnsureRequest, AttachEnsureResultDTO } from './dto/attach.js';
12
- import type { DeleteProfileRequest, DeleteProfileResultDTO, EnsureProfileRequest, ProfileDTO, UpdateProfileMetadataRequest } from './dto/profiles.js';
13
+ import type { DeleteProfileRequest, DeleteProfileResultDTO, EnsureProfileRequest, ProfileDTO, ProfilePauseResultDTO, UpdateProfileMetadataRequest } from './dto/profiles.js';
13
14
  import type { FilePeekDTO } from './dto/files.js';
14
15
  import type { MemoryDocRefDTO } from './dto/memory.js';
15
16
  import type { ChatInventoryDTO, ProspectiveChatInventoryDTO, ProspectiveChatInventoryQuery } from './dto/chat-inventory.js';
@@ -21,13 +22,15 @@ import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, I
21
22
  import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest } from './dto/human-requests.js';
22
23
  import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, PruneRequest, PruneResultDTO, RebuildIndexResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
23
24
  import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO } from './dto/worktree.js';
24
- import type { BrokerExtensionStateDTO, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerInboxCursorDirective, BrokerInboxCursorRequest, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest } from './dto/broker-ops.js';
25
+ import type { BrokerExtensionStateDTO, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerInboxCursorDirective, BrokerInboxCursorRequest, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerParkActivityResultDTO, BrokerParkCompleteRequest, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest } from './dto/broker-ops.js';
25
26
  export interface CrtrClientOptions {
26
27
  /** Unix socket path (default local transport). Exactly one of socketPath|baseUrl. */
27
28
  socketPath?: string;
28
29
  /** `http(s)://host:port` for TCP/remote transport. */
29
30
  baseUrl?: string;
30
- /** Extra headers (e.g. an edge auth token on TCP; crtrd ignores it). */
31
+ /** Extra headers, e.g. `{ authorization: 'Bearer <token>' }` when the target
32
+ * crtrd's TCP listener has `CRTRD_TOKEN` set (unix-socket transport is
33
+ * never checked, and a TCP daemon with no token set ignores this too). */
31
34
  headers?: Record<string, string>;
32
35
  /** Autostart on a cold socket (default true for socketPath, false for baseUrl). */
33
36
  autostart?: boolean;
@@ -95,6 +98,16 @@ export declare class CrtrClient {
95
98
  * latest/canonical reports and pending-human counts in the same response. */
96
99
  listNodes(q?: ListNodesQuery): Promise<NodeSummaryDTO[]>;
97
100
  getNode(id: string): Promise<NodeDetailDTO>;
101
+ /** Read a node outcome, optionally awaiting it for at most 25 seconds. This
102
+ * is a GET so the client can safely replay it across daemon handover. */
103
+ getNodeOutcome(id: string, { waitSeconds }?: {
104
+ waitSeconds?: number;
105
+ }): Promise<NodeOutcomeResponseDTO>;
106
+ /** Register or replace an armed target for terminal-outcome delivery. */
107
+ registerOutcomeDelivery(id: string, req: RegisterOutcomeDeliveryRequest): Promise<OutcomeDeliveryDTO>;
108
+ getOutcomeDelivery(id: string): Promise<OutcomeDeliveryDTO>;
109
+ /** Disarm an unsettled outcome-delivery registration. */
110
+ disarmOutcomeDelivery(id: string): Promise<void>;
98
111
  listBashJobs(id: string): Promise<BashJobStatusDTO[]>;
99
112
  stopBashJob(id: string, jobId: string): Promise<BashJobStopResultDTO>;
100
113
  sendMessage(id: string, req: SendMessageRequest): Promise<MessageResultDTO>;
@@ -103,11 +116,14 @@ export declare class CrtrClient {
103
116
  * revives a dormant target. */
104
117
  interruptNode(id: string): Promise<InterruptResultDTO>;
105
118
  pushReport(id: string, req: PushReportRequest): Promise<PushReportResultDTO>;
119
+ submitResult(id: string, req: SubmitResultRequest): Promise<SubmitResultDTO>;
106
120
  forkNode(id: string): Promise<NodeDetailDTO>;
107
121
  reviveNode(id: string, req?: ReviveRequest): Promise<ReviveResultDTO>;
108
122
  relaunchRoot(id: string): Promise<RelaunchRootResultDTO>;
109
123
  bindBrokerSession(id: string, req: BrokerSessionBoundRequest): Promise<BrokerSessionBoundResultDTO>;
110
124
  settleBroker(id: string, req: BrokerSettleRequest): Promise<BrokerSettleDirective>;
125
+ completeBrokerPark(id: string, req: BrokerParkCompleteRequest): Promise<BrokerSettleDirective>;
126
+ recordBrokerParkActivity(id: string): Promise<BrokerParkActivityResultDTO>;
111
127
  advanceBrokerInboxCursor(id: string, req: BrokerInboxCursorRequest): Promise<BrokerInboxCursorDirective>;
112
128
  commitBrokerModel(id: string, req: BrokerModelCommitRequest): Promise<BrokerModelCommitResultDTO>;
113
129
  brokerExtensionState(id: string): Promise<BrokerExtensionStateDTO>;
@@ -187,6 +203,8 @@ export declare class CrtrClient {
187
203
  ensureProfile(name: string, req?: EnsureProfileRequest): Promise<ProfileDTO>;
188
204
  listProfiles(): Promise<ProfileDTO[]>;
189
205
  getProfile(name: string): Promise<ProfileDTO>;
206
+ pauseProfile(name: string): Promise<ProfilePauseResultDTO>;
207
+ resumeProfile(name: string): Promise<ProfilePauseResultDTO>;
190
208
  /** Merge and remove entries in a profile's metadata map. */
191
209
  updateProfileMetadata(name: string, req: UpdateProfileMetadataRequest): Promise<ProfileDTO>;
192
210
  /** Force-delete or detach one profile by exact id or unique name. */
@@ -104,6 +104,25 @@ export class CrtrClient {
104
104
  getNode(id) {
105
105
  return this.request('GET', routes.node(this.nodePath(id)));
106
106
  }
107
+ /** Read a node outcome, optionally awaiting it for at most 25 seconds. This
108
+ * is a GET so the client can safely replay it across daemon handover. */
109
+ getNodeOutcome(id, { waitSeconds } = {}) {
110
+ if (waitSeconds !== undefined && (!Number.isInteger(waitSeconds) || waitSeconds < 0 || waitSeconds > 25)) {
111
+ throw new RangeError('waitSeconds must be an integer between 0 and 25');
112
+ }
113
+ return this.request('GET', withQuery(routes.nodeOutcome(this.nodePath(id)), { wait: waitSeconds }));
114
+ }
115
+ /** Register or replace an armed target for terminal-outcome delivery. */
116
+ registerOutcomeDelivery(id, req) {
117
+ return this.request('PUT', routes.nodeOutcomeDelivery(this.nodePath(id)), req);
118
+ }
119
+ getOutcomeDelivery(id) {
120
+ return this.request('GET', routes.nodeOutcomeDelivery(this.nodePath(id)));
121
+ }
122
+ /** Disarm an unsettled outcome-delivery registration. */
123
+ async disarmOutcomeDelivery(id) {
124
+ await this.request('DELETE', routes.nodeOutcomeDelivery(this.nodePath(id)));
125
+ }
107
126
  listBashJobs(id) {
108
127
  return this.request('GET', routes.nodeJobs(this.nodePath(id)));
109
128
  }
@@ -122,6 +141,9 @@ export class CrtrClient {
122
141
  pushReport(id, req) {
123
142
  return this.request('POST', routes.nodeReports(this.nodePath(id)), req);
124
143
  }
144
+ submitResult(id, req) {
145
+ return this.request('POST', routes.nodeResult(this.nodePath(id)), req);
146
+ }
125
147
  forkNode(id) {
126
148
  return this.request('POST', routes.nodeFork(this.nodePath(id)), {});
127
149
  }
@@ -137,6 +159,12 @@ export class CrtrClient {
137
159
  settleBroker(id, req) {
138
160
  return this.request('POST', routes.nodeBrokerSettle(this.nodePath(id)), req);
139
161
  }
162
+ completeBrokerPark(id, req) {
163
+ return this.request('POST', routes.nodeBrokerParkComplete(this.nodePath(id)), req);
164
+ }
165
+ recordBrokerParkActivity(id) {
166
+ return this.request('POST', routes.nodeBrokerParkActivity(this.nodePath(id)), {});
167
+ }
140
168
  advanceBrokerInboxCursor(id, req) {
141
169
  return this.request('POST', routes.nodeBrokerInboxCursor(this.nodePath(id)), req);
142
170
  }
@@ -319,6 +347,12 @@ export class CrtrClient {
319
347
  getProfile(name) {
320
348
  return this.request('GET', routes.profile(name));
321
349
  }
350
+ pauseProfile(name) {
351
+ return this.request('POST', routes.profilePause(name), {});
352
+ }
353
+ resumeProfile(name) {
354
+ return this.request('POST', routes.profileResume(name), {});
355
+ }
322
356
  /** Merge and remove entries in a profile's metadata map. */
323
357
  updateProfileMetadata(name, req) {
324
358
  return this.request('PATCH', routes.profileMetadata(name), req);
@@ -36,6 +36,17 @@ export type BrokerSettleDirective = {
36
36
  } | {
37
37
  action: 'shutdown';
38
38
  };
39
+ /** A main-engine input has won broker admission while a parking summary may be
40
+ * in flight. crtrd records it against the process-local pending marker before
41
+ * Pi begins the input, making parking completion and input admission atomic. */
42
+ export interface BrokerParkActivityResultDTO {
43
+ activity: 'recorded' | 'none';
44
+ }
45
+ /** `POST /v1/nodes/{id}/broker/park-complete` body. The isolated parking turn
46
+ * has ended; crtrd alone decides whether its pending park still applies. */
47
+ export interface BrokerParkCompleteRequest {
48
+ outcome: 'completed' | 'failed';
49
+ }
39
50
  /** `POST /v1/nodes/{id}/broker/inbox-cursor` body. The watcher advances this
40
51
  * only after Pi has settled every handoff through the supplied physical entry.
41
52
  * `brokerPid` binds the commit to the broker generation crtrd currently owns. */
@@ -46,11 +46,6 @@ export interface BrokerWelcomeFrame<M = unknown> {
46
46
  type: 'welcome';
47
47
  snapshot?: BrokerWelcomeSnapshot<M>;
48
48
  }
49
- /** The presentation classification of the run whose native events follow. */
50
- export interface BrokerTurnVisibilityFrame {
51
- type: 'turn_visibility';
52
- visibility: 'visible' | 'internal';
53
- }
54
49
  /**
55
50
  * The crtrd broker `node_named` control frame — the node's generated name at the
56
51
  * instant crtrd committed it.
@@ -76,12 +71,12 @@ export interface BrokerNodeNamedFrame {
76
71
  editorLabel: string;
77
72
  }
78
73
  /**
79
- * The broker-control frames a relay consumer reads: `welcome` (catch-up snapshot),
80
- * `turn_visibility`, `error`, and `node_named`. The broker interleaves others (display_*, ack, …)
74
+ * The broker-control frames a relay consumer reads: `welcome`, `error`, and
75
+ * `node_named`. The broker interleaves others (display_*, ack, …)
81
76
  * under non-colliding `type` discriminants; a relay mapper drops those through its
82
77
  * `default` arm untyped, so they are not enumerated here.
83
78
  */
84
- export type BrokerControlFrame<M = unknown> = BrokerWelcomeFrame<M> | BrokerTurnVisibilityFrame | BrokerErrorFrame | BrokerNodeNamedFrame;
79
+ export type BrokerControlFrame<M = unknown> = BrokerWelcomeFrame<M> | BrokerErrorFrame | BrokerNodeNamedFrame;
85
80
  /**
86
81
  * What the crtrd broker attach delivers to a relay consumer: the live engine
87
82
  * event stream (`E` — pi's `AgentSessionEvent`, relayed verbatim) unioned with the
@@ -20,7 +20,7 @@ export type ModeDTO = 'base' | 'orchestrator';
20
20
  /** Why a node last stopped (mirrors the runtime `ExitIntent` union). */
21
21
  export type ExitIntentDTO = 'done' | 'refresh' | 'idle-release' | 'parked' | null;
22
22
  /** Why a terminal node ended (mirrors the runtime `TerminalReason` union). */
23
- export type TerminalReasonDTO = 'finalized' | 'finished' | 'parked' | 'closed' | 'retired' | 'crashed' | 'stranded';
23
+ export type TerminalReasonDTO = 'finalized' | 'finished' | 'parked' | 'closed' | 'retired' | 'crashed' | 'stranded' | 'boot_failed' | 'crash_looped' | 'launch_failed' | 'context_overflow' | 'deadline_exceeded' | 'provider_fatal' | 'declined';
24
24
  /** Inbox urgency tier for a delivered message (mirrors feed/inbox `InboxTier`). */
25
25
  export type InboxTierDTO = 'critical' | 'urgent' | 'normal' | 'deferred';
26
26
  /** Whether a node id is a safe single filesystem path segment. Re-declared here
@@ -36,8 +36,8 @@ export interface SendMessageRequest {
36
36
  /** One-shot runtime cards for this turn only — never persisted. Delivered in
37
37
  * array order, after `situational_card` and ahead of the body. */
38
38
  context_cards?: RuntimeCardRequest[];
39
- /** Raw JSON-schema string granting a one-off `submit` tool before delivery
40
- * (`--output-schema`). Immediate only. */
39
+ /** Raw JSON-schema string installing a one-off output schema before delivery
40
+ * (`--output-schema`); the target answers with `crtr push result`. Immediate only. */
41
41
  output_schema?: string;
42
42
  /** `'interactive'`: deliver via the target's LIVE broker engine (prompt/steer
43
43
  * on its one serialized frame loop — the same ordering a tmux viewer gets)
@@ -0,0 +1,80 @@
1
+ import type { IsoTime, NodeIdDTO, NodeStatusDTO, TerminalReasonDTO } from './common.js';
2
+ import type { DeclinedResultDTO } from './reports.js';
3
+ export type OutcomeKindDTO = 'result' | 'failure';
4
+ /** Bounded diagnostics recorded for a failed node outcome. */
5
+ export interface NodeOutcomeDetailV1 {
6
+ schema: 'crtr.node-outcome-detail/v1';
7
+ message?: string;
8
+ fault_kind?: 'rate-limit' | 'overloaded' | 'connection' | 'auth' | 'protocol' | 'context-overflow' | 'other' | 'wedged' | 'model-not-found';
9
+ error_class?: 'rate_limit' | 'overloaded' | 'connection' | 'auth' | 'protocol' | 'context_overflow' | 'wedged' | 'model_not_found' | 'unknown';
10
+ respawn_failures?: number;
11
+ deadline?: {
12
+ deadline_at: string;
13
+ elapsed_ms: number;
14
+ };
15
+ /** Present only for reason `declined`: what the node gave `crtr push result --decline`. */
16
+ declined?: DeclinedResultDTO;
17
+ truncated?: true;
18
+ }
19
+ interface NodeOutcomeBaseDTO {
20
+ node_id: NodeIdDTO;
21
+ revision: number;
22
+ settled_at: IsoTime;
23
+ /** Canonical final report basename; set for kind='result' and for a declined structured result (kind='failure', reason='declined'); else null. */
24
+ final_report: string | null;
25
+ /** Absolute path of the canonical final report; null whenever `final_report` is. */
26
+ final_report_path: string | null;
27
+ /** Parsed context/result.json when the node ran under --output-schema; else null. */
28
+ structured_result: unknown | null;
29
+ /** Bounded diagnostics; null for kind='result'. */
30
+ detail: NodeOutcomeDetailV1 | null;
31
+ }
32
+ /** A settled outcome. Narrowing on `kind` then `reason` makes a declined
33
+ * structured result (`failure`/`declined`) a case a consumer must handle:
34
+ * only that case carries `declined`; every other outcome has it null. */
35
+ export type NodeOutcomeDTO = (NodeOutcomeBaseDTO & {
36
+ kind: 'result';
37
+ reason: TerminalReasonDTO;
38
+ declined: null;
39
+ }) | (NodeOutcomeBaseDTO & {
40
+ kind: 'failure';
41
+ reason: 'declined';
42
+ declined: DeclinedResultDTO;
43
+ }) | (NodeOutcomeBaseDTO & {
44
+ kind: 'failure';
45
+ reason: Exclude<TerminalReasonDTO, 'declined'>;
46
+ declined: null;
47
+ });
48
+ export interface NodeOutcomeResponseDTO {
49
+ node_id: NodeIdDTO;
50
+ state: 'pending' | 'settled';
51
+ outcome: NodeOutcomeDTO | null;
52
+ node_status: NodeStatusDTO;
53
+ deadline_at: IsoTime | null;
54
+ }
55
+ export interface RegisterOutcomeDeliveryRequest {
56
+ /** A name declared in the humanActions map of scope config. */
57
+ action: string;
58
+ /** Opaque, frozen at registration, echoed verbatim in the document. */
59
+ payload?: unknown;
60
+ }
61
+ export type OutcomeDeliveryStateDTO = 'armed' | 'pending' | 'running' | 'accepted' | 'permanent_failed';
62
+ export interface OutcomeDeliveryDTO {
63
+ node_id: NodeIdDTO;
64
+ state: OutcomeDeliveryStateDTO;
65
+ action: string;
66
+ attempt: number;
67
+ /** ISO-8601 time of the next retry, or null before the row is scheduled. */
68
+ next_attempt_at: IsoTime | null;
69
+ accepted_at: IsoTime | null;
70
+ permanent_failed_at: IsoTime | null;
71
+ last_failure: {
72
+ kind: string;
73
+ exit_code?: number;
74
+ signal?: string;
75
+ message?: string;
76
+ } | null;
77
+ created_at: IsoTime;
78
+ updated_at: IsoTime;
79
+ }
80
+ export {};
@@ -0,0 +1,2 @@
1
+ // Node terminal-outcome and outcome-delivery DTOs.
2
+ export {};
@@ -1,5 +1,6 @@
1
1
  import type { Cursor, ExitIntentDTO, IsoTime, LifecycleDTO, ModeDTO, NodeIdDTO, NodeStatusDTO, TerminalReasonDTO } from './common.js';
2
2
  import type { ReportDTO } from './reports.js';
3
+ import type { NodeOutcomeDTO, RegisterOutcomeDeliveryRequest } from './node-outcomes.js';
3
4
  /** `GET /v1/nodes/{id}/subject` — the node-config subject substrate gate
4
5
  * predicates evaluate against. Mirrors `NodeConfigSubject`; this narrow
5
6
  * endpoint exists so a CLI process (the `memory read` leaf) can gate-check
@@ -51,6 +52,10 @@ export interface CreateNodeRequest {
51
52
  situational_context?: string;
52
53
  no_kickoff?: boolean;
53
54
  output_schema?: string;
55
+ /** Wall-clock bound from spawn, e.g. "45m", "2h", "1h30m". Expiry cancels the node and synthesizes a failure outcome with reason 'deadline_exceeded'. */
56
+ deadline?: string;
57
+ /** Arm outcome delivery atomically with node birth. */
58
+ outcome_delivery?: RegisterOutcomeDeliveryRequest;
54
59
  /** Spawn AT this exact node id instead of a runtime-minted one — format-
55
60
  * validated and duplicate-rejected server-side (`NodeIdConflictError` →
56
61
  * HTTP 409 `node_id_exists`). See `crtr node new --node-id`. */
@@ -80,6 +85,8 @@ export interface NodeSummaryDTO {
80
85
  cwd: string;
81
86
  host_kind: 'tmux' | 'broker' | null;
82
87
  profile_id: string | null;
88
+ /** Whether the node's profile is currently paused. */
89
+ profile_paused: boolean;
83
90
  parent: NodeIdDTO | null;
84
91
  created: IsoTime;
85
92
  intent: ExitIntentDTO;
@@ -96,6 +103,8 @@ export interface NodeSummaryDTO {
96
103
  /** Basename of the canonical final report, or null when this node has not finalized. */
97
104
  final_report: string | null;
98
105
  finalized_at: IsoTime | null;
106
+ deadline_at: IsoTime | null;
107
+ outcome: NodeOutcomeDTO | null;
99
108
  /** Present only when requested with `include=activity`. */
100
109
  activity?: NodeActivityDTO;
101
110
  }
@@ -28,6 +28,11 @@ export interface UpdateProfileMetadataRequest {
28
28
  set?: Record<string, string>;
29
29
  unset?: string[];
30
30
  }
31
+ /** The daemon-owned result of pausing or resuming one profile. */
32
+ export interface ProfilePauseResultDTO {
33
+ profile_id: string;
34
+ paused_at: string | null;
35
+ }
31
36
  /** `DELETE /v1/profiles/{name}` body. Destructive deletion is never implicit. */
32
37
  export interface DeleteProfileRequest {
33
38
  force: boolean;
@@ -31,6 +31,51 @@ export interface PushReportResultDTO {
31
31
  /** Present only alongside `worktree_auto_dropped`: the checkout path dropped. */
32
32
  worktree_auto_dropped_path?: string;
33
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 worktree
59
+ * auto-drop 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
+ /** Absolute path of the report pushed alongside the result. */
69
+ report_path: 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
+ }
34
79
  /** `GET /v1/nodes/{id}/reports` query filters. */
35
80
  export interface ReportsQuery {
36
81
  tier?: ReportTierDTO;
@@ -7,6 +7,7 @@ export * from '../shared/generated-context.js';
7
7
  export * from './dto/common.js';
8
8
  export * from './dto/health.js';
9
9
  export * from './dto/nodes.js';
10
+ export * from './dto/node-outcomes.js';
10
11
  export * from './dto/bash-jobs.js';
11
12
  export * from './dto/messages.js';
12
13
  export * from './dto/reports.js';
package/dist/api/index.js CHANGED
@@ -8,6 +8,7 @@ export * from '../shared/generated-context.js';
8
8
  export * from './dto/common.js';
9
9
  export * from './dto/health.js';
10
10
  export * from './dto/nodes.js';
11
+ export * from './dto/node-outcomes.js';
11
12
  export * from './dto/bash-jobs.js';
12
13
  export * from './dto/messages.js';
13
14
  export * from './dto/reports.js';
@@ -8,6 +8,8 @@ export declare const routes: {
8
8
  readonly nodes: () => string;
9
9
  readonly reviveAll: () => string;
10
10
  readonly node: (id: string) => string;
11
+ readonly nodeOutcome: (id: string) => string;
12
+ readonly nodeOutcomeDelivery: (id: string) => string;
11
13
  readonly nodeSnapshot: (id: string) => string;
12
14
  readonly nodeSubject: (id: string) => string;
13
15
  readonly nodeSession: (id: string) => string;
@@ -17,6 +19,7 @@ export declare const routes: {
17
19
  readonly nodeContext: (id: string) => string;
18
20
  readonly nodeArtifacts: (id: string) => string;
19
21
  readonly nodeReports: (id: string) => string;
22
+ readonly nodeResult: (id: string) => string;
20
23
  readonly nodeJobs: (id: string) => string;
21
24
  readonly nodeJob: (id: string, jobId: string) => string;
22
25
  readonly nodeMessages: (id: string) => string;
@@ -26,6 +29,8 @@ export declare const routes: {
26
29
  readonly nodeRelaunchRoot: (id: string) => string;
27
30
  readonly nodeBrokerSessionBound: (id: string) => string;
28
31
  readonly nodeBrokerSettle: (id: string) => string;
32
+ readonly nodeBrokerParkComplete: (id: string) => string;
33
+ readonly nodeBrokerParkActivity: (id: string) => string;
29
34
  readonly nodeBrokerInboxCursor: (id: string) => string;
30
35
  readonly nodeBrokerModel: (id: string) => string;
31
36
  readonly nodeBrokerExtensionState: (id: string) => string;
@@ -96,6 +101,8 @@ export declare const routes: {
96
101
  readonly humanRequestCancel: (requestId: string) => string;
97
102
  readonly profiles: () => string;
98
103
  readonly profile: (name: string) => string;
104
+ readonly profilePause: (name: string) => string;
105
+ readonly profileResume: (name: string) => string;
99
106
  readonly profileMetadata: (name: string) => string;
100
107
  readonly modelAuths: () => string;
101
108
  readonly modelAuth: (provider: string) => string;
@@ -23,6 +23,8 @@ export const routes = {
23
23
  nodes: () => `${V}/nodes`,
24
24
  reviveAll: () => `${V}/nodes/revive-all`,
25
25
  node: (id) => `${V}/nodes/${id}`,
26
+ nodeOutcome: (id) => `${V}/nodes/${id}/outcome`,
27
+ nodeOutcomeDelivery: (id) => `${V}/nodes/${id}/outcome-delivery`,
26
28
  // Node reads
27
29
  nodeSnapshot: (id) => `${V}/nodes/${id}/snapshot`,
28
30
  nodeSubject: (id) => `${V}/nodes/${id}/subject`,
@@ -33,6 +35,7 @@ export const routes = {
33
35
  nodeContext: (id) => `${V}/nodes/${id}/context`,
34
36
  nodeArtifacts: (id) => `${V}/nodes/${id}/artifacts`,
35
37
  nodeReports: (id) => `${V}/nodes/${id}/reports`,
38
+ nodeResult: (id) => `${V}/nodes/${id}/result`,
36
39
  nodeJobs: (id) => `${V}/nodes/${id}/jobs`,
37
40
  nodeJob: (id, jobId) => `${V}/nodes/${id}/jobs/${jobId}`,
38
41
  // Node messages / feed
@@ -44,6 +47,8 @@ export const routes = {
44
47
  nodeRelaunchRoot: (id) => `${V}/nodes/${id}/relaunch-root`,
45
48
  nodeBrokerSessionBound: (id) => `${V}/nodes/${id}/broker/session-bound`,
46
49
  nodeBrokerSettle: (id) => `${V}/nodes/${id}/broker/settle`,
50
+ nodeBrokerParkComplete: (id) => `${V}/nodes/${id}/broker/park-complete`,
51
+ nodeBrokerParkActivity: (id) => `${V}/nodes/${id}/broker/park-activity`,
47
52
  nodeBrokerInboxCursor: (id) => `${V}/nodes/${id}/broker/inbox-cursor`,
48
53
  nodeBrokerModel: (id) => `${V}/nodes/${id}/broker/model`,
49
54
  nodeBrokerExtensionState: (id) => `${V}/nodes/${id}/broker/extension-state`,
@@ -127,6 +132,8 @@ export const routes = {
127
132
  // Profiles (deletion is daemon-owned because it crosses canvas state)
128
133
  profiles: () => `${V}/profiles`,
129
134
  profile: (name) => `${V}/profiles/${name}`,
135
+ profilePause: (name) => `${V}/profiles/${name}/pause`,
136
+ profileResume: (name) => `${V}/profiles/${name}/resume`,
130
137
  profileMetadata: (name) => `${V}/profiles/${name}/metadata`,
131
138
  // Model auth
132
139
  modelAuths: () => `${V}/model-auth`,
@@ -56,6 +56,11 @@ export declare function envNoDaemonAutostart(): boolean;
56
56
  /** The `--tcp` fallback for crtrd's opt-in TCP listener (`CRTRD_TCP`), raw
57
57
  * (`host:port` or undefined — absent means unix socket only). */
58
58
  export declare function envCrtrdTcp(): string | undefined;
59
+ /** The opt-in bearer token guarding crtrd's TCP listener (`CRTRD_TOKEN`).
60
+ * Unset (or blank) → undefined, and the TCP listener performs NO auth check
61
+ * at all — exactly today's behavior. The unix socket never checks this,
62
+ * set or not. */
63
+ export declare function envCrtrdToken(): string | undefined;
59
64
  /** Kill switch for the host-exports writer/pruner (`CRTR_NO_EXPORTS=1`). */
60
65
  export declare function envNoExports(): boolean;
61
66
  /** Verbose-diagnostics gate for otherwise-silent best-effort catches
@@ -82,3 +87,6 @@ export declare function envUnattendedParkMs(): number | undefined;
82
87
  /** Test-only park-summary grace-period override
83
88
  * (`CRTR_TEST_PARK_SUMMARY_GRACE_MS`); no production default. */
84
89
  export declare function envTestParkSummaryGraceMs(): number | undefined;
90
+ /** The bounded lifetime shared by the daemon's pending-park sweep and its
91
+ * in-broker isolated turn. */
92
+ export declare function parkSummaryGraceMs(): number;
@@ -137,6 +137,14 @@ export function envNoDaemonAutostart() {
137
137
  export function envCrtrdTcp() {
138
138
  return process.env['CRTRD_TCP'];
139
139
  }
140
+ /** The opt-in bearer token guarding crtrd's TCP listener (`CRTRD_TOKEN`).
141
+ * Unset (or blank) → undefined, and the TCP listener performs NO auth check
142
+ * at all — exactly today's behavior. The unix socket never checks this,
143
+ * set or not. */
144
+ export function envCrtrdToken() {
145
+ const raw = process.env['CRTRD_TOKEN'];
146
+ return raw !== undefined && raw !== '' ? raw : undefined;
147
+ }
140
148
  /** Kill switch for the host-exports writer/pruner (`CRTR_NO_EXPORTS=1`). */
141
149
  export function envNoExports() {
142
150
  return process.env['CRTR_NO_EXPORTS'] === '1';
@@ -195,3 +203,9 @@ export function envUnattendedParkMs() {
195
203
  export function envTestParkSummaryGraceMs() {
196
204
  return parsePositiveMsNoDefault(process.env['CRTR_TEST_PARK_SUMMARY_GRACE_MS']);
197
205
  }
206
+ const DEFAULT_PARK_SUMMARY_GRACE_MS = 5 * 60_000;
207
+ /** The bounded lifetime shared by the daemon's pending-park sweep and its
208
+ * in-broker isolated turn. */
209
+ export function parkSummaryGraceMs() {
210
+ return envTestParkSummaryGraceMs() ?? DEFAULT_PARK_SUMMARY_GRACE_MS;
211
+ }
@@ -8,15 +8,9 @@ export declare const CONTEXT_NUDGE_CUSTOM_TYPE = "crtr-context-nudge";
8
8
  export declare const REVIEW_BOUNDARY_CUSTOM_TYPE = "crtr-review-boundary";
9
9
  /** Generic completion mandate issued by the terminal-node stop guard. */
10
10
  export declare const STALL_REPROMPT: string;
11
- /** The daemon's parking mandate: the last turn of a conversation the unattended
12
- * clock is concluding. Delivered live, wrapped in a `park` runtime card. It
13
- * governs both the node's durable inheritance and reader-facing output:
14
- * one update for subscribers and history, then a brief completion reply.
15
- *
16
- * The durable inheritance shares a CONTRACT with `node yield`'s pre-invocation
17
- * guide (roadmap current, short and shrinking; context dir for in-progress
18
- * material; memory only for gated permanent lessons) but not a string: yield is
19
- * read by an agent choosing to refresh, this by an agent being told to conclude. */
11
+ /** The daemon's parking mandate for an isolated turn. It leaves current truth,
12
+ * supporting material when needed, lasting lessons, and one deferred update;
13
+ * the main conversation remains untouched and resumes without a fresh cycle. */
20
14
  export declare const PARK_SUMMARY_PROMPT: string;
21
15
  /** Static recovery prompts shared by the broker producer and display classifier. */
22
16
  export declare const AUTH_FAULT_RECOVERY_BODY = "Provider credentials were just updated (a new login landed). Your previous turn stopped on a provider authentication failure. Continue from where you left off and retry the work that failed.";
@@ -13,22 +13,14 @@ export const REVIEW_BOUNDARY_CUSTOM_TYPE = 'crtr-review-boundary';
13
13
  /** Generic completion mandate issued by the terminal-node stop guard. */
14
14
  export const STALL_REPROMPT = "You've stopped but you're not waiting on anyone and haven't finished. " +
15
15
  "Pipe the result to `crtr push final` through a single-quoted heredoc if the work is done, or use `crtr human send` if you are blocked or need the user.";
16
- /** The daemon's parking mandate: the last turn of a conversation the unattended
17
- * clock is concluding. Delivered live, wrapped in a `park` runtime card. It
18
- * governs both the node's durable inheritance and reader-facing output:
19
- * one update for subscribers and history, then a brief completion reply.
20
- *
21
- * The durable inheritance shares a CONTRACT with `node yield`'s pre-invocation
22
- * guide (roadmap current, short and shrinking; context dir for in-progress
23
- * material; memory only for gated permanent lessons) but not a string: yield is
24
- * read by an agent choosing to refresh, this by an agent being told to conclude. */
25
- export const PARK_SUMMARY_PROMPT = 'This conversation has been idle with nothing left to wake it, so it is being concluded. This is your last turn. Use it to leave a trustworthy inheritance, not to restart or broaden the work. Do these six things now, then stop.\n\n'
16
+ /** The daemon's parking mandate for an isolated turn. It leaves current truth,
17
+ * supporting material when needed, lasting lessons, and one deferred update;
18
+ * the main conversation remains untouched and resumes without a fresh cycle. */
19
+ export const PARK_SUMMARY_PROMPT = 'This conversation has been idle with nothing left to wake it, so it is being concluded. This is your last turn. Use it to leave a trustworthy inheritance, not to restart or broaden the work. Do these four things now, then stop.\n\n'
26
20
  + '1. Establish current truth. Check only state that may have changed outside the transcript and matters to resuming—such as the working tree, a remote run, or an external decision. Do not start new work; perform only a quick check needed to avoid recording an unverified claim. If no mandate or work ever began, record that plainly in the inheritance and keep every artifact minimal.\n\n'
27
- + '2. Rewrite `$CRTR_CONTEXT_DIR/roadmap.md` for a fresh context window. This is the only handoff document a later fresh cycle receives in full. Preserve the current goal and exit criteria when they still apply, then state the present outcome; what remains or is blocked; decisions or questions still open; exact recovery handles for in-flight state; and the first safe move on return. Keep strategy and present state, not a transcript recap. Delete stale and completed steps instead of marking them done; the roadmap should stay short and shrink. Write a minimal one now if none exists.\n\n'
28
- + '3. Put supporting material in your context directory only when the roadmap would become bulky without it. Rewrite existing living documents rather than leave superseded versions. Name every supporting file the next cycle must read from the roadmap and say what it is for—the revive shows filenames but does not inject their contents. Task state, identifiers, and recovery detail belong here, not in memory.\n\n'
29
- + '4. Use memory only for a non-obvious, reusable lesson that should survive this task and is not already recorded. Read `crtr memory write -h`, find before writing, and choose the narrowest scope that will reach the next agent who needs it. Do not put a conversation recap, task status, recovery handles, or facts already captured in code or docs into memory.\n\n'
30
- + '5. Push exactly one regular update with `crtr push update --tier deferred`, never `crtr push final`. Write for someone who has not seen this conversation: name the work in plain terms, say where it stands, and say what remains or is blocked. Put the current outcome in the first line; include only needed decisions and recovery handles. This concludes the conversation, not the mandate.\n\n'
31
- + '6. When finished, reply with exactly `done`.';
21
+ + '2. Put supporting material in your context directory only when it is needed to keep the inheritance concise. Rewrite existing living documents rather than leave superseded versions. Task state, identifiers, and recovery detail belong here, not in memory.\n\n'
22
+ + '3. Use memory only for a non-obvious, reusable lesson that should survive this task and is not already recorded. Read `crtr memory write -h`, find before writing, and choose the narrowest scope that will reach the next agent who needs it. Do not put a conversation recap, task status, recovery handles, or facts already captured in code or docs into memory.\n\n'
23
+ + '4. Push exactly one regular update with `crtr push update --tier deferred`, never `crtr push final`. Write for someone who has not seen this conversation: name the work in plain terms, say where it stands, and say what remains or is blocked. Put the current outcome in the first line; include only needed decisions and recovery handles, then stop.';
32
24
  /** Static recovery prompts shared by the broker producer and display classifier. */
33
25
  export const AUTH_FAULT_RECOVERY_BODY = 'Provider credentials were just updated (a new login landed). Your previous turn stopped on a provider authentication failure. Continue from where you left off and retry the work that failed.';
34
26
  export const CONNECTION_FAULT_RECOVERY_BODY = 'The network connection is back online. Your previous turn stopped on a connection error (the network was down). Continue from where you left off and retry the work that failed.';
@@ -37,7 +29,7 @@ const REVIEW_APPROVAL_OPEN = '<crtr-review-approval>';
37
29
  const REVIEW_APPROVAL_CLOSE = '</crtr-review-approval>';
38
30
  const MODEL_FALLBACK_RECOVERY_OPEN = '<model-fallback-recovery>';
39
31
  const MODEL_FALLBACK_RECOVERY_CLOSE = '</model-fallback-recovery>';
40
- const STRUCTURED_OUTPUT_REPROMPT_PREFIX = 'You must call the `submit` tool with a result matching the required schema before you can stop. You cannot finish or go dormant any other way while this request is pending.\n\nRequired schema:\n\n```json\n';
32
+ const STRUCTURED_OUTPUT_REPROMPT_PREFIX = 'You must submit a result matching the required schema with `crtr push result` before you can stop, or decline it with `crtr push result --decline "<reason>" --code <token>` when the schema cannot be honestly satisfied. You cannot finish or go dormant any other way while this request is pending.\n\nRequired schema:\n\n```json\n';
41
33
  const STRUCTURED_OUTPUT_REPROMPT_SUFFIX = '\n```';
42
34
  /** Format the stop guard's dynamic structured-output mandate. */
43
35
  export function formatStructuredOutputReprompt(schema) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/crouter-api",
3
- "version": "0.3.282",
3
+ "version": "0.3.284",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",