@north-light/cli 0.3.612 → 0.3.614

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.
@@ -1,5 +1,5 @@
1
1
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
2
- export declare const CONTRACT_LEVEL = "1.46";
2
+ export declare const CONTRACT_LEVEL = "1.47";
3
3
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
4
4
  export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
5
5
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -1 +1 @@
1
- var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.46",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
1
+ var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.47",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
@@ -9,6 +9,10 @@ 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.613
13
+
14
+ `oauth.appMember('user:<id>')` asks the directory whether that person is on the team that holds your app, for your app's own staff pages. It answers `{member: true, role: 'admin' | 'member'}` or `{member: false}` (an unknown user is `member: false`) by calling `GET /v1/apps/self/members/:user_id` as the app itself, and caches nothing, so someone removed from the team is refused at their next call. A 401 re-mints the directory token once. Nothing existing changes.
15
+
12
16
  ## 0.3.599
13
17
 
14
18
  `PUT /v1/model-auth/:provider` with `kind: "api_key"` accepts an optional `models: {ultra, strong, medium, light}` for `anthropic`, `openai`, `openrouter` and `moonshotai`. Each value is `<provider>/<model-id>`, a registered chat model of that provider; all four are required. The key is saved with that mapping as the person's model route `key:<provider>`, which is tried after every subscription. An invalid mapping is refused `400 invalid_request`. Without `models` the call behaves as before.
@@ -9,6 +9,9 @@ export declare function createRowStore(): ConversationStore & {
9
9
  transcript_path: string | null;
10
10
  }>): void;
11
11
  };
12
+ /** Part 0's bytes with the header's `cwd` replaced by `next(cwd)` and every later byte untouched; null when `next` leaves the cwd as it was.
13
+ * Throws when the first line is not the session header of conversation `id`. */
14
+ export declare function withHeaderCwd(data: Buffer, id: string, next: (cwd: string) => string): Buffer | null;
12
15
  /** Rewrite part 0's header `cwd` under the conversation's row lock, leaving later parts and tail rows untouched.
13
16
  * Returns false when the header's cwd is not `oldCwd`. */
14
17
  export declare function relocateConversationHeader(id: string, oldCwd: string, newCwd: string): Promise<boolean>;
