@ddlqhd/agent-sdk 0.1.1 → 0.2.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.
Files changed (40) hide show
  1. package/README.md +2 -1
  2. package/dist/{chunk-742JTNYI.js → chunk-D3UZNLZO.js} +570 -77
  3. package/dist/chunk-D3UZNLZO.js.map +1 -0
  4. package/dist/{chunk-AJD3DTL7.cjs → chunk-JXAJQGV5.cjs} +756 -107
  5. package/dist/chunk-JXAJQGV5.cjs.map +1 -0
  6. package/dist/{chunk-DQFTAD3I.cjs → chunk-NYZD3THB.cjs} +573 -76
  7. package/dist/chunk-NYZD3THB.cjs.map +1 -0
  8. package/dist/{chunk-Q3L4GIBG.cjs → chunk-P2X3AMDK.cjs} +115 -117
  9. package/dist/chunk-P2X3AMDK.cjs.map +1 -0
  10. package/dist/{chunk-THKEF32L.js → chunk-TKUPLTGJ.js} +110 -114
  11. package/dist/chunk-TKUPLTGJ.js.map +1 -0
  12. package/dist/{chunk-DXMVWGLJ.js → chunk-UHENMHUS.js} +744 -100
  13. package/dist/chunk-UHENMHUS.js.map +1 -0
  14. package/dist/cli/index.cjs +40 -31
  15. package/dist/cli/index.cjs.map +1 -1
  16. package/dist/cli/index.js +14 -5
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/{index-DGPDMbW5.d.cts → index-CnrY1ZA2.d.ts} +36 -14
  19. package/dist/{index-nEfayAzD.d.ts → index-DzBt4ewK.d.cts} +36 -14
  20. package/dist/index.cjs +128 -88
  21. package/dist/index.d.cts +42 -22
  22. package/dist/index.d.ts +42 -22
  23. package/dist/index.js +3 -3
  24. package/dist/models/index.cjs +14 -10
  25. package/dist/models/index.d.cts +7 -2
  26. package/dist/models/index.d.ts +7 -2
  27. package/dist/models/index.js +1 -1
  28. package/dist/tools/index.cjs +65 -57
  29. package/dist/tools/index.d.cts +3 -3
  30. package/dist/tools/index.d.ts +3 -3
  31. package/dist/tools/index.js +1 -1
  32. package/dist/{types-BLf9IqRs.d.cts → types-BUwjMwNH.d.cts} +279 -13
  33. package/dist/{types-BLf9IqRs.d.ts → types-BUwjMwNH.d.ts} +279 -13
  34. package/package.json +11 -11
  35. package/dist/chunk-742JTNYI.js.map +0 -1
  36. package/dist/chunk-AJD3DTL7.cjs.map +0 -1
  37. package/dist/chunk-DQFTAD3I.cjs.map +0 -1
  38. package/dist/chunk-DXMVWGLJ.js.map +0 -1
  39. package/dist/chunk-Q3L4GIBG.cjs.map +0 -1
  40. package/dist/chunk-THKEF32L.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var chunkAJD3DTL7_cjs = require('../chunk-AJD3DTL7.cjs');
5
- require('../chunk-DQFTAD3I.cjs');
6
- var chunkQ3L4GIBG_cjs = require('../chunk-Q3L4GIBG.cjs');
4
+ var chunkJXAJQGV5_cjs = require('../chunk-JXAJQGV5.cjs');
5
+ require('../chunk-NYZD3THB.cjs');
6
+ var chunkP2X3AMDK_cjs = require('../chunk-P2X3AMDK.cjs');
7
7
  require('../chunk-OZO7D77N.cjs');
8
8
  var commander = require('commander');
9
9
  var chalk = require('chalk');
@@ -13,6 +13,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
13
 
14
14
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
15
15
 
16
+ var STREAM_END_MAX_ITERATIONS_MESSAGE = "\n[stopped: reached maxIterations \u2014 increase AgentConfig.maxIterations if the task needs more tool rounds]";
16
17
  function tokenUsageEqual(a, b) {
17
18
  return a.promptTokens === b.promptTokens && a.completionTokens === b.completionTokens && a.totalTokens === b.totalTokens;
18
19
  }
