@north-light/cli 0.3.743 → 0.3.744

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,4 +1,4 @@
1
- var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});import{openDb as r,withCanvasWrite as u}from"./db.js";import{getById as N,nodeObject as w}from"../graph/objects.js";import{recordWatch as b,unwatch as I,configFromJson as E,configToJson as D}from"../graph/watches.js";import{publish as T}from"../graph/events.js";import{DEFAULT_LISTEN as v}from"../graph/types.js";const R=["spawn","job-start","ask"],S="('spawn','job-start','ask')",j=[{threshold:3,delivery:"next-turn"}];function A(o){const t=o.find(e=>e.threshold<=7);return t!==void 0&&t.delivery!=="next-turn"}i(A,"wakesAtSeven");async function d(o,t,...e){const a=await o.prepareUncached(`SELECT wo.id AS from_id, oo.id AS to_id, ws.config_json, ws.created_at,
1
+ var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});import{openDb as r,withCanvasWrite as u}from"./db.js";import{getById as N,nodeObject as w}from"../graph/objects.js";import{recordWatch as I,unwatch as b,configFromJson as E,configToJson as T}from"../graph/watches.js";import{publish as D}from"../graph/events.js";import{DEFAULT_LISTEN as v}from"../graph/types.js";const R=["spawn","job-start","ask"],S="('spawn','job-start','ask')",j=[{threshold:3,delivery:"next-turn"}];function h(o){const t=o.find(n=>n.threshold<=7);return t!==void 0&&t.delivery!=="next-turn"}i(h,"wakesAtSeven");async function d(o,t,...n){const a=await o.prepareUncached(`SELECT wo.id AS from_id, oo.id AS to_id, ws.config_json, ws.created_at,
2
2
  wo.listen_json, wn.status AS from_status, onode.status AS to_status
3
3
  FROM watches w
4
4
  JOIN objects wo ON wo.id = w.watcher AND wo.type = 'node'
@@ -7,13 +7,13 @@ var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});i
7
7
  JOIN nodes wn ON wn.node_id = wo.id
8
8
  JOIN nodes onode ON onode.node_id = oo.id
9
9
  WHERE w.in_tree = 1 ${t}
10
- ORDER BY ws.created_at, ws.seq`).all(...e),s=new Map;for(const n of a){const c=n.config_json,f=n.listen_json,_=c!=null?E(c):f!=null?E(f):v,p=`${n.from_id}\0${n.to_id}`,l=s.get(p);if(l){l.active||=A(_);continue}s.set(p,{from_id:n.from_id,to_id:n.to_id,active:A(_),created:n.created_at,from_status:n.from_status??null,to_status:n.to_status??null})}return[...s.values()]}i(d,"treeEdges");async function F(o=null){const t=o===null?null:[...o];return(t===null?await d(await r(),""):await d(await r(),"AND wo.id = ANY(?::text[]) AND oo.id = ANY(?::text[])",t,t)).map(({from_id:a,to_id:s,active:n,created:c})=>({from_id:a,to_id:s,active:n,created:c}))}i(F,"rosterEdges");async function W(o,t,e=!0){await u(async a=>{const s=await w(a,o),n=await w(a,t);await b(a,s,n,"ask"),await x(o,t,e),await T(a,{event:"watched",object:n,actor:s,attrs:{}})})}i(W,"subscribe");async function M(o,t){await u(async e=>{const a=await w(e,o),s=await w(e,t);for(const n of R)await I(e,a,s,{startedBy:n})})}i(M,"unsubscribe");async function x(o,t,e){await u(async a=>{await a.prepareUncached(`UPDATE watch_subscriptions SET config_json = ?
10
+ ORDER BY ws.created_at, ws.seq`).all(...n),s=new Map;for(const e of a){const c=e.config_json,f=e.listen_json,_=c!=null?E(c):f!=null?E(f):v,p=`${e.from_id}\0${e.to_id}`,l=s.get(p);if(l){l.active||=h(_);continue}s.set(p,{from_id:e.from_id,to_id:e.to_id,active:h(_),created:e.created_at,from_status:e.from_status??null,to_status:e.to_status??null})}return[...s.values()]}i(d,"treeEdges");async function F(o=null){const t=o===null?null:[...o];return(t===null?await d(await r(),""):await d(await r(),"AND wo.id IN (SELECT unnest(?::text[])) AND oo.id IN (SELECT unnest(?::text[]))",t,t)).map(({from_id:a,to_id:s,active:e,created:c})=>({from_id:a,to_id:s,active:e,created:c}))}i(F,"rosterEdges");async function W(o,t,n=!0){await u(async a=>{const s=await w(a,o),e=await w(a,t);await I(a,s,e,"ask"),await x(o,t,n),await D(a,{event:"watched",object:e,actor:s,attrs:{}})})}i(W,"subscribe");async function M(o,t){await u(async n=>{const a=await w(n,o),s=await w(n,t);for(const e of R)await b(n,a,s,{startedBy:e})})}i(M,"unsubscribe");async function x(o,t,n){await u(async a=>{await a.prepareUncached(`UPDATE watch_subscriptions SET config_json = ?
11
11
  WHERE started_by IN ${S}
