@humain/terminal 0.0.4-beta.2 → 0.0.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.5] - 2026-08-25
4
+
5
+ ### Added
6
+
7
+ - Added exact per-child model selection for built-in `subagent` single, parallel, and chain calls, with agent and parent-model fallbacks.
8
+
9
+ ### Changed
10
+
11
+ - Updated the bundled `pi-web-access` implementation to upstream `0.24.2`.
12
+
3
13
  ## [0.0.4-beta.2] - 2026-08-22
4
14
 
5
15
  ### Added
@@ -62,14 +62,17 @@ export interface SubagentDetails {
62
62
  declare const SubagentParams: Type.TObject<{
63
63
  agent: Type.TOptional<Type.TString>;
64
64
  task: Type.TOptional<Type.TString>;
65
+ model: Type.TOptional<Type.TString>;
65
66
  tasks: Type.TOptional<Type.TArray<Type.TObject<{
66
67
  agent: Type.TString;
67
68
  task: Type.TString;
69
+ model: Type.TOptional<Type.TString>;
68
70
  cwd: Type.TOptional<Type.TString>;
69
71
  }>>>;
70
72
  chain: Type.TOptional<Type.TArray<Type.TObject<{
71
73
  agent: Type.TString;
72
74
  task: Type.TString;
75
+ model: Type.TOptional<Type.TString>;
73
76
  cwd: Type.TOptional<Type.TString>;
74
77
  }>>>;
75
78
  agentScope: Type.TOptional<Type.TUnsafe<"both" | "project" | "user">>;
@@ -1 +1 @@
1
- {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../../src/core/tools/subagent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI/B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAU/E,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AA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,oBAAoB,CAmBnF;AAoGD,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,oBAAoB,EAAE,CAAC;CAChC;AAgTD,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;EAWlB,CAAC;AAEH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,OAAO,cAAc,EAAE,eAAe,CAAC,CAsnBhH;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,2EAE7C"}
@@ -297,7 +297,7 @@ function getCliInvocation(args) {
297
297
  }
298
298
  return { command: "humain-terminal", args };
299
299
  }
300
- async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, signal, onUpdate, makeDetails) {
300
+ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, model, parentModel, signal, onUpdate, makeDetails) {
301
301
  const agent = agents.find((a) => a.name === agentName);
302
302
  if (!agent) {
303
303
  const available = agents.map((a) => `"${a.name}"`).join(", ") || "none";
@@ -312,9 +312,26 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
312
312
  step,
313
313
  };
314
314
  }
315
+ const selectedModel = model ?? agent.model;
316
+ if (!selectedModel && !parentModel) {
317
+ const errorMessage = "Cannot run subagents without a selected model.";
318
+ return {
319
+ agent: agentName,
320
+ agentSource: agent.source,
321
+ task,
322
+ exitCode: 1,
323
+ messages: [],
324
+ stderr: errorMessage,
325
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
326
+ errorMessage,
327
+ step,
328
+ };
329
+ }
315
330
  const args = ["--mode", "json", "-p", "--no-session"];
316
- if (agent.model)
317
- args.push("--model", agent.model);
331
+ if (selectedModel)
332
+ args.push("--model", selectedModel);
333
+ else if (parentModel)
334
+ args.push("--provider", parentModel.provider, "--model", parentModel.id);
318
335
  if (agent.tools && agent.tools.length > 0)
319
336
  args.push("--tools", agent.tools.join(","));
320
337
  let tmpPromptDir = null;
@@ -327,7 +344,7 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
327
344
  messages: [],
328
345
  stderr: "",
329
346
  usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
330
- model: agent.model,
347
+ model: selectedModel ?? (parentModel ? `${parentModel.provider}/${parentModel.id}` : undefined),
331
348
  step,
332
349
  };
333
350
  const emitUpdate = () => {
@@ -380,8 +397,8 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
380
397
  currentResult.usage.cost += usage.cost?.total || 0;
381
398
  currentResult.usage.contextTokens = usage.totalTokens || 0;
382
399
  }
383
- if (!currentResult.model && msg.model)
384
- currentResult.model = msg.model;
400
+ if (msg.model)
401
+ currentResult.model = msg.responseModel ?? msg.model;
385
402
  if (msg.stopReason)