@@ -1,13 +1,13 @@
1
- var H=Object.defineProperty;var f=(o,t)=>H(o,"name",{value:t,configurable:!0});import{randomUUID as g}from"node:crypto";import{existsSync as W,readFileSync as q,rmSync as A}from"node:fs";import{join as B}from"node:path";import{SessionManager as j}from"@earendil-works/pi-coding-agent";import{blobStore as l}from"../blobs/index.js";import{openDb as w,withCanvasWrite as y}from"../canvas/db.js";import{appSpace as J}from"../layout.js";import{appendConversationEvents as T,rootRepromptPending as L}from"../../daemon/runs/append-section.js";import{ConversationNotFoundError as R}from"./index.js";const O="s.unbound_at IS NULL DESC, s.created_at DESC, s.seq DESC",D=f((o,t,n)=>`conversations/${o}/${t}/${n}.jsonl`,"keyFor"),k=f(o=>o.map(t=>JSON.stringify(t)+`
2
- `).join(""),"encode"),$=f(o=>o.split(`
3
- `).filter(Boolean).map(t=>JSON.parse(t)),"decode"),h=f(()=>new Date().toISOString(),"at");async function N(o,t,n=!1){const i=await o.prepare(`SELECT s.binding_id, s.node_id, s.transcript_path, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY ${O} LIMIT 1${n?" FOR UPDATE OF s":""}`).get(t);if(!i)throw new R(t);return i}f(N,"binding");async function b(o,t){return await o.prepare("SELECT seq, blob_key, bytes, entries, created FROM conversation_parts WHERE conversation_id = ? ORDER BY seq").all(t)}f(b,"parts");async function Y(o,t){return await o.prepare("SELECT seq, body, bytes, created FROM conversation_entries WHERE conversation_id = ? ORDER BY seq").all(t)}f(Y,"tail");async function I(o,t){const n=await o.prepare(`SELECT 'part' AS kind, seq, blob_key, NULL AS body, bytes, entries, created FROM conversation_parts WHERE conversation_id = ?
4
- UNION ALL SELECT 'tail', seq, NULL, body, bytes, NULL, created FROM conversation_entries WHERE conversation_id = ? ORDER BY 1, 2`).all(t,t);return{parts:n.filter(i=>i.kind==="part").map(({seq:i,blob_key:s,bytes:a,entries:e,created:r})=>({seq:Number(i),blob_key:s,bytes:Number(a),entries:Number(e),created:r})),tail:n.filter(i=>i.kind==="tail").map(({seq:i,body:s,bytes:a,created:e})=>({seq:Number(i),body:s,bytes:Number(a),created:e}))}}f(I,"snapshot");const C=1024*1024;async function m(o,t,n){const i=[];let s=0;const a=await l();for(const e of o.parts){const r=Math.max(t,s),c=Math.min(n,s+e.bytes);if(r<c){const d=await a.get(e.blob_key,{start:r-s,length:c-r});if(!d)throw new Error(`missing conversation object: ${e.blob_key}`);i.push(d)}s+=e.bytes}for(const e of o.tail){const r=Math.max(t,s),c=Math.min(n,s+e.bytes);r<c&&i.push(Buffer.from(e.body+`
5
- `).subarray(r-s,c-s)),s+=e.bytes}return Buffer.concat(i)}f(m,"bytesOf");const M=new Map;async function U(o,t,n){const i=await w();if(await i.prepare("SELECT 1 FROM conversation_parts WHERE conversation_id = ? AND seq = 0").get(o)||!W(n))return;let s=q(n);const a=s.lastIndexOf(10);if(a<0)return;s=s.subarray(0,a+1);const e=await i.prepare("SELECT s.binding_id, s.node_id, s.event_offset, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY "+O+" LIMIT 1").get(o);let r=[];if(e?.run_id&&e.event_offset!==null){const p=Number(e.event_offset);if(s.length<p)throw new Error(`conversation shorter than indexed offset: ${o}`);r=$(s.subarray(p).toString("utf8")).filter(u=>u.type!=="session")}const c=e?.run_id?await L(e.run_id,e.node_id,r):!1,d=D(t,o,0);await(await l()).put(d,s),await y(async p=>{if(!await p.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?) ON CONFLICT DO NOTHING RETURNING seq").get(o,d,s.length,Math.max(0,s.toString("utf8").split(`
6
- `).filter(Boolean).length-1),h())||!e?.run_id||e.event_offset===null)return;const _=e.source_session_id?[]:await T(p,e.run_id,e.node_id,r,JSON.parse(e.input_ids_json),c);await p.prepare("UPDATE sessions SET event_offset = ?, indexed_entry_id = ?, input_ids_json = ? WHERE binding_id = ?").run(s.length,r.at(-1)?.id??null,JSON.stringify(_),e.binding_id)})}f(U,"importOne");async function S(o,t){const n=await t.prepare(`SELECT s.binding_id, s.node_id, s.transcript_path, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY ${O} LIMIT 1`).get(o),i=M.get(o);if(!n&&!i)throw new R(o);let s=(await b(t,o))[0];if(!s){const c=i?.path??n?.transcript_path??void 0;c&&await U(o,i?.node??n.node_id,c),s=(await b(t,o))[0]}if(!s||s.seq!==0)throw new R(o);const a=await(await l()).get(s.blob_key,{start:0,length:Math.min(s.bytes,256*1024)});if(!a)throw new Error(`missing conversation object: ${s.blob_key}`);const e=a.indexOf(10);if(e<0)throw new Error(`invalid conversation header: ${o}`);const r=JSON.parse(a.subarray(0,e).toString("utf8"));if(r.type!=="session"||r.id!==o)throw new Error(`invalid conversation header: ${o}`);return{header:r,path:n?.transcript_path??i?.path??"",binding:n}}f(S,"initial");function et(){const o={async create(t,n,i,s){const e=await(await w()).prepare("SELECT grantee, run_id FROM node_rows WHERE node_id = ?").get(t);if(!e)throw new Error(`missing conversation owner ${t}`);const r=n.id,c=B(J(e.grantee).conversations,t,`${n.timestamp.replace(/[:.]/g,"-")}_${r}.jsonl`),d=k([n,...i]),p=D(t,r,0),u=e.run_id?await L(e.run_id,t,i):!1;return await(await l()).put(p,d),await y(async _=>{if(await _.prepare("SELECT 1 FROM conversation_parts WHERE conversation_id = ?").get(r))throw new Error(`conversation already exists: ${r}`);const E=h(),v=n.parentSession?await _.prepare("SELECT session_id FROM sessions WHERE transcript_path = ? LIMIT 1").get(n.parentSession):void 0;if(await _.prepare("INSERT INTO sessions (binding_id, session_id, node_id, transcript_path, source_session_id, fork_entry_id, created_at, bound_at, unbound_at) VALUES (?, ?, ?, ?, ?, NULL, ?, ?, ?)").run(g(),r,t,c,v?v.session_id:null,E,E,E),await _.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?)").run(r,p,Buffer.byteLength(d),i.length,E),e.run_id&&!v){const F=await T(_,e.run_id,t,i,[],u);await _.prepare("UPDATE sessions SET indexed_entry_id = ?, input_ids_json = ? WHERE session_id = ? AND node_id = ?").run(i.at(-1)?.id??null,JSON.stringify(F),r,t)}}),r},async append(t,n){if(!n.length)return;const i=await N(await w(),t),s=i.run_id?await L(i.run_id,i.node_id,n):!1;await y(async a=>{const e=await N(a,t,!0);if(!(await b(a,t)).length)throw new R(t);const r=[];for(const c of n){const d=JSON.stringify(c);await a.prepare("INSERT INTO conversation_entries (conversation_id, entry_id, body, bytes, execution_id, created) VALUES (?, ?, ?, ?, NULL, ?) ON CONFLICT (conversation_id, entry_id) DO NOTHING RETURNING entry_id").get(t,c.id,d,Buffer.byteLength(d)+1,h())&&r.push(c)}if(e.run_id&&r.length){const c=await T(a,e.run_id,e.node_id,r,JSON.parse(e.input_ids_json??"[]"),s);await a.prepare("UPDATE sessions SET indexed_entry_id = ?, input_ids_json = ? WHERE binding_id = ?").run(r.at(-1).id,JSON.stringify(c),e.binding_id)}})},async readLines(t){const n=await w(),{path:i}=await S(t,n),s=await I(n,t),a=s.parts.reduce((r,c)=>r+c.bytes,0)+s.tail.reduce((r,c)=>r+c.bytes,0);async function*e(){let r="";for(let c=0;c<a;c+=C){const d=r+(await m(s,c,Math.min(a,c+C))).toString("latin1"),p=d.lastIndexOf(`
7
- `);r=d.slice(p+1);for(const u of d.slice(0,p+1).split(`
8
- `))u&&(yield Buffer.from(u,"latin1").toString("utf8"))}r&&(yield Buffer.from(r,"latin1").toString("utf8"))}return f(e,"lines"),{path:i,lines:e()}},async read(t,n){const i=await w(),{header:s,path:a}=await S(t,i),e=await I(i,t),r=e.parts.reduce((_,E)=>_+E.bytes,0)+e.tail.reduce((_,E)=>_+E.bytes,0),c=f(_=>$(_).filter(E=>E.type!=="session"),"entriesOf");if(!n||r<=n.head+n.tail)return{header:s,entries:c((await m(e,0,r)).toString("utf8")),path:a};const d=(await m(e,0,Math.max(0,n.head))).toString("utf8").split(`
9
- `);d.pop();const p=Math.max(0,r-n.tail),u=(await m(e,p>0?p-1:0,r)).toString("utf8").split(`
10
- `);return p>0&&u.shift(),{header:s,entries:c(d.join(`
1
+ var F=Object.defineProperty;var _=(o,t)=>F(o,"name",{value:t,configurable:!0});import{randomUUID as g}from"node:crypto";import{existsSync as W,readFileSync as q,rmSync as A}from"node:fs";import{join as B}from"node:path";import{SessionManager as j}from"@earendil-works/pi-coding-agent";import{blobStore as E}from"../blobs/index.js";import{openDb as w,withCanvasWrite as y}from"../canvas/db.js";import{appSpace as J}from"../layout.js";import{appendConversationEvents as T,rootRepromptPending as L}from"../../daemon/runs/append-section.js";import{ConversationNotFoundError as R}from"./index.js";const O="s.unbound_at IS NULL DESC, s.created_at DESC, s.seq DESC",D=_((o,t,r)=>`conversations/${o}/${t}/${r}.jsonl`,"keyFor"),k=_(o=>o.map(t=>JSON.stringify(t)+`
2
+ `).join(""),"encode"),C=_(o=>o.split(`
3
+ `).filter(Boolean).map(t=>JSON.parse(t)),"decode"),h=_(()=>new Date().toISOString(),"at");async function N(o,t,r=!1){const i=await o.prepare(`SELECT s.binding_id, s.node_id, s.transcript_path, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY ${O} LIMIT 1${r?" FOR UPDATE OF s":""}`).get(t);if(!i)throw new R(t);return i}_(N,"binding");async function b(o,t){return await o.prepare("SELECT seq, blob_key, bytes, entries, created FROM conversation_parts WHERE conversation_id = ? ORDER BY seq").all(t)}_(b,"parts");async function x(o,t){return await o.prepare("SELECT seq, body, bytes, created FROM conversation_entries WHERE conversation_id = ? ORDER BY seq").all(t)}_(x,"tail");async function I(o,t){const r=await o.prepare(`SELECT 'part' AS kind, seq, blob_key, NULL AS body, bytes, entries, created FROM conversation_parts WHERE conversation_id = ?
4
+ UNION ALL SELECT 'tail', seq, NULL, body, bytes, NULL, created FROM conversation_entries WHERE conversation_id = ? ORDER BY 1, 2`).all(t,t);return{parts:r.filter(i=>i.kind==="part").map(({seq:i,blob_key:n,bytes:s,entries:e,created:a})=>({seq:Number(i),blob_key:n,bytes:Number(s),entries:Number(e),created:a})),tail:r.filter(i=>i.kind==="tail").map(({seq:i,body:n,bytes:s,created:e})=>({seq:Number(i),body:n,bytes:Number(s),created:e}))}}_(I,"snapshot");const $=1024*1024;async function m(o,t,r){const i=[];let n=0;const s=await E();for(const e of o.parts){const a=Math.max(t,n),c=Math.min(r,n+e.bytes);if(a<c){const d=await s.get(e.blob_key,{start:a-n,length:c-a});if(!d)throw new Error(`missing conversation object: ${e.blob_key}`);i.push(d)}n+=e.bytes}for(const e of o.tail){const a=Math.max(t,n),c=Math.min(r,n+e.bytes);a<c&&i.push(Buffer.from(e.body+`
5
+ `).subarray(a-n,c-n)),n+=e.bytes}return Buffer.concat(i)}_(m,"bytesOf");const M=new Map;async function H(o,t,r){const i=await w();if(await i.prepare("SELECT 1 FROM conversation_parts WHERE conversation_id = ? AND seq = 0").get(o)||!W(r))return;let n=q(r);const s=n.lastIndexOf(10);if(s<0)return;n=n.subarray(0,s+1);const e=await i.prepare("SELECT s.binding_id, s.node_id, s.event_offset, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY "+O+" LIMIT 1").get(o);let a=[];if(e?.run_id&&e.event_offset!==null){const p=Number(e.event_offset);if(n.length<p)throw new Error(`conversation shorter than indexed offset: ${o}`);a=C(n.subarray(p).toString("utf8")).filter(u=>u.type!=="session")}const c=e?.run_id?await L(e.run_id,e.node_id,a):!1,d=D(t,o,0);await(await E()).put(d,n),await y(async p=>{if(!await p.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?) ON CONFLICT DO NOTHING RETURNING seq").get(o,d,n.length,Math.max(0,n.toString("utf8").split(`
6
+ `).filter(Boolean).length-1),h())||!e?.run_id||e.event_offset===null)return;const f=e.source_session_id?[]:await T(p,e.run_id,e.node_id,a,JSON.parse(e.input_ids_json),c);await p.prepare("UPDATE sessions SET event_offset = ?, indexed_entry_id = ?, input_ids_json = ? WHERE binding_id = ?").run(n.length,a.at(-1)?.id??null,JSON.stringify(f),e.binding_id)})}_(H,"importOne");async function S(o,t){const r=await t.prepare(`SELECT s.binding_id, s.node_id, s.transcript_path, s.input_ids_json, s.source_session_id, n.run_id FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id = ? ORDER BY ${O} LIMIT 1`).get(o),i=M.get(o);if(!r&&!i)throw new R(o);let n=(await b(t,o))[0];if(!n){const c=i?.path??r?.transcript_path??void 0;c&&await H(o,i?.node??r.node_id,c),n=(await b(t,o))[0]}if(!n||n.seq!==0)throw new R(o);const s=await(await E()).get(n.blob_key,{start:0,length:Math.min(n.bytes,256*1024)});if(!s)throw new Error(`missing conversation object: ${n.blob_key}`);const e=s.indexOf(10);if(e<0)throw new Error(`invalid conversation header: ${o}`);const a=JSON.parse(s.subarray(0,e).toString("utf8"));if(a.type!=="session"||a.id!==o)throw new Error(`invalid conversation header: ${o}`);return{header:a,path:r?.transcript_path??i?.path??"",binding:r}}_(S,"initial");function nt(){const o={async create(t,r,i,n){const e=await(await w()).prepare("SELECT grantee, run_id FROM node_rows WHERE node_id = ?").get(t);if(!e)throw new Error(`missing conversation owner ${t}`);const a=r.id,c=B(J(e.grantee).conversations,t,`${r.timestamp.replace(/[:.]/g,"-")}_${a}.jsonl`),d=k([r,...i]),p=D(t,a,0),u=e.run_id?await L(e.run_id,t,i):!1;return await(await E()).put(p,d),await y(async f=>{if(await f.prepare("SELECT 1 FROM conversation_parts WHERE conversation_id = ?").get(a))throw new Error(`conversation already exists: ${a}`);const l=h(),v=r.parentSession?await f.prepare("SELECT session_id FROM sessions WHERE transcript_path = ? LIMIT 1").get(r.parentSession):void 0;if(await f.prepare("INSERT INTO sessions (binding_id, session_id, node_id, transcript_path, source_session_id, fork_entry_id, created_at, bound_at, unbound_at) VALUES (?, ?, ?, ?, ?, NULL, ?, ?, ?)").run(g(),a,t,c,v?v.session_id:null,l,l,l),await f.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?)").run(a,p,Buffer.byteLength(d),i.length,l),e.run_id&&!v){const U=await T(f,e.run_id,t,i,[],u);await f.prepare("UPDATE sessions SET indexed_entry_id = ?, input_ids_json = ? WHERE session_id = ? AND node_id = ?").run(i.at(-1)?.id??null,JSON.stringify(U),a,t)}}),a},async append(t,r){if(!r.length)return;const i=await N(await w(),t),n=i.run_id?await L(i.run_id,i.node_id,r):!1;await y(async s=>{const e=await N(s,t,!0);if(!(await b(s,t)).length)throw new R(t);const a=[];for(const c of r){const d=JSON.stringify(c);await s.prepare("INSERT INTO conversation_entries (conversation_id, entry_id, body, bytes, execution_id, created) VALUES (?, ?, ?, ?, NULL, ?) ON CONFLICT (conversation_id, entry_id) DO NOTHING RETURNING entry_id").get(t,c.id,d,Buffer.byteLength(d)+1,h())&&a.push(c)}if(e.run_id&&a.length){const c=await T(s,e.run_id,e.node_id,a,JSON.parse(e.input_ids_json??"[]"),n);await s.prepare("UPDATE sessions SET indexed_entry_id = ?, input_ids_json = ? WHERE binding_id = ?").run(a.at(-1).id,JSON.stringify(c),e.binding_id)}})},async readLines(t){const r=await w(),{path:i}=await S(t,r),n=await I(r,t),s=n.parts.reduce((a,c)=>a+c.bytes,0)+n.tail.reduce((a,c)=>a+c.bytes,0);async function*e(){let a="";for(let c=0;c<s;c+=$){const d=a+(await m(n,c,Math.min(s,c+$))).toString("latin1"),p=d.lastIndexOf(`
7
+ `);a=d.slice(p+1);for(const u of d.slice(0,p+1).split(`
8
+ `))u&&(yield Buffer.from(u,"latin1").toString("utf8"))}a&&(yield Buffer.from(a,"latin1").toString("utf8"))}return _(e,"lines"),{path:i,lines:e()}},async read(t,r){const i=await w(),{header:n,path:s}=await S(t,i),e=await I(i,t),a=e.parts.reduce((f,l)=>f+l.bytes,0)+e.tail.reduce((f,l)=>f+l.bytes,0),c=_(f=>C(f).filter(l=>l.type!=="session"),"entriesOf");if(!r||a<=r.head+r.tail)return{header:n,entries:c((await m(e,0,a)).toString("utf8")),path:s};const d=(await m(e,0,Math.max(0,r.head))).toString("utf8").split(`
9
+ `);d.pop();const p=Math.max(0,a-r.tail),u=(await m(e,p>0?p-1:0,a)).toString("utf8").split(`
10
+ `);return p>0&&u.shift(),{header:n,entries:c(d.join(`
11
11
  `)),tail:c(u.join(`
12
- `)),path:a}},async header(t){const n=await w(),{header:i,path:s}=await S(t,n),a=await I(n,t);return{header:i,path:s,mtime:Date.parse(a.tail.at(-1)?.created??a.parts.at(-1).created),size:a.parts.reduce((e,r)=>e+r.bytes,0)+a.tail.reduce((e,r)=>e+r.bytes,0)}},async list(t){const i=await(await w()).prepare(`SELECT DISTINCT ON (s.session_id) s.session_id, s.node_id FROM sessions s JOIN conversation_parts p ON p.conversation_id = s.session_id WHERE s.session_id IS NOT NULL ORDER BY s.session_id, ${O}`).all(),s=[];for(const a of i){if(t&&a.node_id!==t)continue;const e=await o.header(a.session_id);s.push({conversation_id:a.session_id,node_id:a.node_id,...e})}return s.sort((a,e)=>e.mtime-a.mtime)},async replace(t,n,i){if(n.id!==t)throw new Error("replacement header id differs from conversation id");const s=await w(),a=await N(s,t);if(a.run_id)throw new Error(`run conversation ${t} is append-only; replace refused`);const e=`conversations/${a.node_id}/${t}/0-${g()}.jsonl`,r=k([n,...i]);await(await l()).put(e,r);const c=await y(async d=>{if((await N(d,t,!0)).run_id)throw new Error(`run conversation ${t} is append-only; replace refused`);const u=await b(d,t);return await d.prepare("DELETE FROM conversation_parts WHERE conversation_id = ?").run(t),await d.prepare("DELETE FROM conversation_entries WHERE conversation_id = ?").run(t),await d.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?)").run(t,e,Buffer.byteLength(r),i.length,h()),u});for(const d of c)await(await l()).delete(d.blob_key)},async fork(t,n,i,s){const a=await o.read(t);let e=a.entries;if(i!==void 0){const r=j.inMemory(a.header.cwd,void 0,[a.header,...e]);r.createBranchedSession(i),e=r.getEntries()}return await o.create(n??(await S(t,await w())).binding?.node_id??M.get(t).node,{...a.header,id:g(),timestamp:h(),cwd:s??a.header.cwd,parentSession:a.path},e)},async delete(t,n){const i=await w(),s=await b(i,t);await y(async a=>{await a.prepare("DELETE FROM conversation_entries WHERE conversation_id = ?").run(t),await a.prepare("DELETE FROM conversation_parts WHERE conversation_id = ?").run(t),await a.prepare("DELETE FROM sessions WHERE session_id = ?").run(t)});for(const a of s)await(await l()).delete(a.blob_key);n&&A(n,{force:!0})},async commit(t){return await y(async n=>{const i=await N(n,t,!0),s=await Y(n,t),a=await b(n,t);if(!s.length)return a.at(-1)?.seq??0;const e=(a.at(-1)?.seq??0)+1,r=D(i.node_id,t,e),c=s.map(d=>d.body+`
13
- `).join("");return await(await l()).put(r,c),process.env.CRTR_FAULT_CONVERSATION==="commit_exit_after_put"&&process.exit(1),await n.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, ?, ?, ?, ?, ?)").run(t,e,r,Buffer.byteLength(c),s.length,h()),await n.prepare("DELETE FROM conversation_entries WHERE conversation_id = ? AND seq <= ?").run(t,s.at(-1).seq),e})},async importLegacy(t){const i=await(await w()).prepare(`SELECT DISTINCT ON (s.session_id) s.session_id, s.node_id, s.transcript_path FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id IS NOT NULL AND s.transcript_path IS NOT NULL ${t?"AND n.run_id = ?":""} ORDER BY s.session_id, ${O}`).all(...t?[t]:[]);for(const s of i)await U(s.session_id,s.node_id,s.transcript_path)},recover(t){for(const n of t)n.transcript_path&&M.set(n.session_id,{node:n.node_id,path:n.transcript_path})}};return o}f(et,"createRowStore");async function nt(o,t,n){const i=await w(),s=await N(i,o),a=(await b(i,o))[0];if(!a||a.seq!==0)return!1;const e=await(await l()).get(a.blob_key);if(!e)throw new Error(`missing conversation object: ${a.blob_key}`);const r=e.indexOf(10);if(r<0)throw new Error(`invalid conversation header: ${o}`);const c=JSON.parse(e.subarray(0,r).toString("utf8"));if(c.type!=="session"||c.id!==o)throw new Error(`invalid conversation header: ${o}`);if(c.cwd!==t)return!1;const d=Buffer.concat([Buffer.from(JSON.stringify({...c,cwd:n})),e.subarray(r)]),p=`conversations/${s.node_id}/${o}/0-${g()}.jsonl`;await(await l()).put(p,d);const u=await y(async _=>await _.prepare("UPDATE conversation_parts SET blob_key = ?, bytes = ? WHERE conversation_id = ? AND seq = 0 AND blob_key = ? RETURNING seq").get(p,d.length,o,a.blob_key)!==void 0);if(await(await l()).delete(u?a.blob_key:p).catch(()=>{}),!u)throw new Error(`conversation header changed during relocation: ${o}`);return!0}f(nt,"relocateConversationHeader");export{et as createRowStore,nt as relocateConversationHeader};
12
+ `)),path:s}},async header(t){const r=await w(),{header:i,path:n}=await S(t,r),s=await I(r,t);return{header:i,path:n,mtime:Date.parse(s.tail.at(-1)?.created??s.parts.at(-1).created),size:s.parts.reduce((e,a)=>e+a.bytes,0)+s.tail.reduce((e,a)=>e+a.bytes,0)}},async list(t){const i=await(await w()).prepare(`SELECT DISTINCT ON (s.session_id) s.session_id, s.node_id FROM sessions s JOIN conversation_parts p ON p.conversation_id = s.session_id WHERE s.session_id IS NOT NULL ORDER BY s.session_id, ${O}`).all(),n=[];for(const s of i){if(t&&s.node_id!==t)continue;const e=await o.header(s.session_id);n.push({conversation_id:s.session_id,node_id:s.node_id,...e})}return n.sort((s,e)=>e.mtime-s.mtime)},async replace(t,r,i){if(r.id!==t)throw new Error("replacement header id differs from conversation id");const n=await w(),s=await N(n,t);if(s.run_id)throw new Error(`run conversation ${t} is append-only; replace refused`);const e=`conversations/${s.node_id}/${t}/0-${g()}.jsonl`,a=k([r,...i]);await(await E()).put(e,a);const c=await y(async d=>{if((await N(d,t,!0)).run_id)throw new Error(`run conversation ${t} is append-only; replace refused`);const u=await b(d,t);return await d.prepare("DELETE FROM conversation_parts WHERE conversation_id = ?").run(t),await d.prepare("DELETE FROM conversation_entries WHERE conversation_id = ?").run(t),await d.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, 0, ?, ?, ?, ?)").run(t,e,Buffer.byteLength(a),i.length,h()),u});for(const d of c)await(await E()).delete(d.blob_key)},async fork(t,r,i,n){const s=await o.read(t);let e=s.entries;if(i!==void 0){const a=j.inMemory(s.header.cwd,void 0,[s.header,...e]);a.createBranchedSession(i),e=a.getEntries()}return await o.create(r??(await S(t,await w())).binding?.node_id??M.get(t).node,{...s.header,id:g(),timestamp:h(),cwd:n??s.header.cwd,parentSession:s.path},e)},async delete(t,r){const i=await w(),n=await b(i,t);await y(async s=>{await s.prepare("DELETE FROM conversation_entries WHERE conversation_id = ?").run(t),await s.prepare("DELETE FROM conversation_parts WHERE conversation_id = ?").run(t),await s.prepare("DELETE FROM sessions WHERE session_id = ?").run(t)});for(const s of n)await(await E()).delete(s.blob_key);r&&A(r,{force:!0})},async commit(t){return await y(async r=>{const i=await N(r,t,!0),n=await x(r,t),s=await b(r,t);if(!n.length)return s.at(-1)?.seq??0;const e=(s.at(-1)?.seq??0)+1,a=D(i.node_id,t,e),c=n.map(d=>d.body+`
13
+ `).join("");return await(await E()).put(a,c),process.env.CRTR_FAULT_CONVERSATION==="commit_exit_after_put"&&process.exit(1),await r.prepare("INSERT INTO conversation_parts (conversation_id, seq, blob_key, bytes, entries, created) VALUES (?, ?, ?, ?, ?, ?)").run(t,e,a,Buffer.byteLength(c),n.length,h()),await r.prepare("DELETE FROM conversation_entries WHERE conversation_id = ? AND seq <= ?").run(t,n.at(-1).seq),e})},async importLegacy(t){const i=await(await w()).prepare(`SELECT DISTINCT ON (s.session_id) s.session_id, s.node_id, s.transcript_path FROM sessions s JOIN nodes n ON n.node_id = s.node_id WHERE s.session_id IS NOT NULL AND s.transcript_path IS NOT NULL ${t?"AND n.run_id = ?":""} ORDER BY s.session_id, ${O}`).all(...t?[t]:[]);for(const n of i)await H(n.session_id,n.node_id,n.transcript_path)},recover(t){for(const r of t)r.transcript_path&&M.set(r.session_id,{node:r.node_id,path:r.transcript_path})}};return o}_(nt,"createRowStore");function Y(o,t,r){const i=o.indexOf(10);if(i<0)throw new Error(`invalid conversation header: ${t}`);const n=JSON.parse(o.subarray(0,i).toString("utf8"));if(n.type!=="session"||n.id!==t)throw new Error(`invalid conversation header: ${t}`);const s=r(n.cwd);return s===n.cwd?null:Buffer.concat([Buffer.from(JSON.stringify({...n,cwd:s})),o.subarray(i)])}_(Y,"withHeaderCwd");async function st(o,t,r){const i=await w(),n=await N(i,o),s=(await b(i,o))[0];if(!s||s.seq!==0)return!1;const e=await(await E()).get(s.blob_key);if(!e)throw new Error(`missing conversation object: ${s.blob_key}`);const a=Y(e,o,p=>p===t?r:p);if(a===null)return!1;const c=`conversations/${n.node_id}/${o}/0-${g()}.jsonl`;await(await E()).put(c,a);const d=await y(async p=>await p.prepare("UPDATE conversation_parts SET blob_key = ?, bytes = ? WHERE conversation_id = ? AND seq = 0 AND blob_key = ? RETURNING seq").get(c,a.length,o,s.blob_key)!==void 0);if(await(await E()).delete(d?s.blob_key:c).catch(()=>{}),!d)throw new Error(`conversation header changed during relocation: ${o}`);return!0}_(st,"relocateConversationHeader");export{nt as createRowStore,st as relocateConversationHeader,Y as withHeaderCwd};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var d=(o,t)=>f(o,"name",{value:t,configurable:!0});import{bundleKeys as l}from"../bundle/layout.js";import{q as c}from"./catalog.js";import{ImportLaneError as s}from"./stage.js";const p="/var/lib/crtr",u="/work/imported";function b(o){const t=o.map(e=>{if(!e.from.startsWith("/")||e.from.split("/").includes(".."))throw new s("stage","bundle_invalid",`path prefix ${e.from} of node ${e.node} is not an absolute path`);const n=e.app.replace(/^app:/,"");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(n)||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e.node))throw new s("stage","bundle_invalid",`path prefix names app ${e.app} and node ${e.node}`);const r=`${p}/apps/${n}/nodes/${e.node}`,i=e.role==="context"?`${r}/context`:e.role==="worktree"?`${r}/worktree`:`${u}/${e.node}`;return{from:e.from,to:i}});return t.filter((e,n)=>t.findIndex(r=>r.from===e.from)===n)}d(b,"sandboxPathMap");async function _(o,t,e,n){if(n.kind!=="hosted")return 0;const r=[...new Set((n.pathPrefixes??[]).map(a=>a.node))];let i=0;for(const a of r){if(await o.prepareUncached(`SELECT 1 AS found FROM ${c(t)}.nodes WHERE node_id = ? AND status IN ('active', 'idle')`).get(a)===void 0)throw new s("copy","bundle_invalid",`an archive was uploaded for node ${a}, which is not a running node of the bundle`);i+=Number((await o.prepare("INSERT INTO import_node_files (node, blob_key) VALUES (?, ?) ON CONFLICT DO NOTHING").run(a,l.nodeFiles(e,a))).changes)}return i}d(_,"writeNodeFiles");export{b as sandboxPathMap,_ as writeNodeFiles};
1
+ var s=Object.defineProperty;var d=(n,o)=>s(n,"name",{value:o,configurable:!0});import{basename as m,dirname as l}from"node:path";import{nodeAgentDir as c}from"../../canvas/paths.js";import{bundleKeys as u}from"../bundle/layout.js";import{q as p}from"./catalog.js";import{ImportLaneError as a}from"./stage.js";const h="/work/imported";function A(n){const o=n.map(e=>{if(!e.from.startsWith("/")||e.from.split("/").includes(".."))throw new a("stage","bundle_invalid",`path prefix ${e.from} of node ${e.node} is not an absolute path`);const r=e.app.replace(/^app:/,"");if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r)||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e.node))throw new a("stage","bundle_invalid",`path prefix names app ${e.app} and node ${e.node}`);const t=c(e.node,e.app);if(e.role==="context"){if(m(e.from)!=="context")throw new a("stage","bundle_invalid",`the context prefix ${e.from} of node ${e.node} is not a context directory`);return{from:l(e.from),to:t}}return{from:e.from,to:e.role==="worktree"?`${t}/worktree`:`${h}/${e.node}`}});return o.filter((e,r)=>o.findIndex(t=>t.from===e.from)===r)}d(A,"sandboxPathMap");async function E(n,o,e,r){if(r.kind!=="hosted")return 0;const t=[...new Set((r.pathPrefixes??[]).map(i=>i.node))];let f=0;for(const i of t){if(await n.prepareUncached(`SELECT 1 AS found FROM ${p(o)}.nodes WHERE node_id = ? AND status IN ('active', 'idle')`).get(i)===void 0)throw new a("copy","bundle_invalid",`an archive was uploaded for node ${i}, which is not a running node of the bundle`);f+=Number((await n.prepare("INSERT INTO import_node_files (node, blob_key) VALUES (?, ?) ON CONFLICT DO NOTHING").run(i,u.nodeFiles(e,i))).changes)}return f}d(E,"writeNodeFiles");export{A as sandboxPathMap,E as writeNodeFiles};
@@ -1,5 +1,6 @@
1
1
  import type { CanvasDb } from '../../canvas/db.js';
2
2
  import { type PathMap, type SourceJson } from '../bundle/layout.js';
3
+ import type { BlobStore } from '../../blobs/index.js';
3
4
  import { type Catalog } from './catalog.js';
4
5
  /** A revision of a document the target already holds, to be added through repo sync's own arrival path. */
5
6
  export interface ArrivingRevision {
@@ -12,6 +13,10 @@ export interface ArrivingRevision {
12
13
  }
13
14
  /** Rewrite 4: for rows of running nodes of a hosted source, path columns go through the run's map. Ended nodes' rows stay as historical text. */
14
15
  export declare function rewritePaths(db: CanvasDb, schema: string, map: PathMap): Promise<number>;
16
+ /** Rewrite 4, conversations: pi refuses to open a session whose header `cwd` does not exist, so the header of part 0 of each conversation of a running node goes through the
17
+ * run's map like `nodes.cwd`. The run's uploaded copy of the blob is rewritten (the move step copies it to its key) and the staged row's `bytes` follows, so verify and the
18
+ * pre-check compare the rewritten rows. A bundle loaded again, or a run retried after an earlier attempt rewrote the upload, ends with the same bytes. Runs after `rewritePaths`, before the pre-check. Returns conversations rewritten. */
19
+ export declare function rewriteConversationHeaders(db: CanvasDb, schema: string, map: PathMap, blobs: BlobStore, runId: string): Promise<number>;
15
20
  /** Rewrite 4b: a human request's files live in the blob store under `requests/<id>/` (the exporter uploaded the request dir there). `request_dir` becomes that
16
21
  * prefix; a `file` or `presentation_dir` inside the old dir keeps its relative path, one outside it was uploaded to `source/<basename>`. A path that is not
17
22
  * absolute is already a blob path and stays. */
@@ -1,10 +1,11 @@
1
- var y=Object.defineProperty;var d=(n,o)=>y(n,"name",{value:o,configurable:!0});import{createProfileBlaxelEnvironment as v}from"../../environments.js";import{KEY_MAPPED_TABLES as U,mapPath as S}from"../bundle/layout.js";import{ImportLaneError as O}from"./stage.js";import{q as l}from"./catalog.js";const $=d((n,o)=>`${l(n)}.${l(o)}`,"sq");async function g(n,o,c){if(c.length===0)return 0;const e=d(s=>$(o,s),"S"),t=`(SELECT node_id FROM ${e("nodes")} WHERE status IN ('active', 'idle'))`;let a=0;const E=d(async(s,r,i,u=!1)=>{const _=await n.prepareUncached(`SELECT ${l(r)}::text AS value FROM ${e(s)} WHERE ${i} AND ${l(r)} IS NOT NULL`).all();for(const{value:R}of _){const h=u?A(R,c):S(c,R);h!==R&&(await n.prepareUncached(`UPDATE ${e(s)} SET ${l(r)} = ? WHERE ${l(r)}::text = ? AND ${i}`).run(h,R),a+=1)}},"apply");return await E("nodes","cwd",`node_id IN ${t}`),await E("worktrees","path",`node_id IN ${t}`),await E("worktrees","repo_root",`node_id IN ${t}`),await E("crons","cwd",`anchor_node IN ${t}`),await E("provider_approvals","prepared_files","TRUE",!0),await E("upload_uses","path",`run_id IN ${t}`),a}d(g,"rewritePaths");async function j(n,o){const c=$(o,"human_requests"),e=d(a=>`CASE WHEN ${a} IS NULL OR ${a} NOT LIKE '/%' THEN ${a}
1
+ var y=Object.defineProperty;var d=(n,s)=>y(n,"name",{value:s,configurable:!0});import{createProfileBlaxelEnvironment as I}from"../../environments.js";import{KEY_MAPPED_TABLES as H,mapPath as S}from"../bundle/layout.js";import{ImportLaneError as N}from"./stage.js";import{withHeaderCwd as U}from"../../conversation-store/row-store.js";import{runBlobKey as A}from"../bundle/blob-keys.js";import{q as u}from"./catalog.js";const $=d((n,s)=>`${u(n)}.${u(s)}`,"sq");async function j(n,s,c){if(c.length===0)return 0;const e=d(o=>$(s,o),"S"),r=`(SELECT node_id FROM ${e("nodes")} WHERE status IN ('active', 'idle'))`;let a=0;const E=d(async(o,t,i,l=!1)=>{const m=await n.prepareUncached(`SELECT ${u(t)}::text AS value FROM ${e(o)} WHERE ${i} AND ${u(t)} IS NOT NULL`).all();for(const{value:f}of m){const h=l?W(f,c):S(c,f);h!==f&&(await n.prepareUncached(`UPDATE ${e(o)} SET ${u(t)} = ? WHERE ${u(t)}::text = ? AND ${i}`).run(h,f),a+=1)}},"apply");return await E("nodes","cwd",`node_id IN ${r}`),await E("worktrees","path",`node_id IN ${r}`),await E("worktrees","repo_root",`node_id IN ${r}`),await E("crons","cwd",`anchor_node IN ${r}`),await E("provider_approvals","prepared_files","TRUE",!0),await E("upload_uses","path",`run_id IN ${r}`),a}d(j,"rewritePaths");async function k(n,s,c,e,r){if(c.length===0)return 0;const a=d(t=>$(s,t),"S"),E=await n.prepareUncached(`SELECT conversation_id, blob_key FROM ${a("conversation_parts")} WHERE seq = 0
2
+ AND split_part(blob_key, '/', 2) IN (SELECT node_id FROM ${a("nodes")} WHERE status IN ('active', 'idle'))`).all();let o=0;for(const{conversation_id:t,blob_key:i}of E){const l=A(r,i),m=await e.get(l);if(m===null)throw new N("rewrite-paths","bundle_invalid",`${l} is missing: the header of conversation ${t} cannot be rewritten`);const f=U(m,t,h=>S(c,h));f!==null&&(await e.put(l,f),o+=1),await n.prepareUncached(`UPDATE ${a("conversation_parts")} SET bytes = ? WHERE conversation_id = ? AND seq = 0`).run((f??m).length,t)}return o}d(k,"rewriteConversationHeaders");async function P(n,s){const c=$(s,"human_requests"),e=d(a=>`CASE WHEN ${a} IS NULL OR ${a} NOT LIKE '/%' THEN ${a}
2
3
  WHEN rtrim(${a}, '/') = rtrim(request_dir, '/') THEN 'requests/' || request_id
3
4
  WHEN ${a} LIKE rtrim(request_dir, '/') || '/%' THEN 'requests/' || request_id || '/' || substr(${a}, length(rtrim(request_dir, '/')) + 2)
4
- ELSE 'requests/' || request_id || '/source/' || regexp_replace(${a}, '^.*/', '') END`,"moved"),t=await n.prepareUncached(`UPDATE ${c} SET file = ${e("file")}, presentation_dir = ${e("presentation_dir")},
5
- request_dir = CASE WHEN request_dir LIKE '/%' THEN 'requests/' || request_id ELSE request_dir END`).run();return Number(t.changes)}d(j,"rewriteRequestPaths");function A(n,o){const c=d(e=>typeof e=="string"?S(o,e):Array.isArray(e)?e.map(c):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,a])=>[t,c(a)])):e,"walk");try{return JSON.stringify(c(JSON.parse(n)))}catch{return S(o,n)}}d(A,"rewriteJsonPaths");async function q(n,o,c,e,t){const a=d(r=>$(o,r),"S"),E=await n.prepareUncached(`SELECT id, name FROM ${a("profiles")} ORDER BY id`).all();let s=0;for(const r of E)await n.prepareUncached(`SELECT 1 AS found FROM ${$(c,"profiles")} WHERE person = ? AND name = ? AND id <> ?`).get(t,r.name,r.id)!==void 0&&(await n.prepareUncached(`UPDATE ${a("profiles")} SET name = ? WHERE id = ?`).run(`${r.name}-${e}`,r.id),s+=1);return s}d(q,"renameClashingProfiles");async function x(n,o,c,e,t){const a=d(r=>$(o,r),"S");let E=0;const s=await n.prepareUncached(`SELECT id, grantee FROM ${a("profiles")} WHERE environment_id IS NULL ORDER BY id`).all();for(const r of s){let i=e.kind==="machine"?e.environmentObject??null:null;if(e.kind==="hosted"&&(i=(await n.prepareUncached(`SELECT environment_id FROM ${$(c,"profiles")} WHERE id = ?`).get(r.id))?.environment_id??await v(n,{profileId:r.id,grantee:r.grantee??"app:terminal",person:t})),i===null)throw new O("fill","bundle_invalid",`profile ${r.id} has no environment and the source names none`);await n.prepareUncached(`UPDATE ${a("profiles")} SET environment_id = ? WHERE id = ?`).run(i,r.id),E+=1}return E}d(x,"fillEnvironments");async function k(n,o,c,e){const t=d(s=>$(o,s),"S"),a={},E=d(async(s,r,...i)=>{const u=Number((await n.prepareUncached(r).run(...i)).changes);u>0&&(a[s]=(a[s]??0)+u)},"del");await E("limits",`DELETE FROM ${t("limits")} WHERE source <> 'person'`),e.kind==="hosted"&&(await n.prepareUncached(`UPDATE ${t("profiles")} SET environment_id = NULL WHERE environment_id IN (SELECT object FROM ${t("environments")})`).run(),await n.prepareUncached(`UPDATE ${t("objects")} SET home_machine = 'import-hosted-source' WHERE id IN (SELECT object FROM ${t("environments")})`).run());for(const[s,r]of Object.entries(U))await E(s,`DELETE FROM ${t(s)} WHERE ${l(r)}::text IN (SELECT source_key FROM import_key_map WHERE source_install_id = ? AND table_name = ?)`,e.installId,s);for(const s of c.tables.values())s.columns.includes("claimed_by")&&s.columns.includes("lease_expires_at")&&await n.prepareUncached(`UPDATE ${t(s.name)} SET claimed_by = NULL, lease_expires_at = NULL WHERE claimed_by IS NOT NULL OR lease_expires_at IS NOT NULL`).run();return a}d(k,"pruneStaged");async function b(n,o,c){const e=d(E=>$(o,E),"S"),t=`(SELECT d.object FROM ${e("documents")} d WHERE EXISTS (SELECT 1 FROM ${$(c,"documents")} t WHERE t.object = d.object))`;await n.exec(`CREATE TABLE ${e("_arr_revisions")} AS SELECT r.* FROM ${e("revisions")} r WHERE r.document IN ${t};
6
- CREATE TABLE ${e("_arr_parents")} AS SELECT p.* FROM ${e("revision_parents")} p WHERE p.child IN (SELECT rev_id FROM ${e("revisions")} WHERE document IN ${t})`);const a=await n.prepareUncached(`SELECT r.document, r.rev_id, r.body_hash, r.rationale, r.created_at,
5
+ ELSE 'requests/' || request_id || '/source/' || regexp_replace(${a}, '^.*/', '') END`,"moved"),r=await n.prepareUncached(`UPDATE ${c} SET file = ${e("file")}, presentation_dir = ${e("presentation_dir")},
6
+ request_dir = CASE WHEN request_dir LIKE '/%' THEN 'requests/' || request_id ELSE request_dir END`).run();return Number(r.changes)}d(P,"rewriteRequestPaths");function W(n,s){const c=d(e=>typeof e=="string"?S(s,e):Array.isArray(e)?e.map(c):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([r,a])=>[r,c(a)])):e,"walk");try{return JSON.stringify(c(JSON.parse(n)))}catch{return S(s,n)}}d(W,"rewriteJsonPaths");async function B(n,s,c,e,r){const a=d(t=>$(s,t),"S"),E=await n.prepareUncached(`SELECT id, name FROM ${a("profiles")} ORDER BY id`).all();let o=0;for(const t of E)await n.prepareUncached(`SELECT 1 AS found FROM ${$(c,"profiles")} WHERE person = ? AND name = ? AND id <> ?`).get(r,t.name,t.id)!==void 0&&(await n.prepareUncached(`UPDATE ${a("profiles")} SET name = ? WHERE id = ?`).run(`${t.name}-${e}`,t.id),o+=1);return o}d(B,"renameClashingProfiles");async function K(n,s,c,e,r){const a=d(t=>$(s,t),"S");let E=0;const o=await n.prepareUncached(`SELECT id, grantee FROM ${a("profiles")} WHERE environment_id IS NULL ORDER BY id`).all();for(const t of o){let i=e.kind==="machine"?e.environmentObject??null:null;if(e.kind==="hosted"&&(i=(await n.prepareUncached(`SELECT environment_id FROM ${$(c,"profiles")} WHERE id = ?`).get(t.id))?.environment_id??await I(n,{profileId:t.id,grantee:t.grantee??"app:terminal",person:r})),i===null)throw new N("fill","bundle_invalid",`profile ${t.id} has no environment and the source names none`);await n.prepareUncached(`UPDATE ${a("profiles")} SET environment_id = ? WHERE id = ?`).run(i,t.id),E+=1}return E}d(K,"fillEnvironments");async function J(n,s,c,e){const r=d(o=>$(s,o),"S"),a={},E=d(async(o,t,...i)=>{const l=Number((await n.prepareUncached(t).run(...i)).changes);l>0&&(a[o]=(a[o]??0)+l)},"del");await E("limits",`DELETE FROM ${r("limits")} WHERE source <> 'person'`),e.kind==="hosted"&&(await n.prepareUncached(`UPDATE ${r("profiles")} SET environment_id = NULL WHERE environment_id IN (SELECT object FROM ${r("environments")})`).run(),await n.prepareUncached(`UPDATE ${r("objects")} SET home_machine = 'import-hosted-source' WHERE id IN (SELECT object FROM ${r("environments")})`).run());for(const[o,t]of Object.entries(H))await E(o,`DELETE FROM ${r(o)} WHERE ${u(t)}::text IN (SELECT source_key FROM import_key_map WHERE source_install_id = ? AND table_name = ?)`,e.installId,o);for(const o of c.tables.values())o.columns.includes("claimed_by")&&o.columns.includes("lease_expires_at")&&await n.prepareUncached(`UPDATE ${r(o.name)} SET claimed_by = NULL, lease_expires_at = NULL WHERE claimed_by IS NOT NULL OR lease_expires_at IS NOT NULL`).run();return a}d(J,"pruneStaged");async function Y(n,s,c){const e=d(E=>$(s,E),"S"),r=`(SELECT d.object FROM ${e("documents")} d WHERE EXISTS (SELECT 1 FROM ${$(c,"documents")} t WHERE t.object = d.object))`;await n.exec(`CREATE TABLE ${e("_arr_revisions")} AS SELECT r.* FROM ${e("revisions")} r WHERE r.document IN ${r};
7
+ CREATE TABLE ${e("_arr_parents")} AS SELECT p.* FROM ${e("revision_parents")} p WHERE p.child IN (SELECT rev_id FROM ${e("revisions")} WHERE document IN ${r})`);const a=await n.prepareUncached(`SELECT r.document, r.rev_id, r.body_hash, r.rationale, r.created_at,
7
8
  COALESCE((SELECT array_agg(p.parent) FROM ${e("revision_parents")} p WHERE p.child = r.rev_id), ARRAY[]::text[]) AS parents
8
- FROM ${e("revisions")} r WHERE r.document IN ${t} ORDER BY r.document, r.number`).all();return await n.prepareUncached(`DELETE FROM ${e("revision_parents")} WHERE child IN (SELECT rev_id FROM ${e("revisions")} WHERE document IN ${t})`).run(),await n.prepareUncached(`DELETE FROM ${e("revisions")} WHERE document IN ${t}`).run(),await n.prepareUncached(`DELETE FROM ${e("objects")} WHERE id IN ${t}`).run(),await n.prepareUncached(`DELETE FROM ${e("documents")} WHERE object IN ${t}`).run(),a.map(E=>({...E}))}d(b,"takeRepoSyncedDocuments");const H={edges:["created_at"],relations:["created_at"]};async function P(n,o,c,e,t,a,E){const s=d(i=>[...E.get(i)??[],...i==="profiles"?["environment_id"]:[],...H[i]??[],"claimed_by","lease_expires_at"],"ignored"),r=[];for(const i of t){const u=e.tables.get(i);if(u===void 0||a.has(i)||u.primaryKey.length===0)continue;const _=u.primaryKey,R=_.some(p=>u.identity.includes(p)),h=_.map(p=>`s.${l(p)} = t.${l(p)}`).join(" AND "),w=R?"TRUE":_.map(p=>`s.${l(p)} IS DISTINCT FROM t.${l(p)}`).join(" OR "),I=new Set([...u.identity,...E.get(i)??[]]);for(const p of e.uniqueKeys.filter(f=>f.table===i&&!f.columns.every(m=>I.has(m)))){const f=p.predicate===null?"":` WHERE ${p.predicate}`,m=p.columns.map(T=>`s.${l(T)} = t.${l(T)}`).join(" AND "),L=await n.prepareUncached(`SELECT ${p.columns.map(T=>`s.${l(T)}::text`).join(" || ',' || ")} AS value
9
- FROM (SELECT * FROM ${$(o,i)}${f}) s JOIN (SELECT * FROM ${$(c,i)}${f}) t ON ${m} AND (${w}) LIMIT 10`).all();L.length>0&&r.push({table:i,key:p.name,values:L.map(T=>T.value)})}const N=u.columns.filter(p=>!u.identity.includes(p)&&!s(i).includes(p));if(N.length>0&&!R){const p=N.map(m=>`s.${l(m)} IS DISTINCT FROM t.${l(m)}`).join(" OR "),f=await n.prepareUncached(`SELECT ${_.map(m=>`s.${l(m)}::text`).join(" || ',' || ")} AS value
10
- FROM ${$(o,i)} s JOIN ${$(c,i)} t ON ${h} WHERE ${p} LIMIT 10`).all();f.length>0&&r.push({table:i,key:"primary key payload",values:f.map(m=>m.value)})}}if(r.length>0){const i=r[0];throw new O("pre-check","unique_conflict",`${i.table} ${i.key} collides with the target: ${i.values.join(", ")}`,{collisions:r})}}d(P,"precheck");export{x as fillEnvironments,P as precheck,k as pruneStaged,q as renameClashingProfiles,g as rewritePaths,j as rewriteRequestPaths,b as takeRepoSyncedDocuments};
9
+ FROM ${e("revisions")} r WHERE r.document IN ${r} ORDER BY r.document, r.number`).all();return await n.prepareUncached(`DELETE FROM ${e("revision_parents")} WHERE child IN (SELECT rev_id FROM ${e("revisions")} WHERE document IN ${r})`).run(),await n.prepareUncached(`DELETE FROM ${e("revisions")} WHERE document IN ${r}`).run(),await n.prepareUncached(`DELETE FROM ${e("objects")} WHERE id IN ${r}`).run(),await n.prepareUncached(`DELETE FROM ${e("documents")} WHERE object IN ${r}`).run(),a.map(E=>({...E}))}d(Y,"takeRepoSyncedDocuments");const C={edges:["created_at"],relations:["created_at"]};async function X(n,s,c,e,r,a,E){const o=d(i=>[...E.get(i)??[],...i==="profiles"?["environment_id"]:[],...C[i]??[],"claimed_by","lease_expires_at"],"ignored"),t=[];for(const i of r){const l=e.tables.get(i);if(l===void 0||a.has(i)||l.primaryKey.length===0)continue;const m=l.primaryKey,f=m.some(p=>l.identity.includes(p)),h=m.map(p=>`s.${u(p)} = t.${u(p)}`).join(" AND "),O=f?"TRUE":m.map(p=>`s.${u(p)} IS DISTINCT FROM t.${u(p)}`).join(" OR "),v=new Set([...l.identity,...E.get(i)??[]]);for(const p of e.uniqueKeys.filter(R=>R.table===i&&!R.columns.every(_=>v.has(_)))){const R=p.predicate===null?"":` WHERE ${p.predicate}`,_=p.columns.map(T=>`s.${u(T)} = t.${u(T)}`).join(" AND "),L=await n.prepareUncached(`SELECT ${p.columns.map(T=>`s.${u(T)}::text`).join(" || ',' || ")} AS value
10
+ FROM (SELECT * FROM ${$(s,i)}${R}) s JOIN (SELECT * FROM ${$(c,i)}${R}) t ON ${_} AND (${O}) LIMIT 10`).all();L.length>0&&t.push({table:i,key:p.name,values:L.map(T=>T.value)})}const w=l.columns.filter(p=>!l.identity.includes(p)&&!o(i).includes(p));if(w.length>0&&!f){const p=w.map(_=>`s.${u(_)} IS DISTINCT FROM t.${u(_)}`).join(" OR "),R=await n.prepareUncached(`SELECT ${m.map(_=>`s.${u(_)}::text`).join(" || ',' || ")} AS value
11
+ FROM ${$(s,i)} s JOIN ${$(c,i)} t ON ${h} WHERE ${p} LIMIT 10`).all();R.length>0&&t.push({table:i,key:"primary key payload",values:R.map(_=>_.value)})}}if(t.length>0){const i=t[0];throw new N("pre-check","unique_conflict",`${i.table} ${i.key} collides with the target: ${i.values.join(", ")}`,{collisions:t})}}d(X,"precheck");export{K as fillEnvironments,X as precheck,J as pruneStaged,B as renameClashingProfiles,k as rewriteConversationHeaders,j as rewritePaths,P as rewriteRequestPaths,Y as takeRepoSyncedDocuments};
@@ -1,3 +1,3 @@
1
- var Q=Object.defineProperty;var u=(e,i)=>Q(e,"name",{value:i,configurable:!0});import{zstdCompressSync as V}from"node:zlib";import{blobStore as Y}from"../../blobs/index.js";import{openDb as E,withCanvasWrite as N}from"../../canvas/db.js";import{insertImportedRevisions as X}from"../../graph/documents.js";import{getById as Z}from"../../graph/objects.js";import{bundleKeys as S,decodeRows as x,rowKeys as ee,SEQ_TABLES as te}from"../bundle/layout.js";import{readCatalog as ae}from"./catalog.js";import{copyRows as ne,decodeKeys as C,encodeKeys as B}from"./copy.js";import{pruneStaged as ie,precheck as se,renameClashingProfiles as re,rewritePaths as oe,rewriteRequestPaths as de,takeRepoSyncedDocuments as pe}from"./prepare.js";import{boundSub as ce,checkSourcePerson as ue,checkStagedBlobKeys as fe,checkStagedPersons as le,checkStagedReferences as me,checkStagedRequestKeys as _e}from"./bind.js";import{deleteBlobs as we,deleteRunBlobs as ge,moveRunBlobs as be}from"./blobs.js";import{dropStubRows as he,findFleetGrant as ye,grantMissing as Ee,mapProfileIds as Se,rewriteIds as ve,rewritePerson as Re}from"./rewrite.js";import{dropStaging as W,ImportLaneError as w,stage as Oe,stagingSchema as Te,targetSchema as Pe}from"./stage.js";import{verifyRun as ke}from"./verify.js";import{sandboxPathMap as je,writeNodeFiles as Ie}from"./path-map.js";import{allStoreKeys as De,readPluginsStore as Ae,recordImportedActivations as Me,writeStores as Ne}from"./stores.js";import{publishImportedPlugins as Ce}from"./publish-plugins.js";import{COPIED_TABLES as Be}from"../bundle/layout.js";import{ClaimLostError as We}from"../../../daemon/reconcilers/row-claim.js";const L=10*6e4,v=u(()=>new Date().toISOString(),"now"),R=u(async(e,i)=>{await(await E()).prepare("UPDATE import_runs SET step = ? WHERE run_id = ?").run(i,e)},"setStep");async function Le(e,i){const n=await e.get(S.source(i));if(n===null)throw new w("stage","bundle_invalid","source.json is missing");return JSON.parse(n.toString("utf8"))}u(Le,"readSource");async function He(e,i,n,r,s,d){const t=await e.get(S.rows(n.run_id,"grants")),l=t===null?[]:x(t),m=[];for(const a of l){const c=ce(a.sub,r,n.person,"grants.sub");await ye(i,s,d,c,a.grantee)===void 0&&m.push(a.grantee)}if(m.length===0)return!0;if(n.loaded_at===void 0||n.loaded_at===null)throw new w("stage","import_failed","a loading run has no loaded_at");if(Date.now()-Date.parse(n.loaded_at)>=L)throw Ee(m);return!1}u(He,"grantsReady");async function ct(e,i,n={}){const r=n.blobs??await Y(),s=await E(),d=Te(e.run_id),t=u(async a=>{await i.assertOwned(),await R(e.run_id,a),await n.atStep?.(a)},"at");let l=e.state==="committed";const m=[];try{const a=await Le(r,e.run_id);if(e.source_kind==="machine"&&a.installId!==e.source_install_id)throw new w("stage","bundle_invalid",`source.json names install ${a.installId}, the run is for ${e.source_install_id}`);a.installId=e.source_install_id;const c=await Pe(s),O=[...Be],g=await ae(s,c,[...O,"grants"]);if(!l){const f={},P=[],k=[],j=n.fleetRuntime??process.env.CRTR_RUNTIME??null;if(await ue(s,c,a.person,e.person),!await He(r,s,e,a.person,c,j)){await i.assertOwned(),await R(e.run_id,"waiting_for_grants");return}await t("publish-plugins");const h=await Ce(await Ae(r,e.run_id));if(h.unavailable.length>0){if(e.loaded_at===void 0||e.loaded_at===null)throw new w("publish-plugins","import_failed","a loading run has no loaded_at");if(Date.now()-Date.parse(e.loaded_at)>=L)throw new w("publish-plugins","directory_unavailable",`the directory did not answer for: ${h.unavailable.slice(0,10).join(", ")}; rerun the import once it is reachable`,{plugins:h.unavailable});await i.assertOwned(),await R(e.run_id,"waiting_for_directory");return}k.push(...h.refused),await t("stage");const K=await Oe(s,e.run_id,a.counts,o=>ee(e.run_id,o,a),o=>r.get(o));for(const[o,p]of Object.entries(K))f[o]={staged:p,inserted:0,mapped:0,dropped:0};const _={db:s,schema:d,target:c,catalog:g,sourcePerson:a.person,targetPerson:e.person,fleetRuntime:j,shippedBodies:a.shippedBodies??{}};await t("bind-staged");for(const[o,p]of Object.entries(await le(_)))y(f,o,p);for(const[o,p]of Object.entries(await fe(_)))y(f,o,p);await t("rewrite-person"),await Re(_),await t("prune");const U=await ie(s,d,g,a),I=a.kind==="hosted"?je(a.pathPrefixes??[]):[];await t("rewrite-paths"),await oe(s,d,I),await de(s,d),await _e(_);const F=await Se(_);await re(s,d,c,a.installId,e.person),await t("rewrite-ids");const D=await ve(_,F);await t("drop");const J=await pe(s,d,c),q=await he(_);for(const[o,p]of Object.entries({...U}))y(f,o,p);for(const[o,p]of Object.entries(q))y(f,o,p);await me(_),await t("pre-check");const $=new Map([["messages",["seq"]],...te.map(o=>[o,["seq"]])]);await se(s,d,c,g,O,new Set,$),await t("blobs"),await be(s,d,c,e.person,r,e.run_id,m),await t("copy"),await N(async o=>{await i.assertOwned();const p=await ne({db:o,runId:e.run_id,schema:d,target:c,catalog:g,source:a,person:e.person,idMap:D,pathMap:I}),A=await Fe(o,e.run_id,J);A>0&&(p.inserted.revisions=(p.inserted.revisions??0)+A),await Ie(o,d,e.run_id,a);const M=await Ne({db:o,blobs:r,runId:e.run_id,person:e.person,objectMap:D.object});for(const[G,z]of Object.entries(M.inserted))p.inserted[G]=z.length;return P.push(...M.unresolvedPlugins),await o.prepare("UPDATE import_runs SET counts_json = ?, loaded_at = COALESCE(loaded_at, ?) WHERE run_id = ?").run(JSON.stringify({...Ue(f,p),unresolved_plugins:P,refused_plugins:k}),v(),e.run_id),p}),l=!0,await n.atStep?.("committed")}await t("verify");const b=await ke(s,e.run_id,d,c,g,a.installId);if(await s.prepare("UPDATE import_runs SET verify_json = ? WHERE run_id = ?").run(JSON.stringify(b),e.run_id),!b.ok)throw new w("verify","verify_failed","the committed rows differ from the staged rows or an invariant failed",{differences:b.differences,invariants:b.invariants});await t("manifest");const T=S.manifest(e.run_id);await r.put(T,await Je(e.run_id)),await W(s,e.run_id);for(const f of De(e.run_id))await r.delete(f);await ge(r,e.run_id),await N(async f=>{await Me(f,e.run_id,e.person),await f.prepare("UPDATE import_runs SET state = 'done', step = 'done', manifest_key = ?, finished_at = ? WHERE run_id = ?").run(T,v(),e.run_id)})}catch(a){if(a instanceof We)throw a;const c=Ke(a);await W(s,e.run_id).catch(()=>{}),l||await we(r,m,!0),await s.prepare("UPDATE import_runs SET state = 'failed', failure_json = ?, finished_at = ? WHERE run_id = ?").run(JSON.stringify(c),v(),e.run_id)}}u(ct,"processRun");function Ke(e){if(e instanceof w)return{step:e.step,code:e.code,message:e.message,...e.detail===void 0?{}:{detail:e.detail}};const i=e.code;return{step:"unknown",code:typeof i=="string"?i:"import_failed",message:e instanceof Error?e.message:String(e)}}u(Ke,"failureOf");function y(e,i,n){(e[i]??={staged:0,inserted:0,mapped:0,dropped:0}).dropped+=n}u(y,"addDropped");function Ue(e,i){for(const[n,r]of Object.entries(i.inserted))(e[n]??={staged:0,inserted:0,mapped:0,dropped:0}).inserted=r;for(const[n,r]of Object.entries(i.mapped))(e[n]??={staged:0,inserted:0,mapped:0,dropped:0}).mapped=r;return e}u(Ue,"withInserted");async function Fe(e,i,n){const r=new Set((await e.prepareUncached("SELECT rev_id FROM revisions WHERE rev_id IN (SELECT jsonb_array_elements_text(?::jsonb))").all(JSON.stringify(n.map(t=>t.rev_id)))).map(t=>t.rev_id)),s=n.filter(t=>!r.has(t.rev_id)),d=new Map;for(const t of n)d.set(t.document,[...d.get(t.document)??[],t]);for(const[t,l]of d){const m=await Z(e,t);m!==null&&await X(e,m,l.map(a=>({rev_id:a.rev_id,parents:a.parents,body_hash:a.body_hash,rationale:a.rationale,created_at:a.created_at})))}return await H(e,i,"revisions",s.map(t=>[t.rev_id])),await H(e,i,"revision_parents",s.flatMap(t=>t.parents.map(l=>[t.rev_id,l]))),s.length}u(Fe,"arrive");async function H(e,i,n,r){if(r.length===0)return;const s=await e.prepare("SELECT inserted_keys FROM import_manifest WHERE run_id = ? AND table_name = ?").get(i,n);s===void 0?await e.prepare("INSERT INTO import_manifest (run_id, table_name, inserted_keys) VALUES (?, ?, ?)").run(i,n,B(r)):await e.prepare("UPDATE import_manifest SET inserted_keys = ? WHERE run_id = ? AND table_name = ?").run(B([...C(s.inserted_keys),...r]),i,n)}u(H,"appendManifest");async function Je(e){const n=await(await E()).prepare("SELECT table_name, inserted_keys FROM import_manifest WHERE run_id = ? ORDER BY table_name").all(e);return V(Buffer.from(n.map(r=>JSON.stringify({table:r.table_name,keys:C(r.inserted_keys)})).join(`
1
+ var Q=Object.defineProperty;var c=(e,i)=>Q(e,"name",{value:i,configurable:!0});import{zstdCompressSync as V}from"node:zlib";import{blobStore as Y}from"../../blobs/index.js";import{openDb as S,withCanvasWrite as M}from"../../canvas/db.js";import{insertImportedRevisions as X}from"../../graph/documents.js";import{getById as Z}from"../../graph/objects.js";import{bundleKeys as v,decodeRows as x,rowKeys as ee,SEQ_TABLES as te}from"../bundle/layout.js";import{readCatalog as ae}from"./catalog.js";import{copyRows as ne,decodeKeys as N,encodeKeys as B}from"./copy.js";import{pruneStaged as ie,precheck as se,renameClashingProfiles as re,rewriteConversationHeaders as oe,rewritePaths as de,rewriteRequestPaths as pe,takeRepoSyncedDocuments as ue}from"./prepare.js";import{boundSub as ce,checkSourcePerson as fe,checkStagedBlobKeys as le,checkStagedPersons as me,checkStagedReferences as _e,checkStagedRequestKeys as we}from"./bind.js";import{deleteBlobs as ge,deleteRunBlobs as be,moveRunBlobs as he}from"./blobs.js";import{dropStubRows as ye,findFleetGrant as Ee,grantMissing as Se,mapProfileIds as ve,rewriteIds as Re,rewritePerson as Oe}from"./rewrite.js";import{dropStaging as W,ImportLaneError as w,stage as Te,stagingSchema as Pe,targetSchema as ke}from"./stage.js";import{verifyRun as je}from"./verify.js";import{sandboxPathMap as Ie,writeNodeFiles as De}from"./path-map.js";import{allStoreKeys as Ae,readPluginsStore as Ce,recordImportedActivations as Me,writeStores as Ne}from"./stores.js";import{publishImportedPlugins as Be}from"./publish-plugins.js";import{COPIED_TABLES as We}from"../bundle/layout.js";import{ClaimLostError as He}from"../../../daemon/reconcilers/row-claim.js";const H=10*6e4,R=c(()=>new Date().toISOString(),"now"),O=c(async(e,i)=>{await(await S()).prepare("UPDATE import_runs SET step = ? WHERE run_id = ?").run(i,e)},"setStep");async function Le(e,i){const n=await e.get(v.source(i));if(n===null)throw new w("stage","bundle_invalid","source.json is missing");return JSON.parse(n.toString("utf8"))}c(Le,"readSource");async function Ke(e,i,n,r,s,d){const t=await e.get(v.rows(n.run_id,"grants")),l=t===null?[]:x(t),m=[];for(const a of l){const u=ce(a.sub,r,n.person,"grants.sub");await Ee(i,s,d,u,a.grantee)===void 0&&m.push(a.grantee)}if(m.length===0)return!0;if(n.loaded_at===void 0||n.loaded_at===null)throw new w("stage","import_failed","a loading run has no loaded_at");if(Date.now()-Date.parse(n.loaded_at)>=H)throw Se(m);return!1}c(Ke,"grantsReady");async function ct(e,i,n={}){const r=n.blobs??await Y(),s=await S(),d=Pe(e.run_id),t=c(async a=>{await i.assertOwned(),await O(e.run_id,a),await n.atStep?.(a)},"at");let l=e.state==="committed";const m=[];try{const a=await Le(r,e.run_id);if(e.source_kind==="machine"&&a.installId!==e.source_install_id)throw new w("stage","bundle_invalid",`source.json names install ${a.installId}, the run is for ${e.source_install_id}`);a.installId=e.source_install_id;const u=await ke(s),T=[...We],g=await ae(s,u,[...T,"grants"]);if(!l){const f={},k=[],j=[],I=n.fleetRuntime??process.env.CRTR_RUNTIME??null;if(await fe(s,u,a.person,e.person),!await Ke(r,s,e,a.person,u,I)){await i.assertOwned(),await O(e.run_id,"waiting_for_grants");return}await t("publish-plugins");const h=await Be(await Ce(r,e.run_id));if(h.unavailable.length>0){if(e.loaded_at===void 0||e.loaded_at===null)throw new w("publish-plugins","import_failed","a loading run has no loaded_at");if(Date.now()-Date.parse(e.loaded_at)>=H)throw new w("publish-plugins","directory_unavailable",`the directory did not answer for: ${h.unavailable.slice(0,10).join(", ")}; rerun the import once it is reachable`,{plugins:h.unavailable});await i.assertOwned(),await O(e.run_id,"waiting_for_directory");return}j.push(...h.refused),await t("stage");const K=await Te(s,e.run_id,a.counts,o=>ee(e.run_id,o,a),o=>r.get(o));for(const[o,p]of Object.entries(K))f[o]={staged:p,inserted:0,mapped:0,dropped:0};const _={db:s,schema:d,target:u,catalog:g,sourcePerson:a.person,targetPerson:e.person,fleetRuntime:I,shippedBodies:a.shippedBodies??{}};await t("bind-staged");for(const[o,p]of Object.entries(await me(_)))y(f,o,p);for(const[o,p]of Object.entries(await le(_)))y(f,o,p);await t("rewrite-person"),await Oe(_),await t("prune");const U=await ie(s,d,g,a),E=a.kind==="hosted"?Ie(a.pathPrefixes??[]):[];await t("rewrite-paths"),await de(s,d,E),await oe(s,d,E,r,e.run_id),await pe(s,d),await we(_);const F=await ve(_);await re(s,d,u,a.installId,e.person),await t("rewrite-ids");const D=await Re(_,F);await t("drop");const J=await ue(s,d,u),q=await ye(_);for(const[o,p]of Object.entries({...U}))y(f,o,p);for(const[o,p]of Object.entries(q))y(f,o,p);await _e(_),await t("pre-check");const $=new Map([["messages",["seq"]],...te.map(o=>[o,["seq"]])]);await se(s,d,u,g,T,new Set,$),await t("blobs"),await he(s,d,u,e.person,r,e.run_id,m),await t("copy"),await M(async o=>{await i.assertOwned();const p=await ne({db:o,runId:e.run_id,schema:d,target:u,catalog:g,source:a,person:e.person,idMap:D,pathMap:E}),A=await Je(o,e.run_id,J);A>0&&(p.inserted.revisions=(p.inserted.revisions??0)+A),await De(o,d,e.run_id,a);const C=await Ne({db:o,blobs:r,runId:e.run_id,person:e.person,objectMap:D.object});for(const[G,z]of Object.entries(C.inserted))p.inserted[G]=z.length;return k.push(...C.unresolvedPlugins),await o.prepare("UPDATE import_runs SET counts_json = ?, loaded_at = COALESCE(loaded_at, ?) WHERE run_id = ?").run(JSON.stringify({...Fe(f,p),unresolved_plugins:k,refused_plugins:j}),R(),e.run_id),p}),l=!0,await n.atStep?.("committed")}await t("verify");const b=await je(s,e.run_id,d,u,g,a.installId);if(await s.prepare("UPDATE import_runs SET verify_json = ? WHERE run_id = ?").run(JSON.stringify(b),e.run_id),!b.ok)throw new w("verify","verify_failed","the committed rows differ from the staged rows or an invariant failed",{differences:b.differences,invariants:b.invariants});await t("manifest");const P=v.manifest(e.run_id);await r.put(P,await qe(e.run_id)),await W(s,e.run_id);for(const f of Ae(e.run_id))await r.delete(f);await be(r,e.run_id),await M(async f=>{await Me(f,e.run_id,e.person),await f.prepare("UPDATE import_runs SET state = 'done', step = 'done', manifest_key = ?, finished_at = ? WHERE run_id = ?").run(P,R(),e.run_id)})}catch(a){if(a instanceof He)throw a;const u=Ue(a);await W(s,e.run_id).catch(()=>{}),l||await ge(r,m,!0),await s.prepare("UPDATE import_runs SET state = 'failed', failure_json = ?, finished_at = ? WHERE run_id = ?").run(JSON.stringify(u),R(),e.run_id)}}c(ct,"processRun");function Ue(e){if(e instanceof w)return{step:e.step,code:e.code,message:e.message,...e.detail===void 0?{}:{detail:e.detail}};const i=e.code;return{step:"unknown",code:typeof i=="string"?i:"import_failed",message:e instanceof Error?e.message:String(e)}}c(Ue,"failureOf");function y(e,i,n){(e[i]??={staged:0,inserted:0,mapped:0,dropped:0}).dropped+=n}c(y,"addDropped");function Fe(e,i){for(const[n,r]of Object.entries(i.inserted))(e[n]??={staged:0,inserted:0,mapped:0,dropped:0}).inserted=r;for(const[n,r]of Object.entries(i.mapped))(e[n]??={staged:0,inserted:0,mapped:0,dropped:0}).mapped=r;return e}c(Fe,"withInserted");async function Je(e,i,n){const r=new Set((await e.prepareUncached("SELECT rev_id FROM revisions WHERE rev_id IN (SELECT jsonb_array_elements_text(?::jsonb))").all(JSON.stringify(n.map(t=>t.rev_id)))).map(t=>t.rev_id)),s=n.filter(t=>!r.has(t.rev_id)),d=new Map;for(const t of n)d.set(t.document,[...d.get(t.document)??[],t]);for(const[t,l]of d){const m=await Z(e,t);m!==null&&await X(e,m,l.map(a=>({rev_id:a.rev_id,parents:a.parents,body_hash:a.body_hash,rationale:a.rationale,created_at:a.created_at})))}return await L(e,i,"revisions",s.map(t=>[t.rev_id])),await L(e,i,"revision_parents",s.flatMap(t=>t.parents.map(l=>[t.rev_id,l]))),s.length}c(Je,"arrive");async function L(e,i,n,r){if(r.length===0)return;const s=await e.prepare("SELECT inserted_keys FROM import_manifest WHERE run_id = ? AND table_name = ?").get(i,n);s===void 0?await e.prepare("INSERT INTO import_manifest (run_id, table_name, inserted_keys) VALUES (?, ?, ?)").run(i,n,B(r)):await e.prepare("UPDATE import_manifest SET inserted_keys = ? WHERE run_id = ? AND table_name = ?").run(B([...N(s.inserted_keys),...r]),i,n)}c(L,"appendManifest");async function qe(e){const n=await(await S()).prepare("SELECT table_name, inserted_keys FROM import_manifest WHERE run_id = ? ORDER BY table_name").all(e);return V(Buffer.from(n.map(r=>JSON.stringify({table:r.table_name,keys:N(r.inserted_keys)})).join(`
2
2
  `)+`
3
- `))}u(Je,"manifestFile");export{L as GRANT_WAIT_MS,ct as processRun};
3
+ `))}c(qe,"manifestFile");export{H as GRANT_WAIT_MS,ct as processRun};
@@ -1,3 +1,3 @@
1
- var $=Object.defineProperty;var i=(n,a)=>$(n,"name",{value:a,configurable:!0});import{openDb as k}from"../../../canvas/db.js";import{mintExecutionToken as I}from"../../../canvas/node-tokens.js";import{BlaxelApiError as S,isWorkloadUnavailable as f}from"./client.js";const m=4180,u="view",T="node /opt/crtr/current/scripts/sandbox-start.mjs --wake",y=3,C=/^crtr-sandbox-start: failed (\S+)/m,p=i(n=>`broker-${n}`,"brokerProcessName"),w=i(n=>n.sandboxName??`${n.nodeId}-${n.attempt}`,"sandboxNameFor");async function h(n){const a=await(await k()).prepare("SELECT execution_id, attempt, sandbox_name FROM executions WHERE node_id = ? AND runner = 'blaxel'").all(n);return[...new Set(a.map(c=>w({executionId:c.execution_id,nodeId:n,attempt:Number(c.attempt),sandboxName:c.sandbox_name})))]}i(h,"defaultSandboxNames");function N(n){const a=`${n.logs}
1
+ var $=Object.defineProperty;var i=(n,a)=>$(n,"name",{value:a,configurable:!0});import{openDb as k}from"../../../canvas/db.js";import{mintExecutionToken as S}from"../../../canvas/node-tokens.js";import{BlaxelApiError as y,isWorkloadUnavailable as f}from"./client.js";const m=4180,w="view",I="node /opt/crtr/current/scripts/sandbox-start.mjs --wake",T=3,C=/^crtr-sandbox-start: failed (\S+)/m,p=i(n=>`broker-${n}`,"brokerProcessName"),d=i(n=>n.sandboxName??`${n.nodeId}-${n.attempt}`,"sandboxNameFor");async function h(n){const a=await(await k()).prepare("SELECT execution_id, attempt, sandbox_name FROM executions WHERE node_id = ? AND runner = 'blaxel'").all(n);return[...new Set(a.map(c=>d({executionId:c.execution_id,nodeId:n,attempt:Number(c.attempt),sandboxName:c.sandbox_name})))]}i(h,"defaultSandboxNames");function N(n){const a=`${n.logs}
2
2
  ${n.stderr}
3
- ${n.stdout}`;return{state:"failed",reason:C.exec(a)?.[1]??"start_failed",code:n.exitCode}}i(N,"failureOf");function O(n){const{client:a}=n,c=(n.stopGraceS??10)*1e3,E=new Map;async function d(t){return await a.getSandbox(w(t))}i(d,"sandboxOf");async function _(t,r){if(!/^[A-Za-z0-9_-]+$/.test(r))throw new Error(`execution id ${JSON.stringify(r)} is not safe to name in a command`);const e=Math.max(1,Math.ceil(c/1e3)),o=`p='[b]roker-cli\\.js .*--epoch ${r}( |$)'; pkill -TERM -f "$p"; i=0; while pgrep -f "$p" >/dev/null && [ $i -lt ${e*5} ]; do sleep 0.2; i=$((i+1)); done; pkill -KILL -f "$p"; sleep 0.3; ! pgrep -f "$p"`;return(await a.exec(t,`stop-${r}-${Date.now()}`,o,e+20)).exitCode===0}return i(_,"brokerGone"),{kind:"blaxel",async start(t){const r=await n.launchContext(t),e=w(t),o=await a.createSandbox({name:e,image:r.image,memoryMb:r.memoryMb,ports:[{name:u,target:m}]}),s=p(t.executionId);if((await a.getProcess(o,s))?.status==="running")return{pid:null,exited:null};await a.ensurePreview(e,u,m);const x=await(n.mintToken??(b=>I(b.executionId,b.nodeId)))(t),R={...r.secrets,CRTR_API_URL:r.apiUrl,CRTR_EXECUTION_ID:t.executionId,CRTR_NODE_TOKEN:x,CRTR_RELEASE:t.release,CRTR_RELEASE_URL:r.releaseUrl,CRTR_RELEASE_SHA256:r.releaseSha256};return await a.startProcess(o,{name:s,command:n.bootstrap(),env:R,waitForCompletion:!1}),{pid:null,exited:null}},async wake(t){const r=await d(t);if(r===null)return"no_broker";try{const e=await a.exec(r,`wake-${t.executionId}-${Date.now()}`,`${T} ${t.executionId}`,30);if(e.exitCode===0)return"signalled";if(e.exitCode===y)return"no_broker";throw new Error(`wake of ${t.executionId} failed (exit ${e.exitCode}): ${(e.stderr||e.logs).slice(0,300)}`)}catch(e){if(f(e))return"no_broker";throw e}},async stop(t,r){try{const e=await d(t);if(e===null)return{confirmed:!0};const o=p(t.executionId),s=i(async()=>(await a.getProcess(e,o))?.status==="running","running");if(await s()){await a.stopProcess(e,o);const l=Date.now()+c;for(;Date.now()<l&&await s();)await new Promise(x=>setTimeout(x,250));if(await s()&&await a.killProcess(e,o),await s())return{confirmed:!1}}return{confirmed:await _(e,t.executionId)}}catch(e){return f(e)?{confirmed:!0}:{confirmed:!1,error:e instanceof Error?e:new Error(String(e))}}},async status(t,r){try{const e=await d(t);if(e===null)return{state:"gone"};if(r?.idle===!0)return{state:"running",pid:null};const o=await a.getProcess(e,p(t.executionId));return o===null?{state:"gone"}:o.status==="running"?{state:"running",pid:null}:o.status==="failed"||o.status==="completed"&&o.exitCode!==0?N(o):{state:"gone"}}catch(e){return f(e)?{state:"gone"}:{state:"unknown",error:e instanceof Error?e.message:String(e)}}},async delete(t){for(const r of await(n.sandboxNamesForNode??h)(t))await a.deleteSandbox(r)},async viewerAddress(t){const r=w(t),e=E.get(r);if(e&&e.expiresAt-Date.now()>5*6e4)return g(e.url,e.token);const o=await a.ensurePreview(r,u,m),s=new Date(Date.now()+60*6e4),{token:l}=await a.createPreviewToken(r,u,s);return E.set(r,{url:o,token:l,expiresAt:s.getTime()}),g(o,l)},async sandboxState(t){return(await d(t))?.state??null}}}i(O,"createBlaxelRunner");function g(n,a){return{kind:"wss",url:`${n.replace(/^https:/,"wss:")}/view`,headers:{"x-blaxel-preview-token":a}}}i(g,"viewer");export{m as BROKER_VIEW_PORT,S as BlaxelApiError,y as EXIT_NO_BROKER,C as FAILURE_LINE,T as WAKE_COMMAND,p as brokerProcessName,O as createBlaxelRunner,w as sandboxNameFor};
3
+ ${n.stdout}`;return{state:"failed",reason:C.exec(a)?.[1]??"start_failed",code:n.exitCode}}i(N,"failureOf");function O(n){const{client:a}=n,c=(n.stopGraceS??10)*1e3,E=new Map;async function u(t){return await a.getSandbox(d(t))}i(u,"sandboxOf");async function _(t,r){if(!/^[A-Za-z0-9_-]+$/.test(r))throw new Error(`execution id ${JSON.stringify(r)} is not safe to name in a command`);const e=Math.max(1,Math.ceil(c/1e3)),o=`p='[b]roker-cli\\.js .*--epoch ${r}( |$)'; pkill -TERM -f "$p"; i=0; while pgrep -f "$p" >/dev/null && [ $i -lt ${e*5} ]; do sleep 0.2; i=$((i+1)); done; pkill -KILL -f "$p"; sleep 0.3; ! pgrep -f "$p"`;return(await a.exec(t,`stop-${r}-${Date.now()}`,o,e+20)).exitCode===0}return i(_,"brokerGone"),{kind:"blaxel",async start(t){const r=await n.launchContext(t),e=d(t),o=await a.createSandbox({name:e,image:r.image,memoryMb:r.memoryMb,ports:[{name:w,target:m}]}),s=p(t.executionId);if((await a.getProcess(o,s))?.status==="running")return{pid:null,exited:null};await a.ensurePreview(e,w,m);const x=await(n.mintToken??(b=>S(b.executionId,b.nodeId)))(t),R={...r.secrets,CRTR_API_URL:r.apiUrl,CRTR_EXECUTION_ID:t.executionId,CRTR_NODE_TOKEN:x,CRTR_RELEASE:t.release,CRTR_RELEASE_URL:r.releaseUrl,CRTR_RELEASE_SHA256:r.releaseSha256};return await a.startProcess(o,{name:s,command:n.bootstrap(),env:R,waitForCompletion:!1}),{pid:null,exited:null}},async wake(t){const r=await u(t);if(r===null)return"no_broker";try{const e=await a.exec(r,`wake-${t.executionId}-${Date.now()}`,`${I} ${t.executionId}`,30);if(e.exitCode===0)return"signalled";if(e.exitCode===T)return"no_broker";throw new Error(`wake of ${t.executionId} failed (exit ${e.exitCode}): ${(e.stderr||e.logs).slice(0,300)}`)}catch(e){if(f(e))return"no_broker";throw e}},async stop(t,r){try{const e=await u(t);if(e===null)return{confirmed:!0};const o=p(t.executionId),s=i(async()=>(await a.getProcess(e,o))?.status==="running","running");if(await s()){await a.stopProcess(e,o);const l=Date.now()+c;for(;Date.now()<l&&await s();)await new Promise(x=>setTimeout(x,250));if(await s()&&await a.killProcess(e,o),await s())return{confirmed:!1}}return{confirmed:await _(e,t.executionId)}}catch(e){return f(e)?{confirmed:!0}:{confirmed:!1,error:e instanceof Error?e:new Error(String(e))}}},async status(t,r){try{const e=await u(t);if(e===null)return{state:"gone"};if(r?.idle===!0)return{state:"running",pid:null};const o=await a.getProcess(e,p(t.executionId));return o===null?{state:"gone"}:o.status==="running"?{state:"running",pid:null}:o.status==="failed"||o.status==="completed"&&o.exitCode!==0?N(o):{state:"gone"}}catch(e){return f(e)?{state:"gone"}:{state:"unknown",error:e instanceof Error?e.message:String(e)}}},async delete(t){for(const r of await(n.sandboxNamesForNode??h)(t))await a.deleteSandbox(r)},async deleteExecution(t){await a.deleteSandbox(d(t))},async viewerAddress(t){const r=d(t),e=E.get(r);if(e&&e.expiresAt-Date.now()>5*6e4)return g(e.url,e.token);const o=await a.ensurePreview(r,w,m),s=new Date(Date.now()+60*6e4),{token:l}=await a.createPreviewToken(r,w,s);return E.set(r,{url:o,token:l,expiresAt:s.getTime()}),g(o,l)},async sandboxState(t){return(await u(t))?.state??null}}}i(O,"createBlaxelRunner");function g(n,a){return{kind:"wss",url:`${n.replace(/^https:/,"wss:")}/view`,headers:{"x-blaxel-preview-token":a}}}i(g,"viewer");export{m as BROKER_VIEW_PORT,y as BlaxelApiError,T as EXIT_NO_BROKER,C as FAILURE_LINE,I as WAKE_COMMAND,p as brokerProcessName,O as createBlaxelRunner,d as sandboxNameFor};
@@ -100,6 +100,8 @@ export interface Runner {
100
100
  status(execution: RunnerExecution, options?: RunnerStatusOptions): Promise<RunnerStatus>;
101
101
  /** Remove everything the runner holds for the node: the run dir (process) or the sandbox (Blaxel). */
102
102
  delete(nodeId: string): Promise<void>;
103
+ /** Remove only what one failed execution created (the Blaxel sandbox `<node id>-<attempt>`), where each attempt has its own. */
104
+ deleteExecution?(execution: RunnerExecution): Promise<void>;
103
105
  /** Where a viewer reaches this execution's broker. */
104
106
  viewerAddress(execution: RunnerExecution): Promise<RunnerViewerAddress>;
105
107
  }
@@ -1,5 +1,5 @@
1
1
  import { type Execution } from '../../../core/canvas/executions.js';
2
- import type { NodeMeta } from '../../../core/canvas/index.js';
2
+ import { type NodeMeta } from '../../../core/canvas/index.js';
3
3
  import { type EnvironmentImage } from '../recipe-image.js';
4
4
  /** A `launching` execution running past this since `started_at` is stopped: the 30-minute recipe setup limit plus boot. */
5
5
  export declare const LAUNCH_DEADLINE_MS: number;
@@ -29,5 +29,7 @@ export declare function wakeResident(execution: Execution): Promise<'woken' | 'l
29
29
  * reports it gone (or ended non-zero), that exact execution is ended; a runner that cannot tell leaves it as it is. An idle
30
30
  * execution is asked without touching its workload (`RunnerStatusOptions.idle`), so a frozen sandbox is not woken by the question. */
31
31
  export declare function endRemoteExecutionIfGone(execution: Execution): Promise<boolean>;
32
- /** The recovery table for a `launching` Blaxel execution found by a claim after its starter is gone. */
33
- export declare function recoverLaunching(nodeId: string, now: number): Promise<void>;
32
+ /** The recovery table for a `launching` Blaxel execution found by a claim after its starter is gone. True when this call ended the
33
+ * launch with a verdict on the node (crashed it, or recorded a failed launch and its backoff): the caller's row is then stale and the
34
+ * pass must not classify it, or it would relaunch at once as a stranded launch. */
35
+ export declare function recoverLaunching(nodeId: string, now: number): Promise<boolean>;
@@ -1 +1 @@
1
- var f=Object.defineProperty;var a=(e,t)=>f(e,"name",{value:t,configurable:!0});import{liveExecutionForNode as m,endExecution as d,recordExecutionAwake as p,endLaunchingExecution as s,requestExecutionStop as w}from"../../../core/canvas/executions.js";import{openDb as h}from"../../../core/canvas/db.js";import{isCloudRole as _}from"../../../core/canvas/person-state.js";import{emitEvent as u}from"../../../core/events/emit.js";import{findRefusal as x,refusalError as E,refusedMark as g,writeCharge as v}from"../../../core/ledger/index.js";import{transition as c}from"../../../core/runtime/lifecycle.js";import{runnerForExecution as l}from"../../../core/runtime/runner/index.js";import{machineEnvironmentOfProfile as b}from"../../../core/runtime/runner/machine/environment.js";import{startCandidateOf as k}from"../../../core/runtime/start-check.js";import{settleSandboxBeforeWake as y}from"../ledger-sandbox.js";import{crtrVersion as I}from"../../../shared/crtr-version.js";import{resolveEnvironmentImage as S}from"../recipe-image.js";const A=45*6e4,L=12e4,D=a(()=>I(),"acceptedRelease");async function G(e){return e===null||!_()?null:await b(e)}a(G,"remoteMachineEnvironmentOf");async function q(e){const t=await k(e);if(t===null)return;const n={scope:"call",payer:t.payer,funding:"bill",sub:t.sub,grantee:t.grantee,provider:"blaxel"},r=await x(n),o=await h();if(r===null){await o.prepare("UPDATE nodes SET spend_refusal = NULL WHERE node_id = ? AND spend_refusal IS NOT NULL").run(e.node_id);return}throw await o.prepare("UPDATE nodes SET spend_refusal = ? WHERE node_id = ?").run(JSON.stringify({limit:r.limit.id,usd:r.usd,reset_at:r.reset_at,at:new Date().toISOString()}),e.node_id),await v({id:`refused:sandbox:${e.node_id}:${r.limit.id}:${r.month}`,kind:"sandbox",what:"wake",usd:null,payer:n.payer,funding:"bill",sub:n.sub,grantee:n.grantee,node:e.node_id,run:e.run_id??null,provider:"blaxel",refused:g(r)}),E(r)}a(q,"checkBilledWake");class J extends Error{static{a(this,"EnvironmentImagePending")}environmentId;imageError;constructor(t,n){super(`environment ${t} has no built image yet${n===null?"":` (${n})`}; the wake waits for the build.`),this.environmentId=t,this.imageError=n,this.name="EnvironmentImagePending"}}async function V(e){return await S(e)}a(V,"imageForWake");async function j(e){return e.release!==D()&&await w(e.nodeId,{afterTurn:!1,reason:"release"}),await l(e.runner).wake(e)==="no_broker"?(await d(e.executionId,{reason:"lost"}),"lost"):(await y(e.executionId,Date.now()),await p(e.executionId),"woken")}a(j,"wakeResident");async function z(e){const t=await l(e.runner).status(e,{idle:e.idleAt!==null});if(t.state!=="gone"&&t.state!=="failed")return!1;const n=await d(e.executionId,{reason:"lost"});return n&&u({level:"warn",event:"execution.lost",node_id:e.nodeId}),n}a(z,"endRemoteExecutionIfGone");async function K(e,t){const n=await m(e);if(n===null||n.state!=="launching"||n.runner==="process")return;const r=l(n.runner),o=t-Date.parse(n.startedAt),i=await r.status(n);if(i.state!=="unknown"){if(i.state==="running"){if(o<=A||!await s(n.executionId,{reason:"launch_timeout"}))return;await r.stop(n,{reason:"launch_timeout"}),await c(e,"crash",{reason:"launch_failed",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:"the sandbox launch did not report within the launch deadline"}}}),u({level:"warn",event:"execution.launch_timeout",node_id:e});return}if(i.state==="failed"){if(!await s(n.executionId,{reason:"launch_failed"}))return;await c(e,"crash",{reason:"launch_failed",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:`the sandbox start script failed: ${i.reason}`}}});return}if(o>L){if(!await s(n.executionId,{reason:"launch_lost"}))return;u({level:"warn",event:"execution.launch_lost",node_id:e})}}}a(K,"recoverLaunching");export{J as EnvironmentImagePending,A as LAUNCH_DEADLINE_MS,L as LAUNCH_LOST_GRACE_MS,D as acceptedRelease,q as checkBilledWake,z as endRemoteExecutionIfGone,V as imageForWake,K as recoverLaunching,G as remoteMachineEnvironmentOf,j as wakeResident};
1
+ var h=Object.defineProperty;var a=(e,r)=>h(e,"name",{value:r,configurable:!0});import{liveExecutionForNode as _,endExecution as p,recordExecutionAwake as x,endLaunchingExecution as c,requestExecutionStop as v}from"../../../core/canvas/executions.js";import{openDb as E}from"../../../core/canvas/db.js";import{isCloudRole as g}from"../../../core/canvas/person-state.js";import{getRow as b}from"../../../core/canvas/index.js";import{fullName as k}from"../../../core/canvas/labels.js";import{publishNotice as y}from"../../../core/runtime/close.js";import{emitEvent as s}from"../../../core/events/emit.js";import{findRefusal as $,refusalError as L,refusedMark as N,writeCharge as S}from"../../../core/ledger/index.js";import{transition as w}from"../../../core/runtime/lifecycle.js";import{runnerForExecution as d}from"../../../core/runtime/runner/index.js";import{machineEnvironmentOfProfile as A}from"../../../core/runtime/runner/machine/environment.js";import{startCandidateOf as R}from"../../../core/runtime/start-check.js";import{settleSandboxBeforeWake as D}from"../ledger-sandbox.js";import{crtrVersion as C}from"../../../shared/crtr-version.js";import{resolveEnvironmentImage as I}from"../recipe-image.js";import{recordRespawnPolicy as O}from"./respawn-policy.js";import{recordLaunchFailure as T}from"./launch-failure.js";const P=45*6e4,U=12e4,W=a(()=>C(),"acceptedRelease");async function ne(e){return e===null||!g()?null:await A(e)}a(ne,"remoteMachineEnvironmentOf");async function ae(e){const r=await R(e);if(r===null)return;const t={scope:"call",payer:r.payer,funding:"bill",sub:r.sub,grantee:r.grantee,provider:"blaxel"},n=await $(t),i=await E();if(n===null){await i.prepare("UPDATE nodes SET spend_refusal = NULL WHERE node_id = ? AND spend_refusal IS NOT NULL").run(e.node_id);return}throw await i.prepare("UPDATE nodes SET spend_refusal = ? WHERE node_id = ?").run(JSON.stringify({limit:n.limit.id,usd:n.usd,reset_at:n.reset_at,at:new Date().toISOString()}),e.node_id),await S({id:`refused:sandbox:${e.node_id}:${n.limit.id}:${n.month}`,kind:"sandbox",what:"wake",usd:null,payer:t.payer,funding:"bill",sub:t.sub,grantee:t.grantee,node:e.node_id,run:e.run_id??null,provider:"blaxel",refused:N(n)}),L(n)}a(ae,"checkBilledWake");class ie extends Error{static{a(this,"EnvironmentImagePending")}environmentId;imageError;constructor(r,t){super(`environment ${r} has no built image yet${t===null?"":` (${t})`}; the wake waits for the build.`),this.environmentId=r,this.imageError=t,this.name="EnvironmentImagePending"}}async function oe(e){return await I(e)}a(oe,"imageForWake");async function se(e){return e.release!==W()&&await v(e.nodeId,{afterTurn:!1,reason:"release"}),await d(e.runner).wake(e)==="no_broker"?(await p(e.executionId,{reason:"lost"}),"lost"):(await D(e.executionId,Date.now()),await x(e.executionId),"woken")}a(se,"wakeResident");async function ue(e){const r=await d(e.runner).status(e,{idle:e.idleAt!==null});if(r.state!=="gone"&&r.state!=="failed")return!1;const t=await p(e.executionId,{reason:"lost"});return t&&s({level:"warn",event:"execution.lost",node_id:e.nodeId}),t}a(ue,"endRemoteExecutionIfGone");async function le(e,r){const t=await _(e);if(t===null||t.state!=="launching"||t.runner==="process")return!1;const n=d(t.runner),i=r-Date.parse(t.startedAt),o=await n.status(t);if(o.state==="unknown")return!1;if(o.state==="running")return i<=P||!await c(t.executionId,{reason:"launch_timeout"})?!1:(await n.stop(t,{reason:"launch_timeout"}),await w(e,"crash",{reason:"launch_failed",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:"the sandbox launch did not report within the launch deadline"}}}),s({level:"warn",event:"execution.launch_timeout",node_id:e}),!0);if(o.state==="failed"){if(!await c(t.executionId,{reason:"launch_failed"}))return!1;const f=`the sandbox start script failed: ${o.reason}`;await T(t.executionId,new Error(f));const l=await b(e);if(l!==null){const u=await O(l,r);if(!u.exhausted)s({level:"warn",event:"execution.launch_failed",node_id:e,fields:{reason:o.reason,consecutive_failures:u.failures}});else{const m=`Child crashed \u2014 ${k(l)} (${e}) failed ${u.failures} consecutive sandbox launches (${f}) and is now dead. It stays dead until you revive it \u2014 \`crtr node lifecycle revive ${e}\`.`;s({level:"error",event:"broker.respawn.exhausted",node_id:e}),await w(e,"crash",{reason:"crash_looped",outcome:{detail:{schema:"crtr.node-outcome-detail/v1",message:m,respawn_failures:u.failures}}}),await y(e,"notice.crash",m,{reason:"child-crashed",child:e})}}return await n.deleteExecution?.(t),!0}if(i>U){if(!await c(t.executionId,{reason:"launch_lost"}))return!1;s({level:"warn",event:"execution.launch_lost",node_id:e})}return!1}a(le,"recoverLaunching");export{ie as EnvironmentImagePending,P as LAUNCH_DEADLINE_MS,U as LAUNCH_LOST_GRACE_MS,W as acceptedRelease,ae as checkBilledWake,ue as endRemoteExecutionIfGone,oe as imageForWake,le as recoverLaunching,ne as remoteMachineEnvironmentOf,se as wakeResident};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var o=(s,i)=>g(s,"name",{value:i,configurable:!0});import{clearFrozen as P,getNode as z}from"../../../core/canvas/index.js";import{isSafeNodeId as L}from"../../../core/canvas/paths.js";import{recordedPidLiveness as x}from"../../../core/canvas/pid.js";import{endExecution as v,hasAbsorbedProfilePauseStop as N,hasObservedExit as M,latestExecutionForNode as w,liveExecutionForNode as c}from"../../../core/canvas/executions.js";import{emitEvent as I}from"../../../core/events/emit.js";import{operationIdContext as D}from"../../../core/events/operation-id.js";import{readInterruptedTurn as F}from"../../../core/canvas/recovery.js";import{isProfilePaused as d}from"../../../core/profiles/manifest.js";import{isRecoveryHeld as E}from"../../../core/runtime/recovery-hold.js";import{hasUnseenWakeMail as p}from"../../../core/canvas/deliveries.js";import{hasIdleReleaseIntent as A,isParkedResident as C}from"../../../core/runtime/lifecycle.js";import{classifyDeadNode as S}from"../../fleet.js";import{applyParkEvent as T,hasPendingWake as U,parkEvent as W}from"../live-obligation.js";import{FreezeLaneReconciler as B}from"./freeze-lane.js";import{isInBackoff as k}from"./respawn-policy.js";import{asNodePerson as G,NodePersonUnresolvedError as R}from"./node-person.js";import{handleTerminatingRow as H}from"./terminating.js";import{wantsExecution as O}from"./wants-execution.js";import{enactRequestedStops as q}from"./requested-stops.js";import{endRemoteExecutionIfGone as j,recoverLaunching as J,wakeResident as K}from"./remote-wake.js";import{isDrained as Q}from"../../drain.js";function V(s){return s.status==="done"||s.status==="canceled"||s.status==="dead"}o(V,"isTerminal");const X=12e4;function Y(s,i,e){const n=Math.max(...[s.created,s.launched_at].map(r=>r==null?0:Date.parse(r)||0));return n>0&&i-n<X&&e?.state!=="exited"}o(Y,"isLaunchInFlight");async function b(s){const i=await c(s);return i!==null&&i.state==="running"&&i.pid!=null&&x(i.pid,i.processIdentity)==="dead"?i:null}o(b,"executionWithDeadPid");class we{static{o(this,"NodeLifecycleReconciler")}freezeLane=new B;async run(i,e){const n=[];await q(i);for(const r of e.rows)await D.fresh(async()=>{try{await G(r,()=>this.classifyRow(i,r,e,n))}catch(t){const l=r.node_id;I({level:t instanceof R?"warn":"error",event:t instanceof R?"node.lifecycle.person_unresolved":"node.lifecycle.classify_failed",...L(l)?{node_id:l}:{fields:{affected_node_id:l}},error:t})}});return await Q()?{stalled:0,waitingOnMail:0}:this.freezeLane.run(i,{fleet:e.fleet,candidates:n})}async classifyRow(i,e,n,r){const t=e.node_id;if(V(e)){if(H(e,await n.fleet.has(t)))return;if(C(e)&&!await n.fleet.has(t)&&!d(e.profile_id)&&!await E(t)&&!k(e,i)&&await p(t)){r.push({row:e,enact:"reopen"});return}if(e.pi_pid!=null){const a=await b(t);a!==null&&await v(a.executionId,{reason:"observed-dead"})}e.frozen_at!=null&&(e.final_report!=null||e.status==="dead"?await P(t):r.push({row:e,enact:"thaw"}));return}if(await n.fleet.has(t)){const a=await c(t);if(a?.runner!==void 0&&a.runner!=="process"&&a.state==="running"&&!d(e.profile_id)&&await p(t)){if(await K(a)==="lost")return}else a?.runner!==void 0&&a.runner!=="process"&&a.state==="running"&&await j(a);if(await n.fleet.has(t)){d(e.profile_id)?await n.fleet.interruptForProfilePause(t):await this.thawMark(e);return}}if(await J(t,i),d(e.profile_id)){await this.freezeLane.endEpisode(t);return}if(await E(t))return;const l=e.pi_pid==null?await w(t):null,f=l!==null&&M(l),m=l!==null&&!f&&N(l),h=e.pi_pid!=null?await b(t):null,_=f||m||h!==null;if(_&&!await n.fleet.hasProfilePauseInterruption(t)){const a=h??l;a!==null&&await v(a.executionId,{reason:"observed-dead"});const y=await c(t);if(y!==null&&y.executionId!==a?.executionId)return}if(!await O(e)){await this.thawMark(e),await this.settleParked(e);return}if(k(e,i))return;if(e.status==="idle"&&A(e)&&await p(t)){r.push({row:e,enact:"idle-release"});return}if(e.pi_pid==null&&(!f||e.frozen_at!=null)&&!m){if(e.respawn_not_before!=null){r.push({row:e,enact:"policy"});return}if(e.frozen_at!=null){r.push({row:e,enact:"thaw"});return}if(await n.fleet.isClaimed(t)||Y(e,i,await w(t)))return;I({level:"warn",event:"node.lifecycle.stranded_launch",node_id:t}),r.push({row:e,enact:"thaw"});return}if(!_)return;const u=S(await z(t),(await F(t))?.interrupted===!0,await U(t));if(u==="respawn-fresh"||u==="respawn-cycle"||u==="respawn-resume"){r.push({row:e,enact:"policy"});return}await n.fleet.applyDeadRowPolicy(t),await this.thawMark(e)}async thawMark(i){i.frozen_at!=null&&await P(i.node_id)}async settleParked(i){if(i.status!=="idle")return;await this.freezeLane.endEpisode(i.node_id);const e=await W(i.node_id,i.lifecycle);e!=="release"&&await T(i.node_id,e)}}export{X as LAUNCH_GRACE_MS,we as NodeLifecycleReconciler,Y as isLaunchInFlight};
1
+ var g=Object.defineProperty;var o=(s,i)=>g(s,"name",{value:i,configurable:!0});import{clearFrozen as P,getNode as z}from"../../../core/canvas/index.js";import{isSafeNodeId as L}from"../../../core/canvas/paths.js";import{recordedPidLiveness as x}from"../../../core/canvas/pid.js";import{endExecution as v,hasAbsorbedProfilePauseStop as N,hasObservedExit as M,latestExecutionForNode as w,liveExecutionForNode as c}from"../../../core/canvas/executions.js";import{emitEvent as I}from"../../../core/events/emit.js";import{operationIdContext as D}from"../../../core/events/operation-id.js";import{readInterruptedTurn as F}from"../../../core/canvas/recovery.js";import{isProfilePaused as d}from"../../../core/profiles/manifest.js";import{isRecoveryHeld as E}from"../../../core/runtime/recovery-hold.js";import{hasUnseenWakeMail as p}from"../../../core/canvas/deliveries.js";import{hasIdleReleaseIntent as A,isParkedResident as C}from"../../../core/runtime/lifecycle.js";import{classifyDeadNode as S}from"../../fleet.js";import{applyParkEvent as T,hasPendingWake as U,parkEvent as W}from"../live-obligation.js";import{FreezeLaneReconciler as B}from"./freeze-lane.js";import{isInBackoff as k}from"./respawn-policy.js";import{asNodePerson as G,NodePersonUnresolvedError as R}from"./node-person.js";import{handleTerminatingRow as H}from"./terminating.js";import{wantsExecution as O}from"./wants-execution.js";import{enactRequestedStops as q}from"./requested-stops.js";import{endRemoteExecutionIfGone as j,recoverLaunching as J,wakeResident as K}from"./remote-wake.js";import{isDrained as Q}from"../../drain.js";function V(s){return s.status==="done"||s.status==="canceled"||s.status==="dead"}o(V,"isTerminal");const X=12e4;function Y(s,i,e){const n=Math.max(...[s.created,s.launched_at].map(r=>r==null?0:Date.parse(r)||0));return n>0&&i-n<X&&e?.state!=="exited"}o(Y,"isLaunchInFlight");async function b(s){const i=await c(s);return i!==null&&i.state==="running"&&i.pid!=null&&x(i.pid,i.processIdentity)==="dead"?i:null}o(b,"executionWithDeadPid");class we{static{o(this,"NodeLifecycleReconciler")}freezeLane=new B;async run(i,e){const n=[];await q(i);for(const r of e.rows)await D.fresh(async()=>{try{await G(r,()=>this.classifyRow(i,r,e,n))}catch(t){const l=r.node_id;I({level:t instanceof R?"warn":"error",event:t instanceof R?"node.lifecycle.person_unresolved":"node.lifecycle.classify_failed",...L(l)?{node_id:l}:{fields:{affected_node_id:l}},error:t})}});return await Q()?{stalled:0,waitingOnMail:0}:this.freezeLane.run(i,{fleet:e.fleet,candidates:n})}async classifyRow(i,e,n,r){const t=e.node_id;if(V(e)){if(H(e,await n.fleet.has(t)))return;if(C(e)&&!await n.fleet.has(t)&&!d(e.profile_id)&&!await E(t)&&!k(e,i)&&await p(t)){r.push({row:e,enact:"reopen"});return}if(e.pi_pid!=null){const a=await b(t);a!==null&&await v(a.executionId,{reason:"observed-dead"})}e.frozen_at!=null&&(e.final_report!=null||e.status==="dead"?await P(t):r.push({row:e,enact:"thaw"}));return}if(await n.fleet.has(t)){const a=await c(t);if(a?.runner!==void 0&&a.runner!=="process"&&a.state==="running"&&!d(e.profile_id)&&await p(t)){if(await K(a)==="lost")return}else a?.runner!==void 0&&a.runner!=="process"&&a.state==="running"&&await j(a);if(await n.fleet.has(t)){d(e.profile_id)?await n.fleet.interruptForProfilePause(t):await this.thawMark(e);return}}if(await J(t,i))return;if(d(e.profile_id)){await this.freezeLane.endEpisode(t);return}if(await E(t))return;const l=e.pi_pid==null?await w(t):null,f=l!==null&&M(l),m=l!==null&&!f&&N(l),h=e.pi_pid!=null?await b(t):null,_=f||m||h!==null;if(_&&!await n.fleet.hasProfilePauseInterruption(t)){const a=h??l;a!==null&&await v(a.executionId,{reason:"observed-dead"});const y=await c(t);if(y!==null&&y.executionId!==a?.executionId)return}if(!await O(e)){await this.thawMark(e),await this.settleParked(e);return}if(k(e,i))return;if(e.status==="idle"&&A(e)&&await p(t)){r.push({row:e,enact:"idle-release"});return}if(e.pi_pid==null&&(!f||e.frozen_at!=null)&&!m){if(e.respawn_not_before!=null){r.push({row:e,enact:"policy"});return}if(e.frozen_at!=null){r.push({row:e,enact:"thaw"});return}if(await n.fleet.isClaimed(t)||Y(e,i,await w(t)))return;I({level:"warn",event:"node.lifecycle.stranded_launch",node_id:t}),r.push({row:e,enact:"thaw"});return}if(!_)return;const u=S(await z(t),(await F(t))?.interrupted===!0,await U(t));if(u==="respawn-fresh"||u==="respawn-cycle"||u==="respawn-resume"){r.push({row:e,enact:"policy"});return}await n.fleet.applyDeadRowPolicy(t),await this.thawMark(e)}async thawMark(i){i.frozen_at!=null&&await P(i.node_id)}async settleParked(i){if(i.status!=="idle")return;await this.freezeLane.endEpisode(i.node_id);const e=await W(i.node_id,i.lifecycle);e!=="release"&&await T(i.node_id,e)}}export{X as LAUNCH_GRACE_MS,we as NodeLifecycleReconciler,Y as isLaunchInFlight};
@@ -7,6 +7,10 @@ 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.613
11
+
12
+ `oauth.appMember('user:<id>')` asks the directory whether that person is on the team that holds your app, for your app's own staff pages. It answers `{member: true, role: 'admin' | 'member'}` or `{member: false}` (an unknown user is `member: false`) by calling `GET /v1/apps/self/members/:user_id` as the app itself, and caches nothing, so someone removed from the team is refused at their next call. A 401 re-mints the directory token once. Nothing existing changes.
13
+
10
14
  ## 0.3.599
