@north-light/crouter-api 0.3.207 → 0.3.209
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.
- package/dist/api/client.d.ts +3 -1
- package/dist/api/client.js +4 -0
- package/dist/api/dto/broker-ops.d.ts +2 -12
- package/dist/api/dto/nodes.d.ts +16 -0
- package/dist/api/routes.d.ts +1 -0
- package/dist/api/routes.js +1 -0
- package/dist/shared/generated-context.d.ts +0 -18
- package/dist/shared/generated-context.js +16 -120
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DaemonRestartDTO, HealthDTO, StatusDTO } from './dto/health.js';
|
|
2
2
|
import type { BashJobStatusDTO, BashJobStopResultDTO } from './dto/bash-jobs.js';
|
|
3
|
-
import type { ArtifactListDTO, ArtifactsQuery, ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
|
|
3
|
+
import type { ArtifactListDTO, ArtifactsQuery, ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSubjectDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
|
|
4
4
|
import type { InterruptResultDTO, MessageResultDTO, SendMessageRequest } from './dto/messages.js';
|
|
5
5
|
import type { PushReportRequest, PushReportResultDTO, ReportDTO, ReportsQuery } from './dto/reports.js';
|
|
6
6
|
import type { CloseRequest, CloseResultDTO, PromoteRequest, RelaunchRootResultDTO, ReviveRequest, ReviveResultDTO, WaitRequest, YieldRequest } from './dto/lifecycle.js';
|
|
@@ -143,6 +143,8 @@ export declare class CrtrClient {
|
|
|
143
143
|
getReports(id: string, q?: ReportsQuery): Promise<ReportDTO[]>;
|
|
144
144
|
getTranscript(id: string, q?: TranscriptQuery): Promise<TranscriptDTO>;
|
|
145
145
|
getSnapshot(id: string): Promise<NodeSnapshotDTO>;
|
|
146
|
+
/** The node-config subject substrate gates evaluate against. */
|
|
147
|
+
nodeSubject(id: string): Promise<NodeSubjectDTO>;
|
|
146
148
|
getNodeMessages(id: string, q?: NodeMessagesQuery): Promise<NodeMessagesPageDTO>;
|
|
147
149
|
/** The node's conversation exactly as it ran — raw `.jsonl` bytes plus the
|
|
148
150
|
* assembled system prompt. For exports; `getSnapshot` is for renderers. */
|
package/dist/api/client.js
CHANGED
|
@@ -253,6 +253,10 @@ export class CrtrClient {
|
|
|
253
253
|
getSnapshot(id) {
|
|
254
254
|
return this.request('GET', routes.nodeSnapshot(this.nodePath(id)));
|
|
255
255
|
}
|
|
256
|
+
/** The node-config subject substrate gates evaluate against. */
|
|
257
|
+
nodeSubject(id) {
|
|
258
|
+
return this.request('GET', routes.nodeSubject(this.nodePath(id)));
|
|
259
|
+
}
|
|
256
260
|
getNodeMessages(id, q) {
|
|
257
261
|
return this.request('GET', withQuery(routes.nodeMessages(this.nodePath(id)), q));
|
|
258
262
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExitIntentDTO, NodeStatusDTO } from './common.js';
|
|
2
|
+
import type { NodeSubjectDTO } from './nodes.js';
|
|
2
3
|
/** `POST /v1/nodes/{id}/broker/session-bound` body. Pi's session-start reason
|
|
3
4
|
* distinguishes an ordinary boot/resume from `/new`, whose child-side session
|
|
4
5
|
* reset is a different durable operation. `reviewBoundaryIds` reports only the
|
|
@@ -95,18 +96,7 @@ export interface BrokerExtensionNodeDTO {
|
|
|
95
96
|
};
|
|
96
97
|
created: string;
|
|
97
98
|
}
|
|
98
|
-
export
|
|
99
|
-
kind: string;
|
|
100
|
-
mode: 'base' | 'orchestrator';
|
|
101
|
-
lifecycle: 'terminal' | 'resident';
|
|
102
|
-
hasManager: boolean;
|
|
103
|
-
cwd: string;
|
|
104
|
-
scope: 'user' | 'project';
|
|
105
|
-
orchestration: {
|
|
106
|
-
depth: number;
|
|
107
|
-
};
|
|
108
|
-
profile: string | null;
|
|
109
|
-
}
|
|
99
|
+
export type BrokerExtensionSubjectDTO = NodeSubjectDTO;
|
|
110
100
|
/** One resolved report sender. Report contents stay broker-local filesystem
|
|
111
101
|
* data; this daemon projection supplies only existence and display metadata. */
|
|
112
102
|
export interface BrokerReportNodeDTO {
|
package/dist/api/dto/nodes.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { Cursor, ExitIntentDTO, IsoTime, LifecycleDTO, ModeDTO, NodeIdDTO, NodeStatusDTO } from './common.js';
|
|
2
|
+
/** `GET /v1/nodes/{id}/subject` — the node-config subject substrate gate
|
|
3
|
+
* predicates evaluate against. Mirrors `NodeConfigSubject`; this narrow
|
|
4
|
+
* endpoint exists so a CLI process (the `memory read` leaf) can gate-check
|
|
5
|
+
* docs without reaching canvas state. */
|
|
6
|
+
export interface NodeSubjectDTO {
|
|
7
|
+
kind: string;
|
|
8
|
+
mode: ModeDTO;
|
|
9
|
+
lifecycle: LifecycleDTO;
|
|
10
|
+
hasManager: boolean;
|
|
11
|
+
cwd: string;
|
|
12
|
+
scope: 'user' | 'project';
|
|
13
|
+
orchestration: {
|
|
14
|
+
depth: number;
|
|
15
|
+
};
|
|
16
|
+
profile: string | null;
|
|
17
|
+
}
|
|
2
18
|
/** `POST /v1/nodes` body. Carries the full immediate spawn recipe. */
|
|
3
19
|
export interface CreateNodeRequest {
|
|
4
20
|
kind: string;
|
package/dist/api/routes.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const routes: {
|
|
|
9
9
|
readonly reviveAll: () => string;
|
|
10
10
|
readonly node: (id: string) => string;
|
|
11
11
|
readonly nodeSnapshot: (id: string) => string;
|
|
12
|
+
readonly nodeSubject: (id: string) => string;
|
|
12
13
|
readonly nodeSession: (id: string) => string;
|
|
13
14
|
readonly nodeTranscript: (id: string) => string;
|
|
14
15
|
readonly nodeContext: (id: string) => string;
|
package/dist/api/routes.js
CHANGED
|
@@ -25,6 +25,7 @@ export const routes = {
|
|
|
25
25
|
node: (id) => `${V}/nodes/${id}`,
|
|
26
26
|
// Node reads
|
|
27
27
|
nodeSnapshot: (id) => `${V}/nodes/${id}/snapshot`,
|
|
28
|
+
nodeSubject: (id) => `${V}/nodes/${id}/subject`,
|
|
28
29
|
nodeSession: (id) => `${V}/nodes/${id}/session`,
|
|
29
30
|
nodeTranscript: (id) => `${V}/nodes/${id}/transcript`,
|
|
30
31
|
nodeContext: (id) => `${V}/nodes/${id}/context`,
|
|
@@ -58,24 +58,7 @@ export interface GeneratedCard {
|
|
|
58
58
|
facts: Readonly<Record<string, string>>;
|
|
59
59
|
body: string;
|
|
60
60
|
senders: CardSender[];
|
|
61
|
-
label: string;
|
|
62
|
-
summary: string;
|
|
63
|
-
expandable: boolean;
|
|
64
61
|
}
|
|
65
|
-
type CardSummary = (facts: Readonly<Record<string, string>>) => string;
|
|
66
|
-
export interface CardKindDefinition {
|
|
67
|
-
label: string;
|
|
68
|
-
summary: CardSummary;
|
|
69
|
-
expandable: boolean;
|
|
70
|
-
customTypes?: Readonly<Record<string, Partial<Pick<CardKindDefinition, 'label' | 'summary' | 'expandable'>>>>;
|
|
71
|
-
}
|
|
72
|
-
/** The closed crouter vocabulary, plus custom-role aliases for the same cards. */
|
|
73
|
-
export declare const KIND_TABLE: Readonly<Record<string, CardKindDefinition>>;
|
|
74
|
-
/** Contribute presentation for namespaced kinds this process will render.
|
|
75
|
-
* Idempotent and last-write-wins, so a re-imported module cannot fail a boot.
|
|
76
|
-
* A process that never registers is not degraded: an unregistered kind still
|
|
77
|
-
* parses and only falls back to the generic label and summary. */
|
|
78
|
-
export declare function registerCardKinds(kinds: Readonly<Record<string, CardKindDefinition>>): void;
|
|
79
62
|
/** Plain text from a generated message's string or text-block content. */
|
|
80
63
|
export declare function generatedContextText(message: GeneratedContextMessageLike): string;
|
|
81
64
|
/** Wrap a user-role runtime message in its whole-message card envelope. */
|
|
@@ -91,4 +74,3 @@ export declare function parseCard(message: GeneratedContextMessageLike): Generat
|
|
|
91
74
|
/** Format a complete inbox card from report bodies resolved by the caller. */
|
|
92
75
|
export declare function formatInboxCard(sections: readonly InboxCardSection[]): string;
|
|
93
76
|
export declare function isLegacyRuntimeText(text: string): boolean;
|
|
94
|
-
export {};
|
|
@@ -35,98 +35,13 @@ export function formatModelFallbackRecovery(previousModel, nextModel, reason) {
|
|
|
35
35
|
? `The previous model (${previousModel}) had no usable provider credential, so you were automatically switched to ${nextModel}. Continue the task from where the failed turn left off.`
|
|
36
36
|
: `The previous model (${previousModel}) was unavailable (provider 404 not_found), so you were automatically switched to ${nextModel}. Continue the task from where the failed turn left off.`;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const updates = countFact(facts, 'updates');
|
|
46
|
-
const senders = countFact(facts, 'senders');
|
|
47
|
-
if (updates === null)
|
|
48
|
-
return 'inbox update';
|
|
49
|
-
if (senders === null || senders <= 1)
|
|
50
|
-
return `${updates === 1 ? 'message' : `${updates} messages`} received`;
|
|
51
|
-
return `${updates} messages received from ${senders} nodes`;
|
|
52
|
-
}
|
|
53
|
-
function recoverySummaryFromFacts(facts) {
|
|
54
|
-
switch (facts.reason) {
|
|
55
|
-
case 'model-fallback': return 'model route changed';
|
|
56
|
-
case 'connection': return 'network connection restored';
|
|
57
|
-
case 'provider': return 'provider retry';
|
|
58
|
-
case 'auth': return 'provider credentials updated';
|
|
59
|
-
default: return 'runtime recovery';
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function reviewCommentSummary(facts) {
|
|
63
|
-
switch (facts.verb) {
|
|
64
|
-
case 'create': return 'review comment created';
|
|
65
|
-
case 'edit': return 'review comment edited';
|
|
66
|
-
case 'resolve': return 'review comment resolved';
|
|
67
|
-
case 'reopen': return 'review comment reopened';
|
|
68
|
-
case 'delete': return 'review comment deleted';
|
|
69
|
-
default: return 'review comment updated';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/** The closed crouter vocabulary, plus custom-role aliases for the same cards. */
|
|
73
|
-
export const KIND_TABLE = {
|
|
74
|
-
inbox: { label: 'crtr inbox', summary: inboxSummary, expandable: true },
|
|
75
|
-
revive: { label: 'crtr revive', summary: () => 'fresh context kickoff', expandable: true },
|
|
76
|
-
'restart-continuation': { label: 'crouter continuation', summary: () => 'continuing from where it left off', expandable: true },
|
|
77
|
-
'stop-guard': {
|
|
78
|
-
label: 'crtr stop guard',
|
|
79
|
-
summary: (facts) => facts.reason === 'structured-output' ? 'structured output required' : 'completion required',
|
|
80
|
-
expandable: true,
|
|
81
|
-
},
|
|
82
|
-
recovery: { label: 'crouter continuation', summary: recoverySummaryFromFacts, expandable: true },
|
|
83
|
-
'persona-transition': { label: 'crtr persona', summary: () => 'runtime role update', expandable: true },
|
|
84
|
-
'review-approval': { label: 'crtr review', summary: () => 'review approved by the user', expandable: true },
|
|
85
|
-
'review-comment': { label: 'crtr review', summary: reviewCommentSummary, expandable: true },
|
|
86
|
-
'review-queued': { label: 'crtr review', summary: () => 'review submitted; completion pending', expandable: true },
|
|
87
|
-
'context-nudge': {
|
|
88
|
-
label: 'crtr',
|
|
89
|
-
summary: (facts) => facts.size === undefined ? 'context-window guidance' : `Context ${facts.size}`,
|
|
90
|
-
expandable: true,
|
|
91
|
-
customTypes: { [CONTEXT_NUDGE_CUSTOM_TYPE]: {} },
|
|
92
|
-
},
|
|
93
|
-
bearings: {
|
|
94
|
-
label: 'crtr context',
|
|
95
|
-
summary: () => 'orienting bearings',
|
|
96
|
-
expandable: true,
|
|
97
|
-
customTypes: { [CONTEXT_INTRO_CUSTOM_TYPE]: {} },
|
|
98
|
-
},
|
|
99
|
-
'review-boundary': {
|
|
100
|
-
label: 'review boundary',
|
|
101
|
-
summary: () => 'earlier conversation is not shown',
|
|
102
|
-
expandable: true,
|
|
103
|
-
customTypes: { [REVIEW_BOUNDARY_CUSTOM_TYPE]: {} },
|
|
104
|
-
},
|
|
105
|
-
situational: {
|
|
106
|
-
label: 'situational context',
|
|
107
|
-
summary: () => 'ambient context update',
|
|
108
|
-
expandable: true,
|
|
109
|
-
customTypes: { [SITUATIONAL_CONTEXT_CUSTOM_TYPE]: {} },
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
const GENERIC_CARD = {
|
|
113
|
-
label: 'crtr runtime',
|
|
114
|
-
summary: () => 'runtime context',
|
|
115
|
-
expandable: true,
|
|
116
|
-
};
|
|
117
|
-
/** Kinds contributed by a product or plugin, in whatever process renders them. */
|
|
118
|
-
const KIND_REGISTRY = {};
|
|
119
|
-
/** Contribute presentation for namespaced kinds this process will render.
|
|
120
|
-
* Idempotent and last-write-wins, so a re-imported module cannot fail a boot.
|
|
121
|
-
* A process that never registers is not degraded: an unregistered kind still
|
|
122
|
-
* parses and only falls back to the generic label and summary. */
|
|
123
|
-
export function registerCardKinds(kinds) {
|
|
124
|
-
for (const [kind, definition] of Object.entries(kinds)) {
|
|
125
|
-
// Bare kinds are crouter core's closed vocabulary. A product claiming one
|
|
126
|
-
// is a programming error at boot, not a runtime condition to tolerate.
|
|
127
|
-
if (!kind.includes(':'))
|
|
128
|
-
throw new Error(`Runtime card kind must be namespaced (contain ':'): ${kind}`);
|
|
129
|
-
KIND_REGISTRY[kind] = definition;
|
|
38
|
+
function legacyCustomTypeKind(customType) {
|
|
39
|
+
switch (customType) {
|
|
40
|
+
case CONTEXT_NUDGE_CUSTOM_TYPE: return 'context-nudge';
|
|
41
|
+
case CONTEXT_INTRO_CUSTOM_TYPE: return 'bearings';
|
|
42
|
+
case REVIEW_BOUNDARY_CUSTOM_TYPE: return 'review-boundary';
|
|
43
|
+
case SITUATIONAL_CONTEXT_CUSTOM_TYPE: return 'situational';
|
|
44
|
+
default: return undefined;
|
|
130
45
|
}
|
|
131
46
|
}
|
|
132
47
|
const XML_ATTRIBUTE_NAME = /^[A-Za-z_:][A-Za-z0-9_:.-]*$/;
|
|
@@ -248,16 +163,7 @@ function parseInboxBody(body) {
|
|
|
248
163
|
return senders;
|
|
249
164
|
}
|
|
250
165
|
function cardFor(kind, facts, body, senders) {
|
|
251
|
-
|
|
252
|
-
return {
|
|
253
|
-
kind,
|
|
254
|
-
facts,
|
|
255
|
-
body,
|
|
256
|
-
senders,
|
|
257
|
-
label: definition.label,
|
|
258
|
-
summary: definition.summary(facts),
|
|
259
|
-
expandable: definition.expandable,
|
|
260
|
-
};
|
|
166
|
+
return { kind, facts, body, senders };
|
|
261
167
|
}
|
|
262
168
|
/** Parse a whole-message runtime envelope, regardless of delivery role. */
|
|
263
169
|
function parseEnvelope(text) {
|
|
@@ -286,22 +192,13 @@ export function parseCard(message) {
|
|
|
286
192
|
return null;
|
|
287
193
|
// Pre-envelope custom-message fallback for old sessions. New custom messages
|
|
288
194
|
// classify through their envelope; customType is delivery metadata only.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
facts,
|
|
297
|
-
body: text,
|
|
298
|
-
senders: [],
|
|
299
|
-
label: override.label ?? definition.label,
|
|
300
|
-
summary: (override.summary ?? definition.summary)(facts),
|
|
301
|
-
expandable: override.expandable ?? definition.expandable,
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
return null;
|
|
195
|
+
const kind = legacyCustomTypeKind(message.customType);
|
|
196
|
+
return kind === undefined ? null : {
|
|
197
|
+
kind,
|
|
198
|
+
facts: Object.freeze({}),
|
|
199
|
+
body: text,
|
|
200
|
+
senders: [],
|
|
201
|
+
};
|
|
305
202
|
}
|
|
306
203
|
/** Format a complete inbox card from report bodies resolved by the caller. */
|
|
307
204
|
export function formatInboxCard(sections) {
|
|
@@ -316,8 +213,7 @@ export function formatInboxCard(sections) {
|
|
|
316
213
|
}).join('\n');
|
|
317
214
|
return `<from${formatAttributes({ id: section.id, name: section.name, updates, finished: finished || undefined })}>${entries}</from>`;
|
|
318
215
|
}).join('\n');
|
|
319
|
-
|
|
320
|
-
return formatCard('inbox', { senders: sections.length, updates }, body);
|
|
216
|
+
return formatCard('inbox', {}, body);
|
|
321
217
|
}
|
|
322
218
|
// LEGACY — landed 2026-08-14. Pre-envelope runtime text, kept ONLY so old
|
|
323
219
|
// scrollback is not attributed to the person. Delete this section and its
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/crouter-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.209",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, and the CrtrClient. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|