@north-light/cli 0.3.632 → 0.3.633

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.
@@ -9,6 +9,12 @@ when-and-why-to-read: When you need Release notes, this knowledge should be read
9
9
 
10
10
  Changes to `@north-light/sdk` that can change what an existing app sees. Newest first.
11
11
 
12
+ ## 0.3.633
13
+
14
+ ### `inferenceEndpoint` falls back to the app's API key when the team Claude pool cannot serve a Northlight-paid call
15
+
16
+ When the admission carries `pool` and the pool is unreachable or answers 401, 402, 403, 404, 408, 429 or any 5xx (every login rate-limited, no login, a pool-side refusal, a pool failure), the same request is now sent to Anthropic with `apiKey` instead of being refused. Any other pool answer, such as a 400 for a malformed request, still reaches the caller unchanged. A call the key serves settles under the same admission with `cost_usd` equal to `list_usd`, so the directory counts it exactly as it counts a pool call; the log entry carries `upstream: 'api_key_fallback'`. This replaces the 0.3.625 rule that a call is never sent to `apiKey` when the admission carried `pool`. No option or type changes.
17
+
12
18
  ## 0.3.625
13
19
 
14
20
  ### `inferenceEndpoint` serves Anthropic Messages, admits and settles every call (breaking, no existing consumer outside Northlight's own apps)
@@ -1 +1 @@
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};
1
+ var j=Object.defineProperty;var l=(i,c)=>j(i,"name",{value:c,configurable:!0});import{createHash as k,randomUUID as B}from"node:crypto";import{closeSync as m,existsSync as z,fsyncSync as S,linkSync as g,lstatSync as U,mkdirSync as D,openSync as p,readFileSync as w,readSync as W,readdirSync as I,realpathSync as M,renameSync as P,rmSync as a,rmdirSync as $,statSync as T,writeSync as v}from"node:fs";import{dirname as N,join as h,resolve as X}from"node:path";import{assertBlobKey as Y}from"./index.js";import{blobFault as x}from"./fault.js";function F(i){const c=p(i,"r");try{S(c)}finally{m(c)}}l(F,"syncDir");function J(i,c,y=g){let s;try{s=M(i)}catch(t){if(t.code==="ENOENT")return;throw t}if(s===X(c))return;const u=new Set,r=l((t,n)=>{let o;try{o=I(t,{withFileTypes:!0})}catch(e){if(e.code==="ENOENT")return;throw e}for(const e of o){if(e.name.endsWith(".tmp"))continue;const f=h(t,e.name),O=h(n,e.name);if(e.isDirectory()){r(f,O);try{$(f)}catch(E){if(!["ENOTEMPTY","ENOENT"].includes(E.code??""))throw E}continue}const d=h(c,O);D(N(d),{recursive:!0,mode:448}),u.add(N(d));try{y(f,d)}catch(E){const b=E.code;if(b==="EEXIST"){H(f,d)&&a(f,{force:!0});continue}if(b==="ENOENT"||!K(f,d))continue}a(f,{force:!0})}},"adopt");r(s,"");for(const t of u)F(t);try{$(s)}catch(t){if(!["ENOTEMPTY","ENOENT"].includes(t.code??""))throw t}U(i,{throwIfNoEntry:!1})?.isSymbolicLink()&&!z(i)&&a(i,{force:!0})}l(J,"adoptBlobDirectory");function H(i,c){try{const y=T(i),s=T(c);return y.ino===s.ino&&y.dev===s.dev}catch{return!1}}l(H,"sameFile");function K(i,c){const y=`${c}.${B()}.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{m(s)}try{g(y,c)}catch(u){if(u.code==="EEXIST")return!1;throw u}return!0}finally{a(y,{force:!0})}}l(K,"copyInto");function Q(i){const c=l(r=>(Y(r),h(i,...r.split("/"))),"pathOf");function y(r,t,n){let o;try{o=I(r,{withFileTypes:!0})}catch(e){if(["ENOENT","ENOTDIR"].includes(e.code??""))return;throw e}for(const e of o){if(e.name.endsWith(".tmp"))continue;const f=t===""?e.name:`${t}/${e.name}`;e.isDirectory()?y(h(r,e.name),f,n):n.push(f)}}l(y,"walk");function s(r,t){D(N(r),{recursive:!0,mode:448});const n=`${r}.${B()}.tmp`,o=p(n,"wx",384);try{let e=0;for(;e<t.length;)e+=v(o,t,e);S(o)}catch(e){throw m(o),a(n,{force:!0}),e}m(o),P(n,r),F(N(r))}l(s,"write");const u={async put(r,t){x("put"),s(c(r),typeof t=="string"?Buffer.from(t,"utf8"):Buffer.from(t))},async head(r){let t;try{t=w(c(r))}catch(n){if(n.code==="ENOENT")return null;throw n}return{size:t.length,etag:k("md5").update(t).digest("hex")}},async copy(r,t){x("copy");const n=c(r),o=c(t);let e;try{e=w(n)}catch(f){if(f.code==="ENOENT")return!1;throw f}return s(o,e),!0},async get(r,t){try{if(!t)return w(c(r));const n=p(c(r),"r");try{const o=Buffer.allocUnsafe(t.length),e=W(n,o,0,t.length,t.start);return o.subarray(0,e)}finally{m(n)}}catch(n){if(n.code==="ENOENT")return null;throw n}},async list(r){const t=r.split("/").slice(0,-1);if(t.some(o=>o===""||o==="."||o===".."))return[];const n=[];return y(h(i,...t),t.join("/"),n),n.filter(o=>o.startsWith(r)).sort((o,e)=>Buffer.compare(Buffer.from(o),Buffer.from(e)))},async listObjects(r){const t=[];for(const n of await u.list(r))try{t.push({key:n,size:T(c(n)).size,etag:null})}catch(o){if(o.code!=="ENOENT")throw o}return t},async delete(r){a(c(r),{force:!0})}};return u}l(Q,"createDirectoryBlobStore");export{J as adoptBlobDirectory,Q as createDirectoryBlobStore};
@@ -1,10 +1,13 @@
1
- var W=Object.defineProperty;var d=(n,E)=>W(n,"name",{value:E,configurable:!0});import{KEY_MAPPED_TABLES as k}from"../bundle/layout.js";import{keyMatch as v,q as s,rowKey as H}from"./catalog.js";import{archiveCutoffs as j,BODY_TYPES as J}from"../../events/run-event-chunks.js";import{MEMORY_READS_RETENTION_MS as x}from"../../canvas/memory-reads.js";import{decodeKeys as B}from"./copy.js";const r=d((n,E)=>`${s(n)}.${s(E)}`,"sq"),Y={messages:["seq"]},q=["claimed_by","lease_expires_at"],K={worktrees:["attempts","next_attempt_at","sweep_reason","sweep_detail","sweep_last_at","sweep_observed_json"]},P=10*6e4;function C(n){const E=Date.now()+P;if(n==="run_events"){const{bodyCutoff:t,controlCutoff:O}=j(E);return`(s.ts < '${O}' OR (s.ts < '${t}' AND s.type IN (${J.map(p=>`'${p}'`).join(", ")})))`}return n==="memory_reads"?`s.at < '${new Date(E-x).toISOString()}'`:"false"}d(C,"removedByMaintenance");async function ee(n,E,t,O,p,h){const m={},l={},S=await n.prepare("SELECT table_name, inserted_keys FROM import_manifest WHERE run_id = ?").all(E);await n.exec(`DROP TABLE IF EXISTS ${s(t)}._m; CREATE TABLE ${s(t)}._m (tbl text NOT NULL, k jsonb NOT NULL)`);for(const{table_name:e,inserted_keys:a}of S){const i=p.tables.get(e);if(i===void 0)continue;const N=B(a);if(N.length===0)continue;await n.prepare(`DELETE FROM ${s(t)}._m WHERE tbl = ?`).run(e);for(let o=0;o<N.length;o+=5e3)await n.prepare(`INSERT INTO ${s(t)}._m SELECT ?, e FROM jsonb_array_elements(?::jsonb) e`).run(e,JSON.stringify(N.slice(o,o+5e3)));await n.exec(`ANALYZE ${s(t)}._m`);const f=[...i.identity,...Y[e]??[],...q,...K[e]??[]].map(o=>`'${o.replace(/'/g,"''")}'`).join(", ")||"''",I=d(o=>`to_jsonb(${o}) - ARRAY[${f}]::text[]`,"strip"),_=H(i);let $;if(e in k){const o=k[e];$=`JOIN import_key_map km ON km.source_install_id = '${h.replace(/'/g,"''")}' AND km.table_name = '${e}' AND km.target_key = m.k ->> 0
2
- JOIN ${r(t,e)} s ON s.${s(o)}::text = km.source_key`}else $=`JOIN ${r(t,e)} s ON ${_.map((o,U)=>`s.${s(o)}::text = m.k ->> ${U}`).join(" AND ")}`;const F=e==="revisions"?` AND m.k ->> 0 NOT IN (SELECT rev_id FROM ${r(t,"_arr_revisions")})`:e==="revision_parents"?` AND NOT EXISTS (SELECT 1 FROM ${r(t,"_arr_parents")} a WHERE a.child = m.k ->> 0 AND a.parent = m.k ->> 1)`:"",b=`FROM ${r(t,"_m")} m LEFT JOIN ${r(O,e)} t ON ${v(i,_,"t","m.k")} ${$.replace("JOIN","LEFT JOIN")} WHERE m.tbl = '${e}'${F}`,w=`${b} AND ((t.${s(_[0])} IS NULL AND NOT (s.${s(_[0])} IS NOT NULL AND ${C(e)})) OR s.${s(_[0])} IS NULL OR (${I("t")}) <> (${I("s")}))`,y=await n.prepareUncached(`SELECT count(*) AS n, array_agg(k) FILTER (WHERE rn <= 10) AS keys FROM (SELECT m.k::text AS k, row_number() OVER () AS rn ${w}) d`).get(),D=Number(y.n);if(D>0&&(m[e]={count:D,keys:y.keys??[]}),e==="run_events"||e==="memory_reads"){const o=Number((await n.prepareUncached(`SELECT count(*) AS n ${b} AND t.${s(_[0])} IS NULL AND s.${s(_[0])} IS NOT NULL AND ${C(e)}`).get()).n);o>0&&(l[e]=o)}}for(const[e,a]of[["revisions",`FROM ${r(t,"_m")} m JOIN ${r(t,"_arr_revisions")} a ON a.rev_id = m.k ->> 0 LEFT JOIN revisions t ON t.rev_id = a.rev_id
1
+ var w=Object.defineProperty;var m=(n,c)=>w(n,"name",{value:c,configurable:!0});import{KEY_MAPPED_TABLES as k}from"../bundle/layout.js";import{keyMatch as D,q as a,rowKey as W}from"./catalog.js";import{archiveCutoffs as H,BODY_TYPES as J}from"../../events/run-event-chunks.js";import{MEMORY_READS_RETENTION_MS as j}from"../../canvas/memory-reads.js";import{decodeKeys as x}from"./copy.js";const r=m((n,c)=>`${a(n)}.${a(c)}`,"sq"),B={messages:["seq"]},Y=["claimed_by","lease_expires_at"],P={worktrees:["attempts","next_attempt_at","sweep_reason","sweep_detail","sweep_last_at","sweep_observed_json"]},K=10*6e4;function C(n){const c=Date.now()+K;if(n==="run_events"){const{bodyCutoff:t,controlCutoff:O}=H(c);return`(s.ts < '${O}' OR (s.ts < '${t}' AND s.type IN (${J.map(S=>`'${S}'`).join(", ")})))`}return n==="memory_reads"?`s.at < '${new Date(c-j).toISOString()}'`:"false"}m(C,"removedByMaintenance");async function Q(n,c,t,O,S,h){const d={},A={},L=await n.prepare("SELECT table_name, inserted_keys FROM import_manifest WHERE run_id = ?").all(c);await n.exec(`DROP TABLE IF EXISTS ${a(t)}._m; CREATE TABLE ${a(t)}._m (tbl text NOT NULL, k jsonb NOT NULL)`);for(const{table_name:e,inserted_keys:E}of L){const i=S.tables.get(e);if(i===void 0)continue;const p=x(E);if(p.length===0)continue;await n.prepare(`DELETE FROM ${a(t)}._m WHERE tbl = ?`).run(e);for(let o=0;o<p.length;o+=5e3)await n.prepare(`INSERT INTO ${a(t)}._m SELECT ?, e FROM jsonb_array_elements(?::jsonb) e`).run(e,JSON.stringify(p.slice(o,o+5e3)));await n.exec(`ANALYZE ${a(t)}._m`);const $=[...i.identity,...B[e]??[],...Y,...P[e]??[]].map(o=>`'${o.replace(/'/g,"''")}'`).join(", ")||"''",s=m(o=>`to_jsonb(${o}) - ARRAY[${$}]::text[]`,"strip"),N=W(i);let T;if(e in k){const o=k[e];T=`JOIN import_key_map km ON km.source_install_id = '${h.replace(/'/g,"''")}' AND km.table_name = '${e}' AND km.target_key = m.k ->> 0
2
+ JOIN ${r(t,e)} s ON s.${a(o)}::text = km.source_key`}else T=`JOIN ${r(t,e)} s ON ${N.map((o,U)=>`s.${a(o)}::text = m.k ->> ${U}`).join(" AND ")}`;const g=e==="revisions"?` AND m.k ->> 0 NOT IN (SELECT rev_id FROM ${r(t,"_arr_revisions")})`:e==="revision_parents"?` AND NOT EXISTS (SELECT 1 FROM ${r(t,"_arr_parents")} a WHERE a.child = m.k ->> 0 AND a.parent = m.k ->> 1)`:"",b=`FROM ${r(t,"_m")} m LEFT JOIN ${r(O,e)} t ON ${D(i,N,"t","m.k")} ${T.replace("JOIN","LEFT JOIN")} WHERE m.tbl = '${e}'${g}`,F=`${b} AND ((t.${a(N[0])} IS NULL AND NOT (s.${a(N[0])} IS NOT NULL AND ${C(e)})) OR s.${a(N[0])} IS NULL OR (${s("t")}) <> (${s("s")}))`,y=await n.prepareUncached(`SELECT count(*) AS n, array_agg(k) FILTER (WHERE rn <= 10) AS keys FROM (SELECT m.k::text AS k, row_number() OVER () AS rn ${F}) d`).get(),v=Number(y.n);if(v>0&&(d[e]={count:v,keys:y.keys??[]}),e==="run_events"||e==="memory_reads"){const o=Number((await n.prepareUncached(`SELECT count(*) AS n ${b} AND t.${a(N[0])} IS NULL AND s.${a(N[0])} IS NOT NULL AND ${C(e)}`).get()).n);o>0&&(A[e]=o)}}for(const[e,E]of[["revisions",`FROM ${r(t,"_m")} m JOIN ${r(t,"_arr_revisions")} a ON a.rev_id = m.k ->> 0 LEFT JOIN revisions t ON t.rev_id = a.rev_id
3
3
  WHERE m.tbl = 'revisions' AND (t.rev_id IS NULL OR t.document <> a.document OR t.body_hash <> a.body_hash OR t.rationale IS DISTINCT FROM a.rationale OR t.created_at <> a.created_at)`],["revision_parents",`FROM ${r(t,"_m")} m JOIN ${r(t,"_arr_parents")} a ON a.child = m.k ->> 0 AND a.parent = m.k ->> 1 LEFT JOIN revision_parents t ON t.child = a.child AND t.parent = a.parent
4
- WHERE m.tbl = 'revision_parents' AND t.child IS NULL`]]){const i=Number((await n.prepareUncached(`SELECT count(*) AS n ${a}`).get()).n);i>0&&(m[`${e}.arrived`]={count:i,keys:[]})}const c={},A=`SELECT source AS key FROM ${r(t,"_idmap")} WHERE kind = 'object'`,M=d(e=>e==="messages"?`(${A})`:`(${A} UNION SELECT key FROM ${r(t,"_dropped")} WHERE tbl = 'objects')`,"droppedFor");let u=!1;for(const{table_name:e}of S){const a=p.tables.get(e);if(a===void 0||u||a.primaryKey.length===0)continue;const i=await n.prepareUncached("SELECT column_name FROM information_schema.columns WHERE table_schema = ? AND table_name = ? AND data_type = 'text'").all(O,e);for(const{column_name:N}of i){if(a.primaryKey.includes(N)&&e==="objects")continue;if(await n.prepareUncached(`SELECT 1 AS found FROM ${r(t,"_m")} m JOIN ${r(O,e)} t ON ${v(a,a.primaryKey,"t","m.k")}
5
- WHERE m.tbl = ? AND t.${s(N)} IN ${M(e)} LIMIT 1`).get(e)!==void 0){u=!0,m[`${e}.${N}`]={count:1,keys:["holds a dropped object id"]};break}}}c.no_dropped_id=!u;const R=S.find(e=>e.table_name==="revisions");let T=!0,L=0;if(R!==void 0){const e=`FROM ${r(t,"_m")} m JOIN revisions r ON r.rev_id = m.k ->> 0 WHERE m.tbl = 'revisions' AND NOT EXISTS (SELECT 1 FROM bodies b WHERE b.hash = r.body_hash)`;T=await n.prepare(`SELECT 1 AS lost ${e} AND EXISTS (SELECT 1 FROM ${r(t,"bodies")} s WHERE s.hash = r.body_hash) LIMIT 1`).get()===void 0,L=Number((await n.prepare(`SELECT count(*) AS n ${e} AND NOT EXISTS (SELECT 1 FROM ${r(t,"bodies")} s WHERE s.hash = r.body_hash)`).get()).n)}c.revision_bodies_readable=T,c.revision_bodies_canonical=R===void 0||await n.prepare(`SELECT 1 AS wrong FROM ${r(t,"_m")} m JOIN revisions r ON r.rev_id = m.k ->> 0 JOIN bodies b ON b.hash = r.body_hash
6
- WHERE m.tbl = 'revisions' AND encode(sha256(convert_to(b.text, 'UTF8')), 'hex') <> b.hash LIMIT 1`).get()===void 0;const g=await n.prepare(`SELECT 1 AS found FROM (
4
+ WHERE m.tbl = 'revision_parents' AND t.child IS NULL`]]){const i=Number((await n.prepareUncached(`SELECT count(*) AS n ${E}`).get()).n);i>0&&(d[`${e}.arrived`]={count:i,keys:[]})}const _={},l=r(t,"_ids");await n.exec(`DROP TABLE IF EXISTS ${l}; CREATE TABLE ${l} (key text PRIMARY KEY, mapped boolean NOT NULL);
5
+ INSERT INTO ${l} SELECT key, bool_or(mapped) FROM (SELECT source AS key, true AS mapped FROM ${r(t,"_idmap")} WHERE kind = 'object'
6
+ UNION ALL SELECT key, false FROM ${r(t,"_dropped")} WHERE tbl = 'objects') u GROUP BY key; ANALYZE ${l}`);let R=!1;for(const{table_name:e}of L){const E=S.tables.get(e);if(E===void 0||R||E.primaryKey.length===0)continue;const i=(await n.prepareUncached("SELECT column_name FROM information_schema.columns WHERE table_schema = ? AND table_name = ? AND data_type = 'text'").all(O,e)).map(s=>s.column_name).filter(s=>!(E.primaryKey.includes(s)&&e==="objects"));if(i.length===0)continue;const p=i.map(s=>`('${s.replace(/'/g,"''")}', t.${a(s)})`).join(", "),$=await n.prepareUncached(`SELECT v.col AS col, count(*) AS n FROM ${r(t,"_m")} m JOIN ${r(O,e)} t ON ${D(E,E.primaryKey,"t","m.k")}
7
+ CROSS JOIN LATERAL (VALUES ${p}) v(col, val) JOIN ${l} i ON i.key = v.val${e==="messages"?" AND i.mapped":""}
8
+ WHERE m.tbl = ? GROUP BY v.col ORDER BY v.col`).all(e);for(const{col:s,n:N}of $)R=!0,d[`${e}.${s}`]={count:Number(N),keys:["holds a dropped object id"]}}_.no_dropped_id=!R;const I=L.find(e=>e.table_name==="revisions");let f=!0,u=0;if(I!==void 0){const e=`FROM ${r(t,"_m")} m JOIN revisions r ON r.rev_id = m.k ->> 0 WHERE m.tbl = 'revisions' AND NOT EXISTS (SELECT 1 FROM bodies b WHERE b.hash = r.body_hash)`;f=await n.prepare(`SELECT 1 AS lost ${e} AND EXISTS (SELECT 1 FROM ${r(t,"bodies")} s WHERE s.hash = r.body_hash) LIMIT 1`).get()===void 0,u=Number((await n.prepare(`SELECT count(*) AS n ${e} AND NOT EXISTS (SELECT 1 FROM ${r(t,"bodies")} s WHERE s.hash = r.body_hash)`).get()).n)}_.revision_bodies_readable=f,_.revision_bodies_canonical=I===void 0||await n.prepare(`SELECT 1 AS wrong FROM ${r(t,"_m")} m JOIN revisions r ON r.rev_id = m.k ->> 0 JOIN bodies b ON b.hash = r.body_hash
9
+ WHERE m.tbl = 'revisions' AND encode(sha256(convert_to(b.text, 'UTF8')), 'hex') <> b.hash LIMIT 1`).get()===void 0;const M=await n.prepare(`SELECT 1 AS found FROM (
7
10
  SELECT month, payer, funding, COALESCE(sub, '') AS sub, grantee, COALESCE(provider, '') AS provider, COALESCE(SUM(usd), 0) AS usd, COALESCE(SUM(billed_usd), 0) AS billed
8
11
  FROM charges WHERE refused IS NULL AND kind <> 'take' AND (month, payer) IN (SELECT DISTINCT month, payer FROM ${r(t,"charges")}) GROUP BY 1, 2, 3, 4, 5, 6) c
9
12
  FULL JOIN charge_totals t ON t.month = c.month AND t.payer = c.payer AND t.funding = c.funding AND t.sub = c.sub AND t.grantee = c.grantee AND t.provider = c.provider
10
- WHERE (COALESCE(t.month, c.month), COALESCE(t.payer, c.payer)) IN (SELECT DISTINCT month, payer FROM ${r(t,"charges")}) AND (c.month IS NULL OR t.month IS NULL OR c.usd <> t.usd OR c.billed <> t.billed_usd) LIMIT 1`).get();return c.charge_totals_equal_recompute=g===void 0,{ok:Object.keys(m).length===0&&Object.values(c).every(Boolean),differences:m,...Object.keys(l).length>0?{archived:l}:{},...L>0?{source_missing_bodies:L}:{},invariants:c}}d(ee,"verifyRun");export{ee as verifyRun};
13
+ WHERE (COALESCE(t.month, c.month), COALESCE(t.payer, c.payer)) IN (SELECT DISTINCT month, payer FROM ${r(t,"charges")}) AND (c.month IS NULL OR t.month IS NULL OR c.usd <> t.usd OR c.billed <> t.billed_usd) LIMIT 1`).get();return _.charge_totals_equal_recompute=M===void 0,{ok:Object.keys(d).length===0&&Object.values(_).every(Boolean),differences:d,...Object.keys(A).length>0?{archived:A}:{},...u>0?{source_missing_bodies:u}:{},invariants:_}}m(Q,"verifyRun");export{Q as verifyRun};
@@ -7,6 +7,12 @@ description: Behavior changes in @north-light/sdk that an app must act on, newes
7
7
 
8
8
  Changes to `@north-light/sdk` that can change what an existing app sees. Newest first.
9
9
 
10
+ ## 0.3.633
11
+
12
+ ### `inferenceEndpoint` falls back to the app's API key when the team Claude pool cannot serve a Northlight-paid call
13
+
14
+ When the admission carries `pool` and the pool is unreachable or answers 401, 402, 403, 404, 408, 429 or any 5xx (every login rate-limited, no login, a pool-side refusal, a pool failure), the same request is now sent to Anthropic with `apiKey` instead of being refused. Any other pool answer, such as a 400 for a malformed request, still reaches the caller unchanged. A call the key serves settles under the same admission with `cost_usd` equal to `list_usd`, so the directory counts it exactly as it counts a pool call; the log entry carries `upstream: 'api_key_fallback'`. This replaces the 0.3.625 rule that a call is never sent to `apiKey` when the admission carried `pool`. No option or type changes.
15
+
10
16
  ## 0.3.625
11
17
 
12
18
  ### `inferenceEndpoint` serves Anthropic Messages, admits and settles every call (breaking, no existing consumer outside Northlight's own apps)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.632",
3
+ "version": "0.3.633",
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.632",
148
+ "@north-light/identity": "0.3.633",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.632",
3
+ "version": "0.3.633",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.632",
3
+ "version": "0.3.633",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.632",
9
+ "version": "0.3.633",
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.632",
31
+ "@north-light/identity": "0.3.633",
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.632",
11959
+ "version": "0.3.633",
11960
11960
  "license": "UNLICENSED"
11961
11961
  },
11962
11962
  "packages/crouter-env-docker": {
11963
11963
  "name": "@north-light/env-docker",
11964
- "version": "0.3.632",
11964
+ "version": "0.3.633",
11965
11965
  "license": "UNLICENSED"
11966
11966
  },
11967
11967
  "packages/crouter-identity": {
11968
11968
  "name": "@north-light/identity",
11969
- "version": "0.3.632",
11969
+ "version": "0.3.633",
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.632",
11977
+ "version": "0.3.633",
11978
11978
  "license": "UNLICENSED",
11979
11979
  "dependencies": {
11980
- "@north-light/api": "0.3.632",
11981
- "@north-light/identity": "0.3.632"
11980
+ "@north-light/api": "0.3.633",
11981
+ "@north-light/identity": "0.3.633"
11982
11982
  }
11983
11983
  },
11984
11984
  "packages/crouter-sdk": {
11985
11985
  "name": "@north-light/sdk",
11986
- "version": "0.3.632",
11986
+ "version": "0.3.633",
11987
11987
  "license": "UNLICENSED",
11988
11988
  "dependencies": {
11989
- "@north-light/api": "0.3.632",
11990
- "@north-light/identity": "0.3.632",
11991
- "@north-light/plugin": "0.3.632",
11989
+ "@north-light/api": "0.3.633",
11990
+ "@north-light/identity": "0.3.633",
11991
+ "@north-light/plugin": "0.3.633",
11992
11992
  "jose": "^6.2.1"
11993
11993
  },
11994
11994
  "bin": {