@north-light/cli 0.3.600 → 0.3.601

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.
@@ -5,8 +5,8 @@ import { ProviderError } from './errors.js';
5
5
  export declare const LIBS_SEARCH_PATH = "/v1/libs/search";
6
6
  export declare const LIBS_BUNDLE_PATH = "/v1/libs/bundle";
7
7
  export declare const LIBS_REPORT_PATH = "/v1/libs/report";
8
- /** The device wire version libs routes and bundled execs are served at. */
9
- export declare const LIBS_MAJOR = 2;
8
+ /** The first device wire major that serves libs routes and bundled execs; every later major keeps them. */
9
+ export declare const LIBS_MIN_MAJOR = 2;
10
10
  export declare const isLibsSearch: (major: number, tool: string) => boolean;
11
11
  /** An exec whose code may import a library. The relay does the exact leading-import parse; a false positive costs one round trip. */
12
12
  export declare function wantsBundling(major: number, tool: string, args: Record<string, unknown>): boolean;
@@ -1 +1 @@
1
- var T=Object.defineProperty;var a=(e,r)=>T(e,"name",{value:r,configurable:!0});import{ProviderError as p}from"./errors.js";import{deviceDeps as w,deviceFailure as C,deviceUnreachable as _}from"./device.js";const $="/v1/libs/search",L="/v1/libs/bundle",R="/v1/libs/report",A=2,x=1e4,E=/@(northlight|vallum)\//,j=1e3,M=2e3,D=300,X=a((e,r)=>e===A&&r==="browser libs","isLibsSearch");function W(e,r,n){return e===A&&r==="browser executor exec"&&typeof n.code=="string"&&E.test(n.code)}a(W,"wantsBundling");function O(e){const r=e["retry-after"],n=Array.isArray(r)?r[0]:r,t=n===void 0?NaN:Number(n);return Number.isFinite(t)&&t>=0?t:void 0}a(O,"retryAfterSeconds");function U(e,r){const n=r.body?.error,t=n&&typeof n=="object"&&typeof n.code=="string"?n.code:void 0,o=n&&typeof n=="object"&&typeof n.message=="string"?n.message:void 0,i=C(e.machine,r.status,t,o,r.body);if(i!==null)return i;const s=e.mapFailure(r.status,r.body,r.headers),d=r.status===503?O(r.headers):void 0;return d===void 0||s.retry_after_s!==void 0?s:new p("provider_unavailable",s.message,{origin:s.origin,details:s.details,...s.param?{param:s.param}:{},retry_after_s:d})}a(U,"libsFailure");const N=a(e=>_(e.machine,"timeout",""),"budgetSpent");async function v(e,r,n,t){const o=e.deadlineAt-Date.now();if(o<=0)throw N(e);const i=await w.current.call(e.machine.machine_id,{method:"POST",path:r,body:{...n,version:t,deadline_at:e.deadlineAt}},{envelope:e.envelope,device:!0,signal:AbortSignal.any([e.signal,AbortSignal.timeout(o)])});if(e.signal.aborted)throw e.signal.reason??new Error("provider call aborted");if("unreachable"in i)throw _(e.machine,i.unreachable.reason,i.unreachable.message);if(i.status<200||i.status>=300)throw U(e,i);const s=i.body&&typeof i.body=="object"&&!Array.isArray(i.body)?i.body.result:void 0;if(!s||typeof s!="object"||Array.isArray(s))throw new p("provider_bad_response","the libraries result is not a JSON object",{origin:"provider",details:{status:i.status,message:"the libraries result is not a JSON object"}});return s}a(v,"libsRequest");function q(e,r,n){return v(e,$,{arguments:r},n)}a(q,"callLibsSearch");const b=a(e=>Array.isArray(e)&&e.every(r=>typeof r=="string")?e:null,"strings");function P(e){if(!Array.isArray(e))return null;const r=[];for(const n of e){const t=n,o=b(t?.domains),i=b(t?.writes);if(!t||typeof t.id!="string"||typeof t.name!="string"||o===null||i===null)return null;r.push({id:t.id,name:t.name,domains:o,writes:i})}return r}a(P,"parseServices");async function z(e,r,n){const t=await v(e,L,{code:r.code},n);if(t.bundled===!1)return null;const o=b(t.domains),i=P(t.services);if(t.bundled!==!0||typeof t.bundle!="string"||o===null||i===null||typeof t.release!="string")throw new p("provider_bad_response","the libraries bundle answer is malformed",{origin:"provider",details:{status:200,message:"the libraries bundle answer is malformed"}});const{code:s,...d}=r;return{arguments:{...d,bundle:t.bundle,domains:o},release:t.release,services:i}}a(z,"bundleExec");const S=a(e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,"object"),l=a(e=>typeof e=="string"?e.slice(0,M):void 0,"text"),y=a(e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,"finite");function k(e){if(!Array.isArray(e))return[];const r=[];for(const n of e.slice(0,j)){const t=S(n),o=l(t?.service),i=l(t?.fn);if(!t||o===void 0||i===void 0)continue;const s=l(t.errorClass),d=y(t.status),u=l(t.upstreamCode);r.push({service:o,fn:i,ok:t.ok===!0,durationMs:Math.max(0,Math.round(y(t.durationMs)??0)),...s!==void 0&&{errorClass:s},...d!==void 0&&{status:d},...u!==void 0&&{upstreamCode:u},...typeof t.wasDispatched=="boolean"&&{wasDispatched:t.wasDispatched}})}return r}a(k,"sanitizeCalls");function F(e,r){let n;try{n=new URL(e).hostname.toLowerCase()}catch{return!1}return r.some(t=>{const o=t.toLowerCase().replace(/^\*\./,"").replace(/^\./,"");return n===o||n.endsWith(`.${o}`)})}a(F,"hostMatches");function B(e,r,n){for(const t of e){if(t.ok||t.errorClass!=="Unauthenticated")continue;const o=r.find(s=>s.id===t.service);if(!o||o.domains.length===0||F(n,o.domains))continue;let i=n;try{i=new URL(n).hostname||n}catch{}return`${o.name} is not on ${i} (it runs on ${o.domains.join(", ")})`}}a(B,"offSiteCall");function f(e,r,n,t,o){return new p(e,n,{status:r,origin:"provider",details:{code:e,message:n,next:t,status:r},...o===void 0?{}:{retry_after_s:o}})}a(f,"outcomeError");function Y(e,r){const n=S(e.envelope);if(!n||typeof e.url!="string")return{calls:[],error:f("js_exception",409,"The page returned a result that could not be read","Run the code again; if it keeps happening, report it")};const t=e.url,o=k(n.calls),i=l(e.warning);if(!("error"in n))return{calls:o,result:{result:n.result===void 0?null:n.result,url:t,calls:o,...i!==void 0&&{warning:i}}};const s=l(n.error)??"The script threw",d=i===void 0?"":` ${i}`,u=l(n.errorClass),h=a(c=>({calls:o,error:c}),"fail"),g=o.filter(c=>c.wasDispatched===!0&&r.find(m=>m.id===c.service)?.writes.includes(c.fn)===!0);if(g.length>0)return h(f("outcome_unknown",409,`The script threw after ${g.map(c=>`${c.service}.${c.fn}`).join(", ")} was sent, so it may have taken effect: ${s}`,`Check the site before repeating this action; do not retry blindly.${d}`));if(u==="Unauthenticated"){const c=B(o,r,t);return h((c??i)!==void 0?f("wrong_site",409,`The executor is on the wrong site, not signed out: ${c??i} (${s})`,"Create the executor on the service's own site (browser executor create --url https://\u2026) or navigate it there, then run the code again"):f("site_signed_out",409,`The site is signed out in this Chrome profile: ${s}`,"Sign in to the service in Chrome through the Northlight Desktop menu's Open Chrome profile, then run the code again"))}if(u==="RateLimited"){const c=y(n.retryAfterS),m=c!==void 0&&c>=1?Math.ceil(c):D;return h(f("rate_limited",429,s,`Wait for Retry-After seconds, then run the code again.${d}`,m))}return h(u==="ContractDrift"?f("lib_broken",502,`The library no longer matches the site: ${s}`,`Do not retry; the library needs a fix. Use a different approach for now.${d}`):f("js_exception",409,u&&u!=="Unknown"?`${u}: ${s}`:s,`Fix the code or its arguments and run it again.${d}`))}a(Y,"mapLibOutcome");function G(e,r,n,t){if(t.some(o=>!o.ok))try{w.current.call(e.machine_id,{method:"POST",path:R,body:{release:n,calls:t}},{envelope:r,device:!0,signal:AbortSignal.timeout(x)}).catch(()=>{})}catch{}}a(G,"reportLibCalls");export{L as LIBS_BUNDLE_PATH,A as LIBS_MAJOR,R as LIBS_REPORT_PATH,$ as LIBS_SEARCH_PATH,z as bundleExec,q as callLibsSearch,X as isLibsSearch,Y as mapLibOutcome,G as reportLibCalls,k as sanitizeCalls,W as wantsBundling};
1
+ var T=Object.defineProperty;var a=(e,r)=>T(e,"name",{value:r,configurable:!0});import{ProviderError as p}from"./errors.js";import{deviceDeps as w,deviceFailure as C,deviceUnreachable as _}from"./device.js";const $="/v1/libs/search",L="/v1/libs/bundle",R="/v1/libs/report",A=2,x=1e4,E=/@(northlight|vallum)\//,M=1e3,j=2e3,D=300,X=a((e,r)=>e>=A&&r==="browser libs","isLibsSearch");function W(e,r,n){return e>=A&&r==="browser executor exec"&&typeof n.code=="string"&&E.test(n.code)}a(W,"wantsBundling");function O(e){const r=e["retry-after"],n=Array.isArray(r)?r[0]:r,t=n===void 0?NaN:Number(n);return Number.isFinite(t)&&t>=0?t:void 0}a(O,"retryAfterSeconds");function N(e,r){const n=r.body?.error,t=n&&typeof n=="object"&&typeof n.code=="string"?n.code:void 0,o=n&&typeof n=="object"&&typeof n.message=="string"?n.message:void 0,i=C(e.machine,r.status,t,o,r.body);if(i!==null)return i;const s=e.mapFailure(r.status,r.body,r.headers),d=r.status===503?O(r.headers):void 0;return d===void 0||s.retry_after_s!==void 0?s:new p("provider_unavailable",s.message,{origin:s.origin,details:s.details,...s.param?{param:s.param}:{},retry_after_s:d})}a(N,"libsFailure");const U=a(e=>_(e.machine,"timeout",""),"budgetSpent");async function v(e,r,n,t){const o=e.deadlineAt-Date.now();if(o<=0)throw U(e);const i=await w.current.call(e.machine.machine_id,{method:"POST",path:r,body:{...n,version:t,deadline_at:e.deadlineAt}},{envelope:e.envelope,device:!0,signal:AbortSignal.any([e.signal,AbortSignal.timeout(o)])});if(e.signal.aborted)throw e.signal.reason??new Error("provider call aborted");if("unreachable"in i)throw _(e.machine,i.unreachable.reason,i.unreachable.message);if(i.status<200||i.status>=300)throw N(e,i);const s=i.body&&typeof i.body=="object"&&!Array.isArray(i.body)?i.body.result:void 0;if(!s||typeof s!="object"||Array.isArray(s))throw new p("provider_bad_response","the libraries result is not a JSON object",{origin:"provider",details:{status:i.status,message:"the libraries result is not a JSON object"}});return s}a(v,"libsRequest");function q(e,r,n){return v(e,$,{arguments:r},n)}a(q,"callLibsSearch");const b=a(e=>Array.isArray(e)&&e.every(r=>typeof r=="string")?e:null,"strings");function P(e){if(!Array.isArray(e))return null;const r=[];for(const n of e){const t=n,o=b(t?.domains),i=b(t?.writes);if(!t||typeof t.id!="string"||typeof t.name!="string"||o===null||i===null)return null;r.push({id:t.id,name:t.name,domains:o,writes:i})}return r}a(P,"parseServices");async function z(e,r,n){const t=await v(e,L,{code:r.code},n);if(t.bundled===!1)return null;const o=b(t.domains),i=P(t.services);if(t.bundled!==!0||typeof t.bundle!="string"||o===null||i===null||typeof t.release!="string")throw new p("provider_bad_response","the libraries bundle answer is malformed",{origin:"provider",details:{status:200,message:"the libraries bundle answer is malformed"}});const{code:s,...d}=r;return{arguments:{...d,bundle:t.bundle,domains:o},release:t.release,services:i}}a(z,"bundleExec");const S=a(e=>e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0,"object"),l=a(e=>typeof e=="string"?e.slice(0,j):void 0,"text"),y=a(e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,"finite");function k(e){if(!Array.isArray(e))return[];const r=[];for(const n of e.slice(0,M)){const t=S(n),o=l(t?.service),i=l(t?.fn);if(!t||o===void 0||i===void 0)continue;const s=l(t.errorClass),d=y(t.status),u=l(t.upstreamCode);r.push({service:o,fn:i,ok:t.ok===!0,durationMs:Math.max(0,Math.round(y(t.durationMs)??0)),...s!==void 0&&{errorClass:s},...d!==void 0&&{status:d},...u!==void 0&&{upstreamCode:u},...typeof t.wasDispatched=="boolean"&&{wasDispatched:t.wasDispatched}})}return r}a(k,"sanitizeCalls");function F(e,r){let n;try{n=new URL(e).hostname.toLowerCase()}catch{return!1}return r.some(t=>{const o=t.toLowerCase().replace(/^\*\./,"").replace(/^\./,"");return n===o||n.endsWith(`.${o}`)})}a(F,"hostMatches");function I(e,r,n){for(const t of e){if(t.ok||t.errorClass!=="Unauthenticated")continue;const o=r.find(s=>s.id===t.service);if(!o||o.domains.length===0||F(n,o.domains))continue;let i=n;try{i=new URL(n).hostname||n}catch{}return`${o.name} is not on ${i} (it runs on ${o.domains.join(", ")})`}}a(I,"offSiteCall");function f(e,r,n,t,o){return new p(e,n,{status:r,origin:"provider",details:{code:e,message:n,next:t,status:r},...o===void 0?{}:{retry_after_s:o}})}a(f,"outcomeError");function Y(e,r){const n=S(e.envelope);if(!n||typeof e.url!="string")return{calls:[],error:f("js_exception",409,"The page returned a result that could not be read","Run the code again; if it keeps happening, report it")};const t=e.url,o=k(n.calls),i=l(e.warning);if(!("error"in n))return{calls:o,result:{result:n.result===void 0?null:n.result,url:t,calls:o,...i!==void 0&&{warning:i}}};const s=l(n.error)??"The script threw",d=i===void 0?"":` ${i}`,u=l(n.errorClass),h=a(c=>({calls:o,error:c}),"fail"),g=o.filter(c=>c.wasDispatched===!0&&r.find(m=>m.id===c.service)?.writes.includes(c.fn)===!0);if(g.length>0)return h(f("outcome_unknown",409,`The script threw after ${g.map(c=>`${c.service}.${c.fn}`).join(", ")} was sent, so it may have taken effect: ${s}`,`Check the site before repeating this action; do not retry blindly.${d}`));if(u==="Unauthenticated"){const c=I(o,r,t);return h((c??i)!==void 0?f("wrong_site",409,`The executor is on the wrong site, not signed out: ${c??i} (${s})`,"Create the executor on the service's own site (browser executor create --url https://\u2026) or navigate it there, then run the code again"):f("site_signed_out",409,`The site is signed out in this Chrome profile: ${s}`,"Sign in to the service in Chrome through the Northlight Desktop menu's Open Chrome profile, then run the code again"))}if(u==="RateLimited"){const c=y(n.retryAfterS),m=c!==void 0&&c>=1?Math.ceil(c):D;return h(f("rate_limited",429,s,`Wait for Retry-After seconds, then run the code again.${d}`,m))}return h(u==="ContractDrift"?f("lib_broken",502,`The library no longer matches the site: ${s}`,`Do not retry; the library needs a fix. Use a different approach for now.${d}`):f("js_exception",409,u&&u!=="Unknown"?`${u}: ${s}`:s,`Fix the code or its arguments and run it again.${d}`))}a(Y,"mapLibOutcome");function G(e,r,n,t){if(t.some(o=>!o.ok))try{w.current.call(e.machine_id,{method:"POST",path:R,body:{release:n,calls:t}},{envelope:r,device:!0,signal:AbortSignal.timeout(x)}).catch(()=>{})}catch{}}a(G,"reportLibCalls");export{L as LIBS_BUNDLE_PATH,A as LIBS_MIN_MAJOR,R as LIBS_REPORT_PATH,$ as LIBS_SEARCH_PATH,z as bundleExec,q as callLibsSearch,X as isLibsSearch,Y as mapLibOutcome,G as reportLibCalls,k as sanitizeCalls,W as wantsBundling};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.600",
3
+ "version": "0.3.601",
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.600",
148
+ "@north-light/identity": "0.3.601",
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.600",
3
+ "version": "0.3.601",
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.600",
3
+ "version": "0.3.601",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.600",
9
+ "version": "0.3.601",
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.600",
31
+ "@north-light/identity": "0.3.601",
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.600",
11959
+ "version": "0.3.601",
11960
11960
  "license": "UNLICENSED"
