@anthropic-ai/claude-agent-sdk 0.1.22 → 0.1.25

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/sdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://docs.claude.com/en/docs/claude-code/legal-and-compliance.
3
3
 
4
- // Version: 0.1.22
4
+ // Version: 0.1.25
5
5
 
6
6
  // Want to see the unminified source? We're hiring!
7
7
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -6327,7 +6327,25 @@ function getFsImplementation() {
6327
6327
  return activeFs;
6328
6328
  }
6329
6329
 
6330
- // ../src/entrypoints/sdkTypes.ts
6330
+ // ../src/entrypoints/agentSdkTypes.ts
6331
+ var HOOK_EVENTS = [
6332
+ "PreToolUse",
6333
+ "PostToolUse",
6334
+ "Notification",
6335
+ "UserPromptSubmit",
6336
+ "SessionStart",
6337
+ "SessionEnd",
6338
+ "Stop",
6339
+ "SubagentStop",
6340
+ "PreCompact"
6341
+ ];
6342
+ var EXIT_REASONS = [
6343
+ "clear",
6344
+ "logout",
6345
+ "prompt_input_exit",
6346
+ "other",
6347
+ "bypass_permissions_disabled"
6348
+ ];
6331
6349
  class AbortError extends Error {
6332
6350
  }
6333
6351
 
@@ -7379,7 +7397,8 @@ function getInitialState() {
7379
7397
  agentColorIndex: 0,
7380
7398
  envVarValidators: [bashMaxOutputLengthValidator, maxOutputTokensValidator],
7381
7399
  lastAPIRequest: null,
7382
- inMemoryErrorLog: []
7400
+ inMemoryErrorLog: [],
7401
+ inlinePlugins: []
7383
7402
  };
7384
7403
  }
7385
7404
  var STATE = getInitialState();
@@ -7825,117 +7844,6 @@ class Query {
7825
7844
  }
7826
7845
  }
7827
7846
 
7828
- // ../src/core/sharedQuery.ts
7829
- function createSharedQuery({
7830
- prompt,
7831
- options: {
7832
- abortController = createAbortController(),
7833
- additionalDirectories = [],
7834
- agents,
7835
- allowedTools = [],
7836
- appendSystemPrompt,
7837
- canUseTool,
7838
- continue: continueConversation,
7839
- customSystemPrompt,
7840
- cwd: cwd2,
7841
- disallowedTools = [],
7842
- env,
7843
- executable = isRunningWithBun() ? "bun" : "node",
7844
- executableArgs = [],
7845
- extraArgs = {},
7846
- fallbackModel,
7847
- forkSession,
7848
- hooks,
7849
- includePartialMessages,
7850
- maxThinkingTokens,
7851
- maxTurns,
7852
- mcpServers,
7853
- model,
7854
- pathToClaudeCodeExecutable,
7855
- permissionMode = "default",
7856
- permissionPromptToolName,
7857
- resume,
7858
- resumeSessionAt,
7859
- settingSources,
7860
- stderr,
7861
- strictMcpConfig
7862
- } = {}
7863
- }) {
7864
- if (!env) {
7865
- env = { ...process.env };
7866
- }
7867
- if (!env.CLAUDE_CODE_ENTRYPOINT) {
7868
- env.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
7869
- }
7870
- if (!pathToClaudeCodeExecutable) {
7871
- throw new Error("pathToClaudeCodeExecutable is required");
7872
- }
7873
- const allMcpServers = {};
7874
- const sdkMcpServers = new Map;
7875
- if (mcpServers) {
7876
- for (const [name, config] of Object.entries(mcpServers)) {
7877
- if (config.type === "sdk" && "instance" in config) {
7878
- sdkMcpServers.set(name, config.instance);
7879
- allMcpServers[name] = {
7880
- type: "sdk",
7881
- name
7882
- };
7883
- } else {
7884
- allMcpServers[name] = config;
7885
- }
7886
- }
7887
- }
7888
- const isSingleUserTurn = typeof prompt === "string";
7889
- const transport = new ProcessTransport({
7890
- abortController,
7891
- additionalDirectories,
7892
- agents,
7893
- cwd: cwd2,
7894
- executable,
7895
- executableArgs,
7896
- extraArgs,
7897
- pathToClaudeCodeExecutable,
7898
- env,
7899
- forkSession,
7900
- stderr,
7901
- customSystemPrompt,
7902
- appendSystemPrompt,
7903
- maxThinkingTokens,
7904
- maxTurns,
7905
- model,
7906
- fallbackModel,
7907
- permissionMode,
7908
- permissionPromptToolName,
7909
- continueConversation,
7910
- resume,
7911
- resumeSessionAt,
7912
- settingSources,
7913
- allowedTools,
7914
- disallowedTools,
7915
- mcpServers: allMcpServers,
7916
- strictMcpConfig,
7917
- canUseTool: !!canUseTool,
7918
- hooks: !!hooks,
7919
- includePartialMessages
7920
- });
7921
- const query = new Query(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers);
7922
- if (typeof prompt === "string") {
7923
- transport.write(JSON.stringify({
7924
- type: "user",
7925
- session_id: "",
7926
- message: {
7927
- role: "user",
7928
- content: [{ type: "text", text: prompt }]
7929
- },
7930
- parent_tool_use_id: null
7931
- }) + `
7932
- `);
7933
- } else {
7934
- query.streamInput(prompt);
7935
- }
7936
- return query;
7937
- }
7938
-
7939
7847
  // ../node_modules/zod/v3/external.js