12
- AND watch IN (SELECT watch_id FROM watches WHERE watcher = ? AND object = ?)`).run(e?null:D(j),(await w(a,o)).id,(await w(a,t)).id)})}i(x,"setSubscriptionActive");async function $(o){const t=await r(),e=await N(t,o);if(e?.type!=="node")return[];let a=e.id;const s=new Set([a]);for(;;){const c=(await d(t,"AND oo.id = ?",a))[0]?.from_id;if(c===void 0||s.has(c))break;s.add(c),a=c}const n=(await t.prepareUncached(m).all(a,a)).map(c=>c.id);return[a,...n]}i($,"treeContaining");async function B(o){return(await d(await r(),"AND oo.id = ?",o)).map(t=>({node_id:t.from_id,active:t.active,created:t.created}))}i(B,"subscribersOf");async function H(o){return(await d(await r(),"AND wo.id = ?",o)).map(t=>({node_id:t.to_id,active:t.active,created:t.created}))}i(H,"subscriptionsOf");function h(o){return`WITH RECURSIVE walk(id) AS (
12
+ AND watch IN (SELECT watch_id FROM watches WHERE watcher = ? AND object = ?)`).run(n?null:T(j),(await w(a,o)).id,(await w(a,t)).id)})}i(x,"setSubscriptionActive");async function $(o){const t=await r(),n=await N(t,o);if(n?.type!=="node")return[];let a=n.id;const s=new Set([a]);for(;;){const c=(await d(t,"AND oo.id = ?",a))[0]?.from_id;if(c===void 0||s.has(c))break;s.add(c),a=c}const e=(await t.prepareUncached(m).all(a,a)).map(c=>c.id);return[a,...e]}i($,"treeContaining");async function B(o){return(await d(await r(),"AND oo.id = ?",o)).map(t=>({node_id:t.from_id,active:t.active,created:t.created}))}i(B,"subscribersOf");async function H(o){return(await d(await r(),"AND wo.id = ?",o)).map(t=>({node_id:t.to_id,active:t.active,created:t.created}))}i(H,"subscriptionsOf");function A(o){return`WITH RECURSIVE walk(id) AS (
13
13
  SELECT CAST(? AS text)
14
14
  UNION
15
15
  SELECT w.object FROM walk
16
16
  JOIN watches w ON w.watcher = walk.id AND w.in_tree = 1
17
17
  ${o?`JOIN objects oo ON oo.id = w.object AND oo.type = 'node' AND oo.kind IS DISTINCT FROM 'human'
18
18
  JOIN nodes onode ON onode.node_id = oo.id`:"JOIN nodes onode ON onode.node_id = w.object"}
19
- ) SELECT id FROM walk WHERE id != ?`}i(h,"subtreeSql");const P=h(!0),m=h(!1);async function Q(o){const t=await r(),e=await N(t,o);return e?.type!=="node"?[]:(await t.prepareUncached(m).all(e.id,e.id)).map(a=>a.id)}i(Q,"view");const y=new Set(["active","idle"]);async function V(o){return(await d(await r(),"AND wo.id = ?",o)).some(t=>t.active&&y.has(t.to_status??""))}i(V,"hasActiveLiveSubscription");async function Y(o){return(await d(await r(),"AND oo.id = ?",o)).some(t=>t.active&&y.has(t.from_status??""))}i(Y,"hasLiveSubscriber");export{m as SUBTREE_ALL_IDS_SQL,P as SUBTREE_IDS_SQL,V as hasActiveLiveSubscription,Y as hasLiveSubscriber,F as rosterEdges,x as setSubscriptionActive,W as subscribe,B as subscribersOf,H as subscriptionsOf,$ as treeContaining,M as unsubscribe,Q as view};
19
+ ) SELECT id FROM walk WHERE id != ?`}i(A,"subtreeSql");const P=A(!0),m=A(!1);async function Q(o){const t=await r(),n=await N(t,o);return n?.type!=="node"?[]:(await t.prepareUncached(m).all(n.id,n.id)).map(a=>a.id)}i(Q,"view");const y=new Set(["active","idle"]);async function V(o){return(await d(await r(),"AND wo.id = ?",o)).some(t=>t.active&&y.has(t.to_status??""))}i(V,"hasActiveLiveSubscription");async function q(o){return(await d(await r(),"AND oo.id = ?",o)).some(t=>t.active&&y.has(t.from_status??""))}i(q,"hasLiveSubscriber");export{m as SUBTREE_ALL_IDS_SQL,P as SUBTREE_IDS_SQL,V as hasActiveLiveSubscription,q as hasLiveSubscriber,F as rosterEdges,x as setSubscriptionActive,W as subscribe,B as subscribersOf,H as subscriptionsOf,$ as treeContaining,M as unsubscribe,Q as view};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.743",
3
+ "version": "0.3.744",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,8 +158,8 @@
158
158
  },
