@north-light/cli 0.3.644 → 0.3.645

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 +1 @@
1
- var N=Object.defineProperty;var o=(t,e)=>N(t,"name",{value:e,configurable:!0});import{openDb as q}from"../../../core/canvas/db.js";import{assertLaunchKind as c}from"../../../core/runtime/launch-target.js";import{listNodesByProfile as v,shiftProfileNodeDeadlines as L}from"../../../core/canvas/canvas.js";import{liveExecutionForNode as S}from"../../../core/canvas/executions.js";import{shiftJobDeadlines as $}from"../../../core/graph/jobs.js";import{boundFleet as F}from"../../../core/runtime/fleet.js";import{recordedPidLiveness as M}from"../../../core/canvas/pid.js";import{withCanvasWrite as w}from"../../../core/canvas/db.js";import{reposForCwd as R,warmCheckoutIdentities as V}from"../../../core/graph/repo-sync/repos.js";import{renameProfileObject as C}from"../../../core/graph/objects.js";import{usage as l}from"../../../core/errors.js";import{ApiError as f}from"../../../api/errors.js";import{scopeAllowed as E}from"../../../core/scopes.js";import{validateEnvVarName as G}from"../../../core/env-name.js";import{listProfileEnvNames as U,removeProfileEnvVar as H,setProfileEnvVar as K}from"../../../core/profiles/env-store.js";import{isDeploymentName as W,listAppEnvNames as B,removeAppEnvVar as J,setAppEnvVar as z}from"../../../core/profiles/app-env-store.js";import{addProfileProject as Q,assertDeliveryLimits as X,setProfileDeliveryLimit as g,assertProfileProjects as h,createProfile as j,ensureRootProfile as Y,listProfiles as m,loadProfileManifest as y,pauseProfile as Z,removeProfileProject as x,renameProfile as ee,resumeProfile as te,setProfileDefaultKind as ae,updateProfileMetadata as ne}from"../../../core/profiles/manifest.js";import{requestProfileDeletion as re}from"../../profile-delete.js";import{brokerSignalBus as ie}from"../../broker-signals/bus.js";import{toProfileDTO as oe}from"../map.js";import{machineEnvironmentId as se}from"../../../core/environments.js";import{actsAsPerson as _,appOf as b,resolvedScopes as de}from"../router.js";const T="root";function d(t){return{...oe(t),environment_id:t.manifest.environment_id??se()}}o(d,"toProfileDTO");function u(t){return b(t.principal)??"app:terminal"}o(u,"callerApp");function A(t,e,n=null){if(m().some(a=>a.manifest.name===e&&a.profileId!==n&&(a.manifest.grantee??"app:terminal")===t))throw new f(400,"invalid_request",`${t} already has a profile named ${e}`)}o(A,"assertNameFree");async function p(t,e){const n=await k(t,e),a=n.manifest.grantee??"app:terminal";if(!_(t.principal)&&a!==b(t.principal))throw new f(403,"permission_error",`profile ${n.profileId} belongs to ${a}; only that app changes it`);return n}o(p,"requireOwnProfile");async function le(t){const e=t.body??{};if(typeof e.name!="string"||e.name.trim()==="")throw l("a profile name is required",{field:"name"});e.projects!==void 0&&h(e.projects);const n=u(t),a=e.name.trim();A(n,a),e.default_kind!==void 0&&await c(e.default_kind,process.cwd(),null);const i=await j(a,e.projects??[],{defaultKind:e.default_kind,metadata:e.metadata,grantee:n});return{status:201,body:d(i)}}o(le,"handleCreate");async function fe(t,e){const n=e.trim();if(n==="")throw l("profile name must not be empty");return await w(async a=>(await C(a,t,n),await ee(t,n)))}o(fe,"renameProfileAndHandle");async function pe(t,e,n){await V(n);const a=await w(async i=>(await R(i,n)).map(r=>r.name));await Q(t,n);for(const i of a)e[i]===void 0&&e[`repo:${i}`]===void 0&&await g(t,i,"preview")}o(pe,"addProjectWithDefaultLimit");async function me(t){const{profileId:e,manifest:n}=await p(t,t.params.name),a=t.body??{};return a.name!==void 0&&A(n.grantee??"app:terminal",a.name.trim(),e),a.default_kind!==void 0&&await c(a.default_kind,process.cwd(),e),a.add_project!==void 0&&h([a.add_project]),a.set_delivery_limit!==void 0&&X({[a.set_delivery_limit.owner]:a.set_delivery_limit.level}),a.name!==void 0&&await fe(e,a.name),a.default_kind!==void 0&&await ae(e,a.default_kind),a.add_project!==void 0&&await pe(e,n.delivery_limits??{},a.add_project.path),a.set_delivery_limit!==void 0&&await g(e,a.set_delivery_limit.owner,a.set_delivery_limit.level),a.remove_project!==void 0&&await x(e,a.remove_project),{status:200,body:d(y(e))}}o(me,"handleUpdate");async function ue(t){const{profileId:e}=await p(t,t.params.name);return{status:200,body:{profile_id:e,names:await U(e)}}}o(ue,"handleEnvList");function P(t){const e=t.params.var,n=G(e);if(!n.isValid)throw l(`invalid env var name: ${n.errors.join("; ")}`,{field:"name",received:e});return e}o(P,"requireEnvVarName");function D(t){const e=P(t);if(W(e)&&!_(t.principal))throw new f(403,"permission_error",`${e} is deployment-wide; only a person changes it`);return e}o(D,"requireSelfEnvVarName");async function ce(t){const{profileId:e}=await p(t,t.params.name),n=P(t),{value:a}=t.body??{};if(typeof a!="string"||a==="")throw l("a non-empty env value is required",{field:"value"});return{status:200,body:{profile_id:e,changed:await K(e,n,a)}}}o(ce,"handleEnvSet");async function ve(t){const{profileId:e}=await p(t,t.params.name),n=P(t);return{status:200,body:{profile_id:e,changed:await H(e,n)}}}o(ve,"handleEnvRemove");async function we(t){const e=t.params.name,n=t.body??{};n.projects!==void 0&&h(n.projects);const a=u(t);if(e===T&&a==="app:terminal")return{status:200,body:d(await Y())};if(e===T)throw new f(403,"permission_error","root belongs to the terminal app");const i=m().find(s=>s.manifest.name===e&&(s.manifest.grantee??"app:terminal")===a);if(i!==void 0)return{status:200,body:d(i)};n.default_kind!==void 0&&await c(n.default_kind,process.cwd(),null);const r=await j(e,n.projects??[],{defaultKind:n.default_kind,metadata:n.metadata,grantee:a});return{status:200,body:d(r)}}o(we,"handleEnsure");async function he(t){const e=await p(t,t.params.name),n=t.body??{};if(typeof n!="object"||n===null||Array.isArray(n))throw l("profile metadata body must be an object",{field:"body"});const a=n,i=a.unset===void 0?[]:a.unset;if(!Array.isArray(i)||i.some(O=>typeof O!="string"))throw l("profile metadata `unset` must be an array of strings",{field:"unset"});const r=a.set===void 0?{}:a.set,s=await ne(e.profileId,r,i);return{status:200,body:d(s)}}o(he,"handleSetMetadata");async function ye(t){const e=y(t.params.name),n=await Z(e.profileId),a=(await v(e.profileId)).filter(r=>r.status==="active"||r.status==="idle");if(a.length===0)return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}};const i=F();for(const r of a){const s=i.get(r.node_id);if(s!==void 0){await i.interruptForProfilePause(r.node_id,s.pid);continue}r.pi_pid!=null&&M(r.pi_pid,r.pi_pid_identity)==="alive"&&await i.interruptForProfilePause(r.node_id,r.pi_pid)}return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}}}o(ye,"handlePause");async function _e(t){const e=y(t.params.name),n=await te(e.profileId);for(const a of await v(e.profileId))(a.status==="active"||a.status==="idle"||await S(a.node_id)!==null)&&ie.markMail(a.node_id);if(n.pausedAt!==null){const a=Date.parse(n.pausedAt);if(!Number.isNaN(a)){const i=Math.max(0,Date.now()-a);await L(e.profileId,i);for(const r of await v(e.profileId))r.status!=="dead"&&await w(s=>$(s,r.node_id,i))}}return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}}}o(_e,"handleResume");async function I(t){const e=t.principal;if(_(e))return m();if(e.class==="person"&&e.sub!==void 0){const a=await q(),i=new Set((await a.prepare("SELECT id FROM profiles WHERE person = ?").all(e.sub)).map(r=>r.id));return m().filter(({profileId:r})=>i.has(r))}const n=await de(e);return m().filter(({profileId:a,manifest:i})=>{const r=i.grantee??"app:terminal";if(r===b(e))return!0;const s=`crtr:memory:rw:${r}:profile:${a}`;return E(n,s)&&(e.class!=="broker"||E(e.scopes,s))})}o(I,"visibleProfiles");async function k(t,e){const n=await I(t),a=n.find(({profileId:r})=>r===e),i=a?[a]:n.filter(({manifest:r})=>r.name===e);if(i.length===0)throw new f(404,"not_found","profile not found");if(i.length>1)throw new f(400,"ambiguous","profile name matches multiple visible profiles; use an exact id");return i[0]}o(k,"requireUsableProfile");async function be(t){return{status:200,body:(await I(t)).map(d)}}o(be,"handleList");async function Pe(t){return{status:200,body:d(await k(t,t.params.name))}}o(Pe,"handleGet");async function Ee(t){return re((await p(t,t.params.name)).profileId,t.body)}o(Ee,"handleDelete");const Be=[{method:"GET",pattern:"/v1/apps/self/env",handler:o(async t=>({status:200,body:{names:await B(u(t))}}),"handler")},{method:"PUT",pattern:"/v1/apps/self/env/:var",handler:o(async t=>{const e=D(t),{value:n}=t.body??{};if(typeof n!="string"||!n)throw l("a non-empty env value is required",{field:"value"});return{status:200,body:{changed:await z(u(t),e,n)}}},"handler")},{method:"DELETE",pattern:"/v1/apps/self/env/:var",handler:o(async t=>({status:200,body:{changed:await J(u(t),D(t))}}),"handler")},{method:"PUT",pattern:"/v1/profiles/:name",handler:we},{method:"POST",pattern:"/v1/profiles/:name/pause",ownerOnly:!0,handler:ye},{method:"POST",pattern:"/v1/profiles/:name/resume",ownerOnly:!0,handler:_e},{method:"PATCH",pattern:"/v1/profiles/:name/metadata",handler:he},{method:"POST",pattern:"/v1/profiles",handler:le},{method:"PATCH",pattern:"/v1/profiles/:name",handler:me},{method:"GET",pattern:"/v1/profiles/:name/env",handler:ue},{method:"PUT",pattern:"/v1/profiles/:name/env/:var",handler:ce},{method:"DELETE",pattern:"/v1/profiles/:name/env/:var",handler:ve},{method:"DELETE",pattern:"/v1/profiles/:name",handler:Ee},{method:"GET",pattern:"/v1/profiles",handler:be},{method:"GET",pattern:"/v1/profiles/:name",handler:Pe}];export{pe as addProjectWithDefaultLimit,Be as profileRoutes,fe as renameProfileAndHandle,k as requireUsableProfile};
1
+ var N=Object.defineProperty;var o=(a,e)=>N(a,"name",{value:e,configurable:!0});import{openDb as q}from"../../../core/canvas/db.js";import{assertLaunchKind as c}from"../../../core/runtime/launch-target.js";import{listNodesByProfile as v,shiftProfileNodeDeadlines as L}from"../../../core/canvas/canvas.js";import{liveExecutionForNode as S}from"../../../core/canvas/executions.js";import{shiftJobDeadlines as $}from"../../../core/graph/jobs.js";import{boundFleet as F}from"../../../core/runtime/fleet.js";import{recordedPidLiveness as M}from"../../../core/canvas/pid.js";import{withCanvasWrite as w}from"../../../core/canvas/db.js";import{reposForCwd as R,warmCheckoutIdentities as V}from"../../../core/graph/repo-sync/repos.js";import{renameProfileObject as C}from"../../../core/graph/objects.js";import{usage as l}from"../../../core/errors.js";import{ApiError as f}from"../../../api/errors.js";import{scopeAllowed as E}from"../../../core/scopes.js";import{validateEnvVarName as G}from"../../../core/env-name.js";import{listProfileEnvNames as U,removeProfileEnvVar as H,setProfileEnvVar as K}from"../../../core/profiles/env-store.js";import{isDeploymentName as W,listAppEnvNames as B,removeAppEnvVar as J,setAppEnvVar as z}from"../../../core/profiles/app-env-store.js";import{addProfileProject as Q,assertDeliveryLimits as X,setProfileDeliveryLimit as g,assertProfileProjects as h,createProfile as j,ensureRootProfile as Y,listProfiles as m,loadProfileManifest as y,pauseProfile as Z,removeProfileProject as x,renameProfile as ee,resumeProfile as ae,setProfileDefaultKind as te,updateProfileMetadata as ne}from"../../../core/profiles/manifest.js";import{requestProfileDeletion as re}from"../../profile-delete.js";import{brokerSignalBus as ie}from"../../broker-signals/bus.js";import{toProfileDTO as oe}from"../map.js";import{machineEnvironmentId as se}from"../../../core/environments.js";import{actsAsPerson as _,appOf as b,resolvedScopes as de}from"../router.js";const T="root";function d(a){return{...oe(a),environment_id:a.manifest.environment_id??se()}}o(d,"toProfileDTO");function u(a){return b(a.principal)??"app:terminal"}o(u,"callerApp");function A(a,e,n=null){if(m().some(t=>t.manifest.name===e&&t.profileId!==n&&(t.manifest.grantee??"app:terminal")===a))throw new f(400,"invalid_request",`${a} already has a profile named ${e}`)}o(A,"assertNameFree");async function p(a,e){const n=await k(a,e),t=n.manifest.grantee??"app:terminal";if(a.principal.class!=="person"&&!_(a.principal)&&t!==b(a.principal))throw new f(403,"permission_error",`profile ${n.profileId} belongs to ${t}; only that app changes it`);return n}o(p,"requireOwnProfile");async function le(a){const e=a.body??{};if(typeof e.name!="string"||e.name.trim()==="")throw l("a profile name is required",{field:"name"});e.projects!==void 0&&h(e.projects);const n=u(a),t=e.name.trim();A(n,t),e.default_kind!==void 0&&await c(e.default_kind,process.cwd(),null);const i=await j(t,e.projects??[],{defaultKind:e.default_kind,metadata:e.metadata,grantee:n});return{status:201,body:d(i)}}o(le,"handleCreate");async function fe(a,e){const n=e.trim();if(n==="")throw l("profile name must not be empty");return await w(async t=>(await C(t,a,n),await ee(a,n)))}o(fe,"renameProfileAndHandle");async function pe(a,e,n){await V(n);const t=await w(async i=>(await R(i,n)).map(r=>r.name));await Q(a,n);for(const i of t)e[i]===void 0&&e[`repo:${i}`]===void 0&&await g(a,i,"preview")}o(pe,"addProjectWithDefaultLimit");async function me(a){const{profileId:e,manifest:n}=await p(a,a.params.name),t=a.body??{};return t.name!==void 0&&A(n.grantee??"app:terminal",t.name.trim(),e),t.default_kind!==void 0&&await c(t.default_kind,process.cwd(),e),t.add_project!==void 0&&h([t.add_project]),t.set_delivery_limit!==void 0&&X({[t.set_delivery_limit.owner]:t.set_delivery_limit.level}),t.name!==void 0&&await fe(e,t.name),t.default_kind!==void 0&&await te(e,t.default_kind),t.add_project!==void 0&&await pe(e,n.delivery_limits??{},t.add_project.path),t.set_delivery_limit!==void 0&&await g(e,t.set_delivery_limit.owner,t.set_delivery_limit.level),t.remove_project!==void 0&&await x(e,t.remove_project),{status:200,body:d(y(e))}}o(me,"handleUpdate");async function ue(a){const{profileId:e}=await p(a,a.params.name);return{status:200,body:{profile_id:e,names:await U(e)}}}o(ue,"handleEnvList");function P(a){const e=a.params.var,n=G(e);if(!n.isValid)throw l(`invalid env var name: ${n.errors.join("; ")}`,{field:"name",received:e});return e}o(P,"requireEnvVarName");function D(a){const e=P(a);if(W(e)&&!_(a.principal))throw new f(403,"permission_error",`${e} is deployment-wide; only a person changes it`);return e}o(D,"requireSelfEnvVarName");async function ce(a){const{profileId:e}=await p(a,a.params.name),n=P(a),{value:t}=a.body??{};if(typeof t!="string"||t==="")throw l("a non-empty env value is required",{field:"value"});return{status:200,body:{profile_id:e,changed:await K(e,n,t)}}}o(ce,"handleEnvSet");async function ve(a){const{profileId:e}=await p(a,a.params.name),n=P(a);return{status:200,body:{profile_id:e,changed:await H(e,n)}}}o(ve,"handleEnvRemove");async function we(a){const e=a.params.name,n=a.body??{};n.projects!==void 0&&h(n.projects);const t=u(a);if(e===T&&t==="app:terminal")return{status:200,body:d(await Y())};if(e===T)throw new f(403,"permission_error","root belongs to the terminal app");const i=m().find(s=>s.manifest.name===e&&(s.manifest.grantee??"app:terminal")===t);if(i!==void 0)return{status:200,body:d(i)};n.default_kind!==void 0&&await c(n.default_kind,process.cwd(),null);const r=await j(e,n.projects??[],{defaultKind:n.default_kind,metadata:n.metadata,grantee:t});return{status:200,body:d(r)}}o(we,"handleEnsure");async function he(a){const e=await p(a,a.params.name),n=a.body??{};if(typeof n!="object"||n===null||Array.isArray(n))throw l("profile metadata body must be an object",{field:"body"});const t=n,i=t.unset===void 0?[]:t.unset;if(!Array.isArray(i)||i.some(O=>typeof O!="string"))throw l("profile metadata `unset` must be an array of strings",{field:"unset"});const r=t.set===void 0?{}:t.set,s=await ne(e.profileId,r,i);return{status:200,body:d(s)}}o(he,"handleSetMetadata");async function ye(a){const e=y(a.params.name),n=await Z(e.profileId),t=(await v(e.profileId)).filter(r=>r.status==="active"||r.status==="idle");if(t.length===0)return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}};const i=F();for(const r of t){const s=i.get(r.node_id);if(s!==void 0){await i.interruptForProfilePause(r.node_id,s.pid);continue}r.pi_pid!=null&&M(r.pi_pid,r.pi_pid_identity)==="alive"&&await i.interruptForProfilePause(r.node_id,r.pi_pid)}return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}}}o(ye,"handlePause");async function _e(a){const e=y(a.params.name),n=await ae(e.profileId);for(const t of await v(e.profileId))(t.status==="active"||t.status==="idle"||await S(t.node_id)!==null)&&ie.markMail(t.node_id);if(n.pausedAt!==null){const t=Date.parse(n.pausedAt);if(!Number.isNaN(t)){const i=Math.max(0,Date.now()-t);await L(e.profileId,i);for(const r of await v(e.profileId))r.status!=="dead"&&await w(s=>$(s,r.node_id,i))}}return{status:200,body:{profile_id:e.profileId,paused_at:n.manifest.paused_at}}}o(_e,"handleResume");async function I(a){const e=a.principal;if(_(e))return m();if(e.class==="person"&&e.sub!==void 0){const t=await q(),i=new Set((await t.prepare("SELECT id FROM profiles WHERE person = ?").all(e.sub)).map(r=>r.id));return m().filter(({profileId:r})=>i.has(r))}const n=await de(e);return m().filter(({profileId:t,manifest:i})=>{const r=i.grantee??"app:terminal";if(r===b(e))return!0;const s=`crtr:memory:rw:${r}:profile:${t}`;return E(n,s)&&(e.class!=="broker"||E(e.scopes,s))})}o(I,"visibleProfiles");async function k(a,e){const n=await I(a),t=n.find(({profileId:r})=>r===e),i=t?[t]:n.filter(({manifest:r})=>r.name===e);if(i.length===0)throw new f(404,"not_found","profile not found");if(i.length>1)throw new f(400,"ambiguous","profile name matches multiple visible profiles; use an exact id");return i[0]}o(k,"requireUsableProfile");async function be(a){return{status:200,body:(await I(a)).map(d)}}o(be,"handleList");async function Pe(a){return{status:200,body:d(await k(a,a.params.name))}}o(Pe,"handleGet");async function Ee(a){return re((await p(a,a.params.name)).profileId,a.body)}o(Ee,"handleDelete");const Be=[{method:"GET",pattern:"/v1/apps/self/env",handler:o(async a=>({status:200,body:{names:await B(u(a))}}),"handler")},{method:"PUT",pattern:"/v1/apps/self/env/:var",handler:o(async a=>{const e=D(a),{value:n}=a.body??{};if(typeof n!="string"||!n)throw l("a non-empty env value is required",{field:"value"});return{status:200,body:{changed:await z(u(a),e,n)}}},"handler")},{method:"DELETE",pattern:"/v1/apps/self/env/:var",handler:o(async a=>({status:200,body:{changed:await J(u(a),D(a))}}),"handler")},{method:"PUT",pattern:"/v1/profiles/:name",handler:we},{method:"POST",pattern:"/v1/profiles/:name/pause",ownerOnly:!0,handler:ye},{method:"POST",pattern:"/v1/profiles/:name/resume",ownerOnly:!0,handler:_e},{method:"PATCH",pattern:"/v1/profiles/:name/metadata",handler:he},{method:"POST",pattern:"/v1/profiles",handler:le},{method:"PATCH",pattern:"/v1/profiles/:name",handler:me},{method:"GET",pattern:"/v1/profiles/:name/env",handler:ue},{method:"PUT",pattern:"/v1/profiles/:name/env/:var",handler:ce},{method:"DELETE",pattern:"/v1/profiles/:name/env/:var",handler:ve},{method:"DELETE",pattern:"/v1/profiles/:name",handler:Ee},{method:"GET",pattern:"/v1/profiles",handler:be},{method:"GET",pattern:"/v1/profiles/:name",handler:Pe}];export{pe as addProjectWithDefaultLimit,Be as profileRoutes,fe as renameProfileAndHandle,k as requireUsableProfile};
@@ -1,2 +1,2 @@
1
- import type { RouteTable } from '../router.js';
1
+ import { type RouteTable } from '../router.js';
2
2
  export declare const subscriptionRoutes: RouteTable;
