motebit 1.11.2 → 1.11.3
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/index.js +392 -302
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -361,17 +361,17 @@ function optimalPathTrace(graph, source, target) {
|
|
|
361
361
|
const value = dist.get(target) ?? sr.zero;
|
|
362
362
|
if (value === sr.zero && source !== target)
|
|
363
363
|
return null;
|
|
364
|
-
const
|
|
364
|
+
const path20 = [];
|
|
365
365
|
let current2 = target;
|
|
366
366
|
const visited = /* @__PURE__ */ new Set();
|
|
367
367
|
while (current2 != null && !visited.has(current2)) {
|
|
368
368
|
visited.add(current2);
|
|
369
|
-
|
|
369
|
+
path20.unshift(current2);
|
|
370
370
|
current2 = pred.get(current2) ?? null;
|
|
371
371
|
}
|
|
372
|
-
if (
|
|
372
|
+
if (path20[0] !== source)
|
|
373
373
|
return null;
|
|
374
|
-
return { value, path:
|
|
374
|
+
return { value, path: path20 };
|
|
375
375
|
}
|
|
376
376
|
var init_traversal = __esm({
|
|
377
377
|
"../../packages/protocol/dist/traversal.js"() {
|
|
@@ -25587,7 +25587,7 @@ var init_config2 = __esm({
|
|
|
25587
25587
|
"src/config.ts"() {
|
|
25588
25588
|
"use strict";
|
|
25589
25589
|
init_esm_shims();
|
|
25590
|
-
VERSION = true ? "1.11.
|
|
25590
|
+
VERSION = true ? "1.11.3" : "0.0.0-dev";
|
|
25591
25591
|
CONFIG_DIR = process.env["MOTEBIT_CONFIG_DIR"] ?? path2.join(os.homedir(), ".motebit");
|
|
25592
25592
|
CONFIG_PATH = path2.join(CONFIG_DIR, "config.json");
|
|
25593
25593
|
RELAY_DIR = path2.join(CONFIG_DIR, "relay");
|
|
@@ -26457,13 +26457,13 @@ var init_intelligence = __esm({
|
|
|
26457
26457
|
});
|
|
26458
26458
|
|
|
26459
26459
|
// ../../packages/runtime/dist/commands/types.js
|
|
26460
|
-
async function relayFetch(relay,
|
|
26460
|
+
async function relayFetch(relay, path20, options) {
|
|
26461
26461
|
const headers = {
|
|
26462
26462
|
"Content-Type": "application/json",
|
|
26463
26463
|
Authorization: `Bearer ${relay.authToken}`,
|
|
26464
26464
|
...options?.headers
|
|
26465
26465
|
};
|
|
26466
|
-
const res = await fetch(`${relay.relayUrl}${
|
|
26466
|
+
const res = await fetch(`${relay.relayUrl}${path20}`, { ...options, headers });
|
|
26467
26467
|
if (!res.ok) {
|
|
26468
26468
|
const text = await res.text().catch(() => "");
|
|
26469
26469
|
throw new Error(`${res.status}: ${text}`);
|
|
@@ -29923,8 +29923,8 @@ function urlAuditDetail(url) {
|
|
|
29923
29923
|
}
|
|
29924
29924
|
try {
|
|
29925
29925
|
const parsed = new URL(url);
|
|
29926
|
-
const
|
|
29927
|
-
const hasPath =
|
|
29926
|
+
const path20 = parsed.pathname;
|
|
29927
|
+
const hasPath = path20.length > 0 && path20 !== "/";
|
|
29928
29928
|
return {
|
|
29929
29929
|
// Drop the trailing colon ("https:" → "https"). Lowercased
|
|
29930
29930
|
// for canonical-form audit comparisons across replays.
|
|
@@ -30660,7 +30660,7 @@ var init_cloud_browser_dispatcher = __esm({
|
|
|
30660
30660
|
};
|
|
30661
30661
|
}
|
|
30662
30662
|
// ── Internal: signed HTTP roundtrip ────────────────────────────────
|
|
30663
|
-
async request(method,
|
|
30663
|
+
async request(method, path20, body) {
|
|
30664
30664
|
let token;
|
|
30665
30665
|
try {
|
|
30666
30666
|
token = await this.getAuthToken();
|
|
@@ -30675,7 +30675,7 @@ var init_cloud_browser_dispatcher = __esm({
|
|
|
30675
30675
|
headers["Content-Type"] = "application/json";
|
|
30676
30676
|
let response;
|
|
30677
30677
|
try {
|
|
30678
|
-
response = await this.fetchImpl(`${this.baseUrl}${
|
|
30678
|
+
response = await this.fetchImpl(`${this.baseUrl}${path20}`, {
|
|
30679
30679
|
method,
|
|
30680
30680
|
headers,
|
|
30681
30681
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
@@ -41660,8 +41660,8 @@ var init_three_core = __esm({
|
|
|
41660
41660
|
* @param {string} path - The base path.
|
|
41661
41661
|
* @return {Loader} A reference to this instance.
|
|
41662
41662
|
*/
|
|
41663
|
-
setPath(
|
|
41664
|
-
this.path =
|
|
41663
|
+
setPath(path20) {
|
|
41664
|
+
this.path = path20;
|
|
41665
41665
|
return this;
|
|
41666
41666
|
}
|
|
41667
41667
|
/**
|
|
@@ -41709,10 +41709,10 @@ var init_three_core = __esm({
|
|
|
41709
41709
|
);
|
|
41710
41710
|
_supportedObjectNames = ["material", "materials", "bones", "map"];
|
|
41711
41711
|
Composite = class {
|
|
41712
|
-
constructor(targetGroup,
|
|
41713
|
-
const parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(
|
|
41712
|
+
constructor(targetGroup, path20, optionalParsedPath) {
|
|
41713
|
+
const parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path20);
|
|
41714
41714
|
this._targetGroup = targetGroup;
|
|
41715
|
-
this._bindings = targetGroup.subscribe_(
|
|
41715
|
+
this._bindings = targetGroup.subscribe_(path20, parsedPath);
|
|
41716
41716
|
}
|
|
41717
41717
|
getValue(array, offset) {
|
|
41718
41718
|
this.bind();
|
|
@@ -41746,9 +41746,9 @@ var init_three_core = __esm({
|
|
|
41746
41746
|
* @param {string} path - The path.
|
|
41747
41747
|
* @param {?Object} [parsedPath] - The parsed path.
|
|
41748
41748
|
*/
|
|
41749
|
-
constructor(rootNode,
|
|
41750
|
-
this.path =
|
|
41751
|
-
this.parsedPath = parsedPath || _PropertyBinding.parseTrackName(
|
|
41749
|
+
constructor(rootNode, path20, parsedPath) {
|
|
41750
|
+
this.path = path20;
|
|
41751
|
+
this.parsedPath = parsedPath || _PropertyBinding.parseTrackName(path20);
|
|
41752
41752
|
this.node = _PropertyBinding.findNode(rootNode, this.parsedPath.nodeName);
|
|
41753
41753
|
this.rootNode = rootNode;
|
|
41754
41754
|
this.getValue = this._getValue_unbound;
|
|
@@ -41763,11 +41763,11 @@ var init_three_core = __esm({
|
|
|
41763
41763
|
* @param {?Object} [parsedPath] - The parsed path.
|
|
41764
41764
|
* @return {PropertyBinding|Composite} The created property binding or composite.
|
|
41765
41765
|
*/
|
|
41766
|
-
static create(root,
|
|
41766
|
+
static create(root, path20, parsedPath) {
|
|
41767
41767
|
if (!(root && root.isAnimationObjectGroup)) {
|
|
41768
|
-
return new _PropertyBinding(root,
|
|
41768
|
+
return new _PropertyBinding(root, path20, parsedPath);
|
|
41769
41769
|
} else {
|
|
41770
|
-
return new _PropertyBinding.Composite(root,
|
|
41770
|
+
return new _PropertyBinding.Composite(root, path20, parsedPath);
|
|
41771
41771
|
}
|
|
41772
41772
|
}
|
|
41773
41773
|
/**
|
|
@@ -73914,14 +73914,14 @@ var init_dependency_container = __esm({
|
|
|
73914
73914
|
provider = providerOrConstructor;
|
|
73915
73915
|
}
|
|
73916
73916
|
if (isTokenProvider(provider)) {
|
|
73917
|
-
var
|
|
73917
|
+
var path20 = [token];
|
|
73918
73918
|
var tokenProvider = provider;
|
|
73919
73919
|
while (tokenProvider != null) {
|
|
73920
73920
|
var currentToken = tokenProvider.useToken;
|
|
73921
|
-
if (
|
|
73922
|
-
throw new Error("Token registration cycle detected! " + __spread(
|
|
73921
|
+
if (path20.includes(currentToken)) {
|
|
73922
|
+
throw new Error("Token registration cycle detected! " + __spread(path20, [currentToken]).join(" -> "));
|
|
73923
73923
|
}
|
|
73924
|
-
|
|
73924
|
+
path20.push(currentToken);
|
|
73925
73925
|
var registration = this._registry.get(currentToken);
|
|
73926
73926
|
if (registration && isTokenProvider(registration.provider)) {
|
|
73927
73927
|
tokenProvider = registration.provider;
|
|
@@ -83998,8 +83998,8 @@ ${FRONTMATTER_DELIM}`);
|
|
|
83998
83998
|
const validation = SkillManifestSchema.safeParse(frontmatter);
|
|
83999
83999
|
if (!validation.success) {
|
|
84000
84000
|
const first = validation.error.issues[0];
|
|
84001
|
-
const
|
|
84002
|
-
throw new SkillParseError(`Frontmatter failed schema validation at \`${
|
|
84001
|
+
const path20 = first?.path.join(".") ?? "(root)";
|
|
84002
|
+
throw new SkillParseError(`Frontmatter failed schema validation at \`${path20}\`: ${first?.message ?? "unknown"}`);
|
|
84003
84003
|
}
|
|
84004
84004
|
return {
|
|
84005
84005
|
manifest: validation.data,
|
|
@@ -84379,16 +84379,16 @@ var init_dist32 = __esm({
|
|
|
84379
84379
|
// ../../packages/skills/dist/fs-adapter.js
|
|
84380
84380
|
import { closeSync, fsyncSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync3, renameSync, rmSync, statSync, writeFileSync as writeFileSync3 } from "fs";
|
|
84381
84381
|
import { dirname, join as join2, relative, sep } from "path";
|
|
84382
|
-
function existsFile(
|
|
84382
|
+
function existsFile(path20) {
|
|
84383
84383
|
try {
|
|
84384
|
-
statSync(
|
|
84384
|
+
statSync(path20);
|
|
84385
84385
|
return true;
|
|
84386
84386
|
} catch {
|
|
84387
84387
|
return false;
|
|
84388
84388
|
}
|
|
84389
84389
|
}
|
|
84390
|
-
function atomicWriteFile(
|
|
84391
|
-
const tempPath = `${
|
|
84390
|
+
function atomicWriteFile(path20, content) {
|
|
84391
|
+
const tempPath = `${path20}.tmp.${process.pid}`;
|
|
84392
84392
|
const fd = openSync(tempPath, "w");
|
|
84393
84393
|
try {
|
|
84394
84394
|
writeFileSync3(fd, content);
|
|
@@ -84396,7 +84396,7 @@ function atomicWriteFile(path19, content) {
|
|
|
84396
84396
|
} finally {
|
|
84397
84397
|
closeSync(fd);
|
|
84398
84398
|
}
|
|
84399
|
-
renameSync(tempPath,
|
|
84399
|
+
renameSync(tempPath, path20);
|
|
84400
84400
|
}
|
|
84401
84401
|
function collectAuxFiles(dir) {
|
|
84402
84402
|
const out = {};
|
|
@@ -84432,9 +84432,9 @@ function ensureSafeRelativePath(relPath) {
|
|
|
84432
84432
|
}
|
|
84433
84433
|
return segments.join("/");
|
|
84434
84434
|
}
|
|
84435
|
-
function resolveDirectorySkillSource(
|
|
84436
|
-
const skillMdPath = join2(
|
|
84437
|
-
const envPath = join2(
|
|
84435
|
+
function resolveDirectorySkillSource(path20) {
|
|
84436
|
+
const skillMdPath = join2(path20, SKILL_MD);
|
|
84437
|
+
const envPath = join2(path20, SKILL_ENVELOPE_JSON);
|
|
84438
84438
|
if (!existsFile(skillMdPath)) {
|
|
84439
84439
|
throw new SkillParseError(`No SKILL.md at ${skillMdPath}`);
|
|
84440
84440
|
}
|
|
@@ -84443,7 +84443,7 @@ function resolveDirectorySkillSource(path19) {
|
|
|
84443
84443
|
}
|
|
84444
84444
|
const parsed = parseSkillFile(readFileSync3(skillMdPath, "utf-8"));
|
|
84445
84445
|
const envelope = JSON.parse(readFileSync3(envPath, "utf-8"));
|
|
84446
|
-
const files = collectAuxFiles(
|
|
84446
|
+
const files = collectAuxFiles(path20);
|
|
84447
84447
|
return {
|
|
84448
84448
|
kind: "in_memory",
|
|
84449
84449
|
manifest: parsed.manifest,
|
|
@@ -84567,10 +84567,10 @@ var init_fs_adapter = __esm({
|
|
|
84567
84567
|
return join2(this.root, name);
|
|
84568
84568
|
}
|
|
84569
84569
|
readIndex() {
|
|
84570
|
-
const
|
|
84571
|
-
if (!existsFile(
|
|
84570
|
+
const path20 = join2(this.root, INSTALLED_JSON);
|
|
84571
|
+
if (!existsFile(path20))
|
|
84572
84572
|
return [];
|
|
84573
|
-
const raw = readFileSync3(
|
|
84573
|
+
const raw = readFileSync3(path20, "utf-8");
|
|
84574
84574
|
if (raw.trim() === "")
|
|
84575
84575
|
return [];
|
|
84576
84576
|
try {
|
|
@@ -84579,7 +84579,7 @@ var init_fs_adapter = __esm({
|
|
|
84579
84579
|
return [];
|
|
84580
84580
|
return parsed;
|
|
84581
84581
|
} catch (err2) {
|
|
84582
|
-
throw new Error(`Failed to parse skills index at ${
|
|
84582
|
+
throw new Error(`Failed to parse skills index at ${path20}: ${err2 instanceof Error ? err2.message : String(err2)}`, { cause: err2 instanceof Error ? err2 : void 0 });
|
|
84583
84583
|
}
|
|
84584
84584
|
}
|
|
84585
84585
|
writeIndex(index) {
|
|
@@ -94028,8 +94028,8 @@ var init_x402_facilitator = __esm({
|
|
|
94028
94028
|
|
|
94029
94029
|
// ../../services/relay/dist/tasks.js
|
|
94030
94030
|
import { HTTPException as HTTPException7 } from "hono/http-exception";
|
|
94031
|
-
function extractMotebitIdFromPath(
|
|
94032
|
-
const match =
|
|
94031
|
+
function extractMotebitIdFromPath(path20) {
|
|
94032
|
+
const match = path20.match(/\/agent\/([^/]+)\/task/);
|
|
94033
94033
|
return match ? match[1] : null;
|
|
94034
94034
|
}
|
|
94035
94035
|
function getListingUnitCost(moteDb, agentId, capability) {
|
|
@@ -95916,9 +95916,9 @@ function enrichWithBondStatus(agents, db, nowMs = Date.now()) {
|
|
|
95916
95916
|
function registerAgentAuthMiddleware(deps) {
|
|
95917
95917
|
const { app, apiToken, identityManager, parseTokenPayloadUnsafe: parseTokenPayloadUnsafe2, verifySignedTokenForDevice: verifySignedTokenForDevice2, isTokenBlacklisted, isAgentRevoked } = deps;
|
|
95918
95918
|
app.use("/api/v1/agents/*", async (c5, next) => {
|
|
95919
|
-
const
|
|
95919
|
+
const path20 = c5.req.path;
|
|
95920
95920
|
const method = c5.req.method;
|
|
95921
|
-
if (PUBLIC_AGENT_ROUTES.some((r2) => r2.match(
|
|
95921
|
+
if (PUBLIC_AGENT_ROUTES.some((r2) => r2.match(path20, method))) {
|
|
95922
95922
|
await next();
|
|
95923
95923
|
return;
|
|
95924
95924
|
}
|
|
@@ -95936,25 +95936,25 @@ function registerAgentAuthMiddleware(deps) {
|
|
|
95936
95936
|
throw new HTTPException8(401, { message: "Invalid token" });
|
|
95937
95937
|
}
|
|
95938
95938
|
let agentAudience;
|
|
95939
|
-
if (
|
|
95939
|
+
if (path20.includes("/p2p-eligibility")) {
|
|
95940
95940
|
agentAudience = "market:listing";
|
|
95941
|
-
} else if (
|
|
95941
|
+
} else if (path20.includes("/listing")) {
|
|
95942
95942
|
agentAudience = "market:listing";
|
|
95943
|
-
} else if (
|
|
95943
|
+
} else if (path20.includes("/credentials")) {
|
|
95944
95944
|
agentAudience = "credentials";
|
|
95945
|
-
} else if (
|
|
95945
|
+
} else if (path20.includes("/presentation")) {
|
|
95946
95946
|
agentAudience = "credentials:present";
|
|
95947
|
-
} else if (
|
|
95947
|
+
} else if (path20.includes("/proxy-token")) {
|
|
95948
95948
|
agentAudience = "proxy:token";
|
|
95949
|
-
} else if (
|
|
95949
|
+
} else if (path20.includes("/receipts")) {
|
|
95950
95950
|
agentAudience = "receipts:read";
|
|
95951
|
-
} else if (
|
|
95951
|
+
} else if (path20.endsWith("/balance") || path20.endsWith("/settlements")) {
|
|
95952
95952
|
agentAudience = "account:balance";
|
|
95953
|
-
} else if (
|
|
95953
|
+
} else if (path20.endsWith("/withdrawals")) {
|
|
95954
95954
|
agentAudience = "account:withdrawals";
|
|
95955
|
-
} else if (
|
|
95955
|
+
} else if (path20.endsWith("/withdraw")) {
|
|
95956
95956
|
agentAudience = "account:withdraw";
|
|
95957
|
-
} else if (
|
|
95957
|
+
} else if (path20.endsWith("/checkout")) {
|
|
95958
95958
|
agentAudience = "account:checkout";
|
|
95959
95959
|
} else {
|
|
95960
95960
|
agentAudience = "admin:query";
|
|
@@ -95974,7 +95974,7 @@ function registerAgentAuthMiddleware(deps) {
|
|
|
95974
95974
|
reason,
|
|
95975
95975
|
expectedAudience: agentAudience,
|
|
95976
95976
|
mid: claims.mid,
|
|
95977
|
-
path:
|
|
95977
|
+
path: path20
|
|
95978
95978
|
})
|
|
95979
95979
|
);
|
|
95980
95980
|
if (!valid) {
|
|
@@ -101804,10 +101804,10 @@ function generateUUIDv72() {
|
|
|
101804
101804
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
101805
101805
|
}
|
|
101806
101806
|
function loadStoredGrant(grantId) {
|
|
101807
|
-
const
|
|
101808
|
-
if (!existsSync(
|
|
101807
|
+
const path20 = join7(grantsDir(), `${grantId}.json`);
|
|
101808
|
+
if (!existsSync(path20)) return null;
|
|
101809
101809
|
try {
|
|
101810
|
-
return JSON.parse(readFileSync4(
|
|
101810
|
+
return JSON.parse(readFileSync4(path20, "utf8"));
|
|
101811
101811
|
} catch {
|
|
101812
101812
|
return null;
|
|
101813
101813
|
}
|
|
@@ -102352,11 +102352,12 @@ function parseCliArgs(args = process.argv.slice(2)) {
|
|
|
102352
102352
|
);
|
|
102353
102353
|
}
|
|
102354
102354
|
const cliProvider = rawProvider;
|
|
102355
|
-
const defaultModel = cliProvider
|
|
102355
|
+
const defaultModel = defaultModelForProvider(cliProvider);
|
|
102356
102356
|
const allowedPaths = values["allowed-paths"] != null && values["allowed-paths"] !== "" ? values["allowed-paths"].split(",").map((p5) => p5.trim()) : [process.cwd()];
|
|
102357
102357
|
return {
|
|
102358
102358
|
provider: cliProvider,
|
|
102359
102359
|
model: values.model ?? defaultModel,
|
|
102360
|
+
modelExplicit: values.model != null,
|
|
102360
102361
|
dbPath: values["db-path"],
|
|
102361
102362
|
noStream: values["no-stream"],
|
|
102362
102363
|
syncUrl: values["sync-url"],
|
|
@@ -102660,6 +102661,9 @@ Slash commands (in REPL):`
|
|
|
102660
102661
|
function printVersion() {
|
|
102661
102662
|
console.log(VERSION);
|
|
102662
102663
|
}
|
|
102664
|
+
function defaultModelForProvider(provider) {
|
|
102665
|
+
return provider === "local-server" ? "llama3.2" : provider === "openai" ? "gpt-5.4-mini" : provider === "google" ? "gemini-2.5-flash" : provider === "groq" ? "llama-3.3-70b-versatile" : provider === "deepseek" ? "deepseek-chat" : "claude-sonnet-4-6";
|
|
102666
|
+
}
|
|
102663
102667
|
function printBanner(opts) {
|
|
102664
102668
|
const W2 = 56;
|
|
102665
102669
|
const pad = (s3, visibleLen) => s3 + " ".repeat(Math.max(0, W2 - visibleLen));
|
|
@@ -102706,6 +102710,80 @@ function trimHistory(history) {
|
|
|
102706
102710
|
|
|
102707
102711
|
// src/index.ts
|
|
102708
102712
|
init_config2();
|
|
102713
|
+
|
|
102714
|
+
// src/update-nudge.ts
|
|
102715
|
+
init_esm_shims();
|
|
102716
|
+
init_config2();
|
|
102717
|
+
import * as fs7 from "fs";
|
|
102718
|
+
import * as path9 from "path";
|
|
102719
|
+
var UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
102720
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
102721
|
+
function updateCheckPath() {
|
|
102722
|
+
return path9.join(CONFIG_DIR, "update-check.json");
|
|
102723
|
+
}
|
|
102724
|
+
function isNewerVersion(latest, current2) {
|
|
102725
|
+
const parse3 = (v3) => {
|
|
102726
|
+
const parts = v3.trim().split(".");
|
|
102727
|
+
if (parts.length !== 3) return null;
|
|
102728
|
+
const nums = parts.map((p5) => /^\d+$/.test(p5) ? Number(p5) : NaN);
|
|
102729
|
+
return nums.some((n2) => Number.isNaN(n2)) ? null : nums;
|
|
102730
|
+
};
|
|
102731
|
+
const l6 = parse3(latest);
|
|
102732
|
+
const c5 = parse3(current2);
|
|
102733
|
+
if (l6 == null || c5 == null) return false;
|
|
102734
|
+
for (let i = 0; i < 3; i++) {
|
|
102735
|
+
if (l6[i] > c5[i]) return true;
|
|
102736
|
+
if (l6[i] < c5[i]) return false;
|
|
102737
|
+
}
|
|
102738
|
+
return false;
|
|
102739
|
+
}
|
|
102740
|
+
function readUpdateState(statePath = updateCheckPath()) {
|
|
102741
|
+
try {
|
|
102742
|
+
const raw = JSON.parse(fs7.readFileSync(statePath, "utf-8"));
|
|
102743
|
+
if (typeof raw.last_checked_at !== "number") return null;
|
|
102744
|
+
return {
|
|
102745
|
+
last_checked_at: raw.last_checked_at,
|
|
102746
|
+
...typeof raw.latest === "string" ? { latest: raw.latest } : {}
|
|
102747
|
+
};
|
|
102748
|
+
} catch {
|
|
102749
|
+
return null;
|
|
102750
|
+
}
|
|
102751
|
+
}
|
|
102752
|
+
function renderUpdateNudge(params) {
|
|
102753
|
+
const latest = params.state?.latest;
|
|
102754
|
+
if (latest == null || !isNewerVersion(latest, params.currentVersion)) return null;
|
|
102755
|
+
return `motebit ${latest} available \u2014 npm i -g motebit`;
|
|
102756
|
+
}
|
|
102757
|
+
function refreshUpdateCheckInBackground(params) {
|
|
102758
|
+
const statePath = params?.statePath ?? updateCheckPath();
|
|
102759
|
+
const now = params?.nowMs ?? Date.now();
|
|
102760
|
+
const ttl = params?.ttlMs ?? UPDATE_CHECK_TTL_MS;
|
|
102761
|
+
const fetchFn = params?.fetchFn ?? fetch;
|
|
102762
|
+
const state = readUpdateState(statePath);
|
|
102763
|
+
if (state != null && now - state.last_checked_at < ttl) return;
|
|
102764
|
+
void (async () => {
|
|
102765
|
+
const controller = new AbortController();
|
|
102766
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
102767
|
+
try {
|
|
102768
|
+
const resp = await fetchFn("https://registry.npmjs.org/motebit/latest", {
|
|
102769
|
+
signal: controller.signal
|
|
102770
|
+
});
|
|
102771
|
+
if (!resp.ok) return;
|
|
102772
|
+
const body = await resp.json();
|
|
102773
|
+
if (typeof body.version !== "string") return;
|
|
102774
|
+
fs7.mkdirSync(path9.dirname(statePath), { recursive: true });
|
|
102775
|
+
fs7.writeFileSync(
|
|
102776
|
+
statePath,
|
|
102777
|
+
JSON.stringify({ last_checked_at: now, latest: body.version })
|
|
102778
|
+
);
|
|
102779
|
+
} catch {
|
|
102780
|
+
} finally {
|
|
102781
|
+
clearTimeout(timer);
|
|
102782
|
+
}
|
|
102783
|
+
})();
|
|
102784
|
+
}
|
|
102785
|
+
|
|
102786
|
+
// src/index.ts
|
|
102709
102787
|
init_identity();
|
|
102710
102788
|
init_runtime_factory();
|
|
102711
102789
|
|
|
@@ -103176,14 +103254,14 @@ var JsonLineDecoder = class {
|
|
|
103176
103254
|
|
|
103177
103255
|
// ../../packages/runtime-host/dist/paths-shared.js
|
|
103178
103256
|
init_esm_shims();
|
|
103179
|
-
function isWindowsPipePath(
|
|
103180
|
-
return
|
|
103257
|
+
function isWindowsPipePath(path20) {
|
|
103258
|
+
return path20.startsWith("\\\\.\\pipe\\");
|
|
103181
103259
|
}
|
|
103182
103260
|
|
|
103183
103261
|
// ../../packages/runtime-host/dist/lockfile.js
|
|
103184
103262
|
init_esm_shims();
|
|
103185
|
-
async function readLockfile(platform,
|
|
103186
|
-
const raw = await platform.readFile(
|
|
103263
|
+
async function readLockfile(platform, path20) {
|
|
103264
|
+
const raw = await platform.readFile(path20);
|
|
103187
103265
|
if (raw === null)
|
|
103188
103266
|
return null;
|
|
103189
103267
|
try {
|
|
@@ -103203,16 +103281,16 @@ async function readLockfile(platform, path19) {
|
|
|
103203
103281
|
return null;
|
|
103204
103282
|
}
|
|
103205
103283
|
}
|
|
103206
|
-
async function writeLockfile(platform,
|
|
103207
|
-
await platform.writeFile(
|
|
103284
|
+
async function writeLockfile(platform, path20, record) {
|
|
103285
|
+
await platform.writeFile(path20, `${JSON.stringify(record)}
|
|
103208
103286
|
`);
|
|
103209
103287
|
}
|
|
103210
|
-
async function removeLockfile(platform,
|
|
103211
|
-
const current2 = await readLockfile(platform,
|
|
103288
|
+
async function removeLockfile(platform, path20, pid) {
|
|
103289
|
+
const current2 = await readLockfile(platform, path20);
|
|
103212
103290
|
if (current2 !== null && current2.pid !== pid)
|
|
103213
103291
|
return;
|
|
103214
103292
|
try {
|
|
103215
|
-
await platform.removeFile(
|
|
103293
|
+
await platform.removeFile(path20);
|
|
103216
103294
|
} catch {
|
|
103217
103295
|
}
|
|
103218
103296
|
}
|
|
@@ -104203,11 +104281,11 @@ init_esm_shims();
|
|
|
104203
104281
|
|
|
104204
104282
|
// ../../packages/runtime-host/dist/node-platform.js
|
|
104205
104283
|
init_esm_shims();
|
|
104206
|
-
import { chmodSync, mkdirSync as
|
|
104284
|
+
import { chmodSync, mkdirSync as mkdirSync6, readFileSync as readFileSync6, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
104207
104285
|
import { connect, createServer } from "net";
|
|
104208
|
-
import { dirname as
|
|
104209
|
-
function isWindowsPipe(
|
|
104210
|
-
return
|
|
104286
|
+
import { dirname as dirname5 } from "path";
|
|
104287
|
+
function isWindowsPipe(path20) {
|
|
104288
|
+
return path20.startsWith("\\\\.\\pipe\\");
|
|
104211
104289
|
}
|
|
104212
104290
|
function wrapSocket(socket) {
|
|
104213
104291
|
return {
|
|
@@ -104301,36 +104379,36 @@ function nodePlatform(overrides = {}) {
|
|
|
104301
104379
|
}
|
|
104302
104380
|
},
|
|
104303
104381
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
104304
|
-
async readFile(
|
|
104382
|
+
async readFile(path20) {
|
|
104305
104383
|
try {
|
|
104306
|
-
return
|
|
104384
|
+
return readFileSync6(path20, "utf8");
|
|
104307
104385
|
} catch {
|
|
104308
104386
|
return null;
|
|
104309
104387
|
}
|
|
104310
104388
|
},
|
|
104311
104389
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
104312
|
-
async writeFile(
|
|
104313
|
-
|
|
104314
|
-
|
|
104390
|
+
async writeFile(path20, content) {
|
|
104391
|
+
mkdirSync6(dirname5(path20), { recursive: true, mode: 448 });
|
|
104392
|
+
writeFileSync6(path20, content, { mode: 384 });
|
|
104315
104393
|
},
|
|
104316
104394
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
104317
|
-
async removeFile(
|
|
104318
|
-
rmSync2(
|
|
104395
|
+
async removeFile(path20) {
|
|
104396
|
+
rmSync2(path20, { force: true });
|
|
104319
104397
|
},
|
|
104320
104398
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
104321
|
-
async mkdirExclusive(
|
|
104322
|
-
|
|
104399
|
+
async mkdirExclusive(path20) {
|
|
104400
|
+
mkdirSync6(dirname5(path20), { recursive: true, mode: 448 });
|
|
104323
104401
|
try {
|
|
104324
|
-
|
|
104402
|
+
mkdirSync6(path20);
|
|
104325
104403
|
return "created";
|
|
104326
104404
|
} catch {
|
|
104327
104405
|
return "exists";
|
|
104328
104406
|
}
|
|
104329
104407
|
},
|
|
104330
104408
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
104331
|
-
async removeDir(
|
|
104409
|
+
async removeDir(path20) {
|
|
104332
104410
|
try {
|
|
104333
|
-
rmSync2(
|
|
104411
|
+
rmSync2(path20, { recursive: true, force: true });
|
|
104334
104412
|
} catch {
|
|
104335
104413
|
}
|
|
104336
104414
|
},
|
|
@@ -104352,19 +104430,19 @@ function nodePlatform(overrides = {}) {
|
|
|
104352
104430
|
init_esm_shims();
|
|
104353
104431
|
import { createHash } from "crypto";
|
|
104354
104432
|
import { homedir as homedir3 } from "os";
|
|
104355
|
-
import { join as
|
|
104433
|
+
import { join as join9 } from "path";
|
|
104356
104434
|
function defaultRuntimeHostPaths(home = homedir3(), platform = process.platform) {
|
|
104357
|
-
const dir =
|
|
104435
|
+
const dir = join9(home, ".motebit");
|
|
104358
104436
|
if (platform === "win32") {
|
|
104359
104437
|
const tag2 = createHash("sha256").update(dir).digest("hex").slice(0, 16);
|
|
104360
104438
|
return {
|
|
104361
104439
|
socketPath: `\\\\.\\pipe\\motebit-runtime-${tag2}`,
|
|
104362
|
-
lockfilePath:
|
|
104440
|
+
lockfilePath: join9(dir, "runtime.lock")
|
|
104363
104441
|
};
|
|
104364
104442
|
}
|
|
104365
104443
|
return {
|
|
104366
|
-
socketPath:
|
|
104367
|
-
lockfilePath:
|
|
104444
|
+
socketPath: join9(dir, "runtime.sock"),
|
|
104445
|
+
lockfilePath: join9(dir, "runtime.lock")
|
|
104368
104446
|
};
|
|
104369
104447
|
}
|
|
104370
104448
|
|
|
@@ -105007,21 +105085,21 @@ var RelayClientError = class extends Error {
|
|
|
105007
105085
|
path;
|
|
105008
105086
|
/** Relay-provided error body text when available (non-2xx responses). */
|
|
105009
105087
|
body;
|
|
105010
|
-
constructor(kind,
|
|
105088
|
+
constructor(kind, path20, message2, options) {
|
|
105011
105089
|
super(message2, options?.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
105012
105090
|
this.name = "RelayClientError";
|
|
105013
105091
|
this.kind = kind;
|
|
105014
|
-
this.path =
|
|
105092
|
+
this.path = path20;
|
|
105015
105093
|
this.status = options?.status;
|
|
105016
105094
|
this.body = options?.body;
|
|
105017
105095
|
}
|
|
105018
105096
|
};
|
|
105019
105097
|
|
|
105020
105098
|
// ../../packages/relay-client/dist/client.js
|
|
105021
|
-
function validate(schema, body,
|
|
105099
|
+
function validate(schema, body, path20, label) {
|
|
105022
105100
|
const parsed = schema.safeParse(body);
|
|
105023
105101
|
if (!parsed.success) {
|
|
105024
|
-
throw new RelayClientError("schema",
|
|
105102
|
+
throw new RelayClientError("schema", path20, `${label} response failed wire-schema validation: ${parsed.error.message}`);
|
|
105025
105103
|
}
|
|
105026
105104
|
return parsed.data;
|
|
105027
105105
|
}
|
|
@@ -105060,11 +105138,11 @@ var RelayClient = class {
|
|
|
105060
105138
|
* never sends credentials, regardless of configured auth.
|
|
105061
105139
|
*/
|
|
105062
105140
|
async discover(motebitId) {
|
|
105063
|
-
const
|
|
105064
|
-
const body = await this.requestJson("GET",
|
|
105141
|
+
const path20 = `/api/v1/discover/${encodeURIComponent(motebitId)}`;
|
|
105142
|
+
const body = await this.requestJson("GET", path20, {
|
|
105065
105143
|
retry: true
|
|
105066
105144
|
});
|
|
105067
|
-
return validate(AgentResolutionResultSchema, body,
|
|
105145
|
+
return validate(AgentResolutionResultSchema, body, path20, "discover");
|
|
105068
105146
|
}
|
|
105069
105147
|
/**
|
|
105070
105148
|
* `GET /api/v1/agents/:motebitId/balance`. Contract tier: VALIDATED
|
|
@@ -105073,12 +105151,12 @@ var RelayClient = class {
|
|
|
105073
105151
|
* converts from micro-units at its boundary; never convert again.
|
|
105074
105152
|
*/
|
|
105075
105153
|
async getBalance(motebitId) {
|
|
105076
|
-
const
|
|
105077
|
-
const body = await this.requestJson("GET",
|
|
105154
|
+
const path20 = `/api/v1/agents/${encodeURIComponent(motebitId)}/balance`;
|
|
105155
|
+
const body = await this.requestJson("GET", path20, {
|
|
105078
105156
|
audience: ACCOUNT_BALANCE_AUDIENCE,
|
|
105079
105157
|
retry: true
|
|
105080
105158
|
});
|
|
105081
|
-
return validate(AccountBalanceResultSchema, body,
|
|
105159
|
+
return validate(AccountBalanceResultSchema, body, path20, "balance");
|
|
105082
105160
|
}
|
|
105083
105161
|
/**
|
|
105084
105162
|
* `POST /agent/:targetMotebitId/task` — submit a delegation task.
|
|
@@ -105087,8 +105165,8 @@ var RelayClient = class {
|
|
|
105087
105165
|
* caller supplies it so a retry by the CALLER replays, never double-spends.
|
|
105088
105166
|
*/
|
|
105089
105167
|
async submitTask(targetMotebitId, request, options) {
|
|
105090
|
-
const
|
|
105091
|
-
const body = await this.requestJson("POST",
|
|
105168
|
+
const path20 = `/agent/${encodeURIComponent(targetMotebitId)}/task`;
|
|
105169
|
+
const body = await this.requestJson("POST", path20, {
|
|
105092
105170
|
audience: TASK_SUBMIT_AUDIENCE,
|
|
105093
105171
|
retry: false,
|
|
105094
105172
|
jsonBody: request,
|
|
@@ -105102,8 +105180,8 @@ var RelayClient = class {
|
|
|
105102
105180
|
* token; the relay authorizes submitter-or-target).
|
|
105103
105181
|
*/
|
|
105104
105182
|
async getTask(targetMotebitId, taskId) {
|
|
105105
|
-
const
|
|
105106
|
-
const body = await this.requestJson("GET",
|
|
105183
|
+
const path20 = `/agent/${encodeURIComponent(targetMotebitId)}/task/${encodeURIComponent(taskId)}`;
|
|
105184
|
+
const body = await this.requestJson("GET", path20, {
|
|
105107
105185
|
audience: TASK_QUERY_AUDIENCE,
|
|
105108
105186
|
retry: true
|
|
105109
105187
|
});
|
|
@@ -105121,24 +105199,24 @@ var RelayClient = class {
|
|
|
105121
105199
|
* `kind: "http"`, `status: 402`.
|
|
105122
105200
|
*/
|
|
105123
105201
|
async withdraw(motebitId, request, options) {
|
|
105124
|
-
const
|
|
105125
|
-
const body = await this.requestJson("POST",
|
|
105202
|
+
const path20 = `/api/v1/agents/${encodeURIComponent(motebitId)}/withdraw`;
|
|
105203
|
+
const body = await this.requestJson("POST", path20, {
|
|
105126
105204
|
audience: ACCOUNT_WITHDRAW_AUDIENCE,
|
|
105127
105205
|
retry: false,
|
|
105128
105206
|
jsonBody: request,
|
|
105129
105207
|
headers: { "Idempotency-Key": options.idempotencyKey }
|
|
105130
105208
|
});
|
|
105131
|
-
return validate(AccountWithdrawResultSchema, body,
|
|
105209
|
+
return validate(AccountWithdrawResultSchema, body, path20, "withdraw");
|
|
105132
105210
|
}
|
|
105133
105211
|
// ── Transport kernel ─────────────────────────────────────────────────
|
|
105134
|
-
async requestJson(method,
|
|
105212
|
+
async requestJson(method, path20, opts) {
|
|
105135
105213
|
const headers = { ...opts.headers };
|
|
105136
105214
|
if (opts.jsonBody !== void 0)
|
|
105137
105215
|
headers["Content-Type"] = "application/json";
|
|
105138
105216
|
if (opts.audience !== void 0) {
|
|
105139
105217
|
const token = await this.resolveToken(opts.audience);
|
|
105140
105218
|
if (token == null) {
|
|
105141
|
-
throw new RelayClientError("auth",
|
|
105219
|
+
throw new RelayClientError("auth", path20, `no credential available for ${path20} (audience ${opts.audience}) \u2014 provide credentialSource, deviceKey, or staticToken`);
|
|
105142
105220
|
}
|
|
105143
105221
|
headers["Authorization"] = `Bearer ${token}`;
|
|
105144
105222
|
}
|
|
@@ -105147,7 +105225,7 @@ var RelayClient = class {
|
|
|
105147
105225
|
headers,
|
|
105148
105226
|
...opts.jsonBody !== void 0 ? { body: JSON.stringify(opts.jsonBody) } : {}
|
|
105149
105227
|
};
|
|
105150
|
-
const res = await this.fetchWithRetry(
|
|
105228
|
+
const res = await this.fetchWithRetry(path20, init, opts.retry);
|
|
105151
105229
|
if (!res.ok) {
|
|
105152
105230
|
let bodyText;
|
|
105153
105231
|
try {
|
|
@@ -105155,7 +105233,7 @@ var RelayClient = class {
|
|
|
105155
105233
|
} catch {
|
|
105156
105234
|
bodyText = void 0;
|
|
105157
105235
|
}
|
|
105158
|
-
throw new RelayClientError("http",
|
|
105236
|
+
throw new RelayClientError("http", path20, `${method} ${path20} \u2192 ${res.status}`, {
|
|
105159
105237
|
status: res.status,
|
|
105160
105238
|
body: bodyText
|
|
105161
105239
|
});
|
|
@@ -105163,13 +105241,13 @@ var RelayClient = class {
|
|
|
105163
105241
|
try {
|
|
105164
105242
|
return await res.json();
|
|
105165
105243
|
} catch (err2) {
|
|
105166
|
-
throw new RelayClientError("parse",
|
|
105244
|
+
throw new RelayClientError("parse", path20, `${method} ${path20} returned non-JSON body`, {
|
|
105167
105245
|
cause: err2
|
|
105168
105246
|
});
|
|
105169
105247
|
}
|
|
105170
105248
|
}
|
|
105171
|
-
async fetchWithRetry(
|
|
105172
|
-
const url = `${this.baseUrl}${
|
|
105249
|
+
async fetchWithRetry(path20, init, retry) {
|
|
105250
|
+
const url = `${this.baseUrl}${path20}`;
|
|
105173
105251
|
const attempts = retry ? this.maxRetries + 1 : 1;
|
|
105174
105252
|
let lastNetworkError;
|
|
105175
105253
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
@@ -105186,7 +105264,7 @@ var RelayClient = class {
|
|
|
105186
105264
|
}
|
|
105187
105265
|
await this.backoff(attempt);
|
|
105188
105266
|
}
|
|
105189
|
-
throw new RelayClientError("network",
|
|
105267
|
+
throw new RelayClientError("network", path20, `request to ${path20} failed after ${attempts} attempt(s)`, {
|
|
105190
105268
|
cause: lastNetworkError
|
|
105191
105269
|
});
|
|
105192
105270
|
}
|
|
@@ -105471,7 +105549,7 @@ init_dist6();
|
|
|
105471
105549
|
|
|
105472
105550
|
// ../../packages/mcp-server/dist/bootstrap-service.js
|
|
105473
105551
|
init_esm_shims();
|
|
105474
|
-
import { writeFileSync as
|
|
105552
|
+
import { writeFileSync as writeFileSync8 } from "fs";
|
|
105475
105553
|
import { resolve as resolve6 } from "path";
|
|
105476
105554
|
|
|
105477
105555
|
// ../../packages/core-identity/dist/node.js
|
|
@@ -105479,12 +105557,12 @@ init_esm_shims();
|
|
|
105479
105557
|
|
|
105480
105558
|
// ../../packages/core-identity/dist/file-stores.js
|
|
105481
105559
|
init_esm_shims();
|
|
105482
|
-
import { existsSync as existsSync2, readFileSync as
|
|
105560
|
+
import { existsSync as existsSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync7, renameSync as renameSync2, chmodSync as chmodSync2 } from "fs";
|
|
105483
105561
|
|
|
105484
105562
|
// ../../packages/core-identity/dist/bootstrap-service.js
|
|
105485
105563
|
init_esm_shims();
|
|
105486
|
-
import { mkdirSync as
|
|
105487
|
-
import { join as
|
|
105564
|
+
import { mkdirSync as mkdirSync7, existsSync as existsSync3 } from "fs";
|
|
105565
|
+
import { join as join10 } from "path";
|
|
105488
105566
|
init_dist17();
|
|
105489
105567
|
init_dist16();
|
|
105490
105568
|
|
|
@@ -106274,7 +106352,7 @@ var McpServerAdapter = class _McpServerAdapter {
|
|
|
106274
106352
|
init_config2();
|
|
106275
106353
|
init_dist32();
|
|
106276
106354
|
init_node_fs();
|
|
106277
|
-
import { join as
|
|
106355
|
+
import { join as join11 } from "path";
|
|
106278
106356
|
|
|
106279
106357
|
// src/utils.ts
|
|
106280
106358
|
init_esm_shims();
|
|
@@ -106475,8 +106553,8 @@ function parseSub(args) {
|
|
|
106475
106553
|
const m4 = args.match(/^(\S+)\s*([\s\S]*)$/);
|
|
106476
106554
|
return m4 ? { sub: m4[1], rest: (m4[2] ?? "").trim() } : { sub: "", rest: "" };
|
|
106477
106555
|
}
|
|
106478
|
-
async function relayFetch2(baseUrl,
|
|
106479
|
-
const url = `${baseUrl.replace(/\/+$/, "")}${
|
|
106556
|
+
async function relayFetch2(baseUrl, path20, opts) {
|
|
106557
|
+
const url = `${baseUrl.replace(/\/+$/, "")}${path20}`;
|
|
106480
106558
|
const init = { headers: opts?.headers };
|
|
106481
106559
|
if (opts?.method) init.method = opts.method;
|
|
106482
106560
|
if (opts?.body != null) init.body = JSON.stringify(opts.body);
|
|
@@ -107057,9 +107135,9 @@ Unknown model: ${cyan(args)}
|
|
|
107057
107135
|
let guardianAttest;
|
|
107058
107136
|
try {
|
|
107059
107137
|
const { parse: parse3 } = await Promise.resolve().then(() => (init_dist34(), dist_exports10));
|
|
107060
|
-
const
|
|
107138
|
+
const fs20 = await import("fs");
|
|
107061
107139
|
const idPath = config.identity ?? "motebit.md";
|
|
107062
|
-
const content =
|
|
107140
|
+
const content = fs20.readFileSync(idPath, "utf-8");
|
|
107063
107141
|
const guardian = parse3(content).frontmatter.guardian;
|
|
107064
107142
|
guardianPubKey = guardian?.public_key;
|
|
107065
107143
|
guardianAttest = guardian?.attestation;
|
|
@@ -108406,7 +108484,7 @@ Curiosity targets (${targets.length}):
|
|
|
108406
108484
|
}
|
|
108407
108485
|
case "skills": {
|
|
108408
108486
|
const registry = new SkillRegistry(
|
|
108409
|
-
new NodeFsSkillStorageAdapter({ root:
|
|
108487
|
+
new NodeFsSkillStorageAdapter({ root: join11(CONFIG_DIR, "skills") })
|
|
108410
108488
|
);
|
|
108411
108489
|
const records = await registry.list();
|
|
108412
108490
|
if (records.length === 0) {
|
|
@@ -108437,7 +108515,7 @@ Curiosity targets (${targets.length}):
|
|
|
108437
108515
|
break;
|
|
108438
108516
|
}
|
|
108439
108517
|
const registry = new SkillRegistry(
|
|
108440
|
-
new NodeFsSkillStorageAdapter({ root:
|
|
108518
|
+
new NodeFsSkillStorageAdapter({ root: join11(CONFIG_DIR, "skills") })
|
|
108441
108519
|
);
|
|
108442
108520
|
const record = await registry.get(name);
|
|
108443
108521
|
if (!record) {
|
|
@@ -108647,8 +108725,8 @@ init_dist11();
|
|
|
108647
108725
|
init_config2();
|
|
108648
108726
|
init_identity();
|
|
108649
108727
|
init_runtime_factory();
|
|
108650
|
-
import * as
|
|
108651
|
-
import * as
|
|
108728
|
+
import * as fs8 from "fs";
|
|
108729
|
+
import * as path10 from "path";
|
|
108652
108730
|
import * as readline2 from "readline";
|
|
108653
108731
|
async function buildAttestationCredential(input) {
|
|
108654
108732
|
return composeHardwareAttestationCredential({
|
|
@@ -108731,8 +108809,8 @@ async function handleAttest(config) {
|
|
|
108731
108809
|
rl.close();
|
|
108732
108810
|
const json = JSON.stringify(signed, null, 2);
|
|
108733
108811
|
if (config.output != null && config.output !== "") {
|
|
108734
|
-
const outPath =
|
|
108735
|
-
|
|
108812
|
+
const outPath = path10.resolve(config.output);
|
|
108813
|
+
fs8.writeFileSync(outPath, `${json}
|
|
108736
108814
|
`, "utf-8");
|
|
108737
108815
|
process.stderr.write(
|
|
108738
108816
|
`Wrote attestation credential for ${motebitId.slice(0, 8)}\u2026 to ${outPath}
|
|
@@ -109386,8 +109464,8 @@ Agent ${data.motebit_id}: found`);
|
|
|
109386
109464
|
init_esm_shims();
|
|
109387
109465
|
init_dist11();
|
|
109388
109466
|
init_config2();
|
|
109389
|
-
import * as
|
|
109390
|
-
import * as
|
|
109467
|
+
import * as fs9 from "fs";
|
|
109468
|
+
import * as path11 from "path";
|
|
109391
109469
|
|
|
109392
109470
|
// src/subcommands/seed.ts
|
|
109393
109471
|
init_esm_shims();
|
|
@@ -109492,26 +109570,26 @@ async function handleDoctor() {
|
|
|
109492
109570
|
detail: major >= 20 ? `v${nodeVer}` : `v${nodeVer} (requires >=20)`
|
|
109493
109571
|
});
|
|
109494
109572
|
try {
|
|
109495
|
-
|
|
109496
|
-
const testFile =
|
|
109497
|
-
|
|
109498
|
-
|
|
109573
|
+
fs9.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
109574
|
+
const testFile = path11.join(CONFIG_DIR, ".doctor-test");
|
|
109575
|
+
fs9.writeFileSync(testFile, "ok", "utf-8");
|
|
109576
|
+
fs9.unlinkSync(testFile);
|
|
109499
109577
|
checks.push({ name: "Config dir", ok: true, detail: CONFIG_DIR });
|
|
109500
109578
|
} catch {
|
|
109501
109579
|
checks.push({ name: "Config dir", ok: false, detail: `Cannot write to ${CONFIG_DIR}` });
|
|
109502
109580
|
}
|
|
109503
109581
|
try {
|
|
109504
|
-
const tmpDbPath =
|
|
109582
|
+
const tmpDbPath = path11.join(CONFIG_DIR, ".doctor-test.db");
|
|
109505
109583
|
const db = await openMotebitDatabase(tmpDbPath);
|
|
109506
109584
|
const driverName = db.db.driverName;
|
|
109507
109585
|
db.close();
|
|
109508
|
-
|
|
109586
|
+
fs9.unlinkSync(tmpDbPath);
|
|
109509
109587
|
try {
|
|
109510
|
-
|
|
109588
|
+
fs9.unlinkSync(tmpDbPath + "-wal");
|
|
109511
109589
|
} catch {
|
|
109512
109590
|
}
|
|
109513
109591
|
try {
|
|
109514
|
-
|
|
109592
|
+
fs9.unlinkSync(tmpDbPath + "-shm");
|
|
109515
109593
|
} catch {
|
|
109516
109594
|
}
|
|
109517
109595
|
checks.push({ name: "SQLite", ok: true, detail: `${driverName} loaded and functional` });
|
|
@@ -109540,10 +109618,10 @@ async function handleDoctor() {
|
|
|
109540
109618
|
checks.push({ name: "Identity", ok: true, detail: "not created yet (run motebit to create)" });
|
|
109541
109619
|
}
|
|
109542
109620
|
{
|
|
109543
|
-
const mdPath =
|
|
109544
|
-
if (
|
|
109621
|
+
const mdPath = path11.join(CONFIG_DIR, "motebit.md");
|
|
109622
|
+
if (fs9.existsSync(mdPath) && fullCfg.device_public_key) {
|
|
109545
109623
|
try {
|
|
109546
|
-
const md =
|
|
109624
|
+
const md = fs9.readFileSync(mdPath, "utf-8");
|
|
109547
109625
|
const keyMatch = /public_key:\s*"?([0-9a-fA-F]{64})"?/.exec(md);
|
|
109548
109626
|
const fileKey = keyMatch?.[1]?.toLowerCase();
|
|
109549
109627
|
const stale = fileKey != null && fileKey !== fullCfg.device_public_key.toLowerCase();
|
|
@@ -109589,7 +109667,7 @@ async function handleDoctor() {
|
|
|
109589
109667
|
detail: "cli_private_key (plaintext, deprecated \u2014 re-encrypt at next run)"
|
|
109590
109668
|
});
|
|
109591
109669
|
} else {
|
|
109592
|
-
const clobberedBackups =
|
|
109670
|
+
const clobberedBackups = fs9.readdirSync(CONFIG_DIR).filter((f7) => f7.startsWith("config.json.clobbered-"));
|
|
109593
109671
|
const restoreHint = clobberedBackups.length > 0 ? `restore from ~/.motebit/${clobberedBackups[0]} (a clobbered backup is present)` : "run `motebit init` to create or import an identity key";
|
|
109594
109672
|
checks.push({
|
|
109595
109673
|
name: "Identity key",
|
|
@@ -109873,8 +109951,8 @@ init_config2();
|
|
|
109873
109951
|
init_identity();
|
|
109874
109952
|
init_runtime_factory();
|
|
109875
109953
|
import * as readline4 from "readline";
|
|
109876
|
-
import * as
|
|
109877
|
-
import * as
|
|
109954
|
+
import * as fs10 from "fs";
|
|
109955
|
+
import * as path12 from "path";
|
|
109878
109956
|
async function handleExport(config) {
|
|
109879
109957
|
const fullConfig = loadFullConfig();
|
|
109880
109958
|
const rl = readline4.createInterface({
|
|
@@ -109948,22 +110026,22 @@ async function handleExport(config) {
|
|
|
109948
110026
|
},
|
|
109949
110027
|
privateKey
|
|
109950
110028
|
);
|
|
109951
|
-
const outputDir = config.output != null && config.output !== "" ?
|
|
109952
|
-
|
|
110029
|
+
const outputDir = config.output != null && config.output !== "" ? path12.resolve(config.output) : path12.resolve("motebit-export");
|
|
110030
|
+
fs10.mkdirSync(outputDir, { recursive: true });
|
|
109953
110031
|
const exported = [];
|
|
109954
110032
|
const skipped = [];
|
|
109955
|
-
const identityPath =
|
|
109956
|
-
|
|
110033
|
+
const identityPath = path12.join(outputDir, "motebit.md");
|
|
110034
|
+
fs10.writeFileSync(identityPath, identityContent, "utf-8");
|
|
109957
110035
|
exported.push("identity");
|
|
109958
110036
|
try {
|
|
109959
|
-
|
|
110037
|
+
fs10.writeFileSync(path12.join(CONFIG_DIR, "motebit.md"), identityContent, "utf-8");
|
|
109960
110038
|
} catch {
|
|
109961
110039
|
}
|
|
109962
110040
|
try {
|
|
109963
110041
|
const latestGradient = moteDb.gradientStore.latest(motebitId);
|
|
109964
110042
|
if (latestGradient) {
|
|
109965
|
-
const gradientPath =
|
|
109966
|
-
|
|
110043
|
+
const gradientPath = path12.join(outputDir, "gradient.json");
|
|
110044
|
+
fs10.writeFileSync(gradientPath, JSON.stringify(latestGradient, null, 2), "utf-8");
|
|
109967
110045
|
exported.push("gradient snapshot");
|
|
109968
110046
|
} else {
|
|
109969
110047
|
skipped.push("gradient (no snapshots recorded)");
|
|
@@ -109990,8 +110068,8 @@ async function handleExport(config) {
|
|
|
109990
110068
|
if (credResult.ok) {
|
|
109991
110069
|
const credBody = credResult.data;
|
|
109992
110070
|
const creds = credBody.credentials ?? [];
|
|
109993
|
-
const credPath =
|
|
109994
|
-
|
|
110071
|
+
const credPath = path12.join(outputDir, "credentials.json");
|
|
110072
|
+
fs10.writeFileSync(credPath, JSON.stringify(creds, null, 2), "utf-8");
|
|
109995
110073
|
exported.push(`${creds.length} credential${creds.length !== 1 ? "s" : ""}`);
|
|
109996
110074
|
} else {
|
|
109997
110075
|
skipped.push(`credentials (${credResult.error})`);
|
|
@@ -110003,8 +110081,8 @@ async function handleExport(config) {
|
|
|
110003
110081
|
);
|
|
110004
110082
|
if (vpResult.ok) {
|
|
110005
110083
|
const vpBody = vpResult.data;
|
|
110006
|
-
const vpPath =
|
|
110007
|
-
|
|
110084
|
+
const vpPath = path12.join(outputDir, "presentation.json");
|
|
110085
|
+
fs10.writeFileSync(vpPath, JSON.stringify(vpBody.presentation ?? vpBody, null, 2), "utf-8");
|
|
110008
110086
|
const credCount = vpBody.credential_count ?? 0;
|
|
110009
110087
|
exported.push(`presentation (${credCount} credential${credCount !== 1 ? "s" : ""})`);
|
|
110010
110088
|
} else {
|
|
@@ -110012,16 +110090,16 @@ async function handleExport(config) {
|
|
|
110012
110090
|
}
|
|
110013
110091
|
try {
|
|
110014
110092
|
const ossaManifest = generateOssaManifest(motebitId, publicKeyHex);
|
|
110015
|
-
const ossaPath =
|
|
110016
|
-
|
|
110093
|
+
const ossaPath = path12.join(outputDir, "ossa-manifest.yaml");
|
|
110094
|
+
fs10.writeFileSync(ossaPath, ossaManifest, "utf-8");
|
|
110017
110095
|
exported.push("OSSA manifest");
|
|
110018
110096
|
} catch {
|
|
110019
110097
|
skipped.push("OSSA manifest (generation failed)");
|
|
110020
110098
|
}
|
|
110021
110099
|
const budgetResult = await fetchRelayJson(`${baseUrl}/agent/${motebitId}/budget`, headers);
|
|
110022
110100
|
if (budgetResult.ok) {
|
|
110023
|
-
const budgetPath =
|
|
110024
|
-
|
|
110101
|
+
const budgetPath = path12.join(outputDir, "budget.json");
|
|
110102
|
+
fs10.writeFileSync(budgetPath, JSON.stringify(budgetResult.data, null, 2), "utf-8");
|
|
110025
110103
|
const budgetData = budgetResult.data;
|
|
110026
110104
|
const allocCount = budgetData.allocations?.length ?? 0;
|
|
110027
110105
|
exported.push(`budget (${allocCount} allocation${allocCount !== 1 ? "s" : ""})`);
|
|
@@ -110485,8 +110563,8 @@ async function handleGoalSetEnabled(config, enabled2) {
|
|
|
110485
110563
|
|
|
110486
110564
|
// src/subcommands/init.ts
|
|
110487
110565
|
init_esm_shims();
|
|
110488
|
-
import * as
|
|
110489
|
-
import * as
|
|
110566
|
+
import * as fs11 from "fs";
|
|
110567
|
+
import * as path13 from "path";
|
|
110490
110568
|
var DEFAULT_PATH = "motebit.yaml";
|
|
110491
110569
|
var SCAFFOLD = `# motebit.yaml \u2014 declarative config for a motebit.
|
|
110492
110570
|
#
|
|
@@ -110538,14 +110616,14 @@ routines: []
|
|
|
110538
110616
|
`;
|
|
110539
110617
|
function handleInit(config) {
|
|
110540
110618
|
const targetRelative = config.file ?? DEFAULT_PATH;
|
|
110541
|
-
const target =
|
|
110542
|
-
if (
|
|
110619
|
+
const target = path13.isAbsolute(targetRelative) ? targetRelative : path13.join(process.cwd(), targetRelative);
|
|
110620
|
+
if (fs11.existsSync(target) && !config.force) {
|
|
110543
110621
|
console.error(
|
|
110544
110622
|
`Error: ${target} already exists. Edit it directly, or pass --force to overwrite.`
|
|
110545
110623
|
);
|
|
110546
110624
|
process.exit(1);
|
|
110547
110625
|
}
|
|
110548
|
-
|
|
110626
|
+
fs11.writeFileSync(target, SCAFFOLD, "utf-8");
|
|
110549
110627
|
console.log(`Wrote ${target}`);
|
|
110550
110628
|
console.log("Next: edit the file to declare routines, then run `motebit up`.");
|
|
110551
110629
|
}
|
|
@@ -110767,9 +110845,9 @@ function formatDiagnostic(d6) {
|
|
|
110767
110845
|
const pathStr = d6.path.length === 0 ? "" : `${formatPath(d6.path)}: `;
|
|
110768
110846
|
return `${loc}: ${pathStr}${d6.message}`;
|
|
110769
110847
|
}
|
|
110770
|
-
function formatPath(
|
|
110848
|
+
function formatPath(path20) {
|
|
110771
110849
|
const parts = [];
|
|
110772
|
-
for (const seg of
|
|
110850
|
+
for (const seg of path20) {
|
|
110773
110851
|
if (typeof seg === "number") {
|
|
110774
110852
|
parts.push(`[${seg}]`);
|
|
110775
110853
|
} else if (parts.length === 0) {
|
|
@@ -110885,7 +110963,7 @@ import { isMap, isSeq, isScalar } from "yaml";
|
|
|
110885
110963
|
function findPathAtOffset(doc, offset) {
|
|
110886
110964
|
return walk(doc.contents, offset, []);
|
|
110887
110965
|
}
|
|
110888
|
-
function walk(node, offset,
|
|
110966
|
+
function walk(node, offset, path20) {
|
|
110889
110967
|
if (node == null) return null;
|
|
110890
110968
|
if (isMap(node)) {
|
|
110891
110969
|
for (const pair of node.items) {
|
|
@@ -110894,30 +110972,30 @@ function walk(node, offset, path19) {
|
|
|
110894
110972
|
const keyName = key != null && isScalar(key) ? String(key.value) : null;
|
|
110895
110973
|
const keyRange = key?.range;
|
|
110896
110974
|
if (keyRange && offset >= keyRange[0] && offset <= keyRange[1]) {
|
|
110897
|
-
return { path: keyName != null ? [...
|
|
110975
|
+
return { path: keyName != null ? [...path20, keyName] : path20, onKey: true };
|
|
110898
110976
|
}
|
|
110899
110977
|
const valueRange = value?.range;
|
|
110900
110978
|
if (value && keyName != null && valueRange) {
|
|
110901
110979
|
if (offset >= valueRange[0] && offset <= valueRange[2]) {
|
|
110902
|
-
const inner = walk(value, offset, [...
|
|
110980
|
+
const inner = walk(value, offset, [...path20, keyName]);
|
|
110903
110981
|
if (inner) return inner;
|
|
110904
|
-
return { path: [...
|
|
110982
|
+
return { path: [...path20, keyName], onKey: false };
|
|
110905
110983
|
}
|
|
110906
110984
|
}
|
|
110907
110985
|
}
|
|
110908
|
-
return
|
|
110986
|
+
return path20.length > 0 ? { path: path20, onKey: false } : null;
|
|
110909
110987
|
}
|
|
110910
110988
|
if (isSeq(node)) {
|
|
110911
110989
|
for (let i = 0; i < node.items.length; i++) {
|
|
110912
110990
|
const item = node.items[i];
|
|
110913
110991
|
const range = item?.range;
|
|
110914
110992
|
if (range && offset >= range[0] && offset <= range[2]) {
|
|
110915
|
-
const inner = walk(item, offset, [...
|
|
110993
|
+
const inner = walk(item, offset, [...path20, i]);
|
|
110916
110994
|
if (inner) return inner;
|
|
110917
|
-
return { path: [...
|
|
110995
|
+
return { path: [...path20, i], onKey: false };
|
|
110918
110996
|
}
|
|
110919
110997
|
}
|
|
110920
|
-
return
|
|
110998
|
+
return path20.length > 0 ? { path: path20, onKey: false } : null;
|
|
110921
110999
|
}
|
|
110922
111000
|
return null;
|
|
110923
111001
|
}
|
|
@@ -110950,9 +111028,9 @@ function findDescription(schema) {
|
|
|
110950
111028
|
cur = next;
|
|
110951
111029
|
}
|
|
110952
111030
|
}
|
|
110953
|
-
function resolvePath(schema,
|
|
111031
|
+
function resolvePath(schema, path20) {
|
|
110954
111032
|
let cur = schema;
|
|
110955
|
-
for (const seg of
|
|
111033
|
+
for (const seg of path20) {
|
|
110956
111034
|
const inner = unwrapAll(cur);
|
|
110957
111035
|
if (inner instanceof z44.ZodObject) {
|
|
110958
111036
|
const shape = inner.shape;
|
|
@@ -110969,8 +111047,8 @@ function resolvePath(schema, path19) {
|
|
|
110969
111047
|
}
|
|
110970
111048
|
return cur;
|
|
110971
111049
|
}
|
|
110972
|
-
function objectKeys(schema,
|
|
110973
|
-
const target = resolvePath(schema,
|
|
111050
|
+
function objectKeys(schema, path20) {
|
|
111051
|
+
const target = resolvePath(schema, path20);
|
|
110974
111052
|
if (target == null) return [];
|
|
110975
111053
|
const inner = unwrapAll(target);
|
|
110976
111054
|
if (inner instanceof z44.ZodObject) {
|
|
@@ -110984,8 +111062,8 @@ function objectKeys(schema, path19) {
|
|
|
110984
111062
|
}
|
|
110985
111063
|
return [];
|
|
110986
111064
|
}
|
|
110987
|
-
function enumValues(schema,
|
|
110988
|
-
const target = resolvePath(schema,
|
|
111065
|
+
function enumValues(schema, path20) {
|
|
111066
|
+
const target = resolvePath(schema, path20);
|
|
110989
111067
|
if (target == null) return null;
|
|
110990
111068
|
const inner = unwrapAll(target);
|
|
110991
111069
|
if (inner instanceof z44.ZodEnum) {
|
|
@@ -111050,9 +111128,9 @@ async function computeDiagnostics(doc) {
|
|
|
111050
111128
|
}
|
|
111051
111129
|
return diagnostics;
|
|
111052
111130
|
}
|
|
111053
|
-
function formatPath2(
|
|
111131
|
+
function formatPath2(path20) {
|
|
111054
111132
|
const parts = [];
|
|
111055
|
-
for (const seg of
|
|
111133
|
+
for (const seg of path20) {
|
|
111056
111134
|
if (typeof seg === "number") {
|
|
111057
111135
|
parts.push(`[${seg}]`);
|
|
111058
111136
|
} else if (parts.length === 0) {
|
|
@@ -111145,14 +111223,14 @@ function inferParentPath(lines, currentLine, currentIndent) {
|
|
|
111145
111223
|
stack.unshift({ indent: effectiveIndent, key, isArray: arrayBullet });
|
|
111146
111224
|
if (effectiveIndent === 0) break;
|
|
111147
111225
|
}
|
|
111148
|
-
const
|
|
111226
|
+
const path20 = [];
|
|
111149
111227
|
for (let i = 0; i < stack.length; i++) {
|
|
111150
111228
|
const cur = stack[i];
|
|
111151
|
-
|
|
111229
|
+
path20.push(cur.key);
|
|
111152
111230
|
const next = stack[i + 1];
|
|
111153
|
-
if (next && next.isArray)
|
|
111231
|
+
if (next && next.isArray) path20.push(0);
|
|
111154
111232
|
}
|
|
111155
|
-
return
|
|
111233
|
+
return path20;
|
|
111156
111234
|
}
|
|
111157
111235
|
|
|
111158
111236
|
// src/subcommands/lsp.ts
|
|
@@ -111210,8 +111288,8 @@ init_dist25();
|
|
|
111210
111288
|
init_dist11();
|
|
111211
111289
|
init_config2();
|
|
111212
111290
|
init_runtime_factory();
|
|
111213
|
-
import * as
|
|
111214
|
-
import * as
|
|
111291
|
+
import * as fs12 from "fs";
|
|
111292
|
+
import * as path14 from "path";
|
|
111215
111293
|
async function handleUp(config) {
|
|
111216
111294
|
const yamlPath = resolveYamlPath(config.file);
|
|
111217
111295
|
if (yamlPath == null) {
|
|
@@ -111246,7 +111324,7 @@ async function handleUp(config) {
|
|
|
111246
111324
|
console.log("\nApplied.");
|
|
111247
111325
|
}
|
|
111248
111326
|
async function applyMotebitYaml(opts) {
|
|
111249
|
-
const raw =
|
|
111327
|
+
const raw = fs12.readFileSync(opts.yamlPath, "utf-8");
|
|
111250
111328
|
const parsed = await parseMotebitYaml(raw, opts.yamlPath);
|
|
111251
111329
|
if (!parsed.ok) {
|
|
111252
111330
|
return { kind: "parse_error", diagnostics: parsed.diagnostics };
|
|
@@ -111407,14 +111485,14 @@ function printPlan(plan, opts) {
|
|
|
111407
111485
|
}
|
|
111408
111486
|
function resolveYamlPath(explicit) {
|
|
111409
111487
|
if (explicit != null && explicit !== "") {
|
|
111410
|
-
const abs =
|
|
111411
|
-
return
|
|
111488
|
+
const abs = path14.isAbsolute(explicit) ? explicit : path14.resolve(explicit);
|
|
111489
|
+
return fs12.existsSync(abs) ? abs : null;
|
|
111412
111490
|
}
|
|
111413
111491
|
let dir = process.cwd();
|
|
111414
111492
|
for (; ; ) {
|
|
111415
|
-
const candidate =
|
|
111416
|
-
if (
|
|
111417
|
-
const parent =
|
|
111493
|
+
const candidate = path14.join(dir, "motebit.yaml");
|
|
111494
|
+
if (fs12.existsSync(candidate)) return candidate;
|
|
111495
|
+
const parent = path14.dirname(dir);
|
|
111418
111496
|
if (parent === dir) return null;
|
|
111419
111497
|
dir = parent;
|
|
111420
111498
|
}
|
|
@@ -111675,8 +111753,8 @@ init_esm_shims();
|
|
|
111675
111753
|
init_dist6();
|
|
111676
111754
|
init_config2();
|
|
111677
111755
|
init_identity();
|
|
111678
|
-
import * as
|
|
111679
|
-
import * as
|
|
111756
|
+
import * as fs13 from "fs";
|
|
111757
|
+
import * as path15 from "path";
|
|
111680
111758
|
async function handleMigrateKeyring(config) {
|
|
111681
111759
|
const force = config.force === true;
|
|
111682
111760
|
const fullConfig = loadFullConfig();
|
|
@@ -111692,8 +111770,8 @@ async function handleMigrateKeyring(config) {
|
|
|
111692
111770
|
);
|
|
111693
111771
|
process.exit(1);
|
|
111694
111772
|
}
|
|
111695
|
-
const devKeyringPath =
|
|
111696
|
-
if (!
|
|
111773
|
+
const devKeyringPath = path15.join(CONFIG_DIR, "dev-keyring.json");
|
|
111774
|
+
if (!fs13.existsSync(devKeyringPath)) {
|
|
111697
111775
|
console.error(`Error: no plaintext keyring at ${devKeyringPath}.`);
|
|
111698
111776
|
console.error(
|
|
111699
111777
|
" This subcommand recovers from configs where cli_encrypted_key was lost\n but a plaintext key remains on disk. If you have neither, run\n `motebit` (no args) to create a fresh identity."
|
|
@@ -111702,7 +111780,7 @@ async function handleMigrateKeyring(config) {
|
|
|
111702
111780
|
}
|
|
111703
111781
|
let devKeyring;
|
|
111704
111782
|
try {
|
|
111705
|
-
const raw =
|
|
111783
|
+
const raw = fs13.readFileSync(devKeyringPath, "utf-8");
|
|
111706
111784
|
devKeyring = JSON.parse(raw);
|
|
111707
111785
|
} catch (err2) {
|
|
111708
111786
|
console.error(
|
|
@@ -111768,9 +111846,9 @@ async function handleMigrateKeyring(config) {
|
|
|
111768
111846
|
saveFullConfig(fullConfig);
|
|
111769
111847
|
secureErase(privateKeyBytes);
|
|
111770
111848
|
try {
|
|
111771
|
-
const stat =
|
|
111772
|
-
|
|
111773
|
-
|
|
111849
|
+
const stat = fs13.statSync(devKeyringPath);
|
|
111850
|
+
fs13.writeFileSync(devKeyringPath, "0".repeat(Math.min(stat.size, 4096)));
|
|
111851
|
+
fs13.unlinkSync(devKeyringPath);
|
|
111774
111852
|
} catch (err2) {
|
|
111775
111853
|
console.warn(
|
|
111776
111854
|
`Warning: could not remove ${devKeyringPath} (${err2 instanceof Error ? err2.message : String(err2)}).`
|
|
@@ -112153,7 +112231,7 @@ init_dist6();
|
|
|
112153
112231
|
init_config2();
|
|
112154
112232
|
init_identity();
|
|
112155
112233
|
init_colors();
|
|
112156
|
-
import * as
|
|
112234
|
+
import * as fs14 from "fs";
|
|
112157
112235
|
import * as readline5 from "readline";
|
|
112158
112236
|
var IDENTITY_SUITE = "motebit-jcs-ed25519-hex-v1";
|
|
112159
112237
|
function askVisible(prompt2) {
|
|
@@ -112179,7 +112257,7 @@ async function handleRestore(config) {
|
|
|
112179
112257
|
let mdContent = null;
|
|
112180
112258
|
if (mdPath != null) {
|
|
112181
112259
|
try {
|
|
112182
|
-
mdContent =
|
|
112260
|
+
mdContent = fs14.readFileSync(mdPath, "utf-8");
|
|
112183
112261
|
} catch (err2) {
|
|
112184
112262
|
console.error(`Cannot read ${mdPath}: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
112185
112263
|
process.exit(1);
|
|
@@ -112371,7 +112449,7 @@ async function handleKeychain(config) {
|
|
|
112371
112449
|
|
|
112372
112450
|
// src/subcommands/relay.ts
|
|
112373
112451
|
init_esm_shims();
|
|
112374
|
-
import * as
|
|
112452
|
+
import * as fs15 from "fs";
|
|
112375
112453
|
import { serve } from "@hono/node-server";
|
|
112376
112454
|
|
|
112377
112455
|
// ../../services/relay/dist/index.js
|
|
@@ -120974,7 +121052,7 @@ function resolveRelayDbPath(override) {
|
|
|
120974
121052
|
if (override != null && override !== "") return override;
|
|
120975
121053
|
const envPath = process.env["MOTEBIT_RELAY_DB_PATH"];
|
|
120976
121054
|
if (envPath != null && envPath !== "") return envPath;
|
|
120977
|
-
|
|
121055
|
+
fs15.mkdirSync(RELAY_DIR, { recursive: true });
|
|
120978
121056
|
return RELAY_DB_PATH;
|
|
120979
121057
|
}
|
|
120980
121058
|
async function resolveOptions2(config) {
|
|
@@ -121108,22 +121186,22 @@ init_dist6();
|
|
|
121108
121186
|
init_config2();
|
|
121109
121187
|
init_identity();
|
|
121110
121188
|
import * as readline6 from "readline";
|
|
121111
|
-
import * as
|
|
121112
|
-
import * as
|
|
121189
|
+
import * as fs16 from "fs";
|
|
121190
|
+
import * as path16 from "path";
|
|
121113
121191
|
function discoverIdentityFile() {
|
|
121114
121192
|
let dir = process.cwd();
|
|
121115
|
-
const root =
|
|
121116
|
-
let parent =
|
|
121193
|
+
const root = path16.parse(dir).root;
|
|
121194
|
+
let parent = path16.dirname(dir);
|
|
121117
121195
|
while (dir !== parent && dir !== root) {
|
|
121118
|
-
const candidate =
|
|
121119
|
-
if (
|
|
121196
|
+
const candidate = path16.join(dir, "motebit.md");
|
|
121197
|
+
if (fs16.existsSync(candidate)) return candidate;
|
|
121120
121198
|
dir = parent;
|
|
121121
|
-
parent =
|
|
121199
|
+
parent = path16.dirname(dir);
|
|
121122
121200
|
}
|
|
121123
|
-
const rootCandidate =
|
|
121124
|
-
if (
|
|
121125
|
-
const homeCandidate =
|
|
121126
|
-
if (
|
|
121201
|
+
const rootCandidate = path16.join(root, "motebit.md");
|
|
121202
|
+
if (fs16.existsSync(rootCandidate)) return rootCandidate;
|
|
121203
|
+
const homeCandidate = path16.join(CONFIG_DIR, "identity.md");
|
|
121204
|
+
if (fs16.existsSync(homeCandidate)) return homeCandidate;
|
|
121127
121205
|
return null;
|
|
121128
121206
|
}
|
|
121129
121207
|
async function handleRotate(config) {
|
|
@@ -121138,7 +121216,7 @@ async function handleRotate(config) {
|
|
|
121138
121216
|
Identity file: ${identityPath}`);
|
|
121139
121217
|
let existingContent;
|
|
121140
121218
|
try {
|
|
121141
|
-
existingContent =
|
|
121219
|
+
existingContent = fs16.readFileSync(identityPath, "utf-8");
|
|
121142
121220
|
} catch (err2) {
|
|
121143
121221
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
121144
121222
|
console.error(`Error: cannot read identity file: ${msg}`);
|
|
@@ -121209,7 +121287,7 @@ Identity file: ${identityPath}`);
|
|
|
121209
121287
|
rl.close();
|
|
121210
121288
|
process.exit(1);
|
|
121211
121289
|
}
|
|
121212
|
-
|
|
121290
|
+
fs16.writeFileSync(identityPath, rotatedContent, "utf-8");
|
|
121213
121291
|
console.log(" Identity file: updated and re-signed");
|
|
121214
121292
|
fullConfig.cli_encrypted_key = await encryptPrivateKey(
|
|
121215
121293
|
bytesToHex4(rotateResult.newPrivateKey),
|
|
@@ -121401,12 +121479,12 @@ init_esm_shims();
|
|
|
121401
121479
|
init_dist6();
|
|
121402
121480
|
init_config2();
|
|
121403
121481
|
import * as crypto3 from "crypto";
|
|
121404
|
-
import * as
|
|
121405
|
-
import * as
|
|
121482
|
+
import * as fs17 from "fs";
|
|
121483
|
+
import * as path17 from "path";
|
|
121406
121484
|
var SMOKE_UNIT_COST_USD = 0.01;
|
|
121407
121485
|
var SMOKE_CAPABILITY = "echo";
|
|
121408
|
-
var BUYER_EOA_FILE =
|
|
121409
|
-
var WORKER_EOA_FILE =
|
|
121486
|
+
var BUYER_EOA_FILE = path17.join(CONFIG_DIR, "smoke-x402-buyer-eoa.txt");
|
|
121487
|
+
var WORKER_EOA_FILE = path17.join(CONFIG_DIR, "smoke-x402-worker-eoa.txt");
|
|
121410
121488
|
var USDC_CONTRACTS2 = {
|
|
121411
121489
|
mainnet: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
121412
121490
|
testnet: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
|
|
@@ -121484,8 +121562,8 @@ async function handleSmokeX402(config) {
|
|
|
121484
121562
|
}
|
|
121485
121563
|
async function loadOrGenerateEoa(filePath, label) {
|
|
121486
121564
|
const { generatePrivateKey, privateKeyToAccount } = await import("viem/accounts");
|
|
121487
|
-
if (
|
|
121488
|
-
const privateKey2 =
|
|
121565
|
+
if (fs17.existsSync(filePath)) {
|
|
121566
|
+
const privateKey2 = fs17.readFileSync(filePath, "utf-8").trim();
|
|
121489
121567
|
if (!/^0x[0-9a-f]{64}$/i.test(privateKey2)) {
|
|
121490
121568
|
throw new Error(
|
|
121491
121569
|
`${filePath} is not a valid EOA private key (expected 0x + 64 hex). Delete the file to regenerate.`
|
|
@@ -121494,9 +121572,9 @@ async function loadOrGenerateEoa(filePath, label) {
|
|
|
121494
121572
|
const account2 = privateKeyToAccount(privateKey2);
|
|
121495
121573
|
return { address: account2.address, privateKey: privateKey2, justGenerated: false };
|
|
121496
121574
|
}
|
|
121497
|
-
|
|
121575
|
+
fs17.mkdirSync(path17.dirname(filePath), { recursive: true });
|
|
121498
121576
|
const privateKey = generatePrivateKey();
|
|
121499
|
-
|
|
121577
|
+
fs17.writeFileSync(filePath, privateKey, { mode: 384 });
|
|
121500
121578
|
const account = privateKeyToAccount(privateKey);
|
|
121501
121579
|
console.log(`Generated ${label} EOA at ${filePath} (mode 0600)`);
|
|
121502
121580
|
return { address: account.address, privateKey, justGenerated: true };
|
|
@@ -121721,13 +121799,13 @@ init_colors();
|
|
|
121721
121799
|
import {
|
|
121722
121800
|
appendFileSync,
|
|
121723
121801
|
existsSync as existsSync10,
|
|
121724
|
-
mkdirSync as
|
|
121725
|
-
readFileSync as
|
|
121802
|
+
mkdirSync as mkdirSync12,
|
|
121803
|
+
readFileSync as readFileSync14,
|
|
121726
121804
|
readdirSync as readdirSync4,
|
|
121727
121805
|
statSync as statSync4,
|
|
121728
|
-
writeFileSync as
|
|
121806
|
+
writeFileSync as writeFileSync16
|
|
121729
121807
|
} from "fs";
|
|
121730
|
-
import { isAbsolute as isAbsolute3, join as
|
|
121808
|
+
import { isAbsolute as isAbsolute3, join as join19, resolve as resolve10 } from "path";
|
|
121731
121809
|
import * as readline7 from "readline";
|
|
121732
121810
|
var DEFAULT_RELAY_URL = "https://relay.motebit.com";
|
|
121733
121811
|
var REGISTRY_ADDRESS_RE = /^did:key:z[1-9A-HJ-NP-Za-km-z]+\/[a-z0-9-]+@[^/]+$/;
|
|
@@ -121747,15 +121825,15 @@ function resolveRelayUrl() {
|
|
|
121747
121825
|
var SKILLS_DIR_NAME = "skills";
|
|
121748
121826
|
var AUDIT_LOG_NAME = "audit.log";
|
|
121749
121827
|
function getSkillsRoot() {
|
|
121750
|
-
return
|
|
121828
|
+
return join19(CONFIG_DIR, SKILLS_DIR_NAME);
|
|
121751
121829
|
}
|
|
121752
121830
|
function getAuditLogPath() {
|
|
121753
|
-
return
|
|
121831
|
+
return join19(getSkillsRoot(), AUDIT_LOG_NAME);
|
|
121754
121832
|
}
|
|
121755
121833
|
function makeAuditSink() {
|
|
121756
121834
|
return (event) => {
|
|
121757
121835
|
const root = getSkillsRoot();
|
|
121758
|
-
if (!existsSync10(root))
|
|
121836
|
+
if (!existsSync10(root)) mkdirSync12(root, { recursive: true });
|
|
121759
121837
|
appendFileSync(getAuditLogPath(), JSON.stringify(event) + "\n", "utf-8");
|
|
121760
121838
|
};
|
|
121761
121839
|
}
|
|
@@ -121793,18 +121871,18 @@ async function handleSkillsInstall(config) {
|
|
|
121793
121871
|
await installFromDirectory(config, sourceArg);
|
|
121794
121872
|
}
|
|
121795
121873
|
async function installFromDirectory(config, sourceArg) {
|
|
121796
|
-
const
|
|
121874
|
+
const path20 = isAbsolute3(sourceArg) ? sourceArg : resolve10(process.cwd(), sourceArg);
|
|
121797
121875
|
let stat;
|
|
121798
121876
|
try {
|
|
121799
|
-
stat = statSync4(
|
|
121877
|
+
stat = statSync4(path20);
|
|
121800
121878
|
} catch {
|
|
121801
|
-
console.error(error2(`No such path: ${
|
|
121879
|
+
console.error(error2(`No such path: ${path20}`));
|
|
121802
121880
|
process.exit(1);
|
|
121803
121881
|
}
|
|
121804
121882
|
if (!stat.isDirectory()) {
|
|
121805
121883
|
console.error(
|
|
121806
121884
|
error2(
|
|
121807
|
-
`Source must be a directory containing SKILL.md and skill-envelope.json. Got: ${
|
|
121885
|
+
`Source must be a directory containing SKILL.md and skill-envelope.json. Got: ${path20}`
|
|
121808
121886
|
)
|
|
121809
121887
|
);
|
|
121810
121888
|
console.error(dim("(git+ssh install sources land in phase 2.)"));
|
|
@@ -121812,13 +121890,13 @@ async function installFromDirectory(config, sourceArg) {
|
|
|
121812
121890
|
}
|
|
121813
121891
|
let installSource;
|
|
121814
121892
|
try {
|
|
121815
|
-
installSource = resolveDirectorySkillSource(
|
|
121893
|
+
installSource = resolveDirectorySkillSource(path20);
|
|
121816
121894
|
} catch (err2) {
|
|
121817
|
-
console.error(error2(`Failed to read skill at ${
|
|
121895
|
+
console.error(error2(`Failed to read skill at ${path20}:`));
|
|
121818
121896
|
console.error(` ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
121819
121897
|
process.exit(1);
|
|
121820
121898
|
}
|
|
121821
|
-
await runInstall(config, installSource, `directory:${
|
|
121899
|
+
await runInstall(config, installSource, `directory:${path20}`, path20);
|
|
121822
121900
|
}
|
|
121823
121901
|
async function installFromRelay(config, rawAddress, parsed) {
|
|
121824
121902
|
const relayUrl = resolveRelayUrl().replace(/\/$/, "");
|
|
@@ -121894,8 +121972,8 @@ async function installFromRelay(config, rawAddress, parsed) {
|
|
|
121894
121972
|
const bodyBytes = base64Decode2(bundle.body);
|
|
121895
121973
|
const fileBytes = {};
|
|
121896
121974
|
if (bundle.files) {
|
|
121897
|
-
for (const [
|
|
121898
|
-
fileBytes[
|
|
121975
|
+
for (const [path20, b64] of Object.entries(bundle.files)) {
|
|
121976
|
+
fileBytes[path20] = base64Decode2(b64);
|
|
121899
121977
|
}
|
|
121900
121978
|
}
|
|
121901
121979
|
const installSource = {
|
|
@@ -122091,9 +122169,9 @@ function parseAuditFilters(config) {
|
|
|
122091
122169
|
return { skillName, type, limit, json: config.json };
|
|
122092
122170
|
}
|
|
122093
122171
|
function readAuditEvents() {
|
|
122094
|
-
const
|
|
122095
|
-
if (!existsSync10(
|
|
122096
|
-
const text =
|
|
122172
|
+
const path20 = getAuditLogPath();
|
|
122173
|
+
if (!existsSync10(path20)) return [];
|
|
122174
|
+
const text = readFileSync14(path20, "utf-8");
|
|
122097
122175
|
const events = [];
|
|
122098
122176
|
for (const line of text.split("\n")) {
|
|
122099
122177
|
const trimmed = line.trim();
|
|
@@ -122255,8 +122333,8 @@ async function handleSkillsRunScript(config) {
|
|
|
122255
122333
|
const { mkdtempSync, writeFileSync: writeBytes, chmodSync: chmodSync3, rmSync: rmSync3 } = await import("fs");
|
|
122256
122334
|
const { tmpdir: tmpdir2 } = await import("os");
|
|
122257
122335
|
const { spawnSync: spawnSync2 } = await import("child_process");
|
|
122258
|
-
const tempDir = mkdtempSync(
|
|
122259
|
-
const tempPath =
|
|
122336
|
+
const tempDir = mkdtempSync(join19(tmpdir2(), "motebit-skill-script-"));
|
|
122337
|
+
const tempPath = join19(tempDir, scriptName);
|
|
122260
122338
|
try {
|
|
122261
122339
|
writeBytes(tempPath, Buffer.from(scriptBytes));
|
|
122262
122340
|
chmodSync3(tempPath, 448);
|
|
@@ -122326,17 +122404,17 @@ function collectAuxFiles2(skillDir) {
|
|
|
122326
122404
|
function walk2(current2, base) {
|
|
122327
122405
|
const entries = readdirSync4(current2, { withFileTypes: true });
|
|
122328
122406
|
for (const entry of entries) {
|
|
122329
|
-
const full =
|
|
122407
|
+
const full = join19(current2, entry.name);
|
|
122330
122408
|
if (entry.isDirectory()) {
|
|
122331
122409
|
walk2(full, base);
|
|
122332
122410
|
} else if (entry.isFile()) {
|
|
122333
122411
|
const rel = full.slice(base.length + 1).split(/[\\/]+/).join("/");
|
|
122334
|
-
out[rel] =
|
|
122412
|
+
out[rel] = readFileSync14(full);
|
|
122335
122413
|
}
|
|
122336
122414
|
}
|
|
122337
122415
|
}
|
|
122338
122416
|
for (const subdir of AUX_DIRS2) {
|
|
122339
|
-
const subdirPath =
|
|
122417
|
+
const subdirPath = join19(skillDir, subdir);
|
|
122340
122418
|
if (existsSync10(subdirPath)) walk2(subdirPath, skillDir);
|
|
122341
122419
|
}
|
|
122342
122420
|
return out;
|
|
@@ -122387,12 +122465,12 @@ async function loadIdentityKey() {
|
|
|
122387
122465
|
};
|
|
122388
122466
|
}
|
|
122389
122467
|
async function signSkillDirectory(skillDir, privateKey, publicKey) {
|
|
122390
|
-
const skillMdPath =
|
|
122468
|
+
const skillMdPath = join19(skillDir, SKILL_MD_NAME);
|
|
122391
122469
|
if (!existsSync10(skillMdPath)) {
|
|
122392
122470
|
console.error(error2(` No SKILL.md at ${skillMdPath}`));
|
|
122393
122471
|
process.exit(1);
|
|
122394
122472
|
}
|
|
122395
|
-
const text =
|
|
122473
|
+
const text = readFileSync14(skillMdPath, "utf-8");
|
|
122396
122474
|
const parsed = parseSkillFile(text);
|
|
122397
122475
|
const body = parsed.body;
|
|
122398
122476
|
const motebitNoSig = { ...parsed.manifest.motebit };
|
|
@@ -122411,7 +122489,7 @@ async function signSkillDirectory(skillDir, privateKey, publicKey) {
|
|
|
122411
122489
|
const bodyHash = await hash(body);
|
|
122412
122490
|
const auxFiles = collectAuxFiles2(skillDir);
|
|
122413
122491
|
const filesEntries = await Promise.all(
|
|
122414
|
-
Object.entries(auxFiles).sort(([a4], [b5]) => a4.localeCompare(b5)).map(async ([
|
|
122492
|
+
Object.entries(auxFiles).sort(([a4], [b5]) => a4.localeCompare(b5)).map(async ([path20, bytes]) => ({ path: path20, hash: await hash(bytes) }))
|
|
122415
122493
|
);
|
|
122416
122494
|
const signedEnvelope = await signSkillEnvelope(
|
|
122417
122495
|
{
|
|
@@ -122429,9 +122507,9 @@ async function signSkillDirectory(skillDir, privateKey, publicKey) {
|
|
|
122429
122507
|
publicKey
|
|
122430
122508
|
);
|
|
122431
122509
|
const skillMdContent = serializeSkillFile(signedManifest, body);
|
|
122432
|
-
|
|
122433
|
-
|
|
122434
|
-
|
|
122510
|
+
writeFileSync16(skillMdPath, skillMdContent);
|
|
122511
|
+
writeFileSync16(
|
|
122512
|
+
join19(skillDir, SKILL_ENVELOPE_JSON_NAME),
|
|
122435
122513
|
JSON.stringify(signedEnvelope, null, 2) + "\n"
|
|
122436
122514
|
);
|
|
122437
122515
|
return { envelope: signedEnvelope, manifest: signedManifest, body };
|
|
@@ -122461,8 +122539,8 @@ async function handleSkillsPublish(config) {
|
|
|
122461
122539
|
}
|
|
122462
122540
|
const auxFiles = collectAuxFiles2(skillDir);
|
|
122463
122541
|
const filesPayload = {};
|
|
122464
|
-
for (const [
|
|
122465
|
-
filesPayload[
|
|
122542
|
+
for (const [path20, bytes] of Object.entries(auxFiles)) {
|
|
122543
|
+
filesPayload[path20] = bytesToBase64(bytes);
|
|
122466
122544
|
}
|
|
122467
122545
|
const submission = {
|
|
122468
122546
|
envelope,
|
|
@@ -122508,8 +122586,8 @@ async function handleSkillsPublish(config) {
|
|
|
122508
122586
|
init_esm_shims();
|
|
122509
122587
|
init_dist34();
|
|
122510
122588
|
init_dist6();
|
|
122511
|
-
import * as
|
|
122512
|
-
import * as
|
|
122589
|
+
import * as fs18 from "fs";
|
|
122590
|
+
import * as path18 from "path";
|
|
122513
122591
|
function tryParseJson(text) {
|
|
122514
122592
|
try {
|
|
122515
122593
|
return JSON.parse(text);
|
|
@@ -122520,7 +122598,7 @@ function tryParseJson(text) {
|
|
|
122520
122598
|
function readJsonFile(filePath) {
|
|
122521
122599
|
let raw;
|
|
122522
122600
|
try {
|
|
122523
|
-
raw =
|
|
122601
|
+
raw = fs18.readFileSync(filePath, "utf-8");
|
|
122524
122602
|
} catch {
|
|
122525
122603
|
return { ok: false, error: "file not found" };
|
|
122526
122604
|
}
|
|
@@ -122553,10 +122631,10 @@ function extractSubjectMotebitId(vc) {
|
|
|
122553
122631
|
return typeof subject.id === "string" ? subject.id : null;
|
|
122554
122632
|
}
|
|
122555
122633
|
async function handleVerify(filePath) {
|
|
122556
|
-
const resolved =
|
|
122634
|
+
const resolved = path18.resolve(filePath);
|
|
122557
122635
|
let stat;
|
|
122558
122636
|
try {
|
|
122559
|
-
stat =
|
|
122637
|
+
stat = fs18.statSync(resolved);
|
|
122560
122638
|
} catch {
|
|
122561
122639
|
console.error(`Error: path does not exist: ${resolved}`);
|
|
122562
122640
|
process.exit(1);
|
|
@@ -122581,7 +122659,7 @@ async function handleVerify(filePath) {
|
|
|
122581
122659
|
async function verifySingleIdentityFile(filePath) {
|
|
122582
122660
|
let content;
|
|
122583
122661
|
try {
|
|
122584
|
-
content =
|
|
122662
|
+
content = fs18.readFileSync(filePath, "utf-8");
|
|
122585
122663
|
} catch {
|
|
122586
122664
|
console.error(`Error: cannot read file: ${filePath}`);
|
|
122587
122665
|
process.exit(1);
|
|
@@ -122674,16 +122752,16 @@ Verifying ${data.length} credential${data.length !== 1 ? "s" : ""}...
|
|
|
122674
122752
|
}
|
|
122675
122753
|
async function verifyBundle(dirPath) {
|
|
122676
122754
|
console.log(`
|
|
122677
|
-
Verifying ${
|
|
122755
|
+
Verifying ${path18.basename(dirPath)}/...
|
|
122678
122756
|
`);
|
|
122679
122757
|
let passed = true;
|
|
122680
122758
|
let motebitId = null;
|
|
122681
122759
|
let identityDid = null;
|
|
122682
|
-
const identityPath =
|
|
122683
|
-
if (
|
|
122760
|
+
const identityPath = path18.join(dirPath, "motebit.md");
|
|
122761
|
+
if (fs18.existsSync(identityPath)) {
|
|
122684
122762
|
let content;
|
|
122685
122763
|
try {
|
|
122686
|
-
content =
|
|
122764
|
+
content = fs18.readFileSync(identityPath, "utf-8");
|
|
122687
122765
|
} catch {
|
|
122688
122766
|
console.log(` Identity (motebit.md): FAILED \u2014 cannot read file`);
|
|
122689
122767
|
passed = false;
|
|
@@ -122705,9 +122783,9 @@ Verifying ${path17.basename(dirPath)}/...
|
|
|
122705
122783
|
} else {
|
|
122706
122784
|
console.log(` Identity (motebit.md): not found, skipping`);
|
|
122707
122785
|
}
|
|
122708
|
-
const credsPath =
|
|
122786
|
+
const credsPath = path18.join(dirPath, "credentials.json");
|
|
122709
122787
|
const credentials = [];
|
|
122710
|
-
if (
|
|
122788
|
+
if (fs18.existsSync(credsPath)) {
|
|
122711
122789
|
const credResult = readJsonFile(credsPath);
|
|
122712
122790
|
if (!credResult.ok) {
|
|
122713
122791
|
console.log(` Credentials: FAILED \u2014 ${credResult.error}`);
|
|
@@ -122750,8 +122828,8 @@ Verifying ${path17.basename(dirPath)}/...
|
|
|
122750
122828
|
} else {
|
|
122751
122829
|
console.log(` Credentials: not found, skipping`);
|
|
122752
122830
|
}
|
|
122753
|
-
const vpPath =
|
|
122754
|
-
if (
|
|
122831
|
+
const vpPath = path18.join(dirPath, "presentation.json");
|
|
122832
|
+
if (fs18.existsSync(vpPath)) {
|
|
122755
122833
|
const vpResult = readJsonFile(vpPath);
|
|
122756
122834
|
if (!vpResult.ok) {
|
|
122757
122835
|
console.log(` Presentation: FAILED \u2014 ${vpResult.error}`);
|
|
@@ -122800,8 +122878,8 @@ Verifying ${path17.basename(dirPath)}/...
|
|
|
122800
122878
|
passed = false;
|
|
122801
122879
|
}
|
|
122802
122880
|
}
|
|
122803
|
-
const budgetPath =
|
|
122804
|
-
if (
|
|
122881
|
+
const budgetPath = path18.join(dirPath, "budget.json");
|
|
122882
|
+
if (fs18.existsSync(budgetPath)) {
|
|
122805
122883
|
const budgetResult = readJsonFile(budgetPath);
|
|
122806
122884
|
if (!budgetResult.ok) {
|
|
122807
122885
|
console.log(` Budget: FAILED \u2014 ${budgetResult.error}`);
|
|
@@ -122823,8 +122901,8 @@ Verifying ${path17.basename(dirPath)}/...
|
|
|
122823
122901
|
} else {
|
|
122824
122902
|
console.log(` Budget: not found, skipping`);
|
|
122825
122903
|
}
|
|
122826
|
-
const gradientPath =
|
|
122827
|
-
if (
|
|
122904
|
+
const gradientPath = path18.join(dirPath, "gradient.json");
|
|
122905
|
+
if (fs18.existsSync(gradientPath)) {
|
|
122828
122906
|
const gradientResult = readJsonFile(gradientPath);
|
|
122829
122907
|
if (!gradientResult.ok) {
|
|
122830
122908
|
console.log(` Gradient: FAILED \u2014 ${gradientResult.error}`);
|
|
@@ -122851,7 +122929,7 @@ init_esm_shims();
|
|
|
122851
122929
|
init_dist6();
|
|
122852
122930
|
init_dist31();
|
|
122853
122931
|
init_colors();
|
|
122854
|
-
import { readFileSync as
|
|
122932
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
122855
122933
|
import { resolve as resolve12 } from "path";
|
|
122856
122934
|
var KIND_KEYWORDS = /* @__PURE__ */ new Set(["receipt", "token", "listing"]);
|
|
122857
122935
|
function isVerifyKind(s3) {
|
|
@@ -122862,7 +122940,7 @@ async function verifyWire(kind, filePath, now = Date.now()) {
|
|
|
122862
122940
|
const absPath = resolve12(filePath);
|
|
122863
122941
|
let raw;
|
|
122864
122942
|
try {
|
|
122865
|
-
const text =
|
|
122943
|
+
const text = readFileSync16(absPath, "utf-8");
|
|
122866
122944
|
raw = JSON.parse(text);
|
|
122867
122945
|
checks.push({ name: "json", ok: true, detail: `parsed ${text.length} bytes` });
|
|
122868
122946
|
} catch (err2) {
|
|
@@ -122986,7 +123064,7 @@ async function handleVerifyWire(kindArg, pathArg, opts) {
|
|
|
122986
123064
|
// src/subcommands/verify-release.ts
|
|
122987
123065
|
init_esm_shims();
|
|
122988
123066
|
import { createHash as createHash3 } from "crypto";
|
|
122989
|
-
import { readFileSync as
|
|
123067
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
122990
123068
|
init_config2();
|
|
122991
123069
|
init_config2();
|
|
122992
123070
|
async function handleVerifyRelease(options = {}) {
|
|
@@ -123000,7 +123078,7 @@ async function handleVerifyRelease(options = {}) {
|
|
|
123000
123078
|
}
|
|
123001
123079
|
let selfHash;
|
|
123002
123080
|
try {
|
|
123003
|
-
selfHash = createHash3("sha256").update(
|
|
123081
|
+
selfHash = createHash3("sha256").update(readFileSync17(bundlePath)).digest("hex");
|
|
123004
123082
|
} catch (err2) {
|
|
123005
123083
|
console.error(
|
|
123006
123084
|
`verify-release: cannot read own bytes at ${bundlePath}: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
@@ -123065,8 +123143,8 @@ init_dist22();
|
|
|
123065
123143
|
init_dist2();
|
|
123066
123144
|
init_dist6();
|
|
123067
123145
|
init_dist34();
|
|
123068
|
-
import * as
|
|
123069
|
-
import * as
|
|
123146
|
+
import * as fs19 from "fs";
|
|
123147
|
+
import * as path19 from "path";
|
|
123070
123148
|
init_dist10();
|
|
123071
123149
|
init_dist13();
|
|
123072
123150
|
|
|
@@ -123958,10 +124036,10 @@ async function publishServiceListing(syncUrl, motebitId, headers, toolNames, pri
|
|
|
123958
124036
|
}
|
|
123959
124037
|
async function handleRun(config) {
|
|
123960
124038
|
const explicitIdentity = config.identity != null && config.identity !== "";
|
|
123961
|
-
const identityPath = explicitIdentity ?
|
|
124039
|
+
const identityPath = explicitIdentity ? path19.resolve(config.identity) : path19.resolve("motebit.md");
|
|
123962
124040
|
let identityContent;
|
|
123963
124041
|
try {
|
|
123964
|
-
identityContent =
|
|
124042
|
+
identityContent = fs19.readFileSync(identityPath, "utf-8");
|
|
123965
124043
|
} catch {
|
|
123966
124044
|
if (explicitIdentity) {
|
|
123967
124045
|
console.error(`Error: cannot read identity file: ${identityPath}`);
|
|
@@ -124075,7 +124153,7 @@ async function handleRun(config) {
|
|
|
124075
124153
|
if (watchedYaml != null) {
|
|
124076
124154
|
console.log(`Watching ${watchedYaml} \u2014 changes will re-apply automatically.`);
|
|
124077
124155
|
try {
|
|
124078
|
-
|
|
124156
|
+
fs19.watch(watchedYaml, () => {
|
|
124079
124157
|
if (yamlDebounce) clearTimeout(yamlDebounce);
|
|
124080
124158
|
yamlDebounce = setTimeout(() => {
|
|
124081
124159
|
void (async () => {
|
|
@@ -124555,10 +124633,10 @@ async function handleServe(config) {
|
|
|
124555
124633
|
let guardianAttestation;
|
|
124556
124634
|
let policyOverrides = {};
|
|
124557
124635
|
if (config.identity != null && config.identity !== "") {
|
|
124558
|
-
const identityPath =
|
|
124636
|
+
const identityPath = path19.resolve(config.identity);
|
|
124559
124637
|
let identityContent;
|
|
124560
124638
|
try {
|
|
124561
|
-
identityContent =
|
|
124639
|
+
identityContent = fs19.readFileSync(identityPath, "utf-8");
|
|
124562
124640
|
} catch {
|
|
124563
124641
|
console.error(`Error: cannot read identity file: ${identityPath}`);
|
|
124564
124642
|
process.exit(1);
|
|
@@ -124623,7 +124701,7 @@ async function handleServe(config) {
|
|
|
124623
124701
|
const runtimeHostServer = election.server;
|
|
124624
124702
|
if (config.tools) {
|
|
124625
124703
|
const { pathToFileURL } = await import("url");
|
|
124626
|
-
const resolved =
|
|
124704
|
+
const resolved = path19.resolve(config.tools);
|
|
124627
124705
|
const mod2 = await import(pathToFileURL(resolved).href);
|
|
124628
124706
|
const entries = mod2.default ?? mod2.tools;
|
|
124629
124707
|
if (!Array.isArray(entries)) {
|
|
@@ -124863,7 +124941,7 @@ async function handleServe(config) {
|
|
|
124863
124941
|
}
|
|
124864
124942
|
if (config.identity != null && config.identity !== "") {
|
|
124865
124943
|
try {
|
|
124866
|
-
deps.identityFileContent =
|
|
124944
|
+
deps.identityFileContent = fs19.readFileSync(path19.resolve(config.identity), "utf-8");
|
|
124867
124945
|
} catch {
|
|
124868
124946
|
}
|
|
124869
124947
|
}
|
|
@@ -125140,7 +125218,7 @@ init_esm_shims();
|
|
|
125140
125218
|
import { spawn } from "child_process";
|
|
125141
125219
|
import { mkdtemp, writeFile as writeFile3, unlink } from "fs/promises";
|
|
125142
125220
|
import { tmpdir } from "os";
|
|
125143
|
-
import { join as
|
|
125221
|
+
import { join as join21 } from "path";
|
|
125144
125222
|
|
|
125145
125223
|
// ../../packages/voice/dist/index.js
|
|
125146
125224
|
init_esm_shims();
|
|
@@ -125416,22 +125494,22 @@ var SystemTTSProvider = class {
|
|
|
125416
125494
|
}
|
|
125417
125495
|
};
|
|
125418
125496
|
async function writeTempMp3(buf) {
|
|
125419
|
-
const dir = await mkdtemp(
|
|
125420
|
-
const
|
|
125421
|
-
await writeFile3(
|
|
125422
|
-
return
|
|
125497
|
+
const dir = await mkdtemp(join21(tmpdir(), "motebit-tts-"));
|
|
125498
|
+
const path20 = join21(dir, "out.mp3");
|
|
125499
|
+
await writeFile3(path20, buf);
|
|
125500
|
+
return path20;
|
|
125423
125501
|
}
|
|
125424
|
-
function mp3PlayerCommand(
|
|
125425
|
-
if (process.platform === "darwin") return { bin: "afplay", args: [
|
|
125426
|
-
return { bin: "mpg123", args: ["-q",
|
|
125502
|
+
function mp3PlayerCommand(path20) {
|
|
125503
|
+
if (process.platform === "darwin") return { bin: "afplay", args: [path20] };
|
|
125504
|
+
return { bin: "mpg123", args: ["-q", path20] };
|
|
125427
125505
|
}
|
|
125428
125506
|
function systemSpeakCommand() {
|
|
125429
125507
|
if (process.platform === "darwin") return { bin: "say", args: [] };
|
|
125430
125508
|
if (process.platform === "linux") return { bin: "espeak", args: [] };
|
|
125431
125509
|
return null;
|
|
125432
125510
|
}
|
|
125433
|
-
function playMp3(
|
|
125434
|
-
const cmd = mp3PlayerCommand(
|
|
125511
|
+
function playMp3(path20, onSpawn) {
|
|
125512
|
+
const cmd = mp3PlayerCommand(path20);
|
|
125435
125513
|
if (!cmd) {
|
|
125436
125514
|
return Promise.reject(new Error(`No MP3 player available on ${process.platform}`));
|
|
125437
125515
|
}
|
|
@@ -125812,12 +125890,16 @@ async function main() {
|
|
|
125812
125890
|
const validProviders = ["anthropic", "openai", "google", "local-server", "proxy"];
|
|
125813
125891
|
if (validProviders.includes(personalityConfig.default_provider)) {
|
|
125814
125892
|
config.provider = personalityConfig.default_provider;
|
|
125893
|
+
if (!config.modelExplicit) {
|
|
125894
|
+
config.model = defaultModelForProvider(config.provider);
|
|
125895
|
+
}
|
|
125815
125896
|
}
|
|
125816
125897
|
}
|
|
125817
125898
|
if (personalityConfig.default_model != null && personalityConfig.default_model !== "" && !process.argv.includes("--model")) {
|
|
125818
125899
|
if (admitModelForProvider(config.provider, personalityConfig.default_model).admissible) {
|
|
125819
125900
|
config.model = personalityConfig.default_model;
|
|
125820
125901
|
} else {
|
|
125902
|
+
config.model = defaultModelForProvider(config.provider);
|
|
125821
125903
|
console.log(
|
|
125822
125904
|
dim(
|
|
125823
125905
|
` [config default_model "${personalityConfig.default_model}" belongs to another provider; using ${config.model} for ${config.provider}]`
|
|
@@ -126184,6 +126266,14 @@ async function main() {
|
|
|
126184
126266
|
console.log(dim(" recovery seed not backed up \u2014 `motebit seed reveal` (once, on paper)"));
|
|
126185
126267
|
console.log();
|
|
126186
126268
|
}
|
|
126269
|
+
if (process.env["MOTEBIT_NO_UPDATE_CHECK"] !== "1") {
|
|
126270
|
+
const updateNudge = renderUpdateNudge({ currentVersion: VERSION, state: readUpdateState() });
|
|
126271
|
+
if (updateNudge != null) {
|
|
126272
|
+
console.log(dim(` ${updateNudge}`));
|
|
126273
|
+
console.log();
|
|
126274
|
+
}
|
|
126275
|
+
refreshUpdateCheckInBackground();
|
|
126276
|
+
}
|
|
126187
126277
|
if (isFirstLaunch) {
|
|
126188
126278
|
try {
|
|
126189
126279
|
const activationRunId = crypto.randomUUID();
|