agent-director 0.11.1 → 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 +317 -144
- package/dist/errors.d.ts +108 -9
- package/dist/index.d.ts +4 -3
- package/dist/index.js +317 -40
- package/dist/internal/argv.d.ts +25 -11
- package/dist/internal/discovery.d.ts +3 -2
- package/dist/internal/errorMap.d.ts +10 -7
- package/dist/internal/subprocessClient.d.ts +37 -6
- package/dist/internal/verbs.d.ts +4 -4
- package/dist/types.d.ts +671 -141
- package/dist/version-floor.json +1 -1
- package/package.json +1 -1
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,44 @@ __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,
|
|
49
52
|
ErrStoreOpen: () => ErrStoreOpen,
|
|
53
|
+
ErrStoreBusy: () => ErrStoreBusy,
|
|
50
54
|
ErrSpawnNotResumable: () => ErrSpawnNotResumable,
|
|
51
55
|
ErrSpawnNotPausable: () => ErrSpawnNotPausable,
|
|
52
56
|
ErrSpawnNotInteractive: () => ErrSpawnNotInteractive,
|
|
53
57
|
ErrSpawnNotFound: () => ErrSpawnNotFound,
|
|
54
58
|
ErrSpawnDeniedFlag: () => ErrSpawnDeniedFlag,
|
|
55
59
|
ErrSendKeysWhileRelayed: () => ErrSendKeysWhileRelayed,
|
|
60
|
+
ErrSchemaMismatch: () => ErrSchemaMismatch,
|
|
61
|
+
ErrSchemaMigrationRequired: () => ErrSchemaMigrationRequired,
|
|
56
62
|
ErrReservedEnvKey: () => ErrReservedEnvKey,
|
|
57
63
|
ErrRelayModeOff: () => ErrRelayModeOff,
|
|
58
64
|
ErrRelayModeInvalid: () => ErrRelayModeInvalid,
|
|
59
65
|
ErrRelayFallenBack: () => ErrRelayFallenBack,
|
|
60
66
|
ErrProbeUnsupported: () => ErrProbeUnsupported,
|
|
67
|
+
ErrPermissionsUnsupported: () => ErrPermissionsUnsupported,
|
|
61
68
|
ErrPermissionRequestNotFound: () => ErrPermissionRequestNotFound,
|
|
62
69
|
ErrPauseTimeout: () => ErrPauseTimeout,
|
|
70
|
+
ErrPaneChanged: () => ErrPaneChanged,
|
|
71
|
+
ErrPaneAnswerInProgress: () => ErrPaneAnswerInProgress,
|
|
72
|
+
ErrOldLayout: () => ErrOldLayout,
|
|
63
73
|
ErrNoSessionId: () => ErrNoSessionId,
|
|
64
74
|
ErrNoOpenPermissionRequest: () => ErrNoOpenPermissionRequest,
|
|
65
75
|
ErrMissingRequestToken: () => ErrMissingRequestToken,
|
|
66
76
|
ErrListInvalidLabel: () => ErrListInvalidLabel,
|
|
67
77
|
ErrJsonlNeverWritten: () => ErrJsonlNeverWritten,
|
|
68
78
|
ErrJsonlMissing: () => ErrJsonlMissing,
|
|
79
|
+
ErrJSONMarshal: () => ErrJSONMarshal,
|
|
69
80
|
ErrInvalidFlags: () => ErrInvalidFlags,
|
|
70
81
|
ErrInvalidDecision: () => ErrInvalidDecision,
|
|
82
|
+
ErrInternal: () => ErrInternal,
|
|
71
83
|
ErrInstanceIdCollision: () => ErrInstanceIdCollision,
|
|
84
|
+
ErrDialogMaybeOpen: () => ErrDialogMaybeOpen,
|
|
72
85
|
ErrCwdNotFound: () => ErrCwdNotFound,
|
|
73
86
|
ErrCwdNotAPath: () => ErrCwdNotAPath,
|
|
74
87
|
ErrCwdNotADirectory: () => ErrCwdNotADirectory,
|
|
@@ -76,11 +89,15 @@ __export(exports_errors, {
|
|
|
76
89
|
ErrConsumerSignal: () => ErrConsumerSignal,
|
|
77
90
|
ErrConfigMalformed: () => ErrConfigMalformed,
|
|
78
91
|
ErrClientClosed: () => ErrClientClosed,
|
|
92
|
+
ErrClaimTooSoon: () => ErrClaimTooSoon,
|
|
79
93
|
ErrCallerCwdUnreachable: () => ErrCallerCwdUnreachable,
|
|
80
94
|
ErrCallTimeout: () => ErrCallTimeout,
|
|
81
95
|
ErrBunVersionTooOld: () => ErrBunVersionTooOld,
|
|
82
96
|
ErrAmbiguousRequest: () => ErrAmbiguousRequest,
|
|
83
97
|
ErrAlreadyDecided: () => ErrAlreadyDecided,
|
|
98
|
+
ErrAgentMissing: () => ErrAgentMissing,
|
|
99
|
+
ErrAgentInvalid: () => ErrAgentInvalid,
|
|
100
|
+
ErrAgentArgsMismatch: () => ErrAgentArgsMismatch,
|
|
84
101
|
AgentDirectorError: () => AgentDirectorError
|
|
85
102
|
});
|
|
86
103
|
|
|
@@ -103,11 +120,13 @@ class AgentDirectorError extends Error {
|
|
|
103
120
|
verb;
|
|
104
121
|
errName;
|
|
105
122
|
errDescription;
|
|
106
|
-
|
|
123
|
+
errDetails;
|
|
124
|
+
constructor(verb, err_name, err_description, err_details) {
|
|
107
125
|
super(`${err_name}: ${err_description}`);
|
|
108
126
|
this.verb = verb;
|
|
109
127
|
this.errName = err_name;
|
|
110
128
|
this.errDescription = err_description;
|
|
129
|
+
this.errDetails = err_details ?? null;
|
|
111
130
|
this.name = this.constructor.name;
|
|
112
131
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
113
132
|
}
|
|
@@ -266,6 +285,18 @@ class ErrSpawnDeniedFlag extends AgentDirectorError {
|
|
|
266
285
|
class ErrReservedEnvKey extends AgentDirectorError {
|
|
267
286
|
}
|
|
268
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
|
+
|
|
269
300
|
class ErrInstanceIdCollision extends AgentDirectorError {
|
|
270
301
|
}
|
|
271
302
|
|
|
@@ -329,6 +360,9 @@ class ErrTemplateMalformed extends AgentDirectorError {
|
|
|
329
360
|
class ErrTemplateExists extends AgentDirectorError {
|
|
330
361
|
}
|
|
331
362
|
|
|
363
|
+
class ErrTemplateAgentMissing extends AgentDirectorError {
|
|
364
|
+
}
|
|
365
|
+
|
|
332
366
|
class ErrProbeUnsupported extends AgentDirectorError {
|
|
333
367
|
}
|
|
334
368
|
|
|
@@ -350,6 +384,18 @@ class ErrRelayModeOff extends AgentDirectorError {
|
|
|
350
384
|
class ErrRelayFallenBack extends AgentDirectorError {
|
|
351
385
|
}
|
|
352
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
|
+
|
|
353
399
|
class ErrInvalidDecision extends AgentDirectorError {
|
|
354
400
|
}
|
|
355
401
|
|
|
@@ -365,6 +411,9 @@ class ErrPermissionRequestNotFound extends AgentDirectorError {
|
|
|
365
411
|
class ErrAmbiguousRequest extends AgentDirectorError {
|
|
366
412
|
}
|
|
367
413
|
|
|
414
|
+
class ErrStoreBusy extends AgentDirectorError {
|
|
415
|
+
}
|
|
416
|
+
|
|
368
417
|
class ErrMissingRequestToken extends AgentDirectorError {
|
|
369
418
|
}
|
|
370
419
|
|
|
@@ -376,6 +425,27 @@ class ErrConfigMalformed extends AgentDirectorError {
|
|
|
376
425
|
|
|
377
426
|
class ErrStoreOpen extends AgentDirectorError {
|
|
378
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
|
+
}
|
|
379
449
|
var ERROR_TABLE = {
|
|
380
450
|
ErrCwdMissing,
|
|
381
451
|
ErrCwdNotAPath,
|
|
@@ -384,6 +454,10 @@ var ERROR_TABLE = {
|
|
|
384
454
|
ErrRelayModeInvalid,
|
|
385
455
|
ErrSpawnDeniedFlag,
|
|
386
456
|
ErrReservedEnvKey,
|
|
457
|
+
ErrAgentMissing,
|
|
458
|
+
ErrAgentInvalid,
|
|
459
|
+
ErrAgentArgsMismatch,
|
|
460
|
+
ErrPermissionsUnsupported,
|
|
387
461
|
ErrInstanceIdCollision,
|
|
388
462
|
ErrTmuxSessionNameEmpty,
|
|
389
463
|
ErrTmuxSessionNameInvalid,
|
|
@@ -393,6 +467,7 @@ var ERROR_TABLE = {
|
|
|
393
467
|
ErrAlreadyDecided,
|
|
394
468
|
ErrPermissionRequestNotFound,
|
|
395
469
|
ErrAmbiguousRequest,
|
|
470
|
+
ErrStoreBusy,
|
|
396
471
|
ErrTmuxNotAvailable,
|
|
397
472
|
ErrTmuxSessionCreate,
|
|
398
473
|
ErrTmuxSendKeys,
|
|
@@ -411,6 +486,10 @@ var ERROR_TABLE = {
|
|
|
411
486
|
ErrJsonlNeverWritten,
|
|
412
487
|
ErrRelayModeOff,
|
|
413
488
|
ErrRelayFallenBack,
|
|
489
|
+
ErrPaneChanged,
|
|
490
|
+
ErrPaneAnswerInProgress,
|
|
491
|
+
ErrClaimTooSoon,
|
|
492
|
+
ErrDialogMaybeOpen,
|
|
414
493
|
ErrInvalidDecision,
|
|
415
494
|
ErrMissingRequestToken,
|
|
416
495
|
ErrInvalidFlags,
|
|
@@ -418,21 +497,29 @@ var ERROR_TABLE = {
|
|
|
418
497
|
ErrTemplateNotFound,
|
|
419
498
|
ErrTemplateMalformed,
|
|
420
499
|
ErrTemplateExists,
|
|
500
|
+
ErrTemplateAgentMissing,
|
|
421
501
|
ErrProbeUnsupported,
|
|
422
502
|
ErrConfigMalformed,
|
|
423
|
-
ErrStoreOpen
|
|
503
|
+
ErrStoreOpen,
|
|
504
|
+
ErrSchemaMismatch,
|
|
505
|
+
ErrSchemaMigrationRequired,
|
|
506
|
+
ErrOldLayout,
|
|
507
|
+
ErrUnknownVerb,
|
|
508
|
+
ErrJSONMarshal,
|
|
509
|
+
ErrTrailWrite,
|
|
510
|
+
ErrInternal
|
|
424
511
|
};
|
|
425
|
-
function errorFromEnvelope(verb, err_name, err_description) {
|
|
512
|
+
function errorFromEnvelope(verb, err_name, err_description, err_details) {
|
|
426
513
|
const Ctor = ERROR_TABLE[err_name];
|
|
427
514
|
if (Ctor) {
|
|
428
|
-
return new Ctor(verb, err_name, err_description);
|
|
515
|
+
return new Ctor(verb, err_name, err_description, err_details);
|
|
429
516
|
}
|
|
430
517
|
console.warn(`agent-director: unknown err_name "${err_name}" (verb=${verb}); returning base AgentDirectorError`);
|
|
431
|
-
return new AgentDirectorError(verb, err_name, err_description);
|
|
518
|
+
return new AgentDirectorError(verb, err_name, err_description, err_details);
|
|
432
519
|
}
|
|
433
520
|
|
|
434
521
|
// src/internal/discovery.ts
|
|
435
|
-
var STANDARD_INSTALL_PATH_RELATIVE = ".agent-director/bin/agent-director";
|
|
522
|
+
var STANDARD_INSTALL_PATH_RELATIVE = ".config/agent-director/bin/agent-director";
|
|
436
523
|
var CLI_BINARY_NAME = "agent-director";
|
|
437
524
|
function resolveStandardInstallPath(homeEnv) {
|
|
438
525
|
if (homeEnv === undefined || homeEnv === "" || !isAbsolute(homeEnv)) {
|
|
@@ -802,7 +889,7 @@ async function runProbe(candidatePath) {
|
|
|
802
889
|
}
|
|
803
890
|
// version-floor.json
|
|
804
891
|
var version_floor_default = {
|
|
805
|
-
min_binary_version: "0.
|
|
892
|
+
min_binary_version: "0.12.0"
|
|
806
893
|
};
|
|
807
894
|
|
|
808
895
|
// src/internal/constants.ts
|
|
@@ -834,10 +921,24 @@ import { statSync as statSync2 } from "fs";
|
|
|
834
921
|
|
|
835
922
|
// src/internal/argv.ts
|
|
836
923
|
function buildArgv(cliPath, verb, params, globalOpts) {
|
|
924
|
+
refuseOldKeys(verb, params);
|
|
837
925
|
const globalFlags = buildGlobalFlags(globalOpts);
|
|
838
926
|
const verbFlags = buildVerbFlags(verb, params);
|
|
839
927
|
return [cliPath, ...globalFlags, ...verbFlags];
|
|
840
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
|
+
}
|
|
841
942
|
function buildGlobalFlags(opts) {
|
|
842
943
|
if (!opts)
|
|
843
944
|
return [];
|
|
@@ -848,6 +949,8 @@ function buildGlobalFlags(opts) {
|
|
|
848
949
|
f.push("--home", opts.home);
|
|
849
950
|
if (opts.tmuxCommand !== undefined)
|
|
850
951
|
f.push("--tmux-command", opts.tmuxCommand);
|
|
952
|
+
if (opts.createIfMissing === false)
|
|
953
|
+
f.push("--create-if-missing", "false");
|
|
851
954
|
return f;
|
|
852
955
|
}
|
|
853
956
|
function buildVerbFlags(verb, params) {
|
|
@@ -870,6 +973,8 @@ function buildVerbFlags(verb, params) {
|
|
|
870
973
|
return buildDecide(params);
|
|
871
974
|
case "get-permission":
|
|
872
975
|
return buildGetPermission(params);
|
|
976
|
+
case "record-pane-answer":
|
|
977
|
+
return buildRecordPaneAnswer(params);
|
|
873
978
|
case "resume":
|
|
874
979
|
return buildResume(params);
|
|
875
980
|
case "find-missing":
|
|
@@ -880,6 +985,8 @@ function buildVerbFlags(verb, params) {
|
|
|
880
985
|
return buildMakeTemplate(params);
|
|
881
986
|
case "list":
|
|
882
987
|
return buildList(params);
|
|
988
|
+
case "list-subagents":
|
|
989
|
+
return buildListSubagents(params);
|
|
883
990
|
case "pause":
|
|
884
991
|
return buildPause(params);
|
|
885
992
|
default: {
|
|
@@ -896,8 +1003,10 @@ function buildSpawn(p) {
|
|
|
896
1003
|
f.push("--cwd", p.cwd);
|
|
897
1004
|
if (p.template !== undefined)
|
|
898
1005
|
f.push("--template", p.template);
|
|
899
|
-
if (p.
|
|
900
|
-
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);
|
|
901
1010
|
if (p.tmux_session_name !== undefined)
|
|
902
1011
|
f.push("--tmux-session-name", p.tmux_session_name);
|
|
903
1012
|
if (p.relay_mode !== undefined && p.relay_mode !== "")
|
|
@@ -910,10 +1019,8 @@ function buildSpawn(p) {
|
|
|
910
1019
|
for (const lv of p.label)
|
|
911
1020
|
f.push("--label", lv);
|
|
912
1021
|
}
|
|
913
|
-
if (p.extra_env)
|
|
914
|
-
|
|
915
|
-
f.push("--extra-env", `${k}=${v}`);
|
|
916
|
-
}
|
|
1022
|
+
if (p.extra_env)
|
|
1023
|
+
f.push(...extraEnvFlags("spawn", p.extra_env));
|
|
917
1024
|
if (p.allow) {
|
|
918
1025
|
for (const a of p.allow)
|
|
919
1026
|
f.push("--allow", a);
|
|
@@ -926,32 +1033,69 @@ function buildSpawn(p) {
|
|
|
926
1033
|
for (const a of p.ask)
|
|
927
1034
|
f.push("--ask", a);
|
|
928
1035
|
}
|
|
929
|
-
if (p.
|
|
930
|
-
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}`);
|
|
931
1046
|
}
|
|
1047
|
+
const f = [];
|
|
1048
|
+
for (const [k, v] of Object.entries(env))
|
|
1049
|
+
f.push("--extra-env", `${k}=${v}`);
|
|
932
1050
|
return f;
|
|
933
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
|
+
}
|
|
934
1070
|
function buildStatus(p) {
|
|
935
|
-
return ["status", "--
|
|
1071
|
+
return ["status", "--instance-id", p.instance_id];
|
|
936
1072
|
}
|
|
937
1073
|
function buildGet(p) {
|
|
938
|
-
return ["get", "--
|
|
1074
|
+
return ["get", "--instance-id", p.instance_id];
|
|
939
1075
|
}
|
|
940
1076
|
function buildSendKeys(p) {
|
|
941
|
-
const f = [
|
|
942
|
-
|
|
943
|
-
"--
|
|
944
|
-
p.claude_instance_id,
|
|
945
|
-
"--text",
|
|
946
|
-
p.text
|
|
947
|
-
];
|
|
1077
|
+
const f = ["send-keys", "--instance-id", p.instance_id];
|
|
1078
|
+
if (p.text !== undefined)
|
|
1079
|
+
f.push("--text", p.text);
|
|
948
1080
|
if (p.allow_pending === true)
|
|
949
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);
|
|
950
1094
|
return f;
|
|
951
1095
|
}
|
|
952
1096
|
function buildReadPane(p) {
|
|
953
|
-
const f = ["read-pane", "--
|
|
954
|
-
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)
|
|
955
1099
|
f.push("--n-lines", String(p.n_lines));
|
|
956
1100
|
if (p.ansi === true)
|
|
957
1101
|
f.push("--ansi");
|
|
@@ -960,13 +1104,13 @@ function buildReadPane(p) {
|
|
|
960
1104
|
return f;
|
|
961
1105
|
}
|
|
962
1106
|
function buildKill(p) {
|
|
963
|
-
return ["kill", "--
|
|
1107
|
+
return ["kill", "--instance-id", p.instance_id];
|
|
964
1108
|
}
|
|
965
1109
|
function buildDecide(p) {
|
|
966
1110
|
const f = [
|
|
967
1111
|
"decide",
|
|
968
|
-
"--
|
|
969
|
-
p.
|
|
1112
|
+
"--instance-id",
|
|
1113
|
+
p.instance_id,
|
|
970
1114
|
"--decision",
|
|
971
1115
|
p.decision
|
|
972
1116
|
];
|
|
@@ -974,13 +1118,29 @@ function buildDecide(p) {
|
|
|
974
1118
|
f.push("--request-token", p.request_token);
|
|
975
1119
|
if (p.reason !== undefined)
|
|
976
1120
|
f.push("--reason", p.reason);
|
|
1121
|
+
if (p.max_wait_ms !== undefined)
|
|
1122
|
+
f.push("--max-wait-ms", String(p.max_wait_ms));
|
|
977
1123
|
return f;
|
|
978
1124
|
}
|
|
979
1125
|
function buildGetPermission(p) {
|
|
980
1126
|
return ["get-permission", "--request-token", p.request_token];
|
|
981
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
|
+
}
|
|
982
1142
|
function buildResume(p) {
|
|
983
|
-
return ["resume", "--
|
|
1143
|
+
return ["resume", "--instance-id", p.instance_id];
|
|
984
1144
|
}
|
|
985
1145
|
function buildFindMissing() {
|
|
986
1146
|
return ["find-missing"];
|
|
@@ -995,6 +1155,8 @@ function buildMakeTemplate(p) {
|
|
|
995
1155
|
const f = ["make-template", "--name", p.name];
|
|
996
1156
|
if (p.cwd !== undefined)
|
|
997
1157
|
f.push("--cwd", p.cwd);
|
|
1158
|
+
if (p.agent !== undefined && p.agent !== "")
|
|
1159
|
+
f.push("--agent", p.agent);
|
|
998
1160
|
if (p.relay_mode !== undefined && p.relay_mode !== "")
|
|
999
1161
|
f.push("--relay-mode", p.relay_mode);
|
|
1000
1162
|
if (p.overwrite === true)
|
|
@@ -1003,10 +1165,8 @@ function buildMakeTemplate(p) {
|
|
|
1003
1165
|
for (const lv of p.label)
|
|
1004
1166
|
f.push("--label", lv);
|
|
1005
1167
|
}
|
|
1006
|
-
if (p.extra_env)
|
|
1007
|
-
|
|
1008
|
-
f.push("--extra-env", `${k}=${v}`);
|
|
1009
|
-
}
|
|
1168
|
+
if (p.extra_env)
|
|
1169
|
+
f.push(...extraEnvFlags("make-template", p.extra_env));
|
|
1010
1170
|
if (p.allow) {
|
|
1011
1171
|
for (const a of p.allow)
|
|
1012
1172
|
f.push("--allow", a);
|
|
@@ -1019,12 +1179,15 @@ function buildMakeTemplate(p) {
|
|
|
1019
1179
|
for (const a of p.ask)
|
|
1020
1180
|
f.push("--ask", a);
|
|
1021
1181
|
}
|
|
1022
|
-
if (p.
|
|
1023
|
-
for (const a of p.
|
|
1024
|
-
f.push("--
|
|
1182
|
+
if (p.agent_args) {
|
|
1183
|
+
for (const a of p.agent_args)
|
|
1184
|
+
f.push("--agent-args", a);
|
|
1025
1185
|
}
|
|
1026
1186
|
return f;
|
|
1027
1187
|
}
|
|
1188
|
+
function buildListSubagents(p) {
|
|
1189
|
+
return ["list-subagents", "--instance-id", p.instance_id];
|
|
1190
|
+
}
|
|
1028
1191
|
function buildList(p) {
|
|
1029
1192
|
const f = ["list"];
|
|
1030
1193
|
if (p.state && p.state.length > 0)
|
|
@@ -1039,12 +1202,12 @@ function buildList(p) {
|
|
|
1039
1202
|
f.push("--cwd", p.cwd);
|
|
1040
1203
|
if (p.tmux_session_name !== undefined)
|
|
1041
1204
|
f.push("--tmux-session-name", p.tmux_session_name);
|
|
1042
|
-
if (p.limit !== undefined && p.limit
|
|
1205
|
+
if (p.limit !== undefined && p.limit !== 0)
|
|
1043
1206
|
f.push("--limit", String(p.limit));
|
|
1044
1207
|
return f;
|
|
1045
1208
|
}
|
|
1046
1209
|
function buildPause(p) {
|
|
1047
|
-
return ["pause", "--
|
|
1210
|
+
return ["pause", "--instance-id", p.instance_id];
|
|
1048
1211
|
}
|
|
1049
1212
|
|
|
1050
1213
|
// src/internal/spawner.ts
|
|
@@ -1101,6 +1264,26 @@ var catalog_default = [
|
|
|
1101
1264
|
package: "spawn",
|
|
1102
1265
|
description: ""
|
|
1103
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
|
+
},
|
|
1104
1287
|
{
|
|
1105
1288
|
name: "ErrInstanceIdCollision",
|
|
1106
1289
|
package: "spawn",
|
|
@@ -1206,6 +1389,11 @@ var catalog_default = [
|
|
|
1206
1389
|
package: "config",
|
|
1207
1390
|
description: ""
|
|
1208
1391
|
},
|
|
1392
|
+
{
|
|
1393
|
+
name: "ErrTemplateAgentMissing",
|
|
1394
|
+
package: "config",
|
|
1395
|
+
description: ""
|
|
1396
|
+
},
|
|
1209
1397
|
{
|
|
1210
1398
|
name: "ErrProbeUnsupported",
|
|
1211
1399
|
package: "probe",
|
|
@@ -1241,6 +1429,26 @@ var catalog_default = [
|
|
|
1241
1429
|
package: "api",
|
|
1242
1430
|
description: ""
|
|
1243
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
|
+
},
|
|
1244
1452
|
{
|
|
1245
1453
|
name: "ErrInvalidDecision",
|
|
1246
1454
|
package: "api",
|
|
@@ -1276,6 +1484,11 @@ var catalog_default = [
|
|
|
1276
1484
|
package: "store",
|
|
1277
1485
|
description: ""
|
|
1278
1486
|
},
|
|
1487
|
+
{
|
|
1488
|
+
name: "ErrStoreBusy",
|
|
1489
|
+
package: "store",
|
|
1490
|
+
description: ""
|
|
1491
|
+
},
|
|
1279
1492
|
{
|
|
1280
1493
|
name: "ErrConfigMalformed",
|
|
1281
1494
|
package: "clisetup",
|
|
@@ -1285,6 +1498,41 @@ var catalog_default = [
|
|
|
1285
1498
|
name: "ErrStoreOpen",
|
|
1286
1499
|
package: "clisetup",
|
|
1287
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: ""
|
|
1288
1536
|
}
|
|
1289
1537
|
];
|
|
1290
1538
|
|
|
@@ -1306,9 +1554,11 @@ function throwFromEnvelope(verb, envelope) {
|
|
|
1306
1554
|
const errName = env.err_name;
|
|
1307
1555
|
const envelopeRecord = envelope;
|
|
1308
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;
|
|
1309
1559
|
const Ctor = errorMap.get(errName);
|
|
1310
1560
|
if (Ctor !== undefined) {
|
|
1311
|
-
throw new Ctor(verb, errName, errDescription);
|
|
1561
|
+
throw new Ctor(verb, errName, errDescription, errDetails);
|
|
1312
1562
|
}
|
|
1313
1563
|
throw new ErrUnknownErrorName(errName, envelope);
|
|
1314
1564
|
}
|
|
@@ -1353,6 +1603,8 @@ class SubprocessClient {
|
|
|
1353
1603
|
g.tmuxCommand = opts.tmuxCommand;
|
|
1354
1604
|
if (opts.home !== undefined)
|
|
1355
1605
|
g.home = opts.home;
|
|
1606
|
+
if (opts.createIfMissing !== undefined)
|
|
1607
|
+
g.createIfMissing = opts.createIfMissing;
|
|
1356
1608
|
this.#globalOpts = g;
|
|
1357
1609
|
this.#open = true;
|
|
1358
1610
|
this.#tail = Promise.resolve();
|
|
@@ -1536,6 +1788,10 @@ class SubprocessClient {
|
|
|
1536
1788
|
this.#assertOpen();
|
|
1537
1789
|
return this.#enqueue("get-permission", params);
|
|
1538
1790
|
}
|
|
1791
|
+
async recordPaneAnswer(params) {
|
|
1792
|
+
this.#assertOpen();
|
|
1793
|
+
return this.#enqueue("record-pane-answer", params);
|
|
1794
|
+
}
|
|
1539
1795
|
async resume(params) {
|
|
1540
1796
|
this.#assertOpen();
|
|
1541
1797
|
return this.#enqueue("resume", params);
|
|
@@ -1556,6 +1812,10 @@ class SubprocessClient {
|
|
|
1556
1812
|
this.#assertOpen();
|
|
1557
1813
|
return this.#enqueue("list", params);
|
|
1558
1814
|
}
|
|
1815
|
+
async listSubagents(params) {
|
|
1816
|
+
this.#assertOpen();
|
|
1817
|
+
return this.#enqueue("list-subagents", params);
|
|
1818
|
+
}
|
|
1559
1819
|
async pause(params) {
|
|
1560
1820
|
this.#assertOpen();
|
|
1561
1821
|
return this.#enqueue("pause", params);
|
|
@@ -1661,7 +1921,9 @@ export {
|
|
|
1661
1921
|
resolveSystemBinary,
|
|
1662
1922
|
errorFromEnvelope,
|
|
1663
1923
|
MIN_BINARY_VERSION,
|
|
1924
|
+
ErrUnknownVerb,
|
|
1664
1925
|
ErrUnknownErrorName,
|
|
1926
|
+
ErrTrailWrite,
|
|
1665
1927
|
ErrTmuxUnresponsive,
|
|
1666
1928
|
ErrTmuxSessionNameTooLong,
|
|
1667
1929
|
ErrTmuxSessionNameInvalid,
|
|
@@ -1676,33 +1938,44 @@ export {
|
|
|
1676
1938
|
ErrTemplateNameUnsafe,
|
|
1677
1939
|
ErrTemplateMalformed,
|
|
1678
1940
|
ErrTemplateExists,
|
|
1941
|
+
ErrTemplateAgentMissing,
|
|
1679
1942
|
ErrSystemInstallUnreachable,
|
|
1680
1943
|
ErrSystemInstallTooOld,
|
|
1681
1944
|
ErrSystemInstallNotFound,
|
|
1682
1945
|
ErrSystemInstallDisappeared,
|
|
1683
1946
|
ErrStoreOpen,
|
|
1947
|
+
ErrStoreBusy,
|
|
1684
1948
|
ErrSpawnNotResumable,
|
|
1685
1949
|
ErrSpawnNotPausable,
|
|
1686
1950
|
ErrSpawnNotInteractive,
|
|
1687
1951
|
ErrSpawnNotFound,
|
|
1688
1952
|
ErrSpawnDeniedFlag,
|
|
1689
1953
|
ErrSendKeysWhileRelayed,
|
|
1954
|
+
ErrSchemaMismatch,
|
|
1955
|
+
ErrSchemaMigrationRequired,
|
|
1690
1956
|
ErrReservedEnvKey,
|
|
1691
1957
|
ErrRelayModeOff,
|
|
1692
1958
|
ErrRelayModeInvalid,
|
|
1693
1959
|
ErrRelayFallenBack,
|
|
1694
1960
|
ErrProbeUnsupported,
|
|
1961
|
+
ErrPermissionsUnsupported,
|
|
1695
1962
|
ErrPermissionRequestNotFound,
|
|
1696
1963
|
ErrPauseTimeout,
|
|
1964
|
+
ErrPaneChanged,
|
|
1965
|
+
ErrPaneAnswerInProgress,
|
|
1966
|
+
ErrOldLayout,
|
|
1697
1967
|
ErrNoSessionId,
|
|
1698
1968
|
ErrNoOpenPermissionRequest,
|
|
1699
1969
|
ErrMissingRequestToken,
|
|
1700
1970
|
ErrListInvalidLabel,
|
|
1701
1971
|
ErrJsonlNeverWritten,
|
|
1702
1972
|
ErrJsonlMissing,
|
|
1973
|
+
ErrJSONMarshal,
|
|
1703
1974
|
ErrInvalidFlags,
|
|
1704
1975
|
ErrInvalidDecision,
|
|
1976
|
+
ErrInternal,
|
|
1705
1977
|
ErrInstanceIdCollision,
|
|
1978
|
+
ErrDialogMaybeOpen,
|
|
1706
1979
|
ErrCwdNotFound,
|
|
1707
1980
|
ErrCwdNotAPath,
|
|
1708
1981
|
ErrCwdNotADirectory,
|
|
@@ -1710,11 +1983,15 @@ export {
|
|
|
1710
1983
|
ErrConsumerSignal,
|
|
1711
1984
|
ErrConfigMalformed,
|
|
1712
1985
|
ErrClientClosed,
|
|
1986
|
+
ErrClaimTooSoon,
|
|
1713
1987
|
ErrCallerCwdUnreachable,
|
|
1714
1988
|
ErrCallTimeout,
|
|
1715
1989
|
ErrBunVersionTooOld,
|
|
1716
1990
|
ErrAmbiguousRequest,
|
|
1717
1991
|
ErrAlreadyDecided,
|
|
1992
|
+
ErrAgentMissing,
|
|
1993
|
+
ErrAgentInvalid,
|
|
1994
|
+
ErrAgentArgsMismatch,
|
|
1718
1995
|
DEV_SENTINEL_VERSION,
|
|
1719
1996
|
Client,
|
|
1720
1997
|
AgentDirectorError
|