@north-light/crouter-api 0.3.227 → 0.3.229

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.
@@ -21,7 +21,7 @@ import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, I
21
21
  import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest } from './dto/human-requests.js';
22
22
  import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, PruneRequest, PruneResultDTO, RebuildIndexResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
23
23
  import type { CloseWorktreeResultDTO } from './dto/worktree.js';
24
- import type { BrokerExtensionStateDTO, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerInboxCursorDirective, BrokerInboxCursorRequest, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerPersonaAckRequest, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest } from './dto/broker-ops.js';
24
+ import type { BrokerExtensionStateDTO, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerInboxCursorDirective, BrokerInboxCursorRequest, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest } from './dto/broker-ops.js';
25
25
  export interface CrtrClientOptions {
26
26
  /** Unix socket path (default local transport). Exactly one of socketPath|baseUrl. */
27
27
  socketPath?: string;
@@ -101,7 +101,7 @@ export declare class CrtrClient {
101
101
  commitBrokerModel(id: string, req: BrokerModelCommitRequest): Promise<BrokerModelCommitResultDTO>;
102
102
  brokerExtensionState(id: string): Promise<BrokerExtensionStateDTO>;
103
103
  commitBrokerGeneratedName(id: string, req: BrokerGeneratedNameRequest): Promise<BrokerGeneratedNameResultDTO>;
104
- commitBrokerPersonaAck(id: string, req: BrokerPersonaAckRequest): Promise<void>;
104
+ commitBrokerPersonaAck(id: string, req: BrokerPersonaAckRequest): Promise<BrokerPersonaAckResultDTO>;
105
105
  closeNode(id: string, req?: CloseRequest): Promise<CloseResultDTO>;
106
106
  recycleNode(id: string): Promise<NodeDetailDTO>;
107
107
  demoteNode(id: string): Promise<NodeDetailDTO>;
@@ -164,9 +164,9 @@ export declare class CrtrClient {
164
164
  /** Read an absolute host path as UTF-8 (capped, `truncated` when clipped) for
165
165
  * the browser file-peek panel. */
166
166
  peekFile(path: string): Promise<FilePeekDTO>;
167
- /** Resolve a `[[name]]` memory-document link to the absolute path the given
168
- * node would read — the node's own precedence chain, not this process's.
169
- * Pair with `peekFile` to render the document. */
167
+ /** Resolve an exact canonical `[[name]]` memory-document link to the winning
168
+ * document's physical origin for the given node — the node's own precedence
169
+ * chain, not this process's. Pair with `peekFile` to render the document. */
170
170
  resolveMemoryDoc(name: string, nodeId: string): Promise<MemoryDocRefDTO>;
171
171
  /** Create-or-return by name. Supplied `projects` are shape-checked even when
172
172
  * the profile already exists; their directories are only required to exist
@@ -290,9 +290,9 @@ export class CrtrClient {
290
290
  return this.request('GET', withQuery(routes.filePeek(), { path }));
291
291
  }
292
292
  // ---- Memory documents --------------------------------------------------
293
- /** Resolve a `[[name]]` memory-document link to the absolute path the given
294
- * node would read — the node's own precedence chain, not this process's.
295
- * Pair with `peekFile` to render the document. */
293
+ /** Resolve an exact canonical `[[name]]` memory-document link to the winning
294
+ * document's physical origin for the given node — the node's own precedence
295
+ * chain, not this process's. Pair with `peekFile` to render the document. */
296
296
  resolveMemoryDoc(name, nodeId) {
297
297
  return this.request('GET', withQuery(routes.memoryResolve(), { name, node: nodeId }));
298
298
  }
@@ -90,7 +90,10 @@ export interface BrokerExtensionNodeDTO {
90
90
  target_file: string;
91
91
  } | null;
92
92
  intent: ExitIntentDTO;
93
+ /** `kind` is absent on rows written before kind joined the drift key; a read
94
+ * resolves it to the node's current kind. */
93
95
  persona_ack?: {
96
+ kind?: string;
94
97
  mode: 'base' | 'orchestrator';
95
98
  lifecycle: 'terminal' | 'resident';
96
99
  };
@@ -145,11 +148,16 @@ export interface BrokerGeneratedNameResultDTO {
145
148
  }
146
149
  export interface BrokerPersonaAckRequest {
147
150
  from: {
151
+ kind: string;
148
152
  mode: 'base' | 'orchestrator';
149
153
  lifecycle: 'terminal' | 'resident';
150
154
  };
151
155
  to: {
156
+ kind: string;
152
157
  mode: 'base' | 'orchestrator';
153
158
  lifecycle: 'terminal' | 'resident';
154
159
  };
155
160
  }
161
+ export interface BrokerPersonaAckResultDTO {
162
+ applied: boolean;
163
+ }
@@ -1,16 +1,17 @@
1
- /** `GET /v1/memory/resolve?name=<name>&node=<id>` result where the named
2
- * document lives for that node. Resolution runs the node's own precedence
3
- * chain (its context store, its project stack, its profile, user, builtin), so
4
- * the same name can answer with different documents for different nodes. */
1
+ /** `GET /v1/memory/resolve?name=<name>&node=<id>` result. Resolution runs the
2
+ * node's own precedence chain (its context store, its project stack, its
3
+ * profile, user, builtin) and returns the winner for the exact canonical name. */
5
4
  export interface MemoryDocRefDTO {
6
- /** The document's canonical identity (its frontmatter `name`, else its
7
- * path-derived name) — which may differ from the queried name when the query
8
- * was a bare leaf or a directory whose INDEX resolved. */
5
+ /** The winner's canonical identity for the exact resolved query. */
9
6
  name: string;
10
7
  /** Which store it came from: node | project | profile | user | builtin. */
11
8
  scope: string;
12
9
  /** Absolute path to the `.md` file. */
13
10
  path: string;
11
+ /** Absolute path to the physical memory store root. */
12
+ store_root: string;
13
+ /** Store-relative markdown path of the winning document. */
14
+ physical_relative_path: string;
14
15
  /** The owning plugin's name when the doc is mounted from an installed plugin,
15
16
  * absent for a native scope doc. */
16
17
  plugin?: string;
@@ -1,6 +1,6 @@
1
1
  // Memory-document resolution DTO. Backs `GET /v1/memory/resolve` — a client
2
- // holding a `[[name]]` link out of a node's transcript turns it into the
3
- // absolute path of the document that node would read, then peeks that path.
2
+ // holding a canonical `[[name]]` link out of a node's transcript gets the
3
+ // winning document's canonical identity and physical origin.
4
4
  //
5
5
  // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
6
6
  export {};
@@ -6,8 +6,6 @@ export declare const SITUATIONAL_CONTEXT_CUSTOM_TYPE = "crtr-situational-context
6
6
  export declare const CONTEXT_NUDGE_CUSTOM_TYPE = "crtr-context-nudge";
7
7
  /** Custom message that opens a review companion's visible transcript. */
8
8
  export declare const REVIEW_BOUNDARY_CUSTOM_TYPE = "crtr-review-boundary";
9
- /** Opening text of a pre-envelope fresh-revive kickoff user message. */
10
- export declare const REVIVE_KICKOFF_SENTINEL = "You have been revived fresh after a context refresh";
11
9
  /** Generic completion mandate issued by the terminal-node stop guard. */
12
10
  export declare const STALL_REPROMPT: string;
13
11
  /** Static recovery prompts shared by the broker producer and display classifier. */
@@ -69,4 +67,3 @@ export declare function formatDataCard(kind: string, facts: Record<string, strin
69
67
  export declare function parseCard(message: GeneratedContextMessageLike): GeneratedCard | null;
70
68
  /** Format a complete inbox card from report bodies resolved by the caller. */
71
69
  export declare function formatInboxCard(sections: readonly InboxCardSection[]): string;
72
- export declare function isLegacyRuntimeText(text: string): boolean;
@@ -10,8 +10,6 @@ export const SITUATIONAL_CONTEXT_CUSTOM_TYPE = 'crtr-situational-context';
10
10
  export const CONTEXT_NUDGE_CUSTOM_TYPE = 'crtr-context-nudge';
11
11
  /** Custom message that opens a review companion's visible transcript. */
12
12
  export const REVIEW_BOUNDARY_CUSTOM_TYPE = 'crtr-review-boundary';
13
- /** Opening text of a pre-envelope fresh-revive kickoff user message. */
14
- export const REVIVE_KICKOFF_SENTINEL = 'You have been revived fresh after a context refresh';
15
13
  /** Generic completion mandate issued by the terminal-node stop guard. */
16
14
  export const STALL_REPROMPT = "You've stopped but you're not waiting on anyone and haven't finished. " +
17
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.";
@@ -212,58 +210,3 @@ export function formatInboxCard(sections) {
212
210
  }).join('\n');
213
211
  return formatCard('inbox', {}, body);
214
212
  }
215
- // LEGACY — landed 2026-08-14. Pre-envelope runtime text, kept ONLY so old
216
- // scrollback is not attributed to the person. Delete this section and its
217
- // callers one week after that date; after deletion, pre-cut scrollback
218
- // misattributes and that cost is accepted.
219
- const LEGACY_RESTART_CONTINUATION = '<runtime-restart-continuation>\ncontinue\n</runtime-restart-continuation>';
220
- const CONTEXT_NUDGE_PREFIX = '[crtr] Context ~';
221
- const PERSONA_TRANSITION_OPEN = '<persona-transition>';
222
- const PERSONA_TRANSITION_CLOSE = '</persona-transition>';
223
- const INBOX_SENDER_ID = '[a-z0-9]+(?:-[a-z0-9]+)+';
224
- const INBOX_HEADER_RE = new RegExp(`^From (?:(.+?) \\[(${INBOX_SENDER_ID})\\]|(${INBOX_SENDER_ID}|system|human|crtrd)) — (\\d+) update`, 'm');
225
- function isPersonaTransition(body) {
226
- return body.startsWith(`${PERSONA_TRANSITION_OPEN}\n`) && body.endsWith(`\n${PERSONA_TRANSITION_CLOSE}`);
227
- }
228
- function isReviewApproval(body) {
229
- return body.startsWith(`${REVIEW_APPROVAL_OPEN}\n`) && body.endsWith(`\n${REVIEW_APPROVAL_CLOSE}`);
230
- }
231
- function isStructuredOutputReprompt(body) {
232
- if (!body.startsWith(STRUCTURED_OUTPUT_REPROMPT_PREFIX) || !body.endsWith(STRUCTURED_OUTPUT_REPROMPT_SUFFIX)) {
233
- return false;
234
- }
235
- const schema = body.slice(STRUCTURED_OUTPUT_REPROMPT_PREFIX.length, -STRUCTURED_OUTPUT_REPROMPT_SUFFIX.length);
236
- try {
237
- JSON.parse(schema);
238
- return true;
239
- }
240
- catch {
241
- return false;
242
- }
243
- }
244
- const MODEL_CREDENTIAL_RECOVERY_RE = /^The previous model \([^\n]+\) had no usable provider credential, so you were automatically switched to [^\n]+\. Continue the task from where the failed turn left off\.$/;
245
- const MODEL_NOT_FOUND_RECOVERY_RE = /^The previous model \([^\n]+\) was unavailable \(provider 404 not_found\), so you were automatically switched to [^\n]+\. Continue the task from where the failed turn left off\.$/;
246
- function isModelFallbackRecovery(body) {
247
- if (!body.startsWith(`${MODEL_FALLBACK_RECOVERY_OPEN}\n`) || !body.endsWith(`\n${MODEL_FALLBACK_RECOVERY_CLOSE}`)) {
248
- return false;
249
- }
250
- const guidance = body.slice(MODEL_FALLBACK_RECOVERY_OPEN.length + 1, -(MODEL_FALLBACK_RECOVERY_CLOSE.length + 1));
251
- return MODEL_CREDENTIAL_RECOVERY_RE.test(guidance) || MODEL_NOT_FOUND_RECOVERY_RE.test(guidance);
252
- }
253
- function isRecoveryBody(body) {
254
- return body === AUTH_FAULT_RECOVERY_BODY
255
- || body === CONNECTION_FAULT_RECOVERY_BODY
256
- || body === PROVIDER_FAULT_RECOVERY_BODY
257
- || body === LEGACY_RESTART_CONTINUATION
258
- || isModelFallbackRecovery(body);
259
- }
260
- export function isLegacyRuntimeText(text) {
261
- return text.startsWith(REVIVE_KICKOFF_SENTINEL)
262
- || text.startsWith(CONTEXT_NUDGE_PREFIX)
263
- || INBOX_HEADER_RE.test(text)
264
- || isReviewApproval(text)
265
- || isPersonaTransition(text)
266
- || text === STALL_REPROMPT
267
- || isStructuredOutputReprompt(text)
268
- || isRecoveryBody(text);
269
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/crouter-api",
3
- "version": "0.3.227",
3
+ "version": "0.3.229",
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",