386
403
  currentResult.stopReason = msg.stopReason;
387
404
  if (msg.errorMessage)
@@ -452,11 +469,13 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
452
469
  const TaskItem = Type.Object({
453
470
  agent: Type.String({ description: "Name of the agent to invoke" }),
454
471
  task: Type.String({ description: "Task to delegate to the agent" }),
472
+ model: Type.Optional(Type.String({ description: "Canonical provider/model for this child" })),
455
473
  cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
456
474
  });
457
475
  const ChainItem = Type.Object({
458
476
  agent: Type.String({ description: "Name of the agent to invoke" }),
459
477
  task: Type.String({ description: "Task with optional {previous} placeholder for prior output" }),
478
+ model: Type.Optional(Type.String({ description: "Canonical provider/model for this child" })),
460
479
  cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
461
480
  });
462
481
  const AgentScopeSchema = StringEnum(["user", "project", "both"], {
@@ -466,6 +485,7 @@ const AgentScopeSchema = StringEnum(["user", "project", "both"], {
466
485
  const SubagentParams = Type.Object({
467
486
  agent: Type.Optional(Type.String({ description: "Name of the agent to invoke (for single mode)" })),
468
487
  task: Type.Optional(Type.String({ description: "Task to delegate (for single mode)" })),
488
+ model: Type.Optional(Type.String({ description: "Canonical provider/model for the single child" })),
469
489
  tasks: Type.Optional(Type.Array(TaskItem, { description: "Array of {agent, task} for parallel execution" })),
470
490
  chain: Type.Optional(Type.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })),
471
491
  agentScope: Type.Optional(AgentScopeSchema),
@@ -490,6 +510,7 @@ export function createSubagentToolDefinition(cwd) {
490
510
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
491
511
  const agentScope = params.agentScope ?? "user";
492
512
  const defaultCwd = ctx?.cwd ?? cwd;
513
+ const parentModel = ctx?.model;
493
514
  const discovery = discoverAgents(defaultCwd, agentScope);
494
515
  const agents = discovery.agents;
495
516
  const confirmProjectAgents = params.confirmProjectAgents ?? true;
@@ -596,7 +617,7 @@ export function createSubagentToolDefinition(cwd) {
596
617
  }
597
618
  }
598
619
  : undefined;
599
- const result = await runSingleAgent(defaultCwd, agents, step.agent, taskWithContext, step.cwd, i + 1, signal, chainUpdate, makeDetails("chain"));
620
+ const result = await runSingleAgent(defaultCwd, agents, step.agent, taskWithContext, step.cwd, i + 1, step.model, parentModel, signal, chainUpdate, makeDetails("chain"));
600
621
  results.push(result);
601
622
  const isError = isFailedResult(result);
602
623
  if (isError) {
@@ -656,7 +677,7 @@ export function createSubagentToolDefinition(cwd) {
656
677
  }
657
678
  };
658
679
  const results = await mapWithConcurrencyLimit(params.tasks, MAX_CONCURRENCY, async (t, index) => {
659
- const result = await runSingleAgent(defaultCwd, agents, t.agent, t.task, t.cwd, undefined, signal,
680
+ const result = await runSingleAgent(defaultCwd, agents, t.agent, t.task, t.cwd, undefined, t.model, parentModel, signal,
660
681
  // Per-task update callback
661
682
  (partial) => {
662
683
  if (partial.details?.results[0]) {
@@ -687,7 +708,7 @@ export function createSubagentToolDefinition(cwd) {
687
708
  };
688
709
  }
689
710
  if (params.agent && params.task) {
690
- const result = await runSingleAgent(defaultCwd, agents, params.agent, params.task, params.cwd, undefined, signal, onUpdate, makeDetails("single"));
711
+ const result = await runSingleAgent(defaultCwd, agents, params.agent, params.task, params.cwd, undefined, params.model, parentModel, signal, onUpdate, makeDetails("single"));
691
712
  const isError = isFailedResult(result);
692
713
  if (isError) {
693
714
  const errorMsg = getResultOutput(result);