11
15
 
12
16
  `PUT /v1/model-auth/:provider` with `kind: "api_key"` accepts an optional `models: {ultra, strong, medium, light}` for `anthropic`, `openai`, `openrouter` and `moonshotai`. Each value is `<provider>/<model-id>`, a registered chat model of that provider; all four are required. The key is saved with that mapping as the person's model route `key:<provider>`, which is tried after every subscription. An invalid mapping is refused `400 invalid_request`. Without `models` the call behaves as before.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.612",
3
+ "version": "0.3.614",
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.612",
148
+ "@north-light/identity": "0.3.614",
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.612",
3
+ "version": "0.3.614",
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.612",
3
+ "version": "0.3.614",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.612",
9
+ "version": "0.3.614",
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.612",
31
+ "@north-light/identity": "0.3.614",
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.612",
11959
+ "version": "0.3.614",
11960
11960
  "license": "UNLICENSED"
11961
11961
  },
11962
11962
  "packages/crouter-env-docker": {
11963
11963
  "name": "@north-light/env-docker",
11964
- "version": "0.3.612",
11964
+ "version": "0.3.614",
11965
11965
  "license": "UNLICENSED"
11966
11966
  },
11967
11967
  "packages/crouter-identity": {
11968
11968
  "name": "@north-light/identity",
11969
- "version": "0.3.612",
11969
+ "version": "0.3.614",
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.612",
11977
+ "version": "0.3.614",
11978
11978
  "license": "UNLICENSED",
11979
11979
  "dependencies": {
11980
- "@north-light/api": "0.3.612",
11981
- "@north-light/identity": "0.3.612"
11980
+ "@north-light/api": "0.3.614",
11981
+ "@north-light/identity": "0.3.614"
11982
11982
  }
11983
11983
  },
11984
11984
  "packages/crouter-sdk": {
11985
11985
  "name": "@north-light/sdk",
11986
- "version": "0.3.612",
11986
+ "version": "0.3.614",
11987
11987
  "license": "UNLICENSED",
11988
11988
  "dependencies": {
11989
- "@north-light/api": "0.3.612",
11990
- "@north-light/identity": "0.3.612",
11991
- "@north-light/plugin": "0.3.612",
11989
+ "@north-light/api": "0.3.614",
11990
+ "@north-light/identity": "0.3.614",
11991
+ "@north-light/plugin": "0.3.614",
11992
11992
  "jose": "^6.2.1"
11993
11993
  },
11994
11994
  "bin": {