gemi 0.190.0 → 0.191.0
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/dist/ai/Agent.d.ts +12 -0
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/index.js +1 -1
- package/dist/{chunk-2qqm3482.js → chunk-6rdr7ne2.js} +2 -2
- package/dist/{chunk-2qqm3482.js.map → chunk-6rdr7ne2.js.map} +1 -1
- package/dist/{chunk-71jcjnwk.js → chunk-ca76mcea.js} +2 -2
- package/dist/{chunk-71jcjnwk.js.map → chunk-ca76mcea.js.map} +3 -3
- package/dist/{chunk-352y2y3z.js → chunk-fq006ypv.js} +1 -1
- package/dist/{chunk-nbhxm3sz.js → chunk-j2twdj8b.js} +1 -1
- package/dist/{chunk-2v7a5wv6.js → chunk-xc2m8qa1.js} +1 -1
- package/dist/client/Head.d.ts +26 -1
- package/dist/client/Head.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +17 -2
- package/dist/client/index.js.map +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-352y2y3z.js.map → chunk-fq006ypv.js.map} +0 -0
- /package/dist/{chunk-nbhxm3sz.js.map → chunk-j2twdj8b.js.map} +0 -0
- /package/dist/{chunk-2v7a5wv6.js.map → chunk-xc2m8qa1.js.map} +0 -0
package/dist/ai/Agent.d.ts
CHANGED
|
@@ -478,6 +478,18 @@ export interface RunAgentParams<Ctx = AgentContext> {
|
|
|
478
478
|
*/
|
|
479
479
|
maxOutputTokens?: number;
|
|
480
480
|
temperature?: number;
|
|
481
|
+
/**
|
|
482
|
+
* The provider for this sub-run's model calls (#1171). Omitted, the sub-run
|
|
483
|
+
* uses the provider the parent run was given (`stream({ provider })`) when
|
|
484
|
+
* it was given one, and its own agent's otherwise.
|
|
485
|
+
*
|
|
486
|
+
* Inherited because a per-run provider is usually about the run rather than
|
|
487
|
+
* the agent: a recorder that replays a test's model calls, or a route to a
|
|
488
|
+
* different deployment, should reach every sub-run too. Pass one to tell
|
|
489
|
+
* sub-runs apart (e.g. `recorder.child(key)` for parallel sub-runs) or to
|
|
490
|
+
* keep a sub-agent on its own: `provider: subAgent.provider`.
|
|
491
|
+
*/
|
|
492
|
+
provider?: AgentProvider;
|
|
481
493
|
}
|
|
482
494
|
/**
|
|
483
495
|
* What a completed sub-run gives back.
|
package/dist/ai/Agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../ai/Agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAA2C,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAkB,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAapB,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAY,MAAM,iBAAiB,CAAC;AACrG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAIvB,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAW5B,OAAO,KAAK,EACV,UAAU,EAEV,iBAAiB,EAGjB,eAAe,EA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OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$b as Z8,$c as Z6,Ac as ZQ,Bc as WQ,Cc as M8,Ec as S8,Fc as j8,Gc as E8,Hc as T8,Ic as k8,Jc as x8,Kc as q8,Lc as I8,Mc as w8,Nc as b8,Oc as f8,Pc as v8,Rc as b,Sc as Z9,Tc as O9,Uc as _9,Vc as M9,Wc as a,Xc as x,Yb as Q8,Yc as K8,Zb as MQ,Zc as $6,_b as SQ,_c as Q6,ad as W6,bd as K6,cc as IJ,cd as X6,dc as E,dd as Y6,ec as k,ed as G6,fd as V6,gc as e8,gd as H6,hc as n8,hd as z6,ic as XJ,id as FJ,jc as J6,jd as D6,kc as m,kd as xQ,lc as W8,ld as F6,mc as AQ,md as qQ,nc as RQ,nd as P6,oc as EQ,od as B6,pc as d,pd as U6,qc as TQ,qd as kJ,rc as aJ,rd as B$,sc as kQ,sd as N6,tc as jQ,td as L6,uc as tJ,ud as IQ,vc as C8,vd as C6,wc as O8,wd as O6,xd as _6,yc as _8,yd as M6,zc as g,zd as F$}from"../chunk-
|
|
2
|
+
import{$b as Z8,$c as Z6,Ac as ZQ,Bc as WQ,Cc as M8,Ec as S8,Fc as j8,Gc as E8,Hc as T8,Ic as k8,Jc as x8,Kc as q8,Lc as I8,Mc as w8,Nc as b8,Oc as f8,Pc as v8,Rc as b,Sc as Z9,Tc as O9,Uc as _9,Vc as M9,Wc as a,Xc as x,Yb as Q8,Yc as K8,Zb as MQ,Zc as $6,_b as SQ,_c as Q6,ad as W6,bd as K6,cc as IJ,cd as X6,dc as E,dd as Y6,ec as k,ed as G6,fd as V6,gc as e8,gd as H6,hc as n8,hd as z6,ic as XJ,id as FJ,jc as J6,jd as D6,kc as m,kd as xQ,lc as W8,ld as F6,mc as AQ,md as qQ,nc as RQ,nd as P6,oc as EQ,od as B6,pc as d,pd as U6,qc as TQ,qd as kJ,rc as aJ,rd as B$,sc as kQ,sd as N6,tc as jQ,td as L6,uc as tJ,ud as IQ,vc as C8,vd as C6,wc as O8,wd as O6,xd as _6,yc as _8,yd as M6,zc as g,zd as F$}from"../chunk-ca76mcea.js";import{Rd as P8}from"../chunk-495k9h6p.js";import"../chunk-baknm4tn.js";import{Oh as NQ,Rh as CQ,Si as OQ,Vi as d$,Zi as _Q,fi as T9,gi as t0,hi as r0,ii as e0,ji as w}from"../chunk-1987f978.js";import{_i as LQ,aj as oJ,bj as sJ}from"../chunk-8b897pc1.js";import{kj as c}from"../chunk-bwmyd47e.js";import"../chunk-2k948anx.js";import"../chunk-khzss89b.js";import"../chunk-xqzrd7st.js";import{Ck as RJ,nk as o,ok as s}from"../chunk-fgk1e5xe.js";import"../chunk-yn2av14e.js";import"../chunk-x1ng1dnx.js";import{pl as n9}from"../chunk-nc37phkt.js";import"../chunk-6tsyk2mr.js";import"../chunk-6a3t825g.js";import{Il as $$}from"../chunk-h8knqrc5.js";import"../chunk-80kpxp4m.js";import{existsSync as gQ,readdirSync as A6,readFileSync as z8}from"fs";import{isAbsolute as uQ,join as CJ,relative as cQ,sep as mQ}from"path";var D8="prompts.json",pQ=/\{\{>\s*([\w./-]+)\s*\}\}/g,G8=/\{\{(\w+)\}\}/g,lQ=/^[\w-]+(\/[\w-]+)*$/,V8={dir:"app/agents",shared:"prompts"},_J={},eJ=new Map,OJ;function dQ(){if(OJ===void 0){let J=CJ($$(),"dist","server",D8);OJ=gQ(J)?JSON.parse(z8(J,"utf8")):null}return OJ??null}function iQ(J){return J.replace(/\r?\n$/,"")}function H8(){return _J.cache??Bun.env.NODE_ENV==="production"}function nQ(J){if(!lQ.test(J))throw Error(`"${J}" is not a prompt name. Use letters, digits, "-" and "_", with "/" between folders.`);let $=_J.dir??V8.dir,Q=uQ($)?$:CJ(process.cwd(),$),Z=J.includes("/")?`${J}.md`:CJ(_J.shared??V8.shared,`${J}.md`);return CJ(Q,Z)}function oQ(J){let $=nQ(J),Q=H8()?eJ.get($):void 0;if(Q!==void 0)return Q;let Z=Bun.env.NODE_ENV==="production";if(Z){let K=dQ()?.[cQ($$(),$).split(mQ).join("/")];if(K!==void 0)return K}let W;try{W=iQ(z8($,"utf8"))}catch(K){if(K.code==="ENOENT"){let X=Z?` or in dist/server/${D8}`:"";throw Error(`The prompt "${J}" does not exist (looked for ${$}${X}).`)}throw K}if(H8())eJ.set($,W);return W}function J$(J,$){if($.includes(J))throw Error(`The prompt "${J}" includes itself: ${[...$,J].join(" > ")}.`);return oQ(J).replace(pQ,(Q,Z)=>J$(Z,[...$,J]))}class F8{static configure(J){_J={...J},eJ.clear(),OJ=void 0}static render(J,$={}){return J$(J,[]).replace(G8,(Q,Z)=>{if(!Object.hasOwn($,Z))throw Error(`The prompt "${J}" has no value for {{${Z}}}.`);return String($[Z])})}static placeholders(J){let $=[...J$(J,[]).matchAll(G8)].map((Q)=>Q[1]);return[...new Set($)]}}class Q$ extends P8{name="AgentJobDeadlineSweep";cron="* * * * *";async callback(){while(await g.sweep({limit:100})===100);}}var MJ=20;function U8(J,$){if($<=0||J.length===0)return null;let Q=(K,X)=>X.createdAt-K.createdAt||(K.id<X.id?1:-1);return["<jobs>","Background jobs that tools started in this conversation, running ones first. A running job's result replaces its tool result when it finishes. Do not start the same work again while a job for it is running.",...[...J.filter((K)=>K.state==="running").sort(Q),...J.filter((K)=>K.state!=="running").sort(Q)].slice(0,$).map((K)=>{let X=[`- ${K.id} (${K.toolName})`];if(K.state==="running")X.push(`running since ${Z$(K.createdAt)}`);else if(K.state==="ok")X.push(`finished at ${Z$(K.settledAt??K.updatedAt)}`);else{let G=K.error?`${K.error.code}: ${B8(K.error.message,200)}`:"failed";X.push(`failed at ${Z$(K.settledAt??K.updatedAt)} (${G})`)}if(K.summary!==void 0)X.push(`summary: ${B8(JSON.stringify(K.summary),300)}`);if(K.orphaned)X.push("its tool call was lost when the turn that started it was cut short");return X.join("; ")}),"</jobs>"].join(`
|
|
3
3
|
`)}function Z$(J){return new Date(J).toISOString().replace(/\.\d{3}Z$/,"Z")}function B8(J,$){return J.length<=$?J:`${J.slice(0,$-1)}\u2026`}class K${table;sql;dialect;connection;constructor(J,$={}){let Q=$.table??"gemi_agent_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(Q))throw Error(`The agent jobs table name "${Q}" is not a plain identifier. Use letters, digits and underscores.`);this.table=Q,this.sql=J.sql,this.dialect=J.dialect,this.connection=J.name}async createTable(){for(let J of sQ(this.dialect,this.table))await this.sql.unsafe(J)}async transaction(J){if(this.connection===void 0||this.joinable())return J();return RJ(this.sql,()=>J(),{connection:this.connection})}async create(J){let $=this.q(),Q=this.clock($);await $`
|
|
4
4
|
INSERT INTO ${this.name($)}
|
|
5
5
|
(id, thread_id, run_id, tool_call_id, tool_name, owner, job, summary, state,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ca as f}from"./chunk-s0z61m9j.js";import{createElement as v}from"react";function q(i,t){let e=Object.keys(t).sort((s,r)=>r.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),p=new RegExp(e.join("|"),"g");return i.replace(p,(s)=>t[s])}async function X(i,t,e=[],p){let s=[...e.map((n)=>`${i}/views/${n}.tsx`),p?`${i}/views/${p}.tsx`:`${i}/views/RootLayout.tsx`],r=new Set;for(let n of s){let u=t.moduleGraph.getModulesByFile(n);if(u)for(let d of u)r.add(d)}let b=[],l=[],g={};for(let n of r)if(n)for(let u of n.importedModules){if(u.file.includes("module.css"))g[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let n of l){let u=await t.transformRequest(n+"?direct"),d=n.includes("module.css"),j="";if(d)j=q(g[n],u.default);b.push({isDev:!0,id:n,content:d?j:u.code})}return b.map((n,u)=>{return v("style",{key:u,type:"text/css","data-vite-dev-id":n.id,dangerouslySetInnerHTML:{__html:n.content}})})}async function Y(i=[]){return i.map((t,e)=>{return v("style",{key:e,id:t?.id,type:"text/css",dangerouslySetInnerHTML:{__html:t.content}})})}import{existsSync as k}from"fs";import{basename as z}from"path";import{networkInterfaces as $}from"os";var a={name:"gemi",version:"0.
|
|
2
|
+
import{Ca as f}from"./chunk-s0z61m9j.js";import{createElement as v}from"react";function q(i,t){let e=Object.keys(t).sort((s,r)=>r.length-s.length).map((s)=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),p=new RegExp(e.join("|"),"g");return i.replace(p,(s)=>t[s])}async function X(i,t,e=[],p){let s=[...e.map((n)=>`${i}/views/${n}.tsx`),p?`${i}/views/${p}.tsx`:`${i}/views/RootLayout.tsx`],r=new Set;for(let n of s){let u=t.moduleGraph.getModulesByFile(n);if(u)for(let d of u)r.add(d)}let b=[],l=[],g={};for(let n of r)if(n)for(let u of n.importedModules){if(u.file.includes("module.css"))g[u.file]=u.ssrTransformResult.map.sourcesContent.join("");if(u.file.includes(".css"))l.push(u.file)}for(let n of l){let u=await t.transformRequest(n+"?direct"),d=n.includes("module.css"),j="";if(d)j=q(g[n],u.default);b.push({isDev:!0,id:n,content:d?j:u.code})}return b.map((n,u)=>{return v("style",{key:u,type:"text/css","data-vite-dev-id":n.id,dangerouslySetInnerHTML:{__html:n.content}})})}async function Y(i=[]){return i.map((t,e)=>{return v("style",{key:e,id:t?.id,type:"text/css",dangerouslySetInnerHTML:{__html:t.content}})})}import{existsSync as k}from"fs";import{basename as z}from"path";import{networkInterfaces as $}from"os";var a={name:"gemi",version:"0.191.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*","ide/typescript-plugin/package.json","skills/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./ai":"./ai/index.ts","./ai/client":"./ai/client/index.ts","./ai/voice":"./ai/voice/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./probe":"./probe/index.ts","./console/run":"./console/run.ts","./queue/work":"./services/queue/work.ts","./stats/route-table":"./stats/route-table.ts","./ide/typescript-plugin":"./ide/typescript-plugin/index.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts","./vitest":"./vitest/index.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.browser.json && tsc --noEmit -p ide/typescript-plugin/tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:ts-plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --external=typescript --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/ai/client dist/ai/voice dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:ts-plugin":"bun ./scripts/build-ts-plugin.ts","build:types":"tsc -p tsconfig.build.json","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun x vitest","test:types":"vitest run --typecheck.only","test:live":"bun --bun x vitest run ai/live","test:packaging":"bun --bun x vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0","happy-dom":"^21.0.4",jsdom:"^30.0.1",oxlint:"^1.39.0",postgres:"^3.4.5",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",typescript:">=5",vite:"^8.0.0",postgres:"^3.4.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0},typescript:{optional:!0},postgres:{optional:!0}}};var h=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],m=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,c=(i,t)=>m?`\x1B[${i}m${t}\x1B[0m`:t,E=(i)=>c("1",i),x=(i)=>c("2",i),o=(i)=>c("36",i),G=(i)=>c("32",i),J=(i)=>c("35",i);function N(){return a.version??"?"}function O(i){for(let t of Object.values($()))for(let e of t??[])if((e.family==="IPv4"||e.family===4)&&!e.internal)return`http://${e.address}:${i}`;return null}function Q(i){return f(i).filter((t)=>k(t)).map((t)=>z(t))}function F(i){let{port:t,rootDir:e}=i,p=`http://localhost:${t}`,s=O(t),r=Q(e),b=(g,n)=>` ${G("\u279C")} ${E(g.padEnd(9))}${n}`,l=["",...h.map((g)=>J(g)),"",` ${x("gemi")} ${o(`v${N()}`)}`,"",b("Local:",o(p)),b("Network:",s?o(s):x("unavailable")),b("Env:",r.length?r.join(", "):x("none")),""];console.log(l.join(`
|
|
3
3
|
`))}function V(i,t){return Error(`app/views/${i}.tsx is missing. gemi's auth routes render it because ${t} is on. Add the view, or turn that setting off in app/config/auth.ts.`)}function U(i=process.env.SERVER_IDLE_TIMEOUT){if(i===void 0||i.trim()==="")return 10;let t=Number(i.trim());if(!Number.isInteger(t)||t<0||t>255)throw Error(`SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 (0 disables the timeout), got ${JSON.stringify(i)}.`);return t}
|
|
4
4
|
export{X as W,Y as X,F as Y,V as Z,U as _};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=AD001A6915E7B83564756E2164756E21
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"/**\n * Bun's default, and what both servers use when `SERVER_IDLE_TIMEOUT` is unset.\n */\nexport const DEFAULT_SERVER_IDLE_TIMEOUT = 10;\n\n/**\n * The `idleTimeout` (seconds) both `gemi dev` and `gemi start` pass to\n * `Bun.serve`, from `SERVER_IDLE_TIMEOUT` (#787).\n *\n * One reader for both servers, so a long-poll that works under `gemi start`\n * also works under `gemi dev`. Before this, only `httpProd` read the variable\n * and the dev server always ran at Bun's 10 seconds.\n *\n * It is the time a connection may stay silent, a response that has not started\n * included, before Bun closes it; `0` disables it. It does not apply to an\n * upgraded websocket (the HMR relay included), which has its own\n * `websocket.idleTimeout`.\n *\n * Unset or blank means the default. Anything that is not a whole number from 0\n * to 255 (Bun's own limits) fails the boot with the variable's name, instead\n * of Bun's \"expects idleTimeout to be an integer\", which does not say where the\n * value came from.\n */\nexport function serverIdleTimeout(raw: string | undefined = process.env.SERVER_IDLE_TIMEOUT): number {\n if (raw === undefined || raw.trim() === \"\") return DEFAULT_SERVER_IDLE_TIMEOUT;\n\n const seconds = Number(raw.trim());\n if (!Number.isInteger(seconds) || seconds < 0 || seconds > 255) {\n throw new Error(\n `SERVER_IDLE_TIMEOUT must be a whole number of seconds from 0 to 255 ` +\n `(0 disables the timeout), got ${JSON.stringify(raw)}.`,\n );\n }\n return seconds;\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"mappings": ";yCAAA,wBAAS,cAGT,SAAS,CAAc,CAAC,EAAc,EAAwC,CAC5E,IAAM,EAAc,OAAO,KAAK,CAAM,EACnC,KAAK,CAAC,EAAG,IAAM,EAAE,OAAS,EAAE,MAAM,EAClC,IAAI,CAAC,IAAQ,EAAI,QAAQ,sBAAuB,MAAM,CAAC,EAGpD,EAAQ,IAAI,OAAO,EAAY,KAAK,GAAG,EAAG,GAAG,EAEnD,OAAO,EAAK,QAA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AK,IAAI,EAAY,GAAG,IAC5C,GACA,EAAI,SAAU,EAAK,CAAK,CAAC,EACzB,EAAI,WAAY,EAAU,EAAK,CAAO,EAAI,EAAI,aAAa,CAAC,EAC5D,EAAI,OAAQ,EAAI,OAAS,EAAI,KAAK,IAAI,EAAI,EAAI,MAAM,CAAC,EACrD,EACF,EAEA,QAAQ,IAAI,EAAI,KAAK;AAAA,CAAI,CAAC,ECjErB,SAAS,CAAwB,CAAC,EAAc,EAAoB,CACzE,OAAW,MACT,aAAa,0DAA6D,wEAE5E,ECcK,SAAS,CAAiB,CAAC,EAA0B,QAAQ,IAAI,oBAA6B,CACnG,GAAI,IAAQ,QAAa,EAAI,KAAK,IAAM,GAAI,MArBH,IAuBzC,IAAM,EAAU,OAAO,EAAI,KAAK,CAAC,EACjC,GAAI,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GAAK,EAAU,IACzD,MAAU,MACR,qGACmC,KAAK,UAAU,CAAG,IACvD,EAEF,OAAO",
|
|
11
|
-
"debugId": "
|
|
11
|
+
"debugId": "AD001A6915E7B83564756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -24,7 +24,7 @@ data: ${JSON.stringify(z.event)}
|
|
|
24
24
|
|
|
25
25
|
`):void 0}async runTools(Z,$,Q){let B=[],X=[],G=null;for(let J of $){let z=String(J.name),W=!this.config.offered||this.config.offered.has(z)?this.config.registry.get(z):void 0;if(!W){this.addResult(Z,{type:"tool-result",toolCallId:J.toolCallId,name:J.name,status:"error",error:{code:"tool_error",message:`There is no tool named "${String(J.name)}".`,toolCallId:J.toolCallId,retryable:!0}});continue}let H=W.inputSchema.safeParse(J.input);if(H.ok===!1){this.addResult(Z,{type:"tool-result",toolCallId:J.toolCallId,name:J.name,status:"error",error:{code:"invalid_tool_input",message:`Invalid arguments for "${String(J.name)}": ${H.errors.join(", ")}`,toolCallId:J.toolCallId,retryable:!0}});continue}J.input=H.value;let K=X7(W.tool);if(K==="approval"&&W.tool.approvalPredicate&&!await this.asksApproval(W.tool,J,H.value,Q))K=null;if(K){if(this.onPending==="deny"){this.addResult(Z,this.deniedByPolicy(J));continue}let q=K==="approval"&&W.tool.approvalPreview?await this.previewApproval(W.tool,J,H.value,Q):void 0;B.push({toolCallId:J.toolCallId,name:J.name,input:H.value,kind:K,signature:C4(this.claimsFor(J.toolCallId,String(J.name),K,H.value)),...this.pathPrefix.length>0?{path:[...this.pathPrefix]}:{},...q!==void 0?{preview:q}:{}});continue}if(this.limiter){let q=this.limitHit;if(!q&&!G)try{q=await this.limiter.check(this.spent(),{toolCalls:1})}catch(F){if(!(F instanceof GZ))throw F;G=F}if(G){this.addResult(Z,{type:"tool-result",toolCallId:J.toolCallId,name:J.name,status:"error",error:{code:"unknown",message:G.message,toolCallId:J.toolCallId,retryable:!0}});continue}if(q){this.limitHit=q,this.addResult(Z,{type:"tool-result",toolCallId:J.toolCallId,name:J.name,status:"error",error:{code:"usage_limit",message:j0(q),toolCallId:J.toolCallId,retryable:!1}});continue}}this.toolCallCount++,X.push(this.executeTool(W,Z.id,J,H.value,Q).then(async(q)=>{this.addResult(Z,q),await this.settleShown(J.toolCallId)}).catch((q)=>{if(q instanceof n){if(this.onPending==="deny"){this.addResult(Z,this.deniedByPolicy(J));return}B.push(...q.pending);return}}))}if(await w(Promise.all(X).then(()=>{return}),this.controller.signal),G)throw G;return B}async closingText(Z,$,Q){let B=[];for(let X of $){let G=this.config.registry.get(String(X.name))?.tool;if(!G?.endsRun)return null;let J=Z.content.find((V)=>V.type==="tool-result"&&V.toolCallId===X.toolCallId);if(J?.status!=="ok")return null;let z=!0;if(typeof G.endsRun==="function"){let V={input:X.input,context:this.context,body:this.params.body??{},runId:this.runId,threadId:this.params.threadId,toolCallId:X.toolCallId,step:Q,depth:this.depth,signal:this.controller.signal};try{z=await w(Promise.resolve().then(()=>G.endsRun(J.output,V)),this.controller.signal)}catch(W){if(W instanceof x)throw W;return this.writeLog(`[gemi/ai] agent "${this.config.name}": the endsRun of "${G.name}" threw, so the run carries on`,{error:W,toolCallId:X.toolCallId}),null}}if(typeof z==="string"){if(z)B.push(z)}else if(z!==!0)return null}return B.join(`
|
|
26
26
|
|
|
27
|
-
`)}async asksApproval(Z,$,Q,B){let X=this.approvalContext($,B);try{return await w(Promise.resolve().then(()=>Z.approvalPredicate(Q,X)),this.controller.signal)!==!1}catch(G){if(G instanceof x)throw G;return this.writeLog(`[gemi/ai] agent "${this.config.name}": the requiresApproval of "${Z.name}" threw, so the call asks the user`,{error:G,toolCallId:$.toolCallId}),!0}}approvalContext(Z,$){return{context:this.context,body:this.params.body??{},runId:this.runId,threadId:this.params.threadId,toolCallId:Z.toolCallId,step:$,depth:this.depth,signal:this.controller.signal}}async previewApproval(Z,$,Q,B){let X=this.approvalContext($,B),G=()=>{};try{let J=Promise.resolve().then(()=>Z.approvalPreview(Q,X)),z=Z.timeoutMs,V=z===void 0?J:Promise.race([J,new Promise((H,K)=>{G=L0(z,()=>K(Error(`approvalPreview did not finish within ${z}ms`)))})]);J.catch(()=>{});let W=await w(V,this.controller.signal);if(W===void 0)return;return JSON.parse(JSON.stringify(W))}catch(J){if(J instanceof x)throw J;this.writeLog(`[gemi/ai] agent "${this.config.name}": the approvalPreview of "${Z.name}" failed, so the call is asked without a preview`,{error:J,toolCallId:$.toolCallId});return}finally{G()}}claimsFor(Z,$,Q,B){return{runId:this.signingRunId,toolCallId:Z,name:$,kind:Q,input:B,path:this.pathPrefix.length>0?[...this.pathPrefix]:void 0,subject:this.params.subject??null}}deniedByPolicy(Z){return{type:"tool-result",toolCallId:Z.toolCallId,name:Z.name,status:"denied",cause:"refused",reason:`"${String(Z.name)}" needs the user, and this run was started with onPending: "deny". Answer from what you already have.`}}async executeTool(Z,$,Q,B,X,G){let J=Z.tool.timeoutMs;if(J===void 0)return this.runToolBody(Z,$,Q,B,X,G,this.controller.signal,()=>!1);let z=new AbortController,V=this.controller.signal,W=()=>z.abort(V.reason);if(V.aborted)W();else V.addEventListener("abort",W,{once:!0});let H=!1,K=this.runToolBody(Z,$,Q,B,X,G,z.signal,()=>H),q=()=>{},F=new Promise((Y)=>{q=L0(J,()=>{let D=`"${String(Q.name)}" did not finish within ${C0(J)} (timeoutMs: ${J}) and was cancelled.`;z.abort(new DOMException(D,"TimeoutError")),Y({type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"error",error:{code:"timeout",message:D,toolCallId:Q.toolCallId,retryable:!0}})})});K.catch(()=>{});try{return await Promise.race([K,F])}finally{H=!0,q()}}async runToolBody(Z,$,Q,B,X,G,J,z){let V=this.toolFiles(Q,J),W=this.approvals.get(Q.toolCallId),H={context:this.context,body:this.params.body??{},runId:this.runId,threadId:this.params.threadId,toolCallId:Q.toolCallId,signal:J,step:X,depth:this.depth,resumed:G!==void 0,attachments:V.attachments,generateImage:V.generateImage,editImage:V.editImage,turn:this.toolTurn($),runAgent:this.nestedRunner($,Q,J,G),generate:(K)=>this.generateForTool(K,J,Q.toolCallId),jobs:W7({jobs:this.depth===0?this.params.jobs:void 0,threadId:this.params.threadId,runId:this.runId,toolCallId:Q.toolCallId,toolName:String(Q.name),depth:this.depth,async:Z.tool.async,attachments:this.params.attachments??null}),memory:this.memory.handle({messageId:$}),meter:this.meter,...W?{approval:W}:{}};try{let K=Z.tool.execute(B,H),q;if(Y$(K)){let Y=await K.next();while(!Y.done){if(z())throw K.return(void 0).catch(()=>{}),new x;this.emit({type:"tool-progress",toolCallId:Q.toolCallId,data:Y.value}),Y=await K.next()}q=Y.value}else q=await K;if(V7(q)){if(q.toolCallId!==Q.toolCallId)throw new P(`"${String(Q.name)}" returned the handle of a job another tool call started. Return the handle from this call's own ctx.jobs.`,{retryable:!1});return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"running",job:{id:q.id,...q.summary!==void 0?{summary:q.summary}:{}}}}let F=i4(Z.tool,q,(Y)=>this.writeLog(`[gemi/ai] agent "${this.config.name}": the toModel of "${String(Q.name)}" threw, so the model reads the whole output`,{error:Y,toolCallId:Q.toolCallId}));return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"ok",output:q,...F!==void 0?{modelOutput:F}:{}}}catch(K){if(K instanceof x||this.controller.signal.aborted)throw new x;if(K instanceof n)throw K;let q=K instanceof P;if(!q&&this.config.logErrors)this.logToolFailure(Q,K);let F={code:"tool_error",message:K instanceof Error?K.message:String(K),toolCallId:Q.toolCallId,retryable:q?K.retryable:!0};return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"error",error:this.redact(F,{source:"tool",toolName:String(Q.name),cause:K})}}}async generateForTool(Z,$,Q){let B=this.controller.signal;return zZ({...Z,signal:Z.signal?AbortSignal.any([$,Z.signal]):$},{origin:{agent:this.config.name,runId:this.runId,...this.params.threadId?{threadId:this.params.threadId}:{},toolCallId:Q},settled:(X)=>{if(this.usage=_(this.usage,X.usage),B.aborted)throw new x}})}nestedRunner(Z,$,Q,B){let X=new N0(()=>$.nested,()=>$.nested=[]);return async(G,J={})=>{let{at:z,recorded:V,write:W}=X.next();if(V){let H=F$(V,G,J);if(H)throw new P(`Nested run ${z} of "${String($.name)}" ${H}. `+"runAgent is memoized by call index, so a body whose runAgent calls depend on a condition that changed between turns cannot be resumed \u2014 the answer would be paired with a different sub-run. "+"Make the sequence of runAgent calls, and what each one is asked, the same every time this tool runs, or branch on ctx.resumed.");if(V.finishReason!=="awaiting-input")return{runId:V.runId,agent:V.agent,messages:V.messages,finishReason:V.finishReason??"stop",usage:V.usage??I(),output:Z7(V.messages),nested:V}}return this.runNested(Z,$,Q,G,J,W,V,B?.answers??[])}}async runNested(Z,$,Q,B,X,G,J,z){let V=[...this.chain,B.name];if(this.chain.includes(B.name))throw new P(`"${B.name}" is already running further up this chain: ${V.join(" -> ")}. An agent cannot run itself, directly or through another agent.`);let W=this.depth+1;if(W>this.maxDepth)throw new P(`Nested agent runs are ${this.maxDepth} deep at most and this one would be ${W}: ${V.join(" -> ")}. Raise maxDepth on the agent at the root of the run if the tree is meant to be this deep.`);let H=X.label,K=[...this.pathPrefix,$.toolCallId],q=this.onPending==="deny"?"deny":X.onPending??"escalate",F=J!==void 0,Y=F?kZ(J.messages):new Set,D=F?z.filter((O)=>{let k=B7(O.path,K);if(k===null)return!1;return Y.has(k.length>0?k[0]:O.toolCallId)}):[],U=B.stream({messages:F?J.messages:X.messages??[],turn:F?{toolResults:D}:X.prompt?{text:X.prompt}:void 0,context:X.context??this.context,attachments:this.params.attachments,body:this.params.body,signal:Q,threadId:this.params.threadId,redactError:this.params.redactError,nonces:this.params.nonces,receipts:this.params.receipts,subject:this.params.subject,...this.params.memory?{memory:{scopes:this.params.memory.scopes}}:{},instructions:X.instructions,maxOutputTokens:X.maxOutputTokens,temperature:X.temperature,runId:F?J.runId:void 0,nesting:{depth:W,maxDepth:this.maxDepth,chain:V,signingRunId:this.signingRunId,signingPath:K,onPending:q,memoryWrites:this.memory.writes}}),j=[],L=(O)=>this.emit({type:"nested-event",toolCallId:$.toolCallId,runId:U.runId,agent:B.name,label:H,event:O}),C=(async()=>{for await(let O of U){if(O.type==="awaiting-input")j=O.pending;if(L(O),O.type==="run-start"&&!F)for(let k of X.messages??[])L({type:"message",message:k});if(O.type==="error")this.emit({type:"error",error:O.error,nested:{toolCallId:$.toolCallId,runId:U.runId,agent:B.name}})}})(),M=(async()=>{let O=await U.result();await C;let k=F?e4(J.messages,O.messages):e4(X.messages??[],O.messages),s={runId:U.runId,agent:B.name,label:H,messages:k,finishReason:O.finishReason,usage:F?_(J.usage??I(),O.usage):O.usage,...O.finishReason==="awaiting-input"?{signature:I4({runId:this.signingRunId,path:K,nestedRunId:U.runId,open:[...kZ(k)],input:$.input,subject:this.params.subject??null})}:{}};return G(s),this.usage=_(this.usage,O.usage),{result:O,record:s}})(),N=M.then(()=>{return},()=>{return});this.nestedSettling.add(N);let b,A;try{({result:b,record:A}=await M)}finally{this.nestedSettling.delete(N)}if(this.controller.signal.aborted)throw new x;if(b.finishReason==="awaiting-input"){if(j.length===0)throw new P(`"${B.name}" ended awaiting input but asked nothing, so there is no question to escalate.`);throw this.emit({type:"tool-call",messageId:Z,part:$,resent:!0}),new n({pending:j,path:K,nested:A})}return{runId:A.runId,agent:B.name,messages:A.messages,finishReason:b.finishReason,usage:A.usage??I(),output:b.output??Z7(A.messages),...b.error?{error:b.error}:{},nested:A}}addResult(Z,$){let Q=Z.content.find((B)=>B.type==="tool-call"&&B.toolCallId===$.toolCallId);if(Q)r4($,Q.input);Z.content.push($),this.emit({type:"tool-result",messageId:Z.id,part:$})}toolFiles(Z,$){let Q=this.params.attachments??null,B=new N0(()=>Z.attachments,()=>Z.attachments=[],()=>({failed:!0})),X=()=>{if(!Q)throw new l("This request has no attachment scope, so a tool cannot store or read files on it. `attachmentScope()` returned null \u2014 put the chat route behind authentication, send a `threadId`, or override `attachmentScope()` on the controller.");return Q},G=async(W,H,K)=>{let q=X(),F=H.mimeType||W.type||"",Y=H.name??(W instanceof File?W.name:"attachment"),D;if(H.showModel){let j=this.config.provider;if(!j.capabilities.fileInput)throw new P(`"${String(Z.name)}" asked to show a file to ${j.model}, which does not accept file input. Drop \`showModel\` for this provider, or run this agent on a model that takes files \u2014 \`capabilities.fileInput\` is what says which do.`);D=await j.upload(new File([W],Y,{type:F||void 0}))}return{attachment:await q.put(W,{name:Y,mimeType:F,fileId:D}),...K?{generated:K}:{},...D?{shown:{fileId:D,messageId:`msg_${crypto.randomUUID()}`,createdAt:new Date().toISOString()}}:{}}},J=(W,H,K)=>{let q=W.generated?"image":"put";if(q===H)return;throw new P(`Attachment ${K} of "${String(Z.name)}" was ${q==="image"?"a generated image":"a stored file"} on the first attempt and is ${H==="image"?"a generated image":"a stored file"} now. ctx.attachments.put, ctx.generateImage and ctx.editImage share one memo indexed by call order within a tool call, so the sequence has to be the same every time this tool runs. Branch on ctx.resumed if it cannot be.`)},z=async(W,H,K)=>{let{at:q,recorded:F,write:Y}=B.next();if(F&&"attachment"in F){if(J(F,"image",q),F.shown)this.queueShown(Z.toolCallId,F);return{attachment:F.attachment,size:F.generated.size,mimeType:F.attachment.mimeType,usage:F.generated.usage}}let D=await K();this.usage=_(this.usage,D.usage);let U=D.mimeType==="image/jpeg"?"jpg":"png",j=await G(D.image,{name:H.name??`${W.name}.${U}`,mimeType:D.mimeType,...H.showModel?{showModel:!0}:{}},{size:D.size,usage:D.usage});if(Y(j),j.shown)this.queueShown(Z.toolCallId,j);return{attachment:j.attachment,size:D.size,mimeType:D.mimeType,usage:D.usage}},V=async(W)=>typeof W==="string"?await X().file(W):W;return{generateImage:(W,H)=>z(W,H,()=>W.generate({...H,signal:$})),editImage:(W,H)=>z(W,H,async()=>{let{images:K,mask:q,...F}=H;return await W.edit({...F,images:await Promise.all(K.map(V)),...q?{mask:await V(q)}:{},signal:$})}),attachments:{get:(W)=>X().get(W),read:(W)=>X().read(W),file:(W)=>X().file(W),put:async(W,H={})=>{let{at:K,recorded:q,write:F}=B.next();if(q&&"attachment"in q){J(q,"put",K);let D=K$(q,W,H);if(D)throw new P(`Attachment ${K} of "${String(Z.name)}" ${D}. `+"ctx.attachments.put is memoized by call index within a tool call, so a body whose put calls depend on a condition that changed between turns cannot be replayed \u2014 the model would be shown a file under an id that names different bytes. "+"Make the sequence of put calls the same every time this tool runs, or branch on ctx.resumed.");if(q.shown)this.queueShown(Z.toolCallId,q);return q.attachment}let Y=await G(W,H);if(F(Y),Y.shown)this.queueShown(Z.toolCallId,Y);return Y.attachment}}}}toolTurn(Z){let $=this.history.findIndex((G)=>G.id===Z),Q=xZ(this.history),B;for(let G=$-1;G>=0;G--){let J=this.history[G];if(J.role!=="user"||Q.has(J.id))continue;B=J;break}let X=[];for(let G of B?.content??[]){if(G.type!=="file")continue;let J=G.attachmentId;if(typeof J!=="string"||!J.startsWith(tZ))continue;if(!X.includes(J))X.push(J)}return Object.freeze({attachments:Object.freeze(X)})}queueShown(Z,$){let Q=$.shown;if(!Q)return;let B=this.shownQueue.get(Z)??[];if(B.some((X)=>X.id===Q.messageId))return;B.push({id:Q.messageId,role:"user",content:[{type:"file",fileId:Q.fileId,name:$.attachment.name,mimeType:$.attachment.mimeType,attachmentId:$.attachment.id}],createdAt:Q.createdAt,finishReason:"stop"}),this.shownQueue.set(Z,B)}async settleShown(Z){let $=this.shownQueue.get(Z);if(!$||$.length===0)return;if(this.shownQueue.delete(Z),this.ended||this.controller.signal.aborted)return;for(let Q of $){if(this.history.some((B)=>B.id===Q.id))continue;this.history.push(Q),this.produced.push(Q),this.emit({type:"message",message:Q}),this.unreported.add(Q)}}historyForProvider(Z){let $=this.history.filter((G)=>G!==Z),Q=xZ($),B=[];for(let G of $){if(!Q.has(G.id))continue;for(let J of G.content)if(J.type==="file")B.push(J)}if(B.length<=Q7)return $;let X=new Set(B.slice(0,B.length-Q7));return $.map((G)=>{if(!G.content.some((J)=>J.type==="file"&&X.has(J)))return G;return{...G,content:G.content.map((J)=>J.type==="file"&&X.has(J)?{type:"text",text:`[A ${J.mimeType||"file"} produced by a tool (attachment ${J.attachmentId}) was attached here and has been dropped from this request: only the most recent tool-produced file is kept attached, to keep the context bounded. Call the tool again if you need to look at it.]`}:J)}})}async ingestTurn(){let Z=this.params.turn,$=this.openCalls();this.openedWith=$.length;let Q=[];if($.length>0){let B=new Set,X=new Set,G=new Map;for(let J of Z?.toolResults??[]){let z=`${(J.path??[]).join("/")}#${J.toolCallId}`;if(X.has(z))continue;X.add(z);let V=(q)=>this.emit({type:"error",error:{code:"invalid_tool_result",message:q,toolCallId:J.toolCallId,retryable:!1}}),W=B7(J.path,this.pathPrefix);if(W===null){V(`The answer for "${J.toolCallId}" is addressed to a tool call this run is not inside.`);continue}if(W.length>0){let q=W[0],F=$.find((U)=>U.call.toolCallId===q);if(!F){V(`No pending tool call with id "${q}" to deliver a nested answer to.`);continue}let Y=this.parkedBelow(F.call,W,J.toolCallId);if(Y.ok===!1){let U=`The answer for "${J.toolCallId}" is addressed under "${q}", which`;V(Y.reason==="unparked"?`${U} has no sub-agent run waiting on that question.`:Y.reason==="expired"?`${U} parked a sub-agent run that has since expired. Ask again.`:`${U} carries a record of a parked sub-agent run the server did not sign.`);continue}let D=G.get(q);if(!D){if(!await this.spend(A4,Y.signature)){V(`The answer for "${J.toolCallId}" is addressed under "${q}", which has already been re-entered on that record. Ask again.`);continue}D=[],G.set(q,D),B.add(q)}D.push(J);continue}let H=$.find((q)=>q.call.toolCallId===J.toolCallId);if(!H){V(`No pending tool call with id "${J.toolCallId}".`);continue}let K=await this.resolveAnswer(H,J,Q);if(K===null)continue;if(B.add(J.toolCallId),K!=="open")this.attachToHistory(H,K),await this.settleShown(J.toolCallId)}for(let[J,z]of G){let V=$.find((H)=>H.call.toolCallId===J),W=await this.reenter(V,z,Q);if(W)this.attachToHistory(V,W),await this.settleShown(J)}for(let J of $){if(B.has(J.call.toolCallId))continue;this.attachToHistory(J,{type:"tool-result",toolCallId:J.call.toolCallId,name:J.call.name,status:"denied",cause:"refused"})}if(this.depth===0)this.restatePending($,Q);await this.reportDeferred()}if(Z&&(Z.text||Z.files&&Z.files.length>0)){let B={id:`msg_${crypto.randomUUID()}`,role:"user",content:[...Z.text?[{type:"text",text:Z.text}]:[],...(Z.files??[]).map((X)=>({type:"file",...X.fileId?{fileId:X.fileId}:{},name:X.name,mimeType:X.mimeType,...X.attachmentId?{attachmentId:X.attachmentId}:{}}))],createdAt:new Date().toISOString(),finishReason:"stop"};if(this.history.push(B),this.produced.push(B),this.depth>0)this.emit({type:"message",message:B});else if(Z.localId)this.emit({type:"message-id",localId:Z.localId,messageId:B.id,message:B});if(await this.report(B),this.params.onTurn)try{await this.params.onTurn(B)}catch{}}return Q}parkedBelow(Z,$,Q){let B=$.length>1?$[1]:Q,X=[...this.pathPrefix,Z.toolCallId],G=(Z.nested??[]).find((z)=>z.finishReason==="awaiting-input"&&kZ(z.messages).has(B));if(!G)return{ok:!1,reason:"unparked"};if(typeof G.signature!=="string")return{ok:!1,reason:"unsigned"};let J=M4(G.signature,{path:X,nestedRunId:G.runId,open:[...kZ(G.messages)],input:Z.input,subject:this.params.subject??null});if(J.ok===!1)return{ok:!1,reason:J.reason==="expired"?"expired":"unsigned"};return{ok:!0,signature:G.signature}}async reenter(Z,$,Q){let B=String(Z.call.name),X=this.config.registry.get(B);if(!X||!X.tool.execute)return{type:"tool-result",toolCallId:Z.call.toolCallId,name:Z.call.name,status:"error",error:{code:"invalid_tool_result",message:`The tool "${B}" no longer exists, so the sub-agent's question cannot be delivered.`,toolCallId:Z.call.toolCallId,retryable:!1}};let G=X.inputSchema.safeParse(Z.call.input);if(G.ok===!1)return{type:"tool-result",toolCallId:Z.call.toolCallId,name:Z.call.name,status:"error",error:{code:"invalid_tool_input",message:`Invalid arguments for "${B}": ${G.errors.join(", ")}`,toolCallId:Z.call.toolCallId,retryable:!0}};let J=this.amendCall(Z);J.input=G.value;try{return await w(this.executeTool(X,Z.message.id,J,G.value,0,{answers:$}),this.controller.signal)}catch(z){if(z instanceof n)return Q.push(...z.pending),null;throw z}}amendCall(Z){let $=this.amend(Z.message),Q=$.content.indexOf(Z.call),B={...Z.call,nested:(Z.call.nested??[]).map((X)=>({...X})),...Z.call.attachments?{attachments:Z.call.attachments.map((X)=>({...X}))}:{}};if(Q>=0)$.content[Q]=B;return this.unreported.add($),B}answersOnlyStale(){let Z=this.params.turn;if(!Z?.toolResults?.length||Z.text||Z.files?.length)return!1;return this.openedWith===0}restatePending(Z,$){let Q=new Map;for(let B of Z){let X=Q.get(B.message);if(!X)Q.set(B.message,X=new Set);X.add(B.call.toolCallId)}for(let[B,X]of Q){let G=$.filter((z)=>X.has(z.path?.[0]??z.toolCallId));if(G.length===0&&B.pending===void 0)continue;let J=this.amend(B);if(G.length>0)J.pending=G;else delete J.pending;this.unreported.add(J)}}openCalls(){let Z=new Set;for(let Q of this.history)for(let B of Q.content)if(B.type==="tool-result")Z.add(B.toolCallId);let $=[];for(let Q of this.history)for(let B of Q.content)if(B.type==="tool-call"&&!Z.has(B.toolCallId))$.push({message:Q,call:B});return $}async spend(Z,$){try{return await Z($,this.params.nonces??cZ)}catch(Q){return this.writeLog(`[gemi/ai] agent "${this.config.name}" could not spend a nonce`,{error:Q}),!1}}async recordReceipt(Z,$){let Q=await $;try{await Z.store.complete(Z.id,Q,Z.expiresAt)}catch(B){this.writeLog(`[gemi/ai] agent "${this.config.name}" could not record a tool receipt`,{error:B})}return Q}approvalRecord(Z,$){return{approved:Z,at:new Date().toISOString(),by:this.params.subject??null,...typeof $==="string"&&$!==""?{reason:$}:{}}}async resolveAnswer(Z,$,Q){let B=Z.call,X=String(B.name),G=this.config.registry.get(X),J=(K)=>{return this.emit({type:"error",error:{code:"invalid_tool_result",message:K,toolCallId:B.toolCallId,retryable:!1}}),null};if(!G)return J(`The tool "${X}" no longer exists, so its answer cannot be checked.`);let z=X7(G.tool);if(!z)return J(`"${X}" is a server tool with no pending question.`);if(typeof $.signature!=="string"||$.signature.length===0)return J(`The answer for "${X}" carried no signature.`);let V=Y0($.signature);if(!V)return J(`The signature for "${X}" is malformed.`);let W=O4($.signature,{...this.claimsFor(B.toolCallId,X,z,B.input),runId:V.runId});if(W.ok===!1)return J(W.reason==="expired"?`The approval for "${X}" has expired. Ask again.`:`The answer for "${X}" does not match the call the server made.`);let H;if(this.params.receipts&&z==="approval"&&"approve"in $&&$.approve===!0){let K=this.params.receipts,q=x4(this.config.name,{...this.claimsFor(B.toolCallId,X,z,B.input),runId:V.runId}),F;try{F=await K.claim(q,V.expiresAt)}catch(Y){return this.writeLog(`[gemi/ai] agent "${this.config.name}" could not claim a tool receipt`,{error:Y}),J(`The approval for "${X}" could not be checked. Ask again.`)}if(F.status==="replay")return{...F.result,toolCallId:B.toolCallId,name:B.name};if(F.status==="blocked")return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"error",error:{code:"tool_error",message:`"${X}" was already approved and started, and its result is not recorded yet: it is still running, or it stopped before finishing. It was not run again.`,toolCallId:B.toolCallId,retryable:!1}};H={store:K,id:q,expiresAt:V.expiresAt}}if(!await this.spend(T4,$.signature))return await H?.store.release(H.id).catch((K)=>{this.writeLog(`[gemi/ai] agent "${this.config.name}" could not release a tool receipt`,{error:K})}),J(`The answer for "${X}" has already been used. Ask again.`);if("approve"in $){if(z!=="approval")return J(`"${X}" is answered by the client, not approved.`);if($.approve===!0){let K=this.amendCall(Z),q=this.approvalRecord(!0,$.reason);this.approvals.set(B.toolCallId,q);let F=this.executeTool(G,Z.message.id,K,K.input,0).then((Y)=>({...Y,approval:q}));try{return await w(H?this.recordReceipt(H,F):F,this.controller.signal)}catch(Y){if(Y instanceof n)return Q.push(...Y.pending),"open";throw Y}}return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"denied",cause:"refused",reason:$.reason,approval:this.approvalRecord(!1,$.reason)}}if("output"in $){if(z==="approval")return J(`"${X}" is approved, not answered: the server produces its result.`);let K=G.tool.outputSchema,q=K?K.safeParse($.output):{ok:!0,value:$.output};if(q.ok===!1)return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"error",error:{code:"invalid_tool_result",message:`The answer for "${X}" did not match its output schema: ${q.errors.join(", ")}`,toolCallId:B.toolCallId,retryable:!0}};return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"ok",output:q.value}}return J(`The answer for "${X}" carried neither an approval nor an output.`)}attachToHistory(Z,$){let Q=this.amend(Z.message);r4($,Z.call.input),Q.content.push($),this.unreported.add(Q),this.emit({type:"tool-result",messageId:Q.id,part:$})}markFileRejected(Z,$,Q){for(let J of this.history){if(!J.content.some((W)=>W.type==="file"&&W.fileId===Z&&!W.providerRejected))continue;let V=this.produced.includes(J)?J:this.amend(J);if(V.content=V.content.map((W)=>W.type==="file"&&W.fileId===Z&&!W.providerRejected?{...W,providerRejected:!0}:W),V!==this.current)this.unreported.add(V)}if(!this.config.logErrors)return;let B=`[gemi/ai] agent "${this.config.name}": the provider refused file ${Z}${Q.status!==void 0?` (${Q.status})`:""}; it was left out of the request and will not be sent again: ${$}`,X={agent:this.config.name,runId:this.runId,...this.params.threadId?{threadId:this.params.threadId}:{},fileId:Z,...Q},G=!1;try{o.warning(B,X),G=!0}catch{}if(!G||Bun.env.NODE_ENV==="development")console.warn(B,X)}amend(Z){let $=this.amended.get(Z.id);if($)return $;let Q={...Z,content:[...Z.content]},B=this.history.indexOf(Z);if(B>=0)this.history[B]=Q;return this.produced.push(Q),this.amended.set(Z.id,Q),Q}async reportDeferred(){let Z=[...this.unreported];this.unreported.clear();for(let $ of Z)await this.report($)}async finalizeAborted(){if(this.nestedSettling.size>0)await Promise.all([...this.nestedSettling]);for(let $ of this.openCalls()){if($.message===this.current)continue;this.attachToHistory($,{type:"tool-result",toolCallId:$.call.toolCallId,name:$.call.name,status:"denied",cause:"stopped",reason:this.stopReason})}await this.reportDeferred();let Z=this.current;if(Z){let $=new Set(Z.content.filter((Q)=>Q.type==="tool-result").map((Q)=>Q.toolCallId));for(let Q of[...Z.content]){if(Q.type!=="tool-call"||$.has(Q.toolCallId))continue;delete Q.partial,this.addResult(Z,{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"denied",cause:"stopped",reason:this.stopReason})}}if(this.timedOutAfter!==void 0){this.fail({code:"timeout",message:`The run did not finish within its time limit of ${C0(this.timedOutAfter)} (maxRunDurationMs: ${this.timedOutAfter}) and was stopped.`,retryable:!0}),this.finishReason="error",await this.finalizeMessage("error");return}this.finishReason="aborted",await this.finalizeMessage("aborted")}}function X7(Z){if(Z.answeredBy==="client")return Z.inputSchema===_0?"question":"client";return Z.requiresApproval?"approval":null}function G7(Z){if(!Z||!Z.trim())return{};try{return JSON.parse(Z)}catch{return Z}}function a1(Z){let $=new wZ;return $.push(Z),$.snapshot()}var x0={true:!0,false:!1,null:null};class wZ{frames=[];scalar;root;done=!1;failed=!1;dirty=!1;shownOpen;push(Z){let $=[];for(let Q=0;Q<Z.length&&!this.failed;Q++)this.read(Z[Q],$);return $}get changed(){if(this.dirty)return!0;let Z=this.openStringValue();return Z!==void 0&&Z!==this.shownOpen}snapshot(){if(this.dirty=!1,this.shownOpen=this.openStringValue(),this.done)return this.root;if(this.frames.length===0)return this.shownOpen;return this.build(0)}build(Z){let $=this.frames[Z],Q=Z+1<this.frames.length?this.build(Z+1):this.openStringValue();if($.kind==="array"){let X=$.value.slice();if(Q!==void 0)X.push(Q);return X}let B={...$.value};if(Q!==void 0&&$.expect==="value"&&$.key!==void 0)P7(B,$.key,Q);return B}openStringValue(){let Z=this.scalar;if(!Z||Z.kind!=="string"||Z.key)return;return L7(j$(Z.raw))}read(Z,$){let Q=this.scalar;if(Q?.kind==="string"){if(Q.escaped)Q.escaped=!1;else if(Z==="\\")Q.escaped=!0;else if(Z==='"'){this.scalar=void 0;let X=L7(Q.raw);if(Q.key)this.gotKey(X);else this.gotValue(X,X!==this.shownOpen);return}Q.raw+=Z;return}if(Q){if(Q.kind==="number"?/[0-9eE+\-.]/.test(Z):/[a-z]/.test(Z)){if(Q.raw+=Z,Q.kind==="literal")this.checkLiteral(Q);return}if(this.scalar=void 0,Q.kind==="number"){let X=U$(Q.raw);if(X===void 0)return this.fail();this.gotValue(X,!0)}else return this.fail();if(this.failed)return}if(Z===" "||Z===`
|
|
27
|
+
`)}async asksApproval(Z,$,Q,B){let X=this.approvalContext($,B);try{return await w(Promise.resolve().then(()=>Z.approvalPredicate(Q,X)),this.controller.signal)!==!1}catch(G){if(G instanceof x)throw G;return this.writeLog(`[gemi/ai] agent "${this.config.name}": the requiresApproval of "${Z.name}" threw, so the call asks the user`,{error:G,toolCallId:$.toolCallId}),!0}}approvalContext(Z,$){return{context:this.context,body:this.params.body??{},runId:this.runId,threadId:this.params.threadId,toolCallId:Z.toolCallId,step:$,depth:this.depth,signal:this.controller.signal}}async previewApproval(Z,$,Q,B){let X=this.approvalContext($,B),G=()=>{};try{let J=Promise.resolve().then(()=>Z.approvalPreview(Q,X)),z=Z.timeoutMs,V=z===void 0?J:Promise.race([J,new Promise((H,K)=>{G=L0(z,()=>K(Error(`approvalPreview did not finish within ${z}ms`)))})]);J.catch(()=>{});let W=await w(V,this.controller.signal);if(W===void 0)return;return JSON.parse(JSON.stringify(W))}catch(J){if(J instanceof x)throw J;this.writeLog(`[gemi/ai] agent "${this.config.name}": the approvalPreview of "${Z.name}" failed, so the call is asked without a preview`,{error:J,toolCallId:$.toolCallId});return}finally{G()}}claimsFor(Z,$,Q,B){return{runId:this.signingRunId,toolCallId:Z,name:$,kind:Q,input:B,path:this.pathPrefix.length>0?[...this.pathPrefix]:void 0,subject:this.params.subject??null}}deniedByPolicy(Z){return{type:"tool-result",toolCallId:Z.toolCallId,name:Z.name,status:"denied",cause:"refused",reason:`"${String(Z.name)}" needs the user, and this run was started with onPending: "deny". Answer from what you already have.`}}async executeTool(Z,$,Q,B,X,G){let J=Z.tool.timeoutMs;if(J===void 0)return this.runToolBody(Z,$,Q,B,X,G,this.controller.signal,()=>!1);let z=new AbortController,V=this.controller.signal,W=()=>z.abort(V.reason);if(V.aborted)W();else V.addEventListener("abort",W,{once:!0});let H=!1,K=this.runToolBody(Z,$,Q,B,X,G,z.signal,()=>H),q=()=>{},F=new Promise((Y)=>{q=L0(J,()=>{let D=`"${String(Q.name)}" did not finish within ${C0(J)} (timeoutMs: ${J}) and was cancelled.`;z.abort(new DOMException(D,"TimeoutError")),Y({type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"error",error:{code:"timeout",message:D,toolCallId:Q.toolCallId,retryable:!0}})})});K.catch(()=>{});try{return await Promise.race([K,F])}finally{H=!0,q()}}async runToolBody(Z,$,Q,B,X,G,J,z){let V=this.toolFiles(Q,J),W=this.approvals.get(Q.toolCallId),H={context:this.context,body:this.params.body??{},runId:this.runId,threadId:this.params.threadId,toolCallId:Q.toolCallId,signal:J,step:X,depth:this.depth,resumed:G!==void 0,attachments:V.attachments,generateImage:V.generateImage,editImage:V.editImage,turn:this.toolTurn($),runAgent:this.nestedRunner($,Q,J,G),generate:(K)=>this.generateForTool(K,J,Q.toolCallId),jobs:W7({jobs:this.depth===0?this.params.jobs:void 0,threadId:this.params.threadId,runId:this.runId,toolCallId:Q.toolCallId,toolName:String(Q.name),depth:this.depth,async:Z.tool.async,attachments:this.params.attachments??null}),memory:this.memory.handle({messageId:$}),meter:this.meter,...W?{approval:W}:{}};try{let K=Z.tool.execute(B,H),q;if(Y$(K)){let Y=await K.next();while(!Y.done){if(z())throw K.return(void 0).catch(()=>{}),new x;this.emit({type:"tool-progress",toolCallId:Q.toolCallId,data:Y.value}),Y=await K.next()}q=Y.value}else q=await K;if(V7(q)){if(q.toolCallId!==Q.toolCallId)throw new P(`"${String(Q.name)}" returned the handle of a job another tool call started. Return the handle from this call's own ctx.jobs.`,{retryable:!1});return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"running",job:{id:q.id,...q.summary!==void 0?{summary:q.summary}:{}}}}let F=i4(Z.tool,q,(Y)=>this.writeLog(`[gemi/ai] agent "${this.config.name}": the toModel of "${String(Q.name)}" threw, so the model reads the whole output`,{error:Y,toolCallId:Q.toolCallId}));return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"ok",output:q,...F!==void 0?{modelOutput:F}:{}}}catch(K){if(K instanceof x||this.controller.signal.aborted)throw new x;if(K instanceof n)throw K;let q=K instanceof P;if(!q&&this.config.logErrors)this.logToolFailure(Q,K);let F={code:"tool_error",message:K instanceof Error?K.message:String(K),toolCallId:Q.toolCallId,retryable:q?K.retryable:!0};return{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"error",error:this.redact(F,{source:"tool",toolName:String(Q.name),cause:K})}}}async generateForTool(Z,$,Q){let B=this.controller.signal;return zZ({...Z,signal:Z.signal?AbortSignal.any([$,Z.signal]):$},{origin:{agent:this.config.name,runId:this.runId,...this.params.threadId?{threadId:this.params.threadId}:{},toolCallId:Q},settled:(X)=>{if(this.usage=_(this.usage,X.usage),B.aborted)throw new x}})}nestedRunner(Z,$,Q,B){let X=new N0(()=>$.nested,()=>$.nested=[]);return async(G,J={})=>{let{at:z,recorded:V,write:W}=X.next();if(V){let H=F$(V,G,J);if(H)throw new P(`Nested run ${z} of "${String($.name)}" ${H}. `+"runAgent is memoized by call index, so a body whose runAgent calls depend on a condition that changed between turns cannot be resumed \u2014 the answer would be paired with a different sub-run. "+"Make the sequence of runAgent calls, and what each one is asked, the same every time this tool runs, or branch on ctx.resumed.");if(V.finishReason!=="awaiting-input")return{runId:V.runId,agent:V.agent,messages:V.messages,finishReason:V.finishReason??"stop",usage:V.usage??I(),output:Z7(V.messages),nested:V}}return this.runNested(Z,$,Q,G,J,W,V,B?.answers??[])}}async runNested(Z,$,Q,B,X,G,J,z){let V=[...this.chain,B.name];if(this.chain.includes(B.name))throw new P(`"${B.name}" is already running further up this chain: ${V.join(" -> ")}. An agent cannot run itself, directly or through another agent.`);let W=this.depth+1;if(W>this.maxDepth)throw new P(`Nested agent runs are ${this.maxDepth} deep at most and this one would be ${W}: ${V.join(" -> ")}. Raise maxDepth on the agent at the root of the run if the tree is meant to be this deep.`);let H=X.label,K=[...this.pathPrefix,$.toolCallId],q=this.onPending==="deny"?"deny":X.onPending??"escalate",F=J!==void 0,Y=F?kZ(J.messages):new Set,D=F?z.filter((O)=>{let k=B7(O.path,K);if(k===null)return!1;return Y.has(k.length>0?k[0]:O.toolCallId)}):[],U=B.stream({messages:F?J.messages:X.messages??[],turn:F?{toolResults:D}:X.prompt?{text:X.prompt}:void 0,context:X.context??this.context,attachments:this.params.attachments,body:this.params.body,signal:Q,threadId:this.params.threadId,redactError:this.params.redactError,nonces:this.params.nonces,receipts:this.params.receipts,subject:this.params.subject,...this.params.memory?{memory:{scopes:this.params.memory.scopes}}:{},instructions:X.instructions,maxOutputTokens:X.maxOutputTokens,temperature:X.temperature,provider:X.provider??this.params.provider,runId:F?J.runId:void 0,nesting:{depth:W,maxDepth:this.maxDepth,chain:V,signingRunId:this.signingRunId,signingPath:K,onPending:q,memoryWrites:this.memory.writes}}),j=[],L=(O)=>this.emit({type:"nested-event",toolCallId:$.toolCallId,runId:U.runId,agent:B.name,label:H,event:O}),C=(async()=>{for await(let O of U){if(O.type==="awaiting-input")j=O.pending;if(L(O),O.type==="run-start"&&!F)for(let k of X.messages??[])L({type:"message",message:k});if(O.type==="error")this.emit({type:"error",error:O.error,nested:{toolCallId:$.toolCallId,runId:U.runId,agent:B.name}})}})(),M=(async()=>{let O=await U.result();await C;let k=F?e4(J.messages,O.messages):e4(X.messages??[],O.messages),s={runId:U.runId,agent:B.name,label:H,messages:k,finishReason:O.finishReason,usage:F?_(J.usage??I(),O.usage):O.usage,...O.finishReason==="awaiting-input"?{signature:I4({runId:this.signingRunId,path:K,nestedRunId:U.runId,open:[...kZ(k)],input:$.input,subject:this.params.subject??null})}:{}};return G(s),this.usage=_(this.usage,O.usage),{result:O,record:s}})(),N=M.then(()=>{return},()=>{return});this.nestedSettling.add(N);let b,A;try{({result:b,record:A}=await M)}finally{this.nestedSettling.delete(N)}if(this.controller.signal.aborted)throw new x;if(b.finishReason==="awaiting-input"){if(j.length===0)throw new P(`"${B.name}" ended awaiting input but asked nothing, so there is no question to escalate.`);throw this.emit({type:"tool-call",messageId:Z,part:$,resent:!0}),new n({pending:j,path:K,nested:A})}return{runId:A.runId,agent:B.name,messages:A.messages,finishReason:b.finishReason,usage:A.usage??I(),output:b.output??Z7(A.messages),...b.error?{error:b.error}:{},nested:A}}addResult(Z,$){let Q=Z.content.find((B)=>B.type==="tool-call"&&B.toolCallId===$.toolCallId);if(Q)r4($,Q.input);Z.content.push($),this.emit({type:"tool-result",messageId:Z.id,part:$})}toolFiles(Z,$){let Q=this.params.attachments??null,B=new N0(()=>Z.attachments,()=>Z.attachments=[],()=>({failed:!0})),X=()=>{if(!Q)throw new l("This request has no attachment scope, so a tool cannot store or read files on it. `attachmentScope()` returned null \u2014 put the chat route behind authentication, send a `threadId`, or override `attachmentScope()` on the controller.");return Q},G=async(W,H,K)=>{let q=X(),F=H.mimeType||W.type||"",Y=H.name??(W instanceof File?W.name:"attachment"),D;if(H.showModel){let j=this.config.provider;if(!j.capabilities.fileInput)throw new P(`"${String(Z.name)}" asked to show a file to ${j.model}, which does not accept file input. Drop \`showModel\` for this provider, or run this agent on a model that takes files \u2014 \`capabilities.fileInput\` is what says which do.`);D=await j.upload(new File([W],Y,{type:F||void 0}))}return{attachment:await q.put(W,{name:Y,mimeType:F,fileId:D}),...K?{generated:K}:{},...D?{shown:{fileId:D,messageId:`msg_${crypto.randomUUID()}`,createdAt:new Date().toISOString()}}:{}}},J=(W,H,K)=>{let q=W.generated?"image":"put";if(q===H)return;throw new P(`Attachment ${K} of "${String(Z.name)}" was ${q==="image"?"a generated image":"a stored file"} on the first attempt and is ${H==="image"?"a generated image":"a stored file"} now. ctx.attachments.put, ctx.generateImage and ctx.editImage share one memo indexed by call order within a tool call, so the sequence has to be the same every time this tool runs. Branch on ctx.resumed if it cannot be.`)},z=async(W,H,K)=>{let{at:q,recorded:F,write:Y}=B.next();if(F&&"attachment"in F){if(J(F,"image",q),F.shown)this.queueShown(Z.toolCallId,F);return{attachment:F.attachment,size:F.generated.size,mimeType:F.attachment.mimeType,usage:F.generated.usage}}let D=await K();this.usage=_(this.usage,D.usage);let U=D.mimeType==="image/jpeg"?"jpg":"png",j=await G(D.image,{name:H.name??`${W.name}.${U}`,mimeType:D.mimeType,...H.showModel?{showModel:!0}:{}},{size:D.size,usage:D.usage});if(Y(j),j.shown)this.queueShown(Z.toolCallId,j);return{attachment:j.attachment,size:D.size,mimeType:D.mimeType,usage:D.usage}},V=async(W)=>typeof W==="string"?await X().file(W):W;return{generateImage:(W,H)=>z(W,H,()=>W.generate({...H,signal:$})),editImage:(W,H)=>z(W,H,async()=>{let{images:K,mask:q,...F}=H;return await W.edit({...F,images:await Promise.all(K.map(V)),...q?{mask:await V(q)}:{},signal:$})}),attachments:{get:(W)=>X().get(W),read:(W)=>X().read(W),file:(W)=>X().file(W),put:async(W,H={})=>{let{at:K,recorded:q,write:F}=B.next();if(q&&"attachment"in q){J(q,"put",K);let D=K$(q,W,H);if(D)throw new P(`Attachment ${K} of "${String(Z.name)}" ${D}. `+"ctx.attachments.put is memoized by call index within a tool call, so a body whose put calls depend on a condition that changed between turns cannot be replayed \u2014 the model would be shown a file under an id that names different bytes. "+"Make the sequence of put calls the same every time this tool runs, or branch on ctx.resumed.");if(q.shown)this.queueShown(Z.toolCallId,q);return q.attachment}let Y=await G(W,H);if(F(Y),Y.shown)this.queueShown(Z.toolCallId,Y);return Y.attachment}}}}toolTurn(Z){let $=this.history.findIndex((G)=>G.id===Z),Q=xZ(this.history),B;for(let G=$-1;G>=0;G--){let J=this.history[G];if(J.role!=="user"||Q.has(J.id))continue;B=J;break}let X=[];for(let G of B?.content??[]){if(G.type!=="file")continue;let J=G.attachmentId;if(typeof J!=="string"||!J.startsWith(tZ))continue;if(!X.includes(J))X.push(J)}return Object.freeze({attachments:Object.freeze(X)})}queueShown(Z,$){let Q=$.shown;if(!Q)return;let B=this.shownQueue.get(Z)??[];if(B.some((X)=>X.id===Q.messageId))return;B.push({id:Q.messageId,role:"user",content:[{type:"file",fileId:Q.fileId,name:$.attachment.name,mimeType:$.attachment.mimeType,attachmentId:$.attachment.id}],createdAt:Q.createdAt,finishReason:"stop"}),this.shownQueue.set(Z,B)}async settleShown(Z){let $=this.shownQueue.get(Z);if(!$||$.length===0)return;if(this.shownQueue.delete(Z),this.ended||this.controller.signal.aborted)return;for(let Q of $){if(this.history.some((B)=>B.id===Q.id))continue;this.history.push(Q),this.produced.push(Q),this.emit({type:"message",message:Q}),this.unreported.add(Q)}}historyForProvider(Z){let $=this.history.filter((G)=>G!==Z),Q=xZ($),B=[];for(let G of $){if(!Q.has(G.id))continue;for(let J of G.content)if(J.type==="file")B.push(J)}if(B.length<=Q7)return $;let X=new Set(B.slice(0,B.length-Q7));return $.map((G)=>{if(!G.content.some((J)=>J.type==="file"&&X.has(J)))return G;return{...G,content:G.content.map((J)=>J.type==="file"&&X.has(J)?{type:"text",text:`[A ${J.mimeType||"file"} produced by a tool (attachment ${J.attachmentId}) was attached here and has been dropped from this request: only the most recent tool-produced file is kept attached, to keep the context bounded. Call the tool again if you need to look at it.]`}:J)}})}async ingestTurn(){let Z=this.params.turn,$=this.openCalls();this.openedWith=$.length;let Q=[];if($.length>0){let B=new Set,X=new Set,G=new Map;for(let J of Z?.toolResults??[]){let z=`${(J.path??[]).join("/")}#${J.toolCallId}`;if(X.has(z))continue;X.add(z);let V=(q)=>this.emit({type:"error",error:{code:"invalid_tool_result",message:q,toolCallId:J.toolCallId,retryable:!1}}),W=B7(J.path,this.pathPrefix);if(W===null){V(`The answer for "${J.toolCallId}" is addressed to a tool call this run is not inside.`);continue}if(W.length>0){let q=W[0],F=$.find((U)=>U.call.toolCallId===q);if(!F){V(`No pending tool call with id "${q}" to deliver a nested answer to.`);continue}let Y=this.parkedBelow(F.call,W,J.toolCallId);if(Y.ok===!1){let U=`The answer for "${J.toolCallId}" is addressed under "${q}", which`;V(Y.reason==="unparked"?`${U} has no sub-agent run waiting on that question.`:Y.reason==="expired"?`${U} parked a sub-agent run that has since expired. Ask again.`:`${U} carries a record of a parked sub-agent run the server did not sign.`);continue}let D=G.get(q);if(!D){if(!await this.spend(A4,Y.signature)){V(`The answer for "${J.toolCallId}" is addressed under "${q}", which has already been re-entered on that record. Ask again.`);continue}D=[],G.set(q,D),B.add(q)}D.push(J);continue}let H=$.find((q)=>q.call.toolCallId===J.toolCallId);if(!H){V(`No pending tool call with id "${J.toolCallId}".`);continue}let K=await this.resolveAnswer(H,J,Q);if(K===null)continue;if(B.add(J.toolCallId),K!=="open")this.attachToHistory(H,K),await this.settleShown(J.toolCallId)}for(let[J,z]of G){let V=$.find((H)=>H.call.toolCallId===J),W=await this.reenter(V,z,Q);if(W)this.attachToHistory(V,W),await this.settleShown(J)}for(let J of $){if(B.has(J.call.toolCallId))continue;this.attachToHistory(J,{type:"tool-result",toolCallId:J.call.toolCallId,name:J.call.name,status:"denied",cause:"refused"})}if(this.depth===0)this.restatePending($,Q);await this.reportDeferred()}if(Z&&(Z.text||Z.files&&Z.files.length>0)){let B={id:`msg_${crypto.randomUUID()}`,role:"user",content:[...Z.text?[{type:"text",text:Z.text}]:[],...(Z.files??[]).map((X)=>({type:"file",...X.fileId?{fileId:X.fileId}:{},name:X.name,mimeType:X.mimeType,...X.attachmentId?{attachmentId:X.attachmentId}:{}}))],createdAt:new Date().toISOString(),finishReason:"stop"};if(this.history.push(B),this.produced.push(B),this.depth>0)this.emit({type:"message",message:B});else if(Z.localId)this.emit({type:"message-id",localId:Z.localId,messageId:B.id,message:B});if(await this.report(B),this.params.onTurn)try{await this.params.onTurn(B)}catch{}}return Q}parkedBelow(Z,$,Q){let B=$.length>1?$[1]:Q,X=[...this.pathPrefix,Z.toolCallId],G=(Z.nested??[]).find((z)=>z.finishReason==="awaiting-input"&&kZ(z.messages).has(B));if(!G)return{ok:!1,reason:"unparked"};if(typeof G.signature!=="string")return{ok:!1,reason:"unsigned"};let J=M4(G.signature,{path:X,nestedRunId:G.runId,open:[...kZ(G.messages)],input:Z.input,subject:this.params.subject??null});if(J.ok===!1)return{ok:!1,reason:J.reason==="expired"?"expired":"unsigned"};return{ok:!0,signature:G.signature}}async reenter(Z,$,Q){let B=String(Z.call.name),X=this.config.registry.get(B);if(!X||!X.tool.execute)return{type:"tool-result",toolCallId:Z.call.toolCallId,name:Z.call.name,status:"error",error:{code:"invalid_tool_result",message:`The tool "${B}" no longer exists, so the sub-agent's question cannot be delivered.`,toolCallId:Z.call.toolCallId,retryable:!1}};let G=X.inputSchema.safeParse(Z.call.input);if(G.ok===!1)return{type:"tool-result",toolCallId:Z.call.toolCallId,name:Z.call.name,status:"error",error:{code:"invalid_tool_input",message:`Invalid arguments for "${B}": ${G.errors.join(", ")}`,toolCallId:Z.call.toolCallId,retryable:!0}};let J=this.amendCall(Z);J.input=G.value;try{return await w(this.executeTool(X,Z.message.id,J,G.value,0,{answers:$}),this.controller.signal)}catch(z){if(z instanceof n)return Q.push(...z.pending),null;throw z}}amendCall(Z){let $=this.amend(Z.message),Q=$.content.indexOf(Z.call),B={...Z.call,nested:(Z.call.nested??[]).map((X)=>({...X})),...Z.call.attachments?{attachments:Z.call.attachments.map((X)=>({...X}))}:{}};if(Q>=0)$.content[Q]=B;return this.unreported.add($),B}answersOnlyStale(){let Z=this.params.turn;if(!Z?.toolResults?.length||Z.text||Z.files?.length)return!1;return this.openedWith===0}restatePending(Z,$){let Q=new Map;for(let B of Z){let X=Q.get(B.message);if(!X)Q.set(B.message,X=new Set);X.add(B.call.toolCallId)}for(let[B,X]of Q){let G=$.filter((z)=>X.has(z.path?.[0]??z.toolCallId));if(G.length===0&&B.pending===void 0)continue;let J=this.amend(B);if(G.length>0)J.pending=G;else delete J.pending;this.unreported.add(J)}}openCalls(){let Z=new Set;for(let Q of this.history)for(let B of Q.content)if(B.type==="tool-result")Z.add(B.toolCallId);let $=[];for(let Q of this.history)for(let B of Q.content)if(B.type==="tool-call"&&!Z.has(B.toolCallId))$.push({message:Q,call:B});return $}async spend(Z,$){try{return await Z($,this.params.nonces??cZ)}catch(Q){return this.writeLog(`[gemi/ai] agent "${this.config.name}" could not spend a nonce`,{error:Q}),!1}}async recordReceipt(Z,$){let Q=await $;try{await Z.store.complete(Z.id,Q,Z.expiresAt)}catch(B){this.writeLog(`[gemi/ai] agent "${this.config.name}" could not record a tool receipt`,{error:B})}return Q}approvalRecord(Z,$){return{approved:Z,at:new Date().toISOString(),by:this.params.subject??null,...typeof $==="string"&&$!==""?{reason:$}:{}}}async resolveAnswer(Z,$,Q){let B=Z.call,X=String(B.name),G=this.config.registry.get(X),J=(K)=>{return this.emit({type:"error",error:{code:"invalid_tool_result",message:K,toolCallId:B.toolCallId,retryable:!1}}),null};if(!G)return J(`The tool "${X}" no longer exists, so its answer cannot be checked.`);let z=X7(G.tool);if(!z)return J(`"${X}" is a server tool with no pending question.`);if(typeof $.signature!=="string"||$.signature.length===0)return J(`The answer for "${X}" carried no signature.`);let V=Y0($.signature);if(!V)return J(`The signature for "${X}" is malformed.`);let W=O4($.signature,{...this.claimsFor(B.toolCallId,X,z,B.input),runId:V.runId});if(W.ok===!1)return J(W.reason==="expired"?`The approval for "${X}" has expired. Ask again.`:`The answer for "${X}" does not match the call the server made.`);let H;if(this.params.receipts&&z==="approval"&&"approve"in $&&$.approve===!0){let K=this.params.receipts,q=x4(this.config.name,{...this.claimsFor(B.toolCallId,X,z,B.input),runId:V.runId}),F;try{F=await K.claim(q,V.expiresAt)}catch(Y){return this.writeLog(`[gemi/ai] agent "${this.config.name}" could not claim a tool receipt`,{error:Y}),J(`The approval for "${X}" could not be checked. Ask again.`)}if(F.status==="replay")return{...F.result,toolCallId:B.toolCallId,name:B.name};if(F.status==="blocked")return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"error",error:{code:"tool_error",message:`"${X}" was already approved and started, and its result is not recorded yet: it is still running, or it stopped before finishing. It was not run again.`,toolCallId:B.toolCallId,retryable:!1}};H={store:K,id:q,expiresAt:V.expiresAt}}if(!await this.spend(T4,$.signature))return await H?.store.release(H.id).catch((K)=>{this.writeLog(`[gemi/ai] agent "${this.config.name}" could not release a tool receipt`,{error:K})}),J(`The answer for "${X}" has already been used. Ask again.`);if("approve"in $){if(z!=="approval")return J(`"${X}" is answered by the client, not approved.`);if($.approve===!0){let K=this.amendCall(Z),q=this.approvalRecord(!0,$.reason);this.approvals.set(B.toolCallId,q);let F=this.executeTool(G,Z.message.id,K,K.input,0).then((Y)=>({...Y,approval:q}));try{return await w(H?this.recordReceipt(H,F):F,this.controller.signal)}catch(Y){if(Y instanceof n)return Q.push(...Y.pending),"open";throw Y}}return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"denied",cause:"refused",reason:$.reason,approval:this.approvalRecord(!1,$.reason)}}if("output"in $){if(z==="approval")return J(`"${X}" is approved, not answered: the server produces its result.`);let K=G.tool.outputSchema,q=K?K.safeParse($.output):{ok:!0,value:$.output};if(q.ok===!1)return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"error",error:{code:"invalid_tool_result",message:`The answer for "${X}" did not match its output schema: ${q.errors.join(", ")}`,toolCallId:B.toolCallId,retryable:!0}};return{type:"tool-result",toolCallId:B.toolCallId,name:B.name,status:"ok",output:q.value}}return J(`The answer for "${X}" carried neither an approval nor an output.`)}attachToHistory(Z,$){let Q=this.amend(Z.message);r4($,Z.call.input),Q.content.push($),this.unreported.add(Q),this.emit({type:"tool-result",messageId:Q.id,part:$})}markFileRejected(Z,$,Q){for(let J of this.history){if(!J.content.some((W)=>W.type==="file"&&W.fileId===Z&&!W.providerRejected))continue;let V=this.produced.includes(J)?J:this.amend(J);if(V.content=V.content.map((W)=>W.type==="file"&&W.fileId===Z&&!W.providerRejected?{...W,providerRejected:!0}:W),V!==this.current)this.unreported.add(V)}if(!this.config.logErrors)return;let B=`[gemi/ai] agent "${this.config.name}": the provider refused file ${Z}${Q.status!==void 0?` (${Q.status})`:""}; it was left out of the request and will not be sent again: ${$}`,X={agent:this.config.name,runId:this.runId,...this.params.threadId?{threadId:this.params.threadId}:{},fileId:Z,...Q},G=!1;try{o.warning(B,X),G=!0}catch{}if(!G||Bun.env.NODE_ENV==="development")console.warn(B,X)}amend(Z){let $=this.amended.get(Z.id);if($)return $;let Q={...Z,content:[...Z.content]},B=this.history.indexOf(Z);if(B>=0)this.history[B]=Q;return this.produced.push(Q),this.amended.set(Z.id,Q),Q}async reportDeferred(){let Z=[...this.unreported];this.unreported.clear();for(let $ of Z)await this.report($)}async finalizeAborted(){if(this.nestedSettling.size>0)await Promise.all([...this.nestedSettling]);for(let $ of this.openCalls()){if($.message===this.current)continue;this.attachToHistory($,{type:"tool-result",toolCallId:$.call.toolCallId,name:$.call.name,status:"denied",cause:"stopped",reason:this.stopReason})}await this.reportDeferred();let Z=this.current;if(Z){let $=new Set(Z.content.filter((Q)=>Q.type==="tool-result").map((Q)=>Q.toolCallId));for(let Q of[...Z.content]){if(Q.type!=="tool-call"||$.has(Q.toolCallId))continue;delete Q.partial,this.addResult(Z,{type:"tool-result",toolCallId:Q.toolCallId,name:Q.name,status:"denied",cause:"stopped",reason:this.stopReason})}}if(this.timedOutAfter!==void 0){this.fail({code:"timeout",message:`The run did not finish within its time limit of ${C0(this.timedOutAfter)} (maxRunDurationMs: ${this.timedOutAfter}) and was stopped.`,retryable:!0}),this.finishReason="error",await this.finalizeMessage("error");return}this.finishReason="aborted",await this.finalizeMessage("aborted")}}function X7(Z){if(Z.answeredBy==="client")return Z.inputSchema===_0?"question":"client";return Z.requiresApproval?"approval":null}function G7(Z){if(!Z||!Z.trim())return{};try{return JSON.parse(Z)}catch{return Z}}function a1(Z){let $=new wZ;return $.push(Z),$.snapshot()}var x0={true:!0,false:!1,null:null};class wZ{frames=[];scalar;root;done=!1;failed=!1;dirty=!1;shownOpen;push(Z){let $=[];for(let Q=0;Q<Z.length&&!this.failed;Q++)this.read(Z[Q],$);return $}get changed(){if(this.dirty)return!0;let Z=this.openStringValue();return Z!==void 0&&Z!==this.shownOpen}snapshot(){if(this.dirty=!1,this.shownOpen=this.openStringValue(),this.done)return this.root;if(this.frames.length===0)return this.shownOpen;return this.build(0)}build(Z){let $=this.frames[Z],Q=Z+1<this.frames.length?this.build(Z+1):this.openStringValue();if($.kind==="array"){let X=$.value.slice();if(Q!==void 0)X.push(Q);return X}let B={...$.value};if(Q!==void 0&&$.expect==="value"&&$.key!==void 0)P7(B,$.key,Q);return B}openStringValue(){let Z=this.scalar;if(!Z||Z.kind!=="string"||Z.key)return;return L7(j$(Z.raw))}read(Z,$){let Q=this.scalar;if(Q?.kind==="string"){if(Q.escaped)Q.escaped=!1;else if(Z==="\\")Q.escaped=!0;else if(Z==='"'){this.scalar=void 0;let X=L7(Q.raw);if(Q.key)this.gotKey(X);else this.gotValue(X,X!==this.shownOpen);return}Q.raw+=Z;return}if(Q){if(Q.kind==="number"?/[0-9eE+\-.]/.test(Z):/[a-z]/.test(Z)){if(Q.raw+=Z,Q.kind==="literal")this.checkLiteral(Q);return}if(this.scalar=void 0,Q.kind==="number"){let X=U$(Q.raw);if(X===void 0)return this.fail();this.gotValue(X,!0)}else return this.fail();if(this.failed)return}if(Z===" "||Z===`
|
|
28
28
|
`||Z==="\r"||Z==="\t")return;let B=this.frames[this.frames.length-1];if(!B){if(this.done)return this.fail();return this.startValue(Z,"$")}if(B.kind==="object")switch(B.expect){case"key-or-end":case"key":if(Z==='"'){this.scalar={kind:"string",raw:"",key:!0,escaped:!1};return}if(Z==="}"&&B.expect==="key-or-end")return this.close($);return this.fail();case"colon":if(Z===":"){B.expect="value";return}return this.fail();case"value":return this.startValue(Z,D$(B.path,B.key));case"comma-or-end":if(Z===","){B.expect="key",B.key=void 0;return}if(Z==="}")return this.close($);return this.fail()}switch(B.expect){case"value-or-end":if(Z==="]")return this.close($);return this.startValue(Z,`${B.path}[${B.value.length}]`);case"value":return this.startValue(Z,`${B.path}[${B.value.length}]`);case"comma-or-end":if(Z===","){B.expect="value";return}if(Z==="]")return this.close($);return this.fail()}}startValue(Z,$){if(Z==="{")this.frames.push({kind:"object",value:{},path:$,expect:"key-or-end"}),this.dirty=!0;else if(Z==="[")this.frames.push({kind:"array",value:[],path:$,expect:"value-or-end"}),this.dirty=!0;else if(Z==='"')this.scalar={kind:"string",raw:"",key:!1,escaped:!1},this.dirty=!0;else if(Z==="-"||Z>="0"&&Z<="9")this.scalar={kind:"number",raw:Z,key:!1,escaped:!1};else if(Z>="a"&&Z<="z")this.scalar={kind:"literal",raw:Z,key:!1,escaped:!1},this.checkLiteral(this.scalar);else this.fail()}checkLiteral(Z){if(Z.raw in x0)this.scalar=void 0,this.gotValue(x0[Z.raw],!0);else if(!Object.keys(x0).some(($)=>$.startsWith(Z.raw)))this.fail()}gotKey(Z){let $=this.frames[this.frames.length-1];$.key=Z,$.expect="colon"}gotValue(Z,$){if($)this.dirty=!0;let Q=this.frames[this.frames.length-1];if(!Q)this.root=Z,this.done=!0;else if(Q.kind==="array")Q.value.push(Z),Q.expect="comma-or-end";else P7(Q.value,Q.key,Z),Q.expect="comma-or-end"}close(Z){let $=this.frames.pop();Z.push($.path),this.gotValue($.value,!1)}fail(){this.failed=!0,this.scalar=void 0}}function D$(Z,$){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test($)?`${Z}.${$}`:`${Z}[${JSON.stringify($)}]`}function P7(Z,$,Q){if($==="__proto__")Object.defineProperty(Z,$,{value:Q,enumerable:!0,writable:!0,configurable:!0});else Z[$]=Q}function U$(Z){if(!/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/.test(Z))return;return Number(Z)}function L7(Z){try{return JSON.parse(`"${Z.replace(/[\u0000-\u001f]/g,($)=>`\\u${$.charCodeAt(0).toString(16).padStart(4,"0")}`)}"`)}catch{return Z}}function j$(Z){let $=/\\u[0-9a-fA-F]{0,3}$/.exec(Z);if($&&T0(Z,$.index))return Z.slice(0,$.index);let Q=/\\u[dD][89abAB][0-9a-fA-F]{2}$/.exec(Z);if(Q&&T0(Z,Q.index))return Z.slice(0,Q.index);if(Z.endsWith("\\")&&T0(Z,Z.length-1))return Z.slice(0,-1);return Z}function T0(Z,$){let Q=0;for(let B=$-1;B>=0&&Z[B]==="\\";B--)Q++;return Q%2===0}function l4(Z){return zZ(Z)}async function zZ(Z,$={}){let Q=`gen_${crypto.randomUUID()}`,B=await L$(Z);if($.settled?.(B),!B.ok){if(Z.logErrors!==!1&&B.error.code!=="aborted")R$(Q,B.error,$.origin);if(Z.throwOnError)throw new bZ({runId:Q,messages:B.messages,finishReason:B.finishReason,usage:B.usage,error:B.error},B.rejected?{rejected:B.rejected}:void 0)}return B}var P$=30000;async function L$(Z){if(Z.timeoutMs===void 0)return C7(Z,Z.signal);let $=new AbortController,Q=setTimeout(()=>$.abort(new DOMException("The operation timed out.","TimeoutError")),Z.timeoutMs);try{return await C7(Z,O7(Z.signal,$.signal))}finally{clearTimeout(Q)}}async function C7(Z,$){let Q=Z.validate,B=Math.max(1,Math.floor(Z.attempts??(Q?3:1))),X=Z.feedback??_$,G=Z.onInvalidOutput??"continue",J=Z.retryErrors??!0,z=Z.messages??[],V=Z.prompt,W="",H=I(),K=[],q,F,Y=(D)=>({...D,usage:H,attempts:K.length,attemptLog:K,...!D.ok&&q?{rejected:q}:{}});for(let D=1;D<=B;D++){if(D>1&&$?.aborted)return Y({ok:!1,error:N7($),messages:F.messages,usage:H,finishReason:"aborted"});let U=Date.now(),j=Z.attemptTimeoutMs!==void 0?new AbortController:void 0,L=j&&setTimeout(()=>j.abort(new DOMException("The attempt took too long.","TimeoutError")),Z.attemptTimeoutMs),C;try{C=await I$({...Z,messages:z,prompt:W?[V,W].filter(Boolean).join(`
|
|
29
29
|
|
|
30
30
|
`):V,signal:O7($,j?.signal)},D)}finally{clearTimeout(L)}F=C,H=_(H,C.usage);let M={attempt:D,outcome:"passed",durationMs:Date.now()-U,usage:C.usage,finishReason:C.finishReason},N=(E)=>{Object.assign(M,E),K.push(M),Z.onAttempt?.(M)},b=D<B;if(!C.ok){let{error:E}=C,gZ=!!j?.signal.aborted&&!$?.aborted,uZ=E.code==="invalid_output"&&C.finishReason==="length";if(gZ||uZ||E.code==="invalid_output"){let VZ=gZ?"timeout":uZ?"cut_off":"invalid_output",E0=gZ?[`The answer took longer than ${Math.round(Z.attemptTimeoutMs/1000)} seconds and was stopped before it finished.`]:uZ?[E.message]:[`The output does not match the output schema: ${E.message}`];N({outcome:VZ,problems:E0,error:E});let v0=VZ!=="invalid_output"||G==="restart";if(!b||VZ==="invalid_output"&&G==="fail")return Y(C);let f0=X(E0,{attempt:D,attempts:B,cause:VZ,restart:v0});if(v0)W=f0;else z=C.messages,V=f0,W="";continue}if(N({outcome:"error",error:E}),b&&J&&E.retryable&&!$?.aborted&&!j?.signal.aborted){if(E.retryAfter)await O$(Math.min(E.retryAfter,P$),$);continue}return Y(C)}if(!Q)return N({}),Y(C);let A=N$(await Q(C.output,{attempt:D,attempts:B,messages:C.messages,signal:$??C$}));if(A.ok===!0)return N({}),Y({...C,output:A.value===A0?C.output:A.value});let O=A.problems.length>0?A.problems:["The answer was rejected."];if(q={output:C.output,problems:O},N({outcome:"rejected",problems:O}),!b||A.retry===!1)return Y({ok:!1,error:{code:"invalid_output",message:A.retry===!1?`The answer was rejected:
|
|
@@ -39,4 +39,4 @@ ${hZ(Z)}
|
|
|
39
39
|
Correct these problems and give the whole answer again.`}function R$(Z,$,Q){let B=`[gemi/ai] generate() failed (${$.code}${$.status!==void 0?` ${$.status}`:""}): ${$.message}`,X={...Q,generateId:Z,error:$},G=!1;try{o.error(B,X),G=!0}catch{}if(!G||Bun.env.NODE_ENV==="development")console.error(B,X)}async function I$(Z,$){let Q=Z.messages??[];if(Q.length===0&&!Z.prompt)throw Error("generate() was given neither a `prompt` nor `messages`, so there is nothing to send the model.");let B=[...Q];if(Z.prompt)B.push({id:`msg_${crypto.randomUUID()}`,role:"user",content:[{type:"text",text:Z.prompt}],createdAt:new Date().toISOString()});let X={id:`msg_${crypto.randomUUID()}`,role:"assistant",content:[],createdAt:new Date().toISOString()},G=Z.signal??new AbortController().signal,J=I(),z="stop",V,W={},H="",K=Z.onPartial?new wZ:void 0;try{let D=Z.provider.stream({messages:[...B],systemPrompt:Z.instructions?.trim()?Z.instructions:void 0,output:qZ(Z.output),reasoning:Z.reasoning,maxOutputTokens:Z.maxOutputTokens,temperature:Z.temperature,signal:Z.signal})[Symbol.asyncIterator]();try{for(;;){let U=await w(Promise.resolve(D.next()),G);if(U.done)break;let j=U.value;switch(j.type){case"output-delta":if(H+=j.delta,K){let L=K.push(j.delta);if(K.changed||L.length>0)M$(Z.onPartial,K.snapshot(),{attempt:$,closed:L})}break;case"text-delta":m(X,"text",j.delta);break;case"reasoning-delta":DZ(X,j.id,j.delta);break;case"finish":if(J=_(J,j.usage),a(j.model??Z.provider.model,j.usage),!V)z=j.reason;break;case"error":z="error",V=j.error,W=c(j);break}}}finally{if(G.aborted)Promise.resolve(D.return?.()).catch(()=>{})}}catch(Y){if(Y instanceof x||G.aborted)z="aborted",V=N7(G);else z="error",V=Z.provider.normalizeError(Y),W=c(Y)}let q=!1,F;if(!V)if(z==="length")V={code:"invalid_output",message:"The model ran out of output tokens before finishing its structured answer, so it was cut off. Raise maxOutputTokens, or ask for a shorter answer.",retryable:!0};else if(!H.trim())V={code:"invalid_output",message:"The model finished without giving a structured answer.",retryable:!0};else{let Y=KZ(Z.output,H);if(Y.ok===!0)q=!0,F=Y.value;else V=Y.error}if(q)X.content.push({type:"output",value:F});else if(H)m(X,"text",H);for(let Y of X.content)if((Y.type==="text"||Y.type==="reasoning")&&typeof Y.text==="string")Y.text=FZ(Y.text);if(X.finishReason=z,X.usage=J,B.push(X),q)return{ok:!0,output:F,messages:B,usage:J,finishReason:z};return{ok:!1,error:{...V,...W},messages:B,usage:J,finishReason:z}}function M$(Z,$,Q){let B=(X)=>{let G=`[gemi/ai] generate() onPartial threw: ${X instanceof Error?X.message:String(X)}`;try{o.warning(G,{error:X})}catch{console.error(G,X)}};try{let X=Z($,Q);if(X instanceof Promise)X.catch(B)}catch(X){B(X)}}function N7(Z){return Z.reason?.name==="TimeoutError"?{code:"timeout",message:"The generation timed out.",retryable:!0}:{code:"aborted",message:"The generation was stopped.",retryable:!1}}var T7=Symbol.for("gemi.ai.JobHandle");class A7{id;toolCallId;summary;deadlineAt;[T7]=!0;constructor(Z,$,Q,B){this.id=Z;this.toolCallId=$;this.summary=Q;this.deadlineAt=B}}function V7(Z){return typeof Z==="object"&&Z!==null&&Z[T7]===!0}class S0 extends P{code="jobs_require_thread";constructor(Z){super(Z,{retryable:!1});this.name="JobsRequireThreadError"}}var t=new aZ,x$=["running","ok","error"],k0={get store(){return t},use(Z){t=Z},get(Z){return t.get(Z)},async settle(Z,$){return yZ(t,Z,$)},async fail(Z,$){return yZ(t,Z,{error:$})},async sweep(Z={}){let $=t,Q=Z.limit??100,B=await T$($),X=0;for(let G of await $.overdue(B,Q))if(await A$($,G))X++;return X}};async function T$(Z){return Z.now?await Z.now():Date.now()}function A$(Z,$){return Z.transition($.id,["running"],{state:"error",error:{code:"timeout",message:`The background job for "${$.toolName}" did not finish before its deadline, so it was given up on. Its result, if it ever arrives, is ignored.`,toolCallId:$.toolCallId,retryable:!0}})}async function yZ(Z,$,Q){let B=await Z.get($);if(!B||B.state!=="running")return!1;let X=Q.usage?_(B.usage??I(),Q.usage):void 0;if("error"in Q)return Z.transition($,["running"],{state:"error",error:S$(B,Q.error),...X?{usage:X}:{}});return Z.transition($,["running"],{state:"ok",output:S7(Q.output,B),...X?{usage:X}:{}})}function S$(Z,$){if(typeof $==="string")return{code:"tool_error",message:$,toolCallId:Z.toolCallId,retryable:!0};if($ instanceof Error){let Q={code:"tool_error",message:$.message,toolCallId:Z.toolCallId,retryable:$ instanceof P?$.retryable:!0};if(!($ instanceof P))console.error(`The background job ${Z.job??"(tracked)"} for "${Z.toolName}" failed.`,$);return UZ(Q,{source:"tool",toolName:Z.toolName,cause:$})}return{code:$.code??"tool_error",message:String($.message),toolCallId:Z.toolCallId,retryable:$.retryable??!0}}function S7(Z,$){if(Z===void 0)return null;try{return JSON.parse(JSON.stringify(Z))}catch(Q){throw Error(`The output of the background job for "${$.toolName}" is not JSON: ${String(Q)}`)}}var k$=3600000;function W7(Z){let $=null,Q=(B,X,G={})=>{if(Z.async===void 0)throw new P(`"${Z.toolName}" called ctx.jobs, but the tool does not declare \`async\`. Add \`async: { deadlineMs }\` to its definition.`,{retryable:!1});if(!Z.jobs||!Z.threadId)throw new S0(`"${Z.toolName}" can only run in the background on a conversation the server keeps (a turn with a threadId), and this one has none.`);if(Z.depth>0)throw new S0(`"${Z.toolName}" can only run in the background from the top-level agent, not from a sub-agent.`);if($)throw new P(`"${Z.toolName}" started a background job already: a tool call has at most one.`,{retryable:!1});let J=G.deadlineMs??Z.async.deadlineMs??k$;if(!Number.isFinite(J)||J<=0)throw new P(`A job's deadlineMs must be a positive number; got ${J}.`);let{jobs:z,threadId:V}=Z;return $=(async()=>{let W=k0.store,H=(await W.listForThread(V,{limit:50})).find((F)=>F.toolCallId===Z.toolCallId);if(H)return _7(H);let K=async()=>{let F=await W.create({id:`ajob_${crypto.randomUUID()}`,threadId:V,runId:Z.runId,toolCallId:Z.toolCallId,toolName:Z.toolName,owner:z.owner,job:B?B.name:null,...G.summary!==void 0?{summary:S7(G.summary,Z)}:{},attachmentScope:Z.attachments?.scopeKey??null,deadlineMs:J});if(B)try{await E$(B,{jobId:F.id,args:X})}catch(Y){if(W.transaction)throw Y;throw await W.transition(F.id,["running"],{state:"error",error:{code:"tool_error",message:`The background job for "${Z.toolName}" could not be queued.`,toolCallId:Z.toolCallId,retryable:!0}}).catch(()=>{}),Y}return F},q=W.transaction?await W.transaction(K):await K();return _7(q)})(),$};return{start:(B,X,G)=>Q(B,X,G),track:(B)=>Q(null,void 0,B)}}function _7(Z){return new A7(Z.id,Z.toolCallId,Z.summary,Z.deadlineAt)}function E$(Z,$){if(Z.name==="unset"||!Z.name)throw Error("Cannot start an AgentJob with no `static name`.");return WZ(M7).push(Z,JSON.stringify([$]))}class v$ extends x7{attachments=l0;attachmentStorage=I7;constructor(){super();let Z=this.run;this.run=($)=>this.$runEnvelope($,Z)}onDeadletter(Z,...$){let Q=$[0];if(!Q?.jobId)return;yZ(k0.store,Q.jobId,{error:Z}).catch((B)=>{console.error(`Could not record the failure of background job ${Q.jobId}.`,B)})}async $runEnvelope(Z,$){let Q=k0.store,B=await Q.get(Z.jobId);if(!B||B.state!=="running")return;let X=new k7(B,this),G;try{G=await $.call(this,Z.args,X)}catch(J){throw await R7(Q,B.id,X.usage),J}if(this.$outcome)return await R7(Q,B.id,X.usage),G;return await yZ(Q,B.id,{output:G,usage:X.usage}),G}}async function R7(Z,$,Q){if(Q.totalTokens===0&&Q.inputTokens===0&&Q.outputTokens===0)return;let B=await Z.get($);if(!B)return;await Z.transition($,x$,{usage:_(B.usage??I(),Q)}).catch(()=>{})}class k7{id;threadId;toolCallId;toolName;owner;summary;signal=new AbortController().signal;usage=I();attachments;constructor(Z,$){this.id=Z.id,this.threadId=Z.threadId,this.toolCallId=Z.toolCallId,this.toolName=Z.toolName,this.owner=Z.owner,this.summary=Z.summary;let Q=Z.attachmentScope?new sZ($.attachments,$.attachmentStorage,{key:Z.attachmentScope}):null,B=()=>{if(!Q)throw new l("The run that started this job had no attachment scope, so the job cannot store or read files. See `attachmentScope()` on the controller.");return Q};this.attachments={put:(X,G={})=>B().put(X,G),get:(X)=>B().get(X),read:(X)=>B().read(X),file:(X)=>B().file(X)}}generate(Z){return zZ(Z,{origin:{threadId:this.threadId,toolCallId:this.toolCallId,jobId:this.id},settled:($)=>{this.usage=_(this.usage,$.usage)}})}async generateImage(Z,$){let{name:Q,...B}=$,X=await Z.generate({...B,signal:this.signal});return this.park(Z,X,Q)}async editImage(Z,$){let{name:Q,images:B,mask:X,...G}=$,J=async(V)=>typeof V==="string"?await this.attachments.file(V):V,z=await Z.edit({...G,images:await Promise.all(B.map(J)),...X?{mask:await J(X)}:{},signal:this.signal});return this.park(Z,z,Q)}async park(Z,$,Q){this.usage=_(this.usage,$.usage);let B=$.mimeType==="image/jpeg"?"jpg":"png";return{attachment:await this.attachments.put($.image,{name:Q??`${Z.name}.${B}`,mimeType:$.mimeType}),size:$.size,mimeType:$.mimeType,usage:$.usage}}}
|
|
40
40
|
export{w0 as Yb,E7 as Zb,v7 as _b,cZ as $b,$Z as ac,S as bc,g$ as cc,I as dc,_ as ec,iZ as fc,a as gc,y7 as hc,p$ as ic,m$ as jc,P as kc,UZ as lc,i$ as mc,nZ as nc,l as oc,tZ as pc,u7 as qc,sZ as rc,d7 as sc,m0 as tc,l0 as uc,aZ as vc,A7 as wc,V7 as xc,S0 as yc,k0 as zc,T$ as Ac,A$ as Bc,k$ as Cc,W7 as Dc,v$ as Ec,s0 as Fc,e0 as Gc,a7 as Hc,r7 as Ic,jZ as Jc,i as Kc,X0 as Lc,u as Mc,G0 as Nc,Q9 as Oc,v as Pc,Y1 as Qc,k4 as Rc,IZ as Sc,F9 as Tc,D9 as Uc,E4 as Vc,c as Wc,U1 as Xc,xZ as Yc,TZ as Zc,P1 as _c,_9 as $c,I9 as ad,M9 as bd,QZ as cd,S9 as dd,v9 as ed,b9 as fd,w9 as gd,y4 as hd,y9 as id,g4 as jd,R1 as kd,I1 as ld,i4 as md,o4 as nd,r9 as od,n as pd,h as qd,fZ as rd,H7 as sd,f as td,t1 as ud,K7 as vd,bZ as wd,M0 as xd,a1 as yd,l4 as zd,zZ as Ad};
|
|
41
41
|
|
|
42
|
-
//# debugId=
|
|
42
|
+
//# debugId=3457D68A329E1A9F64756E2164756E21
|