super-dsh 0.1.10 → 0.1.11-b
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 +71 -2
- package/agent-agy/dist/agent.d.ts +2 -0
- package/agent-agy/dist/agent.js +33 -1
- package/agent-agy/dist/agy-cli-client.d.ts +9 -0
- package/agent-agy/dist/agy-cli-client.js +56 -8
- package/agent-agy/dist/index.js +13 -7
- package/agent-agy/package.json +5 -1
- package/agent-claude/dist/adapter.js +106 -31
- package/agent-claude/dist/agent.js +244 -26
- package/agent-claude/dist/claude-client.js +129 -43
- package/agent-claude/dist/claude-launch.js +101 -0
- package/agent-claude/dist/claude-native-config.js +169 -0
- package/agent-claude/dist/claude-provider-gateway.js +340 -0
- package/agent-claude/dist/claude-providers.js +391 -0
- package/agent-claude/dist/claude-route.js +152 -0
- package/agent-claude/dist/index.js +217 -37
- package/agent-claude/dist/models.js +14 -0
- package/agent-claude/dist/sdk-runtime.js +320 -0
- package/agent-claude/package.json +6 -4
- package/agent-codex/dist/adapter.js +3 -2
- package/agent-codex/dist/agent.js +74 -15
- package/agent-codex/dist/app-server-client.js +33 -4
- package/agent-codex/dist/app-server-protocol.js +6 -2
- package/agent-codex/dist/app-server-wire.js +29 -24
- package/agent-codex/dist/codex-launch.js +10 -32
- package/agent-codex/dist/codex-native-config.js +15 -4
- package/agent-codex/dist/codex-oauth.js +153 -0
- package/agent-codex/dist/codex-provider-gateway.js +36 -38
- package/agent-codex/dist/codex-providers.js +20 -7
- package/agent-codex/dist/codex-runtime-fetch.js +293 -0
- package/agent-codex/dist/codex-runtime.js +120 -0
- package/agent-codex/dist/index.js +25 -12
- package/agent-codex/package.json +8 -3
- package/agent-codex-sdk/dist/adapter.js +3 -2
- package/agent-codex-sdk/dist/agent.js +35 -1
- package/agent-codex-sdk/dist/codex-native-config.js +9 -3
- package/agent-codex-sdk/dist/codex-oauth.js +153 -0
- package/agent-codex-sdk/dist/codex-provider-gateway.js +36 -38
- package/agent-codex-sdk/dist/codex-providers.js +20 -7
- package/agent-codex-sdk/dist/codex-sdk-launch.js +5 -38
- package/agent-codex-sdk/dist/index.js +18 -11
- package/agent-codex-sdk/dist/sdk-runtime.js +3 -3
- package/agent-hermes/dist/agent.js +46 -2
- package/agent-hermes/dist/hermes-client.js +93 -6
- package/agent-hermes/dist/index.js +6 -2
- package/agent-omp/dist/agent.js +53 -9
- package/agent-omp/dist/index.js +23 -3
- package/agent-omp/dist/lazy-rpc.js +11 -2
- package/agent-omp/dist/rpc-client.js +6 -1
- package/agent-omp-sdk/dist/agent.d.ts +11 -0
- package/agent-omp-sdk/dist/agent.js +17 -4
- package/agent-pi/dist/agent.js +69 -10
- package/agent-pi/dist/index.js +6 -2
- package/agent-pi/dist/pi-client.js +13 -3
- package/client/index.js +150 -58
- package/package.json +6 -5
- package/superd-hub/dist/a2a-row.js +20 -3
- package/superd-hub/dist/client/agent-settings.d.ts +66 -12
- package/superd-hub/dist/client/agent-settings.js +85 -14
- package/superd-hub/dist/client/runtime-settings-api.js +5 -5
- package/superd-hub/dist/connection-trust.d.ts +8 -0
- package/superd-hub/dist/connection-trust.js +16 -0
- package/superd-hub/dist/foreign-agy.d.ts +3 -0
- package/superd-hub/dist/foreign-agy.js +110 -0
- package/superd-hub/dist/foreign-claude.d.ts +4 -0
- package/superd-hub/dist/foreign-claude.js +160 -0
- package/superd-hub/dist/foreign-extension.d.ts +10 -0
- package/superd-hub/dist/foreign-extension.js +27 -0
- package/superd-hub/dist/foreign-hub.d.ts +27 -0
- package/superd-hub/dist/foreign-hub.js +243 -0
- package/superd-hub/dist/foreign-native.d.ts +4 -0
- package/superd-hub/dist/foreign-native.js +115 -0
- package/superd-hub/dist/web-trust.d.ts +14 -42
- package/superd-hub/dist/web-trust.js +18 -43
- package/superd-hub/dist/world-mount.d.ts +6 -5
- package/superd-hub/dist/world-mount.js +6 -6
- package/superd-hub/lib/client/index.js +150 -58
- package/superd-hub/package.json +14 -2
- package/agent-codex/README.md +0 -179
- package/agent-codex-sdk/README.md +0 -79
- package/agent-hermes/README.md +0 -145
- package/agent-omp/README.md +0 -94
- package/agent-omp-sdk/README.md +0 -103
- package/agent-pi/README.md +0 -67
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ the foreign store.
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
dsh plugin --profile <name> add super-dsh@0.1.
|
|
17
|
+
dsh plugin --profile <name> add super-dsh@0.1.11
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
That single package composes the whole line (`@pgmi-builds/superd-hub` plus the
|
|
@@ -22,17 +22,86 @@ six primary `@pgmi-builds/agent-*` packages and three OPTIONAL SDK halves).
|
|
|
22
22
|
Restart the profile and the
|
|
23
23
|
home under `<DSH_HOME>/agents/<label>/` on first boot.
|
|
24
24
|
|
|
25
|
+
## Remote web access
|
|
26
|
+
|
|
27
|
+
To use the same authenticated UI through a reverse proxy or LAN relay, enable
|
|
28
|
+
this profile patch:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
- id: superd-web-trust
|
|
32
|
+
config:
|
|
33
|
+
trustAllHosts: true
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This skips Host/Origin restrictions and enables browser ownership for every
|
|
37
|
+
hostname. Native token-to-cookie login, cookie expiry, and authority binding
|
|
38
|
+
remain in effect. The default is `false`, preserving declared-authority mode.
|
|
39
|
+
It does not change the server's listening address: keep loopback behind Caddy
|
|
40
|
+
and a LAN relay. The test launcher enables this mode without `--host` or
|
|
41
|
+
`--trusted-host` and starts the relay on every test port, including 4999.
|
|
42
|
+
|
|
25
43
|
## Runtimes
|
|
26
44
|
|
|
27
45
|
| Label | Runtime | Integration |
|
|
28
46
|
|---|---|---|
|
|
29
47
|
| OMP | OMP (`~/.omp`) | host `omp` binary over RPC (`omp --mode rpc`, NDJSON v1), lazy per session |
|
|
30
|
-
| Codex | Codex
|
|
48
|
+
| Codex | Codex app-server (`~/.codex`) | CLI first, desktop core and lazy world-home fetch fallback |
|
|
31
49
|
| Claude | Claude Code (`~/.claude`) | standalone adapter, joined by the hub |
|
|
32
50
|
| Pi | pi coding agent (`~/.pi`) | in-process SDK |
|
|
33
51
|
| Hermes | Hermes (`~/.hermes`) | gateway child |
|
|
34
52
|
| Antigravity | agy SDK | Python bridge (`bridge/agy_bridge.py`) |
|
|
35
53
|
|
|
54
|
+
### Foreign-agent Hub facility
|
|
55
|
+
|
|
56
|
+
Super D sessions in Pi, OMP, and Codex can use the same `superd-hub` facility
|
|
57
|
+
for agent roster/status, messaging, and shell execution. Tool descriptions,
|
|
58
|
+
argument validation, receipts, and reply guidance come from the existing Hub.
|
|
59
|
+
Replies wake the initiating session automatically; do not poll for them.
|
|
60
|
+
|
|
61
|
+
Pi and OMP share one native extension. It is loaded incrementally on the first
|
|
62
|
+
prompt, preserving normal extension discovery and native tools. Its per-session
|
|
63
|
+
wrapper lives under the Super D world home (`hub-extensions`, mode 0600), with a
|
|
64
|
+
session capability for a loopback-only HTTP listener. No global extension is
|
|
65
|
+
installed in `~/.pi` or `~/.omp`. Some OMP versions present registered extension
|
|
66
|
+
tools as devices: read `xd://superd-hub` for instructions and write action JSON
|
|
67
|
+
to that device.
|
|
68
|
+
|
|
69
|
+
Codex uses the official experimental app-server `dynamicTools` interface on
|
|
70
|
+
new threads. Callbacks bind to that thread and the Super D session; existing
|
|
71
|
+
native tools/plugins remain available. No global plugin is installed in
|
|
72
|
+
`~/.codex`. Resuming a thread created through this integration restores its
|
|
73
|
+
saved tool definition. Older threads without that definition need a new
|
|
74
|
+
Super D conversation to gain the facility. A native Codex client resuming one
|
|
75
|
+
of these threads does not supply Super D's callback host.
|
|
76
|
+
|
|
77
|
+
Pi/OMP extension closures cannot transparently renew an already-loaded listener
|
|
78
|
+
capability when the Hub row is unmounted/remounted. Restart Super D and resume
|
|
79
|
+
the conversation after that operation; the tool reports this recovery path
|
|
80
|
+
when its connection becomes unavailable. Whole-app restart/resume is tested.
|
|
81
|
+
|
|
82
|
+
Draft creation and passive history viewing create no extension file, listener,
|
|
83
|
+
or agent process. Closing a session invalidates its capability. Interrupted
|
|
84
|
+
tool operations retain conservative upstream recovery guidance about unknown
|
|
85
|
+
outcomes rather than encouraging blind retries.
|
|
86
|
+
|
|
87
|
+
### Codex in 0.1.11
|
|
88
|
+
|
|
89
|
+
Codex discovers the local OpenAI OAuth login as a read-only provider in the
|
|
90
|
+
model selector. Selecting it explicitly overrides a third-party provider in the
|
|
91
|
+
native config, while credentials and native configuration stay in the native
|
|
92
|
+
home. Third-party providers remain selectable per session.
|
|
93
|
+
|
|
94
|
+
The adapter prefers the installed desktop core, then the CLI, then the bundled
|
|
95
|
+
0.160.0 core (`CODEX_BIN` overrides discovery). Desktop host browser and computer
|
|
96
|
+
use services are separate and are not attached by this adapter.
|
|
97
|
+
|
|
98
|
+
**Provider compatibility:** each provider defines its own message, reasoning,
|
|
99
|
+
and encrypted-state formats. Selecting another provider does not guarantee
|
|
100
|
+
that it can consume the existing session history. Successful continuation
|
|
101
|
+
across endpoints is an observed convenience, not an adapter guarantee.
|
|
102
|
+
The adapter surfaces provider errors; if the selected provider rejects the
|
|
103
|
+
history, start a new session with that provider.
|
|
104
|
+
|
|
36
105
|
### Opt-in SDK halves
|
|
37
106
|
|
|
38
107
|
Three runtimes also ship a preserved in-process SDK transport beside the primary
|
|
@@ -35,6 +35,7 @@ import { type WithSystemHead } from "../../superd-hub/dist/index.js";
|
|
|
35
35
|
/** The CLI stream transport the agent drives (SDK bridge moved to agent-agy-sdk). */
|
|
36
36
|
export type LiveAgyClient = Pick<AgyCliClient, "conversationId" | "lastUsage" | "onThinkingDelta" | "onToolEvent" | "setApprovalHandler" | "turn" | "close"> & {
|
|
37
37
|
setSystemMessageHandler?(handler: (text: string) => void): void;
|
|
38
|
+
interrupt?: () => Promise<void>;
|
|
38
39
|
};
|
|
39
40
|
/** Classify a bridge turn failure into the stable {message, code} UI chip. */
|
|
40
41
|
export declare function classifyTurnError(error: unknown): {
|
|
@@ -119,6 +120,7 @@ export declare class AgyAgent implements Agent {
|
|
|
119
120
|
/** Flush ONE parked follow-up as a fresh prompt (never submit while busy). */
|
|
120
121
|
private flushFollowUps;
|
|
121
122
|
private pendingThinking;
|
|
123
|
+
private stopInFlight?;
|
|
122
124
|
/** Calls from this turn still lacking a result (SDK 0.1.17 exposes none). */
|
|
123
125
|
private unpairedCalls;
|
|
124
126
|
private armTurnDeadline;
|
package/agent-agy/dist/agent.js
CHANGED
|
@@ -129,9 +129,27 @@ export class AgyAgent {
|
|
|
129
129
|
this.closeStep();
|
|
130
130
|
this.commitStepStart();
|
|
131
131
|
const callId = ToolCallId(ev.id || `agy-${this.dashTurn}-${this.step}`);
|
|
132
|
+
const argumentsJson = ev.args || "{}";
|
|
133
|
+
// Advertisement-before-execution (validator invariant, 2026-10-04 dev3
|
|
134
|
+
// omp/hermes repair family): agy assistant frames carry only
|
|
135
|
+
// reasoning/text — never tool-call blocks — so every tool/call needs
|
|
136
|
+
// a minimal advertisement assistant frame first; arguments are copied
|
|
137
|
+
// verbatim into both frames (validator: lifecycle arguments ≡
|
|
138
|
+
// advertised, strict string equality).
|
|
139
|
+
const advertisement = createAssistantMessage({
|
|
140
|
+
content: [{ type: "tool-call", id: callId, name: ev.name, arguments: argumentsJson }],
|
|
141
|
+
source: {
|
|
142
|
+
provider: this.options.provider ?? "agy",
|
|
143
|
+
model: this.options.model ?? "",
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
this.session.append("assistant/message", {
|
|
147
|
+
turn: this.dashTurn, step: this.step,
|
|
148
|
+
message: advertisement, stream: [],
|
|
149
|
+
}, { surfaceOp: "append" });
|
|
132
150
|
this.session.append("tool/call", {
|
|
133
151
|
turn: this.dashTurn, step: this.step,
|
|
134
|
-
callId, name: ev.name, arguments:
|
|
152
|
+
callId, name: ev.name, arguments: argumentsJson,
|
|
135
153
|
});
|
|
136
154
|
this.unpairedCalls.push({ callId, name: ev.name });
|
|
137
155
|
}
|
|
@@ -275,6 +293,8 @@ export class AgyAgent {
|
|
|
275
293
|
this.ensureStreamBridge().push({ type: "text-delta", index: full.length, text: chunk });
|
|
276
294
|
full += chunk;
|
|
277
295
|
}
|
|
296
|
+
await this.stopInFlight;
|
|
297
|
+
this.stopInFlight = undefined;
|
|
278
298
|
this.clearTurnDeadline();
|
|
279
299
|
// SDK 0.1.17 streams ToolCall but NEVER ToolResult (verified live and
|
|
280
300
|
// in SDK source: receive_chunks yields Thought/Text/ToolCall only; the
|
|
@@ -309,6 +329,8 @@ export class AgyAgent {
|
|
|
309
329
|
this.flushFollowUps();
|
|
310
330
|
}
|
|
311
331
|
catch (error) {
|
|
332
|
+
await this.stopInFlight;
|
|
333
|
+
this.stopInFlight = undefined;
|
|
312
334
|
this.clearTurnDeadline();
|
|
313
335
|
this.abandonStreamBridge();
|
|
314
336
|
const failure = classifyTurnError(error);
|
|
@@ -327,8 +349,10 @@ export class AgyAgent {
|
|
|
327
349
|
if (this.turnOpen && this.step > 0)
|
|
328
350
|
this.closeStep();
|
|
329
351
|
this.closeTurn({ kind: "error", error: failure });
|
|
352
|
+
this.cancelCause = null;
|
|
330
353
|
this.markIdle();
|
|
331
354
|
this.endActivity();
|
|
355
|
+
this.flushFollowUps();
|
|
332
356
|
}
|
|
333
357
|
}
|
|
334
358
|
appendSystemNotice(text) {
|
|
@@ -434,6 +458,7 @@ export class AgyAgent {
|
|
|
434
458
|
this.deliverPrompt(entry.message);
|
|
435
459
|
}
|
|
436
460
|
pendingThinking = [];
|
|
461
|
+
stopInFlight;
|
|
437
462
|
/** Calls from this turn still lacking a result (SDK 0.1.17 exposes none). */
|
|
438
463
|
unpairedCalls = [];
|
|
439
464
|
armTurnDeadline() {
|
|
@@ -444,6 +469,13 @@ export class AgyAgent {
|
|
|
444
469
|
if (!this.turnOpen)
|
|
445
470
|
return;
|
|
446
471
|
trace(`turn deadline exceeded after ${AGY_TURN_DEADLINE_MS}ms — failing open turn`);
|
|
472
|
+
if (this.client.interrupt !== undefined) {
|
|
473
|
+
// Keep ownership until the old CLI stops. Its catch pairs unresolved
|
|
474
|
+
// calls and only then starts the next queued message.
|
|
475
|
+
this.cancelCause = { kind: "hook", reason: `agy turn deadline exceeded after ${AGY_TURN_DEADLINE_MS}ms` };
|
|
476
|
+
this.stopInFlight = this.client.interrupt().catch(error => trace(`deadline interrupt failed: ${String(error)}`));
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
447
479
|
this.abandonStreamBridge();
|
|
448
480
|
if (this.step > 0)
|
|
449
481
|
this.closeStep();
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* Same surface as AgyBridgeClient so AgyAgent needs no changes.
|
|
17
17
|
*/
|
|
18
|
+
import type { ForeignHubBinding } from "@pgmi-builds/superd-hub/foreign-hub";
|
|
18
19
|
import { type AgyAuthMode, type AgySettingsMutation } from "./agy-auth.js";
|
|
19
20
|
export interface AgyCliOptions {
|
|
20
21
|
/** Key or a resolver (onboarding-saved keys become visible at first spawn). */
|
|
@@ -49,6 +50,9 @@ export interface AgyCliOptions {
|
|
|
49
50
|
authMode?: AgyAuthMode;
|
|
50
51
|
spawnAttempts?: number;
|
|
51
52
|
trace?: (...parts: unknown[]) => void;
|
|
53
|
+
hubBinding?: ForeignHubBinding;
|
|
54
|
+
hubStagingDirectory?: string;
|
|
55
|
+
prepareHub?: () => Promise<string | undefined>;
|
|
52
56
|
}
|
|
53
57
|
export type CliEvent = {
|
|
54
58
|
event: "ready";
|
|
@@ -110,6 +114,9 @@ export declare class AgyCliClient {
|
|
|
110
114
|
private dead;
|
|
111
115
|
private conversationIdValue;
|
|
112
116
|
private toolsSeen;
|
|
117
|
+
private hubPreparation?;
|
|
118
|
+
private hubSession?;
|
|
119
|
+
private prepare;
|
|
113
120
|
onThinkingDelta?: (text: string) => void;
|
|
114
121
|
onToolEvent?: (ev: {
|
|
115
122
|
event: "tool_call";
|
|
@@ -163,5 +170,7 @@ export declare class AgyCliClient {
|
|
|
163
170
|
private readyReceived;
|
|
164
171
|
private expectReady;
|
|
165
172
|
ping(): Promise<void>;
|
|
173
|
+
/** Stop one CLI execution, preserving its conversation and Hub capability. */
|
|
174
|
+
interrupt(): Promise<void>;
|
|
166
175
|
close(): Promise<void>;
|
|
167
176
|
}
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
* Same surface as AgyBridgeClient so AgyAgent needs no changes.
|
|
17
17
|
*/
|
|
18
18
|
import { spawn } from "node:child_process";
|
|
19
|
+
import { execFile } from "node:child_process";
|
|
20
|
+
import { promisify } from "node:util";
|
|
21
|
+
import { prepareAgyNativePlugin } from "@pgmi-builds/superd-hub/foreign-agy";
|
|
19
22
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
20
23
|
import { join } from "node:path";
|
|
21
24
|
import { authChildEnv, authSettingsMutation, nativeSettingsPath, } from "./agy-auth.js";
|
|
@@ -63,6 +66,24 @@ export class AgyCliClient {
|
|
|
63
66
|
dead = false;
|
|
64
67
|
conversationIdValue = "";
|
|
65
68
|
toolsSeen = 0;
|
|
69
|
+
hubPreparation;
|
|
70
|
+
hubSession;
|
|
71
|
+
async prepare() {
|
|
72
|
+
if (this.dead)
|
|
73
|
+
throw new Error("agy client is closed");
|
|
74
|
+
this.hubPreparation ??= (async () => {
|
|
75
|
+
if (this.opts.hubBinding === undefined)
|
|
76
|
+
return;
|
|
77
|
+
this.hubSession = await (this.opts.prepareHub?.() ?? prepareAgyNativePlugin(this.opts.hubBinding, join(this.realHome(), ".gemini", "antigravity-cli"), this.opts.hubStagingDirectory, async (directory) => {
|
|
78
|
+
const exec = promisify(execFile);
|
|
79
|
+
await exec(this.opts.agyBin ?? "agy", ["plugin", "install", directory], { timeout: 60_000 });
|
|
80
|
+
await exec(this.opts.agyBin ?? "agy", ["plugin", "enable", "superd-hub"], { timeout: 60_000 });
|
|
81
|
+
}));
|
|
82
|
+
})();
|
|
83
|
+
await this.hubPreparation;
|
|
84
|
+
if (this.dead)
|
|
85
|
+
throw new Error("agy client is closed");
|
|
86
|
+
}
|
|
66
87
|
onThinkingDelta;
|
|
67
88
|
onToolEvent;
|
|
68
89
|
setApprovalHandler(_handler) {
|
|
@@ -90,6 +111,8 @@ export class AgyCliClient {
|
|
|
90
111
|
spawnCli() {
|
|
91
112
|
if (this.child || this.dead)
|
|
92
113
|
return;
|
|
114
|
+
this.pending.length = 0;
|
|
115
|
+
this.buffer = "";
|
|
93
116
|
const mode = this.opts.authMode ?? "apiKey";
|
|
94
117
|
// Only key mode patches settings (`modelProvider: "gemini"`); ADC and OAuth
|
|
95
118
|
// need the DEFAULT backend, where that key must be ABSENT — the binary
|
|
@@ -107,8 +130,9 @@ export class AgyCliClient {
|
|
|
107
130
|
"--input-format=stream-json", "--output-format=stream-json",
|
|
108
131
|
"--disable-slash-commands",
|
|
109
132
|
];
|
|
110
|
-
|
|
111
|
-
|
|
133
|
+
const conversationId = this.conversationIdValue || this.opts.conversationId;
|
|
134
|
+
if (conversationId)
|
|
135
|
+
args.push(`--conversation=${conversationId}`);
|
|
112
136
|
if (this.opts.model)
|
|
113
137
|
args.push(`--model=${this.opts.model}`);
|
|
114
138
|
if (this.opts.effort)
|
|
@@ -127,6 +151,9 @@ export class AgyCliClient {
|
|
|
127
151
|
// ADC, the key for key mode, and the auto-update pin on EVERY mode.
|
|
128
152
|
// NO_PROXY keeps the dev3 loopback bridge reachable.
|
|
129
153
|
const env = { ...process.env, NO_PROXY: "127.0.0.1,localhost", ...authChildEnv(mode, key) };
|
|
154
|
+
delete env.SUPERD_HUB_SESSION;
|
|
155
|
+
if (this.hubSession !== undefined)
|
|
156
|
+
env.SUPERD_HUB_SESSION = this.hubSession;
|
|
130
157
|
// No HOME override, ever: the settings we just maintained live at
|
|
131
158
|
// `$HOME/.gemini`, ADC at `$HOME/.config/gcloud`, and the sign-in token
|
|
132
159
|
// in the keyring — isolating HOME destroys all three. That was the
|
|
@@ -155,6 +182,8 @@ export class AgyCliClient {
|
|
|
155
182
|
});
|
|
156
183
|
child.on("exit", (code) => {
|
|
157
184
|
this.child = undefined;
|
|
185
|
+
this.readyReceived = false;
|
|
186
|
+
this.buffer = "";
|
|
158
187
|
// The CLI reports its refusals on stderr / as non-JSON stdout lines and
|
|
159
188
|
// then exits non-zero. Those lines ARE the diagnosis ("--effort is not
|
|
160
189
|
// supported for model …", "Eligibility check failed: …"), so the exit
|
|
@@ -206,6 +235,8 @@ export class AgyCliClient {
|
|
|
206
235
|
continue;
|
|
207
236
|
}
|
|
208
237
|
if (parsed.event === "init") {
|
|
238
|
+
if (typeof parsed.conversation_id === "string")
|
|
239
|
+
this.conversationIdValue = parsed.conversation_id;
|
|
209
240
|
const init = parsed.init;
|
|
210
241
|
this.toolsSeen = Array.isArray(init?.tools) ? init.tools.length : 0;
|
|
211
242
|
this.dispatch({ event: "ready", tools: this.toolsSeen, permissionMode: init?.permission_mode });
|
|
@@ -262,7 +293,6 @@ export class AgyCliClient {
|
|
|
262
293
|
event: "tool_call", id, name,
|
|
263
294
|
args: JSON.stringify(su.tool_info?.parameters ?? {}),
|
|
264
295
|
});
|
|
265
|
-
this.onToolEvent?.({ event: "tool_call", id, name, args: JSON.stringify(su.tool_info?.parameters ?? {}) });
|
|
266
296
|
}
|
|
267
297
|
else if (su.state === "DONE" || su.state === "ERROR") {
|
|
268
298
|
const output = su.tool_info?.output ?? "";
|
|
@@ -271,10 +301,6 @@ export class AgyCliClient {
|
|
|
271
301
|
event: "tool_result", id, name, is_error: isError,
|
|
272
302
|
result: output || (isError ? "tool failed" : "[agy CLI reported no output summary]"),
|
|
273
303
|
});
|
|
274
|
-
this.onToolEvent?.({
|
|
275
|
-
event: "tool_result", id, name, is_error: isError,
|
|
276
|
-
result: output || (isError ? "tool failed" : "[agy CLI reported no output summary]"),
|
|
277
|
-
});
|
|
278
304
|
}
|
|
279
305
|
}
|
|
280
306
|
}
|
|
@@ -298,6 +324,7 @@ export class AgyCliClient {
|
|
|
298
324
|
}
|
|
299
325
|
/** One turn. First call spawns the CLI (lazy per §14-i) and keeps it resident. */
|
|
300
326
|
async *turn(text) {
|
|
327
|
+
await this.prepare();
|
|
301
328
|
this.spawnCli();
|
|
302
329
|
await this.expectReady();
|
|
303
330
|
this.send({ event: "user", message: { content: text } });
|
|
@@ -343,13 +370,34 @@ export class AgyCliClient {
|
|
|
343
370
|
}
|
|
344
371
|
}
|
|
345
372
|
async ping() {
|
|
373
|
+
await this.prepare();
|
|
346
374
|
this.spawnCli();
|
|
347
375
|
await this.expectReady();
|
|
348
376
|
}
|
|
377
|
+
/** Stop one CLI execution, preserving its conversation and Hub capability. */
|
|
378
|
+
async interrupt() {
|
|
379
|
+
const child = this.child;
|
|
380
|
+
if (child === undefined)
|
|
381
|
+
return;
|
|
382
|
+
this.readyReceived = false;
|
|
383
|
+
const exited = new Promise(resolve => child.once("exit", () => resolve()));
|
|
384
|
+
child.kill("SIGTERM");
|
|
385
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), 2000);
|
|
386
|
+
timer.unref();
|
|
387
|
+
try {
|
|
388
|
+
await exited;
|
|
389
|
+
}
|
|
390
|
+
finally {
|
|
391
|
+
clearTimeout(timer);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
349
394
|
async close() {
|
|
350
|
-
if (
|
|
395
|
+
if (this.dead)
|
|
351
396
|
return;
|
|
352
397
|
this.dead = true;
|
|
398
|
+
await this.opts.hubBinding?.dispose();
|
|
399
|
+
if (!this.child)
|
|
400
|
+
return;
|
|
353
401
|
const child = this.child;
|
|
354
402
|
try {
|
|
355
403
|
child.stdin.end();
|
package/agent-agy/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* `sessionPersistence` service (hermes create/resume transaction shape).
|
|
19
19
|
*/
|
|
20
20
|
import { realpathSync, statSync } from "node:fs";
|
|
21
|
+
import { bindForeignHub } from "@pgmi-builds/superd-hub/foreign-hub";
|
|
21
22
|
import { join } from "node:path";
|
|
22
23
|
import { Service } from "@deepseek-ai/cordis";
|
|
23
24
|
import { installModelSelection } from "@deepseek-ai/dsh-agent";
|
|
@@ -149,6 +150,8 @@ export class AgyProvider extends Service {
|
|
|
149
150
|
hasAuthEvidence() {
|
|
150
151
|
if (this.resolveApiKey() !== undefined)
|
|
151
152
|
return true;
|
|
153
|
+
if (hasSigninCredential(this.opts.realHome ?? process.env.HOME ?? ""))
|
|
154
|
+
return true;
|
|
152
155
|
return hasAdcEvidence(process.env, process.env.HOME ?? "");
|
|
153
156
|
}
|
|
154
157
|
/** Default model id: adapter state → native TUI default (slug-normalized) → catalog head. */
|
|
@@ -260,7 +263,8 @@ export class AgyProvider extends Service {
|
|
|
260
263
|
trace(`create id=${id} spawnCwd=${spawnCwd}`);
|
|
261
264
|
// Full-lazy (§14-i): construct the client (spawns NOTHING); the bridge
|
|
262
265
|
// child materializes on the first real prompt.
|
|
263
|
-
const
|
|
266
|
+
const agentRef = {};
|
|
267
|
+
const client = this.createLiveClient(spawnCwd, agentOptionsModel(options.agentOptions), options.agentOptions?.reasoningEffort, bindForeignHub("agy", id, this.home, () => agentRef.current));
|
|
264
268
|
const preparation = SessionPreparation.create(loopCtx.sessions.prepare(id, {
|
|
265
269
|
...(options.seed === undefined ? {} : { seed: options.seed }),
|
|
266
270
|
...(meta === undefined ? {} : { meta }),
|
|
@@ -273,7 +277,7 @@ export class AgyProvider extends Service {
|
|
|
273
277
|
upsertSession(this.home, String(id), { conversationId: null, cwd: spawnCwd, createdAt: Date.now(), preset: null });
|
|
274
278
|
handedOff = true;
|
|
275
279
|
const agentOptions = await this.sessionAgentOptions(options.agentOptions);
|
|
276
|
-
return await setupAndPublish(loopCtx, ownerCtx, id, agentOptions, options.setup, preparation.session, client, options.parentAgent, "startup", { enterSession: true, preparation }, stored, this.agentRuntime(spawnCwd), () => this.followConversationId(id, client));
|
|
280
|
+
return await setupAndPublish(loopCtx, ownerCtx, id, agentOptions, options.setup, preparation.session, client, options.parentAgent, "startup", { enterSession: true, preparation }, stored, this.agentRuntime(spawnCwd), () => this.followConversationId(id, client), agentRef);
|
|
277
281
|
}
|
|
278
282
|
catch (error) {
|
|
279
283
|
trace(`create ${id} THREW: ${String(error)}`);
|
|
@@ -318,7 +322,8 @@ export class AgyProvider extends Service {
|
|
|
318
322
|
}
|
|
319
323
|
return verified;
|
|
320
324
|
})();
|
|
321
|
-
const
|
|
325
|
+
const agentRef = {};
|
|
326
|
+
const client = this.createLiveClient(spawnCwd, agentOptionsModel(options.agentOptions), options.agentOptions?.reasoningEffort, bindForeignHub("agy", id, this.home, () => agentRef.current), blank ? undefined : record.conversationId);
|
|
322
327
|
let handle;
|
|
323
328
|
let stored;
|
|
324
329
|
let preparation;
|
|
@@ -340,7 +345,7 @@ export class AgyProvider extends Service {
|
|
|
340
345
|
handle = undefined;
|
|
341
346
|
handedOff = true;
|
|
342
347
|
const agentOptions = await this.sessionAgentOptions(options.agentOptions);
|
|
343
|
-
return await setupAndPublish(loopCtx, ownerCtx, id, agentOptions, options.setup, preparation.session, client, options.parentAgent, "resume", { enterSession: true, preparation }, stored, this.agentRuntime(spawnCwd), () => this.followConversationId(id, client));
|
|
348
|
+
return await setupAndPublish(loopCtx, ownerCtx, id, agentOptions, options.setup, preparation.session, client, options.parentAgent, "resume", { enterSession: true, preparation }, stored, this.agentRuntime(spawnCwd), () => this.followConversationId(id, client), agentRef);
|
|
344
349
|
}
|
|
345
350
|
catch (error) {
|
|
346
351
|
trace(`resume ${id} THREW: ${String(error)}`);
|
|
@@ -363,8 +368,8 @@ export class AgyProvider extends Service {
|
|
|
363
368
|
* environment for free while the SDK is an opt-in extra. Auth-form selection
|
|
364
369
|
* still rides the agy-auth ladder.
|
|
365
370
|
*/
|
|
366
|
-
createLiveClient(cwd, modelId, reasoningEffort) {
|
|
367
|
-
return new AgyCliClient(this.cliOptions(cwd, modelId, reasoningEffort));
|
|
371
|
+
createLiveClient(cwd, modelId, reasoningEffort, hubBinding, conversationId) {
|
|
372
|
+
return new AgyCliClient({ ...this.cliOptions(cwd, modelId, reasoningEffort), conversationId, hubBinding, hubStagingDirectory: join(this.home, "hub-native-agy") });
|
|
368
373
|
}
|
|
369
374
|
/**
|
|
370
375
|
* The auth form this machine should use: an explicitly selected, actually
|
|
@@ -457,7 +462,7 @@ async function appendUnstoredSuffix(stored, session) {
|
|
|
457
462
|
stored.storedCount += suffix.length;
|
|
458
463
|
}
|
|
459
464
|
/** Shared create/resume transaction (module-level: Cordis tracing proxy). */
|
|
460
|
-
async function setupAndPublish(loopCtx, ownerCtx, id, agentOptions, setup, session, client, parentAgent, source, opts, stored, runtimeInfo, onTurnDone) {
|
|
465
|
+
async function setupAndPublish(loopCtx, ownerCtx, id, agentOptions, setup, session, client, parentAgent, source, opts, stored, runtimeInfo, onTurnDone, agentRef) {
|
|
461
466
|
const runtime = { ...runtimeInfo, onTurnDone };
|
|
462
467
|
let detachSession;
|
|
463
468
|
let detachAgent;
|
|
@@ -465,6 +470,7 @@ async function setupAndPublish(loopCtx, ownerCtx, id, agentOptions, setup, sessi
|
|
|
465
470
|
let idleExit;
|
|
466
471
|
try {
|
|
467
472
|
agent = new AgyAgent(loopCtx, id, agentOptions, session, client, () => idleExit?.(), runtime);
|
|
473
|
+
agentRef.current = agent;
|
|
468
474
|
// Pin THIS session to the agy route (static resolution — synchronous).
|
|
469
475
|
try {
|
|
470
476
|
const selection = { provider: agentOptions.provider ?? "agy", model: agentOptions.model ?? "" };
|
package/agent-agy/package.json
CHANGED
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"@deepseek-ai/dsh-scope": ">=0.1.5-0 <0.3.0-0",
|
|
31
31
|
"@deepseek-ai/dsh-session": ">=0.1.5-0 <0.3.0-0",
|
|
32
32
|
"@deepseek-ai/dsh-session-persistence": ">=0.1.5-0 <0.3.0-0",
|
|
33
|
-
"@deepseek-ai/dsh-typert-protocol": ">=0.1.5-0 <0.3.0-0"
|
|
33
|
+
"@deepseek-ai/dsh-typert-protocol": ">=0.1.5-0 <0.3.0-0",
|
|
34
|
+
"@pgmi-builds/superd-hub": "*"
|
|
34
35
|
},
|
|
35
36
|
"peerDependenciesMeta": {
|
|
36
37
|
"@deepseek-ai/cordis": {
|
|
@@ -51,6 +52,9 @@
|
|
|
51
52
|
"@deepseek-ai/dsh-session-persistence": {
|
|
52
53
|
"optional": true
|
|
53
54
|
},
|
|
55
|
+
"@pgmi-builds/superd-hub": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
54
58
|
"@deepseek-ai/dsh-typert-protocol": {
|
|
55
59
|
"optional": true
|
|
56
60
|
}
|
|
@@ -4,8 +4,23 @@
|
|
|
4
4
|
* The browser model selector never touches the Claude agent directly: it is an
|
|
5
5
|
* RPC round-trip through the apiproxy, which reads `ctx.llm.listProviders /
|
|
6
6
|
* listModels / resolveModel` to build the catalog. This adapter answers those
|
|
7
|
-
* queries from
|
|
8
|
-
*
|
|
7
|
+
* queries from TWO sources, one route each (the codex twin's one-route-per-
|
|
8
|
+
* provider shape, 2026-10-04 F-A rework):
|
|
9
|
+
*
|
|
10
|
+
* - the fixed native route `claude` serves the OBSERVED catalog only (raw
|
|
11
|
+
* ids — what the CLI itself reports, `models.ts`); its group stays "Claude".
|
|
12
|
+
* - one route PER configured provider (route id = provider id) serves that
|
|
13
|
+
* provider's curated `models[]` (RAW model ids, `claude-providers.ts`).
|
|
14
|
+
*
|
|
15
|
+
* The route/model composition therefore yields selection ids identical to the
|
|
16
|
+
* old composite keys (`deepseek/deepseek-flash`, `glm/glm-5.3`), so route seeds
|
|
17
|
+
* and logged selections keep working — the route half simply moved from the
|
|
18
|
+
* hardcoded `claude` to the provider id itself.
|
|
19
|
+
*
|
|
20
|
+
* The curated half follows the codex twin's rule exactly: the store is read
|
|
21
|
+
* LIVE on every call, so a panel edit is visible to the next catalog query
|
|
22
|
+
* without re-registration. An absent `worldHome` means observed-only (the
|
|
23
|
+
* settings-UI round trip and the unit tests).
|
|
9
24
|
*
|
|
10
25
|
* The route id must be `claude`, NOT `claude-code`: the upstream package
|
|
11
26
|
* `@deepseek-ai/dsh-subagent-claude-code` already occupies the subagent
|
|
@@ -14,47 +29,107 @@
|
|
|
14
29
|
* `stream` is never dispatched: Claude owns generation through its own SDK
|
|
15
30
|
* thread, so the adapter only serves catalog/metadata queries. It throws
|
|
16
31
|
* rather than fabricating a wire route the harness would misuse.
|
|
32
|
+
*
|
|
33
|
+
* @module agent-claude/adapter
|
|
17
34
|
*/
|
|
18
35
|
import { LlmAdapter, LlmError, ReasoningEffortId, } from "@deepseek-ai/dsh-llm";
|
|
36
|
+
import { readProviderStore } from "./claude-providers.js";
|
|
19
37
|
import { readModelCatalog } from "./models.js";
|
|
20
|
-
/** The
|
|
38
|
+
/** The fixed native route every observed Claude model is served under. */
|
|
21
39
|
export const CLAUDE_PROVIDER_ID = "claude";
|
|
22
|
-
/** Human-readable provider name for
|
|
40
|
+
/** Human-readable provider name for the fixed native route. */
|
|
23
41
|
const CLAUDE_PROVIDER_NAME = "Claude";
|
|
42
|
+
/** Whether a provider may be registered as a model route. */
|
|
43
|
+
export function routableProvider(entry) {
|
|
44
|
+
return entry.models.length > 0;
|
|
45
|
+
}
|
|
46
|
+
/** The route ids a store currently contributes to `ctx.llm`: the fixed `claude`
|
|
47
|
+
* route first, then one route per provider that has models (store order). */
|
|
48
|
+
export function routeIds(store) {
|
|
49
|
+
return [CLAUDE_PROVIDER_ID, ...store.providers.filter(routableProvider).map((entry) => entry.id)];
|
|
50
|
+
}
|
|
24
51
|
export class ClaudeLlmAdapter extends LlmAdapter {
|
|
25
|
-
|
|
26
|
-
|
|
52
|
+
worldHome;
|
|
53
|
+
/**
|
|
54
|
+
* @param worldHome - the world's DSH home, holding the curated provider
|
|
55
|
+
* store in `<worldHome>/claude-providers.json`. Read on every call (the
|
|
56
|
+
* codex twin's rule), so a panel edit is visible to the next catalog query
|
|
57
|
+
* without re-registration. Absent = observed-only (the fixed `claude` route).
|
|
58
|
+
*/
|
|
59
|
+
constructor(worldHome) {
|
|
60
|
+
super();
|
|
61
|
+
this.worldHome = worldHome;
|
|
62
|
+
}
|
|
63
|
+
/** The curated store entry a provider route id names, or `undefined`. */
|
|
64
|
+
curatedProvider(providerId) {
|
|
65
|
+
if (this.worldHome === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
return readProviderStore(this.worldHome).providers.find((entry) => entry.id === providerId);
|
|
68
|
+
}
|
|
69
|
+
providerInfo(provider) {
|
|
70
|
+
if (provider === CLAUDE_PROVIDER_ID)
|
|
71
|
+
return { id: CLAUDE_PROVIDER_ID, name: CLAUDE_PROVIDER_NAME };
|
|
72
|
+
// The display name is the entry's label — for a provider folded in from the
|
|
73
|
+
// user's own settings that is its endpoint URL, the only name it supplies.
|
|
74
|
+
return { id: provider, name: this.curatedProvider(provider)?.label ?? provider };
|
|
27
75
|
}
|
|
28
|
-
async listModels(
|
|
29
|
-
|
|
30
|
-
|
|
76
|
+
async listModels(provider) {
|
|
77
|
+
if (provider === CLAUDE_PROVIDER_ID) {
|
|
78
|
+
// Observed catalog only, raw ids exactly as the CLI reported them.
|
|
79
|
+
return readModelCatalog().models.map((model) => ({
|
|
80
|
+
provider: CLAUDE_PROVIDER_ID,
|
|
81
|
+
id: model.id,
|
|
82
|
+
name: model.label,
|
|
83
|
+
...(model.description === undefined ? {} : { description: model.description }),
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
const entry = this.curatedProvider(provider);
|
|
87
|
+
if (entry === undefined)
|
|
88
|
+
return [];
|
|
89
|
+
return entry.models.map((model) => ({
|
|
90
|
+
provider,
|
|
31
91
|
id: model.id,
|
|
32
|
-
name: model.
|
|
33
|
-
...(model.description === undefined ? {} : { description: model.description }),
|
|
92
|
+
name: model.displayName ?? model.id,
|
|
34
93
|
}));
|
|
35
94
|
}
|
|
36
|
-
async resolveModel(
|
|
37
|
-
|
|
38
|
-
|
|
95
|
+
async resolveModel(provider, model) {
|
|
96
|
+
if (provider === CLAUDE_PROVIDER_ID) {
|
|
97
|
+
// Observed catalog (primary; unchanged behavior for the native route).
|
|
98
|
+
const found = readModelCatalog().models.find((candidate) => candidate.id === model);
|
|
99
|
+
if (found !== undefined) {
|
|
100
|
+
return {
|
|
101
|
+
provider: CLAUDE_PROVIDER_ID,
|
|
102
|
+
id: found.id,
|
|
103
|
+
name: found.label,
|
|
104
|
+
...(found.description === undefined ? {} : { description: found.description }),
|
|
105
|
+
// Only a positive window is real metadata: an absent or zero window must
|
|
106
|
+
// never become `context: { contextWindow: 0 }`.
|
|
107
|
+
...(found.contextWindow !== undefined && found.contextWindow > 0
|
|
108
|
+
? { context: { contextWindow: found.contextWindow } }
|
|
109
|
+
: {}),
|
|
110
|
+
// The CLI's advertised effort levels become adapter-owned reasoning
|
|
111
|
+
// efforts (omp thinking.efforts parity); the CLI names no default, so
|
|
112
|
+
// none is invented.
|
|
113
|
+
...(found.reasoningEfforts !== undefined && found.reasoningEfforts.length > 0
|
|
114
|
+
? { reasoning: { efforts: found.reasoningEfforts.map((effort) => ({ id: ReasoningEffortId(effort), name: effort })) } }
|
|
115
|
+
: {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
39
118
|
throw new LlmError(`Claude provider "${CLAUDE_PROVIDER_ID}" does not serve model "${model}"`, "MODEL_NOT_FOUND");
|
|
40
119
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...(found.reasoningEfforts !== undefined && found.reasoningEfforts.length > 0
|
|
55
|
-
? { reasoning: { efforts: found.reasoningEfforts.map((effort) => ({ id: ReasoningEffortId(effort), name: effort })) } }
|
|
56
|
-
: {}),
|
|
57
|
-
};
|
|
120
|
+
const entry = this.curatedProvider(provider);
|
|
121
|
+
const curated = entry?.models.find((candidate) => candidate.id === model);
|
|
122
|
+
if (entry !== undefined && curated !== undefined) {
|
|
123
|
+
return {
|
|
124
|
+
provider,
|
|
125
|
+
id: curated.id,
|
|
126
|
+
name: curated.displayName ?? curated.id,
|
|
127
|
+
...(curated.contextWindow !== undefined && curated.contextWindow > 0
|
|
128
|
+
? { context: { contextWindow: curated.contextWindow } }
|
|
129
|
+
: {}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
throw new LlmError(`Claude provider "${provider}" does not serve model "${model}"`, "MODEL_NOT_FOUND");
|
|
58
133
|
}
|
|
59
134
|
stream(_options) {
|
|
60
135
|
throw new LlmError("the Claude adapter does not stream: Claude owns generation through its SDK thread", "UNSUPPORTED_STREAM");
|