fourmis-agents-sdk 0.3.1 → 0.4.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 (84) hide show
  1. package/README.md +126 -198
  2. package/dist/agent-loop.d.ts +21 -3
  3. package/dist/agent-loop.d.ts.map +1 -1
  4. package/dist/agent-loop.js +279 -90
  5. package/dist/agents/index.js +1079 -124
  6. package/dist/agents/tools.d.ts.map +1 -1
  7. package/dist/agents/tools.js +1079 -124
  8. package/dist/agents/types.d.ts +4 -0
  9. package/dist/agents/types.d.ts.map +1 -1
  10. package/dist/api.d.ts +8 -5
  11. package/dist/api.d.ts.map +1 -1
  12. package/dist/api.js +1663 -430
  13. package/dist/hooks.d.ts +19 -1
  14. package/dist/hooks.d.ts.map +1 -1
  15. package/dist/hooks.js +27 -2
  16. package/dist/index.d.ts +8 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1671 -431
  19. package/dist/mcp/client.d.ts +8 -1
  20. package/dist/mcp/client.d.ts.map +1 -1
  21. package/dist/mcp/client.js +134 -13
  22. package/dist/mcp/index.js +134 -13
  23. package/dist/mcp/types.d.ts +21 -1
  24. package/dist/mcp/types.d.ts.map +1 -1
  25. package/dist/permissions.d.ts.map +1 -1
  26. package/dist/permissions.js +7 -3
  27. package/dist/providers/anthropic.d.ts.map +1 -1
  28. package/dist/providers/anthropic.js +41 -2
  29. package/dist/providers/openai.d.ts +6 -0
  30. package/dist/providers/openai.d.ts.map +1 -1
  31. package/dist/providers/openai.js +36 -6
  32. package/dist/providers/registry.js +76 -8
  33. package/dist/providers/types.d.ts +4 -1
  34. package/dist/providers/types.d.ts.map +1 -1
  35. package/dist/query.d.ts +21 -2
  36. package/dist/query.d.ts.map +1 -1
  37. package/dist/query.js +69 -1
  38. package/dist/skills/index.js +23 -1
  39. package/dist/skills/skills.d.ts +16 -0
  40. package/dist/skills/skills.d.ts.map +1 -1
  41. package/dist/skills/skills.js +23 -1
  42. package/dist/tools/ask-user-question.d.ts +7 -0
  43. package/dist/tools/ask-user-question.d.ts.map +1 -0
  44. package/dist/tools/ask-user-question.js +48 -0
  45. package/dist/tools/bash.d.ts.map +1 -1
  46. package/dist/tools/bash.js +47 -2
  47. package/dist/tools/config.d.ts +7 -0
  48. package/dist/tools/config.d.ts.map +1 -0
  49. package/dist/tools/config.js +114 -0
  50. package/dist/tools/exit-plan-mode.d.ts +7 -0
  51. package/dist/tools/exit-plan-mode.d.ts.map +1 -0
  52. package/dist/tools/exit-plan-mode.js +34 -0
  53. package/dist/tools/index.d.ts +7 -0
  54. package/dist/tools/index.d.ts.map +1 -1
  55. package/dist/tools/index.js +506 -9
  56. package/dist/tools/notebook-edit.d.ts +7 -0
  57. package/dist/tools/notebook-edit.d.ts.map +1 -0
  58. package/dist/tools/notebook-edit.js +83 -0
  59. package/dist/tools/presets.d.ts +2 -1
  60. package/dist/tools/presets.d.ts.map +1 -1
  61. package/dist/tools/presets.js +22 -4
  62. package/dist/tools/read.d.ts.map +1 -1
  63. package/dist/tools/read.js +12 -1
  64. package/dist/tools/registry.d.ts +2 -0
  65. package/dist/tools/registry.d.ts.map +1 -1
  66. package/dist/tools/registry.js +10 -0
  67. package/dist/tools/todo-write.d.ts +7 -0
  68. package/dist/tools/todo-write.d.ts.map +1 -0
  69. package/dist/tools/todo-write.js +69 -0
  70. package/dist/tools/web-fetch.d.ts +6 -0
  71. package/dist/tools/web-fetch.d.ts.map +1 -0
  72. package/dist/tools/web-fetch.js +85 -0
  73. package/dist/tools/web-search.d.ts +7 -0
  74. package/dist/tools/web-search.d.ts.map +1 -0
  75. package/dist/tools/web-search.js +78 -0
  76. package/dist/types.d.ts +344 -42
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/utils/session-store.d.ts +1 -1
  79. package/dist/utils/session-store.d.ts.map +1 -1
  80. package/dist/utils/session-store.js +49 -2
  81. package/dist/utils/system-prompt.d.ts +2 -0
  82. package/dist/utils/system-prompt.d.ts.map +1 -1
  83. package/dist/utils/system-prompt.js +33 -4
  84. package/package.json +3 -2
