@north-light/crouter-api 0.3.262 → 0.3.269

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.
@@ -19,7 +19,7 @@ import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, Review
19
19
  import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
20
20
  import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
21
21
  import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest } from './dto/human-requests.js';
22
- import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, PruneRequest, PruneResultDTO, RebuildIndexResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
22
+ import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, PruneRequest, PruneResultDTO, RebuildIndexResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
23
23
  import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO } from './dto/worktree.js';
24
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 {
@@ -279,6 +279,10 @@ export declare class CrtrClient {
279
279
  /** Resolve one `<node-id>:<relpath>` history ref to its full body
280
280
  * (`crtr canvas history read`). */
281
281
  historyRead(q: HistoryReadQuery): Promise<HistoryReadResultDTO>;
282
+ /** Grouped-count projection over the per-cwd episodic corpus
283
+ * (`crtr canvas history stats`). Same filters as search/grep, aggregate
284
+ * result instead of a hit page — POST-bodied for the same reasons. */
285
+ historyStats(q: HistoryStatsQuery): Promise<HistoryStatsResultDTO>;
282
286
  /** The machine-readable browser canvas roster (`crtr canvas snapshot`) —
283
287
  * distinct from the per-node `getSnapshot`. */
284
288
  canvasSnapshot(): Promise<SnapshotDTO>;
@@ -519,6 +519,12 @@ export class CrtrClient {
519
519
  historyRead(q) {
520
520
  return this.request('GET', withQuery(routes.canvasHistoryRead(), q));
521
521
  }
522
+ /** Grouped-count projection over the per-cwd episodic corpus
523
+ * (`crtr canvas history stats`). Same filters as search/grep, aggregate
524
+ * result instead of a hit page — POST-bodied for the same reasons. */
525
+ historyStats(q) {
526
+ return this.request('POST', routes.canvasHistoryStats(), q);
527
+ }
522
528
  /** The machine-readable browser canvas roster (`crtr canvas snapshot`) —
523
529
  * distinct from the per-node `getSnapshot`. */
524
530
  canvasSnapshot() {
@@ -52,7 +52,7 @@ export interface HistorySearchQuery {
52
52
  under?: string;
53
53
  /** Restrict to specific node ids. */
54
54
  nodes?: string[];
55
- /** Corpus types: report | doc | roadmap | meta | inbox. */
55
+ /** Corpus types: report | doc | roadmap | meta | inbox | transcript. */
56
56
  types?: string[];
57
57
  report_kind?: string;
58
58
  kinds?: string[];
@@ -61,6 +61,12 @@ export interface HistorySearchQuery {
61
61
  since_ms?: number;
62
62
  /** Upper bound on artifact timestamp (epoch ms), parsed CLI-side. */
63
63
  until_ms?: number;
64
+ /** Inbound-message narrowing (transcript + inbox): what drove arrival. */
65
+ origins?: string[];
66
+ /** Transcript-message roles: user | assistant | toolResult. */
67
+ roles?: string[];
68
+ /** Case-insensitive substring against sender attribution. */
69
+ from?: string;
64
70
  /** Weigh full body text in ranking (`--body`). */
65
71
  weigh_body?: boolean;
66
72
  /** relevance | recency | oldest — already resolved to the effective sort. */
@@ -93,7 +99,7 @@ export interface HistoryGrepQuery {
93
99
  under?: string;
94
100
  /** Restrict to specific node ids. */
95
101
  nodes?: string[];
96
- /** Corpus types: report | doc | roadmap | meta | inbox. */
102
+ /** Corpus types: report | doc | roadmap | meta | inbox | transcript. */
97
103
  types?: string[];
98
104
  report_kind?: string;
99
105
  kinds?: string[];
@@ -102,9 +108,50 @@ export interface HistoryGrepQuery {
102
108
  since_ms?: number;
103
109
  /** Upper bound on artifact timestamp (epoch ms), parsed CLI-side. */
104
110
  until_ms?: number;
111
+ /** Inbound-message narrowing (transcript + inbox): what drove arrival. */
112
+ origins?: string[];
113
+ /** Transcript-message roles: user | assistant | toolResult. */
114
+ roles?: string[];
115
+ /** Case-insensitive substring against sender attribution. */
116
+ from?: string;
105
117
  limit?: number;
106
118
  cursor?: Cursor;
107
119
  }
120
+ /** `POST /v1/canvas/history/stats` body — the grouped-count projection over
121
+ * the same corpus search and grep scan, backing `crtr canvas history stats`.
122
+ * Shares every scope/corpus/message filter; carries no query, pattern, or
123
+ * pagination because the result is an aggregate, not a hit list. */
124
+ export interface HistoryStatsQuery {
125
+ /** origin | node | kind | day | type | role. Defaults to type. */
126
+ group_by?: string;
127
+ cwd?: string;
128
+ all_cwds?: boolean;
129
+ under?: string;
130
+ nodes?: string[];
131
+ types?: string[];
132
+ report_kind?: string;
133
+ kinds?: string[];
134
+ statuses?: string[];
135
+ since_ms?: number;
136
+ until_ms?: number;
137
+ origins?: string[];
138
+ roles?: string[];
139
+ from?: string;
140
+ }
141
+ /** `POST /v1/canvas/history/stats` result — counts by the grouped dimension,
142
+ * descending. `total` counts the artifacts that carried the dimension, so it
143
+ * can be lower than the corpus size when grouping by one not every artifact
144
+ * has (origin, role). */
145
+ export interface HistoryStatsResultDTO {
146
+ group_by: string;
147
+ groups: Array<{
148
+ key: string;
149
+ count: number;
150
+ }>;
151
+ total: number;
152
+ /** Artifacts scanned before the grouping dimension was applied. */
153
+ scanned: number;
154
+ }
108
155
  /** One matching body line from `crtr canvas history grep`. */
109
156
  export interface HistoryGrepHitDTO {
110
157
  ref: string;
@@ -126,6 +173,10 @@ export interface HistoryReadQuery {
126
173
  ref: string;
127
174
  /** Keep the artifact's YAML frontmatter (stripped by default). */
128
175
  frontmatter?: boolean;
176
+ /** `rendered` (default) or `raw` — the verbatim bytes behind the ref: the
177
+ * session file for a bare `session` ref, the one jsonl line for a message,
178
+ * the unparsed file for a report or doc. */
179
+ format?: string;
129
180
  }
130
181
  /** `GET /v1/canvas/history/read` result — one hit's full body. */
131
182
  export interface HistoryReadResultDTO {
@@ -15,6 +15,8 @@ export interface StatusDTO {
15
15
  tick_interval_ms: number;
16
16
  /** Node counts keyed by status. */
17
17
  node_counts: Partial<Record<NodeStatusDTO, number>>;
18
+ /** Nodes genuinely mid-turn: their busy marker exists and their recorded pid is alive. Unlike `node_counts.active`, this excludes live-but-waiting, parked, or blocked engines. */
19
+ busy_node_count: number;
18
20
  /** Bound listener addresses. `tcp` is null when the TCP listener is off. */
19
21
  listeners: {
20
22
  socket_path: string;
@@ -67,6 +67,12 @@ export interface CreateNodeRequest {
67
67
  export interface NodeSummaryDTO {
68
68
  node_id: NodeIdDTO;
69
69
  name: string;
70
+ /** Generated first-task description, absent when the node is not yet named.
71
+ * Paired with `name` it forms the full display label, so a roster consumer
72
+ * builds it without a per-node metadata fetch. */
73
+ description?: string;
74
+ /** How many times the node has been (re)launched; absent on a pre-v38 row. */
75
+ cycles?: number;
70
76
  kind: string;
71
77
  mode: ModeDTO;
72
78
  lifecycle: LifecycleDTO;
@@ -169,7 +175,6 @@ export interface NodeFaultDTO {
169
175
  export interface NodeDetailDTO extends NodeSummaryDTO {
170
176
  /** Node that created this node, or null when an external process did. */
171
177
  creator: NodeIdDTO | null;
172
- description?: string;
173
178
  /** The namer's prose form of `description` — sentence case, punctuation intact
174
179
  * (`NodeMeta.title`). What a surface showing this node to a person reads;
175
180
  * absent on a node named before titles existed. */
@@ -177,7 +182,6 @@ export interface NodeDetailDTO extends NodeSummaryDTO {
177
182
  /** The Nerd Font glyph the namer chose for this node's work, when it has one
178
183
  * (`NodeMeta.icon`). Rendered ahead of the label by surfaces that want it. */
179
184
  icon?: string;
180
- cycles?: number;
181
185
  /** Approximate context-window token load of the node's live/last session,
182
186
  * used by the orchestrator yield-nudge (`childFollowUp`). Null when unknown
183
187
  * (never launched, or no token accounting yet). */
@@ -59,6 +59,7 @@ export declare const routes: {
59
59
  readonly canvasHistorySearch: () => string;
60
60
  readonly canvasHistoryGrep: () => string;
61
61
  readonly canvasHistoryRead: () => string;
62
+ readonly canvasHistoryStats: () => string;
62
63
  readonly canvasSnapshot: () => string;
63
64
  readonly canvasRoster: () => string;
64
65
  readonly canvasPrune: () => string;
@@ -81,6 +81,7 @@ export const routes = {
81
81
  canvasHistorySearch: () => `${V}/canvas/history/search`,
82
82
  canvasHistoryGrep: () => `${V}/canvas/history/grep`,
83
83
  canvasHistoryRead: () => `${V}/canvas/history/read`,
84
+ canvasHistoryStats: () => `${V}/canvas/history/stats`,
84
85
  canvasSnapshot: () => `${V}/canvas/snapshot`,
85
86
  canvasRoster: () => `${V}/canvas/roster`,
86
87
  canvasPrune: () => `${V}/canvas/prune`,
@@ -8,6 +8,8 @@ export declare function envNodeCwd(): string | undefined;
8
8
  * undefined. Cleared (not read) via `delete process.env['CRTR_MODEL_INTENT']`
9
9
  * in `runtime/broker.ts` — a mutation, not a read, so it stays there. */
10
10
  export declare function envModelIntent(): string | undefined;
11
+ /** Whether the launch recipe requires this broker to keep its exact provider/model. */
12
+ export declare function envModelExact(): boolean;
11
13
  /** The raw `CRTR_HOME` override, unresolved. Use `crtrHome()`
12
14
  * (`core/canvas/paths.ts`) to get the resolved canvas-home path; use this
13
15
  * only when a caller needs the override itself — to check whether one is
@@ -67,6 +69,14 @@ export declare function envWarnLiveBrokers(): number | undefined;
67
69
  /** Test-only unattended-park interval override (`CRTR_TEST_UNATTENDED_PARK_MS`),
68
70
  * gated by `envNoDaemonAutostart()` at the call site; no production default. */
69
71
  export declare function envTestUnattendedParkMs(): number | undefined;
72
+ /** Production unattended-park interval override (`CRTR_UNATTENDED_PARK_MS`), in
73
+ * milliseconds; wins over the user-scope config value
74
+ * (`readConfig('user').lifecycle.unattendedParkMs`, itself defaulting to 15
75
+ * min) whenever set, autostart or not. Unlike `CRTR_TEST_UNATTENDED_PARK_MS`
76
+ * this is not gated on `envNoDaemonAutostart()`: it is the env escape hatch
77
+ * above the configured knob a deployment sets to tune how long an eligible
78
+ * resident idles before its parking turn. */
79
+ export declare function envUnattendedParkMs(): number | undefined;
70
80
  /** Test-only park-summary grace-period override
71
81
  * (`CRTR_TEST_PARK_SUMMARY_GRACE_MS`); no production default. */
72
82
  export declare function envTestParkSummaryGraceMs(): number | undefined;
@@ -40,6 +40,10 @@ export function envNodeCwd() {
40
40
  export function envModelIntent() {
41
41
  return process.env['CRTR_MODEL_INTENT'];
42
42
  }
43
+ /** Whether the launch recipe requires this broker to keep its exact provider/model. */
44
+ export function envModelExact() {
45
+ return process.env['CRTR_MODEL_EXACT'] === '1';
46
+ }
43
47
  /** The raw `CRTR_HOME` override, unresolved. Use `crtrHome()`
44
48
  * (`core/canvas/paths.ts`) to get the resolved canvas-home path; use this
45
49
  * only when a caller needs the override itself — to check whether one is
@@ -140,10 +144,11 @@ export function envDebug() {
140
144
  return process.env['CRTR_DEBUG'] === '1';
141
145
  }
142
146
  // Precedence — broker-supervision.ts's threshold/interval overrides. Each
143
- // returns the raw parsed value with NO default: the caller (config for the
144
- // thresholds, a hardcoded production constant for the intervals) supplies
145
- // the default, and env wins over it when set. Undefined, unparseable, or
146
- // non-positive all mean "no override" the caller's own default applies.
147
+ // returns the raw parsed value with NO default: the caller supplies the
148
+ // default (user config for the broker thresholds and the unattended-park
149
+ // interval, a hardcoded constant for the test-only park-summary grace), and
150
+ // env wins over it when set. Undefined, unparseable, or non-positive all mean
151
+ // "no override" — the caller's own default applies.
147
152
  function parsePositiveInteger(raw) {
148
153
  if (raw === undefined || raw === '')
149
154
  return undefined;
@@ -171,6 +176,16 @@ function parsePositiveMsNoDefault(raw) {
171
176
  export function envTestUnattendedParkMs() {
172
177
  return parsePositiveMsNoDefault(process.env['CRTR_TEST_UNATTENDED_PARK_MS']);
173
178
  }
179
+ /** Production unattended-park interval override (`CRTR_UNATTENDED_PARK_MS`), in
180
+ * milliseconds; wins over the user-scope config value
181
+ * (`readConfig('user').lifecycle.unattendedParkMs`, itself defaulting to 15
182
+ * min) whenever set, autostart or not. Unlike `CRTR_TEST_UNATTENDED_PARK_MS`
183
+ * this is not gated on `envNoDaemonAutostart()`: it is the env escape hatch
184
+ * above the configured knob a deployment sets to tune how long an eligible
185
+ * resident idles before its parking turn. */
186
+ export function envUnattendedParkMs() {
187
+ return parsePositiveMsNoDefault(process.env['CRTR_UNATTENDED_PARK_MS']);
188
+ }
174
189
  /** Test-only park-summary grace-period override
175
190
  * (`CRTR_TEST_PARK_SUMMARY_GRACE_MS`); no production default. */
176
191
  export function envTestParkSummaryGraceMs() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/crouter-api",
3
- "version": "0.3.262",
3
+ "version": "0.3.269",
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",