gemi 0.219.0 → 0.220.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/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/testing/index.js +2 -2
- package/dist/ai/testing/index.js.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-xyv3y476.js → chunk-0av1gyns.js} +3 -3
- package/dist/{chunk-xyv3y476.js.map → chunk-0av1gyns.js.map} +1 -1
- package/dist/{chunk-yxtfg4wy.js → chunk-0k2r6bep.js} +2 -2
- package/dist/{chunk-yxtfg4wy.js.map → chunk-0k2r6bep.js.map} +1 -1
- package/dist/chunk-169e9dg7.js +517 -0
- package/dist/chunk-169e9dg7.js.map +25 -0
- package/dist/{chunk-xp5mmgfp.js → chunk-2vv04thj.js} +2 -2
- package/dist/{chunk-xp5mmgfp.js.map → chunk-2vv04thj.js.map} +1 -1
- package/dist/{chunk-kt174y9e.js → chunk-2y0nr525.js} +3 -3
- package/dist/{chunk-kt174y9e.js.map → chunk-2y0nr525.js.map} +1 -1
- package/dist/{chunk-aes0ecnp.js → chunk-37209psn.js} +3 -3
- package/dist/{chunk-aes0ecnp.js.map → chunk-37209psn.js.map} +1 -1
- package/dist/{chunk-yedb5vvg.js → chunk-3dkv4989.js} +2 -2
- package/dist/{chunk-5gp49wph.js.map → chunk-3dkv4989.js.map} +1 -1
- package/dist/{chunk-5wh3cw2x.js → chunk-3y91vexx.js} +3 -3
- package/dist/{chunk-5wh3cw2x.js.map → chunk-3y91vexx.js.map} +1 -1
- package/dist/{chunk-cmyt2txd.js → chunk-4v5nwqw6.js} +3 -3
- package/dist/{chunk-cmyt2txd.js.map → chunk-4v5nwqw6.js.map} +1 -1
- package/dist/{chunk-v0sgcy87.js → chunk-4wh4dfgf.js} +1 -1
- package/dist/{chunk-1nw9jhpt.js → chunk-50791bmz.js} +2 -2
- package/dist/{chunk-1nw9jhpt.js.map → chunk-50791bmz.js.map} +1 -1
- package/dist/{chunk-rp2f9mq1.js → chunk-55btq9c7.js} +2 -2
- package/dist/{chunk-rp2f9mq1.js.map → chunk-55btq9c7.js.map} +1 -1
- package/dist/{chunk-w3ks9nz7.js → chunk-5h2xj3cx.js} +2 -2
- package/dist/{chunk-w3ks9nz7.js.map → chunk-5h2xj3cx.js.map} +1 -1
- package/dist/{chunk-at6zjajz.js → chunk-5jvbr0e5.js} +2 -2
- package/dist/{chunk-at6zjajz.js.map → chunk-5jvbr0e5.js.map} +1 -1
- package/dist/{chunk-hmtn7996.js → chunk-5mrtgr7q.js} +2 -2
- package/dist/{chunk-hmtn7996.js.map → chunk-5mrtgr7q.js.map} +1 -1
- package/dist/{chunk-2vktfp1f.js → chunk-6d67a1d4.js} +2 -2
- package/dist/{chunk-2vktfp1f.js.map → chunk-6d67a1d4.js.map} +1 -1
- package/dist/{chunk-q0d45r2j.js → chunk-6r7956dh.js} +2 -2
- package/dist/{chunk-q0d45r2j.js.map → chunk-6r7956dh.js.map} +1 -1
- package/dist/{chunk-ee7xb9qr.js → chunk-6ttbhhnn.js} +1 -1
- package/dist/{chunk-w85wrer7.js → chunk-726gd69z.js} +2 -2
- package/dist/{chunk-w85wrer7.js.map → chunk-726gd69z.js.map} +1 -1
- package/dist/{chunk-dgna0e7g.js → chunk-79wjkaa4.js} +2 -2
- package/dist/{chunk-dgna0e7g.js.map → chunk-79wjkaa4.js.map} +1 -1
- package/dist/{chunk-c250kpcm.js → chunk-7etvj6w2.js} +2 -2
- package/dist/{chunk-c250kpcm.js.map → chunk-7etvj6w2.js.map} +1 -1
- package/dist/{chunk-yv3y3r9q.js → chunk-7sjzgme6.js} +4 -4
- package/dist/{chunk-yv3y3r9q.js.map → chunk-7sjzgme6.js.map} +1 -1
- package/dist/chunk-89egc0h3.js +5 -0
- package/dist/{chunk-4g24ffv8.js.map → chunk-89egc0h3.js.map} +1 -1
- package/dist/{chunk-4k3r37be.js → chunk-8a3fqcf0.js} +2 -2
- package/dist/{chunk-4k3r37be.js.map → chunk-8a3fqcf0.js.map} +1 -1
- package/dist/{chunk-3r7z4kc0.js → chunk-8ddt5fa2.js} +2 -2
- package/dist/{chunk-3r7z4kc0.js.map → chunk-8ddt5fa2.js.map} +1 -1
- package/dist/{chunk-4kkb85z8.js → chunk-8gnbc9dg.js} +3 -3
- package/dist/{chunk-4kkb85z8.js.map → chunk-8gnbc9dg.js.map} +1 -1
- package/dist/{chunk-66re5qsr.js → chunk-8nctfg18.js} +2 -2
- package/dist/{chunk-66re5qsr.js.map → chunk-8nctfg18.js.map} +1 -1
- package/dist/{chunk-17agj0r3.js → chunk-8vpe54ek.js} +2 -2
- package/dist/{chunk-17agj0r3.js.map → chunk-8vpe54ek.js.map} +1 -1
- package/dist/{chunk-9c8e4nkz.js → chunk-97tj0d7v.js} +2 -2
- package/dist/{chunk-9c8e4nkz.js.map → chunk-97tj0d7v.js.map} +1 -1
- package/dist/{chunk-w9a3b4vs.js → chunk-9yascc81.js} +2 -2
- package/dist/{chunk-w9a3b4vs.js.map → chunk-9yascc81.js.map} +1 -1
- package/dist/{chunk-9pvxexh1.js → chunk-adw279ge.js} +2 -2
- package/dist/{chunk-9pvxexh1.js.map → chunk-adw279ge.js.map} +1 -1
- package/dist/{chunk-w4aw44zg.js → chunk-anc5v266.js} +2 -2
- package/dist/{chunk-w4aw44zg.js.map → chunk-anc5v266.js.map} +1 -1
- package/dist/{chunk-6b7z5h54.js → chunk-ax042w6k.js} +2 -2
- package/dist/{chunk-6b7z5h54.js.map → chunk-ax042w6k.js.map} +1 -1
- package/dist/{chunk-59p034g3.js → chunk-b87wvmsz.js} +2 -2
- package/dist/{chunk-59p034g3.js.map → chunk-b87wvmsz.js.map} +1 -1
- package/dist/{chunk-xn7azkgd.js → chunk-bqm79ar0.js} +3 -3
- package/dist/{chunk-xn7azkgd.js.map → chunk-bqm79ar0.js.map} +1 -1
- package/dist/{chunk-5gp49wph.js → chunk-cf8bztwq.js} +2 -2
- package/dist/{chunk-yedb5vvg.js.map → chunk-cf8bztwq.js.map} +1 -1
- package/dist/{chunk-kggwk7hz.js → chunk-dj0nvj66.js} +1 -1
- package/dist/{chunk-xf3wke41.js → chunk-e4zxacxd.js} +2 -2
- package/dist/{chunk-xf3wke41.js.map → chunk-e4zxacxd.js.map} +1 -1
- package/dist/{chunk-b8tmmpcf.js → chunk-fp9yn4k8.js} +2 -2
- package/dist/{chunk-b8tmmpcf.js.map → chunk-fp9yn4k8.js.map} +1 -1
- package/dist/{chunk-sba3s380.js → chunk-fqhkkpq3.js} +2 -2
- package/dist/{chunk-sba3s380.js.map → chunk-fqhkkpq3.js.map} +1 -1
- package/dist/{chunk-nhebjh6n.js → chunk-fxa72ppw.js} +1 -1
- package/dist/{chunk-w9sw2kn7.js → chunk-gyszenps.js} +3 -3
- package/dist/{chunk-w9sw2kn7.js.map → chunk-gyszenps.js.map} +1 -1
- package/dist/{chunk-y12m6w7b.js → chunk-h1wmpa03.js} +2 -2
- package/dist/{chunk-y12m6w7b.js.map → chunk-h1wmpa03.js.map} +1 -1
- package/dist/{chunk-5vdkqv17.js → chunk-h9nt7hm6.js} +2 -2
- package/dist/{chunk-5vdkqv17.js.map → chunk-h9nt7hm6.js.map} +1 -1
- package/dist/{chunk-nrv7hdeh.js → chunk-j9abwrkv.js} +3 -3
- package/dist/{chunk-nrv7hdeh.js.map → chunk-j9abwrkv.js.map} +1 -1
- package/dist/{chunk-m68cxnbv.js → chunk-jf2dr481.js} +2 -2
- package/dist/{chunk-m68cxnbv.js.map → chunk-jf2dr481.js.map} +1 -1
- package/dist/{chunk-h6knw9f0.js → chunk-k16phdjv.js} +1 -1
- package/dist/{chunk-vewxnk3g.js → chunk-k6af7qek.js} +2 -2
- package/dist/{chunk-vewxnk3g.js.map → chunk-k6af7qek.js.map} +1 -1
- package/dist/{chunk-xm6hfksv.js → chunk-kp7wcpx7.js} +2 -2
- package/dist/{chunk-xm6hfksv.js.map → chunk-kp7wcpx7.js.map} +1 -1
- package/dist/{chunk-d6056zme.js → chunk-mt82209n.js} +2 -2
- package/dist/{chunk-d6056zme.js.map → chunk-mt82209n.js.map} +1 -1
- package/dist/{chunk-vawqmdh4.js → chunk-ncnygh0s.js} +2 -2
- package/dist/{chunk-vawqmdh4.js.map → chunk-ncnygh0s.js.map} +1 -1
- package/dist/{chunk-g178aect.js → chunk-nqgeny8m.js} +4 -4
- package/dist/{chunk-g178aect.js.map → chunk-nqgeny8m.js.map} +1 -1
- package/dist/{chunk-zy6hj5cc.js → chunk-nqqyn3cx.js} +2 -2
- package/dist/{chunk-zy6hj5cc.js.map → chunk-nqqyn3cx.js.map} +1 -1
- package/dist/{chunk-ppdfwnqw.js → chunk-nzd7z4s6.js} +1 -1
- package/dist/{chunk-s4sx97fn.js → chunk-p4v71qfx.js} +3 -3
- package/dist/{chunk-s4sx97fn.js.map → chunk-p4v71qfx.js.map} +1 -1
- package/dist/{chunk-vck02shp.js → chunk-ps5rpy9n.js} +2 -2
- package/dist/{chunk-vck02shp.js.map → chunk-ps5rpy9n.js.map} +1 -1
- package/dist/{chunk-gt6eq1p2.js → chunk-pxjkxhf9.js} +3 -3
- package/dist/{chunk-gt6eq1p2.js.map → chunk-pxjkxhf9.js.map} +1 -1
- package/dist/{chunk-r90djdx6.js → chunk-pxjptskr.js} +2 -2
- package/dist/{chunk-r90djdx6.js.map → chunk-pxjptskr.js.map} +1 -1
- package/dist/{chunk-6ncn8rdn.js → chunk-q5xcjm5z.js} +2 -2
- package/dist/{chunk-6ncn8rdn.js.map → chunk-q5xcjm5z.js.map} +1 -1
- package/dist/{chunk-0egjv6cj.js → chunk-qs2xvc8g.js} +2 -2
- package/dist/{chunk-0egjv6cj.js.map → chunk-qs2xvc8g.js.map} +1 -1
- package/dist/{chunk-6my6c6b1.js → chunk-qy0k2s5f.js} +2 -2
- package/dist/{chunk-6my6c6b1.js.map → chunk-qy0k2s5f.js.map} +1 -1
- package/dist/{chunk-jzqywxpj.js → chunk-rat2827k.js} +2 -2
- package/dist/{chunk-jzqywxpj.js.map → chunk-rat2827k.js.map} +1 -1
- package/dist/{chunk-ykshxc5k.js → chunk-s3gn68dy.js} +2 -2
- package/dist/{chunk-ykshxc5k.js.map → chunk-s3gn68dy.js.map} +1 -1
- package/dist/{chunk-8524ejgk.js → chunk-sfrjkysf.js} +2 -2
- package/dist/{chunk-8524ejgk.js.map → chunk-sfrjkysf.js.map} +1 -1
- package/dist/{chunk-cw50n89n.js → chunk-snmyjq03.js} +2 -2
- package/dist/{chunk-cw50n89n.js.map → chunk-snmyjq03.js.map} +1 -1
- package/dist/{chunk-cwm5x7rf.js → chunk-swmf6w3z.js} +2 -2
- package/dist/{chunk-cwm5x7rf.js.map → chunk-swmf6w3z.js.map} +1 -1
- package/dist/{chunk-xvf1hcxg.js → chunk-t0ke72e9.js} +2 -2
- package/dist/{chunk-xvf1hcxg.js.map → chunk-t0ke72e9.js.map} +1 -1
- package/dist/{chunk-gf3m0866.js → chunk-t586p2g2.js} +2 -2
- package/dist/{chunk-gf3m0866.js.map → chunk-t586p2g2.js.map} +1 -1
- package/dist/{chunk-zyvmbqcx.js → chunk-t8ygf6zj.js} +3 -3
- package/dist/{chunk-zyvmbqcx.js.map → chunk-t8ygf6zj.js.map} +1 -1
- package/dist/{chunk-ak85ee4e.js → chunk-tac25cnj.js} +3 -3
- package/dist/{chunk-ak85ee4e.js.map → chunk-tac25cnj.js.map} +1 -1
- package/dist/{chunk-p4b5hmr8.js → chunk-vcw98sp6.js} +3 -3
- package/dist/{chunk-p4b5hmr8.js.map → chunk-vcw98sp6.js.map} +1 -1
- package/dist/{chunk-jfpwjqvq.js → chunk-vcy1y0ta.js} +2 -2
- package/dist/{chunk-jfpwjqvq.js.map → chunk-vcy1y0ta.js.map} +1 -1
- package/dist/{chunk-fhb00fjx.js → chunk-vmmjq9fn.js} +2 -2
- package/dist/{chunk-fhb00fjx.js.map → chunk-vmmjq9fn.js.map} +1 -1
- package/dist/{chunk-prc4bcgp.js → chunk-wt4ekzp9.js} +2 -2
- package/dist/{chunk-prc4bcgp.js.map → chunk-wt4ekzp9.js.map} +1 -1
- package/dist/{chunk-xrkr2yzz.js → chunk-wy82t7mz.js} +2 -2
- package/dist/{chunk-xrkr2yzz.js.map → chunk-wy82t7mz.js.map} +1 -1
- package/dist/{chunk-g5drp5xx.js → chunk-x3pbssy4.js} +2 -2
- package/dist/{chunk-g5drp5xx.js.map → chunk-x3pbssy4.js.map} +1 -1
- package/dist/{chunk-71r1x773.js → chunk-xjgfmefy.js} +2 -2
- package/dist/{chunk-71r1x773.js.map → chunk-xjgfmefy.js.map} +1 -1
- package/dist/{chunk-qstjm3cb.js → chunk-yj7pbbnm.js} +2 -2
- package/dist/{chunk-qstjm3cb.js.map → chunk-yj7pbbnm.js.map} +1 -1
- package/dist/{chunk-qa528feb.js → chunk-zmt5kdpb.js} +2 -2
- package/dist/{chunk-qa528feb.js.map → chunk-zmt5kdpb.js.map} +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/probe/index.js +2 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +2 -2
- package/dist/services/queue/DatabaseQueueDriver.d.ts +8 -1
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts +21 -0
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/ItemSource.d.ts +68 -0
- package/dist/services/queue/workflow/ItemSource.d.ts.map +1 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +12 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/Step.d.ts +28 -1
- package/dist/services/queue/workflow/Step.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -1
- package/dist/services/queue/workflow/WorkflowStore.d.ts +23 -1
- package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -1
- package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4g24ffv8.js +0 -5
- package/dist/chunk-pnt0c59g.js +0 -484
- package/dist/chunk-pnt0c59g.js.map +0 -24
- /package/dist/{chunk-v0sgcy87.js.map → chunk-4wh4dfgf.js.map} +0 -0
- /package/dist/{chunk-ee7xb9qr.js.map → chunk-6ttbhhnn.js.map} +0 -0
- /package/dist/{chunk-kggwk7hz.js.map → chunk-dj0nvj66.js.map} +0 -0
- /package/dist/{chunk-nhebjh6n.js.map → chunk-fxa72ppw.js.map} +0 -0
- /package/dist/{chunk-h6knw9f0.js.map → chunk-k16phdjv.js.map} +0 -0
- /package/dist/{chunk-ppdfwnqw.js.map → chunk-nzd7z4s6.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V as A}from"./chunk-
|
|
2
|
+
import{V as A}from"./chunk-fp9yn4k8.js";import"./chunk-8ddt5fa2.js";import{X as I}from"./chunk-5jvbr0e5.js";import{Y as f}from"./chunk-ncnygh0s.js";import{Mm as t,Qm as T}from"./chunk-3dkv4989.js";var N=t(I(),1),a=t(f(),1),d=t(A(),1);import{readFileSync as g}from"fs";var c=(e)=>async(s)=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromWebToken");let{roleArn:o,roleSessionName:r,webIdentityToken:i,providerId:n,policyArns:m,policy:S,durationSeconds:l}=e,{roleAssumerWithWebIdentity:E}=e;if(!E){let{getDefaultRoleAssumerWithWebIdentity:p}=await import("./chunk-97tj0d7v.js").then((m)=>t(m.default,1));E=p({...e.clientConfig,credentialProviderLogger:e.logger,parentClientConfig:{...s?.callerClientConfig,...e.parentClientConfig}},e.clientPlugins)}return E({RoleArn:o,RoleSessionName:r??`aws-sdk-js-session-${Date.now()}`,WebIdentityToken:i,ProviderId:n,PolicyArns:m,Policy:S,DurationSeconds:l})};var _="AWS_WEB_IDENTITY_TOKEN_FILE",O="AWS_ROLE_ARN",k="AWS_ROLE_SESSION_NAME",L=(e={})=>async(s)=>{e.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");let o=e?.webIdentityTokenFile??process.env[_],r=e?.roleArn??process.env[O],i=e?.roleSessionName??process.env[k];if(!o||!r)throw new a.CredentialsProviderError("Web identity configuration not specified",{logger:e.logger});let n=await c({...e,webIdentityToken:d.externalDataInterceptor?.getTokenRecord?.()[o]??g(o,{encoding:"ascii"}),roleArn:r,roleSessionName:i})(s);if(o===process.env[_])N.setCredentialFeature(n,"CREDENTIALS_ENV_VARS_STS_WEB_ID_TOKEN","h");return n};export{c as fromWebToken,L as fromTokenFile};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=C533F07BD4C73E2264756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"export const fromWebToken = (init) => async (awsIdentityProperties) => {\n init.logger?.debug(\"@aws-sdk/credential-provider-web-identity - fromWebToken\");\n const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init;\n let { roleAssumerWithWebIdentity } = init;\n if (!roleAssumerWithWebIdentity) {\n const { getDefaultRoleAssumerWithWebIdentity } = await import(\"@aws-sdk/nested-clients/sts\");\n roleAssumerWithWebIdentity = getDefaultRoleAssumerWithWebIdentity({\n ...init.clientConfig,\n credentialProviderLogger: init.logger,\n parentClientConfig: {\n ...awsIdentityProperties?.callerClientConfig,\n ...init.parentClientConfig,\n },\n }, init.clientPlugins);\n }\n return roleAssumerWithWebIdentity({\n RoleArn: roleArn,\n RoleSessionName: roleSessionName ?? `aws-sdk-js-session-${Date.now()}`,\n WebIdentityToken: webIdentityToken,\n ProviderId: providerId,\n PolicyArns: policyArns,\n Policy: policy,\n DurationSeconds: durationSeconds,\n });\n};\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";6NAAA,SACA,KACA,KACA,iBAAS,WCHF,IAAM,EAAe,CAAC,IAAS,MAAO,IAA0B,CACnE,EAAK,QAAQ,MAAM,0DAA0D,EAC7E,IAAQ,UAAS,kBAAiB,mBAAkB,aAAY,aAAY,SAAQ,mBAAoB,GAClG,8BAA+B,EACrC,GAAI,CAAC,EAA4B,CAC7B,IAAQ,wCAAyC,KAAa,yDAC9D,EAA6B,EAAqC,IAC3D,EAAK,aACR,yBAA0B,EAAK,OAC/B,mBAAoB,IACb,GAAuB,sBACvB,EAAK,kBACZ,CACJ,EAAG,EAAK,aAAa,EAEzB,OAAO,EAA2B,CAC9B,QAAS,EACT,gBAAiB,GAAmB,sBAAsB,KAAK,IAAI,IACnE,iBAAkB,EAClB,WAAY,EACZ,WAAY,EACZ,OAAQ,EACR,gBAAiB,CACrB,CAAC,GDlBL,IAAM,EAAiB,8BACjB,EAAe,eACf,EAAwB,wBACjB,EAAgB,CAAC,EAAO,CAAC,IAAM,MAAO,IAA0B,CACzE,EAAK,QAAQ,MAAM,2DAA2D,EAC9E,IAAM,EAAuB,GAAM,sBAAwB,QAAQ,IAAI,GACjE,EAAU,GAAM,SAAW,QAAQ,IAAI,GACvC,EAAkB,GAAM,iBAAmB,QAAQ,IAAI,GAC7D,GAAI,CAAC,GAAwB,CAAC,EAC1B,MAAM,IAAI,2BAAyB,2CAA4C,CAC3E,OAAQ,EAAK,MACjB,CAAC,EAEL,IAAM,EAAc,MAAM,EAAa,IAChC,EACH,iBAAkB,2BAAyB,iBAAiB,EAAE,IAC1D,EAAa,EAAsB,CAAE,SAAU,OAAQ,CAAC,EAC5D,UACA,iBACJ,CAAC,EAAE,CAAqB,EACxB,GAAI,IAAyB,QAAQ,IAAI,GACrC,uBAAqB,EAAa,wCAAyC,GAAG,EAElF,OAAO",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "C533F07BD4C73E2264756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W as J}from"./chunk-
|
|
2
|
+
import{W as J}from"./chunk-8ddt5fa2.js";import{Nm as I}from"./chunk-3dkv4989.js";var Z=I((Q)=>{var K=J(),L=(b)=>{return{setHttpHandler(j){b.httpHandler=j},httpHandler(){return b.httpHandler},updateHttpClientConfig(j,w){b.httpHandler?.updateHttpClientConfig(j,w)},httpHandlerConfigs(){return b.httpHandler.httpHandlerConfigs()}}},M=(b)=>{return{httpHandler:b.httpHandler()}};class B{name;kind;values;constructor({name:b,kind:j=K.FieldPosition.HEADER,values:w=[]}){this.name=b,this.kind=j,this.values=w}add(b){this.values.push(b)}set(b){this.values=b}remove(b){this.values=this.values.filter((j)=>j!==b)}toString(){return this.values.map((b)=>b.includes(",")||b.includes(" ")?`"${b}"`:b).join(", ")}get(){return this.values}}class D{entries={};encoding;constructor({fields:b=[],encoding:j="utf-8"}){b.forEach(this.setField.bind(this)),this.encoding=j}setField(b){this.entries[b.name.toLowerCase()]=b}getField(b){return this.entries[b.toLowerCase()]}removeField(b){delete this.entries[b.toLowerCase()]}getByType(b){return Object.values(this.entries).filter((j)=>j.kind===b)}}class z{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(b){this.method=b.method||"GET",this.hostname=b.hostname||"localhost",this.port=b.port,this.query=b.query||{},this.headers=b.headers||{},this.body=b.body,this.protocol=b.protocol?b.protocol.slice(-1)!==":"?`${b.protocol}:`:b.protocol:"https:",this.path=b.path?b.path.charAt(0)!=="/"?`/${b.path}`:b.path:"/",this.username=b.username,this.password=b.password,this.fragment=b.fragment}static clone(b){let j=new z({...b,headers:{...b.headers}});if(j.query)j.query=O(j.query);return j}static isInstance(b){if(!b)return!1;let j=b;return"method"in j&&"protocol"in j&&"hostname"in j&&"path"in j&&typeof j.query==="object"&&typeof j.headers==="object"}clone(){return z.clone(this)}}function O(b){return Object.keys(b).reduce((j,w)=>{let A=b[w];return{...j,[w]:Array.isArray(A)?[...A]:A}},{})}class G{statusCode;reason;headers;body;constructor(b){this.statusCode=b.statusCode,this.reason=b.reason,this.headers=b.headers||{},this.body=b.body}static isInstance(b){if(!b)return!1;let j=b;return typeof j.statusCode==="number"&&typeof j.headers==="object"}}function P(b){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(b)}Q.Field=B;Q.Fields=D;Q.HttpRequest=z;Q.HttpResponse=G;Q.getHttpHandlerExtensionConfiguration=L;Q.isValidHostname=P;Q.resolveHttpHandlerRuntimeConfig=M});
|
|
3
3
|
export{Z as Q};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=3A766AF9429DAF0A64756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"'use strict';\n\nvar types = require('@smithy/types');\n\nconst getHttpHandlerExtensionConfiguration = (runtimeConfig) => {\n return {\n setHttpHandler(handler) {\n runtimeConfig.httpHandler = handler;\n },\n httpHandler() {\n return runtimeConfig.httpHandler;\n },\n updateHttpClientConfig(key, value) {\n runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);\n },\n httpHandlerConfigs() {\n return runtimeConfig.httpHandler.httpHandlerConfigs();\n },\n };\n};\nconst resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {\n return {\n httpHandler: httpHandlerExtensionConfiguration.httpHandler(),\n };\n};\n\nclass Field {\n name;\n kind;\n values;\n constructor({ name, kind = types.FieldPosition.HEADER, values = [] }) {\n this.name = name;\n this.kind = kind;\n this.values = values;\n }\n add(value) {\n this.values.push(value);\n }\n set(values) {\n this.values = values;\n }\n remove(value) {\n this.values = this.values.filter((v) => v !== value);\n }\n toString() {\n return this.values.map((v) => (v.includes(\",\") || v.includes(\" \") ? `\"${v}\"` : v)).join(\", \");\n }\n get() {\n return this.values;\n }\n}\n\nclass Fields {\n entries = {};\n encoding;\n constructor({ fields = [], encoding = \"utf-8\" }) {\n fields.forEach(this.setField.bind(this));\n this.encoding = encoding;\n }\n setField(field) {\n this.entries[field.name.toLowerCase()] = field;\n }\n getField(name) {\n return this.entries[name.toLowerCase()];\n }\n removeField(name) {\n delete this.entries[name.toLowerCase()];\n }\n getByType(kind) {\n return Object.values(this.entries).filter((field) => field.kind === kind);\n }\n}\n\nclass HttpRequest {\n method;\n protocol;\n hostname;\n port;\n path;\n query;\n headers;\n username;\n password;\n fragment;\n body;\n constructor(options) {\n this.method = options.method || \"GET\";\n this.hostname = options.hostname || \"localhost\";\n this.port = options.port;\n this.query = options.query || {};\n this.headers = options.headers || {};\n this.body = options.body;\n this.protocol = options.protocol\n ? options.protocol.slice(-1) !== \":\"\n ? `${options.protocol}:`\n : options.protocol\n : \"https:\";\n this.path = options.path ? (options.path.charAt(0) !== \"/\" ? `/${options.path}` : options.path) : \"/\";\n this.username = options.username;\n this.password = options.password;\n this.fragment = options.fragment;\n }\n static clone(request) {\n const cloned = new HttpRequest({\n ...request,\n headers: { ...request.headers },\n });\n if (cloned.query) {\n cloned.query = cloneQuery(cloned.query);\n }\n return cloned;\n }\n static isInstance(request) {\n if (!request) {\n return false;\n }\n const req = request;\n return (\"method\" in req &&\n \"protocol\" in req &&\n \"hostname\" in req &&\n \"path\" in req &&\n typeof req[\"query\"] === \"object\" &&\n typeof req[\"headers\"] === \"object\");\n }\n clone() {\n return HttpRequest.clone(this);\n }\n}\nfunction cloneQuery(query) {\n return Object.keys(query).reduce((carry, paramName) => {\n const param = query[paramName];\n return {\n ...carry,\n [paramName]: Array.isArray(param) ? [...param] : param,\n };\n }, {});\n}\n\nclass HttpResponse {\n statusCode;\n reason;\n headers;\n body;\n constructor(options) {\n this.statusCode = options.statusCode;\n this.reason = options.reason;\n this.headers = options.headers || {};\n this.body = options.body;\n }\n static isInstance(response) {\n if (!response)\n return false;\n const resp = response;\n return typeof resp.statusCode === \"number\" && typeof resp.headers === \"object\";\n }\n}\n\nfunction isValidHostname(hostname) {\n const hostPattern = /^[a-z0-9][a-z0-9\\.\\-]*[a-z0-9]$/;\n return hostPattern.test(hostname);\n}\n\nexports.Field = Field;\nexports.Fields = Fields;\nexports.HttpRequest = HttpRequest;\nexports.HttpResponse = HttpResponse;\nexports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration;\nexports.isValidHostname = isValidHostname;\nexports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig;\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qGAEA,FAAI,MAEE,EAAuC,CAAC,IAAkB,CAC5D,MAAO,CACH,cAAc,CAAC,EAAS,CACpB,EAAc,YAAc,GAEhC,WAAW,EAAG,CACV,OAAO,EAAc,aAEzB,sBAAsB,CAAC,EAAK,EAAO,CAC/B,EAAc,aAAa,uBAAuB,EAAK,CAAK,GAEhE,kBAAkB,EAAG,CACjB,OAAO,EAAc,YAAY,mBAAmB,EAE5D,GAEE,EAAkC,CAA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,OAAO,EAAK,aAAe,UAAY,OAAO,EAAK,UAAY,SAE9E,CAEA,SAAS,CAAe,CAAC,EAAU,CAE/B,MADoB,kCACD,KAAK,CAAQ,EAG5B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,uCAAuC,EACvC,kBAAkB,EAClB,kCAAkC",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "3A766AF9429DAF0A64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
function I(B){if(!B.definition)throw Error(`gemi/ai: the recursive schema "${B.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return B.definition}var k=new WeakMap;function MB(B){return typeof B==="object"&&B!==null&&k.has(B)}function x(B){let F=k.get(B);if(!F)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return F}function o(B){let F={defs:{},cells:new Map},G=B;if(B.node.kind==="ref"){let Q=I(B.node.cell);G={...Q,...B.description?{description:B.description}:{},optional:B.optional,nullable:B.nullable||Q.nullable}}let H=K(G,F);return Object.keys(F.defs).length>0?{...H,$defs:F.defs}:H}function K(B,F){let G=(B.optional||B.nullable)&&B.node.kind!=="json",H=n(l(B.node,F),G),Q=[B.description,t(B.node)].filter(Boolean).join(" ");if(Q&&H.$ref!==void 0)H={anyOf:[H]};return Q?{description:Q,...H}:H}function t(B){let F=[];if(B.kind==="string"||B.kind==="enum"){let G=B.checks;if(G?.format)F.push(`Format: ${G.format.name}.`);if(G?.minLength!==void 0)F.push(`At least ${G.minLength} characters.`);if(G?.maxLength!==void 0)F.push(`At most ${G.maxLength} characters.`)}else if(B.kind==="number"){let G=B.checks;if(G?.minimum!==void 0)F.push(`Minimum ${G.minimum}.`);if(G?.exclusiveMinimum!==void 0)F.push(`Greater than ${G.exclusiveMinimum}.`);if(G?.maximum!==void 0)F.push(`Maximum ${G.maximum}.`);if(G?.exclusiveMaximum!==void 0)F.push(`Less than ${G.exclusiveMaximum}.`)}else if(B.kind==="array"){let G=B.checks;if(G?.minItems!==void 0)F.push(`At least ${G.minItems} items.`);if(G?.maxItems!==void 0)F.push(`At most ${G.maxItems} items.`)}return F.join(" ")}function l(B,F){switch(B.kind){case"string":return{type:"string"};case"number":return{type:B.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof B.value,const:B.value};case"enum":return{type:"string",enum:B.values};case"array":return{type:"array",items:K(B.item,F)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(B.shape).map(([G,H])=>[G,K(H,F)])),required:Object.keys(B.shape),additionalProperties:!1};case"union":return{anyOf:B.members.map((G)=>K(G,F))};case"json":return{};case"ref":{let{cell:G}=B,H=F.cells.get(G.name);if(H&&H!==G)throw Error(`gemi/ai: two different recursive schemas are named "${G.name}" in one schema; give each s.recursive(...) its own name`);if(!H)F.cells.set(G.name,G),F.defs[G.name]={},F.defs[G.name]=K(I(G),F);return{$ref:`#/$defs/${G.name}`}}}}function n(B,F){if(!F)return B;if(B.anyOf)return{...B,anyOf:[...B.anyOf,{type:"null"}]};if(B.enum||B.const!==void 0)return{anyOf:[B,{type:"null"}]};if(typeof B.type==="string")return{...B,type:[B.type,"null"]};return{anyOf:[B,{type:"null"}]}}function i(B){if(B===null)return"null";if(Array.isArray(B))return"array";return typeof B}function s(B,F){if(typeof F==="number"&&!Number.isFinite(F))return String(F);if(B.kind==="literal"||B.kind==="enum"){if(typeof F==="string"||typeof F==="number"||typeof F==="boolean")return JSON.stringify(F)}return i(F)}function d(B){let F=B.node,G=(()=>{switch(F.kind){case"number":return F.checks?.integer?"integer":"number";case"string":case"boolean":return F.kind;case"literal":return JSON.stringify(F.value);case"enum":return`one of ${F.values.map((H)=>JSON.stringify(H)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return d({...I(F.cell),optional:!1,nullable:!1})}})();return B.optional||B.nullable?`${G} or null`:G}function a(B){let F="";for(let G of B)F+=typeof G==="number"?`[${G}]`:F?`.${G}`:G;return F}function e(B){let F=a(B);return F?`${F}: `:""}function p(B){return`${e(B.path)}${B.message}`}function O(B,F){if(F===null||F===void 0)return B.optional||B.nullable?1:0;let G=B.node;switch(G.kind){case"string":return typeof F==="string"?1:0;case"number":return typeof F==="number"?1:0;case"boolean":return typeof F==="boolean"?1:0;case"literal":return F===G.value?10:0;case"enum":return typeof F==="string"&&G.values.includes(F)?10:0;case"array":return Array.isArray(F)?1:0;case"object":{if(typeof F!=="object"||Array.isArray(F))return 0;let H=F,Q=1;for(let[X,$]of Object.entries(G.shape))Q+=O($,H[X]);return Q}case"union":return G.members.reduce((H,Q)=>Math.max(H,O(Q,F)),0);case"json":return 1;case"ref":return m(G.cell,F,()=>1,()=>O(I(G.cell),F))}}function m(B,F,G,H){if(typeof F!=="object"||F===null)return H();if(B.active.has(F))return G();B.active.add(F);try{return H()}finally{B.active.delete(F)}}function R(B,F,G,H){if(B.optional&&(F===null||F===void 0))return{drop:!0,value:void 0};if(B.nullable&&F===null)return{drop:!1,value:null};return{drop:!1,value:BB(B,F,G,H)}}function BB(B,F,G,H){let Q=B.node,X=()=>{let $=F===void 0?"required":Q.kind==="literal"?"const":Q.kind==="enum"&&typeof F==="string"?"enum":"type",M=$==="const"?{allowedValue:Q.value}:$==="enum"?{allowedValues:Q.values}:{};H.push({path:G,code:$,message:`expected ${d(B)}, got ${s(Q,F)}`,params:M});return};switch(Q.kind){case"string":if(typeof F!=="string")return X();return r(Q.checks,F,G,H),F;case"number":if(typeof F!=="number"||!Number.isFinite(F))return X();if(Q.checks?.integer&&!Number.isInteger(F))return X();return GB(Q.checks,F,G,H),F;case"boolean":return typeof F==="boolean"?F:X();case"literal":return F===Q.value?F:X();case"enum":if(typeof F!=="string"||!Q.values.includes(F))return X();return r(Q.checks,F,G,H),F;case"array":{if(!Array.isArray(F))return X();let $=F.map((V,Y)=>{let L=R(Q.item,V,[...G,Y],H);return L.drop?void 0:L.value}),{minItems:M,maxItems:A}=Q.checks??{};if(M!==void 0&&F.length<M)H.push({path:G,code:"minItems",message:`expected at least ${M} items, got ${F.length}`,params:{limit:M}});if(A!==void 0&&F.length>A)H.push({path:G,code:"maxItems",message:`expected at most ${A} items, got ${F.length}`,params:{limit:A}});return $}case"object":{if(typeof F!=="object"||F===null||Array.isArray(F))return X();let $=F,M={};for(let[A,V]of Object.entries(Q.shape)){let Y=R(V,$[A],[...G,A],H);if(!Y.drop)M[A]=Y.value}if(Q.unknownKeys)for(let A of Object.keys($)){if(Object.hasOwn(Q.shape,A)||$[A]===void 0)continue;if(Q.unknownKeys==="error"){H.push({path:[...G,A],code:"additionalProperties",message:"unknown key",params:{additionalProperty:A}});continue}N($[A],[...G,A],H,new Set),Object.defineProperty(M,A,{value:$[A],enumerable:!0,writable:!0,configurable:!0})}return M}case"union":{let $;for(let M of Q.members){let A=[],V=R(M,F,G,A);if(A.length===0)return V.drop?void 0:V.value;let Y=O(M,F);if(!$||Y>$.score)$={issues:A,score:Y}}H.push({path:G,code:"anyOf",message:`no matching variant; closest: ${$.issues.map(p).join("; ")}`,params:{closest:$.issues}});return}case"json":if(F===void 0)return X();return N(F,G,H,new Set),F;case"ref":return m(Q.cell,F,()=>{H.push({path:G,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>R(I(Q.cell),F,G,H).value)}}function FB(B){let F=0;for(let G of B)F++;return F}function r(B,F,G,H){if(!B)return;let{minLength:Q,maxLength:X,format:$}=B;if(Q!==void 0||X!==void 0){let M=FB(F);if(Q!==void 0&&M<Q)H.push({path:G,code:"minLength",message:`expected at least ${Q} characters, got ${M}`,params:{limit:Q}});if(X!==void 0&&M>X)H.push({path:G,code:"maxLength",message:`expected at most ${X} characters, got ${M}`,params:{limit:X}})}if($){let M=!1;try{M=$.test(F)===!0}catch{}if(!M)H.push({path:G,code:"format",message:`expected a string in format "${$.name}"`,params:{format:$.name}})}}function GB(B,F,G,H){if(!B)return;let Q=(X,$,M,A)=>{if($===void 0||M($))return;H.push({path:G,code:X,message:`expected ${A} ${$}, got ${F}`,params:{limit:$}})};Q("minimum",B.minimum,(X)=>F>=X,"at least"),Q("exclusiveMinimum",B.exclusiveMinimum,(X)=>F>X,"more than"),Q("maximum",B.maximum,(X)=>F<=X,"at most"),Q("exclusiveMaximum",B.exclusiveMaximum,(X)=>F<X,"less than")}function N(B,F,G,H,Q=!0){let X=(M)=>{G.push({path:F,code:"type",message:`expected a JSON value, got ${M}`,params:{}})};switch(typeof B){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(B))X(String(B));return;case"bigint":return X("a bigint");case"function":return X("a function");case"symbol":return X("a symbol")}if(B===null)return;let $=B;if(H.has($))return X("a circular reference");H.add($);try{let M=Q?$.toJSON:void 0;if(typeof M==="function"){let A;try{A=M.call($)}catch{return X("a toJSON that threw")}if(A===void 0)return X("a toJSON that returns undefined");return N(A,F,G,H,!1)}if(Array.isArray(B))B.forEach((A,V)=>N(A,[...F,V],G,H));else for(let[A,V]of Object.entries($))N(V,[...F,A],G,H)}finally{H.delete($)}}function D(B){return g(B)}function g(B){let F={toJSONSchema:()=>o(B),parse(G){let H=[],Q=R(B,G,[],H);if(H.length>0)throw Error(H.map(p).join("; "));return Q.drop?void 0:Q.value},safeParse(G){let H=[],Q=R(B,G,[],H);if(H.length>0)return{ok:!1,errors:H.map(p)};return{ok:!0,value:Q.drop?void 0:Q.value}},validate(G){let H=[],Q=R(B,G,[],H);if(H.length>0)return{ok:!1,issues:H};return{ok:!0,value:Q.drop?void 0:Q.value}},describe:(G)=>g({...B,description:G}),optional:()=>g({...B,optional:!0}),nullable:()=>g({...B,nullable:!0,optional:!1})};return k.set(F,B),F}function T(B){return{node:B,optional:!1,nullable:!1}}var h=["strip","error","passthrough"];class u extends Error{problems;constructor(B){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
|
|
3
3
|
${B.map((F)=>`- ${F}`).join(`
|
|
4
4
|
`)}`);this.name="JSONSchemaError",this.problems=B}}var HB=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),E={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function S(B){return typeof B==="object"&&B!==null&&!Array.isArray(B)}function y(B,F,G,H){let Q=(Z,_=G)=>{H.push(_?`${_}: ${Z}`:Z);return},X=(Z)=>G?`${G}.${Z}`:Z;if(!S(B))return Q("expected a schema object");let $=new Set(F.ignoreKeywords??[]),M=(Z)=>HB.has(Z)||Z.startsWith("x-")||$.has(Z),A=!1,V=B.type;if(Array.isArray(V)){let Z=V.filter((_)=>_!=="null");if(Z.length!==1)return Q(`type ${JSON.stringify(V)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,X("type"));A=Z.length<V.length,V=Z[0]}if(V!==void 0&&(typeof V!=="string"||!(V in E)))return Q(`type ${JSON.stringify(V)} is not supported; expected one of ${Object.keys(E).join(", ")}`,X("type"));let Y=new Set(["type","description","enum","const","anyOf",...V?E[V]:[]]),L=!1;for(let Z of Object.keys(B)){if(Y.has(Z)||M(Z))continue;L=!0;let _=Object.entries(E).find(([,z])=>z.includes(Z));Q(_&&_[0]!==V?`"${Z}" applies to type ${_[0]}, and this schema is ${V?`type ${V}`:"untyped"}`:`"${Z}" is not supported by s.fromJSONSchema`,X(Z))}if(L)return;if(B.description!==void 0&&typeof B.description!=="string")return Q("expected a string",X("description"));let w=B.description,U=(Z)=>({node:Z,optional:!1,nullable:A,...w?{description:w}:{}});if(B.anyOf!==void 0){if(V!==void 0||B.enum!==void 0||B.const!==void 0)return Q("anyOf cannot be combined with type, enum or const here",X("anyOf"));if(!Array.isArray(B.anyOf)||B.anyOf.length===0)return Q("expected a non-empty array",X("anyOf"));let Z=[],_=!1;if(B.anyOf.forEach((z,q)=>{if(S(z)&&z.type==="null"&&Object.keys(z).length===1){A=!0;return}let P=y(z,F,X(`anyOf[${q}]`),H);if(P)Z.push(P);else _=!0}),_)return;if(Z.length===0)return Q("anyOf has only null in it",X("anyOf"));if(Z.length===1){let z=Z[0];return{...z,nullable:z.nullable||A,...w?{description:w}:{}}}return U({kind:"union",members:Z})}if(B.const!==void 0){let Z=B.const;if(typeof Z!=="string"&&typeof Z!=="number"&&typeof Z!=="boolean")return Q("only a string, number or boolean const is supported",X("const"));if(V!==void 0&&typeof Z!==(V==="integer"?"number":V))return Q(`const ${JSON.stringify(Z)} is not of type ${V}`,X("const"));return U({kind:"literal",value:Z})}let W;if(V==="string"){if(W=QB(B,F,X,H),W===null)return}if(B.enum!==void 0){if(!Array.isArray(B.enum)||B.enum.length===0)return Q("expected a non-empty array",X("enum"));let Z=B.enum.filter((q)=>q!==null);if(Z.length<B.enum.length)A=!0;let _=Z.find((q)=>!(typeof q==="string"||typeof q==="number"||typeof q==="boolean")||V!==void 0&&typeof q!==(V==="integer"?"number":V));if(_!==void 0||Z.length===0)return Q(V?`every value must be of type ${V}${Z.length===0?", and there must be one":`; ${JSON.stringify(_)} is not`}`:"only strings, numbers and booleans are supported",X("enum"));if(Z.every((q)=>typeof q==="string"))return U({kind:"enum",values:[...new Set(Z)],...W?{checks:W}:{}});let z=[...new Set(Z)];if(z.length===1)return U({kind:"literal",value:z[0]});return U({kind:"union",members:z.map((q)=>T({kind:"literal",value:q}))})}switch(V){case void 0:return Q("a schema needs a type, an enum, a const or an anyOf");case"string":return U({kind:"string",...W?{checks:W}:{}});case"number":case"integer":{let Z=V==="integer"?{integer:!0}:{},_=!1;for(let z of E.number){let q=B[z];if(q===void 0)continue;if(typeof q!=="number"||!Number.isFinite(q)){Q("expected a number",X(z)),_=!0;continue}Z[z]=q}if(_)return;return U({kind:"number",...Object.keys(Z).length>0?{checks:Z}:{}})}case"boolean":return U({kind:"boolean"});case"array":{if(!S(B.items))return Q('an array needs "items" to be one schema (tuples are not supported)',X("items"));let Z={},_=!1;for(let q of["minItems","maxItems"]){let P=B[q];if(P===void 0)continue;if(typeof P!=="number"||!Number.isInteger(P)||P<0){Q("expected a non-negative integer",X(q)),_=!0;continue}Z[q]=P}let z=y(B.items,F,X("items"),H);if(!z||_)return;return U({kind:"array",item:z,...Object.keys(Z).length>0?{checks:Z}:{}})}case"object":{let Z=B.properties??{};if(!S(Z))return Q("expected an object",X("properties"));if(B.additionalProperties!==void 0&&B.additionalProperties!==!1)return Q("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",X("additionalProperties"));let _=B.required??[];if(!Array.isArray(_)||!_.every((C)=>typeof C==="string"))return Q("expected an array of property names",X("required"));let z=_.filter((C)=>!Object.hasOwn(Z,C));if(z.length>0)return Q(`lists properties the schema doesn't have: ${z.join(", ")}`,X("required"));let q={},P=!1;for(let[C,c]of Object.entries(Z)){let f=y(c,F,X(`properties.${C}`),H);if(!f){P=!0;continue}q[C]=_.includes(C)?f:{...f,optional:!0}}if(P)return;let b=F.unknownKeys;return U({kind:"object",shape:q,...b==="error"||b==="passthrough"?{unknownKeys:b}:{}})}}return}function QB(B,F,G,H){let Q={},X=!1;for(let $ of["minLength","maxLength"]){let M=B[$];if(M===void 0)continue;if(typeof M!=="number"||!Number.isInteger(M)||M<0){H.push(`${G($)}: expected a non-negative integer`),X=!0;continue}Q[$]=M}if(B.format!==void 0){let $=B.format,M=typeof $==="string"?F.formats?.[$]:void 0;if(typeof $!=="string")H.push(`${G("format")}: expected a string`),X=!0;else if(!M||!Object.hasOwn(F.formats,$))H.push(`${G("format")}: unknown format ${JSON.stringify($)}; pass a check for it in the formats option`),X=!0;else Q.format={name:$,test:XB(M)}}if(X)return null;return Object.keys(Q).length>0?Q:void 0}function XB(B){if(B===!0)return()=>!0;if(B instanceof RegExp)return(F)=>{return B.lastIndex=0,B.test(F)};return B}var VB={string:()=>D(T({kind:"string"})),number:()=>D(T({kind:"number"})),boolean:()=>D(T({kind:"boolean"})),literal:(B)=>D(T({kind:"literal",value:B})),enum:(B)=>D(T({kind:"enum",values:B})),object:(B)=>D(T({kind:"object",shape:Object.fromEntries(Object.entries(B).map(([F,G])=>[F,x(G)]))})),array:(B)=>D(T({kind:"array",item:x(B)})),union:(B)=>D(T({kind:"union",members:B.map(x)})),json:()=>D(T({kind:"json"})),recursive:$B,fromJSONSchema:(B,F={})=>{let G=[];if(F.unknownKeys!==void 0&&!h.includes(F.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${h.map((Q)=>JSON.stringify(Q)).join(", ")}, got ${JSON.stringify(F.unknownKeys)}`);let H=y(B,F,"",G);if(!H||G.length>0)throw new u(G.length>0?G:["unreadable schema"]);return D(H)}};function AB(B){let F=k.get(B);if(F)return J(F.node);return j(B.toJSONSchema())}function j(B){if(!(B.$ref!==void 0||B.type!==void 0||B.enum!==void 0||B.const!==void 0||B.anyOf!==void 0||B.properties!==void 0||B.items!==void 0))return!1;for(let G of Object.values(B.properties??{}))if(!j(G))return!1;if(B.items&&!j(B.items))return!1;for(let G of B.anyOf??[])if(!j(G))return!1;for(let G of Object.values(B.$defs??{}))if(!j(G))return!1;return!0}function J(B,F=new Set){switch(B.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(B.shape).every((G)=>J(G.node,F));case"array":return J(B.item.node,F);case"union":return B.members.every((G)=>J(G.node,F));case"json":return!1;case"ref":if(F.has(B.cell))return!0;return F.add(B.cell),J(I(B.cell).node,F)}}function v(B,F,G=new Set){let H=B.node;if(H.kind==="union")return H.members.some((Q)=>v(Q,F,G));if(H.kind!=="ref")return!1;if(H.cell===F)return!0;if(G.has(H.cell)||!H.cell.definition)return!1;return G.add(H.cell),v(H.cell.definition,F,G)}var ZB=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function $B(B,F){if(typeof B!=="string"||!ZB.test(B))throw Error(`gemi/ai: s.recursive needs a name of letters, digits, "_" and "-" (starting with a letter or "_", at most 64), got ${JSON.stringify(B)}`);let G={name:B,active:new Set},H=()=>T({kind:"ref",cell:G}),Q=x(F(D(H())));if(Q.optional)throw Error(`gemi/ai: the recursive schema "${B}" is optional() as a whole; mark the places that use it optional instead`);if(v(Q,G))throw Error(`gemi/ai: the recursive schema "${B}" refers to itself outside any object or array, so it describes no finite value; nest \`self\` in an s.object(...) field or an s.array(...)`);return G.definition=Q,D(H())}
|
|
5
|
-
export{MB as
|
|
5
|
+
export{MB as Nj,u as Oj,VB as Pj,AB as Qj};
|
|
6
6
|
|
|
7
|
-
//# debugId=
|
|
7
|
+
//# debugId=112B69F843666D5964756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The schema layer for tool inputs, tool outputs and structured final answers.\n *\n * Two things have to come out of one declaration: a TypeScript type, so\n * `execute(input)` is typed at the call site and the result is typed in the\n * browser, and a JSON Schema, because that is what the model is actually shown.\n * A phantom `Schema<T>` gives the first and nothing of the second, and a\n * hand-written JSON Schema next to a hand-written type gives both and lets them\n * drift. So the builder below is the single source, and `Infer` reads the type\n * back off it.\n *\n * Everything here is deliberately narrower than JSON Schema. OpenAI's strict\n * structured output only accepts a subset — every property listed in\n * `required`, `additionalProperties: false` on every object, no patterns, no\n * `oneOf` at the root — and a builder that cannot express the rejected parts is\n * better than one that lets you write a schema the API refuses at runtime.\n *\n * `json()` is the one deliberate hole in that, for the formats strict mode\n * cannot describe at all: a record with arbitrary keys, a mixed-type tuple. It\n * does not widen the subset — it turns strict mode off for the schema containing\n * it, which `supportsStrict` reads back off the tree so that no caller has to\n * remember to.\n *\n * A document that nests into itself is NOT one of those: strict mode accepts\n * `$defs` + `$ref`, and `recursive()` emits exactly that (#745).\n */\n\nexport type JSONSchema = {\n type?: string | string[];\n description?: string;\n enum?: readonly (string | number)[];\n const?: string | number | boolean;\n properties?: Record<string, JSONSchema>;\n required?: readonly string[];\n additionalProperties?: false;\n items?: JSONSchema;\n anyOf?: readonly JSONSchema[];\n /**\n * `#/$defs/<name>`, pointing at an entry of the root's `$defs`. Emitted by\n * `s.recursive` and never with a sibling keyword: OpenAI's strict mode\n * refuses `{ $ref, description }`, so a described or nullable reference is\n * wrapped in an `anyOf` instead.\n */\n $ref?: string;\n /** Only ever on the root: every `s.recursive` the schema reaches, by name. */\n $defs?: Record<string, JSONSchema>;\n};\n\n/**\n * Any value JSON can carry. The default output type of `json()`, and the\n * annotation an app reaches for when it hands one of those values on.\n */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\ndeclare const OUTPUT: unique symbol;\ndeclare const OPTIONAL: unique symbol;\n\n/**\n * `T` is carried in a phantom property rather than a real one: it exists only\n * for inference, and a real field would show up on the object the app writes.\n */\nexport interface Schema<T> {\n readonly [OUTPUT]: T;\n /** The JSON Schema handed to the provider. */\n toJSONSchema(): JSONSchema;\n /**\n * Parses a value coming back from the model. Tool arguments arrive as a JSON\n * string the model generated, so they are untrusted in exactly the way a\n * request body is: shape-checked before `execute` ever sees them.\n */\n parse(value: unknown): T;\n safeParse(value: unknown): { ok: true; value: T } | { ok: false; errors: string[] };\n}\n\n/**\n * A schema whose key may be left out of the object containing it.\n *\n * Marked with a property rather than detected from the output type, because\n * `undefined extends T` — the obvious test — is true of *everything* when\n * `strictNullChecks` is off, which is how this package and plenty of apps\n * compile. That version made every field of every tool optional, and did it\n * quietly: the JSON Schema was still right, so only the TypeScript types lied.\n */\nexport interface OptionalSchema<T> extends Schema<T | undefined> {\n readonly [OPTIONAL]: true;\n}\n\nexport type AnySchema = Schema<any>;\n\nexport type Infer<S> = S extends Schema<infer T> ? T : never;\n\n/**\n * Collapses a type into one flat object.\n *\n * `ShapeOutput` builds its result as an intersection of two mapped types, one\n * required and one optional, and that intersection is what every hover, every\n * error message and every type assertion would otherwise show. The difference\n * is between an app reading `{ command: string; cwd?: string }` and reading two\n * mapped types joined by an ampersand.\n *\n * It also drops `readonly`, which the mapped types copy from the shape literal\n * — `s.object({ ... })` infers that literal as `const` to keep the keys, and a\n * tool has no reason to receive an immutable input because of how its schema\n * was written down.\n */\ntype Flatten<T> = { -readonly [K in keyof T]: T[K] };\n\ntype ShapeOutput<S extends Record<string, AnySchema>> = Flatten<\n {\n [K in keyof S as S[K] extends OptionalSchema<any> ? never : K]: Infer<S[K]>;\n } & {\n [K in keyof S as S[K] extends OptionalSchema<any> ? K : never]?: Infer<S[K]>;\n }\n>;\n\ninterface SchemaBuilder<T> extends Schema<T> {\n /**\n * The description is not documentation — it is the only prose the model gets\n * about a field, and it is the difference between a tool that is called\n * correctly and one that is not.\n */\n describe(description: string): this;\n /**\n * Strict mode has no notion of an omitted key: every property must appear in\n * `required`. So `optional()` emits a nullable union and the model is told to\n * send `null`, while the TypeScript type says `| undefined` and the parsed\n * value drops the key. The asymmetry is the point — it is what lets an app\n * write ordinary optional fields against an API that forbids them.\n */\n optional(): OptionalSchemaBuilder<T>;\n nullable(): SchemaBuilder<T | null>;\n /**\n * `safeParse` with the failures as structured issues rather than sentences:\n * each one names the path it is about, a JSON Schema keyword as its `code`\n * and the keyword's argument in `params`. For an app that validates a value\n * against a schema itself — a form, a stored record — and wants to word or\n * group the problems per field. All failures are reported, not the first.\n */\n validate(value: unknown): { ok: true; value: T } | { ok: false; issues: SchemaIssue[] };\n}\n\n/**\n * One reason a value failed `validate`.\n *\n * `code` is the JSON Schema keyword the value broke — the same names Ajv puts\n * on its `keyword` — so a mapping written against one reads the other:\n *\n * - `required`: the key is missing (`path` ends in it).\n * - `type`: the wrong kind of value, an integer that isn't whole, or a value\n * that isn't JSON at all.\n * - `const`, `enum`: a literal or a choice that didn't match (`params.allowedValues`).\n * - `minLength`, `maxLength`, `minimum`, `maximum`, `exclusiveMinimum`,\n * `exclusiveMaximum`, `minItems`, `maxItems`: `params.limit` is the bound.\n * - `format`: `params.format` names the format the string failed.\n * - `anyOf`: no union member matched; `message` names the closest one's problems.\n * - `additionalProperties`: a key the object doesn't declare, reported only by\n * a schema built with `s.fromJSONSchema(schema, { unknownKeys: \"error\" })`.\n * `path` ends in the key (Ajv's `instancePath` stops at the object), and\n * `params.additionalProperty` is the key, as in Ajv.\n *\n * `message` is the sentence `safeParse` reports for it, without the path.\n */\nexport type SchemaIssueCode =\n | \"required\"\n | \"type\"\n | \"const\"\n | \"enum\"\n | \"anyOf\"\n | \"minLength\"\n | \"maxLength\"\n | \"minimum\"\n | \"maximum\"\n | \"exclusiveMinimum\"\n | \"exclusiveMaximum\"\n | \"minItems\"\n | \"maxItems\"\n | \"format\"\n | \"additionalProperties\";\n\nexport type SchemaIssue = {\n /** Keys and array indices from the root, `[]` for the root itself. */\n path: (string | number)[];\n code: SchemaIssueCode;\n message: string;\n params: Record<string, unknown>;\n};\n\ninterface OptionalSchemaBuilder<T> extends SchemaBuilder<T | undefined>, OptionalSchema<T> {}\n\n// --- the runtime ---------------------------------------------------------\n\n/**\n * What a builder actually is. `optional` and `nullable` are flags rather than\n * wrapper nodes so that `.nullable().optional()` cannot nest into something\n * whose emitted shape depends on which order they were called in.\n */\ntype Definition = {\n node: SchemaNode;\n description?: string;\n optional: boolean;\n nullable: boolean;\n};\n\n/**\n * The constraints `s.fromJSONSchema` can carry over from a JSON Schema. None of\n * the builders set them; they exist so that a schema read from data validates\n * what it says it does.\n *\n * They are CHECKED, NOT EMITTED as keywords. Strict structured output refuses\n * most of them (`minLength`, `maxLength`, `minimum` on Anthropic; any `format`\n * outside a short list on both), so the model is told them in the field's\n * description instead, and `parse` enforces them — a model that ignores the\n * prose gets an `invalid_tool_input` it can correct, the same as a wrong type.\n */\ntype StringChecks = {\n minLength?: number;\n maxLength?: number;\n format?: { name: string; test: (value: string) => boolean };\n};\n\ntype NumberChecks = {\n integer?: boolean;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n};\n\ntype ArrayChecks = { minItems?: number; maxItems?: number };\n\ntype SchemaNode =\n | { kind: \"string\"; checks?: StringChecks }\n | { kind: \"number\"; checks?: NumberChecks }\n | { kind: \"boolean\" }\n | { kind: \"literal\"; value: string | number | boolean }\n | { kind: \"enum\"; values: readonly string[]; checks?: StringChecks }\n /**\n * `unknownKeys` is what parsing does with a key `shape` doesn't declare:\n * absent is \"strip\", the default and the only thing the builders make. Only\n * `s.fromJSONSchema` sets the others. Emission ignores it: every object is\n * sent with `additionalProperties: false` either way.\n */\n | { kind: \"object\"; shape: Record<string, Definition>; unknownKeys?: \"error\" | \"passthrough\" }\n | { kind: \"array\"; item: Definition; checks?: ArrayChecks }\n | { kind: \"union\"; members: readonly Definition[] }\n /** Constrains nothing. The node strict mode has no spelling for. */\n | { kind: \"json\" }\n /**\n * A use of an `s.recursive` schema — its `self`, or the builder it returned.\n * Emitted as a `$ref` into the root's `$defs`, read by following the cell.\n */\n | { kind: \"ref\"; cell: RecursiveCell };\n\n/**\n * One `s.recursive` declaration. `definition` is filled in once the callback\n * returns; until then `self` is a reference to something that does not exist\n * yet, which is the whole trick.\n *\n * `active` is the set of values being read through this cell right now, the\n * cycle guard for a JavaScript value that contains itself (a tool output an app\n * built). Per cell rather than global, so that one value read through two\n * different recursive schemas in a row is not mistaken for a cycle.\n */\ntype RecursiveCell = {\n name: string;\n definition?: Definition;\n active: Set<object>;\n};\n\nfunction bodyOf(cell: RecursiveCell): Definition {\n if (!cell.definition) {\n throw new Error(\n `gemi/ai: the recursive schema \"${cell.name}\" was used before its definition returned; \\`self\\` can be nested into the schema, but not parsed or emitted inside the callback`,\n );\n }\n return cell.definition;\n}\n\ntype ParseResult = { ok: true; value: unknown } | { ok: false; errors: string[] };\n\ntype Path = (string | number)[];\n\n/** The public interface with the phantoms and the generic taken off. */\ninterface RuntimeSchema {\n toJSONSchema(): JSONSchema;\n parse(value: unknown): unknown;\n safeParse(value: unknown): ParseResult;\n validate(value: unknown): { ok: true; value: unknown } | { ok: false; issues: SchemaIssue[] };\n describe(description: string): RuntimeSchema;\n optional(): RuntimeSchema;\n nullable(): RuntimeSchema;\n}\n\n/**\n * Definitions hang off the builders here rather than on the builders\n * themselves: a property, however obscurely named, is a property an app can\n * see, serialise or accidentally depend on, and `Schema<T>` promises exactly\n * three methods.\n */\nconst definitions = new WeakMap<object, Definition>();\n\n/**\n * Whether `value` is a schema built with `s`. How `HttpRequest` tells an `s`\n * body schema from a map of rules (#711), without a property on the builder.\n */\nexport function isSchema(value: unknown): value is SchemaBuilder<unknown> {\n return typeof value === \"object\" && value !== null && definitions.has(value);\n}\n\nfunction definitionOf(schema: AnySchema): Definition {\n const definition = definitions.get(schema);\n if (!definition) {\n throw new Error(\"gemi/ai: expected a schema built with `s`, got a foreign object\");\n }\n return definition;\n}\n\n// --- emitting ------------------------------------------------------------\n\n/**\n * What one `toJSONSchema()` call collects on its way down: the `$defs` the\n * root will carry, and which cell owns each name in them.\n */\ntype EmitContext = {\n defs: Record<string, JSONSchema>;\n cells: Map<string, RecursiveCell>;\n};\n\n/**\n * The schema as the provider sees it: the tree, plus `$defs` at the root when\n * an `s.recursive` is anywhere in it.\n *\n * A recursive schema used AS the root is inlined there, and its `$defs` entry\n * is a second copy of the same body. Pointing the root at itself with\n * `\"$ref\": \"#\"` would be shorter, and OpenAI accepts it, but `#` means \"the\n * whole document\" — and a document that gets merged into (MCP's\n * `combineSchemas` adds properties to an input's root) would then demand the\n * merged-in fields at every level of the tree.\n */\nfunction emitRoot(definition: Definition): JSONSchema {\n const context: EmitContext = { defs: {}, cells: new Map() };\n let root = definition;\n if (definition.node.kind === \"ref\") {\n const body = bodyOf(definition.node.cell);\n root = {\n ...body,\n ...(definition.description ? { description: definition.description } : {}),\n optional: definition.optional,\n nullable: definition.nullable || body.nullable,\n };\n }\n const schema = emit(root, context);\n return Object.keys(context.defs).length > 0 ? { ...schema, $defs: context.defs } : schema;\n}\n\nfunction emit(definition: Definition, context: EmitContext): JSONSchema {\n // A `json` node already admits every value there is, null included, so\n // widening it would only add an `anyOf` for the model to read past — and one\n // whose second branch is a strictly narrower repeat of its first.\n const widen = (definition.optional || definition.nullable) && definition.node.kind !== \"json\";\n let body = allowNull(emitNode(definition.node, context), widen);\n const description = [definition.description, hint(definition.node)].filter(Boolean).join(\" \");\n // `$ref` takes no siblings under strict mode, so a described reference\n // becomes a one-member `anyOf` that can carry the description beside it.\n if (description && body.$ref !== undefined) body = { anyOf: [body] };\n return description ? { description, ...body } : body;\n}\n\n/**\n * The checks a node carries, in words, for the description — the one place a\n * strict-mode provider lets them through. See `StringChecks`.\n */\nfunction hint(node: SchemaNode): string {\n const said: string[] = [];\n if (node.kind === \"string\" || node.kind === \"enum\") {\n const checks = node.checks;\n if (checks?.format) said.push(`Format: ${checks.format.name}.`);\n if (checks?.minLength !== undefined) said.push(`At least ${checks.minLength} characters.`);\n if (checks?.maxLength !== undefined) said.push(`At most ${checks.maxLength} characters.`);\n } else if (node.kind === \"number\") {\n const checks = node.checks;\n if (checks?.minimum !== undefined) said.push(`Minimum ${checks.minimum}.`);\n if (checks?.exclusiveMinimum !== undefined) {\n said.push(`Greater than ${checks.exclusiveMinimum}.`);\n }\n if (checks?.maximum !== undefined) said.push(`Maximum ${checks.maximum}.`);\n if (checks?.exclusiveMaximum !== undefined) said.push(`Less than ${checks.exclusiveMaximum}.`);\n } else if (node.kind === \"array\") {\n const checks = node.checks;\n if (checks?.minItems !== undefined) said.push(`At least ${checks.minItems} items.`);\n if (checks?.maxItems !== undefined) said.push(`At most ${checks.maxItems} items.`);\n }\n // A `ref` says nothing of its own: its body's hints are in its `$defs` entry.\n return said.join(\" \");\n}\n\nfunction emitNode(node: SchemaNode, context: EmitContext): JSONSchema {\n switch (node.kind) {\n case \"string\":\n return { type: \"string\" };\n case \"number\":\n // `integer` is in the strict subset of every provider gemi speaks to.\n return { type: node.checks?.integer ? \"integer\" : \"number\" };\n case \"boolean\":\n return { type: \"boolean\" };\n // `const` rather than a one-member `enum`, because a boolean literal has no\n // `enum` form and one branch that works for all three beats two that\n // disagree about what a literal is.\n case \"literal\":\n return { type: typeof node.value, const: node.value };\n case \"enum\":\n return { type: \"string\", enum: node.values };\n case \"array\":\n return { type: \"array\", items: emit(node.item, context) };\n case \"object\":\n return {\n type: \"object\",\n properties: Object.fromEntries(\n Object.entries(node.shape).map(([key, child]) => [key, emit(child, context)]),\n ),\n // Every declared property, optional ones included. This is the whole of\n // strict mode's bargain: the model is never allowed to omit a key, so\n // \"may be absent\" has to be spelled as \"may be null\" instead.\n required: Object.keys(node.shape),\n additionalProperties: false,\n };\n case \"union\":\n return { anyOf: node.members.map((member) => emit(member, context)) };\n // The empty schema, which is JSON Schema's own way of saying \"any value\" —\n // no `type` listing all seven, which reads as a constraint the model then\n // has to check itself. What the field actually is gets said in\n // `description`, the one channel a model reads either way.\n case \"json\":\n return {};\n case \"ref\": {\n const { cell } = node;\n const owner = context.cells.get(cell.name);\n if (owner && owner !== cell) {\n throw new Error(\n `gemi/ai: two different recursive schemas are named \"${cell.name}\" in one schema; give each s.recursive(...) its own name`,\n );\n }\n if (!owner) {\n // Claimed BEFORE the body is emitted: the body refers to itself, and\n // that inner reference has to find the name taken and stop here.\n context.cells.set(cell.name, cell);\n context.defs[cell.name] = {};\n context.defs[cell.name] = emit(bodyOf(cell), context);\n }\n return { $ref: `#/$defs/${cell.name}` };\n }\n }\n}\n\n/**\n * Widens a schema to admit `null` — for a `nullable()` field, and for the null\n * an `optional()` field tells the model to send in place of omitting the key.\n */\nfunction allowNull(base: JSONSchema, on: boolean): JSONSchema {\n if (!on) return base;\n // A union is already a list of alternatives; appending to it is flatter than\n // nesting an `anyOf` inside an `anyOf`, and reads the same to the model.\n if (base.anyOf) return { ...base, anyOf: [...base.anyOf, { type: \"null\" }] };\n // `enum` and `const` cannot carry the null themselves — `enum` here is\n // strings and numbers by declaration — so those get wrapped rather than\n // widened.\n if (base.enum || base.const !== undefined) return { anyOf: [base, { type: \"null\" }] };\n if (typeof base.type === \"string\") return { ...base, type: [base.type, \"null\"] };\n return { anyOf: [base, { type: \"null\" }] };\n}\n\n// --- parsing -------------------------------------------------------------\n\nfunction typeName(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\n/**\n * What the value looked like. For a literal or an enum the *type* is usually\n * right and the value is wrong, and \"expected \\\"refund\\\", got string\" tells\n * whoever is reading the failed tool call nothing they did not know.\n */\nfunction saw(node: SchemaNode, value: unknown): string {\n if (typeof value === \"number\" && !Number.isFinite(value)) return String(value);\n if (node.kind === \"literal\" || node.kind === \"enum\") {\n const primitive =\n typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n if (primitive) return JSON.stringify(value);\n }\n return typeName(value);\n}\n\nfunction wanted(definition: Definition): string {\n const node = definition.node;\n const base = (() => {\n switch (node.kind) {\n case \"number\":\n return node.checks?.integer ? \"integer\" : \"number\";\n case \"string\":\n case \"boolean\":\n return node.kind;\n case \"literal\":\n return JSON.stringify(node.value);\n case \"enum\":\n return `one of ${node.values.map((v) => JSON.stringify(v)).join(\" | \")}`;\n case \"array\":\n return \"array\";\n case \"object\":\n return \"object\";\n case \"union\":\n return \"one of the variants\";\n case \"json\":\n return \"a JSON value\";\n case \"ref\":\n return wanted({ ...bodyOf(node.cell), optional: false, nullable: false });\n }\n })();\n return definition.optional || definition.nullable ? `${base} or null` : base;\n}\n\n/** `orders[2].total` — keys joined with dots, indices in brackets. */\nfunction formatPath(path: Path): string {\n let out = \"\";\n for (const segment of path) {\n out += typeof segment === \"number\" ? `[${segment}]` : out ? `.${segment}` : segment;\n }\n return out;\n}\n\n/** `orders[2].total: ` — empty at the root, where a prefix would be noise. */\nfunction at(path: Path): string {\n const text = formatPath(path);\n return text ? `${text}: ` : \"\";\n}\n\n/** The sentence `safeParse` reports for an issue. */\nfunction render(issue: SchemaIssue): string {\n return `${at(issue.path)}${issue.message}`;\n}\n\n/**\n * How well a value matches, used only to pick which union variant to blame.\n * A literal or an enum hit counts for far more than an ordinary field, because\n * that is what a discriminated union turns on: the variant whose `kind` matched\n * is the one the model meant, whatever else it got wrong.\n */\nfunction score(definition: Definition, value: unknown): number {\n if (value === null || value === undefined) {\n return definition.optional || definition.nullable ? 1 : 0;\n }\n const node = definition.node;\n switch (node.kind) {\n case \"string\":\n return typeof value === \"string\" ? 1 : 0;\n case \"number\":\n return typeof value === \"number\" ? 1 : 0;\n case \"boolean\":\n return typeof value === \"boolean\" ? 1 : 0;\n case \"literal\":\n return value === node.value ? 10 : 0;\n case \"enum\":\n return typeof value === \"string\" && node.values.includes(value) ? 10 : 0;\n case \"array\":\n return Array.isArray(value) ? 1 : 0;\n case \"object\": {\n if (typeof value !== \"object\" || Array.isArray(value)) return 0;\n const source = value as Record<string, unknown>;\n let total = 1;\n for (const [key, child] of Object.entries(node.shape)) {\n total += score(child, source[key]);\n }\n return total;\n }\n case \"union\":\n return node.members.reduce((best, member) => Math.max(best, score(member, value)), 0);\n // Matches, because it matches everything — but at the score of a plain\n // scalar, so a sibling variant that pinned its discriminant still wins the\n // blame.\n //\n // Reached only when no member parsed, which for a `json` member means the\n // value is not JSON at all: a function, a bigint, a cycle. Then this is\n // what makes the report name the reason the value was refused rather than\n // the discriminant of a variant the model was never aiming at.\n case \"json\":\n return 1;\n case \"ref\":\n return through(\n node.cell,\n value,\n () => 1,\n () => score(bodyOf(node.cell), value),\n );\n }\n}\n\n/**\n * Runs `walk` with `value` marked as being read through `cell`, or `cycle` when\n * it already is. A value can only meet the same cell again further down by\n * containing itself — `s.recursive` refuses a body that reaches `self` without\n * an object or array in between — so this is exactly the cycle guard, and a\n * value that merely appears twice side by side is read twice.\n */\nfunction through<R>(cell: RecursiveCell, value: unknown, cycle: () => R, walk: () => R): R {\n if (typeof value !== \"object\" || value === null) return walk();\n if (cell.active.has(value)) return cycle();\n cell.active.add(value);\n try {\n return walk();\n } finally {\n cell.active.delete(value);\n }\n}\n\n/** `drop` is a key that should not appear in the parsed object at all. */\ntype Reading = { drop: boolean; value: unknown };\n\nfunction read(definition: Definition, value: unknown, path: Path, issues: SchemaIssue[]): Reading {\n // `optional` is checked before `nullable`, so a schema that is both treats\n // null as \"absent\". They are not distinguishable on the wire: strict mode\n // gives the model one spelling for \"nothing\", and pretending otherwise would\n // mean `.nullable().optional()` silently kept a key the type says is\n // optional. What that trades away is the ability to say \"present and null\" on\n // a field that may also be absent — a distinction no model can express here.\n if (definition.optional && (value === null || value === undefined)) {\n return { drop: true, value: undefined };\n }\n if (definition.nullable && value === null) return { drop: false, value: null };\n return { drop: false, value: readNode(definition, value, path, issues) };\n}\n\nfunction readNode(\n definition: Definition,\n value: unknown,\n path: Path,\n issues: SchemaIssue[],\n): unknown {\n const node = definition.node;\n const fail = () => {\n const code: SchemaIssueCode =\n value === undefined\n ? \"required\"\n : node.kind === \"literal\"\n ? \"const\"\n : node.kind === \"enum\" && typeof value === \"string\"\n ? \"enum\"\n : \"type\";\n const params =\n code === \"const\"\n ? { allowedValue: (node as { value: unknown }).value }\n : code === \"enum\"\n ? { allowedValues: (node as { values: readonly string[] }).values }\n : {};\n issues.push({\n path,\n code,\n message: `expected ${wanted(definition)}, got ${saw(node, value)}`,\n params,\n });\n return undefined;\n };\n\n switch (node.kind) {\n case \"string\":\n if (typeof value !== \"string\") return fail();\n checkString(node.checks, value, path, issues);\n return value;\n case \"number\":\n // NaN and Infinity do not survive `JSON.stringify`, so a tool that\n // returns one produces a body the provider cannot be sent.\n if (typeof value !== \"number\" || !Number.isFinite(value)) return fail();\n if (node.checks?.integer && !Number.isInteger(value)) return fail();\n checkNumber(node.checks, value, path, issues);\n return value;\n case \"boolean\":\n return typeof value === \"boolean\" ? value : fail();\n case \"literal\":\n return value === node.value ? value : fail();\n case \"enum\":\n if (typeof value !== \"string\" || !node.values.includes(value)) return fail();\n checkString(node.checks, value, path, issues);\n return value;\n case \"array\": {\n if (!Array.isArray(value)) return fail();\n const items = value.map((item, index) => {\n const element = read(node.item, item, [...path, index], issues);\n return element.drop ? undefined : element.value;\n });\n const { minItems, maxItems } = node.checks ?? {};\n if (minItems !== undefined && value.length < minItems) {\n issues.push({\n path,\n code: \"minItems\",\n message: `expected at least ${minItems} items, got ${value.length}`,\n params: { limit: minItems },\n });\n }\n if (maxItems !== undefined && value.length > maxItems) {\n issues.push({\n path,\n code: \"maxItems\",\n message: `expected at most ${maxItems} items, got ${value.length}`,\n params: { limit: maxItems },\n });\n }\n return items;\n }\n case \"object\": {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return fail();\n const source = value as Record<string, unknown>;\n const output: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(node.shape)) {\n const element = read(child, source[key], [...path, key], issues);\n if (!element.drop) output[key] = element.value;\n }\n // By default unknown keys are DROPPED, not rejected. `additionalProperties:\n // false` has already told the model not to send them, so one arriving\n // anyway is a slip rather than an attack, and failing a whole tool call\n // over a stray field costs a turn to fix nothing. Dropping is also what\n // keeps `execute` from ever seeing a field its input type says cannot be\n // there.\n //\n // A schema read from data can ask otherwise (#753): a form submission\n // with a field the form doesn't have is a bot or a stale page, and\n // dropping it loses what the visitor typed without telling them.\n if (node.unknownKeys) {\n for (const key of Object.keys(source)) {\n // `undefined` is absent, the same as for `required`: JSON cannot\n // carry it, and `JSON.stringify` leaves the key out.\n if (Object.hasOwn(node.shape, key) || source[key] === undefined) continue;\n if (node.unknownKeys === \"error\") {\n issues.push({\n path: [...path, key],\n code: \"additionalProperties\",\n message: \"unknown key\",\n params: { additionalProperty: key },\n });\n continue;\n }\n // Kept as it came, checked only for being JSON — there is no schema\n // to read it with. Defined rather than assigned, so that a\n // `__proto__` key from `JSON.parse` stays a key instead of setting\n // the output's prototype.\n checkJson(source[key], [...path, key], issues, new Set());\n Object.defineProperty(output, key, {\n value: source[key],\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n }\n return output;\n }\n case \"union\": {\n let best: { issues: SchemaIssue[]; score: number } | undefined;\n for (const member of node.members) {\n const attempt: SchemaIssue[] = [];\n const element = read(member, value, path, attempt);\n if (attempt.length === 0) return element.drop ? undefined : element.value;\n const points = score(member, value);\n if (!best || points > best.score) best = { issues: attempt, score: points };\n }\n // \"no match\" is useless when one field of a five-field variant was wrong.\n // Naming the closest variant and why it stopped is the difference between\n // a debuggable bad tool call and a shrug.\n issues.push({\n path,\n code: \"anyOf\",\n message: `no matching variant; closest: ${best!.issues.map(render).join(\"; \")}`,\n params: { closest: best!.issues },\n });\n return undefined;\n }\n // Passed through by reference, not rebuilt. Two reasons beyond the obvious\n // one: a rebuild would turn a `Date` into `{}` by copying own properties\n // that a `toJSON` was going to replace anyway, and the agent loop signs the\n // *parsed* input and later verifies the signature against it — a parse that\n // is exactly the identity cannot disagree with itself.\n case \"json\":\n if (value === undefined) return fail();\n checkJson(value, path, issues, new Set());\n return value;\n // The reference's own `optional`/`nullable` were settled by `read` above;\n // the body's are its own business, settled by the `read` below.\n case \"ref\":\n return through(\n node.cell,\n value,\n () => {\n issues.push({\n path,\n code: \"type\",\n message: \"expected a finite tree, got a circular reference\",\n params: {},\n });\n return undefined;\n },\n () => read(bodyOf(node.cell), value, path, issues).value,\n );\n }\n}\n\n/**\n * Length in code points, not UTF-16 units — what JSON Schema (and Ajv) count,\n * so an emoji is one character against a `maxLength` either way.\n */\nfunction length(value: string): number {\n let count = 0;\n for (const _ of value) count++;\n return count;\n}\n\nfunction checkString(\n checks: StringChecks | undefined,\n value: string,\n path: Path,\n issues: SchemaIssue[],\n): void {\n if (!checks) return;\n const { minLength, maxLength, format } = checks;\n if (minLength !== undefined || maxLength !== undefined) {\n const size = length(value);\n if (minLength !== undefined && size < minLength) {\n issues.push({\n path,\n code: \"minLength\",\n message: `expected at least ${minLength} characters, got ${size}`,\n params: { limit: minLength },\n });\n }\n if (maxLength !== undefined && size > maxLength) {\n issues.push({\n path,\n code: \"maxLength\",\n message: `expected at most ${maxLength} characters, got ${size}`,\n params: { limit: maxLength },\n });\n }\n }\n if (format) {\n let ok = false;\n try {\n ok = format.test(value) === true;\n } catch {\n // A check that throws has not said yes.\n }\n if (!ok) {\n issues.push({\n path,\n code: \"format\",\n message: `expected a string in format \"${format.name}\"`,\n params: { format: format.name },\n });\n }\n }\n}\n\nfunction checkNumber(\n checks: NumberChecks | undefined,\n value: number,\n path: Path,\n issues: SchemaIssue[],\n): void {\n if (!checks) return;\n const bound = (\n code: SchemaIssueCode,\n limit: number | undefined,\n passes: (limit: number) => boolean,\n words: string,\n ) => {\n if (limit === undefined || passes(limit)) return;\n issues.push({\n path,\n code,\n message: `expected ${words} ${limit}, got ${value}`,\n params: { limit },\n });\n };\n bound(\"minimum\", checks.minimum, (limit) => value >= limit, \"at least\");\n bound(\"exclusiveMinimum\", checks.exclusiveMinimum, (limit) => value > limit, \"more than\");\n bound(\"maximum\", checks.maximum, (limit) => value <= limit, \"at most\");\n bound(\"exclusiveMaximum\", checks.exclusiveMaximum, (limit) => value < limit, \"less than\");\n}\n\n/**\n * Checks that a value is JSON, which is the only check a `json()` node makes.\n *\n * Tool arguments arrive through `JSON.parse`, so this never fires on model\n * input. It fires on a tool *output* or a structured answer an app built, where\n * a `bigint` or a cycle throws inside `JSON.stringify` and a function or a\n * `symbol` is dropped without a word — one turn later, with the provider's\n * request body to debug instead of the value.\n *\n * `undefined` and non-plain objects are deliberately allowed below the root:\n * `JSON.stringify` drops an `undefined` property, writes `null` for an\n * `undefined` element, and calls `toJSON` where there is one. Those are JSON's\n * own answers, and rejecting a `Date` to catch a `Map` is a bad trade.\n *\n * `toJSON` is honoured rather than assumed harmless: the walk checks what it\n * returns and never the object behind it, because that is all `JSON.stringify`\n * will look at.\n */\nfunction checkJson(\n value: unknown,\n path: Path,\n issues: SchemaIssue[],\n seen: Set<object>,\n // False for the value a `toJSON` just returned: `JSON.stringify` applies\n // `toJSON` once per position, and re-applying it is how a pair of them\n // returning each other became an infinite loop.\n applyToJSON = true,\n): void {\n const reject = (what: string) => {\n issues.push({ path, code: \"type\", message: `expected a JSON value, got ${what}`, params: {} });\n };\n\n switch (typeof value) {\n case \"undefined\":\n case \"string\":\n case \"boolean\":\n return;\n case \"number\":\n if (!Number.isFinite(value)) reject(String(value));\n return;\n case \"bigint\":\n return reject(\"a bigint\");\n case \"function\":\n return reject(\"a function\");\n case \"symbol\":\n return reject(\"a symbol\");\n }\n\n if (value === null) return;\n const object = value as object;\n\n // The cycle guard comes FIRST, above `toJSON`, and that ordering is the whole\n // of it: a `toJSON` is arbitrary code that can hand back another object with a\n // `toJSON` of its own, so two of them returning each other is a cycle that\n // `seen` catches and an identity test cannot. Below the guard, that pair hung\n // `safeParse` forever — and a `toJSON` returning a fresh object each time threw\n // `RangeError` out of a function documented to return `{ ok: false, errors }`.\n if (seen.has(object)) return reject(\"a circular reference\");\n seen.add(object);\n try {\n // `JSON.stringify` asks `toJSON` what to write and never looks at the object\n // itself, so that answer is what has to be checked. Without this the walk\n // descended into the wrapper's own fields and refused values `stringify`\n // serializes without complaint — a `toJSON` returning a string off a `bigint`\n // field being the archetype, since writing a `toJSON` is exactly what one\n // does about a field JSON cannot carry. `Date` passed only by having no own\n // enumerable properties to trip over.\n const toJSON = applyToJSON ? (object as { toJSON?: unknown }).toJSON : undefined;\n if (typeof toJSON === \"function\") {\n let replaced: unknown;\n try {\n replaced = (toJSON as (key?: string) => unknown).call(object);\n } catch {\n return reject(\"a toJSON that threw\");\n }\n // `JSON.stringify` applies `toJSON` once per value position, not until it\n // stops changing, so the replacement is checked with it switched off here\n // — its nested values get their own.\n if (replaced === undefined) return reject(\"a toJSON that returns undefined\");\n return checkJson(replaced, path, issues, seen, false);\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => checkJson(item, [...path, index], issues, seen));\n } else {\n for (const [key, child] of Object.entries(object)) {\n checkJson(child, [...path, key], issues, seen);\n }\n }\n } finally {\n // Removed rather than left in: `seen` is the path currently being walked, and\n // keeping it would call the same object appearing twice side by side — which\n // `JSON.stringify` writes out twice quite happily — a cycle. In a `finally`\n // so the `toJSON` returns above cannot leave it marked.\n seen.delete(object);\n }\n}\n\n/**\n * The one cast in this file, and the reason it has to exist: `OUTPUT` and\n * `OPTIONAL` are `declare const` unique symbols. They have no runtime\n * counterpart — they are inference channels — so no object that can actually be\n * constructed satisfies `Schema<T>` structurally. Funnelling every builder\n * through here means the lie is told once, in one place, and everything else in\n * the module is checked against the real declarations.\n */\nfunction make<T>(definition: Definition): SchemaBuilder<T> {\n return build(definition) as unknown as SchemaBuilder<T>;\n}\n\n/**\n * Builders are immutable: `describe`, `optional` and `nullable` each build a\n * fresh one from a copied definition. Mutating in place is the obvious\n * implementation and it is wrong — `const id = s.string()` reused in two\n * objects, described in one of them, would carry that description into the\n * other, and the only symptom is a model being told the wrong thing about a\n * field somewhere else.\n */\nfunction build(definition: Definition): RuntimeSchema {\n const runtime: RuntimeSchema = {\n toJSONSchema: () => emitRoot(definition),\n parse(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) throw new Error(issues.map(render).join(\"; \"));\n return result.drop ? undefined : result.value;\n },\n safeParse(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) return { ok: false, errors: issues.map(render) };\n return { ok: true, value: result.drop ? undefined : result.value };\n },\n validate(value) {\n const issues: SchemaIssue[] = [];\n const result = read(definition, value, [], issues);\n if (issues.length > 0) return { ok: false, issues };\n return { ok: true, value: result.drop ? undefined : result.value };\n },\n describe: (description) => build({ ...definition, description }),\n optional: () => build({ ...definition, optional: true }),\n // Clearing `optional` is not tidiness. `nullable()` returns a\n // `SchemaBuilder`, not an `OptionalSchemaBuilder`, so the key it describes\n // is required again in `ShapeOutput` — and a parse that still dropped it\n // would hand back an object missing a key its own type declares.\n nullable: () => build({ ...definition, nullable: true, optional: false }),\n };\n definitions.set(runtime, definition);\n return runtime;\n}\n\nfunction leaf(node: SchemaNode): Definition {\n return { node, optional: false, nullable: false };\n}\n\n// --- reading a JSON Schema ---------------------------------------------------\n\n/**\n * How `s.fromJSONSchema` checks a `format`. `true` accepts any string (a format\n * that is only a hint, like `markdown`); a `RegExp` or a function decides.\n */\nexport type JSONSchemaFormat = true | RegExp | ((value: string) => boolean);\n\nexport type FromJSONSchemaOptions = {\n /**\n * The formats the schema may name. A `format` not listed here is refused, not\n * ignored: gemi ships no format checks of its own, and a format that quietly\n * checked nothing would be a constraint that only looks enforced.\n */\n formats?: Record<string, JSONSchemaFormat>;\n /**\n * Keywords to skip as annotations, on top of the ones always skipped:\n * `title`, `$schema`, `$id`, `$comment`, `examples`, `default`,\n * `deprecated`, `readOnly`, `writeOnly`, and every `x-` keyword.\n */\n ignoreKeywords?: readonly string[];\n /**\n * What `parse`, `safeParse` and `validate` do with a key an object of the\n * schema doesn't declare, at every depth:\n *\n * - `\"strip\"` (the default): drop it from the parsed value, silently.\n * - `\"error\"`: fail with an `additionalProperties` issue whose `path` ends in\n * the key and whose `params.additionalProperty` is the key.\n * - `\"passthrough\"`: keep it in the parsed value as it came (it is only\n * checked for being JSON).\n *\n * Every object is closed in `s`, so this applies whether or not the object\n * says `additionalProperties: false`, and the emitted schema still says\n * `additionalProperties: false` (strict mode requires it). It applies to\n * this schema's objects only: an `s.object` it is nested into keeps\n * stripping.\n */\n unknownKeys?: \"strip\" | \"error\" | \"passthrough\";\n};\n\nconst UNKNOWN_KEYS = [\"strip\", \"error\", \"passthrough\"] as const;\n\n/**\n * Thrown by `s.fromJSONSchema` for a schema outside the subset `s` models.\n * `problems` lists every one found, each starting with the path into the\n * schema (`properties.price.type: ...`), so a schema written by a user or a\n * model can be sent back with all of them at once.\n */\nexport class JSONSchemaError extends Error {\n readonly problems: string[];\n constructor(problems: string[]) {\n super(\n `gemi/ai: s.fromJSONSchema cannot model this schema:\\n${problems.map((p) => `- ${p}`).join(\"\\n\")}`,\n );\n this.name = \"JSONSchemaError\";\n this.problems = problems;\n }\n}\n\nconst ANNOTATIONS = new Set([\n \"title\",\n \"$schema\",\n \"$id\",\n \"$comment\",\n \"examples\",\n \"default\",\n \"deprecated\",\n \"readOnly\",\n \"writeOnly\",\n]);\n\n/** The keywords each type may carry, beyond `type`, `description`, `enum` and `const`. */\nconst KEYWORDS: Record<string, readonly string[]> = {\n string: [\"minLength\", \"maxLength\", \"format\"],\n number: [\"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\"],\n integer: [\"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\"],\n boolean: [],\n object: [\"properties\", \"required\", \"additionalProperties\"],\n array: [\"items\", \"minItems\", \"maxItems\"],\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Reads a JSON Schema into a definition, collecting every problem rather than\n * stopping at the first. Returns `undefined` where a node could not be read;\n * the caller throws once the walk is done.\n */\nfunction fromJSON(\n schema: unknown,\n options: FromJSONSchemaOptions,\n where: string,\n problems: string[],\n): Definition | undefined {\n const problem = (message: string, at = where) => {\n problems.push(at ? `${at}: ${message}` : message);\n return undefined;\n };\n const child = (key: string) => (where ? `${where}.${key}` : key);\n if (!isPlainObject(schema)) return problem(\"expected a schema object\");\n\n const ignored = new Set(options.ignoreKeywords ?? []);\n const skip = (key: string) => ANNOTATIONS.has(key) || key.startsWith(\"x-\") || ignored.has(key);\n\n // `type: [T, \"null\"]`, `enum` with a null in it and an `anyOf` with a\n // `{ type: \"null\" }` member all mean the same: T, nullable.\n let nullable = false;\n let type = schema.type;\n if (Array.isArray(type)) {\n const rest = type.filter((t) => t !== \"null\");\n if (rest.length !== 1) {\n return problem(\n `type ${JSON.stringify(type)} is not supported; only one type, optionally with \"null\". Use anyOf for alternatives`,\n child(\"type\"),\n );\n }\n nullable = rest.length < type.length;\n type = rest[0];\n }\n if (type !== undefined && (typeof type !== \"string\" || !(type in KEYWORDS))) {\n return problem(\n `type ${JSON.stringify(type)} is not supported; expected one of ${Object.keys(KEYWORDS).join(\", \")}`,\n child(\"type\"),\n );\n }\n\n const allowed = new Set([\n \"type\",\n \"description\",\n \"enum\",\n \"const\",\n \"anyOf\",\n ...(type ? KEYWORDS[type as string] : []),\n ]);\n let unknown = false;\n for (const key of Object.keys(schema)) {\n if (allowed.has(key) || skip(key)) continue;\n unknown = true;\n const owner = Object.entries(KEYWORDS).find(([, keys]) => keys.includes(key));\n problem(\n owner && owner[0] !== type\n ? `\"${key}\" applies to type ${owner[0]}, and this schema is ${type ? `type ${type}` : \"untyped\"}`\n : `\"${key}\" is not supported by s.fromJSONSchema`,\n child(key),\n );\n }\n if (unknown) return undefined;\n\n if (schema.description !== undefined && typeof schema.description !== \"string\") {\n return problem(\"expected a string\", child(\"description\"));\n }\n const description = schema.description as string | undefined;\n const finish = (node: SchemaNode): Definition => ({\n node,\n optional: false,\n nullable,\n ...(description ? { description } : {}),\n });\n\n if (schema.anyOf !== undefined) {\n if (type !== undefined || schema.enum !== undefined || schema.const !== undefined) {\n return problem(\"anyOf cannot be combined with type, enum or const here\", child(\"anyOf\"));\n }\n if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {\n return problem(\"expected a non-empty array\", child(\"anyOf\"));\n }\n const members: Definition[] = [];\n let failed = false;\n schema.anyOf.forEach((member, index) => {\n if (isPlainObject(member) && member.type === \"null\" && Object.keys(member).length === 1) {\n nullable = true;\n return;\n }\n const read = fromJSON(member, options, child(`anyOf[${index}]`), problems);\n if (read) members.push(read);\n else failed = true;\n });\n if (failed) return undefined;\n if (members.length === 0) return problem(\"anyOf has only null in it\", child(\"anyOf\"));\n if (members.length === 1) {\n const only = members[0]!;\n return {\n ...only,\n nullable: only.nullable || nullable,\n ...(description ? { description } : {}),\n };\n }\n return finish({ kind: \"union\", members });\n }\n\n if (schema.const !== undefined) {\n const value = schema.const;\n if (typeof value !== \"string\" && typeof value !== \"number\" && typeof value !== \"boolean\") {\n return problem(\"only a string, number or boolean const is supported\", child(\"const\"));\n }\n if (type !== undefined && typeof value !== (type === \"integer\" ? \"number\" : type)) {\n return problem(`const ${JSON.stringify(value)} is not of type ${type}`, child(\"const\"));\n }\n return finish({ kind: \"literal\", value });\n }\n\n let stringChecks: StringChecks | undefined;\n if (type === \"string\") {\n stringChecks = readStringChecks(schema, options, child, problems);\n if (stringChecks === null) return undefined;\n }\n\n if (schema.enum !== undefined) {\n if (!Array.isArray(schema.enum) || schema.enum.length === 0) {\n return problem(\"expected a non-empty array\", child(\"enum\"));\n }\n const values = schema.enum.filter((value) => value !== null);\n if (values.length < schema.enum.length) nullable = true;\n const bad = values.find(\n (value) =>\n !(typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") ||\n (type !== undefined && typeof value !== (type === \"integer\" ? \"number\" : type)),\n );\n if (bad !== undefined || values.length === 0) {\n return problem(\n type\n ? `every value must be of type ${type}${values.length === 0 ? \", and there must be one\" : `; ${JSON.stringify(bad)} is not`}`\n : \"only strings, numbers and booleans are supported\",\n child(\"enum\"),\n );\n }\n if (values.every((value) => typeof value === \"string\")) {\n return finish({\n kind: \"enum\",\n values: [...new Set(values as string[])],\n ...(stringChecks ? { checks: stringChecks } : {}),\n });\n }\n const literals = [...new Set(values as (string | number | boolean)[])];\n if (literals.length === 1) return finish({ kind: \"literal\", value: literals[0]! });\n return finish({\n kind: \"union\",\n members: literals.map((value) => leaf({ kind: \"literal\", value })),\n });\n }\n\n switch (type) {\n case undefined:\n return problem(\"a schema needs a type, an enum, a const or an anyOf\");\n case \"string\":\n return finish({ kind: \"string\", ...(stringChecks ? { checks: stringChecks } : {}) });\n case \"number\":\n case \"integer\": {\n const checks: NumberChecks = type === \"integer\" ? { integer: true } : {};\n let failed = false;\n for (const key of KEYWORDS.number!) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n problem(\"expected a number\", child(key));\n failed = true;\n continue;\n }\n checks[key as \"minimum\"] = value;\n }\n if (failed) return undefined;\n return finish({ kind: \"number\", ...(Object.keys(checks).length > 0 ? { checks } : {}) });\n }\n case \"boolean\":\n return finish({ kind: \"boolean\" });\n case \"array\": {\n if (!isPlainObject(schema.items)) {\n return problem(\n 'an array needs \"items\" to be one schema (tuples are not supported)',\n child(\"items\"),\n );\n }\n const checks: ArrayChecks = {};\n let failed = false;\n for (const key of [\"minItems\", \"maxItems\"] as const) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < 0) {\n problem(\"expected a non-negative integer\", child(key));\n failed = true;\n continue;\n }\n checks[key] = value;\n }\n const item = fromJSON(schema.items, options, child(\"items\"), problems);\n if (!item || failed) return undefined;\n return finish({ kind: \"array\", item, ...(Object.keys(checks).length > 0 ? { checks } : {}) });\n }\n case \"object\": {\n const properties = schema.properties ?? {};\n if (!isPlainObject(properties)) return problem(\"expected an object\", child(\"properties\"));\n if (schema.additionalProperties !== undefined && schema.additionalProperties !== false) {\n return problem(\n \"only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())\",\n child(\"additionalProperties\"),\n );\n }\n const required = schema.required ?? [];\n if (!Array.isArray(required) || !required.every((key) => typeof key === \"string\")) {\n return problem(\"expected an array of property names\", child(\"required\"));\n }\n const missing = required.filter((key) => !Object.hasOwn(properties, key));\n if (missing.length > 0) {\n return problem(\n `lists properties the schema doesn't have: ${missing.join(\", \")}`,\n child(\"required\"),\n );\n }\n const shape: Record<string, Definition> = {};\n let failed = false;\n for (const [key, value] of Object.entries(properties)) {\n const read = fromJSON(value, options, child(`properties.${key}`), problems);\n if (!read) {\n failed = true;\n continue;\n }\n // Not in `required` is \"may be left out\", which is `optional()`: the\n // model is told to send null, and a parse drops the key.\n shape[key] = required.includes(key) ? read : { ...read, optional: true };\n }\n if (failed) return undefined;\n const unknownKeys = options.unknownKeys;\n return finish({\n kind: \"object\",\n shape,\n ...(unknownKeys === \"error\" || unknownKeys === \"passthrough\" ? { unknownKeys } : {}),\n });\n }\n }\n return undefined;\n}\n\n/** `null` when a problem was reported. */\nfunction readStringChecks(\n schema: Record<string, unknown>,\n options: FromJSONSchemaOptions,\n child: (key: string) => string,\n problems: string[],\n): StringChecks | undefined | null {\n const checks: StringChecks = {};\n let failed = false;\n for (const key of [\"minLength\", \"maxLength\"] as const) {\n const value = schema[key];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isInteger(value) || value < 0) {\n problems.push(`${child(key)}: expected a non-negative integer`);\n failed = true;\n continue;\n }\n checks[key] = value;\n }\n if (schema.format !== undefined) {\n const name = schema.format;\n const format = typeof name === \"string\" ? options.formats?.[name] : undefined;\n if (typeof name !== \"string\") {\n problems.push(`${child(\"format\")}: expected a string`);\n failed = true;\n } else if (!format || !Object.hasOwn(options.formats!, name)) {\n problems.push(\n `${child(\"format\")}: unknown format ${JSON.stringify(name)}; pass a check for it in the formats option`,\n );\n failed = true;\n } else {\n checks.format = { name, test: formatTest(format) };\n }\n }\n if (failed) return null;\n return Object.keys(checks).length > 0 ? checks : undefined;\n}\n\nfunction formatTest(format: JSONSchemaFormat): (value: string) => boolean {\n if (format === true) return () => true;\n if (format instanceof RegExp) {\n // A `g` or `y` regex keeps `lastIndex` between calls, so the second value\n // tested would start halfway in. Reset it every time.\n return (value) => {\n format.lastIndex = 0;\n return format.test(value);\n };\n }\n return format;\n}\n\nexport const s: {\n string(): SchemaBuilder<string>;\n number(): SchemaBuilder<number>;\n boolean(): SchemaBuilder<boolean>;\n literal<const L extends string | number | boolean>(value: L): SchemaBuilder<L>;\n /** Modelled as a JSON Schema `enum`, which strict mode does support. */\n enum<const L extends readonly [string, ...string[]]>(values: L): SchemaBuilder<L[number]>;\n object<const S extends Record<string, AnySchema>>(shape: S): SchemaBuilder<ShapeOutput<S>>;\n array<const S extends AnySchema>(item: S): SchemaBuilder<Infer<S>[]>;\n /**\n * `anyOf` of object schemas, discriminated by a literal member. Left in\n * because tool outputs are frequently a success/failure pair, and modelling\n * that as one object with everything optional is worse for the model.\n */\n union<const S extends readonly [AnySchema, AnySchema, ...AnySchema[]]>(\n members: S,\n ): SchemaBuilder<Infer<S[number]>>;\n /**\n * Any JSON value, constrained by nothing — for a format the rest of this\n * builder cannot describe: a record with arbitrary keys, a mixed-type tuple,\n * a document whose shape is not known in advance. (A document that nests\n * into itself has a strict spelling: `s.recursive`.)\n *\n * A schema containing one cannot be sent under strict mode, so a tool whose\n * input uses it is sent with `strict: false` automatically. That is not an\n * option to pass anywhere; it is read back off the schema by\n * `supportsStrict`. The rest of the tool is unaffected, and so is streaming:\n * partial arguments are parsed from the raw text, never through a schema.\n *\n * `T` is an assertion, not a guarantee. The emitted schema constrains\n * nothing, so nothing checks the model's output against `T` — only that it is\n * JSON. Validate it in `execute` and hand the model back an error it can fix,\n * the way it would any other bad argument. `describe()` is where you tell it\n * the format; with no constraints to read, that prose is all it gets.\n *\n * TWO CALL SIGNATURES, NOT A DEFAULT TYPE PARAMETER, and that is load-bearing.\n * Written `json<T = JsonValue>()`, the default lost to the surrounding\n * contextual type in the position this is actually used: `s.object`'s shape is\n * constrained to `Record<string, AnySchema>` — `Schema<any>` — which supplies\n * `any` as an inference candidate, and a candidate beats a default. So\n * `s.object({ definition: s.json() })` inferred `{ definition: any }`, which is\n * type checking switched off around exactly the field this exists for, and the\n * opposite of what the default was written to prevent. An overload with no type\n * parameter has nothing to infer, so `s.json()` is `JsonValue` wherever it is\n * written.\n *\n * `ai:generate-client` maps it to the native `JSONValue` and says nothing about\n * it. `JsonValue` is a union of every JSON shape, so it used to reach the\n * generator's \"a union that is not told apart by one string member\" warning —\n * true, and a misdescription of a field that is free-form on purpose. The\n * extractor recognises it now.\n */\n json(): SchemaBuilder<JsonValue>;\n json<T>(): SchemaBuilder<T>;\n /**\n * A schema that contains itself — a tree of UI nodes, a comment thread, a\n * folder listing — and stays strict-mode safe, unlike `s.json()`.\n *\n * ```ts\n * type Node = { tag: string; text?: string; children: Node[] };\n *\n * const node = s.recursive<Node>(\"Node\", (self) =>\n * s.object({\n * tag: s.enum([\"section\", \"heading\", \"text\"]),\n * text: s.string().optional(),\n * children: s.array(self),\n * }),\n * );\n * const output = s.object({ title: s.string(), root: node });\n * ```\n *\n * Emitted the way OpenAI's strict structured output spells recursion: the\n * body once under the root's `$defs[name]`, and `{ \"$ref\": \"#/$defs/<name>\" }`\n * wherever it is used. Used as the root itself, the body is also inlined at\n * the root, since a tool's parameters and an agent's output must be an\n * object there. `parse`, `safeParse` and `validate` follow the reference to\n * any depth.\n *\n * `T` has to be written out: TypeScript cannot infer a type from a value\n * that mentions itself. The callback's schema is checked against it, so a\n * field the type has and the schema lacks (or the reverse) is a type error.\n *\n * Rules, each an error when the schema is built:\n *\n * - `name` is the `$defs` key: letters, digits, `_` and `-`. Two different\n * recursive schemas in one tool or output need different names.\n * - `self` must be nested inside an `s.object` field or an `s.array` — a\n * body that is `self` again through a union describes no finite value.\n * - The body cannot be `optional()`; make the uses optional instead\n * (`children: s.array(self).optional()`, `next: self.optional()`).\n *\n * Strict mode limits the rest as usual: every node of the body is in the\n * strict subset or the whole schema is sent non-strict (`supportsStrict`).\n */\n recursive<T>(name: string, define: (self: SchemaBuilder<T>) => Schema<T>): SchemaBuilder<T>;\n /**\n * A schema read from a JSON Schema at runtime — for a shape that comes from\n * data rather than code, like a collection whose items a user defined.\n *\n * Only the subset `s` itself models is accepted, so the result stays\n * strict-mode safe and can be a tool's `inputSchema` like any other:\n *\n * - `type`: `string`, `number`, `integer`, `boolean`, `object`, `array`,\n * or one of them with `\"null\"` (`[\"string\", \"null\"]`).\n * - `enum` (strings become `s.enum`, numbers and booleans a union of\n * literals; a `null` in it makes the field nullable), `const`, `anyOf`.\n * - strings: `minLength`, `maxLength`, `format` (checked with\n * `options.formats`). Numbers: `minimum`, `maximum`, `exclusiveMinimum`,\n * `exclusiveMaximum`. Arrays: `items` (one schema), `minItems`, `maxItems`.\n * - objects: `properties`, `required`, `additionalProperties: false`. A\n * property not in `required` is `optional()`.\n * - `description`; annotations (`title`, `default`, `examples`, `$schema`,\n * `x-*`, … and `options.ignoreKeywords`) are skipped.\n *\n * Anything else — `pattern`, `oneOf`, `allOf`, `$ref`, a tuple, an open\n * `additionalProperties`, an unknown `format` — throws a `JSONSchemaError`\n * listing every problem with its path.\n *\n * The length, range, item-count and format constraints are enforced by\n * `parse`/`safeParse`/`validate` and told to the model in the field's\n * description, because strict structured output does not accept them as\n * keywords. By default an unknown key in an object is dropped from the\n * parsed value rather than reported; pass `unknownKeys: \"error\"` to report\n * it as an `additionalProperties` issue (as Ajv does), or `\"passthrough\"`\n * to keep it.\n *\n * The output type is `JsonValue` (or the `T` you assert). Validate a value\n * with `.validate(value)` for per-path issues, or `.safeParse(value)`.\n */\n fromJSONSchema(schema: unknown, options?: FromJSONSchemaOptions): SchemaBuilder<JsonValue>;\n fromJSONSchema<T>(schema: unknown, options?: FromJSONSchemaOptions): SchemaBuilder<T>;\n} = {\n string: () => make<string>(leaf({ kind: \"string\" })),\n number: () => make<number>(leaf({ kind: \"number\" })),\n boolean: () => make<boolean>(leaf({ kind: \"boolean\" })),\n literal: (value) => make<typeof value>(leaf({ kind: \"literal\", value })),\n enum: (values) => make<(typeof values)[number]>(leaf({ kind: \"enum\", values })),\n object: (shape) =>\n make<ShapeOutput<typeof shape>>(\n leaf({\n kind: \"object\",\n shape: Object.fromEntries(\n Object.entries(shape).map(([key, child]) => [key, definitionOf(child)]),\n ),\n }),\n ),\n array: (item) => make<Infer<typeof item>[]>(leaf({ kind: \"array\", item: definitionOf(item) })),\n // A union is legal wherever a property is, but not as the root of a tool's\n // input or an agent's structured output: the provider wants an object there.\n // `s` cannot know where a schema will be used, so `AgentTool.create` and\n // `Agent.create` are what reject it at the root.\n union: (members) =>\n make<Infer<(typeof members)[number]>>(\n leaf({ kind: \"union\", members: members.map(definitionOf) }),\n ),\n json: <T>() => make<T>(leaf({ kind: \"json\" })),\n recursive,\n fromJSONSchema: <T>(schema: unknown, options: FromJSONSchemaOptions = {}) => {\n const problems: string[] = [];\n if (\n options.unknownKeys !== undefined &&\n !(UNKNOWN_KEYS as readonly unknown[]).includes(options.unknownKeys)\n ) {\n throw new Error(\n `gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${UNKNOWN_KEYS.map((v) => JSON.stringify(v)).join(\", \")}, got ${JSON.stringify(options.unknownKeys)}`,\n );\n }\n const definition = fromJSON(schema, options, \"\", problems);\n if (!definition || problems.length > 0) {\n throw new JSONSchemaError(problems.length > 0 ? problems : [\"unreadable schema\"]);\n }\n return make<T>(definition);\n },\n};\n\n/**\n * Whether a schema can be sent under a provider's strict mode.\n *\n * False exactly when a `json()` node is somewhere inside it. Strict mode's\n * bargain is that every node constrains its value; an unconstrained one has no\n * spelling there, and sending it anyway is a 400 naming a path.\n *\n * Derived from the tree rather than declared alongside it, because the two\n * would drift: a field added to a tool's input a year from now would need\n * whoever adds it to know that a flag somewhere else describes it. Adding the\n * field is the whole of turning strict off.\n */\nexport function supportsStrict(schema: AnySchema): boolean {\n const definition = definitions.get(schema);\n if (definition) return strictNode(definition.node);\n // A schema built by hand rather than with `s`: `questionSchema` in\n // `ai/Agent.ts`, and the merged one `services/mcp` casts together.\n //\n // Answering `true` here was wrong, and not harmlessly. `McpRegistry`'s\n // `combineSchemas` spreads `meta.input.toJSONSchema()` into its own object,\n // so an `s.json()` field an app declared on an `mcp` route survives into the\n // emitted schema while the *tree* that would have reported it is discarded.\n // Every MCP-projected tool was therefore sent `strict: true` with an empty\n // subschema inside it — a 400 on every turn, from the one path this function\n // exists to get right.\n //\n // So the emitted schema is read instead. It is the same question asked of the\n // artifact rather than the source, which is the only thing a foreign schema\n // has to offer.\n return strictJSONSchema(schema.toJSONSchema());\n}\n\n/**\n * Whether an already-emitted JSON Schema constrains every value it describes.\n *\n * Only for schemas with no definition tree. It answers a narrower question than\n * `strictNode` — it cannot see optionality or a builder's intent, just whether\n * some node says nothing about its value — but that is exactly the property\n * strict mode rejects, and it is visible in the artifact.\n */\nfunction strictJSONSchema(schema: JSONSchema): boolean {\n // `description` is prose, not a constraint. A node carrying only that — which\n // is what `s.json().describe(...)` emits — says nothing about its value.\n const constrained =\n schema.$ref !== undefined ||\n schema.type !== undefined ||\n schema.enum !== undefined ||\n schema.const !== undefined ||\n schema.anyOf !== undefined ||\n schema.properties !== undefined ||\n schema.items !== undefined;\n if (!constrained) return false;\n\n for (const child of Object.values(schema.properties ?? {})) {\n if (!strictJSONSchema(child)) return false;\n }\n if (schema.items && !strictJSONSchema(schema.items)) return false;\n for (const member of schema.anyOf ?? []) {\n if (!strictJSONSchema(member)) return false;\n }\n // A `$ref` is answered for by the `$defs` entry it points at, which is\n // checked here once rather than followed — following it is a cycle.\n for (const definition of Object.values(schema.$defs ?? {})) {\n if (!strictJSONSchema(definition)) return false;\n }\n return true;\n}\n\n/**\n * Enumerated rather than defaulted, so that a node kind added later cannot\n * inherit \"strict\" by omission — which is the failure that shows up as a 400\n * from the provider rather than as a type error here.\n *\n * The one cycle in a definition tree is an `s.recursive` reaching itself, so\n * `seen` holds the cells already being answered for: a body that is strict\n * apart from its references to itself is strict.\n */\nfunction strictNode(node: SchemaNode, seen = new Set<RecursiveCell>()): boolean {\n switch (node.kind) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"literal\":\n case \"enum\":\n return true;\n case \"object\":\n return Object.values(node.shape).every((child) => strictNode(child.node, seen));\n case \"array\":\n return strictNode(node.item.node, seen);\n case \"union\":\n return node.members.every((member) => strictNode(member.node, seen));\n case \"json\":\n return false;\n case \"ref\":\n if (seen.has(node.cell)) return true;\n seen.add(node.cell);\n return strictNode(bodyOf(node.cell).node, seen);\n }\n}\n\n/**\n * Whether `definition` can reach `cell` without an object property or an\n * array item in between — through a union member, or another recursive\n * schema's body. Such a schema describes no finite value (`Self = Self |\n * string` is just `string`), and reading one would recurse forever on a\n * primitive, where no object is there to catch the cycle with.\n */\nfunction reachesUnguarded(\n definition: Definition,\n cell: RecursiveCell,\n seen = new Set<RecursiveCell>(),\n): boolean {\n const node = definition.node;\n if (node.kind === \"union\") {\n return node.members.some((member) => reachesUnguarded(member, cell, seen));\n }\n if (node.kind !== \"ref\") return false;\n if (node.cell === cell) return true;\n if (seen.has(node.cell) || !node.cell.definition) return false;\n seen.add(node.cell);\n return reachesUnguarded(node.cell.definition, cell, seen);\n}\n\nconst RECURSIVE_NAME = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;\n\nfunction recursive<T>(\n name: string,\n define: (self: SchemaBuilder<T>) => Schema<T>,\n): SchemaBuilder<T> {\n if (typeof name !== \"string\" || !RECURSIVE_NAME.test(name)) {\n throw new Error(\n `gemi/ai: s.recursive needs a name of letters, digits, \"_\" and \"-\" (starting with a letter or \"_\", at most 64), got ${JSON.stringify(name)}`,\n );\n }\n const cell: RecursiveCell = { name, active: new Set() };\n const reference = (): Definition => leaf({ kind: \"ref\", cell });\n const body = definitionOf(define(make<T>(reference())));\n if (body.optional) {\n throw new Error(\n `gemi/ai: the recursive schema \"${name}\" is optional() as a whole; mark the places that use it optional instead`,\n );\n }\n if (reachesUnguarded(body, cell)) {\n throw new Error(\n `gemi/ai: the recursive schema \"${name}\" refers to itself outside any object or array, so it describes no finite value; nest \\`self\\` in an s.object(...) field or an s.array(...)`,\n );\n }\n cell.definition = body;\n return make<T>(reference());\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAmRA,SAAS,CAAM,CAAC,EAAiC,CAC/C,GAAI,CAAC,EAAK,WACR,MAAU,MACR,kCAAkC,EAAK,sIACzC,EAEF,OAAO,EAAK,WAwBd,IAAM,EAAc,IAAI,QAMjB,SAAS,EAAQ,CAAC,EAAiD,CACxE,OAAO,OAAO,IAAU,UAAY,IAAU,MAAQ,EAAY,IAAI,CAAK,EAG7E,SAAS,CAAY,CAAC,EAA+B,CACnD,IAAM,EAAa,EAAY,IAAI,CAAM,EACzC,GAAI,CAAC,EACH,MAAU,MAAM,iEAAiE,EAEnF,OAAO,EAyBT,SAAS,CAAQ,CAAC,EAAoC,CACpD,IAAM,EAAuB,CAAE,KAAM,CAAC,EAAG,MAAO,IAAI,GAAM,EACtD,EAAO,EACX,GAAI,EAAW,KAAK,OAAS,MAAO,CAClC,IAAM,EAAO,EAAO,EAAW,KAAK,IAAI,EACxC,EAAO,IACF,KACC,EAAW,YAAc,CAAE,YAAa,EAAW,WAAY,EAAI,CAAC,EACxE,SAAU,EAAW,SACrB,SAAU,EAAW,UAAY,EAAK,QACxC,EAEF,IAAM,EAAS,EAAK,EAAM,CAAO,EACjC,OAAO,OAAO,KAAK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,EAAK,OAAS,EAAM,MAAO,GAC/B,GAAI,EAAK,IAAI,EAAK,IAAI,GAAK,CAAC,EAAK,KAAK,WAAY,MAAO,GAEzD,OADA,EAAK,IAAI,EAAK,IAAI,EACX,EAAiB,EAAK,KAAK,WAAY,EAAM,CAAI,EAG1D,IAAM,GAAiB,iCAEvB,SAAS,EAAY,CACnB,EACA,EACkB,CAClB,GAAI,OAAO,IAAS,UAAY,CAAC,GAAe,KAAK,CAAI,EACvD,MAAU,MACR,sHAAsH,KAAK,UAAU,CAAI,GAC3I,EAEF,IAAM,EAAsB,CAAE,OAAM,OAAQ,IAAI,GAAM,EAChD,EAAY,IAAkB,EAAK,CAAE,KAAM,MAAO,MAAK,CAAC,EACxD,EAAO,EAAa,EAAO,EAAQ,EAAU,CAAC,CAAC,CAAC,EACtD,GAAI,EAAK,SACP,MAAU,MACR,kCAAkC,2EACpC,EAEF,GAAI,EAAiB,EAAM,CAAI,EAC7B,MAAU,MACR,kCAAkC,8IACpC,EAGF,OADA,EAAK,WAAa,EACX,EAAQ,EAAU,CAAC",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "112B69F843666D5964756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"import type { Application } from \"../foundation/Application\";\n\n/**\n * What a provider's `shutdown()` may resolve: nothing, or whether it\n * abandoned work at the deadline. See `ServiceProvider` below.\n */\nexport type ProviderShutdownResult = void | { abandoned: boolean };\n\n/**\n * Every hook defaults to a no-op. `register()` binds services into the\n * container and must not resolve any of them; `boot()` runs after every\n * provider has registered, so it may resolve freely.\n *\n * `shutdown()` runs once when a production server is told to stop (`SIGTERM`\n * or `SIGINT`), after it has stopped accepting requests and the in-flight ones\n * have finished or run out of grace — so nothing a request needs is torn down\n * under it. Providers shut down in reverse registration order, so one\n * registered after another may still use it. Each is awaited, but under a\n * shared deadline (`GEMI_SHUTDOWN_PROVIDER_TIMEOUT`): one that overruns is\n * abandoned and the next begins, and one that throws is logged and does not\n * stop the rest. See `Application.shutdown`.\n *\n * Under `gemi dev` it also runs on every `bun --hot` reload, for the\n * application the reload replaced, once the new one is serving and the old\n * one's requests have finished (see `server/devReload.ts`). A hook that closes\n * something kept on `globalThis` across reloads would close it for the new\n * application too.\n *\n * `timeoutMs` is what is left of that shared deadline when this provider is\n * reached. A provider that waits for something — jobs finishing, a queue\n * draining — should bound its own wait by a little less than this, so that it\n * is still the one to report what it gave up on. Ignoring it is fine; the\n * provider is then simply abandoned at the deadline, with only a generic line\n * from `Application` to say so.\n *\n * A provider that bounds its own wait and gives up on work it was waiting for\n * resolves `{ abandoned: true }`. `Application` then reports it in `timedOut`\n * as if it had overrun, and the process exits `1` — the work was cut off just\n * the same, and an orchestrator or a log alert has to be able to see that from\n * the exit code. The provider names what it abandoned in its own log line.\n */\nexport abstract class ServiceProvider {\n constructor(protected app: Application) {}\n\n register(): void {}\n\n boot(): void | Promise<void> {}\n\n shutdown(options?: {\n timeoutMs: number;\n }): ProviderShutdownResult | Promise<ProviderShutdownResult> {}\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAyCO,MAAe,CAAgB,CACd,IAAtB,WAAW,CAAW,EAAkB,CAAlB,WAEtB,QAAQ,EAAS,EAEjB,IAAI,EAAyB,EAE7B,QAAQ,CAAC,EAEoD,EAC/D",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "A1CEC33B383B201D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var j=globalThis.__GEMI_DICTIONARY_REGISTRY__??={registry:new Map,resolved:new Map,inFlight:new Map,renderThenables:new Map,order:[],warmed:new Map,activeLocale:null},{registry:W,resolved:Z,inFlight:V,renderThenables:I,order:E,warmed:X}=j;function N(q,x){return`${q}\x00${x}`}function D(q){if(W.has(q.id))return;W.set(q.id,q),E.push(q.id)}function H(){return E.length}function P(q,x){return Z.get(q)?.get(x)}function $(q,x,A){let z=Z.get(q);if(!z)z=new Map,Z.set(q,z);z.set(x,A)}function U(q,x){let A=P(q,x);if(A)return A;let z=N(q,x),C=V.get(z);if(C)return C;let B=W.get(q);if(!B)throw Error(`Unknown dictionary "${q}". A dictionary must be created with defineDictionary() and its module must have been evaluated before it is read.`);let J=B.load(x);if(!(J instanceof Promise))return $(q,x,J),J;let O=J.then((Q)=>{return $(q,x,Q),V.delete(z),Q},(Q)=>{throw V.delete(z),Q});return V.set(z,O),O}function K(q,x){let A=N(q,x),z=P(q,x),C=I.get(A);if(C&&!(C.degraded&&z))return C;if(z)return G(A,M(z,!C));let B=U(q,x);if(!(B instanceof Promise))return G(A,M(B,!0));let J=B.then((O)=>O,(O)=>{return console.error(`Failed to load dictionary ${q} for locale ${x}; rendering keys instead.`,O),J.degraded=!0,Y});return G(A,J)}function G(q,x){return I.set(q,x),x}function M(q,x){return Object.assign(Promise.resolve(q),{status:"fulfilled",value:q,inHand:x?q:void 0})}var Y={};async function S(q,x){let A=x??X.get(q)??0,z=E.slice(A);if(z.length===0)return;let C=await Promise.all(z.map(async(B)=>{try{return await U(B,_(B,q)),!0}catch{return!1}}));if(x===void 0){let B=C.indexOf(!1),J=B===-1?z.length:B;X.set(q,Math.max(X.get(q)??0,A+J))}}function _(q,x){if(x)return x;return W.get(q)?.locales[0]??x}function L(q,x){if(!q)return;for(let[A,z]of Object.entries(q))$(A,x,z)}function R(q){if(q)j.activeLocale=q}function w(){return j.activeLocale}if(typeof window<"u"){let q=window,x=([z,C,B])=>{$(z,C,B)},A=Array.isArray(q.__GEMI_DICT__)?q.__GEMI_DICT__:[];q.__GEMI_DICT__={push:x};for(let z of A)x(z)}function F(){W.clear(),Z.clear(),V.clear(),I.clear(),X.clear(),E.length=0,j.activeLocale=null}function f(){let q=new Set,x=[],A=[];return{use(z,C,B){let J=`${z} ${C}`;if(q.has(J))return;q.add(J);let O={id:z,locale:C,strings:B};if(x.length===0){A.push(O);return}for(let Q of x)Q(O)},onUse(z){x.push(z);while(A.length>0)z(A.shift())}}}
|
|
3
|
-
export{D as
|
|
3
|
+
export{D as Ol,H as Pl,U as Ql,K as Rl,S as Sl,L as Tl,R as Ul,w as Vl,F as Wl,f as Xl};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=BEF426940E2C847364756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import type { LocaleStrings } from \"./dictionaryShape\";\n\n/**\n * Collects the dictionaries one SSR render actually read.\n *\n * Scoped per request by living in React context rather than in module state: a\n * streaming server has several renders in flight at once, so a module-level\n * collector would mix one page's dictionaries into another's payload. Context\n * is per render tree, which is exactly the boundary wanted, and it needs no\n * async-local storage to survive React's internal scheduling.\n *\n * Why stream these rather than put them in `__GEMI_DATA__`: that snapshot is\n * serialized before `renderToReadableStream` is even called, and which\n * dictionaries a page reads is only known once it has rendered. A suspended\n * segment reveals later still, long after the shell has flushed.\n *\n * The sink deliberately emits data, not markup — `streamQueryInjection` owns\n * script formatting and the `</script>`-safe encoding that goes with it.\n */\nexport interface DictionaryUse {\n id: string;\n locale: string;\n strings: LocaleStrings;\n}\n\nexport interface DictionarySink {\n /** Called during render, the first time a dictionary is read. */\n use(id: string, locale: string, strings: LocaleStrings): void;\n /** The response injector subscribes to receive uses as they happen. */\n onUse(cb: (use: DictionaryUse) => void): void;\n}\n\nexport function createDictionarySink(): DictionarySink {\n const seen = new Set<string>();\n const listeners: Array<(use: DictionaryUse) => void> = [];\n // Uses recorded before the injector subscribed — the render begins before the\n // response stream is wrapped.\n const pending: DictionaryUse[] = [];\n\n return {\n use(id, locale, strings) {\n const key = `${id} ${locale}`;\n if (seen.has(key)) return;\n seen.add(key);\n const entry: DictionaryUse = { id, locale, strings };\n if (listeners.length === 0) {\n pending.push(entry);\n return;\n }\n for (const listener of listeners) listener(entry);\n },\n onUse(cb) {\n listeners.push(cb);\n while (pending.length > 0) {\n cb(pending.shift()!);\n }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AQ,EACnD,GAAI,EAAU,SAAW,EAAG,CAC1B,EAAQ,KAAK,CAAK,EAClB,OAEF,QAAW,KAAY,EAAW,EAAS,CAAK,GAElD,KAAK,CAAC,EAAI,CACR,EAAU,KAAK,CAAE,EACjB,MAAO,EAAQ,OAAS,EACtB,EAAG,EAAQ,MAAM,CAAE,EAGzB",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "BEF426940E2C847364756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{h as _t}from"./chunk-5gp49wph.js";import{A as oo,B as Lt,C as yo,i as er,k as M,l as vo,m as Eo,n as So,p as Gr,q as zr,r as kt,s as Io,t as cr,u as Po,v as xo,w as ar,x as eo,y as ro,z as to}from"./chunk-gt6eq1p2.js";import{D as gt}from"./chunk-vck02shp.js";import{E as hr,F as mt,H as Qt,L as Ue,P as f}from"./chunk-5wh3cw2x.js";import{Q as Oo}from"./chunk-6ncn8rdn.js";import{T as zt}from"./chunk-dgna0e7g.js";import{U as Ht}from"./chunk-fhb00fjx.js";import"./chunk-b8tmmpcf.js";import"./chunk-3r7z4kc0.js";import"./chunk-at6zjajz.js";import"./chunk-vawqmdh4.js";import{Aa as Zt}from"./chunk-zy6hj5cc.js";import{Lm as S}from"./chunk-yedb5vvg.js";var A=S((oe)=>{Object.defineProperty(oe,"__esModule",{value:!0});oe.resolveHttpAuthSchemeConfig=oe.defaultSSOOIDCHttpAuthSchemeProvider=oe.defaultSSOOIDCHttpAuthSchemeParametersProvider=void 0;var Rr=M(),w=hr(),fr=async(e,r,i)=>{return{operation:(0,w.getSmithyContext)(r).operation,region:await(0,w.normalizeProvider)(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()}};oe.defaultSSOOIDCHttpAuthSchemeParametersProvider=fr;function Fr(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(r,i)=>({signingProperties:{config:r,context:i}})}}function Ur(e){return{schemeId:"smithy.api#noAuth"}}var $r=(e)=>{let r=[];switch(e.operation){case"CreateToken":{r.push(Ur(e));break}default:r.push(Fr(e))}return r};oe.defaultSSOOIDCHttpAuthSchemeProvider=$r;var jr=(e)=>{let r=(0,Rr.resolveAwsSdkSigV4Config)(e);return Object.assign(r,{authSchemePreference:(0,w.normalizeProvider)(e.authSchemePreference??[])})};oe.resolveHttpAuthSchemeConfig=jr});var De=S((xe)=>{Object.defineProperty(xe,"__esModule",{value:!0});xe.ruleSet=void 0;var Ee="required",p="fn",d="argv",q="ref",se=!0,ne="isSet",N="booleanEquals",D="error",b="endpoint",I="tree",G="PartitionResult",z="getAttr",pe={[Ee]:!1,type:"string"},de={[Ee]:!0,default:!1,type:"boolean"},ce={[q]:"Endpoint"},Se={[p]:N,[d]:[{[q]:"UseFIPS"},!0]},Ie={[p]:N,[d]:[{[q]:"UseDualStack"},!0]},n={},ae={[p]:z,[d]:[{[q]:G},"supportsFIPS"]},Pe={[q]:G},le={[p]:N,[d]:[!0,{[p]:z,[d]:[Pe,"supportsDualStack"]}]},ue=[Se],Oe=[Ie],ve=[{[q]:"Region"}],Ar={version:"1.0",parameters:{Region:pe,UseDualStack:de,UseFIPS:de,Endpoint:pe},rules:[{conditions:[{[p]:ne,[d]:[ce]}],rules:[{conditions:ue,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:D},{conditions:Oe,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:D},{endpoint:{url:ce,properties:n,headers:n},type:b}],type:I},{conditions:[{[p]:ne,[d]:ve}],rules:[{conditions:[{[p]:"aws.partition",[d]:ve,assign:G}],rules:[{conditions:[Se,Ie],rules:[{conditions:[{[p]:N,[d]:[se,ae]},le],rules:[{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:D}],type:I},{conditions:ue,rules:[{conditions:[{[p]:N,[d]:[ae,se]}],rules:[{conditions:[{[p]:"stringEquals",[d]:[{[p]:z,[d]:[Pe,"name"]},"aws-us-gov"]}],endpoint:{url:"https://oidc.{Region}.amazonaws.com",properties:n,headers:n},type:b},{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"FIPS is enabled but this partition does not support FIPS",type:D}],type:I},{conditions:Oe,rules:[{conditions:[le],rules:[{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"DualStack is enabled but this partition does not support DualStack",type:D}],type:I},{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:b}],type:I}],type:I},{error:"Invalid Configuration: Missing Region",type:D}]};xe.ruleSet=Ar});var Ne=S((be)=>{Object.defineProperty(be,"__esModule",{value:!0});be.defaultEndpointResolver=void 0;var mr=zr(),m=Gr(),Hr=De(),Lr=new m.EndpointCache({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),Tr=(e,r={})=>{return Lr.get(e,()=>(0,m.resolveEndpoint)(Hr.ruleSet,{endpointParams:e,logger:r.logger}))};be.defaultEndpointResolver=Tr;m.customEndpointFunctions.aws=mr.awsEndpointFunctions});var F=S((L)=>{Object.defineProperty(L,"__esModule",{value:!0});L.SSOOIDCServiceException=L.__ServiceException=void 0;var he=f();Object.defineProperty(L,"__ServiceException",{enumerable:!0,get:function(){return he.ServiceException}});class H extends he.ServiceException{constructor(e){super(e);Object.setPrototypeOf(this,H.prototype)}}L.SSOOIDCServiceException=H});var k=S((fe)=>{Object.defineProperty(fe,"__esModule",{value:!0});fe.UnsupportedGrantTypeException=fe.UnauthorizedClientException=fe.SlowDownException=fe.InvalidScopeException=fe.InvalidRequestException=fe.InvalidGrantException=fe.InvalidClientException=fe.InternalServerException=fe.ExpiredTokenException=fe.AuthorizationPendingException=fe.AccessDeniedException=void 0;var l=F();class T extends l.SSOOIDCServiceException{name="AccessDeniedException";$fault="client";error;reason;error_description;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,T.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}fe.AccessDeniedException=T;class B extends l.SSOOIDCServiceException{name="AuthorizationPendingException";$fault="client";error;error_description;constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e});Object.setPrototypeOf(this,B.prototype),this.error=e.error,this.error_description=e.error_description}}fe.AuthorizationPendingException=B;class V extends l.SSOOIDCServiceException{name="ExpiredTokenException";$fault="client";error;error_description;constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e});Object.setPrototypeOf(this,V.prototype),this.error=e.error,this.error_description=e.error_description}}fe.ExpiredTokenException=V;class W extends l.SSOOIDCServiceException{name="InternalServerException";$fault="server";error;error_description;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,W.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InternalServerException=W;class Y extends l.SSOOIDCServiceException{name="InvalidClientException";$fault="client";error;error_description;constructor(e){super({name:"InvalidClientException",$fault:"client",...e});Object.setPrototypeOf(this,Y.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidClientException=Y;class J extends l.SSOOIDCServiceException{name="InvalidGrantException";$fault="client";error;error_description;constructor(e){super({name:"InvalidGrantException",$fault:"client",...e});Object.setPrototypeOf(this,J.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidGrantException=J;class K extends l.SSOOIDCServiceException{name="InvalidRequestException";$fault="client";error;reason;error_description;constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,K.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}fe.InvalidRequestException=K;class X extends l.SSOOIDCServiceException{name="InvalidScopeException";$fault="client";error;error_description;constructor(e){super({name:"InvalidScopeException",$fault:"client",...e});Object.setPrototypeOf(this,X.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidScopeException=X;class C extends l.SSOOIDCServiceException{name="SlowDownException";$fault="client";error;error_description;constructor(e){super({name:"SlowDownException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error,this.error_description=e.error_description}}fe.SlowDownException=C;class Q extends l.SSOOIDCServiceException{name="UnauthorizedClientException";$fault="client";error;error_description;constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e});Object.setPrototypeOf(this,Q.prototype),this.error=e.error,this.error_description=e.error_description}}fe.UnauthorizedClientException=Q;class Z extends l.SSOOIDCServiceException{name="UnsupportedGrantTypeException";$fault="client";error;error_description;constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e});Object.setPrototypeOf(this,Z.prototype),this.error=e.error,this.error_description=e.error_description}}fe.UnsupportedGrantTypeException=Z});var g=S((ze)=>{Object.defineProperty(ze,"__esModule",{value:!0});ze.CreateToken$=ze.CreateTokenResponse$=ze.CreateTokenRequest$=ze.errorTypeRegistries=ze.UnsupportedGrantTypeException$=ze.UnauthorizedClientException$=ze.SlowDownException$=ze.InvalidScopeException$=ze.InvalidRequestException$=ze.InvalidGrantException$=ze.InvalidClientException$=ze.InternalServerException$=ze.ExpiredTokenException$=ze.AuthorizationPendingException$=ze.AccessDeniedException$=ze.SSOOIDCServiceException$=void 0;var kr="AccessDeniedException",gr="AuthorizationPendingException",_r="AccessToken",et="ClientSecret",rt="CreateToken",tt="CreateTokenRequest",ot="CreateTokenResponse",it="CodeVerifier",st="ExpiredTokenException",nt="InvalidClientException",pt="InvalidGrantException",dt="InvalidRequestException",ct="InternalServerException",at="InvalidScopeException",lt="IdToken",ut="RefreshToken",Ot="SlowDownException",vt="UnauthorizedClientException",Et="UnsupportedGrantTypeException",St="accessToken",E="client",It="clientId",Pt="clientSecret",xt="codeVerifier",yt="code",Dt="deviceCode",t="error",bt="expiresIn",u="error_description",qt="grantType",Nt="http",O="httpError",ht="idToken",$e="reason",je="refreshToken",Rt="redirectUri",we="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc",ft="scope",Ft="server",Ut="tokenType",o="com.amazonaws.ssooidc",Me=Ue(),v=k(),$t=F(),Ae=Me.TypeRegistry.for(we);ze.SSOOIDCServiceException$=[-3,we,"SSOOIDCServiceException",0,[],[]];Ae.registerError(ze.SSOOIDCServiceException$,$t.SSOOIDCServiceException);var c=Me.TypeRegistry.for(o);ze.AccessDeniedException$=[-3,o,kr,{[t]:E,[O]:400},[t,$e,u],[0,0,0]];c.registerError(ze.AccessDeniedException$,v.AccessDeniedException);ze.AuthorizationPendingException$=[-3,o,gr,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.AuthorizationPendingException$,v.AuthorizationPendingException);ze.ExpiredTokenException$=[-3,o,st,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.ExpiredTokenException$,v.ExpiredTokenException);ze.InternalServerException$=[-3,o,ct,{[t]:Ft,[O]:500},[t,u],[0,0]];c.registerError(ze.InternalServerException$,v.InternalServerException);ze.InvalidClientException$=[-3,o,nt,{[t]:E,[O]:401},[t,u],[0,0]];c.registerError(ze.InvalidClientException$,v.InvalidClientException);ze.InvalidGrantException$=[-3,o,pt,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.InvalidGrantException$,v.InvalidGrantException);ze.InvalidRequestException$=[-3,o,dt,{[t]:E,[O]:400},[t,$e,u],[0,0,0]];c.registerError(ze.InvalidRequestException$,v.InvalidRequestException);ze.InvalidScopeException$=[-3,o,at,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.InvalidScopeException$,v.InvalidScopeException);ze.SlowDownException$=[-3,o,Ot,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.SlowDownException$,v.SlowDownException);ze.UnauthorizedClientException$=[-3,o,vt,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.UnauthorizedClientException$,v.UnauthorizedClientException);ze.UnsupportedGrantTypeException$=[-3,o,Et,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.UnsupportedGrantTypeException$,v.UnsupportedGrantTypeException);ze.errorTypeRegistries=[Ae,c];var jt=[0,o,_r,8,0],wt=[0,o,et,8,0],Mt=[0,o,it,8,0],At=[0,o,lt,8,0],Ge=[0,o,ut,8,0];ze.CreateTokenRequest$=[3,o,tt,0,[It,Pt,qt,Dt,yt,je,ft,Rt,xt],[0,[()=>wt,0],0,0,0,[()=>Ge,0],64,0,[()=>Mt,0]],3];ze.CreateTokenResponse$=[3,o,ot,0,[St,Ut,bt,je,ht],[[()=>jt,0],0,1,[()=>Ge,0],[()=>At,0]]];ze.CreateToken$=[9,o,rt,{[Nt]:["POST","/token",200]},()=>ze.CreateTokenRequest$,()=>ze.CreateTokenResponse$]});var or=S((rr)=>{Object.defineProperty(rr,"__esModule",{value:!0});rr.getRuntimeConfig=void 0;var Tt=M(),Bt=Lt(),Vt=er(),Wt=f(),Yt=Ht(),ge=mt(),_e=zt(),Jt=A(),Kt=Ne(),Xt=g(),Ct=(e)=>{return{apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??ge.fromBase64,base64Encoder:e?.base64Encoder??ge.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??Kt.defaultEndpointResolver,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Jt.defaultSSOOIDCHttpAuthSchemeProvider,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(r)=>r.getIdentityProvider("aws.auth#sigv4"),signer:new Tt.AwsSdkSigV4Signer},{schemeId:"smithy.api#noAuth",identityProvider:(r)=>r.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Vt.NoAuthSigner}],logger:e?.logger??new Wt.NoOpLogger,protocol:e?.protocol??Bt.AwsRestJsonProtocol,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.ssooidc",errorTypeRegistries:Xt.errorTypeRegistries,version:"2019-06-10",serviceTarget:"AWSSSOOIDCService"},serviceId:e?.serviceId??"SSO OIDC",urlParser:e?.urlParser??Yt.parseUrl,utf8Decoder:e?.utf8Decoder??_e.fromUtf8,utf8Encoder:e?.utf8Encoder??_e.toUtf8}};rr.getRuntimeConfig=Ct});var Or=S((lr)=>{Object.defineProperty(lr,"__esModule",{value:!0});lr.getRuntimeConfig=void 0;var io=Zt(),so=io.__importDefault(_t()),ir=M(),sr=eo(),U=cr(),no=ro(),nr=ar(),x=gt(),pr=Qt(),dr=f(),po=to(),co=oo(),ao=kt(),lo=or(),uo=(e)=>{(0,dr.emitWarningIfUnsupportedVersion)(process.version);let r=(0,co.resolveDefaultsModeConfig)(e),i=()=>r().then(dr.loadConfigsForDefaultMode),a=(0,lo.getRuntimeConfig)(e);(0,ir.emitWarningIfUnsupportedVersion)(process.version);let s={profile:e?.profile,logger:a.logger};return{...a,...e,runtime:"node",defaultsMode:r,authSchemePreference:e?.authSchemePreference??(0,x.loadConfig)(ir.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,s),bodyLengthChecker:e?.bodyLengthChecker??po.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,sr.createDefaultUserAgentProvider)({serviceId:a.serviceId,clientVersion:so.default.version}),maxAttempts:e?.maxAttempts??(0,x.loadConfig)(nr.NODE_MAX_ATTEMPT_CONFIG_OPTIONS,e),region:e?.region??(0,x.loadConfig)(U.NODE_REGION_CONFIG_OPTIONS,{...U.NODE_REGION_CONFIG_FILE_OPTIONS,...s}),requestHandler:pr.NodeHttpHandler.create(e?.requestHandler??i),retryMode:e?.retryMode??(0,x.loadConfig)({...nr.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await i()).retryMode||ao.DEFAULT_RETRY_MODE},e),sha256:e?.sha256??no.Hash.bind(null,"sha256"),streamCollector:e?.streamCollector??pr.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,x.loadConfig)(U.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,s),useFipsEndpoint:e?.useFipsEndpoint??(0,x.loadConfig)(U.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,s),userAgentAppId:e?.userAgentAppId??(0,x.loadConfig)(sr.NODE_APP_ID_CONFIG_OPTIONS,s)}};lr.getRuntimeConfig=uo});var Yo=S((P)=>{var vr=vo(),Do=Eo(),bo=So(),Er=Io(),qo=cr(),_=er(),No=Ue(),ho=Po(),yr=xo(),Sr=ar(),y=f(),Ir=A(),Ro=Or(),Pr=yo(),xr=Oo(),h=g(),$=k(),fo=F(),Fo=(e)=>{return Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"})},Uo={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},$o=(e)=>{let{httpAuthSchemes:r,httpAuthSchemeProvider:i,credentials:a}=e;return{setHttpAuthScheme(s){let R=r.findIndex((j)=>j.schemeId===s.schemeId);if(R===-1)r.push(s);else r.splice(R,1,s)},httpAuthSchemes(){return r},setHttpAuthSchemeProvider(s){i=s},httpAuthSchemeProvider(){return i},setCredentials(s){a=s},credentials(){return a}}},jo=(e)=>{return{httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}},wo=(e,r)=>{let i=Object.assign(Pr.getAwsRegionExtensionConfiguration(e),y.getDefaultExtensionConfiguration(e),xr.getHttpHandlerExtensionConfiguration(e),$o(e));return r.forEach((a)=>a.configure(i)),Object.assign(e,Pr.resolveAwsRegionExtensionConfiguration(i),y.resolveDefaultRuntimeConfig(i),xr.resolveHttpHandlerRuntimeConfig(i),jo(i))};class ee extends y.Client{config;constructor(...[e]){let r=Ro.getRuntimeConfig(e||{});super(r);this.initConfig=r;let i=Fo(r),a=Er.resolveUserAgentConfig(i),s=Sr.resolveRetryConfig(a),R=qo.resolveRegionConfig(s),j=vr.resolveHostHeaderConfig(R),Dr=yr.resolveEndpointConfig(j),br=Ir.resolveHttpAuthSchemeConfig(Dr),qr=wo(br,e?.extensions||[]);this.config=qr,this.middlewareStack.use(No.getSchemaSerdePlugin(this.config)),this.middlewareStack.use(Er.getUserAgentPlugin(this.config)),this.middlewareStack.use(Sr.getRetryPlugin(this.config)),this.middlewareStack.use(ho.getContentLengthPlugin(this.config)),this.middlewareStack.use(vr.getHostHeaderPlugin(this.config)),this.middlewareStack.use(Do.getLoggerPlugin(this.config)),this.middlewareStack.use(bo.getRecursionDetectionPlugin(this.config)),this.middlewareStack.use(_.getHttpAuthSchemeEndpointRuleSetPlugin(this.config,{httpAuthSchemeParametersProvider:Ir.defaultSSOOIDCHttpAuthSchemeParametersProvider,identityProviderConfigProvider:async(Nr)=>new _.DefaultIdentityProviderConfig({"aws.auth#sigv4":Nr.credentials})})),this.middlewareStack.use(_.getHttpSigningPlugin(this.config))}destroy(){super.destroy()}}class re extends y.Command.classBuilder().ep(Uo).m(function(e,r,i,a){return[yr.getEndpointPlugin(i,e.getEndpointParameterInstructions())]}).s("AWSSSOOIDCService","CreateToken",{}).n("SSOOIDCClient","CreateTokenCommand").sc(h.CreateToken$).build(){}var Mo={CreateTokenCommand:re};class te extends ee{}y.createAggregatedClient(Mo,te);var Ao={KMS_ACCESS_DENIED:"KMS_AccessDeniedException"},Go={KMS_DISABLED_KEY:"KMS_DisabledException",KMS_INVALID_KEY_USAGE:"KMS_InvalidKeyUsageException",KMS_INVALID_STATE:"KMS_InvalidStateException",KMS_KEY_NOT_FOUND:"KMS_NotFoundException"};P.$Command=y.Command;P.__Client=y.Client;P.SSOOIDCServiceException=fo.SSOOIDCServiceException;P.AccessDeniedExceptionReason=Ao;P.CreateTokenCommand=re;P.InvalidRequestExceptionReason=Go;P.SSOOIDC=te;P.SSOOIDCClient=ee;Object.prototype.hasOwnProperty.call(h,"__proto__")&&!Object.prototype.hasOwnProperty.call(P,"__proto__")&&Object.defineProperty(P,"__proto__",{enumerable:!0,value:h.__proto__});Object.keys(h).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(P,e))P[e]=h[e]});Object.prototype.hasOwnProperty.call($,"__proto__")&&!Object.prototype.hasOwnProperty.call(P,"__proto__")&&Object.defineProperty(P,"__proto__",{enumerable:!0,value:$.__proto__});Object.keys($).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(P,e))P[e]=$[e]})});export default Yo();
|
|
2
|
+
import{h as _t}from"./chunk-cf8bztwq.js";import{A as oo,B as Lt,C as yo,i as er,k as M,l as vo,m as Eo,n as So,p as Gr,q as zr,r as kt,s as Io,t as cr,u as Po,v as xo,w as ar,x as eo,y as ro,z as to}from"./chunk-pxjkxhf9.js";import{D as gt}from"./chunk-ps5rpy9n.js";import{E as hr,F as mt,H as Qt,L as Ue,P as f}from"./chunk-3y91vexx.js";import{Q as Oo}from"./chunk-q5xcjm5z.js";import{T as zt}from"./chunk-79wjkaa4.js";import{U as Ht}from"./chunk-vmmjq9fn.js";import"./chunk-fp9yn4k8.js";import"./chunk-8ddt5fa2.js";import"./chunk-5jvbr0e5.js";import"./chunk-ncnygh0s.js";import{Aa as Zt}from"./chunk-nqqyn3cx.js";import{Nm as S}from"./chunk-3dkv4989.js";var A=S((oe)=>{Object.defineProperty(oe,"__esModule",{value:!0});oe.resolveHttpAuthSchemeConfig=oe.defaultSSOOIDCHttpAuthSchemeProvider=oe.defaultSSOOIDCHttpAuthSchemeParametersProvider=void 0;var Rr=M(),w=hr(),fr=async(e,r,i)=>{return{operation:(0,w.getSmithyContext)(r).operation,region:await(0,w.normalizeProvider)(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()}};oe.defaultSSOOIDCHttpAuthSchemeParametersProvider=fr;function Fr(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(r,i)=>({signingProperties:{config:r,context:i}})}}function Ur(e){return{schemeId:"smithy.api#noAuth"}}var $r=(e)=>{let r=[];switch(e.operation){case"CreateToken":{r.push(Ur(e));break}default:r.push(Fr(e))}return r};oe.defaultSSOOIDCHttpAuthSchemeProvider=$r;var jr=(e)=>{let r=(0,Rr.resolveAwsSdkSigV4Config)(e);return Object.assign(r,{authSchemePreference:(0,w.normalizeProvider)(e.authSchemePreference??[])})};oe.resolveHttpAuthSchemeConfig=jr});var De=S((xe)=>{Object.defineProperty(xe,"__esModule",{value:!0});xe.ruleSet=void 0;var Ee="required",p="fn",d="argv",q="ref",se=!0,ne="isSet",N="booleanEquals",D="error",b="endpoint",I="tree",G="PartitionResult",z="getAttr",pe={[Ee]:!1,type:"string"},de={[Ee]:!0,default:!1,type:"boolean"},ce={[q]:"Endpoint"},Se={[p]:N,[d]:[{[q]:"UseFIPS"},!0]},Ie={[p]:N,[d]:[{[q]:"UseDualStack"},!0]},n={},ae={[p]:z,[d]:[{[q]:G},"supportsFIPS"]},Pe={[q]:G},le={[p]:N,[d]:[!0,{[p]:z,[d]:[Pe,"supportsDualStack"]}]},ue=[Se],Oe=[Ie],ve=[{[q]:"Region"}],Ar={version:"1.0",parameters:{Region:pe,UseDualStack:de,UseFIPS:de,Endpoint:pe},rules:[{conditions:[{[p]:ne,[d]:[ce]}],rules:[{conditions:ue,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:D},{conditions:Oe,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:D},{endpoint:{url:ce,properties:n,headers:n},type:b}],type:I},{conditions:[{[p]:ne,[d]:ve}],rules:[{conditions:[{[p]:"aws.partition",[d]:ve,assign:G}],rules:[{conditions:[Se,Ie],rules:[{conditions:[{[p]:N,[d]:[se,ae]},le],rules:[{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:D}],type:I},{conditions:ue,rules:[{conditions:[{[p]:N,[d]:[ae,se]}],rules:[{conditions:[{[p]:"stringEquals",[d]:[{[p]:z,[d]:[Pe,"name"]},"aws-us-gov"]}],endpoint:{url:"https://oidc.{Region}.amazonaws.com",properties:n,headers:n},type:b},{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"FIPS is enabled but this partition does not support FIPS",type:D}],type:I},{conditions:Oe,rules:[{conditions:[le],rules:[{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:n,headers:n},type:b}],type:I},{error:"DualStack is enabled but this partition does not support DualStack",type:D}],type:I},{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dnsSuffix}",properties:n,headers:n},type:b}],type:I}],type:I},{error:"Invalid Configuration: Missing Region",type:D}]};xe.ruleSet=Ar});var Ne=S((be)=>{Object.defineProperty(be,"__esModule",{value:!0});be.defaultEndpointResolver=void 0;var mr=zr(),m=Gr(),Hr=De(),Lr=new m.EndpointCache({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),Tr=(e,r={})=>{return Lr.get(e,()=>(0,m.resolveEndpoint)(Hr.ruleSet,{endpointParams:e,logger:r.logger}))};be.defaultEndpointResolver=Tr;m.customEndpointFunctions.aws=mr.awsEndpointFunctions});var F=S((L)=>{Object.defineProperty(L,"__esModule",{value:!0});L.SSOOIDCServiceException=L.__ServiceException=void 0;var he=f();Object.defineProperty(L,"__ServiceException",{enumerable:!0,get:function(){return he.ServiceException}});class H extends he.ServiceException{constructor(e){super(e);Object.setPrototypeOf(this,H.prototype)}}L.SSOOIDCServiceException=H});var k=S((fe)=>{Object.defineProperty(fe,"__esModule",{value:!0});fe.UnsupportedGrantTypeException=fe.UnauthorizedClientException=fe.SlowDownException=fe.InvalidScopeException=fe.InvalidRequestException=fe.InvalidGrantException=fe.InvalidClientException=fe.InternalServerException=fe.ExpiredTokenException=fe.AuthorizationPendingException=fe.AccessDeniedException=void 0;var l=F();class T extends l.SSOOIDCServiceException{name="AccessDeniedException";$fault="client";error;reason;error_description;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,T.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}fe.AccessDeniedException=T;class B extends l.SSOOIDCServiceException{name="AuthorizationPendingException";$fault="client";error;error_description;constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e});Object.setPrototypeOf(this,B.prototype),this.error=e.error,this.error_description=e.error_description}}fe.AuthorizationPendingException=B;class V extends l.SSOOIDCServiceException{name="ExpiredTokenException";$fault="client";error;error_description;constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e});Object.setPrototypeOf(this,V.prototype),this.error=e.error,this.error_description=e.error_description}}fe.ExpiredTokenException=V;class W extends l.SSOOIDCServiceException{name="InternalServerException";$fault="server";error;error_description;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,W.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InternalServerException=W;class Y extends l.SSOOIDCServiceException{name="InvalidClientException";$fault="client";error;error_description;constructor(e){super({name:"InvalidClientException",$fault:"client",...e});Object.setPrototypeOf(this,Y.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidClientException=Y;class J extends l.SSOOIDCServiceException{name="InvalidGrantException";$fault="client";error;error_description;constructor(e){super({name:"InvalidGrantException",$fault:"client",...e});Object.setPrototypeOf(this,J.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidGrantException=J;class K extends l.SSOOIDCServiceException{name="InvalidRequestException";$fault="client";error;reason;error_description;constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,K.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}fe.InvalidRequestException=K;class X extends l.SSOOIDCServiceException{name="InvalidScopeException";$fault="client";error;error_description;constructor(e){super({name:"InvalidScopeException",$fault:"client",...e});Object.setPrototypeOf(this,X.prototype),this.error=e.error,this.error_description=e.error_description}}fe.InvalidScopeException=X;class C extends l.SSOOIDCServiceException{name="SlowDownException";$fault="client";error;error_description;constructor(e){super({name:"SlowDownException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error,this.error_description=e.error_description}}fe.SlowDownException=C;class Q extends l.SSOOIDCServiceException{name="UnauthorizedClientException";$fault="client";error;error_description;constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e});Object.setPrototypeOf(this,Q.prototype),this.error=e.error,this.error_description=e.error_description}}fe.UnauthorizedClientException=Q;class Z extends l.SSOOIDCServiceException{name="UnsupportedGrantTypeException";$fault="client";error;error_description;constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e});Object.setPrototypeOf(this,Z.prototype),this.error=e.error,this.error_description=e.error_description}}fe.UnsupportedGrantTypeException=Z});var g=S((ze)=>{Object.defineProperty(ze,"__esModule",{value:!0});ze.CreateToken$=ze.CreateTokenResponse$=ze.CreateTokenRequest$=ze.errorTypeRegistries=ze.UnsupportedGrantTypeException$=ze.UnauthorizedClientException$=ze.SlowDownException$=ze.InvalidScopeException$=ze.InvalidRequestException$=ze.InvalidGrantException$=ze.InvalidClientException$=ze.InternalServerException$=ze.ExpiredTokenException$=ze.AuthorizationPendingException$=ze.AccessDeniedException$=ze.SSOOIDCServiceException$=void 0;var kr="AccessDeniedException",gr="AuthorizationPendingException",_r="AccessToken",et="ClientSecret",rt="CreateToken",tt="CreateTokenRequest",ot="CreateTokenResponse",it="CodeVerifier",st="ExpiredTokenException",nt="InvalidClientException",pt="InvalidGrantException",dt="InvalidRequestException",ct="InternalServerException",at="InvalidScopeException",lt="IdToken",ut="RefreshToken",Ot="SlowDownException",vt="UnauthorizedClientException",Et="UnsupportedGrantTypeException",St="accessToken",E="client",It="clientId",Pt="clientSecret",xt="codeVerifier",yt="code",Dt="deviceCode",t="error",bt="expiresIn",u="error_description",qt="grantType",Nt="http",O="httpError",ht="idToken",$e="reason",je="refreshToken",Rt="redirectUri",we="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc",ft="scope",Ft="server",Ut="tokenType",o="com.amazonaws.ssooidc",Me=Ue(),v=k(),$t=F(),Ae=Me.TypeRegistry.for(we);ze.SSOOIDCServiceException$=[-3,we,"SSOOIDCServiceException",0,[],[]];Ae.registerError(ze.SSOOIDCServiceException$,$t.SSOOIDCServiceException);var c=Me.TypeRegistry.for(o);ze.AccessDeniedException$=[-3,o,kr,{[t]:E,[O]:400},[t,$e,u],[0,0,0]];c.registerError(ze.AccessDeniedException$,v.AccessDeniedException);ze.AuthorizationPendingException$=[-3,o,gr,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.AuthorizationPendingException$,v.AuthorizationPendingException);ze.ExpiredTokenException$=[-3,o,st,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.ExpiredTokenException$,v.ExpiredTokenException);ze.InternalServerException$=[-3,o,ct,{[t]:Ft,[O]:500},[t,u],[0,0]];c.registerError(ze.InternalServerException$,v.InternalServerException);ze.InvalidClientException$=[-3,o,nt,{[t]:E,[O]:401},[t,u],[0,0]];c.registerError(ze.InvalidClientException$,v.InvalidClientException);ze.InvalidGrantException$=[-3,o,pt,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.InvalidGrantException$,v.InvalidGrantException);ze.InvalidRequestException$=[-3,o,dt,{[t]:E,[O]:400},[t,$e,u],[0,0,0]];c.registerError(ze.InvalidRequestException$,v.InvalidRequestException);ze.InvalidScopeException$=[-3,o,at,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.InvalidScopeException$,v.InvalidScopeException);ze.SlowDownException$=[-3,o,Ot,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.SlowDownException$,v.SlowDownException);ze.UnauthorizedClientException$=[-3,o,vt,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.UnauthorizedClientException$,v.UnauthorizedClientException);ze.UnsupportedGrantTypeException$=[-3,o,Et,{[t]:E,[O]:400},[t,u],[0,0]];c.registerError(ze.UnsupportedGrantTypeException$,v.UnsupportedGrantTypeException);ze.errorTypeRegistries=[Ae,c];var jt=[0,o,_r,8,0],wt=[0,o,et,8,0],Mt=[0,o,it,8,0],At=[0,o,lt,8,0],Ge=[0,o,ut,8,0];ze.CreateTokenRequest$=[3,o,tt,0,[It,Pt,qt,Dt,yt,je,ft,Rt,xt],[0,[()=>wt,0],0,0,0,[()=>Ge,0],64,0,[()=>Mt,0]],3];ze.CreateTokenResponse$=[3,o,ot,0,[St,Ut,bt,je,ht],[[()=>jt,0],0,1,[()=>Ge,0],[()=>At,0]]];ze.CreateToken$=[9,o,rt,{[Nt]:["POST","/token",200]},()=>ze.CreateTokenRequest$,()=>ze.CreateTokenResponse$]});var or=S((rr)=>{Object.defineProperty(rr,"__esModule",{value:!0});rr.getRuntimeConfig=void 0;var Tt=M(),Bt=Lt(),Vt=er(),Wt=f(),Yt=Ht(),ge=mt(),_e=zt(),Jt=A(),Kt=Ne(),Xt=g(),Ct=(e)=>{return{apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??ge.fromBase64,base64Encoder:e?.base64Encoder??ge.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??Kt.defaultEndpointResolver,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Jt.defaultSSOOIDCHttpAuthSchemeProvider,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(r)=>r.getIdentityProvider("aws.auth#sigv4"),signer:new Tt.AwsSdkSigV4Signer},{schemeId:"smithy.api#noAuth",identityProvider:(r)=>r.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Vt.NoAuthSigner}],logger:e?.logger??new Wt.NoOpLogger,protocol:e?.protocol??Bt.AwsRestJsonProtocol,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.ssooidc",errorTypeRegistries:Xt.errorTypeRegistries,version:"2019-06-10",serviceTarget:"AWSSSOOIDCService"},serviceId:e?.serviceId??"SSO OIDC",urlParser:e?.urlParser??Yt.parseUrl,utf8Decoder:e?.utf8Decoder??_e.fromUtf8,utf8Encoder:e?.utf8Encoder??_e.toUtf8}};rr.getRuntimeConfig=Ct});var Or=S((lr)=>{Object.defineProperty(lr,"__esModule",{value:!0});lr.getRuntimeConfig=void 0;var io=Zt(),so=io.__importDefault(_t()),ir=M(),sr=eo(),U=cr(),no=ro(),nr=ar(),x=gt(),pr=Qt(),dr=f(),po=to(),co=oo(),ao=kt(),lo=or(),uo=(e)=>{(0,dr.emitWarningIfUnsupportedVersion)(process.version);let r=(0,co.resolveDefaultsModeConfig)(e),i=()=>r().then(dr.loadConfigsForDefaultMode),a=(0,lo.getRuntimeConfig)(e);(0,ir.emitWarningIfUnsupportedVersion)(process.version);let s={profile:e?.profile,logger:a.logger};return{...a,...e,runtime:"node",defaultsMode:r,authSchemePreference:e?.authSchemePreference??(0,x.loadConfig)(ir.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS,s),bodyLengthChecker:e?.bodyLengthChecker??po.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,sr.createDefaultUserAgentProvider)({serviceId:a.serviceId,clientVersion:so.default.version}),maxAttempts:e?.maxAttempts??(0,x.loadConfig)(nr.NODE_MAX_ATTEMPT_CONFIG_OPTIONS,e),region:e?.region??(0,x.loadConfig)(U.NODE_REGION_CONFIG_OPTIONS,{...U.NODE_REGION_CONFIG_FILE_OPTIONS,...s}),requestHandler:pr.NodeHttpHandler.create(e?.requestHandler??i),retryMode:e?.retryMode??(0,x.loadConfig)({...nr.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await i()).retryMode||ao.DEFAULT_RETRY_MODE},e),sha256:e?.sha256??no.Hash.bind(null,"sha256"),streamCollector:e?.streamCollector??pr.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,x.loadConfig)(U.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS,s),useFipsEndpoint:e?.useFipsEndpoint??(0,x.loadConfig)(U.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,s),userAgentAppId:e?.userAgentAppId??(0,x.loadConfig)(sr.NODE_APP_ID_CONFIG_OPTIONS,s)}};lr.getRuntimeConfig=uo});var Yo=S((P)=>{var vr=vo(),Do=Eo(),bo=So(),Er=Io(),qo=cr(),_=er(),No=Ue(),ho=Po(),yr=xo(),Sr=ar(),y=f(),Ir=A(),Ro=Or(),Pr=yo(),xr=Oo(),h=g(),$=k(),fo=F(),Fo=(e)=>{return Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"})},Uo={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},$o=(e)=>{let{httpAuthSchemes:r,httpAuthSchemeProvider:i,credentials:a}=e;return{setHttpAuthScheme(s){let R=r.findIndex((j)=>j.schemeId===s.schemeId);if(R===-1)r.push(s);else r.splice(R,1,s)},httpAuthSchemes(){return r},setHttpAuthSchemeProvider(s){i=s},httpAuthSchemeProvider(){return i},setCredentials(s){a=s},credentials(){return a}}},jo=(e)=>{return{httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}},wo=(e,r)=>{let i=Object.assign(Pr.getAwsRegionExtensionConfiguration(e),y.getDefaultExtensionConfiguration(e),xr.getHttpHandlerExtensionConfiguration(e),$o(e));return r.forEach((a)=>a.configure(i)),Object.assign(e,Pr.resolveAwsRegionExtensionConfiguration(i),y.resolveDefaultRuntimeConfig(i),xr.resolveHttpHandlerRuntimeConfig(i),jo(i))};class ee extends y.Client{config;constructor(...[e]){let r=Ro.getRuntimeConfig(e||{});super(r);this.initConfig=r;let i=Fo(r),a=Er.resolveUserAgentConfig(i),s=Sr.resolveRetryConfig(a),R=qo.resolveRegionConfig(s),j=vr.resolveHostHeaderConfig(R),Dr=yr.resolveEndpointConfig(j),br=Ir.resolveHttpAuthSchemeConfig(Dr),qr=wo(br,e?.extensions||[]);this.config=qr,this.middlewareStack.use(No.getSchemaSerdePlugin(this.config)),this.middlewareStack.use(Er.getUserAgentPlugin(this.config)),this.middlewareStack.use(Sr.getRetryPlugin(this.config)),this.middlewareStack.use(ho.getContentLengthPlugin(this.config)),this.middlewareStack.use(vr.getHostHeaderPlugin(this.config)),this.middlewareStack.use(Do.getLoggerPlugin(this.config)),this.middlewareStack.use(bo.getRecursionDetectionPlugin(this.config)),this.middlewareStack.use(_.getHttpAuthSchemeEndpointRuleSetPlugin(this.config,{httpAuthSchemeParametersProvider:Ir.defaultSSOOIDCHttpAuthSchemeParametersProvider,identityProviderConfigProvider:async(Nr)=>new _.DefaultIdentityProviderConfig({"aws.auth#sigv4":Nr.credentials})})),this.middlewareStack.use(_.getHttpSigningPlugin(this.config))}destroy(){super.destroy()}}class re extends y.Command.classBuilder().ep(Uo).m(function(e,r,i,a){return[yr.getEndpointPlugin(i,e.getEndpointParameterInstructions())]}).s("AWSSSOOIDCService","CreateToken",{}).n("SSOOIDCClient","CreateTokenCommand").sc(h.CreateToken$).build(){}var Mo={CreateTokenCommand:re};class te extends ee{}y.createAggregatedClient(Mo,te);var Ao={KMS_ACCESS_DENIED:"KMS_AccessDeniedException"},Go={KMS_DISABLED_KEY:"KMS_DisabledException",KMS_INVALID_KEY_USAGE:"KMS_InvalidKeyUsageException",KMS_INVALID_STATE:"KMS_InvalidStateException",KMS_KEY_NOT_FOUND:"KMS_NotFoundException"};P.$Command=y.Command;P.__Client=y.Client;P.SSOOIDCServiceException=fo.SSOOIDCServiceException;P.AccessDeniedExceptionReason=Ao;P.CreateTokenCommand=re;P.InvalidRequestExceptionReason=Go;P.SSOOIDC=te;P.SSOOIDCClient=ee;Object.prototype.hasOwnProperty.call(h,"__proto__")&&!Object.prototype.hasOwnProperty.call(P,"__proto__")&&Object.defineProperty(P,"__proto__",{enumerable:!0,value:h.__proto__});Object.keys(h).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(P,e))P[e]=h[e]});Object.prototype.hasOwnProperty.call($,"__proto__")&&!Object.prototype.hasOwnProperty.call(P,"__proto__")&&Object.defineProperty(P,"__proto__",{enumerable:!0,value:$.__proto__});Object.keys($).forEach(function(e){if(e!=="default"&&!Object.prototype.hasOwnProperty.call(P,e))P[e]=$[e]})});export default Yo();
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=33179D909EE6DB4364756E2164756E21
|