@@ -525,6 +525,22 @@ var CODEX_MODELS = new Set([
525
525
  "gpt-5-codex",
526
526
  "gpt-5-codex-mini"
527
527
  ]);
528
+ var OPENAI_MAX_TOOL_NAME = 64;
529
+ function sanitizeToolName(name) {
530
+ const clean = name.replace(/[^a-zA-Z0-9_-]/g, "_");
531
+ if (clean.length <= OPENAI_MAX_TOOL_NAME)
532
+ return clean;
533
+ const hash = simpleHash(name);
534
+ return clean.slice(0, OPENAI_MAX_TOOL_NAME - 7) + "_" + hash;
535
+ }
536
+ function simpleHash(s) {
537
+ let h = 2166136261;
538
+ for (let i = 0;i < s.length; i++) {
539
+ h ^= s.charCodeAt(i);
540
+ h = Math.imul(h, 16777619);
541
+ }
542
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
543
+ }
528
544
 
529
545
  class OpenAIAdapter {
530
546
  name = "openai";
@@ -532,6 +548,7 @@ class OpenAIAdapter {
532
548
  codexMode;
533
549
  accountId;
534
550
  currentAccessToken;
551
+ toolNameMap = new Map;
535
552
  constructor(options) {
536
553
  const key = options?.apiKey ?? process.env.OPENAI_API_KEY;
537
554
  if (key) {
@@ -564,6 +581,15 @@ class OpenAIAdapter {
564
581
  }
565
582
  }
566
583
  async* chat(request) {
584
+ this.toolNameMap.clear();
585
+ if (request.tools) {
586
+ for (const tool of request.tools) {
587
+ const sanitized = sanitizeToolName(tool.name);
588
+ if (sanitized !== tool.name) {
589
+ this.toolNameMap.set(sanitized, tool.name);
590
+ }
591
+ }
592
+ }
567
593
  if (this.codexMode) {
568
594
  yield* this.chatResponses(request);
569
595
  } else {
@@ -665,7 +691,7 @@ class OpenAIAdapter {
665
691
  yield {
666
692
  type: "tool_call",
667
693
  id: buf.id,
668
- name: buf.name,
694
+ name: this.resolveToolName(buf.name),
669
695
  input
670
696
  };
671
697
  }
@@ -709,7 +735,7 @@ class OpenAIAdapter {
709
735
  yield {
710
736
  type: "tool_call",
711
737
  id: item.call_id,
712
- name: item.name,
738
+ name: this.resolveToolName(item.name),
713
739
  input: parsedInput
714
740
  };
715
741
  }
@@ -776,7 +802,7 @@ class OpenAIAdapter {
776
802
  id: block.id,
777
803
  type: "function",
778
804
  function: {
779
- name: block.name,
805
+ name: sanitizeToolName(block.name),
780
806
  arguments: JSON.stringify(block.input)
781
807
  }
782
808
  });
@@ -841,7 +867,7 @@ class OpenAIAdapter {
841
867
  result.push({
842
868
  type: "function_call",
843
869
  call_id: tu.id,
844
- name: tu.name,
870
+ name: sanitizeToolName(tu.name),
845
871
  arguments: JSON.stringify(tu.input)
846
872
  });
847
873
  }
@@ -873,7 +899,7 @@ class OpenAIAdapter {
873
899
  return tools.map((tool) => ({
874
900
  type: "function",
875
901
  function: {
876
- name: tool.name,
902
+ name: sanitizeToolName(tool.name),
877
903
  description: tool.description,
878
904
  parameters: tool.inputSchema
879
905
  }
@@ -882,12 +908,15 @@ class OpenAIAdapter {
882
908
  convertToolsForResponses(tools) {
883
909
  return tools.map((tool) => ({
884
910
  type: "function",
885
- name: tool.name,
911
+ name: sanitizeToolName(tool.name),
886
912
  description: tool.description,
887
913
  parameters: tool.inputSchema,
888
914
  strict: false
889
915
  }));
890
916
  }
917
+ resolveToolName(name) {
918
+ return this.toolNameMap.get(name) ?? name;
919
+ }
891
920
  mapStopReason(reason) {
892
921
  switch (reason) {
893
922
  case "stop":
@@ -933,5 +962,6 @@ function loadTokensSync() {
933
962
  return null;
934
963
  }
935
964
  export {
965
+ sanitizeToolName,
936
966
  OpenAIAdapter
937
967
  };
@@ -646,6 +646,44 @@ class AnthropicAdapter {
646
646
  max_tokens: maxTokens,
647
647
  stream: true
648
648
  };
649
+ if (request.thinking) {
650
+ switch (request.thinking.type) {
651
+ case "adaptive":
652
+ params.thinking = { type: "adaptive" };
653
+ break;
654
+ case "disabled":
655
+ params.thinking = { type: "disabled" };
656
+ break;
657
+ case "enabled":
658
+ params.thinking = {
659
+ type: "enabled",
660
+ budget_tokens: request.thinking.budgetTokens
661
+ };
662
+ break;
663
+ }
664
+ } else if (request.thinkingBudget !== undefined) {
665
+ if (request.thinkingBudget <= 0) {
666
+ params.thinking = { type: "disabled" };
667
+ } else {
668
+ params.thinking = {
669
+ type: "enabled",
670
+ budget_tokens: Math.max(1024, request.thinkingBudget)
671
+ };
672
+ }
673
+ }
674
+ const outputConfig = {};
675
+ if (request.effort) {
676
+ outputConfig.effort = request.effort;
677
+ }
678
+ if (request.outputFormat?.type === "json_schema") {
679
+ outputConfig.format = {
680
+ type: "json_schema",
681
+ schema: request.outputFormat.schema
682
+ };
683
+ }
684
+ if (Object.keys(outputConfig).length > 0) {
685
+ params.output_config = outputConfig;
686
+ }
649
687
  if (this.oauthMode) {
650
688
  const systemBlocks = [
651
689
  { type: "text", text: "You are Claude Code, Anthropic's official CLI for Claude." }
@@ -770,11 +808,12 @@ class AnthropicAdapter {
770
808
  switch (feature) {
771
809
  case "streaming":
772
810
  case "tool_calling":
773
- case "image_input":
774
- case "pdf_input":
775
811
  case "thinking":
776
812
  case "structured_output":
777
813
  return true;
814
+ case "image_input":
815
+ case "pdf_input":
816
+ return false;
778
817
  default:
779
818
  return false;
780
819
  }
@@ -845,6 +884,22 @@ var CODEX_MODELS = new Set([
845
884
  "gpt-5-codex",
846
885
  "gpt-5-codex-mini"
847
886
  ]);
887
+ var OPENAI_MAX_TOOL_NAME = 64;
888
+ function sanitizeToolName(name) {
889
+ const clean = name.replace(/[^a-zA-Z0-9_-]/g, "_");
890
+ if (clean.length <= OPENAI_MAX_TOOL_NAME)
891
+ return clean;
892
+ const hash = simpleHash(name);
893
+ return clean.slice(0, OPENAI_MAX_TOOL_NAME - 7) + "_" + hash;
894
+ }
895
+ function simpleHash(s) {
896
+ let h = 2166136261;
897
+ for (let i = 0;i < s.length; i++) {
898
+ h ^= s.charCodeAt(i);
899
+ h = Math.imul(h, 16777619);
900
+ }
901
+ return (h >>> 0).toString(16).padStart(8, "0").slice(0, 6);
902
+ }
848
903
 
849
904
  class OpenAIAdapter {
850
905
  name = "openai";
@@ -852,6 +907,7 @@ class OpenAIAdapter {
852
907
  codexMode;
853
908
  accountId;
854
909
  currentAccessToken;
910
+ toolNameMap = new Map;
855
911
  constructor(options) {
856
912
  const key = options?.apiKey ?? process.env.OPENAI_API_KEY;
857
913
  if (key) {
@@ -884,6 +940,15 @@ class OpenAIAdapter {
884
940
  }
885
941
  }
886
942
  async* chat(request) {
943
+ this.toolNameMap.clear();
944
+ if (request.tools) {
945
+ for (const tool of request.tools) {
946
+ const sanitized = sanitizeToolName(tool.name);
947
+ if (sanitized !== tool.name) {
948
+ this.toolNameMap.set(sanitized, tool.name);
949
+ }
950
+ }
951
+ }
887
952
  if (this.codexMode) {
888
953
  yield* this.chatResponses(request);
889
954
  } else {
@@ -985,7 +1050,7 @@ class OpenAIAdapter {
985
1050
  yield {
986
1051
  type: "tool_call",
987
1052
  id: buf.id,
988
- name: buf.name,
1053
+ name: this.resolveToolName(buf.name),
989
1054
  input
990
1055
  };
991
1056
  }
@@ -1029,7 +1094,7 @@ class OpenAIAdapter {
1029
1094
  yield {
1030
1095
  type: "tool_call",
1031
1096
  id: item.call_id,
1032
- name: item.name,
1097
+ name: this.resolveToolName(item.name),
1033
1098
  input: parsedInput
1034
1099
  };
1035
1100
  }
@@ -1096,7 +1161,7 @@ class OpenAIAdapter {
1096
1161
  id: block.id,
1097
1162
  type: "function",
1098
1163
  function: {
1099
- name: block.name,
1164
+ name: sanitizeToolName(block.name),
1100
1165
  arguments: JSON.stringify(block.input)
1101
1166
  }
1102
1167
  });
@@ -1161,7 +1226,7 @@ class OpenAIAdapter {
1161
1226
  result.push({
1162
1227
  type: "function_call",
1163
1228
  call_id: tu.id,
1164
- name: tu.name,
1229
+ name: sanitizeToolName(tu.name),
1165
1230
  arguments: JSON.stringify(tu.input)
1166
1231
  });
1167
1232
  }
@@ -1193,7 +1258,7 @@ class OpenAIAdapter {
1193
1258
  return tools.map((tool) => ({
1194
1259
  type: "function",
1195
1260
  function: {
1196
- name: tool.name,
1261
+ name: sanitizeToolName(tool.name),
1197
1262
  description: tool.description,
1198
1263
  parameters: tool.inputSchema
1199
1264
  }
@@ -1202,12 +1267,15 @@ class OpenAIAdapter {
1202
1267
  convertToolsForResponses(tools) {
1203
1268
  return tools.map((tool) => ({
1204
1269
  type: "function",
1205
- name: tool.name,
1270
+ name: sanitizeToolName(tool.name),
1206
1271
  description: tool.description,
1207
1272
  parameters: tool.inputSchema,
1208
1273
  strict: false
1209
1274
  }));
1210
1275
  }
1276
+ resolveToolName(name) {
1277
+ return this.toolNameMap.get(name) ?? name;
1278
+ }
1211
1279
  mapStopReason(reason) {
1212
1280
  switch (reason) {
1213
1281
  case "stop":
@@ -2,7 +2,7 @@
2
2
  * Provider adapter interface and related types.
3
3
  * Normalizes all LLM APIs into a common contract.
4
4
  */
5
- import type { TokenUsage } from "../types.js";
5
+ import type { TokenUsage, ThinkingConfig, Effort, OutputFormat } from "../types.js";
6
6
  export type ToolDefinition = {
7
7
  name: string;
8
8
  description: string;
@@ -38,6 +38,9 @@ export type ChatRequest = {
38
38
  maxTokens?: number;
39
39
  temperature?: number;
40
40
  thinkingBudget?: number;
41
+ thinking?: ThinkingConfig;
42
+ effort?: Effort;
43
+ outputFormat?: OutputFormat;
41
44
  signal?: AbortSignal;
42
45
  /**
43
46
  * Provider-specific native tools (e.g. Anthropic's memory_20250818).
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC;AAIF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC;AAElD,M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AC;IACxC,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC;IACnD,UAAU,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;CACrC"}
package/dist/query.d.ts CHANGED
@@ -1,9 +1,28 @@
1
1
  /**
2
2
  * Query class — wraps the agent loop AsyncGenerator with control methods.
3
3
  */
4
- import type { AgentMessage, Query } from "./types.js";
4
+ import type { AgentMessage, Query, PermissionMode, QueryInitializationResult, SlashCommand, AccountInfo, RewindFilesResult, McpSetServersResult, SDKUserMessage } from "./types.js";
5
+ import type { ModelInfo } from "./providers/types.js";
6
+ import type { McpServerConfig, McpServerStatus } from "./mcp/types.js";
7
+ export type QueryControlHandlers = {
8
+ setPermissionMode?: (mode: PermissionMode) => Promise<void>;
9
+ setModel?: (model?: string) => Promise<void>;
10
+ setMaxThinkingTokens?: (maxThinkingTokens: number | null) => Promise<void>;
11
+ initializationResult?: () => Promise<QueryInitializationResult>;
12
+ supportedCommands?: () => Promise<SlashCommand[]>;
13
+ supportedModels?: () => Promise<ModelInfo[]>;
14
+ mcpServerStatus?: () => Promise<McpServerStatus[]>;
15
+ accountInfo?: () => Promise<AccountInfo>;
16
+ rewindFiles?: (userMessageId: string, options?: {
17
+ dryRun?: boolean;
18
+ }) => Promise<RewindFilesResult>;
19
+ reconnectMcpServer?: (serverName: string) => Promise<void>;
20
+ toggleMcpServer?: (serverName: string, enabled: boolean) => Promise<void>;
21
+ setMcpServers?: (servers: Record<string, McpServerConfig>) => Promise<McpSetServersResult>;
22
+ streamInput?: (stream: AsyncIterable<SDKUserMessage>) => Promise<void>;
23
+ };
5
24
  /**
6
25
  * Create a Query that wraps an AsyncGenerator<AgentMessage> with control methods.
7
26
  */
8
- export declare function createQuery(generator: AsyncGenerator<AgentMessage, void, undefined>, abortController: AbortController): Query;
27
+ export declare function createQuery(generator: AsyncGenerator<AgentMessage, void, undefined>, abortController: AbortController, controls?: QueryControlHandlers): Query;
9
28
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,EACxD,eAAe,EAAE,eAAe,GAC/B,KAAK,CAwBP"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,cAAc,EACd,yBAAyB,EACzB,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,oBAAoB,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAChE,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAClD,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC7C,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpG,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC3F,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,CAAC;AAMF;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,EACxD,eAAe,EAAE,eAAe,EAChC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,KAAK,CAyFP"}
package/dist/query.js CHANGED
@@ -13,7 +13,10 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
13
13
  var __require = import.meta.require;
14
14
 
15
15
  // src/query.ts
16
- function createQuery(generator, abortController) {
16
+ function unsupported(methodName) {
17
+ return Promise.reject(new Error(`Query.${methodName} is not supported in this runtime yet.`));
18
+ }
19
+ function createQuery(generator, abortController, controls) {
17
20
  const query = {
18
21
  next: generator.next.bind(generator),
19
22
  return: generator.return.bind(generator),
@@ -24,6 +27,71 @@ function createQuery(generator, abortController) {
24
27
  async interrupt() {
25
28
  abortController.abort();
26
29
  },
30
+ async setPermissionMode(mode) {
31
+ if (!controls?.setPermissionMode)
32
+ return unsupported("setPermissionMode");
33
+ await controls.setPermissionMode(mode);
34
+ },
35
+ async setModel(model) {
36
+ if (!controls?.setModel)
37
+ return unsupported("setModel");
38
+ await controls.setModel(model);
39
+ },
40
+ async setMaxThinkingTokens(maxThinkingTokens) {
41
+ if (!controls?.setMaxThinkingTokens)
42
+ return unsupported("setMaxThinkingTokens");
43
+ await controls.setMaxThinkingTokens(maxThinkingTokens);
44
+ },
45
+ async initializationResult() {
46
+ if (!controls?.initializationResult)
47
+ return unsupported("initializationResult");
48
+ return controls.initializationResult();
49
+ },
50
+ async supportedCommands() {
51
+ if (!controls?.supportedCommands)
52
+ return unsupported("supportedCommands");
53
+ return controls.supportedCommands();
54
+ },
55
+ async supportedModels() {
56
+ if (!controls?.supportedModels)
57
+ return unsupported("supportedModels");
58
+ return controls.supportedModels();
59
+ },
60
+ async mcpServerStatus() {
61
+ if (!controls?.mcpServerStatus)
62
+ return unsupported("mcpServerStatus");
63
+ return controls.mcpServerStatus();
64
+ },
65
+ async accountInfo() {
66
+ if (!controls?.accountInfo)
67
+ return unsupported("accountInfo");
68
+ return controls.accountInfo();
69
+ },
70
+ async rewindFiles(userMessageId, options) {
71
+ if (!controls?.rewindFiles)
72
+ return unsupported("rewindFiles");
73
+ return controls.rewindFiles(userMessageId, options);
74
+ },
75
+ async reconnectMcpServer(serverName) {
76
+ if (!controls?.reconnectMcpServer)
77
+ return unsupported("reconnectMcpServer");
78
+ await controls.reconnectMcpServer(serverName);
79
+ },
80
+ async toggleMcpServer(serverName, enabled) {
81
+ if (!controls?.toggleMcpServer)
82
+ return unsupported("toggleMcpServer");
83
+ await controls.toggleMcpServer(serverName, enabled);
84
+ },
85
+ async setMcpServers(servers) {
86
+ if (!controls?.setMcpServers)
87
+ return unsupported("setMcpServers");
88
+ return controls.setMcpServers(servers);
89
+ },
90
+ async streamInput(stream) {
91
+ if (!controls?.streamInput)
92
+ return unsupported("streamInput");
93
+ await controls.streamInput(stream);
94
+ },
27
95
  close() {
28
96
  abortController.abort();
29
97
  generator.return(undefined);
@@ -52,6 +52,7 @@ import { homedir } from "os";
52
52
  import { basename, dirname, isAbsolute, join, resolve } from "path";
53
53
  var MAX_NAME_LENGTH = 64;
54
54
  var MAX_DESCRIPTION_LENGTH = 1024;
55
+ var MAX_COMPATIBILITY_LENGTH = 500;
55
56
  var CONFIG_DIR_NAME = ".claude";
56
57
  function shouldIgnore(name) {
57
58
  return name.startsWith(".") || name === "node_modules";
@@ -84,6 +85,14 @@ function validateDescription(description) {
84
85
  }
85
86
  return errors;
86
87
  }
88
+ function validateCompatibility(compatibility) {
89
+ if (!compatibility)
90
+ return [];
91
+ if (compatibility.length > MAX_COMPATIBILITY_LENGTH) {
92
+ return [`compatibility exceeds ${MAX_COMPATIBILITY_LENGTH} characters (${compatibility.length})`];
93
+ }
94
+ return [];
95
+ }
87
96
  function loadSkillsFromDir(options) {
88
97
  return loadSkillsFromDirInternal(options.dir, options.source, true);
89
98
  }
@@ -148,9 +157,15 @@ function loadSkillFromFile(filePath, source) {
148
157
  for (const error of nameErrors) {
149
158
  diagnostics.push({ type: "warning", message: error, path: filePath });
150
159
  }
160
+ const compatErrors = validateCompatibility(frontmatter.compatibility);
161
+ for (const error of compatErrors) {
162
+ diagnostics.push({ type: "warning", message: error, path: filePath });
163
+ }
151
164
  if (!frontmatter.description || frontmatter.description.trim() === "") {
152
165
  return { skill: null, diagnostics };
153
166
  }
167
+ const allowedToolsRaw = frontmatter["allowed-tools"];
168
+ const allowedTools = allowedToolsRaw ? allowedToolsRaw.split(/\s+/).filter(Boolean) : undefined;
154
169
  return {
155
170
  skill: {
156
171
  name,
@@ -158,7 +173,11 @@ function loadSkillFromFile(filePath, source) {
158
173
  filePath,
159
174
  baseDir: skillDir,
160
175
  source,
161
- disableModelInvocation: frontmatter["disable-model-invocation"] === true
176
+ disableModelInvocation: frontmatter["disable-model-invocation"] === true,
177
+ license: frontmatter.license,
178
+ compatibility: frontmatter.compatibility,
179
+ metadata: frontmatter.metadata,
180
+ allowedTools
162
181
  },
163
182
  diagnostics
164
183
  };
@@ -274,6 +293,9 @@ function formatSkillsForPrompt(skills) {
274
293
  lines.push(` <name>${escapeXml(skill.name)}</name>`);
275
294
  lines.push(` <description>${escapeXml(skill.description)}</description>`);
276
295
  lines.push(` <location>${escapeXml(skill.filePath)}</location>`);
296
+ if (skill.allowedTools?.length) {
297
+ lines.push(` <allowed-tools>${escapeXml(skill.allowedTools.join(" "))}</allowed-tools>`);
298
+ }
277
299
  lines.push(" </skill>");
278
300
  }
279
301
  lines.push("</available_skills>");
@@ -11,6 +11,14 @@ export interface SkillFrontmatter {
11
11
  name?: string;
12
12
  description?: string;
13
13
  "disable-model-invocation"?: boolean;
14
+ /** License name or reference to a bundled license file. (Agent Skills spec) */
15
+ license?: string;
16
+ /** Environment requirements — max 500 chars. (Agent Skills spec) */
17
+ compatibility?: string;
18
+ /** Arbitrary key-value metadata. (Agent Skills spec) */
19
+ metadata?: Record<string, string>;
20
+ /** Space-delimited list of pre-approved tools. Experimental. (Agent Skills spec) */
21
+ "allowed-tools"?: string;
14
22
  [key: string]: unknown;
15
23
  }
16
24
  export interface Skill {
@@ -20,6 +28,14 @@ export interface Skill {
20
28
  baseDir: string;
21
29
  source: string;
22
30
  disableModelInvocation: boolean;
31
+ /** License (Agent Skills spec) */
32
+ license?: string;
33
+ /** Environment compatibility note (Agent Skills spec) */
34
+ compatibility?: string;
35
+ /** Arbitrary metadata (Agent Skills spec) */
36
+ metadata?: Record<string, string>;
37
+ /** Pre-approved tools list (Agent Skills spec, experimental) */
38
+ allowedTools?: string[];
23
39
  }
24
40
  export interface SkillDiagnostic {
25
41
  type: "warning" | "collision";
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/skills/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM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QACtB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,2FAA2F;IAC3F,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA0DD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CAErF;AAgJD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAkF5E;AAaD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CA6B7D"}
@@ -52,6 +52,7 @@ import { homedir } from "os";
52
52
  import { basename, dirname, isAbsolute, join, resolve } from "path";
53
53
  var MAX_NAME_LENGTH = 64;
54
54
  var MAX_DESCRIPTION_LENGTH = 1024;
55
+ var MAX_COMPATIBILITY_LENGTH = 500;
55
56
  var CONFIG_DIR_NAME = ".claude";
56
57
  function shouldIgnore(name) {
57
58
  return name.startsWith(".") || name === "node_modules";
@@ -84,6 +85,14 @@ function validateDescription(description) {
84
85
  }
85
86
  return errors;
86
87
  }
88
+ function validateCompatibility(compatibility) {
89
+ if (!compatibility)
90
+ return [];
91
+ if (compatibility.length > MAX_COMPATIBILITY_LENGTH) {
92
+ return [`compatibility exceeds ${MAX_COMPATIBILITY_LENGTH} characters (${compatibility.length})`];
93
+ }
94
+ return [];
95
+ }
87
96
  function loadSkillsFromDir(options) {
88
97
  return loadSkillsFromDirInternal(options.dir, options.source, true);
89
98
  }
@@ -148,9 +157,15 @@ function loadSkillFromFile(filePath, source) {
148
157
  for (const error of nameErrors) {
149
158
  diagnostics.push({ type: "warning", message: error, path: filePath });
150
159
  }
160
+ const compatErrors = validateCompatibility(frontmatter.compatibility);
161
+ for (const error of compatErrors) {
162
+ diagnostics.push({ type: "warning", message: error, path: filePath });
163
+ }
151
164
  if (!frontmatter.description || frontmatter.description.trim() === "") {
152
165
  return { skill: null, diagnostics };
153
166
  }
167
+ const allowedToolsRaw = frontmatter["allowed-tools"];
168
+ const allowedTools = allowedToolsRaw ? allowedToolsRaw.split(/\s+/).filter(Boolean) : undefined;
154
169
  return {
155
170
  skill: {
156
171
  name,
@@ -158,7 +173,11 @@ function loadSkillFromFile(filePath, source) {
158
173
  filePath,
159
174
  baseDir: skillDir,
160
175
  source,
161
- disableModelInvocation: frontmatter["disable-model-invocation"] === true
176
+ disableModelInvocation: frontmatter["disable-model-invocation"] === true,
177
+ license: frontmatter.license,
178
+ compatibility: frontmatter.compatibility,
179
+ metadata: frontmatter.metadata,
180
+ allowedTools
162
181
  },
163
182
  diagnostics
164
183
  };
@@ -274,6 +293,9 @@ function formatSkillsForPrompt(skills) {
274
293
  lines.push(` <name>${escapeXml(skill.name)}</name>`);
275
294
  lines.push(` <description>${escapeXml(skill.description)}</description>`);
276
295
  lines.push(` <location>${escapeXml(skill.filePath)}</location>`);
296
+ if (skill.allowedTools?.length) {
297
+ lines.push(` <allowed-tools>${escapeXml(skill.allowedTools.join(" "))}</allowed-tools>`);
298
+ }
277
299
  lines.push(" </skill>");
278
300
  }
279
301
  lines.push("</available_skills>");
@@ -0,0 +1,7 @@
1
+ /**
2
+ * AskUserQuestion tool.
3
+ * In this in-process runtime, direct interactive prompting is not available.
4
+ */
5
+ import type { ToolImplementation } from "./registry.js";
6
+ export declare const AskUserQuestionTool: ToolImplementation;
7
+ //# sourceMappingURL=ask-user-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-user-question.d.ts","sourceRoot":"","sources":["../../src/tools/ask-user-question.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAC;AAEpE,eAAO,MAAM,mBAAmB,EAAE,kBAuCjC,CAAC"}
@@ -0,0 +1,48 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true,
8
+ configurable: true,
9
+ set: (newValue) => all[name] = () => newValue
10
+ });
11
+ };
12
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
13
+ var __require = import.meta.require;
14
+
15
+ // src/tools/ask-user-question.ts
16
+ var AskUserQuestionTool = {
17
+ name: "AskUserQuestion",
18
+ description: "Ask the user a clarifying question and wait for their response.",
19
+ inputSchema: {
20
+ type: "object",
21
+ properties: {
22
+ question: {
23
+ type: "string",
24
+ description: "Question to ask the user."
25
+ },
26
+ options: {
27
+ type: "array",
28
+ items: { type: "string" },
29
+ description: "Optional fixed choices."
30
+ }
31
+ },
32
+ required: ["question"]
33
+ },
34
+ async execute(input) {
35
+ const { question, options } = input ?? {};
36
+ if (!question) {
37
+ return { content: "Error: question is required", isError: true };
38
+ }
39
+ const choices = Array.isArray(options) && options.length > 0 ? ` Choices: ${options.join(" | ")}` : "";
40
+ return {
41
+ content: `User interaction is not available in this runtime. Unanswered question: ${question}.${choices}`,
42
+ isError: true
43
+ };
44
+ }
45
+ };
46
+ export {
47
+ AskUserQuestionTool
48
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAMjF,eAAO,MAAM,QAAQ,EAAE,kBAmFtB,CAAC"}
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAMjF,eAAO,MAAM,QAAQ,EAAE,kBAoItB,CAAC"}