11961
11961
  },
11962
11962
  "packages/crouter-env-docker": {
11963
11963
  "name": "@north-light/env-docker",
11964
- "version": "0.3.600",
11964
+ "version": "0.3.601",
11965
11965
  "license": "UNLICENSED"
11966
11966
  },
11967
11967
  "packages/crouter-identity": {
11968
11968
  "name": "@north-light/identity",
11969
- "version": "0.3.600",
11969
+ "version": "0.3.601",
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.600",
11977
+ "version": "0.3.601",
11978
11978
  "license": "UNLICENSED",
11979
11979
  "dependencies": {
11980
- "@north-light/api": "0.3.600",
11981
- "@north-light/identity": "0.3.600"
11980
+ "@north-light/api": "0.3.601",
11981
+ "@north-light/identity": "0.3.601"
11982
11982
  }
11983
11983
  },
11984
11984
  "packages/crouter-sdk": {
11985
11985
  "name": "@north-light/sdk",
11986
- "version": "0.3.600",
11986
+ "version": "0.3.601",
11987
11987
  "license": "UNLICENSED",
11988
11988
  "dependencies": {
11989
- "@north-light/api": "0.3.600",
11990
- "@north-light/identity": "0.3.600",
11991
- "@north-light/plugin": "0.3.600",
11989
+ "@north-light/api": "0.3.601",
11990
+ "@north-light/identity": "0.3.601",
11991
+ "@north-light/plugin": "0.3.601",
11992
11992
  "jose": "^6.2.1"
11993
11993
  },
11994
11994
  "bin": {