@@ -39,21 +40,26 @@ function createStreamFormatter(config = {}) {
39
40
  return {
40
41
  format(event) {
41
42
  let output = "";
42
- if (lastEventType === "thinking" && event.type !== "thinking") {
43
+ if (lastEventType === "thinking" && event.type !== "thinking" && event.type !== "thinking_end") {
43
44
  output += "\n";
44
45
  isFirstThinking = true;
45
46
  }
46
- if (needsGapAfterToolBlock && (event.type === "text_delta" || event.type === "thinking")) {
47
+ if (needsGapAfterToolBlock && (event.type === "text_delta" || event.type === "thinking" || event.type === "thinking_start")) {
47
48
  output += "\n";
48
49
  needsGapAfterToolBlock = false;
49
50
  }
50
51
  switch (event.type) {
51
52
  case "text_start":
52
53
  case "text_end":
54
+ case "thinking_start":
53
55
  case "tool_call_start":
54
56
  case "tool_call_delta":
55
57
  case "tool_call_end":
56
58
  break;
59
+ case "thinking_end":
60
+ output += "\n";
61
+ isFirstThinking = true;
62
+ break;
57
63
  case "context_compressed":
58
64
  if (verbose) {
59
65
  output += chalk__default.default.gray(
@@ -127,6 +133,8 @@ ${formatUsage(usage)}`;
127
133
  \u2717 ${event.error.message}`);
128
134
  } else if (event.reason === "aborted") {
129
135
  output += chalk__default.default.yellow("\n[interrupted]");
136
+ } else if (event.reason === "max_iterations") {
137
+ output += chalk__default.default.yellow(STREAM_END_MAX_ITERATIONS_MESSAGE);
130
138
  }
131
139
  break;
132
140
  }
@@ -413,12 +421,12 @@ function createChatCommand() {
413
421
  try {
414
422
  let sessionId = options.session;
415
423
  if (options.resume && !sessionId) {
416
- sessionId = await chunkAJD3DTL7_cjs.getLatestSessionId(options.userBasePath);
424
+ sessionId = await chunkJXAJQGV5_cjs.getLatestSessionId(options.userBasePath);
417
425
  if (!sessionId) {
418
426
  console.warn(chalk__default.default.yellow("No saved sessions found; starting a new session."));
419
427
  }
420
428
  }
421
- const mcpResult = chunkAJD3DTL7_cjs.loadMCPConfig(options.mcpConfig, options.cwd || process.cwd(), options.userBasePath);
429
+ const mcpResult = chunkJXAJQGV5_cjs.loadMCPConfig(options.mcpConfig, options.cwd || process.cwd(), options.userBasePath);
422
430
  if (mcpResult.configPath) {
423
431
  console.log(chalk__default.default.gray(`Loaded MCP config from: ${mcpResult.configPath}`));
424
432
  if (mcpResult.servers.length > 0) {
@@ -426,7 +434,7 @@ function createChatCommand() {
426
434
  }
427
435
  }
428
436
  const cwd = options.cwd || process.cwd();
429
- const agent = new chunkAJD3DTL7_cjs.Agent({
437
+ const agent = new chunkJXAJQGV5_cjs.Agent({
430
438
  modelConfig: modelConfigFromOptions(options),
431
439
  cwd,
432
440
  hookConfigDir: cwd,
@@ -443,7 +451,7 @@ function createChatCommand() {
443
451
  const skills = skillRegistry.getUserInvocableSkills();
444
452
  console.log(chalk__default.default.cyan("\u{1F916} Agent SDK Chat"));
445
453
  console.log(chalk__default.default.gray(`Model: ${model.name}`));
446
- console.log(chalk__default.default.gray(`Sessions: ${chunkAJD3DTL7_cjs.getSessionStoragePath(options.userBasePath)}`));
454
+ console.log(chalk__default.default.gray(`Sessions: ${chunkJXAJQGV5_cjs.getSessionStoragePath(options.userBasePath)}`));
447
455
  if (skills.length > 0) {
448
456
  console.log(chalk__default.default.gray(`Skills: ${skills.map((s) => `/${s.name}`).join(", ")}`));
449
457
  }
@@ -584,17 +592,17 @@ function createRunCommand() {
584
592
  try {
585
593
  let sessionId = options.session;
586
594
  if (options.resume && !sessionId) {
587
- sessionId = await chunkAJD3DTL7_cjs.getLatestSessionId(options.userBasePath);
595
+ sessionId = await chunkJXAJQGV5_cjs.getLatestSessionId(options.userBasePath);
588
596
  if (!sessionId) {
589
597
  console.warn(chalk__default.default.yellow("No saved sessions found; starting a new session."));
590
598
  }
591
599
  }
592
- const mcpResult = chunkAJD3DTL7_cjs.loadMCPConfig(options.mcpConfig, options.cwd || process.cwd(), options.userBasePath);
600
+ const mcpResult = chunkJXAJQGV5_cjs.loadMCPConfig(options.mcpConfig, options.cwd || process.cwd(), options.userBasePath);
593
601
  if (mcpResult.configPath) {
594
602
  console.log(chalk__default.default.gray(`Loaded MCP config from: ${mcpResult.configPath}`));
595
603
  }
596
604
  const cwd = options.cwd || process.cwd();
597
- const agent = new chunkAJD3DTL7_cjs.Agent({
605
+ const agent = new chunkJXAJQGV5_cjs.Agent({
598
606
  modelConfig: modelConfigFromOptions(options),
599
607
  cwd,
600
608
  hookConfigDir: cwd,
@@ -638,9 +646,9 @@ ${formatUsage(result.usage)}`);
638
646
  function createToolsCommand() {
639
647
  const command = new commander.Command("tools").description("Manage agent tools");
640
648
  command.command("list").description("List all available tools").option("-f, --format <format>", "Output format (table/json)", "table").option("-c, --category <category>", "Filter by category").action((options) => {
641
- const registry = new chunkQ3L4GIBG_cjs.ToolRegistry();
642
- const skillRegistry = chunkAJD3DTL7_cjs.createSkillRegistry();
643
- registry.registerMany(chunkQ3L4GIBG_cjs.getAllBuiltinTools(skillRegistry));
649
+ const registry = new chunkP2X3AMDK_cjs.ToolRegistry();
650
+ const skillRegistry = chunkJXAJQGV5_cjs.createSkillRegistry();
651
+ registry.registerMany(chunkP2X3AMDK_cjs.getAllBuiltinTools(skillRegistry));
644
652
  let tools = registry.getAll();
645
653
  if (options.category) {
646
654
  tools = tools.filter(
@@ -675,9 +683,9 @@ Total: ${tools.length} tools`));
675
683
  }
676
684
  });
677
685
  command.command("show <name>").description("Show tool details").action((name) => {
678
- const registry = new chunkQ3L4GIBG_cjs.ToolRegistry();
679
- const skillRegistry = chunkAJD3DTL7_cjs.createSkillRegistry();
680
- registry.registerMany(chunkQ3L4GIBG_cjs.getAllBuiltinTools(skillRegistry));
686
+ const registry = new chunkP2X3AMDK_cjs.ToolRegistry();
687
+ const skillRegistry = chunkJXAJQGV5_cjs.createSkillRegistry();
688
+ registry.registerMany(chunkP2X3AMDK_cjs.getAllBuiltinTools(skillRegistry));
681
689
  const tool = registry.get(name);
682
690
  if (!tool) {
683
691
  console.error(chalk__default.default.red(`Tool "${name}" not found`));
@@ -696,9 +704,9 @@ Parameters Schema:`);
696
704
  command.command("test <name>").description(
697
705
  "Test a tool with arguments. Note: AskUserQuestion returns formatted text only unless the Agent is configured with askUserQuestion (e.g. CLI TTY)."
698
706
  ).option("-a, --args <json>", "Tool arguments as JSON").action(async (name, options) => {
699
- const registry = new chunkQ3L4GIBG_cjs.ToolRegistry();
700
- const skillRegistry = chunkAJD3DTL7_cjs.createSkillRegistry();
701
- registry.registerMany(chunkQ3L4GIBG_cjs.getAllBuiltinTools(skillRegistry));
707
+ const registry = new chunkP2X3AMDK_cjs.ToolRegistry();
708
+ const skillRegistry = chunkJXAJQGV5_cjs.createSkillRegistry();
709
+ registry.registerMany(chunkP2X3AMDK_cjs.getAllBuiltinTools(skillRegistry));
702
710
  if (!registry.has(name)) {
703
711
  console.error(chalk__default.default.red(`Tool "${name}" not found`));
704
712
  process.exit(1);
@@ -736,9 +744,9 @@ function createSessionsCommand() {
736
744
  addUserBasePathOption(
737
745
  command.command("list").description("List all sessions").option("-l, --limit <n>", "Limit number of sessions", parseInt, 20).option("-f, --format <format>", "Output format (table/json)", "table")
738
746
  ).action(async (options) => {
739
- const manager = new chunkAJD3DTL7_cjs.SessionManager({
747
+ const manager = new chunkJXAJQGV5_cjs.SessionManager({
740
748
  type: "jsonl",
741
- basePath: chunkAJD3DTL7_cjs.getSessionStoragePath(options.userBasePath)
749
+ basePath: chunkJXAJQGV5_cjs.getSessionStoragePath(options.userBasePath)
742
750
  });
743
751
  const sessions = await manager.listSessions();
744
752
  const limited = sessions.slice(0, options.limit);
@@ -771,9 +779,9 @@ Total: ${sessions.length} sessions`));
771
779
  addUserBasePathOption(
772
780
  command.command("show <id>").description("Show session messages").option("-l, --limit <n>", "Limit number of messages", parseInt, 50)
773
781
  ).action(async (id, options) => {
774
- const manager = new chunkAJD3DTL7_cjs.SessionManager({
782
+ const manager = new chunkJXAJQGV5_cjs.SessionManager({
775
783
  type: "jsonl",
776
- basePath: chunkAJD3DTL7_cjs.getSessionStoragePath(options.userBasePath)
784
+ basePath: chunkJXAJQGV5_cjs.getSessionStoragePath(options.userBasePath)
777
785
  });
778
786
  const exists = await manager.sessionExists(id);
779
787
  if (!exists) {
@@ -796,9 +804,9 @@ Total: ${sessions.length} sessions`));
796
804
  addUserBasePathOption(
797
805
  command.command("delete <id>").description("Delete a session").option("-f, --force", "Skip confirmation")
798
806
  ).action(async (id, options) => {
799
- const manager = new chunkAJD3DTL7_cjs.SessionManager({
807
+ const manager = new chunkJXAJQGV5_cjs.SessionManager({
800
808
  type: "jsonl",
801
- basePath: chunkAJD3DTL7_cjs.getSessionStoragePath(options.userBasePath)
809
+ basePath: chunkJXAJQGV5_cjs.getSessionStoragePath(options.userBasePath)
802
810
  });
803
811
  const exists = await manager.sessionExists(id);
804
812
  if (!exists) {
@@ -826,9 +834,9 @@ Total: ${sessions.length} sessions`));
826
834
  addUserBasePathOption(
827
835
  command.command("clear").description("Delete all sessions").option("-f, --force", "Skip confirmation")
828
836
  ).action(async (options) => {
829
- const manager = new chunkAJD3DTL7_cjs.SessionManager({
837
+ const manager = new chunkJXAJQGV5_cjs.SessionManager({
830
838
  type: "jsonl",
831
- basePath: chunkAJD3DTL7_cjs.getSessionStoragePath(options.userBasePath)
839
+ basePath: chunkJXAJQGV5_cjs.getSessionStoragePath(options.userBasePath)
832
840
  });
833
841
  const sessions = await manager.listSessions();
834
842
  if (sessions.length === 0) {
@@ -862,7 +870,7 @@ function createMCPCommand() {
862
870
  const command = new commander.Command("mcp").description("Manage MCP servers");
863
871
  command.command("connect <command>").description("Connect to an MCP server and list available tools").option("-n, --name <name>", "Server name", "default").option("-a, --args <args>", "Command arguments (comma-separated)").option("-e, --env <env>", "Environment variables (KEY=VALUE,comma-separated)").action(async (cmd, options) => {
864
872
  try {
865
- const adapter = new chunkAJD3DTL7_cjs.MCPAdapter();
873
+ const adapter = new chunkJXAJQGV5_cjs.MCPAdapter();
866
874
  const args = options.args ? options.args.split(",") : [];
867
875
  const env = {};
868
876
  if (options.env) {
@@ -878,6 +886,7 @@ function createMCPCommand() {
878
886
  `));
879
887
  const config = {
880
888
  name: options.name,
889
+ transport: "stdio",
881
890
  command: cmd,
882
891
  args,
883
892
  env: Object.keys(env).length > 0 ? env : void 0
@@ -907,7 +916,7 @@ function createMCPCommand() {
907
916
  var isMainModule = process.argv[1]?.endsWith("cli/index.js") || process.argv[1]?.endsWith("cli\\index.js") || process.argv[1]?.includes("agent-sdk");
908
917
  if (isMainModule) {
909
918
  const program = new commander.Command();
910
- program.name("agent-sdk").description("A TypeScript Agent SDK with multi-model support, MCP integration, and streaming").version(chunkAJD3DTL7_cjs.PACKAGE_VERSION);
919
+ program.name("agent-sdk").description("A TypeScript Agent SDK with multi-model support, MCP integration, and streaming").version(chunkJXAJQGV5_cjs.PACKAGE_VERSION);
911
920
  program.addCommand(createChatCommand());
912
921
  program.addCommand(createRunCommand());
913
922
  program.addCommand(createToolsCommand());