@daex-dev/sdk 0.7.1 → 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 -21
- package/README.md +479 -417
- package/dist/{client-C0KQKP8O.d.cts → client-DVZHOtg6.d.cts} +18 -4
- package/dist/{client-C0KQKP8O.d.ts → client-DVZHOtg6.d.ts} +18 -4
- 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/index.d.cts +2 -2
- package/dist/electron/index.d.ts +2 -2
- package/dist/index.cjs +130 -80
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +130 -80
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/types-DUGv-9QF.d.cts +166 -0
- package/dist/types-DUGv-9QF.d.ts +166 -0
- package/package.json +111 -93
package/dist/index.js
CHANGED
|
@@ -429,7 +429,7 @@ function resolveTrustedWindowsTool(tool, deps = {}) {
|
|
|
429
429
|
|
|
430
430
|
// src/download.ts
|
|
431
431
|
var execFileAsync = promisify(execFile);
|
|
432
|
-
var DEFAULT_RELEASE_REPO = "arul28/
|
|
432
|
+
var DEFAULT_RELEASE_REPO = "arul28/DAEX";
|
|
433
433
|
function resolveRuntimeTarget(platform = process.platform, arch = process.arch) {
|
|
434
434
|
const os3 = platform === "darwin" ? "darwin" : platform === "linux" ? "linux" : platform === "win32" ? "win32" : null;
|
|
435
435
|
if (!os3) {
|
|
@@ -443,8 +443,24 @@ function resolveRuntimeTarget(platform = process.platform, arch = process.arch)
|
|
|
443
443
|
throw new DaexError("binary_not_found", "DAEX only publishes a Windows x64 runtime.");
|
|
444
444
|
}
|
|
445
445
|
const target = `${os3}-${cpu}`;
|
|
446
|
-
const
|
|
447
|
-
return {
|
|
446
|
+
const exe = os3 === "win32" ? ".exe" : "";
|
|
447
|
+
return {
|
|
448
|
+
target,
|
|
449
|
+
binaryAsset: `daex-${target}${exe}`,
|
|
450
|
+
archiveAsset: `daex-${target}.native.tar.gz`,
|
|
451
|
+
legacyBinaryAsset: `ade-${target}${exe}`,
|
|
452
|
+
legacyArchiveAsset: `ade-${target}.native.tar.gz`
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function assetNamesFor(target, checksums) {
|
|
456
|
+
const current = { binary: target.binaryAsset, archive: target.archiveAsset };
|
|
457
|
+
const legacy = target.legacyBinaryAsset && target.legacyArchiveAsset ? { binary: target.legacyBinaryAsset, archive: target.legacyArchiveAsset } : null;
|
|
458
|
+
if (!legacy) return { primary: current, fallback: null };
|
|
459
|
+
if (checksums) {
|
|
460
|
+
const useLegacy = !checksums.has(current.binary) && checksums.has(legacy.binary);
|
|
461
|
+
return { primary: useLegacy ? legacy : current, fallback: null };
|
|
462
|
+
}
|
|
463
|
+
return { primary: current, fallback: legacy };
|
|
448
464
|
}
|
|
449
465
|
function assetUrl(repo, channel, asset) {
|
|
450
466
|
const normalized = channel.trim() || "latest";
|
|
@@ -465,8 +481,9 @@ function parseChecksums(body) {
|
|
|
465
481
|
function runtimeSpawnEnv(runtimeRoot, base = process.env, nodeModulesPath) {
|
|
466
482
|
const nodeModules = nodeModulesPath?.trim() ? path2.resolve(nodeModulesPath.trim()) : path2.join(runtimeRoot, "node_modules");
|
|
467
483
|
const previous = base.NODE_PATH?.trim();
|
|
484
|
+
const { DAEX_RUNTIME_ROOT: _hostRoot, DAEX_RUNTIME_NODE_MODULES: _hostModules, ...rest } = base;
|
|
468
485
|
return {
|
|
469
|
-
...
|
|
486
|
+
...rest,
|
|
470
487
|
ADE_RUNTIME_ROOT: runtimeRoot,
|
|
471
488
|
ADE_RUNTIME_NODE_MODULES: nodeModules,
|
|
472
489
|
NODE_PATH: previous ? `${nodeModules}${path2.delimiter}${previous}` : nodeModules
|
|
@@ -483,31 +500,43 @@ var downloadRuntime = async (request) => {
|
|
|
483
500
|
const { binaryPath, runtimeRoot } = runtimePaths(home, target);
|
|
484
501
|
const cachedMarker = readChannelMarker(runtimeRoot);
|
|
485
502
|
if (isUsableCachedRuntime(binaryPath, runtimeRoot) && cachedMarker != null && cachedMarker.channel === channel.trim()) {
|
|
486
|
-
logger(`
|
|
503
|
+
logger(`daex sdk: reusing cached runtime at ${binaryPath}`);
|
|
487
504
|
return { binaryPath, runtimeRoot, checksumVerified: cachedMarker.checksumVerified };
|
|
488
505
|
}
|
|
489
506
|
const staging = path2.join(home, "cache", `download-${process.pid}-${Date.now()}`);
|
|
490
507
|
await fs2.promises.mkdir(staging, { recursive: true });
|
|
491
508
|
try {
|
|
492
|
-
logger(`ade sdk: downloading ${target.binaryAsset} (${channel}) from ${repo}`);
|
|
493
|
-
const binaryBytes = await fetchAsset(assetUrl(repo, channel, target.binaryAsset), signal);
|
|
494
|
-
const archiveBytes = await fetchAsset(assetUrl(repo, channel, target.archiveAsset), signal);
|
|
495
|
-
let checksumVerified = false;
|
|
496
509
|
const checksums = await fetchChecksums(assetUrl(repo, channel, "SHA256SUMS"), signal);
|
|
497
|
-
if (checksums) {
|
|
498
|
-
verifyChecksum(target.binaryAsset, binaryBytes, checksums);
|
|
499
|
-
verifyChecksum(target.archiveAsset, archiveBytes, checksums);
|
|
500
|
-
checksumVerified = true;
|
|
501
|
-
} else if (requireChecksum) {
|
|
510
|
+
if (!checksums && requireChecksum) {
|
|
502
511
|
throw new DaexError(
|
|
503
512
|
"checksum_mismatch",
|
|
504
513
|
`The ${channel} channel published no SHA256SUMS, so the DAEX runtime download could not be verified. Pass requireChecksum: false to install it unverified.`
|
|
505
514
|
);
|
|
515
|
+
}
|
|
516
|
+
const names = assetNamesFor(target, checksums);
|
|
517
|
+
let assets = names.primary;
|
|
518
|
+
logger(`daex sdk: downloading ${assets.binary} (${channel}) from ${repo}`);
|
|
519
|
+
const firstUrl = assetUrl(repo, channel, assets.binary);
|
|
520
|
+
const firstTry = await fetchAssetIfPresent(firstUrl, signal);
|
|
521
|
+
if (!firstTry && !names.fallback) {
|
|
522
|
+
throw new DaexError("download_failed", `Downloading ${firstUrl} failed with HTTP 404.`);
|
|
523
|
+
}
|
|
524
|
+
if (!firstTry && names.fallback) {
|
|
525
|
+
assets = names.fallback;
|
|
526
|
+
logger(`daex sdk: downloading ${assets.binary} (${channel}) from ${repo}`);
|
|
527
|
+
}
|
|
528
|
+
const binaryBytes = firstTry ?? await fetchAsset(assetUrl(repo, channel, assets.binary), signal);
|
|
529
|
+
const archiveBytes = await fetchAsset(assetUrl(repo, channel, assets.archive), signal);
|
|
530
|
+
let checksumVerified = false;
|
|
531
|
+
if (checksums) {
|
|
532
|
+
verifyChecksum(assets.binary, binaryBytes, checksums);
|
|
533
|
+
verifyChecksum(assets.archive, archiveBytes, checksums);
|
|
534
|
+
checksumVerified = true;
|
|
506
535
|
} else {
|
|
507
|
-
assertPlausibleSize(
|
|
508
|
-
assertPlausibleSize(
|
|
536
|
+
assertPlausibleSize(assets.binary, binaryBytes);
|
|
537
|
+
assertPlausibleSize(assets.archive, archiveBytes);
|
|
509
538
|
logger(
|
|
510
|
-
`
|
|
539
|
+
`daex sdk: ${channel} published no SHA256SUMS and requireChecksum is off; verified download size only`
|
|
511
540
|
);
|
|
512
541
|
}
|
|
513
542
|
const stagedBinary = path2.join(staging, "ade");
|
|
@@ -530,7 +559,7 @@ var downloadRuntime = async (request) => {
|
|
|
530
559
|
await fs2.promises.chmod(binaryPath, 493).catch(() => {
|
|
531
560
|
});
|
|
532
561
|
await writeChannelMarker(runtimeRoot, channel, checksumVerified);
|
|
533
|
-
logger(`
|
|
562
|
+
logger(`daex sdk: installed DAEX runtime at ${binaryPath}`);
|
|
534
563
|
return { binaryPath, runtimeRoot, checksumVerified };
|
|
535
564
|
} finally {
|
|
536
565
|
await fs2.promises.rm(staging, { recursive: true, force: true }).catch(() => {
|
|
@@ -541,6 +570,13 @@ function isUsableCachedRuntime(binaryPath, runtimeRoot) {
|
|
|
541
570
|
return fs2.existsSync(binaryPath) && fs2.existsSync(path2.join(runtimeRoot, "node_modules"));
|
|
542
571
|
}
|
|
543
572
|
async function fetchAsset(url, signal) {
|
|
573
|
+
const bytes = await fetchAssetIfPresent(url, signal);
|
|
574
|
+
if (!bytes) {
|
|
575
|
+
throw new DaexError("download_failed", `Downloading ${url} failed with HTTP 404.`);
|
|
576
|
+
}
|
|
577
|
+
return bytes;
|
|
578
|
+
}
|
|
579
|
+
async function fetchAssetIfPresent(url, signal) {
|
|
544
580
|
let response;
|
|
545
581
|
try {
|
|
546
582
|
response = await fetch(url, { redirect: "follow", ...signal ? { signal } : {} });
|
|
@@ -549,6 +585,11 @@ async function fetchAsset(url, signal) {
|
|
|
549
585
|
cause: error
|
|
550
586
|
});
|
|
551
587
|
}
|
|
588
|
+
if (response.status === 404) {
|
|
589
|
+
await response.body?.cancel().catch(() => {
|
|
590
|
+
});
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
552
593
|
if (!response.ok) {
|
|
553
594
|
throw new DaexError(
|
|
554
595
|
"download_failed",
|
|
@@ -715,6 +756,9 @@ function runtimeBinaryIn(dir, platform, fileExists = isFile) {
|
|
|
715
756
|
|
|
716
757
|
// src/bundledRuntime.ts
|
|
717
758
|
function bundledRuntimePackageName(target) {
|
|
759
|
+
return `@daex-dev/runtime-${target}`;
|
|
760
|
+
}
|
|
761
|
+
function legacyBundledRuntimePackageName(target) {
|
|
718
762
|
return `@ade-dev/runtime-${target}`;
|
|
719
763
|
}
|
|
720
764
|
function defaultResolveAnchor() {
|
|
@@ -751,14 +795,19 @@ function resolveBundledRuntime(options = {}) {
|
|
|
751
795
|
} catch {
|
|
752
796
|
return null;
|
|
753
797
|
}
|
|
754
|
-
const packageName = bundledRuntimePackageName(target);
|
|
755
798
|
const anchor = options.resolveFrom ? anchorFile(options.resolveFrom) : defaultResolveAnchor();
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
799
|
+
const requireFromAnchor = createRequire(anchor);
|
|
800
|
+
let packageName = "";
|
|
801
|
+
let manifestPath = "";
|
|
802
|
+
for (const candidate of [bundledRuntimePackageName(target), legacyBundledRuntimePackageName(target)]) {
|
|
803
|
+
try {
|
|
804
|
+
manifestPath = requireFromAnchor.resolve(`${candidate}/package.json`);
|
|
805
|
+
packageName = candidate;
|
|
806
|
+
break;
|
|
807
|
+
} catch {
|
|
808
|
+
}
|
|
761
809
|
}
|
|
810
|
+
if (!packageName) return null;
|
|
762
811
|
const packageRoot = path4.dirname(manifestPath);
|
|
763
812
|
const { binaryPath, found } = runtimeBinaryIn(path4.join(packageRoot, "bin"), platform);
|
|
764
813
|
const runtimeRoot = path4.join(packageRoot, "native");
|
|
@@ -884,7 +933,7 @@ async function resolveBinary(options) {
|
|
|
884
933
|
const bundled = resolveBundled({ platform, arch });
|
|
885
934
|
if (bundled) {
|
|
886
935
|
logger(
|
|
887
|
-
`
|
|
936
|
+
`daex sdk: using the runtime bundled in ${bundled.packageName}` + (bundled.version ? `@${bundled.version}` : "")
|
|
888
937
|
);
|
|
889
938
|
return {
|
|
890
939
|
binaryPath: bundled.binaryPath,
|
|
@@ -894,7 +943,7 @@ async function resolveBinary(options) {
|
|
|
894
943
|
checksumVerified: false
|
|
895
944
|
};
|
|
896
945
|
}
|
|
897
|
-
tried.push("no @ade-dev/runtime-* platform package is installed");
|
|
946
|
+
tried.push("no @daex-dev/runtime-* (or @ade-dev/runtime-*) platform package is installed");
|
|
898
947
|
const target = resolveRuntimeTarget(platform, arch);
|
|
899
948
|
const cached = runtimePaths(home, target, platform);
|
|
900
949
|
const cachedNodeModules = path6.join(cached.runtimeRoot, "node_modules");
|
|
@@ -911,7 +960,7 @@ async function resolveBinary(options) {
|
|
|
911
960
|
for (const command of RUNTIME_COMMANDS) {
|
|
912
961
|
const onPath = discoverOnPath(command, env, platform);
|
|
913
962
|
if (onPath) {
|
|
914
|
-
logger(`
|
|
963
|
+
logger(`daex sdk: using the ${command} already installed at ${onPath}`);
|
|
915
964
|
return {
|
|
916
965
|
binaryPath: onPath,
|
|
917
966
|
runtimeRoot: null,
|
|
@@ -928,7 +977,7 @@ async function resolveBinary(options) {
|
|
|
928
977
|
if (!allowDownload) {
|
|
929
978
|
throw new DaexError(
|
|
930
979
|
"runtime_unavailable",
|
|
931
|
-
`No DAEX runtime is available for ${target.target} and allowDownload is false, so none was fetched. Tried, in order: ${tried.join("; ")}. Install @
|
|
980
|
+
`No DAEX runtime is available for ${target.target} and allowDownload is false, so none was fetched. Tried, in order: ${tried.join("; ")}. Install @daex-dev/runtime-${target.target}, or pass binaryPath (with runtimeNodeModules when the native modules are not beside the binary).`
|
|
932
981
|
);
|
|
933
982
|
}
|
|
934
983
|
const result = await download({ home, channel, repo, target, logger });
|
|
@@ -986,7 +1035,7 @@ async function readBinaryVersion(binary, env = process.env) {
|
|
|
986
1035
|
const { binaryPath, runtimeRoot, nodeModulesPath } = binary;
|
|
987
1036
|
try {
|
|
988
1037
|
const spawnEnv = runtimeRoot ? runtimeSpawnEnv(runtimeRoot, env, nodeModulesPath ?? void 0) : env;
|
|
989
|
-
const resolvedEnv = { ...spawnEnv, ADE_CLI_NO_DELEGATE: "1" };
|
|
1038
|
+
const resolvedEnv = { ...spawnEnv, ADE_CLI_NO_DELEGATE: "1", DAEX_CLI_NO_DELEGATE: "1" };
|
|
990
1039
|
const invocation = resolveSpawnInvocation(binaryPath, ["--version"], resolvedEnv);
|
|
991
1040
|
const { stdout } = await execFileAsync2(invocation.command, invocation.args, {
|
|
992
1041
|
env: resolvedEnv,
|
|
@@ -1011,7 +1060,7 @@ function isAdeClientEvent(value) {
|
|
|
1011
1060
|
var ADE_CLIENT_EVENTS = DAEX_CLIENT_EVENTS;
|
|
1012
1061
|
|
|
1013
1062
|
// src/version.ts
|
|
1014
|
-
var SDK_VERSION = true ? "0.
|
|
1063
|
+
var SDK_VERSION = true ? "0.8.0" : "0.8.0";
|
|
1015
1064
|
|
|
1016
1065
|
// src/doctorReport.ts
|
|
1017
1066
|
function legacyBinarySource(source) {
|
|
@@ -1134,7 +1183,7 @@ var ChatEventStream = class {
|
|
|
1134
1183
|
return;
|
|
1135
1184
|
} catch (error) {
|
|
1136
1185
|
this.logger(
|
|
1137
|
-
`
|
|
1186
|
+
`daex sdk: push events unavailable (${errorMessage(error)}); falling back to polling`
|
|
1138
1187
|
);
|
|
1139
1188
|
this.mode = "drain";
|
|
1140
1189
|
}
|
|
@@ -1187,11 +1236,11 @@ var ChatEventStream = class {
|
|
|
1187
1236
|
if (this.disposed) return;
|
|
1188
1237
|
this.mode = "unavailable";
|
|
1189
1238
|
this.subscriptionId = null;
|
|
1190
|
-
this.logger("
|
|
1239
|
+
this.logger("daex sdk: chat event stream lost its connection");
|
|
1191
1240
|
});
|
|
1192
1241
|
this.applyBufferMetadata(result);
|
|
1193
1242
|
for (const payload of pending.splice(0)) this.consumeNotification(payload);
|
|
1194
|
-
this.logger(`
|
|
1243
|
+
this.logger(`daex sdk: chat events streaming (push, subscription ${result.subscriptionId})`);
|
|
1195
1244
|
}
|
|
1196
1245
|
consumeNotification(payload) {
|
|
1197
1246
|
if (payload.subscriptionId !== this.subscriptionId) return;
|
|
@@ -1203,7 +1252,7 @@ var ChatEventStream = class {
|
|
|
1203
1252
|
this.emit(event);
|
|
1204
1253
|
}
|
|
1205
1254
|
startDrain() {
|
|
1206
|
-
this.logger("
|
|
1255
|
+
this.logger("daex sdk: chat events streaming (drain fallback)");
|
|
1207
1256
|
this.scheduleDrain(0);
|
|
1208
1257
|
}
|
|
1209
1258
|
scheduleDrain(delayMs) {
|
|
@@ -1818,7 +1867,7 @@ function createProviderStatusPublisher(options) {
|
|
|
1818
1867
|
if (!warnedAboutDerived) {
|
|
1819
1868
|
warnedAboutDerived = true;
|
|
1820
1869
|
logger(
|
|
1821
|
-
'
|
|
1870
|
+
'daex sdk: this runtime has no providers.status RPC, so provider records are derived from the model catalog (source "derived"): installed is modelCount > 0, and binaryPath, version and the remediation commands are null'
|
|
1822
1871
|
);
|
|
1823
1872
|
}
|
|
1824
1873
|
return null;
|
|
@@ -1830,7 +1879,7 @@ function createProviderStatusPublisher(options) {
|
|
|
1830
1879
|
if (!warnedAboutDerived) {
|
|
1831
1880
|
warnedAboutDerived = true;
|
|
1832
1881
|
logger(
|
|
1833
|
-
`
|
|
1882
|
+
`daex sdk: the runtime advertised providers.status but the call failed (${errorMessage(error)}); provider records fall back to catalog derivation with source "derived"`
|
|
1834
1883
|
);
|
|
1835
1884
|
}
|
|
1836
1885
|
return null;
|
|
@@ -2422,11 +2471,11 @@ async function reclaimStaleRuntime(options) {
|
|
|
2422
2471
|
if (answered) {
|
|
2423
2472
|
const ownerAlive = record3.parentPid === process.pid || record3.parentPid > 0 && isAlive(record3.parentPid);
|
|
2424
2473
|
if (ownerAlive) {
|
|
2425
|
-
logger(`
|
|
2474
|
+
logger(`daex sdk: reusing the runtime already listening on ${socketPath} (pid ${record3.pid})`);
|
|
2426
2475
|
return { action: "reused", pid: record3.pid };
|
|
2427
2476
|
}
|
|
2428
2477
|
logger(
|
|
2429
|
-
`
|
|
2478
|
+
`daex sdk: the runtime on ${socketPath} (pid ${record3.pid}) is answering but its owner (pid ${record3.parentPid}) is gone, so its watchdog is about to end it; reclaiming instead of adopting`
|
|
2430
2479
|
);
|
|
2431
2480
|
}
|
|
2432
2481
|
}
|
|
@@ -2448,7 +2497,7 @@ async function reclaimStaleRuntime(options) {
|
|
|
2448
2497
|
};
|
|
2449
2498
|
}
|
|
2450
2499
|
logger(
|
|
2451
|
-
`
|
|
2500
|
+
`daex sdk: reclaiming a stale ADE runtime for this home (pid ${record3.pid}, ${socketPath})`
|
|
2452
2501
|
);
|
|
2453
2502
|
try {
|
|
2454
2503
|
kill(record3.pid, "SIGTERM");
|
|
@@ -2544,6 +2593,7 @@ var FORWARDED_ADE_ENV_VARS = /* @__PURE__ */ new Set([
|
|
|
2544
2593
|
function scrubAdeEnv(env) {
|
|
2545
2594
|
const result = {};
|
|
2546
2595
|
for (const [key, value] of Object.entries(env)) {
|
|
2596
|
+
if (key.startsWith("DAEX_")) continue;
|
|
2547
2597
|
if (key.startsWith("ADE_") && !FORWARDED_ADE_ENV_VARS.has(key)) continue;
|
|
2548
2598
|
result[key] = value;
|
|
2549
2599
|
}
|
|
@@ -2650,7 +2700,7 @@ async function startSidecar(options) {
|
|
|
2650
2700
|
};
|
|
2651
2701
|
const args = ["runtime", "run", "--socket", socketPath, "--profile", "embedded"];
|
|
2652
2702
|
const invocation = resolveSpawnInvocation(binaryPath, args, childEnv);
|
|
2653
|
-
logger(`
|
|
2703
|
+
logger(`daex sdk: spawning ${binaryPath} ${args.join(" ")}`);
|
|
2654
2704
|
let child;
|
|
2655
2705
|
try {
|
|
2656
2706
|
child = spawn(invocation.command, invocation.args, {
|
|
@@ -2732,7 +2782,7 @@ ${stderrTail.join("\n")}` : ""}`
|
|
|
2732
2782
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2733
2783
|
});
|
|
2734
2784
|
} catch (error) {
|
|
2735
|
-
logger(`
|
|
2785
|
+
logger(`daex sdk: could not record the runtime pidfile: ${errorMessage(error)}`);
|
|
2736
2786
|
}
|
|
2737
2787
|
}
|
|
2738
2788
|
return {
|
|
@@ -2902,7 +2952,7 @@ var RuntimeSupervisor = class _RuntimeSupervisor {
|
|
|
2902
2952
|
supervisor.handshaken = await supervisor.handshake(supervisor.bound);
|
|
2903
2953
|
const capabilities = supervisor.capabilities();
|
|
2904
2954
|
if (capabilities && Array.isArray(capabilities.actions) && capabilities.actions.length === 0) {
|
|
2905
|
-
deps.logger("
|
|
2955
|
+
deps.logger("daex sdk: the runtime reports no personal chat actions; calls will fail");
|
|
2906
2956
|
}
|
|
2907
2957
|
supervisor.stream = await supervisor.startEvents();
|
|
2908
2958
|
supervisor.watch();
|
|
@@ -3054,7 +3104,7 @@ var RuntimeSupervisor = class _RuntimeSupervisor {
|
|
|
3054
3104
|
}
|
|
3055
3105
|
const verdict = checkRuntimeCompatibility(result.runtimeInfo?.version ?? null);
|
|
3056
3106
|
if (!verdict.supported) {
|
|
3057
|
-
const line = `
|
|
3107
|
+
const line = `daex sdk: runtime ${verdict.version ?? "(unknown version)"} is outside the range this SDK supports (${SUPPORTED_RUNTIME_RANGE})` + (verdict.note ? ` \u2014 ${verdict.note}` : "");
|
|
3058
3108
|
if (options.requireCompatibleRuntime) {
|
|
3059
3109
|
bound.connection.close();
|
|
3060
3110
|
await bound.sidecar?.stop();
|
|
@@ -3156,7 +3206,7 @@ var RuntimeSupervisor = class _RuntimeSupervisor {
|
|
|
3156
3206
|
this.stream = await this.startEvents();
|
|
3157
3207
|
this.watch();
|
|
3158
3208
|
await this.deps.onRebound();
|
|
3159
|
-
logger(`
|
|
3209
|
+
logger(`daex sdk: runtime restarted (attempt ${attempt})`);
|
|
3160
3210
|
emitClient("restart", { attempt, ok: true, error: null, final: true });
|
|
3161
3211
|
emitClient("transport", { state: "reconnected", error: null });
|
|
3162
3212
|
return;
|
|
@@ -3170,7 +3220,7 @@ var RuntimeSupervisor = class _RuntimeSupervisor {
|
|
|
3170
3220
|
});
|
|
3171
3221
|
}
|
|
3172
3222
|
}
|
|
3173
|
-
logger(`
|
|
3223
|
+
logger(`daex sdk: gave up restarting the runtime after ${policy.maxAttempts} attempts`);
|
|
3174
3224
|
}
|
|
3175
3225
|
};
|
|
3176
3226
|
|
|
@@ -3756,7 +3806,7 @@ async function withResolvedHeaders(key, servers, resolve) {
|
|
|
3756
3806
|
function missingHeadersWarning(key, missing) {
|
|
3757
3807
|
if (missing.length === 0) return null;
|
|
3758
3808
|
const list = missing.map((entry) => `${entry.server} (${entry.headerNames.join(", ")})`).join("; ");
|
|
3759
|
-
return `
|
|
3809
|
+
return `daex sdk: thread "${key}" MCP servers need header values the SDK does not persist: ${list}. They were sent without them. Pass refresh.mcpServers to threads.open, or an mcpHeaders callback to createDaexChat, so the host supplies current credentials.`;
|
|
3760
3810
|
}
|
|
3761
3811
|
function mcpServersFingerprint(servers) {
|
|
3762
3812
|
const canonical = (value) => {
|
|
@@ -4206,7 +4256,7 @@ var ApprovalTracker = class {
|
|
|
4206
4256
|
if (!this.observed.has(observed.itemId)) return;
|
|
4207
4257
|
const { key, chats, logger } = this.deps;
|
|
4208
4258
|
logger(
|
|
4209
|
-
`
|
|
4259
|
+
`daex sdk: thread "${key}" approval "${observed.itemId}" was unanswered for ${timeoutMs}ms; declining it (approvalTimeoutMs)`
|
|
4210
4260
|
);
|
|
4211
4261
|
void chats.approve({
|
|
4212
4262
|
sessionId: this.deps.sessionId(),
|
|
@@ -4217,7 +4267,7 @@ var ApprovalTracker = class {
|
|
|
4217
4267
|
this.observed.delete(observed.itemId);
|
|
4218
4268
|
}).catch((error) => {
|
|
4219
4269
|
logger(
|
|
4220
|
-
`
|
|
4270
|
+
`daex sdk: thread "${key}" could not decline timed-out approval "${observed.itemId}": ${errorMessage(error)}`
|
|
4221
4271
|
);
|
|
4222
4272
|
});
|
|
4223
4273
|
}, timeoutMs);
|
|
@@ -4577,13 +4627,13 @@ var Thread = class {
|
|
|
4577
4627
|
}
|
|
4578
4628
|
});
|
|
4579
4629
|
void this.chats.interrupt(this.id).catch((error) => {
|
|
4580
|
-
this.logger(`
|
|
4630
|
+
this.logger(`daex sdk: could not interrupt thread "${this.key}" after its budget was exceeded: ${String(error)}`);
|
|
4581
4631
|
});
|
|
4582
4632
|
}
|
|
4583
4633
|
}
|
|
4584
4634
|
}).catch((error) => {
|
|
4585
4635
|
this.usageInitializationError = error instanceof Error ? error : new Error(String(error));
|
|
4586
|
-
this.logger(`
|
|
4636
|
+
this.logger(`daex sdk: could not load usage history for thread "${this.key}": ${this.usageInitializationError.message}`);
|
|
4587
4637
|
});
|
|
4588
4638
|
await this.usageInitialization;
|
|
4589
4639
|
}
|
|
@@ -4625,7 +4675,7 @@ var Thread = class {
|
|
|
4625
4675
|
});
|
|
4626
4676
|
if (type !== "done" && type !== "status" && this.currentTurnId) {
|
|
4627
4677
|
void this.chats.interrupt(this.id).catch((error) => {
|
|
4628
|
-
this.logger(`
|
|
4678
|
+
this.logger(`daex sdk: could not interrupt thread "${this.key}" after its budget was exceeded: ${String(error)}`);
|
|
4629
4679
|
});
|
|
4630
4680
|
}
|
|
4631
4681
|
}
|
|
@@ -4962,7 +5012,7 @@ var Thread = class {
|
|
|
4962
5012
|
if (problem === this.lastMcpRefreshProblem) return;
|
|
4963
5013
|
this.lastMcpRefreshProblem = problem;
|
|
4964
5014
|
this.logger(
|
|
4965
|
-
`
|
|
5015
|
+
`daex sdk: thread "${this.key}" could not refresh its MCP headers before the turn: ${problem}. The turn runs with the headers the session already has.`
|
|
4966
5016
|
);
|
|
4967
5017
|
}
|
|
4968
5018
|
}
|
|
@@ -5029,7 +5079,7 @@ var Thread = class {
|
|
|
5029
5079
|
if (!this.warnedAboutDerivedApprovals) {
|
|
5030
5080
|
this.warnedAboutDerivedApprovals = true;
|
|
5031
5081
|
this.logger(
|
|
5032
|
-
`
|
|
5082
|
+
`daex sdk: this runtime has no pendingInputs action, so pendingApprovals() for "${this.key}" is derived from the events this client observed; approvals raised before it connected are not listed`
|
|
5033
5083
|
);
|
|
5034
5084
|
}
|
|
5035
5085
|
return this.approvals.values().map(
|
|
@@ -5179,7 +5229,7 @@ var Thread = class {
|
|
|
5179
5229
|
if (this.warnedAboutHistoryPage) return;
|
|
5180
5230
|
this.warnedAboutHistoryPage = true;
|
|
5181
5231
|
this.logger(
|
|
5182
|
-
`
|
|
5232
|
+
`daex sdk: this runtime has no getEventHistoryPage action, so historyPage() for "${this.key}" can only return the newest page; older pages come back empty`
|
|
5183
5233
|
);
|
|
5184
5234
|
}
|
|
5185
5235
|
});
|
|
@@ -5214,40 +5264,40 @@ function threadOpenWarnings(input) {
|
|
|
5214
5264
|
const expectsCapabilityReport = suppliedServers || loadUserMcpServers === false;
|
|
5215
5265
|
if (expectsCapabilityReport && !mcpCapability) {
|
|
5216
5266
|
lines.push(
|
|
5217
|
-
`
|
|
5267
|
+
`daex sdk: thread "${key}" requested MCP but the runtime reported no capability; treat the guarantee as unverified`
|
|
5218
5268
|
);
|
|
5219
5269
|
}
|
|
5220
5270
|
if (suppliedServers && mcpCapability?.level === "unsupported") {
|
|
5221
5271
|
lines.push(
|
|
5222
|
-
`
|
|
5272
|
+
`daex sdk: thread "${key}" opened WITHOUT the requested MCP servers (${mcpCapability.mechanism})`
|
|
5223
5273
|
);
|
|
5224
5274
|
}
|
|
5225
5275
|
if (mcpCapability?.residual) {
|
|
5226
|
-
lines.push(`
|
|
5276
|
+
lines.push(`daex sdk: thread "${key}" MCP strict mode is best-effort: ${mcpCapability.residual}`);
|
|
5227
5277
|
}
|
|
5228
5278
|
if (instructions && !instructionsCapability) {
|
|
5229
5279
|
lines.push(
|
|
5230
|
-
`
|
|
5280
|
+
`daex sdk: thread "${key}" sent instructions but the runtime reported no capability; treat the text as possibly not delivered`
|
|
5231
5281
|
);
|
|
5232
5282
|
}
|
|
5233
5283
|
if (settingSources && !settingSourcesCapability) {
|
|
5234
5284
|
lines.push(
|
|
5235
|
-
`
|
|
5285
|
+
`daex sdk: thread "${key}" sent settingSources but the runtime reported no capability; the provider's configuration layers are unknown`
|
|
5236
5286
|
);
|
|
5237
5287
|
}
|
|
5238
5288
|
if (permissionPolicy && !permissionCapability) {
|
|
5239
5289
|
lines.push(
|
|
5240
|
-
`
|
|
5290
|
+
`daex sdk: thread "${key}" sent a permission policy but the runtime reported no capability; treat the policy as unenforced`
|
|
5241
5291
|
);
|
|
5242
5292
|
}
|
|
5243
5293
|
if (instructionsCapability && instructionsCapability.level !== "applied") {
|
|
5244
5294
|
lines.push(
|
|
5245
|
-
`
|
|
5295
|
+
`daex sdk: thread "${key}" instructions are ${instructionsCapability.level}${instructionsCapability.detail ? `: ${instructionsCapability.detail}` : ""}`
|
|
5246
5296
|
);
|
|
5247
5297
|
}
|
|
5248
5298
|
if (settingSourcesCapability && settingSourcesCapability.level === "ignored") {
|
|
5249
5299
|
lines.push(
|
|
5250
|
-
`
|
|
5300
|
+
`daex sdk: thread "${key}" settingSources was ignored by this provider${settingSourcesCapability.detail ? `: ${settingSourcesCapability.detail}` : ""}`
|
|
5251
5301
|
);
|
|
5252
5302
|
}
|
|
5253
5303
|
if (permissionPolicy?.fallback === "deny") {
|
|
@@ -5255,20 +5305,20 @@ function threadOpenWarnings(input) {
|
|
|
5255
5305
|
const blocked = mcpServersNotCoveredByPolicy(permissionPolicy, Object.keys(mcpServers));
|
|
5256
5306
|
if (blocked.length > 0) {
|
|
5257
5307
|
lines.push(
|
|
5258
|
-
`
|
|
5308
|
+
`daex sdk: thread "${key}" fallback: deny blocks every tool of MCP servers not named by the policy: ${blocked.join(", ")}`
|
|
5259
5309
|
);
|
|
5260
5310
|
}
|
|
5261
5311
|
}
|
|
5262
5312
|
const toolEntries = individualMcpToolEntries(permissionPolicy);
|
|
5263
5313
|
if (toolEntries.length > 0) {
|
|
5264
5314
|
lines.push(
|
|
5265
|
-
`
|
|
5315
|
+
`daex sdk: thread "${key}" names individual MCP tools (${toolEntries.join(", ")}); on Claude an individual MCP tool entry admits the whole server; read permissionCapability.residual`
|
|
5266
5316
|
);
|
|
5267
5317
|
}
|
|
5268
5318
|
}
|
|
5269
5319
|
if (permissionCapability && permissionCapability.level !== "enforced") {
|
|
5270
5320
|
lines.push(
|
|
5271
|
-
`
|
|
5321
|
+
`daex sdk: thread "${key}" permission policy is ${permissionCapability.level}${permissionCapability.residual ? `: ${permissionCapability.residual}` : ""}`
|
|
5272
5322
|
);
|
|
5273
5323
|
}
|
|
5274
5324
|
return lines;
|
|
@@ -5286,7 +5336,7 @@ function threadResumeMismatchWarnings(input) {
|
|
|
5286
5336
|
const { key, supplied, stored } = input;
|
|
5287
5337
|
const verb = input.verb ?? "resumed";
|
|
5288
5338
|
const lines = [];
|
|
5289
|
-
const ignored = (field, storedValue) => `
|
|
5339
|
+
const ignored = (field, storedValue) => `daex sdk: thread "${key}" ${verb} with its stored ${field} (${storedValue}); the ${field} passed to open() was ignored`;
|
|
5290
5340
|
if (supplied.cwd !== void 0 && supplied.cwd !== stored.cwd) {
|
|
5291
5341
|
lines.push(ignored("cwd", stored.cwd ?? "the runtime's default workspace"));
|
|
5292
5342
|
}
|
|
@@ -5445,7 +5495,7 @@ function createThreadOpener(ctx) {
|
|
|
5445
5495
|
const needing = Object.values(source).filter(isRemoteWithHeaders).length;
|
|
5446
5496
|
if (resolved.missing.length >= needing) {
|
|
5447
5497
|
logger(
|
|
5448
|
-
`
|
|
5498
|
+
`daex sdk: thread "${key}" did not re-send its MCP servers: the mcpHeaders callback supplied no header values for ${resolved.missing.map((entry) => entry.server).join(", ")}, and re-sending would replace the session's current credentials with none`
|
|
5449
5499
|
);
|
|
5450
5500
|
return null;
|
|
5451
5501
|
}
|
|
@@ -5454,13 +5504,13 @@ function createThreadOpener(ctx) {
|
|
|
5454
5504
|
if (warning) logger(warning);
|
|
5455
5505
|
if (!ctx.runtime.updateMcpServers()) {
|
|
5456
5506
|
logger(
|
|
5457
|
-
`
|
|
5507
|
+
`daex sdk: thread "${key}" could not refresh its MCP servers: this runtime does not advertise capabilities.personalChats.updateMcpServers, so it keeps the servers it already has`
|
|
5458
5508
|
);
|
|
5459
5509
|
return null;
|
|
5460
5510
|
}
|
|
5461
5511
|
if (hasMcpToolFilters(resolved.servers) && !ctx.runtime.mcpToolFilters()) {
|
|
5462
5512
|
logger(
|
|
5463
|
-
`
|
|
5513
|
+
`daex sdk: thread "${key}" could not refresh its MCP servers: they carry allowedTools / disallowedTools and this runtime does not advertise capabilities.personalChats.mcpToolFilters, so it would drop them`
|
|
5464
5514
|
);
|
|
5465
5515
|
return null;
|
|
5466
5516
|
}
|
|
@@ -5480,7 +5530,7 @@ function createThreadOpener(ctx) {
|
|
|
5480
5530
|
const budget = validateThreadBudget(record3.budget ?? opts.budget);
|
|
5481
5531
|
if (!record3.budget && budget) await persistThread(key)({ budget });
|
|
5482
5532
|
else if (record3.budget && opts.budget && !sameJson(record3.budget, opts.budget)) {
|
|
5483
|
-
logger(`
|
|
5533
|
+
logger(`daex sdk: thread "${key}" ignored a different budget on resume; the stored budget remains in force`);
|
|
5484
5534
|
}
|
|
5485
5535
|
await pushResolvedSecret(summary.sessionId, record3.provider || summary.provider, record3.credentialId);
|
|
5486
5536
|
await persistThread(key)({ title: summary.title ?? record3.title ?? null });
|
|
@@ -5572,7 +5622,7 @@ function createThreadOpener(ctx) {
|
|
|
5572
5622
|
recordError("getSummary", error);
|
|
5573
5623
|
}
|
|
5574
5624
|
if (summary?.sessionId) return resumeThread(key, record3, summary, opts, { supplied, stored });
|
|
5575
|
-
logger(`
|
|
5625
|
+
logger(`daex sdk: thread "${key}" pointed at a session the runtime no longer has; creating a new one`);
|
|
5576
5626
|
for (const line of threadResumeMismatchWarnings({ key, verb: "recreated", supplied, stored })) logger(line);
|
|
5577
5627
|
}
|
|
5578
5628
|
return createThread(key, opts, record3);
|
|
@@ -5594,7 +5644,7 @@ function createThreadOpener(ctx) {
|
|
|
5594
5644
|
const value = stored ?? requested;
|
|
5595
5645
|
if (value === void 0 || !providerCapabilities || supported(value)) return value;
|
|
5596
5646
|
if (stored === void 0) throw new DaexError("invalid_option", refusal(value));
|
|
5597
|
-
logger(`
|
|
5647
|
+
logger(`daex sdk: thread "${key}" dropped a stored setting its provider no longer supports: ${refusal(value)}`);
|
|
5598
5648
|
return void 0;
|
|
5599
5649
|
};
|
|
5600
5650
|
const permissionMode = fits(
|
|
@@ -5880,10 +5930,10 @@ var ThreadStore = class _ThreadStore {
|
|
|
5880
5930
|
if (migrated) {
|
|
5881
5931
|
try {
|
|
5882
5932
|
await this.writeFile(file);
|
|
5883
|
-
this.logger(`
|
|
5933
|
+
this.logger(`daex sdk: removed stored MCP header values from ${this.filePath}; only header names are kept`);
|
|
5884
5934
|
} catch (error) {
|
|
5885
5935
|
this.logger(
|
|
5886
|
-
`
|
|
5936
|
+
`daex sdk: could not rewrite ${this.filePath} to remove stored MCP header values (${errorMessage(error)})`
|
|
5887
5937
|
);
|
|
5888
5938
|
}
|
|
5889
5939
|
}
|
|
@@ -5892,7 +5942,7 @@ var ThreadStore = class _ThreadStore {
|
|
|
5892
5942
|
const code = error.code;
|
|
5893
5943
|
if (code !== "ENOENT") {
|
|
5894
5944
|
this.logger(
|
|
5895
|
-
`
|
|
5945
|
+
`daex sdk: ${this.filePath} was unreadable (${errorMessage(error)}); starting a new thread map`
|
|
5896
5946
|
);
|
|
5897
5947
|
}
|
|
5898
5948
|
this.cache = { version: 1, threads: {} };
|
|
@@ -6005,7 +6055,7 @@ async function createDaexChat(options) {
|
|
|
6005
6055
|
const recordError = (scope, error) => {
|
|
6006
6056
|
recentErrors.push({ at: (/* @__PURE__ */ new Date()).toISOString(), scope, message: errorMessage(error) });
|
|
6007
6057
|
while (recentErrors.length > MAX_RECENT_ERRORS) recentErrors.shift();
|
|
6008
|
-
logger(`
|
|
6058
|
+
logger(`daex sdk: ${scope} failed: ${errorMessage(error)}`);
|
|
6009
6059
|
};
|
|
6010
6060
|
let disposed = false;
|
|
6011
6061
|
const assertUsable = () => {
|
|
@@ -6017,7 +6067,7 @@ async function createDaexChat(options) {
|
|
|
6017
6067
|
try {
|
|
6018
6068
|
listener(payload);
|
|
6019
6069
|
} catch (error) {
|
|
6020
|
-
logger(`
|
|
6070
|
+
logger(`daex sdk: a "${event}" listener threw: ${errorMessage(error)}`);
|
|
6021
6071
|
}
|
|
6022
6072
|
}
|
|
6023
6073
|
};
|
|
@@ -6206,7 +6256,7 @@ async function createDaexChat(options) {
|
|
|
6206
6256
|
}
|
|
6207
6257
|
if (refresh.mcpServers) {
|
|
6208
6258
|
await existing.updateMcpServers(refresh.mcpServers).catch((error) => {
|
|
6209
|
-
logger(`
|
|
6259
|
+
logger(`daex sdk: thread "${trimmedKey}" could not apply refresh.mcpServers: ${errorMessage(error)}`);
|
|
6210
6260
|
});
|
|
6211
6261
|
}
|
|
6212
6262
|
return existing;
|
|
@@ -6269,7 +6319,7 @@ async function createDaexChat(options) {
|
|
|
6269
6319
|
try {
|
|
6270
6320
|
listener(models);
|
|
6271
6321
|
} catch (error) {
|
|
6272
|
-
logger(`
|
|
6322
|
+
logger(`daex sdk: a models.onChange listener threw: ${errorMessage(error)}`);
|
|
6273
6323
|
}
|
|
6274
6324
|
}
|
|
6275
6325
|
}).catch((error) => recordError("models.onChange", error));
|
|
@@ -6476,7 +6526,7 @@ async function createDaexChat(options) {
|
|
|
6476
6526
|
clientListeners.clear();
|
|
6477
6527
|
await runtime.dispose();
|
|
6478
6528
|
hub.clear();
|
|
6479
|
-
logger("
|
|
6529
|
+
logger("daex sdk: disposed");
|
|
6480
6530
|
}
|
|
6481
6531
|
};
|
|
6482
6532
|
return client;
|
package/dist/server.cjs
CHANGED
|
@@ -983,7 +983,7 @@ function createDaexServer(options) {
|
|
|
983
983
|
const result = await handler(params);
|
|
984
984
|
send({ id, ok: true, result: result === void 0 ? null : result });
|
|
985
985
|
} catch (error) {
|
|
986
|
-
options.logger?.("
|
|
986
|
+
options.logger?.("daex sdk server: " + request.method + " failed: " + (error instanceof Error ? error.message : String(error)));
|
|
987
987
|
send({ id, ok: false, error: serializeAdeError(error) });
|
|
988
988
|
} finally {
|
|
989
989
|
requestIds.delete(id);
|
package/dist/server.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderStatus, aH as Unsubscribe, ae as ProviderCapabilities, aW as AccountManagement, a7 as ModelCatalogEntry, U as DaexThread, T as ThreadModelSelection, M as McpCapabilityReport, I as InstructionsCapability, S as SettingSourcesCapability, b as PermissionCapability, _ as HistoryPageOptions, av as ThreadHistoryPage, aG as ThreadUsage, d as ThreadSummary, W as DoctorReport, D as DaexClientEvent, a as DaexClientEventMap, c as DaexChatClient, e as ThreadOpenOptions, f as ThreadResumeOptions } from './client-
|
|
1
|
+
import { P as ProviderStatus, aH as Unsubscribe, ae as ProviderCapabilities, aW as AccountManagement, a7 as ModelCatalogEntry, U as DaexThread, T as ThreadModelSelection, M as McpCapabilityReport, I as InstructionsCapability, S as SettingSourcesCapability, b as PermissionCapability, _ as HistoryPageOptions, av as ThreadHistoryPage, aG as ThreadUsage, d as ThreadSummary, W as DoctorReport, D as DaexClientEvent, a as DaexClientEventMap, c as DaexChatClient, e as ThreadOpenOptions, f as ThreadResumeOptions } from './client-DVZHOtg6.cjs';
|
|
2
2
|
|
|
3
3
|
/** A browser WebSocket, Node ws socket, or a small adapter around either. */
|
|
4
4
|
type DaexRemoteTransport = {
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as ProviderStatus, aH as Unsubscribe, ae as ProviderCapabilities, aW as AccountManagement, a7 as ModelCatalogEntry, U as DaexThread, T as ThreadModelSelection, M as McpCapabilityReport, I as InstructionsCapability, S as SettingSourcesCapability, b as PermissionCapability, _ as HistoryPageOptions, av as ThreadHistoryPage, aG as ThreadUsage, d as ThreadSummary, W as DoctorReport, D as DaexClientEvent, a as DaexClientEventMap, c as DaexChatClient, e as ThreadOpenOptions, f as ThreadResumeOptions } from './client-
|
|
1
|
+
import { P as ProviderStatus, aH as Unsubscribe, ae as ProviderCapabilities, aW as AccountManagement, a7 as ModelCatalogEntry, U as DaexThread, T as ThreadModelSelection, M as McpCapabilityReport, I as InstructionsCapability, S as SettingSourcesCapability, b as PermissionCapability, _ as HistoryPageOptions, av as ThreadHistoryPage, aG as ThreadUsage, d as ThreadSummary, W as DoctorReport, D as DaexClientEvent, a as DaexClientEventMap, c as DaexChatClient, e as ThreadOpenOptions, f as ThreadResumeOptions } from './client-DVZHOtg6.js';
|
|
2
2
|
|
|
3
3
|
/** A browser WebSocket, Node ws socket, or a small adapter around either. */
|
|
4
4
|
type DaexRemoteTransport = {
|