@north-light/cli 0.3.758 → 0.3.759
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/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
- package/dist/core/grants/mirror.js +2 -2
- package/dist/core/grants/shadow.js +1 -1
- package/dist/daemon/api/handlers/providers.js +1 -1
- package/docs/sdk/release-notes.md +6 -0
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/core/grants/mirror.js +2 -2
- package/packages/crouter-api/dist/core/grants/shadow.js +25 -1
- package/packages/crouter-api/dist/daemon/api/handlers/providers.js +6 -4
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/dist/index.js +5 -2
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
package/dist/api/contract.d.ts
CHANGED
|
@@ -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.
|
|
2
|
+
export declare const CONTRACT_LEVEL = "1.80";
|
|
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`. */
|
package/dist/api/contract.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.
|
|
1
|
+
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.80",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,12 @@ 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.759
|
|
13
|
+
|
|
14
|
+
### A grant can hold a whole provider as `<provider>:*`
|
|
15
|
+
|
|
16
|
+
`grant.get().resolved_scopes` may contain `<provider>:*` (for example `integrations:*`) in place of one entry per group. It means every group of that provider the grant may hold. Check a scope with the new `holds(resolved_scopes, scope)` export instead of comparing strings, because `integrations:gmail` is held while only `integrations:*` is listed. The directory sends this form only to a runtime that understands it.
|
|
17
|
+
|
|
12
18
|
## 0.3.755
|
|
13
19
|
|
|
14
20
|
### An app can start runs in its own environment with no person
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var I=Object.defineProperty;var n=(e,r)=>I(e,"name",{value:r,configurable:!0});import{createHash as L}from"node:crypto";import{parsePrincipal as T,parseScope as C}from"@north-light/identity";import{openDb as d,withCanvasWrite as M}from"../canvas/db.js";import{isUnsandboxedMachine as A}from"../runtime/unsandboxed.js";import{replaceWrittenBy as O,userSubject as F}from"../permissions/facts.js";import{GROUP_TYPE as f,OBJECT_TYPE as $}from"../permissions/builtin.js";import{shadowCheck as k}from"./shadow.js";const U=["not_started","pending","ready","failed","unavailable"],P=["ultra","strong","medium","light"];function G(e,r,t){if(e==null||e==="user")return r;if(e==="app")return t;if(typeof e!="string"||T(e)===null)throw new TypeError("invalid grant payer");return e}n(G,"principalPayer");function H(e){const r=e.payer===null?null:T(e.payer);return r!==null&&r.kind==="app"&&r.path.length===0}n(H,"endpointPays");function x(){const e=process.env.CRTR_RUNTIME;return e?{sql:" AND runtime = ?",args:[e]}:{sql:"",args:[]}}n(x,"runtimeScope");async function c(e,r,t=[]){const s=x();return await(await d()).prepare(`SELECT ${e} FROM grants WHERE (${r})${s.sql}`).all(...t,...s.args)}n(c,"grantRows");async function u(e,r,t=[]){return(await c(e,r,t))[0]}n(u,"grantRow");function W(e){return!/\u0000|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/.test(e)}n(W,"jsonbSafe");function l(e){if(!Array.isArray(e))throw new TypeError("grant scopes must be a list");return e.map(r=>{if(!r||typeof r!="object"||typeof r.scope!="string"||!W(r.scope)||!["always","ask"].includes(r.mode))throw new TypeError("invalid grant scope entry");return{scope:r.scope,mode:r.mode}})}n(l,"entries");function J(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const{state:r,message:t,next:s,step:o}=e;return typeof r!="string"||!U.includes(r)||t!==void 0&&typeof t!="string"||o!==void 0&&typeof o!="string"||typeof s!="string"||!s?null:{state:r,...t===void 0?{}:{message:t},next:s,...o===void 0?{}:{step:o}}}n(J,"dependencyOf");function j(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[t,s]of Object.entries(e)){const o=J(s);o&&(r[t]=o)}return r}n(j,"dependenciesOf");function V(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const{base_url:r,rungs:t}=e;if(typeof r!="string"||!r||!t||typeof t!="object"||Array.isArray(t))return null;const s={};for(const o of P){const a=t[o];typeof a=="string"&&a&&(s[o]=a)}return Object.keys(s).length?{base_url:r.replace(/\/+$/,""),rungs:s}:null}n(V,"inferenceEndpointOf");function w(e,r,t,s){return r===e&&t&&s}n(w,"computedFor");function _(e){if(!w(e.rev,e.computed_rev,e.scopes_json!==null,e.resolved_scopes_json!==null))throw new TypeError("grant columns are not computed for this revision");return{id:e.id,runtime:e.runtime,sub:e.sub,grantee:e.grantee,grantee_prefix:e.grantee_prefix??null,rev:e.rev,scopes:l(JSON.parse(e.scopes_json)),resolved_scopes:l(JSON.parse(e.resolved_scopes_json)),spend_cap:e.spend_cap,expires_at:e.expires_at,status:e.status,revoked_at:e.revoked_at,approved_at:e.approved_at,payer:e.payer,dependencies:j(JSON.parse(e.dependencies_json??"{}")),run_notice_url:e.run_notice_url??null,inference_endpoint:e.inference_endpoint_json?V(JSON.parse(e.inference_endpoint_json)):null,synced_at:e.synced_at??""}}n(_,"record");function p(e){if(!e||e.status!=="active")return null;try{const r=Z(_(e));return r!==null&&k(r),r}catch(r){if(r instanceof TypeError||r instanceof SyntaxError)return null;throw r}}n(p,"active");function y(e){return e.grantee!=="app:terminal"&&A()}n(y,"mirrorOnly");async function de(){return(await Y()).filter(e=>!y(e))}n(de,"localGrants");async function le(e,r){return!y({grantee:e})&&await u("1","grantee = ? AND sub <> ? AND status <> 'removed'",[e,r])!==void 0}n(le,"otherLiveGrantOfApp");const g="[A-Za-z0-9_-]{1,64}",q=new RegExp(`^(${g}):(${g})$`);function B(e){const r=new Set;for(const t of e)if(t.status==="active")for(const{scope:s}of t.resolved_scopes){const o=q.exec(s);o&&o[1]!=="crtr"&&r.add(o[1])}return[...r].sort()}n(B,"providerIdsFromGrants");async function fe(){const e=x();return(await(await d()).prepare(`SELECT DISTINCT m[1] AS id FROM (
|
|
1
|
+
var I=Object.defineProperty;var n=(e,r)=>I(e,"name",{value:r,configurable:!0});import{createHash as L}from"node:crypto";import{parsePrincipal as T,parseScope as C}from"@north-light/identity";import{openDb as d,withCanvasWrite as M}from"../canvas/db.js";import{isUnsandboxedMachine as A}from"../runtime/unsandboxed.js";import{replaceWrittenBy as O,userSubject as F}from"../permissions/facts.js";import{GROUP_TYPE as f,OBJECT_TYPE as $}from"../permissions/builtin.js";import{shadowCheck as k}from"./shadow.js";const U=["not_started","pending","ready","failed","unavailable"],P=["ultra","strong","medium","light"];function G(e,r,t){if(e==null||e==="user")return r;if(e==="app")return t;if(typeof e!="string"||T(e)===null)throw new TypeError("invalid grant payer");return e}n(G,"principalPayer");function H(e){const r=e.payer===null?null:T(e.payer);return r!==null&&r.kind==="app"&&r.path.length===0}n(H,"endpointPays");function x(){const e=process.env.CRTR_RUNTIME;return e?{sql:" AND runtime = ?",args:[e]}:{sql:"",args:[]}}n(x,"runtimeScope");async function c(e,r,t=[]){const s=x();return await(await d()).prepare(`SELECT ${e} FROM grants WHERE (${r})${s.sql}`).all(...t,...s.args)}n(c,"grantRows");async function u(e,r,t=[]){return(await c(e,r,t))[0]}n(u,"grantRow");function W(e){return!/\u0000|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/.test(e)}n(W,"jsonbSafe");function l(e){if(!Array.isArray(e))throw new TypeError("grant scopes must be a list");return e.map(r=>{if(!r||typeof r!="object"||typeof r.scope!="string"||!W(r.scope)||!["always","ask"].includes(r.mode))throw new TypeError("invalid grant scope entry");return{scope:r.scope,mode:r.mode}})}n(l,"entries");function J(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const{state:r,message:t,next:s,step:o}=e;return typeof r!="string"||!U.includes(r)||t!==void 0&&typeof t!="string"||o!==void 0&&typeof o!="string"||typeof s!="string"||!s?null:{state:r,...t===void 0?{}:{message:t},next:s,...o===void 0?{}:{step:o}}}n(J,"dependencyOf");function j(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const r={};for(const[t,s]of Object.entries(e)){const o=J(s);o&&(r[t]=o)}return r}n(j,"dependenciesOf");function V(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const{base_url:r,rungs:t}=e;if(typeof r!="string"||!r||!t||typeof t!="object"||Array.isArray(t))return null;const s={};for(const o of P){const a=t[o];typeof a=="string"&&a&&(s[o]=a)}return Object.keys(s).length?{base_url:r.replace(/\/+$/,""),rungs:s}:null}n(V,"inferenceEndpointOf");function w(e,r,t,s){return r===e&&t&&s}n(w,"computedFor");function _(e){if(!w(e.rev,e.computed_rev,e.scopes_json!==null,e.resolved_scopes_json!==null))throw new TypeError("grant columns are not computed for this revision");return{id:e.id,runtime:e.runtime,sub:e.sub,grantee:e.grantee,grantee_prefix:e.grantee_prefix??null,rev:e.rev,scopes:l(JSON.parse(e.scopes_json)),resolved_scopes:l(JSON.parse(e.resolved_scopes_json)),spend_cap:e.spend_cap,expires_at:e.expires_at,status:e.status,revoked_at:e.revoked_at,approved_at:e.approved_at,payer:e.payer,dependencies:j(JSON.parse(e.dependencies_json??"{}")),run_notice_url:e.run_notice_url??null,inference_endpoint:e.inference_endpoint_json?V(JSON.parse(e.inference_endpoint_json)):null,synced_at:e.synced_at??""}}n(_,"record");function p(e){if(!e||e.status!=="active")return null;try{const r=Z(_(e));return r!==null&&k(r),r}catch(r){if(r instanceof TypeError||r instanceof SyntaxError)return null;throw r}}n(p,"active");function y(e){return e.grantee!=="app:terminal"&&A()}n(y,"mirrorOnly");async function de(){return(await Y()).filter(e=>!y(e))}n(de,"localGrants");async function le(e,r){return!y({grantee:e})&&await u("1","grantee = ? AND sub <> ? AND status <> 'removed'",[e,r])!==void 0}n(le,"otherLiveGrantOfApp");const g="[A-Za-z0-9_-]{1,64}",q=new RegExp(`^(${g}):(${g}|\\*)$`);function B(e){const r=new Set;for(const t of e)if(t.status==="active")for(const{scope:s}of t.resolved_scopes){const o=q.exec(s);o&&o[1]!=="crtr"&&r.add(o[1])}return[...r].sort()}n(B,"providerIdsFromGrants");async function fe(){const e=x();return(await(await d()).prepare(`SELECT DISTINCT m[1] AS id FROM (
|
|
2
2
|
SELECT DISTINCT e->>'scope' AS scope FROM (
|
|
3
3
|
SELECT t::jsonb AS j FROM (SELECT DISTINCT resolved_scopes_json AS t FROM grants WHERE ${m}${S()}${e.sql}) d OFFSET 0) p
|
|
4
4
|
CROSS JOIN LATERAL jsonb_array_elements(CASE WHEN jsonb_typeof(p.j) = 'array' THEN p.j ELSE '[]' END) e) s
|
|
5
|
-
CROSS JOIN LATERAL regexp_match(s.scope, '^(${g})
|
|
5
|
+
CROSS JOIN LATERAL regexp_match(s.scope, '^(${g}):(?:${g}|\\*)$') m
|
|
6
6
|
WHERE m[1] <> 'crtr'`).all(...e.args)).map(t=>t.id).sort()}n(fe,"activeProviderIds");async function _e(){const e=x();return await(await d()).prepare(`SELECT 1 FROM grants WHERE ${m}${S()}${e.sql} LIMIT 1`).get(...e.args)!==void 0}n(_e,"anyActiveGrant");async function ye(e,r){return await u("1",`sub = ? AND ${m}${S()} AND EXISTS (
|
|
7
7
|
SELECT 1 FROM jsonb_array_elements(CASE WHEN jsonb_typeof(resolved_scopes_json::jsonb) = 'array' THEN resolved_scopes_json::jsonb ELSE '[]' END) e
|
|
8
8
|
WHERE starts_with(e->>'scope', ?))`,[e,`${r}:`])!==void 0}n(ye,"activeGrantNamesApp");const m="status = 'active' AND computed_rev = rev AND scopes_json IS NOT NULL AND resolved_scopes_json IS NOT NULL",X="computed_rev = rev AND scopes_json IS NOT NULL AND resolved_scopes_json IS NOT NULL";function S(){return A()?" AND grantee = 'app:terminal'":""}n(S,"localOnly");async function ge(){return(await c("DISTINCT sub",X)).map(e=>e.sub)}n(ge,"grantSubs");async function Ee(e){return b(e===void 0?await c("*","status = 'active'"):await c("*","sub = ? AND status = 'active'",[e]))}n(Ee,"activeGrants");async function ve(e){const r=await c("*","sub = ? AND status = 'active'",[e]);return new Set(B(r.flatMap(t=>{try{return[_(t)]}catch(s){if(s instanceof TypeError||s instanceof SyntaxError)return[];throw s}})))}n(ve,"grantedProviderIds");function xe(e,r){return e.source_marketplace===null&&e.source_path===null&&r.has(e.name)}n(xe,"isProviderBundleRow");async function me(e){return(await c("*","sub = ? AND status = 'active'",[e])).flatMap(t=>{const s=p(t);return s===null?[]:[s]})}n(me,"activeGrantsOfPerson");async function Y(){return b(await c("*","true"))}n(Y,"allGrants");async function Se(e){return(await c("sub, status, rev, computed_rev, resolved_scopes_json, scopes_json IS NOT NULL AS has_scopes","sub = ?",[e])).flatMap(t=>{if(!w(t.rev,t.computed_rev,t.has_scopes,t.resolved_scopes_json!==null))return[];try{return[{sub:t.sub,status:t.status,resolved_scopes:l(JSON.parse(t.resolved_scopes_json))}]}catch(s){if(s instanceof TypeError||s instanceof SyntaxError)return[];throw s}})}n(Se,"grantsOfPerson");function b(e){return e.flatMap(r=>{try{return[_(r)]}catch(t){if(t instanceof TypeError||t instanceof SyntaxError)return[];throw t}})}n(b,"records");function z(e){return e.expires_at!==null&&!(Date.parse(e.expires_at)>Date.now())}n(z,"grantExpired");function Z(e){if(e.status!=="active"||z(e))return null;try{const r=e.resolved_scopes.map(({scope:t})=>C(t));return{...e,resolved:e.resolved_scopes.flatMap(({mode:t},s)=>t==="always"?[r[s]]:[])}}catch(r){if(r instanceof TypeError||r instanceof SyntaxError)return null;throw r}}n(Z,"activeRecord");function N(e){return Array.isArray(e)?`[${e.map(N).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().filter(r=>e[r]!==void 0).map(r=>`${JSON.stringify(r)}:${N(e[r])}`).join(",")}}`:JSON.stringify(e)??"null"}n(N,"canonicalJson");function Ne(e){const r={rev:e.rev,resolved_scopes:e.resolved_scopes,spend_cap:e.spend_cap,payer:e.payer,dependencies:e.dependencies??{},...e.inference_endpoint?{inference_endpoint:e.inference_endpoint}:{}};return L("sha256").update(N(r)).digest("base64url").slice(0,22)}n(Ne,"grantVersion");async function Te(e){return!!await u("1","id = ?",[e])}n(Te,"hasGrant");async function Ae(e){return await u("rev, status","id = ?",[e])??null}n(Ae,"grantSyncState");async function Oe(e,r){return await u("rev, status","grantee = ? AND sub = ?",[e,r])??null}n(Oe,"grantSyncStateFor");async function K(e){const r=await u("*","id = ?",[e]);if(!r)return null;try{return _(r)}catch(t){if(t instanceof TypeError||t instanceof SyntaxError)return null;throw t}}n(K,"grantRecord");async function je(e){const r=await u("*","id = ?",[e]);if(!r)return{standing:"inactive",rev:null,sub:null,grantee:null,status:null,removal_done_at:null,record:null};const t={rev:r.rev,sub:r.sub,grantee:r.grantee,status:r.status,removal_done_at:r.removal_done_at??null};if(r.status!=="active")return{...t,standing:"inactive",record:null};if(r.computed_rev!==r.rev)return{...t,standing:"lagging",record:null};const s=p(r);return s===null?{...t,standing:"inactive",record:null}:{...t,standing:"active",record:s}}n(je,"grantStanding");async function we(e){return(await c("id",e)).map(r=>r.id)}n(we,"grantIdsWhere");async function be(e){const r=e?await K(e):null;return r!==null&&H(r)?"app":"user"}n(be,"payerOfGrant");async function Q(e){return p(await u("*","id = ?",[e]))}n(Q,"activeGrant");async function he(e,r){const t=await u("*","grantee = ? AND grantee_prefix IS NULL AND sub = ?",[e,r]);if(t)return p(t);const s=await c("*","sub = ? AND grantee_prefix IS NOT NULL AND starts_with(?, grantee_prefix)",[r,e]);return s.sort((o,a)=>a.grantee_prefix.length-o.grantee_prefix.length),p(s[0])}n(he,"grantFor");async function Re(e){if(y({grantee:e}))return null;const r=await c("*","grantee = ? AND status = 'active'",[e]);if(r.length>1)throw new Error(`multiple active grants for ${e}`);return p(r[0])}n(Re,"activeGrantForApp");async function De(e){const r=await Q(e);return r&&r.run_notice_url&&!y(r)?{url:r.run_notice_url,sub:r.sub,grantee:r.grantee}:null}n(De,"runNoticeTarget");async function Ie(e){const r=await c("*","grantee = 'app:terminal' AND sub = ? AND status = 'active'",[e]);if(r.length>1)throw new Error(`multiple active terminal grants for ${e}`);return p(r[0])}n(Ie,"terminalGrant");async function Le(){return(await(await d()).prepare("SELECT value FROM runtime_state WHERE key = 'grants_source'").get())?.value??null}n(Le,"grantsSource");async function Ce(e){return(await(await d()).prepare("SELECT value FROM runtime_state WHERE key = 'grants_source'").get())?.value===e}n(Ce,"hasSyncedGrants");async function Me(e){return(await e.prepare("SELECT value FROM runtime_state WHERE key = 'grants_source'").get())?.value!=="local"?0:(await e.prepare("DELETE FROM runtime_state WHERE key = 'grants_source'").run(),Number((await e.prepare("DELETE FROM grants").run()).changes))}n(Me,"dropLocalGrantMirror");function Fe(e){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError("invalid grant sync response");const r=[];for(const t of e){const{team:s,members:o}=t??{};if(!(typeof s!="string"||!/^team:\S+$/.test(s))){if(!Array.isArray(o)||o.some(a=>typeof a!="string"||!/^user:[^\s*]+$/.test(a)))throw new TypeError("invalid grant sync response");r.push({team:s,members:o})}}return r}n(Fe,"teamsOf");async function $e(e,r,t,s=[]){const o=new Set;for(const a of e){if(o.has(a.id)||!a.id||!a.runtime||!a.sub||!a.grantee||!Number.isInteger(a.rev)||!["active","revoked","removed"].includes(a.status))throw new TypeError("invalid grant sync response");if(a.grantee==="*"!=(a.grantee_prefix!=null))throw new TypeError("invalid grant sync response");o.add(a.id),l(a.scopes),l(a.resolved_scopes)}await M(async a=>{let E=0;const v=[...o];E+=Number((await(v.length?a.prepareUncached(`DELETE FROM grants WHERE id NOT IN (${v.map(()=>"?").join(",")})`).run(...v):a.prepareUncached("DELETE FROM grants").run())).changes);const h=a.prepare(`INSERT INTO grants
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var S=Object.defineProperty;var a=(e,r)=>S(e,"name",{value:r,configurable:!0});import{directoryIssuer as v}from"../directory/issuer.js";import{outboundFetch as $}from"../events/outbound.js";import{warn as u}from"../output.js";import{canonicalJson as
|
|
1
|
+
var S=Object.defineProperty;var a=(e,r)=>S(e,"name",{value:r,configurable:!0});import{directoryIssuer as v}from"../directory/issuer.js";import{outboundFetch as $}from"../events/outbound.js";import{warn as u}from"../output.js";import{canonicalJson as _,principalPayer as k}from"./mirror.js";let y=5e3;function T(e){y=e}a(T,"setShadowTtl");const A=512,M=["status","scopes","resolved_scopes","spend_cap","payer","dependencies","run_notice_url","inference_endpoint"];function z(){g.clear()}a(z,"resetShadowCache");const g=new Map,f=new Map,o={agree:0,disagree:0,lagging:0,error:0};async function x(e,r,n){const{mintDirectoryToken:i}=await import("./sync.js"),c=await i(e),t=n?`&epochs=${n.epochs.global},${n.epochs.sub}`:"",s=`${e}/v1/runtime/grant-answers?sub=${encodeURIComponent(r)}${t}`,d=await $("grant_shadow",s,{headers:{Authorization:`Bearer ${c.access_token}`},signal:AbortSignal.timeout(1e4)});if(!d.ok)throw new Error(`grant-answers ${d.status}`);const p=await d.json();if(p.unchanged){if(!n)throw new Error("grant-answers said unchanged to a caller holding nothing");return{...n,epochs:p.epochs,checkedAt:Date.now()}}return{epochs:p.epochs,grants:new Map((p.grants??[]).map(m=>[String(m.id),m])),checkedAt:Date.now()}}a(x,"fetchAnswer");async function b(e,r){const n=g.get(r);if(n&&Date.now()-n.checkedAt<y)return n;const i=f.get(r);if(i)return i;const c=x(e,r,n).then(t=>(g.delete(r),g.set(r,t),g.size>A&&g.delete(g.keys().next().value),t)).finally(()=>f.delete(r));return f.set(r,c),c}a(b,"answerFor");const h=new Set;async function P(){await Promise.all([...h])}a(P,"shadowIdle");async function C(e){const r=v();if(r===null)return;const n=(await b(r,e.sub)).grants.get(e.id);if(!n){o.disagree++,u(`grant_shadow disagree ${JSON.stringify({grant:e.id,sub:e.sub,fields:["missing"]})}`);return}if(n.rev!==e.rev){o.lagging++;return}const i={...n,payer:k(n.payer,e.sub,e.grantee)},c={...e,resolved_scopes:O(e.resolved_scopes,n.resolved_scopes)},t=M.filter(s=>_(i[s]??null)!==_(c[s]??null));if(t.length===0){o.agree++;return}o.disagree++,u(`grant_shadow disagree ${JSON.stringify({grant:e.id,sub:e.sub,rev:e.rev,fields:t})}`)}a(C,"compare");function O(e,r){if(!Array.isArray(r))return e;const n=new Set(r.flatMap(t=>{const s=t?.scope;return typeof s=="string"?[s]:[]})),i=new Set([...n].filter(t=>t.endsWith(":*")).map(t=>t.slice(0,-2)));if(i.size===0)return e;const c=new Set;return e.flatMap(t=>{const s=t.scope.slice(0,t.scope.indexOf(":"));return s==="crtr"||!i.has(s)||n.has(t.scope)?[t]:c.has(s)?[]:(c.add(s),[{...t,scope:`${s}:*`}])})}a(O,"compactLike");let w,l={agree:0,disagree:0,lagging:0,error:0};function D(){w||(w=setInterval(()=>{const e={agree:o.agree-l.agree,disagree:o.disagree-l.disagree,lagging:o.lagging-l.lagging,error:o.error-l.error};l={...o},e.agree+e.disagree+e.lagging+e.error>0&&u(`grant_shadow_summary ${JSON.stringify({window_s:60,...e})}`)},6e4),w.unref())}a(D,"startSummary");function U(e){if(!process.env.CRTR_RUNTIME)return;D();const r=C(e).catch(n=>{o.error++,u(`grant_shadow error ${JSON.stringify({grant:e.id,message:n instanceof Error?n.message:String(n)})}`)}).finally(()=>h.delete(r));h.add(r)}a(U,"shadowCheck");export{z as resetShadowCache,T as setShadowTtl,U as shadowCheck,o as shadowCounts,P as shadowIdle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var q=Object.defineProperty;var s=(e,r)=>q(e,"name",{value:r,configurable:!0});import{parsePrincipal as G}from"@north-light/identity";import{randomUUID as N}from"node:crypto";import{cloudPersonScope as T}from"../../../core/runs/operations.js";import{directoryIssuer as
|
|
1
|
+
var q=Object.defineProperty;var s=(e,r)=>q(e,"name",{value:r,configurable:!0});import{parsePrincipal as G}from"@north-light/identity";import{randomUUID as N}from"node:crypto";import{cloudPersonScope as T}from"../../../core/runs/operations.js";import{directoryIssuer as x}from"../../../core/directory/issuer.js";import{activeGrantForApp as F,grantFor as k,grantsOfPerson as C,localGrants as j,providerIdsFromGrants as S}from"../../../core/grants/mirror.js";import{getNode as B}from"../../../core/canvas/canvas.js";import{scopeAllowed as D}from"../../../core/scopes.js";import{ProviderError as f,providerErrorBody as M,scopeMissing as U}from"../../../core/providers/errors.js";import{callProvider as z,providerTools as L}from"../../../core/providers/call.js";import{providerInstallState as V}from"../../../core/providers/bundles.js";import{installedProviderPlugins as Z,providerRootClaims as W,resolveProviderRef as J}from"../../../core/providers/roots.js";import{isCloudRole as w}from"../../../core/canvas/person-state.js";import{listAudit as X,writeProviderAudit as H}from"../../../core/providers/audit.js";import{emitEvent as P}from"../../../core/events/emit.js";import{resolvedScopes as _}from"../router.js";const Re=new Set(["provider.tools","provider.call","audit.list"]);async function K(e){if(e.class==="forwarded"){if(e.actor.kind==="person")return{class:"person",sub:null,grantee:null,client_id:null,resolved:null,nodeScopes:null,run_id:null,node_id:null,origin:{node:null,run:null,machine:e.via}};const r=await k(e.actor.app,e.sub);if(!r)throw new f("grant_revoked",`app ${e.actor.app} has no active grant`);return{class:"app",sub:e.sub,grantee:e.actor.app,client_id:null,resolved:r.resolved,nodeScopes:e.actor.node_scopes,run_id:null,node_id:null,origin:{node:e.actor.node,run:e.actor.place?.run??null,machine:e.via}}}if(e.class==="machine"||e.class==="import")throw new f("permission_error","this operation is not available to the caller");if(e.class==="person"&&e.sub!==void 0){if(!w())throw new f("permission_error","provider calls are made by the install's person, a node or an app");return{class:"person",sub:e.sub,grantee:null,client_id:null,resolved:await _(e),nodeScopes:null,run_id:null,node_id:null}}if(e.class==="person")return{class:"person",sub:null,grantee:null,client_id:null,resolved:null,nodeScopes:null,run_id:null,node_id:null};if(e.class==="app"){const r=await F(e.app);if(!r)throw new f("grant_revoked",`app ${e.app} has no active grant`);return{class:"app",sub:r.sub,grantee:e.app,client_id:null,resolved:r.resolved,nodeScopes:e.scopes,run_id:null,node_id:null}}return e.class==="cron"?{class:"app",sub:e.sub,grantee:e.app,client_id:null,resolved:await _(e),nodeScopes:e.scopes,run_id:e.origin_run,node_id:null}:{class:"broker",sub:e.sub,grantee:e.app,client_id:e.client_id,resolved:await _(e),nodeScopes:e.scopes,run_id:e.run??(await B(e.node))?.run_id??null,node_id:e.node}}s(K,"callerFromRequest");function Ie(e){return{class:"app",sub:e.sub,grantee:e.grantee,client_id:e.client_id,actor:e.actor,resolved:e.resolved,nodeScopes:null,run_id:null,node_id:null}}s(Ie,"callerFromApp");const Q=/^([A-Za-z0-9_-]{1,64}):([A-Za-z0-9_-]{1,64})$/;function Y(e){const r=Q.exec(e);return r!==null&&r[1]!=="crtr"}s(Y,"isProviderScope");const A=new WeakMap;function ee(e){let r=A.get(e);return r===void 0&&(r=new Set(e),A.set(e,r)),r}s(ee,"heldSet");function E(e,r){if(e===null)return!0;if(Y(r)){const t=ee(e);return t.has(r)||t.has(`${r.slice(0,r.indexOf(":"))}:*`)}return D(e,r)}s(E,"holds");function R(e,r){return e.class==="person"&&e.resolved===null?!0:E(e.resolved??[],r)&&E(e.nodeScopes,r)}s(R,"callerAllows");function Oe(e,r,t){const o=`${r}:${t}`;if(!R(e,o))throw U(o)}s(Oe,"requireGroup");function re(){return!!x()}s(re,"providerOperationsEnabled");const oe=/^[A-Za-z0-9_-]{1,64}$/;function p(e,r){return new f("invalid_request",e,{param:r})}s(p,"invalid");function I(e){if(typeof e!="string"||!oe.test(e)||e==="crtr")throw p("provider must be a provider id","provider");return e}s(I,"parseProvider");function te(e){if(!e||typeof e!="object"||Array.isArray(e))throw new f("invalid_request","a JSON object is required");const r=e,t=I(r.provider),o=r.tool;if(typeof o!="string"||!o.trim())throw p("tool must be a non-empty string","tool");const d=r.arguments??{};if(!d||typeof d!="object"||Array.isArray(d))throw p("arguments must be an object","arguments");const a=r.version;if(a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<1))throw p("version must be an integer >= 1","version");const u=r.approval;if(u!==void 0&&(typeof u!="string"||!u))throw p("approval must be a question id","approval");const l=r.machine;if(l!==void 0&&(typeof l!="string"||!l.trim()))throw p("machine must be a machine id","machine");const i=r.as;if(i!==void 0&&(typeof i!="string"||G(i)===null))throw p("as must be a principal like user:<id> or app:<id>/<path>","as");return{provider:t,tool:o.trim(),arguments:d,...a===void 0?{}:{version:a},...u===void 0?{}:{approval:u},...l===void 0?{}:{machine:l.trim()},...i===void 0?{}:{as:i}}}s(te,"parseCallInput");async function ne(e,r=new URLSearchParams){const t=s((i,v,b)=>{const m=r.get(i);if(m===null)return v;if(!/^\d+$/.test(m)||Number(m)>b||Number(m)<1)throw p(`invalid ${i}`,i);return Number(m)},"numeric"),o=r.has("after")?t("after",0,Number.MAX_SAFE_INTEGER):void 0,d=t("limit",100,1e3),a=Object.fromEntries(["operation","outcome","run_id","since","until"].filter(i=>r.has(i)).map(i=>[i,r.get(i)])),u=T(e.sub),l=u===void 0?{}:{sub:u};return{status:200,body:await X(e.class==="person"?null:e.grantee,{after:o,limit:d,...l,...a})}}s(ne,"auditList");async function se(e,r,t){let o=r;const d=performance.now(),a=Z(),{skipped:u}=W(a),l=w()?e.sub?await C(e.sub):[]:await j(),i=w()?new Set(S(l.filter(n=>n.sub===e.sub))):null,v=s(n=>!u.has(n)&&(i===null||i.has(n)),"shown"),b=new Set(a.filter(n=>n.enabled&&n.manifest.provider?.id===n.name&&v(n.name)).map(n=>n.name)),m=S(l).filter(v),g=[...new Set([...b,...m])].sort();if(o!==void 0){const n=J(o);if(n===null)throw new f("not_found",`provider "${o}" is not available`);o=n}if(o!==void 0&&!g.includes(o))throw new f("not_found",`provider "${o}" is not available`);const O=o===void 0?g:[o],$=e.class==="person"?l.flatMap(n=>n.status==="active"&&(!w()||n.sub===e.sub)?n.resolved_scopes.map(({scope:c})=>c):[]):e.resolved??[],h=await Promise.all(O.map(async n=>{if(b.has(n))return L(e,n);if(!$.some(y=>y.startsWith(`${n}:`)&&R(e,y)))return null;const c=V(n);return c===void 0?null:{provider:n,display_name:n,status:c.status,...c.error?{error:c.error}:{},groups:[],commands:[]}})).then(n=>n.filter(c=>c!==null));if(P({level:"debug",event:"api.provider.tools",duration_ms:performance.now()-d,fields:{caller:e.class,provider:o??null,providers:h.length}}),o!==void 0){if(h.length===0)throw new f("not_found",`provider "${o}" is not available`);return{status:200,body:h[0]}}return{status:200,body:{providers:h}}}s(se,"providerTools");async function ie(e,r,t){return z(e,r,t)}s(ie,"providerCall");async function de(e,r,t,o){if(!re())throw new f("not_found","provider operations need a directory-connected runtime");if(e==="audit.list")return await ne(r,t.query);if(e==="provider.tools")return se(r,t.params.provider===void 0?void 0:I(t.params.provider),o);if(e==="provider.call"){let d;try{d=te(t.body)}catch(a){const u=t.body&&typeof t.body=="object"&&!Array.isArray(t.body)?t.body:{};throw await H({request_id:o.requestId,caller:r,provider:typeof u.provider=="string"?u.provider:"",tool:typeof u.tool=="string"?u.tool:"",outcome:`refused:${a instanceof f?a.code:"invalid_request"}`}),a}return ie(r,d,o)}throw new f("not_found","unknown operation")}s(de,"handleProviderOperation");function ae(e){const r=new AbortController,t=s(()=>{e.writableFinished||r.abort()},"abort");return e.on("close",t),{signal:r.signal,release:s(()=>e.off("close",t),"release")}}s(ae,"abortOnClose");function ue(e,r,t,o){const d=M(e,r,t,o??void 0);return d.status>=500&&!(e instanceof f)&&P({event:"api.provider.failed",level:"error",error:e instanceof Error?e:new Error(String(e)),fields:{request_id:r}}),d}s(ue,"providerFailure");const $e=[{method:"GET",pattern:"/v1/audit",name:"audit.list"},{method:"GET",pattern:"/v1/providers/tools",name:"provider.tools"},{method:"GET",pattern:"/v1/providers/:provider/tools",name:"provider.tools"},{method:"POST",pattern:"/v1/provider/call",name:"provider.call"}].map(({method:e,pattern:r,name:t})=>({method:e,pattern:r,handler:s(async o=>{const d=N(),{signal:a,release:u}=ae(o.res);let l=null;try{return l=await K(o.principal),{...await de(t,l,{params:o.params,body:o.body,query:new URL(o.req.url??"/","http://runtime.local").searchParams},{requestId:d,signal:a,...o.causedBy===void 0?{}:{causedBy:o.causedBy}}),headers:{"Request-Id":d}}}catch(i){return ue(i,d,!1,l?.run_id)}finally{u()}},"handler")}));export{Re as PROVIDER_OPERATIONS,ae as abortOnClose,R as callerAllows,Ie as callerFromApp,K as callerFromRequest,de as handleProviderOperation,te as parseCallInput,I as parseProvider,ue as providerFailure,re as providerOperationsEnabled,$e as providerRoutes,Oe as requireGroup};
|
|
@@ -7,6 +7,12 @@ 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.759
|
|
11
|
+
|
|
12
|
+
### A grant can hold a whole provider as `<provider>:*`
|
|
13
|
+
|
|
14
|
+
`grant.get().resolved_scopes` may contain `<provider>:*` (for example `integrations:*`) in place of one entry per group. It means every group of that provider the grant may hold. Check a scope with the new `holds(resolved_scopes, scope)` export instead of comparing strings, because `integrations:gmail` is held while only `integrations:*` is listed. The directory sends this form only to a runtime that understands it.
|
|
15
|
+
|
|
10
16
|
## 0.3.755
|
|
11
17
|
|
|
12
18
|
### An app can start runs in its own environment with no person
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.759",
|
|
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.759",
|
|
161
|
+
"@north-light/plugin": "0.3.759",
|
|
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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
//
|
|
13
13
|
// PURITY (spec §3.1): Node built-ins + `src/api/*` only.
|
|
14
14
|
/** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
|
|
15
|
-
export const CONTRACT_LEVEL = '1.
|
|
15
|
+
export const CONTRACT_LEVEL = '1.80';
|
|
16
16
|
/** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
|
|
17
17
|
export const REQUIRED_CONTRACT_HEADER = 'Crouter-Required-Contract';
|
|
18
18
|
/** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
|
|
@@ -150,7 +150,7 @@ export async function otherLiveGrantOfApp(app, sub) {
|
|
|
150
150
|
}
|
|
151
151
|
/** Contract 1's `<id>` grammar, shared by provider ids and group ids. */
|
|
152
152
|
const ID = '[A-Za-z0-9_-]{1,64}';
|
|
153
|
-
const PROVIDER_SCOPE = new RegExp(`^(${ID}):(${ID})$`);
|
|
153
|
+
const PROVIDER_SCOPE = new RegExp(`^(${ID}):(${ID}|\\*)$`);
|
|
154
154
|
/** Every provider id a scope of an active grant's resolved set names: a
|
|
155
155
|
* `<id>:<group>` string whose id is not `crtr` (the runtime's own namespace). */
|
|
156
156
|
export function providerIdsFromGrants(grants) {
|
|
@@ -180,7 +180,7 @@ export async function activeProviderIds() {
|
|
|
180
180
|
SELECT DISTINCT e->>'scope' AS scope FROM (
|
|
181
181
|
SELECT t::jsonb AS j FROM (SELECT DISTINCT resolved_scopes_json AS t FROM grants WHERE ${ACTIVE_COMPUTED}${localOnly()}${scope.sql}) d OFFSET 0) p
|
|
182
182
|
CROSS JOIN LATERAL jsonb_array_elements(CASE WHEN jsonb_typeof(p.j) = 'array' THEN p.j ELSE '[]' END) e) s
|
|
183
|
-
CROSS JOIN LATERAL regexp_match(s.scope, '^(${ID})
|
|
183
|
+
CROSS JOIN LATERAL regexp_match(s.scope, '^(${ID}):(?:${ID}|\\*)$') m
|
|
184
184
|
WHERE m[1] <> 'crtr'`).all(...scope.args);
|
|
185
185
|
return rows.map((row) => row.id).sort();
|
|
186
186
|
}
|
|
@@ -69,7 +69,8 @@ async function compare(stored) {
|
|
|
69
69
|
}
|
|
70
70
|
// The directory may still send the older `'user'`/`'app'` payer; the mirror stores it as a principal.
|
|
71
71
|
const liveSide = { ...live, payer: principalPayer(live['payer'], stored.sub, stored.grantee) };
|
|
72
|
-
const
|
|
72
|
+
const storedSide = { ...stored, resolved_scopes: compactLike(stored.resolved_scopes, live['resolved_scopes']) };
|
|
73
|
+
const fields = COMPARED.filter((key) => canonicalJson(liveSide[key] ?? null) !== canonicalJson(storedSide[key] ?? null));
|
|
73
74
|
if (fields.length === 0) {
|
|
74
75
|
shadowCounts.agree++;
|
|
75
76
|
return;
|
|
@@ -77,6 +78,29 @@ async function compare(stored) {
|
|
|
77
78
|
shadowCounts.disagree++;
|
|
78
79
|
warn(`grant_shadow disagree ${JSON.stringify({ grant: stored.id, sub: stored.sub, rev: stored.rev, fields })}`);
|
|
79
80
|
}
|
|
81
|
+
// The live answer may hold `<provider>:*` where the stored column still lists each group (phase 4). Fold the stored groups of each such
|
|
82
|
+
// provider into its wildcard, keeping the first group's mode and position, so the two forms compare equal when they name the same providers. A group the live answer still names (an `own` group) stays.
|
|
83
|
+
function compactLike(stored, live) {
|
|
84
|
+
if (!Array.isArray(live))
|
|
85
|
+
return stored;
|
|
86
|
+
const named = new Set(live.flatMap((entry) => {
|
|
87
|
+
const scope = entry?.scope;
|
|
88
|
+
return typeof scope === 'string' ? [scope] : [];
|
|
89
|
+
}));
|
|
90
|
+
const wild = new Set([...named].filter((scope) => scope.endsWith(':*')).map((scope) => scope.slice(0, -2)));
|
|
91
|
+
if (wild.size === 0)
|
|
92
|
+
return stored;
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
return stored.flatMap((entry) => {
|
|
95
|
+
const provider = entry.scope.slice(0, entry.scope.indexOf(':'));
|
|
96
|
+
if (provider === 'crtr' || !wild.has(provider) || named.has(entry.scope))
|
|
97
|
+
return [entry];
|
|
98
|
+
if (seen.has(provider))
|
|
99
|
+
return [];
|
|
100
|
+
seen.add(provider);
|
|
101
|
+
return [{ ...entry, scope: `${provider}:*` }];
|
|
102
|
+
});
|
|
103
|
+
}
|
|
80
104
|
let summaryTimer;
|
|
81
105
|
let reported = { agree: 0, disagree: 0, lagging: 0, error: 0 };
|
|
82
106
|
// One greppable line a minute while checks are happening: `grep grant_shadow_summary`; sum `disagree` across pods over 7 days.
|
|
@@ -68,7 +68,7 @@ export function callerFromApp(principal) {
|
|
|
68
68
|
return { class: 'app', sub: principal.sub, grantee: principal.grantee, client_id: principal.client_id, actor: principal.actor, resolved: principal.resolved, nodeScopes: null, run_id: null, node_id: null };
|
|
69
69
|
}
|
|
70
70
|
/** A provider scope `<provider>:<group>` (the identity grammar's `provider`
|
|
71
|
-
* selector kind).
|
|
71
|
+
* selector kind). It is held by itself or by the wildcard `<provider>:*`. */
|
|
72
72
|
const PROVIDER_SCOPE = /^([A-Za-z0-9_-]{1,64}):([A-Za-z0-9_-]{1,64})$/;
|
|
73
73
|
function isProviderScope(scope) {
|
|
74
74
|
const match = PROVIDER_SCOPE.exec(scope);
|
|
@@ -87,13 +87,15 @@ function heldSet(scopes) {
|
|
|
87
87
|
return set;
|
|
88
88
|
}
|
|
89
89
|
/** `scopeAllowed` with the provider-scope case answered by set membership:
|
|
90
|
-
* `covers(held, '<p>:<g>')` is true only for `held
|
|
90
|
+
* `covers(held, '<p>:<g>')` is true only for `held` = `<p>:<g>` or `<p>:*`, so the
|
|
91
91
|
* answer is identical and costs O(1) instead of a selector parse per held scope. */
|
|
92
92
|
function holds(scopes, scope) {
|
|
93
93
|
if (scopes === null)
|
|
94
94
|
return true;
|
|
95
|
-
if (isProviderScope(scope))
|
|
96
|
-
|
|
95
|
+
if (isProviderScope(scope)) {
|
|
96
|
+
const set = heldSet(scopes);
|
|
97
|
+
return set.has(scope) || set.has(`${scope.slice(0, scope.indexOf(':'))}:*`);
|
|
98
|
+
}
|
|
97
99
|
return scopeAllowed(scopes, scope);
|
|
98
100
|
}
|
|
99
101
|
/** Does the caller hold `<provider>:<group>`? Both the resolved set and a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.759",
|
|
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",
|
|
@@ -59,8 +59,9 @@ function parseSelector(value) {
|
|
|
59
59
|
if (match)
|
|
60
60
|
return { kind: 'peer', value };
|
|
61
61
|
match = /^([^:]+):([^:]+)$/.exec(value);
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// `<provider>:*` means every group of that provider the grant may hold; it covers each `<provider>:<group>`.
|
|
63
|
+
if (match && match[1] !== 'crtr' && id.test(match[1]) && (match[2] === '*' || id.test(match[2])))
|
|
64
|
+
return { kind: 'provider', value, provider: match[1], group: match[2] };
|
|
64
65
|
throw new TypeError(`Unsupported scope: ${value}`);
|
|
65
66
|
}
|
|
66
67
|
export function parseScope(value, grantee) {
|
|
@@ -90,6 +91,8 @@ export function covers(held, requested) {
|
|
|
90
91
|
return h.holder === r.holder && (h.access === 'rw' || r.access === 'read') &&
|
|
91
92
|
(h.path === '.' || h.path === r.path || r.path.startsWith(`${h.path}/`));
|
|
92
93
|
}
|
|
94
|
+
if (h.kind === 'provider' && r.kind === 'provider')
|
|
95
|
+
return h.provider === r.provider && (h.group === '*' || h.group === r.group);
|
|
93
96
|
return held === requested;
|
|
94
97
|
}
|
|
95
98
|
/** A directory fetch ran past its deadline (or was aborted by its caller before that). `code` is `deadline_exceeded`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.759",
|
|
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.759",
|
|
31
|
+
"@north-light/identity": "0.3.759"
|
|
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.759",
|
|
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.759",
|
|
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.759",
|
|
32
|
+
"@north-light/plugin": "0.3.759",
|
|
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.759",
|
|
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.759",
|
|
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.759",
|
|
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.759",
|
|
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.759",
|
|
11927
|
+
"@north-light/identity": "0.3.759"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.759",
|
|
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.759",
|
|
11936
|
+
"@north-light/identity": "0.3.759",
|
|
11937
|
+
"@north-light/plugin": "0.3.759",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|