@f5-sales-demo/xcsh 21.11.6 → 21.11.7
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.11.
|
|
4
|
+
"version": "21.11.7",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
64
|
-
"@f5-sales-demo/pi-agent-core": "21.11.
|
|
65
|
-
"@f5-sales-demo/pi-ai": "21.11.
|
|
66
|
-
"@f5-sales-demo/pi-natives": "21.11.
|
|
67
|
-
"@f5-sales-demo/pi-resource-management": "21.11.
|
|
68
|
-
"@f5-sales-demo/pi-tui": "21.11.
|
|
69
|
-
"@f5-sales-demo/pi-utils": "21.11.
|
|
70
|
-
"@f5-sales-demo/xcsh-stats": "21.11.
|
|
64
|
+
"@f5-sales-demo/pi-agent-core": "21.11.7",
|
|
65
|
+
"@f5-sales-demo/pi-ai": "21.11.7",
|
|
66
|
+
"@f5-sales-demo/pi-natives": "21.11.7",
|
|
67
|
+
"@f5-sales-demo/pi-resource-management": "21.11.7",
|
|
68
|
+
"@f5-sales-demo/pi-tui": "21.11.7",
|
|
69
|
+
"@f5-sales-demo/pi-utils": "21.11.7",
|
|
70
|
+
"@f5-sales-demo/xcsh-stats": "21.11.7",
|
|
71
71
|
"@mozilla/readability": "^0.6",
|
|
72
72
|
"@sinclair/typebox": "^0.34",
|
|
73
73
|
"@xterm/headless": "^6.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { connect } from "node:net";
|
|
2
1
|
import * as path from "node:path";
|
|
3
|
-
import type { ExtensionAPI, ExtensionContext } from "@f5-sales-demo/xcsh";
|
|
2
|
+
import type { ExtensionAPI, ExtensionContext, UserPromptKind } from "@f5-sales-demo/xcsh";
|
|
3
|
+
import { HerdrClient } from "../../../herdr/client";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* herdr integration (bundled, default-on).
|
|
@@ -10,11 +10,14 @@ import type { ExtensionAPI, ExtensionContext } from "@f5-sales-demo/xcsh";
|
|
|
10
10
|
* blocked indicator.
|
|
11
11
|
*
|
|
12
12
|
* Transport: herdr injects `HERDR_SOCKET_PATH` into every pane, so state is
|
|
13
|
-
* reported
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* reported over herdr's protocol-18 JSONL socket via the shared `HerdrClient`
|
|
14
|
+
* (see `../../../herdr/client`) — the same client `herdr-terminal` uses. Each
|
|
15
|
+
* request reconnects independently, validates the `ping` protocol version
|
|
16
|
+
* before the first real request, and awaits herdr's typed response before
|
|
17
|
+
* resolving. This is PATH-independent — unlike shelling out to the `herdr`
|
|
18
|
+
* CLI, which silently no-ops when herdr runs as a launchd/`brew services`
|
|
19
|
+
* server and spawns panes without `/opt/homebrew/bin` on PATH. If
|
|
20
|
+
* `HERDR_SOCKET_PATH` is somehow unset, we fall back to the `herdr` CLI.
|
|
18
21
|
*
|
|
19
22
|
* xcsh is a fork of pi; a user may have both installed, so this reporter always
|
|
20
23
|
* identifies the agent as "xcsh" (never "pi"). It claims pane authority via the
|
|
@@ -39,8 +42,8 @@ import type { ExtensionAPI, ExtensionContext } from "@f5-sales-demo/xcsh";
|
|
|
39
42
|
* 1. `seq` is seeded from the wall clock, not 0, so a restarted xcsh always
|
|
40
43
|
* outranks its predecessor in the same pane. With a per-process counter from
|
|
41
44
|
* 0, every frame from the second xcsh in a pane looks stale and is dropped.
|
|
42
|
-
* 2. Frames go out one at a time through `enqueue
|
|
43
|
-
*
|
|
45
|
+
* 2. Frames go out one at a time through `enqueue`, awaiting herdr's response
|
|
46
|
+
* before the next frame is sent, so ordering is never left to chance.
|
|
44
47
|
* 3. The state frame is always sent *before* the session frame. herdr discards a
|
|
45
48
|
* `pane.report_agent_session` for a pane whose agent it does not yet own, so
|
|
46
49
|
* the state frame has to establish `herdr:xcsh` as the pane's agent first.
|
|
@@ -57,46 +60,50 @@ const REPORT_METHOD = "pane.report_agent";
|
|
|
57
60
|
const SESSION_METHOD = "pane.report_agent_session";
|
|
58
61
|
const RELEASE_METHOD = "pane.release_agent";
|
|
59
62
|
const SOCKET_TIMEOUT_MS = 2000;
|
|
63
|
+
const PROMPT_BLOCKED_REASONS = {
|
|
64
|
+
select: "selection required",
|
|
65
|
+
confirm: "confirmation required",
|
|
66
|
+
input: "text input required",
|
|
67
|
+
} satisfies Record<UserPromptKind, string>;
|
|
68
|
+
|
|
69
|
+
function getPromptBlockedReason(kind: unknown): string {
|
|
70
|
+
if (typeof kind === "string" && Object.hasOwn(PROMPT_BLOCKED_REASONS, kind)) {
|
|
71
|
+
return PROMPT_BLOCKED_REASONS[kind as UserPromptKind];
|
|
72
|
+
}
|
|
73
|
+
return "user input required";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Reused across calls for the life of the extension so `ensureProtocol()`'s
|
|
77
|
+
// `ping` validation happens at most once per socket path, not once per frame.
|
|
78
|
+
let cachedClient: HerdrClient | undefined;
|
|
79
|
+
|
|
80
|
+
function getHerdrClient(socketPath: string): HerdrClient {
|
|
81
|
+
if (!cachedClient || cachedClient.socketPath !== socketPath) {
|
|
82
|
+
cachedClient = new HerdrClient(socketPath, SOCKET_TIMEOUT_MS);
|
|
83
|
+
}
|
|
84
|
+
return cachedClient;
|
|
85
|
+
}
|
|
60
86
|
|
|
61
87
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* without throwing, so a dead
|
|
88
|
+
* Send one JSON-RPC request to herdr over its protocol-18 socket and await the
|
|
89
|
+
* typed response. Every failure path (transport error, timeout, protocol
|
|
90
|
+
* mismatch) is reported via `onError` without throwing, so a dead or
|
|
91
|
+
* incompatible herdr never disturbs the agent.
|
|
65
92
|
*
|
|
66
|
-
* Resolves once
|
|
93
|
+
* Resolves once herdr has responded (or the attempt failed or timed out),
|
|
67
94
|
* which is what lets callers order frames relative to one another.
|
|
68
95
|
*/
|
|
69
|
-
function sendToHerdrSocket(
|
|
96
|
+
async function sendToHerdrSocket(
|
|
70
97
|
socketPath: string,
|
|
71
98
|
method: string,
|
|
72
99
|
params: Record<string, unknown>,
|
|
73
100
|
onError: (err: unknown) => void,
|
|
74
101
|
): Promise<void> {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
settled = true;
|
|
82
|
-
resolve();
|
|
83
|
-
};
|
|
84
|
-
const conn = connect({ path: socketPath });
|
|
85
|
-
// Never let a report keep xcsh's event loop alive.
|
|
86
|
-
conn.unref();
|
|
87
|
-
conn.once("error", err => {
|
|
88
|
-
onError(err);
|
|
89
|
-
conn.destroy();
|
|
90
|
-
settle();
|
|
91
|
-
});
|
|
92
|
-
conn.once("connect", () => {
|
|
93
|
-
conn.end(`${JSON.stringify({ id: "xcsh:herdr-reporter", method, params })}\n`, settle);
|
|
94
|
-
});
|
|
95
|
-
conn.setTimeout(SOCKET_TIMEOUT_MS, () => {
|
|
96
|
-
conn.destroy();
|
|
97
|
-
settle();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
102
|
+
try {
|
|
103
|
+
await getHerdrClient(socketPath).request<Record<string, unknown>>(method, params);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
onError(err);
|
|
106
|
+
}
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
/** Translate a JSON-RPC report/release into `herdr` CLI arguments (fallback). */
|
|
@@ -114,6 +121,9 @@ function toCliArgs(method: string, params: Record<string, unknown>): string[] {
|
|
|
114
121
|
if (params.state !== undefined) {
|
|
115
122
|
args.push("--state", String(params.state));
|
|
116
123
|
}
|
|
124
|
+
if (params.message !== undefined) {
|
|
125
|
+
args.push("--message", String(params.message));
|
|
126
|
+
}
|
|
117
127
|
args.push("--seq", String(params.seq));
|
|
118
128
|
return args;
|
|
119
129
|
}
|
|
@@ -129,9 +139,9 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
129
139
|
// process in a pane always starts above whatever the previous process reached.
|
|
130
140
|
// Matches the pi/omp reporters and stays well inside Number.MAX_SAFE_INTEGER.
|
|
131
141
|
let seq = Date.now() * 1000;
|
|
132
|
-
//
|
|
133
|
-
// agent_end
|
|
134
|
-
let
|
|
142
|
+
// Retains the fixed reason while an interactive prompt awaits the user, so an
|
|
143
|
+
// agent_end duplicate cannot erase herdr's stored blocked message.
|
|
144
|
+
let promptBlockedReason: string | undefined;
|
|
135
145
|
// Last session ref already delivered, so repeated lifecycle events do not
|
|
136
146
|
// re-send an unchanged ref every turn.
|
|
137
147
|
let lastSessionRefKey: string | undefined;
|
|
@@ -167,12 +177,13 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
167
177
|
);
|
|
168
178
|
};
|
|
169
179
|
|
|
170
|
-
const report = (state: "idle" | "working" | "blocked"): Promise<void> =>
|
|
180
|
+
const report = (state: "idle" | "working" | "blocked", message?: string): Promise<void> =>
|
|
171
181
|
send(REPORT_METHOD, {
|
|
172
182
|
pane_id: paneId,
|
|
173
183
|
source: HERDR_SOURCE,
|
|
174
184
|
agent: HERDR_AGENT_LABEL,
|
|
175
185
|
state,
|
|
186
|
+
...(message === undefined ? {} : { message }),
|
|
176
187
|
seq: seq++,
|
|
177
188
|
});
|
|
178
189
|
|
|
@@ -243,19 +254,19 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
243
254
|
// This is also the first point where a lazily-created session file is certain
|
|
244
255
|
// to exist, so it is the backstop for capturing the resume ref.
|
|
245
256
|
pi.on("agent_end", async (_event, ctx) => {
|
|
246
|
-
await report(
|
|
257
|
+
await report(promptBlockedReason ? "blocked" : "idle", promptBlockedReason);
|
|
247
258
|
await reportSession(ctx);
|
|
248
259
|
});
|
|
249
260
|
|
|
250
261
|
// An interactive prompt (permission gate, ask tool, confirm/input) is
|
|
251
262
|
// awaiting the user: that is herdr's "needs attention" (blocked) state.
|
|
252
|
-
pi.on("user_prompt_start",
|
|
253
|
-
|
|
254
|
-
void report("blocked");
|
|
263
|
+
pi.on("user_prompt_start", event => {
|
|
264
|
+
promptBlockedReason = getPromptBlockedReason(event.kind);
|
|
265
|
+
void report("blocked", promptBlockedReason);
|
|
255
266
|
});
|
|
256
267
|
|
|
257
268
|
pi.on("user_prompt_end", async (_event, ctx) => {
|
|
258
|
-
|
|
269
|
+
promptBlockedReason = undefined;
|
|
259
270
|
await report(ctx.isIdle() ? "idle" : "working");
|
|
260
271
|
await reportSession(ctx);
|
|
261
272
|
});
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.11.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.11.7",
|
|
21
|
+
"commit": "43ba2b5cd078ccbd5d68b9b8c938423d470e2602",
|
|
22
|
+
"shortCommit": "43ba2b5",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.11.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.11.7",
|
|
25
|
+
"commitDate": "2026-09-05T05:33:41+00:00",
|
|
26
|
+
"buildDate": "2026-09-05T06:22:56.333Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.11.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/43ba2b5cd078ccbd5d68b9b8c938423d470e2602",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.11.7"
|
|
33
33
|
};
|