@dimi-agent/cli 0.5.2 → 0.5.4
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/dist/main.mjs +97 -27
- package/package.json +10 -3
package/dist/main.mjs
CHANGED
|
@@ -6,6 +6,9 @@ const __dirname = __cjsShimDirname(__filename);
|
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import * as nodeFs from "node:fs";
|
|
8
8
|
import Vt, { ReadStream, accessSync, appendFileSync, chmodSync, closeSync, constants, copyFileSync, createReadStream, createWriteStream, existsSync, fstatSync, lstatSync, mkdirSync, openSync, promises, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
|
+
import * as nodePath from "node:path";
|
|
10
|
+
import path, { basename, dirname, extname, isAbsolute, join, normalize, parse, posix, relative, resolve, sep, win32 } from "node:path";
|
|
11
|
+
import { fileURLToPath, format, pathToFileURL } from "node:url";
|
|
9
12
|
import jn, { access, appendFile, chmod, copyFile, cp, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
10
13
|
import so from "node:assert";
|
|
11
14
|
import net, { BlockList, isIP } from "node:net";
|
|
@@ -18,10 +21,7 @@ import * as zlib$14 from "node:zlib";
|
|
|
18
21
|
import zlib from "node:zlib";
|
|
19
22
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
20
23
|
import crypto$1, { createHash, createHmac, getRandomValues, randomBytes, randomInt, randomUUID, timingSafeEqual } from "node:crypto";
|
|
21
|
-
import { fileURLToPath, format, pathToFileURL } from "node:url";
|
|
22
24
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
|
-
import * as nodePath from "node:path";
|
|
24
|
-
import path, { basename, dirname, extname, isAbsolute, join, normalize, parse, posix, relative, resolve, sep, win32 } from "node:path";
|
|
25
25
|
import { lookup } from "node:dns";
|
|
26
26
|
import Kr, { EventEmitter as EventEmitter$1 } from "events";
|
|
27
27
|
import { Buffer as Buffer$2 } from "buffer";
|
|
@@ -99274,18 +99274,34 @@ var init_loginShellPath = __esmMin((() => {
|
|
|
99274
99274
|
* live in `dimi-wire` (Rust) and `@dimi-agent/transcript` (zod) and are
|
|
99275
99275
|
* cross-checked by the differential test suite.
|
|
99276
99276
|
*/
|
|
99277
|
+
function loadPlatformSubpackage() {
|
|
99278
|
+
try {
|
|
99279
|
+
return nodeRequire$4(PLATFORM_SUBPACKAGE);
|
|
99280
|
+
} catch {
|
|
99281
|
+
return null;
|
|
99282
|
+
}
|
|
99283
|
+
}
|
|
99277
99284
|
/**
|
|
99278
|
-
* Loads the native binding, building nothing.
|
|
99279
|
-
*
|
|
99285
|
+
* Loads the native binding, building nothing. Resolution order:
|
|
99286
|
+
* 1. `dist/dimi_bridge.node` next to the package — the dev / workspace
|
|
99287
|
+
* layout (local cargo builds always win).
|
|
99288
|
+
* 2. the npm platform subpackage (`@dimi-agent/dimi-native-<platform>-<arch>`)
|
|
99289
|
+
* — npm installs >=0.5.4; the SEA binary's module hook redirects the same
|
|
99290
|
+
* specifier into the embedded native-asset cache.
|
|
99291
|
+
* Throws with a pointer to the build command when neither exists.
|
|
99280
99292
|
*/
|
|
99281
99293
|
function loadNative() {
|
|
99282
99294
|
if (binding) return binding;
|
|
99283
99295
|
try {
|
|
99284
|
-
binding =
|
|
99285
|
-
|
|
99286
|
-
|
|
99296
|
+
binding = nodeRequire$4("../dist/dimi_bridge.node");
|
|
99297
|
+
return binding;
|
|
99298
|
+
} catch {}
|
|
99299
|
+
const platformBinding = loadPlatformSubpackage();
|
|
99300
|
+
if (platformBinding !== null) {
|
|
99301
|
+
binding = platformBinding;
|
|
99302
|
+
return binding;
|
|
99287
99303
|
}
|
|
99288
|
-
|
|
99304
|
+
throw new Error("dimi-native: native binding not found; run `pnpm --filter @dimi-agent/dimi-native run build:native`");
|
|
99289
99305
|
}
|
|
99290
99306
|
/** Full cold rebuild: wire records JSON array → snapshot JSON. */
|
|
99291
99307
|
function coldRebuild(recordsJson) {
|
|
@@ -99321,9 +99337,10 @@ function rustHostEnvironmentProbe() {
|
|
|
99321
99337
|
function rustTerminalSpawn(options) {
|
|
99322
99338
|
return loadNative().RustTerminal.spawn(options);
|
|
99323
99339
|
}
|
|
99324
|
-
var
|
|
99340
|
+
var nodeRequire$4, binding, PLATFORM_SUBPACKAGE, RustAgentTranscript, RustFileSystem;
|
|
99325
99341
|
var init_src$7 = __esmMin((() => {
|
|
99326
|
-
|
|
99342
|
+
nodeRequire$4 = createRequire(import.meta.url);
|
|
99343
|
+
PLATFORM_SUBPACKAGE = `@dimi-agent/dimi-native-${process.platform}-${process.arch}`;
|
|
99327
99344
|
RustAgentTranscript = class {
|
|
99328
99345
|
#inner;
|
|
99329
99346
|
constructor(agentId) {
|
|
@@ -99601,7 +99618,6 @@ function toRustOptions$1(options) {
|
|
|
99601
99618
|
}
|
|
99602
99619
|
var ERRNO_PREFIX, RustHostFileSystem;
|
|
99603
99620
|
var init_rustHostFileSystemService = __esmMin((() => {
|
|
99604
|
-
init_scope();
|
|
99605
99621
|
init_src$7();
|
|
99606
99622
|
init_hostFileSystem();
|
|
99607
99623
|
init_hostFsErrors();
|
|
@@ -393981,6 +393997,20 @@ var init_upgrade = __esmMin((() => {
|
|
|
393981
393997
|
}));
|
|
393982
393998
|
//#endregion
|
|
393983
393999
|
//#region src/native/module-hook.ts
|
|
394000
|
+
/**
|
|
394001
|
+
* The cached dimi_bridge.node for the requested binding subpackage, or null
|
|
394002
|
+
* when the package resolves normally (dev / npm installs — the real package
|
|
394003
|
+
* wins) or the native-asset tree has no such package.
|
|
394004
|
+
*/
|
|
394005
|
+
function dimiNativeBindingPath(request) {
|
|
394006
|
+
try {
|
|
394007
|
+
nodeRequire.resolve(request);
|
|
394008
|
+
return null;
|
|
394009
|
+
} catch {}
|
|
394010
|
+
const pkgRoot = getNativePackageRoot(request);
|
|
394011
|
+
if (pkgRoot === null) return null;
|
|
394012
|
+
return join(pkgRoot, "dimi_bridge.node");
|
|
394013
|
+
}
|
|
393984
394014
|
function installNativeModuleHook() {
|
|
393985
394015
|
if (installed) return;
|
|
393986
394016
|
installed = true;
|
|
@@ -393988,28 +394018,38 @@ function installNativeModuleHook() {
|
|
|
393988
394018
|
const originalLoad = moduleBuiltin._load;
|
|
393989
394019
|
if (originalLoad === void 0) return;
|
|
393990
394020
|
moduleBuiltin._load = function loadWithNativeAssets(request, parent, isMain) {
|
|
393991
|
-
if (typeof request === "string"
|
|
393992
|
-
|
|
393993
|
-
|
|
393994
|
-
|
|
393995
|
-
|
|
393996
|
-
|
|
393997
|
-
|
|
394021
|
+
if (typeof request === "string") {
|
|
394022
|
+
if (PI_TUI_NATIVE_PATTERN.test(request) && !existsSync(request)) {
|
|
394023
|
+
const pkgRoot = getNativePackageRoot("@dimi-agent/pi-tui");
|
|
394024
|
+
if (pkgRoot !== null) {
|
|
394025
|
+
const match = request.match(PI_TUI_NATIVE_PATTERN);
|
|
394026
|
+
if (match !== null) {
|
|
394027
|
+
const redirected = join(pkgRoot, match[0]);
|
|
394028
|
+
return originalLoad.call(this, redirected, parent, isMain);
|
|
394029
|
+
}
|
|
393998
394030
|
}
|
|
394031
|
+
} else if (DIMI_NATIVE_SUBPACKAGE.test(request)) {
|
|
394032
|
+
const redirected = dimiNativeBindingPath(request);
|
|
394033
|
+
if (redirected !== null) return originalLoad.call(this, redirected, parent, isMain);
|
|
393999
394034
|
}
|
|
394000
394035
|
}
|
|
394001
394036
|
return originalLoad.call(this, request, parent, isMain);
|
|
394002
394037
|
};
|
|
394003
394038
|
}
|
|
394004
|
-
var nodeRequire, installed, PI_TUI_NATIVE_PATTERN;
|
|
394039
|
+
var nodeRequire, installed, PI_TUI_NATIVE_PATTERN, DIMI_NATIVE_SUBPACKAGE;
|
|
394005
394040
|
var init_module_hook = __esmMin((() => {
|
|
394006
394041
|
init_native_assets();
|
|
394007
394042
|
nodeRequire = createRequire(import.meta.url);
|
|
394008
394043
|
installed = false;
|
|
394009
394044
|
PI_TUI_NATIVE_PATTERN = /native[\\/](?:win32|darwin)[\\/]prebuilds[\\/].+\.node$/;
|
|
394045
|
+
DIMI_NATIVE_SUBPACKAGE = /^@dimi-agent\/dimi-native-(?:darwin|linux|win32)-(?:arm64|x64)$/;
|
|
394010
394046
|
}));
|
|
394011
394047
|
//#endregion
|
|
394012
394048
|
//#region src/native/smoke.ts
|
|
394049
|
+
function smokeDimiNativeLoad() {
|
|
394050
|
+
const info = createRequire(import.meta.url)(dimiNativePackage)?.RustHostEnvironment?.probe?.();
|
|
394051
|
+
if (typeof info !== "object" || info === null || typeof info.osKind !== "string") throw new Error("dimi-native binding loaded but probe() returned an unexpected shape");
|
|
394052
|
+
}
|
|
394013
394053
|
function smokePiTuiNativeLoad() {
|
|
394014
394054
|
const platform = process.platform;
|
|
394015
394055
|
const arch = process.arch;
|
|
@@ -394027,6 +394067,7 @@ function runNativeAssetSmokeIfRequested() {
|
|
|
394027
394067
|
if (manifest === null) throw new Error("Native asset manifest is not available.");
|
|
394028
394068
|
for (const packageName of smokePackages) if (getNativePackageRoot(packageName, { manifest }) === null) throw new Error(`Native package is not available: ${packageName}`);
|
|
394029
394069
|
smokePiTuiNativeLoad();
|
|
394070
|
+
smokeDimiNativeLoad();
|
|
394030
394071
|
process.stdout.write(`Native asset smoke passed: ${manifest.target}\n`);
|
|
394031
394072
|
process.exit(0);
|
|
394032
394073
|
} catch (error) {
|
|
@@ -394035,10 +394076,15 @@ function runNativeAssetSmokeIfRequested() {
|
|
|
394035
394076
|
process.exit(1);
|
|
394036
394077
|
}
|
|
394037
394078
|
}
|
|
394038
|
-
var smokePackages;
|
|
394079
|
+
var dimiNativePackage, smokePackages;
|
|
394039
394080
|
var init_smoke = __esmMin((() => {
|
|
394040
394081
|
init_native_assets();
|
|
394041
|
-
|
|
394082
|
+
dimiNativePackage = `@dimi-agent/dimi-native-${process.platform}-${process.arch}`;
|
|
394083
|
+
smokePackages = [
|
|
394084
|
+
"@mariozechner/clipboard",
|
|
394085
|
+
"@dimi-agent/pi-tui",
|
|
394086
|
+
dimiNativePackage
|
|
394087
|
+
];
|
|
394042
394088
|
}));
|
|
394043
394089
|
//#endregion
|
|
394044
394090
|
//#region src/main-app.ts
|
|
@@ -394174,14 +394220,38 @@ var init_main_app = __esmMin((() => {
|
|
|
394174
394220
|
/**
|
|
394175
394221
|
* Dimi process entry point.
|
|
394176
394222
|
*
|
|
394177
|
-
* This file must stay dependency-free (no static imports): ESM
|
|
394178
|
-
* imports resolve and evaluate *before* any top-level code here runs,
|
|
394179
|
-
* the agent-core-v2 OS backend modules read the legacy switch at module
|
|
394223
|
+
* This file must stay dependency-free (no static project imports): ESM
|
|
394224
|
+
* static imports resolve and evaluate *before* any top-level code here runs,
|
|
394225
|
+
* and the agent-core-v2 OS backend modules read the legacy switch at module
|
|
394180
394226
|
* load time. The process-wide `--legacy` flag therefore has to be set from
|
|
394181
394227
|
* argv before anything else loads, then the real entry (`main-app`) is
|
|
394182
|
-
* loaded dynamically.
|
|
394228
|
+
* loaded dynamically. Only node built-ins are imported here.
|
|
394183
394229
|
*/
|
|
394184
394230
|
if (process.argv.includes("--legacy")) process.env["DIMI_LEGACY"] = "1";
|
|
394185
|
-
|
|
394231
|
+
if (process.env["DIMI_LEGACY"] !== "1" && !nativeBindingAvailable()) {
|
|
394232
|
+
process.env["DIMI_LEGACY"] = "1";
|
|
394233
|
+
process.stderr.write("dimi: native runtime unavailable (dimi_bridge.node not found); falling back to the legacy TypeScript backend. Reinstall or run \"dimi upgrade\" to get the Rust runtime.\n");
|
|
394234
|
+
}
|
|
394235
|
+
Promise.resolve().then(() => (init_main_app(), main_app_exports)).catch((error) => {
|
|
394236
|
+
process.stderr.write(`dimi: failed to start: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
394237
|
+
process.exit(1);
|
|
394238
|
+
});
|
|
394239
|
+
/** Locate the napi binding without loading it. */
|
|
394240
|
+
function nativeBindingAvailable() {
|
|
394241
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
394242
|
+
try {
|
|
394243
|
+
const sea = nodeRequire("node:sea");
|
|
394244
|
+
if (typeof sea?.isSea === "function" && sea.isSea()) return true;
|
|
394245
|
+
} catch {}
|
|
394246
|
+
if (existsSync(resolve(dirname(fileURLToPath(import.meta.url)), "../dist/dimi_bridge.node"))) return true;
|
|
394247
|
+
try {
|
|
394248
|
+
nodeRequire.resolve(`@dimi-agent/dimi-native-${process.platform}-${process.arch}`);
|
|
394249
|
+
return true;
|
|
394250
|
+
} catch {}
|
|
394251
|
+
try {
|
|
394252
|
+
if (existsSync(resolve(dirname(nodeRequire.resolve("@dimi-agent/dimi-native/package.json")), "dist/dimi_bridge.node"))) return true;
|
|
394253
|
+
} catch {}
|
|
394254
|
+
return false;
|
|
394255
|
+
}
|
|
394186
394256
|
//#endregion
|
|
394187
394257
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimi-agent/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "The Starting Point for Next-Gen Agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
|
+
"!dist/dimi_bridge.node",
|
|
30
31
|
"dist-web",
|
|
31
32
|
"native",
|
|
32
33
|
"README.md"
|
|
@@ -60,17 +61,23 @@
|
|
|
60
61
|
"yazl": "^3.3.1",
|
|
61
62
|
"zod": "^4.3.6",
|
|
62
63
|
"@dimi-agent/agent-core-v2": "^0.1.0",
|
|
64
|
+
"@dimi-agent/dimi-oauth": "^0.1.0",
|
|
63
65
|
"@dimi-agent/dimi-sdk": "^0.2.0",
|
|
64
66
|
"@dimi-agent/dimi-telemetry": "^0.1.0",
|
|
65
67
|
"@dimi-agent/dimi-web": "^0.1.0",
|
|
66
|
-
"@dimi-agent/dimi-oauth": "^0.1.0",
|
|
67
68
|
"@dimi-agent/kap-server": "^0.1.0",
|
|
68
69
|
"@dimi-agent/remote": "^0.1.0",
|
|
69
70
|
"@dimi-agent/pi-tui": "^0.1.0"
|
|
70
71
|
},
|
|
71
72
|
"optionalDependencies": {
|
|
72
73
|
"@mariozechner/clipboard": "^0.3.9",
|
|
73
|
-
"node-pty": "^1.1.0"
|
|
74
|
+
"node-pty": "^1.1.0",
|
|
75
|
+
"@dimi-agent/dimi-native-darwin-arm64": ">=0.5.3 <1",
|
|
76
|
+
"@dimi-agent/dimi-native-darwin-x64": ">=0.5.3 <1",
|
|
77
|
+
"@dimi-agent/dimi-native-linux-x64": ">=0.5.3 <1",
|
|
78
|
+
"@dimi-agent/dimi-native-linux-arm64": ">=0.5.3 <1",
|
|
79
|
+
"@dimi-agent/dimi-native-win32-x64": ">=0.5.3 <1",
|
|
80
|
+
"@dimi-agent/dimi-native-win32-arm64": ">=0.5.3 <1"
|
|
74
81
|
},
|
|
75
82
|
"engines": {
|
|
76
83
|
"node": ">=22.19.0"
|