159
159
  "license": "UNLICENSED",
160
160
  "dependencies": {
161
- "@north-light/identity": "0.3.743",
162
- "@north-light/plugin": "0.3.743",
161
+ "@north-light/identity": "0.3.744",
162
+ "@north-light/plugin": "0.3.744",
163
163
  "@earendil-works/chord": "1.5.2",
164
164
  "@earendil-works/pi-agent-core": "1.5.2",
165
165
  "@earendil-works/pi-ai": "1.5.2",
@@ -52,7 +52,9 @@ export async function rosterEdges(visible = null) {
52
52
  const ids = visible === null ? null : [...visible];
53
53
  const rows = ids === null
54
54
  ? await treeEdges(await openDb(), '')
55
- : await treeEdges(await openDb(), 'AND wo.id = ANY(?::text[]) AND oo.id = ANY(?::text[])', ids, ids);
55
+ // `IN (SELECT unnest(...))`, not `= ANY(...)`: the planner hashes the set instead of scanning the array per joined row
56
+ // (thousands of ids made `ANY` a linear filter: 5.6 s against 0.3 s on the fleet database).
57
+ : await treeEdges(await openDb(), 'AND wo.id IN (SELECT unnest(?::text[])) AND oo.id IN (SELECT unnest(?::text[]))', ids, ids);
56
58
  return rows.map(({ from_id, to_id, active, created }) => ({ from_id, to_id, active, created }));
57
59
  }
58
60
  /** `subscriber` asks to watch `publisher` (an `ask` watch, in the tree). Re-running sets the
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.743",
3
+ "version": "0.3.744",
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/identity",
3
- "version": "0.3.743",
3
+ "version": "0.3.744",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.743",
3
+ "version": "0.3.744",
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.743",
31
- "@north-light/identity": "0.3.743"
30
+ "@north-light/api": "0.3.744",
31
+ "@north-light/identity": "0.3.744"
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.743",
3
+ "version": "0.3.744",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.743",
9
+ "version": "0.3.744",
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.743",
32
- "@north-light/plugin": "0.3.743",
31
+ "@north-light/identity": "0.3.744",
32
+ "@north-light/plugin": "0.3.744",
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.743",
11905
+ "version": "0.3.744",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.743",
11910
+ "version": "0.3.744",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.743",
11915
+ "version": "0.3.744",
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.743",
11923
+ "version": "0.3.744",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.743",
11927
- "@north-light/identity": "0.3.743"
11926
+ "@north-light/api": "0.3.744",
11927
+ "@north-light/identity": "0.3.744"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.743",
11932
+ "version": "0.3.744",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.743",
11936
- "@north-light/identity": "0.3.743",
11937
- "@north-light/plugin": "0.3.743",
11935
+ "@north-light/api": "0.3.744",
11936
+ "@north-light/identity": "0.3.744",
11937
+ "@north-light/plugin": "0.3.744",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {