@north-light/cli 0.3.776 → 0.3.778

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,3 +1,3 @@
1
- var y=Object.defineProperty;var t=(e,r)=>y(e,"name",{value:r,configurable:!0});import{defineBranch as w,defineLeaf as h}from"../../core/command.js";import{InputError as l}from"../../core/io.js";import{cliClient as m}from"../api-client.js";const d=t(e=>e===null?"unpriced":`$${e.toFixed(e<1?4:2)}`,"usd"),$=t(e=>[e.funding&&`funding ${e.funding}`,e.grantee&&`grantee ${e.grantee}`,e.provider&&`provider ${e.provider}`,e.sub&&`sub ${e.sub}`].filter(Boolean).join(", ")||"everything","filters"),p=t(e=>`- \`${e.id}\` ${e.payer??e.account} ${d(e.usd_per_month)}/month on ${$(e)} (${e.source})`,"limitLine"),b=h({name:"show",description:"show a month's spend by payer and funding, with the limits",whenToUse:"checking what a payer has spent this month and which limits apply",help:{name:"sys spend show",summary:"month totals by payer and by payer and funding from the ledger, then every limit row",params:[{kind:"flag",name:"month",type:"string",required:!1,constraint:"UTC month YYYY-MM. Default: the current month."}],output:[{name:"month",type:"string",required:!0,constraint:"The month shown, YYYY-MM."},{name:"totals",type:"ChargeTotalsDTO",required:!0,constraint:"Record: {month, by_payer, by_funding, limits}. Migrated user-paid model history has funding `legacy`."}],outputKind:"object",effects:["None. Read-only."]},run:t(async e=>{const r=await m().listCharges({limit:1,...e.month===void 0?{}:{month:String(e.month)}});if(r.totals===void 0)throw new l({error:"owner_only",message:"month totals and limits are read by the person; this caller sees only its own app's charges",next:"Run `crtr sys spend show` from the person's own shell, not from inside a node."});return{month:r.month,totals:r.totals}},"run"),render:t(e=>{const r=e.totals;return[`Spend for ${r.month}:`,...r.by_payer.length===0?["- nothing charged"]:r.by_payer.map(i=>`- ${i.payer} ${d(i.usd)}${r.by_funding.filter(s=>s.payer===i.payer).map(s=>` ${s.funding} ${d(s.usd)}`).join("")}`),"Limits:",...r.limits.length===0?["- none"]:r.limits.map(p)].join(`
2
- `)},"render")});function v(e){const r=new Map;for(const n of e)r.set(n.provider??"(none)",(r.get(n.provider??"(none)")??0)+(n.usd??0));const i=new Set(e.map(n=>n.request)),s=t(n=>e.filter(o=>(o.caused_by??null)===n),"children"),a=[],u=new Set,c=t((n,o)=>{if(!u.has(n.id)&&(u.add(n.id),a.push(`${" ".repeat(o)}- ${n.at} ${n.kind} ${n.what} ${d(n.usd)} ${n.payer}/${n.funding}${n.provider?` \u2192 ${n.provider}`:""} vendor_ref ${n.vendor_ref??"none"}${n.refused?` REFUSED by ${n.refused.limit}`:""}`),n.request!==null))for(const g of s(`request:${n.request}`))c(g,o+1)},"print"),f=e.filter(n=>n.caused_by===null||!(n.caused_by.startsWith("request:")&&i.has(n.caused_by.slice(8))));for(const n of f)c(n,0);for(const n of e)c(n,0);return[...a,"Total per provider:",...[...r].map(([n,o])=>`- ${n} ${d(o)}`)].join(`
3
- `)}t(v,"tree");const q=h({name:"chain",description:"list the charge rows under a run, message, request or charge on this runtime",whenToUse:"finding what one run, message or request cost and matching its vendor_ref to a vendor's usage line",help:{name:"sys spend chain",summary:"the rows under a reference as a tree, with each row's vendor_ref and a total per provider",params:[{kind:"positional",name:"reference",type:"string",required:!0,constraint:"`run:<id>`, `message:<id>`, `request:<id>`, `cron_run:<id>` or a charge id. Reads this runtime only."}],output:[{name:"reference",type:"string",required:!0,constraint:"The reference read."},{name:"charges",type:"ChargeDTO[]",required:!0,constraint:"Rows in time order; empty when this runtime holds none under the reference."}],outputKind:"object",effects:["None. Read-only."]},run:t(async e=>{const r=String(e.reference),i=[];for(let s;;){const a=await m().listCharges({under:r,...s===void 0?{}:{after:s}});if(i.push(...a.charges),a.next===null)break;s=a.next}return{reference:r,charges:i}},"run"),render:t(e=>{const r=e.charges;return r.length===0?`No charges under ${String(e.reference)} on this runtime.`:v(r)},"render")}),_=h({name:"limit",description:"set or clear one of the person's dollar limits",whenToUse:"stopping a payer's spend (0 is an emergency stop) or capping it per month; clearing a limit you set",help:{name:"sys spend limit",summary:"write or remove the limit row `person:<name>`; the check refuses calls billed to the payer once the month reaches it",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"A name for the row; the id is `person:<name>`."},{kind:"flag",name:"payer",type:"string",required:!1,constraint:"`user:<id>` (the person) or `app:<id>`. Required unless --clear."},{kind:"flag",name:"usd",type:"string",required:!1,constraint:"Dollars per month, 0 or more; 0 stops the payer. Required unless --clear."},{kind:"flag",name:"funding",type:"enum",choices:["bill","subscription","key","endpoint","take","legacy"],required:!1,constraint:"Limit only this funding. Default: any."},{kind:"flag",name:"grantee",type:"string",required:!1,constraint:"Limit only charges attributed to this app, such as `app:terminal`. Default: any."},{kind:"flag",name:"provider",type:"string",required:!1,constraint:"Limit only money going to this vendor or provider app, such as `anthropic`. Default: any."},{kind:"flag",name:"clear",type:"bool",required:!1,constraint:"Remove the row instead of writing it."}],output:[{name:"limit",type:"LimitDTO",required:!1,constraint:"The row written; absent with --clear."},{name:"removed",type:"string",required:!1,constraint:"The id removed with --clear."}],outputKind:"object",effects:["Writes or deletes one `limits` row with source `person`. Takes effect on the next call."]},run:t(async e=>{const r=`person:${String(e.name)}`;if(e.clear===!0)return{removed:(await m().removeSpendLimit(r)).id};const i=e.usd===void 0?Number.NaN:Number(e.usd);if(typeof e.payer!="string"||!Number.isFinite(i)||i<0)throw new l({error:"nothing_to_set",message:"a limit needs --payer and --usd (0 or more), or --clear",next:"Pass --payer user:<id> --usd 20, or --clear to remove the row."});return{limit:await m().setSpendLimit(r,{payer:e.payer,usd_per_month:i,...e.funding===void 0?{}:{funding:e.funding},...e.grantee===void 0?{}:{grantee:String(e.grantee)},...e.provider===void 0?{}:{provider:String(e.provider)}})}},"run"),render:t(e=>e.removed!==void 0?`Removed ${String(e.removed)}.`:p(e.limit),"render")}),D=w({name:"spend",description:"the money ledger: spend by payer, the chain under a run, and dollar limits",whenToUse:"reading what was spent and why, or stopping or capping a payer's spend",help:{name:"sys spend",summary:"read this runtime's charges and set the person's dollar limits",model:"Every model call and priced tool call is one charge row naming its payer, funding and cause. A limit row bounds a payer's month; the check refuses calls billed to that payer once it is reached. `sys limits` is the unrelated per-app memory and disk cap."},children:[b,q,_]});export{D as sysSpendBranch};
1
+ var y=Object.defineProperty;var t=(e,r)=>y(e,"name",{value:r,configurable:!0});import{defineBranch as w,defineLeaf as h}from"../../core/command.js";import{InputError as u}from"../../core/io.js";import{cliClient as m}from"../api-client.js";const d=t(e=>e===null?"unpriced":`$${e.toFixed(e<1?4:2)}`,"usd"),$=t(e=>[e.funding&&`funding ${e.funding}`,e.grantee&&`grantee ${e.grantee}`,e.provider&&`provider ${e.provider}`,e.sub&&`sub ${e.sub}`].filter(Boolean).join(", ")||"everything","filters"),l=t(e=>`- \`${e.id}\` ${e.payer??e.account} ${d(e.usd_per_month)}/month on ${$(e)} (${e.source})`,"limitLine"),b=h({name:"show",description:"show a month's spend by payer and funding, with the limits",whenToUse:"checking what a payer has spent this month and which limits apply",help:{name:"sys spend show",summary:"month totals by payer and by payer and funding from the ledger, then every limit row",params:[{kind:"flag",name:"month",type:"string",required:!1,constraint:"UTC month YYYY-MM. Default: the current month."}],output:[{name:"month",type:"string",required:!0,constraint:"The month shown, YYYY-MM."},{name:"totals",type:"ChargeTotalsDTO",required:!0,constraint:"Record: {month, by_payer, by_funding, limits}. Migrated user-paid model history has funding `legacy`."}],outputKind:"object",effects:["None. Read-only."]},run:t(async e=>{const r=await m().listCharges({limit:1,...e.month===void 0?{}:{month:String(e.month)}});if(r.totals===void 0)throw new u({error:"owner_only",message:"month totals are read by the person and terminal-app nodes; this caller sees only its own app's charges",next:"Run `crtr sys spend show` from the person's own shell or a terminal-app node."});return{month:r.month,totals:r.totals}},"run"),render:t(e=>{const r=e.totals;return[`Spend for ${r.month}:`,...r.by_payer.length===0?["- nothing charged"]:r.by_payer.map(i=>`- ${i.payer} ${d(i.usd)}${r.by_funding.filter(s=>s.payer===i.payer).map(s=>` ${s.funding} ${d(s.usd)}`).join("")}`),"Limits:",...r.limits.length===0?["- none"]:r.limits.map(l)].join(`
2
+ `)},"render")});function v(e){const r=new Map;for(const n of e)r.set(n.provider??"(none)",(r.get(n.provider??"(none)")??0)+(n.usd??0));const i=new Set(e.map(n=>n.request)),s=t(n=>e.filter(o=>(o.caused_by??null)===n),"children"),a=[],p=new Set,c=t((n,o)=>{if(!p.has(n.id)&&(p.add(n.id),a.push(`${" ".repeat(o)}- ${n.at} ${n.kind} ${n.what} ${d(n.usd)} ${n.payer}/${n.funding}${n.provider?` \u2192 ${n.provider}`:""} vendor_ref ${n.vendor_ref??"none"}${n.refused?` REFUSED by ${n.refused.limit}`:""}`),n.request!==null))for(const g of s(`request:${n.request}`))c(g,o+1)},"print"),f=e.filter(n=>n.caused_by===null||!(n.caused_by.startsWith("request:")&&i.has(n.caused_by.slice(8))));for(const n of f)c(n,0);for(const n of e)c(n,0);return[...a,"Total per provider:",...[...r].map(([n,o])=>`- ${n} ${d(o)}`)].join(`
3
+ `)}t(v,"tree");const q=h({name:"chain",description:"list the charge rows under a run, message, request or charge on this runtime",whenToUse:"finding what one run, message or request cost and matching its vendor_ref to a vendor's usage line",help:{name:"sys spend chain",summary:"the rows under a reference as a tree, with each row's vendor_ref and a total per provider",params:[{kind:"positional",name:"reference",type:"string",required:!0,constraint:"`run:<id>`, `message:<id>`, `request:<id>`, `cron_run:<id>` or a charge id. Reads this runtime only."}],output:[{name:"reference",type:"string",required:!0,constraint:"The reference read."},{name:"charges",type:"ChargeDTO[]",required:!0,constraint:"Rows in time order; empty when this runtime holds none under the reference."}],outputKind:"object",effects:["None. Read-only."]},run:t(async e=>{const r=String(e.reference),i=[];for(let s;;){const a=await m().listCharges({under:r,...s===void 0?{}:{after:s}});if(i.push(...a.charges),a.next===null)break;s=a.next}return{reference:r,charges:i}},"run"),render:t(e=>{const r=e.charges;return r.length===0?`No charges under ${String(e.reference)} on this runtime.`:v(r)},"render")}),_=h({name:"limit",description:"set or clear one of the person's dollar limits",whenToUse:"stopping a payer's spend (0 is an emergency stop) or capping it per month; clearing a limit you set",help:{name:"sys spend limit",summary:"write or remove the limit row `person:<name>`; the check refuses calls billed to the payer once the month reaches it",params:[{kind:"positional",name:"name",type:"string",required:!0,constraint:"A name for the row; the id is `person:<name>`."},{kind:"flag",name:"payer",type:"string",required:!1,constraint:"`user:<id>` (the person) or `app:<id>`. Required unless --clear."},{kind:"flag",name:"usd",type:"string",required:!1,constraint:"Dollars per month, 0 or more; 0 stops the payer. Required unless --clear."},{kind:"flag",name:"funding",type:"enum",choices:["bill","subscription","key","endpoint","take","legacy"],required:!1,constraint:"Limit only this funding. Default: any."},{kind:"flag",name:"grantee",type:"string",required:!1,constraint:"Limit only charges attributed to this app, such as `app:terminal`. Default: any."},{kind:"flag",name:"provider",type:"string",required:!1,constraint:"Limit only money going to this vendor or provider app, such as `anthropic`. Default: any."},{kind:"flag",name:"clear",type:"bool",required:!1,constraint:"Remove the row instead of writing it."}],output:[{name:"limit",type:"LimitDTO",required:!1,constraint:"The row written; absent with --clear."},{name:"removed",type:"string",required:!1,constraint:"The id removed with --clear."}],outputKind:"object",effects:["Writes or deletes one `limits` row with source `person`. Takes effect on the next call."]},run:t(async e=>{const r=`person:${String(e.name)}`;if(e.clear===!0)return{removed:(await m().removeSpendLimit(r)).id};const i=e.usd===void 0?Number.NaN:Number(e.usd);if(typeof e.payer!="string"||!Number.isFinite(i)||i<0)throw new u({error:"nothing_to_set",message:"a limit needs --payer and --usd (0 or more), or --clear",next:"Pass --payer user:<id> --usd 20, or --clear to remove the row."});return{limit:await m().setSpendLimit(r,{payer:e.payer,usd_per_month:i,...e.funding===void 0?{}:{funding:e.funding},...e.grantee===void 0?{}:{grantee:String(e.grantee)},...e.provider===void 0?{}:{provider:String(e.provider)}})}},"run"),render:t(e=>e.removed!==void 0?`Removed ${String(e.removed)}.`:l(e.limit),"render")}),D=w({name:"spend",description:"the money ledger: spend by payer, the chain under a run, and dollar limits",whenToUse:"reading what was spent and why, or stopping or capping a payer's spend",help:{name:"sys spend",summary:"read this runtime's charges and set the person's dollar limits",model:"Every model call and priced tool call is one charge row naming its payer, funding and cause. A limit row bounds a payer's month; the check refuses calls billed to that payer once it is reached. `sys limits` is the unrelated per-app memory and disk cap."},children:[b,q,_]});export{D as sysSpendBranch};
@@ -1 +1 @@
1
- var _=Object.defineProperty;var s=(n,e)=>_(n,"name",{value:e,configurable:!0});import{ApiError as a}from"../../../api/errors.js";import{personIdAsync as $}from"../../../core/canvas/person.js";import{assertReference as q,deleteLimit as R,listCharges as E,listLimits as m,monthTotals as L,parseUsageMonth as O,upsertLimit as T}from"../../../core/ledger/index.js";import{payersOf as b}from"../../../core/ledger/read.js";import{appOf as k}from"../router.js";import{integer as N}from"./runs.js";import{cloudPersonScope as P}from"../../../core/runs/operations.js";import{invalidRequest as S,objectBody as W}from"./validate.js";function F(n){const{principal:e}=n;if(e.class==="app"||e.class==="broker"){const r=P(e.sub);return r===void 0?{app:e.app}:{app:e.app,sub:r}}if(e.class==="person")return e.sub===void 0?void 0:{person:e.sub};throw new a(403,"owner_only","charges are read by the person, a node or an app")}s(F,"readerOf");async function G(n){const e=F(n),r=n.query.get("under"),t=n.query.get("after"),o=n.query.get("month"),i=r===null||o!==null?O(o):void 0,{charges:d,next:u}=await E({...i===void 0?{}:{month:i},...e===void 0?{}:{reader:e},...r===null?{}:{under:q(r)},...t===null?{}:{after:t},limit:N(n.query.get("limit"),"limit",1,1e4,1e3)}),f=r!==null||e!==void 0&&!("person"in e)?void 0:await L(i,e===void 0?void 0:e.person);return{...i===void 0?{}:{month:i},charges:d,next:u,...f===void 0?{}:{totals:f}}}s(G,"listRoute");const g=["bill","subscription","key","endpoint","take","legacy"],l="person:";function y(n){const{principal:e}=n;if(e.class!=="person")throw new a(403,"owner_only","spend limits are set by a person");return e.sub===void 0?void 0:e.sub.startsWith("user:")?e.sub:`user:${e.sub}`}s(y,"limitOwner");function v(n,e){const r=n.params.id??"";if(!r.startsWith(l)||r.length===l.length||r.length>128)throw new a(400,"invalid_request",`a person limit id starts with \`${l}\`; received ${r}`,{violations:[{field:"id",problem:`must start with ${l}`,received:r}]});if(e===void 0)return r;const t=r.slice(l.length);if(t.includes("/"))throw new a(400,"invalid_request","a person limit name has no `/`",{violations:[{field:"id",problem:"must not contain /",received:r}]});return`${l}${e.slice(5)}/${t}`}s(v,"idOf");function c(n,e,r){const t=n[e];if(t==null)return t;if(typeof t!="string"||t===""){r.push({field:e,problem:"must be a non-empty string or null",received:t});return}return t}s(c,"nullableString");async function I(n){const e=y(n),r=v(n,e),t=[],o=W(n.body,["payer","usd_per_month","funding","grantee","provider","sub"],t),i=o.payer;(typeof i!="string"||!/^(user|app):.+/.test(i))&&t.push({field:"payer",problem:"must be user:<id> or app:<id>",...i===void 0?{}:{received:i}});const d=o.usd_per_month;(typeof d!="number"||!Number.isFinite(d)||d<0)&&t.push({field:"usd_per_month",problem:"must be a number of at least 0",...d===void 0?{}:{received:d}});const u=c(o,"funding",t);typeof u=="string"&&!g.includes(u)&&t.push({field:"funding",problem:`must be one of ${g.join(", ")}`,received:u});const f=c(o,"grantee",t),h=c(o,"provider",t),w=c(o,"sub",t);t.length>0&&S("spend limit request",t);const p=o;if(e===void 0){if(p.payer.startsWith("user:")&&p.payer!==await $())throw new a(403,"owner_only","a person sets limits only on their own payer or on an app",{payer:p.payer})}else if(!(await b(e)).includes(p.payer))throw new a(403,"owner_only","a person sets limits only on their own payer or on an app they hold",{payer:p.payer});return await T({id:r,payer:p.payer,usd_per_month:p.usd_per_month,source:"person",...u===void 0?{}:{funding:u},...f===void 0?{}:{grantee:f},...h===void 0?{}:{provider:h},...w===void 0?{}:{sub:w}})}s(I,"setRoute");async function U(n){if(n.principal.class==="broker"){if(k(n.principal)!=="app:terminal")throw new a(403,"permission_error","only the person and terminal-app agents may read spend limits");return{limits:await m()}}const e=y(n),r=await m();if(e===void 0)return{limits:r};const t=new Set(await b(e)),o=`${l}${e.slice(5)}/`;return{limits:r.filter(i=>i.id.startsWith(o)||i.payer!==null&&t.has(i.payer)||i.account===e)}}s(U,"listLimitsRoute");async function j(n){const e=v(n,y(n));if((await m({source:"person"})).find(t=>t.id===e)===void 0||!await R(e))throw new a(404,"not_found",`no person limit ${e}`);return{id:e,removed:!0}}s(j,"removeRoute");const K=[{method:"GET",pattern:"/v1/charges",handler:s(async n=>({status:200,body:await G(n)}),"handler")}],Q=[{method:"GET",pattern:"/v1/spend-limits",handler:s(async n=>({status:200,body:await U(n)}),"handler")},{method:"PUT",pattern:"/v1/spend-limits/:id",handler:s(async n=>({status:200,body:await I(n)}),"handler")},{method:"DELETE",pattern:"/v1/spend-limits/:id",handler:s(async n=>({status:200,body:await j(n)}),"handler")}];export{K as chargeRoutes,Q as spendLimitRoutes};
1
+ var q=Object.defineProperty;var s=(n,e)=>q(n,"name",{value:e,configurable:!0});import{ApiError as a}from"../../../api/errors.js";import{personIdAsync as R}from"../../../core/canvas/person.js";import{assertReference as E,deleteLimit as L,listCharges as O,listLimits as m,monthTotals as k,parseUsageMonth as T,upsertLimit as N}from"../../../core/ledger/index.js";import{payersOf as b}from"../../../core/ledger/read.js";import{appOf as g}from"../router.js";import{integer as P}from"./runs.js";import{cloudPersonScope as v}from"../../../core/runs/operations.js";import{invalidRequest as S,objectBody as W}from"./validate.js";function F(n){const{principal:e}=n;if(e.class==="broker"&&g(e)==="app:terminal"){const r=v(e.sub);return r===void 0?void 0:{person:r}}if(e.class==="app"||e.class==="broker"){const r=v(e.sub);return r===void 0?{app:e.app}:{app:e.app,sub:r}}if(e.class==="person")return e.sub===void 0?void 0:{person:e.sub};throw new a(403,"owner_only","charges are read by the person, a node or an app")}s(F,"readerOf");async function G(n){const e=F(n),r=n.query.get("under"),t=n.query.get("after"),o=n.query.get("month"),i=r===null||o!==null?T(o):void 0,{charges:d,next:u}=await O({...i===void 0?{}:{month:i},...e===void 0?{}:{reader:e},...r===null?{}:{under:E(r)},...t===null?{}:{after:t},limit:P(n.query.get("limit"),"limit",1,1e4,1e3)}),f=r!==null||e!==void 0&&!("person"in e)?void 0:await k(i,e===void 0?void 0:e.person);return{...i===void 0?{}:{month:i},charges:d,next:u,...f===void 0?{}:{totals:f}}}s(G,"listRoute");const _=["bill","subscription","key","endpoint","take","legacy"],l="person:";function y(n){const{principal:e}=n;if(e.class!=="person")throw new a(403,"owner_only","spend limits are set by a person");return e.sub===void 0?void 0:e.sub.startsWith("user:")?e.sub:`user:${e.sub}`}s(y,"limitOwner");function $(n,e){const r=n.params.id??"";if(!r.startsWith(l)||r.length===l.length||r.length>128)throw new a(400,"invalid_request",`a person limit id starts with \`${l}\`; received ${r}`,{violations:[{field:"id",problem:`must start with ${l}`,received:r}]});if(e===void 0)return r;const t=r.slice(l.length);if(t.includes("/"))throw new a(400,"invalid_request","a person limit name has no `/`",{violations:[{field:"id",problem:"must not contain /",received:r}]});return`${l}${e.slice(5)}/${t}`}s($,"idOf");function c(n,e,r){const t=n[e];if(t==null)return t;if(typeof t!="string"||t===""){r.push({field:e,problem:"must be a non-empty string or null",received:t});return}return t}s(c,"nullableString");async function I(n){const e=y(n),r=$(n,e),t=[],o=W(n.body,["payer","usd_per_month","funding","grantee","provider","sub"],t),i=o.payer;(typeof i!="string"||!/^(user|app):.+/.test(i))&&t.push({field:"payer",problem:"must be user:<id> or app:<id>",...i===void 0?{}:{received:i}});const d=o.usd_per_month;(typeof d!="number"||!Number.isFinite(d)||d<0)&&t.push({field:"usd_per_month",problem:"must be a number of at least 0",...d===void 0?{}:{received:d}});const u=c(o,"funding",t);typeof u=="string"&&!_.includes(u)&&t.push({field:"funding",problem:`must be one of ${_.join(", ")}`,received:u});const f=c(o,"grantee",t),h=c(o,"provider",t),w=c(o,"sub",t);t.length>0&&S("spend limit request",t);const p=o;if(e===void 0){if(p.payer.startsWith("user:")&&p.payer!==await R())throw new a(403,"owner_only","a person sets limits only on their own payer or on an app",{payer:p.payer})}else if(!(await b(e)).includes(p.payer))throw new a(403,"owner_only","a person sets limits only on their own payer or on an app they hold",{payer:p.payer});return await N({id:r,payer:p.payer,usd_per_month:p.usd_per_month,source:"person",...u===void 0?{}:{funding:u},...f===void 0?{}:{grantee:f},...h===void 0?{}:{provider:h},...w===void 0?{}:{sub:w}})}s(I,"setRoute");async function U(n){if(n.principal.class==="broker"){if(g(n.principal)!=="app:terminal")throw new a(403,"permission_error","only the person and terminal-app agents may read spend limits");return{limits:await m()}}const e=y(n),r=await m();if(e===void 0)return{limits:r};const t=new Set(await b(e)),o=`${l}${e.slice(5)}/`;return{limits:r.filter(i=>i.id.startsWith(o)||i.payer!==null&&t.has(i.payer)||i.account===e)}}s(U,"listLimitsRoute");async function j(n){const e=$(n,y(n));if((await m({source:"person"})).find(t=>t.id===e)===void 0||!await L(e))throw new a(404,"not_found",`no person limit ${e}`);return{id:e,removed:!0}}s(j,"removeRoute");const K=[{method:"GET",pattern:"/v1/charges",handler:s(async n=>({status:200,body:await G(n)}),"handler")}],Q=[{method:"GET",pattern:"/v1/spend-limits",handler:s(async n=>({status:200,body:await U(n)}),"handler")},{method:"PUT",pattern:"/v1/spend-limits/:id",handler:s(async n=>({status:200,body:await I(n)}),"handler")},{method:"DELETE",pattern:"/v1/spend-limits/:id",handler:s(async n=>({status:200,body:await j(n)}),"handler")}];export{K as chargeRoutes,Q as spendLimitRoutes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.776",
3
+ "version": "0.3.778",
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.776",
161
- "@north-light/plugin": "0.3.776",
160
+ "@north-light/identity": "0.3.778",
161
+ "@north-light/plugin": "0.3.778",
162
162
  "@earendil-works/chord": "1.5.2",
163
163
  "@earendil-works/pi-agent-core": "1.5.2",
164
164
  "@earendil-works/pi-ai": "1.5.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.776",
3
+ "version": "0.3.778",
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.776",
3
+ "version": "0.3.778",
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.776",
3
+ "version": "0.3.778",
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.776",
31
- "@north-light/identity": "0.3.776"
30
+ "@north-light/api": "0.3.778",
31
+ "@north-light/identity": "0.3.778"
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.776",
3
+ "version": "0.3.778",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.776",
9
+ "version": "0.3.778",
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.776",
32
- "@north-light/plugin": "0.3.776",
31
+ "@north-light/identity": "0.3.778",
32
+ "@north-light/plugin": "0.3.778",
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.776",
11905
+ "version": "0.3.778",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.776",
11910
+ "version": "0.3.778",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.776",
11915
+ "version": "0.3.778",
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.776",
11923
+ "version": "0.3.778",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.776",
11927
- "@north-light/identity": "0.3.776"
11926
+ "@north-light/api": "0.3.778",
11927
+ "@north-light/identity": "0.3.778"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.776",
11932
+ "version": "0.3.778",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.776",
11936
- "@north-light/identity": "0.3.776",
11937
- "@north-light/plugin": "0.3.776",
11935
+ "@north-light/api": "0.3.778",
11936
+ "@north-light/identity": "0.3.778",
11937
+ "@north-light/plugin": "0.3.778",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {