@sjawhar/pi-envoy 16.23.0 → 16.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dispatch.js
CHANGED
|
@@ -14629,7 +14629,8 @@ var IssueEventPayloadSchema = object({
|
|
|
14629
14629
|
route: string2().nullish(),
|
|
14630
14630
|
changed: array(string2()).optional(),
|
|
14631
14631
|
ancestors: array(string2()).optional(),
|
|
14632
|
-
thread_logins: array(string2()).optional()
|
|
14632
|
+
thread_logins: array(string2()).optional(),
|
|
14633
|
+
forced: object({ past: array(string2()) }).optional()
|
|
14633
14634
|
});
|
|
14634
14635
|
var ArtifactCreatedEventPayloadSchema = object({
|
|
14635
14636
|
artifact: object({ id: string2().optional(), slug: string2().optional(), name: string2().optional() }).optional()
|
|
@@ -15582,12 +15583,12 @@ var dispatchToolSpecs = [
|
|
|
15582
15583
|
{
|
|
15583
15584
|
name: "dispatch_related",
|
|
15584
15585
|
example: { project: "CORE", title: "Retry failed webhook deliveries" },
|
|
15585
|
-
description: "Run the related-item check that dispatch issue, dispatch ask and a new decision block in " + "dispatch doc-edit run on their own write, and write nothing: it lists the three items of " + "one project most like a title and a text (at most one per issue or document, open ones " + "first), each ask with whether it is answered, and a past decision that already answers " + "the same question. Use it to check a draft before filing it. It searches by meaning and by " + "the text's rarest words, and says how it searched; when meaning search cannot run it " + "searches by keywords only and says why. When it could not search at all it says why and " + "names the dispatch search to run instead.
|
|
15586
|
+
description: "Run the related-item check that dispatch issue, dispatch ask and a new decision block in " + "dispatch doc-edit run on their own write, and write nothing: it lists the three items of " + "one project most like a title and a text (at most one per issue or document, open ones " + "first), each ask with whether it is answered, and a past decision that already answers " + "the same question. Use it to check a draft before filing it. It searches by meaning and by " + "the text's rarest words, and says how it searched; when meaning search cannot run it " + "searches by keywords only and says why. When it could not search at all it says why and " + "names the dispatch search to run instead. exclude_issues leaves each named issue's own " + "items out of the results, at most 50 of them, so a draft under a parent can leave out " + "that parent and its children without changing how rare the text's words are; " + "keywords_only skips meaning search.",
|
|
15586
15587
|
arguments: (z) => ({
|
|
15587
15588
|
project: z.string().describe("Project key to search within, such as CORE."),
|
|
15588
15589
|
title: z.string({ max: ISSUE_TITLE_MAX }).describe("Optional title to check, as an issue title; at most 1,000 characters.").optional(),
|
|
15589
15590
|
text: z.string().describe("Optional text to check, such as a draft spec or a question.").optional(),
|
|
15590
|
-
|
|
15591
|
+
exclude_issues: z.array(z.string()).describe("Optional issue keys in the project whose own items are left out of the results; at most 50.").optional(),
|
|
15591
15592
|
keywords_only: z.boolean().describe("Search by keywords only, skipping meaning search.").optional()
|
|
15592
15593
|
}),
|
|
15593
15594
|
validation: {
|
|
@@ -17460,9 +17461,12 @@ async function tryExec(exec, file, args, cwd, limitMs) {
|
|
|
17460
17461
|
exec(file, args, { cwd, signal: controller.signal }),
|
|
17461
17462
|
expired.promise
|
|
17462
17463
|
]);
|
|
17463
|
-
|
|
17464
|
+
if (answer === null) {
|
|
17465
|
+
return { failure: "timedOut", ok: false };
|
|
17466
|
+
}
|
|
17467
|
+
return { ok: true, stdout: answer.stdout };
|
|
17464
17468
|
} catch {
|
|
17465
|
-
return
|
|
17469
|
+
return { failure: "refused", ok: false };
|
|
17466
17470
|
} finally {
|
|
17467
17471
|
clearTimeout(timer);
|
|
17468
17472
|
}
|
|
@@ -17503,13 +17507,13 @@ function parseGitHubRemoteUrl(url) {
|
|
|
17503
17507
|
return null;
|
|
17504
17508
|
}
|
|
17505
17509
|
async function resolveCwdRepo(cwd, exec) {
|
|
17506
|
-
const
|
|
17507
|
-
if (
|
|
17508
|
-
const url = selectRemoteUrl(parseRemoteList(
|
|
17510
|
+
const remoteList = await tryExec(exec, "jj", ["git", "remote", "list"], cwd, REMOTE_LOOKUP_MS);
|
|
17511
|
+
if (remoteList.ok) {
|
|
17512
|
+
const url = selectRemoteUrl(parseRemoteList(remoteList.stdout));
|
|
17509
17513
|
return url ? parseGitHubRemoteUrl(url) : null;
|
|
17510
17514
|
}
|
|
17511
|
-
const
|
|
17512
|
-
return
|
|
17515
|
+
const originRemote = await tryExec(exec, "git", ["remote", "get-url", "origin"], cwd, REMOTE_LOOKUP_MS);
|
|
17516
|
+
return originRemote.ok ? parseGitHubRemoteUrl(originRemote.stdout) : null;
|
|
17513
17517
|
}
|
|
17514
17518
|
async function resolveOrigin(env, exec, cwd) {
|
|
17515
17519
|
const origin = {
|
|
@@ -17518,8 +17522,8 @@ async function resolveOrigin(env, exec, cwd) {
|
|
|
17518
17522
|
};
|
|
17519
17523
|
const pane = env.TMUX_PANE;
|
|
17520
17524
|
if (pane) {
|
|
17521
|
-
const
|
|
17522
|
-
const [target, paneId] =
|
|
17525
|
+
const answer = await tryExec(exec, "tmux", ["display-message", "-p", "-t", pane, "#S:#I.#P #{pane_id}"], cwd, TMUX_PANE_LOOKUP_MS);
|
|
17526
|
+
const [target, paneId] = answer.ok ? answer.stdout.trim().split(" ") : [];
|
|
17523
17527
|
if (target)
|
|
17524
17528
|
origin.tmux = target;
|
|
17525
17529
|
if (paneId)
|
|
@@ -19164,11 +19168,19 @@ function relatedCheckLines(suggestions, context) {
|
|
|
19164
19168
|
lines.push(`A past decision may already answer this: ${suggestionLabel(decision)}, answered by ${decision.answered_by}${when} \u2192 ${absoluteHref(decision.href, context.configUrl)}`);
|
|
19165
19169
|
lines.push(...askLines(decision.ask));
|
|
19166
19170
|
}
|
|
19171
|
+
const likely = suggestions.likely_duplicate;
|
|
19172
|
+
if (likely !== undefined && likely !== null) {
|
|
19173
|
+
lines.push(`Likely duplicate: ${likely.key} [${likely.status}] ${likely.title} \u2192 ${absoluteHref(likely.href, context.configUrl)}`);
|
|
19174
|
+
lines.push("Read it. If it is the same work, fold this issue into it by the duplicate rule of skill://dispatch-first.");
|
|
19175
|
+
}
|
|
19176
|
+
if (suggestions.near_copy_check !== undefined && suggestions.near_copy_check !== "") {
|
|
19177
|
+
lines.push(`No near-copy check was made: ${suggestions.near_copy_check}.`);
|
|
19178
|
+
}
|
|
19167
19179
|
for (const match of suggestions.title_matches ?? []) {
|
|
19168
|
-
lines.push(`
|
|
19180
|
+
lines.push(`Near copy you forced past: ${match.key} [${match.status}] ${match.title} \u2192 ${absoluteHref(match.href, context.configUrl)}`);
|
|
19169
19181
|
}
|
|
19170
19182
|
} catch (error) {
|
|
19171
|
-
lines.push(`The check's past decision or
|
|
19183
|
+
lines.push(`The check's past decision or near copies could not be shown: ${messageFor(error)}`);
|
|
19172
19184
|
}
|
|
19173
19185
|
return lines;
|
|
19174
19186
|
}
|
|
@@ -20826,7 +20838,13 @@ function eventHead(event) {
|
|
|
20826
20838
|
return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
|
|
20827
20839
|
case "artifact.human_edited":
|
|
20828
20840
|
return textHead(humanEditHead(event.payload));
|
|
20829
|
-
case "issue.created":
|
|
20841
|
+
case "issue.created": {
|
|
20842
|
+
const forced = event.payload.forced;
|
|
20843
|
+
const head = `status ${event.payload.status}`;
|
|
20844
|
+
if (forced === undefined)
|
|
20845
|
+
return head;
|
|
20846
|
+
return forced.past.length === 0 ? `${head} \xB7 forced, the near-copy check did not answer` : `${head} \xB7 forced past ${forced.past.join(", ")}`;
|
|
20847
|
+
}
|
|
20830
20848
|
case "issue.updated":
|
|
20831
20849
|
case "issue.closed":
|
|
20832
20850
|
return `status ${event.payload.status}`;
|
|
@@ -20842,10 +20860,14 @@ function eventRef(event) {
|
|
|
20842
20860
|
const kind = event.type.startsWith("message.") ? "message" : event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("ask.") ? "ask" : undefined;
|
|
20843
20861
|
return kind === undefined ? undefined : `dispatch://${event.issue_key}/${kind}/${id}`;
|
|
20844
20862
|
}
|
|
20863
|
+
function eventActorText(actor) {
|
|
20864
|
+
const title = actor.kind === "session" ? actor.origin?.session_title : undefined;
|
|
20865
|
+
return title === undefined || title === "" ? actorText(actor) : `${actorText(actor)} (${title})`;
|
|
20866
|
+
}
|
|
20845
20867
|
function eventLine(event) {
|
|
20846
20868
|
const head = eventHead(event);
|
|
20847
20869
|
const ref = eventRef(event);
|
|
20848
|
-
return `- #${event.seq} ${event.type}${ref === undefined ? "" : ` ${ref}`} \xB7 ${
|
|
20870
|
+
return `- #${event.seq} ${event.type}${ref === undefined ? "" : ` ${ref}`} \xB7 ${eventActorText(event.actor)} \xB7 ${event.created_at}${head === undefined || head === "" ? "" : ` \xB7 ${head}`}`;
|
|
20849
20871
|
}
|
|
20850
20872
|
function childrenSummary(issue) {
|
|
20851
20873
|
return [
|
|
@@ -21662,15 +21684,17 @@ async function executeDispatchTool(input) {
|
|
|
21662
21684
|
const candidates = duplicateCandidates(error);
|
|
21663
21685
|
return {
|
|
21664
21686
|
text: [
|
|
21665
|
-
`Not created: "${title}"
|
|
21687
|
+
`Not created: "${title}" is a near copy of an open issue.`,
|
|
21666
21688
|
...candidates.map((candidate) => {
|
|
21667
21689
|
const href = new URL(candidate.href, linkBase).toString();
|
|
21668
21690
|
return `${candidate.key} [${candidate.status}] ${candidate.title} \u2192 ${href}`;
|
|
21669
21691
|
}),
|
|
21670
|
-
"
|
|
21692
|
+
"Read each issue above. If one is the same work, fold this into it by the duplicate rule of skill://dispatch-first.",
|
|
21693
|
+
"If none is, run dispatch issue again with --force, and write in the new issue's spec why it is not each issue named here."
|
|
21671
21694
|
].join(`
|
|
21672
21695
|
`),
|
|
21673
|
-
details: { duplicates: candidates }
|
|
21696
|
+
details: { duplicates: candidates },
|
|
21697
|
+
refused: true
|
|
21674
21698
|
};
|
|
21675
21699
|
}
|
|
21676
21700
|
}
|
|
@@ -21838,12 +21862,12 @@ async function executeDispatchTool(input) {
|
|
|
21838
21862
|
const project = stringArg(args, "project");
|
|
21839
21863
|
const title = optionalString(args, "title");
|
|
21840
21864
|
const text = optionalString(args, "text");
|
|
21841
|
-
const
|
|
21865
|
+
const excludeIssues = optionalStringArray(args, "exclude_issues");
|
|
21842
21866
|
const keywordsOnly = optionalBoolean(args, "keywords_only");
|
|
21843
21867
|
const suggestions = await client.related(project, {
|
|
21844
21868
|
...title === undefined ? {} : { title },
|
|
21845
21869
|
...text === undefined ? {} : { text },
|
|
21846
|
-
...
|
|
21870
|
+
...excludeIssues === undefined ? {} : { exclude_issues: excludeIssues },
|
|
21847
21871
|
...keywordsOnly === undefined ? {} : { keywords_only: keywordsOnly }
|
|
21848
21872
|
});
|
|
21849
21873
|
return {
|
|
@@ -25920,12 +25944,17 @@ function dispatchTarget(env, config) {
|
|
|
25920
25944
|
var DEFAULT_ENVOY_URL = "http://127.0.0.1:9020";
|
|
25921
25945
|
var DEFAULT_HEARTBEAT_MS = SESSION_HEARTBEAT_MS;
|
|
25922
25946
|
var MIN_PASS_DEADLINE_MS = 30000;
|
|
25947
|
+
var DEFAULT_TMUX_PLACE_CACHE_MS = 30000;
|
|
25923
25948
|
var MIN_INTERVAL_MS = 25;
|
|
25924
25949
|
var MAX_INTERVAL_MS = 2147483647;
|
|
25925
25950
|
function namedInterval(raw) {
|
|
25926
25951
|
const parsed = Number(raw);
|
|
25927
25952
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
25928
25953
|
}
|
|
25954
|
+
function resolvedInterval(raw, fallback) {
|
|
25955
|
+
const named = namedInterval(raw);
|
|
25956
|
+
return named === undefined ? fallback : Math.min(Math.max(named, MIN_INTERVAL_MS), MAX_INTERVAL_MS);
|
|
25957
|
+
}
|
|
25929
25958
|
function natsSeedFromEnvironment(env) {
|
|
25930
25959
|
const { NATS_NKEY_SEED_FILE: file, NATS_NKEY_SEED: plain } = env;
|
|
25931
25960
|
if (file !== undefined) {
|
|
@@ -26016,8 +26045,8 @@ function envoySettings(env, config, options = {}) {
|
|
|
26016
26045
|
inbound = { off: messageFor(error) };
|
|
26017
26046
|
}
|
|
26018
26047
|
}
|
|
26019
|
-
const
|
|
26020
|
-
const
|
|
26048
|
+
const heartbeatMs = resolvedInterval(env.ENVOY_HEARTBEAT_MS, DEFAULT_HEARTBEAT_MS);
|
|
26049
|
+
const tmuxPlaceCacheMs = resolvedInterval(env.ENVOY_TMUX_PLACE_CACHE_MS, DEFAULT_TMUX_PLACE_CACHE_MS);
|
|
26021
26050
|
const namedPassDeadlineMs = namedInterval(env.ENVOY_PASS_DEADLINE_MS);
|
|
26022
26051
|
return {
|
|
26023
26052
|
enabled: true,
|
|
@@ -26025,6 +26054,7 @@ function envoySettings(env, config, options = {}) {
|
|
|
26025
26054
|
credential,
|
|
26026
26055
|
inbound,
|
|
26027
26056
|
heartbeatMs,
|
|
26057
|
+
tmuxPlaceCacheMs,
|
|
26028
26058
|
passDeadlineMs: Math.min(Math.max(namedPassDeadlineMs ?? MIN_PASS_DEADLINE_MS, heartbeatMs), MAX_INTERVAL_MS),
|
|
26029
26059
|
passDeadlineRaisedFrom: namedPassDeadlineMs !== undefined && namedPassDeadlineMs < heartbeatMs ? namedPassDeadlineMs : undefined
|
|
26030
26060
|
};
|
|
@@ -26365,6 +26395,7 @@ function createEnvoyClient(config) {
|
|
|
26365
26395
|
...input.delivery === undefined ? {} : { delivery: input.delivery },
|
|
26366
26396
|
...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
|
|
26367
26397
|
host: machineID(),
|
|
26398
|
+
...input.place === undefined ? {} : { tmux_place: input.place },
|
|
26368
26399
|
plugin: input.plugin.name,
|
|
26369
26400
|
plugin_version: input.plugin.version
|
|
26370
26401
|
}, { actingSession: input.sessionID }))),
|
|
@@ -26585,7 +26616,7 @@ async function runDispatchCli(argv, rawEnv, io) {
|
|
|
26585
26616
|
if (parsed.kind === "refused") {
|
|
26586
26617
|
return parsed.tool === undefined ? refuse([`dispatch: ${parsed.problems.join(`
|
|
26587
26618
|
`)}`, "Run dispatch --help."].join(`
|
|
26588
|
-
`), USAGE) : refuse(new ToolInputError(parsed.tool, parsed.problems).message,
|
|
26619
|
+
`), USAGE) : refuse(new ToolInputError(parsed.tool, parsed.problems).message, USAGE, parsed.tool);
|
|
26589
26620
|
}
|
|
26590
26621
|
const hostName = env.DISPATCH_HOST ?? (env.CLAUDE_CODE_CHILD_SESSION === "1" ? "claude" : undefined);
|
|
26591
26622
|
const host = HOSTS.find((name) => name === hostName);
|
|
@@ -26613,7 +26644,7 @@ async function runDispatchCli(argv, rawEnv, io) {
|
|
|
26613
26644
|
serverUrls: settings?.enabled === true ? dispatchServerUrls(settings) : []
|
|
26614
26645
|
});
|
|
26615
26646
|
if (problems.length > 0) {
|
|
26616
|
-
return refuse(new ToolInputError(parsed.tool, problems).message,
|
|
26647
|
+
return refuse(new ToolInputError(parsed.tool, problems).message, USAGE, parsed.tool);
|
|
26617
26648
|
}
|
|
26618
26649
|
print(JSON.stringify(parsed.args, null, 2));
|
|
26619
26650
|
return OK;
|
|
@@ -26750,7 +26781,7 @@ async function runDispatchCli(argv, rawEnv, io) {
|
|
|
26750
26781
|
notes.push(followNoticeText(followed, await subscriptions()));
|
|
26751
26782
|
}
|
|
26752
26783
|
entry = { tool, details: result.details };
|
|
26753
|
-
code = OK;
|
|
26784
|
+
code = result.refused === true ? REFUSED : OK;
|
|
26754
26785
|
} catch (error) {
|
|
26755
26786
|
text = messageFor(error);
|
|
26756
26787
|
if (error instanceof DispatchWriteLandedError) {
|
|
@@ -26758,7 +26789,7 @@ async function runDispatchCli(argv, rawEnv, io) {
|
|
|
26758
26789
|
code = OK;
|
|
26759
26790
|
} else {
|
|
26760
26791
|
entry = { tool, error: text };
|
|
26761
|
-
code = REFUSED;
|
|
26792
|
+
code = error instanceof ToolInputError ? USAGE : REFUSED;
|
|
26762
26793
|
}
|
|
26763
26794
|
}
|
|
26764
26795
|
try {
|
package/dist/envoy.js
CHANGED
|
@@ -29687,6 +29687,7 @@ function answerNotKept(status, replayed, body) {
|
|
|
29687
29687
|
var IDEMPOTENCY_KEY_TTL_MS = 24 * 60 * 60 * 1000;
|
|
29688
29688
|
var IDEMPOTENCY_LEASE_MS = 60 * 1000;
|
|
29689
29689
|
var DELIVERY_DUPLICATE_WINDOW_MS = 72 * 60 * 60 * 1000;
|
|
29690
|
+
var TMUX_LAYOUT_MAX = 2000;
|
|
29690
29691
|
var IssueDeployedEventPayloadSchema = strictObject({
|
|
29691
29692
|
repo: string2(),
|
|
29692
29693
|
number: number2().int().positive(),
|
|
@@ -29720,7 +29721,8 @@ var IssueEventPayloadSchema = object({
|
|
|
29720
29721
|
route: string2().nullish(),
|
|
29721
29722
|
changed: array(string2()).optional(),
|
|
29722
29723
|
ancestors: array(string2()).optional(),
|
|
29723
|
-
thread_logins: array(string2()).optional()
|
|
29724
|
+
thread_logins: array(string2()).optional(),
|
|
29725
|
+
forced: object({ past: array(string2()) }).optional()
|
|
29724
29726
|
});
|
|
29725
29727
|
var ArtifactCreatedEventPayloadSchema = object({
|
|
29726
29728
|
artifact: object({ id: string2().optional(), slug: string2().optional(), name: string2().optional() }).optional()
|
|
@@ -30626,12 +30628,12 @@ var dispatchToolSpecs = [
|
|
|
30626
30628
|
{
|
|
30627
30629
|
name: "dispatch_related",
|
|
30628
30630
|
example: { project: "CORE", title: "Retry failed webhook deliveries" },
|
|
30629
|
-
description: "Run the related-item check that dispatch issue, dispatch ask and a new decision block in " + "dispatch doc-edit run on their own write, and write nothing: it lists the three items of " + "one project most like a title and a text (at most one per issue or document, open ones " + "first), each ask with whether it is answered, and a past decision that already answers " + "the same question. Use it to check a draft before filing it. It searches by meaning and by " + "the text's rarest words, and says how it searched; when meaning search cannot run it " + "searches by keywords only and says why. When it could not search at all it says why and " + "names the dispatch search to run instead.
|
|
30631
|
+
description: "Run the related-item check that dispatch issue, dispatch ask and a new decision block in " + "dispatch doc-edit run on their own write, and write nothing: it lists the three items of " + "one project most like a title and a text (at most one per issue or document, open ones " + "first), each ask with whether it is answered, and a past decision that already answers " + "the same question. Use it to check a draft before filing it. It searches by meaning and by " + "the text's rarest words, and says how it searched; when meaning search cannot run it " + "searches by keywords only and says why. When it could not search at all it says why and " + "names the dispatch search to run instead. exclude_issues leaves each named issue's own " + "items out of the results, at most 50 of them, so a draft under a parent can leave out " + "that parent and its children without changing how rare the text's words are; " + "keywords_only skips meaning search.",
|
|
30630
30632
|
arguments: (z) => ({
|
|
30631
30633
|
project: z.string().describe("Project key to search within, such as CORE."),
|
|
30632
30634
|
title: z.string({ max: ISSUE_TITLE_MAX }).describe("Optional title to check, as an issue title; at most 1,000 characters.").optional(),
|
|
30633
30635
|
text: z.string().describe("Optional text to check, such as a draft spec or a question.").optional(),
|
|
30634
|
-
|
|
30636
|
+
exclude_issues: z.array(z.string()).describe("Optional issue keys in the project whose own items are left out of the results; at most 50.").optional(),
|
|
30635
30637
|
keywords_only: z.boolean().describe("Search by keywords only, skipping meaning search.").optional()
|
|
30636
30638
|
}),
|
|
30637
30639
|
validation: {
|
|
@@ -37808,6 +37810,7 @@ function fileBearer(bearer, url, section, env, commands = "run") {
|
|
|
37808
37810
|
var DEFAULT_ENVOY_URL = "http://127.0.0.1:9020";
|
|
37809
37811
|
var DEFAULT_HEARTBEAT_MS = SESSION_HEARTBEAT_MS;
|
|
37810
37812
|
var MIN_PASS_DEADLINE_MS = 30000;
|
|
37813
|
+
var DEFAULT_TMUX_PLACE_CACHE_MS = 30000;
|
|
37811
37814
|
var MIN_INTERVAL_MS = 25;
|
|
37812
37815
|
var MAX_INTERVAL_MS = 2147483647;
|
|
37813
37816
|
var REGISTRATION_SETTLE_MS = 5000;
|
|
@@ -37821,6 +37824,10 @@ function namedInterval(raw) {
|
|
|
37821
37824
|
const parsed = Number(raw);
|
|
37822
37825
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
37823
37826
|
}
|
|
37827
|
+
function resolvedInterval(raw, fallback) {
|
|
37828
|
+
const named = namedInterval(raw);
|
|
37829
|
+
return named === undefined ? fallback : Math.min(Math.max(named, MIN_INTERVAL_MS), MAX_INTERVAL_MS);
|
|
37830
|
+
}
|
|
37824
37831
|
function natsSeedFromEnvironment(env) {
|
|
37825
37832
|
const { NATS_NKEY_SEED_FILE: file, NATS_NKEY_SEED: plain } = env;
|
|
37826
37833
|
if (file !== undefined) {
|
|
@@ -37911,8 +37918,8 @@ function envoySettings(env, config, options = {}) {
|
|
|
37911
37918
|
inbound = { off: messageFor(error) };
|
|
37912
37919
|
}
|
|
37913
37920
|
}
|
|
37914
|
-
const
|
|
37915
|
-
const
|
|
37921
|
+
const heartbeatMs = resolvedInterval(env.ENVOY_HEARTBEAT_MS, DEFAULT_HEARTBEAT_MS);
|
|
37922
|
+
const tmuxPlaceCacheMs = resolvedInterval(env.ENVOY_TMUX_PLACE_CACHE_MS, DEFAULT_TMUX_PLACE_CACHE_MS);
|
|
37916
37923
|
const namedPassDeadlineMs = namedInterval(env.ENVOY_PASS_DEADLINE_MS);
|
|
37917
37924
|
return {
|
|
37918
37925
|
enabled: true,
|
|
@@ -37920,6 +37927,7 @@ function envoySettings(env, config, options = {}) {
|
|
|
37920
37927
|
credential,
|
|
37921
37928
|
inbound,
|
|
37922
37929
|
heartbeatMs,
|
|
37930
|
+
tmuxPlaceCacheMs,
|
|
37923
37931
|
passDeadlineMs: Math.min(Math.max(namedPassDeadlineMs ?? MIN_PASS_DEADLINE_MS, heartbeatMs), MAX_INTERVAL_MS),
|
|
37924
37932
|
passDeadlineRaisedFrom: namedPassDeadlineMs !== undefined && namedPassDeadlineMs < heartbeatMs ? namedPassDeadlineMs : undefined
|
|
37925
37933
|
};
|
|
@@ -38246,6 +38254,7 @@ function createEnvoyClient(config) {
|
|
|
38246
38254
|
...input.delivery === undefined ? {} : { delivery: input.delivery },
|
|
38247
38255
|
...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
|
|
38248
38256
|
host: machineID(),
|
|
38257
|
+
...input.place === undefined ? {} : { tmux_place: input.place },
|
|
38249
38258
|
plugin: input.plugin.name,
|
|
38250
38259
|
plugin_version: input.plugin.version
|
|
38251
38260
|
}, { actingSession: input.sessionID }))),
|
|
@@ -39783,6 +39792,88 @@ function activeDispatchSettings(resolution) {
|
|
|
39783
39792
|
return null;
|
|
39784
39793
|
}
|
|
39785
39794
|
|
|
39795
|
+
// ../envoy-client/src/dispatch-cwd.ts
|
|
39796
|
+
import { execFile } from "child_process";
|
|
39797
|
+
import { promisify } from "util";
|
|
39798
|
+
var execFileAsync = promisify(execFile);
|
|
39799
|
+
var defaultExec = (file, args, { cwd, signal }) => {
|
|
39800
|
+
const call = execFileAsync(file, args, { cwd, signal });
|
|
39801
|
+
const kill = () => call.child.kill("SIGKILL");
|
|
39802
|
+
if (signal.aborted)
|
|
39803
|
+
kill();
|
|
39804
|
+
else
|
|
39805
|
+
signal.addEventListener("abort", kill, { once: true });
|
|
39806
|
+
return call;
|
|
39807
|
+
};
|
|
39808
|
+
var REMOTE_LOOKUP_MS = 5000;
|
|
39809
|
+
var TMUX_PANE_LOOKUP_MS = 1000;
|
|
39810
|
+
async function tryExec(exec, file, args, cwd, limitMs) {
|
|
39811
|
+
const controller = new AbortController;
|
|
39812
|
+
const expired = Promise.withResolvers();
|
|
39813
|
+
const timer = setTimeout(() => {
|
|
39814
|
+
controller.abort();
|
|
39815
|
+
expired.resolve(null);
|
|
39816
|
+
}, limitMs);
|
|
39817
|
+
try {
|
|
39818
|
+
const answer = await Promise.race([
|
|
39819
|
+
exec(file, args, { cwd, signal: controller.signal }),
|
|
39820
|
+
expired.promise
|
|
39821
|
+
]);
|
|
39822
|
+
if (answer === null) {
|
|
39823
|
+
return { failure: "timedOut", ok: false };
|
|
39824
|
+
}
|
|
39825
|
+
return { ok: true, stdout: answer.stdout };
|
|
39826
|
+
} catch {
|
|
39827
|
+
return { failure: "refused", ok: false };
|
|
39828
|
+
} finally {
|
|
39829
|
+
clearTimeout(timer);
|
|
39830
|
+
}
|
|
39831
|
+
}
|
|
39832
|
+
function parseRemoteList(stdout) {
|
|
39833
|
+
const remotes = new Map;
|
|
39834
|
+
for (const line of stdout.split(`
|
|
39835
|
+
`)) {
|
|
39836
|
+
const trimmed = line.trim();
|
|
39837
|
+
if (!trimmed)
|
|
39838
|
+
continue;
|
|
39839
|
+
const match = trimmed.match(/^(\S+)\s+(\S+)/);
|
|
39840
|
+
const [, name, url] = match ?? [];
|
|
39841
|
+
if (name && url)
|
|
39842
|
+
remotes.set(name, url);
|
|
39843
|
+
}
|
|
39844
|
+
return remotes;
|
|
39845
|
+
}
|
|
39846
|
+
function selectRemoteUrl(remotes) {
|
|
39847
|
+
const origin = remotes.get("origin");
|
|
39848
|
+
if (origin)
|
|
39849
|
+
return origin;
|
|
39850
|
+
const candidates = [...remotes.entries()].filter(([name]) => name !== "upstream");
|
|
39851
|
+
return candidates.length === 1 ? candidates[0]?.[1] ?? null : null;
|
|
39852
|
+
}
|
|
39853
|
+
var GITHUB_REMOTE_PATTERNS = [
|
|
39854
|
+
/^https:\/\/(?:[^@/\s]+@)?github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
|
|
39855
|
+
/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
|
|
39856
|
+
/^ssh:\/\/git@github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i
|
|
39857
|
+
];
|
|
39858
|
+
function parseGitHubRemoteUrl(url) {
|
|
39859
|
+
const trimmed = url.trim();
|
|
39860
|
+
for (const pattern of GITHUB_REMOTE_PATTERNS) {
|
|
39861
|
+
const match = trimmed.match(pattern);
|
|
39862
|
+
if (match)
|
|
39863
|
+
return canonicalRepo(match[1] ?? "", match[2] ?? "");
|
|
39864
|
+
}
|
|
39865
|
+
return null;
|
|
39866
|
+
}
|
|
39867
|
+
async function resolveCwdRepo(cwd, exec) {
|
|
39868
|
+
const remoteList = await tryExec(exec, "jj", ["git", "remote", "list"], cwd, REMOTE_LOOKUP_MS);
|
|
39869
|
+
if (remoteList.ok) {
|
|
39870
|
+
const url = selectRemoteUrl(parseRemoteList(remoteList.stdout));
|
|
39871
|
+
return url ? parseGitHubRemoteUrl(url) : null;
|
|
39872
|
+
}
|
|
39873
|
+
const originRemote = await tryExec(exec, "git", ["remote", "get-url", "origin"], cwd, REMOTE_LOOKUP_MS);
|
|
39874
|
+
return originRemote.ok ? parseGitHubRemoteUrl(originRemote.stdout) : null;
|
|
39875
|
+
}
|
|
39876
|
+
|
|
39786
39877
|
// ../envoy-client/src/dispatch-first.ts
|
|
39787
39878
|
import { readFileSync as readFileSync4 } from "fs";
|
|
39788
39879
|
import { join as join3 } from "path";
|
|
@@ -39993,84 +40084,6 @@ import {
|
|
|
39993
40084
|
} from "fs";
|
|
39994
40085
|
import { join as join6 } from "path";
|
|
39995
40086
|
|
|
39996
|
-
// ../envoy-client/src/dispatch-cwd.ts
|
|
39997
|
-
import { execFile } from "child_process";
|
|
39998
|
-
import { promisify } from "util";
|
|
39999
|
-
var execFileAsync = promisify(execFile);
|
|
40000
|
-
var defaultExec = (file, args, { cwd, signal }) => {
|
|
40001
|
-
const call = execFileAsync(file, args, { cwd, signal });
|
|
40002
|
-
const kill = () => call.child.kill("SIGKILL");
|
|
40003
|
-
if (signal.aborted)
|
|
40004
|
-
kill();
|
|
40005
|
-
else
|
|
40006
|
-
signal.addEventListener("abort", kill, { once: true });
|
|
40007
|
-
return call;
|
|
40008
|
-
};
|
|
40009
|
-
var REMOTE_LOOKUP_MS = 5000;
|
|
40010
|
-
async function tryExec(exec, file, args, cwd, limitMs) {
|
|
40011
|
-
const controller = new AbortController;
|
|
40012
|
-
const expired = Promise.withResolvers();
|
|
40013
|
-
const timer = setTimeout(() => {
|
|
40014
|
-
controller.abort();
|
|
40015
|
-
expired.resolve(null);
|
|
40016
|
-
}, limitMs);
|
|
40017
|
-
try {
|
|
40018
|
-
const answer = await Promise.race([
|
|
40019
|
-
exec(file, args, { cwd, signal: controller.signal }),
|
|
40020
|
-
expired.promise
|
|
40021
|
-
]);
|
|
40022
|
-
return answer?.stdout ?? null;
|
|
40023
|
-
} catch {
|
|
40024
|
-
return null;
|
|
40025
|
-
} finally {
|
|
40026
|
-
clearTimeout(timer);
|
|
40027
|
-
}
|
|
40028
|
-
}
|
|
40029
|
-
function parseRemoteList(stdout) {
|
|
40030
|
-
const remotes = new Map;
|
|
40031
|
-
for (const line of stdout.split(`
|
|
40032
|
-
`)) {
|
|
40033
|
-
const trimmed = line.trim();
|
|
40034
|
-
if (!trimmed)
|
|
40035
|
-
continue;
|
|
40036
|
-
const match = trimmed.match(/^(\S+)\s+(\S+)/);
|
|
40037
|
-
const [, name, url] = match ?? [];
|
|
40038
|
-
if (name && url)
|
|
40039
|
-
remotes.set(name, url);
|
|
40040
|
-
}
|
|
40041
|
-
return remotes;
|
|
40042
|
-
}
|
|
40043
|
-
function selectRemoteUrl(remotes) {
|
|
40044
|
-
const origin = remotes.get("origin");
|
|
40045
|
-
if (origin)
|
|
40046
|
-
return origin;
|
|
40047
|
-
const candidates = [...remotes.entries()].filter(([name]) => name !== "upstream");
|
|
40048
|
-
return candidates.length === 1 ? candidates[0]?.[1] ?? null : null;
|
|
40049
|
-
}
|
|
40050
|
-
var GITHUB_REMOTE_PATTERNS = [
|
|
40051
|
-
/^https:\/\/(?:[^@/\s]+@)?github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
|
|
40052
|
-
/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?\/?$/i,
|
|
40053
|
-
/^ssh:\/\/git@github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/i
|
|
40054
|
-
];
|
|
40055
|
-
function parseGitHubRemoteUrl(url) {
|
|
40056
|
-
const trimmed = url.trim();
|
|
40057
|
-
for (const pattern of GITHUB_REMOTE_PATTERNS) {
|
|
40058
|
-
const match = trimmed.match(pattern);
|
|
40059
|
-
if (match)
|
|
40060
|
-
return canonicalRepo(match[1] ?? "", match[2] ?? "");
|
|
40061
|
-
}
|
|
40062
|
-
return null;
|
|
40063
|
-
}
|
|
40064
|
-
async function resolveCwdRepo(cwd, exec) {
|
|
40065
|
-
const jjOutput = await tryExec(exec, "jj", ["git", "remote", "list"], cwd, REMOTE_LOOKUP_MS);
|
|
40066
|
-
if (jjOutput !== null) {
|
|
40067
|
-
const url = selectRemoteUrl(parseRemoteList(jjOutput));
|
|
40068
|
-
return url ? parseGitHubRemoteUrl(url) : null;
|
|
40069
|
-
}
|
|
40070
|
-
const originUrl = await tryExec(exec, "git", ["remote", "get-url", "origin"], cwd, REMOTE_LOOKUP_MS);
|
|
40071
|
-
return originUrl ? parseGitHubRemoteUrl(originUrl) : null;
|
|
40072
|
-
}
|
|
40073
|
-
|
|
40074
40087
|
// ../envoy-client/src/session-answers.ts
|
|
40075
40088
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5 } from "fs";
|
|
40076
40089
|
import { join as join5 } from "path";
|
|
@@ -41464,6 +41477,183 @@ function allowedAPIURL(value) {
|
|
|
41464
41477
|
return url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname);
|
|
41465
41478
|
}
|
|
41466
41479
|
|
|
41480
|
+
// ../envoy-client/src/process-ancestry.ts
|
|
41481
|
+
import { execFileSync } from "child_process";
|
|
41482
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
41483
|
+
var MAX_ANCESTORS = 64;
|
|
41484
|
+
var PARENT_LOOKUP_MS = 1000;
|
|
41485
|
+
function procParentPid(pid) {
|
|
41486
|
+
try {
|
|
41487
|
+
const stat = readFileSync7(`/proc/${pid}/stat`, "utf8");
|
|
41488
|
+
const parent = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
41489
|
+
return Number.isInteger(parent) ? parent : undefined;
|
|
41490
|
+
} catch {
|
|
41491
|
+
return;
|
|
41492
|
+
}
|
|
41493
|
+
}
|
|
41494
|
+
function processTable() {
|
|
41495
|
+
const table = new Map;
|
|
41496
|
+
try {
|
|
41497
|
+
const listing = execFileSync("ps", ["-Ao", "pid=,ppid="], {
|
|
41498
|
+
encoding: "utf8",
|
|
41499
|
+
killSignal: "SIGKILL",
|
|
41500
|
+
timeout: PARENT_LOOKUP_MS
|
|
41501
|
+
});
|
|
41502
|
+
for (const line of listing.split(`
|
|
41503
|
+
`)) {
|
|
41504
|
+
const [, pid = "", parent = ""] = line.match(/^\s*(\d+)\s+(\d+)\s*$/) ?? [];
|
|
41505
|
+
if (pid !== "")
|
|
41506
|
+
table.set(Number(pid), Number(parent));
|
|
41507
|
+
}
|
|
41508
|
+
} catch {}
|
|
41509
|
+
return table;
|
|
41510
|
+
}
|
|
41511
|
+
function isAncestor(candidate, pid = process.pid) {
|
|
41512
|
+
let table;
|
|
41513
|
+
const parentPid = (child) => {
|
|
41514
|
+
if (process.platform === "linux")
|
|
41515
|
+
return procParentPid(child);
|
|
41516
|
+
table ??= processTable();
|
|
41517
|
+
return table.get(child);
|
|
41518
|
+
};
|
|
41519
|
+
let current = pid;
|
|
41520
|
+
for (let step = 0;current !== undefined && current > 1 && step < MAX_ANCESTORS; step++) {
|
|
41521
|
+
if (String(current) === candidate)
|
|
41522
|
+
return true;
|
|
41523
|
+
current = parentPid(current);
|
|
41524
|
+
}
|
|
41525
|
+
return false;
|
|
41526
|
+
}
|
|
41527
|
+
|
|
41528
|
+
// ../envoy-client/src/tmux-server.ts
|
|
41529
|
+
function tmuxServer(value) {
|
|
41530
|
+
const parts = (value ?? "").split(",");
|
|
41531
|
+
return { serverPid: parts.at(-2) ?? "", socket: parts.slice(0, -2).join(",") };
|
|
41532
|
+
}
|
|
41533
|
+
|
|
41534
|
+
// ../envoy-client/src/tmux-place.ts
|
|
41535
|
+
var PLACE_FORMAT = [
|
|
41536
|
+
"#{session_name}",
|
|
41537
|
+
"#{window_id}",
|
|
41538
|
+
"#{window_index}",
|
|
41539
|
+
"#{window_name}",
|
|
41540
|
+
"#{pane_id}",
|
|
41541
|
+
"#{pane_index}",
|
|
41542
|
+
"#{pid}",
|
|
41543
|
+
"#{pane_pid}",
|
|
41544
|
+
"#{window_layout}",
|
|
41545
|
+
"#{window_zoomed_flag}"
|
|
41546
|
+
].join("\t");
|
|
41547
|
+
var PLACE_FIELDS = 10;
|
|
41548
|
+
function tmuxIndex(value) {
|
|
41549
|
+
return /^\d+$/.test(value) ? Number(value) : undefined;
|
|
41550
|
+
}
|
|
41551
|
+
async function readTmuxPlace(env, exec) {
|
|
41552
|
+
const { serverPid, socket } = tmuxServer(env.TMUX);
|
|
41553
|
+
const pane = env.TMUX_PANE?.trim() ?? "";
|
|
41554
|
+
if (socket === "" || serverPid === "" || pane === "")
|
|
41555
|
+
return { kind: "refused" };
|
|
41556
|
+
const answer = await tryExec(exec, "tmux", ["-u", "-S", socket, "display-message", "-p", "-t", pane, PLACE_FORMAT], "/", TMUX_PANE_LOOKUP_MS);
|
|
41557
|
+
if (!answer.ok)
|
|
41558
|
+
return answer.failure === "timedOut" ? { kind: "timedOut" } : { kind: "refused" };
|
|
41559
|
+
const fields = answer.stdout.replace(/\r?\n$/, "").split("\t");
|
|
41560
|
+
if (fields.length !== PLACE_FIELDS)
|
|
41561
|
+
return { kind: "refused" };
|
|
41562
|
+
const [
|
|
41563
|
+
sessionName = "",
|
|
41564
|
+
windowId = "",
|
|
41565
|
+
windowIndex = "",
|
|
41566
|
+
windowName = "",
|
|
41567
|
+
paneId = "",
|
|
41568
|
+
paneIndex = "",
|
|
41569
|
+
pid = "",
|
|
41570
|
+
panePid = "",
|
|
41571
|
+
layout = "",
|
|
41572
|
+
zoomedFlag = ""
|
|
41573
|
+
] = fields;
|
|
41574
|
+
if (pid !== serverPid || paneId === "" || !isAncestor(panePid))
|
|
41575
|
+
return { kind: "refused" };
|
|
41576
|
+
const window2 = tmuxIndex(windowIndex);
|
|
41577
|
+
const index = tmuxIndex(paneIndex);
|
|
41578
|
+
if (window2 === undefined || index === undefined)
|
|
41579
|
+
return { kind: "refused" };
|
|
41580
|
+
return {
|
|
41581
|
+
kind: "place",
|
|
41582
|
+
place: {
|
|
41583
|
+
socket,
|
|
41584
|
+
server_pid: serverPid,
|
|
41585
|
+
session_name: sessionName,
|
|
41586
|
+
window_id: windowId,
|
|
41587
|
+
window_index: window2,
|
|
41588
|
+
window_name: windowName,
|
|
41589
|
+
pane_id: paneId,
|
|
41590
|
+
pane_index: index,
|
|
41591
|
+
...layout.length > TMUX_LAYOUT_MAX ? {} : { layout },
|
|
41592
|
+
zoomed: zoomedFlag === "1"
|
|
41593
|
+
}
|
|
41594
|
+
};
|
|
41595
|
+
}
|
|
41596
|
+
|
|
41597
|
+
// ../envoy-client/src/tmux-place-cache.ts
|
|
41598
|
+
function createTmuxPlaceCache(options) {
|
|
41599
|
+
const now = options.now ?? Date.now;
|
|
41600
|
+
const repeat = options.every ?? every2;
|
|
41601
|
+
let held;
|
|
41602
|
+
let readAt;
|
|
41603
|
+
let reading = false;
|
|
41604
|
+
let shuttingDown = false;
|
|
41605
|
+
let stopRefreshing;
|
|
41606
|
+
const startReading = () => {
|
|
41607
|
+
if (reading || shuttingDown)
|
|
41608
|
+
return;
|
|
41609
|
+
reading = true;
|
|
41610
|
+
(async () => {
|
|
41611
|
+
try {
|
|
41612
|
+
const answer = await options.read();
|
|
41613
|
+
if (shuttingDown)
|
|
41614
|
+
return;
|
|
41615
|
+
if (answer.kind === "place")
|
|
41616
|
+
held = answer.place;
|
|
41617
|
+
else if (answer.kind === "refused")
|
|
41618
|
+
held = undefined;
|
|
41619
|
+
readAt = now();
|
|
41620
|
+
} catch (error) {
|
|
41621
|
+
if (shuttingDown)
|
|
41622
|
+
return;
|
|
41623
|
+
options.onFailure?.(error);
|
|
41624
|
+
readAt = now();
|
|
41625
|
+
} finally {
|
|
41626
|
+
reading = false;
|
|
41627
|
+
}
|
|
41628
|
+
})().catch(() => {
|
|
41629
|
+
return;
|
|
41630
|
+
});
|
|
41631
|
+
};
|
|
41632
|
+
const keepFresh = () => {
|
|
41633
|
+
if (stopRefreshing !== undefined || shuttingDown)
|
|
41634
|
+
return;
|
|
41635
|
+
stopRefreshing = repeat(options.lifetimeMs(), startReading);
|
|
41636
|
+
};
|
|
41637
|
+
return {
|
|
41638
|
+
place: () => {
|
|
41639
|
+
keepFresh();
|
|
41640
|
+
if (readAt === undefined || now() - readAt >= options.lifetimeMs())
|
|
41641
|
+
startReading();
|
|
41642
|
+
return held;
|
|
41643
|
+
},
|
|
41644
|
+
shutDown: () => {
|
|
41645
|
+
shuttingDown = true;
|
|
41646
|
+
stopRefreshing?.();
|
|
41647
|
+
stopRefreshing = undefined;
|
|
41648
|
+
}
|
|
41649
|
+
};
|
|
41650
|
+
}
|
|
41651
|
+
function every2(ms, callback) {
|
|
41652
|
+
const timer = setInterval(callback, ms);
|
|
41653
|
+
timer.unref?.();
|
|
41654
|
+
return () => clearInterval(timer);
|
|
41655
|
+
}
|
|
41656
|
+
|
|
41467
41657
|
// ../envoy-client/src/tool-contract.ts
|
|
41468
41658
|
var SESSION_STATE_GUIDE = "A session is live, unresponsive or gone, by how long ago it last registered: live within 5 " + "minutes, unresponsive after that and within an hour, gone past the hour or with no record at " + `all. ${UNRESPONSIVE_RULE} A session named with no state is live.`;
|
|
41469
41659
|
var DELIVERY_CONTRACT = "Delivery is at-least-once, possibly out of order across topics; use id for dedupe and at for freshness.";
|
|
@@ -41934,7 +42124,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
41934
42124
|
|
|
41935
42125
|
// package.json
|
|
41936
42126
|
var name = "@sjawhar/pi-envoy";
|
|
41937
|
-
var version2 = "16.
|
|
42127
|
+
var version2 = "16.25.0";
|
|
41938
42128
|
var package_default = {
|
|
41939
42129
|
name,
|
|
41940
42130
|
version: version2,
|
|
@@ -48982,7 +49172,12 @@ ${REPLAYED_BTW_NOTE}`, frame.envelope, "inert");
|
|
|
48982
49172
|
}
|
|
48983
49173
|
await registrationState.deregister(id);
|
|
48984
49174
|
};
|
|
48985
|
-
const
|
|
49175
|
+
const tmuxPlaces = createTmuxPlaceCache({
|
|
49176
|
+
read: () => readTmuxPlace(process.env, defaultExec),
|
|
49177
|
+
lifetimeMs: () => active?.settings.tmuxPlaceCacheMs ?? DEFAULT_TMUX_PLACE_CACHE_MS,
|
|
49178
|
+
onFailure: (error) => logger3.debug("envoy: the tmux place reading failed", { error: messageFor(error) })
|
|
49179
|
+
});
|
|
49180
|
+
const registrationInput = (asking, place) => {
|
|
48986
49181
|
const own = agentSubject(sessionID);
|
|
48987
49182
|
const topics = [
|
|
48988
49183
|
...new Set([
|
|
@@ -49002,17 +49197,18 @@ ${REPLAYED_BTW_NOTE}`, frame.envelope, "inert");
|
|
|
49002
49197
|
driving: false,
|
|
49003
49198
|
selfSubscribed: true,
|
|
49004
49199
|
plugin: { name, version: version2 },
|
|
49005
|
-
...asking === undefined ? {} : { delivery: asking.delivery.registration() }
|
|
49200
|
+
...asking === undefined ? {} : { delivery: asking.delivery.registration() },
|
|
49201
|
+
...place === undefined ? {} : { place }
|
|
49006
49202
|
};
|
|
49007
49203
|
};
|
|
49008
|
-
const sendRegistration = (send) => {
|
|
49204
|
+
const sendRegistration = async (send) => {
|
|
49205
|
+
const place = tmuxPlaces.place();
|
|
49009
49206
|
const registeringFor = sessionID;
|
|
49010
49207
|
const asking = relay?.sessionID === registeringFor && relay.subscription !== undefined && replay?.startPending() !== true ? relay : undefined;
|
|
49011
|
-
const input = registrationInput(asking);
|
|
49012
|
-
|
|
49013
|
-
|
|
49014
|
-
|
|
49015
|
-
});
|
|
49208
|
+
const input = registrationInput(asking, place);
|
|
49209
|
+
const result = await send(input);
|
|
49210
|
+
takeDeliveryAnswer(registeringFor, input.topics, asking, result);
|
|
49211
|
+
return result;
|
|
49016
49212
|
};
|
|
49017
49213
|
const registerSession = () => trackRegistration(sessionID, sendRegistration(registrationState.refreshRegistration));
|
|
49018
49214
|
const ensureHeartbeat = (context) => {
|
|
@@ -49482,6 +49678,7 @@ ${REPLAYED_BTW_NOTE}`, frame.envelope, "inert");
|
|
|
49482
49678
|
pi.on("session_before_branch", async (_event, context) => announce(undefined, context));
|
|
49483
49679
|
pi.on("session_shutdown", async (_event, context) => {
|
|
49484
49680
|
shuttingDown = true;
|
|
49681
|
+
tmuxPlaces.shutDown();
|
|
49485
49682
|
cardWake.cancel();
|
|
49486
49683
|
if (publishedInterface !== undefined) {
|
|
49487
49684
|
const bound = publishedInterface.roleClaim.instances.indexOf(claimInstance);
|
|
@@ -9,7 +9,7 @@ Dispatch is a record for the people who decide, never a log of your work.
|
|
|
9
9
|
|
|
10
10
|
- Use the `dispatch` command; the HTTP API only for what no command does. `dispatch <command> --help` gives its rules and an example.
|
|
11
11
|
- Put long text on stdin: `--<field>-file -` with a quoted here-document (`<<'EOF'`); give object and list fields as JSON.
|
|
12
|
-
- Exit 1 is a refusal, 2 a usage error. A refusal lists
|
|
12
|
+
- Exit 1 is a refusal, 2 a usage error. A refusal lists every problem: fix all, call once.
|
|
13
13
|
- A Dispatch command hard to use, or storing or losing something wrongly, is a defect to report, not work around: open an issue in the owning project's code and tell that project's controller; a Legion role tells its architect (`skill://legion-worker/references/findings.md`).
|
|
14
14
|
|
|
15
15
|
## Asks and ask blocks
|
|
@@ -35,7 +35,7 @@ The question and the recommendation, as `skill://dispatch-writing-specs` writes
|
|
|
35
35
|
|
|
36
36
|
## Choosing what to work on
|
|
37
37
|
|
|
38
|
-
-
|
|
38
|
+
- Finishing an issue, take the top `todo` one by priority then board rank, per project.
|
|
39
39
|
- `todo` means specced and waiting on nothing; one that waits goes in `backlog`, saying on what.
|
|
40
40
|
- Hold at most three issues in flight; move the rest to `backlog`, saying where each is.
|
|
41
41
|
- Never reorder the board: one agent keeps each project's order (`issue-update --before`/`--after`). If the top looks wrong, tell `notifications.role.legion-<project>-controller`.
|
|
@@ -5,19 +5,17 @@ description: "Use when a session has the dispatch command, before you plan, file
|
|
|
5
5
|
|
|
6
6
|
# Dispatch first
|
|
7
7
|
|
|
8
|
-
Dispatch holds the open issues, their specs and people's answers.
|
|
9
|
-
|
|
10
8
|
## Search before you act
|
|
11
9
|
|
|
12
10
|
- Before you plan, file an issue, ask, post a finding or start work, run `dispatch search`.
|
|
13
|
-
- Each query word must match. Use two or three
|
|
11
|
+
- Each query word must match. Use two or three: the thing and what is wrong. Never paste a draft.
|
|
14
12
|
|
|
15
13
|
```bash
|
|
16
14
|
dispatch search --query 'broadcast send order'
|
|
17
15
|
dispatch search --query 'reviewer threads OR review comments'
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
- No hits: remove a word before
|
|
18
|
+
- No hits: remove a word before adding one. Try two or three wordings before deciding nothing exists.
|
|
21
19
|
- Open each hit that can be yours with `dispatch read --issue KEY`, then its parent (`child_of` under `Links:`, or a document's `Issue:`), with its status and recent events.
|
|
22
20
|
|
|
23
21
|
## What to do with what you find
|
|
@@ -26,7 +24,7 @@ dispatch search --query 'reviewer threads OR review comments'
|
|
|
26
24
|
|
|
27
25
|
- **Work already tracked:** put the finding on that issue. File a new issue only when no hit covers the work, and cite the nearest one you ruled out (`dispatch://KEY`).
|
|
28
26
|
- **Question already decided:** the answered ask is the record. Cite it (`dispatch://KEY/ask/<id>`). Do not ask again.
|
|
29
|
-
- **Duplicate found:**
|
|
27
|
+
- **Duplicate found, or a likely duplicate a create names:** read it; fold only when it is the same work. Keep the issue with the spec, copy to it what only the duplicate has, and close the duplicate (`--status done --reason 'Duplicate of dispatch://KEY.'`). When it has the `legion` label or another holder's claim, comment the kept issue's name on it instead.
|
|
30
28
|
|
|
31
29
|
## Research before you ask
|
|
32
30
|
|
|
@@ -36,8 +34,6 @@ dispatch search --query 'reviewer threads OR review comments'
|
|
|
36
34
|
|
|
37
35
|
## Reach a person only through Dispatch
|
|
38
36
|
|
|
39
|
-
Reach a person through an ask, an ask block or an approval request.
|
|
40
|
-
|
|
41
37
|
- The moment a person blocks your work, open an ask: an ask block for a design question its document records, else `dispatch ask`. A blocker that is not an open ask does not exist for them. A Legion phase worker sends decisions to its architect instead. Before you say you wait on a person, run `dispatch open-asks`.
|
|
42
38
|
- A result a person asked for is the same: a document or artifact notifies nobody. End that document with an ask block asking their next step, else `dispatch ask`.
|
|
43
39
|
- Record every request you accept in Dispatch before you start it: an issue, or a line in your issue's `open-items.md` artifact. Before you end a turn, read that record. Each item is done, in progress, or an open ask. Never drop one.
|
|
@@ -28,7 +28,7 @@ Part | Content
|
|
|
28
28
|
`Design` | How it meets them; a value and its reason for each limit, size and time
|
|
29
29
|
`Decisions` | One line: `The decisions are in dispatch://KEY/artifact/decisions-md.`
|
|
30
30
|
|
|
31
|
-
`serves` and `needs` name a block of this issue or an ancestor. Another agent can build and check the work from these alone. A small change gets a few sentences per part, no matrix; split a large design into
|
|
31
|
+
`serves` and `needs` name a block of this issue or an ancestor. Another agent can build and check the work from these alone. A small change gets a few sentences per part, no matrix; split a large design into children.
|
|
32
32
|
|
|
33
33
|
## Rules for the text
|
|
34
34
|
|