@daex-dev/sdk 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +478 -2
- package/dist/client-DVZHOtg6.d.cts +2635 -0
- package/dist/client-DVZHOtg6.d.ts +2635 -0
- package/dist/connect/browser.cjs +209 -0
- package/dist/connect/browser.d.cts +81 -0
- package/dist/connect/browser.d.ts +81 -0
- package/dist/connect/browser.js +183 -0
- package/dist/connect/index.cjs +1954 -0
- package/dist/connect/index.d.cts +433 -0
- package/dist/connect/index.d.ts +433 -0
- package/dist/connect/index.js +1888 -0
- package/dist/electron/global.cjs +18 -0
- package/dist/electron/global.d.cts +35 -0
- package/dist/electron/global.d.ts +35 -0
- package/dist/electron/global.js +0 -0
- package/dist/electron/index.cjs +1133 -0
- package/dist/electron/index.d.cts +510 -0
- package/dist/electron/index.d.ts +510 -0
- package/dist/electron/index.js +1073 -0
- package/dist/electron/preload-auto.cjs +38 -0
- package/dist/electron/preload.cjs +66 -0
- package/dist/electron/preload.d.cts +46 -0
- package/dist/electron/preload.d.ts +46 -0
- package/dist/electron/preload.js +43 -0
- package/dist/electron/protocol-DXRtliy3.d.cts +904 -0
- package/dist/electron/protocol-DXRtliy3.d.ts +904 -0
- package/dist/electron/renderer.cjs +631 -0
- package/dist/electron/renderer.d.cts +508 -0
- package/dist/electron/renderer.d.ts +508 -0
- package/dist/electron/renderer.global.js +634 -0
- package/dist/electron/renderer.js +608 -0
- package/dist/index.cjs +6731 -0
- package/dist/index.d.cts +316 -0
- package/dist/index.d.ts +316 -0
- package/dist/index.js +6661 -0
- package/dist/server.cjs +1019 -0
- package/dist/server.d.cts +118 -0
- package/dist/server.d.ts +118 -0
- package/dist/server.js +989 -0
- package/dist/testing.cjs +815 -0
- package/dist/testing.d.cts +29 -0
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +787 -0
- package/dist/types-DUGv-9QF.d.cts +166 -0
- package/dist/types-DUGv-9QF.d.ts +166 -0
- package/package.json +109 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { R as RuntimeCompatibility } from './client-DVZHOtg6.cjs';
|
|
2
|
+
export { k as ADE_CLIENT_EVENTS, l as APPROVAL_DECISIONS, m as AccountInfo, n as AccountUsage, o as AdeChatClient, p as AdeClientEvent, q as AdeClientEventMap, g as AdeError, h as AdeErrorCode, r as AdeProvider, s as AdeThread, t as AgentChatCodexCollaborationMode, u as AgentChatEvent, A as AgentChatEventEnvelope, v as AgentChatFileRef, w as AgentChatHostConfigLevel, x as AgentChatInstructions, y as AgentChatSessionStatus, z as AgentChatSessionSummary, B as AgentChatSettingSources, C as ApiCredentialInfo, E as ApprovalDecision, F as ApprovalRequest, G as AttachmentRootCheck, H as AttachmentRootFilterResult, J as CapabilitiesChangedEvent, K as CreateAdeChatOptions, L as CreateDaexChatOptions, N as DAEX_CLIENT_EVENTS, O as DEFAULT_RELEASE_REPO, c as DaexChatClient, D as DaexClientEvent, a as DaexClientEventMap, i as DaexError, j as DaexErrorCode, Q as DaexProvider, U as DaexThread, V as DefaultModelOptions, W as DoctorReport, X as DownloadRequest, Y as DownloadResult, Z as EditLastOptions, _ as HistoryPageOptions, $ as HostConfigCapability, I as InstructionsCapability, a0 as InvalidOutputError, a1 as JsonSchema, a2 as KnownAgentChatEvent, a3 as MAX_ATTACHMENT_ROOTS, M as McpCapabilityReport, a4 as McpHeadersResolver, a5 as McpServerConfig, a6 as McpToolFilter, a7 as ModelCatalogEntry, a8 as PendingInputKind, a9 as PendingInputOption, aa as PendingInputQuestion, ab as PendingInputRequest, ac as PendingInputSource, b as PermissionCapability, ad as PermissionPreset, ae as ProviderCapabilities, P as ProviderStatus, af as ProviderStatusProbeRecord, ag as ProviderStatusRpcResult, ah as RunOptions, ai as RuntimeDownloader, aj as RuntimeTarget, ak as SUPPORTED_PROVIDERS, al as SendOptions, am as SetModelOptions, an as SetModelResult, S as SettingSourcesCapability, ao as SignInHandle, ap as SignInStatus, aq as SteerOptions, ar as SyntheticRuntimeLostStatusEvent, as as ThreadBudget, at as ThreadCapabilities, au as ThreadEventChannel, av as ThreadHistoryPage, aw as ThreadInstructions, ax as ThreadInterruptOptions, T as ThreadModelSelection, e as ThreadOpenOptions, ay as ThreadPermissionPolicy, az as ThreadQueueItem, aA as ThreadRefreshOptions, aB as ThreadRerunResult, aC as ThreadRespondOptions, f as ThreadResumeOptions, d as ThreadSummary, aD as ThreadUpdate, aE as ThreadUpdateOptions, aF as ThreadUpdateResult, aG as ThreadUsage, aH as Unsubscribe, aI as UsageLimitEvent, aJ as UsageLimitResume, aK as assetUrl, aL as checkAttachmentRoot, aM as createAdeChat, aN as createDaexChat, aO as filterAttachmentRoots, aP as isApprovalShaped, aQ as isSupportedProvider, aR as parseChecksums, aS as pickDefaultModel, aT as resolveRuntimeTarget, aU as runtimeSpawnEnv, aV as validateJsonSchema } from './client-DVZHOtg6.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The runtime versions this SDK build is written against.
|
|
6
|
+
*
|
|
7
|
+
* The SDK and the runtime ship on separate cadences, and the runtime a host
|
|
8
|
+
* runs may be downloaded (`channel: "latest"`) rather than pinned. So the
|
|
9
|
+
* handshake compares the runtime's self-reported version with this range. A
|
|
10
|
+
* runtime outside it still connects — features it lacks are feature-detected
|
|
11
|
+
* and degrade with a logged line — unless the host passes
|
|
12
|
+
* `requireCompatibleRuntime: true`, which refuses it with
|
|
13
|
+
* `DaexError("runtime_incompatible")`.
|
|
14
|
+
*
|
|
15
|
+
* The lower bound is the first runtime that carries every wire change this
|
|
16
|
+
* SDK uses: `updateSession.mcpServers`, attachment `type` / `hydrate`, the
|
|
17
|
+
* approval-shaped Codex elicitation (1.2.81), and `rerunLastTurn`,
|
|
18
|
+
* `attachmentRoots` and the `turn_in_flight` / `unsupported` error codes
|
|
19
|
+
* (1.2.82). The upper bound is the next major.
|
|
20
|
+
*/
|
|
21
|
+
declare const SUPPORTED_RUNTIME_RANGE = ">=1.2.82 <2.0.0";
|
|
22
|
+
/**
|
|
23
|
+
* Compare a runtime's reported version with a supported range.
|
|
24
|
+
*
|
|
25
|
+
* A dev build (`0.0.0`) and a runtime that reports no version count as
|
|
26
|
+
* supported, with a `note` saying so: both are what a developer runs from a
|
|
27
|
+
* source checkout, and refusing them would make `requireCompatibleRuntime`
|
|
28
|
+
* unusable in development. A non-empty version that does not parse is NOT
|
|
29
|
+
* supported — the SDK cannot vouch for a build it cannot place.
|
|
30
|
+
*/
|
|
31
|
+
declare function checkRuntimeCompatibility(version: string | null | undefined, range?: string): RuntimeCompatibility;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* One tool name, four spellings.
|
|
35
|
+
*
|
|
36
|
+
* The same MCP tool reaches a host under different names depending on who
|
|
37
|
+
* produced the string: Claude's transcript says `mcp__versic__search`, a
|
|
38
|
+
* permission policy says `mcp:versic:search`, Codex and several ACP dialects
|
|
39
|
+
* say `versic:search`, and a built-in is bare (`Bash`). A host that labels
|
|
40
|
+
* tool chips or matches its own rules had to list every tool three times and
|
|
41
|
+
* keep a private matcher in step with this package. This is that matcher.
|
|
42
|
+
*/
|
|
43
|
+
/** A tool name split into the server that owns it and the tool itself. */
|
|
44
|
+
type ToolIdentity = {
|
|
45
|
+
/** The MCP server, or null for a built-in or a name with no server part. */
|
|
46
|
+
server: string | null;
|
|
47
|
+
/** The tool name on that server, or the whole name when there is none. */
|
|
48
|
+
tool: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Split a tool name into `{ server, tool }`.
|
|
52
|
+
*
|
|
53
|
+
* Accepts, in this order:
|
|
54
|
+
* - `mcp__<server>__<tool>` — Claude's spelling. The server is the segment
|
|
55
|
+
* up to the next `__`; everything after it is the tool, so a tool whose
|
|
56
|
+
* own name contains `__` survives intact.
|
|
57
|
+
* - `mcp:<server>:<tool>` — the permission-policy spelling. `*` is a valid
|
|
58
|
+
* tool here and is returned as-is.
|
|
59
|
+
* - `<server>:<tool>` — Codex and ACP dialects.
|
|
60
|
+
* - `<tool>` — a built-in. `server` is null.
|
|
61
|
+
*
|
|
62
|
+
* Never throws. Surrounding whitespace is trimmed. A name that starts with
|
|
63
|
+
* an `mcp__` or `mcp:` prefix but has an empty server or tool segment
|
|
64
|
+
* (`mcp__srv`, `mcp:srv`, `srv:`) is returned whole as a bare tool rather than
|
|
65
|
+
* split into an invented server: a half-formed MCP name is not evidence of
|
|
66
|
+
* which server owns it.
|
|
67
|
+
*
|
|
68
|
+
* `@daex-dev/chat-ui` keeps a copy of this rule for its tool chips (it takes
|
|
69
|
+
* this package only as an optional peer); the two must agree.
|
|
70
|
+
*/
|
|
71
|
+
declare function parseToolIdentity(name: string): ToolIdentity;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `"image"` or `"file"` for one attachment, by the runtime's rule.
|
|
75
|
+
*
|
|
76
|
+
* Any `image/*` mime type means image. Otherwise — including for a non-image
|
|
77
|
+
* mime type, which does NOT force `"file"` — the path's extension decides:
|
|
78
|
+
* `.bmp .gif .heic .heif .ico .jpeg .jpg .png .svg .tif .tiff .webp` are
|
|
79
|
+
* images, everything else is a file. Same name, signature and answer as the
|
|
80
|
+
* runtime's `inferAttachmentType`.
|
|
81
|
+
*/
|
|
82
|
+
declare function inferAttachmentType(filePath: string, mimeType?: string | null): "file" | "image";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The runtime a host copied into its own app bundle.
|
|
86
|
+
*
|
|
87
|
+
* A signed, notarized app carries the runtime as `extraResources`, at
|
|
88
|
+
* `<resourcesPath>/ade-runtime/{bin,native}` — the layout of an
|
|
89
|
+
* `@daex-dev/runtime-<target>` package, copied whole. Every such host then
|
|
90
|
+
* wrote the same three `path.join` calls by hand and reported
|
|
91
|
+
* `doctor().runtime.source` as `"explicit"`, which says nothing about whether
|
|
92
|
+
* the app ran the copy it signed. This helper owns the layout and the label.
|
|
93
|
+
*/
|
|
94
|
+
/** Options for {@link resolvePackagedRuntime}. */
|
|
95
|
+
type ResolvePackagedRuntimeOptions = {
|
|
96
|
+
/** Directory under `resourcesPath` that holds the runtime. Defaults to `"ade-runtime"`. */
|
|
97
|
+
dir?: string;
|
|
98
|
+
/** Defaults to `process.platform`. Decides the binary name and the Mach-O check. */
|
|
99
|
+
platform?: NodeJS.Platform;
|
|
100
|
+
/** Defaults to `process.arch`. The architecture the binary must be able to run. */
|
|
101
|
+
arch?: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Spread straight into `createDaexChat`:
|
|
105
|
+
*
|
|
106
|
+
* createDaexChat({ ...resolvePackagedRuntime(process.resourcesPath), home, allowDownload: false })
|
|
107
|
+
*
|
|
108
|
+
* The field names ARE the `createDaexChat` option names, which is the point:
|
|
109
|
+
* no host-side mapping to get wrong. `source: "packaged"` makes
|
|
110
|
+
* `doctor().runtime.source` report `"packaged"`.
|
|
111
|
+
*/
|
|
112
|
+
type PackagedRuntime = {
|
|
113
|
+
/** Absolute path of `bin/daex`, or `bin/ade` in an older bundle (`.exe` on Windows). */
|
|
114
|
+
binaryPath: string;
|
|
115
|
+
/** Absolute path of `native/`, which becomes `ADE_RUNTIME_ROOT`. */
|
|
116
|
+
runtimeRoot: string;
|
|
117
|
+
/** Absolute path of `native/node_modules`, which becomes `ADE_RUNTIME_NODE_MODULES`. */
|
|
118
|
+
runtimeNodeModules: string;
|
|
119
|
+
source: "packaged";
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Resolve the runtime a host bundled under its resources directory.
|
|
123
|
+
*
|
|
124
|
+
* Returns null — so the caller can fall back to `resolveBundledRuntime()` in
|
|
125
|
+
* development — when:
|
|
126
|
+
* - neither `<resourcesPath>/<dir>/bin/daex[.exe]` nor `bin/ade[.exe]` exists; or
|
|
127
|
+
* - on macOS, the binary's Mach-O header names no slice for `arch`. An
|
|
128
|
+
* arm64-only runtime inside an app running under Rosetta on Intel would
|
|
129
|
+
* otherwise fail at spawn with an error that names neither architecture.
|
|
130
|
+
* A universal binary matches when it contains the arch. A header this
|
|
131
|
+
* function does not recognize is not treated as a mismatch.
|
|
132
|
+
*
|
|
133
|
+
* Throws `DaexError("binary_not_found")`, naming the path, when the binary is
|
|
134
|
+
* there but `native/node_modules` is not: the binary dlopens those modules,
|
|
135
|
+
* so a bundle missing them is a packaging mistake to fail on, not a fallback
|
|
136
|
+
* to take quietly.
|
|
137
|
+
*/
|
|
138
|
+
declare function resolvePackagedRuntime(resourcesPath: string, opts?: ResolvePackagedRuntimeOptions): PackagedRuntime | null;
|
|
139
|
+
|
|
140
|
+
declare const SDK_VERSION: string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Stable per-home endpoint for the SDK's sidecar runtime.
|
|
144
|
+
*
|
|
145
|
+
* Pure and platform-parameterized so the Windows branch is unit-testable from
|
|
146
|
+
* macOS. Mirrors `resolveAdeRuntimeIpcPath` in
|
|
147
|
+
* `apps/desktop/src/shared/adeRuntimeIpc.ts`: a hashed `\\.\pipe\` name on
|
|
148
|
+
* Windows (named pipes are a flat kernel namespace, not a filesystem), a real
|
|
149
|
+
* socket file elsewhere. The `ade-sdk-` prefix keeps an SDK sidecar from ever
|
|
150
|
+
* colliding with the machine brain's own `ade-` pipe.
|
|
151
|
+
*
|
|
152
|
+
* The tmpdir fallback goes into a per-user subdirectory rather than straight
|
|
153
|
+
* into the temp root: on Linux `/tmp` is shared and world-writable, and a
|
|
154
|
+
* predictable `ade-sdk-<hash-of-home>.sock` there can be pre-created by another
|
|
155
|
+
* local user, who then answers the SDK's connect. `ensurePrivateSocketDirectory`
|
|
156
|
+
* creates that subdirectory 0700 and refuses one this user does not own.
|
|
157
|
+
*/
|
|
158
|
+
declare function resolveRuntimeSocketPath(home: string, platform?: NodeJS.Platform, tempDir?: string, identity?: string): string;
|
|
159
|
+
/** True for a Windows named-pipe endpoint, in either slash spelling. */
|
|
160
|
+
declare function isNamedPipePath(value: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Windows named pipe names are case-insensitive, and `\\.\pipe\` and
|
|
163
|
+
* `//./pipe/` name the same object. Collapse both onto one comparison key so
|
|
164
|
+
* two spellings of one endpoint are never treated as two runtimes.
|
|
165
|
+
*/
|
|
166
|
+
declare function endpointComparisonKey(value: string): string;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Resolution of a runtime shipped as an npm platform package.
|
|
170
|
+
*
|
|
171
|
+
* A downloaded runtime cannot live inside a signed and notarized application:
|
|
172
|
+
* the bundle is one signed artifact, and a Mach-O executable that appears in
|
|
173
|
+
* `userData` after the fact is outside it. So the runtime is also published the
|
|
174
|
+
* way esbuild and swc publish theirs — one package per target, each carrying
|
|
175
|
+
* `os` and `cpu`, listed as `optionalDependencies` of `@daex-dev/runtime` so npm
|
|
176
|
+
* installs exactly one. Runtimes published before the DAEX rename are the
|
|
177
|
+
* `@ade-dev/runtime-<target>` packages, still found when no `@daex-dev` one is
|
|
178
|
+
* installed. The embedder copies that directory into their bundle
|
|
179
|
+
* and signs it with their own identity.
|
|
180
|
+
*
|
|
181
|
+
* Layout, which this module both expects and documents:
|
|
182
|
+
*
|
|
183
|
+
* @daex-dev/runtime-<target>/ (or @ade-dev/runtime-<target>/)
|
|
184
|
+
* package.json { os: [...], cpu: [...], version: <ade release> }
|
|
185
|
+
* bin/daex[.exe] the runtime binary, mode 0755 (bin/ade[.exe] before
|
|
186
|
+
* the DAEX rename; still accepted)
|
|
187
|
+
* native/ the extracted contents of <binary>.native.tar.gz
|
|
188
|
+
* node_modules/ the modules the binary dlopens
|
|
189
|
+
* vendor/crsqlite/... the cr-sqlite extension
|
|
190
|
+
* LICENSE
|
|
191
|
+
* README.md
|
|
192
|
+
*
|
|
193
|
+
* `runtimeRoot` is `<pkg>/native`, which is what `ADE_RUNTIME_ROOT` must point
|
|
194
|
+
* at; `nodeModulesPath` is `<pkg>/native/node_modules`, which is
|
|
195
|
+
* `ADE_RUNTIME_NODE_MODULES`. The two are reported separately rather than
|
|
196
|
+
* derived at the call site because an embedder is free to relocate either half
|
|
197
|
+
* inside their bundle, and `createDaexChat` accepts both.
|
|
198
|
+
*/
|
|
199
|
+
type BundledRuntime = {
|
|
200
|
+
/** Absolute path of the runtime binary inside the platform package. */
|
|
201
|
+
binaryPath: string;
|
|
202
|
+
/** Absolute path that `ADE_RUNTIME_ROOT` must name. */
|
|
203
|
+
runtimeRoot: string;
|
|
204
|
+
/** Absolute path that `ADE_RUNTIME_NODE_MODULES` must name. */
|
|
205
|
+
nodeModulesPath: string;
|
|
206
|
+
/** e.g. `@daex-dev/runtime-darwin-arm64` (`@ade-dev/…` for an older package). */
|
|
207
|
+
packageName: string;
|
|
208
|
+
/** The DAEX release version the package was cut from. */
|
|
209
|
+
version: string;
|
|
210
|
+
};
|
|
211
|
+
type ResolveBundledRuntimeOptions = {
|
|
212
|
+
/**
|
|
213
|
+
* Directory or file to resolve the package from. Defaults to this module's
|
|
214
|
+
* own location, which is what an embedder wants: the runtime package sits
|
|
215
|
+
* beside `@daex-dev/sdk` in the same `node_modules` tree.
|
|
216
|
+
*/
|
|
217
|
+
resolveFrom?: string;
|
|
218
|
+
platform?: NodeJS.Platform;
|
|
219
|
+
arch?: string;
|
|
220
|
+
};
|
|
221
|
+
/** The platform package name for a runtime target, e.g. `darwin-arm64`. */
|
|
222
|
+
declare function bundledRuntimePackageName(target: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* Resolve the runtime from an installed `@daex-dev/runtime-*` package, or else
|
|
225
|
+
* an `@ade-dev/runtime-*` one.
|
|
226
|
+
*
|
|
227
|
+
* Returns `null` when no matching package is installed — the caller falls
|
|
228
|
+
* through to the cache, PATH, or a download. Throws `binary_not_found` only
|
|
229
|
+
* when a package IS installed but does not carry what it promises, because the
|
|
230
|
+
* alternative is a dlopen failure several seconds later that names no path and
|
|
231
|
+
* that nobody can act on.
|
|
232
|
+
*/
|
|
233
|
+
declare function resolveBundledRuntime(options?: ResolveBundledRuntimeOptions): BundledRuntime | null;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Code-signing state of the runtime binary, for a support bundle.
|
|
237
|
+
*
|
|
238
|
+
* An embedder who signs their app but forgets the nested runtime does not get a
|
|
239
|
+
* clean error — the process dies on launch under the hardened runtime, on a
|
|
240
|
+
* user's machine, never on the developer's. `doctor().runtime.signature` is the
|
|
241
|
+
* cheapest way to see that before a release goes out, so this probe never
|
|
242
|
+
* throws and never blocks: a failure to read the state is reported as "not
|
|
243
|
+
* known" (`null`), which is honest, rather than as "not signed", which is not.
|
|
244
|
+
*/
|
|
245
|
+
type RuntimeSignature = {
|
|
246
|
+
/** True when the OS reports a signature of any kind, ad-hoc included. */
|
|
247
|
+
signed: boolean;
|
|
248
|
+
/** The signing authority, when readable: a certificate subject or Team ID. */
|
|
249
|
+
authority?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Whether the OS accepts the runtime for execution.
|
|
252
|
+
*
|
|
253
|
+
* On macOS this is Gatekeeper's verdict (`spctl --assess --type execute`).
|
|
254
|
+
* A runtime embedded in an app bundle is assessed through the OUTERMOST
|
|
255
|
+
* enclosing `.app`, because Gatekeeper judges a nested helper as part of the
|
|
256
|
+
* app that carries it: assessed on its own, a correctly signed and notarized
|
|
257
|
+
* embedded binary is "rejected (the code is valid but does not seem to be an
|
|
258
|
+
* app)". When the binary is not inside a bundle and Gatekeeper answers that
|
|
259
|
+
* way, the verdict is `null` — not known — never `false`.
|
|
260
|
+
*
|
|
261
|
+
* On Windows it is whether the Authenticode chain is valid.
|
|
262
|
+
*
|
|
263
|
+
* Absent or null: acceptance could not be determined. Only `false` means
|
|
264
|
+
* the OS refused it.
|
|
265
|
+
*/
|
|
266
|
+
accepted?: boolean | null;
|
|
267
|
+
};
|
|
268
|
+
type SignatureCommandResult = {
|
|
269
|
+
code: number;
|
|
270
|
+
stdout: string;
|
|
271
|
+
stderr: string;
|
|
272
|
+
/**
|
|
273
|
+
* True when the command did not run to completion — a timeout, a kill, or a
|
|
274
|
+
* spawn failure such as ENOENT.
|
|
275
|
+
*
|
|
276
|
+
* `code` cannot carry this. Node reports a timeout as `error.killed` with a
|
|
277
|
+
* null code and a spawn failure as a string code like `"ENOENT"`, and both
|
|
278
|
+
* used to collapse onto exit code 1, which `codesign` also uses for "not
|
|
279
|
+
* signed at all". So a probe that never ran read back as a definitive "this
|
|
280
|
+
* binary is unsigned" — the exact dishonesty this module refuses.
|
|
281
|
+
*/
|
|
282
|
+
failed?: boolean;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Injectable so the per-platform parsing is testable without a signed binary,
|
|
286
|
+
* a macOS host, or a Windows host.
|
|
287
|
+
*/
|
|
288
|
+
type SignatureCommandRunner = (command: string, args: string[], options: {
|
|
289
|
+
timeoutMs: number;
|
|
290
|
+
env?: NodeJS.ProcessEnv;
|
|
291
|
+
}) => Promise<SignatureCommandResult>;
|
|
292
|
+
type ProbeRuntimeSignatureOptions = {
|
|
293
|
+
platform?: NodeJS.Platform;
|
|
294
|
+
spawn?: SignatureCommandRunner;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Read the code-signing state of a runtime binary.
|
|
298
|
+
*
|
|
299
|
+
* Returns `null` on Linux (there is no OS-level signature to read), when the
|
|
300
|
+
* probe could not run, and when its output could not be understood. Never
|
|
301
|
+
* throws, and never takes longer than 10 s per command.
|
|
302
|
+
*/
|
|
303
|
+
declare function probeRuntimeSignature(binaryPath: string, options?: ProbeRuntimeSignatureOptions): Promise<RuntimeSignature | null>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Which of the five resolution steps produced the binary. Reported verbatim on
|
|
307
|
+
* `doctor().runtime.source`, where it is the difference between a five-minute
|
|
308
|
+
* diagnosis of a packaging mistake and a day of one.
|
|
309
|
+
*
|
|
310
|
+
* `"packaged"` is an explicit binary whose options came from
|
|
311
|
+
* `resolvePackagedRuntime()` (SDK >= 0.4 lists it here; before, only
|
|
312
|
+
* `DoctorReport["runtime"]["source"]` had it).
|
|
313
|
+
*/
|
|
314
|
+
type ResolvedBinarySource = "explicit" | "packaged" | "bundled-package" | "cached-download" | "path" | "downloaded";
|
|
315
|
+
|
|
316
|
+
export { type BundledRuntime, type PackagedRuntime, type ProbeRuntimeSignatureOptions, type ResolveBundledRuntimeOptions, type ResolvePackagedRuntimeOptions, type ResolvedBinarySource, RuntimeCompatibility, type RuntimeSignature, SDK_VERSION, SUPPORTED_RUNTIME_RANGE, type ToolIdentity, bundledRuntimePackageName, checkRuntimeCompatibility, endpointComparisonKey, inferAttachmentType, isNamedPipePath, parseToolIdentity, probeRuntimeSignature, resolveBundledRuntime, resolvePackagedRuntime, resolveRuntimeSocketPath };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { R as RuntimeCompatibility } from './client-DVZHOtg6.js';
|
|
2
|
+
export { k as ADE_CLIENT_EVENTS, l as APPROVAL_DECISIONS, m as AccountInfo, n as AccountUsage, o as AdeChatClient, p as AdeClientEvent, q as AdeClientEventMap, g as AdeError, h as AdeErrorCode, r as AdeProvider, s as AdeThread, t as AgentChatCodexCollaborationMode, u as AgentChatEvent, A as AgentChatEventEnvelope, v as AgentChatFileRef, w as AgentChatHostConfigLevel, x as AgentChatInstructions, y as AgentChatSessionStatus, z as AgentChatSessionSummary, B as AgentChatSettingSources, C as ApiCredentialInfo, E as ApprovalDecision, F as ApprovalRequest, G as AttachmentRootCheck, H as AttachmentRootFilterResult, J as CapabilitiesChangedEvent, K as CreateAdeChatOptions, L as CreateDaexChatOptions, N as DAEX_CLIENT_EVENTS, O as DEFAULT_RELEASE_REPO, c as DaexChatClient, D as DaexClientEvent, a as DaexClientEventMap, i as DaexError, j as DaexErrorCode, Q as DaexProvider, U as DaexThread, V as DefaultModelOptions, W as DoctorReport, X as DownloadRequest, Y as DownloadResult, Z as EditLastOptions, _ as HistoryPageOptions, $ as HostConfigCapability, I as InstructionsCapability, a0 as InvalidOutputError, a1 as JsonSchema, a2 as KnownAgentChatEvent, a3 as MAX_ATTACHMENT_ROOTS, M as McpCapabilityReport, a4 as McpHeadersResolver, a5 as McpServerConfig, a6 as McpToolFilter, a7 as ModelCatalogEntry, a8 as PendingInputKind, a9 as PendingInputOption, aa as PendingInputQuestion, ab as PendingInputRequest, ac as PendingInputSource, b as PermissionCapability, ad as PermissionPreset, ae as ProviderCapabilities, P as ProviderStatus, af as ProviderStatusProbeRecord, ag as ProviderStatusRpcResult, ah as RunOptions, ai as RuntimeDownloader, aj as RuntimeTarget, ak as SUPPORTED_PROVIDERS, al as SendOptions, am as SetModelOptions, an as SetModelResult, S as SettingSourcesCapability, ao as SignInHandle, ap as SignInStatus, aq as SteerOptions, ar as SyntheticRuntimeLostStatusEvent, as as ThreadBudget, at as ThreadCapabilities, au as ThreadEventChannel, av as ThreadHistoryPage, aw as ThreadInstructions, ax as ThreadInterruptOptions, T as ThreadModelSelection, e as ThreadOpenOptions, ay as ThreadPermissionPolicy, az as ThreadQueueItem, aA as ThreadRefreshOptions, aB as ThreadRerunResult, aC as ThreadRespondOptions, f as ThreadResumeOptions, d as ThreadSummary, aD as ThreadUpdate, aE as ThreadUpdateOptions, aF as ThreadUpdateResult, aG as ThreadUsage, aH as Unsubscribe, aI as UsageLimitEvent, aJ as UsageLimitResume, aK as assetUrl, aL as checkAttachmentRoot, aM as createAdeChat, aN as createDaexChat, aO as filterAttachmentRoots, aP as isApprovalShaped, aQ as isSupportedProvider, aR as parseChecksums, aS as pickDefaultModel, aT as resolveRuntimeTarget, aU as runtimeSpawnEnv, aV as validateJsonSchema } from './client-DVZHOtg6.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The runtime versions this SDK build is written against.
|
|
6
|
+
*
|
|
7
|
+
* The SDK and the runtime ship on separate cadences, and the runtime a host
|
|
8
|
+
* runs may be downloaded (`channel: "latest"`) rather than pinned. So the
|
|
9
|
+
* handshake compares the runtime's self-reported version with this range. A
|
|
10
|
+
* runtime outside it still connects — features it lacks are feature-detected
|
|
11
|
+
* and degrade with a logged line — unless the host passes
|
|
12
|
+
* `requireCompatibleRuntime: true`, which refuses it with
|
|
13
|
+
* `DaexError("runtime_incompatible")`.
|
|
14
|
+
*
|
|
15
|
+
* The lower bound is the first runtime that carries every wire change this
|
|
16
|
+
* SDK uses: `updateSession.mcpServers`, attachment `type` / `hydrate`, the
|
|
17
|
+
* approval-shaped Codex elicitation (1.2.81), and `rerunLastTurn`,
|
|
18
|
+
* `attachmentRoots` and the `turn_in_flight` / `unsupported` error codes
|
|
19
|
+
* (1.2.82). The upper bound is the next major.
|
|
20
|
+
*/
|
|
21
|
+
declare const SUPPORTED_RUNTIME_RANGE = ">=1.2.82 <2.0.0";
|
|
22
|
+
/**
|
|
23
|
+
* Compare a runtime's reported version with a supported range.
|
|
24
|
+
*
|
|
25
|
+
* A dev build (`0.0.0`) and a runtime that reports no version count as
|
|
26
|
+
* supported, with a `note` saying so: both are what a developer runs from a
|
|
27
|
+
* source checkout, and refusing them would make `requireCompatibleRuntime`
|
|
28
|
+
* unusable in development. A non-empty version that does not parse is NOT
|
|
29
|
+
* supported — the SDK cannot vouch for a build it cannot place.
|
|
30
|
+
*/
|
|
31
|
+
declare function checkRuntimeCompatibility(version: string | null | undefined, range?: string): RuntimeCompatibility;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* One tool name, four spellings.
|
|
35
|
+
*
|
|
36
|
+
* The same MCP tool reaches a host under different names depending on who
|
|
37
|
+
* produced the string: Claude's transcript says `mcp__versic__search`, a
|
|
38
|
+
* permission policy says `mcp:versic:search`, Codex and several ACP dialects
|
|
39
|
+
* say `versic:search`, and a built-in is bare (`Bash`). A host that labels
|
|
40
|
+
* tool chips or matches its own rules had to list every tool three times and
|
|
41
|
+
* keep a private matcher in step with this package. This is that matcher.
|
|
42
|
+
*/
|
|
43
|
+
/** A tool name split into the server that owns it and the tool itself. */
|
|
44
|
+
type ToolIdentity = {
|
|
45
|
+
/** The MCP server, or null for a built-in or a name with no server part. */
|
|
46
|
+
server: string | null;
|
|
47
|
+
/** The tool name on that server, or the whole name when there is none. */
|
|
48
|
+
tool: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Split a tool name into `{ server, tool }`.
|
|
52
|
+
*
|
|
53
|
+
* Accepts, in this order:
|
|
54
|
+
* - `mcp__<server>__<tool>` — Claude's spelling. The server is the segment
|
|
55
|
+
* up to the next `__`; everything after it is the tool, so a tool whose
|
|
56
|
+
* own name contains `__` survives intact.
|
|
57
|
+
* - `mcp:<server>:<tool>` — the permission-policy spelling. `*` is a valid
|
|
58
|
+
* tool here and is returned as-is.
|
|
59
|
+
* - `<server>:<tool>` — Codex and ACP dialects.
|
|
60
|
+
* - `<tool>` — a built-in. `server` is null.
|
|
61
|
+
*
|
|
62
|
+
* Never throws. Surrounding whitespace is trimmed. A name that starts with
|
|
63
|
+
* an `mcp__` or `mcp:` prefix but has an empty server or tool segment
|
|
64
|
+
* (`mcp__srv`, `mcp:srv`, `srv:`) is returned whole as a bare tool rather than
|
|
65
|
+
* split into an invented server: a half-formed MCP name is not evidence of
|
|
66
|
+
* which server owns it.
|
|
67
|
+
*
|
|
68
|
+
* `@daex-dev/chat-ui` keeps a copy of this rule for its tool chips (it takes
|
|
69
|
+
* this package only as an optional peer); the two must agree.
|
|
70
|
+
*/
|
|
71
|
+
declare function parseToolIdentity(name: string): ToolIdentity;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `"image"` or `"file"` for one attachment, by the runtime's rule.
|
|
75
|
+
*
|
|
76
|
+
* Any `image/*` mime type means image. Otherwise — including for a non-image
|
|
77
|
+
* mime type, which does NOT force `"file"` — the path's extension decides:
|
|
78
|
+
* `.bmp .gif .heic .heif .ico .jpeg .jpg .png .svg .tif .tiff .webp` are
|
|
79
|
+
* images, everything else is a file. Same name, signature and answer as the
|
|
80
|
+
* runtime's `inferAttachmentType`.
|
|
81
|
+
*/
|
|
82
|
+
declare function inferAttachmentType(filePath: string, mimeType?: string | null): "file" | "image";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The runtime a host copied into its own app bundle.
|
|
86
|
+
*
|
|
87
|
+
* A signed, notarized app carries the runtime as `extraResources`, at
|
|
88
|
+
* `<resourcesPath>/ade-runtime/{bin,native}` — the layout of an
|
|
89
|
+
* `@daex-dev/runtime-<target>` package, copied whole. Every such host then
|
|
90
|
+
* wrote the same three `path.join` calls by hand and reported
|
|
91
|
+
* `doctor().runtime.source` as `"explicit"`, which says nothing about whether
|
|
92
|
+
* the app ran the copy it signed. This helper owns the layout and the label.
|
|
93
|
+
*/
|
|
94
|
+
/** Options for {@link resolvePackagedRuntime}. */
|
|
95
|
+
type ResolvePackagedRuntimeOptions = {
|
|
96
|
+
/** Directory under `resourcesPath` that holds the runtime. Defaults to `"ade-runtime"`. */
|
|
97
|
+
dir?: string;
|
|
98
|
+
/** Defaults to `process.platform`. Decides the binary name and the Mach-O check. */
|
|
99
|
+
platform?: NodeJS.Platform;
|
|
100
|
+
/** Defaults to `process.arch`. The architecture the binary must be able to run. */
|
|
101
|
+
arch?: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Spread straight into `createDaexChat`:
|
|
105
|
+
*
|
|
106
|
+
* createDaexChat({ ...resolvePackagedRuntime(process.resourcesPath), home, allowDownload: false })
|
|
107
|
+
*
|
|
108
|
+
* The field names ARE the `createDaexChat` option names, which is the point:
|
|
109
|
+
* no host-side mapping to get wrong. `source: "packaged"` makes
|
|
110
|
+
* `doctor().runtime.source` report `"packaged"`.
|
|
111
|
+
*/
|
|
112
|
+
type PackagedRuntime = {
|
|
113
|
+
/** Absolute path of `bin/daex`, or `bin/ade` in an older bundle (`.exe` on Windows). */
|
|
114
|
+
binaryPath: string;
|
|
115
|
+
/** Absolute path of `native/`, which becomes `ADE_RUNTIME_ROOT`. */
|
|
116
|
+
runtimeRoot: string;
|
|
117
|
+
/** Absolute path of `native/node_modules`, which becomes `ADE_RUNTIME_NODE_MODULES`. */
|
|
118
|
+
runtimeNodeModules: string;
|
|
119
|
+
source: "packaged";
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Resolve the runtime a host bundled under its resources directory.
|
|
123
|
+
*
|
|
124
|
+
* Returns null — so the caller can fall back to `resolveBundledRuntime()` in
|
|
125
|
+
* development — when:
|
|
126
|
+
* - neither `<resourcesPath>/<dir>/bin/daex[.exe]` nor `bin/ade[.exe]` exists; or
|
|
127
|
+
* - on macOS, the binary's Mach-O header names no slice for `arch`. An
|
|
128
|
+
* arm64-only runtime inside an app running under Rosetta on Intel would
|
|
129
|
+
* otherwise fail at spawn with an error that names neither architecture.
|
|
130
|
+
* A universal binary matches when it contains the arch. A header this
|
|
131
|
+
* function does not recognize is not treated as a mismatch.
|
|
132
|
+
*
|
|
133
|
+
* Throws `DaexError("binary_not_found")`, naming the path, when the binary is
|
|
134
|
+
* there but `native/node_modules` is not: the binary dlopens those modules,
|
|
135
|
+
* so a bundle missing them is a packaging mistake to fail on, not a fallback
|
|
136
|
+
* to take quietly.
|
|
137
|
+
*/
|
|
138
|
+
declare function resolvePackagedRuntime(resourcesPath: string, opts?: ResolvePackagedRuntimeOptions): PackagedRuntime | null;
|
|
139
|
+
|
|
140
|
+
declare const SDK_VERSION: string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Stable per-home endpoint for the SDK's sidecar runtime.
|
|
144
|
+
*
|
|
145
|
+
* Pure and platform-parameterized so the Windows branch is unit-testable from
|
|
146
|
+
* macOS. Mirrors `resolveAdeRuntimeIpcPath` in
|
|
147
|
+
* `apps/desktop/src/shared/adeRuntimeIpc.ts`: a hashed `\\.\pipe\` name on
|
|
148
|
+
* Windows (named pipes are a flat kernel namespace, not a filesystem), a real
|
|
149
|
+
* socket file elsewhere. The `ade-sdk-` prefix keeps an SDK sidecar from ever
|
|
150
|
+
* colliding with the machine brain's own `ade-` pipe.
|
|
151
|
+
*
|
|
152
|
+
* The tmpdir fallback goes into a per-user subdirectory rather than straight
|
|
153
|
+
* into the temp root: on Linux `/tmp` is shared and world-writable, and a
|
|
154
|
+
* predictable `ade-sdk-<hash-of-home>.sock` there can be pre-created by another
|
|
155
|
+
* local user, who then answers the SDK's connect. `ensurePrivateSocketDirectory`
|
|
156
|
+
* creates that subdirectory 0700 and refuses one this user does not own.
|
|
157
|
+
*/
|
|
158
|
+
declare function resolveRuntimeSocketPath(home: string, platform?: NodeJS.Platform, tempDir?: string, identity?: string): string;
|
|
159
|
+
/** True for a Windows named-pipe endpoint, in either slash spelling. */
|
|
160
|
+
declare function isNamedPipePath(value: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Windows named pipe names are case-insensitive, and `\\.\pipe\` and
|
|
163
|
+
* `//./pipe/` name the same object. Collapse both onto one comparison key so
|
|
164
|
+
* two spellings of one endpoint are never treated as two runtimes.
|
|
165
|
+
*/
|
|
166
|
+
declare function endpointComparisonKey(value: string): string;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Resolution of a runtime shipped as an npm platform package.
|
|
170
|
+
*
|
|
171
|
+
* A downloaded runtime cannot live inside a signed and notarized application:
|
|
172
|
+
* the bundle is one signed artifact, and a Mach-O executable that appears in
|
|
173
|
+
* `userData` after the fact is outside it. So the runtime is also published the
|
|
174
|
+
* way esbuild and swc publish theirs — one package per target, each carrying
|
|
175
|
+
* `os` and `cpu`, listed as `optionalDependencies` of `@daex-dev/runtime` so npm
|
|
176
|
+
* installs exactly one. Runtimes published before the DAEX rename are the
|
|
177
|
+
* `@ade-dev/runtime-<target>` packages, still found when no `@daex-dev` one is
|
|
178
|
+
* installed. The embedder copies that directory into their bundle
|
|
179
|
+
* and signs it with their own identity.
|
|
180
|
+
*
|
|
181
|
+
* Layout, which this module both expects and documents:
|
|
182
|
+
*
|
|
183
|
+
* @daex-dev/runtime-<target>/ (or @ade-dev/runtime-<target>/)
|
|
184
|
+
* package.json { os: [...], cpu: [...], version: <ade release> }
|
|
185
|
+
* bin/daex[.exe] the runtime binary, mode 0755 (bin/ade[.exe] before
|
|
186
|
+
* the DAEX rename; still accepted)
|
|
187
|
+
* native/ the extracted contents of <binary>.native.tar.gz
|
|
188
|
+
* node_modules/ the modules the binary dlopens
|
|
189
|
+
* vendor/crsqlite/... the cr-sqlite extension
|
|
190
|
+
* LICENSE
|
|
191
|
+
* README.md
|
|
192
|
+
*
|
|
193
|
+
* `runtimeRoot` is `<pkg>/native`, which is what `ADE_RUNTIME_ROOT` must point
|
|
194
|
+
* at; `nodeModulesPath` is `<pkg>/native/node_modules`, which is
|
|
195
|
+
* `ADE_RUNTIME_NODE_MODULES`. The two are reported separately rather than
|
|
196
|
+
* derived at the call site because an embedder is free to relocate either half
|
|
197
|
+
* inside their bundle, and `createDaexChat` accepts both.
|
|
198
|
+
*/
|
|
199
|
+
type BundledRuntime = {
|
|
200
|
+
/** Absolute path of the runtime binary inside the platform package. */
|
|
201
|
+
binaryPath: string;
|
|
202
|
+
/** Absolute path that `ADE_RUNTIME_ROOT` must name. */
|
|
203
|
+
runtimeRoot: string;
|
|
204
|
+
/** Absolute path that `ADE_RUNTIME_NODE_MODULES` must name. */
|
|
205
|
+
nodeModulesPath: string;
|
|
206
|
+
/** e.g. `@daex-dev/runtime-darwin-arm64` (`@ade-dev/…` for an older package). */
|
|
207
|
+
packageName: string;
|
|
208
|
+
/** The DAEX release version the package was cut from. */
|
|
209
|
+
version: string;
|
|
210
|
+
};
|
|
211
|
+
type ResolveBundledRuntimeOptions = {
|
|
212
|
+
/**
|
|
213
|
+
* Directory or file to resolve the package from. Defaults to this module's
|
|
214
|
+
* own location, which is what an embedder wants: the runtime package sits
|
|
215
|
+
* beside `@daex-dev/sdk` in the same `node_modules` tree.
|
|
216
|
+
*/
|
|
217
|
+
resolveFrom?: string;
|
|
218
|
+
platform?: NodeJS.Platform;
|
|
219
|
+
arch?: string;
|
|
220
|
+
};
|
|
221
|
+
/** The platform package name for a runtime target, e.g. `darwin-arm64`. */
|
|
222
|
+
declare function bundledRuntimePackageName(target: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* Resolve the runtime from an installed `@daex-dev/runtime-*` package, or else
|
|
225
|
+
* an `@ade-dev/runtime-*` one.
|
|
226
|
+
*
|
|
227
|
+
* Returns `null` when no matching package is installed — the caller falls
|
|
228
|
+
* through to the cache, PATH, or a download. Throws `binary_not_found` only
|
|
229
|
+
* when a package IS installed but does not carry what it promises, because the
|
|
230
|
+
* alternative is a dlopen failure several seconds later that names no path and
|
|
231
|
+
* that nobody can act on.
|
|
232
|
+
*/
|
|
233
|
+
declare function resolveBundledRuntime(options?: ResolveBundledRuntimeOptions): BundledRuntime | null;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Code-signing state of the runtime binary, for a support bundle.
|
|
237
|
+
*
|
|
238
|
+
* An embedder who signs their app but forgets the nested runtime does not get a
|
|
239
|
+
* clean error — the process dies on launch under the hardened runtime, on a
|
|
240
|
+
* user's machine, never on the developer's. `doctor().runtime.signature` is the
|
|
241
|
+
* cheapest way to see that before a release goes out, so this probe never
|
|
242
|
+
* throws and never blocks: a failure to read the state is reported as "not
|
|
243
|
+
* known" (`null`), which is honest, rather than as "not signed", which is not.
|
|
244
|
+
*/
|
|
245
|
+
type RuntimeSignature = {
|
|
246
|
+
/** True when the OS reports a signature of any kind, ad-hoc included. */
|
|
247
|
+
signed: boolean;
|
|
248
|
+
/** The signing authority, when readable: a certificate subject or Team ID. */
|
|
249
|
+
authority?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Whether the OS accepts the runtime for execution.
|
|
252
|
+
*
|
|
253
|
+
* On macOS this is Gatekeeper's verdict (`spctl --assess --type execute`).
|
|
254
|
+
* A runtime embedded in an app bundle is assessed through the OUTERMOST
|
|
255
|
+
* enclosing `.app`, because Gatekeeper judges a nested helper as part of the
|
|
256
|
+
* app that carries it: assessed on its own, a correctly signed and notarized
|
|
257
|
+
* embedded binary is "rejected (the code is valid but does not seem to be an
|
|
258
|
+
* app)". When the binary is not inside a bundle and Gatekeeper answers that
|
|
259
|
+
* way, the verdict is `null` — not known — never `false`.
|
|
260
|
+
*
|
|
261
|
+
* On Windows it is whether the Authenticode chain is valid.
|
|
262
|
+
*
|
|
263
|
+
* Absent or null: acceptance could not be determined. Only `false` means
|
|
264
|
+
* the OS refused it.
|
|
265
|
+
*/
|
|
266
|
+
accepted?: boolean | null;
|
|
267
|
+
};
|
|
268
|
+
type SignatureCommandResult = {
|
|
269
|
+
code: number;
|
|
270
|
+
stdout: string;
|
|
271
|
+
stderr: string;
|
|
272
|
+
/**
|
|
273
|
+
* True when the command did not run to completion — a timeout, a kill, or a
|
|
274
|
+
* spawn failure such as ENOENT.
|
|
275
|
+
*
|
|
276
|
+
* `code` cannot carry this. Node reports a timeout as `error.killed` with a
|
|
277
|
+
* null code and a spawn failure as a string code like `"ENOENT"`, and both
|
|
278
|
+
* used to collapse onto exit code 1, which `codesign` also uses for "not
|
|
279
|
+
* signed at all". So a probe that never ran read back as a definitive "this
|
|
280
|
+
* binary is unsigned" — the exact dishonesty this module refuses.
|
|
281
|
+
*/
|
|
282
|
+
failed?: boolean;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Injectable so the per-platform parsing is testable without a signed binary,
|
|
286
|
+
* a macOS host, or a Windows host.
|
|
287
|
+
*/
|
|
288
|
+
type SignatureCommandRunner = (command: string, args: string[], options: {
|
|
289
|
+
timeoutMs: number;
|
|
290
|
+
env?: NodeJS.ProcessEnv;
|
|
291
|
+
}) => Promise<SignatureCommandResult>;
|
|
292
|
+
type ProbeRuntimeSignatureOptions = {
|
|
293
|
+
platform?: NodeJS.Platform;
|
|
294
|
+
spawn?: SignatureCommandRunner;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Read the code-signing state of a runtime binary.
|
|
298
|
+
*
|
|
299
|
+
* Returns `null` on Linux (there is no OS-level signature to read), when the
|
|
300
|
+
* probe could not run, and when its output could not be understood. Never
|
|
301
|
+
* throws, and never takes longer than 10 s per command.
|
|
302
|
+
*/
|
|
303
|
+
declare function probeRuntimeSignature(binaryPath: string, options?: ProbeRuntimeSignatureOptions): Promise<RuntimeSignature | null>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Which of the five resolution steps produced the binary. Reported verbatim on
|
|
307
|
+
* `doctor().runtime.source`, where it is the difference between a five-minute
|
|
308
|
+
* diagnosis of a packaging mistake and a day of one.
|
|
309
|
+
*
|
|
310
|
+
* `"packaged"` is an explicit binary whose options came from
|
|
311
|
+
* `resolvePackagedRuntime()` (SDK >= 0.4 lists it here; before, only
|
|
312
|
+
* `DoctorReport["runtime"]["source"]` had it).
|
|
313
|
+
*/
|
|
314
|
+
type ResolvedBinarySource = "explicit" | "packaged" | "bundled-package" | "cached-download" | "path" | "downloaded";
|
|
315
|
+
|
|
316
|
+
export { type BundledRuntime, type PackagedRuntime, type ProbeRuntimeSignatureOptions, type ResolveBundledRuntimeOptions, type ResolvePackagedRuntimeOptions, type ResolvedBinarySource, RuntimeCompatibility, type RuntimeSignature, SDK_VERSION, SUPPORTED_RUNTIME_RANGE, type ToolIdentity, bundledRuntimePackageName, checkRuntimeCompatibility, endpointComparisonKey, inferAttachmentType, isNamedPipePath, parseToolIdentity, probeRuntimeSignature, resolveBundledRuntime, resolvePackagedRuntime, resolveRuntimeSocketPath };
|