@agentskit/cli 0.13.40 → 0.13.42

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createCli } from './chunk-7ALDICSL.js';
2
+ import { createCli } from './chunk-Z4BXQEGB.js';
3
3
 
4
4
  // src/bin.ts
5
5
  async function main() {
@@ -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 { spawn } from 'child_process';
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';
@@ -140,7 +141,7 @@ var providers = {
140
141
  deepseek: {
141
142
  label: "DeepSeek",
142
143
  envKeys: ["DEEPSEEK_API_KEY"],
143
- defaultModel: "deepseek-chat",
144
+ defaultModel: "deepseek-flash",
144
145
  factory: (c) => deepseek(c)
145
146
  },
146
147
  grok: {
@@ -152,7 +153,7 @@ var providers = {
152
153
  kimi: {
153
154
  label: "Kimi",
154
155
  envKeys: ["KIMI_API_KEY", "MOONSHOT_API_KEY"],
155
- defaultModel: "kimi-k2-0711-preview",
156
+ defaultModel: "kimi-k2.6",
156
157
  factory: (c) => kimi(c)
157
158
  },
158
159
  groq: {
@@ -505,90 +506,37 @@ function configHooksToHandlers(config) {
505
506
  }
506
507
  return handlers;
507
508
  }
508
- function runShellHook(entry, payload) {
509
- return new Promise((resolvePromise) => {
510
- const timeoutMs = entry.timeout ?? 5e3;
511
- let settled = false;
512
- const settle = (result) => {
513
- if (settled) return;
514
- settled = true;
515
- clearTimeout(timer);
516
- resolvePromise(result);
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
- try {
587
- child.stdin.write(JSON.stringify(payload));
588
- child.stdin.end();
589
- } catch {
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 = spawn(this.spec.command, this.spec.args ?? [], {
1285
+ const child = spawnNodeChild(this.spec.command, this.spec.args ?? [], {
1338
1286
  env: { ...process.env, ...this.spec.env ?? {} },
1339
- stdio: ["pipe", "pipe", "pipe"],
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
- try {
1380
- if (process.platform !== "win32" && child.pid) process.kill(-child.pid, signal);
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);
@@ -3079,7 +3023,7 @@ var PROVIDER_REGISTRY = [
3079
3023
  catalogId: "deepseek",
3080
3024
  env: { status: "required", keys: ["DEEPSEEK_API_KEY"] },
3081
3025
  reachability: { status: "supported", url: "https://api.deepseek.com/models" },
3082
- defaultModel: { status: "known", id: "deepseek-chat" }
3026
+ defaultModel: { status: "known", id: "deepseek-flash" }
3083
3027
  },
3084
3028
  {
3085
3029
  id: "grok",
@@ -3097,7 +3041,7 @@ var PROVIDER_REGISTRY = [
3097
3041
  catalogId: "moonshotai",
3098
3042
  env: { status: "required", keys: ["KIMI_API_KEY", "MOONSHOT_API_KEY"] },
3099
3043
  reachability: { status: "supported", url: "https://api.moonshot.ai/v1/models" },
3100
- defaultModel: { status: "known", id: "kimi-k2-0711-preview" }
3044
+ defaultModel: { status: "known", id: "kimi-k2.6" }
3101
3045
  },
3102
3046
  {
3103
3047
  id: "groq",
@@ -3151,7 +3095,7 @@ var PROVIDER_REGISTRY = [
3151
3095
  catalogId: "fireworks-ai",
3152
3096
  env: { status: "required", keys: ["FIREWORKS_API_KEY"] },
3153
3097
  reachability: { status: "supported", url: "https://api.fireworks.ai/inference/v1/models" },
3154
- defaultModel: { status: "known", id: "accounts/fireworks/models/deepseek-v4-flash" }
3098
+ defaultModel: { status: "known", id: "accounts/fireworks/models/deepseek-v4-flash-0731" }
3155
3099
  },
3156
3100
  {
3157
3101
  id: "huggingface",
@@ -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.40"};
3704
+ version: "0.13.42"};
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-7ALDICSL.js.map
6206
- //# sourceMappingURL=chunk-7ALDICSL.js.map
6149
+ //# sourceMappingURL=chunk-Z4BXQEGB.js.map
6150
+ //# sourceMappingURL=chunk-Z4BXQEGB.js.map