sdk.d.ts 152 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312
  1. import type { BetaMessage } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
  2. import type { BetaRawMessageStreamEvent } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
  3. import type { BetaUsage } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
  4. import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
  5. import type { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
  6. import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
  7. import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
  8. import type { MessageParam } from '@anthropic-ai/sdk/resources';
  9. import type { Readable } from 'stream';
  10. import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
  11. import type { UUID } from 'crypto';
  12. import type { Writable } from 'stream';
  13. import { z } from 'zod/v4';
  14. import type { ZodRawShape } from 'zod';
  15. import type { ZodRawShape as ZodRawShape_2 } from 'zod/v4';
  16. export declare class AbortError extends Error {
  17. }
  18. /**
  19. * Information about the logged in user's account.
  20. */
  21. export declare type AccountInfo = {
  22. email?: string;
  23. organization?: string;
  24. subscriptionType?: string;
  25. tokenSource?: string;
  26. apiKeySource?: string;
  27. /**
  28. * Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).
  29. */
  30. apiProvider?: 'firstParty' | 'bedrock' | 'vertex' | 'foundry';
  31. };
  32. /**
  33. * Definition for a custom subagent that can be invoked via the Agent tool.
  34. */
  35. export declare type AgentDefinition = {
  36. /**
  37. * Natural language description of when to use this agent
  38. */
  39. description: string;
  40. /**
  41. * Array of allowed tool names. If omitted, inherits all tools from parent
  42. */
  43. tools?: string[];
  44. /**
  45. * Array of tool names to explicitly disallow for this agent
  46. */
  47. disallowedTools?: string[];
  48. /**
  49. * The agent's system prompt
  50. */
  51. prompt: string;
  52. /**
  53. * Model alias (e.g. 'sonnet', 'opus', 'haiku') or full model ID (e.g. 'claude-opus-4-5'). If omitted or 'inherit', uses the main model
  54. */
  55. model?: string;
  56. mcpServers?: AgentMcpServerSpec[];
  57. /**
  58. * Experimental: Critical reminder added to system prompt
  59. */
  60. criticalSystemReminder_EXPERIMENTAL?: string;
  61. /**
  62. * Array of skill names to preload into the agent context
  63. */
  64. skills?: string[];
  65. /**
  66. * Auto-submitted as the first user turn when this agent is the main thread agent. Slash commands are processed. Prepended to any user-provided prompt.
  67. */
  68. initialPrompt?: string;
  69. /**
  70. * Maximum number of agentic turns (API round-trips) before stopping
  71. */
  72. maxTurns?: number;
  73. /**
  74. * Run this agent as a background task (non-blocking, fire-and-forget) when invoked
  75. */
  76. background?: boolean;
  77. /**
  78. * Scope for auto-loading agent memory files. 'user' - ~/.claude/agent-memory/<agentType>/, 'project' - .claude/agent-memory/<agentType>/, 'local' - .claude/agent-memory-local/<agentType>/
  79. */
  80. memory?: 'user' | 'project' | 'local';
  81. /**
  82. * Reasoning effort level for this agent. Either a named level or an integer
  83. */
  84. effort?: ('low' | 'medium' | 'high' | 'max') | number;
  85. /**
  86. * Permission mode controlling how tool executions are handled
  87. */
  88. permissionMode?: PermissionMode;
  89. };
  90. /**
  91. * Information about an available subagent that can be invoked via the Task tool.
  92. */
  93. export declare type AgentInfo = {
  94. /**
  95. * Agent type identifier (e.g., "Explore")
  96. */
  97. name: string;
  98. /**
  99. * Description of when to use this agent
  100. */
  101. description: string;
  102. /**
  103. * Model alias this agent uses. If omitted, inherits the parent's model
  104. */
  105. model?: string;
  106. };
  107. export declare type AgentMcpServerSpec = string | Record<string, McpServerConfigForProcessTransport>;
  108. export declare type AnyZodRawShape = ZodRawShape | ZodRawShape_2;
  109. export declare type ApiKeySource = 'user' | 'project' | 'org' | 'temporary' | 'oauth';
  110. export declare type AsyncHookJSONOutput = {
  111. async: true;
  112. asyncTimeout?: number;
  113. };
  114. export declare type BaseHookInput = {
  115. session_id: string;
  116. transcript_path: string;
  117. cwd: string;
  118. permission_mode?: string;
  119. /**
  120. * Subagent identifier. Present only when the hook fires from within a subagent (e.g., a tool called by an AgentTool worker). Absent for the main thread, even in --agent sessions. Use this field (not agent_type) to distinguish subagent calls from main-thread calls.
  121. */
  122. agent_id?: string;
  123. /**
  124. * Agent type name (e.g., "general-purpose", "code-reviewer"). Present when the hook fires from within a subagent (alongside agent_id), or on the main thread of a session started with --agent (without agent_id).
  125. */
  126. agent_type?: string;
  127. };
  128. export declare type BaseOutputFormat = {
  129. type: OutputFormatType;
  130. };
  131. /**
  132. * Permission callback function for controlling tool usage.
  133. * Called before each tool execution to determine if it should be allowed.
  134. */
  135. export declare type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
  136. /** Signaled if the operation should be aborted. */
  137. signal: AbortSignal;
  138. /**
  139. * Suggestions for updating permissions so that the user will not be
  140. * prompted again for this tool during this session.
  141. *
  142. * Typically if presenting the user an option 'always allow' or similar,
  143. * then this full set of suggestions should be returned as the
  144. * `updatedPermissions` in the PermissionResult.
  145. */
  146. suggestions?: PermissionUpdate[];
  147. /**
  148. * The file path that triggered the permission request, if applicable.
  149. * For example, when a Bash command tries to access a path outside allowed directories.
  150. */
  151. blockedPath?: string;
  152. /** Explains why this permission request was triggered. */
  153. decisionReason?: string;
  154. /**
  155. * Full permission prompt sentence rendered by the bridge (e.g.
  156. * "Claude wants to read foo.txt"). Use this as the primary prompt
  157. * text when present instead of reconstructing from toolName+input.
  158. */
  159. title?: string;
  160. /**
  161. * Short noun phrase for the tool action (e.g. "Read file"), suitable
  162. * for button labels or compact UI.
  163. */
  164. displayName?: string;
  165. /**
  166. * Human-readable subtitle from the bridge (e.g. "Claude will have
  167. * read and write access to files in ~/Downloads").
  168. */
  169. description?: string;
  170. /**
  171. * Unique identifier for this specific tool call within the assistant message.
  172. * Multiple tool calls in the same assistant message will have different toolUseIDs.
  173. */
  174. toolUseID: string;
  175. /** If running within the context of a sub-agent, the sub-agent's ID. */
  176. agentID?: string;
  177. }) => Promise<PermissionResult>;
  178. export declare type ConfigChangeHookInput = BaseHookInput & {
  179. hook_event_name: 'ConfigChange';
  180. source: 'user_settings' | 'project_settings' | 'local_settings' | 'policy_settings' | 'skills';
  181. file_path?: string;
  182. };
  183. /**
  184. * Config scope for settings.
  185. */
  186. export declare type ConfigScope = 'local' | 'user' | 'project';
  187. declare type ControlErrorResponse = {
  188. subtype: 'error';
  189. request_id: string;
  190. error: string;
  191. pending_permission_requests?: SDKControlRequest[];
  192. };
  193. declare type ControlResponse = {
  194. subtype: 'success';
  195. request_id: string;
  196. response?: Record<string, unknown>;
  197. };
  198. declare namespace coreTypes {
  199. export {
  200. SandboxFilesystemConfig,
  201. SandboxIgnoreViolations,
  202. SandboxNetworkConfig,
  203. SandboxSettings,
  204. NonNullableUsage,
  205. HOOK_EVENTS,
  206. EXIT_REASONS,
  207. AccountInfo,
  208. AgentDefinition,
  209. AgentInfo,
  210. AgentMcpServerSpec,
  211. ApiKeySource,
  212. AsyncHookJSONOutput,
  213. BaseHookInput,
  214. BaseOutputFormat,
  215. ConfigChangeHookInput,
  216. ConfigScope,
  217. CwdChangedHookInput,
  218. CwdChangedHookSpecificOutput,
  219. ElicitationHookInput,
  220. ElicitationHookSpecificOutput,
  221. ElicitationResultHookInput,
  222. ElicitationResultHookSpecificOutput,
  223. ExitReason,
  224. FastModeState,
  225. FileChangedHookInput,
  226. FileChangedHookSpecificOutput,
  227. HookEvent,
  228. HookInput,
  229. HookJSONOutput,
  230. InstructionsLoadedHookInput,
  231. JsonSchemaOutputFormat,
  232. McpClaudeAIProxyServerConfig,
  233. McpHttpServerConfig,
  234. McpSSEServerConfig,
  235. McpSdkServerConfig,
  236. McpServerConfigForProcessTransport,
  237. McpServerStatusConfig,
  238. McpServerStatus,
  239. McpSetServersResult,
  240. McpStdioServerConfig,
  241. ModelInfo,
  242. ModelUsage,
  243. NotificationHookInput,
  244. NotificationHookSpecificOutput,
  245. OutputFormat,
  246. OutputFormatType,
  247. PermissionBehavior,
  248. PermissionDecisionClassification,
  249. PermissionDeniedHookInput,
  250. PermissionDeniedHookSpecificOutput,
  251. PermissionMode,
  252. PermissionRequestHookInput,
  253. PermissionRequestHookSpecificOutput,
  254. PermissionResult,
  255. PermissionRuleValue,
  256. PermissionUpdateDestination,
  257. PermissionUpdate,
  258. PostCompactHookInput,
  259. PostToolUseFailureHookInput,
  260. PostToolUseFailureHookSpecificOutput,
  261. PostToolUseHookInput,
  262. PostToolUseHookSpecificOutput,
  263. PreCompactHookInput,
  264. PreToolUseHookInput,
  265. PreToolUseHookSpecificOutput,
  266. PromptRequestOption,
  267. PromptRequest,
  268. PromptResponse,
  269. RewindFilesResult,
  270. SDKAPIRetryMessage,
  271. SDKAssistantMessageError,
  272. SDKAssistantMessage,
  273. SDKAuthStatusMessage,
  274. SDKCompactBoundaryMessage,
  275. SDKElicitationCompleteMessage,
  276. SDKFilesPersistedEvent,
  277. SDKHookProgressMessage,
  278. SDKHookResponseMessage,
  279. SDKHookStartedMessage,
  280. SDKLocalCommandOutputMessage,
  281. SDKMessage,
  282. SDKPartialAssistantMessage,
  283. SDKPermissionDenial,
  284. SDKPromptSuggestionMessage,
  285. SDKRateLimitEvent,
  286. SDKRateLimitInfo,
  287. SDKResultError,
  288. SDKResultMessage,
  289. SDKResultSuccess,
  290. SDKSessionInfo,
  291. SDKSessionStateChangedMessage,
  292. SDKStatusMessage,
  293. SDKStatus,
  294. SDKSystemMessage,
  295. SDKTaskNotificationMessage,
  296. SDKTaskProgressMessage,
  297. SDKTaskStartedMessage,
  298. SDKToolProgressMessage,
  299. SDKToolUseSummaryMessage,
  300. SDKUserMessageReplay,
  301. SDKUserMessage,
  302. SdkBeta,
  303. SdkPluginConfig,
  304. SessionEndHookInput,
  305. SessionStartHookInput,
  306. SessionStartHookSpecificOutput,
  307. SettingSource,
  308. SetupHookInput,
  309. SetupHookSpecificOutput,
  310. SlashCommand,
  311. StopFailureHookInput,
  312. StopHookInput,
  313. SubagentStartHookInput,
  314. SubagentStartHookSpecificOutput,
  315. SubagentStopHookInput,
  316. SyncHookJSONOutput,
  317. TaskCompletedHookInput,
  318. TaskCreatedHookInput,
  319. TeammateIdleHookInput,
  320. ThinkingAdaptive,
  321. ThinkingConfig,
  322. ThinkingDisabled,
  323. ThinkingEnabled,
  324. UserPromptSubmitHookInput,
  325. UserPromptSubmitHookSpecificOutput,
  326. WorktreeCreateHookInput,
  327. WorktreeCreateHookSpecificOutput,
  328. WorktreeRemoveHookInput
  329. }
  330. }
  331. /**
  332. * Creates an MCP server instance that can be used with the SDK transport.
  333. * This allows SDK users to define custom tools that run in the same process.
  334. *
  335. * If your SDK MCP calls will run longer than 60s, override CLAUDE_CODE_STREAM_CLOSE_TIMEOUT
  336. */
  337. export declare function createSdkMcpServer(_options: CreateSdkMcpServerOptions): McpSdkServerConfigWithInstance;
  338. declare type CreateSdkMcpServerOptions = {
  339. name: string;
  340. version?: string;
  341. tools?: Array<SdkMcpToolDefinition<any>>;
  342. };
  343. export declare type CwdChangedHookInput = BaseHookInput & {
  344. hook_event_name: 'CwdChanged';
  345. old_cwd: string;
  346. new_cwd: string;
  347. };
  348. export declare type CwdChangedHookSpecificOutput = {
  349. hookEventName: 'CwdChanged';
  350. watchPaths?: string[];
  351. };
  352. /**
  353. * Effort level for controlling how much thinking/reasoning Claude applies.
  354. *
  355. * - `'low'` — Minimal thinking, fastest responses
  356. * - `'medium'` — Moderate thinking
  357. * - `'high'` — Deep reasoning (default)
  358. * - `'max'` — Maximum effort (select models only)
  359. */
  360. export declare type EffortLevel = 'low' | 'medium' | 'high' | 'max';
  361. /**
  362. * Hook input for the Elicitation event. Fired when an MCP server requests user input. Hooks can auto-respond (accept/decline) instead of showing the dialog.
  363. */
  364. export declare type ElicitationHookInput = BaseHookInput & {
  365. hook_event_name: 'Elicitation';
  366. mcp_server_name: string;
  367. message: string;
  368. mode?: 'form' | 'url';
  369. url?: string;
  370. elicitation_id?: string;
  371. requested_schema?: Record<string, unknown>;
  372. };
  373. /**
  374. * Hook-specific output for the Elicitation event. Return this to programmatically accept or decline an MCP elicitation request.
  375. */
  376. export declare type ElicitationHookSpecificOutput = {
  377. hookEventName: 'Elicitation';
  378. action?: 'accept' | 'decline' | 'cancel';
  379. content?: Record<string, unknown>;
  380. };
  381. /**
  382. * Elicitation request from an MCP server, asking the SDK consumer for user input.
  383. */
  384. export declare type ElicitationRequest = {
  385. /** Name of the MCP server requesting elicitation */
  386. serverName: string;
  387. /** Message to display to the user */
  388. message: string;
  389. /** Elicitation mode: 'form' for structured input, 'url' for browser-based auth */
  390. mode?: 'form' | 'url';
  391. /** URL to open (only for 'url' mode) */
  392. url?: string;
  393. /** Elicitation ID for correlating URL elicitations with completion notifications (URL mode only) */
  394. elicitationId?: string;
  395. /** JSON Schema for the requested input (only for 'form' mode) */
  396. requestedSchema?: Record<string, unknown>;
  397. };
  398. /**
  399. * Elicitation response from the SDK consumer.
  400. * Re-exported from the MCP SDK for convenience.
  401. */
  402. export declare type ElicitationResult = ElicitResult;
  403. /**
  404. * Hook input for the ElicitationResult event. Fired after the user responds to an MCP elicitation. Hooks can observe or override the response before it is sent to the server.
  405. */
  406. export declare type ElicitationResultHookInput = BaseHookInput & {
  407. hook_event_name: 'ElicitationResult';
  408. mcp_server_name: string;
  409. elicitation_id?: string;
  410. mode?: 'form' | 'url';
  411. action: 'accept' | 'decline' | 'cancel';
  412. content?: Record<string, unknown>;
  413. };
  414. /**
  415. * Hook-specific output for the ElicitationResult event. Return this to override the action or content before the response is sent to the MCP server.
  416. */
  417. export declare type ElicitationResultHookSpecificOutput = {
  418. hookEventName: 'ElicitationResult';
  419. action?: 'accept' | 'decline' | 'cancel';
  420. content?: Record<string, unknown>;
  421. };
  422. export declare const EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];
  423. export declare type ExitReason = 'clear' | 'resume' | 'logout' | 'prompt_input_exit' | 'other' | 'bypass_permissions_disabled';
  424. /**
  425. * Fast mode state: off, in cooldown after rate limit, or actively enabled.
  426. */
  427. export declare type FastModeState = 'off' | 'cooldown' | 'on';
  428. export declare type FileChangedHookInput = BaseHookInput & {
  429. hook_event_name: 'FileChanged';
  430. file_path: string;
  431. event: 'change' | 'add' | 'unlink';
  432. };
  433. export declare type FileChangedHookSpecificOutput = {
  434. hookEventName: 'FileChanged';
  435. watchPaths?: string[];
  436. };
  437. /**
  438. * Fork a session into a new branch with fresh UUIDs.
  439. *
  440. * Copies transcript messages from the source session into a new session file,
  441. * remapping every message UUID and preserving the parentUuid chain. Supports
  442. * `upToMessageId` for branching from a specific point in the conversation.
  443. *
  444. * Forked sessions start without undo history (file-history snapshots are not
  445. * copied).
  446. *
  447. * @param sessionId - UUID of the source session
  448. * @param options - `{ dir?, upToMessageId?, title? }`
  449. * @returns `{ sessionId }` — UUID of the new forked session
  450. */
  451. export declare function forkSession(_sessionId: string, _options?: ForkSessionOptions): Promise<ForkSessionResult>;
  452. /**
  453. * Options for forking a session into a new branch.
  454. */
  455. export declare type ForkSessionOptions = SessionMutationOptions & {
  456. /** Slice transcript up to this message UUID (inclusive). If omitted, full copy. */
  457. upToMessageId?: string;
  458. /** Custom title for the fork. If omitted, derives from original title + " (fork)". */
  459. title?: string;
  460. };
  461. /**
  462. * Result of a fork operation.
  463. */
  464. export declare type ForkSessionResult = {
  465. /** New session UUID. Resumable via `resumeSession(sessionId)`. */
  466. sessionId: string;
  467. };
  468. /**
  469. * Reads metadata for a single session by ID. Unlike `listSessions`, this only
  470. * reads the single session file rather than every session in the project.
  471. * Returns undefined if the session file is not found, is a sidechain session,
  472. * or has no extractable summary.
  473. *
  474. * @param sessionId - UUID of the session
  475. * @param options - `{ dir?: string }` project path; omit to search all project directories
  476. */
  477. export declare function getSessionInfo(_sessionId: string, _options?: GetSessionInfoOptions): Promise<SDKSessionInfo | undefined>;
  478. /**
  479. * Options for getSessionInfo.
  480. */
  481. export declare type GetSessionInfoOptions = {
  482. /**
  483. * Project directory path (same semantics as `listSessions({ dir })`).
  484. * When omitted, all project directories are searched for the session file.
  485. */
  486. dir?: string;
  487. };
  488. /**
  489. * Reads a session's conversation messages from its JSONL transcript file.
  490. *
  491. * Parses the transcript, builds the conversation chain via parentUuid links,
  492. * and returns user/assistant messages in chronological order. Set
  493. * `includeSystemMessages: true` in options to also include system messages.
  494. *
  495. * @param sessionId - UUID of the session to read
  496. * @param options - Optional dir, limit, offset, and includeSystemMessages
  497. * @returns Array of messages, or empty array if session not found
  498. */
  499. export declare function getSessionMessages(_sessionId: string, _options?: GetSessionMessagesOptions): Promise<SessionMessage[]>;
  500. /**
  501. * Options for retrieving session messages.
  502. */
  503. export declare type GetSessionMessagesOptions = {
  504. /** Project directory to find the session in. If omitted, searches all projects. */
  505. dir?: string;
  506. /** Maximum number of messages to return. */
  507. limit?: number;
  508. /** Number of messages to skip from the start. */
  509. offset?: number;
  510. /**
  511. * When true, include system messages (e.g., compact boundaries, informational
  512. * notices) in the returned list alongside user/assistant messages.
  513. * Defaults to false for backwards compatibility.
  514. */
  515. includeSystemMessages?: boolean;
  516. };
  517. export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged"];
  518. /**
  519. * Hook callback function for responding to events during execution.
  520. */
  521. export declare type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
  522. signal: AbortSignal;
  523. }) => Promise<HookJSONOutput>;
  524. /**
  525. * Hook callback matcher containing hook callbacks and optional pattern matching.
  526. */
  527. export declare interface HookCallbackMatcher {
  528. matcher?: string;
  529. hooks: HookCallback[];
  530. /** Timeout in seconds for all hooks in this matcher */
  531. timeout?: number;
  532. }
  533. export declare type HookEvent = 'PreToolUse' | 'PostToolUse' | 'PostToolUseFailure' | 'Notification' | 'UserPromptSubmit' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'StopFailure' | 'SubagentStart' | 'SubagentStop' | 'PreCompact' | 'PostCompact' | 'PermissionRequest' | 'PermissionDenied' | 'Setup' | 'TeammateIdle' | 'TaskCreated' | 'TaskCompleted' | 'Elicitation' | 'ElicitationResult' | 'ConfigChange' | 'WorktreeCreate' | 'WorktreeRemove' | 'InstructionsLoaded' | 'CwdChanged' | 'FileChanged';
  534. export declare type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | PermissionDeniedHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | StopFailureHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput | PostCompactHookInput | PermissionRequestHookInput | SetupHookInput | TeammateIdleHookInput | TaskCreatedHookInput | TaskCompletedHookInput | ElicitationHookInput | ElicitationResultHookInput | ConfigChangeHookInput | InstructionsLoadedHookInput | WorktreeCreateHookInput | WorktreeRemoveHookInput | CwdChangedHookInput | FileChangedHookInput;
  535. export declare type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
  536. export declare type InferShape<T extends AnyZodRawShape> = {
  537. [K in keyof T]: T[K] extends {
  538. _output: infer O;
  539. } ? O : never;
  540. } & {};
  541. export declare type InstructionsLoadedHookInput = BaseHookInput & {
  542. hook_event_name: 'InstructionsLoaded';
  543. file_path: string;
  544. memory_type: 'User' | 'Project' | 'Local' | 'Managed';
  545. load_reason: 'session_start' | 'nested_traversal' | 'path_glob_match' | 'include' | 'compact';
  546. globs?: string[];
  547. trigger_file_path?: string;
  548. parent_file_path?: string;
  549. };
  550. export declare type JsonSchemaOutputFormat = {
  551. type: 'json_schema';
  552. schema: Record<string, unknown>;
  553. };
  554. /**
  555. * List sessions with metadata.
  556. *
  557. * When `dir` is provided, returns sessions for that project directory
  558. * and its git worktrees. When omitted, returns sessions across all
  559. * projects.
  560. *
  561. * Use `limit` and `offset` for pagination.
  562. *
  563. * @example
  564. * ```typescript
  565. * // List sessions for a specific project
  566. * const sessions = await listSessions({ dir: '/path/to/project' })
  567. *
  568. * // Paginate
  569. * const page1 = await listSessions({ limit: 50 })
  570. * const page2 = await listSessions({ limit: 50, offset: 50 })
  571. * ```
  572. */
  573. export declare function listSessions(_options?: ListSessionsOptions): Promise<SDKSessionInfo[]>;
  574. /**
  575. * Options for listing sessions.
  576. */
  577. export declare type ListSessionsOptions = {
  578. /**
  579. * Directory to list sessions for. When provided, returns sessions for
  580. * this project directory (and optionally its git worktrees). When omitted,
  581. * returns sessions across all projects.
  582. */
  583. dir?: string;
  584. /** Maximum number of sessions to return. */
  585. limit?: number;
  586. /**
  587. * Number of sessions to skip from the start of the sorted result set.
  588. * Use with `limit` for pagination. Defaults to 0.
  589. */
  590. offset?: number;
  591. /**
  592. * When `dir` is provided and the directory is inside a git repository,
  593. * include sessions from all git worktree paths. Defaults to `true`.
  594. */
  595. includeWorktrees?: boolean;
  596. };
  597. export declare type McpClaudeAIProxyServerConfig = {
  598. type: 'claudeai-proxy';
  599. url: string;
  600. id: string;
  601. };
  602. export declare type McpHttpServerConfig = {
  603. type: 'http';
  604. url: string;
  605. headers?: Record<string, string>;
  606. };
  607. export declare type McpSdkServerConfig = {
  608. type: 'sdk';
  609. name: string;
  610. };
  611. /**
  612. * MCP SDK server config with an actual McpServer instance.
  613. * Not serializable - contains a live McpServer object.
  614. */
  615. export declare type McpSdkServerConfigWithInstance = McpSdkServerConfig & {
  616. instance: McpServer;
  617. };
  618. /**
  619. * Union of all MCP server config types, including those with non-serializable instances.
  620. */
  621. export declare type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfigWithInstance;
  622. export declare type McpServerConfigForProcessTransport = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfig;
  623. /**
  624. * Status information for an MCP server connection.
  625. */
  626. export declare type McpServerStatus = {
  627. /**
  628. * Server name as configured
  629. */
  630. name: string;
  631. /**
  632. * Current connection status
  633. */
  634. status: 'connected' | 'failed' | 'needs-auth' | 'pending' | 'disabled';
  635. /**
  636. * Server information (available when connected)
  637. */
  638. serverInfo?: {
  639. name: string;
  640. version: string;
  641. };
  642. /**
  643. * Error message (available when status is 'failed')
  644. */
  645. error?: string;
  646. /**
  647. * Server configuration (includes URL for HTTP/SSE servers)
  648. */
  649. config?: McpServerStatusConfig;
  650. /**
  651. * Configuration scope (e.g., project, user, local, claudeai, managed)
  652. */
  653. scope?: string;
  654. /**
  655. * Tools provided by this server (available when connected)
  656. */
  657. tools?: {
  658. name: string;
  659. description?: string;
  660. annotations?: {
  661. readOnly?: boolean;
  662. destructive?: boolean;
  663. openWorld?: boolean;
  664. };
  665. }[];
  666. };
  667. export declare type McpServerStatusConfig = McpServerConfigForProcessTransport | McpClaudeAIProxyServerConfig;
  668. /**
  669. * Result of a setMcpServers operation.
  670. */
  671. export declare type McpSetServersResult = {
  672. /**
  673. * Names of servers that were added
  674. */
  675. added: string[];
  676. /**
  677. * Names of servers that were removed
  678. */
  679. removed: string[];
  680. /**
  681. * Map of server names to error messages for servers that failed to connect
  682. */
  683. errors: Record<string, string>;
  684. };
  685. export declare type McpSSEServerConfig = {
  686. type: 'sse';
  687. url: string;
  688. headers?: Record<string, string>;
  689. };
  690. export declare type McpStdioServerConfig = {
  691. type?: 'stdio';
  692. command: string;
  693. args?: string[];
  694. env?: Record<string, string>;
  695. };
  696. /**
  697. * Information about an available model.
  698. */
  699. export declare type ModelInfo = {
  700. /**
  701. * Model identifier to use in API calls
  702. */
  703. value: string;
  704. /**
  705. * Human-readable display name
  706. */
  707. displayName: string;
  708. /**
  709. * Description of the model's capabilities
  710. */
  711. description: string;
  712. /**
  713. * Whether this model supports effort levels
  714. */
  715. supportsEffort?: boolean;
  716. /**
  717. * Available effort levels for this model
  718. */
  719. supportedEffortLevels?: ('low' | 'medium' | 'high' | 'max')[];
  720. /**
  721. * Whether this model supports adaptive thinking (Claude decides when and how much to think)
  722. */
  723. supportsAdaptiveThinking?: boolean;
  724. /**
  725. * Whether this model supports fast mode
  726. */
  727. supportsFastMode?: boolean;
  728. /**
  729. * Whether this model supports auto mode
  730. */
  731. supportsAutoMode?: boolean;
  732. };
  733. export declare type ModelUsage = {
  734. inputTokens: number;
  735. outputTokens: number;
  736. cacheReadInputTokens: number;
  737. cacheCreationInputTokens: number;
  738. webSearchRequests: number;
  739. costUSD: number;
  740. contextWindow: number;
  741. maxOutputTokens: number;
  742. };
  743. export declare type NonNullableUsage = {
  744. [K in keyof BetaUsage]: NonNullable<BetaUsage[K]>;
  745. };
  746. export declare type NotificationHookInput = BaseHookInput & {
  747. hook_event_name: 'Notification';
  748. message: string;
  749. title?: string;
  750. notification_type: string;
  751. };
  752. export declare type NotificationHookSpecificOutput = {
  753. hookEventName: 'Notification';
  754. additionalContext?: string;
  755. };
  756. /**
  757. * Callback for handling MCP elicitation requests.
  758. * Called when an MCP server requests user input and no hook handles it.
  759. */
  760. export declare type OnElicitation = (request: ElicitationRequest, options: {
  761. signal: AbortSignal;
  762. }) => Promise<ElicitationResult>;
  763. /**
  764. * Options for the query function.
  765. * Contains callbacks and other non-serializable fields.
  766. */
  767. export declare type Options = {
  768. /**
  769. * Controller for cancelling the query. When aborted, the query will stop
  770. * and clean up resources.
  771. */
  772. abortController?: AbortController;
  773. /**
  774. * Additional directories Claude can access beyond the current working directory.
  775. * Paths should be absolute.
  776. */
  777. additionalDirectories?: string[];
  778. /**
  779. * Agent name for the main thread. When specified, the agent's system prompt,
  780. * tool restrictions, and model will be applied to the main conversation.
  781. * The agent must be defined either in the `agents` option or in settings.
  782. *
  783. * This is equivalent to the `--agent` CLI flag.
  784. *
  785. * @example
  786. * ```typescript
  787. * agent: 'code-reviewer',
  788. * agents: {
  789. * 'code-reviewer': {
  790. * description: 'Reviews code for best practices',
  791. * prompt: 'You are a code reviewer...'
  792. * }
  793. * }
  794. * ```
  795. */
  796. agent?: string;
  797. /**
  798. * Programmatically define custom subagents that can be invoked via the Agent tool.
  799. * Keys are agent names, values are agent definitions.
  800. *
  801. * @example
  802. * ```typescript
  803. * agents: {
  804. * 'test-runner': {
  805. * description: 'Runs tests and reports results',
  806. * prompt: 'You are a test runner...',
  807. * tools: ['Read', 'Grep', 'Glob', 'Bash']
  808. * }
  809. * }
  810. * ```
  811. */
  812. agents?: Record<string, AgentDefinition>;
  813. /**
  814. * List of tool names that are auto-allowed without prompting for permission.
  815. * These tools will execute automatically without asking the user for approval.
  816. * To restrict which tools are available, use the `tools` option instead.
  817. */
  818. allowedTools?: string[];
  819. /**
  820. * Custom permission handler for controlling tool usage. Called before each
  821. * tool execution to determine if it should be allowed, denied, or prompt the user.
  822. */
  823. canUseTool?: CanUseTool;
  824. /**
  825. * Continue the most recent conversation in the current directory instead of starting a new one.
  826. * Mutually exclusive with `resume`.
  827. */
  828. continue?: boolean;
  829. /**
  830. * Current working directory for the session. Defaults to `process.cwd()`.
  831. */
  832. cwd?: string;
  833. /**
  834. * List of tool names that are disallowed. These tools will be removed
  835. * from the model's context and cannot be used, even if they would
  836. * otherwise be allowed.
  837. */
  838. disallowedTools?: string[];
  839. /**
  840. * Specify the base set of available built-in tools.
  841. * - `string[]` - Array of specific tool names (e.g., `['Bash', 'Read', 'Edit']`)
  842. * - `[]` (empty array) - Disable all built-in tools
  843. * - `{ type: 'preset'; preset: 'claude_code' }` - Use all default Claude Code tools
  844. */
  845. tools?: string[] | {
  846. type: 'preset';
  847. preset: 'claude_code';
  848. };
  849. /**
  850. * Environment variables to pass to the Claude Code process.
  851. * Defaults to `process.env`.
  852. *
  853. * SDK consumers can identify their app/library to include in the User-Agent header by setting:
  854. * - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
  855. *
  856. * @example
  857. * ```typescript
  858. * env: { CLAUDE_AGENT_SDK_CLIENT_APP: 'my-app/1.0.0' }
  859. * ```
  860. */
  861. env?: {
  862. [envVar: string]: string | undefined;
  863. };
  864. /**
  865. * JavaScript runtime to use for executing Claude Code.
  866. * Auto-detected if not specified.
  867. */
  868. executable?: 'bun' | 'deno' | 'node';
  869. /**
  870. * Additional arguments to pass to the JavaScript runtime executable.
  871. */
  872. executableArgs?: string[];
  873. /**
  874. * Additional CLI arguments to pass to Claude Code.
  875. * Keys are argument names (without --), values are argument values.
  876. * Use `null` for boolean flags.
  877. */
  878. extraArgs?: Record<string, string | null>;
  879. /**
  880. * Fallback model to use if the primary model fails or is unavailable.
  881. */
  882. fallbackModel?: string;
  883. /**
  884. * Enable file checkpointing to track file changes during the session.
  885. * When enabled, files can be rewound to their state at any user message
  886. * using `Query.rewindFiles()`.
  887. *
  888. * File checkpointing creates backups of files before they are modified,
  889. * allowing you to restore them to previous states.
  890. */
  891. enableFileCheckpointing?: boolean;
  892. /**
  893. * Per-tool configuration for built-in tools.
  894. *
  895. * @example
  896. * ```typescript
  897. * toolConfig: {
  898. * askUserQuestion: { previewFormat: 'html' }
  899. * }
  900. * ```
  901. */
  902. toolConfig?: ToolConfig;
  903. /**
  904. * When true, resumed sessions will fork to a new session ID rather than
  905. * continuing the previous session. Use with `resume`.
  906. */
  907. forkSession?: boolean;
  908. /**
  909. * Enable beta features. Currently supported:
  910. * - `'context-1m-2025-08-07'` - Enable 1M token context window (Sonnet 4/4.5 only)
  911. *
  912. * @see https://docs.anthropic.com/en/api/beta-headers
  913. */
  914. betas?: SdkBeta[];
  915. /**
  916. * Hook callbacks for responding to various events during execution.
  917. * Hooks can modify behavior, add context, or implement custom logic.
  918. *
  919. * @example
  920. * ```typescript
  921. * hooks: {
  922. * PreToolUse: [{
  923. * hooks: [async (input) => ({ continue: true })]
  924. * }]
  925. * }
  926. * ```
  927. */
  928. hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
  929. /**
  930. * Callback for handling MCP elicitation requests.
  931. * Called when an MCP server requests user input (form fields, URL auth, etc.)
  932. * and no hook handles the request first.
  933. *
  934. * If not provided, elicitation requests that aren't handled by hooks will
  935. * be declined automatically.
  936. *
  937. * @example
  938. * ```typescript
  939. * onElicitation: async (request) => {
  940. * if (request.mode === 'url') {
  941. * // Handle URL-based auth
  942. * return { action: 'accept' }
  943. * }
  944. * // Provide form values
  945. * return { action: 'accept', content: { name: 'Test' } }
  946. * }
  947. * ```
  948. */
  949. onElicitation?: OnElicitation;
  950. /**
  951. * When false, disables session persistence to disk. Sessions will not be
  952. * saved to ~/.claude/projects/ and cannot be resumed later. Useful for
  953. * ephemeral or automated workflows where session history is not needed.
  954. *
  955. * @default true
  956. */
  957. persistSession?: boolean;
  958. /**
  959. * Include hook lifecycle events in the output stream.
  960. * When true, `hook_started`, `hook_progress`, and `hook_response` system
  961. * messages will be emitted for all hook event types (PreToolUse, PostToolUse,
  962. * Stop, etc.). SessionStart and Setup hook events are always emitted
  963. * regardless of this setting.
  964. *
  965. * @default false
  966. */
  967. includeHookEvents?: boolean;
  968. /**
  969. * Include partial/streaming message events in the output.
  970. * When true, `SDKPartialAssistantMessage` events will be emitted during streaming.
  971. */
  972. includePartialMessages?: boolean;
  973. /**
  974. * Controls Claude's thinking/reasoning behavior.
  975. *
  976. * - `{ type: 'adaptive' }` — Claude decides when and how much to think (Opus 4.6+).
  977. * This is the default for models that support it.
  978. * - `{ type: 'enabled', budgetTokens: number }` — Fixed thinking token budget (older models)
  979. * - `{ type: 'disabled' }` — No extended thinking
  980. *
  981. * When set, takes precedence over the deprecated `maxThinkingTokens`.
  982. *
  983. * @see https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking
  984. */
  985. thinking?: ThinkingConfig;
  986. /**
  987. * Controls how much effort Claude puts into its response.
  988. * Works with adaptive thinking to guide thinking depth.
  989. *
  990. * - `'low'` — Minimal thinking, fastest responses
  991. * - `'medium'` — Moderate thinking
  992. * - `'high'` — Deep reasoning (default)
  993. * - `'max'` — Maximum effort (Opus 4.6 only)
  994. *
  995. * @see https://docs.anthropic.com/en/docs/build-with-claude/effort
  996. */
  997. effort?: EffortLevel;
  998. /**
  999. * Maximum number of tokens the model can use for its thinking/reasoning process.
  1000. * Helps control cost and latency for complex tasks.
  1001. *
  1002. * @deprecated Use `thinking` instead. On Opus 4.6, this is treated as on/off
  1003. * (0 = disabled, any other value = adaptive). For explicit control, use
  1004. * `thinking: { type: 'adaptive' }` or `thinking: { type: 'enabled', budgetTokens: N }`.
  1005. */
  1006. maxThinkingTokens?: number;
  1007. /**
  1008. * Maximum number of conversation turns before the query stops.
  1009. * A turn consists of a user message and assistant response.
  1010. */
  1011. maxTurns?: number;
  1012. /**
  1013. * Maximum budget in USD for the query. The query will stop if this
  1014. * budget is exceeded, returning an `error_max_budget_usd` result.
  1015. */
  1016. maxBudgetUsd?: number;
  1017. /**
  1018. * API-side task budget in tokens. When set, the model is made aware of
  1019. * its remaining token budget so it can pace tool use and wrap up before
  1020. * the limit. Sent as `output_config.task_budget` with the
  1021. * `task-budgets-2026-03-13` beta header.
  1022. * @alpha
  1023. */
  1024. taskBudget?: {
  1025. total: number;
  1026. };
  1027. /**
  1028. * MCP (Model Context Protocol) server configurations.
  1029. * Keys are server names, values are server configurations.
  1030. *
  1031. * @example
  1032. * ```typescript
  1033. * mcpServers: {
  1034. * 'my-server': {
  1035. * command: 'node',
  1036. * args: ['./my-mcp-server.js']
  1037. * }
  1038. * }
  1039. * ```
  1040. */
  1041. mcpServers?: Record<string, McpServerConfig>;
  1042. /**
  1043. * Claude model to use. Defaults to the CLI default model.
  1044. * Examples: 'claude-sonnet-4-6', 'claude-opus-4-6'
  1045. */
  1046. model?: string;
  1047. /**
  1048. * Output format configuration for structured responses.
  1049. * When specified, the agent will return structured data matching the schema.
  1050. *
  1051. * @example
  1052. * ```typescript
  1053. * outputFormat: {
  1054. * type: 'json_schema',
  1055. * schema: { type: 'object', properties: { result: { type: 'string' } } }
  1056. * }
  1057. * ```
  1058. */
  1059. outputFormat?: OutputFormat;
  1060. /**
  1061. * Path to the Claude Code executable. Uses the built-in executable if not specified.
  1062. */
  1063. pathToClaudeCodeExecutable?: string;
  1064. /**
  1065. * Permission mode for the session.
  1066. * - `'default'` - Standard permission behavior, prompts for dangerous operations
  1067. * - `'acceptEdits'` - Auto-accept file edit operations
  1068. * - `'bypassPermissions'` - Bypass all permission checks (requires `allowDangerouslySkipPermissions`)
  1069. * - `'plan'` - Planning mode, no execution of tools
  1070. * - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
  1071. */
  1072. permissionMode?: PermissionMode;
  1073. /**
  1074. * Must be set to `true` when using `permissionMode: 'bypassPermissions'`.
  1075. * This is a safety measure to ensure intentional bypassing of permissions.
  1076. */
  1077. allowDangerouslySkipPermissions?: boolean;
  1078. /**
  1079. * MCP tool name to use for permission prompts. When set, permission requests
  1080. * will be routed through this MCP tool instead of the default handler.
  1081. */
  1082. permissionPromptToolName?: string;
  1083. /**
  1084. * Load plugins for this session. Plugins provide custom commands, agents,
  1085. * skills, and hooks that extend Claude Code's capabilities.
  1086. *
  1087. * Currently only local plugins are supported via the 'local' type.
  1088. *
  1089. * @example
  1090. * ```typescript
  1091. * plugins: [
  1092. * { type: 'local', path: './my-plugin' },
  1093. * { type: 'local', path: '/absolute/path/to/plugin' }
  1094. * ]
  1095. * ```
  1096. */
  1097. plugins?: SdkPluginConfig[];
  1098. /**
  1099. * Enable prompt suggestions. When true, the agent emits a `prompt_suggestion`
  1100. * message after each turn with a predicted next user prompt.
  1101. *
  1102. * Delivery semantics:
  1103. * - At most one `prompt_suggestion` per turn; arrives after the `result` message.
  1104. * - Consumers must keep iterating the stream after `result` to receive it.
  1105. * - Suppressed on the first turn, after API errors, in plan mode, and by the
  1106. * `CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false` env var.
  1107. * - Suggestions piggyback on the parent's prompt cache, making them nearly free.
  1108. */
  1109. promptSuggestions?: boolean;
  1110. /**
  1111. * Enable periodic AI-generated progress summaries for running subagents. When
  1112. * true, the subagent's conversation is forked every ~30s to produce a short
  1113. * present-tense description (e.g. "Analyzing authentication module"), emitted
  1114. * on `task_progress` events via the `summary` field. The fork reuses the
  1115. * subagent's model and prompt cache, so cost is typically minimal.
  1116. *
  1117. * Applies to both foreground and background subagents. Defaults to false.
  1118. */
  1119. agentProgressSummaries?: boolean;
  1120. /**
  1121. * Session ID to resume. Loads the conversation history from the specified session.
  1122. */
  1123. resume?: string;
  1124. /**
  1125. * Use a specific session ID for the conversation instead of an auto-generated one.
  1126. * Must be a valid UUID. Cannot be used with `continue` or `resume` unless
  1127. * `forkSession` is also set (to specify a custom ID for the forked session).
  1128. */
  1129. sessionId?: string;
  1130. /**
  1131. * When resuming, only resume messages up to and including the message with this UUID.
  1132. * Use with `resume`. This allows you to resume from a specific point in the conversation.
  1133. * The message ID should be from `SDKAssistantMessage.uuid`.
  1134. */
  1135. resumeSessionAt?: string;
  1136. /**
  1137. * Sandbox settings for command execution isolation.
  1138. *
  1139. * When enabled, commands are executed in a sandboxed environment that restricts
  1140. * filesystem and network access. This provides an additional security layer.
  1141. *
  1142. * **Important:** Filesystem and network restrictions are configured via permission
  1143. * rules, not via these sandbox settings:
  1144. * - Filesystem access: Use `Read` and `Edit` permission rules
  1145. * - Network access: Use `WebFetch` permission rules
  1146. *
  1147. * These sandbox settings control sandbox behavior (enabled, auto-allow, etc.),
  1148. * while the actual access restrictions come from your permission configuration.
  1149. *
  1150. * @example Enable sandboxing with auto-allow
  1151. * ```typescript
  1152. * sandbox: {
  1153. * enabled: true,
  1154. * autoAllowBashIfSandboxed: true
  1155. * }
  1156. * ```
  1157. *
  1158. * @example Configure network options (not restrictions)
  1159. * ```typescript
  1160. * sandbox: {
  1161. * enabled: true,
  1162. * network: {
  1163. * allowLocalBinding: true,
  1164. * allowUnixSockets: ['/var/run/docker.sock']
  1165. * }
  1166. * }
  1167. * ```
  1168. *
  1169. * @see https://docs.anthropic.com/en/docs/claude-code/settings#sandbox-settings
  1170. */
  1171. sandbox?: SandboxSettings;
  1172. /**
  1173. * Additional settings to apply. Accepts either a path to a settings JSON file
  1174. * or a settings object. These are loaded into the "flag settings" layer,
  1175. * which has the highest priority among user-controlled settings.
  1176. *
  1177. * Equivalent to the `--settings` CLI flag.
  1178. *
  1179. * @example Inline settings object
  1180. * ```typescript
  1181. * settings: { model: 'claude-sonnet-4-6', permissions: { allow: ['Bash(*)'] } }
  1182. * ```
  1183. *
  1184. * @example Path to settings file
  1185. * ```typescript
  1186. * settings: '/path/to/settings.json'
  1187. * ```
  1188. */
  1189. settings?: string | Settings;
  1190. /**
  1191. * Control which filesystem settings to load.
  1192. * - `'user'` - Global user settings (`~/.claude/settings.json`)
  1193. * - `'project'` - Project settings (`.claude/settings.json`)
  1194. * - `'local'` - Local settings (`.claude/settings.local.json`)
  1195. *
  1196. * When omitted or empty, no filesystem settings are loaded (SDK isolation mode).
  1197. * Must include `'project'` to load CLAUDE.md files.
  1198. */
  1199. settingSources?: SettingSource[];
  1200. /**
  1201. * Enable debug mode for the Claude Code process.
  1202. * When true, enables verbose debug logging (equivalent to `--debug` CLI flag).
  1203. * Debug logs are written to a file (see `debugFile` option) or to stderr.
  1204. *
  1205. * You can also capture debug output via the `stderr` callback.
  1206. */
  1207. debug?: boolean;
  1208. /**
  1209. * Write debug logs to a specific file path.
  1210. * Implicitly enables debug mode. Equivalent to `--debug-file <path>` CLI flag.
  1211. */
  1212. debugFile?: string;
  1213. /**
  1214. * Callback for stderr output from the Claude Code process.
  1215. * Useful for debugging and logging.
  1216. */
  1217. stderr?: (data: string) => void;
  1218. /**
  1219. * Enforce strict validation of MCP server configurations.
  1220. * When true, invalid configurations will cause errors instead of warnings.
  1221. */
  1222. strictMcpConfig?: boolean;
  1223. /**
  1224. * System prompt configuration.
  1225. * - `string` - Use a custom system prompt
  1226. * - `{ type: 'preset', preset: 'claude_code' }` - Use Claude Code's default system prompt
  1227. * - `{ type: 'preset', preset: 'claude_code', append: '...' }` - Use default prompt with appended instructions
  1228. *
  1229. * @example Custom prompt
  1230. * ```typescript
  1231. * systemPrompt: 'You are a helpful coding assistant.'
  1232. * ```
  1233. *
  1234. * @example Default with additions
  1235. * ```typescript
  1236. * systemPrompt: {
  1237. * type: 'preset',
  1238. * preset: 'claude_code',
  1239. * append: 'Always explain your reasoning.'
  1240. * }
  1241. * ```
  1242. */
  1243. systemPrompt?: string | {
  1244. type: 'preset';
  1245. preset: 'claude_code';
  1246. append?: string;
  1247. };
  1248. /**
  1249. * Custom function to spawn the Claude Code process.
  1250. * Use this to run Claude Code in VMs, containers, or remote environments.
  1251. *
  1252. * When provided, this function is called instead of the default local spawn.
  1253. * The default behavior checks if the executable exists before spawning.
  1254. *
  1255. * @example
  1256. * ```typescript
  1257. * spawnClaudeCodeProcess: (options) => {
  1258. * // Custom spawn logic for VM execution
  1259. * // options contains: command, args, cwd, env, signal
  1260. * return myVMProcess; // Must satisfy SpawnedProcess interface
  1261. * }
  1262. * ```
  1263. */
  1264. spawnClaudeCodeProcess?: (options: SpawnOptions) => SpawnedProcess;
  1265. };
  1266. export declare type OutputFormat = JsonSchemaOutputFormat;
  1267. export declare type OutputFormatType = 'json_schema';
  1268. export declare type PermissionBehavior = 'allow' | 'deny' | 'ask';
  1269. /**
  1270. * Classification of this permission decision for telemetry. SDK hosts that prompt users (desktop apps, IDEs) should set this to reflect what actually happened: user_temporary for allow-once, user_permanent for always-allow (both the click and later cache hits), user_reject for deny. If unset, the CLI infers conservatively (temporary for allow, reject for deny). The vocabulary matches tool_decision OTel events (monitoring-usage docs).
  1271. */
  1272. export declare type PermissionDecisionClassification = 'user_temporary' | 'user_permanent' | 'user_reject';
  1273. export declare type PermissionDeniedHookInput = BaseHookInput & {
  1274. hook_event_name: 'PermissionDenied';
  1275. tool_name: string;
  1276. tool_input: unknown;
  1277. tool_use_id: string;
  1278. reason: string;
  1279. };
  1280. export declare type PermissionDeniedHookSpecificOutput = {
  1281. hookEventName: 'PermissionDenied';
  1282. retry?: boolean;
  1283. };
  1284. /**
  1285. * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
  1286. */
  1287. export declare type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk';
  1288. export declare type PermissionRequestHookInput = BaseHookInput & {
  1289. hook_event_name: 'PermissionRequest';
  1290. tool_name: string;
  1291. tool_input: unknown;
  1292. permission_suggestions?: PermissionUpdate[];
  1293. };
  1294. export declare type PermissionRequestHookSpecificOutput = {
  1295. hookEventName: 'PermissionRequest';
  1296. decision: {
  1297. behavior: 'allow';
  1298. updatedInput?: Record<string, unknown>;
  1299. updatedPermissions?: PermissionUpdate[];
  1300. } | {
  1301. behavior: 'deny';
  1302. message?: string;
  1303. interrupt?: boolean;
  1304. };
  1305. };
  1306. export declare type PermissionResult = {
  1307. behavior: 'allow';
  1308. updatedInput?: Record<string, unknown>;
  1309. updatedPermissions?: PermissionUpdate[];
  1310. toolUseID?: string;
  1311. decisionClassification?: PermissionDecisionClassification;
  1312. } | {
  1313. behavior: 'deny';
  1314. message: string;
  1315. interrupt?: boolean;
  1316. toolUseID?: string;
  1317. decisionClassification?: PermissionDecisionClassification;
  1318. };
  1319. export declare type PermissionRuleValue = {
  1320. toolName: string;
  1321. ruleContent?: string;
  1322. };
  1323. export declare type PermissionUpdate = {
  1324. type: 'addRules';
  1325. rules: PermissionRuleValue[];
  1326. behavior: PermissionBehavior;
  1327. destination: PermissionUpdateDestination;
  1328. } | {
  1329. type: 'replaceRules';
  1330. rules: PermissionRuleValue[];
  1331. behavior: PermissionBehavior;
  1332. destination: PermissionUpdateDestination;
  1333. } | {
  1334. type: 'removeRules';
  1335. rules: PermissionRuleValue[];
  1336. behavior: PermissionBehavior;
  1337. destination: PermissionUpdateDestination;
  1338. } | {
  1339. type: 'setMode';
  1340. mode: PermissionMode;
  1341. destination: PermissionUpdateDestination;
  1342. } | {
  1343. type: 'addDirectories';
  1344. directories: string[];
  1345. destination: PermissionUpdateDestination;
  1346. } | {
  1347. type: 'removeDirectories';
  1348. directories: string[];
  1349. destination: PermissionUpdateDestination;
  1350. };
  1351. export declare type PermissionUpdateDestination = 'userSettings' | 'projectSettings' | 'localSettings' | 'session' | 'cliArg';
  1352. export declare type PostCompactHookInput = BaseHookInput & {
  1353. hook_event_name: 'PostCompact';
  1354. trigger: 'manual' | 'auto';
  1355. /**
  1356. * The conversation summary produced by compaction
  1357. */
  1358. compact_summary: string;
  1359. };
  1360. export declare type PostToolUseFailureHookInput = BaseHookInput & {
  1361. hook_event_name: 'PostToolUseFailure';
  1362. tool_name: string;
  1363. tool_input: unknown;
  1364. tool_use_id: string;
  1365. error: string;
  1366. is_interrupt?: boolean;
  1367. };
  1368. export declare type PostToolUseFailureHookSpecificOutput = {
  1369. hookEventName: 'PostToolUseFailure';
  1370. additionalContext?: string;
  1371. };
  1372. export declare type PostToolUseHookInput = BaseHookInput & {
  1373. hook_event_name: 'PostToolUse';
  1374. tool_name: string;
  1375. tool_input: unknown;
  1376. tool_response: unknown;
  1377. tool_use_id: string;
  1378. };
  1379. export declare type PostToolUseHookSpecificOutput = {
  1380. hookEventName: 'PostToolUse';
  1381. additionalContext?: string;
  1382. updatedMCPToolOutput?: unknown;
  1383. };
  1384. export declare type PreCompactHookInput = BaseHookInput & {
  1385. hook_event_name: 'PreCompact';
  1386. trigger: 'manual' | 'auto';
  1387. custom_instructions: string | null;
  1388. };
  1389. export declare type PreToolUseHookInput = BaseHookInput & {
  1390. hook_event_name: 'PreToolUse';
  1391. tool_name: string;
  1392. tool_input: unknown;
  1393. tool_use_id: string;
  1394. };
  1395. export declare type PreToolUseHookSpecificOutput = {
  1396. hookEventName: 'PreToolUse';
  1397. permissionDecision?: PermissionBehavior;
  1398. permissionDecisionReason?: string;
  1399. updatedInput?: Record<string, unknown>;
  1400. additionalContext?: string;
  1401. };
  1402. export declare type PromptRequest = {
  1403. /**
  1404. * Request ID. Presence of this key marks the line as a prompt request.
  1405. */
  1406. prompt: string;
  1407. /**
  1408. * The prompt message to display to the user
  1409. */
  1410. message: string;
  1411. /**
  1412. * Available options for the user to choose from
  1413. */
  1414. options: PromptRequestOption[];
  1415. };
  1416. export declare type PromptRequestOption = {
  1417. /**
  1418. * Unique key for this option, returned in the response
  1419. */
  1420. key: string;
  1421. /**
  1422. * Display text for this option
  1423. */
  1424. label: string;
  1425. /**
  1426. * Optional description shown below the label
  1427. */
  1428. description?: string;
  1429. };
  1430. export declare type PromptResponse = {
  1431. /**
  1432. * The request ID from the corresponding prompt request
  1433. */
  1434. prompt_response: string;
  1435. /**
  1436. * The key of the selected option
  1437. */
  1438. selected: string;
  1439. };
  1440. /**
  1441. * Query interface with methods for controlling query execution.
  1442. * Extends AsyncGenerator and has methods, so not serializable.
  1443. */
  1444. export declare interface Query extends AsyncGenerator<SDKMessage, void> {
  1445. /**
  1446. * Control Requests
  1447. * The following methods are control requests, and are only supported when
  1448. * streaming input/output is used.
  1449. */
  1450. /**
  1451. * Interrupt the current query execution. The query will stop processing
  1452. * and return control to the caller.
  1453. */
  1454. interrupt(): Promise<void>;
  1455. /**
  1456. * Change the permission mode for the current session.
  1457. * Only available in streaming input mode.
  1458. *
  1459. * @param mode - The new permission mode to set
  1460. */
  1461. setPermissionMode(mode: PermissionMode): Promise<void>;
  1462. /**
  1463. * Change the model used for subsequent responses.
  1464. * Only available in streaming input mode.
  1465. *
  1466. * @param model - The model identifier to use, or undefined to use the default
  1467. */
  1468. setModel(model?: string): Promise<void>;
  1469. /**
  1470. * Set the maximum number of thinking tokens the model is allowed to use
  1471. * when generating its response. This can be used to limit the amount of
  1472. * tokens the model uses for its response, which can help control cost and
  1473. * latency.
  1474. *
  1475. * Use `null` to clear any previously set limit and allow the model to
  1476. * use the default maximum thinking tokens.
  1477. *
  1478. * @deprecated Use the `thinking` option in `query()` instead. On Opus 4.6,
  1479. * this is treated as on/off (0 = disabled, any other value = adaptive).
  1480. * For explicit control, use `thinking: { type: 'adaptive' }` or
  1481. * `thinking: { type: 'enabled', budgetTokens: N }`.
  1482. *
  1483. * @param maxThinkingTokens - Maximum tokens for thinking, or null to clear the limit
  1484. */
  1485. setMaxThinkingTokens(maxThinkingTokens: number | null): Promise<void>;
  1486. /**
  1487. * Merge the provided settings into the flag settings layer, dynamically
  1488. * updating the active configuration. Top-level keys are shallow-merged
  1489. * across successive calls — a second call with `{permissions: {...}}`
  1490. * replaces the entire `permissions` object from a prior call. The resulting
  1491. * flag settings are then deep-merged with file-based settings at read time.
  1492. *
  1493. * Equivalent to passing an object to the `settings` option of `query()`,
  1494. * but applies mid-session. Only available in streaming input mode.
  1495. *
  1496. * @param settings - A partial settings object to merge into the flag settings
  1497. */
  1498. applyFlagSettings(settings: Settings): Promise<void>;
  1499. /**
  1500. * Get the full initialization result, including supported commands, models,
  1501. * account info, and output style configuration.
  1502. *
  1503. * @returns The complete initialization response
  1504. */
  1505. initializationResult(): Promise<SDKControlInitializeResponse>;
  1506. /**
  1507. * Get the list of available skills for the current session.
  1508. *
  1509. * @returns Array of available skills with their names and descriptions
  1510. */
  1511. supportedCommands(): Promise<SlashCommand[]>;
  1512. /**
  1513. * Get the list of available models.
  1514. *
  1515. * @returns Array of model information including display names and descriptions
  1516. */
  1517. supportedModels(): Promise<ModelInfo[]>;
  1518. /**
  1519. * Get the list of available subagents for the current session.
  1520. *
  1521. * @returns Array of available agents with their names, descriptions, and configuration
  1522. */
  1523. supportedAgents(): Promise<AgentInfo[]>;
  1524. /**
  1525. * Get the current status of all configured MCP servers.
  1526. *
  1527. * @returns Array of MCP server statuses (connected, failed, needs-auth, pending)
  1528. */
  1529. mcpServerStatus(): Promise<McpServerStatus[]>;
  1530. /**
  1531. * Get a breakdown of current context window usage by category
  1532. * (system prompt, tools, messages, MCP tools, memory files, etc.).
  1533. *
  1534. * @returns Context usage breakdown including token counts per category and total usage
  1535. */
  1536. getContextUsage(): Promise<SDKControlGetContextUsageResponse>;
  1537. /**
  1538. * Reload plugins from disk and return the refreshed commands, agents,
  1539. * plugins, and MCP server status.
  1540. *
  1541. * @returns The refreshed session components after plugin reload
  1542. */
  1543. reloadPlugins(): Promise<SDKControlReloadPluginsResponse>;
  1544. /**
  1545. * Get information about the authenticated account.
  1546. *
  1547. * @returns Account information including email, organization, and subscription type
  1548. */
  1549. accountInfo(): Promise<AccountInfo>;
  1550. /**
  1551. * Rewind tracked files to their state at a specific user message.
  1552. * Requires file checkpointing to be enabled via the `enableFileCheckpointing` option.
  1553. *
  1554. * @param userMessageId - UUID of the user message to rewind to
  1555. * @param options - Options object with optional `dryRun` boolean to preview changes without modifying files
  1556. * @returns Object with canRewind boolean, optional error message, and file change statistics
  1557. */
  1558. rewindFiles(userMessageId: string, options?: {
  1559. dryRun?: boolean;
  1560. }): Promise<RewindFilesResult>;
  1561. /**
  1562. * Seed the CLI's readFileState cache with a path+mtime entry. Use when
  1563. * the client observed a Read that has since been removed from context
  1564. * (e.g. by snip), so a subsequent Edit won't fail "file not read yet".
  1565. * If the file changed on disk since the given mtime, the seed is skipped
  1566. * and Edit will correctly require a fresh Read.
  1567. *
  1568. * @param path - Path to the file that was previously Read
  1569. * @param mtime - File mtime (floored ms) at the time of the observed Read
  1570. */
  1571. seedReadState(path: string, mtime: number): Promise<void>;
  1572. /**
  1573. * Reconnect an MCP server by name.
  1574. * Throws on failure.
  1575. *
  1576. * @param serverName - The name of the MCP server to reconnect
  1577. */
  1578. reconnectMcpServer(serverName: string): Promise<void>;
  1579. /**
  1580. * Enable or disable an MCP server by name.
  1581. * Throws on failure.
  1582. *
  1583. * @param serverName - The name of the MCP server to toggle
  1584. * @param enabled - Whether the server should be enabled
  1585. */
  1586. toggleMcpServer(serverName: string, enabled: boolean): Promise<void>;
  1587. /**
  1588. * Dynamically set the MCP servers for this session.
  1589. * This replaces the current set of dynamically-added MCP servers with the provided set.
  1590. * Servers that are removed will be disconnected, and new servers will be connected.
  1591. *
  1592. * Supports both process-based servers (stdio, sse, http) and SDK servers (in-process).
  1593. * SDK servers are handled locally in the SDK process, while process-based servers
  1594. * are managed by the CLI subprocess.
  1595. *
  1596. * Note: This only affects servers added dynamically via this method or the SDK.
  1597. * Servers configured via settings files are not affected.
  1598. *
  1599. * @param servers - Record of server name to configuration. Pass an empty object to remove all dynamic servers.
  1600. * @returns Information about which servers were added, removed, and any connection errors
  1601. */
  1602. setMcpServers(servers: Record<string, McpServerConfig>): Promise<McpSetServersResult>;
  1603. /**
  1604. * Stream input messages to the query.
  1605. * Used internally for multi-turn conversations.
  1606. *
  1607. * @param stream - Async iterable of user messages to send
  1608. */
  1609. streamInput(stream: AsyncIterable<SDKUserMessage>): Promise<void>;
  1610. /**
  1611. * Stop a running task. A task_notification with status 'stopped' will be emitted.
  1612. * @param taskId - The task ID from task_notification events
  1613. */
  1614. stopTask(taskId: string): Promise<void>;
  1615. /**
  1616. * Close the query and terminate the underlying process.
  1617. * This forcefully ends the query, cleaning up all resources including
  1618. * pending requests, MCP transports, and the CLI subprocess.
  1619. *
  1620. * Use this when you need to abort a query that is still running.
  1621. * After calling close(), no further messages will be received.
  1622. */
  1623. close(): void;
  1624. }
  1625. export declare function query(_params: {
  1626. prompt: string | AsyncIterable<SDKUserMessage>;
  1627. options?: Options;
  1628. }): Query;
  1629. /**
  1630. * Rename a session. Appends a custom-title entry to the session's JSONL file.
  1631. * @param sessionId - UUID of the session
  1632. * @param title - New title
  1633. * @param options - `{ dir?: string }` project path; omit to search all projects
  1634. */
  1635. export declare function renameSession(_sessionId: string, _title: string, _options?: SessionMutationOptions): Promise<void>;
  1636. /**
  1637. * Result of a rewindFiles operation.
  1638. */
  1639. export declare type RewindFilesResult = {
  1640. canRewind: boolean;
  1641. error?: string;
  1642. filesChanged?: string[];
  1643. insertions?: number;
  1644. deletions?: number;
  1645. };
  1646. export declare type SandboxFilesystemConfig = NonNullable<z.infer<ReturnType<typeof SandboxFilesystemConfigSchema>>>;
  1647. /**
  1648. * Filesystem configuration schema for sandbox.
  1649. */
  1650. declare const SandboxFilesystemConfigSchema: () => z.ZodOptional<z.ZodObject<{
  1651. allowWrite: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1652. denyWrite: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1653. denyRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1654. allowRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1655. allowManagedReadPathsOnly: z.ZodOptional<z.ZodBoolean>;
  1656. }, z.core.$strip>>;
  1657. export declare type SandboxIgnoreViolations = NonNullable<SandboxSettings['ignoreViolations']>;
  1658. export declare type SandboxNetworkConfig = NonNullable<z.infer<ReturnType<typeof SandboxNetworkConfigSchema>>>;
  1659. /**
  1660. * Network configuration schema for sandbox.
  1661. */
  1662. declare const SandboxNetworkConfigSchema: () => z.ZodOptional<z.ZodObject<{
  1663. allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1664. allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
  1665. allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1666. allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
  1667. allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
  1668. httpProxyPort: z.ZodOptional<z.ZodNumber>;
  1669. socksProxyPort: z.ZodOptional<z.ZodNumber>;
  1670. }, z.core.$strip>>;
  1671. export declare type SandboxSettings = z.infer<ReturnType<typeof SandboxSettingsSchema>>;
  1672. /**
  1673. * Sandbox settings schema.
  1674. */
  1675. declare const SandboxSettingsSchema: () => z.ZodObject<{
  1676. enabled: z.ZodOptional<z.ZodBoolean>;
  1677. failIfUnavailable: z.ZodOptional<z.ZodBoolean>;
  1678. autoAllowBashIfSandboxed: z.ZodOptional<z.ZodBoolean>;
  1679. allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
  1680. network: z.ZodOptional<z.ZodObject<{
  1681. allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1682. allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
  1683. allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1684. allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
  1685. allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
  1686. httpProxyPort: z.ZodOptional<z.ZodNumber>;
  1687. socksProxyPort: z.ZodOptional<z.ZodNumber>;
  1688. }, z.core.$strip>>;
  1689. filesystem: z.ZodOptional<z.ZodObject<{
  1690. allowWrite: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1691. denyWrite: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1692. denyRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1693. allowRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1694. allowManagedReadPathsOnly: z.ZodOptional<z.ZodBoolean>;
  1695. }, z.core.$strip>>;
  1696. ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
  1697. enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
  1698. enableWeakerNetworkIsolation: z.ZodOptional<z.ZodBoolean>;
  1699. excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1700. ripgrep: z.ZodOptional<z.ZodObject<{
  1701. command: z.ZodString;
  1702. args: z.ZodOptional<z.ZodArray<z.ZodString>>;
  1703. }, z.core.$strip>>;
  1704. }, z.core.$loose>;
  1705. /**
  1706. * Emitted when an API request fails with a retryable error and will be retried after a delay. error_status is null for connection errors (e.g. timeouts) that had no HTTP response.
  1707. */
  1708. export declare type SDKAPIRetryMessage = {
  1709. type: 'system';
  1710. subtype: 'api_retry';
  1711. attempt: number;
  1712. max_retries: number;
  1713. retry_delay_ms: number;
  1714. error_status: number | null;
  1715. error: SDKAssistantMessageError;
  1716. uuid: UUID;
  1717. session_id: string;
  1718. };
  1719. export declare type SDKAssistantMessage = {
  1720. type: 'assistant';
  1721. message: BetaMessage;
  1722. parent_tool_use_id: string | null;
  1723. error?: SDKAssistantMessageError;
  1724. uuid: UUID;
  1725. session_id: string;
  1726. };
  1727. export declare type SDKAssistantMessageError = 'authentication_failed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens';
  1728. export declare type SDKAuthStatusMessage = {
  1729. type: 'auth_status';
  1730. isAuthenticating: boolean;
  1731. output: string[];
  1732. error?: string;
  1733. uuid: UUID;
  1734. session_id: string;
  1735. };
  1736. export declare type SdkBeta = 'context-1m-2025-08-07';
  1737. export declare type SDKCompactBoundaryMessage = {
  1738. type: 'system';
  1739. subtype: 'compact_boundary';
  1740. compact_metadata: {
  1741. trigger: 'manual' | 'auto';
  1742. pre_tokens: number;
  1743. /**
  1744. * Relink info for messagesToKeep. Loaders splice the preserved segment at anchor_uuid (summary for suffix-preserving, boundary for prefix-preserving partial compact) so resume includes preserved content. Unset when compaction summarizes everything (no messagesToKeep).
  1745. */
  1746. preserved_segment?: {
  1747. head_uuid: UUID;
  1748. anchor_uuid: UUID;
  1749. tail_uuid: UUID;
  1750. };
  1751. };
  1752. uuid: UUID;
  1753. session_id: string;
  1754. };
  1755. /**
  1756. * Merges the provided settings into the flag settings layer, updating the active configuration.
  1757. */
  1758. declare type SDKControlApplyFlagSettingsRequest = {
  1759. subtype: 'apply_flag_settings';
  1760. settings: Record<string, unknown>;
  1761. };
  1762. /**
  1763. * Drops a pending async user message from the command queue by uuid. No-op if already dequeued for execution.
  1764. */
  1765. declare type SDKControlCancelAsyncMessageRequest = {
  1766. subtype: 'cancel_async_message';
  1767. message_uuid: string;
  1768. };
  1769. /**
  1770. * Cancels a currently open control request.
  1771. */
  1772. declare type SDKControlCancelRequest = {
  1773. type: 'control_cancel_request';
  1774. request_id: string;
  1775. };
  1776. /**
  1777. * Requests the SDK consumer to handle an MCP elicitation (user input request).
  1778. */
  1779. declare type SDKControlElicitationRequest = {
  1780. subtype: 'elicitation';
  1781. mcp_server_name: string;
  1782. message: string;
  1783. mode?: 'form' | 'url';
  1784. url?: string;
  1785. elicitation_id?: string;
  1786. requested_schema?: Record<string, unknown>;
  1787. };
  1788. /**
  1789. * Requests a breakdown of current context window usage by category.
  1790. */
  1791. declare type SDKControlGetContextUsageRequest = {
  1792. subtype: 'get_context_usage';
  1793. };
  1794. /**
  1795. * Breakdown of current context window usage by category (system prompt, tools, messages, etc.).
  1796. */
  1797. export declare type SDKControlGetContextUsageResponse = {
  1798. categories: {
  1799. name: string;
  1800. tokens: number;
  1801. color: string;
  1802. isDeferred?: boolean;
  1803. }[];
  1804. totalTokens: number;
  1805. maxTokens: number;
  1806. rawMaxTokens: number;
  1807. percentage: number;
  1808. gridRows: {
  1809. color: string;
  1810. isFilled: boolean;
  1811. categoryName: string;
  1812. tokens: number;
  1813. percentage: number;
  1814. squareFullness: number;
  1815. }[][];
  1816. model: string;
  1817. memoryFiles: {
  1818. path: string;
  1819. type: string;
  1820. tokens: number;
  1821. }[];
  1822. mcpTools: {
  1823. name: string;
  1824. serverName: string;
  1825. tokens: number;
  1826. isLoaded?: boolean;
  1827. }[];
  1828. deferredBuiltinTools?: {
  1829. name: string;
  1830. tokens: number;
  1831. isLoaded: boolean;
  1832. }[];
  1833. systemTools?: {
  1834. name: string;
  1835. tokens: number;
  1836. }[];
  1837. systemPromptSections?: {
  1838. name: string;
  1839. tokens: number;
  1840. }[];
  1841. agents: {
  1842. agentType: string;
  1843. source: string;
  1844. tokens: number;
  1845. }[];
  1846. slashCommands?: {
  1847. totalCommands: number;
  1848. includedCommands: number;
  1849. tokens: number;
  1850. };
  1851. skills?: {
  1852. totalSkills: number;
  1853. includedSkills: number;
  1854. tokens: number;
  1855. skillFrontmatter: {
  1856. name: string;
  1857. source: string;
  1858. tokens: number;
  1859. }[];
  1860. };
  1861. autoCompactThreshold?: number;
  1862. isAutoCompactEnabled: boolean;
  1863. messageBreakdown?: {
  1864. toolCallTokens: number;
  1865. toolResultTokens: number;
  1866. attachmentTokens: number;
  1867. assistantMessageTokens: number;
  1868. userMessageTokens: number;
  1869. toolCallsByType: {
  1870. name: string;
  1871. callTokens: number;
  1872. resultTokens: number;
  1873. }[];
  1874. attachmentsByType: {
  1875. name: string;
  1876. tokens: number;
  1877. }[];
  1878. };
  1879. apiUsage: {
  1880. input_tokens: number;
  1881. output_tokens: number;
  1882. cache_creation_input_tokens: number;
  1883. cache_read_input_tokens: number;
  1884. } | null;
  1885. };
  1886. /**
  1887. * Returns the effective merged settings and the raw per-source settings.
  1888. */
  1889. declare type SDKControlGetSettingsRequest = {
  1890. subtype: 'get_settings';
  1891. };
  1892. /**
  1893. * Initializes the SDK session with hooks, MCP servers, and agent configuration.
  1894. */
  1895. declare type SDKControlInitializeRequest = {
  1896. subtype: 'initialize';
  1897. hooks?: Partial<Record<coreTypes.HookEvent, SDKHookCallbackMatcher[]>>;
  1898. sdkMcpServers?: string[];
  1899. jsonSchema?: Record<string, unknown>;
  1900. systemPrompt?: string;
  1901. appendSystemPrompt?: string;
  1902. agents?: Record<string, coreTypes.AgentDefinition>;
  1903. promptSuggestions?: boolean;
  1904. agentProgressSummaries?: boolean;
  1905. };
  1906. /**
  1907. * Response from session initialization with available commands, models, and account info.
  1908. */
  1909. export declare type SDKControlInitializeResponse = {
  1910. commands: coreTypes.SlashCommand[];
  1911. agents: coreTypes.AgentInfo[];
  1912. output_style: string;
  1913. available_output_styles: string[];
  1914. models: coreTypes.ModelInfo[];
  1915. /**
  1916. * Information about the logged in user's account.
  1917. */
  1918. account: coreTypes.AccountInfo;
  1919. fast_mode_state?: coreTypes.FastModeState;
  1920. };
  1921. /**
  1922. * Interrupts the currently running conversation turn.
  1923. */
  1924. declare type SDKControlInterruptRequest = {
  1925. subtype: 'interrupt';
  1926. };
  1927. /**
  1928. * Sends a JSON-RPC message to a specific MCP server.
  1929. */
  1930. declare type SDKControlMcpMessageRequest = {
  1931. subtype: 'mcp_message';
  1932. server_name: string;
  1933. message: JSONRPCMessage;
  1934. };
  1935. /**
  1936. * Reconnects a disconnected or failed MCP server.
  1937. */
  1938. declare type SDKControlMcpReconnectRequest = {
  1939. subtype: 'mcp_reconnect';
  1940. serverName: string;
  1941. };
  1942. /**
  1943. * Replaces the set of dynamically managed MCP servers.
  1944. */
  1945. declare type SDKControlMcpSetServersRequest = {
  1946. subtype: 'mcp_set_servers';
  1947. servers: Record<string, coreTypes.McpServerConfigForProcessTransport>;
  1948. };
  1949. /**
  1950. * Requests the current status of all MCP server connections.
  1951. */
  1952. declare type SDKControlMcpStatusRequest = {
  1953. subtype: 'mcp_status';
  1954. };
  1955. /**
  1956. * Enables or disables an MCP server.
  1957. */
  1958. declare type SDKControlMcpToggleRequest = {
  1959. subtype: 'mcp_toggle';
  1960. serverName: string;
  1961. enabled: boolean;
  1962. };
  1963. /**
  1964. * Requests permission to use a tool with the given input.
  1965. */
  1966. declare type SDKControlPermissionRequest = {
  1967. subtype: 'can_use_tool';
  1968. tool_name: string;
  1969. input: Record<string, unknown>;
  1970. permission_suggestions?: coreTypes.PermissionUpdate[];
  1971. blocked_path?: string;
  1972. decision_reason?: string;
  1973. title?: string;
  1974. display_name?: string;
  1975. tool_use_id: string;
  1976. agent_id?: string;
  1977. description?: string;
  1978. };
  1979. /**
  1980. * Reloads plugins from disk and returns the refreshed session components.
  1981. */
  1982. declare type SDKControlReloadPluginsRequest = {
  1983. subtype: 'reload_plugins';
  1984. };
  1985. /**
  1986. * Refreshed commands, agents, plugins, and MCP server status after reload.
  1987. */
  1988. export declare type SDKControlReloadPluginsResponse = {
  1989. commands: coreTypes.SlashCommand[];
  1990. agents: coreTypes.AgentInfo[];
  1991. plugins: {
  1992. name: string;
  1993. path: string;
  1994. source?: string;
  1995. }[];
  1996. mcpServers: coreTypes.McpServerStatus[];
  1997. error_count: number;
  1998. };
  1999. export declare type SDKControlRequest = {
  2000. type: 'control_request';
  2001. request_id: string;
  2002. request: SDKControlRequestInner;
  2003. };
  2004. declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKControlGetContextUsageRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlCancelAsyncMessageRequest | SDKControlSeedReadStateRequest | SDKControlMcpSetServersRequest | SDKControlReloadPluginsRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlChannelEnableRequest | SDKControlEndSessionRequest | SDKControlMcpAuthenticateRequest | SDKControlMcpClearAuthRequest | SDKControlMcpOAuthCallbackUrlRequest | SDKControlClaudeAuthenticateRequest | SDKControlClaudeOAuthCallbackRequest | SDKControlClaudeOAuthWaitForCompletionRequest | SDKControlRemoteControlRequest | SDKControlSetProactiveRequest | SDKControlGenerateSessionTitleRequest | SDKControlSideQuestionRequest | SDKControlStopTaskRequest | SDKControlApplyFlagSettingsRequest | SDKControlGetSettingsRequest | SDKControlElicitationRequest;
  2005. export declare type SDKControlResponse = {
  2006. type: 'control_response';
  2007. response: ControlResponse | ControlErrorResponse;
  2008. };
  2009. /**
  2010. * Rewinds file changes made since a specific user message.
  2011. */
  2012. declare type SDKControlRewindFilesRequest = {
  2013. subtype: 'rewind_files';
  2014. user_message_id: string;
  2015. dry_run?: boolean;
  2016. };
  2017. /**
  2018. * Seeds the readFileState cache with a path+mtime entry. Use when a prior Read was removed from context (e.g. by snip) so Edit validation would fail despite the client having observed the Read. The mtime lets the CLI detect if the file changed since the seeded Read — same staleness check as the normal path.
  2019. */
  2020. declare type SDKControlSeedReadStateRequest = {
  2021. subtype: 'seed_read_state';
  2022. path: string;
  2023. mtime: number;
  2024. };
  2025. /**
  2026. * Sets the maximum number of thinking tokens for extended thinking.
  2027. */
  2028. declare type SDKControlSetMaxThinkingTokensRequest = {
  2029. subtype: 'set_max_thinking_tokens';
  2030. max_thinking_tokens: number | null;
  2031. };
  2032. /**
  2033. * Sets the model to use for subsequent conversation turns.
  2034. */
  2035. declare type SDKControlSetModelRequest = {
  2036. subtype: 'set_model';
  2037. model?: string;
  2038. };
  2039. /**
  2040. * Sets the permission mode for tool execution handling.
  2041. */
  2042. declare type SDKControlSetPermissionModeRequest = {
  2043. subtype: 'set_permission_mode';
  2044. /**
  2045. * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
  2046. */
  2047. mode: coreTypes.PermissionMode;
  2048. };
  2049. /**
  2050. * Stops a running task.
  2051. */
  2052. declare type SDKControlStopTaskRequest = {
  2053. subtype: 'stop_task';
  2054. task_id: string;
  2055. };
  2056. /**
  2057. * Emitted when an MCP server confirms that a URL-mode elicitation is complete.
  2058. */
  2059. export declare type SDKElicitationCompleteMessage = {
  2060. type: 'system';
  2061. subtype: 'elicitation_complete';
  2062. mcp_server_name: string;
  2063. elicitation_id: string;
  2064. uuid: UUID;
  2065. session_id: string;
  2066. };
  2067. export declare type SDKFilesPersistedEvent = {
  2068. type: 'system';
  2069. subtype: 'files_persisted';
  2070. files: {
  2071. filename: string;
  2072. file_id: string;
  2073. }[];
  2074. failed: {
  2075. filename: string;
  2076. error: string;
  2077. }[];
  2078. processed_at: string;
  2079. uuid: UUID;
  2080. session_id: string;
  2081. };
  2082. /**
  2083. * Configuration for matching and routing hook callbacks.
  2084. */
  2085. declare type SDKHookCallbackMatcher = {
  2086. matcher?: string;
  2087. hookCallbackIds: string[];
  2088. timeout?: number;
  2089. };
  2090. /**
  2091. * Delivers a hook callback with its input data.
  2092. */
  2093. declare type SDKHookCallbackRequest = {
  2094. subtype: 'hook_callback';
  2095. callback_id: string;
  2096. input: coreTypes.HookInput;
  2097. tool_use_id?: string;
  2098. };
  2099. export declare type SDKHookProgressMessage = {
  2100. type: 'system';
  2101. subtype: 'hook_progress';
  2102. hook_id: string;
  2103. hook_name: string;
  2104. hook_event: string;
  2105. stdout: string;
  2106. stderr: string;
  2107. output: string;
  2108. uuid: UUID;
  2109. session_id: string;
  2110. };
  2111. export declare type SDKHookResponseMessage = {
  2112. type: 'system';
  2113. subtype: 'hook_response';
  2114. hook_id: string;
  2115. hook_name: string;
  2116. hook_event: string;
  2117. output: string;
  2118. stdout: string;
  2119. stderr: string;
  2120. exit_code?: number;
  2121. outcome: 'success' | 'error' | 'cancelled';
  2122. uuid: UUID;
  2123. session_id: string;
  2124. };
  2125. export declare type SDKHookStartedMessage = {
  2126. type: 'system';
  2127. subtype: 'hook_started';
  2128. hook_id: string;
  2129. hook_name: string;
  2130. hook_event: string;
  2131. uuid: UUID;
  2132. session_id: string;
  2133. };
  2134. /**
  2135. * Keep-alive message to maintain WebSocket connection.
  2136. */
  2137. declare type SDKKeepAliveMessage = {
  2138. type: 'keep_alive';
  2139. };
  2140. /**
  2141. * Output from a local slash command (e.g. /voice, /cost). Displayed as assistant-style text in the transcript.
  2142. */
  2143. export declare type SDKLocalCommandOutputMessage = {
  2144. type: 'system';
  2145. subtype: 'local_command_output';
  2146. content: string;
  2147. uuid: UUID;
  2148. session_id: string;
  2149. };
  2150. /**
  2151. * MCP tool definition for SDK servers.
  2152. * Contains a handler function, so not serializable.
  2153. * Supports both Zod 3 and Zod 4 schemas.
  2154. */
  2155. export declare type SdkMcpToolDefinition<Schema extends AnyZodRawShape = AnyZodRawShape> = {
  2156. name: string;
  2157. description: string;
  2158. inputSchema: Schema;
  2159. annotations?: ToolAnnotations;
  2160. _meta?: Record<string, unknown>;
  2161. handler: (args: InferShape<Schema>, extra: unknown) => Promise<CallToolResult>;
  2162. };
  2163. export declare type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage | SDKCompactBoundaryMessage | SDKStatusMessage | SDKAPIRetryMessage | SDKLocalCommandOutputMessage | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKToolProgressMessage | SDKAuthStatusMessage | SDKTaskNotificationMessage | SDKTaskStartedMessage | SDKTaskProgressMessage | SDKSessionStateChangedMessage | SDKFilesPersistedEvent | SDKToolUseSummaryMessage | SDKRateLimitEvent | SDKElicitationCompleteMessage | SDKPromptSuggestionMessage;
  2164. export declare type SDKPartialAssistantMessage = {
  2165. type: 'stream_event';
  2166. event: BetaRawMessageStreamEvent;
  2167. parent_tool_use_id: string | null;
  2168. uuid: UUID;
  2169. session_id: string;
  2170. };
  2171. export declare type SDKPermissionDenial = {
  2172. tool_name: string;
  2173. tool_use_id: string;
  2174. tool_input: Record<string, unknown>;
  2175. };
  2176. /**
  2177. * Configuration for loading a plugin.
  2178. */
  2179. export declare type SdkPluginConfig = {
  2180. /**
  2181. * Plugin type. Currently only 'local' is supported
  2182. */
  2183. type: 'local';
  2184. /**
  2185. * Absolute or relative path to the plugin directory
  2186. */
  2187. path: string;
  2188. };
  2189. /**
  2190. * Predicted next user prompt, emitted after each turn when promptSuggestions is enabled.
  2191. */
  2192. export declare type SDKPromptSuggestionMessage = {
  2193. type: 'prompt_suggestion';
  2194. suggestion: string;
  2195. uuid: UUID;
  2196. session_id: string;
  2197. };
  2198. /**
  2199. * Rate limit event emitted when rate limit info changes.
  2200. */
  2201. export declare type SDKRateLimitEvent = {
  2202. type: 'rate_limit_event';
  2203. /**
  2204. * Rate limit information for claude.ai subscription users.
  2205. */
  2206. rate_limit_info: SDKRateLimitInfo;
  2207. uuid: UUID;
  2208. session_id: string;
  2209. };
  2210. /**
  2211. * Rate limit information for claude.ai subscription users.
  2212. */
  2213. export declare type SDKRateLimitInfo = {
  2214. status: 'allowed' | 'allowed_warning' | 'rejected';
  2215. resetsAt?: number;
  2216. rateLimitType?: 'five_hour' | 'seven_day' | 'seven_day_opus' | 'seven_day_sonnet' | 'overage';
  2217. utilization?: number;
  2218. overageStatus?: 'allowed' | 'allowed_warning' | 'rejected';
  2219. overageResetsAt?: number;
  2220. overageDisabledReason?: 'overage_not_provisioned' | 'org_level_disabled' | 'org_level_disabled_until' | 'out_of_credits' | 'seat_tier_level_disabled' | 'member_level_disabled' | 'seat_tier_zero_credit_limit' | 'group_zero_credit_limit' | 'member_zero_credit_limit' | 'org_service_level_disabled' | 'org_service_zero_credit_limit' | 'no_limits_configured' | 'unknown';
  2221. isUsingOverage?: boolean;
  2222. surpassedThreshold?: number;
  2223. };
  2224. export declare type SDKResultError = {
  2225. type: 'result';
  2226. subtype: 'error_during_execution' | 'error_max_turns' | 'error_max_budget_usd' | 'error_max_structured_output_retries';
  2227. duration_ms: number;
  2228. duration_api_ms: number;
  2229. is_error: boolean;
  2230. num_turns: number;
  2231. stop_reason: string | null;
  2232. total_cost_usd: number;
  2233. usage: NonNullableUsage;
  2234. modelUsage: Record<string, ModelUsage>;
  2235. permission_denials: SDKPermissionDenial[];
  2236. errors: string[];
  2237. fast_mode_state?: FastModeState;
  2238. uuid: UUID;
  2239. session_id: string;
  2240. };
  2241. export declare type SDKResultMessage = SDKResultSuccess | SDKResultError;
  2242. export declare type SDKResultSuccess = {
  2243. type: 'result';
  2244. subtype: 'success';
  2245. duration_ms: number;
  2246. duration_api_ms: number;
  2247. is_error: boolean;
  2248. num_turns: number;
  2249. result: string;
  2250. stop_reason: string | null;
  2251. total_cost_usd: number;
  2252. usage: NonNullableUsage;
  2253. modelUsage: Record<string, ModelUsage>;
  2254. permission_denials: SDKPermissionDenial[];
  2255. structured_output?: unknown;
  2256. fast_mode_state?: FastModeState;
  2257. uuid: UUID;
  2258. session_id: string;
  2259. };
  2260. /**
  2261. * V2 API - UNSTABLE
  2262. * Session interface for multi-turn conversations.
  2263. * Has methods, so not serializable.
  2264. * @alpha
  2265. */
  2266. export declare interface SDKSession {
  2267. /**
  2268. * The session ID. Available after receiving the first message.
  2269. * For resumed sessions, available immediately.
  2270. * Throws if accessed before the session is initialized.
  2271. */
  2272. readonly sessionId: string;
  2273. /** Send a message to the agent */
  2274. send(message: string | SDKUserMessage): Promise<void>;
  2275. /** Stream messages from the agent */
  2276. stream(): AsyncGenerator<SDKMessage, void>;
  2277. /** Close the session */
  2278. close(): void;
  2279. /** Async disposal support (calls close if not already closed) */
  2280. [Symbol.asyncDispose](): Promise<void>;
  2281. }
  2282. /**
  2283. * Session metadata returned by listSessions and getSessionInfo.
  2284. */
  2285. export declare type SDKSessionInfo = {
  2286. /**
  2287. * Unique session identifier (UUID).
  2288. */
  2289. sessionId: string;
  2290. /**
  2291. * Display title for the session: custom title, auto-generated summary, or first prompt.
  2292. */
  2293. summary: string;
  2294. /**
  2295. * Last modified time in milliseconds since epoch.
  2296. */
  2297. lastModified: number;
  2298. /**
  2299. * File size in bytes. Only populated for local JSONL storage.
  2300. */
  2301. fileSize?: number;
  2302. /**
  2303. * User-set session title via /rename.
  2304. */
  2305. customTitle?: string;
  2306. /**
  2307. * First meaningful user prompt in the session.
  2308. */
  2309. firstPrompt?: string;
  2310. /**
  2311. * Git branch at the end of the session.
  2312. */
  2313. gitBranch?: string;
  2314. /**
  2315. * Working directory for the session.
  2316. */
  2317. cwd?: string;
  2318. /**
  2319. * User-set session tag.
  2320. */
  2321. tag?: string;
  2322. /**
  2323. * Creation time in milliseconds since epoch, extracted from the first entry's timestamp.
  2324. */
  2325. createdAt?: number;
  2326. };
  2327. /**
  2328. * V2 API - UNSTABLE
  2329. * Options for creating a session.
  2330. * @alpha
  2331. */
  2332. export declare type SDKSessionOptions = {
  2333. /** Model to use */
  2334. model: string;
  2335. /** Path to Claude Code executable */
  2336. pathToClaudeCodeExecutable?: string;
  2337. /** Executable to use (node, bun) */
  2338. executable?: 'node' | 'bun';
  2339. /** Arguments to pass to executable */
  2340. executableArgs?: string[];
  2341. /**
  2342. * Environment variables to pass to the Claude Code process.
  2343. * Defaults to `process.env`.
  2344. *
  2345. * SDK consumers can identify their app/library to include in the User-Agent header by setting:
  2346. * - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
  2347. */
  2348. env?: {
  2349. [envVar: string]: string | undefined;
  2350. };
  2351. /**
  2352. * List of tool names that are auto-allowed without prompting for permission.
  2353. * These tools will execute automatically without asking the user for approval.
  2354. */
  2355. allowedTools?: string[];
  2356. /**
  2357. * List of tool names that are disallowed. These tools will be removed
  2358. * from the model's context and cannot be used.
  2359. */
  2360. disallowedTools?: string[];
  2361. /**
  2362. * Custom permission handler for controlling tool usage. Called before each
  2363. * tool execution to determine if it should be allowed, denied, or prompt the user.
  2364. */
  2365. canUseTool?: CanUseTool;
  2366. /**
  2367. * Hook callbacks for responding to various events during execution.
  2368. */
  2369. hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
  2370. /**
  2371. * Permission mode for the session.
  2372. * - `'default'` - Standard permission behavior, prompts for dangerous operations
  2373. * - `'acceptEdits'` - Auto-accept file edit operations
  2374. * - `'plan'` - Planning mode, no execution of tools
  2375. * - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
  2376. */
  2377. permissionMode?: PermissionMode;
  2378. };
  2379. /**
  2380. * Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.
  2381. */
  2382. export declare type SDKSessionStateChangedMessage = {
  2383. type: 'system';
  2384. subtype: 'session_state_changed';
  2385. state: 'idle' | 'running' | 'requires_action';
  2386. uuid: UUID;
  2387. session_id: string;
  2388. };
  2389. export declare type SDKStatus = 'compacting' | null;
  2390. export declare type SDKStatusMessage = {
  2391. type: 'system';
  2392. subtype: 'status';
  2393. status: SDKStatus;
  2394. permissionMode?: PermissionMode;
  2395. uuid: UUID;
  2396. session_id: string;
  2397. };
  2398. export declare type SDKSystemMessage = {
  2399. type: 'system';
  2400. subtype: 'init';
  2401. agents?: string[];
  2402. apiKeySource: ApiKeySource;
  2403. betas?: string[];
  2404. claude_code_version: string;
  2405. cwd: string;
  2406. tools: string[];
  2407. mcp_servers: {
  2408. name: string;
  2409. status: string;
  2410. }[];
  2411. model: string;
  2412. /**
  2413. * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
  2414. */
  2415. permissionMode: PermissionMode;
  2416. slash_commands: string[];
  2417. output_style: string;
  2418. skills: string[];
  2419. plugins: {
  2420. name: string;
  2421. path: string;
  2422. }[];
  2423. fast_mode_state?: FastModeState;
  2424. uuid: UUID;
  2425. session_id: string;
  2426. };
  2427. export declare type SDKTaskNotificationMessage = {
  2428. type: 'system';
  2429. subtype: 'task_notification';
  2430. task_id: string;
  2431. tool_use_id?: string;
  2432. status: 'completed' | 'failed' | 'stopped';
  2433. output_file: string;
  2434. summary: string;
  2435. usage?: {
  2436. total_tokens: number;
  2437. tool_uses: number;
  2438. duration_ms: number;
  2439. };
  2440. uuid: UUID;
  2441. session_id: string;
  2442. };
  2443. export declare type SDKTaskProgressMessage = {
  2444. type: 'system';
  2445. subtype: 'task_progress';
  2446. task_id: string;
  2447. tool_use_id?: string;
  2448. description: string;
  2449. usage: {
  2450. total_tokens: number;
  2451. tool_uses: number;
  2452. duration_ms: number;
  2453. };
  2454. last_tool_name?: string;
  2455. summary?: string;
  2456. uuid: UUID;
  2457. session_id: string;
  2458. };
  2459. export declare type SDKTaskStartedMessage = {
  2460. type: 'system';
  2461. subtype: 'task_started';
  2462. task_id: string;
  2463. tool_use_id?: string;
  2464. description: string;
  2465. task_type?: string;
  2466. /**
  2467. * meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.
  2468. */
  2469. workflow_name?: string;
  2470. prompt?: string;
  2471. uuid: UUID;
  2472. session_id: string;
  2473. };
  2474. export declare type SDKToolProgressMessage = {
  2475. type: 'tool_progress';
  2476. tool_use_id: string;
  2477. tool_name: string;
  2478. parent_tool_use_id: string | null;
  2479. elapsed_time_seconds: number;
  2480. task_id?: string;
  2481. uuid: UUID;
  2482. session_id: string;
  2483. };
  2484. export declare type SDKToolUseSummaryMessage = {
  2485. type: 'tool_use_summary';
  2486. summary: string;
  2487. preceding_tool_use_ids: string[];
  2488. uuid: UUID;
  2489. session_id: string;
  2490. };
  2491. export declare type SDKUserMessage = {
  2492. type: 'user';
  2493. message: MessageParam;
  2494. parent_tool_use_id: string | null;
  2495. isSynthetic?: boolean;
  2496. tool_use_result?: unknown;
  2497. priority?: 'now' | 'next' | 'later';
  2498. /**
  2499. * ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.
  2500. */
  2501. timestamp?: string;
  2502. uuid?: UUID;
  2503. session_id?: string;
  2504. };
  2505. export declare type SDKUserMessageReplay = {
  2506. type: 'user';
  2507. message: MessageParam;
  2508. parent_tool_use_id: string | null;
  2509. isSynthetic?: boolean;
  2510. tool_use_result?: unknown;
  2511. priority?: 'now' | 'next' | 'later';
  2512. /**
  2513. * ISO timestamp when the message was created on the originating process. Older emitters omit it; consumers should fall back to receive time.
  2514. */
  2515. timestamp?: string;
  2516. uuid: UUID;
  2517. session_id: string;
  2518. isReplay: true;
  2519. };
  2520. export declare type SessionEndHookInput = BaseHookInput & {
  2521. hook_event_name: 'SessionEnd';
  2522. reason: ExitReason;
  2523. };
  2524. /**
  2525. * A message from a session transcript.
  2526. * Returned by `getSessionMessages` for reading historical session data.
  2527. */
  2528. export declare type SessionMessage = {
  2529. type: 'user' | 'assistant' | 'system';
  2530. uuid: string;
  2531. session_id: string;
  2532. message: unknown;
  2533. parent_tool_use_id: null;
  2534. };
  2535. /**
  2536. * Options shared by session mutation functions (renameSession, tagSession,
  2537. * deleteSession, forkSession).
  2538. */
  2539. export declare type SessionMutationOptions = {
  2540. /**
  2541. * Project directory path (same semantics as `listSessions({ dir })`).
  2542. * When omitted, all project directories are searched for the session file.
  2543. */
  2544. dir?: string;
  2545. };
  2546. export declare type SessionStartHookInput = BaseHookInput & {
  2547. hook_event_name: 'SessionStart';
  2548. source: 'startup' | 'resume' | 'clear' | 'compact';
  2549. agent_type?: string;
  2550. model?: string;
  2551. };
  2552. export declare type SessionStartHookSpecificOutput = {
  2553. hookEventName: 'SessionStart';
  2554. additionalContext?: string;
  2555. initialUserMessage?: string;
  2556. watchPaths?: string[];
  2557. };
  2558. /**
  2559. * AUTO-GENERATED - DO NOT EDIT
  2560. *
  2561. * This file is auto-generated from the settings JSON schema.
  2562. * To modify these types, edit SettingsSchema in src/utils/settings/types.ts and run:
  2563. *
  2564. * bun scripts/generate-sdk-types.ts
  2565. */
  2566. export declare interface Settings {
  2567. /**
  2568. * JSON Schema reference for Claude Code settings
  2569. */
  2570. $schema?: 'https://json.schemastore.org/claude-code-settings.json';
  2571. /**
  2572. * Path to a script that outputs authentication values
  2573. */
  2574. apiKeyHelper?: string;
  2575. /**
  2576. * Path to a script that exports AWS credentials
  2577. */
  2578. awsCredentialExport?: string;
  2579. /**
  2580. * Path to a script that refreshes AWS authentication
  2581. */
  2582. awsAuthRefresh?: string;
  2583. /**
  2584. * Command to refresh GCP authentication (e.g., gcloud auth application-default login)
  2585. */
  2586. gcpAuthRefresh?: string;
  2587. /**
  2588. * Custom file suggestion configuration for \@ mentions
  2589. */
  2590. fileSuggestion?: {
  2591. type: 'command';
  2592. command: string;
  2593. };
  2594. /**
  2595. * Whether file picker should respect .gitignore files (default: true). Note: .ignore files are always respected.
  2596. */
  2597. respectGitignore?: boolean;
  2598. /**
  2599. * Number of days to retain chat transcripts (default: 30). Setting to 0 disables session persistence entirely: no transcripts are written and existing transcripts are deleted at startup.
  2600. */
  2601. cleanupPeriodDays?: number;
  2602. /**
  2603. * Environment variables to set for Claude Code sessions
  2604. */
  2605. env?: {
  2606. [k: string]: string;
  2607. };
  2608. /**
  2609. * Customize attribution text for commits and PRs. Each field defaults to the standard Claude Code attribution if not set.
  2610. */
  2611. attribution?: {
  2612. /**
  2613. * Attribution text for git commits, including any trailers. Empty string hides attribution.
  2614. */
  2615. commit?: string;
  2616. /**
  2617. * Attribution text for pull request descriptions. Empty string hides attribution.
  2618. */
  2619. pr?: string;
  2620. };
  2621. /**
  2622. * Deprecated: Use attribution instead. Whether to include Claude's co-authored by attribution in commits and PRs (defaults to true)
  2623. */
  2624. includeCoAuthoredBy?: boolean;
  2625. /**
  2626. * Include built-in commit and PR workflow instructions in Claude's system prompt (default: true)
  2627. */
  2628. includeGitInstructions?: boolean;
  2629. /**
  2630. * Tool usage permissions configuration
  2631. */
  2632. permissions?: {
  2633. /**
  2634. * List of permission rules for allowed operations
  2635. */
  2636. allow?: string[];
  2637. /**
  2638. * List of permission rules for denied operations
  2639. */
  2640. deny?: string[];
  2641. /**
  2642. * List of permission rules that should always prompt for confirmation
  2643. */
  2644. ask?: string[];
  2645. /**
  2646. * Default permission mode when Claude Code needs access
  2647. */
  2648. defaultMode?: 'acceptEdits' | 'bypassPermissions' | 'default' | 'dontAsk' | 'plan';
  2649. /**
  2650. * Disable the ability to bypass permission prompts
  2651. */
  2652. disableBypassPermissionsMode?: 'disable';
  2653. /**
  2654. * Additional directories to include in the permission scope
  2655. */
  2656. additionalDirectories?: string[];
  2657. [k: string]: unknown;
  2658. };
  2659. /**
  2660. * Override the default model used by Claude Code
  2661. */
  2662. model?: string;
  2663. /**
  2664. * Allowlist of models that users can select. Accepts family aliases ("opus" allows any opus version), version prefixes ("opus-4-5" allows only that version), and full model IDs. If undefined, all models are available. If empty array, only the default model is available. Typically set in managed settings by enterprise administrators.
  2665. */
  2666. availableModels?: string[];
  2667. /**
  2668. * Override mapping from Anthropic model ID (e.g. "claude-opus-4-6") to provider-specific model ID (e.g. a Bedrock inference profile ARN). Typically set in managed settings by enterprise administrators.
  2669. */
  2670. modelOverrides?: {
  2671. [k: string]: string;
  2672. };
  2673. /**
  2674. * Whether to automatically approve all MCP servers in the project
  2675. */
  2676. enableAllProjectMcpServers?: boolean;
  2677. /**
  2678. * List of approved MCP servers from .mcp.json
  2679. */
  2680. enabledMcpjsonServers?: string[];
  2681. /**
  2682. * List of rejected MCP servers from .mcp.json
  2683. */
  2684. disabledMcpjsonServers?: string[];
  2685. /**
  2686. * Enterprise allowlist of MCP servers that can be used. Applies to all scopes including enterprise servers from managed-mcp.json. If undefined, all servers are allowed. If empty array, no servers are allowed. Denylist takes precedence - if a server is on both lists, it is denied.
  2687. */
  2688. allowedMcpServers?: {
  2689. /**
  2690. * Name of the MCP server that users are allowed to configure
  2691. */
  2692. serverName?: string;
  2693. /**
  2694. * Command array [command, ...args] to match exactly for allowed stdio servers
  2695. *
  2696. * \@minItems 1
  2697. */
  2698. serverCommand?: [string, ...string[]];
  2699. /**
  2700. * URL pattern with wildcard support (e.g., "https://*.example.com/*") for allowed remote MCP servers
  2701. */
  2702. serverUrl?: string;
  2703. }[];
  2704. /**
  2705. * Enterprise denylist of MCP servers that are explicitly blocked. If a server is on the denylist, it will be blocked across all scopes including enterprise. Denylist takes precedence over allowlist - if a server is on both lists, it is denied.
  2706. */
  2707. deniedMcpServers?: {
  2708. /**
  2709. * Name of the MCP server that is explicitly blocked
  2710. */
  2711. serverName?: string;
  2712. /**
  2713. * Command array [command, ...args] to match exactly for blocked stdio servers
  2714. *
  2715. * \@minItems 1
  2716. */
  2717. serverCommand?: [string, ...string[]];
  2718. /**
  2719. * URL pattern with wildcard support (e.g., "https://*.example.com/*") for blocked remote MCP servers
  2720. */
  2721. serverUrl?: string;
  2722. }[];
  2723. /**
  2724. * Custom commands to run before/after tool executions
  2725. */
  2726. hooks?: {
  2727. [k: string]: {
  2728. /**
  2729. * String pattern to match (e.g. tool names like "Write")
  2730. */
  2731. matcher?: string;
  2732. /**
  2733. * List of hooks to execute when the matcher matches
  2734. */
  2735. hooks: ({
  2736. /**
  2737. * Shell command hook type
  2738. */
  2739. type: 'command';
  2740. /**
  2741. * Shell command to execute
  2742. */
  2743. command: string;
  2744. /**
  2745. * Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.
  2746. */
  2747. if?: string;
  2748. /**
  2749. * Shell interpreter. 'bash' uses your $SHELL (bash/zsh/sh); 'powershell' uses pwsh. Defaults to bash.
  2750. */
  2751. shell?: 'bash' | 'powershell';
  2752. /**
  2753. * Timeout in seconds for this specific command
  2754. */
  2755. timeout?: number;
  2756. /**
  2757. * Custom status message to display in spinner while hook runs
  2758. */
  2759. statusMessage?: string;
  2760. /**
  2761. * If true, hook runs once and is removed after execution
  2762. */
  2763. once?: boolean;
  2764. /**
  2765. * If true, hook runs in background without blocking
  2766. */
  2767. async?: boolean;
  2768. /**
  2769. * If true, hook runs in background and wakes the model on exit code 2 (blocking error). Implies async.
  2770. */
  2771. asyncRewake?: boolean;
  2772. } | {
  2773. /**
  2774. * LLM prompt hook type
  2775. */
  2776. type: 'prompt';
  2777. /**
  2778. * Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON.
  2779. */
  2780. prompt: string;
  2781. /**
  2782. * Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.
  2783. */
  2784. if?: string;
  2785. /**
  2786. * Timeout in seconds for this specific prompt evaluation
  2787. */
  2788. timeout?: number;
  2789. /**
  2790. * Model to use for this prompt hook (e.g., "claude-sonnet-4-6"). If not specified, uses the default small fast model.
  2791. */
  2792. model?: string;
  2793. /**
  2794. * Custom status message to display in spinner while hook runs
  2795. */
  2796. statusMessage?: string;
  2797. /**
  2798. * If true, hook runs once and is removed after execution
  2799. */
  2800. once?: boolean;
  2801. } | {
  2802. /**
  2803. * Agentic verifier hook type
  2804. */
  2805. type: 'agent';
  2806. /**
  2807. * Prompt describing what to verify (e.g. "Verify that unit tests ran and passed."). Use $ARGUMENTS placeholder for hook input JSON.
  2808. */
  2809. prompt: string;
  2810. /**
  2811. * Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.
  2812. */
  2813. if?: string;
  2814. /**
  2815. * Timeout in seconds for agent execution (default 60)
  2816. */
  2817. timeout?: number;
  2818. /**
  2819. * Model to use for this agent hook (e.g., "claude-sonnet-4-6"). If not specified, uses Haiku.
  2820. */
  2821. model?: string;
  2822. /**
  2823. * Custom status message to display in spinner while hook runs
  2824. */
  2825. statusMessage?: string;
  2826. /**
  2827. * If true, hook runs once and is removed after execution
  2828. */
  2829. once?: boolean;
  2830. } | {
  2831. /**
  2832. * HTTP hook type
  2833. */
  2834. type: 'http';
  2835. /**
  2836. * URL to POST the hook input JSON to
  2837. */
  2838. url: string;
  2839. /**
  2840. * Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.
  2841. */
  2842. if?: string;
  2843. /**
  2844. * Timeout in seconds for this specific request
  2845. */
  2846. timeout?: number;
  2847. /**
  2848. * Additional headers to include in the request. Values may reference environment variables using $VAR_NAME or ${VAR_NAME} syntax (e.g., "Authorization": "Bearer $MY_TOKEN"). Only variables listed in allowedEnvVars will be interpolated.
  2849. */
  2850. headers?: {
  2851. [k: string]: string;
  2852. };
  2853. /**
  2854. * Explicit list of environment variable names that may be interpolated in header values. Only variables listed here will be resolved; all other $VAR references are left as empty strings. Required for env var interpolation to work.
  2855. */
  2856. allowedEnvVars?: string[];
  2857. /**
  2858. * Custom status message to display in spinner while hook runs
  2859. */
  2860. statusMessage?: string;
  2861. /**
  2862. * If true, hook runs once and is removed after execution
  2863. */
  2864. once?: boolean;
  2865. })[];
  2866. }[];
  2867. };
  2868. /**
  2869. * Git worktree configuration for --worktree flag.
  2870. */
  2871. worktree?: {
  2872. /**
  2873. * Directories to symlink from main repository to worktrees to avoid disk bloat. Must be explicitly configured - no directories are symlinked by default. Common examples: "node_modules", ".cache", ".bin"
  2874. */
  2875. symlinkDirectories?: string[];
  2876. /**
  2877. * Directories to include when creating worktrees, via git sparse-checkout (cone mode). Dramatically faster in large monorepos — only the listed paths are written to disk.
  2878. */
  2879. sparsePaths?: string[];
  2880. };
  2881. /**
  2882. * Disable all hooks and statusLine execution
  2883. */
  2884. disableAllHooks?: boolean;
  2885. /**
  2886. * Default shell for input-box ! commands. Defaults to 'bash' on all platforms (no Windows auto-flip).
  2887. */
  2888. defaultShell?: 'bash' | 'powershell';
  2889. /**
  2890. * When true (and set in managed settings), only hooks from managed settings run. User, project, and local hooks are ignored.
  2891. */
  2892. allowManagedHooksOnly?: boolean;
  2893. /**
  2894. * Allowlist of URL patterns that HTTP hooks may target. Supports * as a wildcard (e.g. "https://hooks.example.com/*"). When set, HTTP hooks with non-matching URLs are blocked. If undefined, all URLs are allowed. If empty array, no HTTP hooks are allowed. Arrays merge across settings sources (same semantics as allowedMcpServers).
  2895. */
  2896. allowedHttpHookUrls?: string[];
  2897. /**
  2898. * Allowlist of environment variable names HTTP hooks may interpolate into headers. When set, each hook's effective allowedEnvVars is the intersection with this list. If undefined, no restriction is applied. Arrays merge across settings sources (same semantics as allowedMcpServers).
  2899. */
  2900. httpHookAllowedEnvVars?: string[];
  2901. /**
  2902. * When true (and set in managed settings), only permission rules (allow/deny/ask) from managed settings are respected. User, project, local, and CLI argument permission rules are ignored.
  2903. */
  2904. allowManagedPermissionRulesOnly?: boolean;
  2905. /**
  2906. * When true (and set in managed settings), allowedMcpServers is only read from managed settings. deniedMcpServers still merges from all sources, so users can deny servers for themselves. Users can still add their own MCP servers, but only the admin-defined allowlist applies.
  2907. */
  2908. allowManagedMcpServersOnly?: boolean;
  2909. /**
  2910. * When set in managed settings, blocks non-plugin customization sources for the listed surfaces. Array form locks specific surfaces (e.g. ["skills", "hooks"]); `true` locks all four; `false` is an explicit no-op. Blocked: ~/.claude/{surface}/, .claude/{surface}/ (project), settings.json hooks, .mcp.json. NOT blocked: managed (policySettings) sources, plugin-provided customizations. Composes with strictKnownMarketplaces for end-to-end admin control — plugins gated by marketplace allowlist, everything else blocked here.
  2911. */
  2912. strictPluginOnlyCustomization?: boolean | ('skills' | 'agents' | 'hooks' | 'mcp')[];
  2913. /**
  2914. * Custom status line display configuration
  2915. */
  2916. statusLine?: {
  2917. type: 'command';
  2918. command: string;
  2919. padding?: number;
  2920. };
  2921. /**
  2922. * Enabled plugins using plugin-id\@marketplace-id format. Example: { "formatter\@anthropic-tools": true }. Also supports extended format with version constraints.
  2923. */
  2924. enabledPlugins?: {
  2925. [k: string]: string[] | boolean | {
  2926. [k: string]: unknown;
  2927. };
  2928. };
  2929. /**
  2930. * Additional marketplaces to make available for this repository. Typically used in repository .claude/settings.json to ensure team members have required plugin sources.
  2931. */
  2932. extraKnownMarketplaces?: {
  2933. [k: string]: {
  2934. /**
  2935. * Where to fetch the marketplace from
  2936. */
  2937. source: {
  2938. source: 'url';
  2939. /**
  2940. * Direct URL to marketplace.json file
  2941. */
  2942. url: string;
  2943. /**
  2944. * Custom HTTP headers (e.g., for authentication)
  2945. */
  2946. headers?: {
  2947. [k: string]: string;
  2948. };
  2949. } | {
  2950. source: 'github';
  2951. /**
  2952. * GitHub repository in owner/repo format
  2953. */
  2954. repo: string;
  2955. /**
  2956. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  2957. */
  2958. ref?: string;
  2959. /**
  2960. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  2961. */
  2962. path?: string;
  2963. /**
  2964. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  2965. */
  2966. sparsePaths?: string[];
  2967. } | {
  2968. source: 'git';
  2969. /**
  2970. * Full git repository URL
  2971. */
  2972. url: string;
  2973. /**
  2974. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  2975. */
  2976. ref?: string;
  2977. /**
  2978. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  2979. */
  2980. path?: string;
  2981. /**
  2982. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  2983. */
  2984. sparsePaths?: string[];
  2985. } | {
  2986. source: 'npm';
  2987. /**
  2988. * NPM package containing marketplace.json
  2989. */
  2990. package: string;
  2991. } | {
  2992. source: 'file';
  2993. /**
  2994. * Local file path to marketplace.json
  2995. */
  2996. path: string;
  2997. } | {
  2998. source: 'directory';
  2999. /**
  3000. * Local directory containing .claude-plugin/marketplace.json
  3001. */
  3002. path: string;
  3003. } | {
  3004. source: 'hostPattern';
  3005. /**
  3006. * Regex pattern to match the host/domain extracted from any marketplace source type. For github sources, matches against "github.com". For git sources (SSH or HTTPS), extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all marketplaces from a specific host (e.g., "^github\.mycompany\.com$").
  3007. */
  3008. hostPattern: string;
  3009. } | {
  3010. source: 'pathPattern';
  3011. /**
  3012. * Regex pattern matched against the .path field of file and directory sources. Use in strictKnownMarketplaces to allow filesystem-based marketplaces alongside hostPattern restrictions for network sources. Use ".*" to allow all filesystem paths, or a narrower pattern (e.g., "^/opt/approved/") to restrict to specific directories.
  3013. */
  3014. pathPattern: string;
  3015. } | {
  3016. source: 'settings';
  3017. /**
  3018. * Marketplace name. Must match the extraKnownMarketplaces key (enforced); the synthetic manifest is written under this name. Same validation as PluginMarketplaceSchema plus reserved-name rejection — validateOfficialNameSource runs after the disk write, too late to clean up.
  3019. */
  3020. name: string;
  3021. /**
  3022. * Plugin entries declared inline in settings.json
  3023. */
  3024. plugins: {
  3025. /**
  3026. * Plugin name as it appears in the target repository
  3027. */
  3028. name: string;
  3029. /**
  3030. * Where to fetch the plugin from. Must be a remote source — relative paths have no marketplace repository to resolve against.
  3031. */
  3032. source: string | {
  3033. source: 'npm';
  3034. /**
  3035. * Package name (or url, or local path, or anything else that can be passed to `npm` as a package)
  3036. */
  3037. package: string;
  3038. /**
  3039. * Specific version or version range (e.g., ^1.0.0, ~2.1.0)
  3040. */
  3041. version?: string;
  3042. /**
  3043. * Custom NPM registry URL (defaults to using system default, likely npmjs.org)
  3044. */
  3045. registry?: string;
  3046. } | {
  3047. source: 'pip';
  3048. /**
  3049. * Python package name as it appears on PyPI
  3050. */
  3051. package: string;
  3052. /**
  3053. * Version specifier (e.g., ==1.0.0, >=2.0.0, <3.0.0)
  3054. */
  3055. version?: string;
  3056. /**
  3057. * Custom PyPI registry URL (defaults to using system default, likely pypi.org)
  3058. */
  3059. registry?: string;
  3060. } | {
  3061. source: 'url';
  3062. /**
  3063. * Full git repository URL (https:// or git\@)
  3064. */
  3065. url: string;
  3066. /**
  3067. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3068. */
  3069. ref?: string;
  3070. /**
  3071. * Specific commit SHA to use
  3072. */
  3073. sha?: string;
  3074. } | {
  3075. source: 'github';
  3076. /**
  3077. * GitHub repository in owner/repo format
  3078. */
  3079. repo: string;
  3080. /**
  3081. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3082. */
  3083. ref?: string;
  3084. /**
  3085. * Specific commit SHA to use
  3086. */
  3087. sha?: string;
  3088. } | {
  3089. source: 'git-subdir';
  3090. /**
  3091. * Git repository: GitHub owner/repo shorthand, https://, or git\@ URL
  3092. */
  3093. url: string;
  3094. /**
  3095. * Subdirectory within the repo containing the plugin (e.g., "tools/claude-plugin"). Cloned sparsely using partial clone (--filter=tree:0) to minimize bandwidth for monorepos.
  3096. */
  3097. path: string;
  3098. /**
  3099. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3100. */
  3101. ref?: string;
  3102. /**
  3103. * Specific commit SHA to use
  3104. */
  3105. sha?: string;
  3106. };
  3107. description?: string;
  3108. version?: string;
  3109. strict?: boolean;
  3110. }[];
  3111. owner?: {
  3112. /**
  3113. * Display name of the plugin author or organization
  3114. */
  3115. name: string;
  3116. /**
  3117. * Contact email for support or feedback
  3118. */
  3119. email?: string;
  3120. /**
  3121. * Website, GitHub profile, or organization URL
  3122. */
  3123. url?: string;
  3124. };
  3125. };
  3126. /**
  3127. * Local cache path where marketplace manifest is stored (auto-generated if not provided)
  3128. */
  3129. installLocation?: string;
  3130. /**
  3131. * Whether to automatically update this marketplace and its installed plugins on startup
  3132. */
  3133. autoUpdate?: boolean;
  3134. };
  3135. };
  3136. /**
  3137. * Enterprise strict list of allowed marketplace sources. When set in managed settings, ONLY these exact sources can be added as marketplaces. The check happens BEFORE downloading, so blocked sources never touch the filesystem. Note: this is a policy gate only — it does NOT register marketplaces. To pre-register allowed marketplaces for users, also set extraKnownMarketplaces.
  3138. */
  3139. strictKnownMarketplaces?: ({
  3140. source: 'url';
  3141. /**
  3142. * Direct URL to marketplace.json file
  3143. */
  3144. url: string;
  3145. /**
  3146. * Custom HTTP headers (e.g., for authentication)
  3147. */
  3148. headers?: {
  3149. [k: string]: string;
  3150. };
  3151. } | {
  3152. source: 'github';
  3153. /**
  3154. * GitHub repository in owner/repo format
  3155. */
  3156. repo: string;
  3157. /**
  3158. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3159. */
  3160. ref?: string;
  3161. /**
  3162. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  3163. */
  3164. path?: string;
  3165. /**
  3166. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  3167. */
  3168. sparsePaths?: string[];
  3169. } | {
  3170. source: 'git';
  3171. /**
  3172. * Full git repository URL
  3173. */
  3174. url: string;
  3175. /**
  3176. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3177. */
  3178. ref?: string;
  3179. /**
  3180. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  3181. */
  3182. path?: string;
  3183. /**
  3184. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  3185. */
  3186. sparsePaths?: string[];
  3187. } | {
  3188. source: 'npm';
  3189. /**
  3190. * NPM package containing marketplace.json
  3191. */
  3192. package: string;
  3193. } | {
  3194. source: 'file';
  3195. /**
  3196. * Local file path to marketplace.json
  3197. */
  3198. path: string;
  3199. } | {
  3200. source: 'directory';
  3201. /**
  3202. * Local directory containing .claude-plugin/marketplace.json
  3203. */
  3204. path: string;
  3205. } | {
  3206. source: 'hostPattern';
  3207. /**
  3208. * Regex pattern to match the host/domain extracted from any marketplace source type. For github sources, matches against "github.com". For git sources (SSH or HTTPS), extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all marketplaces from a specific host (e.g., "^github\.mycompany\.com$").
  3209. */
  3210. hostPattern: string;
  3211. } | {
  3212. source: 'pathPattern';
  3213. /**
  3214. * Regex pattern matched against the .path field of file and directory sources. Use in strictKnownMarketplaces to allow filesystem-based marketplaces alongside hostPattern restrictions for network sources. Use ".*" to allow all filesystem paths, or a narrower pattern (e.g., "^/opt/approved/") to restrict to specific directories.
  3215. */
  3216. pathPattern: string;
  3217. } | {
  3218. source: 'settings';
  3219. /**
  3220. * Marketplace name. Must match the extraKnownMarketplaces key (enforced); the synthetic manifest is written under this name. Same validation as PluginMarketplaceSchema plus reserved-name rejection — validateOfficialNameSource runs after the disk write, too late to clean up.
  3221. */
  3222. name: string;
  3223. /**
  3224. * Plugin entries declared inline in settings.json
  3225. */
  3226. plugins: {
  3227. /**
  3228. * Plugin name as it appears in the target repository
  3229. */
  3230. name: string;
  3231. /**
  3232. * Where to fetch the plugin from. Must be a remote source — relative paths have no marketplace repository to resolve against.
  3233. */
  3234. source: string | {
  3235. source: 'npm';
  3236. /**
  3237. * Package name (or url, or local path, or anything else that can be passed to `npm` as a package)
  3238. */
  3239. package: string;
  3240. /**
  3241. * Specific version or version range (e.g., ^1.0.0, ~2.1.0)
  3242. */
  3243. version?: string;
  3244. /**
  3245. * Custom NPM registry URL (defaults to using system default, likely npmjs.org)
  3246. */
  3247. registry?: string;
  3248. } | {
  3249. source: 'pip';
  3250. /**
  3251. * Python package name as it appears on PyPI
  3252. */
  3253. package: string;
  3254. /**
  3255. * Version specifier (e.g., ==1.0.0, >=2.0.0, <3.0.0)
  3256. */
  3257. version?: string;
  3258. /**
  3259. * Custom PyPI registry URL (defaults to using system default, likely pypi.org)
  3260. */
  3261. registry?: string;
  3262. } | {
  3263. source: 'url';
  3264. /**
  3265. * Full git repository URL (https:// or git\@)
  3266. */
  3267. url: string;
  3268. /**
  3269. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3270. */
  3271. ref?: string;
  3272. /**
  3273. * Specific commit SHA to use
  3274. */
  3275. sha?: string;
  3276. } | {
  3277. source: 'github';
  3278. /**
  3279. * GitHub repository in owner/repo format
  3280. */
  3281. repo: string;
  3282. /**
  3283. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3284. */
  3285. ref?: string;
  3286. /**
  3287. * Specific commit SHA to use
  3288. */
  3289. sha?: string;
  3290. } | {
  3291. source: 'git-subdir';
  3292. /**
  3293. * Git repository: GitHub owner/repo shorthand, https://, or git\@ URL
  3294. */
  3295. url: string;
  3296. /**
  3297. * Subdirectory within the repo containing the plugin (e.g., "tools/claude-plugin"). Cloned sparsely using partial clone (--filter=tree:0) to minimize bandwidth for monorepos.
  3298. */
  3299. path: string;
  3300. /**
  3301. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3302. */
  3303. ref?: string;
  3304. /**
  3305. * Specific commit SHA to use
  3306. */
  3307. sha?: string;
  3308. };
  3309. description?: string;
  3310. version?: string;
  3311. strict?: boolean;
  3312. }[];
  3313. owner?: {
  3314. /**
  3315. * Display name of the plugin author or organization
  3316. */
  3317. name: string;
  3318. /**
  3319. * Contact email for support or feedback
  3320. */
  3321. email?: string;
  3322. /**
  3323. * Website, GitHub profile, or organization URL
  3324. */
  3325. url?: string;
  3326. };
  3327. })[];
  3328. /**
  3329. * Enterprise blocklist of marketplace sources. When set in managed settings, these exact sources are blocked from being added as marketplaces. The check happens BEFORE downloading, so blocked sources never touch the filesystem.
  3330. */
  3331. blockedMarketplaces?: ({
  3332. source: 'url';
  3333. /**
  3334. * Direct URL to marketplace.json file
  3335. */
  3336. url: string;
  3337. /**
  3338. * Custom HTTP headers (e.g., for authentication)
  3339. */
  3340. headers?: {
  3341. [k: string]: string;
  3342. };
  3343. } | {
  3344. source: 'github';
  3345. /**
  3346. * GitHub repository in owner/repo format
  3347. */
  3348. repo: string;
  3349. /**
  3350. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3351. */
  3352. ref?: string;
  3353. /**
  3354. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  3355. */
  3356. path?: string;
  3357. /**
  3358. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  3359. */
  3360. sparsePaths?: string[];
  3361. } | {
  3362. source: 'git';
  3363. /**
  3364. * Full git repository URL
  3365. */
  3366. url: string;
  3367. /**
  3368. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3369. */
  3370. ref?: string;
  3371. /**
  3372. * Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)
  3373. */
  3374. path?: string;
  3375. /**
  3376. * Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.
  3377. */
  3378. sparsePaths?: string[];
  3379. } | {
  3380. source: 'npm';
  3381. /**
  3382. * NPM package containing marketplace.json
  3383. */
  3384. package: string;
  3385. } | {
  3386. source: 'file';
  3387. /**
  3388. * Local file path to marketplace.json
  3389. */
  3390. path: string;
  3391. } | {
  3392. source: 'directory';
  3393. /**
  3394. * Local directory containing .claude-plugin/marketplace.json
  3395. */
  3396. path: string;
  3397. } | {
  3398. source: 'hostPattern';
  3399. /**
  3400. * Regex pattern to match the host/domain extracted from any marketplace source type. For github sources, matches against "github.com". For git sources (SSH or HTTPS), extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all marketplaces from a specific host (e.g., "^github\.mycompany\.com$").
  3401. */
  3402. hostPattern: string;
  3403. } | {
  3404. source: 'pathPattern';
  3405. /**
  3406. * Regex pattern matched against the .path field of file and directory sources. Use in strictKnownMarketplaces to allow filesystem-based marketplaces alongside hostPattern restrictions for network sources. Use ".*" to allow all filesystem paths, or a narrower pattern (e.g., "^/opt/approved/") to restrict to specific directories.
  3407. */
  3408. pathPattern: string;
  3409. } | {
  3410. source: 'settings';
  3411. /**
  3412. * Marketplace name. Must match the extraKnownMarketplaces key (enforced); the synthetic manifest is written under this name. Same validation as PluginMarketplaceSchema plus reserved-name rejection — validateOfficialNameSource runs after the disk write, too late to clean up.
  3413. */
  3414. name: string;
  3415. /**
  3416. * Plugin entries declared inline in settings.json
  3417. */
  3418. plugins: {
  3419. /**
  3420. * Plugin name as it appears in the target repository
  3421. */
  3422. name: string;
  3423. /**
  3424. * Where to fetch the plugin from. Must be a remote source — relative paths have no marketplace repository to resolve against.
  3425. */
  3426. source: string | {
  3427. source: 'npm';
  3428. /**
  3429. * Package name (or url, or local path, or anything else that can be passed to `npm` as a package)
  3430. */
  3431. package: string;
  3432. /**
  3433. * Specific version or version range (e.g., ^1.0.0, ~2.1.0)
  3434. */
  3435. version?: string;
  3436. /**
  3437. * Custom NPM registry URL (defaults to using system default, likely npmjs.org)
  3438. */
  3439. registry?: string;
  3440. } | {
  3441. source: 'pip';
  3442. /**
  3443. * Python package name as it appears on PyPI
  3444. */
  3445. package: string;
  3446. /**
  3447. * Version specifier (e.g., ==1.0.0, >=2.0.0, <3.0.0)
  3448. */
  3449. version?: string;
  3450. /**
  3451. * Custom PyPI registry URL (defaults to using system default, likely pypi.org)
  3452. */
  3453. registry?: string;
  3454. } | {
  3455. source: 'url';
  3456. /**
  3457. * Full git repository URL (https:// or git\@)
  3458. */
  3459. url: string;
  3460. /**
  3461. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3462. */
  3463. ref?: string;
  3464. /**
  3465. * Specific commit SHA to use
  3466. */
  3467. sha?: string;
  3468. } | {
  3469. source: 'github';
  3470. /**
  3471. * GitHub repository in owner/repo format
  3472. */
  3473. repo: string;
  3474. /**
  3475. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3476. */
  3477. ref?: string;
  3478. /**
  3479. * Specific commit SHA to use
  3480. */
  3481. sha?: string;
  3482. } | {
  3483. source: 'git-subdir';
  3484. /**
  3485. * Git repository: GitHub owner/repo shorthand, https://, or git\@ URL
  3486. */
  3487. url: string;
  3488. /**
  3489. * Subdirectory within the repo containing the plugin (e.g., "tools/claude-plugin"). Cloned sparsely using partial clone (--filter=tree:0) to minimize bandwidth for monorepos.
  3490. */
  3491. path: string;
  3492. /**
  3493. * Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.
  3494. */
  3495. ref?: string;
  3496. /**
  3497. * Specific commit SHA to use
  3498. */
  3499. sha?: string;
  3500. };
  3501. description?: string;
  3502. version?: string;
  3503. strict?: boolean;
  3504. }[];
  3505. owner?: {
  3506. /**
  3507. * Display name of the plugin author or organization
  3508. */
  3509. name: string;
  3510. /**
  3511. * Contact email for support or feedback
  3512. */
  3513. email?: string;
  3514. /**
  3515. * Website, GitHub profile, or organization URL
  3516. */
  3517. url?: string;
  3518. };
  3519. })[];
  3520. /**
  3521. * Force a specific login method: "claudeai" for Claude Pro/Max, "console" for Console billing
  3522. */
  3523. forceLoginMethod?: 'claudeai' | 'console';
  3524. /**
  3525. * Organization UUID to use for OAuth login
  3526. */
  3527. forceLoginOrgUUID?: string;
  3528. /**
  3529. * Path to a script that outputs OpenTelemetry headers
  3530. */
  3531. otelHeadersHelper?: string;
  3532. /**
  3533. * Controls the output style for assistant responses
  3534. */
  3535. outputStyle?: string;
  3536. /**
  3537. * Preferred language for Claude responses and voice dictation (e.g., "japanese", "spanish")
  3538. */
  3539. language?: string;
  3540. /**
  3541. * Skip the WebFetch blocklist check for enterprise environments with restrictive security policies
  3542. */
  3543. skipWebFetchPreflight?: boolean;
  3544. sandbox?: {
  3545. enabled?: boolean;
  3546. /**
  3547. * Exit with an error at startup if sandbox.enabled is true but the sandbox cannot start (missing dependencies, unsupported platform, or platform not in enabledPlatforms). When false (default), a warning is shown and commands run unsandboxed. Intended for managed-settings deployments that require sandboxing as a hard gate.
  3548. */
  3549. failIfUnavailable?: boolean;
  3550. autoAllowBashIfSandboxed?: boolean;
  3551. /**
  3552. * Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true.
  3553. */
  3554. allowUnsandboxedCommands?: boolean;
  3555. network?: {
  3556. allowedDomains?: string[];
  3557. /**
  3558. * When true (and set in managed settings), only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. User, project, local, and flag settings domains are ignored. Denied domains are still respected from all sources.
  3559. */
  3560. allowManagedDomainsOnly?: boolean;
  3561. /**
  3562. * macOS only: Unix socket paths to allow. Ignored on Linux (seccomp cannot filter by path).
  3563. */
  3564. allowUnixSockets?: string[];
  3565. /**
  3566. * If true, allow all Unix sockets (disables blocking on both platforms).
  3567. */
  3568. allowAllUnixSockets?: boolean;
  3569. allowLocalBinding?: boolean;
  3570. httpProxyPort?: number;
  3571. socksProxyPort?: number;
  3572. };
  3573. filesystem?: {
  3574. /**
  3575. * Additional paths to allow writing within the sandbox. Merged with paths from Edit(...) allow permission rules.
  3576. */
  3577. allowWrite?: string[];
  3578. /**
  3579. * Additional paths to deny writing within the sandbox. Merged with paths from Edit(...) deny permission rules.
  3580. */
  3581. denyWrite?: string[];
  3582. /**
  3583. * Additional paths to deny reading within the sandbox. Merged with paths from Read(...) deny permission rules.
  3584. */
  3585. denyRead?: string[];
  3586. /**
  3587. * Paths to re-allow reading within denyRead regions. Takes precedence over denyRead for matching paths.
  3588. */
  3589. allowRead?: string[];
  3590. /**
  3591. * When true (set in managed settings), only allowRead paths from policySettings are used.
  3592. */
  3593. allowManagedReadPathsOnly?: boolean;
  3594. };
  3595. ignoreViolations?: {
  3596. [k: string]: string[];
  3597. };
  3598. enableWeakerNestedSandbox?: boolean;
  3599. /**
  3600. * macOS only: Allow access to com.apple.trustd.agent in the sandbox. Needed for Go-based CLI tools (gh, gcloud, terraform, etc.) to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. **Reduces security** — opens a potential data exfiltration vector through the trustd service. Default: false
  3601. */
  3602. enableWeakerNetworkIsolation?: boolean;
  3603. excludedCommands?: string[];
  3604. /**
  3605. * Custom ripgrep configuration for bundled ripgrep support
  3606. */
  3607. ripgrep?: {
  3608. command: string;
  3609. args?: string[];
  3610. };
  3611. [k: string]: unknown;
  3612. };
  3613. /**
  3614. * Probability (0–1) that the session quality survey appears when eligible. 0.05 is a reasonable starting point.
  3615. */
  3616. feedbackSurveyRate?: number;
  3617. /**
  3618. * Whether to show tips in the spinner
  3619. */
  3620. spinnerTipsEnabled?: boolean;
  3621. /**
  3622. * Customize spinner verbs. mode: "append" adds verbs to defaults, "replace" uses only your verbs.
  3623. */
  3624. spinnerVerbs?: {
  3625. mode: 'append' | 'replace';
  3626. verbs: string[];
  3627. };
  3628. /**
  3629. * Override spinner tips. tips: array of tip strings. excludeDefault: if true, only show custom tips (default: false).
  3630. */
  3631. spinnerTipsOverride?: {
  3632. excludeDefault?: boolean;
  3633. tips: string[];
  3634. };
  3635. /**
  3636. * Whether to disable syntax highlighting in diffs
  3637. */
  3638. syntaxHighlightingDisabled?: boolean;
  3639. /**
  3640. * Whether /rename updates the terminal tab title (defaults to true). Set to false to keep auto-generated topic titles.
  3641. */
  3642. terminalTitleFromRename?: boolean;
  3643. /**
  3644. * When false, thinking is disabled. When absent or true, thinking is enabled automatically for supported models.
  3645. */
  3646. alwaysThinkingEnabled?: boolean;
  3647. /**
  3648. * Persisted effort level for supported models.
  3649. */
  3650. effortLevel?: 'low' | 'medium' | 'high';
  3651. /**
  3652. * Advisor model for the server-side advisor tool.
  3653. */
  3654. advisorModel?: string;
  3655. /**
  3656. * When true, fast mode is enabled. When absent or false, fast mode is off.
  3657. */
  3658. fastMode?: boolean;
  3659. /**
  3660. * When true, fast mode does not persist across sessions. Each session starts with fast mode off.
  3661. */
  3662. fastModePerSessionOptIn?: boolean;
  3663. /**
  3664. * When false, prompt suggestions are disabled. When absent or true, prompt suggestions are enabled.
  3665. */
  3666. promptSuggestionEnabled?: boolean;
  3667. /**
  3668. * When true, the plan-approval dialog offers a "clear context" option. Defaults to false.
  3669. */
  3670. showClearContextOnPlanAccept?: boolean;
  3671. /**
  3672. * Name of an agent (built-in or custom) to use for the main thread. Applies the agent's system prompt, tool restrictions, and model.
  3673. */
  3674. agent?: string;
  3675. /**
  3676. * Company announcements to display at startup (one will be randomly selected if multiple are provided)
  3677. */
  3678. companyAnnouncements?: string[];
  3679. /**
  3680. * Per-plugin configuration including MCP server user configs, keyed by plugin ID (plugin\@marketplace format)
  3681. */
  3682. pluginConfigs?: {
  3683. [k: string]: {
  3684. /**
  3685. * User configuration values for MCP servers keyed by server name
  3686. */
  3687. mcpServers?: {
  3688. [k: string]: {
  3689. [k: string]: string | number | boolean | string[];
  3690. };
  3691. };
  3692. /**
  3693. * Non-sensitive option values from plugin manifest userConfig, keyed by option name. Sensitive values go to secure storage instead.
  3694. */
  3695. options?: {
  3696. [k: string]: string | number | boolean | string[];
  3697. };
  3698. };
  3699. };
  3700. /**
  3701. * Remote session configuration
  3702. */
  3703. remote?: {
  3704. /**
  3705. * Default environment ID to use for remote sessions
  3706. */
  3707. defaultEnvironmentId?: string;
  3708. };
  3709. /**
  3710. * Release channel for auto-updates (latest or stable)
  3711. */
  3712. autoUpdatesChannel?: 'latest' | 'stable';
  3713. /**
  3714. * Minimum version to stay on - prevents downgrades when switching to stable channel
  3715. */
  3716. minimumVersion?: string;
  3717. /**
  3718. * Custom directory for plan files, relative to project root. If not set, defaults to ~/.claude/plans/
  3719. */
  3720. plansDirectory?: string;
  3721. /**
  3722. * Teams/Enterprise opt-in for channel notifications (MCP servers with the claude/channel capability pushing inbound messages). Default off. Set true to allow; users then select servers via --channels.
  3723. */
  3724. channelsEnabled?: boolean;
  3725. /**
  3726. * Teams/Enterprise allowlist of channel plugins. When set, replaces the default Anthropic allowlist — admins decide which plugins may push inbound messages. Undefined falls back to the default. Requires channelsEnabled: true.
  3727. */
  3728. allowedChannelPlugins?: {
  3729. marketplace: string;
  3730. plugin: string;
  3731. }[];
  3732. /**
  3733. * Reduce or disable animations for accessibility (spinner shimmer, flash effects, etc.)
  3734. */
  3735. prefersReducedMotion?: boolean;
  3736. /**
  3737. * Enable auto-memory for this project. When false, Claude will not read from or write to the auto-memory directory.
  3738. */
  3739. autoMemoryEnabled?: boolean;
  3740. /**
  3741. * Custom directory path for auto-memory storage. Supports ~/ prefix for home directory expansion. Ignored if set in projectSettings (checked-in .claude/settings.json) for security. When unset, defaults to ~/.claude/projects/<sanitized-cwd>/memory/.
  3742. */
  3743. autoMemoryDirectory?: string;
  3744. /**
  3745. * Enable background memory consolidation (auto-dream). When set, overrides the server-side default.
  3746. */
  3747. autoDreamEnabled?: boolean;
  3748. /**
  3749. * Show thinking summaries in the transcript view (ctrl+o). Default: false.
  3750. */
  3751. showThinkingSummaries?: boolean;
  3752. /**
  3753. * Whether the user has accepted the bypass permissions mode dialog
  3754. */
  3755. skipDangerousModePermissionPrompt?: boolean;
  3756. /**
  3757. * Disable auto mode
  3758. */
  3759. disableAutoMode?: 'disable';
  3760. /**
  3761. * SSH connection configurations for remote environments. Typically set in managed settings by enterprise administrators to pre-configure SSH connections for team members.
  3762. */
  3763. sshConfigs?: {
  3764. /**
  3765. * Unique identifier for this SSH config. Used to match configs across settings sources.
  3766. */
  3767. id: string;
  3768. /**
  3769. * Display name for the SSH connection
  3770. */
  3771. name: string;
  3772. /**
  3773. * SSH host in format "user\@hostname" or "hostname", or a host alias from ~/.ssh/config
  3774. */
  3775. sshHost: string;
  3776. /**
  3777. * SSH port (default: 22)
  3778. */
  3779. sshPort?: number;
  3780. /**
  3781. * Path to SSH identity file (private key)
  3782. */
  3783. sshIdentityFile?: string;
  3784. /**
  3785. * Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory. Can be overridden by the [dir] positional argument in `claude ssh <config> [dir]`.
  3786. */
  3787. startDirectory?: string;
  3788. }[];
  3789. /**
  3790. * Glob patterns or absolute paths of CLAUDE.md files to exclude from loading. Patterns are matched against absolute file paths using picomatch. Only applies to User, Project, and Local memory types (Managed/policy files cannot be excluded). Examples: "/home/user/monorepo/CLAUDE.md", "** /code/CLAUDE.md", "** /some-dir/.claude/rules/**"
  3791. */
  3792. claudeMdExcludes?: string[];
  3793. /**
  3794. * Custom message to append to the plugin trust warning shown before installation. Only read from policy settings (managed-settings.json / MDM). Useful for enterprise administrators to add organization-specific context (e.g., "All plugins from our internal marketplace are vetted and approved.").
  3795. */
  3796. pluginTrustMessage?: string;
  3797. [k: string]: unknown;
  3798. }
  3799. /**
  3800. * Source for loading filesystem-based settings. 'user' - Global user settings (~/.claude/settings.json). 'project' - Project settings (.claude/settings.json). 'local' - Local settings (.claude/settings.local.json).
  3801. */
  3802. export declare type SettingSource = 'user' | 'project' | 'local';
  3803. export declare type SetupHookInput = BaseHookInput & {
  3804. hook_event_name: 'Setup';
  3805. trigger: 'init' | 'maintenance';
  3806. };
  3807. export declare type SetupHookSpecificOutput = {
  3808. hookEventName: 'Setup';
  3809. additionalContext?: string;
  3810. };
  3811. /**
  3812. * Information about an available skill (invoked via /command syntax).
  3813. */
  3814. export declare type SlashCommand = {
  3815. /**
  3816. * Skill name (without the leading slash)
  3817. */
  3818. name: string;
  3819. /**
  3820. * Description of what the skill does
  3821. */
  3822. description: string;
  3823. /**
  3824. * Hint for skill arguments (e.g., "<file>")
  3825. */
  3826. argumentHint: string;
  3827. };
  3828. /**
  3829. * Represents a spawned process with stdin/stdout streams and lifecycle management.
  3830. * Implementers provide this interface to abstract the process spawning mechanism.
  3831. * ChildProcess already satisfies this interface.
  3832. */
  3833. export declare interface SpawnedProcess {
  3834. /** Writable stream for sending data to the process stdin */
  3835. stdin: Writable;
  3836. /** Readable stream for receiving data from the process stdout */
  3837. stdout: Readable;
  3838. /** Whether the process has been killed */
  3839. readonly killed: boolean;
  3840. /** Exit code if the process has exited, null otherwise */
  3841. readonly exitCode: number | null;
  3842. /**
  3843. * Kill the process with the given signal
  3844. * @param signal - The signal to send (e.g., 'SIGTERM', 'SIGKILL')
  3845. */
  3846. kill(signal: NodeJS.Signals): boolean;
  3847. /**
  3848. * Register a callback for when the process exits
  3849. * @param event - Must be 'exit'
  3850. * @param listener - Callback receiving exit code and signal
  3851. */
  3852. on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
  3853. /**
  3854. * Register a callback for process errors
  3855. * @param event - Must be 'error'
  3856. * @param listener - Callback receiving the error
  3857. */
  3858. on(event: 'error', listener: (error: Error) => void): void;
  3859. /**
  3860. * Register a one-time callback for when the process exits
  3861. */
  3862. once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
  3863. once(event: 'error', listener: (error: Error) => void): void;
  3864. /**
  3865. * Remove an event listener
  3866. */
  3867. off(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
  3868. off(event: 'error', listener: (error: Error) => void): void;
  3869. }
  3870. /**
  3871. * Options passed to the spawn function.
  3872. */
  3873. export declare interface SpawnOptions {
  3874. /** Command to execute */
  3875. command: string;
  3876. /** Arguments to pass to the command */
  3877. args: string[];
  3878. /** Working directory */
  3879. cwd?: string;
  3880. /** Environment variables */
  3881. env: {
  3882. [envVar: string]: string | undefined;
  3883. };
  3884. /** Abort signal for cancellation */
  3885. signal: AbortSignal;
  3886. }
  3887. declare type StdoutMessage = coreTypes.SDKMessage | coreTypes.SDKStreamlinedTextMessage | coreTypes.SDKStreamlinedToolUseSummaryMessage | coreTypes.SDKPostTurnSummaryMessage | SDKControlResponse | SDKControlRequest | SDKControlCancelRequest | SDKKeepAliveMessage;
  3888. export declare type StopFailureHookInput = BaseHookInput & {
  3889. hook_event_name: 'StopFailure';
  3890. error: SDKAssistantMessageError;
  3891. error_details?: string;
  3892. last_assistant_message?: string;
  3893. };
  3894. export declare type StopHookInput = BaseHookInput & {
  3895. hook_event_name: 'Stop';
  3896. stop_hook_active: boolean;
  3897. /**
  3898. * Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.
  3899. */
  3900. last_assistant_message?: string;
  3901. };
  3902. export declare type SubagentStartHookInput = BaseHookInput & {
  3903. hook_event_name: 'SubagentStart';
  3904. agent_id: string;
  3905. agent_type: string;
  3906. };
  3907. export declare type SubagentStartHookSpecificOutput = {
  3908. hookEventName: 'SubagentStart';
  3909. additionalContext?: string;
  3910. };
  3911. export declare type SubagentStopHookInput = BaseHookInput & {
  3912. hook_event_name: 'SubagentStop';
  3913. stop_hook_active: boolean;
  3914. agent_id: string;
  3915. agent_transcript_path: string;
  3916. agent_type: string;
  3917. /**
  3918. * Text content of the last assistant message before stopping. Avoids the need to read and parse the transcript file.
  3919. */
  3920. last_assistant_message?: string;
  3921. };
  3922. export declare type SyncHookJSONOutput = {
  3923. continue?: boolean;
  3924. suppressOutput?: boolean;
  3925. stopReason?: string;
  3926. decision?: 'approve' | 'block';
  3927. systemMessage?: string;
  3928. reason?: string;
  3929. hookSpecificOutput?: PreToolUseHookSpecificOutput | UserPromptSubmitHookSpecificOutput | SessionStartHookSpecificOutput | SetupHookSpecificOutput | SubagentStartHookSpecificOutput | PostToolUseHookSpecificOutput | PostToolUseFailureHookSpecificOutput | PermissionDeniedHookSpecificOutput | NotificationHookSpecificOutput | PermissionRequestHookSpecificOutput | ElicitationHookSpecificOutput | ElicitationResultHookSpecificOutput | CwdChangedHookSpecificOutput | FileChangedHookSpecificOutput | WorktreeCreateHookSpecificOutput;
  3930. };
  3931. /**
  3932. * Tag a session. Pass null to clear the tag.
  3933. * @param sessionId - UUID of the session
  3934. * @param tag - Tag string, or null to clear
  3935. * @param options - `{ dir?: string }` project path; omit to search all projects
  3936. */
  3937. export declare function tagSession(_sessionId: string, _tag: string | null, _options?: SessionMutationOptions): Promise<void>;
  3938. export declare type TaskCompletedHookInput = BaseHookInput & {
  3939. hook_event_name: 'TaskCompleted';
  3940. task_id: string;
  3941. task_subject: string;
  3942. task_description?: string;
  3943. teammate_name?: string;
  3944. team_name?: string;
  3945. };
  3946. export declare type TaskCreatedHookInput = BaseHookInput & {
  3947. hook_event_name: 'TaskCreated';
  3948. task_id: string;
  3949. task_subject: string;
  3950. task_description?: string;
  3951. teammate_name?: string;
  3952. team_name?: string;
  3953. };
  3954. export declare type TeammateIdleHookInput = BaseHookInput & {
  3955. hook_event_name: 'TeammateIdle';
  3956. teammate_name: string;
  3957. team_name: string;
  3958. };
  3959. /**
  3960. * Claude decides when and how much to think (Opus 4.6+).
  3961. */
  3962. export declare type ThinkingAdaptive = {
  3963. type: 'adaptive';
  3964. };
  3965. /**
  3966. * Controls Claude's thinking/reasoning behavior. When set, takes precedence over the deprecated maxThinkingTokens.
  3967. */
  3968. export declare type ThinkingConfig = ThinkingAdaptive | ThinkingEnabled | ThinkingDisabled;
  3969. /**
  3970. * No extended thinking
  3971. */
  3972. export declare type ThinkingDisabled = {
  3973. type: 'disabled';
  3974. };
  3975. /**
  3976. * Fixed thinking token budget (older models)
  3977. */
  3978. export declare type ThinkingEnabled = {
  3979. type: 'enabled';
  3980. budgetTokens?: number;
  3981. };
  3982. export declare function tool<Schema extends AnyZodRawShape>(_name: string, _description: string, _inputSchema: Schema, _handler: (args: InferShape<Schema>, extra: unknown) => Promise<CallToolResult>, _extras?: {
  3983. annotations?: ToolAnnotations;
  3984. searchHint?: string;
  3985. alwaysLoad?: boolean;
  3986. }): SdkMcpToolDefinition<Schema>;
  3987. /**
  3988. * Per-tool configuration for built-in tools. Allows SDK consumers to
  3989. * customize tool behavior that the CLI hardcodes.
  3990. */
  3991. export declare type ToolConfig = {
  3992. askUserQuestion?: {
  3993. /**
  3994. * Content format for the `preview` field on question options.
  3995. * Controls what the model is instructed to emit and how the field is
  3996. * described in the tool schema.
  3997. *
  3998. * - `'markdown'` — Markdown/ASCII content (CLI default, rendered in a monospace box)
  3999. * - `'html'` — Self-contained HTML fragments (for web-based SDK consumers)
  4000. *
  4001. * @default 'markdown'
  4002. */
  4003. previewFormat?: 'markdown' | 'html';
  4004. };
  4005. };
  4006. /**
  4007. * Transport interface for Claude Code SDK communication
  4008. * Abstracts the communication layer to support both process and WebSocket transports
  4009. */
  4010. export declare interface Transport {
  4011. /**
  4012. * Write data to the transport
  4013. * May be async for network-based transports
  4014. */
  4015. write(data: string): void | Promise<void>;
  4016. /**
  4017. * Close the transport connection and clean up resources
  4018. * This also closes stdin if still open (eliminating need for endInput)
  4019. */
  4020. close(): void;
  4021. /**
  4022. * Check if transport is ready for communication
  4023. */
  4024. isReady(): boolean;
  4025. /**
  4026. * Read and parse messages from the transport
  4027. * Each transport handles its own protocol and error checking
  4028. */
  4029. readMessages(): AsyncGenerator<StdoutMessage, void, unknown>;
  4030. /**
  4031. * End the input stream
  4032. */
  4033. endInput(): void;
  4034. }
  4035. /**
  4036. * V2 API - UNSTABLE
  4037. * Create a persistent session for multi-turn conversations.
  4038. * @alpha
  4039. */
  4040. export declare function unstable_v2_createSession(_options: SDKSessionOptions): SDKSession;
  4041. /**
  4042. * V2 API - UNSTABLE
  4043. * One-shot convenience function for single prompts.
  4044. * @alpha
  4045. *
  4046. * @example
  4047. * ```typescript
  4048. * const result = await unstable_v2_prompt("What files are here?", {
  4049. * model: 'claude-sonnet-4-6'
  4050. * })
  4051. * ```
  4052. */
  4053. export declare function unstable_v2_prompt(_message: string, _options: SDKSessionOptions): Promise<SDKResultMessage>;
  4054. /**
  4055. * V2 API - UNSTABLE
  4056. * Resume an existing session by ID.
  4057. * @alpha
  4058. */
  4059. export declare function unstable_v2_resumeSession(_sessionId: string, _options: SDKSessionOptions): SDKSession;
  4060. export declare type UserPromptSubmitHookInput = BaseHookInput & {
  4061. hook_event_name: 'UserPromptSubmit';
  4062. prompt: string;
  4063. };
  4064. export declare type UserPromptSubmitHookSpecificOutput = {
  4065. hookEventName: 'UserPromptSubmit';
  4066. additionalContext?: string;
  4067. };
  4068. export declare type WorktreeCreateHookInput = BaseHookInput & {
  4069. hook_event_name: 'WorktreeCreate';
  4070. name: string;
  4071. };
  4072. /**
  4073. * Hook-specific output for the WorktreeCreate event. Provides the absolute path to the created worktree directory. Command hooks print the path on stdout instead.
  4074. */
  4075. export declare type WorktreeCreateHookSpecificOutput = {
  4076. hookEventName: 'WorktreeCreate';
  4077. worktreePath: string;
  4078. };
  4079. export declare type WorktreeRemoveHookInput = BaseHookInput & {
  4080. hook_event_name: 'WorktreeRemove';
  4081. worktree_path: string;
  4082. };
  4083. export { }