@todoforai/cli 0.1.6 → 0.1.8
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/todoai.js +118 -24
- package/package.json +1 -1
package/dist/todoai.js
CHANGED
|
@@ -41805,15 +41805,15 @@ var require_route = __commonJS((exports, module) => {
|
|
|
41805
41805
|
};
|
|
41806
41806
|
}
|
|
41807
41807
|
function wrapConversion(toModel, graph) {
|
|
41808
|
-
const
|
|
41808
|
+
const path3 = [graph[toModel].parent, toModel];
|
|
41809
41809
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
41810
41810
|
let cur = graph[toModel].parent;
|
|
41811
41811
|
while (graph[cur].parent) {
|
|
41812
|
-
|
|
41812
|
+
path3.unshift(graph[cur].parent);
|
|
41813
41813
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
41814
41814
|
cur = graph[cur].parent;
|
|
41815
41815
|
}
|
|
41816
|
-
fn.conversion =
|
|
41816
|
+
fn.conversion = path3;
|
|
41817
41817
|
return fn;
|
|
41818
41818
|
}
|
|
41819
41819
|
module.exports = function(fromModel) {
|
|
@@ -42039,7 +42039,7 @@ var require_has_flag = __commonJS((exports, module) => {
|
|
|
42039
42039
|
|
|
42040
42040
|
// node_modules/supports-color/index.js
|
|
42041
42041
|
var require_supports_color = __commonJS((exports, module) => {
|
|
42042
|
-
var
|
|
42042
|
+
var os3 = __require("os");
|
|
42043
42043
|
var tty = __require("tty");
|
|
42044
42044
|
var hasFlag = require_has_flag();
|
|
42045
42045
|
var { env } = process;
|
|
@@ -42087,7 +42087,7 @@ var require_supports_color = __commonJS((exports, module) => {
|
|
|
42087
42087
|
return min;
|
|
42088
42088
|
}
|
|
42089
42089
|
if (process.platform === "win32") {
|
|
42090
|
-
const osRelease =
|
|
42090
|
+
const osRelease = os3.release().split(".");
|
|
42091
42091
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
42092
42092
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
42093
42093
|
}
|
|
@@ -42661,9 +42661,55 @@ var require_dist = __commonJS((exports) => {
|
|
|
42661
42661
|
});
|
|
42662
42662
|
|
|
42663
42663
|
// src/index.ts
|
|
42664
|
-
import { realpathSync } from "fs";
|
|
42664
|
+
import { realpathSync, readFileSync as readFileSync3 } from "fs";
|
|
42665
42665
|
import { resolve as resolve3 } from "path";
|
|
42666
|
+
import { fileURLToPath } from "url";
|
|
42666
42667
|
import { homedir as homedir3 } from "os";
|
|
42668
|
+
import path4 from "path";
|
|
42669
|
+
|
|
42670
|
+
// src/update-notifier.ts
|
|
42671
|
+
import fs from "fs";
|
|
42672
|
+
import path from "path";
|
|
42673
|
+
import os from "os";
|
|
42674
|
+
var TTL_MS = 24 * 60 * 60 * 1000;
|
|
42675
|
+
var CACHE_DIR = path.join(os.homedir(), ".config", "todoforai");
|
|
42676
|
+
function cmpVer(a, b) {
|
|
42677
|
+
const pa = a.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
42678
|
+
const pb = b.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
42679
|
+
for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
|
|
42680
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
42681
|
+
if (d)
|
|
42682
|
+
return d;
|
|
42683
|
+
}
|
|
42684
|
+
return 0;
|
|
42685
|
+
}
|
|
42686
|
+
function checkForUpdates(pkg) {
|
|
42687
|
+
if (!process.stderr.isTTY || process.env.CI || process.env.NO_UPDATE_NOTIFIER)
|
|
42688
|
+
return;
|
|
42689
|
+
const cacheFile = path.join(CACHE_DIR, `notifier-${encodeURIComponent(pkg.name)}.json`);
|
|
42690
|
+
let cache = {};
|
|
42691
|
+
try {
|
|
42692
|
+
cache = JSON.parse(fs.readFileSync(cacheFile, "utf8"));
|
|
42693
|
+
} catch {}
|
|
42694
|
+
if (cache.latest && cmpVer(cache.latest, pkg.version) > 0) {
|
|
42695
|
+
process.stderr.write(`
|
|
42696
|
+
\x1B[33m Update available: \x1B[2m${pkg.version}\x1B[22m \u2192 \x1B[1m${cache.latest}\x1B[0m
|
|
42697
|
+
` + `\x1B[33m Run:\x1B[0m npm i -g ${pkg.name}
|
|
42698
|
+
|
|
42699
|
+
`);
|
|
42700
|
+
}
|
|
42701
|
+
if (Date.now() - (cache.ts ?? 0) > TTL_MS) {
|
|
42702
|
+
try {
|
|
42703
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
42704
|
+
fs.writeFileSync(cacheFile, JSON.stringify({ ...cache, ts: Date.now() }));
|
|
42705
|
+
} catch {}
|
|
42706
|
+
fetch(`https://registry.npmjs.org/${pkg.name}/latest`, { signal: AbortSignal.timeout(3000) }).then((r) => r.ok ? r.json() : null).then((j) => {
|
|
42707
|
+
if (!j?.version)
|
|
42708
|
+
return;
|
|
42709
|
+
fs.writeFileSync(cacheFile, JSON.stringify({ ts: Date.now(), latest: j.version }));
|
|
42710
|
+
}).catch(() => {});
|
|
42711
|
+
}
|
|
42712
|
+
}
|
|
42667
42713
|
|
|
42668
42714
|
// src/tips.ts
|
|
42669
42715
|
var TIPS = [
|
|
@@ -42776,6 +42822,12 @@ class ApiClient {
|
|
|
42776
42822
|
updateAgentSettings(agentId, agentSettingsId, updates) {
|
|
42777
42823
|
return this.request("PUT", `/api/v1/agents/${agentId}/settings`, { agentSettingsId, updates });
|
|
42778
42824
|
}
|
|
42825
|
+
getGlobalAgentSettings() {
|
|
42826
|
+
return this.request("GET", "/api/v1/agents/global");
|
|
42827
|
+
}
|
|
42828
|
+
updateGlobalAgentSettings(updates) {
|
|
42829
|
+
return this.request("PUT", "/api/v1/agents/global", updates);
|
|
42830
|
+
}
|
|
42779
42831
|
setAgentEdgeMcpConfig(agentId, agentSettingsId, edgeId, mcpName, config) {
|
|
42780
42832
|
return this.request("PUT", `/api/v1/agents/${agentId}/edge-mcp-config`, { agentSettingsId, edgeId, mcpName, config });
|
|
42781
42833
|
}
|
|
@@ -42824,8 +42876,8 @@ class ApiClient {
|
|
|
42824
42876
|
import WebSocket from "ws";
|
|
42825
42877
|
|
|
42826
42878
|
// ../edge/bun/src/config.ts
|
|
42827
|
-
import
|
|
42828
|
-
import
|
|
42879
|
+
import path2 from "path";
|
|
42880
|
+
import os2 from "os";
|
|
42829
42881
|
function normalizeApiUrl(url) {
|
|
42830
42882
|
if (url.startsWith("localhost"))
|
|
42831
42883
|
return `http://${url}`;
|
|
@@ -42834,7 +42886,19 @@ function normalizeApiUrl(url) {
|
|
|
42834
42886
|
return url;
|
|
42835
42887
|
}
|
|
42836
42888
|
var SUBCOMMANDS = new Set(["login", "logout"]);
|
|
42837
|
-
|
|
42889
|
+
function credentialsPath() {
|
|
42890
|
+
const sys = os2.platform();
|
|
42891
|
+
if (sys === "win32") {
|
|
42892
|
+
return path2.join(os2.homedir(), "AppData", "Roaming", "todoforai", "credentials.json");
|
|
42893
|
+
}
|
|
42894
|
+
if (sys === "darwin") {
|
|
42895
|
+
return path2.join(os2.homedir(), "Library", "Application Support", "todoforai", "credentials.json");
|
|
42896
|
+
}
|
|
42897
|
+
const xdg = process.env.XDG_CONFIG_HOME || path2.join(os2.homedir(), ".config");
|
|
42898
|
+
return path2.join(xdg, "todoforai", "credentials.json");
|
|
42899
|
+
}
|
|
42900
|
+
var CREDENTIALS_PATH = credentialsPath();
|
|
42901
|
+
var LEGACY_CREDENTIALS_PATH = path2.join(os2.homedir(), ".todoforai", "credentials.json");
|
|
42838
42902
|
|
|
42839
42903
|
// ../edge/bun/src/frontend-ws.ts
|
|
42840
42904
|
var log = (level, ...args) => console.log(`[frontend-ws:${level}]`, ...args);
|
|
@@ -44935,33 +44999,62 @@ async function listAgentsCommand(api, opts) {
|
|
|
44935
44999
|
}
|
|
44936
45000
|
|
|
44937
45001
|
// src/ensure-edge.ts
|
|
44938
|
-
import { spawn } from "child_process";
|
|
44939
|
-
import
|
|
44940
|
-
import
|
|
44941
|
-
import
|
|
45002
|
+
import { spawn, spawnSync } from "child_process";
|
|
45003
|
+
import fs2 from "fs";
|
|
45004
|
+
import path3 from "path";
|
|
45005
|
+
import os3 from "os";
|
|
45006
|
+
function hasBunx() {
|
|
45007
|
+
const probe = spawnSync(process.platform === "win32" ? "where" : "which", ["bunx"], { stdio: "ignore" });
|
|
45008
|
+
return probe.status === 0;
|
|
45009
|
+
}
|
|
44942
45010
|
function ensureEdgeRunning(apiUrl, apiKey) {
|
|
44943
|
-
|
|
44944
|
-
|
|
44945
|
-
|
|
44946
|
-
|
|
45011
|
+
if (!hasBunx()) {
|
|
45012
|
+
console.error("\x1B[2mEdge daemon not started: `bunx` is missing. Install Bun from https://bun.sh to enable it, or pass --no-edge to silence this.\x1B[0m");
|
|
45013
|
+
return;
|
|
45014
|
+
}
|
|
45015
|
+
const logDir = path3.join(os3.homedir(), ".todoforai");
|
|
45016
|
+
fs2.mkdirSync(logDir, { recursive: true });
|
|
45017
|
+
const logFile = path3.join(logDir, "edge.log");
|
|
45018
|
+
const out = fs2.openSync(logFile, "a");
|
|
44947
45019
|
const child = spawn("bunx", ["@todoforai/edge", "--api-url", apiUrl, "--api-key", apiKey], {
|
|
44948
45020
|
detached: true,
|
|
44949
45021
|
stdio: ["ignore", out, out]
|
|
44950
45022
|
});
|
|
45023
|
+
child.on("error", (err) => {
|
|
45024
|
+
console.error(`\x1B[33mFailed to start edge daemon: ${err.message}\x1B[0m`);
|
|
45025
|
+
});
|
|
45026
|
+
let exited = false;
|
|
45027
|
+
let exitCode = null;
|
|
45028
|
+
child.on("exit", (code) => {
|
|
45029
|
+
exited = true;
|
|
45030
|
+
exitCode = code;
|
|
45031
|
+
});
|
|
44951
45032
|
child.unref();
|
|
44952
45033
|
const pid = child.pid;
|
|
45034
|
+
if (!pid)
|
|
45035
|
+
return;
|
|
45036
|
+
const shortLog = logFile.replace(os3.homedir(), "~");
|
|
44953
45037
|
setTimeout(() => {
|
|
44954
|
-
|
|
44955
|
-
|
|
44956
|
-
|
|
44957
|
-
}
|
|
45038
|
+
if (!exited) {
|
|
45039
|
+
console.error(`\x1B[2mStarted edge daemon (pid ${pid}), logs: ${shortLog}\x1B[0m`);
|
|
45040
|
+
return;
|
|
45041
|
+
}
|
|
45042
|
+
if (exitCode === 0) {
|
|
45043
|
+
console.error(`\x1B[2mEdge daemon exited cleanly (another instance likely already running). Logs: ${shortLog}\x1B[0m`);
|
|
45044
|
+
} else {
|
|
45045
|
+
console.error(`\x1B[31mEdge daemon died (exit ${exitCode}). Check logs: ${shortLog}\x1B[0m`);
|
|
45046
|
+
}
|
|
44958
45047
|
}, 500);
|
|
44959
45048
|
}
|
|
44960
45049
|
|
|
44961
45050
|
// src/index.ts
|
|
44962
|
-
|
|
45051
|
+
try {
|
|
45052
|
+
const pkgPath = path4.resolve(fileURLToPath(import.meta.url), "../../package.json");
|
|
45053
|
+
checkForUpdates(JSON.parse(readFileSync3(pkgPath, "utf-8")));
|
|
45054
|
+
} catch {}
|
|
45055
|
+
function formatPathWithTilde(path5) {
|
|
44963
45056
|
const home = homedir3();
|
|
44964
|
-
return
|
|
45057
|
+
return path5.startsWith(home) ? path5.replace(home, "~") : path5;
|
|
44965
45058
|
}
|
|
44966
45059
|
function getFrontendUrl(apiUrl, projectId, todoId) {
|
|
44967
45060
|
if (apiUrl.includes("localhost:4000") || apiUrl.includes("127.0.0.1:4000")) {
|
|
@@ -45073,12 +45166,13 @@ Cancelled by user (Ctrl+C)
|
|
|
45073
45166
|
const loginApi = new ApiClient(apiUrl, "");
|
|
45074
45167
|
const { code, url, expiresIn } = await loginApi.initDeviceLogin("cli");
|
|
45075
45168
|
const userCode = new URL(url).searchParams.get("user_code") || code.slice(-8).toUpperCase();
|
|
45169
|
+
const formattedCode = userCode.length === 8 ? `${userCode.slice(0, 4)}-${userCode.slice(4)}` : userCode;
|
|
45076
45170
|
process.stderr.write(`
|
|
45077
45171
|
\uD83D\uDD11 Open this URL to authorize:
|
|
45078
45172
|
`);
|
|
45079
45173
|
process.stderr.write(`${CYAN}${url}${RESET}
|
|
45080
45174
|
`);
|
|
45081
|
-
process.stderr.write(`Verification code: ${BRIGHT_WHITE}${
|
|
45175
|
+
process.stderr.write(`Verification code: ${BRIGHT_WHITE}${formattedCode}${RESET}
|
|
45082
45176
|
|
|
45083
45177
|
`);
|
|
45084
45178
|
try {
|