@north-light/cli 0.3.578 → 0.3.580
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/crouter-sdk/release-notes.md +1 -1
- package/dist/builtin-memory/internal/storage-tiers.md +2 -2
- package/dist/clients/attach/viewer.js +338 -338
- package/dist/core/canvas/export-sqlite.js +1 -1
- package/dist/core/canvas/schema-pg/009-bodies.sql +10 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/command.js +5 -5
- package/dist/core/feed/feed.js +3 -3
- package/dist/core/feed/inbox.js +1 -1
- package/dist/core/feed/reports.js +2 -2
- package/dist/core/graph/access.d.ts +1 -1
- package/dist/core/graph/bodies-boot-copy.d.ts +14 -0
- package/dist/core/graph/bodies-boot-copy.js +1 -0
- package/dist/core/graph/bodies.d.ts +13 -6
- package/dist/core/graph/bodies.js +1 -1
- package/dist/core/graph/documents.js +8 -8
- package/dist/core/graph/objects.js +11 -11
- package/dist/core/graph/package-docs.js +5 -5
- package/dist/core/graph/repo-sync/exchange.js +2 -2
- package/dist/core/graph/repo-sync/ref-format.d.ts +0 -1
- package/dist/core/graph/repo-sync/ref-format.js +2 -2
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/page.d.ts +2 -4
- package/dist/core/human/page.js +6 -6
- package/dist/core/human/request-files.d.ts +14 -0
- package/dist/core/human/request-files.js +1 -0
- package/dist/core/human/requests.d.ts +3 -0
- package/dist/core/human/requests.js +18 -17
- package/dist/core/human/tickets.js +1 -1
- package/dist/core/human/visible-paths.d.ts +7 -0
- package/dist/core/human/visible-paths.js +1 -1
- package/dist/core/peer/receiver.js +1 -1
- package/dist/core/review/document.d.ts +4 -4
- package/dist/core/review/document.js +2 -2
- package/dist/core/review/project.d.ts +7 -5
- package/dist/core/review/project.js +2 -1
- package/dist/core/review/remap.js +1 -1
- package/dist/core/review/stage.d.ts +2 -0
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.js +1 -1
- package/dist/core/runtime/roadmap.js +3 -3
- package/dist/core/substrate/delivery/corpus.d.ts +2 -0
- package/dist/core/substrate/delivery/corpus.js +3 -3
- package/dist/core/substrate/delivery/deliver.js +3 -3
- package/dist/core/substrate/delivery/render-boot.js +25 -25
- package/dist/core/substrate/delivery/render-event.d.ts +1 -1
- package/dist/core/substrate/delivery/render-event.js +4 -4
- package/dist/core/substrate/delivery/types.d.ts +2 -2
- package/dist/daemon/api/bridge.d.ts +1 -1
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/document-listener.js +4 -4
- package/dist/daemon/api/handlers/docs.js +1 -1
- package/dist/daemon/api/handlers/feedback-comments.js +2 -2
- package/dist/daemon/api/handlers/inbox-page.js +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/memory.js +4 -4
- package/dist/daemon/api/handlers/reports.js +4 -4
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/boot-migrations.js +1 -1
- package/dist/daemon/profile-delete.js +1 -1
- package/dist/daemon/review/finish.js +1 -1
- package/dist/daemon/review/sweep.js +1 -1
- package/dist/daemon/runs/observer.js +3 -3
- package/dist/migrations/004-canvas-documents/apply.d.ts +2 -4
- package/dist/migrations/004-canvas-documents/apply.js +1 -1
- package/dist/migrations/004-canvas-documents/index.js +2 -2
- package/dist/shared/env.d.ts +5 -0
- package/dist/shared/env.js +2 -2
- package/docs/sdk/release-notes.md +1 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
WHERE node_id = ? AND EXISTS (SELECT 1 FROM reconciler_leases WHERE lane = ? AND key = ? AND owner = ? AND expires_at > ?)`).run(...e===null||
|
|
1
|
+
var b=Object.defineProperty;var l=(t,e)=>b(t,"name",{value:e,configurable:!0});import{randomUUID as y}from"node:crypto";import{openDb as d,withCanvasWrite as C}from"../../core/canvas/db.js";import{claimReconcilerLease as F,releaseReconcilerLease as O,renewReconcilerLease as M}from"../../core/canvas/reconciler-leases.js";import{getNode as R}from"../../core/canvas/canvas.js";import{BrokerClient as x,SocketTransport as D}from"../../core/broker-client/client.js";import{liveExecutionForNode as N}from"../../core/canvas/executions.js";import{runnerForExecution as H}from"../../core/runtime/runner/index.js";import{connectWssView as W}from"../../core/runtime/view-socket.js";import{ViewLinkTransport as q}from"./view-transport.js";import{emitRunEvent as g,emitRunSettlement as A,emitRunStatus as U}from"../../core/runs/events.js";import{cancelOpenQuestions as j}from"../../core/runs/questions.js";import{emitEvent as c}from"../../core/events/emit.js";import{toRunOutcomeDTO as J}from"../api/map.js";import{readOutputResult as P}from"../../core/runtime/output-result.js";const V=JSON.stringify({input_tokens:0,output_tokens:0,cache_read_tokens:0,cache_write_tokens:0,cost_usd:0}),p=new Map,h="run-observer",E=1e4,B=250;async function w(t,e,i){return await C(async s=>await s.prepare("SELECT 1 AS held FROM reconciler_leases WHERE lane = ? AND key = ? AND owner = ? AND expires_at > ? FOR SHARE").get(h,t,e,new Date().toISOString())===void 0?{held:!1}:{held:!0,value:await i()})}l(w,"whileHoldingLease");class v{static{l(this,"RunObserver")}nodeId;runId;owner;client;timer;status;piPid=null;outcomeRevision;openAssistant=!1;assistantStartSequence=0;block=null;thinking="";output="";pendingThinking="";pendingOutput="";flushTimer;closed=!1;lastRenewAt=Date.now();released=Promise.resolve();polling;frames=Promise.resolve();constructor(e,i,s,n,r){this.nodeId=e,this.runId=i,this.owner=s,this.status=n,this.outcomeRevision=r,this.timer=setInterval(()=>{this.pollOrClose()},250),this.timer.unref(),p.set(e,this)}static async start(e,i,s){const n=await d(),r=await n.prepare("SELECT body_json FROM run_events WHERE node_id = ? AND type = ? ORDER BY sequence_number DESC LIMIT 1").get(e,e===i?"node.settled":"child.settled"),a=await n.prepare("SELECT body_json FROM run_events WHERE node_id = ? AND type = 'node.status.changed' ORDER BY sequence_number DESC LIMIT 1").get(e),o=new v(e,i,s,a?JSON.parse(a.body_json).status:void 0,r?JSON.parse(r.body_json).outcome.revision:void 0);return await o.writeStream(null,null),await o.poll(),o}async pollOrClose(){try{await this.poll()}catch(e){this.close(),c({level:"error",event:"daemon.runs.observer_failed",node_id:this.nodeId,error:e})}}poll(){return this.polling===void 0&&(this.polling=this.pollOnce().finally(()=>{this.polling=void 0})),this.polling}async holdLease(){return Date.now()-this.lastRenewAt<E/3?!0:await M(h,this.nodeId,this.owner,E)?(this.lastRenewAt=Date.now(),!0):!1}async writeStream(e,i,s=!1){return(await(await d()).prepare(`UPDATE nodes SET ${s?"":`stream_message_seq = ${e===null?"NULL":"(SELECT event_cursor FROM nodes WHERE node_id = ?)"},`} stream_block = ?
|
|
2
|
+
WHERE node_id = ? AND EXISTS (SELECT 1 FROM reconciler_leases WHERE lane = ? AND key = ? AND owner = ? AND expires_at > ?)`).run(...e===null||s?[]:[this.runId],i===null?null:JSON.stringify(i),this.nodeId,h,this.nodeId,this.owner,new Date().toISOString())).changes===1}async pollOnce(){if(this.closed)return;if(!await this.holdLease()){this.close();return}const e=await R(this.nodeId);if(!e||e.run_id!==this.runId||!await T(this.runId)){this.close();return}this.piPid=e.pi_pid??null;const i=e.pi_pid===null?"dormant":e.status;if(this.status!==i){if(!(await w(this.nodeId,this.owner,()=>U(this.runId,this.nodeId,i,e.intent??null))).held){this.close();return}this.status=i}const s=await J(e);if(s&&s.revision!==this.outcomeRevision&&Date.now()-Date.parse(s.settled_at)<720*60*6e4){if(this.nodeId===this.runId){const a=await(await d()).prepare("SELECT node_id FROM nodes WHERE run_id = ? AND node_id != ? ORDER BY created DESC").all(this.runId,this.runId);for(const o of a)await I(o.node_id,this.runId),await p.get(o.node_id)?.poll()}this.outcomeRevision=s.revision;const n=this.nodeId===this.runId&&s.kind==="result"?await P(this.nodeId):void 0;if(!(await w(this.nodeId,this.owner,()=>this.nodeId===this.runId?A(this.runId,this.nodeId,"node.settled",{outcome:s,usage:JSON.parse(e.usage_json??V),...n===void 0?{}:{result:n}}):A(this.runId,this.nodeId,"child.settled",{child_node_id:this.nodeId,outcome:s}))).held){this.close();return}if(e.grantee&&e.grantee!=="app:terminal"){const a=this.nodeId===this.runId?{run_id:this.runId}:{node_id:this.nodeId};j(a,this.nodeId===this.runId?"the run settled":"the asking node was closed").catch(o=>c({level:"error",event:"daemon.runs.question_cancel_failed",node_id:this.nodeId,error:o}))}}e.pi_pid===null?this.close():await this.connect()}async settlePoll(){await this.polling?.catch(()=>{}),await this.frames,await this.released}async viewAdmitted(){const e=await N(this.nodeId);return!(e?.runner==="blaxel"&&e.idleAt!==null)}async dropView(){const e=this.client;e&&(this.client=void 0,await this.frames,await this.flushDeltas(),this.discardDeltas(),this.openAssistant=!1,this.block=null,await this.writeStream(null,null),e.close())}async connect(){if(this.closed)return;if(!await this.viewAdmitted()){await this.dropView();return}if(this.client)return;const e=await Y(this.nodeId),i=await this.viewAdmitted();if(this.client||this.closed||!i){e.destroy();return}const s=new x(this.nodeId,{transport:e});this.client=s,s.on("connect",()=>s.send({type:"hello",role:"observer",client_id:y(),attends:!1}));const n=l(async r=>{if(!(this.closed||this.client!==s)){if(r.type==="message_start"&&r.message.role==="assistant"){if(this.discardDeltas(),this.openAssistant=!0,this.block=null,this.thinking="",this.output="",!await this.writeStream("run-cursor",null)){this.close();return}this.assistantStartSequence=Number((await(await d()).prepare("SELECT stream_message_seq FROM nodes WHERE node_id = ?").get(this.nodeId)).stream_message_seq)}if(r.type==="message_update"&&r.message.role==="assistant"&&this.openAssistant){const a=r.message.content;if(!Array.isArray(a))return;const o=a.at(-1);if(o&&typeof o=="object"&&"type"in o&&(o.type==="toolCall"?this.block={kind:"tool_call",name:"name"in o&&typeof o.name=="string"?o.name:""}:(o.type==="text"||o.type==="thinking")&&(this.block={kind:o.type})),!await this.writeStream(null,this.block,!0)){this.close();return}const f=a.filter(u=>u?.type==="thinking").map(u=>u.thinking).join(""),_=a.filter(u=>u?.type==="text").map(u=>u.text).join(""),k=f.startsWith(this.thinking)?f.slice(this.thinking.length):f,L=_.startsWith(this.output)?_.slice(this.output.length):_;this.thinking=f,this.output=_,this.pendingThinking+=k,this.pendingOutput+=L,(this.pendingThinking||this.pendingOutput)&&!this.flushTimer&&(this.flushTimer=setTimeout(()=>{this.flushDeltas().catch(u=>c({level:"error",event:"daemon.runs.observer_failed",node_id:this.nodeId,error:u}))},B),this.flushTimer.unref())}r.type==="message_end"&&r.message.role==="assistant"&&(await this.flushDeltas(),this.openAssistant=!1,this.block=null,await this.writeStream(null,null))}},"handleFrame");s.on("frame",r=>{this.frames=this.frames.then(()=>n(r)).catch(a=>{this.close(),c({level:"error",event:"daemon.runs.observer_failed",node_id:this.nodeId,error:a})})}),s.on("error",()=>{}),s.on("close",()=>{this.client===s&&(this.client=void 0,this.discardDeltas(),this.openAssistant=!1,this.block=null,this.released=this.released.then(async()=>{await this.writeStream(null,null)}).catch(()=>{}))}),s.connect()}async flushDeltas(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=void 0;const e=this.pendingThinking,i=this.pendingOutput;if(this.pendingThinking="",this.pendingOutput="",!this.openAssistant||!e&&!i)return;(await w(this.nodeId,this.owner,async()=>{if(await(await d()).prepare("SELECT 1 FROM run_events WHERE run_id = ? AND node_id = ? AND sequence_number >= ? AND type IN ('node.output_text.done', 'node.thinking.done', 'usage') LIMIT 1").get(this.runId,this.nodeId,this.assistantStartSequence)){this.openAssistant=!1;return}e&&await g(this.runId,this.nodeId,"node.thinking.delta",{delta:e}),i&&await g(this.runId,this.nodeId,"node.output_text.delta",{delta:i})})).held||this.close()}discardDeltas(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=void 0,this.pendingThinking="",this.pendingOutput=""}close(){if(this.closed)return;this.closed=!0,this.discardDeltas(),clearInterval(this.timer),p.delete(this.nodeId),this.released=this.released.then(async()=>{await this.writeStream(null,null),await O(h,this.nodeId,this.owner)}).then(()=>{}).catch(i=>{c({level:"error",event:"daemon.runs.observer_release_failed",node_id:this.nodeId,error:i})});const e=this.client;this.client=void 0,e?.close()}}async function Y(t){const e=await N(t);if(e===null)return new D(t,{recordsViewerFaults:!1});const i=await H(e.runner).viewerAddress(e);return i.kind==="unix"?new D(t,{recordsViewerFaults:!1}):new q(t,()=>W(i.url,i.headers))}l(Y,"viewTransport");async function ue(t){const e=await(await d()).prepare("SELECT stream_message_seq FROM node_rows WHERE node_id = ? AND pi_pid IS NOT NULL").get(t);return e?.stream_message_seq==null?null:Number(e.stream_message_seq)}l(ue,"openAssistantMessageStartSequence");async function ce(t){const e=await(await d()).prepare("SELECT stream_message_seq, stream_block FROM node_rows WHERE node_id = ? AND pi_pid IS NOT NULL").get(t);return e?.stream_message_seq==null||e.stream_block===null?null:JSON.parse(e.stream_block)}l(ce,"openAssistantBlock");async function he(){const t=[...p.values()];for(const e of t)e.close();await Promise.all(t.map(e=>e.settlePoll())),await Promise.all([...m.values()].map(e=>e.catch(()=>{})))}l(he,"closeRunObserversForTests");async function T(t){return await(await d()).prepare("SELECT 1 FROM nodes WHERE node_id = ? AND run_id = ? AND event_cursor IS NOT NULL").get(t,t)!==void 0}l(T,"runRootExists");const m=new Map;async function I(t,e){const i=m.get(t);if(i)return i;if(p.has(t))return;const s=$(t,e).finally(()=>m.delete(t));return m.set(t,s),s}l(I,"ensureRunObserver");async function $(t,e){if(!await T(e))return;const i=y();if(await F(h,t,i,E)!==void 0)try{if(t!==e){const s=await R(t);if(!await(await d()).prepare("SELECT 1 FROM run_events WHERE run_id = ? AND node_id = ? AND type = 'child.started' LIMIT 1").get(e,t)&&s&&Date.now()-Date.parse(s.created)<720*60*6e4&&!(await w(t,i,()=>g(e,t,"child.started",{child_node_id:t,kind:s.kind}))).held)return}await v.start(t,e,i)}catch(s){throw await O(h,t,i).catch(()=>{}),s}}l($,"startRunObserver");async function pe(){const t=new Date(Date.now()-2592e6).toISOString(),e=await(await d()).prepare(`SELECT n.node_id, n.run_id, n.pi_pid, COALESCE(n.outcome_revision, 1) AS revision, e.body_json
|
|
3
3
|
FROM node_rows n
|
|
4
4
|
LEFT JOIN run_events e ON n.pi_pid IS NULL AND e.run_id = n.run_id AND e.node_id = n.node_id
|
|
5
5
|
AND e.type = CASE WHEN n.node_id = n.run_id THEN 'node.settled' ELSE 'child.settled' END
|
|
6
|
-
WHERE n.run_id IS NOT NULL AND (n.pi_pid IS NOT NULL OR (n.outcome_at IS NOT NULL AND n.outcome_at > ? AND n.outcome_reason != 'parked'))`).all(
|
|
6
|
+
WHERE n.run_id IS NOT NULL AND (n.pi_pid IS NOT NULL OR (n.outcome_at IS NOT NULL AND n.outcome_at > ? AND n.outcome_reason != 'parked'))`).all(t),i=new Map;for(const n of e){const r=i.get(n.node_id)??{node_id:n.node_id,run_id:n.run_id,reported:!1};n.body_json!==null&&JSON.parse(n.body_json).outcome?.revision===n.revision&&(r.reported=!0),i.set(n.node_id,r)}const s=[...i.values()].filter(n=>!n.reported);for(const n of s)try{await I(n.node_id,n.run_id),S.delete(n.node_id)}catch(r){G(n.node_id,r)}}l(pe,"pollRunObservers");const S=new Map;function G(t,e){const i=e instanceof Error?e.message:String(e);S.get(t)!==i&&(S.set(t,i),c({level:"error",event:"daemon.runs.observer_failed",node_id:t,error:e}))}l(G,"reportObserverFailure");export{he as closeRunObserversForTests,I as ensureRunObserver,ce as openAssistantBlock,ue as openAssistantMessageStartSequence,pe as pollRunObservers};
|
|
@@ -4,7 +4,5 @@ import type { CanvasDb } from '../../core/canvas/db.js';
|
|
|
4
4
|
export declare const IMPORT_DONE_KEY = "canvas-import";
|
|
5
5
|
export declare const IMPORT_ID = "004-canvas-documents";
|
|
6
6
|
export declare function readImportRecord(db: CanvasDb): Promise<ImportReport | null>;
|
|
7
|
-
/**
|
|
8
|
-
export declare function
|
|
9
|
-
/** Run inside the caller's write transaction. Throws on any divergence from the plan. */
|
|
10
|
-
export declare function applyPlan(db: CanvasDb, plan: ImportPlan, hashes: ReadonlyMap<string, string>): Promise<void>;
|
|
7
|
+
/** Run inside the caller's write transaction; each revision's text is stored in it. Throws on any divergence from the plan. */
|
|
8
|
+
export declare function applyPlan(db: CanvasDb, plan: ImportPlan): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var x=Object.defineProperty;var
|
|
1
|
+
var x=Object.defineProperty;var c=(n,a)=>x(n,"name",{value:a,configurable:!0});import{put as N}from"../../core/graph/bodies.js";import{importDocument as O}from"../../core/graph/documents.js";import{linksIn as _}from"../../core/graph/documents.js";import{recordActedOn as M,setLinks as R}from"../../core/graph/edges.js";import{resolveName as $}from"../../core/graph/names.js";import{ensureOwner as y,nodeObject as k,ownerForGrantee as b}from"../../core/graph/objects.js";import{ensureRepo as S}from"../../core/graph/repo-sync/repos.js";import{recordWatch as T}from"../../core/graph/watches.js";import{mapAsync as A}from"../../core/async-array.js";import{personId as K}from"../../core/canvas/person.js";const v="canvas-import",j="004-canvas-documents";async function Y(n){const a=await n.prepareUncached("SELECT value FROM canvas_meta WHERE key = ?").get(v);if(a===void 0)return null;const i=JSON.parse(a.value).report;return{...i,resolutions:i.resolutions??[]}}c(Y,"readImportRecord");async function q(n,a){const i=new Map;for(const e of a.documents)for(const t of e.revisions)i.has(t.body)||i.set(t.body,await N(n,t.body));const l=new Map(a.owners.map(e=>[e.key,e])),u=new Map,w=c(async e=>{const t=u.get(e.key);if(t)return t;let o;switch(e.type){case"person":o=await b(n,K());break;case"app":o=await y(n,"app","app",`app:${e.handle}`,e.handle);break;case"profile":{const p=l.get(e.ownerKey);if(!p)throw new Error(`import: profile ${e.key} names unplanned app ${e.ownerKey}`);o=await y(n,"profile","profile",e.key.slice(8),e.handle,await w(p));break}case"repo":o=await S(n,{scheme:e.scheme,externalId:e.externalId,handleHint:e.handle},e.handle);break;case"node":o=await k(n,e.handle);break}if(e.type!=="node"&&o.name!==e.handle)throw new Error(`import: owner ${e.key} holds handle ${o.name}, planned ${e.handle}`);return u.set(e.key,o),o},"ownerRow"),I={class:"person",person:await w(l.get("person")??{key:"person",type:"person",handle:"user"})},f=new Map,m=c(async e=>{let t=f.get(e);return t||f.set(e,t=await k(n,e)),t},"node"),h=[];for(const e of a.documents){const t=await w(l.get(e.ownerKey)),o=await O(n,{owner:t,name:e.name,kind:e.kind,preview:e.preview,privacy:e.privacy,summary:e.summary,whyItExists:e.whyItExists,unlisted:e.unlisted,rules:e.rules,lintIgnore:e.lintIgnore,extensions:e.extensions,revisions:await A(e.revisions,async r=>({body_hash:i.get(r.body),author:r.authorNodeId===null?null:await m(r.authorNodeId),rationale:r.rationale,created_at:r.createdAt}))}),p=new Set(e.revisions.flatMap(r=>r.authorNodeId===null?[]:[r.authorNodeId]));h.push({doc:o,owner:t,body:e.revisions[e.revisions.length-1].body,authors:p})}for(const{doc:e,owner:t,body:o,authors:p}of h){const r=[];for(const s of _(o)){const g=s.includes("/")?[s]:[`${t.type==="node"?t.id:t.name}/${s}`,s];for(const E of g){const d=await $(n,I,E);if("object"in d){r.push({written_as:s,dst:d.object});break}if("deleted"in d){r.push({written_as:s,dst:d.deleted});break}}}await R(n,e,r);for(const s of p)await M(n,await m(s),e),await T(n,await m(s),e,"write")}await n.prepareUncached("INSERT INTO canvas_meta (key, value) VALUES (?, ?)").run(v,JSON.stringify({id:j,report:a.report}))}c(q,"applyPlan");export{v as IMPORT_DONE_KEY,j as IMPORT_ID,q as applyPlan,Y as readImportRecord};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var R=Object.defineProperty;var c=(r,n)=>R(r,"name",{value:n,configurable:!0});import{existsSync as
|
|
2
|
-
LEFT JOIN identities i ON i.object = o.id WHERE o.type IN ('person','app','repo','profile')`).all();return
|
|
1
|
+
var R=Object.defineProperty;var c=(r,n)=>R(r,"name",{value:n,configurable:!0});import{existsSync as y}from"node:fs";import{join as f}from"node:path";import{openDb as l,withCanvasWrite as u}from"../../core/canvas/db.js";import{nodeAgentDir as E,nodeRecordDir as S,onDiskMigrationMarkerPath as L}from"../../core/canvas/paths.js";import{identifyCheckout as I}from"../../core/graph/repo-sync/identity.js";import{profileSpace as k,userRoot as C}from"../../core/layout.js";import{deleteLegacyProjectCaps as _,listLegacyProjectCaps as j,readLegacyUserSnapshot as O}from"../../core/scoped-state/legacy-profiles.js";import{personIdAsync as b}from"../../core/canvas/person.js";import{userStore as A}from"../../core/scoped-state/paths.js";import{userScopeRoot as w}from"../../core/scope.js";import{LEGACY_LOCAL_PERSON as D}from"../../core/canvas/legacy-person.js";import{applyPlan as P,readImportRecord as h}from"./apply.js";import{readLegacyCorpus as v,readMarkerIds as x}from"./legacy/discover.js";import{planImport as M}from"./plan.js";const N=c(()=>({stores:[],counts:{},rewrites:[],droppedFields:[],skipped:[],resolutions:[]}),"emptyReport");async function T(){const r=w(),n=O(r)?.profiles??[],t=j(r),d=A(r).path,a=n.map(({profileId:e,manifest:i})=>{const s=i.grantee??"app:terminal",m=new Map(t.filter(o=>o.profileId===e).map(o=>[o.path,o.memory]));return{id:e,name:i.name,app:s,memory:k(s,e).dir,projects:i.projects.map(o=>o.path),raw:{projects:i.projects.map(o=>m.has(o.path)?{path:o.path,memory:m.get(o.path)}:{path:o.path})},manifestPath:`${d}#${e}`}}),p=await(await l()).prepareUncached("SELECT node_id, cwd, grantee FROM node_rows ORDER BY created").all(),g=p.map(e=>{const i=e.grantee===D?"app:terminal":e.grantee,s=i?.startsWith("app:")?E(e.node_id,i):null,m=s!==null&&(y(f(s,"context"))||y(f(s,"reports")))?s:S(e.node_id);return{id:e.node_id,dir:m}});return{roots:{userMemory:f(C(),"memory"),profiles:a,nodeCwds:[...new Set(p.map(e=>e.cwd))],nodes:g},stored:n}}c(T,"legacyRoots");async function F(){const{roots:r,stored:n}=await T(),t=v(r),d=await(await l()).prepareUncached(`SELECT o.type, o.name AS handle, i.external_id AS externalId FROM objects o
|
|
2
|
+
LEFT JOIN identities i ON i.object = o.id WHERE o.type IN ('person','app','repo','profile')`).all();return M(t,{roots:r,markerIds:x(L()),repoIdentity:I,existingOwners:d,storedProfiles:n.map(a=>({id:a.profileId,deliveryLimits:{...a.manifest.delivery_limits??{}}}))})}c(F,"plan");async function rr(){return await h(await l())!==null}c(rr,"canvasImportDone");async function er(r){const n=await h(await l());if(n!==null)return{report:r.dryRun?n:N(),blockers:[],dryRun:r.dryRun,pending:!1};const t=await F();if(r.dryRun||t.blockers.length>0)return{report:t.report,blockers:t.blockers,dryRun:r.dryRun,pending:!0};const d=await b();return await u(async a=>{for(const p of t.profileLimits)if((await a.prepare("UPDATE profiles SET delivery_limits_json = ? WHERE id = ? AND person = ?").run(JSON.stringify(p.deliveryLimits),p.profileId,d)).changes!==1)throw new Error(`no stored profile ${p.profileId}`)}),_(w()),await u(async a=>await P(a,t)),{report:t.report,blockers:[],dryRun:!1,pending:!1}}c(er,"runCanvasImport");export{rr as canvasImportDone,er as runCanvasImport};
|
package/dist/shared/env.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare function launchSnapshotFile(dir: string): string | undefined;
|
|
|
11
11
|
export declare function sandboxCliNodeId(): string | undefined;
|
|
12
12
|
/** A Linux app command uses its mounted launch snapshot, not host user stores. */
|
|
13
13
|
export declare function isSandboxedNode(): boolean;
|
|
14
|
+
/** True when this CLI reaches `/v1` through its broker's CLI relay to a remote control plane: the broker exports `CRTR_API_URL` (an
|
|
15
|
+
* http(s) URL, the fleet launcher's) and `CRTR_API_SOCKET` (the relay it serves). It chooses only where this process gets provider command
|
|
16
|
+
* descriptions (`GET /v1/providers/tools` through that relay); the relay's node token stays the authority. It is not `isSandboxedNode()`,
|
|
17
|
+
* which gates owner-only commands and launch-snapshot reads on a Linux launcher mount. */
|
|
18
|
+
export declare function providerProjectionOverBrokerRelay(): boolean;
|
|
14
19
|
/** The app that owns the current node, supplied in its broker launch identity. */
|
|
15
20
|
export declare function envGrantee(): string | undefined;
|
|
16
21
|
/** Set to '1' by `nodeEnv` for an app-started run's brokers, which admit inbox
|
package/dist/shared/env.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
2
|
-
`).map(o=>o.split(" ")[4])),t=
|
|
1
|
+
var p=Object.defineProperty;var e=(n,r)=>p(n,"name",{value:r,configurable:!0});import{lstatSync as T,readFileSync as c,readdirSync as f}from"node:fs";import{join as i}from"node:path";import{covers as _}from"@north-light/identity";function W(){return process.env.CRTR_NODE_ID}e(W,"envNodeId");function d(n){for(const r of["broker-launch.json","cron-launch.json"]){const t=i(n,r);if(T(t,{throwIfNoEntry:!1})?.isFile())return t}}e(d,"launchSnapshotFile");function E(){if(process.platform==="linux")try{const n="/run/crtr/nodes",r=new Set(c("/proc/self/mountinfo","utf8").split(`
|
|
2
|
+
`).map(o=>o.split(" ")[4])),t=f(n,{withFileTypes:!0}).filter(o=>o.isDirectory()&&/^[a-zA-Z0-9][a-zA-Z0-9-]{0,127}$/.test(o.name)&&r.has(i(n,o.name))&&d(i(n,o.name))!==void 0);return t.length===1?t[0].name:void 0}catch{return}}e(E,"sandboxCliNodeId");function F(){return E()!==void 0}e(F,"isSandboxedNode");function h(){return/^https?:\/\//.test(process.env.CRTR_API_URL??"")&&(process.env.CRTR_API_SOCKET??"")!==""}e(h,"providerProjectionOverBrokerRelay");function H(){return process.env.CRTR_GRANTEE}e(H,"envGrantee");const v="CRTR_INBOX_BETWEEN_TURNS";function K(){return process.env[v]==="1"}e(K,"envInboxBetweenTurns");const C="CRTR_SCOPES_FILE";function k(){const n=process.env[C];if(n!==void 0&&n!==""){const t=JSON.parse(c(n,"utf8"));if(!Array.isArray(t)||t.some(o=>typeof o!="string"))throw new Error(`invalid scopes file ${n}`);return t}const r=process.env.CRTR_SCOPES;return r===void 0?null:r===""?[]:r.split(",")}e(k,"envScopes");function y(n,r){return n==null?!0:a(n,r)}e(y,"scopeAllowed");function a(n,r){return n.includes(r)?(_(r,r),!0):n.some(t=>_(t,r))}e(a,"coveredByAny");function G(){return process.env.CRTR_EXECUTION_ID}e(G,"envExecutionId");function b(){return process.env.CRTR_PROFILE_ID}e(b,"envProfileId");function w(){return process.env.CRTR_NODE_CWD}e(w,"envNodeCwd");function g(){return process.env.CRTR_MODEL_INTENT}e(g,"envModelIntent");function V(){return process.env.CRTR_MODEL_EXACT==="1"}e(V,"envModelExact");function X(){return process.env.CRTR_HOME}e(X,"envHomeOverride");function j(){return process.env.CRTR_RUNTIME_HOME}e(j,"envRuntimeHomeOverride");function s(n,r){if(n===void 0)return r;const t=Number(n);return Number.isFinite(t)&&t>0?t:r}e(s,"parsePositiveMs");const A=5*6e4;function Y(){return s(process.env.CRTR_STREAM_WATCHDOG_MS,A)}e(Y,"envStreamWatchdogMs");const S=800;function $(){return s(process.env.CRTR_WATCHER_TICK_MS,S)}e($,"envWatcherTickMs");const M=6e4;function z(){return s(process.env.CRTR_WATCHER_BACKSTOP_MS,M)}e(z,"envWatcherBackstopMs");const N=1e3;function Z(){return s(process.env.CRTR_WATCHER_DEBOUNCE_MS,N)}e(Z,"envWatcherDebounceMs");const x=6e4;function J(){return s(process.env.CRTR_RECAP_IDLE_MS,x)}e(J,"envRecapIdleMs");function q(){const n=process.env.CRTR_RECAP_MODEL;return n!==void 0&&n.trim()!==""?n.trim():void 0}e(q,"envRecapModelOverride");const D=300*1e3;function Q(){return s(process.env.CRTR_BASH_VALVE_MS,D)}e(Q,"envBashValveMs");const O=60*1e3;function ee(){return s(process.env.CRTR_BASH_AUTO_BG_DEADLINE_MS,O)}e(ee,"envBashAutoBgDeadlineMs");function ne(){const n=process.env.CRTR_PIDFILE;return n!==void 0&&n!==""?n:void 0}e(ne,"envPidfileOverride");const I="@earendil-works/pi-coding-agent";function re(){return process.env.CRTR_BROKER_ENGINE??I}e(re,"envBrokerEngine");function te(){return process.env.CRTR_PI_BINARY}e(te,"envPiBinaryOverride");function oe(){return process.env.CRTR_NO_DAEMON_AUTOSTART==="1"}e(oe,"envNoDaemonAutostart");function se(){const n=process.env.CRTR_DOCUMENT_PORT;if(n===void 0||!/^\d+$/.test(n))return;const r=Number(n);return r<=65535?r:void 0}e(se,"envDocumentPort");function ue(){return process.env.CRTRD_TCP}e(ue,"envCrtrdTcp");function ie(){const n=process.env.CRTRD_TOKEN;return n!==void 0&&n!==""?n:void 0}e(ie,"envCrtrdToken");function ce(){return process.env.CRTR_NO_EXPORTS==="1"}e(ce,"envNoExports");function _e(){return process.env.CRTR_DEBUG==="1"}e(_e,"envDebug");function R(n){if(n===void 0||n==="")return;const r=Number(n);return Number.isSafeInteger(r)&&r>=1?r:void 0}e(R,"parsePositiveInteger");function Re(){return R(process.env.CRTR_MAX_LIVE_BROKERS)}e(Re,"envMaxLiveBrokers");function pe(){return R(process.env.CRTR_WARN_LIVE_BROKERS)}e(pe,"envWarnLiveBrokers");function u(n){if(n===void 0)return;const r=Number(n);return Number.isFinite(r)&&r>0?r:void 0}e(u,"parsePositiveMsNoDefault");function Te(){return u(process.env.CRTR_TEST_NODE_SOCKET_WINDOW_MS)}e(Te,"envTestNodeSocketWindowMs");function fe(){return u(process.env.CRTR_TEST_UNATTENDED_PARK_MS)}e(fe,"envTestUnattendedParkMs");function de(){return u(process.env.CRTR_UNATTENDED_PARK_MS)}e(de,"envUnattendedParkMs");function Ee(){return u(process.env.CRTR_BASH_SILENCE_MS)??15*6e4}e(Ee,"envBashSilenceMs");function l(){return u(process.env.CRTR_TEST_PARK_SUMMARY_GRACE_MS)}e(l,"envTestParkSummaryGraceMs");const m=5*6e4;function ve(){return l()??m}e(ve,"parkSummaryGraceMs");export{v as INBOX_BETWEEN_TURNS_ENV,C as SCOPES_FILE_ENV,a as coveredByAny,ee as envBashAutoBgDeadlineMs,Ee as envBashSilenceMs,Q as envBashValveMs,re as envBrokerEngine,ue as envCrtrdTcp,ie as envCrtrdToken,_e as envDebug,se as envDocumentPort,G as envExecutionId,H as envGrantee,X as envHomeOverride,K as envInboxBetweenTurns,Re as envMaxLiveBrokers,V as envModelExact,g as envModelIntent,oe as envNoDaemonAutostart,ce as envNoExports,w as envNodeCwd,W as envNodeId,te as envPiBinaryOverride,ne as envPidfileOverride,b as envProfileId,J as envRecapIdleMs,q as envRecapModelOverride,j as envRuntimeHomeOverride,k as envScopes,Y as envStreamWatchdogMs,Te as envTestNodeSocketWindowMs,l as envTestParkSummaryGraceMs,fe as envTestUnattendedParkMs,de as envUnattendedParkMs,pe as envWarnLiveBrokers,z as envWatcherBackstopMs,Z as envWatcherDebounceMs,$ as envWatcherTickMs,F as isSandboxedNode,d as launchSnapshotFile,ve as parkSummaryGraceMs,h as providerProjectionOverBrokerRelay,E as sandboxCliNodeId,y as scopeAllowed};
|
|
@@ -19,7 +19,7 @@ Changes to `@north-light/sdk` that can change what an existing app sees. Newest
|
|
|
19
19
|
|
|
20
20
|
On a cloud role, `provider.tools` now reports a granted provider as `available` once its bundle is installed in the deployment's shared plugin directory. It no longer answers `500` when a person has no materialized bundle; a granted provider still being installed reports `installing` or `install_failed`. Providers without that person's grant remain hidden. The Mac's plugin settings and provider tools behavior are unchanged.
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## 0.3.579
|
|
23
23
|
|
|
24
24
|
A turn that ends because every model route is rate-limited for longer than a turn waits now reports `error.code: 'rate_limited'` with `error.retry_at` (ISO time the limit is expected to lift), on `turn.completed` and `runs.get().last_turn_error`. It was `model_error` with the time only inside `message`. The run stays `idle` and usable, as before. An app that matches `error.code` exhaustively should handle the new value; one that treats any other code as a model error needs no change.
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.580",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
},
|
|
146
146
|
"license": "UNLICENSED",
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@north-light/identity": "0.3.
|
|
148
|
+
"@north-light/identity": "0.3.580",
|
|
149
149
|
"@earendil-works/chord": "1.1.0",
|
|
150
150
|
"@earendil-works/pi-agent-core": "1.1.0",
|
|
151
151
|
"@earendil-works/pi-ai": "1.1.0",
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.580",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.580",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.580",
|
|
32
32
|
"cron-parser": "^5.6.0",
|
|
33
33
|
"esbuild": "^0.27.7",
|
|
34
34
|
"jose": "^6.2.12",
|
|
@@ -11956,17 +11956,17 @@
|
|
|
11956
11956
|
},
|
|
11957
11957
|
"packages/crouter-api": {
|
|
11958
11958
|
"name": "@north-light/api",
|
|
11959
|
-
"version": "0.3.
|
|
11959
|
+
"version": "0.3.580",
|
|
11960
11960
|
"license": "UNLICENSED"
|
|
11961
11961
|
},
|
|
11962
11962
|
"packages/crouter-env-docker": {
|
|
11963
11963
|
"name": "@north-light/env-docker",
|
|
11964
|
-
"version": "0.3.
|
|
11964
|
+
"version": "0.3.580",
|
|
11965
11965
|
"license": "UNLICENSED"
|
|
11966
11966
|
},
|
|
11967
11967
|
"packages/crouter-identity": {
|
|
11968
11968
|
"name": "@north-light/identity",
|
|
11969
|
-
"version": "0.3.
|
|
11969
|
+
"version": "0.3.580",
|
|
11970
11970
|
"license": "UNLICENSED",
|
|
11971
11971
|
"dependencies": {
|
|
11972
11972
|
"jose": "^6.2.1"
|
|
@@ -11974,21 +11974,21 @@
|
|
|
11974
11974
|
},
|
|
11975
11975
|
"packages/crouter-plugin": {
|
|
11976
11976
|
"name": "@north-light/plugin",
|
|
11977
|
-
"version": "0.3.
|
|
11977
|
+
"version": "0.3.580",
|
|
11978
11978
|
"license": "UNLICENSED",
|
|
11979
11979
|
"dependencies": {
|
|
11980
|
-
"@north-light/api": "0.3.
|
|
11981
|
-
"@north-light/identity": "0.3.
|
|
11980
|
+
"@north-light/api": "0.3.580",
|
|
11981
|
+
"@north-light/identity": "0.3.580"
|
|
11982
11982
|
}
|
|
11983
11983
|
},
|
|
11984
11984
|
"packages/crouter-sdk": {
|
|
11985
11985
|
"name": "@north-light/sdk",
|
|
11986
|
-
"version": "0.3.
|
|
11986
|
+
"version": "0.3.580",
|
|
11987
11987
|
"license": "UNLICENSED",
|
|
11988
11988
|
"dependencies": {
|
|
11989
|
-
"@north-light/api": "0.3.
|
|
11990
|
-
"@north-light/identity": "0.3.
|
|
11991
|
-
"@north-light/plugin": "0.3.
|
|
11989
|
+
"@north-light/api": "0.3.580",
|
|
11990
|
+
"@north-light/identity": "0.3.580",
|
|
11991
|
+
"@north-light/plugin": "0.3.580",
|
|
11992
11992
|
"jose": "^6.2.1"
|
|
11993
11993
|
},
|
|
11994
11994
|
"bin": {
|