agent-director 0.11.1 → 0.13.0

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/dist/index.js CHANGED
@@ -27,7 +27,9 @@ var exports_errors = {};
27
27
  __export(exports_errors, {
28
28
  errorFromEnvelope: () => errorFromEnvelope,
29
29
  TS_ONLY_ERROR_NAMES: () => TS_ONLY_ERROR_NAMES,
30
+ ErrUnknownVerb: () => ErrUnknownVerb,
30
31
  ErrUnknownErrorName: () => ErrUnknownErrorName,
32
+ ErrTrailWrite: () => ErrTrailWrite,
31
33
  ErrTmuxUnresponsive: () => ErrTmuxUnresponsive,
32
34
  ErrTmuxSessionNameTooLong: () => ErrTmuxSessionNameTooLong,
33
35
  ErrTmuxSessionNameInvalid: () => ErrTmuxSessionNameInvalid,
@@ -42,33 +44,45 @@ __export(exports_errors, {
42
44
  ErrTemplateNameUnsafe: () => ErrTemplateNameUnsafe,
43
45
  ErrTemplateMalformed: () => ErrTemplateMalformed,
44
46
  ErrTemplateExists: () => ErrTemplateExists,
47
+ ErrTemplateAgentMissing: () => ErrTemplateAgentMissing,
45
48
  ErrSystemInstallUnreachable: () => ErrSystemInstallUnreachable,
46
49
  ErrSystemInstallTooOld: () => ErrSystemInstallTooOld,
47
50
  ErrSystemInstallNotFound: () => ErrSystemInstallNotFound,
48
51
  ErrSystemInstallDisappeared: () => ErrSystemInstallDisappeared,
52
+ ErrSubmissionUnconfirmed: () => ErrSubmissionUnconfirmed,
49
53
  ErrStoreOpen: () => ErrStoreOpen,
54
+ ErrStoreBusy: () => ErrStoreBusy,
50
55
  ErrSpawnNotResumable: () => ErrSpawnNotResumable,
51
56
  ErrSpawnNotPausable: () => ErrSpawnNotPausable,
52
57
  ErrSpawnNotInteractive: () => ErrSpawnNotInteractive,
53
58
  ErrSpawnNotFound: () => ErrSpawnNotFound,
54
59
  ErrSpawnDeniedFlag: () => ErrSpawnDeniedFlag,
55
60
  ErrSendKeysWhileRelayed: () => ErrSendKeysWhileRelayed,
61
+ ErrSchemaMismatch: () => ErrSchemaMismatch,
62
+ ErrSchemaMigrationRequired: () => ErrSchemaMigrationRequired,
56
63
  ErrReservedEnvKey: () => ErrReservedEnvKey,
57
64
  ErrRelayModeOff: () => ErrRelayModeOff,
58
65
  ErrRelayModeInvalid: () => ErrRelayModeInvalid,
59
66
  ErrRelayFallenBack: () => ErrRelayFallenBack,
60
67
  ErrProbeUnsupported: () => ErrProbeUnsupported,
68
+ ErrPermissionsUnsupported: () => ErrPermissionsUnsupported,
61
69
  ErrPermissionRequestNotFound: () => ErrPermissionRequestNotFound,
62
70
  ErrPauseTimeout: () => ErrPauseTimeout,
71
+ ErrPaneChanged: () => ErrPaneChanged,
72
+ ErrPaneAnswerInProgress: () => ErrPaneAnswerInProgress,
73
+ ErrOldLayout: () => ErrOldLayout,
63
74
  ErrNoSessionId: () => ErrNoSessionId,
64
75
  ErrNoOpenPermissionRequest: () => ErrNoOpenPermissionRequest,
65
76
  ErrMissingRequestToken: () => ErrMissingRequestToken,
66
77
  ErrListInvalidLabel: () => ErrListInvalidLabel,
67
78
  ErrJsonlNeverWritten: () => ErrJsonlNeverWritten,
68
79
  ErrJsonlMissing: () => ErrJsonlMissing,
80
+ ErrJSONMarshal: () => ErrJSONMarshal,
69
81
  ErrInvalidFlags: () => ErrInvalidFlags,
70
82
  ErrInvalidDecision: () => ErrInvalidDecision,
83
+ ErrInternal: () => ErrInternal,
71
84
  ErrInstanceIdCollision: () => ErrInstanceIdCollision,
85
+ ErrDialogMaybeOpen: () => ErrDialogMaybeOpen,
72
86
  ErrCwdNotFound: () => ErrCwdNotFound,
73
87
  ErrCwdNotAPath: () => ErrCwdNotAPath,
74
88
  ErrCwdNotADirectory: () => ErrCwdNotADirectory,
@@ -76,11 +90,15 @@ __export(exports_errors, {
76
90
  ErrConsumerSignal: () => ErrConsumerSignal,
77
91
  ErrConfigMalformed: () => ErrConfigMalformed,
78
92
  ErrClientClosed: () => ErrClientClosed,
93
+ ErrClaimTooSoon: () => ErrClaimTooSoon,
79
94
  ErrCallerCwdUnreachable: () => ErrCallerCwdUnreachable,
80
95
  ErrCallTimeout: () => ErrCallTimeout,
81
96
  ErrBunVersionTooOld: () => ErrBunVersionTooOld,
82
97
  ErrAmbiguousRequest: () => ErrAmbiguousRequest,
83
98
  ErrAlreadyDecided: () => ErrAlreadyDecided,
99
+ ErrAgentMissing: () => ErrAgentMissing,
100
+ ErrAgentInvalid: () => ErrAgentInvalid,
101
+ ErrAgentArgsMismatch: () => ErrAgentArgsMismatch,
84
102
  AgentDirectorError: () => AgentDirectorError
85
103
  });
86
104
 
@@ -103,11 +121,13 @@ class AgentDirectorError extends Error {
103
121
  verb;
104
122
  errName;
105
123
  errDescription;
106
- constructor(verb, err_name, err_description) {
124
+ errDetails;
125
+ constructor(verb, err_name, err_description, err_details) {
107
126
  super(`${err_name}: ${err_description}`);
108
127
  this.verb = verb;
109
128
  this.errName = err_name;
110
129
  this.errDescription = err_description;
130
+ this.errDetails = err_details ?? null;
111
131
  this.name = this.constructor.name;
112
132
  Object.setPrototypeOf(this, new.target.prototype);
113
133
  }
@@ -266,6 +286,18 @@ class ErrSpawnDeniedFlag extends AgentDirectorError {
266
286
  class ErrReservedEnvKey extends AgentDirectorError {
267
287
  }
268
288
 
289
+ class ErrAgentMissing extends AgentDirectorError {
290
+ }
291
+
292
+ class ErrAgentInvalid extends AgentDirectorError {
293
+ }
294
+
295
+ class ErrAgentArgsMismatch extends AgentDirectorError {
296
+ }
297
+
298
+ class ErrPermissionsUnsupported extends AgentDirectorError {
299
+ }
300
+
269
301
  class ErrInstanceIdCollision extends AgentDirectorError {
270
302
  }
271
303
 
@@ -305,6 +337,9 @@ class ErrTmuxKillFailed extends AgentDirectorError {
305
337
  class ErrSpawnNotInteractive extends AgentDirectorError {
306
338
  }
307
339
 
340
+ class ErrSubmissionUnconfirmed extends AgentDirectorError {
341
+ }
342
+
308
343
  class ErrSendKeysWhileRelayed extends AgentDirectorError {
309
344
  }
310
345
 
@@ -329,6 +364,9 @@ class ErrTemplateMalformed extends AgentDirectorError {
329
364
  class ErrTemplateExists extends AgentDirectorError {
330
365
  }
331
366
 
367
+ class ErrTemplateAgentMissing extends AgentDirectorError {
368
+ }
369
+
332
370
  class ErrProbeUnsupported extends AgentDirectorError {
333
371
  }
334
372
 
@@ -350,6 +388,18 @@ class ErrRelayModeOff extends AgentDirectorError {
350
388
  class ErrRelayFallenBack extends AgentDirectorError {
351
389
  }
352
390
 
391
+ class ErrPaneChanged extends AgentDirectorError {
392
+ }
393
+
394
+ class ErrPaneAnswerInProgress extends AgentDirectorError {
395
+ }
396
+
397
+ class ErrClaimTooSoon extends AgentDirectorError {
398
+ }
399
+
400
+ class ErrDialogMaybeOpen extends AgentDirectorError {
401
+ }
402
+
353
403
  class ErrInvalidDecision extends AgentDirectorError {
354
404
  }
355
405
 
@@ -365,6 +415,9 @@ class ErrPermissionRequestNotFound extends AgentDirectorError {
365
415
  class ErrAmbiguousRequest extends AgentDirectorError {
366
416
  }
367
417
 
418
+ class ErrStoreBusy extends AgentDirectorError {
419
+ }
420
+
368
421
  class ErrMissingRequestToken extends AgentDirectorError {
369
422
  }
370
423
 
@@ -376,6 +429,27 @@ class ErrConfigMalformed extends AgentDirectorError {
376
429
 
377
430
  class ErrStoreOpen extends AgentDirectorError {
378
431
  }
432
+
433
+ class ErrSchemaMismatch extends AgentDirectorError {
434
+ }
435
+
436
+ class ErrSchemaMigrationRequired extends AgentDirectorError {
437
+ }
438
+
439
+ class ErrOldLayout extends AgentDirectorError {
440
+ }
441
+
442
+ class ErrUnknownVerb extends AgentDirectorError {
443
+ }
444
+
445
+ class ErrJSONMarshal extends AgentDirectorError {
446
+ }
447
+
448
+ class ErrTrailWrite extends AgentDirectorError {
449
+ }
450
+
451
+ class ErrInternal extends AgentDirectorError {
452
+ }
379
453
  var ERROR_TABLE = {
380
454
  ErrCwdMissing,
381
455
  ErrCwdNotAPath,
@@ -384,6 +458,10 @@ var ERROR_TABLE = {
384
458
  ErrRelayModeInvalid,
385
459
  ErrSpawnDeniedFlag,
386
460
  ErrReservedEnvKey,
461
+ ErrAgentMissing,
462
+ ErrAgentInvalid,
463
+ ErrAgentArgsMismatch,
464
+ ErrPermissionsUnsupported,
387
465
  ErrInstanceIdCollision,
388
466
  ErrTmuxSessionNameEmpty,
389
467
  ErrTmuxSessionNameInvalid,
@@ -393,6 +471,7 @@ var ERROR_TABLE = {
393
471
  ErrAlreadyDecided,
394
472
  ErrPermissionRequestNotFound,
395
473
  ErrAmbiguousRequest,
474
+ ErrStoreBusy,
396
475
  ErrTmuxNotAvailable,
397
476
  ErrTmuxSessionCreate,
398
477
  ErrTmuxSendKeys,
@@ -401,6 +480,7 @@ var ERROR_TABLE = {
401
480
  ErrTmuxSessionConflict,
402
481
  ErrTmuxKillFailed,
403
482
  ErrSpawnNotInteractive,
483
+ ErrSubmissionUnconfirmed,
404
484
  ErrSendKeysWhileRelayed,
405
485
  ErrSpawnNotPausable,
406
486
  ErrPauseTimeout,
@@ -411,6 +491,10 @@ var ERROR_TABLE = {
411
491
  ErrJsonlNeverWritten,
412
492
  ErrRelayModeOff,
413
493
  ErrRelayFallenBack,
494
+ ErrPaneChanged,
495
+ ErrPaneAnswerInProgress,
496
+ ErrClaimTooSoon,
497
+ ErrDialogMaybeOpen,
414
498
  ErrInvalidDecision,
415
499
  ErrMissingRequestToken,
416
500
  ErrInvalidFlags,
@@ -418,21 +502,29 @@ var ERROR_TABLE = {
418
502
  ErrTemplateNotFound,
419
503
  ErrTemplateMalformed,
420
504
  ErrTemplateExists,
505
+ ErrTemplateAgentMissing,
421
506
  ErrProbeUnsupported,
422
507
  ErrConfigMalformed,
423
- ErrStoreOpen
508
+ ErrStoreOpen,
509
+ ErrSchemaMismatch,
510
+ ErrSchemaMigrationRequired,
511
+ ErrOldLayout,
512
+ ErrUnknownVerb,
513
+ ErrJSONMarshal,
514
+ ErrTrailWrite,
515
+ ErrInternal
424
516
  };
425
- function errorFromEnvelope(verb, err_name, err_description) {
517
+ function errorFromEnvelope(verb, err_name, err_description, err_details) {
426
518
  const Ctor = ERROR_TABLE[err_name];
427
519
  if (Ctor) {
428
- return new Ctor(verb, err_name, err_description);
520
+ return new Ctor(verb, err_name, err_description, err_details);
429
521
  }
430
522
  console.warn(`agent-director: unknown err_name "${err_name}" (verb=${verb}); returning base AgentDirectorError`);
431
- return new AgentDirectorError(verb, err_name, err_description);
523
+ return new AgentDirectorError(verb, err_name, err_description, err_details);
432
524
  }
433
525
 
434
526
  // src/internal/discovery.ts
435
- var STANDARD_INSTALL_PATH_RELATIVE = ".agent-director/bin/agent-director";
527
+ var STANDARD_INSTALL_PATH_RELATIVE = ".config/agent-director/bin/agent-director";
436
528
  var CLI_BINARY_NAME = "agent-director";
437
529
  function resolveStandardInstallPath(homeEnv) {
438
530
  if (homeEnv === undefined || homeEnv === "" || !isAbsolute(homeEnv)) {
@@ -802,7 +894,7 @@ async function runProbe(candidatePath) {
802
894
  }
803
895
  // version-floor.json
804
896
  var version_floor_default = {
805
- min_binary_version: "0.7.0"
897
+ min_binary_version: "0.12.0"
806
898
  };
807
899
 
808
900
  // src/internal/constants.ts
@@ -834,10 +926,24 @@ import { statSync as statSync2 } from "fs";
834
926
 
835
927
  // src/internal/argv.ts
836
928
  function buildArgv(cliPath, verb, params, globalOpts) {
929
+ refuseOldKeys(verb, params);
837
930
  const globalFlags = buildGlobalFlags(globalOpts);
838
931
  const verbFlags = buildVerbFlags(verb, params);
839
932
  return [cliPath, ...globalFlags, ...verbFlags];
840
933
  }
934
+ var OLD_PARAM_KEYS = [
935
+ { old: "claude_instance_id", renamed: "instance_id" },
936
+ { old: "claude_args", renamed: "agent_args" }
937
+ ];
938
+ function refuseOldKeys(verb, params) {
939
+ if (typeof params !== "object" || params === null)
940
+ return;
941
+ const found = OLD_PARAM_KEYS.filter(({ old }) => Object.prototype.hasOwnProperty.call(params, old));
942
+ if (found.length === 0)
943
+ return;
944
+ const parts = found.map(({ old, renamed }) => `${JSON.stringify(old)} is no longer accepted; use ${JSON.stringify(renamed)}`);
945
+ throw new ErrInvalidFlags(verb, "ErrInvalidFlags", parts.join("; "));
946
+ }
841
947
  function buildGlobalFlags(opts) {
842
948
  if (!opts)
843
949
  return [];
@@ -848,6 +954,8 @@ function buildGlobalFlags(opts) {
848
954
  f.push("--home", opts.home);
849
955
  if (opts.tmuxCommand !== undefined)
850
956
  f.push("--tmux-command", opts.tmuxCommand);
957
+ if (opts.createIfMissing === false)
958
+ f.push("--create-if-missing", "false");
851
959
  return f;
852
960
  }
853
961
  function buildVerbFlags(verb, params) {
@@ -870,6 +978,8 @@ function buildVerbFlags(verb, params) {
870
978
  return buildDecide(params);
871
979
  case "get-permission":
872
980
  return buildGetPermission(params);
981
+ case "record-pane-answer":
982
+ return buildRecordPaneAnswer(params);
873
983
  case "resume":
874
984
  return buildResume(params);
875
985
  case "find-missing":
@@ -880,6 +990,8 @@ function buildVerbFlags(verb, params) {
880
990
  return buildMakeTemplate(params);
881
991
  case "list":
882
992
  return buildList(params);
993
+ case "list-subagents":
994
+ return buildListSubagents(params);
883
995
  case "pause":
884
996
  return buildPause(params);
885
997
  default: {
@@ -896,8 +1008,10 @@ function buildSpawn(p) {
896
1008
  f.push("--cwd", p.cwd);
897
1009
  if (p.template !== undefined)
898
1010
  f.push("--template", p.template);
899
- if (p.claude_instance_id !== undefined)
900
- f.push("--claude-instance-id", p.claude_instance_id);
1011
+ if (p.agent !== undefined && p.agent !== "")
1012
+ f.push("--agent", p.agent);
1013
+ if (p.instance_id !== undefined)
1014
+ f.push("--instance-id", p.instance_id);
901
1015
  if (p.tmux_session_name !== undefined)
902
1016
  f.push("--tmux-session-name", p.tmux_session_name);
903
1017
  if (p.relay_mode !== undefined && p.relay_mode !== "")
@@ -910,10 +1024,8 @@ function buildSpawn(p) {
910
1024
  for (const lv of p.label)
911
1025
  f.push("--label", lv);
912
1026
  }
913
- if (p.extra_env) {
914
- for (const [k, v] of Object.entries(p.extra_env))
915
- f.push("--extra-env", `${k}=${v}`);
916
- }
1027
+ if (p.extra_env)
1028
+ f.push(...extraEnvFlags("spawn", p.extra_env));
917
1029
  if (p.allow) {
918
1030
  for (const a of p.allow)
919
1031
  f.push("--allow", a);
@@ -926,32 +1038,69 @@ function buildSpawn(p) {
926
1038
  for (const a of p.ask)
927
1039
  f.push("--ask", a);
928
1040
  }
929
- if (p.claude_args && p.claude_args.length > 0) {
930
- f.push("--", ...p.claude_args);
1041
+ if (p.agent_args && p.agent_args.length > 0) {
1042
+ f.push("--", ...p.agent_args);
931
1043
  }
932
1044
  return f;
933
1045
  }
1046
+ function extraEnvFlags(verb, env) {
1047
+ const bad = invalidExtraEnvKey(env);
1048
+ if (bad !== undefined) {
1049
+ const key = JSON.stringify(bad.key);
1050
+ throw new ErrReservedEnvKey(verb, "ErrReservedEnvKey", `extra_env key ${key} is not a valid env-var name: ${bad.problem}; remove ${key} from extra_env, and ${INVALID_ENV_KEY_ALTERNATIVE}`);
1051
+ }
1052
+ const f = [];
1053
+ for (const [k, v] of Object.entries(env))
1054
+ f.push("--extra-env", `${k}=${v}`);
1055
+ return f;
1056
+ }
1057
+ var INVALID_ENV_KEY_ALTERNATIVE = "give each variable its own name as the key (not empty, with no '=' and no NUL byte) and its value as the value";
1058
+ function invalidExtraEnvKey(env) {
1059
+ for (const key of Object.keys(env).sort()) {
1060
+ if (key === "") {
1061
+ return { key, problem: 'it is empty, so tmux would be given "=<value>", which names no variable' };
1062
+ }
1063
+ if (key.includes("=")) {
1064
+ return {
1065
+ key,
1066
+ problem: "it contains '=', and tmux splits each KEY=VALUE entry at its first '=', so it would set a different variable"
1067
+ };
1068
+ }
1069
+ if (key.includes("\x00")) {
1070
+ return { key, problem: "it contains a NUL byte, which no env-var name can hold and no tmux argument can carry" };
1071
+ }
1072
+ }
1073
+ return;
1074
+ }
934
1075
  function buildStatus(p) {
935
- return ["status", "--claude-instance-id", p.claude_instance_id];
1076
+ return ["status", "--instance-id", p.instance_id];
936
1077
  }
937
1078
  function buildGet(p) {
938
- return ["get", "--claude-instance-id", p.claude_instance_id];
1079
+ return ["get", "--instance-id", p.instance_id];
939
1080
  }
940
1081
  function buildSendKeys(p) {
941
- const f = [
942
- "send-keys",
943
- "--claude-instance-id",
944
- p.claude_instance_id,
945
- "--text",
946
- p.text
947
- ];
1082
+ const f = ["send-keys", "--instance-id", p.instance_id];
1083
+ if (p.text !== undefined)
1084
+ f.push("--text", p.text);
948
1085
  if (p.allow_pending === true)
949
1086
  f.push("--allow-pending");
1087
+ if (p.no_enter === true)
1088
+ f.push("--no-enter");
1089
+ if (p.key !== undefined)
1090
+ f.push("--key", p.key);
1091
+ if (p.expect_pane_sha256 !== undefined)
1092
+ f.push("--expect-pane-sha256", p.expect_pane_sha256);
1093
+ if (p.n_lines !== undefined && p.n_lines !== 0)
1094
+ f.push("--n-lines", String(p.n_lines));
1095
+ if (p.request_token !== undefined)
1096
+ f.push("--request-token", p.request_token);
1097
+ if (p.as !== undefined)
1098
+ f.push("--as", p.as);
950
1099
  return f;
951
1100
  }
952
1101
  function buildReadPane(p) {
953
- const f = ["read-pane", "--claude-instance-id", p.claude_instance_id];
954
- if (p.n_lines !== undefined && p.n_lines > 0)
1102
+ const f = ["read-pane", "--instance-id", p.instance_id];
1103
+ if (p.n_lines !== undefined && p.n_lines !== 0)
955
1104
  f.push("--n-lines", String(p.n_lines));
956
1105
  if (p.ansi === true)
957
1106
  f.push("--ansi");
@@ -960,13 +1109,13 @@ function buildReadPane(p) {
960
1109
  return f;
961
1110
  }
962
1111
  function buildKill(p) {
963
- return ["kill", "--claude-instance-id", p.claude_instance_id];
1112
+ return ["kill", "--instance-id", p.instance_id];
964
1113
  }
965
1114
  function buildDecide(p) {
966
1115
  const f = [
967
1116
  "decide",
968
- "--claude-instance-id",
969
- p.claude_instance_id,
1117
+ "--instance-id",
1118
+ p.instance_id,
970
1119
  "--decision",
971
1120
  p.decision
972
1121
  ];
@@ -974,13 +1123,29 @@ function buildDecide(p) {
974
1123
  f.push("--request-token", p.request_token);
975
1124
  if (p.reason !== undefined)
976
1125
  f.push("--reason", p.reason);
1126
+ if (p.max_wait_ms !== undefined)
1127
+ f.push("--max-wait-ms", String(p.max_wait_ms));
977
1128
  return f;
978
1129
  }
979
1130
  function buildGetPermission(p) {
980
1131
  return ["get-permission", "--request-token", p.request_token];
981
1132
  }
1133
+ function buildRecordPaneAnswer(p) {
1134
+ const f = [
1135
+ "record-pane-answer",
1136
+ "--request-token",
1137
+ p.request_token,
1138
+ "--as",
1139
+ p.as,
1140
+ "--expect-pane-sha256",
1141
+ p.expect_pane_sha256
1142
+ ];
1143
+ if (p.n_lines !== undefined && p.n_lines !== 0)
1144
+ f.push("--n-lines", String(p.n_lines));
1145
+ return f;
1146
+ }
982
1147
  function buildResume(p) {
983
- return ["resume", "--claude-instance-id", p.claude_instance_id];
1148
+ return ["resume", "--instance-id", p.instance_id];
984
1149
  }
985
1150
  function buildFindMissing() {
986
1151
  return ["find-missing"];
@@ -995,6 +1160,8 @@ function buildMakeTemplate(p) {
995
1160
  const f = ["make-template", "--name", p.name];
996
1161
  if (p.cwd !== undefined)
997
1162
  f.push("--cwd", p.cwd);
1163
+ if (p.agent !== undefined && p.agent !== "")
1164
+ f.push("--agent", p.agent);
998
1165
  if (p.relay_mode !== undefined && p.relay_mode !== "")
999
1166
  f.push("--relay-mode", p.relay_mode);
1000
1167
  if (p.overwrite === true)
@@ -1003,10 +1170,8 @@ function buildMakeTemplate(p) {
1003
1170
  for (const lv of p.label)
1004
1171
  f.push("--label", lv);
1005
1172
  }
1006
- if (p.extra_env) {
1007
- for (const [k, v] of Object.entries(p.extra_env))
1008
- f.push("--extra-env", `${k}=${v}`);
1009
- }
1173
+ if (p.extra_env)
1174
+ f.push(...extraEnvFlags("make-template", p.extra_env));
1010
1175
  if (p.allow) {
1011
1176
  for (const a of p.allow)
1012
1177
  f.push("--allow", a);
@@ -1019,12 +1184,15 @@ function buildMakeTemplate(p) {
1019
1184
  for (const a of p.ask)
1020
1185
  f.push("--ask", a);
1021
1186
  }
1022
- if (p.claude_args) {
1023
- for (const a of p.claude_args)
1024
- f.push("--claude-args", a);
1187
+ if (p.agent_args) {
1188
+ for (const a of p.agent_args)
1189
+ f.push("--agent-args", a);
1025
1190
  }
1026
1191
  return f;
1027
1192
  }
1193
+ function buildListSubagents(p) {
1194
+ return ["list-subagents", "--instance-id", p.instance_id];
1195
+ }
1028
1196
  function buildList(p) {
1029
1197
  const f = ["list"];
1030
1198
  if (p.state && p.state.length > 0)
@@ -1039,12 +1207,12 @@ function buildList(p) {
1039
1207
  f.push("--cwd", p.cwd);
1040
1208
  if (p.tmux_session_name !== undefined)
1041
1209
  f.push("--tmux-session-name", p.tmux_session_name);
1042
- if (p.limit !== undefined && p.limit > 0)
1210
+ if (p.limit !== undefined && p.limit !== 0)
1043
1211
  f.push("--limit", String(p.limit));
1044
1212
  return f;
1045
1213
  }
1046
1214
  function buildPause(p) {
1047
- return ["pause", "--claude-instance-id", p.claude_instance_id];
1215
+ return ["pause", "--instance-id", p.instance_id];
1048
1216
  }
1049
1217
 
1050
1218
  // src/internal/spawner.ts
@@ -1101,6 +1269,26 @@ var catalog_default = [
1101
1269
  package: "spawn",
1102
1270
  description: ""
1103
1271
  },
1272
+ {
1273
+ name: "ErrAgentMissing",
1274
+ package: "spawn",
1275
+ description: ""
1276
+ },
1277
+ {
1278
+ name: "ErrAgentInvalid",
1279
+ package: "spawn",
1280
+ description: ""
1281
+ },
1282
+ {
1283
+ name: "ErrAgentArgsMismatch",
1284
+ package: "spawn",
1285
+ description: ""
1286
+ },
1287
+ {
1288
+ name: "ErrPermissionsUnsupported",
1289
+ package: "spawn",
1290
+ description: ""
1291
+ },
1104
1292
  {
1105
1293
  name: "ErrInstanceIdCollision",
1106
1294
  package: "spawn",
@@ -1181,6 +1369,11 @@ var catalog_default = [
1181
1369
  package: "api",
1182
1370
  description: ""
1183
1371
  },
1372
+ {
1373
+ name: "ErrSubmissionUnconfirmed",
1374
+ package: "api",
1375
+ description: ""
1376
+ },
1184
1377
  {
1185
1378
  name: "ErrListInvalidLabel",
1186
1379
  package: "api",
@@ -1206,6 +1399,11 @@ var catalog_default = [
1206
1399
  package: "config",
1207
1400
  description: ""
1208
1401
  },
1402
+ {
1403
+ name: "ErrTemplateAgentMissing",
1404
+ package: "config",
1405
+ description: ""
1406
+ },
1209
1407
  {
1210
1408
  name: "ErrProbeUnsupported",
1211
1409
  package: "probe",
@@ -1241,6 +1439,26 @@ var catalog_default = [
1241
1439
  package: "api",
1242
1440
  description: ""
1243
1441
  },
1442
+ {
1443
+ name: "ErrPaneChanged",
1444
+ package: "api",
1445
+ description: ""
1446
+ },
1447
+ {
1448
+ name: "ErrPaneAnswerInProgress",
1449
+ package: "api",
1450
+ description: ""
1451
+ },
1452
+ {
1453
+ name: "ErrClaimTooSoon",
1454
+ package: "api",
1455
+ description: ""
1456
+ },
1457
+ {
1458
+ name: "ErrDialogMaybeOpen",
1459
+ package: "api",
1460
+ description: ""
1461
+ },
1244
1462
  {
1245
1463
  name: "ErrInvalidDecision",
1246
1464
  package: "api",
@@ -1276,6 +1494,11 @@ var catalog_default = [
1276
1494
  package: "store",
1277
1495
  description: ""
1278
1496
  },
1497
+ {
1498
+ name: "ErrStoreBusy",
1499
+ package: "store",
1500
+ description: ""
1501
+ },
1279
1502
  {
1280
1503
  name: "ErrConfigMalformed",
1281
1504
  package: "clisetup",
@@ -1285,6 +1508,41 @@ var catalog_default = [
1285
1508
  name: "ErrStoreOpen",
1286
1509
  package: "clisetup",
1287
1510
  description: ""
1511
+ },
1512
+ {
1513
+ name: "ErrSchemaMismatch",
1514
+ package: "clisetup",
1515
+ description: ""
1516
+ },
1517
+ {
1518
+ name: "ErrSchemaMigrationRequired",
1519
+ package: "clisetup",
1520
+ description: ""
1521
+ },
1522
+ {
1523
+ name: "ErrOldLayout",
1524
+ package: "clisetup",
1525
+ description: ""
1526
+ },
1527
+ {
1528
+ name: "ErrUnknownVerb",
1529
+ package: "clisetup",
1530
+ description: ""
1531
+ },
1532
+ {
1533
+ name: "ErrJSONMarshal",
1534
+ package: "clisetup",
1535
+ description: ""
1536
+ },
1537
+ {
1538
+ name: "ErrTrailWrite",
1539
+ package: "clisetup",
1540
+ description: ""
1541
+ },
1542
+ {
1543
+ name: "ErrInternal",
1544
+ package: "errnames",
1545
+ description: ""
1288
1546
  }
1289
1547
  ];
1290
1548
 
@@ -1306,9 +1564,11 @@ function throwFromEnvelope(verb, envelope) {
1306
1564
  const errName = env.err_name;
1307
1565
  const envelopeRecord = envelope;
1308
1566
  const errDescription = typeof envelopeRecord["err_description"] === "string" ? envelopeRecord["err_description"] : "";
1567
+ const rawDetails = envelopeRecord["err_details"];
1568
+ const errDetails = typeof rawDetails === "object" && rawDetails !== null && !Array.isArray(rawDetails) ? rawDetails : null;
1309
1569
  const Ctor = errorMap.get(errName);
1310
1570
  if (Ctor !== undefined) {
1311
- throw new Ctor(verb, errName, errDescription);
1571
+ throw new Ctor(verb, errName, errDescription, errDetails);
1312
1572
  }
1313
1573
  throw new ErrUnknownErrorName(errName, envelope);
1314
1574
  }
@@ -1353,6 +1613,8 @@ class SubprocessClient {
1353
1613
  g.tmuxCommand = opts.tmuxCommand;
1354
1614
  if (opts.home !== undefined)
1355
1615
  g.home = opts.home;
1616
+ if (opts.createIfMissing !== undefined)
1617
+ g.createIfMissing = opts.createIfMissing;
1356
1618
  this.#globalOpts = g;
1357
1619
  this.#open = true;
1358
1620
  this.#tail = Promise.resolve();
@@ -1536,6 +1798,10 @@ class SubprocessClient {
1536
1798
  this.#assertOpen();
1537
1799
  return this.#enqueue("get-permission", params);
1538
1800
  }
1801
+ async recordPaneAnswer(params) {
1802
+ this.#assertOpen();
1803
+ return this.#enqueue("record-pane-answer", params);
1804
+ }
1539
1805
  async resume(params) {
1540
1806
  this.#assertOpen();
1541
1807
  return this.#enqueue("resume", params);
@@ -1556,6 +1822,10 @@ class SubprocessClient {
1556
1822
  this.#assertOpen();
1557
1823
  return this.#enqueue("list", params);
1558
1824
  }
1825
+ async listSubagents(params) {
1826
+ this.#assertOpen();
1827
+ return this.#enqueue("list-subagents", params);
1828
+ }
1559
1829
  async pause(params) {
1560
1830
  this.#assertOpen();
1561
1831
  return this.#enqueue("pause", params);
@@ -1661,7 +1931,9 @@ export {
1661
1931
  resolveSystemBinary,
1662
1932
  errorFromEnvelope,
1663
1933
  MIN_BINARY_VERSION,
1934
+ ErrUnknownVerb,
1664
1935
  ErrUnknownErrorName,
1936
+ ErrTrailWrite,
1665
1937
  ErrTmuxUnresponsive,
1666
1938
  ErrTmuxSessionNameTooLong,
1667
1939
  ErrTmuxSessionNameInvalid,
@@ -1676,33 +1948,45 @@ export {
1676
1948
  ErrTemplateNameUnsafe,
1677
1949
  ErrTemplateMalformed,
1678
1950
  ErrTemplateExists,
1951
+ ErrTemplateAgentMissing,
1679
1952
  ErrSystemInstallUnreachable,
1680
1953
  ErrSystemInstallTooOld,
1681
1954
  ErrSystemInstallNotFound,
1682
1955
  ErrSystemInstallDisappeared,
1956
+ ErrSubmissionUnconfirmed,
1683
1957
  ErrStoreOpen,
1958
+ ErrStoreBusy,
1684
1959
  ErrSpawnNotResumable,
1685
1960
  ErrSpawnNotPausable,
1686
1961
  ErrSpawnNotInteractive,
1687
1962
  ErrSpawnNotFound,
1688
1963
  ErrSpawnDeniedFlag,
1689
1964
  ErrSendKeysWhileRelayed,
1965
+ ErrSchemaMismatch,
1966
+ ErrSchemaMigrationRequired,
1690
1967
  ErrReservedEnvKey,
1691
1968
  ErrRelayModeOff,
1692
1969
  ErrRelayModeInvalid,
1693
1970
  ErrRelayFallenBack,
1694
1971
  ErrProbeUnsupported,
1972
+ ErrPermissionsUnsupported,
1695
1973
  ErrPermissionRequestNotFound,
1696
1974
  ErrPauseTimeout,
1975
+ ErrPaneChanged,
1976
+ ErrPaneAnswerInProgress,
1977
+ ErrOldLayout,
1697
1978
  ErrNoSessionId,
1698
1979
  ErrNoOpenPermissionRequest,
1699
1980
  ErrMissingRequestToken,
1700
1981
  ErrListInvalidLabel,
1701
1982
  ErrJsonlNeverWritten,
1702
1983
  ErrJsonlMissing,
1984
+ ErrJSONMarshal,
1703
1985
  ErrInvalidFlags,
1704
1986
  ErrInvalidDecision,
1987
+ ErrInternal,
1705
1988
  ErrInstanceIdCollision,
1989
+ ErrDialogMaybeOpen,
1706
1990
  ErrCwdNotFound,
1707
1991
  ErrCwdNotAPath,
1708
1992
  ErrCwdNotADirectory,
@@ -1710,11 +1994,15 @@ export {
1710
1994
  ErrConsumerSignal,
1711
1995
  ErrConfigMalformed,
1712
1996
  ErrClientClosed,
1997
+ ErrClaimTooSoon,
1713
1998
  ErrCallerCwdUnreachable,
1714
1999
  ErrCallTimeout,
1715
2000
  ErrBunVersionTooOld,
1716
2001
  ErrAmbiguousRequest,
1717
2002
  ErrAlreadyDecided,
2003
+ ErrAgentMissing,
2004
+ ErrAgentInvalid,
2005
+ ErrAgentArgsMismatch,
1718
2006
  DEV_SENTINEL_VERSION,
1719
2007
  Client,
1720
2008
  AgentDirectorError