@north-light/cli 0.3.766 → 0.3.768
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/clients/attach/viewer.js +222 -222
- package/dist/daemon/api/handlers/execution-start.js +2 -2
- package/dist/daemon/reconcilers/machine-offline.js +4 -4
- package/dist/daemon/reconcilers/row-claim.d.ts +0 -1
- package/dist/daemon/reconcilers/row-claim.js +3 -3
- package/package.json +3 -3
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
2
|
-
WHERE person = ? AND enabled = 1 AND owner_key = ? ORDER BY name`).all(n,t)).map(i=>[i.name,i])),o=[],
|
|
1
|
+
var p=Object.defineProperty;var a=(n,t)=>p(n,"name",{value:t,configurable:!0});import{ApiError as r}from"../../../api/errors.js";import{getNode as _}from"../../../core/canvas/canvas.js";import{openDb as u}from"../../../core/canvas/db.js";import{blobStore as m}from"../../../core/blobs/index.js";import{presignGet as w,releaseSignerFromEnv as f}from"../../../core/secrets/blaxel-launch.js";import{grantedProviderIds as h,isProviderBundleRow as b}from"../../../core/grants/mirror.js";import{profileMetadataEnv as E}from"../../../core/runtime/spawn-env.js";import{localEnvironmentSecrets as g}from"../../../core/secrets/environment-owner.js";import{environmentOfNode as k,recipeOf as x}from"../environment-of.js";import{mintInstallationToken as y}from"./git-credential.js";async function v(n,t){const e=await u(),s=new Map((await e.prepare(`SELECT owner_key, name, version, source_marketplace, source_path FROM scope_plugins
|
|
2
|
+
WHERE person = ? AND enabled = 1 AND owner_key = ? ORDER BY name`).all(n,t)).map(i=>[i.name,i])),o=[],c=await h(n);for(const i of s.values()){if(b(i,c))continue;if(i.source_path!==null){o.push({name:i.name,source:{path:i.source_path},version:i.version});continue}if(i.source_marketplace===null)throw new r(500,"plugin_source_missing",`plugin ${i.name} names neither a marketplace nor a path`);const d=await e.prepare("SELECT url, ref FROM scope_marketplaces WHERE person = ? AND owner_key = ? AND name = ?").get(n,i.owner_key,i.source_marketplace);o.push({name:i.name,source:{marketplace:{url:d?.url??null,ref:d?.ref??null}},version:i.version})}return o}a(v,"plugins");const R=900;async function S(n){const e=await(await u()).prepare("SELECT blob_key, unpacked_at FROM import_node_files WHERE node = ?").get(n);if(e===void 0)return null;if(!(await(await m()).list(e.blob_key)).includes(e.blob_key)){if(e.unpacked_at!==null)return null;throw new r(500,"import_files_missing",`the imported archive ${e.blob_key} of ${n} is gone and no sandbox unpacked it`)}return{url:w(f(),e.blob_key,R),path_map:[]}}a(S,"importFiles");async function T(n){const{principal:t}=n;if(t.class!=="broker")throw new r(403,"broker_only","this route is called with a node token");const e=n.params.execution_id??"",o=await(await u()).prepare("SELECT node_id, state FROM executions WHERE execution_id = ?").get(e);if(o===void 0||o.node_id!==t.node)throw new r(403,"not_your_execution",`execution ${e} is not an execution of this node`);if(o.state!=="launching"&&o.state!=="running")throw new r(403,"execution_ended",`execution ${e} is ${o.state}`);return t.node}a(T,"ownedExecution");async function I(n){const t=await T(n);return await(await u()).prepare("UPDATE import_node_files SET unpacked_at = ? WHERE node = ? AND unpacked_at IS NULL").run(new Date().toISOString(),t),{status:200,body:{}}}a(I,"handleImportUnpacked");async function O(n){const t=await u(),e=await _(n.nodeId);if(e===null)throw new r(404,"node_not_found",`no node ${n.nodeId}`);const s=await t.prepare("SELECT plugins_revision FROM person_settings WHERE person = ?").get(n.sub),o=await k(e.profile_id??null),c=await x(o),i=c?.repositories.map(l=>l.github_full_name)??[],d=i.length===0?null:(await y(n.sub,i)).author;return{launch:JSON.parse(n.launchJson),node:{id:e.node_id,app:n.app,cwd:e.cwd,profile:e.profile_id??null,isolated:e.isolated===!0,environment_id:o},recipe:c,git_identity:d,plugins_revision:s===void 0?0:Number(s.plugins_revision),plugins:await v(n.sub,n.app),import_node_files:await S(e.node_id),...n.runner==="machine"?{machine_env:{...E(e.profile_id??null),...await g(e.profile_id??null,n.app)}}:{}}}a(O,"buildStartBundle");async function N(n){const{principal:t}=n;if(t.class!=="broker")throw new r(403,"broker_only","the start bundle is read with a node token");const e=n.params.execution_id??"",o=await(await u()).prepare("SELECT node_id, state, launch_json, runner FROM executions WHERE execution_id = ?").get(e);if(o===void 0||o.node_id!==t.node)throw new r(403,"not_your_execution",`execution ${e} is not an execution of this node`);if(o.state!=="launching"&&o.state!=="running")throw new r(403,"execution_ended",`execution ${e} is ${o.state}`);if(o.launch_json===null)throw new r(409,"launch_missing",`execution ${e} carries no launch recipe`);return{status:200,body:await O({nodeId:t.node,app:t.app,sub:t.sub,launchJson:o.launch_json,runner:o.runner})}}a(N,"handleStart");const B=[{method:"GET",pattern:"/v1/executions/:execution_id/start",handler:N},{method:"POST",pattern:"/v1/executions/:execution_id/import-unpacked",handler:I}];export{O as buildStartBundle,B as executionStartRoutes,v as plugins};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var _=Object.defineProperty;var d=(o,e)=>_(o,"name",{value:e,configurable:!0});import{openDb as c}from"../../core/canvas/db.js";import{isCloudRole as N}from"../../core/canvas/person.js";import{subscribersOf as p}from"../../core/canvas/tree.js";import{enqueueNodeMail as m}from"../../core/feed/messages.js";import{operationIdContext as O}from"../../core/events/operation-id.js";import{emitEvent as
|
|
1
|
+
var _=Object.defineProperty;var d=(o,e)=>_(o,"name",{value:e,configurable:!0});import{openDb as c}from"../../core/canvas/db.js";import{isCloudRole as N}from"../../core/canvas/person.js";import{subscribersOf as p}from"../../core/canvas/tree.js";import{enqueueNodeMail as m}from"../../core/feed/messages.js";import{operationIdContext as O}from"../../core/events/operation-id.js";import{emitEvent as u}from"../../core/events/emit.js";const w=5*6e4;async function E(o){const e=await c(),a=new Map,t=d((n,s)=>{n!==null&&a.set(n,(a.get(n)??new Set).add(s))},"add"),i="JOIN profiles p ON p.id = n.profile_id WHERE p.environment_id = ?",r=await e.prepare(`SELECT DISTINCT x.node_id FROM executions x JOIN nodes n ON n.node_id = x.node_id ${i}
|
|
2
2
|
AND x.runner = 'machine' AND x.state IN ('launching', 'running')`).all(o);for(const{node_id:n}of r)for(const s of await p(n))t(s.node_id,`its report ${n} runs on it`);const l=await e.prepare(`SELECT DISTINCT m.sender_node_id, d.destination_id FROM deliveries d JOIN messages m ON m.message_id = d.message_id
|
|
3
3
|
JOIN nodes n ON n.node_id = d.destination_id ${i}
|
|
4
|
-
AND d.state IN ('pending', 'handed_off') AND d.canceled_at IS NULL AND m.sender_node_id IS NOT NULL`).all(o);for(const n of l)t(n.sender_node_id,`its message to ${n.destination_id} is waiting for delivery`);const f=await e.prepare(`SELECT c.created_by, c.name FROM crons c JOIN profiles p ON p.id = c.profile
|
|
5
|
-
WHERE p.environment_id = ? AND c.run_state = 'running' AND c.run_execution_id IS NOT NULL AND c.created_by IS NOT NULL`).all(o);for(const n of f)t(n.created_by,`its cron ${n.name} has a run waiting to start on it`);return new Map([...a].map(([n,s])=>[n,[...s]]))}d(
|
|
4
|
+
AND n.status IN ('active', 'idle') AND d.state IN ('pending', 'handed_off') AND d.canceled_at IS NULL AND m.sender_node_id IS NOT NULL`).all(o);for(const n of l)t(n.sender_node_id,`its message to ${n.destination_id} is waiting for delivery`);const f=await e.prepare(`SELECT c.created_by, c.name FROM crons c JOIN profiles p ON p.id = c.profile
|
|
5
|
+
WHERE p.environment_id = ? AND c.run_state = 'running' AND c.run_execution_id IS NOT NULL AND c.created_by IS NOT NULL`).all(o);for(const n of f)t(n.created_by,`its cron ${n.name} has a run waiting to start on it`);return new Map([...a].map(([n,s])=>[n,[...s]]))}d(E,"waitersOn");class T{static{d(this,"MachineOfflineReconciler")}async run(e){if(!N())return;const t=await(await c()).prepare(`SELECT e.object, e.last_seen_at, o.name FROM environments e JOIN objects o ON o.id = e.object
|
|
6
6
|
WHERE e.kind = 'machine' AND e.last_seen_at < ?
|
|
7
|
-
AND NOT EXISTS (SELECT 1 FROM machine_links l WHERE l.environment = e.object AND l.lease_expires_at > ?)`).all(new Date(e-
|
|
7
|
+
AND NOT EXISTS (SELECT 1 FROM machine_links l WHERE l.environment = e.object AND l.lease_expires_at > ?)`).all(new Date(e-w).toISOString(),new Date(e).toISOString());for(const i of t)try{await O.fresh(()=>this.notify(i))}catch(r){u({level:"warn",event:"machine.offline_notice_failed",fields:{environment:i.object},error:r})}}async notify(e){const a=await c();for(const[t,i]of await E(e.object))await a.prepare("SELECT 1 AS live FROM nodes WHERE node_id = ? AND status IN ('active', 'idle')").get(t)!==void 0&&await m(t,{kind:"update",label:"machine offline",urgency:"normal",wake:1,bodyJson:{body:`The Mac ${e.name??e.object} has been offline since ${e.last_seen_at}; ${i.join("; ")}. Nothing was stopped: everything resumes when it reconnects.`},idempotencyKey:`machine-offline:${e.object}:${e.last_seen_at}:${t}`})}}export{w as MACHINE_OFFLINE_NOTICE_MS,T as MachineOfflineReconciler};
|
|
@@ -3,7 +3,6 @@ declare const CLAIMABLE: {
|
|
|
3
3
|
readonly nodes: "node_id";
|
|
4
4
|
readonly structured_requests: "request_id";
|
|
5
5
|
readonly human_requests: "request_id";
|
|
6
|
-
readonly import_runs: "run_id";
|
|
7
6
|
};
|
|
8
7
|
export type ClaimableTable = keyof typeof CLAIMABLE;
|
|
9
8
|
export declare class ClaimLostError extends Error {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var R=Object.defineProperty;var i=(e,r)=>R(e,"name",{value:r,configurable:!0});import{randomUUID as L}from"node:crypto";import{openDb as S}from"../../core/canvas/db.js";const N={nodes:"node_id",structured_requests:"request_id",human_requests:"request_id"
|
|
2
|
-
(SELECT ${t} FROM ${e} WHERE ${t} = ? AND (claimed_by IS NULL OR lease_expires_at IS NULL OR lease_expires_at <= ?) FOR NO KEY UPDATE${
|
|
1
|
+
var R=Object.defineProperty;var i=(e,r)=>R(e,"name",{value:r,configurable:!0});import{randomUUID as L}from"node:crypto";import{openDb as S}from"../../core/canvas/db.js";const N={nodes:"node_id",structured_requests:"request_id",human_requests:"request_id"};class D extends Error{static{i(this,"ClaimLostError")}constructor(r,a){super(`row claim lost: ${r} ${a} is no longer held by this process`)}}async function y(e,r,a,d,p={}){const t=N[e],n=L(),E=await S(),m=new Date().toISOString();if((await E.prepare(`UPDATE ${e} SET claimed_by = ?, lease_expires_at = ? WHERE ${t} IN
|
|
2
|
+
(SELECT ${t} FROM ${e} WHERE ${t} = ? AND (claimed_by IS NULL OR lease_expires_at IS NULL OR lease_expires_at <= ?) FOR NO KEY UPDATE${p.waitForLock===!0?"":" SKIP LOCKED"})`).run(n,new Date(Date.now()+a).toISOString(),r,m)).changes!==1)return!1;let s=!1,c=!1;const A=i(async()=>{const o=await E.prepare(`WITH r AS (SELECT ${t}, claimed_by, lease_expires_at FROM ${e} WHERE ${t} = ? FOR NO KEY UPDATE SKIP LOCKED),
|
|
3
3
|
u AS (UPDATE ${e} t SET lease_expires_at = ? FROM r WHERE t.${t} = r.${t} AND r.claimed_by = ? AND r.lease_expires_at > ? RETURNING 1)
|
|
4
|
-
SELECT (SELECT count(*) FROM r) AS seen, (SELECT count(*) FROM u) AS renewed`).get(r,new Date(Date.now()+
|
|
4
|
+
SELECT (SELECT count(*) FROM r) AS seen, (SELECT count(*) FROM u) AS renewed`).get(r,new Date(Date.now()+a).toISOString(),n,new Date().toISOString());Number(o.seen)===1&&Number(o.renewed)!==1&&(s=!0)},"renewOnce"),w=setInterval(()=>{c||(c=!0,A().catch(()=>{s=!0}).finally(()=>{c=!1}))},Math.max(1,Math.floor(a/3)));w.unref();const O={async assertOwned(o){if(s)throw new D(e,r);const l=await S(),_=new Date().toISOString(),u=o?.extendLeaseMs;if((u===void 0?await l.prepare(`SELECT 1 AS held FROM ${e} WHERE ${t} = ? AND claimed_by = ? AND lease_expires_at > ? FOR UPDATE`).get(r,n,_):await l.prepare(`UPDATE ${e} SET lease_expires_at = ? WHERE ${t} = ? AND claimed_by = ? AND lease_expires_at > ? RETURNING 1 AS held`).get(new Date(Date.now()+u).toISOString(),r,n,_))===void 0)throw s=!0,new D(e,r)}};try{await d(O)}finally{clearInterval(w),await E.prepare(`UPDATE ${e} SET claimed_by = NULL, lease_expires_at = NULL WHERE ${t} = ? AND claimed_by = ?`).run(r,n)}return!0}i(y,"withRowClaim");export{D as ClaimLostError,y as withRowClaim};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.768",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
},
|
|
158
158
|
"license": "UNLICENSED",
|
|
159
159
|
"dependencies": {
|
|
160
|
-
"@north-light/identity": "0.3.
|
|
161
|
-
"@north-light/plugin": "0.3.
|
|
160
|
+
"@north-light/identity": "0.3.768",
|
|
161
|
+
"@north-light/plugin": "0.3.768",
|
|
162
162
|
"@earendil-works/chord": "1.5.2",
|
|
163
163
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
164
164
|
"@earendil-works/pi-ai": "1.5.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.768",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.768",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@north-light/api": "0.3.
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
30
|
+
"@north-light/api": "0.3.768",
|
|
31
|
+
"@north-light/identity": "0.3.768"
|
|
32
32
|
},
|
|
33
33
|
"license": "UNLICENSED",
|
|
34
34
|
"publishConfig": {
|
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.768",
|
|
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.768",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,8 +28,8 @@
|
|
|
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.
|
|
32
|
-
"@north-light/plugin": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.768",
|
|
32
|
+
"@north-light/plugin": "0.3.768",
|
|
33
33
|
"cron-parser": "^5.6.0",
|
|
34
34
|
"esbuild": "0.28.2",
|
|
35
35
|
"jose": "^6.2.12",
|
|
@@ -11902,17 +11902,17 @@
|
|
|
11902
11902
|
},
|
|
11903
11903
|
"packages/crouter-api": {
|
|
11904
11904
|
"name": "@north-light/api",
|
|
11905
|
-
"version": "0.3.
|
|
11905
|
+
"version": "0.3.768",
|
|
11906
11906
|
"license": "UNLICENSED"
|
|
11907
11907
|
},
|
|
11908
11908
|
"packages/crouter-env-docker": {
|
|
11909
11909
|
"name": "@north-light/env-docker",
|
|
11910
|
-
"version": "0.3.
|
|
11910
|
+
"version": "0.3.768",
|
|
11911
11911
|
"license": "UNLICENSED"
|
|
11912
11912
|
},
|
|
11913
11913
|
"packages/crouter-identity": {
|
|
11914
11914
|
"name": "@north-light/identity",
|
|
11915
|
-
"version": "0.3.
|
|
11915
|
+
"version": "0.3.768",
|
|
11916
11916
|
"license": "UNLICENSED",
|
|
11917
11917
|
"dependencies": {
|
|
11918
11918
|
"jose": "^6.2.1"
|
|
@@ -11920,21 +11920,21 @@
|
|
|
11920
11920
|
},
|
|
11921
11921
|
"packages/crouter-plugin": {
|
|
11922
11922
|
"name": "@north-light/plugin",
|
|
11923
|
-
"version": "0.3.
|
|
11923
|
+
"version": "0.3.768",
|
|
11924
11924
|
"license": "UNLICENSED",
|
|
11925
11925
|
"dependencies": {
|
|
11926
|
-
"@north-light/api": "0.3.
|
|
11927
|
-
"@north-light/identity": "0.3.
|
|
11926
|
+
"@north-light/api": "0.3.768",
|
|
11927
|
+
"@north-light/identity": "0.3.768"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.768",
|
|
11933
11933
|
"license": "UNLICENSED",
|
|
11934
11934
|
"dependencies": {
|
|
11935
|
-
"@north-light/api": "0.3.
|
|
11936
|
-
"@north-light/identity": "0.3.
|
|
11937
|
-
"@north-light/plugin": "0.3.
|
|
11935
|
+
"@north-light/api": "0.3.768",
|
|
11936
|
+
"@north-light/identity": "0.3.768",
|
|
11937
|
+
"@north-light/plugin": "0.3.768",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|