@@ -1 +1 @@
1
- var l=Object.defineProperty;var p=(n,r)=>l(n,"name",{value:r,configurable:!0});import{ApiError as t}from"../../../api/index.js";import{getNode as o,subscribe as w,subscriptionsOf as b,unsubscribe as f}from"../../../core/canvas/canvas.js";import{toSubscriptionDTO as h}from"../map.js";async function u(n){if(await o(n)===null)throw new t(404,"node_not_found",`unknown node: ${n}`)}p(u,"requireNode");async function g(n){const r=n.params.id,a=n.body??{},i=a.target;if(typeof i!="string"||i==="")throw new t(400,"invalid_request","subscribe body requires a `target` node id");if(i===r)throw new t(422,"unprocessable","a node cannot subscribe to itself");if(await u(r),await u(i),n.principal.class==="broker"){const s=await o(r),c=await o(i);if(s.grantee!==n.principal.app||c.grantee!==n.principal.app||s.run_id!==c.run_id||n.principal.run!==null&&s.run_id!==n.principal.run)throw new t(403,"other_app_run","subscriptions must stay within the calling app run")}const e=a.active??!0;await w(r,i,e);const d=(await b(r)).find(s=>s.node_id===i);if(d===void 0)throw new t(500,"internal","subscription edge vanished after write");return{status:200,body:h(d)}}p(g,"handleSubscribe");async function _(n){const r=n.params.id,a=n.params.target;if(await u(r),n.principal.class==="broker"){const i=await o(r),e=await o(a);if(i.grantee!==n.principal.app||n.principal.run!==null&&i.run_id!==n.principal.run||e&&(e.grantee!==i.grantee||e.run_id!==i.run_id))throw new t(403,"other_app_run","subscriptions must stay within the calling app run")}return await f(r,a),{status:204}}p(_,"handleUnsubscribe");const E=[{method:"POST",pattern:"/v1/nodes/:id/subscriptions",handler:g},{method:"DELETE",pattern:"/v1/nodes/:id/subscriptions/:target",handler:_}];export{E as subscriptionRoutes};
1
+ var b=Object.defineProperty;var o=(t,n)=>b(t,"name",{value:n,configurable:!0});import{ApiError as r}from"../../../api/index.js";import{getNode as f,subscribe as w,subscriptionsOf as p,unsubscribe as m}from"../../../core/canvas/canvas.js";import{toSubscriptionDTO as h}from"../map.js";import{mayOnNode as l}from"../router.js";async function d(t,n){if(!await l(t.principal,"read",n))throw new r(404,"not_found","node not found")}o(d,"requireReadable");async function a(t){if(await f(t)===null)throw new r(404,"node_not_found",`unknown node: ${t}`)}o(a,"requireNode");async function g(t){const n=t.params.id,i=t.body??{},e=i.target;if(typeof e!="string"||e==="")throw new r(400,"invalid_request","subscribe body requires a `target` node id");if(e===n)throw new r(422,"unprocessable","a node cannot subscribe to itself");await a(n),await a(e),await d(t,e);const u=i.active??!0;await w(n,e,u);const s=(await p(n)).find(c=>c.node_id===e);if(s===void 0)throw new r(500,"internal","subscription edge vanished after write");return{status:200,body:h(s)}}o(g,"handleSubscribe");async function y(t){const n=t.params.id,i=t.params.target;return await a(n),await d(t,i),await m(n,i),{status:204}}o(y,"handleUnsubscribe");const N=[{method:"POST",pattern:"/v1/nodes/:id/subscriptions",handler:g},{method:"DELETE",pattern:"/v1/nodes/:id/subscriptions/:target",handler:y}];export{N as subscriptionRoutes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.644",
3
+ "version": "0.3.645",
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.644",
148
+ "@north-light/identity": "0.3.645",
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.644",
3
+ "version": "0.3.645",
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.644",
3
+ "version": "0.3.645",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.644",
9
+ "version": "0.3.645",
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.644",
31
+ "@north-light/identity": "0.3.645",
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.644",
11959
+ "version": "0.3.645",
11960
11960
  "license": "UNLICENSED"
11961
11961
  },
11962
11962
  "packages/crouter-env-docker": {
11963
11963
  "name": "@north-light/env-docker",
11964
- "version": "0.3.644",
11964
+ "version": "0.3.645",
11965
11965
  "license": "UNLICENSED"
11966
11966
  },
11967
11967
  "packages/crouter-identity": {
11968
11968
  "name": "@north-light/identity",
11969
- "version": "0.3.644",
11969
+ "version": "0.3.645",
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.644",
11977
+ "version": "0.3.645",
11978
11978
  "license": "UNLICENSED",
11979
11979
  "dependencies": {
11980
- "@north-light/api": "0.3.644",
11981
- "@north-light/identity": "0.3.644"
11980
+ "@north-light/api": "0.3.645",
11981
+ "@north-light/identity": "0.3.645"
11982
11982
  }
11983
11983
  },
11984
11984
  "packages/crouter-sdk": {
11985
11985
  "name": "@north-light/sdk",
11986
- "version": "0.3.644",
11986
+ "version": "0.3.645",
11987
11987
  "license": "UNLICENSED",
11988
11988
  "dependencies": {
11989
- "@north-light/api": "0.3.644",
11990
- "@north-light/identity": "0.3.644",
11991
- "@north-light/plugin": "0.3.644",
11989
+ "@north-light/api": "0.3.645",
11990
+ "@north-light/identity": "0.3.645",
11991
+ "@north-light/plugin": "0.3.645",
11992
11992
  "jose": "^6.2.1"
11993
11993
  },
11994
11994
  "bin": {