neurastream 0.3.34 → 0.3.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.3.34",
3
+ "version": "0.3.35",
4
4
  "description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -52,7 +52,7 @@ import { createLimitWake } from "./limit-wake.ts";
52
52
  import "./package-ops.ts";
53
53
  import { createRateLimitController, limitProbeSpawn, recordProviderOutFromRateLimit, recordProviderOutFromTask } from "./rate-limit-controller.ts";
54
54
  import { createRolloverController } from "./rollover-controller.ts";
55
- import { defaultCompletedResults, defaultRunSource, runIdOf } from "./sessions.ts";
55
+ import { defaultCompletedResults, defaultRunSource, runIdOf, SPAWN_NAME_ENTRY } from "./sessions.ts";
56
56
  import { parseTraceFile } from "./traces.ts";
57
57
  import { asCtx, asRecord, asRolloverCtx, asString, call, isMain, lastAssistantIn, toExtensionResult, type EventReply, type ExtensionHost, type RolloverCtx } from "./types.ts";
58
58
 
@@ -422,6 +422,12 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
422
422
 
423
423
  pi.on("session_start", (_e, ctx) => {
424
424
  const c = asCtx(ctx);
425
+ // A herdr-spawned helper names its own session file (plan 20261205_1947): without the
426
+ // marker the dated file builds as `MAIN hh-mm-ss`, kind main, and agent-score refuses
427
+ // the spawn --name. Task subs (no ROLE) and Main write nothing.
428
+ if (process.env.NEURASTREAM_ROLE === "sub" && process.env.NEURASTREAM_AGENT_ID) {
429
+ pi.appendEntry(SPAWN_NAME_ENTRY, { id: process.env.NEURASTREAM_AGENT_ID });
430
+ }
425
431
  // Original: proceed only when no agent is set or it is the main session.
426
432
  if (c.hasAgent && c.kind !== "main") return;
427
433
  // One live Main session per id (plan 20261103_1146 P2): the first session_start in this
@@ -63,6 +63,11 @@ function costOf(m: Record<string, unknown>): number {
63
63
  return c && typeof c.total === "number" ? c.total : 0;
64
64
  }
65
65
 
66
+ /** Custom session-entry type that names a herdr-spawned helper (plan 20261205_1947): the
67
+ * extension host writes `{ id: <name> }` at session_start; `build` reads it back so
68
+ * `agent-score`/`agent-ledger` see the run as a named sub instead of `MAIN hh-mm-ss`. */
69
+ export const SPAWN_NAME_ENTRY = "neurastream.agent";
70
+
66
71
  /** Ledger run id for a session file: `MAIN <HH-MM-SS>` for dated main files, stem otherwise. */
67
72
  export function runIdOf(file: string): string {
68
73
  const stem = basename(file).slice(0, -6);
@@ -124,8 +129,10 @@ function build(file: string, cfg: Config, mtime: number, agentsDir: string): Run
124
129
  return null;
125
130
  }
126
131
  const stem = basename(file).slice(0, -6);
127
- const isMain = /^\d{4}/.test(stem);
128
- const id = runIdOf(file);
132
+ // A herdr-spawned helper's dated file carries the spawn-name marker (plan 20261205_1947);
133
+ // seeing it flips both below so the file builds as a named sub.
134
+ let isMain = /^\d{4}/.test(stem);
135
+ let id = runIdOf(file);
129
136
  let model = "unknown";
130
137
  let scoreModel = "unknown";
131
138
  let sawProviderModel = false;
@@ -159,6 +166,15 @@ function build(file: string, cfg: Config, mtime: number, agentsDir: string): Run
159
166
  } catch {
160
167
  continue;
161
168
  }
169
+ if (d.type === "custom" && d.customType === SPAWN_NAME_ENTRY) {
170
+ const named = asObj(d.data)?.id;
171
+ if (typeof named === "string" && named) {
172
+ // The spawn --name replaces the dated file's `MAIN hh-mm-ss` id; every
173
+ // isMain / id.startsWith("MAIN") check below now sees a sub.
174
+ id = named;
175
+ isMain = false;
176
+ }
177
+ }
162
178
  const ts = typeof d.timestamp === "string" ? parseTs(d.timestamp) : null;
163
179
  if (ts !== null) {
164
180
  first = first ?? ts;
@@ -8,6 +8,8 @@ export interface ExtensionHost {
8
8
  registerCommand(name: string, opts: { description?: string; handler: (args: unknown, ctx: unknown) => unknown }): void;
9
9
  sendUserMessage(content: string | ({ type: "text"; text: string } | { type: "image"; data: string; mimeType: string })[]): void;
10
10
  sendMessage(message: { customType: string; content: string; display: boolean }, options: { triggerTurn: boolean; deliverAs: "nextTurn" }): void;
11
+ /** Store a `custom` entry in the session file without entering model context (omp API). */
12
+ appendEntry(customType: string, data?: unknown): void;
11
13
  }
12
14
 
13
15
  /** The parts of a harness call context the handlers look at. */