@shumai-one/shumai-agent 0.1.7 → 0.1.9
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/bin/chunk-04047smt.js +2 -0
- package/bin/chunk-092vhedy.js +3 -0
- package/bin/chunk-09qk3khg.js +3 -0
- package/bin/chunk-0hsekj7q.js +7 -0
- package/bin/chunk-0zzvpjyx.js +2 -0
- package/bin/chunk-196gwx9k.js +2 -0
- package/bin/chunk-1xnqw6rd.js +14 -0
- package/bin/chunk-31hmzhh3.js +3 -0
- package/bin/chunk-4sgazeqh.js +3 -0
- package/bin/chunk-4vs22x1t.js +44 -0
- package/bin/chunk-4xh97fm8.js +8 -0
- package/bin/chunk-4yppzd09.js +3 -0
- package/bin/chunk-5h8q2pjz.js +3 -0
- package/bin/chunk-62cczr32.js +3 -0
- package/bin/chunk-6pqt1p9h.js +3 -0
- package/bin/chunk-722awnh3.js +4 -0
- package/bin/chunk-7mtn96c1.js +3 -0
- package/bin/chunk-7xm669xc.js +6 -0
- package/bin/chunk-8eg1rj5q.js +12 -0
- package/bin/chunk-8pdrt7yn.js +2 -0
- package/bin/chunk-9cgjmctw.js +6 -0
- package/bin/chunk-9ea4dgez.js +4 -0
- package/bin/chunk-9pfvgwrc.js +3 -0
- package/bin/chunk-bqb5hsbe.js +3 -0
- package/bin/chunk-c11capf1.js +6 -0
- package/bin/chunk-cm44rgmn.js +3 -0
- package/bin/chunk-edhaz54y.js +2 -0
- package/bin/chunk-ej5ed8pg.js +3 -0
- package/bin/chunk-en6m9d5x.js +2 -0
- package/bin/chunk-etda2aqf.js +41 -0
- package/bin/chunk-evkfqc0n.js +3 -0
- package/bin/chunk-f3g62524.js +12152 -0
- package/bin/chunk-gehabk8h.js +2 -0
- package/bin/chunk-gj059qs2.js +13 -0
- package/bin/chunk-jdhnsqss.js +11 -0
- package/bin/chunk-jxp0ghqf.js +2 -0
- package/bin/chunk-k30n4wwk.js +4 -0
- package/bin/chunk-kkr0jwz3.js +2 -0
- package/bin/chunk-n7qv08c3.js +3 -0
- package/bin/chunk-nerm3qbg.js +3 -0
- package/bin/chunk-nqbz5n9d.js +2 -0
- package/bin/chunk-nts78x0z.js +2 -0
- package/bin/chunk-p7dw998p.js +3 -0
- package/bin/chunk-p8c02x99.js +3 -0
- package/bin/chunk-q0f0cac4.js +24 -0
- package/bin/chunk-q5tv58nz.js +14 -0
- package/bin/chunk-r3vpwnnb.js +2 -0
- package/bin/chunk-t1c8qk5y.js +3 -0
- package/bin/chunk-tf62s7rv.js +3 -0
- package/bin/chunk-tsevmz6j.js +8 -0
- package/bin/chunk-vfrddwfj.js +2 -0
- package/bin/chunk-vfw5hbnf.js +4 -0
- package/bin/chunk-vhfqr7n5.js +4 -0
- package/bin/chunk-wpthjy5r.js +2 -0
- package/bin/chunk-wsgbp0ae.js +7 -0
- package/bin/chunk-x7pbj6bf.js +3 -0
- package/bin/chunk-xg9xscqz.js +1 -0
- package/bin/chunk-yqhefh7z.js +2 -0
- package/bin/chunk-zmr5jvxg.js +4 -0
- package/bin/chunk-zzwyep2y.js +4 -0
- package/bin/shumai-agent-app.js +371 -12554
- package/package.json +7 -7
- package/prisma/migrations/20260711121142_add_agent_session_type/migration.sql +8 -0
- package/prisma/migrations/20260711123731_add_agent_session_name/migration.sql +2 -0
- package/prisma/migrations/20260711124459_add_naming_session_type/migration.sql +2 -0
- package/prisma/migrations/20260714024940_add_session_id_to_workflow_tasks/migration.sql +5 -0
- package/prisma/migrations/20260714025034_backfill_session_id_in_workflow_tasks/migration.sql +4 -0
- package/prisma/schema.prisma +11 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{a as _,b as k,c as M,d as L}from"./chunk-x7pbj6bf.js";import{e as f,f as H,g as S}from"./chunk-q5tv58nz.js";import"./chunk-9pfvgwrc.js";import{i as b}from"./chunk-p8c02x99.js";import{j as D}from"./chunk-tf62s7rv.js";import{q as E}from"./chunk-bqb5hsbe.js";import"./chunk-ej5ed8pg.js";import"./chunk-vhfqr7n5.js";import{yb as $}from"./chunk-p7dw998p.js";import{Bb as U,Cb as V}from"./chunk-nerm3qbg.js";import{Mb as B}from"./chunk-q0f0cac4.js";import"./chunk-k30n4wwk.js";import"./chunk-7mtn96c1.js";var C=new Set(["openai","openai-codex","opencode"]);function A(w){if(w)return w;if(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long")return"long";return"short"}function P(w){return{sendSessionIdHeader:w.compat?.sendSessionIdHeader??!0,supportsLongCacheRetention:w.compat?.supportsLongCacheRetention??!0}}function I(w,F){return F==="long"&&w.supportsLongCacheRetention?"24h":void 0}function y(w){if(w instanceof Error){let F=w.status,z=typeof F==="number"?F:void 0;if(z!==void 0)return`OpenAI API error (${z}): ${w.message}`;return w.message}try{return JSON.stringify(w)}catch{return String(w)}}var v=(w,F,z)=>{let G=new V;return(async()=>{let Q={role:"assistant",content:[],api:w.api,provider:w.provider,model:w.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=z?.apiKey||$(w.provider)||"",X=A(z?.cacheRetention)==="none"?void 0:z?.sessionId,Z=x(w,F,W,z?.headers,X),Y=R(w,F,z),q=await z?.onPayload?.(Y,w);if(q!==void 0)Y=q;let j={...z?.signal?{signal:z.signal}:{},...z?.timeoutMs!==void 0?{timeout:z.timeoutMs}:{},...z?.maxRetries!==void 0?{maxRetries:z.maxRetries}:{}},{data:O,response:N}=await Z.responses.create(Y,j).withResponse();if(await z?.onResponse?.({status:N.status,headers:D(N.headers)},w),G.push({type:"start",partial:Q}),await S(O,Q,G,w,{serviceTier:z?.serviceTier,applyServiceTierPricing:(T,K)=>g(T,K,w)}),z?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");G.push({type:"done",reason:Q.stopReason,message:Q}),G.end()}catch(W){for(let J of Q.content)delete J.index,delete J.partialJson;Q.stopReason=z?.signal?.aborted?"aborted":"error",Q.errorMessage=y(W),G.push({type:"error",reason:Q.stopReason,error:Q}),G.end()}})(),G},t=(w,F,z)=>{let G=z?.apiKey||$(w.provider);if(!G)throw Error(`No API key for provider: ${w.provider}`);let Q=E(w,z,G),W=z?.reasoning?U(w,z.reasoning):void 0;return v(w,F,{...Q,reasoningEffort:W==="off"?void 0:W})};function x(w,F,z,G,Q){if(!z){if(!process.env.OPENAI_API_KEY)throw Error("OpenAI API key is required. Set OPENAI_API_KEY environment variable or pass it as an argument.");z=process.env.OPENAI_API_KEY}let W=P(w),J={...w.headers};if(w.provider==="github-copilot"){let Z=M(F.messages),Y=L({messages:F.messages,hasImages:Z});Object.assign(J,Y)}if(Q){if(W.sendSessionIdHeader)J.session_id=Q;J["x-client-request-id"]=Q}if(G)Object.assign(J,G);let X=w.provider==="cloudflare-ai-gateway"?{...J,Authorization:J.Authorization??null,"cf-aig-authorization":`Bearer ${z}`}:J;return new B({apiKey:z,baseURL:_(w.provider)?k(w):w.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:X})}function R(w,F,z){let G=f(w,F,C),Q=A(z?.cacheRetention),W=P(w),J={model:w.id,input:G,stream:!0,prompt_cache_key:Q==="none"?void 0:b(z?.sessionId),prompt_cache_retention:I(W,Q),store:!1};if(z?.maxTokens)J.max_output_tokens=z?.maxTokens;if(z?.temperature!==void 0)J.temperature=z?.temperature;if(z?.serviceTier!==void 0)J.service_tier=z.serviceTier;if(F.tools&&F.tools.length>0)J.tools=H(F.tools);if(w.reasoning){if(z?.reasoningEffort||z?.reasoningSummary){let X=z?.reasoningEffort?w.thinkingLevelMap?.[z.reasoningEffort]??z.reasoningEffort:"medium";J.reasoning={effort:X,summary:z?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(w.provider!=="github-copilot"&&w.thinkingLevelMap?.off!==null)J.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return J}function h(w,F){switch(F){case"flex":return 0.5;case"priority":return w.id==="gpt-5.5"?2.5:2;default:return 1}}function g(w,F,z){let G=h(z,F);if(G===1)return;w.cost.input*=G,w.cost.output*=G,w.cost.cacheRead*=G,w.cost.cacheWrite*=G,w.cost.total=w.cost.input+w.cost.output+w.cost.cacheRead+w.cost.cacheWrite}export{t as streamSimpleOpenAIResponses,v as streamOpenAIResponses};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function L(G,q,D){return{temperature:q?.temperature,maxTokens:q?.maxTokens,signal:q?.signal,apiKey:D||q?.apiKey,transport:q?.transport,cacheRetention:q?.cacheRetention,sessionId:q?.sessionId,headers:q?.headers,onPayload:q?.onPayload,onResponse:q?.onResponse,timeoutMs:q?.timeoutMs,websocketConnectTimeoutMs:q?.websocketConnectTimeoutMs,maxRetries:q?.maxRetries,maxRetryDelayMs:q?.maxRetryDelayMs,metadata:q?.metadata}}function K(G){return G==="xhigh"?"high":G}function y(G,q,D,N){let _={...{minimal:1024,low:2048,medium:8192,high:16384},...N},O=1024,V=K(D),J=_[V],Q=G===void 0?q:Math.min(G+J,q);if(Q<=J)J=Math.max(0,Q-1024);return{maxTokens:Q,thinkingBudget:J}}function j(G,q){let D=[],N=!1;for(let Y of G){if(Y.type==="image"){if(!N)D.push({type:"text",text:q});N=!0;continue}D.push(Y),N=Y.text===q}return D}function U(G,q){if(q.input.includes("image"))return G;return G.map((D)=>{if(D.role==="user"&&Array.isArray(D.content))return{...D,content:j(D.content,"(image omitted: model does not support images)")};if(D.role==="toolResult")return{...D,content:j(D.content,"(tool image omitted: model does not support images)")};return D})}function W(G,q,D){let N=new Map,_=U(G,q).map((E)=>{if(E.role==="user")return E;if(E.role==="toolResult"){let A=N.get(E.toolCallId);if(A&&A!==E.toolCallId)return{...E,toolCallId:A};return E}if(E.role==="assistant"){let A=E,H=A.provider===q.provider&&A.api===q.api&&A.model===q.id,$=A.content.flatMap((F)=>{if(F.type==="thinking"){if(F.redacted)return H?F:[];if(H&&F.thinkingSignature)return F;if(!F.thinking||F.thinking.trim()==="")return[];if(H)return F;return{type:"text",text:F.thinking}}if(F.type==="text"){if(H)return F;return{type:"text",text:F.text}}if(F.type==="toolCall"){let X=F,Z=X;if(!H&&X.thoughtSignature)Z={...X},delete Z.thoughtSignature;if(!H&&D){let w=D(X.id,q,A);if(w!==X.id)N.set(X.id,w),Z={...Z,id:w}}return Z}return F});return{...A,content:$}}return E}),O=[],V=[],J=new Set,Q=()=>{if(V.length>0){for(let E of V)if(!J.has(E.id))O.push({role:"toolResult",toolCallId:E.id,toolName:E.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});V=[],J=new Set}};for(let E=0;E<_.length;E++){let A=_[E];if(A.role==="assistant"){Q();let H=A;if(H.stopReason==="error"||H.stopReason==="aborted")continue;let $=H.content.filter((F)=>F.type==="toolCall");if($.length>0)V=$,J=new Set;O.push(A)}else if(A.role==="toolResult")J.add(A.toolCallId),O.push(A);else if(A.role==="user")Q(),O.push(A);else O.push(A)}return Q(),O}
|
|
3
|
+
export{L as dc,y as ec,W as fc};
|