@shumai-one/shumai-agent 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/bin/chunk-07a5rjnq.js +2 -0
  2. package/bin/chunk-1a493esq.js +2 -0
  3. package/bin/chunk-1y3q1jce.js +2 -0
  4. package/bin/chunk-2mcnt6jh.js +8 -0
  5. package/bin/chunk-33n9p9q4.js +3 -0
  6. package/bin/chunk-40bcg5we.js +2 -0
  7. package/bin/chunk-4926dhzq.js +4 -0
  8. package/bin/chunk-4q9h14c1.js +3 -0
  9. package/bin/chunk-5n4wvh5p.js +3 -0
  10. package/bin/chunk-6195gx01.js +8 -0
  11. package/bin/chunk-8jd9p0bt.js +45 -0
  12. package/bin/chunk-8tj47emj.js +2 -0
  13. package/bin/chunk-9bpp5v13.js +13320 -0
  14. package/bin/chunk-a4xcn19j.js +3 -0
  15. package/bin/chunk-as1vqgag.js +2 -0
  16. package/bin/chunk-b2205272.js +3 -0
  17. package/bin/chunk-bbz8hcag.js +2 -0
  18. package/bin/chunk-cwq65x99.js +2 -0
  19. package/bin/chunk-dc4f80kq.js +2 -0
  20. package/bin/chunk-e7m6nsvr.js +3 -0
  21. package/bin/chunk-edkxjkdy.js +2 -0
  22. package/bin/chunk-fvz08he3.js +2 -0
  23. package/bin/chunk-gekdwjxf.js +2 -0
  24. package/bin/chunk-gqtret3n.js +2 -0
  25. package/bin/chunk-grtavkr4.js +3 -0
  26. package/bin/chunk-h65eqsrp.js +7 -0
  27. package/bin/chunk-hbmbvjjq.js +3 -0
  28. package/bin/chunk-jkx975yd.js +2 -0
  29. package/bin/chunk-jt36jdn3.js +2 -0
  30. package/bin/chunk-k975ym8c.js +7 -0
  31. package/bin/chunk-kd561cva.js +2 -0
  32. package/bin/chunk-m8jmvj7p.js +3 -0
  33. package/bin/chunk-nmxr1m3s.js +2 -0
  34. package/bin/chunk-nwjh8gnr.js +3 -0
  35. package/bin/chunk-s1e2nv5w.js +5 -0
  36. package/bin/chunk-sbtjx4y3.js +2 -0
  37. package/bin/chunk-sfx1j3yr.js +11 -0
  38. package/bin/chunk-sq5rat8t.js +2 -0
  39. package/bin/chunk-td2tpqfb.js +12 -0
  40. package/bin/chunk-tdah647g.js +13 -0
  41. package/bin/chunk-vnn8sej7.js +24 -0
  42. package/bin/chunk-vv932dz6.js +2 -0
  43. package/bin/chunk-vvvkt1vd.js +2 -0
  44. package/bin/chunk-wdvv14a7.js +2 -0
  45. package/bin/chunk-wg6xrc3y.js +3 -0
  46. package/bin/chunk-wzysrq4c.js +16 -0
  47. package/bin/chunk-xp2anj2s.js +3 -0
  48. package/bin/chunk-y2adfzyt.js +2 -0
  49. package/bin/chunk-zdkpvcak.js +4 -0
  50. package/bin/shumai-agent-app.js +912 -666
  51. package/package.json +18 -18
  52. package/prisma/migrations/20260904022457_add_agent_id_to_assets_and_audit_logs/migration.sql +17 -0
  53. package/prisma/migrations/20260906081230_default_denied_tools_delete_asset/migration.sql +15 -0
  54. package/prisma/migrations/20260907021754_add_asset_upload_id/migration.sql +2 -0
  55. package/prisma/schema.prisma +10 -0
  56. package/bin/chunk-1ep7nnzp.js +0 -5
  57. package/bin/chunk-1jq2vgrd.js +0 -3
  58. package/bin/chunk-2ntm65jn.js +0 -3
  59. package/bin/chunk-3nh1p64q.js +0 -12
  60. package/bin/chunk-41gh01qj.js +0 -3
  61. package/bin/chunk-4n1309xp.js +0 -2
  62. package/bin/chunk-616f7y5x.js +0 -8
  63. package/bin/chunk-6a9h5d64.js +0 -3
  64. package/bin/chunk-6dp3ybh2.js +0 -3
  65. package/bin/chunk-6nd8f70y.js +0 -4
  66. package/bin/chunk-6vs3gb9g.js +0 -2
  67. package/bin/chunk-7dyx5m0f.js +0 -6
  68. package/bin/chunk-7j3qbvwc.js +0 -7
  69. package/bin/chunk-9h5qhgqx.js +0 -13
  70. package/bin/chunk-b9s67nd8.js +0 -2
  71. package/bin/chunk-c14kvr2r.js +0 -11
  72. package/bin/chunk-cb5p7shk.js +0 -12240
  73. package/bin/chunk-ccx6803n.js +0 -44
  74. package/bin/chunk-cm4dpd3k.js +0 -4
  75. package/bin/chunk-dd2tfwzy.js +0 -45
  76. package/bin/chunk-dk9vz5tv.js +0 -4
  77. package/bin/chunk-e6691p0v.js +0 -3
  78. package/bin/chunk-e9d2ah8y.js +0 -3
  79. package/bin/chunk-fvmb8en4.js +0 -24
  80. package/bin/chunk-gegf6d3m.js +0 -2
  81. package/bin/chunk-gx9vdcbm.js +0 -2
  82. package/bin/chunk-j427r7a5.js +0 -2
  83. package/bin/chunk-jperx2a8.js +0 -6
  84. package/bin/chunk-k4jm2gt4.js +0 -3
  85. package/bin/chunk-m29dphbf.js +0 -3
  86. package/bin/chunk-mpgy1y53.js +0 -3
  87. package/bin/chunk-n1t3he2k.js +0 -3
  88. package/bin/chunk-pmdb6y7t.js +0 -2
  89. package/bin/chunk-qx9njyk7.js +0 -3
  90. package/bin/chunk-r5h7vczc.js +0 -3
  91. package/bin/chunk-spm76160.js +0 -2
  92. package/bin/chunk-t8k09sgb.js +0 -3
  93. package/bin/chunk-tvef1ck8.js +0 -2
  94. package/bin/chunk-v4j6yxch.js +0 -3
  95. package/bin/chunk-vjzrmneg.js +0 -2
  96. package/bin/chunk-x25enwfz.js +0 -3
  97. package/bin/chunk-xg9xscqz.js +0 -1
  98. package/bin/chunk-xqg06q7q.js +0 -2
  99. package/bin/chunk-xvbd9e2b.js +0 -8
  100. package/bin/chunk-y2z3xj0m.js +0 -12
  101. package/bin/chunk-ywhrsshf.js +0 -2
  102. package/bin/chunk-z512b49m.js +0 -3
  103. package/bin/chunk-z58rb52r.js +0 -3
  104. package/bin/chunk-zazbsz25.js +0 -3
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{m,h,f}from"./shumai-agent-app.js";import{i}from"./chunk-y2adfzyt.js";var F=i(f()),d=i(m());var p=i(m()),b=i(h());import{createHash as K,createPrivateKey as _,createPublicKey as v,sign as B}from"crypto";import{promises as C}from"fs";import{homedir as q}from"os";import{dirname as U,join as R}from"path";class k{profileData;init;callerClientConfig;static REFRESH_THRESHOLD=300000;constructor(e,t,s){this.profileData=e,this.init=t,this.callerClientConfig=s}async loadCredentials(){let e=await this.loadToken();if(!e)throw new p.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`,{tryNextLink:!1,logger:this.logger});let t=e.accessToken,s=Date.now();if(new Date(t.expiresAt).getTime()-s<=k.REFRESH_THRESHOLD)return this.refresh(e);return this.toCredentials(e.accessToken)}get logger(){return this.init?.logger}get loginSession(){return this.profileData.login_session}toCredentials(e){return{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken,accountId:e.accountId,expiration:new Date(e.expiresAt)}}async refresh(e){let t=await this.loadToken().catch(()=>e),s=Date.now(),r=new Date(t.accessToken.expiresAt).getTime(),n=new Date(e.accessToken.expiresAt).getTime(),o=r<=s&&n>s?e:t;if(new Date(o.accessToken.expiresAt).getTime()-Date.now()>k.REFRESH_THRESHOLD)return this.toCredentials(o.accessToken);let{SigninClient:u,CreateOAuth2TokenCommand:x}=await import("./chunk-as1vqgag.js"),{logger:E,userAgentAppId:S}=this.callerClientConfig??{},D=((a)=>a?.metadata?.handlerProtocol==="h2")(this.callerClientConfig?.requestHandler)?void 0:this.callerClientConfig?.requestHandler,w=this.profileData.region??await this.callerClientConfig?.region?.()??process.env.AWS_REGION,y=new u({credentials:{accessKeyId:"",secretAccessKey:""},region:w,requestHandler:D,logger:E,userAgentAppId:S,...this.init?.clientConfig});this.createDPoPInterceptor(y.middlewareStack);let P={tokenInput:{clientId:o.clientId,refreshToken:o.refreshToken,grantType:"refresh_token"}};try{let a=await y.send(new x(P)),{accessKeyId:l,secretAccessKey:T,sessionToken:g}=a.tokenOutput?.accessToken??{},{refreshToken:A,expiresIn:L}=a.tokenOutput??{};if(!l||!T||!g||!A)throw new p.CredentialsProviderError("Token refresh response missing required fields",{logger:this.logger,tryNextLink:!1});let O=(L??900)*1000,H=new Date(Date.now()+O),N={...o,accessToken:{...o.accessToken,accessKeyId:l,secretAccessKey:T,sessionToken:g,expiresAt:H.toISOString()},refreshToken:A};return await this.saveToken(N),this.toCredentials(N.accessToken)}catch(a){if(a.name==="AccessDeniedException"){let T=a.error,g;switch(T){case"TOKEN_EXPIRED":g="Your session has expired. Please reauthenticate.";break;case"USER_CREDENTIALS_CHANGED":g="Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";break;case"INSUFFICIENT_PERMISSIONS":g="Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";break;default:g=`Failed to refresh token: ${String(a)}. Please re-authenticate using \`aws login\``}throw new p.CredentialsProviderError(g,{logger:this.logger,tryNextLink:!1})}if(new Date(o.accessToken.expiresAt).getTime()>Date.now())return this.logger?.warn?.(`Failed to refresh token: ${String(a)}. Using existing token until expiry.`),this.toCredentials(o.accessToken);throw new p.CredentialsProviderError(`Failed to refresh token: ${String(a)}. Please re-authenticate using aws login`,{logger:this.logger})}}async loadToken(){let e=this.getTokenFilePath();try{let t=await C.readFile(e,"utf8"),s=JSON.parse(t),r=["accessToken","clientId","refreshToken","dpopKey"].filter((n)=>!s[n]);if(!s.accessToken?.accountId)r.push("accountId");if(r.length>0)throw new p.CredentialsProviderError(`Token validation failed, missing fields: ${r.join(", ")}`,{logger:this.logger,tryNextLink:!1});return s}catch(t){throw new p.CredentialsProviderError(`Failed to load token from ${e}: ${String(t)}`,{logger:this.logger,tryNextLink:!1})}}async saveToken(e){let t=this.getTokenFilePath(),s=U(t);try{await C.mkdir(s,{recursive:!0})}catch(r){}await C.writeFile(t,JSON.stringify(e,null,2),"utf8")}getTokenFilePath(){let e=process.env.AWS_LOGIN_CACHE_DIRECTORY??R(q(),".aws","login","cache"),t=Buffer.from(this.loginSession,"utf8"),s=K("sha256").update(t).digest("hex");return R(e,`${s}.json`)}derToRawSignature(e){let t=2;if(e[t]!==2)throw Error("Invalid DER signature");t++;let s=e[t++],r=e.subarray(t,t+s);if(t+=s,e[t]!==2)throw Error("Invalid DER signature");t++;let n=e[t++],o=e.subarray(t,t+n);r=r[0]===0?r.subarray(1):r,o=o[0]===0?o.subarray(1):o;let c=Buffer.concat([Buffer.alloc(32-r.length),r]),u=Buffer.concat([Buffer.alloc(32-o.length),o]);return Buffer.concat([c,u])}createDPoPInterceptor(e){e.add((t)=>async(s)=>{if(b.HttpRequest.isInstance(s.request)){let r=s.request,n=`${r.protocol}//${r.hostname}${r.port?`:${r.port}`:""}${r.path}`,o=await this.generateDpop(r.method,n);r.headers={...r.headers,DPoP:o}}return t(s)},{step:"finalizeRequest",name:"dpopInterceptor",override:!0})}async generateDpop(e="POST",t){let s=await this.loadToken();try{let r=_({key:s.dpopKey,format:"pem",type:"sec1"}),o=v(r).export({format:"der",type:"spki"}),c=-1;for(let l=0;l<o.length;l++)if(o[l]===4){c=l;break}let u=o.slice(c+1,c+33),x=o.slice(c+33,c+65),E={alg:"ES256",typ:"dpop+jwt",jwk:{kty:"EC",crv:"P-256",x:u.toString("base64url"),y:x.toString("base64url")}},S={jti:crypto.randomUUID(),htm:e,htu:t,iat:Math.floor(Date.now()/1000)},I=Buffer.from(JSON.stringify(E)).toString("base64url"),D=Buffer.from(JSON.stringify(S)).toString("base64url"),w=`${I}.${D}`,y=B("sha256",Buffer.from(w),r),a=this.derToRawSignature(y).toString("base64url");return`${w}.${a}`}catch(r){throw new p.CredentialsProviderError(`Failed to generate Dpop proof: ${r instanceof Error?r.message:String(r)}`,{logger:this.logger,tryNextLink:!1})}}}var j=(e)=>async({callerClientConfig:t}={})=>{e?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");let s=await d.parseKnownFiles(e||{}),r=d.getProfileName({profile:e?.profile??t?.profile}),n=s[r];if(!n?.login_session)throw new d.CredentialsProviderError(`Profile ${r} does not contain login_session.`,{tryNextLink:!0,logger:e?.logger});let c=await new k(n,e,t).loadCredentials();return F.setCredentialFeature(c,"CREDENTIALS_LOGIN","AD")};export{j as fromLoginCredentials};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Bt,Rt}from"./shumai-agent-app.js";export{Bt as createKyselyAdapter,Rt as kyselyAdapter};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{m,f}from"./shumai-agent-app.js";import{i}from"./chunk-y2adfzyt.js";var g=i(f()),t=i(m());import{readFileSync as T}from"fs";var d=(e)=>async(s)=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");let{roleArn:o,roleSessionName:r,webIdentityToken:l,providerId:n,policyArns:E,policy:p,durationSeconds:_}=e,{roleAssumerWithWebIdentity:c}=e;if(!c){let{getDefaultRoleAssumerWithWebIdentity:S}=await import("./chunk-bbz8hcag.js");c=S({...e.clientConfig,credentialProviderLogger:e.logger,parentClientConfig:{...s?.callerClientConfig,...e.parentClientConfig}},e.clientPlugins)}return c({RoleArn:o,RoleSessionName:r??`aws-sdk-js-session-${Date.now()}`,WebIdentityToken:l,ProviderId:n,PolicyArns:E,Policy:p,DurationSeconds:_})};var a="AWS_WEB_IDENTITY_TOKEN_FILE",N="AWS_ROLE_ARN",I="AWS_ROLE_SESSION_NAME",y=(e={})=>async(s)=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");let o=e?.webIdentityTokenFile??process.env[a],r=e?.roleArn??process.env[N],l=e?.roleSessionName??process.env[I];if(!o||!r)throw new t.CredentialsProviderError("Web identity configuration not specified",{logger:e.logger});let n=await d({...e,webIdentityToken:t.externalDataInterceptor?.getTokenRecord?.()[o]??T(o,{encoding:"ascii"}),roleArn:r,roleSessionName:l})(s);if(o===process.env[a])g.setCredentialFeature(n,"CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN","h");return n};export{y as fromTokenFile};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import{R}from"./chunk-s1e2nv5w.js";import{y}from"./chunk-e7m6nsvr.js";import{U,be}from"./chunk-m8jmvj7p.js";import{ze,ve,I}from"./shumai-agent-app.js";class g extends Error{code;diagnosticDetails;constructor(r,t,n){super(r);this.name="PiMessagesResponseError",this.code=t,this.diagnosticDetails=n}}function x(r){try{let t=JSON.parse(r),n=t?.error;return t&&typeof n==="object"&&n!==null&&!Array.isArray(n)?t:void 0}catch{return}}function m(r){return r.length>8192?`${r.slice(0,8192)}\u2026`:r}function w(r,t,n){let e=typeof n?.error?.message==="string"?n.error.message:void 0,s=typeof n?.error?.code==="string"?n.error.code:void 0,a=e??t,o=s?` (${s})`:"";return`${r.status} ${r.statusText}: ${a}${o}`}function b(r,t,n,e){let s=x(e),a=typeof s?.error?.code==="string"?s.error.code:void 0;return new g(w(n,e,s),a,{version:1,provider:r.provider,model:r.id,url:t.toString(),status:n.status,statusText:n.statusText,error:s?.error,body:s?void 0:m(e),timestampMs:Date.now()})}function h(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function l(r,t){if(!t)return;ve(r,{type:"pi_messages_rewrite",timestamp:Date.now(),details:{...t}})}function k(r){let t={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:"stop",timestamp:Date.now()},n=new Map;return(e)=>{switch(e.type){case"done":return Object.assign(t,{stopReason:e.reason,usage:e.usage,responseId:e.responseId}),l(t,e.rewrite),{type:"done",reason:e.reason,message:t};case"error":return Object.assign(t,{stopReason:e.reason,usage:e.usage,errorMessage:e.errorMessage,responseId:e.responseId}),l(t,e.rewrite),{type:"error",reason:e.reason,error:t};case"start":break;case"text_start":t.content[e.contentIndex]={type:"text",text:""};break;case"text_delta":t.content[e.contentIndex].text+=e.delta;break;case"text_end":Object.assign(t.content[e.contentIndex],{text:e.content,textSignature:e.contentSignature});break;case"thinking_start":t.content[e.contentIndex]={type:"thinking",thinking:""};break;case"thinking_delta":t.content[e.contentIndex].thinking+=e.delta;break;case"thinking_end":Object.assign(t.content[e.contentIndex],{thinking:e.content,thinkingSignature:e.contentSignature,redacted:e.redacted});break;case"toolcall_start":t.content[e.contentIndex]={type:"toolCall",id:e.id,name:e.toolName,arguments:{}},n.set(e.contentIndex,"");break;case"toolcall_delta":{let s=`${n.get(e.contentIndex)??""}${e.delta}`;n.set(e.contentIndex,s),t.content[e.contentIndex].arguments=R(s);break}case"toolcall_end":return Object.assign(t.content[e.contentIndex],e.toolCall),n.delete(e.contentIndex),{type:"toolcall_end",contentIndex:e.contentIndex,toolCall:t.content[e.contentIndex],partial:t}}return{...e,partial:t}}}async function*E(r){let t=new TextDecoder,n=r.getReader(),e="";try{while(!0){let{done:s,value:a}=await n.read();e+=s?t.decode():t.decode(a,{stream:!0}),e=e.replace(/\r\n/g,`
3
+ `);let o=e.indexOf(`
4
+
5
+ `);while(o!==-1){let c=f(e.slice(0,o));if(c)yield c;e=e.slice(o+2),o=e.indexOf(`
6
+
7
+ `)}if(s)break}if(e.trim()){let s=f(e);if(s)yield s}}finally{n.releaseLock()}}function f(r){let t=r.split(`
8
+ `).find((n)=>n.startsWith("data:"))?.slice(5).trim();return t&&t!=="[DONE]"?JSON.parse(t):void 0}function _(r,t,n){let e=n?"aborted":"error",s={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:e,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()};if(!n&&t instanceof g)ve(s,ze("pi_messages_response_failure",t,t.diagnosticDetails));return{type:"error",reason:e,error:s}}function S(r,t){if(r)return r;return y("PI_CACHE_RETENTION",t)==="long"?"long":void 0}var M=(r,t,n)=>{let e=new I,s=k(r);return(async()=>{try{let a=n?.apiKey;if(!a)throw Error(`No API key provided for provider "${r.provider}"`);let o=new URL(`${r.baseUrl.replace(/\/+$/u,"")}/messages`);if(n?.debug)o.searchParams.set("debug","1");let c={model:r.id,context:t,options:{temperature:n?.temperature,maxTokens:n?.maxTokens,reasoning:n?.reasoning,cacheRetention:S(n?.cacheRetention,n?.env),sessionId:n?.sessionId,toolChoice:n?.toolChoice}},p=await n?.onPayload?.(c,r);if(p!==void 0)c=p;let i=await fetch(o,{method:"POST",headers:{authorization:`Bearer ${a}`,accept:"text/event-stream","content-type":"application/json",...be(n?.headers)},body:JSON.stringify(c),signal:n?.signal});if(await n?.onResponse?.({status:i.status,headers:U(i.headers)},r),!i.ok){let d=await i.text();throw b(r,o,i,d)}if(!i.body)throw Error(`${r.provider} response has no body`);for await(let d of E(i.body)){let u=s(d);if(e.push(u),u.type==="done"||u.type==="error")return}throw Error(`${r.provider} stream ended without a terminal event`)}catch(a){e.push(_(r,a,n?.signal?.aborted??!1))}})(),e},j=(r,t,n)=>{let e=n;return M(r,t,{...n,reasoning:n?.reasoning,toolChoice:e?.toolChoice,debug:e?.debug})};export{g as PiMessagesResponseError,M as stream,j as streamSimple};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ function F(t){if(!(t instanceof Error))return{message:u(t),messageCarriesBody:!1};let e=t,n=r(e),s=f(e),d=s===void 0||t.message.includes(s);return{status:n,body:s,message:t.message,messageCarriesBody:d}}function r(t){if(typeof t.statusCode==="number")return t.statusCode;if(typeof t.status==="number")return t.status;if(typeof t.$metadata?.httpStatusCode==="number")return t.$metadata.httpStatusCode;if(typeof t.$response?.statusCode==="number")return t.$response.statusCode;return}function f(t){let e=o(t);if(e===void 0)return;let n=e.trim();if(n.length===0)return;return c(n,4000)}function o(t){if(typeof t.body==="string")return t.body;if(i(t.error))return u(t.error);let e=t.$response?.body;if(typeof e==="string")return e;if(a(e))return;if(i(e))return u(e);return}function a(t){return typeof t==="object"&&t!==null&&"pipe"in t&&typeof t.pipe==="function"}function i(t){return typeof t==="object"&&t!==null&&Object.keys(t).length>0}function Q(t,e){if(t.messageCarriesBody||t.status===void 0||t.body===void 0)return e!==void 0&&t.status!==void 0?`${e} (${t.status}): ${t.message}`:t.message;return e!==void 0?`${e} (${t.status}): ${t.body}`:`${t.status}: ${t.body}`}function c(t,e){if(t.length<=e)return t;return`${t.slice(0,e)}... [truncated ${t.length-e} chars]`}function u(t){try{let e=JSON.stringify(t);return e===void 0?String(t):e}catch{return String(t)}}
3
+ export{F,Q};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ye,je}from"./shumai-agent-app.js";import{n}from"./chunk-y2adfzyt.js";var v=n(function(y,s){var{defineProperty:c,getOwnPropertyDescriptor:_,getOwnPropertyNames:k}=Object,l=Object.prototype.hasOwnProperty,u=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},d=(t,e,o,a)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of k(e))if(!l.call(t,r)&&r!==o)c(t,r,{get:()=>e[r],enumerable:!(a=_(e,r))||a.enumerable})}return t},O=(t)=>d(c({},"__esModule",{value:!0}),t),f={};u(f,{refreshToken:()=>j});s.exports=O(f);var p=Ye(),i=je();async function j(t){let e=t?.project,o=t?.team;if(!e&&!o){let r=(0,i.findProjectInfo)();e=r.projectId,o=r.teamId}else if(!e||!o){let r=(0,i.findProjectInfo)();e=e??r.projectId,o=o??r.teamId}if(!e)throw new p.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let a=(0,i.loadToken)(e);if(!a||(0,i.isExpired)((0,i.getTokenPayload)(a.token),t?.expirationBufferMs)){let r=await(0,i.getVercelToken)({expirationBufferMs:t?.expirationBufferMs});if(a=await(0,i.getVercelOidcToken)(r,e,o),!a)throw new p.VercelOidcTokenError("Failed to refresh OIDC token");(0,i.saveToken)(a,e)}process.env.VERCEL_OIDC_TOKEN=a.token;return}});export default v();