@sjawhar/claude-envoy 6.28.1 → 6.30.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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +54 -17
- package/dist/dispatch.js +54 -17
- package/dist/envoy-channel.js +55 -18
- package/dist/session-hook.js +54 -17
- package/package.json +1 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -24523,10 +24523,17 @@ function optionalComponents(args, name) {
|
|
|
24523
24523
|
function asObject(value) {
|
|
24524
24524
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
24525
24525
|
}
|
|
24526
|
+
function dispatchClientFor(input, options = {}) {
|
|
24527
|
+
return new DispatchClient(input.config.url, input.config.credential, input.fetchImpl ?? fetch, {
|
|
24528
|
+
signal: input.signal,
|
|
24529
|
+
writeRetry: input.writeRetry,
|
|
24530
|
+
sleep: input.sleep,
|
|
24531
|
+
...options
|
|
24532
|
+
});
|
|
24533
|
+
}
|
|
24526
24534
|
function sessionContext(input, checked) {
|
|
24527
|
-
const { url
|
|
24535
|
+
const { url } = input.config;
|
|
24528
24536
|
const configUrl = urlForText(url, "the configured Dispatch URL");
|
|
24529
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
24530
24537
|
return {
|
|
24531
24538
|
input,
|
|
24532
24539
|
args: checked.args,
|
|
@@ -24535,12 +24542,7 @@ function sessionContext(input, checked) {
|
|
|
24535
24542
|
configUrl,
|
|
24536
24543
|
linkBase: linkBaseOf(input.config.publicUrl ?? url),
|
|
24537
24544
|
hostSession: input.sessionId?.trim(),
|
|
24538
|
-
newClient: (options = {}) =>
|
|
24539
|
-
signal: input.signal,
|
|
24540
|
-
writeRetry: input.writeRetry,
|
|
24541
|
-
sleep: input.sleep,
|
|
24542
|
-
...options
|
|
24543
|
-
})
|
|
24545
|
+
newClient: (options = {}) => dispatchClientFor(input, options)
|
|
24544
24546
|
};
|
|
24545
24547
|
}
|
|
24546
24548
|
|
|
@@ -24685,8 +24687,8 @@ class ReadCut {
|
|
|
24685
24687
|
return `Left out at ${this.asOf}: ${named.size === 0 ? "nothing" : [...named].join(", ")}`;
|
|
24686
24688
|
}
|
|
24687
24689
|
}
|
|
24688
|
-
async function readAtCut(session) {
|
|
24689
|
-
const identity = await
|
|
24690
|
+
async function readAtCut(session, whoami) {
|
|
24691
|
+
const identity = await whoami();
|
|
24690
24692
|
const tokenCut = identity.kind === "agent" ? identity.cut ?? null : null;
|
|
24691
24693
|
const { tool } = session.input;
|
|
24692
24694
|
if (tokenCut !== null && tool === "dispatch_results" && optionalString(session.args, "at") !== undefined) {
|
|
@@ -28452,14 +28454,40 @@ function toolSchema(tool) {
|
|
|
28452
28454
|
toolSchemas.set(tool, schema);
|
|
28453
28455
|
return schema;
|
|
28454
28456
|
}
|
|
28455
|
-
|
|
28457
|
+
function dispatchRefAtFirst(refArgument, bases) {
|
|
28458
|
+
for (const base of bases) {
|
|
28459
|
+
if (typeof base !== "string")
|
|
28460
|
+
continue;
|
|
28461
|
+
const resolved = dispatchRefFromUrl(refArgument, base);
|
|
28462
|
+
if (resolved !== undefined)
|
|
28463
|
+
return resolved;
|
|
28464
|
+
}
|
|
28465
|
+
return;
|
|
28466
|
+
}
|
|
28467
|
+
async function resolveDashboardRef(refArgument, dashboardUrls, whoami) {
|
|
28468
|
+
const configured = dispatchRefAtFirst(refArgument, dashboardUrls);
|
|
28469
|
+
if (configured !== undefined)
|
|
28470
|
+
return configured;
|
|
28471
|
+
if (whoami === undefined || !isHttpUrl(refArgument))
|
|
28472
|
+
return refArgument;
|
|
28473
|
+
let origins;
|
|
28474
|
+
try {
|
|
28475
|
+
origins = (await whoami()).origins;
|
|
28476
|
+
} catch {
|
|
28477
|
+
return refArgument;
|
|
28478
|
+
}
|
|
28479
|
+
if (!Array.isArray(origins))
|
|
28480
|
+
return refArgument;
|
|
28481
|
+
return dispatchRefAtFirst(refArgument, origins) ?? refArgument;
|
|
28482
|
+
}
|
|
28483
|
+
async function resolveOwnerArguments(tool, input, context, problems) {
|
|
28456
28484
|
if (issueFreeTools[tool] === true)
|
|
28457
28485
|
return { args: input, ref: null, owner: null };
|
|
28458
28486
|
const refArgument = input.ref;
|
|
28459
28487
|
let ref = null;
|
|
28460
28488
|
let args = input;
|
|
28461
28489
|
if (typeof refArgument === "string") {
|
|
28462
|
-
const refText =
|
|
28490
|
+
const refText = await resolveDashboardRef(refArgument, context.serverUrls, context.whoami);
|
|
28463
28491
|
if (refText !== refArgument)
|
|
28464
28492
|
args = { ...input, ref: refText };
|
|
28465
28493
|
const agentArtifact = parseAgentArtifactRef(refText);
|
|
@@ -28549,7 +28577,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
28549
28577
|
if (tool === "dispatch_spec_form" && typeof args["root"] === "string") {
|
|
28550
28578
|
return { args, ref, owner: null };
|
|
28551
28579
|
}
|
|
28552
|
-
const legionIssue = env.LEGION_ISSUE;
|
|
28580
|
+
const legionIssue = (context.env ?? process.env).LEGION_ISSUE;
|
|
28553
28581
|
if (!legionIssue) {
|
|
28554
28582
|
problems.push(ownerRequiredProblem);
|
|
28555
28583
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -28562,7 +28590,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
28562
28590
|
problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
|
|
28563
28591
|
return { args, ref, owner: null, ownerMissing: true };
|
|
28564
28592
|
}
|
|
28565
|
-
const repo = await resolveCwdRepo(cwd, exec);
|
|
28593
|
+
const repo = await resolveCwdRepo(context.cwd, context.exec ?? defaultExec);
|
|
28566
28594
|
if (!repo) {
|
|
28567
28595
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
28568
28596
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -28585,7 +28613,7 @@ function dispatchServerUrls(config) {
|
|
|
28585
28613
|
async function checkDispatchCall(input) {
|
|
28586
28614
|
const { tool, args, cwd } = input;
|
|
28587
28615
|
const problems = [];
|
|
28588
|
-
const owner = await resolveOwnerArguments(tool, args,
|
|
28616
|
+
const owner = await resolveOwnerArguments(tool, args, input, problems);
|
|
28589
28617
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
28590
28618
|
problems.push(...conflicts);
|
|
28591
28619
|
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
@@ -34901,9 +34929,18 @@ var dispatchCommands = {
|
|
|
34901
34929
|
};
|
|
34902
34930
|
// ../envoy-client/src/dispatch-execute.ts
|
|
34903
34931
|
async function executeDispatchTool(input) {
|
|
34932
|
+
let identity;
|
|
34933
|
+
const whoami = () => {
|
|
34934
|
+
identity ??= dispatchClientFor(input).whoami().catch((error) => {
|
|
34935
|
+
identity = undefined;
|
|
34936
|
+
throw error;
|
|
34937
|
+
});
|
|
34938
|
+
return identity;
|
|
34939
|
+
};
|
|
34904
34940
|
const checked = await checkDispatchCall({
|
|
34905
34941
|
...input,
|
|
34906
|
-
serverUrls: dispatchServerUrls(input.config)
|
|
34942
|
+
serverUrls: dispatchServerUrls(input.config),
|
|
34943
|
+
whoami
|
|
34907
34944
|
});
|
|
34908
34945
|
if (checked.problems.length > 0)
|
|
34909
34946
|
throw new ToolInputError(input.tool, checked.problems);
|
|
@@ -34917,7 +34954,7 @@ async function executeDispatchTool(input) {
|
|
|
34917
34954
|
if (!command.reads) {
|
|
34918
34955
|
return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
|
|
34919
34956
|
}
|
|
34920
|
-
const reading = await readAtCut(session);
|
|
34957
|
+
const reading = await readAtCut(session, whoami);
|
|
34921
34958
|
const result = command.origin === "none" ? await command.run({ ...session, reading }) : await command.run({ ...await commandContext(session, reading.cut), reading });
|
|
34922
34959
|
return withLeftOut(result, reading.cut);
|
|
34923
34960
|
}
|
package/dist/dispatch.js
CHANGED
|
@@ -25687,10 +25687,17 @@ function optionalComponents(args, name) {
|
|
|
25687
25687
|
function asObject(value) {
|
|
25688
25688
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
25689
25689
|
}
|
|
25690
|
+
function dispatchClientFor(input, options = {}) {
|
|
25691
|
+
return new DispatchClient(input.config.url, input.config.credential, input.fetchImpl ?? fetch, {
|
|
25692
|
+
signal: input.signal,
|
|
25693
|
+
writeRetry: input.writeRetry,
|
|
25694
|
+
sleep: input.sleep,
|
|
25695
|
+
...options
|
|
25696
|
+
});
|
|
25697
|
+
}
|
|
25690
25698
|
function sessionContext(input, checked) {
|
|
25691
|
-
const { url
|
|
25699
|
+
const { url } = input.config;
|
|
25692
25700
|
const configUrl = urlForText(url, "the configured Dispatch URL");
|
|
25693
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
25694
25701
|
return {
|
|
25695
25702
|
input,
|
|
25696
25703
|
args: checked.args,
|
|
@@ -25699,12 +25706,7 @@ function sessionContext(input, checked) {
|
|
|
25699
25706
|
configUrl,
|
|
25700
25707
|
linkBase: linkBaseOf(input.config.publicUrl ?? url),
|
|
25701
25708
|
hostSession: input.sessionId?.trim(),
|
|
25702
|
-
newClient: (options = {}) =>
|
|
25703
|
-
signal: input.signal,
|
|
25704
|
-
writeRetry: input.writeRetry,
|
|
25705
|
-
sleep: input.sleep,
|
|
25706
|
-
...options
|
|
25707
|
-
})
|
|
25709
|
+
newClient: (options = {}) => dispatchClientFor(input, options)
|
|
25708
25710
|
};
|
|
25709
25711
|
}
|
|
25710
25712
|
|
|
@@ -25849,8 +25851,8 @@ class ReadCut {
|
|
|
25849
25851
|
return `Left out at ${this.asOf}: ${named.size === 0 ? "nothing" : [...named].join(", ")}`;
|
|
25850
25852
|
}
|
|
25851
25853
|
}
|
|
25852
|
-
async function readAtCut(session) {
|
|
25853
|
-
const identity = await
|
|
25854
|
+
async function readAtCut(session, whoami) {
|
|
25855
|
+
const identity = await whoami();
|
|
25854
25856
|
const tokenCut = identity.kind === "agent" ? identity.cut ?? null : null;
|
|
25855
25857
|
const { tool } = session.input;
|
|
25856
25858
|
if (tokenCut !== null && tool === "dispatch_results" && optionalString(session.args, "at") !== undefined) {
|
|
@@ -35848,14 +35850,40 @@ function toolSchema(tool) {
|
|
|
35848
35850
|
toolSchemas.set(tool, schema);
|
|
35849
35851
|
return schema;
|
|
35850
35852
|
}
|
|
35851
|
-
|
|
35853
|
+
function dispatchRefAtFirst(refArgument, bases) {
|
|
35854
|
+
for (const base of bases) {
|
|
35855
|
+
if (typeof base !== "string")
|
|
35856
|
+
continue;
|
|
35857
|
+
const resolved = dispatchRefFromUrl(refArgument, base);
|
|
35858
|
+
if (resolved !== undefined)
|
|
35859
|
+
return resolved;
|
|
35860
|
+
}
|
|
35861
|
+
return;
|
|
35862
|
+
}
|
|
35863
|
+
async function resolveDashboardRef(refArgument, dashboardUrls, whoami) {
|
|
35864
|
+
const configured = dispatchRefAtFirst(refArgument, dashboardUrls);
|
|
35865
|
+
if (configured !== undefined)
|
|
35866
|
+
return configured;
|
|
35867
|
+
if (whoami === undefined || !isHttpUrl(refArgument))
|
|
35868
|
+
return refArgument;
|
|
35869
|
+
let origins;
|
|
35870
|
+
try {
|
|
35871
|
+
origins = (await whoami()).origins;
|
|
35872
|
+
} catch {
|
|
35873
|
+
return refArgument;
|
|
35874
|
+
}
|
|
35875
|
+
if (!Array.isArray(origins))
|
|
35876
|
+
return refArgument;
|
|
35877
|
+
return dispatchRefAtFirst(refArgument, origins) ?? refArgument;
|
|
35878
|
+
}
|
|
35879
|
+
async function resolveOwnerArguments(tool, input, context, problems) {
|
|
35852
35880
|
if (issueFreeTools[tool] === true)
|
|
35853
35881
|
return { args: input, ref: null, owner: null };
|
|
35854
35882
|
const refArgument = input.ref;
|
|
35855
35883
|
let ref = null;
|
|
35856
35884
|
let args = input;
|
|
35857
35885
|
if (typeof refArgument === "string") {
|
|
35858
|
-
const refText =
|
|
35886
|
+
const refText = await resolveDashboardRef(refArgument, context.serverUrls, context.whoami);
|
|
35859
35887
|
if (refText !== refArgument)
|
|
35860
35888
|
args = { ...input, ref: refText };
|
|
35861
35889
|
const agentArtifact = parseAgentArtifactRef(refText);
|
|
@@ -35945,7 +35973,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
35945
35973
|
if (tool === "dispatch_spec_form" && typeof args["root"] === "string") {
|
|
35946
35974
|
return { args, ref, owner: null };
|
|
35947
35975
|
}
|
|
35948
|
-
const legionIssue = env.LEGION_ISSUE;
|
|
35976
|
+
const legionIssue = (context.env ?? process.env).LEGION_ISSUE;
|
|
35949
35977
|
if (!legionIssue) {
|
|
35950
35978
|
problems.push(ownerRequiredProblem);
|
|
35951
35979
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -35958,7 +35986,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
35958
35986
|
problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
|
|
35959
35987
|
return { args, ref, owner: null, ownerMissing: true };
|
|
35960
35988
|
}
|
|
35961
|
-
const repo = await resolveCwdRepo(cwd, exec);
|
|
35989
|
+
const repo = await resolveCwdRepo(context.cwd, context.exec ?? defaultExec);
|
|
35962
35990
|
if (!repo) {
|
|
35963
35991
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
35964
35992
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -35981,7 +36009,7 @@ function dispatchServerUrls(config) {
|
|
|
35981
36009
|
async function checkDispatchCall(input) {
|
|
35982
36010
|
const { tool, args, cwd } = input;
|
|
35983
36011
|
const problems = [];
|
|
35984
|
-
const owner = await resolveOwnerArguments(tool, args,
|
|
36012
|
+
const owner = await resolveOwnerArguments(tool, args, input, problems);
|
|
35985
36013
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
35986
36014
|
problems.push(...conflicts);
|
|
35987
36015
|
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
@@ -41108,9 +41136,18 @@ var dispatchCommands = {
|
|
|
41108
41136
|
};
|
|
41109
41137
|
// ../envoy-client/src/dispatch-execute.ts
|
|
41110
41138
|
async function executeDispatchTool(input) {
|
|
41139
|
+
let identity;
|
|
41140
|
+
const whoami = () => {
|
|
41141
|
+
identity ??= dispatchClientFor(input).whoami().catch((error) => {
|
|
41142
|
+
identity = undefined;
|
|
41143
|
+
throw error;
|
|
41144
|
+
});
|
|
41145
|
+
return identity;
|
|
41146
|
+
};
|
|
41111
41147
|
const checked = await checkDispatchCall({
|
|
41112
41148
|
...input,
|
|
41113
|
-
serverUrls: dispatchServerUrls(input.config)
|
|
41149
|
+
serverUrls: dispatchServerUrls(input.config),
|
|
41150
|
+
whoami
|
|
41114
41151
|
});
|
|
41115
41152
|
if (checked.problems.length > 0)
|
|
41116
41153
|
throw new ToolInputError(input.tool, checked.problems);
|
|
@@ -41124,7 +41161,7 @@ async function executeDispatchTool(input) {
|
|
|
41124
41161
|
if (!command.reads) {
|
|
41125
41162
|
return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
|
|
41126
41163
|
}
|
|
41127
|
-
const reading = await readAtCut(session);
|
|
41164
|
+
const reading = await readAtCut(session, whoami);
|
|
41128
41165
|
const result = command.origin === "none" ? await command.run({ ...session, reading }) : await command.run({ ...await commandContext(session, reading.cut), reading });
|
|
41129
41166
|
return withLeftOut(result, reading.cut);
|
|
41130
41167
|
}
|
package/dist/envoy-channel.js
CHANGED
|
@@ -52395,10 +52395,17 @@ function optionalComponents(args, name) {
|
|
|
52395
52395
|
function asObject(value) {
|
|
52396
52396
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
52397
52397
|
}
|
|
52398
|
+
function dispatchClientFor(input, options = {}) {
|
|
52399
|
+
return new DispatchClient(input.config.url, input.config.credential, input.fetchImpl ?? fetch, {
|
|
52400
|
+
signal: input.signal,
|
|
52401
|
+
writeRetry: input.writeRetry,
|
|
52402
|
+
sleep: input.sleep,
|
|
52403
|
+
...options
|
|
52404
|
+
});
|
|
52405
|
+
}
|
|
52398
52406
|
function sessionContext(input, checked) {
|
|
52399
|
-
const { url
|
|
52407
|
+
const { url } = input.config;
|
|
52400
52408
|
const configUrl = urlForText(url, "the configured Dispatch URL");
|
|
52401
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
52402
52409
|
return {
|
|
52403
52410
|
input,
|
|
52404
52411
|
args: checked.args,
|
|
@@ -52407,12 +52414,7 @@ function sessionContext(input, checked) {
|
|
|
52407
52414
|
configUrl,
|
|
52408
52415
|
linkBase: linkBaseOf(input.config.publicUrl ?? url),
|
|
52409
52416
|
hostSession: input.sessionId?.trim(),
|
|
52410
|
-
newClient: (options = {}) =>
|
|
52411
|
-
signal: input.signal,
|
|
52412
|
-
writeRetry: input.writeRetry,
|
|
52413
|
-
sleep: input.sleep,
|
|
52414
|
-
...options
|
|
52415
|
-
})
|
|
52417
|
+
newClient: (options = {}) => dispatchClientFor(input, options)
|
|
52416
52418
|
};
|
|
52417
52419
|
}
|
|
52418
52420
|
|
|
@@ -52557,8 +52559,8 @@ class ReadCut {
|
|
|
52557
52559
|
return `Left out at ${this.asOf}: ${named.size === 0 ? "nothing" : [...named].join(", ")}`;
|
|
52558
52560
|
}
|
|
52559
52561
|
}
|
|
52560
|
-
async function readAtCut(session) {
|
|
52561
|
-
const identity = await
|
|
52562
|
+
async function readAtCut(session, whoami) {
|
|
52563
|
+
const identity = await whoami();
|
|
52562
52564
|
const tokenCut = identity.kind === "agent" ? identity.cut ?? null : null;
|
|
52563
52565
|
const { tool } = session.input;
|
|
52564
52566
|
if (tokenCut !== null && tool === "dispatch_results" && optionalString(session.args, "at") !== undefined) {
|
|
@@ -56324,14 +56326,40 @@ function toolSchema(tool) {
|
|
|
56324
56326
|
toolSchemas.set(tool, schema);
|
|
56325
56327
|
return schema;
|
|
56326
56328
|
}
|
|
56327
|
-
|
|
56329
|
+
function dispatchRefAtFirst(refArgument, bases) {
|
|
56330
|
+
for (const base of bases) {
|
|
56331
|
+
if (typeof base !== "string")
|
|
56332
|
+
continue;
|
|
56333
|
+
const resolved = dispatchRefFromUrl(refArgument, base);
|
|
56334
|
+
if (resolved !== undefined)
|
|
56335
|
+
return resolved;
|
|
56336
|
+
}
|
|
56337
|
+
return;
|
|
56338
|
+
}
|
|
56339
|
+
async function resolveDashboardRef(refArgument, dashboardUrls, whoami) {
|
|
56340
|
+
const configured = dispatchRefAtFirst(refArgument, dashboardUrls);
|
|
56341
|
+
if (configured !== undefined)
|
|
56342
|
+
return configured;
|
|
56343
|
+
if (whoami === undefined || !isHttpUrl(refArgument))
|
|
56344
|
+
return refArgument;
|
|
56345
|
+
let origins;
|
|
56346
|
+
try {
|
|
56347
|
+
origins = (await whoami()).origins;
|
|
56348
|
+
} catch {
|
|
56349
|
+
return refArgument;
|
|
56350
|
+
}
|
|
56351
|
+
if (!Array.isArray(origins))
|
|
56352
|
+
return refArgument;
|
|
56353
|
+
return dispatchRefAtFirst(refArgument, origins) ?? refArgument;
|
|
56354
|
+
}
|
|
56355
|
+
async function resolveOwnerArguments(tool, input, context, problems) {
|
|
56328
56356
|
if (issueFreeTools[tool] === true)
|
|
56329
56357
|
return { args: input, ref: null, owner: null };
|
|
56330
56358
|
const refArgument = input.ref;
|
|
56331
56359
|
let ref = null;
|
|
56332
56360
|
let args = input;
|
|
56333
56361
|
if (typeof refArgument === "string") {
|
|
56334
|
-
const refText =
|
|
56362
|
+
const refText = await resolveDashboardRef(refArgument, context.serverUrls, context.whoami);
|
|
56335
56363
|
if (refText !== refArgument)
|
|
56336
56364
|
args = { ...input, ref: refText };
|
|
56337
56365
|
const agentArtifact = parseAgentArtifactRef(refText);
|
|
@@ -56421,7 +56449,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
56421
56449
|
if (tool === "dispatch_spec_form" && typeof args["root"] === "string") {
|
|
56422
56450
|
return { args, ref, owner: null };
|
|
56423
56451
|
}
|
|
56424
|
-
const legionIssue = env.LEGION_ISSUE;
|
|
56452
|
+
const legionIssue = (context.env ?? process.env).LEGION_ISSUE;
|
|
56425
56453
|
if (!legionIssue) {
|
|
56426
56454
|
problems.push(ownerRequiredProblem);
|
|
56427
56455
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -56434,7 +56462,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
56434
56462
|
problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
|
|
56435
56463
|
return { args, ref, owner: null, ownerMissing: true };
|
|
56436
56464
|
}
|
|
56437
|
-
const repo = await resolveCwdRepo(cwd, exec);
|
|
56465
|
+
const repo = await resolveCwdRepo(context.cwd, context.exec ?? defaultExec);
|
|
56438
56466
|
if (!repo) {
|
|
56439
56467
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
56440
56468
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -56457,7 +56485,7 @@ function dispatchServerUrls(config) {
|
|
|
56457
56485
|
async function checkDispatchCall(input) {
|
|
56458
56486
|
const { tool, args, cwd } = input;
|
|
56459
56487
|
const problems = [];
|
|
56460
|
-
const owner = await resolveOwnerArguments(tool, args,
|
|
56488
|
+
const owner = await resolveOwnerArguments(tool, args, input, problems);
|
|
56461
56489
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
56462
56490
|
problems.push(...conflicts);
|
|
56463
56491
|
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
@@ -62402,9 +62430,18 @@ var dispatchCommands = {
|
|
|
62402
62430
|
};
|
|
62403
62431
|
// ../envoy-client/src/dispatch-execute.ts
|
|
62404
62432
|
async function executeDispatchTool(input) {
|
|
62433
|
+
let identity;
|
|
62434
|
+
const whoami = () => {
|
|
62435
|
+
identity ??= dispatchClientFor(input).whoami().catch((error) => {
|
|
62436
|
+
identity = undefined;
|
|
62437
|
+
throw error;
|
|
62438
|
+
});
|
|
62439
|
+
return identity;
|
|
62440
|
+
};
|
|
62405
62441
|
const checked = await checkDispatchCall({
|
|
62406
62442
|
...input,
|
|
62407
|
-
serverUrls: dispatchServerUrls(input.config)
|
|
62443
|
+
serverUrls: dispatchServerUrls(input.config),
|
|
62444
|
+
whoami
|
|
62408
62445
|
});
|
|
62409
62446
|
if (checked.problems.length > 0)
|
|
62410
62447
|
throw new ToolInputError(input.tool, checked.problems);
|
|
@@ -62418,7 +62455,7 @@ async function executeDispatchTool(input) {
|
|
|
62418
62455
|
if (!command.reads) {
|
|
62419
62456
|
return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
|
|
62420
62457
|
}
|
|
62421
|
-
const reading = await readAtCut(session);
|
|
62458
|
+
const reading = await readAtCut(session, whoami);
|
|
62422
62459
|
const result = command.origin === "none" ? await command.run({ ...session, reading }) : await command.run({ ...await commandContext(session, reading.cut), reading });
|
|
62423
62460
|
return withLeftOut(result, reading.cut);
|
|
62424
62461
|
}
|
|
@@ -69005,7 +69042,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
69005
69042
|
|
|
69006
69043
|
// package.json
|
|
69007
69044
|
var name2 = "@sjawhar/claude-envoy";
|
|
69008
|
-
var version2 = "6.
|
|
69045
|
+
var version2 = "6.30.0";
|
|
69009
69046
|
var package_default = {
|
|
69010
69047
|
name: name2,
|
|
69011
69048
|
version: version2,
|
package/dist/session-hook.js
CHANGED
|
@@ -27440,10 +27440,17 @@ function optionalComponents(args, name) {
|
|
|
27440
27440
|
function asObject(value) {
|
|
27441
27441
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
27442
27442
|
}
|
|
27443
|
+
function dispatchClientFor(input, options = {}) {
|
|
27444
|
+
return new DispatchClient(input.config.url, input.config.credential, input.fetchImpl ?? fetch, {
|
|
27445
|
+
signal: input.signal,
|
|
27446
|
+
writeRetry: input.writeRetry,
|
|
27447
|
+
sleep: input.sleep,
|
|
27448
|
+
...options
|
|
27449
|
+
});
|
|
27450
|
+
}
|
|
27443
27451
|
function sessionContext(input, checked) {
|
|
27444
|
-
const { url
|
|
27452
|
+
const { url } = input.config;
|
|
27445
27453
|
const configUrl = urlForText(url, "the configured Dispatch URL");
|
|
27446
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
27447
27454
|
return {
|
|
27448
27455
|
input,
|
|
27449
27456
|
args: checked.args,
|
|
@@ -27452,12 +27459,7 @@ function sessionContext(input, checked) {
|
|
|
27452
27459
|
configUrl,
|
|
27453
27460
|
linkBase: linkBaseOf(input.config.publicUrl ?? url),
|
|
27454
27461
|
hostSession: input.sessionId?.trim(),
|
|
27455
|
-
newClient: (options = {}) =>
|
|
27456
|
-
signal: input.signal,
|
|
27457
|
-
writeRetry: input.writeRetry,
|
|
27458
|
-
sleep: input.sleep,
|
|
27459
|
-
...options
|
|
27460
|
-
})
|
|
27462
|
+
newClient: (options = {}) => dispatchClientFor(input, options)
|
|
27461
27463
|
};
|
|
27462
27464
|
}
|
|
27463
27465
|
|
|
@@ -27602,8 +27604,8 @@ class ReadCut {
|
|
|
27602
27604
|
return `Left out at ${this.asOf}: ${named.size === 0 ? "nothing" : [...named].join(", ")}`;
|
|
27603
27605
|
}
|
|
27604
27606
|
}
|
|
27605
|
-
async function readAtCut(session) {
|
|
27606
|
-
const identity = await
|
|
27607
|
+
async function readAtCut(session, whoami) {
|
|
27608
|
+
const identity = await whoami();
|
|
27607
27609
|
const tokenCut = identity.kind === "agent" ? identity.cut ?? null : null;
|
|
27608
27610
|
const { tool } = session.input;
|
|
27609
27611
|
if (tokenCut !== null && tool === "dispatch_results" && optionalString(session.args, "at") !== undefined) {
|
|
@@ -31369,14 +31371,40 @@ function toolSchema(tool) {
|
|
|
31369
31371
|
toolSchemas.set(tool, schema);
|
|
31370
31372
|
return schema;
|
|
31371
31373
|
}
|
|
31372
|
-
|
|
31374
|
+
function dispatchRefAtFirst(refArgument, bases) {
|
|
31375
|
+
for (const base of bases) {
|
|
31376
|
+
if (typeof base !== "string")
|
|
31377
|
+
continue;
|
|
31378
|
+
const resolved = dispatchRefFromUrl(refArgument, base);
|
|
31379
|
+
if (resolved !== undefined)
|
|
31380
|
+
return resolved;
|
|
31381
|
+
}
|
|
31382
|
+
return;
|
|
31383
|
+
}
|
|
31384
|
+
async function resolveDashboardRef(refArgument, dashboardUrls, whoami) {
|
|
31385
|
+
const configured = dispatchRefAtFirst(refArgument, dashboardUrls);
|
|
31386
|
+
if (configured !== undefined)
|
|
31387
|
+
return configured;
|
|
31388
|
+
if (whoami === undefined || !isHttpUrl(refArgument))
|
|
31389
|
+
return refArgument;
|
|
31390
|
+
let origins;
|
|
31391
|
+
try {
|
|
31392
|
+
origins = (await whoami()).origins;
|
|
31393
|
+
} catch {
|
|
31394
|
+
return refArgument;
|
|
31395
|
+
}
|
|
31396
|
+
if (!Array.isArray(origins))
|
|
31397
|
+
return refArgument;
|
|
31398
|
+
return dispatchRefAtFirst(refArgument, origins) ?? refArgument;
|
|
31399
|
+
}
|
|
31400
|
+
async function resolveOwnerArguments(tool, input, context, problems) {
|
|
31373
31401
|
if (issueFreeTools[tool] === true)
|
|
31374
31402
|
return { args: input, ref: null, owner: null };
|
|
31375
31403
|
const refArgument = input.ref;
|
|
31376
31404
|
let ref = null;
|
|
31377
31405
|
let args = input;
|
|
31378
31406
|
if (typeof refArgument === "string") {
|
|
31379
|
-
const refText =
|
|
31407
|
+
const refText = await resolveDashboardRef(refArgument, context.serverUrls, context.whoami);
|
|
31380
31408
|
if (refText !== refArgument)
|
|
31381
31409
|
args = { ...input, ref: refText };
|
|
31382
31410
|
const agentArtifact = parseAgentArtifactRef(refText);
|
|
@@ -31466,7 +31494,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
31466
31494
|
if (tool === "dispatch_spec_form" && typeof args["root"] === "string") {
|
|
31467
31495
|
return { args, ref, owner: null };
|
|
31468
31496
|
}
|
|
31469
|
-
const legionIssue = env.LEGION_ISSUE;
|
|
31497
|
+
const legionIssue = (context.env ?? process.env).LEGION_ISSUE;
|
|
31470
31498
|
if (!legionIssue) {
|
|
31471
31499
|
problems.push(ownerRequiredProblem);
|
|
31472
31500
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -31479,7 +31507,7 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, dashboardUrls,
|
|
|
31479
31507
|
problems.push("LEGION_ISSUE must be a native issue key (e.g. LEGION-3), an external owner/repo#n reference, or a bare positive issue number");
|
|
31480
31508
|
return { args, ref, owner: null, ownerMissing: true };
|
|
31481
31509
|
}
|
|
31482
|
-
const repo = await resolveCwdRepo(cwd, exec);
|
|
31510
|
+
const repo = await resolveCwdRepo(context.cwd, context.exec ?? defaultExec);
|
|
31483
31511
|
if (!repo) {
|
|
31484
31512
|
problems.push("issue is required; LEGION_ISSUE needs a GitHub repository in cwd");
|
|
31485
31513
|
return { args, ref, owner: null, ownerMissing: true };
|
|
@@ -31502,7 +31530,7 @@ function dispatchServerUrls(config) {
|
|
|
31502
31530
|
async function checkDispatchCall(input) {
|
|
31503
31531
|
const { tool, args, cwd } = input;
|
|
31504
31532
|
const problems = [];
|
|
31505
|
-
const owner = await resolveOwnerArguments(tool, args,
|
|
31533
|
+
const owner = await resolveOwnerArguments(tool, args, input, problems);
|
|
31506
31534
|
const conflicts = issueFreeTools[tool] === true ? [] : ownerConflictProblems(tool, args, owner.ref, optionalString(owner.args, "ref"));
|
|
31507
31535
|
problems.push(...conflicts);
|
|
31508
31536
|
const ownerAlreadySaid = issueFreeTools[tool] !== true && (owner.owner === null || conflicts.length > 0);
|
|
@@ -37818,9 +37846,18 @@ var dispatchCommands = {
|
|
|
37818
37846
|
};
|
|
37819
37847
|
// ../envoy-client/src/dispatch-execute.ts
|
|
37820
37848
|
async function executeDispatchTool(input) {
|
|
37849
|
+
let identity;
|
|
37850
|
+
const whoami = () => {
|
|
37851
|
+
identity ??= dispatchClientFor(input).whoami().catch((error) => {
|
|
37852
|
+
identity = undefined;
|
|
37853
|
+
throw error;
|
|
37854
|
+
});
|
|
37855
|
+
return identity;
|
|
37856
|
+
};
|
|
37821
37857
|
const checked = await checkDispatchCall({
|
|
37822
37858
|
...input,
|
|
37823
|
-
serverUrls: dispatchServerUrls(input.config)
|
|
37859
|
+
serverUrls: dispatchServerUrls(input.config),
|
|
37860
|
+
whoami
|
|
37824
37861
|
});
|
|
37825
37862
|
if (checked.problems.length > 0)
|
|
37826
37863
|
throw new ToolInputError(input.tool, checked.problems);
|
|
@@ -37834,7 +37871,7 @@ async function executeDispatchTool(input) {
|
|
|
37834
37871
|
if (!command.reads) {
|
|
37835
37872
|
return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
|
|
37836
37873
|
}
|
|
37837
|
-
const reading = await readAtCut(session);
|
|
37874
|
+
const reading = await readAtCut(session, whoami);
|
|
37838
37875
|
const result = command.origin === "none" ? await command.run({ ...session, reading }) : await command.run({ ...await commandContext(session, reading.cut), reading });
|
|
37839
37876
|
return withLeftOut(result, reading.cut);
|
|
37840
37877
|
}
|