@swifty.js/swifty 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/dist/agent-3NON2EXE.js +4 -0
- package/dist/anthropic-BJ5GN2VT.js +4 -0
- package/dist/checker-N5TIJEN5.js +4 -0
- package/dist/{chunk-H7VXSMJR.js → chunk-C3WGLVVZ.js} +10 -10
- package/dist/chunk-D34FUVGU.js +4 -0
- package/dist/chunk-FPQ2LBL4.js +10 -0
- package/dist/chunk-JGSIQXEN.js +4 -0
- package/dist/{chunk-5KXBVL2A.js → chunk-K5ZK27BX.js} +1 -1
- package/dist/chunk-LZBOXJX2.js +301 -0
- package/dist/chunk-OTVZGPHD.js +121 -0
- package/dist/chunk-QCKJLO6X.js +4 -0
- package/dist/chunk-R63ASIIW.js +407 -0
- package/dist/chunk-WX3B64R4.js +4 -0
- package/dist/chunk-Y6SQB5FG.js +4 -0
- package/dist/{devtools-3OAJUZGE.js → devtools-OJ75EP3T.js} +1 -1
- package/dist/glob.wasm +0 -0
- package/dist/lib/agent-XYO2MXXK.js +11 -0
- package/dist/lib/{anthropic-RYPJDHQM.js → anthropic-TGJGAP5R.js} +4 -5
- package/dist/lib/{checker-6BW4222R.js → checker-AXHPKVBY.js} +2 -2
- package/dist/lib/{chunk-HK2Z6WP4.js → chunk-2IVEVG5N.js} +5 -1
- package/dist/lib/{chunk-2AUSNVIB.js → chunk-ALJAVRRX.js} +28 -34
- package/dist/lib/{chunk-GNI7YX6F.js → chunk-DJ6AILPN.js} +70 -24
- package/dist/lib/chunk-DV6RV5WU.js +2345 -0
- package/dist/lib/{chunk-3LU4APFB.js → chunk-FBSPZQGC.js} +126 -73
- package/dist/lib/chunk-IB5IQK2S.js +136 -0
- package/dist/lib/{chunk-PZ42NAFA.js → chunk-KG4MJGKQ.js} +19 -21
- package/dist/lib/{chunk-XFSN4LMA.js → chunk-P4F46PEF.js} +43 -14
- package/dist/lib/glob.wasm +0 -0
- package/dist/lib/index.d.ts +145 -123
- package/dist/lib/index.js +2186 -1726
- package/dist/lib/{openai-VX5VBXZ4.js → openai-5UCIIDPO.js} +2 -3
- package/dist/lib/{tool-filter-VF7TZRE5.js → tool-filter-R6HDDJHE.js} +1 -1
- package/dist/main.js +226 -196
- package/dist/{node-OES65R33.js → node-4LTSRXL2.js} +1 -1
- package/dist/{openai-6MXNADYN.js → openai-YLS2LUAI.js} +14 -14
- package/dist/server-GX72MJQF.js +244 -0
- package/dist/{tool-filter-NO7I3HFD.js → tool-filter-VBP6WOGO.js} +1 -1
- package/package.json +36 -32
- package/dist/agent-GAABBZRW.js +0 -4
- package/dist/anthropic-7QRAPLOY.js +0 -4
- package/dist/checker-3RWAYF2U.js +0 -4
- package/dist/chunk-7MHXMDYC.js +0 -35
- package/dist/chunk-A2VR3BC4.js +0 -4
- package/dist/chunk-FZPTNGTU.js +0 -4
- package/dist/chunk-MWZIARZE.js +0 -130
- package/dist/chunk-NR62AA5K.js +0 -4
- package/dist/chunk-QN27QEFS.js +0 -4
- package/dist/chunk-RMMK4PO5.js +0 -389
- package/dist/chunk-SIWLMWHH.js +0 -93
- package/dist/chunk-VC6OXOMP.js +0 -238
- package/dist/chunk-W37Y53LX.js +0 -4
- package/dist/chunk-XBHVVB5A.js +0 -10
- package/dist/lib/agent-U7MIUCKT.js +0 -9
- package/dist/lib/chunk-2QILP24G.js +0 -1120
- package/dist/lib/chunk-OO2CLOEE.js +0 -88
- package/dist/lib/chunk-RKJYTYQM.js +0 -1285
- package/dist/server-P2VE5HLJ.js +0 -244
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
3
|
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{a as b,b as d,c as $,d as G,e as u,f as W}from"./chunk-
|
|
4
|
+
import{a as b,b as d,c as $,d as G,e as u,f as W}from"./chunk-C3WGLVVZ.js";import"./chunk-X3UA5OZL.js";import*as w from"fs/promises";import*as P from"fs";import*as p from"path";import*as J from"child_process";import*as V from"crypto";import*as Y from"readline";function O(r){if(r.inputSchema.type!=="object")throw new Error(`JSON schema for tool "${r.name}" must be an object, but got ${r.inputSchema.type}`);return{type:"custom",name:r.name,input_schema:r.inputSchema,description:r.description,run:r.run,parse:t=>t,...r.close?{close:r.close}:{}}}import*as E from"fs/promises";import*as h from"path";import{randomUUID as nt}from"crypto";var x=493,st=420;async function ot(r){try{return await E.realpath(r)}catch{return r}}async function at(r){let t=[],e=r;for(;;){let i;try{i=await E.realpath(e)}catch{let n=!1;try{n=(await E.lstat(e)).isSymbolicLink()}catch{}if(n){e=h.resolve(h.dirname(e),await E.readlink(e));continue}let s=h.dirname(e);if(s===e)return r;t.push(h.basename(e)),e=s;continue}return t.length?h.join(i,...t.reverse()):i}}async function j(r,t,e){let i=e?.allowOutside??!1;if(h.isAbsolute(t)){if(!i)throw new u(`absolute path ${JSON.stringify(t)} not permitted`);return h.resolve(t)}let n=await ot(h.resolve(r)),s=h.resolve(n,t);if(i)return s;let o=await at(s),a=n.endsWith(h.sep)?n:n+h.sep;if(o!==n&&!o.startsWith(a))throw new u(`path ${JSON.stringify(t)} escapes workdir`);return o}async function q(r,t){let e=h.dirname(r),i=h.join(e,`.tmp-${process.pid}-${nt()}`),n;try{n=await E.open(i,"wx",st),await n.writeFile(t,"utf-8"),await n.sync(),await n.close(),n=void 0,await E.rename(i,r)}catch(s){throw n&&await n.close().catch(()=>{}),await E.unlink(i).catch(()=>{}),s}}function A(r,t){switch(r?.code){case"ENOENT":return`${t}: no such file or directory`;case"EACCES":case"EPERM":return`${t}: permission denied`;case"ENOTDIR":return`${t}: not a directory`;case"EISDIR":return`${t}: is a directory`;case"ELOOP":return`${t}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${t}: file name too long`;case"ENOSPC":return`${t}: no space left on device`;case"EMFILE":case"ENFILE":return`${t}: too many open files`;default:return`${t}: ${r instanceof Error?r.message:String(r)}`}}import*as g from"fs/promises";import*as H from"fs";import*as m from"path";import{execFile as ct}from"child_process";import{promisify as lt}from"util";import{Readable as ft}from"stream";import{pipeline as ut}from"stream/promises";var dt=lt(ct);async function pt(r){let{client:t,sessionId:e}=r;if(!t||!e)return async()=>{};let i=G(t),n=await t.beta.sessions.retrieve(e),s=m.resolve(r.workdir,"skills"),o=[];for(let a of n.agent.skills)try{let c=await z(t,a.skill_id,a.version),f=await t.beta.skills.versions.retrieve(c,{skill_id:a.skill_id}),l=m.basename(f.name.trim());(l===""||l==="."||l==="..")&&(l=a.skill_id);let v=m.resolve(s,l);if(v!==s&&!v.startsWith(s+m.sep)){i.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:f.name});continue}let T=await t.beta.skills.versions.download(c,{skill_id:a.skill_id});await g.rm(v,{recursive:!0,force:!0}),await g.mkdir(v,{recursive:!0,mode:x}),o.push(v),await K(T,v),i.info("downloaded skill",{component:"agent-tool-context",skill_id:a.skill_id,version:c,dest:v})}catch(c){i.warn("failed to download skill",{component:"agent-tool-context",skill_id:a.skill_id,error:String(c)})}return async()=>{for(let a of o)await g.rm(a,{recursive:!0,force:!0}).catch(c=>{i.warn("failed to clean up skill",{component:"agent-tool-context",dest:a,error:String(c)})})}}async function z(r,t,e){if(/^\d+$/.test(e))return e;let i;for await(let n of r.beta.skills.versions.list(t))/^\d+$/.test(n.version)&&(i===void 0||BigInt(n.version)>BigInt(i))&&(i=n.version);if(i===void 0)throw new $(`skill ${JSON.stringify(t)} has no concrete version to resolve ${JSON.stringify(e)} against`);return i}function ht(r){for(let t of r.split(`
|
|
5
5
|
`)){let e=t.trim();if(e&&(m.isAbsolute(e)||e.split(/[\\/]/).includes("..")))throw new $(`refusing to extract unsafe archive member: ${e}`)}}function mt(r){for(let t of r.split(`
|
|
6
6
|
`)){let e=t.trimStart()[0];if(e==="l"||e==="h"||e==="b"||e==="c"||e==="p"||e==="s")throw new $("refusing to extract archive with symlink/hardlink/device member")}}async function B(r,t){try{let{stdout:e}=await dt(r,t);return e}catch(e){throw e!=null&&typeof e=="object"&&e.code==="ENOENT"?new $(`skill extraction requires the \`${r}\` command, but it was not found on PATH`):e}}function wt(r){let t,e=!1;for(let i of r.split(`
|
|
7
7
|
`)){let n=i.trim().split("/").filter(o=>o!==""&&o!==".");if(n.length===0)continue;let s=n[0];if(t===void 0)t=s;else if(s!==t)return"";n.length>1&&(e=!0)}return t!==void 0&&e?t:""}async function K(r,t){let e=m.join(t,`.skill-archive-${process.pid}-${Date.now()}`);if(!r.body)throw new $("skill download response had no body");await ut(ft.fromWeb(r.body),H.createWriteStream(e));let i=m.join(m.dirname(t),`.skill-stage-${process.pid}-${Date.now()}`);try{let n=await yt(e,4),s=n.length>=4&&n[0]===80&&n[1]===75&&n[2]===3&&n[3]===4,o=s?"unzip":"tar",a=await B(o,s?["-Z1",e]:["-tf",e]);ht(a),mt(await B(o,s?["-Z",e]:["-tvf",e]));let c=wt(a);await g.mkdir(i,{recursive:!0,mode:x}),await B(o,s?["-oq",e,"-d",i]:["-xf",e,"-C",i]);let f=c?m.join(i,c):i;for(let l of await g.readdir(f))await g.rename(m.join(f,l),m.join(t,l))}finally{await g.rm(e,{force:!0}),await g.rm(i,{recursive:!0,force:!0})}}async function yt(r,t){let e=await g.open(r,"r");try{let i=Buffer.alloc(t),{bytesRead:n}=await e.read(i,0,t,0);return i.subarray(0,n)}finally{await e.close()}}var F,y,_,I,S,k,U,X=100*1024,Q=12e4,bt=256*1024,R=100*1024,gt=2e3,_t=200,vt=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,$t=w.glob;function tt(r){return r===void 0?bt:r}function ae(r){return[kt(r),Ot(r),St(r),Tt(r),xt(r),At(r)]}function M(r,t){return j(r.workdir,t,{allowOutside:r.unrestrictedPaths??!1})}function Et(){let r={};for(let[t,e]of Object.entries(process.env))t.startsWith("ANTHROPIC_")||(r[t]=e);return r}var C=class{constructor(t,e=Et()){F.add(this),y.set(this,void 0),_.set(this,""),I.set(this,!1),S.set(this,!1),k.set(this,null),b(this,y,J.spawn("/bin/bash",["--noprofile","--norc"],{cwd:t,env:{...e,PS1:"",PS2:"",TERM:"dumb"},stdio:["pipe","pipe","pipe"],detached:!0}),"f"),d(this,y,"f").stdout.setEncoding("utf8"),d(this,y,"f").stderr.setEncoding("utf8"),d(this,y,"f").stdout.on("data",i=>d(this,F,"m",U).call(this,i)),d(this,y,"f").stderr.on("data",i=>d(this,F,"m",U).call(this,i)),d(this,y,"f").once("close",()=>{b(this,S,!0,"f");let i=d(this,k,"f");b(this,k,null,"f"),i?.resolve()})}get closed(){return d(this,S,"f")}async exec(t,e={}){if(d(this,S,"f"))throw new $("bash session terminated");let i=e.timeoutMs??Q,n=e.signal;if(n?.aborted)throw new $("bash command aborted");b(this,_,"","f"),b(this,I,!1,"f");let s=`__ANT_CMD_${V.randomUUID()}_DONE__`,o=`${s.slice(0,8)}''${s.slice(8)}`,a=`{ ${t}
|