7940
7848
  var exports_external = {};
7941
7849
  __export(exports_external, {
@@ -14815,6 +14723,7 @@ function createSdkMcpServer(options) {
14815
14723
  instance: server
14816
14724
  };
14817
14725
  }
14726
+
14818
14727
  // ../src/entrypoints/agentSdk.ts
14819
14728
  function query({
14820
14729
  prompt,
@@ -14836,20 +14745,115 @@ function query({
14836
14745
  const dirname2 = join3(filename, "..");
14837
14746
  pathToClaudeCodeExecutable = join3(dirname2, "cli.js");
14838
14747
  }
14839
- process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.22";
14840
- return createSharedQuery({
14841
- prompt,
14842
- options: {
14843
- ...rest,
14844
- pathToClaudeCodeExecutable,
14845
- customSystemPrompt,
14846
- appendSystemPrompt,
14847
- settingSources: settingSources ?? []
14748
+ process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.25";
14749
+ const {
14750
+ abortController = createAbortController(),
14751
+ additionalDirectories = [],
14752
+ agents,
14753
+ allowedTools = [],
14754
+ canUseTool,
14755
+ continue: continueConversation,
14756
+ cwd: cwd2,
14757
+ disallowedTools = [],
14758
+ env,
14759
+ executable = isRunningWithBun() ? "bun" : "node",
14760
+ executableArgs = [],
14761
+ extraArgs = {},
14762
+ fallbackModel,
14763
+ forkSession,
14764
+ hooks,
14765
+ includePartialMessages,
14766
+ maxThinkingTokens,
14767
+ maxTurns,
14768
+ mcpServers,
14769
+ model,
14770
+ permissionMode = "default",
14771
+ permissionPromptToolName,
14772
+ resume,
14773
+ resumeSessionAt,
14774
+ stderr,
14775
+ strictMcpConfig
14776
+ } = rest;
14777
+ let processEnv = env;
14778
+ if (!processEnv) {
14779
+ processEnv = { ...process.env };
14780
+ }
14781
+ if (!processEnv.CLAUDE_CODE_ENTRYPOINT) {
14782
+ processEnv.CLAUDE_CODE_ENTRYPOINT = "sdk-ts";
14783
+ }
14784
+ if (!pathToClaudeCodeExecutable) {
14785
+ throw new Error("pathToClaudeCodeExecutable is required");
14786
+ }
14787
+ const allMcpServers = {};
14788
+ const sdkMcpServers = new Map;
14789
+ if (mcpServers) {
14790
+ for (const [name, config] of Object.entries(mcpServers)) {
14791
+ if (config.type === "sdk" && "instance" in config) {
14792
+ sdkMcpServers.set(name, config.instance);
14793
+ allMcpServers[name] = {
14794
+ type: "sdk",
14795
+ name
14796
+ };
14797
+ } else {
14798
+ allMcpServers[name] = config;
14799
+ }
14848
14800
  }
14801
+ }
14802
+ const isSingleUserTurn = typeof prompt === "string";
14803
+ const transport = new ProcessTransport({
14804
+ abortController,
14805
+ additionalDirectories,
14806
+ agents,
14807
+ cwd: cwd2,
14808
+ executable,
14809
+ executableArgs,
14810
+ extraArgs,
14811
+ pathToClaudeCodeExecutable,
14812
+ env: processEnv,
14813
+ forkSession,
14814
+ stderr,
14815
+ customSystemPrompt,
14816
+ appendSystemPrompt,
14817
+ maxThinkingTokens,
14818
+ maxTurns,
14819
+ model,
14820
+ fallbackModel,
14821
+ permissionMode,
14822
+ permissionPromptToolName,
14823
+ continueConversation,
14824
+ resume,
14825
+ resumeSessionAt,
14826
+ settingSources: settingSources ?? [],
14827
+ allowedTools,
14828
+ disallowedTools,
14829
+ mcpServers: allMcpServers,
14830
+ strictMcpConfig,
14831
+ canUseTool: !!canUseTool,
14832
+ hooks: !!hooks,
14833
+ includePartialMessages
14849
14834
  });
14835
+ const queryInstance = new Query(transport, isSingleUserTurn, canUseTool, hooks, abortController, sdkMcpServers);
14836
+ if (typeof prompt === "string") {
14837
+ transport.write(JSON.stringify({
14838
+ type: "user",
14839
+ session_id: "",
14840
+ message: {
14841
+ role: "user",
14842
+ content: [{ type: "text", text: prompt }]
14843
+ },
14844
+ parent_tool_use_id: null
14845
+ }) + `
14846
+ `);
14847
+ } else {
14848
+ queryInstance.streamInput(prompt);
14849
+ }
14850
+ return queryInstance;
14850
14851
  }
14851
14852
  export {
14852
14853
  tool,
14853
14854
  query,
14854
- createSdkMcpServer
14855
+ createSdkMcpServer,
14856
+ HOOK_EVENTS,
14857
+ EXIT_REASONS,
14858
+ AbortError
14855
14859
  };