dsh-loop-engine-allinone 0.0.0-stage → 0.4.1
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/CHANGELOG.md +119 -0
- package/CONTRIBUTING.md +78 -0
- package/LICENSE +23 -0
- package/NOTICE +45 -0
- package/README.md +223 -2
- package/README.zh.md +179 -0
- package/SECURITY.md +39 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +2166 -0
- package/lib/index.js +11621 -0
- package/lib/invariant.js +453 -0
- package/lib/types/agent-preset-ids.d.ts +276 -0
- package/lib/types/client/LoopEngineBadge.d.ts +71 -0
- package/lib/types/client/LoopEngineComposerSelect.d.ts +126 -0
- package/lib/types/client/LoopEngineSection.d.ts +35 -0
- package/lib/types/client/engine-marks.d.ts +87 -0
- package/lib/types/client/index.d.ts +39 -0
- package/lib/types/client/locales.d.ts +182 -0
- package/lib/types/client/reload.d.ts +135 -0
- package/lib/types/client/session-engine.d.ts +508 -0
- package/lib/types/client/store.d.ts +103 -0
- package/lib/types/client/turn-status.d.ts +234 -0
- package/lib/types/client/use-session-engine.d.ts +74 -0
- package/lib/types/commands.d.ts +77 -0
- package/lib/types/compat.d.ts +25 -0
- package/lib/types/driver-acp/agent.d.ts +289 -0
- package/lib/types/driver-acp/approval.d.ts +27 -0
- package/lib/types/driver-acp/capabilities.d.ts +200 -0
- package/lib/types/driver-acp/client.d.ts +297 -0
- package/lib/types/driver-acp/executable.d.ts +53 -0
- package/lib/types/driver-acp/mapping.d.ts +76 -0
- package/lib/types/driver-acp/profile.d.ts +126 -0
- package/lib/types/driver-acp/runtime.d.ts +45 -0
- package/lib/types/driver-acp/subprocess.d.ts +19 -0
- package/lib/types/driver-acp/terminal.d.ts +98 -0
- package/lib/types/driver-acp/transport.d.ts +43 -0
- package/lib/types/driver-acp/types.d.ts +152 -0
- package/lib/types/driver-cli/capability.d.ts +42 -0
- package/lib/types/driver-cli/cli-agent.d.ts +258 -0
- package/lib/types/driver-cli/cli-loop.d.ts +46 -0
- package/lib/types/driver-cli/flatten.d.ts +35 -0
- package/lib/types/driver-cli/frames.d.ts +128 -0
- package/lib/types/driver-cli/ndjson.d.ts +106 -0
- package/lib/types/driver-cli/session-sink.d.ts +333 -0
- package/lib/types/driver-cli/stream-json.d.ts +61 -0
- package/lib/types/driver-cli/text.d.ts +66 -0
- package/lib/types/driver-cli/transport.d.ts +84 -0
- package/lib/types/driver-core/agents-md-skill-provider.d.ts +72 -0
- package/lib/types/driver-core/assistant-stream.d.ts +68 -0
- package/lib/types/driver-core/context-files.d.ts +62 -0
- package/lib/types/driver-core/host-servers.d.ts +119 -0
- package/lib/types/driver-core/hosted-engine-runtime.d.ts +190 -0
- package/lib/types/driver-core/hosted-tool-vocabulary.d.ts +78 -0
- package/lib/types/driver-core/idle-child.d.ts +57 -0
- package/lib/types/driver-core/image-access.d.ts +25 -0
- package/lib/types/driver-core/inbox.d.ts +104 -0
- package/lib/types/driver-core/model-handover.d.ts +134 -0
- package/lib/types/driver-core/ownership.d.ts +41 -0
- package/lib/types/driver-core/permission-knobs.d.ts +26 -0
- package/lib/types/driver-core/prompt.d.ts +64 -0
- package/lib/types/driver-core/session-lifetime.d.ts +62 -0
- package/lib/types/driver-core/session-model.d.ts +128 -0
- package/lib/types/driver-core/skill-inject.d.ts +59 -0
- package/lib/types/driver-core/step-close.d.ts +49 -0
- package/lib/types/driver-core/step-images.d.ts +62 -0
- package/lib/types/driver-core/step-tools.d.ts +43 -0
- package/lib/types/driver-core/system-head.d.ts +43 -0
- package/lib/types/engine-agy/agent.d.ts +67 -0
- package/lib/types/engine-agy/frames.d.ts +90 -0
- package/lib/types/engine-agy/loop.d.ts +64 -0
- package/lib/types/engine-agy/process.d.ts +173 -0
- package/lib/types/engine-claude/agent.d.ts +186 -0
- package/lib/types/engine-claude/loop.d.ts +73 -0
- package/lib/types/engine-claude/mapping.d.ts +108 -0
- package/lib/types/engine-claude/permission.d.ts +41 -0
- package/lib/types/engine-claude/process.d.ts +59 -0
- package/lib/types/engine-claude/sdk.d.ts +67 -0
- package/lib/types/engine-claude/types.d.ts +28 -0
- package/lib/types/engine-codex/agent.d.ts +216 -0
- package/lib/types/engine-codex/appserver/client.d.ts +80 -0
- package/lib/types/engine-codex/appserver/mapping.d.ts +67 -0
- package/lib/types/engine-codex/appserver/thread.d.ts +66 -0
- package/lib/types/engine-codex/appserver/types.d.ts +225 -0
- package/lib/types/engine-codex/loop.d.ts +75 -0
- package/lib/types/engine-codex/model-handover.d.ts +56 -0
- package/lib/types/engine-codex/permission.d.ts +126 -0
- package/lib/types/engine-codex/skills.d.ts +28 -0
- package/lib/types/engine-codex/types.d.ts +36 -0
- package/lib/types/engine-drivers.d.ts +132 -0
- package/lib/types/engine-grok/agent.d.ts +24 -0
- package/lib/types/engine-grok/loop.d.ts +61 -0
- package/lib/types/engine-grok/process.d.ts +46 -0
- package/lib/types/engine-grok/profile.d.ts +82 -0
- package/lib/types/engine-hermes/agent.d.ts +47 -0
- package/lib/types/engine-hermes/loop.d.ts +56 -0
- package/lib/types/engine-hermes/process.d.ts +92 -0
- package/lib/types/engine-kimi/acp/client.d.ts +123 -0
- package/lib/types/engine-kimi/acp/mapping.d.ts +73 -0
- package/lib/types/engine-kimi/acp/types.d.ts +143 -0
- package/lib/types/engine-kimi/agent.d.ts +24 -0
- package/lib/types/engine-kimi/commands.d.ts +44 -0
- package/lib/types/engine-kimi/loop.d.ts +62 -0
- package/lib/types/engine-kimi/model-handover.d.ts +32 -0
- package/lib/types/engine-kimi/permission.d.ts +28 -0
- package/lib/types/engine-kimi/process.d.ts +47 -0
- package/lib/types/engine-kimi/profile.d.ts +19 -0
- package/lib/types/engine-kimi/skills.d.ts +52 -0
- package/lib/types/engine-kimi/types.d.ts +25 -0
- package/lib/types/engine-minimaxcode/agent.d.ts +24 -0
- package/lib/types/engine-minimaxcode/loop.d.ts +83 -0
- package/lib/types/engine-minimaxcode/process.d.ts +53 -0
- package/lib/types/engine-minimaxcode/profile.d.ts +72 -0
- package/lib/types/engine-of-session.d.ts +97 -0
- package/lib/types/engine-pi/agent.d.ts +230 -0
- package/lib/types/engine-pi/loop.d.ts +72 -0
- package/lib/types/engine-pi/model-handover.d.ts +84 -0
- package/lib/types/engine-pi/permission.d.ts +47 -0
- package/lib/types/engine-pi/rpc/client.d.ts +107 -0
- package/lib/types/engine-pi/rpc/mapping.d.ts +37 -0
- package/lib/types/engine-pi/rpc/types.d.ts +249 -0
- package/lib/types/engine-pi/skills.d.ts +47 -0
- package/lib/types/engine-pi/types.d.ts +36 -0
- package/lib/types/engine-qoderclicn/agent.d.ts +59 -0
- package/lib/types/engine-qoderclicn/loop.d.ts +51 -0
- package/lib/types/engine-qoderclicn/process.d.ts +113 -0
- package/lib/types/engine-registry.d.ts +584 -0
- package/lib/types/engine-remote.d.ts +192 -0
- package/lib/types/engine-surface.d.ts +36 -0
- package/lib/types/engine-zcode/agent.d.ts +50 -0
- package/lib/types/engine-zcode/loop.d.ts +47 -0
- package/lib/types/engine-zcode/process.d.ts +111 -0
- package/lib/types/index.d.ts +205 -0
- package/lib/types/invariant.d.ts +26 -0
- package/lib/types/model-selection-reset.d.ts +271 -0
- package/lib/types/namespace.d.ts +25 -0
- package/lib/types/patch-manager.d.ts +104 -0
- package/lib/types/preset.d.ts +254 -0
- package/lib/types/provider-route.d.ts +245 -0
- package/lib/types/router-loop.d.ts +458 -0
- package/lib/types/session-engine-store.d.ts +138 -0
- package/lib/types/settings.d.ts +60 -0
- package/lib/types/skills.d.ts +85 -0
- package/package.json +152 -6
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Antigravity (`agy`) CLI process projection.
|
|
3
|
+
*
|
|
4
|
+
* `agy` is the Antigravity CLI. Its non-interactive surface is a `--print` mode
|
|
5
|
+
* with an explicit INPUT format and OUTPUT format; the combination this driver
|
|
6
|
+
* uses is the streaming-NDJSON one, because it is the only shape that carries a
|
|
7
|
+
* machine-readable verdict:
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* agy --input-format stream-json --output-format stream-json --print=<prompt-arg>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* with the prompt itself written to stdin as one NDJSON line, and `--print=`
|
|
14
|
+
* given an EMPTY value. That last detail is not cosmetic — it is a real trap
|
|
15
|
+
* recorded in `docs/probes/agy.md`: `--print` takes an OPTIONAL value, so
|
|
16
|
+
* `agy --input-format stream-json --print` makes `--input-format` the prompt and
|
|
17
|
+
* the intended prompt is silently ignored (the CLI says so on stderr). Attaching
|
|
18
|
+
* an empty value (`--print=`) pins the flag's argument and leaves the rest of the
|
|
19
|
+
* command line alone.
|
|
20
|
+
*
|
|
21
|
+
* ## Verified against a signed-in host
|
|
22
|
+
*
|
|
23
|
+
* The first probe run could not get past
|
|
24
|
+
* `{"event":"result","result":{"status":"ERROR","error":"authentication failed or
|
|
25
|
+
* timed out"}}` — the host's Google credential had expired — so the streaming
|
|
26
|
+
* vocabulary was recorded as UNKNOWN rather than guessed. Re-probing after the
|
|
27
|
+
* host signed in produced the whole protocol (`docs/probes/agy.md`, raw captures
|
|
28
|
+
* with `scripts/probe/probe.mjs agy`), and this module and `./frames.ts` are written
|
|
29
|
+
* against it. The three findings that shape the code:
|
|
30
|
+
*
|
|
31
|
+
* 1. **`--print` takes an OPTIONAL value**, so a bare `--print` makes the NEXT
|
|
32
|
+
* flag the prompt and silently ignores the real one (the CLI says so on
|
|
33
|
+
* stderr after the fact). Attaching an empty value (`--print=`) pins it.
|
|
34
|
+
* 2. **The stdin message needs an `event` field**: one NDJSON line of
|
|
35
|
+
* `{"event":"user","message":{"role":"user","content":[…blocks…]}}`. Without
|
|
36
|
+
* it the CLI answers
|
|
37
|
+
* `error: stream input message is missing the "event" field`; an event it does
|
|
38
|
+
* not know is only a warning and is ignored.
|
|
39
|
+
* 3. **Headless mode cannot prompt, so a tool that needs permission is
|
|
40
|
+
* AUTO-DENIED** (`permission_mode: "request-review"` at `init`), and the turn
|
|
41
|
+
* ends with the CLI's own explanation. `--dangerously-skip-permissions` is
|
|
42
|
+
* what switches it to `permission_mode: "always-proceed"`. `--mode` does NOT
|
|
43
|
+
* affect this — `accept-edits` and `plan` both leave `request-review` — so the
|
|
44
|
+
* dsh sandbox knob is mapped to exactly that one flag (see
|
|
45
|
+
* {@link agyDangerouslySkipPermissions}).
|
|
46
|
+
*
|
|
47
|
+
* @module dsh-loop-engine-allinone/engine-agy/process
|
|
48
|
+
*/
|
|
49
|
+
import type { DshSandboxMode } from '../driver-core/permission-knobs.ts';
|
|
50
|
+
import type { CliSpawnRequest } from '../driver-cli/transport.ts';
|
|
51
|
+
/** Grace in milliseconds for Antigravity process-tree termination. */
|
|
52
|
+
export declare const AGY_DISPOSE_GRACE_MS = 3000;
|
|
53
|
+
/** The `--mode` values the CLI accepts for a session's execution mode. */
|
|
54
|
+
export declare const AGY_MODES: readonly ["accept-edits", "auto", "plan"];
|
|
55
|
+
/** One Antigravity execution mode. */
|
|
56
|
+
export type AgyMode = (typeof AGY_MODES)[number];
|
|
57
|
+
/** The `--effort` values the CLI accepts. */
|
|
58
|
+
export declare const AGY_EFFORTS: readonly ["low", "medium", "high", "xhigh", "max"];
|
|
59
|
+
/** One Antigravity reasoning effort. */
|
|
60
|
+
export type AgyEffort = (typeof AGY_EFFORTS)[number];
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the `agy` executable.
|
|
63
|
+
*
|
|
64
|
+
* Antigravity installs into the user's local application data under `agy/bin`.
|
|
65
|
+
* `LOCALAPPDATA` is consulted rather than a hardcoded home so the same code is
|
|
66
|
+
* right for a profile running under a different user; PATH is the last resort.
|
|
67
|
+
* @param configBin - an operator-pinned path, if any.
|
|
68
|
+
* @returns the executable to spawn as `argv[0]`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function agyBinResolver(configBin?: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the host has an Antigravity credential file on disk.
|
|
73
|
+
*
|
|
74
|
+
* A HINT for the settings page, never a gate: Antigravity owns its credentials,
|
|
75
|
+
* the plugin only reports whether a login has happened at least once. A missing
|
|
76
|
+
* file means "never signed in here"; a PRESENT file can still be expired, which
|
|
77
|
+
* is exactly the state this machine was in when the probe ran, so the file's
|
|
78
|
+
* existence must not be read as "ready".
|
|
79
|
+
* @param home - the user's home directory.
|
|
80
|
+
* @returns whether the credential file exists.
|
|
81
|
+
*/
|
|
82
|
+
export declare function agyCredentialPresent(home: string): boolean;
|
|
83
|
+
/** Everything one step's Antigravity child needs. */
|
|
84
|
+
export interface AgySpawnSpec {
|
|
85
|
+
/** The resolved executable (`argv[0]`). */
|
|
86
|
+
readonly bin: string;
|
|
87
|
+
/** The prompt text; written to stdin as one NDJSON user message. */
|
|
88
|
+
readonly prompt: string;
|
|
89
|
+
/** The session's working directory. */
|
|
90
|
+
readonly cwd: string;
|
|
91
|
+
/** Explicit environment entries layered over the scrubbed parent environment. */
|
|
92
|
+
readonly env: Record<string, string>;
|
|
93
|
+
/** Pinned model (`--model`). */
|
|
94
|
+
readonly model: string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Pinned execution mode (`--mode`), when the deployment named one.
|
|
97
|
+
*
|
|
98
|
+
* Optional with no default ON PURPOSE, and that is a finding rather than a
|
|
99
|
+
* shrug: `--mode auto` was observed to be refused for the probe host's account
|
|
100
|
+
* ("not available for this account; continuing in the default mode"), so the
|
|
101
|
+
* set of modes a given account accepts is not knowable ahead of time. Omitting
|
|
102
|
+
* the flag lets the CLI use its own default instead of warning on every step.
|
|
103
|
+
*/
|
|
104
|
+
readonly mode: AgyMode | undefined;
|
|
105
|
+
/** Pinned reasoning effort (`--effort`). */
|
|
106
|
+
readonly effort: AgyEffort | undefined;
|
|
107
|
+
/** Whether to run the child with terminal restrictions (`--sandbox`). */
|
|
108
|
+
readonly sandbox: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether to auto-approve every tool (`--dangerously-skip-permissions`).
|
|
111
|
+
*
|
|
112
|
+
* The ONLY switch that makes tools run headless: without it the CLI reports
|
|
113
|
+
* `permission_mode: "request-review"` and denies anything that would have
|
|
114
|
+
* prompted. Mapped from the dsh sandbox knob by
|
|
115
|
+
* {@link agyDangerouslySkipPermissions}.
|
|
116
|
+
*/
|
|
117
|
+
readonly dangerouslySkipPermissions: boolean;
|
|
118
|
+
/** Cancellation. */
|
|
119
|
+
readonly signal: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Build the argv for one non-interactive Antigravity step.
|
|
123
|
+
*
|
|
124
|
+
* `--print=` carries an EMPTY value on purpose (see the module note): the flag
|
|
125
|
+
* takes an optional argument, so leaving it bare swallows the NEXT flag as the
|
|
126
|
+
* prompt.
|
|
127
|
+
* @param spec - the step's spawn spec.
|
|
128
|
+
* @returns the argv.
|
|
129
|
+
*/
|
|
130
|
+
export declare function agyArgv(spec: AgySpawnSpec): string[];
|
|
131
|
+
/**
|
|
132
|
+
* Project one step's prompt onto the CLI's stdin wire shape.
|
|
133
|
+
*
|
|
134
|
+
* One NDJSON document per line, of which the driver writes exactly one. The
|
|
135
|
+
* `event` member is REQUIRED — it is the discriminator the CLI reads, and its
|
|
136
|
+
* absence is answered with
|
|
137
|
+
* `error: stream input message is missing the "event" field`. An event the CLI
|
|
138
|
+
* does not know is only a warning (`warning: ignoring unsupported stream input
|
|
139
|
+
* message event "message"`) and is ignored, so a future input kind cannot break
|
|
140
|
+
* a working driver. Verified shape:
|
|
141
|
+
* `{"event":"user","message":{"role":"user","content":[{"type":"text","text":"…"}]}}`.
|
|
142
|
+
* @param prompt - the prompt text.
|
|
143
|
+
* @returns the stdin payload, newline-terminated.
|
|
144
|
+
*/
|
|
145
|
+
export declare function agyStdinPrompt(prompt: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* Map the session's dsh sandbox knob onto Antigravity's permission switch.
|
|
148
|
+
*
|
|
149
|
+
* There is exactly one switch, and it is all-or-nothing. Headless Antigravity
|
|
150
|
+
* runs at `permission_mode: "request-review"` and AUTO-DENIES any tool that would
|
|
151
|
+
* have prompted — the CLI's own words being `a tool required the "command"
|
|
152
|
+
* permission that headless mode cannot prompt for, so it was auto-denied` —
|
|
153
|
+
* while `--dangerously-skip-permissions` moves it to `always-proceed`.
|
|
154
|
+
*
|
|
155
|
+
* So full access is the only knob that earns the flag. Everything else, including
|
|
156
|
+
* "no knobs at all", fails closed and leaves the subprocess sandbox as the
|
|
157
|
+
* boundary.
|
|
158
|
+
*
|
|
159
|
+
* `--mode` is deliberately NOT consulted here: it was verified to leave
|
|
160
|
+
* `permission_mode` at `request-review` for BOTH `accept-edits` and `plan`, so it
|
|
161
|
+
* is an execution mode rather than a permission switch, and using it as one would
|
|
162
|
+
* be a guess dressed up as a mapping.
|
|
163
|
+
* @param sandbox - the session's durable sandbox mode, if any.
|
|
164
|
+
* @returns whether to pass `--dangerously-skip-permissions`.
|
|
165
|
+
*/
|
|
166
|
+
export declare function agyDangerouslySkipPermissions(sandbox: DshSandboxMode | undefined): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Project one step's spawn spec onto the transport request.
|
|
169
|
+
* @param spec - the step's spawn spec.
|
|
170
|
+
* @returns the transport's request shape.
|
|
171
|
+
*/
|
|
172
|
+
export declare function agySpawnRequest(spec: AgySpawnSpec): CliSpawnRequest;
|
|
173
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code loop Agent: drives one session through turn and step boundaries
|
|
3
|
+
* with one Claude Agent SDK query per step. Claude Code owns its prompt,
|
|
4
|
+
* tools, and permissions; the durable session log remains the source of truth
|
|
5
|
+
* and the query prompt is a pure serialization of it.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-loop-engine-allinone/engine-claude/agent
|
|
8
|
+
*/
|
|
9
|
+
import type { Agent, AgentCancelCause, AgentOptions, AgentStatus, CancelOptions, InboxTarget } from '@deepseek-ai/dsh-agent';
|
|
10
|
+
import type { Scope } from '@deepseek-ai/dsh-scope';
|
|
11
|
+
import type { Session, SessionId, UserMessage } from '@deepseek-ai/dsh-session';
|
|
12
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
+
import type { ResolvedConfig } from './types.ts';
|
|
14
|
+
import { DriverInbox } from '../driver-core/inbox.ts';
|
|
15
|
+
import { type SpawnCapability } from './sdk.ts';
|
|
16
|
+
/**
|
|
17
|
+
* Provider route label this driver logs into request/header snapshots and
|
|
18
|
+
* message provenance — the ONE route every hosted engine shares
|
|
19
|
+
* ({@link HOSTED_ROUTE_LABEL}), so all four engines select `external/default`
|
|
20
|
+
* and the model menu carries a single group instead of one per engine.
|
|
21
|
+
*/
|
|
22
|
+
export declare const PROVIDER = "external";
|
|
23
|
+
/** Drives one session through turn and step boundaries on Claude Code. */
|
|
24
|
+
export declare class ClaudeCodeAgent implements Agent {
|
|
25
|
+
private loopCtx;
|
|
26
|
+
readonly id: SessionId;
|
|
27
|
+
readonly options: AgentOptions;
|
|
28
|
+
readonly session: Session;
|
|
29
|
+
private readonly config;
|
|
30
|
+
/**
|
|
31
|
+
* Process-spawn capability handed down from the engine, which resolves it
|
|
32
|
+
* from the host's subprocess service. Held as a capability rather than read
|
|
33
|
+
* off the context because a service PROPERTY read requires the reading
|
|
34
|
+
* fiber to have injected it, and this agent's context is the engine's.
|
|
35
|
+
*/
|
|
36
|
+
private readonly spawn;
|
|
37
|
+
readonly inbox: DriverInbox;
|
|
38
|
+
private phase;
|
|
39
|
+
private activityDone;
|
|
40
|
+
/** The agent-scoped registration boundary; the lifecycle owner unwinds it after the driver exits. */
|
|
41
|
+
readonly scope: Scope;
|
|
42
|
+
readonly ctx: Context;
|
|
43
|
+
/** Fused dispatcher, built once in the constructor so hot-path dispatches never allocate. */
|
|
44
|
+
private readonly dispatch;
|
|
45
|
+
/** Whether this loop instance has appended its initial/resume request anchor. */
|
|
46
|
+
private requestHeaderLogged;
|
|
47
|
+
/** Agent-lifecycle-local counter naming each streamed attempt. */
|
|
48
|
+
private streamAttempts;
|
|
49
|
+
/**
|
|
50
|
+
* Tool results logged into the currently open step. A result means the
|
|
51
|
+
* segment that requested the call is finished, so the next assistant content
|
|
52
|
+
* opens the next step (see {@link beginSegment}).
|
|
53
|
+
*/
|
|
54
|
+
private stepSettledTools;
|
|
55
|
+
/**
|
|
56
|
+
* The current step's calls, and which of them already carry a result.
|
|
57
|
+
*
|
|
58
|
+
* Two facts, both of them load-bearing for Session V4:
|
|
59
|
+
*
|
|
60
|
+
* - a call must not be given a SECOND result in one step. The Claude Agent
|
|
61
|
+
* SDK delivers the same tool result in two `user` messages ~57 ms apart,
|
|
62
|
+
* and V4 keys its pending-tool map by call id alone — it deletes the call
|
|
63
|
+
* on the first result, so a repeat is refused (`tool/result <id> has no
|
|
64
|
+
* advertised tool lifecycle`) and the whole session log fails to load;
|
|
65
|
+
* - a step must not END while a call it announced has no result at all
|
|
66
|
+
* (`step/end leaves unresolved tool call <id>`). An engine that announces
|
|
67
|
+
* several calls in one model turn and reports fewer outcomes leaves the
|
|
68
|
+
* step unbalanced, so the closing pass writes the missing outcomes.
|
|
69
|
+
*
|
|
70
|
+
* Reset per step (see {@link step}), never on an internal segment rotation:
|
|
71
|
+
* call ids are unique for the life of the session, so retaining the marks
|
|
72
|
+
* only widens duplicate suppression and can never hide a legitimate result.
|
|
73
|
+
*/
|
|
74
|
+
private readonly stepTools;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the current query has rotated into a second step. The query-total
|
|
77
|
+
* usage record is only meaningful while one step holds the whole query.
|
|
78
|
+
*/
|
|
79
|
+
private rotated;
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the read-only path behind each image block of the prompt. The
|
|
82
|
+
* attachment service is read lazily on every call, so a host that composes it
|
|
83
|
+
* after this agent still reaches the transcript.
|
|
84
|
+
*/
|
|
85
|
+
private readonly imageAccess;
|
|
86
|
+
constructor(loopCtx: Context, id: SessionId, options: AgentOptions, session: Session, config: ResolvedConfig,
|
|
87
|
+
/**
|
|
88
|
+
* Process-spawn capability handed down from the engine, which resolves it
|
|
89
|
+
* from the host's subprocess service. Held as a capability rather than read
|
|
90
|
+
* off the context because a service PROPERTY read requires the reading
|
|
91
|
+
* fiber to have injected it, and this agent's context is the engine's.
|
|
92
|
+
*/
|
|
93
|
+
spawn: SpawnCapability);
|
|
94
|
+
get status(): AgentStatus;
|
|
95
|
+
/** Commit a phase and publish its externally visible status transition. */
|
|
96
|
+
private setPhase;
|
|
97
|
+
send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;
|
|
98
|
+
/**
|
|
99
|
+
* Queue a message for the next turn and wake the driver.
|
|
100
|
+
* @param input - the user message to deliver.
|
|
101
|
+
*/
|
|
102
|
+
followup(input: UserMessage): void;
|
|
103
|
+
/**
|
|
104
|
+
* Queue a message for the running step and wake the driver.
|
|
105
|
+
* @param input - the user message to deliver.
|
|
106
|
+
*/
|
|
107
|
+
steer(input: UserMessage): void;
|
|
108
|
+
/**
|
|
109
|
+
* Queue a message for the running step without waking the driver.
|
|
110
|
+
* @param input - the user message to deliver.
|
|
111
|
+
*/
|
|
112
|
+
inject(input: UserMessage): void;
|
|
113
|
+
cancel(cause: AgentCancelCause, options?: CancelOptions): void;
|
|
114
|
+
/**
|
|
115
|
+
* Run a maintenance job while the agent is idle.
|
|
116
|
+
* @param job - the maintenance operation, receiving the phase abort signal.
|
|
117
|
+
* @returns the maintenance result.
|
|
118
|
+
*/
|
|
119
|
+
runMaintenance<T>(job: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Start one driver, or latch its wake behind maintenance or an aborted
|
|
122
|
+
* activity. A wake sent while idle always opens its turn boundary, even
|
|
123
|
+
* when its message was cleared; only a latched replay is suppressed when
|
|
124
|
+
* the queue no longer holds the wake.
|
|
125
|
+
* @param wakeAfterAbort - the {@link send} classification, captured before
|
|
126
|
+
* the inbox insertion so a reentrant cancel cannot reclassify it.
|
|
127
|
+
*/
|
|
128
|
+
private wakeDriver;
|
|
129
|
+
whenIdle(): Promise<void>;
|
|
130
|
+
/** Report one failure at its live boundary, then preserve it for driver containment. */
|
|
131
|
+
private throwError;
|
|
132
|
+
private kick;
|
|
133
|
+
private preStep;
|
|
134
|
+
/**
|
|
135
|
+
* Scan the step's user messages for `/name` skill gestures, load each
|
|
136
|
+
* matching skill, and inject the rendered skill content into the message
|
|
137
|
+
* batch. This mirrors what dsh-tool-skill does for the in-process engine.
|
|
138
|
+
* @param messages - the current step's message batch.
|
|
139
|
+
* @param signal - cancellation signal (aborted loads are silently dropped).
|
|
140
|
+
* @returns the original batch when no skill was invoked, or an extended
|
|
141
|
+
* batch with injected skill-content messages appended.
|
|
142
|
+
*/
|
|
143
|
+
private injectSkills;
|
|
144
|
+
/**
|
|
145
|
+
* Resolve the native permission handling for one query. A deployment-pinned
|
|
146
|
+
* mode wins outright; otherwise the session's durable dsh permission knobs
|
|
147
|
+
* decide per query (mid-session preset switches included): full access
|
|
148
|
+
* bypasses native checks, an `ask` policy forwards each native permission
|
|
149
|
+
* request to the dsh approval seam, and anything else fails closed with the
|
|
150
|
+
* unattended deny-all stance.
|
|
151
|
+
* @returns the permission fields of the query spec.
|
|
152
|
+
*/
|
|
153
|
+
private queryPermission;
|
|
154
|
+
/** Open one turn before claiming its first proposed step. */
|
|
155
|
+
private turn;
|
|
156
|
+
/**
|
|
157
|
+
* Rotate to the next step when the segment that ran a tool has finished, so
|
|
158
|
+
* each assistant segment lands in its own step.
|
|
159
|
+
*
|
|
160
|
+
* Called as new assistant content begins. A step holding a settled tool
|
|
161
|
+
* result means the previous segment is complete, and the content about to be
|
|
162
|
+
* written belongs to the next one. Rotating here (rather than when a call is
|
|
163
|
+
* announced) keeps calls announced together — one model turn — in one step.
|
|
164
|
+
*
|
|
165
|
+
* A step that still OWES a result does not rotate: an engine that announces
|
|
166
|
+
* several calls in one turn reports their outcomes one at a time, and rotating
|
|
167
|
+
* on the first one would strand the rest in a step that can never resolve them
|
|
168
|
+
* (`step/end leaves unresolved tool call …`). Those calls run one model turn
|
|
169
|
+
* later instead, which is what they belong to, and a call the engine never
|
|
170
|
+
* answers is closed by {@link closeStep} rather than by moving on.
|
|
171
|
+
* @param phase - the running phase carrying the open step's position.
|
|
172
|
+
*/
|
|
173
|
+
private beginSegment;
|
|
174
|
+
/** Model label recorded in the request header for one lifecycle. */
|
|
175
|
+
private modelLabel;
|
|
176
|
+
/** Append the request header snapshot once per loop instance. */
|
|
177
|
+
private assertRequestHeader;
|
|
178
|
+
/**
|
|
179
|
+
* Run one Claude Code query for the current step and map its transcript into
|
|
180
|
+
* the session log.
|
|
181
|
+
* @param messages - the messages this step delivers; only their images ride
|
|
182
|
+
* with the prompt as bytes, and only they.
|
|
183
|
+
*/
|
|
184
|
+
private step;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code loop engine module: drives every session it is handed through
|
|
3
|
+
* the official Claude Agent SDK, one stateless query per dsh step, with the
|
|
4
|
+
* durable session log as the sole source of model context. The router routes a
|
|
5
|
+
* session here on the plugin's own engine record, else its recorded agent
|
|
6
|
+
* preset; this module is a library, not a Cordis plugin entry.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-loop-engine-allinone/engine-claude
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import z from '@deepseek-ai/schemastery';
|
|
12
|
+
import type { AgentOptions } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
import type { Session, SessionId } from '@deepseek-ai/dsh-session';
|
|
14
|
+
import { ClaudeCodeAgent } from './agent.ts';
|
|
15
|
+
import { type SpawnCapability } from './sdk.ts';
|
|
16
|
+
import type { ClaudeCodePermissionMode, ResolvedConfig } from './types.ts';
|
|
17
|
+
import { HostedEngineRuntime } from '../driver-core/hosted-engine-runtime.ts';
|
|
18
|
+
/** Deployment-selectable non-interactive Claude Code permission modes. */
|
|
19
|
+
export declare const CLAUDE_CODE_PERMISSION_MODES: readonly ClaudeCodePermissionMode[];
|
|
20
|
+
/** Deployment-owned configuration for the Claude Code loop plugin. */
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Native non-interactive permission handling for every query. When omitted,
|
|
24
|
+
* each query follows the session's dsh permission knobs (`sandbox/mode` and
|
|
25
|
+
* `approval/policy`): full access bypasses native checks, an `ask` policy
|
|
26
|
+
* forwards requests to the dsh approval seam, and anything else auto-denies.
|
|
27
|
+
* A pinned mode overrides the session for every query: `dontAsk` auto-denies,
|
|
28
|
+
* `acceptEdits` accepts edits, `auto` uses the native classifier, `plan`
|
|
29
|
+
* returns a plan without approving execution, and `bypassPermissions`
|
|
30
|
+
* explicitly skips permission checks.
|
|
31
|
+
*/
|
|
32
|
+
permissionMode?: ClaudeCodePermissionMode;
|
|
33
|
+
/** Explicit environment entries layered over the credential-scrubbed parent environment. */
|
|
34
|
+
env?: Record<string, string>;
|
|
35
|
+
/** Model passed to each query (`Options.model`, overridden by the session's own pick); also the request-header label. Claude Code native settings own the model when omitted. */
|
|
36
|
+
model?: string;
|
|
37
|
+
/** Grace in milliseconds for Claude Code process-tree termination. */
|
|
38
|
+
disposeGraceMs?: number;
|
|
39
|
+
/** Cap on the number of conversation turns before each query stops. */
|
|
40
|
+
maxTurns?: number;
|
|
41
|
+
/**
|
|
42
|
+
* An EXTERNAL Claude Code executable to run instead of the SDK's bundled one.
|
|
43
|
+
*
|
|
44
|
+
* Unbinding the SDK is a supported SDK option (`pathToClaudeCodeExecutable`),
|
|
45
|
+
* not a hack: it lets a deployment run its own signed-in `claude` install —
|
|
46
|
+
* including one whose credentials the bundled copy would not see. Omitted
|
|
47
|
+
* keeps the bundled binary and its own login directory, which is the
|
|
48
|
+
* behaviour every earlier release had.
|
|
49
|
+
*/
|
|
50
|
+
bin?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Schema of the Claude Code loop plugin configuration. */
|
|
53
|
+
export declare const Config: z<Config>;
|
|
54
|
+
/** Host-face ctx key this engine's runtime is registered under. */
|
|
55
|
+
export declare const CLAUDE_CODE_ENGINE_LABEL = "agentLoopClaudeCode";
|
|
56
|
+
declare module '@deepseek-ai/cordis' {
|
|
57
|
+
interface Context {
|
|
58
|
+
agentLoopClaudeCode: ClaudeCodeLoop;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creation/resume machinery for the Claude Code engine. The process-wide
|
|
63
|
+
* AgentFactory slot belongs to the router, which delegates each session to the
|
|
64
|
+
* engine its preset names; this class is that engine's driver, not a plugin.
|
|
65
|
+
*/
|
|
66
|
+
export declare class ClaudeCodeLoop extends HostedEngineRuntime<ResolvedConfig, ClaudeCodeAgent> {
|
|
67
|
+
/** Process-spawn capability handed to every agent, sandboxed by the subprocess seam. */
|
|
68
|
+
readonly spawn: SpawnCapability;
|
|
69
|
+
constructor(ctx: Context, config: Config);
|
|
70
|
+
/** Construct the Claude Code driver for one prepared session. */
|
|
71
|
+
protected buildAgent(loopCtx: Context, id: SessionId, options: AgentOptions, session: Session): ClaudeCodeAgent;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure translation from the Claude Agent SDK's message vocabulary to the dsh
|
|
3
|
+
* session-log vocabulary. Each function maps one SDK message to the durable
|
|
4
|
+
* event payloads the driver appends inside its current step, so the mapping
|
|
5
|
+
* stays unit-testable without any SDK process.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-loop-engine-allinone/engine-claude/mapping
|
|
8
|
+
*/
|
|
9
|
+
import type { BetaMessage, BetaRawMessageStreamEvent } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
|
|
10
|
+
import type { MessageParam } from '@anthropic-ai/sdk/resources';
|
|
11
|
+
import { ToolCallId, type ContentBlock, type StreamChunk, type TokenUsage, type ToolResultMessage } from '@deepseek-ai/dsh-llm';
|
|
12
|
+
/** One tool invocation surfaced from a Claude Code assistant message. */
|
|
13
|
+
export interface MappedToolCall {
|
|
14
|
+
/** SDK tool_use id, reused as the dsh call-id so results pair. */
|
|
15
|
+
readonly callId: ToolCallId;
|
|
16
|
+
/** Tool name exactly as the SDK reported it. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Raw JSON arguments string as the SDK produced them. */
|
|
19
|
+
readonly arguments: string;
|
|
20
|
+
}
|
|
21
|
+
/** Result of translating one SDK assistant message. */
|
|
22
|
+
export interface MappedAssistantMessage {
|
|
23
|
+
/** dsh content blocks: text verbatim, tool calls as tool-call blocks. */
|
|
24
|
+
readonly content: ContentBlock[];
|
|
25
|
+
/** Tool invocations surfaced as dsh tool/call events. */
|
|
26
|
+
readonly toolCalls: readonly MappedToolCall[];
|
|
27
|
+
/** Provider-reported token accounting, when present. */
|
|
28
|
+
readonly usage: TokenUsage | undefined;
|
|
29
|
+
/** Model id reported by the SDK message. */
|
|
30
|
+
readonly model: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Render an SDK tool input as the raw JSON string carried by a dsh tool-call
|
|
34
|
+
* block. Values that cannot be stringified (undefined, functions, cyclic
|
|
35
|
+
* graphs) fall back to a stable placeholder instead of failing the mapping.
|
|
36
|
+
* @param input - the SDK tool input value.
|
|
37
|
+
* @returns the JSON string, or a placeholder when the input is not JSON-serializable.
|
|
38
|
+
*/
|
|
39
|
+
export declare function stringifyToolInput(input: unknown): string;
|
|
40
|
+
/**
|
|
41
|
+
* Translate one SDK assistant message into dsh content blocks and tool calls.
|
|
42
|
+
* Text blocks map verbatim; tool_use blocks map to tool-call blocks and
|
|
43
|
+
* surfaced calls; thinking blocks map to reasoning blocks; redacted-thinking
|
|
44
|
+
* and unknown blocks are dropped.
|
|
45
|
+
* @param message - the SDK assistant message.
|
|
46
|
+
* @returns the mapped content, calls, usage, and model.
|
|
47
|
+
*/
|
|
48
|
+
export declare function mapAssistantMessage(message: BetaMessage): MappedAssistantMessage;
|
|
49
|
+
/**
|
|
50
|
+
* Translate the tool_result blocks of one SDK user message into dsh
|
|
51
|
+
* tool-result messages. Non-tool_result blocks are ignored: Claude Code user
|
|
52
|
+
* messages inside a query carry only tool outcomes.
|
|
53
|
+
* @param message - the SDK user message.
|
|
54
|
+
* @returns the mapped tool-result messages, in block order.
|
|
55
|
+
*/
|
|
56
|
+
export declare function mapToolResults(message: MessageParam): ToolResultMessage[];
|
|
57
|
+
/**
|
|
58
|
+
* The counters {@link mapUsage} reads. The SDK reports these on an assistant
|
|
59
|
+
* message's `usage`, on a stream `message_delta`'s narrower usage, and on the
|
|
60
|
+
* query `result`'s totals, so the parameter is the common shape rather than any
|
|
61
|
+
* one of those types.
|
|
62
|
+
*/
|
|
63
|
+
export interface ReportedUsage {
|
|
64
|
+
readonly input_tokens: number | null;
|
|
65
|
+
readonly output_tokens: number | null;
|
|
66
|
+
readonly cache_read_input_tokens?: number | null;
|
|
67
|
+
readonly cache_creation_input_tokens?: number | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Translate SDK token accounting into the dsh token-usage shape. Cache
|
|
71
|
+
* breakpoints are optional; absent or null SDK counters stay absent.
|
|
72
|
+
* @param usage - SDK-reported usage for one assistant message, stream delta, or query result.
|
|
73
|
+
* @returns dsh token accounting, omitting absent optional counters.
|
|
74
|
+
*/
|
|
75
|
+
export declare function mapUsage(usage: ReportedUsage): TokenUsage;
|
|
76
|
+
/**
|
|
77
|
+
* Keep a usage sample only when it accounts for something.
|
|
78
|
+
*
|
|
79
|
+
* The SDK zero-fills `usage` on streamed assistant messages it cannot attribute
|
|
80
|
+
* (gateway-fronted models report the real counters on the stream's
|
|
81
|
+
* `message_delta` and the query's `result` instead). A sample with every bucket
|
|
82
|
+
* at zero is that placeholder, not a measurement: keeping it would both show an
|
|
83
|
+
* empty usage row and — because the token meter trusts a present sample over
|
|
84
|
+
* the stream — hide the real one.
|
|
85
|
+
* @param usage - a mapped usage sample, or undefined.
|
|
86
|
+
* @returns the sample when it is non-empty, otherwise undefined.
|
|
87
|
+
*/
|
|
88
|
+
export declare function meaningfulUsage(usage: TokenUsage | undefined): TokenUsage | undefined;
|
|
89
|
+
/** Per-block-index tool-call identity captured at `content_block_start`, reused by `input_json_delta`. */
|
|
90
|
+
export interface StreamToolCall {
|
|
91
|
+
readonly callId: ToolCallId;
|
|
92
|
+
readonly name: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Translate one SDK raw stream event into the dsh assistant chunks that drive
|
|
96
|
+
* the live partial projection. Text blocks yield `block-start`/`text-delta`;
|
|
97
|
+
* thinking blocks yield `block-start`/`reasoning-delta`; tool_use blocks yield
|
|
98
|
+
* `block-start`/`tool-call-delta`. Redacted thinking, signature deltas,
|
|
99
|
+
* `content_block_stop`, and transport events yield nothing — the durable
|
|
100
|
+
* `assistant/message` is appended separately from the SDK's complete message,
|
|
101
|
+
* so the streamed chunks never have to carry the whole block.
|
|
102
|
+
* @param event - one raw stream event from an `includePartialMessages` query.
|
|
103
|
+
* @param toolCalls - per-block-index tool identity, mutated here at a tool
|
|
104
|
+
* `content_block_start` so later `input_json_delta` can name the call.
|
|
105
|
+
* @returns the chunks that change the visible partial (empty for non-visual events).
|
|
106
|
+
*/
|
|
107
|
+
export declare function mapStreamEvent(event: BetaRawMessageStreamEvent, toolCalls: Map<number, StreamToolCall>): StreamChunk[];
|
|
108
|
+
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapping from the dsh session's durable permission knobs to one Claude Code
|
|
3
|
+
* query's native permission handling. The session log pins `sandbox/mode`
|
|
4
|
+
* and `approval/policy` events at creation and records every later switch;
|
|
5
|
+
* folding them per query keeps the Claude Code driver consistent with the
|
|
6
|
+
* permission preset the web surface shows, including mid-session switches.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-loop-engine-allinone/engine-claude/permission
|
|
9
|
+
*/
|
|
10
|
+
import type { PermissionEvent } from '../driver-core/permission-knobs.ts';
|
|
11
|
+
/**
|
|
12
|
+
* The effective native permission stance for one query:
|
|
13
|
+
* - `bypass` — full access: skip every native permission check.
|
|
14
|
+
* - `ask` — forward each native permission request to the dsh approval seam.
|
|
15
|
+
* - `deny` — auto-deny every native permission request (unattended default).
|
|
16
|
+
*/
|
|
17
|
+
export type SessionPermission = {
|
|
18
|
+
readonly kind: 'bypass';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'ask';
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'deny';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the session's effective native permission stance. Full access wins
|
|
26
|
+
* outright (the web "full" preset pins it together with `never`); otherwise
|
|
27
|
+
* an `ask` policy forwards permission requests to the dsh approval seam and
|
|
28
|
+
* anything else — including a session with no recorded knobs — fails closed.
|
|
29
|
+
* @param events - the durable session log.
|
|
30
|
+
* @returns the stance one query should run under.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveSessionPermission(events: readonly PermissionEvent[]): SessionPermission;
|
|
33
|
+
/**
|
|
34
|
+
* Human-readable explanation of WHY a native permission request is asked,
|
|
35
|
+
* carrying a bounded excerpt of the exact tool input.
|
|
36
|
+
* @param toolName - the native tool being decided.
|
|
37
|
+
* @param input - the exact tool input.
|
|
38
|
+
* @returns the approval request's reason text.
|
|
39
|
+
*/
|
|
40
|
+
export declare function approvalReason(toolName: string, input: Record<string, unknown>): string;
|
|
41
|
+
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection from the shared managed-process handle to the official Claude
|
|
3
|
+
* Agent SDK's custom-spawn process interface.
|
|
4
|
+
*
|
|
5
|
+
* @module dsh-loop-engine-allinone/engine-claude/process
|
|
6
|
+
*/
|
|
7
|
+
import type { SpawnedProcess, SpawnOptions } from '@anthropic-ai/claude-agent-sdk';
|
|
8
|
+
import { type SubprocessHandle, type SubprocessOutcome, type SubprocessSpawnSpec } from '@deepseek-ai/dsh-subprocess';
|
|
9
|
+
/**
|
|
10
|
+
* Encode the SDK's complete child environment as a subprocess overlay.
|
|
11
|
+
* @param env - SDK-composed child environment after its removals and replacements.
|
|
12
|
+
* @returns explicit values plus tombstones for surviving ambient names the SDK removed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sdkEnvironmentOverlay(env: SpawnOptions['env']): NodeJS.ProcessEnv;
|
|
15
|
+
/**
|
|
16
|
+
* Translate one official SDK spawn request to the shared process owner.
|
|
17
|
+
* @param options - command, arguments, workspace, environment, and forwarded signal from the SDK.
|
|
18
|
+
* @param graceMs - process-tree termination grace.
|
|
19
|
+
* @returns the fully explicit shared subprocess request.
|
|
20
|
+
*/
|
|
21
|
+
export declare function claudeSpawnSpec(options: SpawnOptions, graceMs: number): SubprocessSpawnSpec;
|
|
22
|
+
/**
|
|
23
|
+
* SDK-facing view of one shared managed process. Protocol transport remains
|
|
24
|
+
* in the official SDK; this adapter only projects streams and exit events.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ManagedClaudeCodeProcess implements SpawnedProcess {
|
|
27
|
+
private readonly child;
|
|
28
|
+
readonly stdin: import("stream").Writable;
|
|
29
|
+
readonly stdout: import("stream").Readable;
|
|
30
|
+
private readonly events;
|
|
31
|
+
private outcomeValue;
|
|
32
|
+
private killRequested;
|
|
33
|
+
/**
|
|
34
|
+
* Project a managed process with piped stdin and stdout.
|
|
35
|
+
* @param child - shared handle that remains the process-tree authority.
|
|
36
|
+
*/
|
|
37
|
+
constructor(child: SubprocessHandle);
|
|
38
|
+
/** Whether the SDK has requested managed tree termination. */
|
|
39
|
+
get killed(): boolean;
|
|
40
|
+
/** Direct-child exit code, or null while running or after signal exit. */
|
|
41
|
+
get exitCode(): number | null;
|
|
42
|
+
/** Direct-child terminating signal, if any. */
|
|
43
|
+
get signalCode(): NodeJS.Signals | null;
|
|
44
|
+
/** Exact managed-process outcome after exit, or undefined while running. */
|
|
45
|
+
get outcome(): SubprocessOutcome | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Route the SDK's termination request to the tree-scoped process owner.
|
|
48
|
+
* @param _signal - SDK-selected signal; the shared seam owns its escalation ladder.
|
|
49
|
+
* @returns false only after exit or a previous termination request.
|
|
50
|
+
*/
|
|
51
|
+
kill(_signal: NodeJS.Signals): boolean;
|
|
52
|
+
/** Register a persistent process lifecycle listener. */
|
|
53
|
+
on(event: 'exit' | 'error', listener: ((code: number | null, signal: NodeJS.Signals | null) => void) | ((error: Error) => void)): void;
|
|
54
|
+
/** Register a one-shot process lifecycle listener. */
|
|
55
|
+
once(event: 'exit' | 'error', listener: ((code: number | null, signal: NodeJS.Signals | null) => void) | ((error: Error) => void)): void;
|
|
56
|
+
/** Remove a process lifecycle listener. */
|
|
57
|
+
off(event: 'exit' | 'error', listener: ((code: number | null, signal: NodeJS.Signals | null) => void) | ((error: Error) => void)): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=process.d.ts.map
|