agent-director 0.11.0 → 0.12.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/README.md +326 -133
- package/dist/errors.d.ts +114 -7
- package/dist/index.d.ts +4 -3
- package/dist/index.js +342 -56
- package/dist/internal/argv.d.ts +28 -15
- package/dist/internal/discovery.d.ts +3 -2
- package/dist/internal/errorMap.d.ts +11 -5
- package/dist/internal/subprocessClient.d.ts +37 -6
- package/dist/internal/verbs.d.ts +4 -4
- package/dist/types.d.ts +687 -152
- package/dist/version-floor.json +1 -1
- package/package.json +1 -1
- package/dist/internal/tilde.d.ts +0 -16
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,43 +44,60 @@ __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
|
+
ErrStoreOpen: () => ErrStoreOpen,
|
|
53
|
+
ErrStoreBusy: () => ErrStoreBusy,
|
|
49
54
|
ErrSpawnNotResumable: () => ErrSpawnNotResumable,
|
|
50
55
|
ErrSpawnNotPausable: () => ErrSpawnNotPausable,
|
|
51
56
|
ErrSpawnNotInteractive: () => ErrSpawnNotInteractive,
|
|
52
57
|
ErrSpawnNotFound: () => ErrSpawnNotFound,
|
|
53
58
|
ErrSpawnDeniedFlag: () => ErrSpawnDeniedFlag,
|
|
54
59
|
ErrSendKeysWhileRelayed: () => ErrSendKeysWhileRelayed,
|
|
60
|
+
ErrSchemaMismatch: () => ErrSchemaMismatch,
|
|
61
|
+
ErrSchemaMigrationRequired: () => ErrSchemaMigrationRequired,
|
|
55
62
|
ErrReservedEnvKey: () => ErrReservedEnvKey,
|
|
56
63
|
ErrRelayModeOff: () => ErrRelayModeOff,
|
|
57
64
|
ErrRelayModeInvalid: () => ErrRelayModeInvalid,
|
|
58
65
|
ErrRelayFallenBack: () => ErrRelayFallenBack,
|
|
59
66
|
ErrProbeUnsupported: () => ErrProbeUnsupported,
|
|
67
|
+
ErrPermissionsUnsupported: () => ErrPermissionsUnsupported,
|
|
60
68
|
ErrPermissionRequestNotFound: () => ErrPermissionRequestNotFound,
|
|
61
69
|
ErrPauseTimeout: () => ErrPauseTimeout,
|
|
70
|
+
ErrPaneChanged: () => ErrPaneChanged,
|
|
71
|
+
ErrPaneAnswerInProgress: () => ErrPaneAnswerInProgress,
|
|
72
|
+
ErrOldLayout: () => ErrOldLayout,
|
|
62
73
|
ErrNoSessionId: () => ErrNoSessionId,
|
|
63
74
|
ErrNoOpenPermissionRequest: () => ErrNoOpenPermissionRequest,
|
|
64
75
|
ErrMissingRequestToken: () => ErrMissingRequestToken,
|
|
65
76
|
ErrListInvalidLabel: () => ErrListInvalidLabel,
|
|
66
77
|
ErrJsonlNeverWritten: () => ErrJsonlNeverWritten,
|
|
67
78
|
ErrJsonlMissing: () => ErrJsonlMissing,
|
|
79
|
+
ErrJSONMarshal: () => ErrJSONMarshal,
|
|
68
80
|
ErrInvalidFlags: () => ErrInvalidFlags,
|
|
69
81
|
ErrInvalidDecision: () => ErrInvalidDecision,
|
|
82
|
+
ErrInternal: () => ErrInternal,
|
|
70
83
|
ErrInstanceIdCollision: () => ErrInstanceIdCollision,
|
|
84
|
+
ErrDialogMaybeOpen: () => ErrDialogMaybeOpen,
|
|
71
85
|
ErrCwdNotFound: () => ErrCwdNotFound,
|
|
72
86
|
ErrCwdNotAPath: () => ErrCwdNotAPath,
|
|
73
87
|
ErrCwdNotADirectory: () => ErrCwdNotADirectory,
|
|
74
88
|
ErrCwdMissing: () => ErrCwdMissing,
|
|
75
89
|
ErrConsumerSignal: () => ErrConsumerSignal,
|
|
90
|
+
ErrConfigMalformed: () => ErrConfigMalformed,
|
|
76
91
|
ErrClientClosed: () => ErrClientClosed,
|
|
92
|
+
ErrClaimTooSoon: () => ErrClaimTooSoon,
|
|
77
93
|
ErrCallerCwdUnreachable: () => ErrCallerCwdUnreachable,
|
|
78
94
|
ErrCallTimeout: () => ErrCallTimeout,
|
|
79
95
|
ErrBunVersionTooOld: () => ErrBunVersionTooOld,
|
|
80
96
|
ErrAmbiguousRequest: () => ErrAmbiguousRequest,
|
|
81
97
|
ErrAlreadyDecided: () => ErrAlreadyDecided,
|
|
98
|
+
ErrAgentMissing: () => ErrAgentMissing,
|
|
99
|
+
ErrAgentInvalid: () => ErrAgentInvalid,
|
|
100
|
+
ErrAgentArgsMismatch: () => ErrAgentArgsMismatch,
|
|
82
101
|
AgentDirectorError: () => AgentDirectorError
|
|
83
102
|
});
|
|
84
103
|
|
|
@@ -101,11 +120,13 @@ class AgentDirectorError extends Error {
|
|
|
101
120
|
verb;
|
|
102
121
|
errName;
|
|
103
122
|
errDescription;
|
|
104
|
-
|
|
123
|
+
errDetails;
|
|
124
|
+
constructor(verb, err_name, err_description, err_details) {
|
|
105
125
|
super(`${err_name}: ${err_description}`);
|
|
106
126
|
this.verb = verb;
|
|
107
127
|
this.errName = err_name;
|
|
108
128
|
this.errDescription = err_description;
|
|
129
|
+
this.errDetails = err_details ?? null;
|
|
109
130
|
this.name = this.constructor.name;
|
|
110
131
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
111
132
|
}
|
|
@@ -264,6 +285,18 @@ class ErrSpawnDeniedFlag extends AgentDirectorError {
|
|
|
264
285
|
class ErrReservedEnvKey extends AgentDirectorError {
|
|
265
286
|
}
|
|
266
287
|
|
|
288
|
+
class ErrAgentMissing extends AgentDirectorError {
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
class ErrAgentInvalid extends AgentDirectorError {
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
class ErrAgentArgsMismatch extends AgentDirectorError {
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
class ErrPermissionsUnsupported extends AgentDirectorError {
|
|
298
|
+
}
|
|
299
|
+
|
|
267
300
|
class ErrInstanceIdCollision extends AgentDirectorError {
|
|
268
301
|
}
|
|
269
302
|
|
|
@@ -327,6 +360,9 @@ class ErrTemplateMalformed extends AgentDirectorError {
|
|
|
327
360
|
class ErrTemplateExists extends AgentDirectorError {
|
|
328
361
|
}
|
|
329
362
|
|
|
363
|
+
class ErrTemplateAgentMissing extends AgentDirectorError {
|
|
364
|
+
}
|
|
365
|
+
|
|
330
366
|
class ErrProbeUnsupported extends AgentDirectorError {
|
|
331
367
|
}
|
|
332
368
|
|
|
@@ -348,6 +384,18 @@ class ErrRelayModeOff extends AgentDirectorError {
|
|
|
348
384
|
class ErrRelayFallenBack extends AgentDirectorError {
|
|
349
385
|
}
|
|
350
386
|
|
|
387
|
+
class ErrPaneChanged extends AgentDirectorError {
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
class ErrPaneAnswerInProgress extends AgentDirectorError {
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
class ErrClaimTooSoon extends AgentDirectorError {
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
class ErrDialogMaybeOpen extends AgentDirectorError {
|
|
397
|
+
}
|
|
398
|
+
|
|
351
399
|
class ErrInvalidDecision extends AgentDirectorError {
|
|
352
400
|
}
|
|
353
401
|
|
|
@@ -363,11 +411,41 @@ class ErrPermissionRequestNotFound extends AgentDirectorError {
|
|
|
363
411
|
class ErrAmbiguousRequest extends AgentDirectorError {
|
|
364
412
|
}
|
|
365
413
|
|
|
414
|
+
class ErrStoreBusy extends AgentDirectorError {
|
|
415
|
+
}
|
|
416
|
+
|
|
366
417
|
class ErrMissingRequestToken extends AgentDirectorError {
|
|
367
418
|
}
|
|
368
419
|
|
|
369
420
|
class ErrInvalidFlags extends AgentDirectorError {
|
|
370
421
|
}
|
|
422
|
+
|
|
423
|
+
class ErrConfigMalformed extends AgentDirectorError {
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
class ErrStoreOpen extends AgentDirectorError {
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
class ErrSchemaMismatch extends AgentDirectorError {
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
class ErrSchemaMigrationRequired extends AgentDirectorError {
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
class ErrOldLayout extends AgentDirectorError {
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
class ErrUnknownVerb extends AgentDirectorError {
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
class ErrJSONMarshal extends AgentDirectorError {
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
class ErrTrailWrite extends AgentDirectorError {
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
class ErrInternal extends AgentDirectorError {
|
|
448
|
+
}
|
|
371
449
|
var ERROR_TABLE = {
|
|
372
450
|
ErrCwdMissing,
|
|
373
451
|
ErrCwdNotAPath,
|
|
@@ -376,6 +454,10 @@ var ERROR_TABLE = {
|
|
|
376
454
|
ErrRelayModeInvalid,
|
|
377
455
|
ErrSpawnDeniedFlag,
|
|
378
456
|
ErrReservedEnvKey,
|
|
457
|
+
ErrAgentMissing,
|
|
458
|
+
ErrAgentInvalid,
|
|
459
|
+
ErrAgentArgsMismatch,
|
|
460
|
+
ErrPermissionsUnsupported,
|
|
379
461
|
ErrInstanceIdCollision,
|
|
380
462
|
ErrTmuxSessionNameEmpty,
|
|
381
463
|
ErrTmuxSessionNameInvalid,
|
|
@@ -385,6 +467,7 @@ var ERROR_TABLE = {
|
|
|
385
467
|
ErrAlreadyDecided,
|
|
386
468
|
ErrPermissionRequestNotFound,
|
|
387
469
|
ErrAmbiguousRequest,
|
|
470
|
+
ErrStoreBusy,
|
|
388
471
|
ErrTmuxNotAvailable,
|
|
389
472
|
ErrTmuxSessionCreate,
|
|
390
473
|
ErrTmuxSendKeys,
|
|
@@ -403,6 +486,10 @@ var ERROR_TABLE = {
|
|
|
403
486
|
ErrJsonlNeverWritten,
|
|
404
487
|
ErrRelayModeOff,
|
|
405
488
|
ErrRelayFallenBack,
|
|
489
|
+
ErrPaneChanged,
|
|
490
|
+
ErrPaneAnswerInProgress,
|
|
491
|
+
ErrClaimTooSoon,
|
|
492
|
+
ErrDialogMaybeOpen,
|
|
406
493
|
ErrInvalidDecision,
|
|
407
494
|
ErrMissingRequestToken,
|
|
408
495
|
ErrInvalidFlags,
|
|
@@ -410,19 +497,29 @@ var ERROR_TABLE = {
|
|
|
410
497
|
ErrTemplateNotFound,
|
|
411
498
|
ErrTemplateMalformed,
|
|
412
499
|
ErrTemplateExists,
|
|
413
|
-
|
|
500
|
+
ErrTemplateAgentMissing,
|
|
501
|
+
ErrProbeUnsupported,
|
|
502
|
+
ErrConfigMalformed,
|
|
503
|
+
ErrStoreOpen,
|
|
504
|
+
ErrSchemaMismatch,
|
|
505
|
+
ErrSchemaMigrationRequired,
|
|
506
|
+
ErrOldLayout,
|
|
507
|
+
ErrUnknownVerb,
|
|
508
|
+
ErrJSONMarshal,
|
|
509
|
+
ErrTrailWrite,
|
|
510
|
+
ErrInternal
|
|
414
511
|
};
|
|
415
|
-
function errorFromEnvelope(verb, err_name, err_description) {
|
|
512
|
+
function errorFromEnvelope(verb, err_name, err_description, err_details) {
|
|
416
513
|
const Ctor = ERROR_TABLE[err_name];
|
|
417
514
|
if (Ctor) {
|
|
418
|
-
return new Ctor(verb, err_name, err_description);
|
|
515
|
+
return new Ctor(verb, err_name, err_description, err_details);
|
|
419
516
|
}
|
|
420
517
|
console.warn(`agent-director: unknown err_name "${err_name}" (verb=${verb}); returning base AgentDirectorError`);
|
|
421
|
-
return new AgentDirectorError(verb, err_name, err_description);
|
|
518
|
+
return new AgentDirectorError(verb, err_name, err_description, err_details);
|
|
422
519
|
}
|
|
423
520
|
|
|
424
521
|
// src/internal/discovery.ts
|
|
425
|
-
var STANDARD_INSTALL_PATH_RELATIVE = ".agent-director/bin/agent-director";
|
|
522
|
+
var STANDARD_INSTALL_PATH_RELATIVE = ".config/agent-director/bin/agent-director";
|
|
426
523
|
var CLI_BINARY_NAME = "agent-director";
|
|
427
524
|
function resolveStandardInstallPath(homeEnv) {
|
|
428
525
|
if (homeEnv === undefined || homeEnv === "" || !isAbsolute(homeEnv)) {
|
|
@@ -792,7 +889,7 @@ async function runProbe(candidatePath) {
|
|
|
792
889
|
}
|
|
793
890
|
// version-floor.json
|
|
794
891
|
var version_floor_default = {
|
|
795
|
-
min_binary_version: "0.
|
|
892
|
+
min_binary_version: "0.12.0"
|
|
796
893
|
};
|
|
797
894
|
|
|
798
895
|
// src/internal/constants.ts
|
|
@@ -822,25 +919,26 @@ function checkBunVersion() {
|
|
|
822
919
|
import { readFile } from "fs/promises";
|
|
823
920
|
import { statSync as statSync2 } from "fs";
|
|
824
921
|
|
|
825
|
-
// src/internal/tilde.ts
|
|
826
|
-
import * as os from "os";
|
|
827
|
-
function expandTilde(p) {
|
|
828
|
-
if (p === "")
|
|
829
|
-
return "";
|
|
830
|
-
if (p !== "~" && !p.startsWith("~/"))
|
|
831
|
-
return p;
|
|
832
|
-
const home = process.env["HOME"] || os.homedir();
|
|
833
|
-
if (p === "~")
|
|
834
|
-
return home;
|
|
835
|
-
return home + p.slice(1);
|
|
836
|
-
}
|
|
837
|
-
|
|
838
922
|
// src/internal/argv.ts
|
|
839
923
|
function buildArgv(cliPath, verb, params, globalOpts) {
|
|
924
|
+
refuseOldKeys(verb, params);
|
|
840
925
|
const globalFlags = buildGlobalFlags(globalOpts);
|
|
841
926
|
const verbFlags = buildVerbFlags(verb, params);
|
|
842
927
|
return [cliPath, ...globalFlags, ...verbFlags];
|
|
843
928
|
}
|
|
929
|
+
var OLD_PARAM_KEYS = [
|
|
930
|
+
{ old: "claude_instance_id", renamed: "instance_id" },
|
|
931
|
+
{ old: "claude_args", renamed: "agent_args" }
|
|
932
|
+
];
|
|
933
|
+
function refuseOldKeys(verb, params) {
|
|
934
|
+
if (typeof params !== "object" || params === null)
|
|
935
|
+
return;
|
|
936
|
+
const found = OLD_PARAM_KEYS.filter(({ old }) => Object.prototype.hasOwnProperty.call(params, old));
|
|
937
|
+
if (found.length === 0)
|
|
938
|
+
return;
|
|
939
|
+
const parts = found.map(({ old, renamed }) => `${JSON.stringify(old)} is no longer accepted; use ${JSON.stringify(renamed)}`);
|
|
940
|
+
throw new ErrInvalidFlags(verb, "ErrInvalidFlags", parts.join("; "));
|
|
941
|
+
}
|
|
844
942
|
function buildGlobalFlags(opts) {
|
|
845
943
|
if (!opts)
|
|
846
944
|
return [];
|
|
@@ -851,6 +949,8 @@ function buildGlobalFlags(opts) {
|
|
|
851
949
|
f.push("--home", opts.home);
|
|
852
950
|
if (opts.tmuxCommand !== undefined)
|
|
853
951
|
f.push("--tmux-command", opts.tmuxCommand);
|
|
952
|
+
if (opts.createIfMissing === false)
|
|
953
|
+
f.push("--create-if-missing", "false");
|
|
854
954
|
return f;
|
|
855
955
|
}
|
|
856
956
|
function buildVerbFlags(verb, params) {
|
|
@@ -873,6 +973,8 @@ function buildVerbFlags(verb, params) {
|
|
|
873
973
|
return buildDecide(params);
|
|
874
974
|
case "get-permission":
|
|
875
975
|
return buildGetPermission(params);
|
|
976
|
+
case "record-pane-answer":
|
|
977
|
+
return buildRecordPaneAnswer(params);
|
|
876
978
|
case "resume":
|
|
877
979
|
return buildResume(params);
|
|
878
980
|
case "find-missing":
|
|
@@ -883,6 +985,8 @@ function buildVerbFlags(verb, params) {
|
|
|
883
985
|
return buildMakeTemplate(params);
|
|
884
986
|
case "list":
|
|
885
987
|
return buildList(params);
|
|
988
|
+
case "list-subagents":
|
|
989
|
+
return buildListSubagents(params);
|
|
886
990
|
case "pause":
|
|
887
991
|
return buildPause(params);
|
|
888
992
|
default: {
|
|
@@ -899,8 +1003,10 @@ function buildSpawn(p) {
|
|
|
899
1003
|
f.push("--cwd", p.cwd);
|
|
900
1004
|
if (p.template !== undefined)
|
|
901
1005
|
f.push("--template", p.template);
|
|
902
|
-
if (p.
|
|
903
|
-
f.push("--
|
|
1006
|
+
if (p.agent !== undefined && p.agent !== "")
|
|
1007
|
+
f.push("--agent", p.agent);
|
|
1008
|
+
if (p.instance_id !== undefined)
|
|
1009
|
+
f.push("--instance-id", p.instance_id);
|
|
904
1010
|
if (p.tmux_session_name !== undefined)
|
|
905
1011
|
f.push("--tmux-session-name", p.tmux_session_name);
|
|
906
1012
|
if (p.relay_mode !== undefined && p.relay_mode !== "")
|
|
@@ -913,10 +1019,8 @@ function buildSpawn(p) {
|
|
|
913
1019
|
for (const lv of p.label)
|
|
914
1020
|
f.push("--label", lv);
|
|
915
1021
|
}
|
|
916
|
-
if (p.extra_env)
|
|
917
|
-
|
|
918
|
-
f.push("--extra-env", `${k}=${v}`);
|
|
919
|
-
}
|
|
1022
|
+
if (p.extra_env)
|
|
1023
|
+
f.push(...extraEnvFlags("spawn", p.extra_env));
|
|
920
1024
|
if (p.allow) {
|
|
921
1025
|
for (const a of p.allow)
|
|
922
1026
|
f.push("--allow", a);
|
|
@@ -929,32 +1033,69 @@ function buildSpawn(p) {
|
|
|
929
1033
|
for (const a of p.ask)
|
|
930
1034
|
f.push("--ask", a);
|
|
931
1035
|
}
|
|
932
|
-
if (p.
|
|
933
|
-
f.push("--", ...p.
|
|
1036
|
+
if (p.agent_args && p.agent_args.length > 0) {
|
|
1037
|
+
f.push("--", ...p.agent_args);
|
|
1038
|
+
}
|
|
1039
|
+
return f;
|
|
1040
|
+
}
|
|
1041
|
+
function extraEnvFlags(verb, env) {
|
|
1042
|
+
const bad = invalidExtraEnvKey(env);
|
|
1043
|
+
if (bad !== undefined) {
|
|
1044
|
+
const key = JSON.stringify(bad.key);
|
|
1045
|
+
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}`);
|
|
934
1046
|
}
|
|
1047
|
+
const f = [];
|
|
1048
|
+
for (const [k, v] of Object.entries(env))
|
|
1049
|
+
f.push("--extra-env", `${k}=${v}`);
|
|
935
1050
|
return f;
|
|
936
1051
|
}
|
|
1052
|
+
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";
|
|
1053
|
+
function invalidExtraEnvKey(env) {
|
|
1054
|
+
for (const key of Object.keys(env).sort()) {
|
|
1055
|
+
if (key === "") {
|
|
1056
|
+
return { key, problem: 'it is empty, so tmux would be given "=<value>", which names no variable' };
|
|
1057
|
+
}
|
|
1058
|
+
if (key.includes("=")) {
|
|
1059
|
+
return {
|
|
1060
|
+
key,
|
|
1061
|
+
problem: "it contains '=', and tmux splits each KEY=VALUE entry at its first '=', so it would set a different variable"
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
if (key.includes("\x00")) {
|
|
1065
|
+
return { key, problem: "it contains a NUL byte, which no env-var name can hold and no tmux argument can carry" };
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
937
1070
|
function buildStatus(p) {
|
|
938
|
-
return ["status", "--
|
|
1071
|
+
return ["status", "--instance-id", p.instance_id];
|
|
939
1072
|
}
|
|
940
1073
|
function buildGet(p) {
|
|
941
|
-
return ["get", "--
|
|
1074
|
+
return ["get", "--instance-id", p.instance_id];
|
|
942
1075
|
}
|
|
943
1076
|
function buildSendKeys(p) {
|
|
944
|
-
const f = [
|
|
945
|
-
|
|
946
|
-
"--
|
|
947
|
-
p.claude_instance_id,
|
|
948
|
-
"--text",
|
|
949
|
-
p.text
|
|
950
|
-
];
|
|
1077
|
+
const f = ["send-keys", "--instance-id", p.instance_id];
|
|
1078
|
+
if (p.text !== undefined)
|
|
1079
|
+
f.push("--text", p.text);
|
|
951
1080
|
if (p.allow_pending === true)
|
|
952
1081
|
f.push("--allow-pending");
|
|
1082
|
+
if (p.no_enter === true)
|
|
1083
|
+
f.push("--no-enter");
|
|
1084
|
+
if (p.key !== undefined)
|
|
1085
|
+
f.push("--key", p.key);
|
|
1086
|
+
if (p.expect_pane_sha256 !== undefined)
|
|
1087
|
+
f.push("--expect-pane-sha256", p.expect_pane_sha256);
|
|
1088
|
+
if (p.n_lines !== undefined && p.n_lines !== 0)
|
|
1089
|
+
f.push("--n-lines", String(p.n_lines));
|
|
1090
|
+
if (p.request_token !== undefined)
|
|
1091
|
+
f.push("--request-token", p.request_token);
|
|
1092
|
+
if (p.as !== undefined)
|
|
1093
|
+
f.push("--as", p.as);
|
|
953
1094
|
return f;
|
|
954
1095
|
}
|
|
955
1096
|
function buildReadPane(p) {
|
|
956
|
-
const f = ["read-pane", "--
|
|
957
|
-
if (p.n_lines !== undefined && p.n_lines
|
|
1097
|
+
const f = ["read-pane", "--instance-id", p.instance_id];
|
|
1098
|
+
if (p.n_lines !== undefined && p.n_lines !== 0)
|
|
958
1099
|
f.push("--n-lines", String(p.n_lines));
|
|
959
1100
|
if (p.ansi === true)
|
|
960
1101
|
f.push("--ansi");
|
|
@@ -963,13 +1104,13 @@ function buildReadPane(p) {
|
|
|
963
1104
|
return f;
|
|
964
1105
|
}
|
|
965
1106
|
function buildKill(p) {
|
|
966
|
-
return ["kill", "--
|
|
1107
|
+
return ["kill", "--instance-id", p.instance_id];
|
|
967
1108
|
}
|
|
968
1109
|
function buildDecide(p) {
|
|
969
1110
|
const f = [
|
|
970
1111
|
"decide",
|
|
971
|
-
"--
|
|
972
|
-
p.
|
|
1112
|
+
"--instance-id",
|
|
1113
|
+
p.instance_id,
|
|
973
1114
|
"--decision",
|
|
974
1115
|
p.decision
|
|
975
1116
|
];
|
|
@@ -977,13 +1118,29 @@ function buildDecide(p) {
|
|
|
977
1118
|
f.push("--request-token", p.request_token);
|
|
978
1119
|
if (p.reason !== undefined)
|
|
979
1120
|
f.push("--reason", p.reason);
|
|
1121
|
+
if (p.max_wait_ms !== undefined)
|
|
1122
|
+
f.push("--max-wait-ms", String(p.max_wait_ms));
|
|
980
1123
|
return f;
|
|
981
1124
|
}
|
|
982
1125
|
function buildGetPermission(p) {
|
|
983
1126
|
return ["get-permission", "--request-token", p.request_token];
|
|
984
1127
|
}
|
|
1128
|
+
function buildRecordPaneAnswer(p) {
|
|
1129
|
+
const f = [
|
|
1130
|
+
"record-pane-answer",
|
|
1131
|
+
"--request-token",
|
|
1132
|
+
p.request_token,
|
|
1133
|
+
"--as",
|
|
1134
|
+
p.as,
|
|
1135
|
+
"--expect-pane-sha256",
|
|
1136
|
+
p.expect_pane_sha256
|
|
1137
|
+
];
|
|
1138
|
+
if (p.n_lines !== undefined && p.n_lines !== 0)
|
|
1139
|
+
f.push("--n-lines", String(p.n_lines));
|
|
1140
|
+
return f;
|
|
1141
|
+
}
|
|
985
1142
|
function buildResume(p) {
|
|
986
|
-
return ["resume", "--
|
|
1143
|
+
return ["resume", "--instance-id", p.instance_id];
|
|
987
1144
|
}
|
|
988
1145
|
function buildFindMissing() {
|
|
989
1146
|
return ["find-missing"];
|
|
@@ -998,6 +1155,8 @@ function buildMakeTemplate(p) {
|
|
|
998
1155
|
const f = ["make-template", "--name", p.name];
|
|
999
1156
|
if (p.cwd !== undefined)
|
|
1000
1157
|
f.push("--cwd", p.cwd);
|
|
1158
|
+
if (p.agent !== undefined && p.agent !== "")
|
|
1159
|
+
f.push("--agent", p.agent);
|
|
1001
1160
|
if (p.relay_mode !== undefined && p.relay_mode !== "")
|
|
1002
1161
|
f.push("--relay-mode", p.relay_mode);
|
|
1003
1162
|
if (p.overwrite === true)
|
|
@@ -1006,10 +1165,8 @@ function buildMakeTemplate(p) {
|
|
|
1006
1165
|
for (const lv of p.label)
|
|
1007
1166
|
f.push("--label", lv);
|
|
1008
1167
|
}
|
|
1009
|
-
if (p.extra_env)
|
|
1010
|
-
|
|
1011
|
-
f.push("--extra-env", `${k}=${v}`);
|
|
1012
|
-
}
|
|
1168
|
+
if (p.extra_env)
|
|
1169
|
+
f.push(...extraEnvFlags("make-template", p.extra_env));
|
|
1013
1170
|
if (p.allow) {
|
|
1014
1171
|
for (const a of p.allow)
|
|
1015
1172
|
f.push("--allow", a);
|
|
@@ -1022,12 +1179,15 @@ function buildMakeTemplate(p) {
|
|
|
1022
1179
|
for (const a of p.ask)
|
|
1023
1180
|
f.push("--ask", a);
|
|
1024
1181
|
}
|
|
1025
|
-
if (p.
|
|
1026
|
-
for (const a of p.
|
|
1027
|
-
f.push("--
|
|
1182
|
+
if (p.agent_args) {
|
|
1183
|
+
for (const a of p.agent_args)
|
|
1184
|
+
f.push("--agent-args", a);
|
|
1028
1185
|
}
|
|
1029
1186
|
return f;
|
|
1030
1187
|
}
|
|
1188
|
+
function buildListSubagents(p) {
|
|
1189
|
+
return ["list-subagents", "--instance-id", p.instance_id];
|
|
1190
|
+
}
|
|
1031
1191
|
function buildList(p) {
|
|
1032
1192
|
const f = ["list"];
|
|
1033
1193
|
if (p.state && p.state.length > 0)
|
|
@@ -1042,12 +1202,12 @@ function buildList(p) {
|
|
|
1042
1202
|
f.push("--cwd", p.cwd);
|
|
1043
1203
|
if (p.tmux_session_name !== undefined)
|
|
1044
1204
|
f.push("--tmux-session-name", p.tmux_session_name);
|
|
1045
|
-
if (p.limit !== undefined && p.limit
|
|
1205
|
+
if (p.limit !== undefined && p.limit !== 0)
|
|
1046
1206
|
f.push("--limit", String(p.limit));
|
|
1047
1207
|
return f;
|
|
1048
1208
|
}
|
|
1049
1209
|
function buildPause(p) {
|
|
1050
|
-
return ["pause", "--
|
|
1210
|
+
return ["pause", "--instance-id", p.instance_id];
|
|
1051
1211
|
}
|
|
1052
1212
|
|
|
1053
1213
|
// src/internal/spawner.ts
|
|
@@ -1104,6 +1264,26 @@ var catalog_default = [
|
|
|
1104
1264
|
package: "spawn",
|
|
1105
1265
|
description: ""
|
|
1106
1266
|
},
|
|
1267
|
+
{
|
|
1268
|
+
name: "ErrAgentMissing",
|
|
1269
|
+
package: "spawn",
|
|
1270
|
+
description: ""
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
name: "ErrAgentInvalid",
|
|
1274
|
+
package: "spawn",
|
|
1275
|
+
description: ""
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
name: "ErrAgentArgsMismatch",
|
|
1279
|
+
package: "spawn",
|
|
1280
|
+
description: ""
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
name: "ErrPermissionsUnsupported",
|
|
1284
|
+
package: "spawn",
|
|
1285
|
+
description: ""
|
|
1286
|
+
},
|
|
1107
1287
|
{
|
|
1108
1288
|
name: "ErrInstanceIdCollision",
|
|
1109
1289
|
package: "spawn",
|
|
@@ -1209,6 +1389,11 @@ var catalog_default = [
|
|
|
1209
1389
|
package: "config",
|
|
1210
1390
|
description: ""
|
|
1211
1391
|
},
|
|
1392
|
+
{
|
|
1393
|
+
name: "ErrTemplateAgentMissing",
|
|
1394
|
+
package: "config",
|
|
1395
|
+
description: ""
|
|
1396
|
+
},
|
|
1212
1397
|
{
|
|
1213
1398
|
name: "ErrProbeUnsupported",
|
|
1214
1399
|
package: "probe",
|
|
@@ -1244,6 +1429,26 @@ var catalog_default = [
|
|
|
1244
1429
|
package: "api",
|
|
1245
1430
|
description: ""
|
|
1246
1431
|
},
|
|
1432
|
+
{
|
|
1433
|
+
name: "ErrPaneChanged",
|
|
1434
|
+
package: "api",
|
|
1435
|
+
description: ""
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
name: "ErrPaneAnswerInProgress",
|
|
1439
|
+
package: "api",
|
|
1440
|
+
description: ""
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
name: "ErrClaimTooSoon",
|
|
1444
|
+
package: "api",
|
|
1445
|
+
description: ""
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
name: "ErrDialogMaybeOpen",
|
|
1449
|
+
package: "api",
|
|
1450
|
+
description: ""
|
|
1451
|
+
},
|
|
1247
1452
|
{
|
|
1248
1453
|
name: "ErrInvalidDecision",
|
|
1249
1454
|
package: "api",
|
|
@@ -1278,6 +1483,56 @@ var catalog_default = [
|
|
|
1278
1483
|
name: "ErrAmbiguousRequest",
|
|
1279
1484
|
package: "store",
|
|
1280
1485
|
description: ""
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
name: "ErrStoreBusy",
|
|
1489
|
+
package: "store",
|
|
1490
|
+
description: ""
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
name: "ErrConfigMalformed",
|
|
1494
|
+
package: "clisetup",
|
|
1495
|
+
description: ""
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
name: "ErrStoreOpen",
|
|
1499
|
+
package: "clisetup",
|
|
1500
|
+
description: ""
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
name: "ErrSchemaMismatch",
|
|
1504
|
+
package: "clisetup",
|
|
1505
|
+
description: ""
|
|
1506
|
+
},
|
|
1507
|
+
{
|
|
1508
|
+
name: "ErrSchemaMigrationRequired",
|
|
1509
|
+
package: "clisetup",
|
|
1510
|
+
description: ""
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
name: "ErrOldLayout",
|
|
1514
|
+
package: "clisetup",
|
|
1515
|
+
description: ""
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
name: "ErrUnknownVerb",
|
|
1519
|
+
package: "clisetup",
|
|
1520
|
+
description: ""
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
name: "ErrJSONMarshal",
|
|
1524
|
+
package: "clisetup",
|
|
1525
|
+
description: ""
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
name: "ErrTrailWrite",
|
|
1529
|
+
package: "clisetup",
|
|
1530
|
+
description: ""
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
name: "ErrInternal",
|
|
1534
|
+
package: "errnames",
|
|
1535
|
+
description: ""
|
|
1281
1536
|
}
|
|
1282
1537
|
];
|
|
1283
1538
|
|
|
@@ -1299,9 +1554,11 @@ function throwFromEnvelope(verb, envelope) {
|
|
|
1299
1554
|
const errName = env.err_name;
|
|
1300
1555
|
const envelopeRecord = envelope;
|
|
1301
1556
|
const errDescription = typeof envelopeRecord["err_description"] === "string" ? envelopeRecord["err_description"] : "";
|
|
1557
|
+
const rawDetails = envelopeRecord["err_details"];
|
|
1558
|
+
const errDetails = typeof rawDetails === "object" && rawDetails !== null && !Array.isArray(rawDetails) ? rawDetails : null;
|
|
1302
1559
|
const Ctor = errorMap.get(errName);
|
|
1303
1560
|
if (Ctor !== undefined) {
|
|
1304
|
-
throw new Ctor(verb, errName, errDescription);
|
|
1561
|
+
throw new Ctor(verb, errName, errDescription, errDetails);
|
|
1305
1562
|
}
|
|
1306
1563
|
throw new ErrUnknownErrorName(errName, envelope);
|
|
1307
1564
|
}
|
|
@@ -1341,11 +1598,13 @@ class SubprocessClient {
|
|
|
1341
1598
|
this.#binaryVersion = init.binaryVersion;
|
|
1342
1599
|
const g = {};
|
|
1343
1600
|
if (opts.storePath !== undefined)
|
|
1344
|
-
g.storePath =
|
|
1601
|
+
g.storePath = opts.storePath;
|
|
1345
1602
|
if (opts.tmuxCommand !== undefined)
|
|
1346
|
-
g.tmuxCommand =
|
|
1603
|
+
g.tmuxCommand = opts.tmuxCommand;
|
|
1347
1604
|
if (opts.home !== undefined)
|
|
1348
|
-
g.home =
|
|
1605
|
+
g.home = opts.home;
|
|
1606
|
+
if (opts.createIfMissing !== undefined)
|
|
1607
|
+
g.createIfMissing = opts.createIfMissing;
|
|
1349
1608
|
this.#globalOpts = g;
|
|
1350
1609
|
this.#open = true;
|
|
1351
1610
|
this.#tail = Promise.resolve();
|
|
@@ -1529,6 +1788,10 @@ class SubprocessClient {
|
|
|
1529
1788
|
this.#assertOpen();
|
|
1530
1789
|
return this.#enqueue("get-permission", params);
|
|
1531
1790
|
}
|
|
1791
|
+
async recordPaneAnswer(params) {
|
|
1792
|
+
this.#assertOpen();
|
|
1793
|
+
return this.#enqueue("record-pane-answer", params);
|
|
1794
|
+
}
|
|
1532
1795
|
async resume(params) {
|
|
1533
1796
|
this.#assertOpen();
|
|
1534
1797
|
return this.#enqueue("resume", params);
|
|
@@ -1549,6 +1812,10 @@ class SubprocessClient {
|
|
|
1549
1812
|
this.#assertOpen();
|
|
1550
1813
|
return this.#enqueue("list", params);
|
|
1551
1814
|
}
|
|
1815
|
+
async listSubagents(params) {
|
|
1816
|
+
this.#assertOpen();
|
|
1817
|
+
return this.#enqueue("list-subagents", params);
|
|
1818
|
+
}
|
|
1552
1819
|
async pause(params) {
|
|
1553
1820
|
this.#assertOpen();
|
|
1554
1821
|
return this.#enqueue("pause", params);
|
|
@@ -1654,7 +1921,9 @@ export {
|
|
|
1654
1921
|
resolveSystemBinary,
|
|
1655
1922
|
errorFromEnvelope,
|
|
1656
1923
|
MIN_BINARY_VERSION,
|
|
1924
|
+
ErrUnknownVerb,
|
|
1657
1925
|
ErrUnknownErrorName,
|
|
1926
|
+
ErrTrailWrite,
|
|
1658
1927
|
ErrTmuxUnresponsive,
|
|
1659
1928
|
ErrTmuxSessionNameTooLong,
|
|
1660
1929
|
ErrTmuxSessionNameInvalid,
|
|
@@ -1669,43 +1938,60 @@ export {
|
|
|
1669
1938
|
ErrTemplateNameUnsafe,
|
|
1670
1939
|
ErrTemplateMalformed,
|
|
1671
1940
|
ErrTemplateExists,
|
|
1941
|
+
ErrTemplateAgentMissing,
|
|
1672
1942
|
ErrSystemInstallUnreachable,
|
|
1673
1943
|
ErrSystemInstallTooOld,
|
|
1674
1944
|
ErrSystemInstallNotFound,
|
|
1675
1945
|
ErrSystemInstallDisappeared,
|
|
1946
|
+
ErrStoreOpen,
|
|
1947
|
+
ErrStoreBusy,
|
|
1676
1948
|
ErrSpawnNotResumable,
|
|
1677
1949
|
ErrSpawnNotPausable,
|
|
1678
1950
|
ErrSpawnNotInteractive,
|
|
1679
1951
|
ErrSpawnNotFound,
|
|
1680
1952
|
ErrSpawnDeniedFlag,
|
|
1681
1953
|
ErrSendKeysWhileRelayed,
|
|
1954
|
+
ErrSchemaMismatch,
|
|
1955
|
+
ErrSchemaMigrationRequired,
|
|
1682
1956
|
ErrReservedEnvKey,
|
|
1683
1957
|
ErrRelayModeOff,
|
|
1684
1958
|
ErrRelayModeInvalid,
|
|
1685
1959
|
ErrRelayFallenBack,
|
|
1686
1960
|
ErrProbeUnsupported,
|
|
1961
|
+
ErrPermissionsUnsupported,
|
|
1687
1962
|
ErrPermissionRequestNotFound,
|
|
1688
1963
|
ErrPauseTimeout,
|
|
1964
|
+
ErrPaneChanged,
|
|
1965
|
+
ErrPaneAnswerInProgress,
|
|
1966
|
+
ErrOldLayout,
|
|
1689
1967
|
ErrNoSessionId,
|
|
1690
1968
|
ErrNoOpenPermissionRequest,
|
|
1691
1969
|
ErrMissingRequestToken,
|
|
1692
1970
|
ErrListInvalidLabel,
|
|
1693
1971
|
ErrJsonlNeverWritten,
|
|
1694
1972
|
ErrJsonlMissing,
|
|
1973
|
+
ErrJSONMarshal,
|
|
1695
1974
|
ErrInvalidFlags,
|
|
1696
1975
|
ErrInvalidDecision,
|
|
1976
|
+
ErrInternal,
|
|
1697
1977
|
ErrInstanceIdCollision,
|
|
1978
|
+
ErrDialogMaybeOpen,
|
|
1698
1979
|
ErrCwdNotFound,
|
|
1699
1980
|
ErrCwdNotAPath,
|
|
1700
1981
|
ErrCwdNotADirectory,
|
|
1701
1982
|
ErrCwdMissing,
|
|
1702
1983
|
ErrConsumerSignal,
|
|
1984
|
+
ErrConfigMalformed,
|
|
1703
1985
|
ErrClientClosed,
|
|
1986
|
+
ErrClaimTooSoon,
|
|
1704
1987
|
ErrCallerCwdUnreachable,
|
|
1705
1988
|
ErrCallTimeout,
|
|
1706
1989
|
ErrBunVersionTooOld,
|
|
1707
1990
|
ErrAmbiguousRequest,
|
|
1708
1991
|
ErrAlreadyDecided,
|
|
1992
|
+
ErrAgentMissing,
|
|
1993
|
+
ErrAgentInvalid,
|
|
1994
|
+
ErrAgentArgsMismatch,
|
|
1709
1995
|
DEV_SENTINEL_VERSION,
|
|
1710
1996
|
Client,
|
|
1711
1997
|
AgentDirectorError
|