@north-light/crouter-api 0.3.207 → 0.3.208
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.
|
@@ -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.208",
|
|
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",
|