@anthropic-ai/claude-agent-sdk 0.3.318 → 0.3.319

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
2
+
3
+ // Version: 0.3.319
4
+
5
+ //! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.
6
+ if (typeof Symbol.dispose !== 'symbol') {
7
+ try {
8
+ Symbol.dispose = Symbol.for('Symbol.dispose')
9
+ } catch {}
10
+ }
11
+ if (typeof Symbol.asyncDispose !== 'symbol') {
12
+ try {
13
+ Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')
14
+ } catch {}
15
+ }
16
+ import{d,i,l,n,r,ne,Ke,L,at,ct,W,ke,Ge,dt,je,xe,z}from"./core-ytn251z7.mjs";import{gt}from"./core-actjkrgm.mjs";import{randomUUID as N}from"crypto";import{constants as v}from"fs";import{open as Z,readdir as O,rm as Q,stat as ee}from"fs/promises";import{join as g}from"path";class I{available=void 0;probing=void 0;procUnreadableLogged=!1}var Ye=new i(()=>new I);var j=["commands","agents","output-styles","skills","workflows","routines","themes","rules","session-env","uploads","mcp-skill-archives","usage-data","mcp-discovery-cache"];var pn=new Set(j),mn=`must be one of the userConfigDir directory names (${j.join(", ")})`,k=["installed","marketplaces","flagged","catalog","inUseSweep"];var gn=new Set(k),hn=`must be one of the pluginRegistry files (${k.join(", ")})`,R=["manifest","catalog"];var yn=new Set(R),Sn=`must be one of the marketplaceCache forms (${R.join(", ")})`;var w=["world"];var bn=new Set(w),En=`must be one of the session journal names (${w.join(", ")})`;var P=["backup","corrupted"];var In=new Set(P),jn=`must be one of the global-config copy kinds (${P.join(", ")})`;var Y="cloud-snapshots";var B=new Set(["memory","tiny_memory","bagel",Y,"bridge-pointer.json",".session-aliases"]);var C=".cast",kn=`<stamp>${C} inside a session's folder is that session's terminal recording stream: address it as keys.recording(projectKey, sessionId, stamp)`;var J=[".ccr-tip.json",".precompact.json",C],Rn=`must not end with ${J.join(", ")}: those name a session's project-level sibling files`;var q=".dir-sync.json",wn=`must not end with ${q}: that name is reserved for a cloud session's record at the project level`;var Pn=`${[...B].join(", ")} are reserved: they name project-level entries, not sessions`;var X="timeline.jsonl",Cn=`${X} is the job's timeline stream: address it as keys.jobTimeline(jobId)`;function y(e){return e===void 0?void 0:{source:e,hoverRestOn:d()}}var re=64;function E(e){return d()?e:void 0}async function x(e,t,a={},s){if(!L(e))throw Error(`Invalid sessionId: ${e}`);if(!t.trim())throw Error("title must be non-empty");let o=r({type:"custom-title",customTitle:t.trim(),sessionId:e})+`
17
+ `;await T(e,o,a,E(s))}async function K(e,t,a={},s){if(!L(e))throw Error(`Invalid sessionId: ${e}`);if(t!==null){let c=ne(t).trim();if(!c)throw Error("tag must be non-empty (use null to clear)");t=c}let o=r({type:"tag",tag:t??"",sessionId:e})+`
18
+ `;await T(e,o,a,E(s))}async function A(e,t={},a){if(!L(e))throw Error(`Invalid sessionId: ${e}`);let s=E(a);for(let o of await ae(t,s)){if(d()&&s!==void 0){let u=Ge(o,s.isKeySegment);if(u!==void 0){if(await te(u,e,s))return;continue}}let c=g(o,`${e}.jsonl`),f;try{({size:f}=await ee(c))}catch(u){let p=n(u);if(p==="ENOENT"||p==="ENOTDIR")continue;throw u}if(f===0)continue;await Q(c,{force:!0}),await gt(g(o,e));return}throw Error(t.dir?`Session ${e} not found in project directory for ${t.dir}`:`Session ${e} not found in any project directory`)}async function te(e,t,a){let{backend:s,transcriptKey:o}=a,c=o(e,t),f=await s.statMeta(c);if(!f.ok){if(f.error.code==="NotFound")return!1;throw Error("Session delete: transcript unreadable via storage",{cause:f.error})}if((f.value.storedBytes??f.value.size)===0)return!1;for(let p of["transcript","sidecar"]){let m=await s.deleteScope({namespace:p,projectKey:e,sessionId:t});if(!m.ok)throw Error("Session delete: session directory not deletable via storage",{cause:m.error})}let u=await s.delete(c);if(!u.ok)throw Error("Session delete: transcript not deletable via storage",{cause:u.error});return!0}async function ae(e,t){if(e.dir){let s=await dt(e.dir,at(t,d())),o=await _(s,t),c;try{c=await Ke(s)}catch{c=[]}for(let f of c){if(f===s)continue;o.push(...await _(f,t))}return o}let a=W();if(d()&&t!==void 0){let s=await F(t);if(s===void 0)return[];if(s.laterPageFailed)throw Error("Session delete: project listing incomplete via storage");return s.names.map((o)=>g(a,o))}try{return(await O(a,{withFileTypes:!0})).filter((o)=>o.isDirectory()||o.isSymbolicLink()).map((o)=>g(a,o.name))}catch{return[]}}async function _(e,t){let a=y(t);if(a===void 0||!a.hoverRestOn)return xe(e);let s=await xe(e,a),o=ke(e),c=process.platform==="win32",f=[];for(let u of s)if(u===o||await je(u,e,c,a))f.push(u);return f}async function F(e){let t=[],a,s=0;try{do{let o=await e.backend.listEntries({namespace:"transcript"},{skipScopeStats:!0,...a!==void 0&&{cursor:a}});if(!o.ok)return s===0?void 0:{names:t,laterPageFailed:!0};for(let c of o.value.items){let f=ct(c,e.isKeySegment);if(f!==void 0)t.push(f)}a=o.value.cursor}while(a&&++s<re);return{names:t,laterPageFailed:Boolean(a)}}catch{return s===0&&t.length===0?void 0:{names:t,laterPageFailed:!0}}}async function T(e,t,a,s){let o=`${e}.jsonl`;if(a.dir){let u=await dt(a.dir,at(s,d()));for(let m of await xe(u,y(s)))if(await S(g(m,o),t,b(m,e,s)))return;let p;try{p=await Ke(u)}catch{p=[]}for(let m of p){if(m===u)continue;for(let h of await xe(m,y(s)))if(await S(g(h,o),t,b(h,e,s)))return}throw Error(`Session ${e} not found in project directory for ${a.dir}`)}let c=W();if(d()&&s!==void 0){let u=await F(s);if(u===void 0)throw new l(`Session ${e} not found (no projects directory)`,"Session not found (no projects directory)");let{names:p}=u;for(let m of p){let h=g(c,m);if(await S(g(h,o),t,b(h,e,s)))return}throw new l(`Session ${e} not found in any project directory`,"Session not found in any project directory")}let f;try{f=await O(c)}catch{throw Error(`Session ${e} not found (no projects directory)`)}for(let u of f)if(await S(g(c,u,o),t))return;throw Error(`Session ${e} not found in any project directory`)}async function S(e,t,a){if(d()&&a!==void 0)return se(a,t);let s;try{s=await Z(e,v.O_WRONLY|v.O_APPEND)}catch(o){let c=n(o);if(c==="ENOENT"||c==="ENOTDIR")return!1;throw o}try{let{size:o}=await s.stat();if(o===0)return!1;let c=process.platform==="win32"?o:void 0,f=Buffer.from(t,"utf8"),u=0;while(u<f.length){let{bytesWritten:p}=await s.write(f,u,f.length-u,c);if(p<=0)throw new l(`tryAppend: short write to ${e} stalled with ${f.length-u} bytes remaining`,"tryAppend: zero-progress short write");if(u+=p,c!==void 0)c+=p}return!0}finally{await s.close()}}async function se({backend:e,key:t},a){let s=await e.append(t,[{data:a}],{precondition:{type:"ifExists",nonEmpty:!0}});if(!s.ok){if(s.error.code==="NotFound")return!1;throw Error("Session append: transcript not writable via storage",{cause:s.error})}return!0}function b(e,t,a){if(!d()||a===void 0)return;let s=Ge(e,a.isKeySegment);return s===void 0?void 0:{backend:a.backend,key:a.transcriptKey(s,t)}}async function or(e,t,a){if(a?.sessionStore)return oe(a.sessionStore,e,t,a.dir);return x(e,t,a)}async function ir(e,t,a){if(a?.sessionStore)return ie(a.sessionStore,e,t,a.dir);return K(e,t,a)}async function cr(e,t){if(!L(e))throw new l(`Invalid sessionId: ${e}`,"deleteSession: invalid sessionId (must be a UUID)");if(t?.sessionStore){if(!t.sessionStore.delete)return;let a=z(t.dir);await t.sessionStore.delete({projectKey:a,sessionId:e});return}return A(e,t)}async function oe(e,t,a,s){if(!L(t))throw new l(`Invalid sessionId: ${t}`,"renameSession: invalid sessionId (must be a UUID)");if(!a.trim())throw Error("title must be non-empty");let o=z(s);await e.append({projectKey:o,sessionId:t},[{type:"custom-title",customTitle:a.trim(),sessionId:t,uuid:N(),timestamp:new Date().toISOString()}])}async function ie(e,t,a,s){if(!L(t))throw new l(`Invalid sessionId: ${t}`,"tagSession: invalid sessionId (must be a UUID)");if(a!==null){let c=ne(a).trim();if(!c)throw Error("tag must be non-empty (use null to clear)");a=c}let o=z(s);await e.append({projectKey:o,sessionId:t},[{type:"tag",tag:a??"",sessionId:t,uuid:N(),timestamp:new Date().toISOString()}])}export{cr as deleteSession,or as renameSession,ir as tagSession};
@@ -0,0 +1,17 @@
1
+ // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
2
+
3
+ // Version: 0.3.319
4
+
5
+ //! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.
6
+ if (typeof Symbol.dispose !== 'symbol') {
7
+ try {
8
+ Symbol.dispose = Symbol.for('Symbol.dispose')
9
+ } catch {}
10
+ }
11
+ if (typeof Symbol.asyncDispose !== 'symbol') {
12
+ try {
13
+ Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')
14
+ } catch {}
15
+ }
16
+ import{l,n,Et,O}from"./core-ytn251z7.mjs";import{lstat as i,rm as s,rmdir as m,unlink as h}from"fs/promises";var a=new Set(["EPERM","EACCES","EBUSY"]),E=50;async function gt(e){for(let t=1;;t++){let o=!0;try{await s(e,{recursive:!0,force:!0})}catch(r){if(n(r)!=="ENOTEMPTY")throw r;o=!1}try{await i(e)}catch(r){if(Et(r)||o&&process.platform==="win32"&&a.has(n(r)))return;throw r}if(t===3)throw Object.assign(new l(`'${e}' is still on disk after three tries to delete it. A program may be writing to it, such as a running Claude Code session, or you may not have permission to change it. Stop that program or fix the permissions, then delete it yourself.`,"removeTree: still on disk after three tries"),{code:"ENOTEMPTY"});await O(t*E)}}import{createHash as c}from"crypto";function Se(e){if(typeof e!=="string"&&!ArrayBuffer.isView(e))throw Object.assign(TypeError("sha256Hex: the data is neither text nor bytes"),{code:"ERR_INVALID_ARG_TYPE"});return c("sha256").update(e).digest("hex")}
17
+ export{gt,Se};