@theokit/cli 3.0.2 → 4.0.1
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/CHANGELOG.md +257 -0
- package/LICENSE +2 -2
- package/README.md +13 -0
- package/dist/bin/theokit.cjs +59 -28
- package/dist/bin/theokit.cjs.map +1 -1
- package/dist/bin/theokit.js +59 -28
- package/dist/bin/theokit.js.map +1 -1
- package/dist/index.cjs +59 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -10
- package/dist/index.d.ts +127 -10
- package/dist/index.js +59 -28
- package/dist/index.js.map +1 -1
- package/package.json +19 -16
- package/templates/chatbot/.env.example +14 -0
- package/templates/chatbot/README.md +34 -0
- package/templates/chatbot/package.json +20 -0
- package/templates/chatbot/src/index.ts +88 -0
- package/templates/chatbot/tsconfig.json +12 -0
- package/templates/minimal/README.md +1 -1
- package/templates/multi-agent/.env.example +14 -0
- package/templates/multi-agent/README.md +33 -0
- package/templates/multi-agent/package.json +20 -0
- package/templates/multi-agent/src/index.ts +90 -0
- package/templates/multi-agent/tsconfig.json +12 -0
- package/templates/rag-agent/.env.example +14 -0
- package/templates/rag-agent/README.md +34 -0
- package/templates/rag-agent/package.json +21 -0
- package/templates/rag-agent/src/index.ts +115 -0
- package/templates/rag-agent/tsconfig.json +12 -0
- package/templates/telegram-bot/README.md +4 -4
- package/templates/telegram-bot/package.json +2 -2
- package/templates/telegram-bot/src/index.ts +2 -2
- package/templates/workflow-automation/.env.example +14 -0
- package/templates/workflow-automation/README.md +33 -0
- package/templates/workflow-automation/package.json +20 -0
- package/templates/workflow-automation/src/index.ts +86 -0
- package/templates/workflow-automation/tsconfig.json +12 -0
package/dist/index.cjs
CHANGED
|
@@ -384,7 +384,7 @@ function startRunner(opts) {
|
|
|
384
384
|
args.push(opts.entry);
|
|
385
385
|
const child = child_process.spawn(process.execPath, [tsxBin, ...args], {
|
|
386
386
|
cwd: opts.cwd,
|
|
387
|
-
stdio: "inherit",
|
|
387
|
+
stdio: opts.stdio ?? "inherit",
|
|
388
388
|
env: process.env
|
|
389
389
|
});
|
|
390
390
|
const exited = new Promise((resolve6) => {
|
|
@@ -515,7 +515,13 @@ function formatReport(result) {
|
|
|
515
515
|
}
|
|
516
516
|
function truncate(s, max) {
|
|
517
517
|
if (s.length <= max) return s;
|
|
518
|
-
|
|
518
|
+
const budget = max - 1;
|
|
519
|
+
let out = "";
|
|
520
|
+
for (const ch of s) {
|
|
521
|
+
if (out.length + ch.length > budget) break;
|
|
522
|
+
out += ch;
|
|
523
|
+
}
|
|
524
|
+
return `${out}\u2026`;
|
|
519
525
|
}
|
|
520
526
|
function escapeMd(s) {
|
|
521
527
|
return s.replaceAll("|", "\\|").replaceAll("\n", " ");
|
|
@@ -645,8 +651,8 @@ ${pc5__default.default.green("\u2713")} ${result.aggregate.totalRows} rows \xB7
|
|
|
645
651
|
}
|
|
646
652
|
|
|
647
653
|
// src/version.ts
|
|
648
|
-
var SDK_VERSION = "4.
|
|
649
|
-
var CLI_VERSION = "
|
|
654
|
+
var SDK_VERSION = "4.57.0";
|
|
655
|
+
var CLI_VERSION = "4.0.1";
|
|
650
656
|
|
|
651
657
|
// src/init/templates.ts
|
|
652
658
|
var TEMPLATES = [
|
|
@@ -660,6 +666,26 @@ var TEMPLATES = [
|
|
|
660
666
|
description: "100% local agent via Ollama (no remote API key required).",
|
|
661
667
|
hint: "Requires `ollama serve` + `ollama pull llama3.2:3b`."
|
|
662
668
|
},
|
|
669
|
+
{
|
|
670
|
+
name: "chatbot",
|
|
671
|
+
description: "Conversational agent that resumes its own thread across runs.",
|
|
672
|
+
hint: "SESSION_DIR=~/.claude writes sessions the Claude Code CLI can --continue."
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: "multi-agent",
|
|
676
|
+
description: "A classifier routes to specialists, all from one AgentFactory prefix.",
|
|
677
|
+
hint: 'Pass the input as an argument: `pnpm dev "Translate to French: hello"`.'
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "rag-agent",
|
|
681
|
+
description: "Retrieval over your own files \u2014 Memory.openIndex behind a Tool.",
|
|
682
|
+
hint: "Put markdown under .theokit/memory/ first, or there is nothing to cite."
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
name: "workflow-automation",
|
|
686
|
+
description: "A committed Workflow (fn -> agentStep -> fn) handed to Cron.",
|
|
687
|
+
hint: "WORKFLOW_CRON overrides the schedule; default is every 5 minutes."
|
|
688
|
+
},
|
|
663
689
|
{
|
|
664
690
|
name: "telegram-bot",
|
|
665
691
|
description: "Telegram bot via @theokit/gateway + grammy.",
|
|
@@ -721,6 +747,13 @@ function resolveTemplatesRoot() {
|
|
|
721
747
|
`Could not locate bundled templates/ directory (searched up from ${here}). This usually means the published tarball was built without "files": ["templates"] (EC-C regression).`
|
|
722
748
|
);
|
|
723
749
|
}
|
|
750
|
+
var SCAFFOLD_USER_ERROR_CODES = [
|
|
751
|
+
"invalid_project_name",
|
|
752
|
+
"unknown_template",
|
|
753
|
+
"invalid_dest",
|
|
754
|
+
"dest_is_symlink",
|
|
755
|
+
"dest_not_empty"
|
|
756
|
+
];
|
|
724
757
|
function scaffoldError(code, message) {
|
|
725
758
|
const err = new Error(message);
|
|
726
759
|
err.code = code;
|
|
@@ -856,12 +889,7 @@ async function resolveTemplate(optsTemplate, skipPrompts) {
|
|
|
856
889
|
}
|
|
857
890
|
return template;
|
|
858
891
|
}
|
|
859
|
-
var USER_ERROR_CODES =
|
|
860
|
-
"invalid_project_name",
|
|
861
|
-
"dest_not_empty",
|
|
862
|
-
"invalid_dest",
|
|
863
|
-
"unknown_template"
|
|
864
|
-
]);
|
|
892
|
+
var USER_ERROR_CODES = new Set(SCAFFOLD_USER_ERROR_CODES);
|
|
865
893
|
async function runScaffold(name, template, force) {
|
|
866
894
|
try {
|
|
867
895
|
const result = await scaffold({
|
|
@@ -1215,14 +1243,6 @@ ${pc5__default.default.dim(" shape: Desktop OAuth client (installed block prese
|
|
|
1215
1243
|
}
|
|
1216
1244
|
const interactiveCode = await runInteractiveSetup();
|
|
1217
1245
|
if (interactiveCode !== 0) return interactiveCode;
|
|
1218
|
-
if (typeof opts.writable === "string" && opts.writable.length > 0) {
|
|
1219
|
-
process.stdout.write(
|
|
1220
|
-
`
|
|
1221
|
-
${pc5__default.default.yellow("note:")} you passed --writable=${opts.writable}. The upstream MCP server does not narrow scopes \u2014 all scopes are granted at consent.
|
|
1222
|
-
Write tools are gated at runtime by ${pc5__default.default.bold("googleWorkspace({ writable: true })")} in your code.
|
|
1223
|
-
`
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
1246
|
process.stdout.write(
|
|
1227
1247
|
`
|
|
1228
1248
|
${pc5__default.default.green("\u2713")} gworkspace setup complete.
|
|
@@ -1269,7 +1289,6 @@ function spawnUpstream(args, timeoutMs) {
|
|
|
1269
1289
|
async function runSetup(domain, opts) {
|
|
1270
1290
|
if (domain === "gworkspace") {
|
|
1271
1291
|
const gworkspaceOpts = {
|
|
1272
|
-
writable: opts.writable,
|
|
1273
1292
|
probe: opts.probe === true,
|
|
1274
1293
|
nonInteractive: opts.nonInteractive === true,
|
|
1275
1294
|
...opts.credentialsPath !== void 0 ? { credentialsPath: opts.credentialsPath } : {}
|
|
@@ -1400,7 +1419,7 @@ async function runTasksInspect(id, opts) {
|
|
|
1400
1419
|
}
|
|
1401
1420
|
return 0;
|
|
1402
1421
|
}
|
|
1403
|
-
async function runTasksCancel(id,
|
|
1422
|
+
async function runTasksCancel(id, opts) {
|
|
1404
1423
|
if (!isValidTaskId(id)) {
|
|
1405
1424
|
process.stderr.write(`tasks: invalid id grammar: ${id}
|
|
1406
1425
|
`);
|
|
@@ -1425,12 +1444,21 @@ async function runTasksCancel(id, _opts) {
|
|
|
1425
1444
|
}
|
|
1426
1445
|
if (handle.state === "queued") {
|
|
1427
1446
|
const cancelledAt = Date.now();
|
|
1428
|
-
await store.update(id, (h) => ({
|
|
1447
|
+
await store.update(id, (h) => ({
|
|
1448
|
+
...h,
|
|
1449
|
+
state: "cancelled",
|
|
1450
|
+
cancelledAt,
|
|
1451
|
+
...opts.reason !== void 0 ? { cancelReason: opts.reason } : {}
|
|
1452
|
+
}));
|
|
1429
1453
|
process.stdout.write(`task ${id} cancelled (was queued)
|
|
1430
1454
|
`);
|
|
1431
1455
|
return 0;
|
|
1432
1456
|
}
|
|
1433
|
-
await store.update(id, (h) => ({
|
|
1457
|
+
await store.update(id, (h) => ({
|
|
1458
|
+
...h,
|
|
1459
|
+
cancelRequested: true,
|
|
1460
|
+
...opts.reason !== void 0 ? { cancelReason: opts.reason } : {}
|
|
1461
|
+
}));
|
|
1434
1462
|
process.stdout.write(
|
|
1435
1463
|
`cancel requested for task ${id}; the owning process will honor it at the next checkpoint
|
|
1436
1464
|
`
|
|
@@ -1440,7 +1468,13 @@ async function runTasksCancel(id, _opts) {
|
|
|
1440
1468
|
|
|
1441
1469
|
// src/main.ts
|
|
1442
1470
|
function registerSubcommands(program, setExit) {
|
|
1443
|
-
program.command("init [project-name]").description("Scaffold a new agent project from a bundled template.").option(
|
|
1471
|
+
program.command("init [project-name]").description("Scaffold a new agent project from a bundled template.").option(
|
|
1472
|
+
"-t, --template <name>",
|
|
1473
|
+
// Derived from the registry, not restated. This line named three templates while the
|
|
1474
|
+
// registry held seven — a help text that lists options is a second copy of the list, and
|
|
1475
|
+
// the copy is the one that goes stale.
|
|
1476
|
+
`Template name: ${TEMPLATES.map((t) => t.name).join(" | ")}`
|
|
1477
|
+
).option("-f, --force", "Overwrite a non-empty destination directory").option("-y, --yes", "Skip interactive prompts (CI mode)").action(async (projectName, opts) => {
|
|
1444
1478
|
setExit(await runInit(projectName, opts));
|
|
1445
1479
|
});
|
|
1446
1480
|
program.command("dev").description("Run the agent entry point under tsx --watch (hot-reload).").option("--entry <path>", "Entry file (default: src/index.ts or package.main)").option("--env <path>", "Env file to load (default: .env)").action(async (opts) => {
|
|
@@ -1456,15 +1490,12 @@ function registerSubcommands(program, setExit) {
|
|
|
1456
1490
|
setExit(await runEval(opts));
|
|
1457
1491
|
});
|
|
1458
1492
|
program.command("acp").description(
|
|
1459
|
-
"Launch a stdio Agent Client Protocol (ACP) server pointing at the entry file's default-exported agent. Used by
|
|
1493
|
+
"Launch a stdio Agent Client Protocol (ACP) server pointing at the entry file's default-exported agent. Used by ACP-compatible hosts. ADRs D349-D360."
|
|
1460
1494
|
).option("--entry <path>", "Entry file (default: src/index.ts or package.main)").option("--permission <mode>", "Tool permission mode: ask | auto | deny (default: ask)").option("--trusted-tools <list>", "Comma-separated tool names that bypass ask").option("--permission-timeout-ms <ms>", "Permission request timeout in ms (default: 60000)").action(async (opts) => {
|
|
1461
1495
|
setExit(await runAcp(opts));
|
|
1462
1496
|
});
|
|
1463
1497
|
program.command("setup <domain>").description(
|
|
1464
1498
|
"Stage credentials + connectivity probe for a third-party integration. Domains: gworkspace (Google Workspace)."
|
|
1465
|
-
).option(
|
|
1466
|
-
"--writable <products>",
|
|
1467
|
-
"Comma-separated products to grant write access (e.g., 'drive,calendar')"
|
|
1468
1499
|
).option("--probe", "Run upstream connectivity check after staging credentials").option(
|
|
1469
1500
|
"--credentials-path <path>",
|
|
1470
1501
|
"Override path to credentials.json (default: ~/.google-mcp/credentials.json)"
|
|
@@ -1502,7 +1533,7 @@ function registerSubcommands(program, setExit) {
|
|
|
1502
1533
|
setExit(await runTasksInspect(id, opts));
|
|
1503
1534
|
});
|
|
1504
1535
|
tasks.command("cancel <id>").description("Cancel a task (best-effort cross-process via cancelRequested flag)").option("--reason <reason>", "Cancellation reason recorded in the registry").action(async (id, opts) => {
|
|
1505
|
-
setExit(await runTasksCancel(id));
|
|
1536
|
+
setExit(await runTasksCancel(id, opts));
|
|
1506
1537
|
});
|
|
1507
1538
|
}
|
|
1508
1539
|
function mapCommanderExitCode(code, fallback) {
|