@agentskit/cli 0.13.41 → 0.13.43
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/bin.cjs +36 -92
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-7Q363GHQ.js → chunk-ZN5JCLSK.js} +38 -94
- package/dist/chunk-ZN5JCLSK.js.map +1 -0
- package/dist/index.cjs +36 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-7Q363GHQ.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -5,7 +5,7 @@ import path, { join, resolve, isAbsolute, basename, dirname, relative, sep } fro
|
|
|
5
5
|
import { openrouter, groq, kimi, grok, deepseek, ollama, gemini, anthropic, openai } from '@agentskit/adapters';
|
|
6
6
|
import { randomBytes, randomUUID, createHash } from 'crypto';
|
|
7
7
|
import { writeFileSync, chmodSync, existsSync, readdirSync, statSync, readFileSync, mkdirSync, rmSync } from 'fs';
|
|
8
|
-
import {
|
|
8
|
+
import { runShell, spawnNodeChild, killProcessTree } from '@agentskit/cross-platform';
|
|
9
9
|
import React2, { useMemo, useState, useEffect, useRef } from 'react';
|
|
10
10
|
import { Box, Text, render } from 'ink';
|
|
11
11
|
import { useChat, StatusHeader, ChatContainer, Message, ToolCallView, ToolConfirmation, ThinkingIndicator, InputBar } from '@agentskit/ink';
|
|
@@ -16,6 +16,7 @@ import { getIntegration, integrationToolsFromEnv } from '@agentskit/integrations
|
|
|
16
16
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
17
17
|
import { pathToFileURL } from 'url';
|
|
18
18
|
import { createRuntime, validateFlow, flowToMermaid, compileFlow, createFileStepLog } from '@agentskit/runtime';
|
|
19
|
+
import { spawn } from 'child_process';
|
|
19
20
|
import { createRequire } from 'module';
|
|
20
21
|
import chokidar from 'chokidar';
|
|
21
22
|
import kleur3 from 'kleur';
|
|
@@ -505,90 +506,37 @@ function configHooksToHandlers(config) {
|
|
|
505
506
|
}
|
|
506
507
|
return handlers;
|
|
507
508
|
}
|
|
508
|
-
function runShellHook(entry, payload) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
const child = spawn("sh", ["-c", entry.run], {
|
|
519
|
-
stdio: ["pipe", "pipe", "inherit"],
|
|
520
|
-
detached: true
|
|
521
|
-
});
|
|
522
|
-
let stdout = "";
|
|
523
|
-
let stdoutBytes = 0;
|
|
524
|
-
child.stdout.on("data", (chunk) => {
|
|
525
|
-
const text = chunk.toString();
|
|
526
|
-
const bytes = Buffer.byteLength(text);
|
|
527
|
-
if (stdoutBytes + bytes > MAX_HOOK_STDOUT_BYTES) {
|
|
528
|
-
if (child.pid !== void 0) {
|
|
529
|
-
try {
|
|
530
|
-
process.kill(-child.pid, "SIGKILL");
|
|
531
|
-
} catch {
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
try {
|
|
535
|
-
child.kill("SIGKILL");
|
|
536
|
-
} catch {
|
|
537
|
-
}
|
|
538
|
-
settle({ decision: "block", reason: `shell hook output exceeded ${MAX_HOOK_STDOUT_BYTES} bytes` });
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
stdoutBytes += bytes;
|
|
542
|
-
stdout += text;
|
|
543
|
-
});
|
|
544
|
-
const timer = setTimeout(() => {
|
|
545
|
-
if (child.pid !== void 0) {
|
|
546
|
-
try {
|
|
547
|
-
process.kill(-child.pid, "SIGKILL");
|
|
548
|
-
} catch {
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
try {
|
|
552
|
-
child.kill("SIGKILL");
|
|
553
|
-
} catch {
|
|
554
|
-
}
|
|
555
|
-
settle({ decision: "block", reason: `shell hook timed out after ${timeoutMs}ms` });
|
|
556
|
-
}, timeoutMs);
|
|
557
|
-
child.stdin.on("error", () => {
|
|
558
|
-
});
|
|
559
|
-
child.on("close", (code) => {
|
|
560
|
-
if (code !== 0) {
|
|
561
|
-
settle({
|
|
562
|
-
decision: "block",
|
|
563
|
-
reason: `shell hook exited with code ${code}`
|
|
564
|
-
});
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
const trimmed = stdout.trim();
|
|
568
|
-
if (!trimmed) {
|
|
569
|
-
settle({ decision: "continue" });
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
try {
|
|
573
|
-
const parsed = JSON.parse(trimmed);
|
|
574
|
-
if (!parsed || typeof parsed !== "object" || !("decision" in parsed) || !["continue", "block", "modify"].includes(String(parsed.decision))) {
|
|
575
|
-
settle({ decision: "block", reason: "shell hook returned an invalid decision" });
|
|
576
|
-
} else {
|
|
577
|
-
settle(parsed);
|
|
578
|
-
}
|
|
579
|
-
} catch {
|
|
580
|
-
settle({ decision: "block", reason: "shell hook returned invalid JSON" });
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
child.on("error", (err) => {
|
|
584
|
-
settle({ decision: "block", reason: err.message });
|
|
509
|
+
async function runShellHook(entry, payload) {
|
|
510
|
+
const timeoutMs = entry.timeout ?? 5e3;
|
|
511
|
+
let result;
|
|
512
|
+
try {
|
|
513
|
+
result = await runShell(entry.run, {
|
|
514
|
+
input: JSON.stringify(payload),
|
|
515
|
+
timeoutMs,
|
|
516
|
+
// Hooks are fire-and-judge: no grace period once the budget is spent.
|
|
517
|
+
killGraceMs: 0,
|
|
518
|
+
maxOutputBytes: MAX_HOOK_STDOUT_BYTES
|
|
585
519
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
520
|
+
} catch (err) {
|
|
521
|
+
return { decision: "block", reason: err instanceof Error ? err.message : String(err) };
|
|
522
|
+
}
|
|
523
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
524
|
+
if (result.truncated) {
|
|
525
|
+
return { decision: "block", reason: `shell hook output exceeded ${MAX_HOOK_STDOUT_BYTES} bytes` };
|
|
526
|
+
}
|
|
527
|
+
if (result.timedOut) return { decision: "block", reason: `shell hook timed out after ${timeoutMs}ms` };
|
|
528
|
+
if (result.code !== 0) return { decision: "block", reason: `shell hook exited with code ${result.code}` };
|
|
529
|
+
const trimmed = result.stdout.trim();
|
|
530
|
+
if (!trimmed) return { decision: "continue" };
|
|
531
|
+
try {
|
|
532
|
+
const parsed = JSON.parse(trimmed);
|
|
533
|
+
if (!parsed || typeof parsed !== "object" || !("decision" in parsed) || !["continue", "block", "modify"].includes(String(parsed.decision))) {
|
|
534
|
+
return { decision: "block", reason: "shell hook returned an invalid decision" };
|
|
590
535
|
}
|
|
591
|
-
|
|
536
|
+
return parsed;
|
|
537
|
+
} catch {
|
|
538
|
+
return { decision: "block", reason: "shell hook returned invalid JSON" };
|
|
539
|
+
}
|
|
592
540
|
}
|
|
593
541
|
|
|
594
542
|
// src/slash-commands.ts
|
|
@@ -1334,10 +1282,9 @@ var McpClient = class {
|
|
|
1334
1282
|
}
|
|
1335
1283
|
async start() {
|
|
1336
1284
|
if (this.child) return;
|
|
1337
|
-
const child =
|
|
1285
|
+
const child = spawnNodeChild(this.spec.command, this.spec.args ?? [], {
|
|
1338
1286
|
env: { ...process.env, ...this.spec.env ?? {} },
|
|
1339
|
-
stdio:
|
|
1340
|
-
detached: process.platform !== "win32"
|
|
1287
|
+
stdio: "pipe"
|
|
1341
1288
|
});
|
|
1342
1289
|
this.child = child;
|
|
1343
1290
|
child.stdout.on("data", (chunk) => this.onStdout(chunk.toString()));
|
|
@@ -1376,11 +1323,8 @@ var McpClient = class {
|
|
|
1376
1323
|
const child = this.child;
|
|
1377
1324
|
if (!child || child.killed) return;
|
|
1378
1325
|
const kill = (signal) => {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
else child.kill(signal);
|
|
1382
|
-
} catch {
|
|
1383
|
-
}
|
|
1326
|
+
if (child.pid === void 0 || child.exitCode !== null || child.signalCode !== null) return;
|
|
1327
|
+
void killProcessTree(child.pid, signal, (sig) => child.kill(sig));
|
|
1384
1328
|
};
|
|
1385
1329
|
kill("SIGTERM");
|
|
1386
1330
|
const timer = setTimeout(() => kill("SIGKILL"), DISPOSE_GRACE_MS);
|
|
@@ -3757,7 +3701,7 @@ async function indexSources(rag, config, cwd) {
|
|
|
3757
3701
|
|
|
3758
3702
|
// package.json
|
|
3759
3703
|
var package_default = {
|
|
3760
|
-
version: "0.13.
|
|
3704
|
+
version: "0.13.43"};
|
|
3761
3705
|
|
|
3762
3706
|
// src/commands/shared.ts
|
|
3763
3707
|
function mergeWithConfig(options, config) {
|
|
@@ -6202,5 +6146,5 @@ function createCli() {
|
|
|
6202
6146
|
}
|
|
6203
6147
|
|
|
6204
6148
|
export { ChatApp, HookDispatcher, McpClient, applyPolicyToTool, applyPolicyToTools, bridgeMcpServers, buildRagFromConfig, computeCost, configHooksToHandlers, createCli, createOpenAiEmbedder, defaultPolicy, derivePreview, disposeMcpClients, evaluatePolicy, findLatestSession, findSession, forkSession, generateSessionId, getPricing, indexSources, listSessions, loadConfig, loadPlugins, mergePluginsIntoBundle, registerPricing, renameSession, renderChatHeader, renderReport, resolveChatProvider, resolveSession, runAgent, runDoctor, sessionFilePath, startDev, startTunnel, writeSessionMeta, writeStarterProject2 as writeStarterProject };
|
|
6205
|
-
//# sourceMappingURL=chunk-
|
|
6206
|
-
//# sourceMappingURL=chunk-
|
|
6149
|
+
//# sourceMappingURL=chunk-ZN5JCLSK.js.map
|
|
6150
|
+
//# sourceMappingURL=chunk-ZN5JCLSK.js.map
|