@north-light/cli 0.3.616 → 0.3.618
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/core/blobs/directory.js +1 -1
- package/dist/core/blobs/index.d.ts +8 -0
- package/dist/core/blobs/r2.d.ts +2 -0
- package/dist/core/blobs/r2.js +6 -6
- package/dist/core/import/load/blobs.js +1 -1
- package/dist/core/llm/app-rungs.d.ts +1 -1
- package/dist/core/llm/app-rungs.js +1 -1
- package/dist/core/llm/owner-candidates.d.ts +6 -3
- package/dist/core/llm/owner-candidates.js +1 -1
- package/dist/core/llm/run.js +2 -2
- package/dist/core/model-auth/readiness.js +1 -1
- package/dist/core/runtime/broker/model-adapter.d.ts +2 -1
- package/dist/core/runtime/broker/model-adapter.js +3 -3
- package/dist/daemon/http-dispatcher.d.ts +3 -0
- package/dist/daemon/http-dispatcher.js +1 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
var k=Object.defineProperty;var
|
|
1
|
+
var k=Object.defineProperty;var a=(i,n)=>k(i,"name",{value:n,configurable:!0});import{createHash as j,randomUUID as g}from"node:crypto";import{closeSync as d,existsSync as z,fsyncSync as S,linkSync as B,lstatSync as U,mkdirSync as x,openSync as p,readFileSync as w,readSync as W,readdirSync as D,realpathSync as M,renameSync as P,rmSync as l,rmdirSync as $,statSync as T,writeSync as v}from"node:fs";import{dirname as N,join as m,resolve as X}from"node:path";import{assertBlobKey as Y}from"./index.js";import{blobFault as F}from"./fault.js";function I(i){const n=p(i,"r");try{S(n)}finally{d(n)}}a(I,"syncDir");function Q(i,n,y=B){let s;try{s=M(i)}catch(t){if(t.code==="ENOENT")return;throw t}if(s===X(n))return;const u=new Set,r=a((t,o)=>{let c;try{c=D(t,{withFileTypes:!0})}catch(e){if(e.code==="ENOENT")return;throw e}for(const e of c){if(e.name.endsWith(".tmp"))continue;const f=m(t,e.name),O=m(o,e.name);if(e.isDirectory()){r(f,O);try{$(f)}catch(E){if(!["ENOTEMPTY","ENOENT"].includes(E.code??""))throw E}continue}const h=m(n,O);x(N(h),{recursive:!0,mode:448}),u.add(N(h));try{y(f,h)}catch(E){const b=E.code;if(b==="EEXIST"){H(f,h)&&l(f,{force:!0});continue}if(b==="ENOENT"||!K(f,h))continue}l(f,{force:!0})}},"adopt");r(s,"");for(const t of u)I(t);try{$(s)}catch(t){if(!["ENOTEMPTY","ENOENT"].includes(t.code??""))throw t}U(i,{throwIfNoEntry:!1})?.isSymbolicLink()&&!z(i)&&l(i,{force:!0})}a(Q,"adoptBlobDirectory");function H(i,n){try{const y=T(i),s=T(n);return y.ino===s.ino&&y.dev===s.dev}catch{return!1}}a(H,"sameFile");function K(i,n){const y=`${n}.${g()}.tmp`;try{const s=p(y,"wx",384);try{let u;try{u=w(i)}catch(t){if(t.code==="ENOENT")return!1;throw t}let r=0;for(;r<u.length;)r+=v(s,u,r);S(s)}finally{d(s)}try{B(y,n)}catch(u){if(u.code==="EEXIST")return!1;throw u}return!0}finally{l(y,{force:!0})}}a(K,"copyInto");function R(i){const n=a(r=>(Y(r),m(i,...r.split("/"))),"pathOf");function y(r,t,o){let c;try{c=D(r,{withFileTypes:!0})}catch(e){if(e.code==="ENOENT")return;throw e}for(const e of c){if(e.name.endsWith(".tmp"))continue;const f=t===""?e.name:`${t}/${e.name}`;e.isDirectory()?y(m(r,e.name),f,o):o.push(f)}}a(y,"walk");function s(r,t){x(N(r),{recursive:!0,mode:448});const o=`${r}.${g()}.tmp`,c=p(o,"wx",384);try{let e=0;for(;e<t.length;)e+=v(c,t,e);S(c)}catch(e){throw d(c),l(o,{force:!0}),e}d(c),P(o,r),I(N(r))}a(s,"write");const u={async put(r,t){F("put"),s(n(r),typeof t=="string"?Buffer.from(t,"utf8"):Buffer.from(t))},async head(r){let t;try{t=w(n(r))}catch(o){if(o.code==="ENOENT")return null;throw o}return{size:t.length,etag:j("md5").update(t).digest("hex")}},async copy(r,t){F("copy");const o=n(r),c=n(t);let e;try{e=w(o)}catch(f){if(f.code==="ENOENT")return!1;throw f}return s(c,e),!0},async get(r,t){try{if(!t)return w(n(r));const o=p(n(r),"r");try{const c=Buffer.allocUnsafe(t.length),e=W(o,c,0,t.length,t.start);return c.subarray(0,e)}finally{d(o)}}catch(o){if(o.code==="ENOENT")return null;throw o}},async list(r){const t=[];return y(i,"",t),t.filter(o=>o.startsWith(r)).sort((o,c)=>Buffer.compare(Buffer.from(o),Buffer.from(c)))},async listObjects(r){const t=[];for(const o of await u.list(r))try{t.push({key:o,size:T(n(o)).size,etag:null})}catch(c){if(c.code!=="ENOENT")throw c}return t},async delete(r){l(n(r),{force:!0})}};return u}a(R,"createDirectoryBlobStore");export{Q as adoptBlobDirectory,R as createDirectoryBlobStore};
|
|
@@ -11,6 +11,8 @@ export interface BlobStore {
|
|
|
11
11
|
}): Promise<Buffer | null>;
|
|
12
12
|
/** Every key beginning with `prefix`, in ascending byte order. */
|
|
13
13
|
list(prefix: string): Promise<string[]>;
|
|
14
|
+
/** Every object whose key begins with `prefix`, in the order of `list`, each with the size and etag `head` would report: one paged listing instead of a `head` per key. */
|
|
15
|
+
listObjects(prefix: string): Promise<BlobObject[]>;
|
|
14
16
|
/** The object's size and content hash without its bytes, or `null` when no object has this key. `etag` is the hex MD5 of the bytes when the store knows it (an object written in one piece), else `null`: equal sizes and equal non-null etags mean equal bytes. */
|
|
15
17
|
head(key: string): Promise<{
|
|
16
18
|
size: number;
|
|
@@ -21,6 +23,12 @@ export interface BlobStore {
|
|
|
21
23
|
/** Remove the object at `key`; removing an absent key is not an error. */
|
|
22
24
|
delete(key: string): Promise<void>;
|
|
23
25
|
}
|
|
26
|
+
/** An object as `listObjects` and `head` describe it. */
|
|
27
|
+
export interface BlobObject {
|
|
28
|
+
key: string;
|
|
29
|
+
size: number;
|
|
30
|
+
etag: string | null;
|
|
31
|
+
}
|
|
24
32
|
/** A key is safe when it is a relative path of plain segments. Throws on anything else. */
|
|
25
33
|
export declare function assertBlobKey(key: string): void;
|
|
26
34
|
export declare function blobStore(): Promise<BlobStore>;
|
package/dist/core/blobs/r2.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface R2Config {
|
|
|
5
5
|
accessKeyId: string;
|
|
6
6
|
secretAccessKey: string;
|
|
7
7
|
}
|
|
8
|
+
/** Connections to R2 at once, kept alive and reused. This is the import's blob step worker count, so that step never queues below its old concurrency; without reuse each of its requests opened its own connection and the TLS handshakes cost more CPU than the requests. */
|
|
9
|
+
export declare const R2_MAX_CONNECTIONS = 256;
|
|
8
10
|
/** S3-compatible object store (R2) over `fetch`: path-style requests signed with SigV4, region `auto`. */
|
|
9
11
|
export declare function createR2BlobStore(config: R2Config): BlobStore;
|
|
10
12
|
/** The R2 settings of this process, or `null` when it uses the directory store. Same variables as `blobStore()`. */
|
package/dist/core/blobs/r2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).join(""),
|
|
3
|
-
`),
|
|
4
|
-
`),
|
|
1
|
+
var D=Object.defineProperty;var i=(n,a)=>D(n,"name",{value:a,configurable:!0});import{createHash as M,createHmac as C}from"node:crypto";import{fetch as O}from"undici";import{createHttpAgent as P}from"../../daemon/http-dispatcher.js";import{assertBlobKey as w}from"./index.js";import{blobFault as K}from"./fault.js";const _=i(n=>M("sha256").update(n).digest("hex"),"sha256"),m=i((n,a)=>C("sha256",n).update(a).digest(),"hmac"),$=i(n=>encodeURIComponent(n).replace(/[!'()*]/g,a=>`%${a.charCodeAt(0).toString(16).toUpperCase()}`),"encode"),X=5,k=200,L=256,W=3e4,b=i(n=>/^(?:"|")?([0-9a-f]{32})(?:"|")?$/.exec(n??"")?.[1]??null,"md5Etag"),v={"&":"&","<":"<",">":">",""":'"',"'":"'"},Y=i(n=>n.replace(/&(?:amp|lt|gt|quot|apos);/g,a=>v[a]),"unescapeXml");function et(n){const a=new URL(n.endpoint),y=P({connections:L,keepAliveTimeout:W});async function u(t,e,s,o,c,d={}){for(let f=1;;f++){let r,p;try{r=await S(t,e,s,o,c,d)}catch(l){p=l}if(r&&r.status!==429&&r.status<500)return r;if(f===X){if(r)return r;throw p}await r?.arrayBuffer().catch(()=>{}),await new Promise(l=>setTimeout(l,k*2**(f-1)*(.5+Math.random())))}}i(u,"send");async function S(t,e,s,o,c,d){const f=`/${$(n.bucket)}${e===""?"":`/${e.split("/").map($).join("/")}`}`,r=[...s].sort(([A],[T])=>A<T?-1:1).map(([A,T])=>`${$(A)}=${$(T)}`).join("&"),p=new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),l=p.slice(0,8),R=_(o??""),E={host:a.host,"x-amz-content-sha256":R,"x-amz-date":p,...d},x=Object.keys(E).sort(),I=x.map(A=>`${A}:${E[A]}
|
|
2
|
+
`).join(""),z=x.join(";"),B=`${l}/auto/s3/aws4_request`,j=[t,f,r,I,z,R].join(`
|
|
3
|
+
`),q=["AWS4-HMAC-SHA256",p,B,_(j)].join(`
|
|
4
|
+
`),N=m(m(m(m(`AWS4${n.secretAccessKey}`,l),"auto"),"s3"),"aws4_request"),U=C("sha256",N).update(q).digest("hex");E.authorization=`AWS4-HMAC-SHA256 Credential=${n.accessKeyId}/${B}, SignedHeaders=${z}, Signature=${U}`;const{host:G,...H}=E;return c&&(H.range=`bytes=${c.start}-${c.start+c.length-1}`),await O(`${a.origin}${f}${r?`?${r}`:""}`,{dispatcher:y,method:t,headers:H,...o?{body:new Uint8Array(o)}:{}})}i(S,"sendOnce");async function h(t,e){if(!t.ok)throw new Error(`R2 ${e} failed (${t.status}): ${(await t.text()).slice(0,300)}`);return t}i(h,"ok");async function g(t){const e=[];let s;do{const o=[["list-type","2"],["prefix",t],...s?[["continuation-token",s]]:[]],c=await(await h(await u("GET","",o),`list ${t}`)).text();for(const[,d]of c.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){const f=/<Key>([^<]*)<\/Key>/.exec(d)?.[1],r=/<Size>(\d+)<\/Size>/.exec(d)?.[1];if(f===void 0||r===void 0)throw new Error(`R2 list ${t} returned an entry without a key and size: ${d.slice(0,300)}`);e.push({key:Y(f),size:Number(r),etag:b(/<ETag>([^<]*)<\/ETag>/.exec(d)?.[1])})}s=/<IsTruncated>true<\/IsTruncated>/.test(c)?/<NextContinuationToken>([^<]*)<\/NextContinuationToken>/.exec(c)?.[1]:void 0}while(s);return e.sort((o,c)=>Buffer.compare(Buffer.from(o.key),Buffer.from(c.key)))}return i(g,"listObjects"),{async put(t,e){K("put"),w(t),await h(await u("PUT",t,[],typeof e=="string"?Buffer.from(e,"utf8"):Buffer.from(e)),`put ${t}`)},async head(t){w(t);const e=await u("HEAD",t,[]);return e.status===404?null:(await h(e,`head ${t}`),{size:Number(e.headers.get("content-length")),etag:b(e.headers.get("etag"))})},async copy(t,e){K("copy"),w(t),w(e);const s=await u("PUT",e,[],void 0,void 0,{"x-amz-copy-source":`/${$(n.bucket)}/${t.split("/").map($).join("/")}`});if(s.status===404)return await s.arrayBuffer(),!1;const o=await(await h(s,`copy ${t} to ${e}`)).text();if(/<Error>/.test(o))throw new Error(`R2 copy ${t} to ${e} failed: ${o.slice(0,300)}`);return!0},async get(t,e){w(t);const s=await u("GET",t,[],void 0,e);return s.status===416?(await s.arrayBuffer(),Buffer.alloc(0)):s.status===404?(await s.arrayBuffer(),null):Buffer.from(await(await h(s,`get ${t}`)).arrayBuffer())},async list(t){return(await g(t)).map(e=>e.key)},listObjects:g,async delete(t){w(t);const e=await u("DELETE",t,[]);e.status!==404?await h(e,`delete ${t}`):await e.arrayBuffer()}}}i(et,"createR2BlobStore");function nt(){const n=process.env.CRTR_R2_BUCKET;if(!n)return null;const a=i(y=>{const u=process.env[y];if(!u)throw new Error(`${y} is required when CRTR_R2_BUCKET is set`);return u},"need");return{bucket:n,endpoint:a("CRTR_R2_ENDPOINT"),accessKeyId:a("CRTR_R2_ACCESS_KEY_ID"),secretAccessKey:a("CRTR_R2_SECRET_ACCESS_KEY")}}i(nt,"r2ConfigFromEnv");function st(n,a,y,u=new Date){w(a);const S=new URL(n.endpoint),h=`/${$(n.bucket)}/${a.split("/").map($).join("/")}`,g=u.toISOString().replace(/[:-]|\.\d{3}/g,""),t=g.slice(0,8),e=`${t}/auto/s3/aws4_request`,o=[["X-Amz-Algorithm","AWS4-HMAC-SHA256"],["X-Amz-Credential",`${n.accessKeyId}/${e}`],["X-Amz-Date",g],["X-Amz-Expires",String(y)],["X-Amz-SignedHeaders","host"]].sort(([p],[l])=>p<l?-1:1).map(([p,l])=>`${$(p)}=${$(l)}`).join("&"),c=["PUT",h,o,`host:${S.host}
|
|
5
5
|
`,"host","UNSIGNED-PAYLOAD"].join(`
|
|
6
|
-
`),
|
|
7
|
-
`)
|
|
6
|
+
`),d=["AWS4-HMAC-SHA256",g,e,_(c)].join(`
|
|
7
|
+
`),f=m(m(m(m(`AWS4${n.secretAccessKey}`,t),"auto"),"s3"),"aws4_request"),r=C("sha256",f).update(d).digest("hex");return`${S.origin}${h}?${o}&X-Amz-Signature=${r}`}i(st,"presignPutUrl");export{L as R2_MAX_CONNECTIONS,et as createR2BlobStore,st as presignPutUrl,nt as r2ConfigFromEnv};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Object.defineProperty;var i=(e,t)=>S(e,"name",{value:t,configurable:!0});import{R2_MAX_CONNECTIONS as k}from"../../blobs/r2.js";import{parseBlobKey as v,runBlobPrefix as g}from"../bundle/blob-keys.js";import{q as h}from"./catalog.js";import{ImportLaneError as R}from"./stage.js";const B=k;function M(){const e=process.env.CRTR_IMPORT_BLOB_WORKERS;if(e===void 0||e==="")return B;const t=Number(e);if(!Number.isInteger(t)||t<1||t>1024)throw new Error(`CRTR_IMPORT_BLOB_WORKERS must be an integer from 1 to 1024, got ${JSON.stringify(e)}`);return t}i(M,"workerLimit");async function m(e,t){if(e.length===0)return;let a=0,n;const s=i(async()=>{for(;n===void 0&&a<e.length;)try{await t(e[a++])}catch(c){n??={error:c}}},"worker");if(await Promise.all(Array.from({length:Math.min(M(),e.length)},s)),n!==void 0)throw n.error}i(m,"forEachBounded");async function A(e,t,a,n,s,c,l){const _={nodes:new Set((await e.prepareUncached(`SELECT node_id AS v FROM ${h(t)}.nodes UNION SELECT node_id FROM ${h(a)}.nodes WHERE sub = ?`).all(n)).map(r=>r.v)),human_requests:new Set((await e.prepareUncached(`SELECT request_id AS v FROM ${h(t)}.human_requests`).all()).map(r=>r.v))},f=g(c),u={moved:0,left:0},w=[];for(const r of await s.listObjects(f)){const o=v(r.key.slice(f.length));o===null||!_[o.ownerTable].has(o.owner)?u.left+=1:w.push(r)}const y=new Map,d=new Set(w.map(r=>r.key.slice(f.length)));return await m([...new Set([...d].map(T))],async r=>{for(const o of await s.listObjects(r))d.has(o.key)&&y.set(o.key,o)}),await m(w,async r=>{const o=r.key.slice(f.length),p=y.get(o);if(p===void 0){if(l.push(o),!await s.copy(r.key,o))throw O(r.key)}else if(!await C(s,r,p))throw new R("blobs","unique_conflict",`${o} already exists with other contents; the import does not replace it`,{key:o});u.moved+=1}),u}i(A,"moveRunBlobs");const T=i(e=>e.split("/").slice(0,2).join("/")+"/","ownerPrefix"),O=i(e=>new R("blobs","bundle_invalid",`${e} was listed and is gone`),"gone");async function C(e,t,a){if(t.size!==a.size)return!1;if(t.etag!==null&&a.etag!==null)return t.etag===a.etag;for(let n=0;n<t.size;n+=E){const s={start:n,length:Math.min(E,t.size-n)},[c,l]=await Promise.all([e.get(t.key,s),e.get(a.key,s)]);if(c===null)throw O(t.key);if(l===null||!c.equals(l))return!1}return!0}i(C,"sameObject");const E=256*1024;async function N(e,t,a=!1){await m(t,a?n=>e.delete(n).catch(()=>{}):n=>e.delete(n))}i(N,"deleteBlobs");async function I(e,t){await N(e,await e.list(g(t)))}i(I,"deleteRunBlobs");export{N as deleteBlobs,I as deleteRunBlobs,A as moveRunBlobs};
|
|
@@ -7,7 +7,7 @@ export interface AppRung {
|
|
|
7
7
|
/** The rung the endpoint serves at `strength`, or the nearest declared one (the stronger on a tie). */
|
|
8
8
|
export declare function rungAt(endpoint: InferenceEndpoint, strength: ModelStrength): AppRung;
|
|
9
9
|
/** The rung a request for `requested` lands on. An omitted model is the `strong` rung. An exact request for a
|
|
10
|
-
* concrete id outside the rungs is refused `substitution_refused
|
|
10
|
+
* concrete id outside the rungs is refused `substitution_refused`; one inside keeps its requested thinking level. */
|
|
11
11
|
export declare function resolveAppRung(endpoint: InferenceEndpoint, requested: string | undefined, exact?: boolean): AppRung;
|
|
12
12
|
/** Every rung in the order `llm` tries them: the requested rung first, then the declared rungs by distance. */
|
|
13
13
|
export declare function appCandidates(endpoint: InferenceEndpoint, requested: string | undefined, exact?: boolean): AppRung[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=Object.defineProperty;var s=(e,r)=>m(e,"name",{value:r,configurable:!0});import{defaultModelLaddersConfig as b}from"../../types.js";import{MODEL_STRENGTHS as w,stripThinkingSuffix as l}from"../runtime/model-selection.js";import{modelTokenStrength as x}from"../runtime/launch.js";import{RunError as u}from"../runs/operations.js";import{grantRecord as O}from"../grants/mirror.js";const o=w;function p(e,r){const t=o.indexOf(r);return o.filter(n=>e.rungs[n]!==void 0).sort((n,i)=>Math.abs(o.indexOf(n)-t)-Math.abs(o.indexOf(i)-t)||o.indexOf(n)-o.indexOf(i)).map(n=>({strength:n,model:e.rungs[n]}))}s(p,"rungsByDistance");function d(e,r){const t=p(e,r)[0];if(t===void 0)throw new u(404,"model_unavailable","the app's inference endpoint declares no rung");return t}s(d,"rungAt");function g(e,r,t=!1){if(r===void 0||r==="")return d(e,"strong");const n=x(r)??void 0;if(n!==void 0)return d(e,n);const i=l(r),f=o.find(a=>e.rungs[a]===i);if(f!==void 0)return{strength:f,model:`${e.rungs[f]}${t?r.slice(i.length):""}`};if(t)throw new u(400,"substitution_refused",`model '${r}' is not one of this app's inference rungs`);const c=b(),h=[...Object.entries(c.anthropic),...Object.entries(c.openai)].find(([,a])=>l(a)===i);return d(e,h?.[0]??"strong")}s(g,"resolveAppRung");function $(e,r,t=!1){const n=g(e,r,t);if(t)return[n];const i=p(e,n.strength).filter(f=>f.strength!==n.strength);return[n,...i]}s($,"appCandidates");async function v(e,r,t=!1){const n=e?await O(e):null;if(n?.payer!=="app")return null;if(!n.inference_endpoint)throw new u(404,"model_unavailable",`${n.grantee} is app-paid but its grant carries no inference endpoint`);return g(n.inference_endpoint,r,t)}s(v,"appRungForGrant");export{$ as appCandidates,v as appRungForGrant,g as resolveAppRung,d as rungAt};
|
|
@@ -2,6 +2,7 @@ import type { LlmRequest } from './run.js';
|
|
|
2
2
|
import { type MergedLaunchConfig } from '../config.js';
|
|
3
3
|
import { type ModelRequest, type RoutedCandidate } from '../model-routes.js';
|
|
4
4
|
import { openModelRegistry } from '../runtime/model-registry.js';
|
|
5
|
+
import type { HostedEndpoint } from '../grants/hosted-endpoint.js';
|
|
5
6
|
export declare function requestFor(model: string | undefined, policy: LlmRequest['model_policy'], cwd?: string, profileId?: string | null, config?: MergedLaunchConfig): ModelRequest;
|
|
6
7
|
/** Whether the catalog model behind `candidate` can serve the request's features (reasoning, seed, response format, stop). */
|
|
7
8
|
export declare function matchesFeatures(registry: Awaited<ReturnType<typeof openModelRegistry>>, input: OwnerCandidateInput, candidate: RoutedCandidate): boolean;
|
|
@@ -11,7 +12,9 @@ export declare function ownerCandidates(registry: Awaited<ReturnType<typeof open
|
|
|
11
12
|
cwd: string;
|
|
12
13
|
profileId: string | null;
|
|
13
14
|
}, config?: MergedLaunchConfig): Promise<RoutedCandidate[]>;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
15
|
+
/** The hosted endpoint's route for a call (contract §5), added as its last route; `runLlm` asks it, and so does every gate that asks whether a
|
|
16
|
+
* launch can run without a credential of its own. A request for a strength takes the rung of the strength the first owner candidate names,
|
|
17
|
+
* so it needs one. An exact request takes the endpoint only when a rung serves that same provider/model, keeping the requested thinking
|
|
18
|
+
* level and never another model; an endpoint that does not offer the model adds no route. */
|
|
19
|
+
export declare function hostedRoute(input: Pick<LlmRequest, 'model' | 'model_policy'>, candidates: readonly RoutedCandidate[], endpoint: HostedEndpoint): RoutedCandidate | undefined;
|
|
17
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var a=(r,e)=>x(r,"name",{value:e,configurable:!0});import{readMergedLaunchConfig as g}from"../config.js";import{APP_FAMILY as L,expandModelCandidates as I,parseModelSpec as m}from"../model-routes.js";import{MODEL_STRENGTHS as w}from"../runtime/model-selection.js";function y(r,e,n,d,i){const s=a(()=>{const o=i??g(n,d),f=Object.values({...o.modelRoutes??{},...o.legacyModelRoutes??{}});return f.length?[o.modelLadders.defaultProvider,...o.modelRouting?.familyOrder??[],...f.map(l=>l.family)].find(l=>f.some(p=>p.family===l)):o.modelLadders.defaultProvider??"anthropic"},"ownerFamily");if(!r){const o=s();return{kind:"logical",family:o,strength:"strong",spec:`${o}/strong`}}const t=/^([^/]+)\/(ultra|strong|medium|light)$/.exec(r);if(t){if(t[1]===L){const o=s();return{kind:"logical",family:o,strength:t[2],spec:`${o}/${t[2]}`}}return{kind:"logical",family:t[1],strength:t[2],spec:r}}return{kind:e==="exact"?"exact":"concrete",spec:r}}a(y,"requestFor");const k=a(r=>r.unrouted!==!0,"configured");function v(r,e,n){const d=r.find(n.providerId,n.modelId);return d!==void 0&&(!e.reasoning_effort||d.reasoning)&&(e.seed===void 0&&e.response_format===void 0||d.api==="openai-completions")&&(e.stop===void 0||["openai-completions","anthropic-messages"].includes(d.api))}a(v,"matchesFeatures");async function $(r,e,n,d){const i=y(e.model,e.model_policy,n?.cwd,n?.profileId,d),s=(await I(i.kind==="exact"?{kind:"concrete",spec:i.spec}:i,n?.cwd,n?.profileId,d)).filter(k);let t;if(i.kind==="logical")t=e.model_policy==="exact"?s.filter(o=>o.family===i.family&&o.strength===i.strength).slice(0,1):s;else{const o=m(i.spec),f=s.filter(l=>l.providerId===o?.providerId&&l.modelId===o.modelId&&(e.model_policy!=="exact"||l.thinkingLevel===o.thinkingLevel)&&v(r,e,l));if(e.model_policy==="exact")t=f.slice(0,1);else if(f.length)t=f;else{const l=d??g(n?.cwd,n?.profileId),u=[...Object.values(l.modelRoutes??{}).flatMap(c=>Object.entries(c.models)),...[l.modelLadders.anthropic,l.modelLadders.openai].flatMap(c=>Object.entries(c))].find(([,c])=>c===i.spec)?.[0],h=y(void 0,"substitute",n?.cwd,n?.profileId,d);t=u&&h.kind==="logical"?(await I({...h,strength:u,spec:i.spec},n?.cwd,n?.profileId,d)).filter(c=>k(c)&&c.strength===u):[]}}return t.filter(o=>v(r,e,o))}a($,"ownerCandidates");function b(r,e,n){if(r.model_policy!=="exact"){if(e.length===0)return;const s=e[0].strength,t=m(`anthropic/${n.rungs[s]}`);return t?{routeId:"hosted",credentialSource:"hosted",family:"hosted",strength:s,...t,rank:e.length}:void 0}const d=r.model===void 0?void 0:m(r.model);if(d?.providerId!=="anthropic")return;const i=w.find(s=>m(`anthropic/${n.rungs[s]}`)?.modelId===d.modelId);return i===void 0?void 0:{routeId:"hosted",credentialSource:"hosted",family:"hosted",strength:i,providerId:d.providerId,modelId:d.modelId,...d.thinkingLevel!==void 0?{thinkingLevel:d.thinkingLevel}:{},rank:e.length}}a(b,"hostedRoute");export{b as hostedRoute,v as matchesFeatures,$ as ownerCandidates,y as requestFor};
|
package/dist/core/llm/run.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var We=Object.defineProperty;var c=(e,t)=>We(e,"name",{value:t,configurable:!0});import{randomUUID as He}from"node:crypto";import{streamSimple as ze}from"@earendil-works/pi-ai/compat";import{keyRouteProviders as Xe,probeRouteAvailability as Ge}from"../model-routes-pool.js";import{KEY_CREDENTIAL_SOURCE as Ve,parseModelSpec as
|
|
1
|
+
var We=Object.defineProperty;var c=(e,t)=>We(e,"name",{value:t,configurable:!0});import{randomUUID as He}from"node:crypto";import{streamSimple as ze}from"@earendil-works/pi-ai/compat";import{keyRouteProviders as Xe,probeRouteAvailability as Ge}from"../model-routes-pool.js";import{KEY_CREDENTIAL_SOURCE as Ve,parseModelSpec as Ye}from"../model-routes.js";import{openModelRegistry as Ze}from"../runtime/model-registry.js";import{isInvalidRefreshTokenError as Qe}from"../managed-providers.js";import{MAX_RATE_LIMIT_COOLDOWN_MS as $e,coolingUntilFor as Ce,isManagedProvider as W,markSubscriptionRateLimited as et,markSubscriptionSuccess as tt,readSubscriptionPool as nt,retryAfterMsFromHeaders as H,retryAfterMsFromError as ot,refreshSubscriptionCredential as rt,subscriptionNeedsSuccessWrite as it,RefreshBusyError as at,RefreshTimeoutError as st}from"../subscription-state.js";import{classifyRateLimit as dt,describeRateLimitScope as Ee,rateLimitHeaders as lt}from"../rate-limit-scope.js";import{RunError as r}from"../runs/operations.js";import{recognizeProviderError as ge}from"../provider-error-recognition.js";import{isSafetyRefusal as ut}from"./refusal.js";import{findRefusal as ct,payerOf as Se,refusalError as ft,refusedMark as mt,writeCharge as we}from"../ledger/index.js";import{storedApiKey as Ie}from"../auth-file.js";import{eligibleHostedEndpoint as pt,readHostedEndpoint as Oe}from"../grants/hosted-endpoint.js";import{parseProviderPayment as ht}from"../provider-failure.js";import{personIdAsync as _t}from"../canvas/person.js";import{getNode as De}from"../canvas/canvas.js";import{outboundToken as Ne}from"../providers/mint.js";import{discardFile as Te}from"../providers/token-cache.js";import{ProviderError as yt}from"../providers/errors.js";import{appCandidates as gt}from"./app-rungs.js";import{hostedRoute as wt,matchesFeatures as bt,ownerCandidates as vt}from"./owner-candidates.js";function kt(e){return typeof e=="string"||e===null||Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&(t.type==="text"&&typeof t.text=="string"||t.type==="image_url"&&typeof t.image_url?.url=="string"&&/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(t.image_url.url)))}c(kt,"validContent");function Fe(e){return Array.isArray(e)?e.map(t=>{if(t.type==="text")return t;const[,o,s]=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.*)$/.exec(t.image_url.url);return{type:"image",mimeType:o,data:s}}):e??""}c(Fe,"imageContent");function xt(e,t){const o=(e instanceof Error?e.message:String(e)).split("; stack=",1)[0],s=ge({message:o}).kind;return s!=="connection"&&s!=="connection-only"?e:new r(503,"upstream_model_unavailable",o.slice(0,500),void 0,{served_model:t})}c(xt,"refreshFailure");function nn(e){if(!e||typeof e!="object"||Array.isArray(e))throw new r(400,"invalid_request","body must be an object");const t=e;if(!Array.isArray(t.messages)||!t.messages.every(o=>o&&typeof o=="object"&&["system","user","assistant","tool"].includes(o.role)&&kt(o.content)))throw new r(400,"invalid_request","messages must be chat messages","messages");if(t.messages.some(o=>["system","assistant"].includes(o.role)&&typeof o.content!="string"&&o.content!==null))throw new r(400,"invalid_request","system and assistant content must be text","messages");if(t.model!==void 0&&typeof t.model!="string")throw new r(400,"invalid_request","model must be a string","model");if(t.model_policy!==void 0&&!["exact","substitute"].includes(t.model_policy))throw new r(400,"invalid_request","invalid model_policy","model_policy");if(t.payer!==void 0&&!["user","app"].includes(t.payer))throw new r(400,"invalid_request","invalid payer","payer");if(t.reasoning_effort!==void 0&&!["minimal","low","medium","high","xhigh","max"].includes(t.reasoning_effort))throw new r(400,"invalid_request","invalid reasoning_effort","reasoning_effort");if(t.stream!==void 0&&typeof t.stream!="boolean")throw new r(400,"invalid_request","stream must be boolean","stream");if(t.tools!==void 0&&(!Array.isArray(t.tools)||!t.tools.every(o=>o?.type==="function"&&typeof o.function?.name=="string"&&o.function.name.length>0&&(o.function.description===void 0||typeof o.function.description=="string")&&(o.function.parameters===void 0||o.function.parameters!==null&&typeof o.function.parameters=="object"&&!Array.isArray(o.function.parameters)&&o.function.parameters.type==="object"))))throw new r(400,"invalid_request","invalid tools","tools");if(t.tool_choice!==void 0&&t.tool_choice!=="auto"&&t.tool_choice!=="none"&&t.tool_choice!=="required"&&(typeof t.tool_choice!="object"||t.tool_choice===null||t.tool_choice.type!=="function"||typeof t.tool_choice.function?.name!="string"))throw new r(400,"invalid_request","invalid tool_choice","tool_choice");if(t.messages.some(o=>o.role==="assistant"&&o.tool_calls!==void 0&&(!Array.isArray(o.tool_calls)||!o.tool_calls.every(s=>s&&typeof s.id=="string"&&typeof s.function?.name=="string"&&typeof s.function.arguments=="string"&&Rt(s.function.arguments)))))throw new r(400,"invalid_request","invalid assistant tool_calls","messages");if(t.stop!==void 0&&!(typeof t.stop=="string"||Array.isArray(t.stop)&&t.stop.every(o=>typeof o=="string")))throw new r(400,"invalid_request","invalid stop","stop");if(t.seed!==void 0&&!Number.isSafeInteger(t.seed))throw new r(400,"invalid_request","invalid seed","seed");for(const[o,s]of[["temperature",t.temperature],["top_p",t.top_p],["max_tokens",t.max_tokens]])if(s!==void 0&&(typeof s!="number"||!Number.isFinite(s)||o==="temperature"&&(s<0||s>2)||o==="top_p"&&(s<0||s>1)||o==="max_tokens"&&(!Number.isSafeInteger(s)||s<1)))throw new r(400,"invalid_request",`invalid ${o}`,o);if(t.response_format!==void 0){const o=t.response_format;if(!o||typeof o!="object"||Array.isArray(o)||!["text","json_object","json_schema"].includes(o.type)||o.type==="json_schema"&&(typeof o.json_schema?.name!="string"||!o.json_schema.name||!o.json_schema.schema||typeof o.json_schema.schema!="object"||Array.isArray(o.json_schema.schema)))throw new r(400,"invalid_request","invalid response_format","response_format")}if(t.metadata!==void 0&&Buffer.byteLength(JSON.stringify(t.metadata)??"")>4096)throw new r(400,"invalid_request","metadata exceeds 4 KB","metadata");return t}c(nn,"parseLlmRequest");function Rt(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}c(Rt,"isJsonObject");function At(e){const t=Date.now(),o=e.messages.map(i=>i.role==="system"?{role:"system",content:i.content??"",timestamp:t}:i.role==="tool"?{role:"toolResult",toolCallId:i.tool_call_id??"",toolName:"",content:typeof i.content=="string"||i.content===null?[{type:"text",text:i.content??""}]:Fe(i.content),isError:!1,timestamp:t}:i.role==="assistant"?{role:"assistant",content:[...i.content?[{type:"text",text:i.content}]:[],...(i.tool_calls??[]).map(_=>({type:"toolCall",id:_.id,name:_.function.name,arguments:JSON.parse(_.function.arguments)}))],api:"openai-completions",provider:"openai",model:e.model??"",usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:t}:{role:"user",content:Fe(i.content),timestamp:t}),s=o.findIndex(i=>i.role!=="system"),d=o.slice(0,s<0?o.length:s).map(i=>i.content),E=d.join(`
|
|
2
2
|
|
|
3
|
-
`),z=e.tools?.map(({function:i})=>({name:i.name,description:i.description??"",parameters:i.parameters??{type:"object",properties:{}}}));return{...S?{systemPrompt:S}:{},messages:o.slice(d.length),...z?{tools:z}:{}}}c(Rt,"contextOf");function At(e){return pt(e?.payment)}c(At,"paymentOf");function qt(e,t){const o=e.find("anthropic",t);if(o)return o;const a=e.getAll().find(d=>d.provider==="anthropic"&&d.api==="anthropic-messages");return a?{...a,id:t,name:t}:void 0}c(qt,"hostedModel");function jt(e,t){const{input:o,output:a,cacheRead:d,cacheWrite:S}=e.cost;return o===0&&a===0&&d===0&&S===0?null:Number.isFinite(t)&&t>=0?t:null}c(jt,"usdEquivalent");function Mt(e,t){return e.compat?.allowedFallbackModels?.find(a=>a.provider===e.provider&&a.model===t)}c(Mt,"allowedFallback");function on(e){return e?{payer:e.payer??"user",sub:e.sub,grantee:e.grantee,inference_endpoint:e.inference_endpoint??null}:void 0}c(on,"llmCallerOf");function Le(e){return e instanceof _t?e.code==="server_error"?new r(503,"upstream_model_unavailable",e.message):new r(404,"model_unavailable",e.message):e}c(Le,"mintFailure");const $t=/\bmodel is not supported when using Codex with a ChatGPT account\b/i;function Ct(e,t,o){if(!(e!=="openai-codex"||t===void 0||!$t.test(t)))return new r(404,"model_unavailable",t,void 0,{served_model:o})}c(Ct,"codexAccountModelRejection");function St(e){return e.get("request-id")??e.get("x-request-id")}c(St,"vendorRequestId");function Et(e,t,o){const a=$e(`anthropic/${o.rungs[e]}`);return a?{routeId:"hosted",credentialSource:"hosted",family:"hosted",strength:e,...a,rank:t}:void 0}c(Et,"hostedCandidate");async function rn(e,t,o,a,d,S,z){const i=S?.payer==="app"?S:void 0;if(e.payer==="app"&&!i)throw new r(403,"payer_not_app","this grant is not app-paid");if(e.payer==="user"&&i)throw new r(400,"invalid_request","this grant is app-paid; payer cannot be user","payer");if(i&&!i.inference_endpoint)throw new r(404,"model_unavailable",`${i.grantee} is app-paid but its grant carries no inference endpoint`);const _=i?.inference_endpoint??void 0,A=d===void 0?null:i?.sub??d.sub??await ht(),E=await Ye();let k;_?(k=yt(_,e.model,e.model_policy==="exact").flatMap((b,y)=>{const q=$e(b.model);return q?[{routeId:"app",credentialSource:"app",family:"app",strength:b.strength,...q,rank:y}]:[]}),k=k.filter(b=>wt(E,e,b))):k=await bt(E,e,a);const ie=!_&&d!==void 0&&A!==null&>(e.model_policy,k)?await mt():null,we=ie===null?void 0:Et(k[0].strength,k.length,ie);we&&(k=[...k,we]);const Ke=_?new Set:Xe(),be=c(async()=>new r(429,"all_routes_exhausted","no available way to pay for this call",void 0,{payment:{reason:"nothing_left",message:"No available way to pay for this call",pay_url:(await De())?.payment_setup_url??null,reset_at:null}}),"nothingLeft");if(k.length===0)throw e.model_policy==="exact"?new r(400,"substitution_refused","no eligible model route is configured"):_?new r(404,"model_unavailable","no eligible model route is configured"):await be();const K=`chatcmpl-${He()}`;let N=1/0,X=1/0,ae,w,se,de;const le=c(async()=>z??(d?.node?(await Ne(d.node))?.caused_by??null:null)??(d?.run?(await Ne(d.run))?.caused_by??null:null),"causeOf");for(const b of k){const y=b.credentialSource==="hosted";if(!i&&!y&&!(await Ge(b,E)).authenticated)continue;const q=y?qt(E,b.modelId):E.find(b.providerId,b.modelId);if(!q)continue;const U=y?ie.base_url:void 0,u=_?{...q,baseUrl:`${_.base_url}/${q.provider}`}:U?{...q,baseUrl:`${U}/anthropic`,compat:{...q.compat,allowedFallbackModels:void 0}}:q,p=b.providerId,G=b.credentialSource===Ve&&W(p),ue=!i&&!y&&!G&&W(p)?await tt(p):[],B=ue.filter(j=>!j.authFailure),ve=B.filter(j=>Se(j,u.id)<=Date.now()),T=G?await Oe(p):Ke.has(p)?void 0:ue.length?await Oe(p):void 0;if(G&&T===void 0||ue.length>0&&B.length===0&&T===void 0)continue;if(B.length&&!ve.length&&T===void 0){const j=Math.min(...B.map(I=>Se(I,u.id)));j<N&&(N=j,se=`${u.provider}/${u.id}`);continue}const ke=i||y?[void 0,void 0]:G?["key"]:B.length||T!==void 0?[...ve,...T!==void 0?["key"]:[]]:[void 0];let xe=!1;for(const[j,I]of ke.entries()){if(xe&&I!=="key")continue;const g=I==="key"?void 0:I,Re=I==="key",V=Date.now();let Ae=g?.access;if(g&&g.expires<=Date.now()&&W(p)){const n=E.getProvider(p)?.auth.oauth;if(!n)throw new r(503,"upstream_model_unavailable",`no OAuth refresh for ${p}`,void 0,{served_model:`${u.provider}/${u.id}`});let m;try{m=await ot(p,g.label,async(l,Me)=>{const re=await n.refresh({type:"oauth",refresh:l,access:"",expires:0,...Me?{clientId:Me}:{}},t??new AbortController().signal).catch(Je=>{throw kt(Je,`${u.provider}/${u.id}`)}),_e=re.clientId;return{refresh:re.refresh,access:re.access,expires:re.expires,...typeof _e=="string"&&_e?{clientId:_e}:{}}}).catch(l=>{throw l instanceof it||l instanceof at?new r(503,"upstream_model_unavailable",l.message,void 0,{served_model:`${u.provider}/${u.id}`}):l})}catch(l){if(!Ze(l))throw l;ae??=l;continue}Ae=m.access}const Ue=Rt(e),F=g||i||y||Re?void 0:await E.getApiKeyAndHeaders(u);if(F&&!F.ok)continue;const f=`${u.provider}/${u.id}`,P=e.model??f,x=y?A===null?null:{payer:A,funding:"endpoint"}:i?Ie({call:"model",route:"endpoint",grantee:i.grantee}):A===null?null:Ie({call:"model",route:g?"subscription":"key",sub:A});if(d!==void 0&&x!==null){const n=await ut({scope:"call",payer:x.payer,funding:x.funding,sub:A,grantee:d.grantee,provider:p});if(n!==null){if(await ge({request:d.request??K,kind:"model",what:f,usd:null,payer:x.payer,funding:x.funding,sub:A,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await le(),refused:ft(n)}),de??=n,I!=="key"&&ke.includes("key")){xe=!0;continue}break}}let O;if(i&&_)try{O=await Te({audience:_.base_url,sub:i.sub,grantee:i.grantee,initiating_app:i.grantee,scope:["crtr:llm"]},{signal:t})}catch(n){throw Le(n)}if(U)try{O=await Te({audience:U,sub:A,grantee:d.grantee,initiating_app:d.grantee,scope:["crtr:llm"]},{signal:t})}catch(n){throw Le(n)}let L=null,qe=!1,h,J,Y,M=!1,R,Z=null,v=3e4,$;const ce=[],fe=[],Q=[];let s,D;const ee=c((n,m=null)=>({id:K,object:"chat.completion.chunk",created:Math.floor(V/1e3),model:f,served_model:f,requested_model:P,substituted:P!==f&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(P),choices:[{index:0,delta:n,finish_reason:m}]}),"chunk"),te=c(n=>{ce.push(n),o?.(n)},"emit"),Be=ze(u,Ue,{apiKey:O?.access_token??Ae??(Re?T:void 0)??(F?.ok?F.apiKey:void 0),...F?.ok?{headers:F.headers}:{},signal:t,reasoning:e.reasoning_effort??b.thinkingLevel,...e.temperature!==void 0?{temperature:e.temperature}:{},...e.max_tokens!==void 0?{maxTokens:e.max_tokens}:{},...e.top_p!==void 0?{samplingParams:{top_p:e.top_p}}:{},...e.tool_choice==="none"?{toolChoice:"none"}:{},onPayload:c(n=>{if(!n||typeof n!="object")return;const m=e.tool_choice,l=m==="required"?u.api==="anthropic-messages"?{type:"any"}:"required":typeof m=="object"&&m!==null?u.api==="anthropic-messages"?{type:"tool",name:m.function.name}:m:void 0;return{...n,...l?{tool_choice:l}:{},...e.stop!==void 0?{[u.api==="anthropic-messages"?"stop_sequences":"stop"]:typeof e.stop=="string"?[e.stop]:e.stop}:{},...e.seed!==void 0?{seed:e.seed}:{},...e.response_format!==void 0?{response_format:e.response_format}:{}}},"onPayload"),fetch:c(async(n,m)=>{const l=await fetch(n,m);if(R=l.status,Z=St(l.headers)??Z,y){if(L=l.headers.get("crtr-charge-id")?.trim()||null,l.ok&&!L)throw qe=!0,await l.body?.cancel(),new Error("The hosted endpoint omitted Crtr-Charge-Id; the call may already have been charged. Do not automatically replay it.");return l.status===402&&(Y=At(await l.clone().json().catch(()=>{}))),l}return l.status===429&&(M=!0,$=l.headers,v=H(l.headers)??15e3),l},"fetch"),onProviderStreamEvent:c(n=>{y&&n!==null&&typeof n=="object"&&"type"in n&&n.type==="message_stop"&&"crtr_charge"in n&&(h=n.crtr_charge)},"onProviderStreamEvent"),onResponse:c(n=>{!y&&n.status===429&&(M=!0,$=n.headers,v=H(n.headers)??15e3)},"onResponse")});try{for await(const n of Be)n.type==="text_delta"&&(fe.push(n.delta),te(ee({content:n.delta}))),n.type==="thinking_delta"&&(Q.push(n.delta),te(ee({reasoning_content:n.delta}))),n.type==="done"&&(s=n.message),n.type==="error"&&(s=n.error)}catch(n){const m=nt(n);$===void 0&&n&&typeof n=="object"&&"headers"in n&&Object.keys(dt(n.headers)).length&&($=n.headers);const l=ye({status:n&&typeof n=="object"&&"status"in n?n.status:void 0,message:n instanceof Error?n.message:String(n)});if(i||y)D=n;else{if(!M&&l.kind!=="rate-limit")throw ce.length?new r(503,"upstream_model_unavailable",n instanceof Error?n.message:String(n),void 0,{served_model:f}):n;M=!0,v=m??v}}if(y){if(qe)throw new r(502,"upstream_refused","The hosted endpoint omitted Crtr-Charge-Id; the call may already have been charged. Do not automatically replay it.",void 0,{served_model:f});if(R===402&&Y)throw new r(402,"payment_refused",Y.message,void 0,{payment:Y,served_model:f});if(R===401){if(O&&Fe(O.key),j===0)continue;throw new r(404,"model_unavailable",`${U} refuses this runtime's tokens`,void 0,{served_model:f})}if(D!==void 0||R!==void 0&&R>=400||s?.stopReason==="error"||s?.stopReason==="aborted"){const m=D instanceof Error?D.message:s?.errorMessage??`the inference endpoint answered ${R??"with an error"}`;throw R===403?new r(502,"upstream_refused",m,void 0,{served_model:f}):new r(503,"upstream_model_unavailable",m,void 0,{served_model:f})}if(h===null||typeof h!="object"||!("id"in h)||h.id!==L||!("served_model"in h)||typeof h.served_model!="string"||!h.served_model.trim()||!("list_usd"in h)||typeof h.list_usd!="number"||!Number.isFinite(h.list_usd)||h.list_usd<0||Number(h.list_usd.toFixed(6))!==h.list_usd)throw new r(502,"upstream_refused","The hosted endpoint returned missing or invalid final charge accounting; output and cost may already exist. Do not automatically replay this call.",void 0,{served_model:f,charge_id:L});J={id:L,served_model:h.served_model,list_usd:h.list_usd}}if(i){if(R===401){if(O&&Fe(O.key),j===0)continue;throw new r(404,"model_unavailable",`${_.base_url} refuses this runtime's tokens`,void 0,{served_model:f})}if(M&&H($)===void 0)throw new r(503,"upstream_model_unavailable",`${f} was rate-limited without a retry-after`,void 0,{served_model:f});if(!M&&(D!==void 0||R!==void 0&&R>=500))throw new r(503,"upstream_model_unavailable",D instanceof Error?D.message:s?.errorMessage??"inference endpoint failed",void 0,{served_model:f})}if(!M&&s?.stopReason==="error"&&ye({message:s.errorMessage}).kind==="rate-limit"&&(M=!0,v=15e3),M){const n=st($,u.id),m=H($)!==void 0?Date.now()+v:n.resetAt;if(H($)===void 0&&n.resetAt!==void 0&&(v=Math.max(v,n.resetAt-Date.now())),w={provider:p,model:u.id,...g?{account:g.label}:{},observation:n},console.error(`[llm] 429 from ${f}${g?` account "${g.label}"`:""}: scope=${Ee(n.scope)} retry_after_ms=${v} headers=${JSON.stringify(n.headers)}`),g&&W(p)&&await Qe(p,g.label,v,V,Date.now(),n.scope),m!==void 0&&(X=Math.min(X,m)),Date.now()+Math.min(v,Ce)<N&&(N=Date.now()+Math.min(v,Ce),se=f),fe.length||Q.length)throw new r(503,"service_unavailable","vendor rate limit after output began",void 0,{served_model:f});if(i)break;continue}const ne=lt(s);if(R===400&&e.tool_choice!==void 0&&e.tool_choice!=="auto"&&e.tool_choice!=="none"&&/\btool[_ ]choice\b/i.test(s?.errorMessage??"")&&/not supported|does not support|unsupported|cannot|must be auto/i.test(s?.errorMessage??""))throw new r(400,"invalid_request",s.errorMessage,"tool_choice",{served_model:f});if(s?.stopReason==="error"){const n=Ct(u.provider,s.errorMessage,f);if(n)throw n}if(!s||s.stopReason==="error"&&!ne||s.stopReason==="aborted")throw new r(503,"upstream_model_unavailable",s?.errorMessage??"model request failed",void 0,{served_model:f});g&&W(p)&&rt(g,u.id)&&await et(p,g.label,V,u.id);const me=s.content.filter(n=>n.type==="toolCall").map(n=>({id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.arguments)}})),pe=ne?"content_filter":s.stopReason==="toolUse"?"tool_calls":s.stopReason==="length"?"length":"stop",he=s.responseModel?Mt(u,s.responseModel):void 0,C=J?`${u.provider}/${J.served_model}`:he?`${u.provider}/${he.model}`:f,oe={prompt_tokens:s.usage.input,completion_tokens:s.usage.output,total_tokens:s.usage.totalTokens,cache_read_tokens:s.usage.cacheRead,cache_write_tokens:s.usage.cacheWrite,usd_equivalent:J?J.list_usd:jt(he??u,s.usage.cost.total),served_model:C};y?d!==void 0&&x!==null&&await ge({id:L,request:d.request??K,kind:"model",what:C,usd:oe.usd_equivalent,payer:x.payer,funding:x.funding,sub:A,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await le(),vendorRef:Z}):d!==void 0&&x!==null&&await ge({request:d.request??K,kind:"model",what:C,units:{input:s.usage.input,output:s.usage.output,cache_read:s.usage.cacheRead,cache_write:s.usage.cacheWrite},usd:oe.usd_equivalent,payer:x.payer,funding:x.funding,sub:A,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await le(),vendorRef:Z});const je={id:K,object:"chat.completion",created:Math.floor(V/1e3),model:C,served_model:C,requested_model:P,substituted:P!==C&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(P),choices:[{index:0,message:{role:"assistant",content:fe.join("")||null,...Q.length?{reasoning_content:Q.join("")}:{},...me.length?{tool_calls:me}:{},...ne?{refusal:s.errorMessage??"Content filtered"}:{}},finish_reason:pe}],usage:oe,...e.metadata!==void 0?{metadata:e.metadata}:{}};for(const[n,m]of me.entries())te(ee({tool_calls:[{index:n,...m}]}));return te({...ee({},pe),model:C,served_model:C,substituted:je.substituted,...ne?{choices:[{index:0,delta:{},finish_reason:pe,message:{refusal:s.errorMessage??"Content filtered"}}]}:{},usage:oe}),{completion:je,chunks:ce}}}throw de!==void 0?ct(de):N!==1/0?new r(429,"all_routes_exhausted","all eligible model routes are rate-limited",void 0,{payment:{reason:"nothing_left",message:"Every connected subscription and key is rate-limited or used up right now.",pay_url:(await De())?.payment_setup_url??null,reset_at:X===1/0?null:new Date(X).toISOString()},retry_after_s:Math.max(1,Math.ceil((N-Date.now())/1e3)),served_model:w?`${w.provider}/${w.model}`:se,...w?{rate_limit:{provider:w.provider,model:w.model,...w.account?{account:w.account}:{},scope:Ee(w.observation.scope),...w.observation.claim?{claim:w.observation.claim}:{},headers:w.observation.headers}}:{}},void 0,!0):ae!==void 0?ae:e.model_policy==="exact"?new r(400,"substitution_refused","the requested model is unavailable"):_?new r(404,"model_unavailable","no usable model route is available"):await be()}c(rn,"runLlm");export{on as llmCallerOf,nn as parseLlmRequest,rn as runLlm};
|
|
3
|
+
`),z=e.tools?.map(({function:i})=>({name:i.name,description:i.description??"",parameters:i.parameters??{type:"object",properties:{}}}));return{...E?{systemPrompt:E}:{},messages:o.slice(d.length),...z?{tools:z}:{}}}c(At,"contextOf");function qt(e){return ht(e?.payment)}c(qt,"paymentOf");function jt(e,t){const o=e.find("anthropic",t);if(o)return o;const s=e.getAll().find(d=>d.provider==="anthropic"&&d.api==="anthropic-messages");return s?{...s,id:t,name:t}:void 0}c(jt,"hostedModel");function Mt(e,t){const{input:o,output:s,cacheRead:d,cacheWrite:E}=e.cost;return o===0&&s===0&&d===0&&E===0?null:Number.isFinite(t)&&t>=0?t:null}c(Mt,"usdEquivalent");function $t(e,t){return e.compat?.allowedFallbackModels?.find(s=>s.provider===e.provider&&s.model===t)}c($t,"allowedFallback");function on(e){return e?{payer:e.payer??"user",sub:e.sub,grantee:e.grantee,inference_endpoint:e.inference_endpoint??null}:void 0}c(on,"llmCallerOf");function Pe(e){return e instanceof yt?e.code==="server_error"?new r(503,"upstream_model_unavailable",e.message):new r(404,"model_unavailable",e.message):e}c(Pe,"mintFailure");const Ct=/\bmodel is not supported when using Codex with a ChatGPT account\b/i;function Et(e,t,o){if(!(e!=="openai-codex"||t===void 0||!Ct.test(t)))return new r(404,"model_unavailable",t,void 0,{served_model:o})}c(Et,"codexAccountModelRejection");function St(e){return e.get("request-id")??e.get("x-request-id")}c(St,"vendorRequestId");async function rn(e,t,o,s,d,E,z){const i=E?.payer==="app"?E:void 0;if(e.payer==="app"&&!i)throw new r(403,"payer_not_app","this grant is not app-paid");if(e.payer==="user"&&i)throw new r(400,"invalid_request","this grant is app-paid; payer cannot be user","payer");if(i&&!i.inference_endpoint)throw new r(404,"model_unavailable",`${i.grantee} is app-paid but its grant carries no inference endpoint`);const _=i?.inference_endpoint??void 0,R=d===void 0?null:i?.sub??d.sub??await _t(),S=await Ze();let A;_?(A=gt(_,e.model,e.model_policy==="exact").flatMap((b,y)=>{const q=Ye(b.model);return q?[{routeId:"app",credentialSource:"app",family:"app",strength:b.strength,...q,rank:y}]:[]}),A=A.filter(b=>bt(S,e,b))):A=await vt(S,e,s);const ie=!_&&d!==void 0&&R!==null?await pt():null,ae=ie===null?void 0:wt(e,A,ie),Le=ae?ie:null;ae&&(A=[...A,ae]);const Ke=_?new Set:Xe(),be=c(async()=>new r(429,"all_routes_exhausted","no available way to pay for this call",void 0,{payment:{reason:"nothing_left",message:"No available way to pay for this call",pay_url:(await Oe())?.payment_setup_url??null,reset_at:null}}),"nothingLeft");if(A.length===0)throw e.model_policy==="exact"?new r(400,"substitution_refused","no eligible model route is configured"):_?new r(404,"model_unavailable","no eligible model route is configured"):await be();const K=`chatcmpl-${He()}`;let N=1/0,X=1/0,se,w,de,le;const ue=c(async()=>z??(d?.node?(await De(d.node))?.caused_by??null:null)??(d?.run?(await De(d.run))?.caused_by??null:null),"causeOf");for(const b of A){const y=b.credentialSource==="hosted";if(!i&&!y&&!(await Ge(b,S)).authenticated)continue;const q=y?jt(S,b.modelId):S.find(b.providerId,b.modelId);if(!q)continue;const U=y?Le.base_url:void 0,u=_?{...q,baseUrl:`${_.base_url}/${q.provider}`}:U?{...q,baseUrl:`${U}/anthropic`,compat:{...q.compat,allowedFallbackModels:void 0}}:q,p=b.providerId,G=b.credentialSource===Ve&&W(p),ce=!i&&!y&&!G&&W(p)?await nt(p):[],B=ce.filter(j=>!j.authFailure),ve=B.filter(j=>Ce(j,u.id)<=Date.now()),T=G?await Ie(p):Ke.has(p)?void 0:ce.length?await Ie(p):void 0;if(G&&T===void 0||ce.length>0&&B.length===0&&T===void 0)continue;if(B.length&&!ve.length&&T===void 0){const j=Math.min(...B.map(I=>Ce(I,u.id)));j<N&&(N=j,de=`${u.provider}/${u.id}`);continue}const ke=i||y?[void 0,void 0]:G?["key"]:B.length||T!==void 0?[...ve,...T!==void 0?["key"]:[]]:[void 0];let xe=!1;for(const[j,I]of ke.entries()){if(xe&&I!=="key")continue;const g=I==="key"?void 0:I,Re=I==="key",V=Date.now();let Ae=g?.access;if(g&&g.expires<=Date.now()&&W(p)){const n=S.getProvider(p)?.auth.oauth;if(!n)throw new r(503,"upstream_model_unavailable",`no OAuth refresh for ${p}`,void 0,{served_model:`${u.provider}/${u.id}`});let m;try{m=await rt(p,g.label,async(l,Me)=>{const re=await n.refresh({type:"oauth",refresh:l,access:"",expires:0,...Me?{clientId:Me}:{}},t??new AbortController().signal).catch(Je=>{throw xt(Je,`${u.provider}/${u.id}`)}),ye=re.clientId;return{refresh:re.refresh,access:re.access,expires:re.expires,...typeof ye=="string"&&ye?{clientId:ye}:{}}}).catch(l=>{throw l instanceof at||l instanceof st?new r(503,"upstream_model_unavailable",l.message,void 0,{served_model:`${u.provider}/${u.id}`}):l})}catch(l){if(!Qe(l))throw l;se??=l;continue}Ae=m.access}const Ue=At(e),F=g||i||y||Re?void 0:await S.getApiKeyAndHeaders(u);if(F&&!F.ok)continue;const f=`${u.provider}/${u.id}`,P=e.model??f,k=y?R===null?null:{payer:R,funding:"endpoint"}:i?Se({call:"model",route:"endpoint",grantee:i.grantee}):R===null?null:Se({call:"model",route:g?"subscription":"key",sub:R});if(d!==void 0&&k!==null){const n=await ct({scope:"call",payer:k.payer,funding:k.funding,sub:R,grantee:d.grantee,provider:p});if(n!==null){if(await we({request:d.request??K,kind:"model",what:f,usd:null,payer:k.payer,funding:k.funding,sub:R,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await ue(),refused:mt(n)}),le??=n,I!=="key"&&ke.includes("key")){xe=!0;continue}break}}let O;if(i&&_)try{O=await Ne({audience:_.base_url,sub:i.sub,grantee:i.grantee,initiating_app:i.grantee,scope:["crtr:llm"]},{signal:t})}catch(n){throw Pe(n)}if(U)try{O=await Ne({audience:U,sub:R,grantee:d.grantee,initiating_app:d.grantee,scope:["crtr:llm"]},{signal:t})}catch(n){throw Pe(n)}let L=null,qe=!1,h,J,Y,M=!1,x,Z=null,v=3e4,$;const fe=[],me=[],Q=[];let a,D;const ee=c((n,m=null)=>({id:K,object:"chat.completion.chunk",created:Math.floor(V/1e3),model:f,served_model:f,requested_model:P,substituted:P!==f&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(P),choices:[{index:0,delta:n,finish_reason:m}]}),"chunk"),te=c(n=>{fe.push(n),o?.(n)},"emit"),Be=ze(u,Ue,{apiKey:O?.access_token??Ae??(Re?T:void 0)??(F?.ok?F.apiKey:void 0),...F?.ok?{headers:F.headers}:{},signal:t,reasoning:e.reasoning_effort??b.thinkingLevel,...e.temperature!==void 0?{temperature:e.temperature}:{},...e.max_tokens!==void 0?{maxTokens:e.max_tokens}:{},...e.top_p!==void 0?{samplingParams:{top_p:e.top_p}}:{},...e.tool_choice==="none"?{toolChoice:"none"}:{},onPayload:c(n=>{if(!n||typeof n!="object")return;const m=e.tool_choice,l=m==="required"?u.api==="anthropic-messages"?{type:"any"}:"required":typeof m=="object"&&m!==null?u.api==="anthropic-messages"?{type:"tool",name:m.function.name}:m:void 0;return{...n,...l?{tool_choice:l}:{},...e.stop!==void 0?{[u.api==="anthropic-messages"?"stop_sequences":"stop"]:typeof e.stop=="string"?[e.stop]:e.stop}:{},...e.seed!==void 0?{seed:e.seed}:{},...e.response_format!==void 0?{response_format:e.response_format}:{}}},"onPayload"),fetch:c(async(n,m)=>{const l=await fetch(n,m);if(x=l.status,Z=St(l.headers)??Z,y){if(L=l.headers.get("crtr-charge-id")?.trim()||null,l.ok&&!L)throw qe=!0,await l.body?.cancel(),new Error("The hosted endpoint omitted Crtr-Charge-Id; the call may already have been charged. Do not automatically replay it.");return l.status===402&&(Y=qt(await l.clone().json().catch(()=>{}))),l}return l.status===429&&(M=!0,$=l.headers,v=H(l.headers)??15e3),l},"fetch"),onProviderStreamEvent:c(n=>{y&&n!==null&&typeof n=="object"&&"type"in n&&n.type==="message_stop"&&"crtr_charge"in n&&(h=n.crtr_charge)},"onProviderStreamEvent"),onResponse:c(n=>{!y&&n.status===429&&(M=!0,$=n.headers,v=H(n.headers)??15e3)},"onResponse")});try{for await(const n of Be)n.type==="text_delta"&&(me.push(n.delta),te(ee({content:n.delta}))),n.type==="thinking_delta"&&(Q.push(n.delta),te(ee({reasoning_content:n.delta}))),n.type==="done"&&(a=n.message),n.type==="error"&&(a=n.error)}catch(n){const m=ot(n);$===void 0&&n&&typeof n=="object"&&"headers"in n&&Object.keys(lt(n.headers)).length&&($=n.headers);const l=ge({status:n&&typeof n=="object"&&"status"in n?n.status:void 0,message:n instanceof Error?n.message:String(n)});if(i||y)D=n;else{if(!M&&l.kind!=="rate-limit")throw fe.length?new r(503,"upstream_model_unavailable",n instanceof Error?n.message:String(n),void 0,{served_model:f}):n;M=!0,v=m??v}}if(y){if(qe)throw new r(502,"upstream_refused","The hosted endpoint omitted Crtr-Charge-Id; the call may already have been charged. Do not automatically replay it.",void 0,{served_model:f});if(x===402&&Y)throw new r(402,"payment_refused",Y.message,void 0,{payment:Y,served_model:f});if(x===401){if(O&&Te(O.key),j===0)continue;throw new r(404,"model_unavailable",`${U} refuses this runtime's tokens`,void 0,{served_model:f})}if(D!==void 0||x!==void 0&&x>=400||a?.stopReason==="error"||a?.stopReason==="aborted"){const m=D instanceof Error?D.message:a?.errorMessage??`the inference endpoint answered ${x??"with an error"}`;throw x===403?new r(502,"upstream_refused",m,void 0,{served_model:f}):new r(503,"upstream_model_unavailable",m,void 0,{served_model:f})}if(h===null||typeof h!="object"||!("id"in h)||h.id!==L||!("served_model"in h)||typeof h.served_model!="string"||!h.served_model.trim()||!("list_usd"in h)||typeof h.list_usd!="number"||!Number.isFinite(h.list_usd)||h.list_usd<0||Number(h.list_usd.toFixed(6))!==h.list_usd)throw new r(502,"upstream_refused","The hosted endpoint returned missing or invalid final charge accounting; output and cost may already exist. Do not automatically replay this call.",void 0,{served_model:f,charge_id:L});J={id:L,served_model:h.served_model,list_usd:h.list_usd}}if(i){if(x===401){if(O&&Te(O.key),j===0)continue;throw new r(404,"model_unavailable",`${_.base_url} refuses this runtime's tokens`,void 0,{served_model:f})}if(M&&H($)===void 0)throw new r(503,"upstream_model_unavailable",`${f} was rate-limited without a retry-after`,void 0,{served_model:f});if(!M&&(D!==void 0||x!==void 0&&x>=500))throw new r(503,"upstream_model_unavailable",D instanceof Error?D.message:a?.errorMessage??"inference endpoint failed",void 0,{served_model:f})}if(!M&&a?.stopReason==="error"&&ge({message:a.errorMessage}).kind==="rate-limit"&&(M=!0,v=15e3),M){const n=dt($,u.id),m=H($)!==void 0?Date.now()+v:n.resetAt;if(H($)===void 0&&n.resetAt!==void 0&&(v=Math.max(v,n.resetAt-Date.now())),w={provider:p,model:u.id,...g?{account:g.label}:{},observation:n},console.error(`[llm] 429 from ${f}${g?` account "${g.label}"`:""}: scope=${Ee(n.scope)} retry_after_ms=${v} headers=${JSON.stringify(n.headers)}`),g&&W(p)&&await et(p,g.label,v,V,Date.now(),n.scope),m!==void 0&&(X=Math.min(X,m)),Date.now()+Math.min(v,$e)<N&&(N=Date.now()+Math.min(v,$e),de=f),me.length||Q.length)throw new r(503,"service_unavailable","vendor rate limit after output began",void 0,{served_model:f});if(i)break;continue}const ne=ut(a);if(x===400&&e.tool_choice!==void 0&&e.tool_choice!=="auto"&&e.tool_choice!=="none"&&/\btool[_ ]choice\b/i.test(a?.errorMessage??"")&&/not supported|does not support|unsupported|cannot|must be auto/i.test(a?.errorMessage??""))throw new r(400,"invalid_request",a.errorMessage,"tool_choice",{served_model:f});if(a?.stopReason==="error"){const n=Et(u.provider,a.errorMessage,f);if(n)throw n}if(!a||a.stopReason==="error"&&!ne||a.stopReason==="aborted")throw new r(503,"upstream_model_unavailable",a?.errorMessage??"model request failed",void 0,{served_model:f});g&&W(p)&&it(g,u.id)&&await tt(p,g.label,V,u.id);const pe=a.content.filter(n=>n.type==="toolCall").map(n=>({id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.arguments)}})),he=ne?"content_filter":a.stopReason==="toolUse"?"tool_calls":a.stopReason==="length"?"length":"stop",_e=a.responseModel?$t(u,a.responseModel):void 0,C=J?`${u.provider}/${J.served_model}`:_e?`${u.provider}/${_e.model}`:f,oe={prompt_tokens:a.usage.input,completion_tokens:a.usage.output,total_tokens:a.usage.totalTokens,cache_read_tokens:a.usage.cacheRead,cache_write_tokens:a.usage.cacheWrite,usd_equivalent:J?J.list_usd:Mt(_e??u,a.usage.cost.total),served_model:C};y?d!==void 0&&k!==null&&await we({id:L,request:d.request??K,kind:"model",what:C,usd:oe.usd_equivalent,payer:k.payer,funding:k.funding,sub:R,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await ue(),vendorRef:Z}):d!==void 0&&k!==null&&await we({request:d.request??K,kind:"model",what:C,units:{input:a.usage.input,output:a.usage.output,cache_read:a.usage.cacheRead,cache_write:a.usage.cacheWrite},usd:oe.usd_equivalent,payer:k.payer,funding:k.funding,sub:R,grantee:d.grantee,node:d.node??null,run:d.run??null,provider:p,causedBy:await ue(),vendorRef:Z});const je={id:K,object:"chat.completion",created:Math.floor(V/1e3),model:C,served_model:C,requested_model:P,substituted:P!==C&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(P),choices:[{index:0,message:{role:"assistant",content:me.join("")||null,...Q.length?{reasoning_content:Q.join("")}:{},...pe.length?{tool_calls:pe}:{},...ne?{refusal:a.errorMessage??"Content filtered"}:{}},finish_reason:he}],usage:oe,...e.metadata!==void 0?{metadata:e.metadata}:{}};for(const[n,m]of pe.entries())te(ee({tool_calls:[{index:n,...m}]}));return te({...ee({},he),model:C,served_model:C,substituted:je.substituted,...ne?{choices:[{index:0,delta:{},finish_reason:he,message:{refusal:a.errorMessage??"Content filtered"}}]}:{},usage:oe}),{completion:je,chunks:fe}}}throw le!==void 0?ft(le):N!==1/0?new r(429,"all_routes_exhausted","all eligible model routes are rate-limited",void 0,{payment:{reason:"nothing_left",message:"Every connected subscription and key is rate-limited or used up right now.",pay_url:(await Oe())?.payment_setup_url??null,reset_at:X===1/0?null:new Date(X).toISOString()},retry_after_s:Math.max(1,Math.ceil((N-Date.now())/1e3)),served_model:w?`${w.provider}/${w.model}`:de,...w?{rate_limit:{provider:w.provider,model:w.model,...w.account?{account:w.account}:{},scope:Ee(w.observation.scope),...w.observation.claim?{claim:w.observation.claim}:{},headers:w.observation.headers}}:{}},void 0,!0):se!==void 0?se:e.model_policy==="exact"?new r(400,"substitution_refused","the requested model is unavailable"):_?new r(404,"model_unavailable","no usable model route is available"):await be()}c(rn,"runLlm");export{on as llmCallerOf,nn as parseLlmRequest,rn as runLlm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var v=Object.defineProperty;var l=(e,o)=>v(e,"name",{value:o,configurable:!0});import{ApiError as
|
|
1
|
+
var v=Object.defineProperty;var l=(e,o)=>v(e,"name",{value:o,configurable:!0});import{ApiError as u}from"../../api/index.js";import{storedApiKey as h}from"../auth-file.js";import{readConfig as _}from"../config.js";import{eligibleHostedEndpoint as g}from"../grants/hosted-endpoint.js";import{hostedRoute as I,ownerCandidates as S}from"../llm/owner-candidates.js";import{KEY_CREDENTIAL_SOURCE as b,llmModelFor as E,parseModelSpec as p}from"../model-routes.js";import{keyRouteProviders as R}from"../model-routes-pool.js";import{PoolCredentialStore as k}from"../pool-credential-store.js";import{openModelRegistry as x}from"../runtime/model-registry.js";import{resolveLaunchTarget as C}from"../runtime/launch-target.js";import{readMergedLaunchConfigAsync as M}from"../runtime/launch.js";import{coolingUntilFor as f,isManagedProvider as A,readSubscriptionPool as O}from"../subscription-state.js";function P(e){const o=e.indexOf("/"),t=o>0?e.slice(0,o):"";if(t==="")throw new u(422,"unresolved_model","the selected launch has no concrete model provider");return t}l(P,"providerFromModel");async function s(e,o){if(await h(e)===void 0)return!1;if(!R().has(e))return!0;const t=Object.values(_("user").modelRoutes??{}).filter(i=>i.credentialSource===b&&i.providerId===e),n=p(o);return t.some(i=>Object.values(i.models).some(d=>{const r=p(d);return r?.providerId===n?.providerId&&r?.modelId===n?.modelId}))}l(s,"keyServes");async function J(e){const o=await C({root:!0,...e.profile!=null?{profile:e.profile}:{},...e.cwd!=null?{cwd:e.cwd}:{},...e.pin_cwd!=null?{pin_cwd:e.pin_cwd}:{},...e.mode!=null?{mode:e.mode}:{},...e.kind!=null?{kind:e.kind}:{},...e.model!=null?{model:e.model}:{}},{readOnlyProfileSelection:!0});return{...await D(o),hosted_endpoint:await F(o)}}l(J,"modelAuthReadiness");async function F(e){const o=await g();if(o===null)return!1;const{model:t,modelIntent:n,modelExact:i}=e.launch,d=i===!0,r={model:E(t,n===void 0?void 0:`${n.family}/${n.strength}`,d),model_policy:d?"exact":"substitute"};return I(r,await S(await x(),r,{cwd:e.cwd,profileId:e.profileId},await M(e.cwd,e.profileId,e.app)),o)!==void 0}l(F,"launchUsesHostedEndpoint");async function D(e){const o=e.launch.model;if(o===void 0)throw new u(422,"unresolved_model","the selected launch has no concrete model");const t=P(o);if(A(t)){const d=await O(t);if(d.length>0){const r=d.filter(a=>a.authFailure===void 0);if(r.length===0)return await s(t,o)?{provider:t,model:o,credential:"ready"}:{provider:t,model:o,credential:"unusable",reason:"invalid_grant"};const c=Date.now(),w=r.some(a=>f(a,o)<=c),m=Math.min(...r.map(a=>f(a,o))),y=!w&&m>c&&!await s(t,o);return{provider:t,model:o,credential:"ready",...y?{rate_limited_until:new Date(m).toISOString()}:{}}}}const n=await new k().read(t),i=n?.type==="oauth"||n?.type==="api_key"&&!!n.key&&await s(t,o);return{provider:t,model:o,credential:i?"ready":"missing"}}l(D,"ownCredentialReadiness");export{F as launchUsesHostedEndpoint,J as modelAuthReadiness};
|
|
@@ -22,7 +22,8 @@ export declare function wireHistory(messages: Context['messages']): Context['mes
|
|
|
22
22
|
/** The thinking levels the node's own ladder cell gives `model` for its logical, substitutable request: the launch default.
|
|
23
23
|
* The daemon reads `reasoning_effort` as a requirement on every route that may serve the call, so the default of the model
|
|
24
24
|
* the broker launched with must not ride along (it would drop substitutes that do not reason); a level outside this set was chosen on purpose.
|
|
25
|
-
* Empty for an exact or concrete request, whose thinking is the call's own
|
|
25
|
+
* Empty for an exact or concrete request, whose thinking is the call's own, and for an app-paid recipe (`app/<strength>`): the daemon's rung
|
|
26
|
+
* resolver supplies no level, so a suffix on its model is an exact request's effort and must ride along. */
|
|
26
27
|
export declare function launchThinkingLevels(model: Model<any>, intent: string | undefined): Promise<ReadonlySet<string>>;
|
|
27
28
|
export declare function requestBody(model: Model<any>, context: Context, options: ModelsSimpleStreamOptions, intentOverride?: string, launchThinking?: ReadonlySet<string>): Record<string, unknown>;
|
|
28
29
|
/** The real response under a deferred-head framing (`daemon/api/deferred-head.ts`): the magic line, keep-alive
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var G=Object.defineProperty;var f=(e,t)=>G(e,"name",{value:t,configurable:!0});import{setTimeout as X}from"node:timers/promises";import{createAssistantMessageEventStream as K,getCurrentSystemPrompt as Q,getCurrentTools as V}from"@earendil-works/pi-ai";import{socketFetch as Z}from"../../../api/node-transport.js";import{DEFER_HEAD_REQUEST_HEADER as ee,DEFERRED_HEAD_CONTENT_TYPE as te,DEFERRED_HEAD_MAGIC as ne}from"../../../daemon/api/deferred-head.js";import{apiSocketPath as re}from"../../canvas/paths.js";import{northlightUnreachable as oe}from"../../directory/reach.js";import{currentNodeToken as se}from"./node-token.js";import{brokerApiUrl as A}from"./daemon-ops.js";import{currentCausedBy as ie}from"./turn-cause.js";import{envModelExact as S,envModelIntent as
|
|
2
|
-
`!==ne)throw new Error("deferred head response has no magic line");a=!0;continue}if(s==="")continue;const r=JSON.parse(s),i=new Headers;for(const[c,p]of Object.entries(r.headers))for(const m of Array.isArray(p)?p:[p])i.append(c,m);const x=n,E=new ReadableStream({start(c){x.length>0&&c.enqueue(x)},async pull(c){const{value:p,done:m}=await t.read();m?c.close():c.enqueue(p)},cancel(c){return t.cancel(c)}});return new Response(r.status===204?null:E,{status:r.status,headers:i})}}f(
|
|
3
|
-
`))>=0;){const h=w.slice(0,g).trim();w=w.slice(g+1),h&&
|
|
1
|
+
var G=Object.defineProperty;var f=(e,t)=>G(e,"name",{value:t,configurable:!0});import{setTimeout as X}from"node:timers/promises";import{createAssistantMessageEventStream as K,getCurrentSystemPrompt as Q,getCurrentTools as V}from"@earendil-works/pi-ai";import{socketFetch as Z}from"../../../api/node-transport.js";import{DEFER_HEAD_REQUEST_HEADER as ee,DEFERRED_HEAD_CONTENT_TYPE as te,DEFERRED_HEAD_MAGIC as ne}from"../../../daemon/api/deferred-head.js";import{apiSocketPath as re}from"../../canvas/paths.js";import{northlightUnreachable as oe}from"../../directory/reach.js";import{currentNodeToken as se}from"./node-token.js";import{brokerApiUrl as A}from"./daemon-ops.js";import{currentCausedBy as ie}from"./turn-cause.js";import{envModelExact as S,envModelIntent as F,envNodeCwd as ae,envProfileId as de}from"../../../shared/env.js";import{MODEL_CONTEXT_BODY_MAX_BYTES as L}from"../../llm/body-limits.js";import{APP_FAMILY as ce,expandModelCandidates as le,llmModelFor as ue,modelRequestFromConfig as fe}from"../../model-routes.js";import{parseProviderPayment as pe,parseProviderRateLimit as me,providerFailureDiagnostic as U}from"../../provider-failure.js";import{UPSTREAM_MODEL_UNAVAILABLE as T}from"../../fault-classifier.js";function Fe(e,t,n){e.checkAuth=async a=>e.getProvider(a)?{type:"api_key"}:void 0,e.getAvailable=async a=>e.getModels(a),e.getAvailableSnapshot=()=>e.getModels(),e.streamSimple=(a,d,s)=>be(a,d,s,t,n)}f(Fe,"configureBrokerModelRuntime");const he=300,q="crtr:llm-refusal";class v extends Error{static{f(this,"LlmRefusalError")}retryAt;rateLimit;code;status;payment;constructor(t,n,a,d,s,r){super(t),this.retryAt=n,this.rateLimit=a,this.code=d,this.status=s,this.payment=r}}class k extends Error{static{f(this,"UpstreamModelUnavailableError")}}function B(e,t){const n=e===void 0?"the request body":`the request body (${e} bytes)`;return new Error(`request_too_large: ${n} exceeds the ${t}-byte model request limit; compact the conversation to shrink the context`)}f(B,"contextTooLargeError");function I(e){const t=e.details?.rate_limit;if(!t||typeof t!="object")return;const n=me(t);if(n===void 0)return;const{provider:a,model:d}=t;return typeof a=="string"&&a!==""&&typeof d=="string"&&d!==""?{...n,model:`${a}/${d}`}:n}f(I,"refusalRateLimit");function Ue(e){for(const t of e.diagnostics??[]){if(t.type!==q)continue;const n=t.details?.retryAt;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n}}f(Ue,"refusalRetryAt");class H extends Error{static{f(this,"ContentFilteredError")}}function D(e){return pe(e.details?.payment)}f(D,"refusalPayment");function j(e){return typeof e=="string"?e:e.map(t=>t.type==="text"?{type:"text",text:t.text}:{type:"image_url",image_url:{url:`data:${t.mimeType};base64,${t.data}`}})}f(j,"wireContent");function ge(e){const t=f(d=>d.role==="assistant"&&(d.stopReason==="error"||d.stopReason==="aborted"),"incomplete"),n=e.some(t)?e.filter(d=>!t(d)):e;let a=n.length;for(;a>0&&n[a-1]?.role==="assistant";)a--;return a===n.length?n:n.slice(0,a)}f(ge,"wireHistory");async function ye(e,t){const n=S()?void 0:fe(`${e.provider}/${e.id}`,t,!1);if(n?.kind!=="logical"||n.family===ce)return new Set;const a=await le(n,ae(),de());return new Set(a.flatMap(d=>d.strength===n.strength&&d.providerId===e.provider&&d.modelId===e.id&&d.thinkingLevel!==void 0?[d.thinkingLevel]:[]))}f(ye,"launchThinkingLevels");function we(e,t,n,a,d=new Set){const s=[],r=Q(t.messages),i=V(t.messages);r?s.push({role:"system",content:r}):t.systemPrompt&&s.push({role:"system",content:t.systemPrompt});for(const c of ge(t.messages))c.role==="user"?s.push({role:"user",content:j(c.content)}):c.role==="toolResult"?s.push({role:"tool",content:j(c.content),tool_call_id:c.toolCallId}):c.role==="assistant"&&s.push({role:"assistant",content:c.content.filter(p=>p.type==="text").map(p=>p.text).join("")||null,tool_calls:c.content.filter(p=>p.type==="toolCall").map(p=>({id:p.id,type:"function",function:{name:p.name,arguments:JSON.stringify(p.arguments)}}))});const x=`${e.provider}/${e.id}`,E=a??F();return{model:ue(x,E,S()),model_policy:S()?"exact":"substitute",stream:!0,messages:s,...i.length?{tools:i.map(c=>({type:"function",function:{name:c.name,description:c.description,parameters:c.parameters}}))}:{},...n.reasoning&&!d.has(n.reasoning)?{reasoning_effort:n.reasoning}:{},...n.temperature!==void 0?{temperature:n.temperature}:{},...n.maxTokens!==void 0?{max_tokens:n.maxTokens}:{}}}f(we,"requestBody");function M(e,t){if(typeof t!="string")return!1;const n=t.indexOf("/");return n<1||n===t.length-1?!1:(e.provider=t.slice(0,n),e.model=t.slice(n+1),!0)}f(M,"applyServedModel");function W(e){if(e.details?.served_model!==void 0)return e.details.served_model;const t=e.details?.rate_limit;return typeof t?.provider=="string"&&typeof t.model=="string"?`${t.provider}/${t.model}`:void 0}f(W,"refusalRoute");function J(e){if(!e||typeof e!="object"||!("error"in e))throw new Error("llm returned an invalid response");const t=e.error;if(!t||typeof t.message!="string")throw new Error("llm returned an invalid refusal");return t}f(J,"parseRefusal");function Y(){const e=A();return e===void 0?"http://localhost/v1/llm":new URL("/v1/llm",e).toString()}f(Y,"llmUrl");function _e(){return A()===void 0?Z(re()):globalThis.fetch}f(_e,"llmFetch");async function xe(e){if(!e.headers.get("content-type")?.startsWith(te))return e;if(!e.body)throw new Error("deferred head response has no body");const t=e.body.getReader();let n=new Uint8Array(0),a=!1;for(;;){const d=n.indexOf(10);if(d<0){const{value:c,done:p}=await t.read();if(p)throw new Error("deferred head response ended before its head");const m=new Uint8Array(n.length+c.length);m.set(n),m.set(c,n.length),n=m;continue}const s=new TextDecoder().decode(n.subarray(0,d)).trim();if(n=n.subarray(d+1),!a){if(`${s}
|
|
2
|
+
`!==ne)throw new Error("deferred head response has no magic line");a=!0;continue}if(s==="")continue;const r=JSON.parse(s),i=new Headers;for(const[c,p]of Object.entries(r.headers))for(const m of Array.isArray(p)?p:[p])i.append(c,m);const x=n,E=new ReadableStream({start(c){x.length>0&&c.enqueue(x)},async pull(c){const{value:p,done:m}=await t.read();m?c.close():c.enqueue(p)},cancel(c){return t.cancel(c)}});return new Response(r.status===204?null:E,{status:r.status,headers:i})}}f(xe,"unwrapDeferredHead");function Ee(e){const t=e??ie();return t===void 0?{}:{"crtr-caused-by":t}}f(Ee,"causedByHeader");function be(e,t,n={},a,d){const s=K(),r={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};return(async()=>{const i=se();if(!i)throw new Error("llm requires a node token");const x=JSON.stringify(we(e,t,n,a,await ye(e,a??F()))),E=Buffer.byteLength(x);if(E>L)throw B(E,L);let c=0;for(;;){n.signal?.throwIfAborted();const p=await _e()(Y(),{method:"POST",headers:{authorization:`Bearer ${i}`,"content-type":"application/json",[ee]:"1",...Ee(d)},body:x,signal:n.signal}).catch(l=>{const o=Y();throw A()===void 0||n.signal?.aborted?l:new k(oe(l,o).message)}),m=await xe(p);if(!m.ok){const l=J(await m.json());if(m.status===413||l.code==="payload_too_large")throw B(E,L);if(M(r,W(l)),l.retryable!==!0)throw new v(l.message,void 0,I(l),l.code,m.status,D(l));const o=l.retry_after_s;if(typeof o!="number"||!Number.isFinite(o)||o<=0)throw l.code===T?new k(l.message):new Error(l.message);const g=he-c;if(o>g){const h=Date.now()+o*1e3;throw new v(`${l.message} (retry after ${o}s, at ${new Date(h).toISOString()})`,h,I(l),l.code,m.status,D(l))}await X(o*1e3,void 0,{signal:n.signal}),c+=o;continue}if(!m.body)throw new Error("llm returned no stream");s.push({type:"start",partial:r});const z=m.body.getReader(),O=new TextDecoder;let w="",b="stop",$,C=!1,N=!1;const P=f(l=>{const o=JSON.parse(l);if(o.error){const u=J(o);throw M(r,W(u)),u.retryable!==!0?new v(u.message,void 0,I(u),u.code,void 0,D(u)):u.code===T?new k(u.message):new Error(u.message)}if(o.served_model){if(N=!0,o.served_model.indexOf("/")<1)throw new Error("llm returned an invalid served_model");M(r,o.served_model)}const g=o.choices?.[0],h=g?.delta;if(h?.reasoning_content){const u=r.content.findIndex(R=>R.type==="thinking"),y=u<0?{type:"thinking",thinking:""}:r.content[u],_=u<0?r.content.push(y)-1:u;if(u<0&&s.push({type:"thinking_start",contentIndex:_,partial:r}),y.type!=="thinking")throw new Error("invalid thinking block");y.thinking+=h.reasoning_content,s.push({type:"thinking_delta",contentIndex:_,delta:h.reasoning_content,partial:r})}if(h?.content){const u=r.content.findIndex(R=>R.type==="text"),y=u<0?{type:"text",text:""}:r.content[u],_=u<0?r.content.push(y)-1:u;if(u<0&&s.push({type:"text_start",contentIndex:_,partial:r}),y.type!=="text")throw new Error("invalid text block");y.text+=h.content,s.push({type:"text_delta",contentIndex:_,delta:h.content,partial:r})}for(const u of h?.tool_calls??[]){const y={type:"toolCall",id:u.id,name:u.function.name,arguments:JSON.parse(u.function.arguments)},_=r.content.push(y)-1;s.push({type:"toolcall_start",contentIndex:_,partial:r}),s.push({type:"toolcall_end",contentIndex:_,toolCall:y,partial:r})}g?.finish_reason&&(b=g.finish_reason),g?.message?.refusal&&($=g.message.refusal),o.usage&&(C=!0,r.usage={input:o.usage.prompt_tokens,output:o.usage.completion_tokens,cacheRead:o.usage.cache_read_tokens,cacheWrite:o.usage.cache_write_tokens,totalTokens:o.usage.total_tokens,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:typeof o.usage.usd_equivalent=="number"&&Number.isFinite(o.usage.usd_equivalent)?o.usage.usd_equivalent:0}})},"apply");for(;;){const{value:l,done:o}=await z.read();if(o)break;w+=O.decode(l,{stream:!0});let g;for(;(g=w.indexOf(`
|
|
3
|
+
`))>=0;){const h=w.slice(0,g).trim();w=w.slice(g+1),h&&P(h)}}if(w+=O.decode(),w.trim()&&P(w.trim()),!C||!N)throw new Error("llm stream ended without usage or served_model");for(const[l,o]of r.content.entries())o.type==="text"&&s.push({type:"text_end",contentIndex:l,content:o.text,partial:r}),o.type==="thinking"&&s.push({type:"thinking_end",contentIndex:l,content:o.thinking,partial:r});if(b==="content_filter")throw new H($??"Content filtered");if(!["stop","tool_calls","length"].includes(b))throw new Error(`llm returned unknown finish reason: ${b}`);r.stopReason=b==="tool_calls"?"toolUse":b==="length"?"length":"stop",s.push({type:"done",reason:r.stopReason,message:r}),s.end();return}})().catch(i=>{r.stopReason=n.signal?.aborted?"aborted":"error",r.errorMessage=i instanceof Error?i.message:String(i),i instanceof v&&(r.diagnostics=[{type:q,timestamp:Date.now(),...i.retryAt!==void 0?{details:{retryAt:i.retryAt}}:{}},...i.rateLimit!==void 0||i.code==="cap_exhausted"||i.code==="payment_refused"||i.payment!==void 0?[U({status:i.rateLimit!==void 0?429:i.status??402,...i.code===void 0?{}:{code:i.code},...i.rateLimit===void 0?{}:{ratelimit:i.rateLimit},...i.payment===void 0?{}:{payment:i.payment}})]:[]]),i instanceof k&&(r.diagnostics=[U({status:503,code:T})]),i instanceof H&&r.stopReason==="error"&&(r.rawStopReason="content_filter"),s.push({type:"error",reason:r.stopReason,error:r}),s.end()}),s}f(be,"streamBrokerModel");export{he as LLM_BROKER_RETRY_WINDOW_S,q as LLM_REFUSAL_DIAGNOSTIC,Fe as configureBrokerModelRuntime,ye as launchThinkingLevels,Ue as refusalRetryAt,we as requestBody,be as streamBrokerModel,xe as unwrapDeferredHead,ge as wireHistory};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
import { Agent } from 'undici';
|
|
2
|
+
/** An undici Agent with the daemon's transport settings (HTTP/1.1, the connect timeout, the error listener on every Client and Pool). `options` adds to them, for example a connection cap. */
|
|
3
|
+
export declare function createHttpAgent(options?: Agent.Options): Agent;
|
|
1
4
|
export declare function configureDaemonHttpDispatcher(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=Object.defineProperty;var n=(t,e)=>a(t,"name",{value:e,configurable:!0});import{EventEmitter as c}from"node:events";import{Agent as f,Client as l,Pool as u,setGlobalDispatcher as m}from"undici";const T=2e3;function o(t){return t instanceof c&&c.prototype.on.call(t,"error",()=>{}),t}n(o,"withErrorListener");function i(t,e){return o(new l(t,e))}n(i,"createClient");function E(t={}){return o(new f({...t,allowH2:!1,connect:{autoSelectFamilyAttemptTimeout:T},factory:n((e,r)=>r.connections===1?i(e,r):o(new u(e,{...r,factory:i})),"factory")}))}n(E,"createHttpAgent");function w(){m(E())}n(w,"configureDaemonHttpDispatcher");export{w as configureDaemonHttpDispatcher,E as createHttpAgent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.618",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
},
|
|
146
146
|
"license": "UNLICENSED",
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@north-light/identity": "0.3.
|
|
148
|
+
"@north-light/identity": "0.3.618",
|
|
149
149
|
"@earendil-works/chord": "1.1.0",
|
|
150
150
|
"@earendil-works/pi-agent-core": "1.1.0",
|
|
151
151
|
"@earendil-works/pi-ai": "1.1.0",
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.618",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.618",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.618",
|
|
32
32
|
"cron-parser": "^5.6.0",
|
|
33
33
|
"esbuild": "^0.27.7",
|
|
34
34
|
"jose": "^6.2.12",
|
|
@@ -11956,17 +11956,17 @@
|
|
|
11956
11956
|
},
|
|
11957
11957
|
"packages/crouter-api": {
|
|
11958
11958
|
"name": "@north-light/api",
|
|
11959
|
-
"version": "0.3.
|
|
11959
|
+
"version": "0.3.618",
|
|
11960
11960
|
"license": "UNLICENSED"
|
|
11961
11961
|
},
|
|
11962
11962
|
"packages/crouter-env-docker": {
|
|
11963
11963
|
"name": "@north-light/env-docker",
|
|
11964
|
-
"version": "0.3.
|
|
11964
|
+
"version": "0.3.618",
|
|
11965
11965
|
"license": "UNLICENSED"
|
|
11966
11966
|
},
|
|
11967
11967
|
"packages/crouter-identity": {
|
|
11968
11968
|
"name": "@north-light/identity",
|
|
11969
|
-
"version": "0.3.
|
|
11969
|
+
"version": "0.3.618",
|
|
11970
11970
|
"license": "UNLICENSED",
|
|
11971
11971
|
"dependencies": {
|
|
11972
11972
|
"jose": "^6.2.1"
|
|
@@ -11974,21 +11974,21 @@
|
|
|
11974
11974
|
},
|
|
11975
11975
|
"packages/crouter-plugin": {
|
|
11976
11976
|
"name": "@north-light/plugin",
|
|
11977
|
-
"version": "0.3.
|
|
11977
|
+
"version": "0.3.618",
|
|
11978
11978
|
"license": "UNLICENSED",
|
|
11979
11979
|
"dependencies": {
|
|
11980
|
-
"@north-light/api": "0.3.
|
|
11981
|
-
"@north-light/identity": "0.3.
|
|
11980
|
+
"@north-light/api": "0.3.618",
|
|
11981
|
+
"@north-light/identity": "0.3.618"
|
|
11982
11982
|
}
|
|
11983
11983
|
},
|
|
11984
11984
|
"packages/crouter-sdk": {
|
|
11985
11985
|
"name": "@north-light/sdk",
|
|
11986
|
-
"version": "0.3.
|
|
11986
|
+
"version": "0.3.618",
|
|
11987
11987
|
"license": "UNLICENSED",
|
|
11988
11988
|
"dependencies": {
|
|
11989
|
-
"@north-light/api": "0.3.
|
|
11990
|
-
"@north-light/identity": "0.3.
|
|
11991
|
-
"@north-light/plugin": "0.3.
|
|
11989
|
+
"@north-light/api": "0.3.618",
|
|
11990
|
+
"@north-light/identity": "0.3.618",
|
|
11991
|
+
"@north-light/plugin": "0.3.618",
|
|
11992
11992
|
"jose": "^6.2.1"
|
|
11993
11993
|
},
|
|
11994
11994
|
"bin": {
|