@north-light/cli 0.3.754 → 0.3.755
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/builtin-memory/crouter-sdk/release-notes.md +6 -0
- package/dist/core/runs/operations.js +7 -7
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/docs/sdk/release-notes.md +6 -0
- package/package.json +3 -3
- package/packages/crouter-api/dist/core/runs/operations.js +6 -0
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
|
@@ -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.755
|
|
13
|
+
|
|
14
|
+
### An app can start runs in its own environment with no person
|
|
15
|
+
|
|
16
|
+
`run.start` with a `profile` that is an app environment accepts the app's own call token (subject `app:<id>` or a path under it, no grant). The run's subject is the token's and it has no grant. Any other caller is refused with 403 `app_environment`. Charges for the run name the environment's payer.
|
|
17
|
+
|
|
12
18
|
## 0.3.753
|
|
13
19
|
|
|
14
20
|
### Charges and audit rows record the actor
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var Ae=Object.defineProperty;var
|
|
1
|
+
var Ae=Object.defineProperty;var u=(e,t)=>Ae(e,"name",{value:t,configurable:!0});import{coveredByAny as Ie}from"../../shared/env.js";import{createHash as Z}from"node:crypto";import{ApiError as Te}from"../../api/errors.js";import{CrtrError as Le}from"../errors.js";import{isCloudRole as Ce}from"../canvas/person.js";import{isAbsolute as K,relative as ke,resolve as xe,sep as We,join as Fe}from"node:path";import{SessionManager as qe}from"@earendil-works/pi-coding-agent";import{covers as j}from"@north-light/identity";import{openDb as Y,withCanvasWrite as U}from"../canvas/db.js";import{deleteNodeWithOwned as He}from"../graph/deletion.js";import{getById as Ue}from"../graph/objects.js";import{repairRunConversations as ee}from"../canvas/sessions.js";import{getNode as v,nodeFiles as $e,removeNodeFiles as Pe,updateNode as Be}from"../canvas/canvas.js";import{fullName as Je}from"../canvas/labels.js";import{renameWindow as je}from"../runtime/placement.js";import{latestExecutionForNode as Ye,liveExecutionForNode as te}from"../canvas/executions.js";import{conversationStore as ne,isConversationNotFound as Ge}from"../conversation-store/index.js";import{PARKED_RESIDENT_SQL as Xe}from"../canvas/canvas.js";import{WAKE_MAIL_SQL as ze}from"../canvas/deliveries.js";import{readNodeRecap as Qe}from"../canvas/node-recap.js";import{enqueueNodeMail as Ve}from"../feed/messages.js";import{recordInitialInput as Ze}from"./initial-input.js";import{newestReportBody as Ke}from"../feed/reports.js";import{ensureAppProfile as ae,loadExactProfileManifest as se}from"../profiles/manifest.js";import{stopNodeSandboxes as re}from"../spaces/stop.js";import{deleteNodeSandboxes as et}from"../runtime/runner/delete-sandboxes.js";import{BrokerUnreachableError as tt}from"../runtime/broker-request.js";import{interruptLive as nt}from"../runtime/interactive-deliver.js";import{isBrokerLive as ie}from"../runtime/model-swap.js";import{newNodeId as at}from"../runtime/nodes.js";import{reviveNode as G}from"../runtime/revive.js";import{spawnChildPrepared as st}from"../runtime/spawn.js";import{isPortableModelToken as rt}from"../runtime/launch.js";import{parseDurationMs as it}from"../wake.js";import{expandModelCandidates as ot,parseModelSpec as dt}from"../model-routes.js";import{payerOfGrant as X}from"../grants/mirror.js";import{ownsWithoutRow as ct}from"../grants/owner.js";import{environmentPayerOfProfile as ut}from"../ledger/index.js";import{runUsage as mt}from"../ledger/read.js";import{ZERO_RUN_USAGE as lt}from"../../api/dto/run-events.js";import{isolatedBrokerLauncherAvailable as ft}from"../runtime/host.js";import{blaxelEnvironmentOf as pt}from"../runtime/blaxel-environment.js";import{resolveRunKind as _t,resolveRunModel as wt}from"../runtime/launch-target.js";import{transcriptMessages as gt}from"../runtime/session-cycles.js";import{originFor as oe}from"../runtime/stamp/protocol.js";import{readOutputRequest as Et,readOutputResult as de}from"../runtime/output-result.js";import{admitLegacyStructuredOutput as ce}from"../../daemon/structured-requests/sidecar.js";import{runSchemaRepromptPending as yt}from"../runtime/stop-guard.js";import{toRunOutcomeDTO as ht}from"../../daemon/api/map.js";import{openAssistantMessageStartSequence as Rt}from"../../daemon/runs/observer.js";import{closeNode as ue}from"../runtime/close.js";import{parseScope as St}from"@north-light/identity";import{appendRunEvent as me,lockRunRoot as Nt,subscribeRunEvents as bt}from"./events.js";import{runActivity as vt}from"./activity.js";import{cancelOpenQuestions as le,openNoticeIds as Ot,openQuestionIds as fe}from"./questions.js";import{appSpace as z}from"../layout.js";import{ensureAppSpace as Dt}from"../spaces/space.js";import{assertUploadsUsable as pe,resolveStorageUrls as Mt}from"../storage/attachments.js";import{storageClient as At,storageConfig as It}from"../storage/client.js";import{deleteRunFiles as Tt,deleteUploadRow as Lt,insertUploadUses as _e,releaseRunUploads as Ct,runUsesPath as kt}from"../storage/tables.js";import{abortProviderCalls as we}from"../providers/inflight.js";import{filterAsync as ge,mapAsync as q}from"../async-array.js";import{blobStore as xt}from"../blobs/index.js";import{emitEvent as Wt}from"../events/emit.js";const Ee=u((e,t,a,n,d)=>Mt(t,d,e,a,n?{taken:n}:{}),"defaultResolver"),Ft=3e3;class R extends Error{static{u(this,"RunError")}status;code;param;details;scope;retryable;constructor(t,a,n,d,f,i,s=t===503){super(n),this.status=t,this.code=a,this.param=d,this.details=f,this.scope=i,this.retryable=s}}const S=u((e,t)=>new R(400,"invalid_request",e,t),"invalid"),Q=u(()=>new R(404,"not_found","run not found"),"missing"),I=u(async()=>await Y(),"db");async function $(e,t,a=!1){const n=await v(e);if(!n||n.parent!==null||n.run_id!==e||n.grantee!==t||!a&&n.deleting_at)throw Q();return n}u($,"ownedRun");const ye=["waiting_on_user","idle","settled"];async function k(e){if(e.status==="canceled"||e.status==="dead"||e.status==="done"&&e.intent!=="parked")return"settled";const t=await(await I()).prepare(`SELECT 1 FROM node_rows n WHERE n.run_id = ? AND n.status = 'active' AND
|
|
2
2
|
(n.last_settled_at IS NULL OR EXISTS (
|
|
3
3
|
SELECT 1 FROM run_events e WHERE e.run_id = ? AND e.node_id = n.node_id AND e.type = 'node.turn.started'
|
|
4
4
|
AND e.sequence_number > COALESCE((SELECT MAX(c.sequence_number) FROM run_events c
|
|
5
5
|
WHERE c.run_id = e.run_id AND c.node_id = e.node_id AND c.type = 'node.turn.completed'), 0)
|
|
6
|
-
)) LIMIT 1`).get(e.node_id,e.node_id),a=!e.last_settled_at&&e.status!=="done";return t||a||await
|
|
6
|
+
)) LIMIT 1`).get(e.node_id,e.node_id),a=!e.last_settled_at&&e.status!=="done";return t||a||await yt(e)?"running":(await fe(e.node_id)).length?"waiting_on_user":await(await I()).prepare(`SELECT 1 FROM deliveries d JOIN nodes n ON n.node_id = d.destination_id
|
|
7
7
|
WHERE n.run_id = ? AND ${ze("d","'armed', 'pending', 'handed_off'")}
|
|
8
|
-
AND (n.status IN ('active', 'idle') OR ${Xe("n")}) LIMIT 1`).get(e.node_id)?"running":"idle"}
|
|
8
|
+
AND (n.status IN ('active', 'idle') OR ${Xe("n")}) LIMIT 1`).get(e.node_id)?"running":"idle"}u(k,"runStatus");async function na(e){const t=await v(e);return t!==null&&await k(t)==="running"}u(na,"runIsRunning");async function H(e){await ee(e.node_id),e=await v(e.node_id)??e;const t=await k(e),a=t==="settled"?[]:await fe(e.node_id),n=await Ke(e.node_id)||void 0,d=t==="settled"?await ht(e):null,f=d?.kind==="result"?await de(e.node_id):void 0,i=Qe(e.node_id);return{run_id:e.node_id,name:e.name,status:t,...d?{outcome:d}:{},...f===void 0?{}:{result:f},...n!==void 0?{last_report:n}:{},...i?{recap:i}:{},pending_question_ids:a,open_notice_ids:t==="settled"?[]:await Ot(e.node_id),...e.last_turn_error_json?{last_turn_error:JSON.parse(e.last_turn_error_json)}:{},usage:await mt(e.node_id),payer:await X(e.grant_id),scopes:e.scopes,metadata:e.metadata_json?JSON.parse(e.metadata_json):{},created_at:e.created,...t==="settled"&&e.outcome_at?{settled_at:e.outcome_at}:{},latest_sequence:(e.event_cursor??1)-1,last_activity_at:e.last_activity_at,activity:await vt(e.node_id,t),worktree:await qt(e.node_id)}}u(H,"runObject");async function qt(e){const t=await Ye(e);if(t===null||t.runner!=="blaxel"||t.launchJson===null)return null;const a=JSON.parse(t.launchJson).worktree;return typeof a?.repository=="string"&&typeof a.branch=="string"?{repository:a.repository,branch:a.branch}:null}u(qt,"runWorktree");const V=864e5,he=255;function aa(e){if(e!==void 0){if(typeof e!="string"||!e.length||e.length>he)throw S(`Idempotency-Key must be 1-${he} characters`);return e}}u(aa,"idempotencyKeyOf");function x(e){if(Ce()){if(!e)throw new R(403,"permission_error","a cloud role serves this call only for a token that names a person");return e}}u(x,"cloudPersonScope");function W(e,t){const a=x(e);return a===void 0?t:`${a}:${t}`}u(W,"personKey");async function P(e,t,a,n){n&&await n.prepare("SELECT pg_advisory_xact_lock(hashtext(?))").get(`idempotency:${e}:${t}`),n??=await Y();const d=await n.prepare("SELECT body_hash, run_id, response_json, created_at FROM idempotency_keys WHERE grantee = ? AND key = ?").get(e,t);if(!(!d||Date.now()-Date.parse(d.created_at)>=V)){if(d.body_hash!==a)throw new R(409,"idempotency_conflict","key used with a different request");return{run_id:d.run_id,response:JSON.parse(d.response_json)}}}u(P,"findIdempotent");async function Re(e,t,a,n,d,f,i){await e.prepare("DELETE FROM idempotency_keys WHERE grantee = ? AND key = ? AND created_at <= ?").run(t,a,new Date(Date.now()-V).toISOString()),await e.prepare("INSERT INTO idempotency_keys (grantee, key, body_hash, run_id, response_json, created_at) VALUES (?, ?, ?, ?, ?, ?)").run(t,a,n,d,JSON.stringify(f),i)}u(Re,"recordIdempotent");async function sa(e=Date.now()){return Number((await(await Y()).prepare("DELETE FROM idempotency_keys WHERE created_at <= ?").run(new Date(e-V).toISOString())).changes)}u(sa,"pruneExpiredIdempotencyKeys");async function Se(e,t,a,n,d,f,i=!1){const s=d.text;let c=0;return{messageId:(await Ve(t,{kind:"message",label:s.slice(0,120),senderNodeId:"human",senderName:a,bodyJson:f?{body:s,...i?{steer:!0}:{}}:{body:s,start_turn:!1},urgency:f?"normal":"deferred",wake:f?1:0,withinEnqueue:u(async(h,o)=>{d.uses.length&&(await pe(a,x(n),d.uses,h),await _e(d.uses.map(({upload_id:m,path:y,blob_key:r})=>({upload_id:m,path:y,blob_key:r,run_id:t})),h)),c=(await me(h,t,t,"node.message.accepted",{message_id:o,start_turn:f})).sequence_number},"withinEnqueue")})).messageId,sequence:c}}u(Se,"acceptRunMessage");class Ne extends Error{static{u(this,"IdempotentReplay")}winner;constructor(t){super("idempotent replay"),this.winner=t}}const Ht=1440*60*1e3;function be(e){const t=typeof e=="string"?it(e):null;if(t===null||!Number.isSafeInteger(t))throw S(`deadline '${String(e)}' is not a duration; use one or more <int>[smhd] parts such as 10m or 1h30m`,"deadline");if(t<=0)throw S("deadline must be greater than zero","deadline");if(t>Ht)throw S("deadline must be at most 24h","deadline");return t}u(be,"parseRunDeadlineMs");async function ra(e,t,a,n=Ee){if(t.isolated&&!ft()&&await pt((t.profile===void 0?await ae(e.grantee):se(t.profile)).profileId)===null)throw new R(503,"isolated_unavailable","isolated runs require the Linux root launcher","isolated");t.deadline!==void 0&&be(t.deadline);const{causedBy:d,...f}=t,i=Z("sha256").update(JSON.stringify(f)).digest("hex");if(a){const o=await P(e.grantee,W(e.sub,a),i);if(o){const m=await $(o.run_id,e.grantee);return!m.pi_pid&&await k(m)==="running"&&(t.output_schema!==void 0&&!m.outcome_at&&await Et(m.node_id)===null&&await de(m.node_id)===void 0&&await ce(m.node_id,"terminal",t.output_schema),await G(m.node_id,{resume:!0,capacity:"freeze"})),o.response}}await Dt(e.grantee);const s=t.profile===void 0?await ae(e.grantee):se(t.profile),c=s.manifest.grantee??"app:terminal";if(await ut(s.profileId)!==null&&!ct(c,e.sub,e.grant))throw new R(403,"app_environment",`an app environment starts runs for ${c} only, not for ${e.sub}`,"profile");if(c!==e.grantee){const o=`crtr:memory:rw:${c}:profile:${s.profileId}`;if(!e.resolved.some(m=>j(m,o))||t.scopes!==null&&!t.scopes.some(m=>j(m,o)))throw new R(403,"scope_missing",`missing scope ${o}`,"profile",void 0,o)}if(t.model!==void 0){const o=t.model;if(rt(o)){if(o.includes("/")&&await X(e.grant)!=="app"){const m=o.lastIndexOf("/"),y=o.slice(0,m),r=o.slice(m+1);if(["ultra","strong","medium","light"].includes(r)&&(await ot({kind:"logical",family:y,strength:r,spec:o},z(e.grantee).files,s.profileId)).every(E=>E.family!==y))throw S(`model '${o}' names a model family that is not configured in this daemon`,"model")}}else if(dt(o)===void 0)throw S(`model '${o}' is not a strength (ultra, strong, medium, light), a family/strength, or a provider/model id`,"model")}const _=await at(),h=Fe(z(e.grantee).nodes,_);if(t.isolated&&t.cwd!==void 0){const o=ke(h,xe(t.cwd));if(!K(t.cwd)||o===".."||o.startsWith(`..${We}`)||K(o))throw S("cwd must be inside the isolated root node folder","cwd")}try{const o=await n(_,e.grantee,t.prompt,void 0,x(e.sub)),m=o.text,y=t.message===void 0?void 0:await n(_,e.grantee,t.message,o.uses.map(p=>p.path),x(e.sub)),r=await X(e.grant);let E;try{const p=wt(s,t.model);await st({kind:_t(s),mode:"base",root:!0,rootLifecycle:"resident",readiness:"launch",cwd:t.isolated?t.cwd??h:z(e.grantee).files,profile:s.profileId,prompt:m,nodeId:_,isolated:t.isolated??!1,...t.causedBy===void 0?{}:{causedBy:t.causedBy},...p===void 0?{}:{model:p},...t.deadline===void 0?{}:{deadlineAt:new Date(Date.now()+be(t.deadline)).toISOString()},...t.scopes===null?{}:{scopes:t.scopes},run:{grantee:e.grantee,sub:e.sub,grant_id:e.grant,client_id:e.client_id,metadata_json:JSON.stringify(t.metadata),run_id:_,event_cursor:1},withinCreate:u(async(g,O)=>{if(a){const N=await P(e.grantee,W(e.sub,a),i,g);if(N)throw new Ne(N)}const A=o.uses;if(A.length&&(await pe(e.grantee,x(e.sub),A,g),await _e(A.map(({upload_id:N,path:F,blob_key:T})=>({upload_id:N,path:F,blob_key:T,run_id:_})),g)),E={run_id:_,node_id:_,grantee:e.grantee,grant:e.grant,rev:e.rev,scopes:t.scopes,payer:r,status:"running",created_at:O.created,metadata:t.metadata,sequence_number:0},await me(g,_,_,"run.started",{scopes:t.scopes,payer:r,usage:lt}),y){const N=await Se(g,_,e.grantee,e.sub,y,!1);E.message={run_id:_,message_id:N.messageId,sequence_number:N.sequence}}else await Ze(_,e.grantee,m);a&&await Re(g,e.grantee,W(e.sub,a),i,_,E,O.created)},"withinCreate")},t.output_schema===void 0?void 0:async g=>{await ce(g,"terminal",t.output_schema)})}catch(p){if(p instanceof Ne)return p.winner.response;if(t.model!==void 0&&p instanceof Le&&p.code==="usage")throw S(p.message,"model");if(p instanceof Te&&(p.code==="isolated_run"||p.code==="invalid_request")){const g=p.details&&typeof p.details=="object"&&"param"in p.details&&typeof p.details.param=="string"?p.details.param:void 0;throw new R(p.status,p.code,p.message,g)}throw p}if(!E)throw new Error("run creation did not commit");return E}finally{await Ut(_)}}u(ra,"startRun");async function Ut(e){try{if(await v(e)!==null)return;const t=await xt();for(const a of await t.list(`attachments/${e}/`))await t.delete(a)}catch(t){Wt({level:"warn",event:"runs.start_attachment_cleanup_failed",error:t,fields:{run_id:e}})}}u(Ut,"discardUncommittedAttachments");async function ia(e,t){let a;if(t.after)try{const s=JSON.parse(Buffer.from(t.after,"base64url").toString());if(!s||typeof s!="object"||!("activity"in s)||typeof s.activity!="string"||!("id"in s)||typeof s.id!="string")throw new Error("invalid cursor");a={activity:s.activity,id:s.id}}catch{throw S("invalid list cursor","after")}const n=await(await I()).prepareUncached(`SELECT node_id, COALESCE(last_activity_at, created) AS activity FROM node_rows
|
|
9
9
|
WHERE run_id = node_id AND deleting_at IS NULL ${e===null?"":"AND grantee = ?"}${t.sub===void 0?"":" AND sub = ?"}
|
|
10
|
-
ORDER BY activity DESC, node_id DESC`).all(...e===null?[]:[e],...t.sub===void 0?[]:[t.sub]),d=await ge(await q((await ge(n,async({node_id:
|
|
10
|
+
ORDER BY activity DESC, node_id DESC`).all(...e===null?[]:[e],...t.sub===void 0?[]:[t.sub]),d=await ge(await q((await ge(n,async({node_id:s})=>!t.visible||await t.visible(s))).filter(({activity:s,node_id:c})=>!a||s<a.activity||s===a.activity&&c<a.id),async s=>({root:await v(s.node_id),activity:s.activity})),async({root:s})=>!t.status||await k(s)===t.status),f=d.slice(0,t.limit),i=f.at(-1);return{runs:await q(f,async({root:s})=>await H(s)),next:d.length>t.limit&&i?Buffer.from(JSON.stringify({activity:i.activity,id:i.root.node_id})).toString("base64url"):null}}u(ia,"listRuns");async function oa(e,t,a){const n=await $(e,t),d=u(async()=>await H(await $(e,t)),"read");return!a||ye.includes(await k(n))?await d():new Promise((f,i)=>{let s=u(()=>{},"unsubscribe");const c=u(()=>{clearTimeout(y),clearInterval(m),s()},"settle"),_=u(async()=>{c();try{f(await d())}catch(r){i(r)}},"finish"),h=u(async()=>{ye.includes(String((await d()).status))&&await _()},"check"),o=u(()=>{h().catch(r=>{c(),i(r)})},"run"),m=setInterval(o,250),y=setTimeout(()=>{_()},a*1e3);bt(e,o).then(r=>{s=r},r=>{c(),i(r)})})}u(oa,"waitRun");const $t=5;async function da(e,t,a=Ee,n=!0,d,f=!0){const i=e.status==="canceled"||e.outcome_reason==="closed",s=e.grantee??"app:terminal",c=Z("sha256").update(JSON.stringify(["run.message",e.node_id,t,n,...n&&!f?["steer:false"]:[]])).digest("hex"),_=u(async o=>{const m=await v(e.node_id),y=await(await I()).prepare("SELECT 1 FROM deliveries WHERE message_id = ? AND state = 'pending' AND canceled_at IS NULL").get(String(o.message_id));return m&&!i&&n&&!m.pi_pid&&y&&await G(e.node_id,{resume:!0,capacity:"freeze"}),o},"replay");if(d){const o=await P(s,W(e.sub,d),c);if(o)return _(o.response)}if(i)throw new R(409,"run_settled","canceled run cannot receive a message");const h=n&&e.final_report&&!e.pi_pid?(await import("../runtime/reopen.js")).commitReopenResident:void 0;for(let o=1;;o++){const m=await a(e.node_id,s,t,void 0,x(e.sub)),y=await U(async r=>{if(d){const g=await P(s,W(e.sub,d),c,r);if(g)return{replayed:g.response}}if(m.uses.length){await Nt(r,e.node_id);for(const g of m.uses)if(await kt(e.node_id,g.path,r))return"path_taken"}await h?.(e.node_id);const E=await Se(r,e.node_id,s,e.sub,m,n,n&&f),p={run_id:e.node_id,message_id:E.messageId,sequence_number:E.sequence};return d&&await Re(r,s,W(e.sub,d),c,e.node_id,p,new Date().toISOString()),{result:p}});if(y==="path_taken"){if(o>=$t)throw new R(503,"service_unavailable","attachments of concurrent messages kept taking each other's file names; retry");continue}return"replayed"in y?_(y.replayed):(n&&!e.pi_pid&&await G(e.node_id,{resume:!0,capacity:"freeze"}),y.result)}}u(da,"messageRun");async function Pt(e){const t=u(()=>new R(503,"service_unavailable",`node ${e} broker was unavailable before the interrupt reached it`),"unavailable");for(let a=0;a<2;a++){const n=await v(e);if(!n)throw Q();if(!ie(n)){if(n.streaming)throw t();return}const d=(await te(e))?.executionId;try{await nt(e)==="turn"&&we({nodes:[e]});return}catch(f){if(!(f instanceof tt))throw f;const i=await v(e);if(!i)throw Q();if(!i.streaming)return;if(a===0&&ie(i)&&(await te(e))?.executionId!==d)continue;throw t()}}throw t()}u(Pt,"interruptNode");async function ca(e,t="stop"){const a=t==="stop"?(await(await I()).prepare("SELECT node_id FROM nodes WHERE run_id = ?").all(e.node_id)).map(({node_id:n})=>n):[e.node_id];return await Promise.all(a.map(n=>Pt(n))),await H(await v(e.node_id)??e)}u(ca,"interruptRun");async function ua(e,t={}){const a=(await(await I()).prepare("SELECT node_id FROM nodes WHERE run_id = ? ORDER BY created DESC").all(e.node_id)).map(i=>i.node_id);we({run:e.node_id});const n=[];if(await k(e)!=="settled")n.push(...(await ue(e.node_id,{preserveEmpty:!0,stopReason:"run_canceled"})).closed);else for(const i of a){if(i===e.node_id)continue;const s=await v(i);s&&s.status!=="done"&&s.status!=="canceled"&&s.status!=="dead"&&n.push(...(await ue(i,{preserveEmpty:!0,stopReason:"run_canceled"})).closed)}if(await le({run_id:e.node_id},"the run was canceled"),(await Promise.all([...new Set([e.node_id,...n])].map(i=>re(i,"run_canceled")))).some(i=>!i.confirmed))throw new R(500,"server_error","run process teardown could not be confirmed",void 0,void 0,void 0,!0);const f=await v(e.node_id);return await H(f??e)}u(ua,"cancelRun");const ve=200;async function ma(e,t){if(typeof t!="string"||!t.trim())throw S("name is required","name");const a=t.trim();if(a.length>ve)throw S(`name exceeds ${ve} characters`,"name");const n=await Be(e.node_id,{name:a});return n.window&&je(n.window,Je(n)),await H(n)}u(ma,"renameRun");async function la(e,t={config:It,client:At}){await le({run_id:e.node_id},"the run was deleted");const a=await U(async c=>(await c.prepare("UPDATE nodes SET deleting_at = COALESCE(deleting_at, ?) WHERE node_id = ?").run(new Date().toISOString(),e.node_id),(await c.prepare("SELECT node_id FROM nodes WHERE run_id = ? ORDER BY created DESC").all(e.node_id)).map(_=>_.node_id)));if((await Promise.all(a.map(c=>re(c,"run_deleted",{deleting:!0})))).some(c=>!c.confirmed))throw new R(500,"server_error","run process teardown could not be confirmed",void 0,void 0,void 0,!0);if((await et(a)).length>0)throw new R(500,"server_error","run sandbox deletion could not be confirmed",void 0,void 0,void 0,!0);const d=await q(a,async c=>{const _=await $e(c);if(_.app===null)throw new Error(`run node missing during deletion: ${c}`);return _}),f=await(await I()).prepare("SELECT DISTINCT session_id FROM sessions WHERE session_id IS NOT NULL AND node_id IN (SELECT node_id FROM nodes WHERE run_id = ?)").all(e.node_id);for(const{session_id:c}of f)try{await ne().delete(c)}catch(_){if(!Ge(_))throw _}const i=await U(async c=>{for(const m of a){const y=await Ue(c,m);y!==null&&y.deleted_at===null&&await He(c,y)}const _=await Ct([e.node_id],c);await Tt([e.node_id],c),await c.prepare("DELETE FROM run_events WHERE run_id = ?").run(e.node_id),await c.prepare("DELETE FROM idempotency_keys WHERE run_id = ?").run(e.node_id);const h=a.map(()=>"?").join(","),o=await c.prepareUncached(`SELECT message_id FROM messages WHERE sender_node_id IN (${h}) UNION SELECT message_id FROM deliveries WHERE destination_id IN (${h})`).all(...a,...a);await c.prepareUncached(`DELETE FROM deliveries WHERE destination_id IN (${h})`).run(...a);for(const{message_id:m}of o)await c.prepare("DELETE FROM messages WHERE message_id = ? AND NOT EXISTS (SELECT 1 FROM deliveries WHERE message_id = ?)").run(m,m);return _});for(const c of d)await Pe(c);const{notifyRunDeleted:s}=await import("./events.js");return s(e.node_id),{uploads_pending:await Bt(i,t)}}u(la,"deleteRun");async function Bt(e,t){if(!e.length||!t.config())return e.length;let a;try{a=t.client()}catch{return e.length}const n=new Set,d=e.map(i=>a.deleteUpload(i).then(async()=>{await Lt(i),n.add(i)},()=>{}));let f;return await Promise.race([Promise.all(d),new Promise(i=>{f=setTimeout(i,t.budgetMs??Ft),f.unref?.()})]),clearTimeout(f),e.length-n.size}u(Bt,"deleteReleasedUploads");async function fa(e,t,a){await $(e,t),await ee(e);const n=await U(async r=>{const E=await r.prepare("SELECT node_id, parent FROM nodes WHERE run_id = ? ORDER BY CASE WHEN node_id = ? THEN 0 ELSE 1 END, created, node_id").all(e,e),p=new Map;for(const b of E)p.set(b.node_id,(await r.prepare("SELECT session_id FROM sessions WHERE node_id = ? GROUP BY session_id ORDER BY min(created_at)").all(b.node_id)).map(l=>l.session_id));const O=(await r.prepare("SELECT event_cursor FROM nodes WHERE node_id = ?").get(e)).event_cursor-1,A=await r.prepare(`SELECT node_id, sequence_number FROM run_events
|
|
11
11
|
WHERE run_id = ? AND sequence_number <= ? AND type IN ('node.thinking.done', 'node.output_text.done', 'usage')
|
|
12
|
-
ORDER BY sequence_number`).all(e,O),N=await
|
|
12
|
+
ORDER BY sequence_number`).all(e,O),N=await r.prepare(`SELECT node_id, sequence_number, type, body_json FROM run_events
|
|
13
13
|
WHERE run_id = ? AND sequence_number <= ? AND type IN ('node.thinking.delta', 'node.output_text.delta')
|
|
14
|
-
ORDER BY sequence_number`).all(e,O),F=await
|
|
14
|
+
ORDER BY sequence_number`).all(e,O),F=await r.prepare(`SELECT node_id, sequence_number, ts, body_json FROM run_events
|
|
15
15
|
WHERE run_id = ? AND sequence_number <= ? AND type = 'file.sent'
|
|
16
|
-
ORDER BY sequence_number`).all(e,O),T=new Set((await
|
|
16
|
+
ORDER BY sequence_number`).all(e,O),T=new Set((await r.prepare("SELECT file_id FROM files WHERE run_id = ? AND completed_at IS NOT NULL").all(e)).map(b=>b.file_id)),B=F.flatMap(b=>{const l=JSON.parse(b.body_json);return T.has(l.file_id)?[{file_id:l.file_id,node_id:b.node_id,name:l.name,media_type:l.media_type,size:l.size,sequence_number:Number(b.sequence_number),ts:b.ts}]:[]});return{nodes:E,sessionIds:p,latestSequence:O,completed:A,deltas:N,files:B}}),{nodes:d,sessionIds:f,latestSequence:i,completed:s,deltas:c,files:_}=n,h=await q(d,async r=>({node_id:r.node_id,parent_node_id:r.parent,conversations:await q(f.get(r.node_id)??[],async E=>{const{header:p,entries:g}=await ne().read(E);if(a==="entries")return{conversation_id:E,header:p,entries:g};const O=qe.inMemory(p.cwd,void 0,[p,...g]),A=gt(O.getEntries(),O.getLeafId()),N=new Map(g.map((l,D)=>[l.id,D])),F=g.filter(l=>l.type==="custom"&&l.customType==="crtr-system-prompt").map(l=>({id:l.id,message:{role:"custom",customType:"crtr-system-prompt",data:"data"in l?l.data:void 0,timestamp:l.timestamp}})),T=g.filter(l=>l.type==="custom_message"&&l.customType==="app_message").map(l=>({id:l.id,message:{role:"custom",customType:"app_message",content:"content"in l?l.content:"",timestamp:l.timestamp}})),B=r.node_id===e?g.find(l=>{if(l.type!=="message"||l.message.role!=="user")return!1;const D=oe(g,l.message.timestamp);return D?.type==="runtime"&&D.kind==="kickoff"})?.id:void 0,b=[...A.filter(({id:l})=>!T.some(D=>D.id===l)),...F,...T].sort((l,D)=>(N.get(l.id)??Number.MAX_SAFE_INTEGER)-(N.get(D.id)??Number.MAX_SAFE_INTEGER)).map(({id:l,message:D})=>{const w=D,L=w.usage,J=w.role==="user"?oe(g,Number(w.timestamp)):null,Oe=J?.type==="human"||l===B,C=w.role==="toolResult"?"tool_result":w.role==="bashExecution"?"bash_execution":w.role==="compactionSummary"?"compaction_summary":w.role==="branchSummary"?"branch_summary":w.role==="custom"&&w.customType==="crtr-system-prompt"?"system":w.role==="user"?Oe?"user":"custom":w.role,De=C==="custom"?w.role==="custom"?w.customType:J?.type==="runtime"?J.kind:"unknown":void 0,Me=C==="system"&&w.customType==="crtr-system-prompt"?[{type:"text",text:w.data?.text??""}]:typeof w.content=="string"?[{type:"text",text:w.content}]:Array.isArray(w.content)?w.content.map(M=>M.type==="toolCall"?{type:"tool_call",tool_call_id:M.id,name:M.name,arguments:M.arguments}:M.type==="image"?{type:"image",mime_type:M.mimeType}:M.type==="thinking"?{type:"thinking",text:M.thinking}:M):[];return{entry_id:l,role:C,...C==="custom"?{custom_type:De}:{},time:typeof w.timestamp=="string"?w.timestamp:new Date(Number(w.timestamp??Date.now())).toISOString(),content:Me,...C==="assistant"?{model:w.model,provider:w.provider,stop_reason:w.stopReason,...w.errorMessage?{error_message:w.errorMessage}:{},...L?{usage:{input_tokens:L.input??0,output_tokens:L.output??0,cache_read_tokens:L.cacheRead??0,cache_write_tokens:L.cacheWrite??0,cost_usd:L.cost?.total??0}}:{}}:{},...C==="tool_result"?{tool_call_id:w.toolCallId,tool_name:w.toolName,is_error:w.isError}:{}}})??[];return{conversation_id:E,messages:b}})})),o=new Map(await Promise.all(h.map(async r=>[r.node_id,await Rt(r.node_id)])));for(const r of s){const E=o.get(r.node_id);E!=null&&r.sequence_number>=E&&o.set(r.node_id,null)}const m=new Map;for(const r of c){const E=o.get(r.node_id);if(E==null||r.sequence_number<E)continue;const p=JSON.parse(r.body_json),g=m.get(r.node_id)??{thinking:"",text:""};r.type==="node.thinking.delta"?g.thinking+=p.delta:g.text+=p.delta,m.set(r.node_id,g)}const y=h.map(r=>({...r,in_progress_message:o.get(r.node_id)==null?null:m.get(r.node_id)??{thinking:"",text:""}}));return{run_id:e,latest_sequence:i,nodes:y,files:_}}u(fa,"traceRun");function pa(e,t,a){if(t===void 0){if(!e.some(n=>j(n,"crtr:llm")))throw new R(403,"scope_missing","missing scope crtr:llm",void 0,void 0,"crtr:llm");return null}if(!Array.isArray(t)||t.some(n=>typeof n!="string"))throw S("scopes must be a list of scope strings","scopes");for(const n of t){try{St(n)}catch{throw S(`invalid scope ${n}`,"scopes")}if(/^crtr:files:(?:read|rw):app:/.test(n)&&n.split(":")[4]===a.slice(4))throw S(`own-app files cannot narrow a run: ${n}`,"scopes");if(!(/^crtr:memory:(?:read|rw):app:/.test(n)&&n.split(":")[4]===a.slice(4))&&!Ie(e,n))throw new R(403,"scope_missing",`missing scope ${n}`,void 0,void 0,n)}if(!t.includes("crtr:llm"))throw new R(403,"scope_missing","missing scope crtr:llm",void 0,void 0,"crtr:llm");return t}u(pa,"requestedScopes");export{V as IDEMPOTENCY_WINDOW_MS,Ht as RUN_DEADLINE_MAX_MS,Ft as RUN_DELETE_STORAGE_BUDGET_MS,ve as RUN_NAME_MAX,R as RunError,ua as cancelRun,x as cloudPersonScope,la as deleteRun,aa as idempotencyKeyOf,ca as interruptRun,ia as listRuns,da as messageRun,$ as ownedRun,be as parseRunDeadlineMs,sa as pruneExpiredIdempotencyKeys,ma as renameRun,pa as requestedScopes,na as runIsRunning,H as runObject,ra as startRun,fa as traceRun,oa as waitRun};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Fe=Object.defineProperty;var d=(e,n)=>Fe(e,"name",{value:n,configurable:!0});import{randomUUID as Ge}from"node:crypto";import{envProfileId as xe}from"../../../shared/env.js";import{pausedCanvasProfiles as Be}from"../../../core/profiles/manifest.js";import{existsSync as $,realpathSync as oe,statSync as ae}from"node:fs";import{isAbsolute as W,resolve as L}from"node:path";import{appendSituationalContext as We,formatSituationalProse as Ue}from"../../../core/runtime/situational-context.js";import{closeNode as Ve}from"../../../core/runtime/close.js";import{reviveNode as de}from"../../../core/runtime/revive.js";import{nowIso as U}from"../../../core/fs-utils.js";import{appPaidLaunch as Ke,assertLaunchModelRegistered as V,forkNode as Je,resolveForkSource as se,spawnChildPrepared as ze}from"../../../core/runtime/spawn.js";import{forkSourceNode as le,newNodeId as ce}from"../../../core/runtime/nodes.js";import{abandonCreateRequest as ue,CREATE_LEASE_RENEW_MS as He,claimCreateLease as fe,createLeaseLive as Ye,renewCreateLease as Qe,childrenOf as Xe,completeCreateRequest as pe,findCreateRequest as me,getNode as b,recordCreateRequestNode as Ze,reserveCreateRequest as we,reserveCreateRequestNode as qe,listNodes as en,recordRespawnAttempt as he,subscribersOf as nn,subscriptionsOf as ye,updateNode as T}from"../../../core/canvas/canvas.js";import{armControllerWait as tn,liveControllerWaits as rn}from"../../../core/canvas/waits.js";import{withCanvasWrite as K}from"../../../core/canvas/db.js";import{markNodeRead as on}from"../../../core/canvas/recovery.js";import{nodeObject as an}from"../../../core/graph/objects.js";import{recordActedOn as dn}from"../../../core/graph/edges.js";import{publish as sn}from"../../../core/graph/events.js";import{readerFor as ln}from"../reader.js";import{relocateSessionCwd as cn,unbindSession as un}from"../../../core/canvas/sessions.js";import{ticketCountsForNodes as fn}from"../../../core/canvas/attention.js";import{isSafeNodeId as pn}from"../../../core/canvas/paths.js";import{contextDir as _e,nodeAgentDir as J}from"../../../core/canvas/node-agent-paths.js";import{checkCronBirth as mn,cronRefusalError as wn}from"../../cron/authority.js";import{cronBirthPlacement as hn}from"../../cron/armed-context.js";import{existsBeneath as yn,isAbsentOrRefused as _n,isBeneathRefusal as gn,readdirBeneath as bn}from"../../../core/spaces/open-beneath.js";import{readNodeMessagesPage as vn,readNodeSession as kn,readNodeSnapshot as Sn,transcriptMarkdown as In}from"../../../core/runtime/node-read.js";import{toolCallIds as Rn,withoutImages as ge}from"../../../core/runtime/broker-protocol.js";import{welcomeWindow as En}from"../../../core/runtime/session-cycles.js";import{assembleNodeSubject as On}from"../../../core/substrate/subject.js";import{reviveAll as An}from"../../../core/runtime/revive-all.js";import{promoteAsync as Cn,requestYieldAsync as $n,reshapeNodeAsync as z}from"../../../core/runtime/promote.js";import{recycleNode as Tn}from"../../../core/runtime/recycle.js";import{relaunchRoot as Nn}from"../../../core/runtime/reset.js";import{assertReopenGate as Pn}from"../../../core/runtime/reopen.js";import{requireCurrentExecution as Dn}from"./broker-recovery.js";import{readOutputRequest as Ln}from"../../../core/runtime/output-result.js";import{writeYieldMessage as Mn,readGoal as jn,captureGoalIfAbsent as Fn}from"../../../core/runtime/kickoff.js";import{ensureRoadmap as Gn,hasRoadmap as xn}from"../../../core/runtime/roadmap.js";import{renameWindow as Bn}from"../../../core/runtime/placement.js";import{buildLaunchSpecAsync as Wn,explicitModelIntent as Un,normalizeModel as Vn,readMergedLaunchConfigAsync as be}from"../../../core/runtime/launch.js";import{modelRequestFromConfig as Kn}from"../../../core/model-routes.js";import{persistDormantModel as Jn,setModelLive as zn}from"../../../core/runtime/model-swap.js";import{waitForBrokerViewSocket as ve}from"../../../core/runtime/view-socket.js";import{viewTransport as Hn}from"../../runs/observer.js";import{BrokerUnreachableError as Yn}from"../../../core/runtime/broker-request.js";import{boundFleet as M}from"../../../core/runtime/fleet.js";import{admitLegacyStructuredOutput as Qn}from"../../structured-requests/sidecar.js";import{assertOutputSchemaAccepted as Xn}from"../../../core/runtime/structured-output.js";import{OUTCOME_PAYLOAD_MAX_BYTES as ke}from"../../../core/canvas/types.js";import{HUMAN_ACTION_NAME_PATTERN as Zn}from"../../../core/human/action-binding.js";import{resolveHumanAction as qn}from"../../../core/human-actions.js";import{parseDurationMs as et}from"../../../core/wake.js";import{claimWarmNode as nt,refillWarmPool as Se,resumeWarmClaim as tt,warmPoolEnabled as it}from"../../../core/runtime/warm-pool.js";import{assertLaunchKind as H,isLaunchKind as rt,resolveLaunchTarget as ot}from"../../../core/runtime/launch-target.js";import{fullName as at}from"../../../core/canvas/labels.js";import{reportsForNode as Ie}from"./reports.js";import{requireUsableProfile as dt}from"./profiles.js";import{assertProfileActive as st,isProfilePaused as lt,loadExactProfileManifest as ct}from"../../../core/profiles/manifest.js";import{MachineOfflineError as ut}from"../../../core/runtime/runner/machine/ops.js";import{asNodePerson as ft}from"../../reconcilers/node-lifecycle/node-person.js";import{getCron as Y}from"../../../core/canvas/crons.js";import{cronWakeOrigin as pt}from"../../../core/runtime/bearings.js";import{boundDaemonControl as mt}from"../../control.js";import{notFound as N,usage as y}from"../../../core/errors.js";import{assertScope as wt,validateScopes as Re}from"../../../core/scopes.js";import{scopeAllowed as E}from"../../../shared/env.js";import{toCloseResultDTO as ht,toNodeDetailDTO as Q,toNodeSummaryDTO as yt,toReviveResultDTO as _t}from"../map.js";import{ApiError as p}from"../../../api/index.js";import{InputError as w}from"../../../core/io.js";import{endExecution as gt,liveExecutionForNode as X,requestExecutionStop as bt}from"../../../core/canvas/executions.js";import{runnerForExecution as vt}from"../../../core/runtime/runner/index.js";import{wakeResident as kt}from"../../reconcilers/node-lifecycle/remote-wake.js";import{isNowEligibleFault as St}from"../../../core/canvas/status-glyph.js";import{remoteEnvironmentOf as Ee}from"../../../core/runtime/blaxel-environment.js";import{machineEnvironmentOfProfile as It}from"../../../core/runtime/runner/machine/environment.js";import{isCloudRole as Rt}from"../../../core/canvas/person-state.js";import{actsAsPerson as j,canReadNode as A,mayOnNode as Et,readableNodeIds as Ot,resolvedScopes as At}from"../router.js";import{forwardVerb as Ct,queryWithoutMachine as $t,relayError as Tt,unknownError as Nt,withMachine as Pt}from"../../peer/forward.js";import{fileRoot as Dt}from"../../../core/spaces/file-root.js";import{activeGrant as Lt,payerOfGrant as Mt}from"../../../core/grants/mirror.js";import{launchUsesHostedEndpoint as jt}from"../../../core/model-auth/readiness.js";import{nodeTerminalGrant as Ft}from"../../../core/grants/terminal.js";import{appRungForGrant as Gt}from"../../../core/llm/app-rungs.js";import{APP_FAMILY as xt}from"../../../core/model-routes.js";import{listProfileEnvNames as Bt}from"../../../core/profiles/env-store.js";import{hasConfiguredProviderCredential as Wt,NO_PROVIDER_CREDENTIAL_MESSAGE as Oe}from"../../../core/runtime/provider-credential-gate.js";import{filterAsync as Ut,mapAsync as Ae}from"../../../core/async-array.js";import{addStepTiming as Vt,collectStepTimings as Kt,serverTimingHeader as Jt,sinceCollectionStart as zt,timedStep as Ht}from"../../../core/step-timings.js";async function h(e){const n=await b(e);if(n===null)throw N(`unknown node: ${e}`,{received:e});return n}d(h,"requireMeta");async function Z(e){return{subscribesTo:await ye(e),subscribers:await nn(e),children:await Xe(e)}}d(Z,"edgesFor");async function v(e){const n=await h(e);return await Q(n,await Z(e))}d(v,"detailOf");async function Yt(e){let n=(await Ie(e)).length;try{n+=bn(await J(e),await _e(e)).length}catch(t){if(!_n(t))throw t}return n}d(Yt,"countFiles");function Qt(e){if(typeof e!="object"||e===null)throw y("a node create requires a JSON body");const n=e;if(n.kind!==void 0&&(typeof n.kind!="string"||n.kind.trim()===""))throw y("kind must be a non-empty string when provided");if(n.description!==void 0&&(typeof n.description!="string"||n.description.trim()===""))throw y("description must be a non-empty string when provided");if(n.creator!==void 0&&(typeof n.creator!="string"||n.creator.trim()===""))throw y("creator must be a non-empty node id when provided");if(n.scopes!==void 0&&Re(n.scopes),n.isolated!==void 0&&typeof n.isolated!="boolean")throw new p(400,"invalid_request","isolated must be a boolean",{param:"isolated"});if(n.start!==void 0&&typeof n.start!="boolean")throw new p(400,"invalid_request","start must be a boolean",{param:"start"});const t=n.root_lifecycle;if(t!==void 0&&t!=="resident"&&t!=="terminal")throw y("root_lifecycle must be 'resident' or 'terminal'");if(n.request_key!==void 0&&(typeof n.request_key!="string"||n.request_key.trim()===""||n.request_key.length>128))throw y("request_key must be a non-empty string of at most 128 characters when provided");return n}d(Qt,"parseCreateBody");function Xt(e){if(e===void 0)return;const n=et(e),t=n===null?null:new Date(Date.now()+n);if(n===null||!Number.isFinite(n)||n<=0||t===null||!Number.isFinite(t.getTime()))throw new p(422,"invalid_deadline","`deadline` must be a positive representable duration");return t.toISOString()}d(Xt,"parseDeadline");function Zt(e){if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e))throw new p(400,"invalid_request","`outcome_delivery` must be an object");if(typeof e.action!="string"||!Zn.test(e.action))throw new p(400,"invalid_request","`outcome_delivery.action` must be a declared action name");if(e.payload!==void 0){let n;try{n=JSON.stringify(e.payload)}catch{throw new p(400,"invalid_request","`outcome_delivery.payload` must be JSON-serializable")}if(n===void 0)throw new p(400,"invalid_request","`outcome_delivery.payload` must be JSON-serializable");if(Buffer.byteLength(n,"utf8")>ke)throw new p(413,"payload_too_large",`serialized payload exceeds ${ke} bytes`)}return e}}d(Zt,"parseOutcomeDelivery");function qt(e,n){const t=qn(e.action,n);if(!("kind"in t))return{actionName:e.action,argv:t.argv,cwd:t.cwd,configOrigin:t.configOrigin,...e.payload===void 0?{}:{payload:e.payload}};throw t.kind==="unknown_action"?new p(422,"unknown_action",`no action named ${e.action} is declared from ${n}`):new p(422,"invalid_action",`${e.action} is declared in ${t.configOrigin} but unusable: ${t.reason}`,{reason:t.reason,configOrigin:t.configOrigin})}d(qt,"resolveOutcomeDelivery");function ei(e,n,t){const r={kind:e.kind,cwd:t,prompt:e.prompt??""};return e.mode!==void 0&&(r.mode=e.mode),e.name!==void 0&&(r.name=e.name),e.description!==void 0&&(r.description=e.description),n!==void 0&&(r.parent=n),e.creator!==void 0&&(r.creator=e.creator),e.scopes!==void 0&&(r.scopes=e.scopes),e.isolated!==void 0&&(r.isolated=e.isolated),e.root===!0&&(r.root=!0),e.start===!0&&(r.start=!0),e.root_lifecycle!==void 0&&(r.rootLifecycle=e.root_lifecycle),(e.worktree===!0||typeof e.worktree=="string")&&(r.worktree=!0),typeof e.worktree=="string"&&(r.worktreeBase=e.worktree),e.worktree!==void 0&&(r.worktreeCwd=L(e.pin_cwd??e.cwd??t)),e.fork_from!==void 0&&(r.forkFrom=e.fork_from),e.model!==void 0&&(r.model=e.model),e.profile!==void 0&&(r.profile=e.profile),e.situational_context!==void 0&&(r.situationalContext=e.situational_context),e.node_id!==void 0&&(r.nodeId=e.node_id),r}d(ei,"buildRecipe");function ni(e,n,t){return!it()||e.prefer_warm!==!0||e.root!==!0||e.parent!=null||e.root_lifecycle==="terminal"||(e.prompt??"")!==""||e.model!==void 0||e.fork_from!==void 0||e.worktree!==void 0||e.node_id!==void 0||e.scopes!==void 0||e.isolated!==void 0?null:{kind:e.kind,mode:e.mode??"base",cwd:n,profileId:t,model:e.model??null,situationalContext:e.situational_context??null,name:e.name??null,creator:e.creator??null}}d(ni,"warmRequestFor");import{resolveCreateKind as Io}from"../../../core/runtime/launch-target.js";function Ce(e){const n=e.modelIntent===void 0?void 0:`${e.modelIntent.family}/${e.modelIntent.strength}`;return Kn(e.model,n,e.modelExact===!0)}d(Ce,"requestFromLaunch");function ti(e,n){if(n===null)return e;if(e.scopes===void 0)return{...e,scopes:[...n]};const t=e.scopes.filter(r=>!E(n,r));if(t.length===0)return e;throw new p(403,"scope_denied",`scopes exceed the bearer token's ceiling: ${t.join(", ")}`,{scopes:t,ceiling:n})}d(ti,"withinCeiling");async function $e(e,n,t){const r=(await Wn(n.kind,n.mode,{lifecycle:n.lifecycle,hasManager:e.parent!==null,model:n.model,modelOverride:!0,cwd:e.cwd,profileId:e.profile_id??null,app:e.grantee??"app:terminal"})).launch;await V(Ce(r),{cwd:e.cwd,profileId:e.profile_id??null},t)}d($e,"assertNodeModelChangeRegistered");async function ii(e){if(!Rt()||e.app!=="app:terminal")return!1;const n=e.class==="broker"?(await b(e.node))?.profile_id??null:e.cron===null?null:(await Y(e.cron))?.profile??null;return n!==null&&await It(n)!==null}d(ii,"callerRunsOnMachine");async function Te(e,n){const t=e.principal;if(t.class!=="broker"&&t.class!=="cron"||await ii(t))return;const r=Dt({app:t.app,resolved:await At(t),launched:t.scopes},n,"read");if("root"in r)return;const i="missing"in r?r.missing:null;throw new p(403,"scope_missing",i?`the child's directory ${n} needs missing scope ${i}`:`no permission of this run names the child's directory ${n}`,void 0,void 0,i?{scope:i}:void 0)}d(Te,"assertCallerReaches");const q=new Map;async function ri(e,n={},t={}){const r=performance.now(),{value:i,steps:a}=await Kt(()=>oi(e,n,t));return a.push(["total",performance.now()-r]),{...i,headers:{...i.headers??{},"server-timing":Jt(a)}}}d(ri,"handleCreate");async function oi(e,n,t){const r=ti(Qt(e.body),e.ceiling);if(e.principal.class==="broker"){const s=e.principal;if(r.prefer_warm===!0&&s.app!=="app:terminal"&&(r.prefer_warm=!1),r.parent!=null){const o=await h(r.parent);if(o.grantee!==s.app)throw new p(403,"other_app_run","cannot create a child under another app's node");if(!await A(s,o.grantee??"app:terminal",r.parent))throw N(`unknown node: ${r.parent}`,{received:r.parent})}if(r.creator!==void 0&&r.creator!==s.node)throw new p(403,"other_app_run","cannot create for another node");if(r.fork_from!==void 0){let o=null;try{o=await le(await se(r.fork_from))}catch{}if(o?.grantee!==s.app||!await A(s,o.grantee,o.node_id))throw new p(403,"other_app_run","cannot fork another app's conversation")}r.creator=s.node}if(e.principal.class==="person"&&e.principal.sub!==void 0){const s=r.fork_from===void 0?null:await le(await se(r.fork_from)).catch(()=>null);for(const o of[r.parent,r.creator,s?.node_id])if(o!=null&&await b(o)!==null&&!await Et(e.principal,"edit",o))throw N(`unknown node: ${o}`,{received:o})}if(e.principal.class==="cron"){const s=e.principal;for(const l of["parent","creator","fork_from","node_id"])if(r[l]!=null)throw new p(403,"permission_error",`a cron cannot set ${l} on a node it starts`);r.prefer_warm=!1,r.node_id=await ce(),s.isolated&&(r.isolated=!0,r.cwd=await J(r.node_id,s.app));const o=await mn({grantee:s.app,sub:s.sub,grant_id:s.grant,scopes:s.scopes,from_exec:s.from_exec},{profile:r.profile,cwd:r.cwd,pin_cwd:r.pin_cwd,kind:r.kind,model:r.model,mode:r.mode});if(!o.allowed)throw wn(o);if(r.scopes!==void 0){const l=r.scopes.find(m=>!E(o.effectiveScopes,m)||!E(s.scopes,m));if(l!==void 0)throw new p(403,"scope_missing",`scope ${l} is not held by this cron`,void 0,void 0,{scope:l})}else o.scopes!==null&&(r.scopes=o.scopes)}r.creator!==void 0&&wt(await h(r.creator),"crtr:act");const i=r.request_key?.trim();if(i===void 0||r.node_id!==void 0&&pn(r.node_id)&&await b(r.node_id)!==null&&(await me(i))?.nodeId!==r.node_id)return F(e,r,n,t);const a=q.get(i);if(a!==void 0)return a;const c=ai(e,r,i,n,t);q.set(i,c);try{return await c}finally{q.delete(i)}}d(oi,"createWithinTimings");const Ne=`${process.pid}:${Ge()}`,ee="create_request_in_progress";async function Pe(e,n,t){const r=Date.now()+9e4;let i=Date.now()+1e4;for(;t!==null;){const a=await b(t);if(a!==null){if(!j(e.principal)&&!await A(e.principal,a.grantee??"app:terminal",t))throw new p(409,"create_request_conflict","request_key belongs to another caller");return{status:201,body:await v(t)}}if(await Ye(n)&&(i=Math.min(r,Date.now()+1e3)),Date.now()>=i||(await me(n))?.nodeId!==t)break;await new Promise(c=>setTimeout(c,100))}throw new p(409,ee,"another create with this request_key is in progress; retry it")}d(Pe,"awaitForeignCreate");async function ai(e,n,t,r,i){const a=await we(t),c=Ne;if(a.nodeId!==null&&a.state==="reserved"&&await b(a.nodeId)===null&&!await fe(t,a.nodeId,c))try{return await Pe(e,t,a.nodeId)}catch(o){if(!(o instanceof p)||o.code!==ee||!await fe(t,a.nodeId,c))throw o}const s=setInterval(()=>{Qe(t,c).catch(()=>{})},He);try{return await di(e,n,t,r,i,a)}finally{clearInterval(s)}}d(ai,"handleKeyedCreateRequest");async function di(e,n,t,r,i,a){if(a.nodeId!==null&&await b(a.nodeId)!==null){if(a.state!=="warm_claimed"){const c=await b(a.nodeId);if(!j(e.principal)&&!await A(e.principal,c.grantee??"app:terminal",a.nodeId))throw new p(409,"create_request_conflict","request_key belongs to another caller");return{status:201,body:await v(a.nodeId)}}return F(e,n,r,i,a)}try{return await F(e,n,r,i,a)}catch(c){if(c instanceof p&&c.code===ee)throw c;const s=await we(t);throw(s.nodeId===null||await b(s.nodeId)===null)&&await ue(t,s.nodeId),c}}d(di,"keyedCreateOwned");async function F(e,n,t,r,i=void 0){const a=r.deadlineAt??Xt(n.deadline),c=Zt(n.outcome_delivery),s=e.principal.class==="cron"?await hn({grantee:e.principal.app,sub:e.principal.sub,grant_id:e.principal.grant,scopes:e.principal.scopes,cron_id:e.principal.cron,origin_run_id:e.principal.origin_run,isolated:e.principal.isolated,creator:e.principal.kind==="exec"?null:(await Y(e.principal.cron))?.created_by??null},n.node_id):null;s!==null&&(n.root=s.root===!0);const o=s?.parent??n.parent??void 0;if(o==null&&n.root!==!0)throw y("a node create requires a parent (or root: true for an independent root)");let l=null;if(n.output_schema!==void 0){try{l=JSON.parse(n.output_schema)}catch{throw y("output_schema must be a JSON schema string")}if(l===null||typeof l!="object"||Array.isArray(l))throw y("output_schema must be a JSON schema object");await Xn(l)}const m=await ot(n,{validateKind:je,...e.principal.class==="broker"||e.principal.class==="cron"?{app:e.principal.app}:{}}),{profileId:f,kind:u,cwd:_,launch:I}=m;if(n.pin_cwd!==void 0&&n.pin_cwd!==""&&n.worktree===void 0&&n.isolated!==!0&&!$(_)&&await Ee(f)===null)throw new w({error:"cwd_missing",message:`cwd is not an existing directory: ${_}`,received:_,field:"cwd",next:"Pass an existing directory with --cwd."});await Te(e,_),n.worktree!==void 0&&await Te(e,L(n.pin_cwd??n.cwd??_));const k={...n,kind:u},P=c===void 0?void 0:qt(c,_),te=("grant"in e.principal?e.principal.grant:null)??(o==null?null:(await b(o))?.grant_id??null);if(await V(Ce(await Ke(I,te,n.model)),{cwd:_,profileId:f},t.modelRegistry),await Mt(te)!=="app"&&!await Wt(f===null?[]:await Bt(f))&&!await jt(m))throw new p(412,"no_provider_credential",Oe,{error:"no_provider_credential",message:Oe,next:"The person running this runtime logs a provider in with `crtr sys setup`, or stores a provider key on the profile."});let x=null;{const ie=i===void 0||i.nodeId===null||i.state==="warm_claimed"?ni(k,_,f):null,O=ie!==null&&!(n.start===!0&&await Ee(f)!==null)?ie:null,B=l===null&&r.beforeBrokerLaunch===void 0?void 0:async g=>{l!==null&&await Qn(g,"terminal",l),r.beforeBrokerLaunch?.(g)};if(i?.state==="warm_claimed"&&i.nodeId!==null){const g=O===null?null:await tt(O,i.nodeId,B);if(g===null)throw await ue(i.requestKey,i.nodeId),new p(503,"create_resume_failed",`could not resume warm claim ${i.nodeId}; retry the create`);return await pe(i.requestKey,g),{status:201,body:await v(g)}}if(O!==null){const g=await nt(O,{...a===void 0?{}:{deadlineAt:a},...P===void 0?{}:{outcomeDelivery:P},...i===void 0?{}:{requestKey:i.requestKey}},B);if(g!==null)return i!==void 0&&await pe(i.requestKey,g),Se(O),{status:201,body:await v(g)};x=O}const D=i?.nodeId??n.node_id??(i===void 0?void 0:await ce());if(i!==void 0&&i.nodeId===null){const g=await qe(i.requestKey,D,Ne);if(g!==D)return await Pe(e,i.requestKey,g)}const R=ei(D===void 0?k:{...k,node_id:D},o,_);s!==null&&(s.rootLifecycle!==void 0&&(R.rootLifecycle=s.rootLifecycle),s.scopes!==void 0&&k.scopes===void 0&&(R.scopes=s.scopes),s.run!==void 0&&(R.run=s.run),s.withinCreate!==void 0&&(R.withinCreate=s.withinCreate)),a!==void 0&&(R.deadlineAt=a),P!==void 0&&(R.outcomeDelivery=P),R.readiness=n.root===!0?"await":"launch",Vt("handler_checks",zt());const re=await ze(R,B,()=>{x!==null&&Se(x)});return i!==void 0&&await Ze(i.requestKey,re.node.node_id),{status:201,body:await Ht("response_detail",()=>v(re.node.node_id))}}}d(F,"handleCreateRequest");function S(e,n){const t=e.query.getAll(n);if(t.length>1)throw y(`${n} must appear at most once`);return t[0]}d(S,"singleQueryValue");function ne(e,n){if(e!==void 0){if(e==="1"||e==="true")return!0;if(e==="0"||e==="false")return!1;throw y(`${n} must be true or false`)}}d(ne,"optionalBoolean");function G(e,n,t){if(e!==void 0){if(t.includes(e))return e;throw y(`${n} must be one of: ${t.join(", ")}`)}}d(G,"oneOf");function si(e){const n=new Set(["status","lifecycle","kind","mode","profile_id","profile_prefix","parent","top_level","under","under_inclusive","hanging","include"]);for(const[I]of e.query)if(!n.has(I))throw y(`unknown nodes query parameter: ${I}`);const t=G(S(e,"status"),"status",["active","idle","done","dead","canceled"]),r=G(S(e,"lifecycle"),"lifecycle",["terminal","resident"]),i=S(e,"kind"),a=G(S(e,"mode"),"mode",["base","orchestrator"]),c=S(e,"profile_id"),s=S(e,"profile_prefix"),o=S(e,"parent"),l=ne(S(e,"top_level"),"top_level"),m=S(e,"under"),f=ne(S(e,"under_inclusive"),"under_inclusive"),u=ne(S(e,"hanging"),"hanging"),_=G(S(e,"include"),"include",["activity"]);if(o!==void 0&&l===!0)throw y("parent and top_level=true cannot be combined");return{...t!==void 0?{status:t}:{},...r!==void 0?{lifecycle:r}:{},...i!==void 0?{kind:i}:{},...a!==void 0?{mode:a}:{},...c!==void 0?{profile_id:c}:{},...s!==void 0?{profile_prefix:s}:{},...o!==void 0?{parent:o}:{},...l!==void 0?{top_level:l}:{},...m!==void 0?{under:m}:{},...f!==void 0?{under_inclusive:f}:{},...u!==void 0?{hanging:u}:{},..._!==void 0?{include:_}:{}}}d(si,"parseListQuery");async function li(e){const n=si(e);let t=await en({...n.status!==void 0?{status:n.status}:{},...n.lifecycle!==void 0?{lifecycle:n.lifecycle}:{},...n.kind!==void 0?{kind:n.kind}:{},...n.mode!==void 0?{mode:n.mode}:{},...n.profile_id!==void 0?{profileId:n.profile_id}:{},...n.profile_prefix!==void 0?{profilePrefix:n.profile_prefix}:{},...n.parent!==void 0?{parent:n.parent}:{},...n.top_level===!0?{topLevel:!0}:{},...n.under!==void 0?{under:n.under}:{},...n.under_inclusive===!0?{underInclusive:!0}:{},...n.hanging===!0?{hanging:!0}:{}});const r=await Ot(e.principal);r!==null&&(t=t.filter(o=>r.has(o.node_id)));const i=n.include==="activity"?await fn(t.map(o=>o.node_id)):null,a=t.length>0?Be():new Set,c=new Map((await rn()).map(o=>[o.nodeId,o.controllerId]));return{status:200,body:await Ae(t,async o=>{const l=await yt(o,o.profile_id!==null&&a.has(o.profile_id),c.get(o.node_id)??null);if(i!==null){const m=await Ie(o.node_id);l.activity={latest_report:m[0]??null,final_report:o.final_report===null?null:m.find(f=>f.name===o.final_report)??null,pending_human_count:i[o.node_id]??0}}return l})}}d(li,"handleList");async function ci(e){const n=e.params.id,t=await Ct(e,n,{method:"GET",path:`/v1/nodes/${encodeURIComponent(n)}`,query:$t(e)});if(t.kind==="unknown")throw Nt(n,t.unreachable);if(t.kind==="remote"){if(t.status>=400)throw Tt(t.status,t.body);return{status:t.status,body:Pt(t.body,t.machine)}}return await h(n),{status:200,body:await v(n)}}d(ci,"handleDetail");async function ui(e){const n=e.params.id;await h(n);const t=await Sn(n),{start:r}=En(t.snapshot.messages,s=>JSON.stringify(ge(s,n)).length),i=t.snapshot.messages.slice(r).map(s=>ge(s,n)),a=Rn(i);return{status:200,body:{node_id:n,snapshot:{messages:i,...t.snapshot.messageIds===void 0?{}:{messageIds:t.snapshot.messageIds.slice(r)},messageVisibility:t.snapshot.messageVisibility.slice(r),turnVisibility:t.snapshot.turnVisibility,stats:t.snapshot.stats,state:t.snapshot.state,display:t.snapshot.display,...t.snapshot.queued===void 0?{}:{queued:t.snapshot.queued},...t.snapshot.toolGroupSummaries===void 0?{}:{toolGroupSummaries:Object.fromEntries(Object.entries(t.snapshot.toolGroupSummaries).filter(([s])=>a.has(s)))},...t.snapshot.turnReplies===void 0?{}:{turnReplies:t.snapshot.turnReplies},...t.snapshot.workingActivity===void 0?{}:{workingActivity:t.snapshot.workingActivity}},commands:t.commands.map(s=>({name:s.name,description:s.description,source:s.source})),captured_at:U()}}}d(ui,"handleSnapshot");async function fi(e){const n=e.params.id,t=await On(n);if(t===null)throw N(`unknown node: ${n}`,{received:n});return{status:200,body:t}}d(fi,"handleSubject");function pi(e){for(const[a]of e.query)if(a!=="cursor"&&a!=="limit")throw y(`unknown messages query parameter: ${a}`);const n=e.query.getAll("cursor"),t=e.query.getAll("limit");if(n.length>1)throw y("cursor must appear at most once");if(t.length>1)throw y("limit must appear at most once");if(t.length===0)return n.length===0?{}:{cursor:n[0]};const r=t[0],i=Number(r);if(!Number.isSafeInteger(i)||r==="")throw y("limit must be an integer from 1 through 500");return n.length===0?{limit:i}:{cursor:n[0],limit:i}}d(pi,"parseMessagesQuery");async function mi(e){const n=e.params.id,t=await vn(n,pi(e));return{status:200,body:{node_id:n,messages:t.messages,...t.messageIds===void 0?{}:{message_ids:t.messageIds},message_visibility:t.messageVisibility,next_cursor:t.nextCursor,captured_at:U()}}}d(mi,"handleMessages");async function wi(e){const n=e.params.id;await h(n);const t=await kn(n);return{status:200,body:{node_id:n,session_file:t.sessionFile,session_jsonl:t.sessionJsonl,system_prompt:t.systemPrompt,captured_at:U()}}}d(wi,"handleSession");async function hi(e){const n=e.params.id;return await h(n),{status:200,body:{node_id:n,markdown:await In(n)}}}d(hi,"handleTranscript");async function yi(e){const n=e.params.id;await h(n);const t=d(async(i,a)=>({node_id:i,label:(await b(i))?.name??i,dir:await _e(i),self:a,files:await Yt(i)}),"root"),r=await Ut([await t(n,!0),...await Ae(await ye(n),async i=>await t(i.node_id,!1))],async i=>await _i(i.node_id,i.dir)||i.files>0);return{status:200,body:{node_id:n,roots:r}}}d(yi,"handleContext");async function _i(e,n){try{return yn(await J(e),n)}catch(t){if(gn(t))return!1;throw t}}d(_i,"hasDir");async function gi(e){const n=await h(e.params.id),t=e.principal.class==="broker"?e.principal.scopes:e.ceiling,r=t===null?void 0:n.scopes==null?[...t]:[...new Set([...n.scopes.filter(a=>E(t,a)),...t.filter(a=>E(n.scopes,a))])],i=await Je(n.node_id,r,e.principal.class==="broker"?e.principal.node:void 0);return{status:201,body:await v(i.node.node_id)}}d(gi,"handleFork");const bi=1e4;async function vi(e){const n=e.params.id,t=await h(n),r=await X(n);if(r===null||r.runner!=="machine")throw new w({error:"not_hanging",message:`${n} has no live broker on a Mac \u2014 nothing to kick here.`,next:`Use \`crtr node lifecycle revive ${n} --now\` from the CLI, which kicks a local broker directly.`});if(!St(t.fault??null))throw new w({error:"not_hanging",message:`${n} is live but has no pi\u2192provider fault eligible for --now.`,next:"Use --now only on a node the canvas shows as hanging (\u26A0) with a `pi\u2192provider` fault."});if(t.streaming===!0)throw new w({error:"busy",message:`${n} is mid-turn right now (busy) \u2014 refusing to stop a working engine.`,next:"Re-check the canvas \u2014 if it is no longer marked hanging (\u26A0), nothing to do."});await bt(n,{afterTurn:!1,reason:"revive_now"});const i=await vt("machine").stop(r,{reason:"revive_now"});if(!i.confirmed)throw i.error??new Error(`stop of ${n} on its Mac was not confirmed`);return await gt(r.executionId,{reason:"revive_now"}),await de(n,{resume:!0,capacity:"refuse"}),{status:200,body:{kicked:!0}}}d(vi,"handleKick");async function ki(e){const n=e.params.id,t=await h(n),r=e.body,i=r?.resume??!0,a=r?.reopen??!1;await Pn(n,a,e.principal.class==="broker"?e.principal.node:null);const c=!i&&r?.cron_id!==void 0?await Y(r.cron_id):null,s=await X(n);if(i&&s!==null&&s.runner!=="process"&&s.state==="running"&&!lt(t.profile_id))try{await ft({node_id:n,sub:t.sub??null,profile_id:t.profile_id??null},()=>kt(s))}catch(u){if(!(u instanceof ut))throw u}await he(n,{failures:0,notBefore:null});const o=await de(n,{resume:i,capacity:"refuse",...c!==null?{wakeReason:await pt(c,"schedule_revive")}:{}});o.outcome==="already-live"&&await he(n,{failures:t.respawn_failures??0,notBefore:t.respawn_not_before??null});const l=(await b(n))?.status??"active",m=(o.launch??M().get(n)?.handle)?.exited,f=o.outcome!=="frozen"&&await ve(n,m,bi);return{status:200,body:_t(n,o,l,f)}}d(ki,"handleRevive");async function Si(e){const n=e.params.id;return{status:200,body:{newNodeId:(await Nn(n))?.newNodeId??null}}}d(Si,"handleRelaunchRoot");async function Ii(e){const n=e.params.id;await h(n);const t=e.body;if(t?.caller_pid!==void 0&&(!Number.isInteger(t.caller_pid)||t.caller_pid<=0))throw y("caller_pid must be a positive integer when provided");const r=mt(),i=new Promise(c=>{e.res.once("close",()=>c())}),a=await Ve(n,{teardownAfter:i,rootEvent:t?.finish===!0?"finish":"cancel",callerPid:t?.caller_pid,...e.principal.class==="broker"?{closer:e.principal.node}:{},...r===null?{}:{registerDetached:r.registerDetached}});return{status:200,body:ht(a)}}d(Ii,"handleClose");async function Ri(e){if(!j(e.principal))throw new p(403,"permission_error","only the person marks a conversation read");const n=e.params.id;return await h(n),await on(n),{status:204}}d(Ri,"handleMarkRead");async function Ei(e){const n=e.params.id;await h(n);const t=await Tn(n);return{status:200,body:{recycled:t.recycled,finalized:t.finalized,new_root:t.newRoot,delivered:t.delivered}}}d(Ei,"handleRecycle");async function Oi(e){const n=e.params.id;return await h(n),await z(n,{lifecycle:"terminal"}),await C(e,n,["lifecycle"]),{status:200,body:await v(n)}}d(Oi,"handleDemote");async function Ai(e,n={}){const t=e.params.id,r=await h(t),i=e.body??{};i.kind!==void 0&&await H(i.kind,r.cwd,r.profile_id??null),i.model!==void 0&&await $e(r,{kind:i.kind??r.kind,mode:"orchestrator",lifecycle:i.resident===!0?"resident":r.lifecycle,model:i.model},n.modelRegistry);const a=await Cn(t,{...i.kind!==void 0?{kind:i.kind}:{},...i.resident===!0?{resident:!0}:{},...i.model!==void 0?{model:i.model}:{}});await C(e,t,["mode",...i.kind!==void 0?["kind"]:[],...i.resident===!0?["lifecycle"]:[],...i.model!==void 0?["model"]:[]]);const c=await Q(a.meta,await Z(t));return c.roadmap_written=a.roadmapWritten,c.roadmap_ref=a.roadmapRef,c.goal_path=a.goalPath,{status:200,body:c}}d(Ai,"handlePromote");async function Ci(e){const n=e.params.id;return await h(n),{status:200,body:{request:await Ln(n)}}}d(Ci,"handleBrokerStructuredRequest");async function $i(e){const n=e.params.id,t=e.body??{};if(await Dn(n,t.expected_execution_id),typeof t.text!="string")throw new p(400,"invalid_request","text must be a string");return await h(n),{status:200,body:{captured:await Fn(n,t.text)}}}d($i,"handleBrokerGoal");async function Ti(e,n={}){const t=e.params.id,r=await h(t),i=e.body??{};i.kind!==void 0&&await H(i.kind,r.cwd,r.profile_id??null),i.model!==void 0&&await $e(r,{kind:i.kind??r.kind,mode:i.promote===!0?"orchestrator":r.mode,lifecycle:r.lifecycle,model:i.model},n.modelRegistry);const a=i.note??"Refresh: continue against your roadmap or goal.";await Mn(t,a);const c=await $n(t,{...i.promote===!0?{promote:!0}:{},...i.kind!==void 0?{kind:i.kind}:{},...i.model!==void 0?{model:i.model}:{}});return{status:200,body:await Q(c.meta,await Z(t))}}d(Ti,"handleYield");async function Ni(e){const n=e.params.id;await h(n);const t=e.body;if(t===void 0||typeof t.controller!="string"||t.controller.trim()==="")throw y("a wait requires a controller node id");const r=await b(t.controller);if(r===null)throw N(`unknown controller: ${t.controller}`,{received:t.controller});if(r.status!=="active"&&r.status!=="idle")throw new p(422,"unprocessable",`controller ${t.controller} is ${r.status}`);return await tn(n,t.controller),{status:200,body:await v(n)}}d(Ni,"handleWait");async function Pi(e){const n=e.principal,t=await An(n.class==="broker"?async i=>i.grantee===n.app&&await A(n,i.grantee,i.node_id):n.class==="person"&&!j(n)?async i=>await A(n,i.grantee??"app:terminal",i.node_id):void 0);return{status:200,body:{revived:[...t.revived],failed:[...t.failed],frozen:[...t.frozen]}}}d(Pi,"handleReviveAll");const Di=new Set(["interrupt","steer","after-turn","next-turn"]);function Li(e){if(e===null)return null;const n=d(r=>{throw new w({error:"invalid_listen",message:r,received:e,field:"listen",next:'Send an object mapping levels "1".."10" to interrupt|steer|after-turn|next-turn (e.g. {"3":"next-turn"}), or null to reset to the global default.'})},"bad");if(typeof e!="object"||Array.isArray(e))return n("listen must be an object or null");const t=Object.entries(e);if(t.length===0)return n("listen must name at least one level");for(const[r,i]of t)/^(?:[1-9]|10)$/.test(r)||n(`listen level must be 1..10: ${r}`),(typeof i!="string"||!Di.has(i))&&n(`listen delivery must be interrupt|steer|after-turn|next-turn: ${String(i)}`);return JSON.stringify(Object.fromEntries(t))}d(Li,"listenJson");async function C(e,n,t,r){t.length===0&&r===void 0||await K(async i=>{if(r?.(i),t.length===0)return;const a=await an(i,n),c=await ln(i,e),s=c.class==="person"?c.person:c.class==="app"?c.app:c.node;await dn(i,s,a),await sn(i,{event:"configured",object:a,actor:s,attrs:{changed:t.join(",")}})})}d(C,"recordConfigured");function De(e){const n=M().get(e);if(n===void 0)return!1;try{return process.kill(n.pid,"SIGTERM"),!0}catch{return!1}}d(De,"restartLiveBroker");function Le(e,n){try{return oe(e)===oe(n)}catch{return!1}}d(Le,"sameDirectory");async function Mi(e,n={}){const t=e.params.id,r=e.body;let i;if(r===void 0)i={};else if(typeof r=="object"&&r!==null&&!Array.isArray(r))i=r;else throw new w({error:"cwd_invalid",message:"cwd repair requires a non-null object with a non-empty cwd string",received:r,field:"cwd",next:"Send a config patch with a non-empty absolute cwd string."});if(i.profile!==void 0){if(typeof i.profile!="string"||i.profile==="")throw new w({error:"profile_invalid",message:"profile must be a non-empty profile id or name",received:i.profile,field:"profile",next:"Send a profile id or exact name."});if(Object.keys(i).some(f=>f!=="profile"&&f!=="restart"&&i[f]!==void 0))throw new w({error:"profile_not_exclusive",message:"profile can only be combined with restart",field:"profile",next:"Send profile (and optionally restart) alone."});const o=await h(t),l=await dt(e,i.profile);st(l.profileId);const m=ct(l.profileId).manifest.grantee??"app:terminal";if(m!==(o.grantee??"app:terminal"))throw new w({error:"profile_grantee_mismatch",message:`profile ${l.profileId} belongs to ${m}, node ${t} to ${o.grantee}`,received:i.profile,field:"profile",next:"Pick a profile owned by the same app as the node."});return(o.profile_id??null)!==l.profileId&&(rt(o.kind)?(await H(o.kind,o.cwd,l.profileId),await z(t,{profileId:l.profileId})):await T(t,{profile_id:l.profileId}),await C(e,t,["profile"])),i.restart===!0&&De(t),{status:200,body:await v(t)}}if(Object.prototype.hasOwnProperty.call(i,"cwd")){const o=i.cwd;if(typeof o!="string"||o==="")throw new w({error:"cwd_invalid",message:"cwd must be a non-empty string",received:o,field:"cwd",next:"Send a non-empty absolute cwd string."});if(Object.keys(i).some(u=>u!=="cwd"&&u!=="keep_session"&&u!=="restart"&&i[u]!==void 0))throw new w({error:"cwd_not_exclusive",message:"cwd repair cannot be combined with another config field",received:i,field:"cwd",next:"Send cwd as the only config field."});const l=await h(t),m=$(l.cwd);if(i.keep_session===!0||m&&W(o)&&$(o)&&Le(l.cwd,o)){if(!W(o))throw new w({error:"cwd_not_absolute",message:`cwd must be an absolute path: ${o}`,received:o,field:"cwd",next:"Send an absolute path."});const u=L(o);let _=!1;try{_=ae(u).isDirectory()}catch{}if(!_)throw new w({error:"cwd_missing",message:`cwd is not an existing directory: ${u}`,received:o,field:"cwd",next:"Send an existing absolute directory."});if(m&&!Le(l.cwd,u))throw new w({error:"cwd_not_same_directory",message:`${u} is not the same directory as the recorded ${l.cwd}; --keep-session only relocates an alias`,received:o,field:"cwd",next:"Drop --keep-session to repair a gone cwd, or pass the real path of the recorded directory."});if(l.managed_worktree?.state==="open")throw new w({error:"cwd_node_managed_worktree_open",message:`${t} owns an open managed worktree and cannot relocate its cwd`,received:o,field:"cwd",next:"Reconcile the managed worktree first."});const I=l.cwd;return I!==u&&(await K(async k=>{await T(t,{cwd:u}),await k.prepare("UPDATE crons SET cwd = ? WHERE anchor_node = ? AND cwd = ?").run(u,t,I),await cn(t,I,u)}),await C(e,t,["cwd"])),i.restart===!0&&De(t),{status:200,body:await v(t)}}if(await M().has(t)){const u=`${t} cannot repair its cwd while its broker is live`;throw new p(409,"cwd_node_live",u,{error:"cwd_node_live",message:u,received:o,field:"cwd",next:"Let the node become dormant, then retry the cwd repair."})}if(l.fork_from!=null)throw new w({error:"cwd_node_forked",message:`${t} is a fork and cannot repair its cwd; recorded cwd: ${l.cwd}`,received:o,field:"cwd",next:`Restore ${l.cwd}, then revive the fork normally.`});if(l.managed_worktree?.state==="open")throw new w({error:"cwd_node_managed_worktree_open",message:`${t} owns an open managed worktree and cannot repair its cwd`,received:o,field:"cwd",next:"Restore or reconcile the recorded checkout, then use the managed-worktree close or abandon flow."});if($(l.cwd))throw new w({error:"cwd_still_present",message:`${t} recorded cwd still exists: ${l.cwd}; cwd repair is not a relocation command`,received:o,field:"cwd",next:"This command only repairs a node whose recorded cwd is gone."});if(!W(o))throw new w({error:"cwd_not_absolute",message:`cwd must be an absolute path: ${o}`,received:o,field:"cwd",next:"Send an absolute path."});const f=L(o);if(!$(f))throw new w({error:"cwd_missing",message:`cwd does not exist: ${f}`,received:o,field:"cwd",next:"Create the replacement directory or send an existing absolute directory."});try{if(!ae(f).isDirectory())throw new w({error:"cwd_not_a_directory",message:`cwd is not a directory: ${f}`,received:o,field:"cwd",next:"Send an existing absolute directory."})}catch(u){throw u instanceof w?u:new w({error:"cwd_missing",message:`cwd does not exist: ${f}`,received:o,field:"cwd",next:"Create the replacement directory or send an existing absolute directory."})}return await K(async()=>{await T(t,{cwd:f}),await un(t)}),await C(e,t,["cwd"]),{status:200,body:await v(t)}}let a=await h(t);const c=i.listen===void 0?void 0:Li(i.listen);if(i.scopes!==void 0){const o=Re(i.scopes),l=a.grantee==="app:terminal"?await Ft(a):a.grant_id?await Lt(a.grant_id):null;if(!o.every(m=>E(a.scopes,m)&&l!==null&&E(l.resolved,m)))throw new w({error:"unknown_scope",message:"scopes may only narrow the node's current effective set",received:o,field:"scopes",next:"Send only scopes the node currently holds."});if(o.includes("crtr:act")&&!E(o,"crtr:llm"))throw new p(400,"invalid_scope","crtr:act requires crtr:llm");a=await T(t,{scopes:o})}if(i.situational_context!==void 0&&await We(t,Ue(i.situational_context)),i.model!==void 0){const o=(await be(a.cwd,a.profile_id??null,a.grantee??"app:terminal")).modelLadders,l=Un(i.model,o),m=await Gt(a.grant_id,i.model,l===void 0),f=m?{family:xt,strength:m.strength}:l,u=m?m.model:Vn(i.model,o);await V({kind:"concrete",spec:u},{cwd:a.cwd,profileId:a.profile_id??null},n.modelRegistry);const _=M();let I=!1;if(await _.isClaimed(t)&&((await X(t))?.runner==="machine"||await ve(t,_.get(t)?.handle.exited))&&(I=await zn(t,u,f,await Hn(t)).then(()=>!0,k=>{if(k instanceof Yn)return!1;throw k})),!I){if(await _.isClaimed(t)){const k=`${t}'s broker did not accept the model switch; the model was not changed`;throw new p(409,"broker_not_ready",k,{error:"broker_not_ready",message:k,received:i.model,field:"model",next:"Check the node with `crtr node inspect show`, then retry the model change."})}if(!u.includes("/"))throw y(`model must resolve to a provider/id spec: ${i.model}`);await Jn(t,u,f)}a=await h(t)}if(i.kind!==void 0||i.mode!==void 0||i.lifecycle!==void 0){i.kind!==void 0&&await je(i.kind,a.grantee??"app:terminal");const o=i.kind??a.kind,l=i.mode??a.mode,m=i.lifecycle??a.lifecycle;let f;l==="orchestrator"&&!await xn(t)&&(f=d(async()=>{const u=await jn(t);await Gn(t,u!==null&&u.trim()!==""?{goal:u.trim()}:{})},"beforePersist")),a=await z(t,{...i.kind!==void 0?{kind:o}:{},...i.mode!==void 0?{mode:l}:{},...i.lifecycle!==void 0?{lifecycle:m}:{}},f)}i.name!==void 0&&(a=await T(t,{name:i.name}),a.window&&Bn(a.window,at(a)));const s=["scopes","situational_context","model","kind","mode","lifecycle","name","listen"].filter(o=>i[o]!==void 0);return await C(e,t,s,c===void 0?void 0:async o=>{await o.prepare("UPDATE objects SET listen_json = ? WHERE id = ? AND type = 'node'").run(c,t)}),{status:200,body:await v(t)}}d(Mi,"handleConfig");async function Me(e="app:terminal"){return(await be(process.cwd(),xe()||null,e)).kinds}d(Me,"daemonKinds");async function je(e,n="app:terminal"){const t=Object.keys(await Me(n));if(!t.includes(e))throw y(`unknown kind: ${e}`,{received:e,next:`Valid kinds: ${t.sort().join(", ")}.`})}d(je,"assertKindServer");async function ji(){const e=await Me();return{status:200,body:{kinds:Object.keys(e).sort().map(t=>({kind:t,when_to_use:e[t]?.whenToUse??null,available_to:e[t]?.availableTo??null}))}}}d(ji,"handleListKinds");const vo=[{method:"POST",pattern:"/v1/nodes",scope:"crtr:act",handler:ri},{method:"GET",pattern:"/v1/nodes",handler:li},{method:"GET",pattern:"/v1/kinds",handler:d(()=>ji(),"handler")},{method:"POST",pattern:"/v1/nodes/revive-all",scope:"crtr:act",handler:Pi},{method:"GET",pattern:"/v1/nodes/:id",handler:ci},{method:"GET",pattern:"/v1/nodes/:id/snapshot",handler:ui},{method:"GET",pattern:"/v1/nodes/:id/subject",handler:fi},{method:"GET",pattern:"/v1/nodes/:id/messages",handler:mi},{method:"GET",pattern:"/v1/nodes/:id/session",handler:wi},{method:"GET",pattern:"/v1/nodes/:id/transcript",handler:hi},{method:"GET",pattern:"/v1/nodes/:id/context",handler:yi},{method:"POST",pattern:"/v1/nodes/:id/fork",scope:"crtr:act",handler:gi},{method:"POST",pattern:"/v1/nodes/:id/revive",scope:"crtr:act",handler:ki},{method:"POST",pattern:"/v1/nodes/:id/kick",scope:"crtr:act",handler:vi},{method:"POST",pattern:"/v1/nodes/:id/relaunch-root",scope:"crtr:act",handler:Si},{method:"POST",pattern:"/v1/nodes/:id/close",handler:Ii},{method:"POST",pattern:"/v1/nodes/:id/read",handler:Ri},{method:"POST",pattern:"/v1/nodes/:id/recycle",scope:"crtr:act",handler:Ei},{method:"POST",pattern:"/v1/nodes/:id/demote",scope:"crtr:act",handler:Oi},{method:"POST",pattern:"/v1/nodes/:id/promote",scope:"crtr:act",handler:Ai},{method:"POST",pattern:"/v1/nodes/:id/yield",scope:"crtr:act",handler:Ti},{method:"GET",pattern:"/v1/nodes/:id/broker/structured-request",handler:Ci},{method:"POST",pattern:"/v1/nodes/:id/broker/goal",handler:$i},{method:"POST",pattern:"/v1/nodes/:id/wait",handler:Ni},{method:"PATCH",pattern:"/v1/nodes/:id/config",handler:Mi}];export{Mi as handleConfig,ri as handleCreate,gi as handleFork,li as handleList,Ai as handlePromote,Ti as handleYield,vo as nodeRoutes,Io as resolveCreateKind};
|
|
1
|
+
var Fe=Object.defineProperty;var d=(e,n)=>Fe(e,"name",{value:n,configurable:!0});import{randomUUID as Ge}from"node:crypto";import{envProfileId as xe}from"../../../shared/env.js";import{pausedCanvasProfiles as Be}from"../../../core/profiles/manifest.js";import{existsSync as $,realpathSync as oe,statSync as ae}from"node:fs";import{isAbsolute as W,resolve as L}from"node:path";import{appendSituationalContext as We,formatSituationalProse as Ue}from"../../../core/runtime/situational-context.js";import{closeNode as Ve}from"../../../core/runtime/close.js";import{reviveNode as de}from"../../../core/runtime/revive.js";import{nowIso as U}from"../../../core/fs-utils.js";import{appPaidLaunch as Ke,assertLaunchModelRegistered as V,forkNode as Je,resolveForkSource as se,spawnChildPrepared as ze}from"../../../core/runtime/spawn.js";import{forkSourceNode as le,newNodeId as ce}from"../../../core/runtime/nodes.js";import{abandonCreateRequest as ue,CREATE_LEASE_RENEW_MS as He,claimCreateLease as fe,createLeaseLive as Ye,renewCreateLease as Qe,childrenOf as Xe,completeCreateRequest as pe,findCreateRequest as me,getNode as b,recordCreateRequestNode as Ze,reserveCreateRequest as we,reserveCreateRequestNode as qe,listNodes as en,recordRespawnAttempt as he,subscribersOf as nn,subscriptionsOf as ye,updateNode as T}from"../../../core/canvas/canvas.js";import{armControllerWait as tn,liveControllerWaits as rn}from"../../../core/canvas/waits.js";import{withCanvasWrite as K}from"../../../core/canvas/db.js";import{markNodeRead as on}from"../../../core/canvas/recovery.js";import{nodeObject as an}from"../../../core/graph/objects.js";import{recordActedOn as dn}from"../../../core/graph/edges.js";import{publish as sn}from"../../../core/graph/events.js";import{readerFor as ln}from"../reader.js";import{relocateSessionCwd as cn,unbindSession as un}from"../../../core/canvas/sessions.js";import{ticketCountsForNodes as fn}from"../../../core/canvas/attention.js";import{isSafeNodeId as pn}from"../../../core/canvas/paths.js";import{contextDir as _e,nodeAgentDir as J}from"../../../core/canvas/node-agent-paths.js";import{checkCronBirth as mn,cronRefusalError as wn}from"../../cron/authority.js";import{cronBirthPlacement as hn}from"../../cron/armed-context.js";import{existsBeneath as yn,isAbsentOrRefused as _n,isBeneathRefusal as gn,readdirBeneath as bn}from"../../../core/spaces/open-beneath.js";import{readNodeMessagesPage as vn,readNodeSession as kn,readNodeSnapshot as Sn,transcriptMarkdown as In}from"../../../core/runtime/node-read.js";import{toolCallIds as Rn,withoutImages as ge}from"../../../core/runtime/broker-protocol.js";import{welcomeWindow as En}from"../../../core/runtime/session-cycles.js";import{assembleNodeSubject as On}from"../../../core/substrate/subject.js";import{reviveAll as An}from"../../../core/runtime/revive-all.js";import{promoteAsync as Cn,requestYieldAsync as $n,reshapeNodeAsync as z}from"../../../core/runtime/promote.js";import{recycleNode as Tn}from"../../../core/runtime/recycle.js";import{relaunchRoot as Nn}from"../../../core/runtime/reset.js";import{assertReopenGate as Pn}from"../../../core/runtime/reopen.js";import{requireCurrentExecution as Dn}from"./broker-recovery.js";import{readOutputRequest as Ln}from"../../../core/runtime/output-result.js";import{writeYieldMessage as Mn,readGoal as jn,captureGoalIfAbsent as Fn}from"../../../core/runtime/kickoff.js";import{ensureRoadmap as Gn,hasRoadmap as xn}from"../../../core/runtime/roadmap.js";import{renameWindow as Bn}from"../../../core/runtime/placement.js";import{buildLaunchSpecAsync as Wn,explicitModelIntent as Un,normalizeModel as Vn,readMergedLaunchConfigAsync as be}from"../../../core/runtime/launch.js";import{modelRequestFromConfig as Kn}from"../../../core/model-routes.js";import{persistDormantModel as Jn,setModelLive as zn}from"../../../core/runtime/model-swap.js";import{waitForBrokerViewSocket as ve}from"../../../core/runtime/view-socket.js";import{viewTransport as Hn}from"../../runs/observer.js";import{BrokerUnreachableError as Yn}from"../../../core/runtime/broker-request.js";import{boundFleet as M}from"../../../core/runtime/fleet.js";import{admitLegacyStructuredOutput as Qn}from"../../structured-requests/sidecar.js";import{assertOutputSchemaAccepted as Xn}from"../../../core/runtime/structured-output.js";import{OUTCOME_PAYLOAD_MAX_BYTES as ke}from"../../../core/canvas/types.js";import{HUMAN_ACTION_NAME_PATTERN as Zn}from"../../../core/human/action-binding.js";import{resolveHumanAction as qn}from"../../../core/human-actions.js";import{parseDurationMs as et}from"../../../core/wake.js";import{claimWarmNode as nt,refillWarmPool as Se,resumeWarmClaim as tt,warmPoolEnabled as it}from"../../../core/runtime/warm-pool.js";import{assertLaunchKind as H,isLaunchKind as rt,resolveLaunchTarget as ot}from"../../../core/runtime/launch-target.js";import{fullName as at}from"../../../core/canvas/labels.js";import{reportsForNode as Ie}from"./reports.js";import{requireUsableProfile as dt}from"./profiles.js";import{assertProfileActive as st,isProfilePaused as lt,loadExactProfileManifest as ct}from"../../../core/profiles/manifest.js";import{MachineOfflineError as ut}from"../../../core/runtime/runner/machine/ops.js";import{asNodePerson as ft}from"../../reconcilers/node-lifecycle/node-person.js";import{getCron as Y}from"../../../core/canvas/crons.js";import{cronWakeOrigin as pt}from"../../../core/runtime/bearings.js";import{boundDaemonControl as mt}from"../../control.js";import{notFound as N,usage as y}from"../../../core/errors.js";import{assertScope as wt,validateScopes as Re}from"../../../core/scopes.js";import{scopeAllowed as E}from"../../../shared/env.js";import{toCloseResultDTO as ht,toNodeDetailDTO as Q,toNodeSummaryDTO as yt,toReviveResultDTO as _t}from"../map.js";import{ApiError as p}from"../../../api/index.js";import{InputError as w}from"../../../core/io.js";import{endExecution as gt,liveExecutionForNode as X,requestExecutionStop as bt}from"../../../core/canvas/executions.js";import{runnerForExecution as vt}from"../../../core/runtime/runner/index.js";import{wakeResident as kt}from"../../reconcilers/node-lifecycle/remote-wake.js";import{isNowEligibleFault as St}from"../../../core/canvas/status-glyph.js";import{remoteEnvironmentOf as Ee}from"../../../core/runtime/blaxel-environment.js";import{machineEnvironmentOfProfile as It}from"../../../core/runtime/runner/machine/environment.js";import{isCloudRole as Rt}from"../../../core/canvas/person-state.js";import{actsAsPerson as j,canReadNode as A,mayOnNode as Et,readableNodeIds as Ot,resolvedScopes as At}from"../router.js";import{forwardVerb as Ct,queryWithoutMachine as $t,relayError as Tt,unknownError as Nt,withMachine as Pt}from"../../peer/forward.js";import{fileRoot as Dt}from"../../../core/spaces/file-root.js";import{activeGrant as Lt,payerOfGrant as Mt}from"../../../core/grants/mirror.js";import{launchUsesHostedEndpoint as jt}from"../../../core/model-auth/readiness.js";import{nodeTerminalGrant as Ft}from"../../../core/grants/terminal.js";import{appRungForGrant as Gt}from"../../../core/llm/app-rungs.js";import{APP_FAMILY as xt}from"../../../core/model-routes.js";import{listProfileEnvNames as Bt}from"../../../core/profiles/env-store.js";import{environmentPayerOfProfile as Wt}from"../../../core/ledger/index.js";import{hasConfiguredProviderCredential as Ut,NO_PROVIDER_CREDENTIAL_MESSAGE as Oe}from"../../../core/runtime/provider-credential-gate.js";import{filterAsync as Vt,mapAsync as Ae}from"../../../core/async-array.js";import{addStepTiming as Kt,collectStepTimings as Jt,serverTimingHeader as zt,sinceCollectionStart as Ht,timedStep as Yt}from"../../../core/step-timings.js";async function h(e){const n=await b(e);if(n===null)throw N(`unknown node: ${e}`,{received:e});return n}d(h,"requireMeta");async function Z(e){return{subscribesTo:await ye(e),subscribers:await nn(e),children:await Xe(e)}}d(Z,"edgesFor");async function v(e){const n=await h(e);return await Q(n,await Z(e))}d(v,"detailOf");async function Qt(e){let n=(await Ie(e)).length;try{n+=bn(await J(e),await _e(e)).length}catch(t){if(!_n(t))throw t}return n}d(Qt,"countFiles");function Xt(e){if(typeof e!="object"||e===null)throw y("a node create requires a JSON body");const n=e;if(n.kind!==void 0&&(typeof n.kind!="string"||n.kind.trim()===""))throw y("kind must be a non-empty string when provided");if(n.description!==void 0&&(typeof n.description!="string"||n.description.trim()===""))throw y("description must be a non-empty string when provided");if(n.creator!==void 0&&(typeof n.creator!="string"||n.creator.trim()===""))throw y("creator must be a non-empty node id when provided");if(n.scopes!==void 0&&Re(n.scopes),n.isolated!==void 0&&typeof n.isolated!="boolean")throw new p(400,"invalid_request","isolated must be a boolean",{param:"isolated"});if(n.start!==void 0&&typeof n.start!="boolean")throw new p(400,"invalid_request","start must be a boolean",{param:"start"});const t=n.root_lifecycle;if(t!==void 0&&t!=="resident"&&t!=="terminal")throw y("root_lifecycle must be 'resident' or 'terminal'");if(n.request_key!==void 0&&(typeof n.request_key!="string"||n.request_key.trim()===""||n.request_key.length>128))throw y("request_key must be a non-empty string of at most 128 characters when provided");return n}d(Xt,"parseCreateBody");function Zt(e){if(e===void 0)return;const n=et(e),t=n===null?null:new Date(Date.now()+n);if(n===null||!Number.isFinite(n)||n<=0||t===null||!Number.isFinite(t.getTime()))throw new p(422,"invalid_deadline","`deadline` must be a positive representable duration");return t.toISOString()}d(Zt,"parseDeadline");function qt(e){if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e))throw new p(400,"invalid_request","`outcome_delivery` must be an object");if(typeof e.action!="string"||!Zn.test(e.action))throw new p(400,"invalid_request","`outcome_delivery.action` must be a declared action name");if(e.payload!==void 0){let n;try{n=JSON.stringify(e.payload)}catch{throw new p(400,"invalid_request","`outcome_delivery.payload` must be JSON-serializable")}if(n===void 0)throw new p(400,"invalid_request","`outcome_delivery.payload` must be JSON-serializable");if(Buffer.byteLength(n,"utf8")>ke)throw new p(413,"payload_too_large",`serialized payload exceeds ${ke} bytes`)}return e}}d(qt,"parseOutcomeDelivery");function ei(e,n){const t=qn(e.action,n);if(!("kind"in t))return{actionName:e.action,argv:t.argv,cwd:t.cwd,configOrigin:t.configOrigin,...e.payload===void 0?{}:{payload:e.payload}};throw t.kind==="unknown_action"?new p(422,"unknown_action",`no action named ${e.action} is declared from ${n}`):new p(422,"invalid_action",`${e.action} is declared in ${t.configOrigin} but unusable: ${t.reason}`,{reason:t.reason,configOrigin:t.configOrigin})}d(ei,"resolveOutcomeDelivery");function ni(e,n,t){const r={kind:e.kind,cwd:t,prompt:e.prompt??""};return e.mode!==void 0&&(r.mode=e.mode),e.name!==void 0&&(r.name=e.name),e.description!==void 0&&(r.description=e.description),n!==void 0&&(r.parent=n),e.creator!==void 0&&(r.creator=e.creator),e.scopes!==void 0&&(r.scopes=e.scopes),e.isolated!==void 0&&(r.isolated=e.isolated),e.root===!0&&(r.root=!0),e.start===!0&&(r.start=!0),e.root_lifecycle!==void 0&&(r.rootLifecycle=e.root_lifecycle),(e.worktree===!0||typeof e.worktree=="string")&&(r.worktree=!0),typeof e.worktree=="string"&&(r.worktreeBase=e.worktree),e.worktree!==void 0&&(r.worktreeCwd=L(e.pin_cwd??e.cwd??t)),e.fork_from!==void 0&&(r.forkFrom=e.fork_from),e.model!==void 0&&(r.model=e.model),e.profile!==void 0&&(r.profile=e.profile),e.situational_context!==void 0&&(r.situationalContext=e.situational_context),e.node_id!==void 0&&(r.nodeId=e.node_id),r}d(ni,"buildRecipe");function ti(e,n,t){return!it()||e.prefer_warm!==!0||e.root!==!0||e.parent!=null||e.root_lifecycle==="terminal"||(e.prompt??"")!==""||e.model!==void 0||e.fork_from!==void 0||e.worktree!==void 0||e.node_id!==void 0||e.scopes!==void 0||e.isolated!==void 0?null:{kind:e.kind,mode:e.mode??"base",cwd:n,profileId:t,model:e.model??null,situationalContext:e.situational_context??null,name:e.name??null,creator:e.creator??null}}d(ti,"warmRequestFor");import{resolveCreateKind as Eo}from"../../../core/runtime/launch-target.js";function Ce(e){const n=e.modelIntent===void 0?void 0:`${e.modelIntent.family}/${e.modelIntent.strength}`;return Kn(e.model,n,e.modelExact===!0)}d(Ce,"requestFromLaunch");function ii(e,n){if(n===null)return e;if(e.scopes===void 0)return{...e,scopes:[...n]};const t=e.scopes.filter(r=>!E(n,r));if(t.length===0)return e;throw new p(403,"scope_denied",`scopes exceed the bearer token's ceiling: ${t.join(", ")}`,{scopes:t,ceiling:n})}d(ii,"withinCeiling");async function $e(e,n,t){const r=(await Wn(n.kind,n.mode,{lifecycle:n.lifecycle,hasManager:e.parent!==null,model:n.model,modelOverride:!0,cwd:e.cwd,profileId:e.profile_id??null,app:e.grantee??"app:terminal"})).launch;await V(Ce(r),{cwd:e.cwd,profileId:e.profile_id??null},t)}d($e,"assertNodeModelChangeRegistered");async function ri(e){if(!Rt()||e.app!=="app:terminal")return!1;const n=e.class==="broker"?(await b(e.node))?.profile_id??null:e.cron===null?null:(await Y(e.cron))?.profile??null;return n!==null&&await It(n)!==null}d(ri,"callerRunsOnMachine");async function Te(e,n){const t=e.principal;if(t.class!=="broker"&&t.class!=="cron"||await ri(t))return;const r=Dt({app:t.app,resolved:await At(t),launched:t.scopes},n,"read");if("root"in r)return;const i="missing"in r?r.missing:null;throw new p(403,"scope_missing",i?`the child's directory ${n} needs missing scope ${i}`:`no permission of this run names the child's directory ${n}`,void 0,void 0,i?{scope:i}:void 0)}d(Te,"assertCallerReaches");const q=new Map;async function oi(e,n={},t={}){const r=performance.now(),{value:i,steps:a}=await Jt(()=>ai(e,n,t));return a.push(["total",performance.now()-r]),{...i,headers:{...i.headers??{},"server-timing":zt(a)}}}d(oi,"handleCreate");async function ai(e,n,t){const r=ii(Xt(e.body),e.ceiling);if(e.principal.class==="broker"){const s=e.principal;if(r.prefer_warm===!0&&s.app!=="app:terminal"&&(r.prefer_warm=!1),r.parent!=null){const o=await h(r.parent);if(o.grantee!==s.app)throw new p(403,"other_app_run","cannot create a child under another app's node");if(!await A(s,o.grantee??"app:terminal",r.parent))throw N(`unknown node: ${r.parent}`,{received:r.parent})}if(r.creator!==void 0&&r.creator!==s.node)throw new p(403,"other_app_run","cannot create for another node");if(r.fork_from!==void 0){let o=null;try{o=await le(await se(r.fork_from))}catch{}if(o?.grantee!==s.app||!await A(s,o.grantee,o.node_id))throw new p(403,"other_app_run","cannot fork another app's conversation")}r.creator=s.node}if(e.principal.class==="person"&&e.principal.sub!==void 0){const s=r.fork_from===void 0?null:await le(await se(r.fork_from)).catch(()=>null);for(const o of[r.parent,r.creator,s?.node_id])if(o!=null&&await b(o)!==null&&!await Et(e.principal,"edit",o))throw N(`unknown node: ${o}`,{received:o})}if(e.principal.class==="cron"){const s=e.principal;for(const l of["parent","creator","fork_from","node_id"])if(r[l]!=null)throw new p(403,"permission_error",`a cron cannot set ${l} on a node it starts`);r.prefer_warm=!1,r.node_id=await ce(),s.isolated&&(r.isolated=!0,r.cwd=await J(r.node_id,s.app));const o=await mn({grantee:s.app,sub:s.sub,grant_id:s.grant,scopes:s.scopes,from_exec:s.from_exec},{profile:r.profile,cwd:r.cwd,pin_cwd:r.pin_cwd,kind:r.kind,model:r.model,mode:r.mode});if(!o.allowed)throw wn(o);if(r.scopes!==void 0){const l=r.scopes.find(m=>!E(o.effectiveScopes,m)||!E(s.scopes,m));if(l!==void 0)throw new p(403,"scope_missing",`scope ${l} is not held by this cron`,void 0,void 0,{scope:l})}else o.scopes!==null&&(r.scopes=o.scopes)}r.creator!==void 0&&wt(await h(r.creator),"crtr:act");const i=r.request_key?.trim();if(i===void 0||r.node_id!==void 0&&pn(r.node_id)&&await b(r.node_id)!==null&&(await me(i))?.nodeId!==r.node_id)return F(e,r,n,t);const a=q.get(i);if(a!==void 0)return a;const c=di(e,r,i,n,t);q.set(i,c);try{return await c}finally{q.delete(i)}}d(ai,"createWithinTimings");const Ne=`${process.pid}:${Ge()}`,ee="create_request_in_progress";async function Pe(e,n,t){const r=Date.now()+9e4;let i=Date.now()+1e4;for(;t!==null;){const a=await b(t);if(a!==null){if(!j(e.principal)&&!await A(e.principal,a.grantee??"app:terminal",t))throw new p(409,"create_request_conflict","request_key belongs to another caller");return{status:201,body:await v(t)}}if(await Ye(n)&&(i=Math.min(r,Date.now()+1e3)),Date.now()>=i||(await me(n))?.nodeId!==t)break;await new Promise(c=>setTimeout(c,100))}throw new p(409,ee,"another create with this request_key is in progress; retry it")}d(Pe,"awaitForeignCreate");async function di(e,n,t,r,i){const a=await we(t),c=Ne;if(a.nodeId!==null&&a.state==="reserved"&&await b(a.nodeId)===null&&!await fe(t,a.nodeId,c))try{return await Pe(e,t,a.nodeId)}catch(o){if(!(o instanceof p)||o.code!==ee||!await fe(t,a.nodeId,c))throw o}const s=setInterval(()=>{Qe(t,c).catch(()=>{})},He);try{return await si(e,n,t,r,i,a)}finally{clearInterval(s)}}d(di,"handleKeyedCreateRequest");async function si(e,n,t,r,i,a){if(a.nodeId!==null&&await b(a.nodeId)!==null){if(a.state!=="warm_claimed"){const c=await b(a.nodeId);if(!j(e.principal)&&!await A(e.principal,c.grantee??"app:terminal",a.nodeId))throw new p(409,"create_request_conflict","request_key belongs to another caller");return{status:201,body:await v(a.nodeId)}}return F(e,n,r,i,a)}try{return await F(e,n,r,i,a)}catch(c){if(c instanceof p&&c.code===ee)throw c;const s=await we(t);throw(s.nodeId===null||await b(s.nodeId)===null)&&await ue(t,s.nodeId),c}}d(si,"keyedCreateOwned");async function F(e,n,t,r,i=void 0){const a=r.deadlineAt??Zt(n.deadline),c=qt(n.outcome_delivery),s=e.principal.class==="cron"?await hn({grantee:e.principal.app,sub:e.principal.sub,grant_id:e.principal.grant,scopes:e.principal.scopes,cron_id:e.principal.cron,origin_run_id:e.principal.origin_run,isolated:e.principal.isolated,creator:e.principal.kind==="exec"?null:(await Y(e.principal.cron))?.created_by??null},n.node_id):null;s!==null&&(n.root=s.root===!0);const o=s?.parent??n.parent??void 0;if(o==null&&n.root!==!0)throw y("a node create requires a parent (or root: true for an independent root)");let l=null;if(n.output_schema!==void 0){try{l=JSON.parse(n.output_schema)}catch{throw y("output_schema must be a JSON schema string")}if(l===null||typeof l!="object"||Array.isArray(l))throw y("output_schema must be a JSON schema object");await Xn(l)}const m=await ot(n,{validateKind:je,...e.principal.class==="broker"||e.principal.class==="cron"?{app:e.principal.app}:{}}),{profileId:f,kind:u,cwd:_,launch:I}=m;if(n.pin_cwd!==void 0&&n.pin_cwd!==""&&n.worktree===void 0&&n.isolated!==!0&&!$(_)&&await Ee(f)===null)throw new w({error:"cwd_missing",message:`cwd is not an existing directory: ${_}`,received:_,field:"cwd",next:"Pass an existing directory with --cwd."});await Te(e,_),n.worktree!==void 0&&await Te(e,L(n.pin_cwd??n.cwd??_));const k={...n,kind:u},P=c===void 0?void 0:ei(c,_),te=("grant"in e.principal?e.principal.grant:null)??(o==null?null:(await b(o))?.grant_id??null);if(await V(Ce(await Ke(I,te,n.model)),{cwd:_,profileId:f},t.modelRegistry),await Mt(te)!=="app"&&await Wt(f)===null&&!await Ut(f===null?[]:await Bt(f))&&!await jt(m))throw new p(412,"no_provider_credential",Oe,{error:"no_provider_credential",message:Oe,next:"The person running this runtime logs a provider in with `crtr sys setup`, or stores a provider key on the profile."});let x=null;{const ie=i===void 0||i.nodeId===null||i.state==="warm_claimed"?ti(k,_,f):null,O=ie!==null&&!(n.start===!0&&await Ee(f)!==null)?ie:null,B=l===null&&r.beforeBrokerLaunch===void 0?void 0:async g=>{l!==null&&await Qn(g,"terminal",l),r.beforeBrokerLaunch?.(g)};if(i?.state==="warm_claimed"&&i.nodeId!==null){const g=O===null?null:await tt(O,i.nodeId,B);if(g===null)throw await ue(i.requestKey,i.nodeId),new p(503,"create_resume_failed",`could not resume warm claim ${i.nodeId}; retry the create`);return await pe(i.requestKey,g),{status:201,body:await v(g)}}if(O!==null){const g=await nt(O,{...a===void 0?{}:{deadlineAt:a},...P===void 0?{}:{outcomeDelivery:P},...i===void 0?{}:{requestKey:i.requestKey}},B);if(g!==null)return i!==void 0&&await pe(i.requestKey,g),Se(O),{status:201,body:await v(g)};x=O}const D=i?.nodeId??n.node_id??(i===void 0?void 0:await ce());if(i!==void 0&&i.nodeId===null){const g=await qe(i.requestKey,D,Ne);if(g!==D)return await Pe(e,i.requestKey,g)}const R=ni(D===void 0?k:{...k,node_id:D},o,_);s!==null&&(s.rootLifecycle!==void 0&&(R.rootLifecycle=s.rootLifecycle),s.scopes!==void 0&&k.scopes===void 0&&(R.scopes=s.scopes),s.run!==void 0&&(R.run=s.run),s.withinCreate!==void 0&&(R.withinCreate=s.withinCreate)),a!==void 0&&(R.deadlineAt=a),P!==void 0&&(R.outcomeDelivery=P),R.readiness=n.root===!0?"await":"launch",Kt("handler_checks",Ht());const re=await ze(R,B,()=>{x!==null&&Se(x)});return i!==void 0&&await Ze(i.requestKey,re.node.node_id),{status:201,body:await Yt("response_detail",()=>v(re.node.node_id))}}}d(F,"handleCreateRequest");function S(e,n){const t=e.query.getAll(n);if(t.length>1)throw y(`${n} must appear at most once`);return t[0]}d(S,"singleQueryValue");function ne(e,n){if(e!==void 0){if(e==="1"||e==="true")return!0;if(e==="0"||e==="false")return!1;throw y(`${n} must be true or false`)}}d(ne,"optionalBoolean");function G(e,n,t){if(e!==void 0){if(t.includes(e))return e;throw y(`${n} must be one of: ${t.join(", ")}`)}}d(G,"oneOf");function li(e){const n=new Set(["status","lifecycle","kind","mode","profile_id","profile_prefix","parent","top_level","under","under_inclusive","hanging","include"]);for(const[I]of e.query)if(!n.has(I))throw y(`unknown nodes query parameter: ${I}`);const t=G(S(e,"status"),"status",["active","idle","done","dead","canceled"]),r=G(S(e,"lifecycle"),"lifecycle",["terminal","resident"]),i=S(e,"kind"),a=G(S(e,"mode"),"mode",["base","orchestrator"]),c=S(e,"profile_id"),s=S(e,"profile_prefix"),o=S(e,"parent"),l=ne(S(e,"top_level"),"top_level"),m=S(e,"under"),f=ne(S(e,"under_inclusive"),"under_inclusive"),u=ne(S(e,"hanging"),"hanging"),_=G(S(e,"include"),"include",["activity"]);if(o!==void 0&&l===!0)throw y("parent and top_level=true cannot be combined");return{...t!==void 0?{status:t}:{},...r!==void 0?{lifecycle:r}:{},...i!==void 0?{kind:i}:{},...a!==void 0?{mode:a}:{},...c!==void 0?{profile_id:c}:{},...s!==void 0?{profile_prefix:s}:{},...o!==void 0?{parent:o}:{},...l!==void 0?{top_level:l}:{},...m!==void 0?{under:m}:{},...f!==void 0?{under_inclusive:f}:{},...u!==void 0?{hanging:u}:{},..._!==void 0?{include:_}:{}}}d(li,"parseListQuery");async function ci(e){const n=li(e);let t=await en({...n.status!==void 0?{status:n.status}:{},...n.lifecycle!==void 0?{lifecycle:n.lifecycle}:{},...n.kind!==void 0?{kind:n.kind}:{},...n.mode!==void 0?{mode:n.mode}:{},...n.profile_id!==void 0?{profileId:n.profile_id}:{},...n.profile_prefix!==void 0?{profilePrefix:n.profile_prefix}:{},...n.parent!==void 0?{parent:n.parent}:{},...n.top_level===!0?{topLevel:!0}:{},...n.under!==void 0?{under:n.under}:{},...n.under_inclusive===!0?{underInclusive:!0}:{},...n.hanging===!0?{hanging:!0}:{}});const r=await Ot(e.principal);r!==null&&(t=t.filter(o=>r.has(o.node_id)));const i=n.include==="activity"?await fn(t.map(o=>o.node_id)):null,a=t.length>0?Be():new Set,c=new Map((await rn()).map(o=>[o.nodeId,o.controllerId]));return{status:200,body:await Ae(t,async o=>{const l=await yt(o,o.profile_id!==null&&a.has(o.profile_id),c.get(o.node_id)??null);if(i!==null){const m=await Ie(o.node_id);l.activity={latest_report:m[0]??null,final_report:o.final_report===null?null:m.find(f=>f.name===o.final_report)??null,pending_human_count:i[o.node_id]??0}}return l})}}d(ci,"handleList");async function ui(e){const n=e.params.id,t=await Ct(e,n,{method:"GET",path:`/v1/nodes/${encodeURIComponent(n)}`,query:$t(e)});if(t.kind==="unknown")throw Nt(n,t.unreachable);if(t.kind==="remote"){if(t.status>=400)throw Tt(t.status,t.body);return{status:t.status,body:Pt(t.body,t.machine)}}return await h(n),{status:200,body:await v(n)}}d(ui,"handleDetail");async function fi(e){const n=e.params.id;await h(n);const t=await Sn(n),{start:r}=En(t.snapshot.messages,s=>JSON.stringify(ge(s,n)).length),i=t.snapshot.messages.slice(r).map(s=>ge(s,n)),a=Rn(i);return{status:200,body:{node_id:n,snapshot:{messages:i,...t.snapshot.messageIds===void 0?{}:{messageIds:t.snapshot.messageIds.slice(r)},messageVisibility:t.snapshot.messageVisibility.slice(r),turnVisibility:t.snapshot.turnVisibility,stats:t.snapshot.stats,state:t.snapshot.state,display:t.snapshot.display,...t.snapshot.queued===void 0?{}:{queued:t.snapshot.queued},...t.snapshot.toolGroupSummaries===void 0?{}:{toolGroupSummaries:Object.fromEntries(Object.entries(t.snapshot.toolGroupSummaries).filter(([s])=>a.has(s)))},...t.snapshot.turnReplies===void 0?{}:{turnReplies:t.snapshot.turnReplies},...t.snapshot.workingActivity===void 0?{}:{workingActivity:t.snapshot.workingActivity}},commands:t.commands.map(s=>({name:s.name,description:s.description,source:s.source})),captured_at:U()}}}d(fi,"handleSnapshot");async function pi(e){const n=e.params.id,t=await On(n);if(t===null)throw N(`unknown node: ${n}`,{received:n});return{status:200,body:t}}d(pi,"handleSubject");function mi(e){for(const[a]of e.query)if(a!=="cursor"&&a!=="limit")throw y(`unknown messages query parameter: ${a}`);const n=e.query.getAll("cursor"),t=e.query.getAll("limit");if(n.length>1)throw y("cursor must appear at most once");if(t.length>1)throw y("limit must appear at most once");if(t.length===0)return n.length===0?{}:{cursor:n[0]};const r=t[0],i=Number(r);if(!Number.isSafeInteger(i)||r==="")throw y("limit must be an integer from 1 through 500");return n.length===0?{limit:i}:{cursor:n[0],limit:i}}d(mi,"parseMessagesQuery");async function wi(e){const n=e.params.id,t=await vn(n,mi(e));return{status:200,body:{node_id:n,messages:t.messages,...t.messageIds===void 0?{}:{message_ids:t.messageIds},message_visibility:t.messageVisibility,next_cursor:t.nextCursor,captured_at:U()}}}d(wi,"handleMessages");async function hi(e){const n=e.params.id;await h(n);const t=await kn(n);return{status:200,body:{node_id:n,session_file:t.sessionFile,session_jsonl:t.sessionJsonl,system_prompt:t.systemPrompt,captured_at:U()}}}d(hi,"handleSession");async function yi(e){const n=e.params.id;return await h(n),{status:200,body:{node_id:n,markdown:await In(n)}}}d(yi,"handleTranscript");async function _i(e){const n=e.params.id;await h(n);const t=d(async(i,a)=>({node_id:i,label:(await b(i))?.name??i,dir:await _e(i),self:a,files:await Qt(i)}),"root"),r=await Vt([await t(n,!0),...await Ae(await ye(n),async i=>await t(i.node_id,!1))],async i=>await gi(i.node_id,i.dir)||i.files>0);return{status:200,body:{node_id:n,roots:r}}}d(_i,"handleContext");async function gi(e,n){try{return yn(await J(e),n)}catch(t){if(gn(t))return!1;throw t}}d(gi,"hasDir");async function bi(e){const n=await h(e.params.id),t=e.principal.class==="broker"?e.principal.scopes:e.ceiling,r=t===null?void 0:n.scopes==null?[...t]:[...new Set([...n.scopes.filter(a=>E(t,a)),...t.filter(a=>E(n.scopes,a))])],i=await Je(n.node_id,r,e.principal.class==="broker"?e.principal.node:void 0);return{status:201,body:await v(i.node.node_id)}}d(bi,"handleFork");const vi=1e4;async function ki(e){const n=e.params.id,t=await h(n),r=await X(n);if(r===null||r.runner!=="machine")throw new w({error:"not_hanging",message:`${n} has no live broker on a Mac \u2014 nothing to kick here.`,next:`Use \`crtr node lifecycle revive ${n} --now\` from the CLI, which kicks a local broker directly.`});if(!St(t.fault??null))throw new w({error:"not_hanging",message:`${n} is live but has no pi\u2192provider fault eligible for --now.`,next:"Use --now only on a node the canvas shows as hanging (\u26A0) with a `pi\u2192provider` fault."});if(t.streaming===!0)throw new w({error:"busy",message:`${n} is mid-turn right now (busy) \u2014 refusing to stop a working engine.`,next:"Re-check the canvas \u2014 if it is no longer marked hanging (\u26A0), nothing to do."});await bt(n,{afterTurn:!1,reason:"revive_now"});const i=await vt("machine").stop(r,{reason:"revive_now"});if(!i.confirmed)throw i.error??new Error(`stop of ${n} on its Mac was not confirmed`);return await gt(r.executionId,{reason:"revive_now"}),await de(n,{resume:!0,capacity:"refuse"}),{status:200,body:{kicked:!0}}}d(ki,"handleKick");async function Si(e){const n=e.params.id,t=await h(n),r=e.body,i=r?.resume??!0,a=r?.reopen??!1;await Pn(n,a,e.principal.class==="broker"?e.principal.node:null);const c=!i&&r?.cron_id!==void 0?await Y(r.cron_id):null,s=await X(n);if(i&&s!==null&&s.runner!=="process"&&s.state==="running"&&!lt(t.profile_id))try{await ft({node_id:n,sub:t.sub??null,profile_id:t.profile_id??null},()=>kt(s))}catch(u){if(!(u instanceof ut))throw u}await he(n,{failures:0,notBefore:null});const o=await de(n,{resume:i,capacity:"refuse",...c!==null?{wakeReason:await pt(c,"schedule_revive")}:{}});o.outcome==="already-live"&&await he(n,{failures:t.respawn_failures??0,notBefore:t.respawn_not_before??null});const l=(await b(n))?.status??"active",m=(o.launch??M().get(n)?.handle)?.exited,f=o.outcome!=="frozen"&&await ve(n,m,vi);return{status:200,body:_t(n,o,l,f)}}d(Si,"handleRevive");async function Ii(e){const n=e.params.id;return{status:200,body:{newNodeId:(await Nn(n))?.newNodeId??null}}}d(Ii,"handleRelaunchRoot");async function Ri(e){const n=e.params.id;await h(n);const t=e.body;if(t?.caller_pid!==void 0&&(!Number.isInteger(t.caller_pid)||t.caller_pid<=0))throw y("caller_pid must be a positive integer when provided");const r=mt(),i=new Promise(c=>{e.res.once("close",()=>c())}),a=await Ve(n,{teardownAfter:i,rootEvent:t?.finish===!0?"finish":"cancel",callerPid:t?.caller_pid,...e.principal.class==="broker"?{closer:e.principal.node}:{},...r===null?{}:{registerDetached:r.registerDetached}});return{status:200,body:ht(a)}}d(Ri,"handleClose");async function Ei(e){if(!j(e.principal))throw new p(403,"permission_error","only the person marks a conversation read");const n=e.params.id;return await h(n),await on(n),{status:204}}d(Ei,"handleMarkRead");async function Oi(e){const n=e.params.id;await h(n);const t=await Tn(n);return{status:200,body:{recycled:t.recycled,finalized:t.finalized,new_root:t.newRoot,delivered:t.delivered}}}d(Oi,"handleRecycle");async function Ai(e){const n=e.params.id;return await h(n),await z(n,{lifecycle:"terminal"}),await C(e,n,["lifecycle"]),{status:200,body:await v(n)}}d(Ai,"handleDemote");async function Ci(e,n={}){const t=e.params.id,r=await h(t),i=e.body??{};i.kind!==void 0&&await H(i.kind,r.cwd,r.profile_id??null),i.model!==void 0&&await $e(r,{kind:i.kind??r.kind,mode:"orchestrator",lifecycle:i.resident===!0?"resident":r.lifecycle,model:i.model},n.modelRegistry);const a=await Cn(t,{...i.kind!==void 0?{kind:i.kind}:{},...i.resident===!0?{resident:!0}:{},...i.model!==void 0?{model:i.model}:{}});await C(e,t,["mode",...i.kind!==void 0?["kind"]:[],...i.resident===!0?["lifecycle"]:[],...i.model!==void 0?["model"]:[]]);const c=await Q(a.meta,await Z(t));return c.roadmap_written=a.roadmapWritten,c.roadmap_ref=a.roadmapRef,c.goal_path=a.goalPath,{status:200,body:c}}d(Ci,"handlePromote");async function $i(e){const n=e.params.id;return await h(n),{status:200,body:{request:await Ln(n)}}}d($i,"handleBrokerStructuredRequest");async function Ti(e){const n=e.params.id,t=e.body??{};if(await Dn(n,t.expected_execution_id),typeof t.text!="string")throw new p(400,"invalid_request","text must be a string");return await h(n),{status:200,body:{captured:await Fn(n,t.text)}}}d(Ti,"handleBrokerGoal");async function Ni(e,n={}){const t=e.params.id,r=await h(t),i=e.body??{};i.kind!==void 0&&await H(i.kind,r.cwd,r.profile_id??null),i.model!==void 0&&await $e(r,{kind:i.kind??r.kind,mode:i.promote===!0?"orchestrator":r.mode,lifecycle:r.lifecycle,model:i.model},n.modelRegistry);const a=i.note??"Refresh: continue against your roadmap or goal.";await Mn(t,a);const c=await $n(t,{...i.promote===!0?{promote:!0}:{},...i.kind!==void 0?{kind:i.kind}:{},...i.model!==void 0?{model:i.model}:{}});return{status:200,body:await Q(c.meta,await Z(t))}}d(Ni,"handleYield");async function Pi(e){const n=e.params.id;await h(n);const t=e.body;if(t===void 0||typeof t.controller!="string"||t.controller.trim()==="")throw y("a wait requires a controller node id");const r=await b(t.controller);if(r===null)throw N(`unknown controller: ${t.controller}`,{received:t.controller});if(r.status!=="active"&&r.status!=="idle")throw new p(422,"unprocessable",`controller ${t.controller} is ${r.status}`);return await tn(n,t.controller),{status:200,body:await v(n)}}d(Pi,"handleWait");async function Di(e){const n=e.principal,t=await An(n.class==="broker"?async i=>i.grantee===n.app&&await A(n,i.grantee,i.node_id):n.class==="person"&&!j(n)?async i=>await A(n,i.grantee??"app:terminal",i.node_id):void 0);return{status:200,body:{revived:[...t.revived],failed:[...t.failed],frozen:[...t.frozen]}}}d(Di,"handleReviveAll");const Li=new Set(["interrupt","steer","after-turn","next-turn"]);function Mi(e){if(e===null)return null;const n=d(r=>{throw new w({error:"invalid_listen",message:r,received:e,field:"listen",next:'Send an object mapping levels "1".."10" to interrupt|steer|after-turn|next-turn (e.g. {"3":"next-turn"}), or null to reset to the global default.'})},"bad");if(typeof e!="object"||Array.isArray(e))return n("listen must be an object or null");const t=Object.entries(e);if(t.length===0)return n("listen must name at least one level");for(const[r,i]of t)/^(?:[1-9]|10)$/.test(r)||n(`listen level must be 1..10: ${r}`),(typeof i!="string"||!Li.has(i))&&n(`listen delivery must be interrupt|steer|after-turn|next-turn: ${String(i)}`);return JSON.stringify(Object.fromEntries(t))}d(Mi,"listenJson");async function C(e,n,t,r){t.length===0&&r===void 0||await K(async i=>{if(r?.(i),t.length===0)return;const a=await an(i,n),c=await ln(i,e),s=c.class==="person"?c.person:c.class==="app"?c.app:c.node;await dn(i,s,a),await sn(i,{event:"configured",object:a,actor:s,attrs:{changed:t.join(",")}})})}d(C,"recordConfigured");function De(e){const n=M().get(e);if(n===void 0)return!1;try{return process.kill(n.pid,"SIGTERM"),!0}catch{return!1}}d(De,"restartLiveBroker");function Le(e,n){try{return oe(e)===oe(n)}catch{return!1}}d(Le,"sameDirectory");async function ji(e,n={}){const t=e.params.id,r=e.body;let i;if(r===void 0)i={};else if(typeof r=="object"&&r!==null&&!Array.isArray(r))i=r;else throw new w({error:"cwd_invalid",message:"cwd repair requires a non-null object with a non-empty cwd string",received:r,field:"cwd",next:"Send a config patch with a non-empty absolute cwd string."});if(i.profile!==void 0){if(typeof i.profile!="string"||i.profile==="")throw new w({error:"profile_invalid",message:"profile must be a non-empty profile id or name",received:i.profile,field:"profile",next:"Send a profile id or exact name."});if(Object.keys(i).some(f=>f!=="profile"&&f!=="restart"&&i[f]!==void 0))throw new w({error:"profile_not_exclusive",message:"profile can only be combined with restart",field:"profile",next:"Send profile (and optionally restart) alone."});const o=await h(t),l=await dt(e,i.profile);st(l.profileId);const m=ct(l.profileId).manifest.grantee??"app:terminal";if(m!==(o.grantee??"app:terminal"))throw new w({error:"profile_grantee_mismatch",message:`profile ${l.profileId} belongs to ${m}, node ${t} to ${o.grantee}`,received:i.profile,field:"profile",next:"Pick a profile owned by the same app as the node."});return(o.profile_id??null)!==l.profileId&&(rt(o.kind)?(await H(o.kind,o.cwd,l.profileId),await z(t,{profileId:l.profileId})):await T(t,{profile_id:l.profileId}),await C(e,t,["profile"])),i.restart===!0&&De(t),{status:200,body:await v(t)}}if(Object.prototype.hasOwnProperty.call(i,"cwd")){const o=i.cwd;if(typeof o!="string"||o==="")throw new w({error:"cwd_invalid",message:"cwd must be a non-empty string",received:o,field:"cwd",next:"Send a non-empty absolute cwd string."});if(Object.keys(i).some(u=>u!=="cwd"&&u!=="keep_session"&&u!=="restart"&&i[u]!==void 0))throw new w({error:"cwd_not_exclusive",message:"cwd repair cannot be combined with another config field",received:i,field:"cwd",next:"Send cwd as the only config field."});const l=await h(t),m=$(l.cwd);if(i.keep_session===!0||m&&W(o)&&$(o)&&Le(l.cwd,o)){if(!W(o))throw new w({error:"cwd_not_absolute",message:`cwd must be an absolute path: ${o}`,received:o,field:"cwd",next:"Send an absolute path."});const u=L(o);let _=!1;try{_=ae(u).isDirectory()}catch{}if(!_)throw new w({error:"cwd_missing",message:`cwd is not an existing directory: ${u}`,received:o,field:"cwd",next:"Send an existing absolute directory."});if(m&&!Le(l.cwd,u))throw new w({error:"cwd_not_same_directory",message:`${u} is not the same directory as the recorded ${l.cwd}; --keep-session only relocates an alias`,received:o,field:"cwd",next:"Drop --keep-session to repair a gone cwd, or pass the real path of the recorded directory."});if(l.managed_worktree?.state==="open")throw new w({error:"cwd_node_managed_worktree_open",message:`${t} owns an open managed worktree and cannot relocate its cwd`,received:o,field:"cwd",next:"Reconcile the managed worktree first."});const I=l.cwd;return I!==u&&(await K(async k=>{await T(t,{cwd:u}),await k.prepare("UPDATE crons SET cwd = ? WHERE anchor_node = ? AND cwd = ?").run(u,t,I),await cn(t,I,u)}),await C(e,t,["cwd"])),i.restart===!0&&De(t),{status:200,body:await v(t)}}if(await M().has(t)){const u=`${t} cannot repair its cwd while its broker is live`;throw new p(409,"cwd_node_live",u,{error:"cwd_node_live",message:u,received:o,field:"cwd",next:"Let the node become dormant, then retry the cwd repair."})}if(l.fork_from!=null)throw new w({error:"cwd_node_forked",message:`${t} is a fork and cannot repair its cwd; recorded cwd: ${l.cwd}`,received:o,field:"cwd",next:`Restore ${l.cwd}, then revive the fork normally.`});if(l.managed_worktree?.state==="open")throw new w({error:"cwd_node_managed_worktree_open",message:`${t} owns an open managed worktree and cannot repair its cwd`,received:o,field:"cwd",next:"Restore or reconcile the recorded checkout, then use the managed-worktree close or abandon flow."});if($(l.cwd))throw new w({error:"cwd_still_present",message:`${t} recorded cwd still exists: ${l.cwd}; cwd repair is not a relocation command`,received:o,field:"cwd",next:"This command only repairs a node whose recorded cwd is gone."});if(!W(o))throw new w({error:"cwd_not_absolute",message:`cwd must be an absolute path: ${o}`,received:o,field:"cwd",next:"Send an absolute path."});const f=L(o);if(!$(f))throw new w({error:"cwd_missing",message:`cwd does not exist: ${f}`,received:o,field:"cwd",next:"Create the replacement directory or send an existing absolute directory."});try{if(!ae(f).isDirectory())throw new w({error:"cwd_not_a_directory",message:`cwd is not a directory: ${f}`,received:o,field:"cwd",next:"Send an existing absolute directory."})}catch(u){throw u instanceof w?u:new w({error:"cwd_missing",message:`cwd does not exist: ${f}`,received:o,field:"cwd",next:"Create the replacement directory or send an existing absolute directory."})}return await K(async()=>{await T(t,{cwd:f}),await un(t)}),await C(e,t,["cwd"]),{status:200,body:await v(t)}}let a=await h(t);const c=i.listen===void 0?void 0:Mi(i.listen);if(i.scopes!==void 0){const o=Re(i.scopes),l=a.grantee==="app:terminal"?await Ft(a):a.grant_id?await Lt(a.grant_id):null;if(!o.every(m=>E(a.scopes,m)&&l!==null&&E(l.resolved,m)))throw new w({error:"unknown_scope",message:"scopes may only narrow the node's current effective set",received:o,field:"scopes",next:"Send only scopes the node currently holds."});if(o.includes("crtr:act")&&!E(o,"crtr:llm"))throw new p(400,"invalid_scope","crtr:act requires crtr:llm");a=await T(t,{scopes:o})}if(i.situational_context!==void 0&&await We(t,Ue(i.situational_context)),i.model!==void 0){const o=(await be(a.cwd,a.profile_id??null,a.grantee??"app:terminal")).modelLadders,l=Un(i.model,o),m=await Gt(a.grant_id,i.model,l===void 0),f=m?{family:xt,strength:m.strength}:l,u=m?m.model:Vn(i.model,o);await V({kind:"concrete",spec:u},{cwd:a.cwd,profileId:a.profile_id??null},n.modelRegistry);const _=M();let I=!1;if(await _.isClaimed(t)&&((await X(t))?.runner==="machine"||await ve(t,_.get(t)?.handle.exited))&&(I=await zn(t,u,f,await Hn(t)).then(()=>!0,k=>{if(k instanceof Yn)return!1;throw k})),!I){if(await _.isClaimed(t)){const k=`${t}'s broker did not accept the model switch; the model was not changed`;throw new p(409,"broker_not_ready",k,{error:"broker_not_ready",message:k,received:i.model,field:"model",next:"Check the node with `crtr node inspect show`, then retry the model change."})}if(!u.includes("/"))throw y(`model must resolve to a provider/id spec: ${i.model}`);await Jn(t,u,f)}a=await h(t)}if(i.kind!==void 0||i.mode!==void 0||i.lifecycle!==void 0){i.kind!==void 0&&await je(i.kind,a.grantee??"app:terminal");const o=i.kind??a.kind,l=i.mode??a.mode,m=i.lifecycle??a.lifecycle;let f;l==="orchestrator"&&!await xn(t)&&(f=d(async()=>{const u=await jn(t);await Gn(t,u!==null&&u.trim()!==""?{goal:u.trim()}:{})},"beforePersist")),a=await z(t,{...i.kind!==void 0?{kind:o}:{},...i.mode!==void 0?{mode:l}:{},...i.lifecycle!==void 0?{lifecycle:m}:{}},f)}i.name!==void 0&&(a=await T(t,{name:i.name}),a.window&&Bn(a.window,at(a)));const s=["scopes","situational_context","model","kind","mode","lifecycle","name","listen"].filter(o=>i[o]!==void 0);return await C(e,t,s,c===void 0?void 0:async o=>{await o.prepare("UPDATE objects SET listen_json = ? WHERE id = ? AND type = 'node'").run(c,t)}),{status:200,body:await v(t)}}d(ji,"handleConfig");async function Me(e="app:terminal"){return(await be(process.cwd(),xe()||null,e)).kinds}d(Me,"daemonKinds");async function je(e,n="app:terminal"){const t=Object.keys(await Me(n));if(!t.includes(e))throw y(`unknown kind: ${e}`,{received:e,next:`Valid kinds: ${t.sort().join(", ")}.`})}d(je,"assertKindServer");async function Fi(){const e=await Me();return{status:200,body:{kinds:Object.keys(e).sort().map(t=>({kind:t,when_to_use:e[t]?.whenToUse??null,available_to:e[t]?.availableTo??null}))}}}d(Fi,"handleListKinds");const So=[{method:"POST",pattern:"/v1/nodes",scope:"crtr:act",handler:oi},{method:"GET",pattern:"/v1/nodes",handler:ci},{method:"GET",pattern:"/v1/kinds",handler:d(()=>Fi(),"handler")},{method:"POST",pattern:"/v1/nodes/revive-all",scope:"crtr:act",handler:Di},{method:"GET",pattern:"/v1/nodes/:id",handler:ui},{method:"GET",pattern:"/v1/nodes/:id/snapshot",handler:fi},{method:"GET",pattern:"/v1/nodes/:id/subject",handler:pi},{method:"GET",pattern:"/v1/nodes/:id/messages",handler:wi},{method:"GET",pattern:"/v1/nodes/:id/session",handler:hi},{method:"GET",pattern:"/v1/nodes/:id/transcript",handler:yi},{method:"GET",pattern:"/v1/nodes/:id/context",handler:_i},{method:"POST",pattern:"/v1/nodes/:id/fork",scope:"crtr:act",handler:bi},{method:"POST",pattern:"/v1/nodes/:id/revive",scope:"crtr:act",handler:Si},{method:"POST",pattern:"/v1/nodes/:id/kick",scope:"crtr:act",handler:ki},{method:"POST",pattern:"/v1/nodes/:id/relaunch-root",scope:"crtr:act",handler:Ii},{method:"POST",pattern:"/v1/nodes/:id/close",handler:Ri},{method:"POST",pattern:"/v1/nodes/:id/read",handler:Ei},{method:"POST",pattern:"/v1/nodes/:id/recycle",scope:"crtr:act",handler:Oi},{method:"POST",pattern:"/v1/nodes/:id/demote",scope:"crtr:act",handler:Ai},{method:"POST",pattern:"/v1/nodes/:id/promote",scope:"crtr:act",handler:Ci},{method:"POST",pattern:"/v1/nodes/:id/yield",scope:"crtr:act",handler:Ni},{method:"GET",pattern:"/v1/nodes/:id/broker/structured-request",handler:$i},{method:"POST",pattern:"/v1/nodes/:id/broker/goal",handler:Ti},{method:"POST",pattern:"/v1/nodes/:id/wait",handler:Pi},{method:"PATCH",pattern:"/v1/nodes/:id/config",handler:ji}];export{ji as handleConfig,oi as handleCreate,bi as handleFork,ci as handleList,Ci as handlePromote,Ni as handleYield,So as nodeRoutes,Eo as resolveCreateKind};
|
|
@@ -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.755
|
|
11
|
+
|
|
12
|
+
### An app can start runs in its own environment with no person
|
|
13
|
+
|
|
14
|
+
`run.start` with a `profile` that is an app environment accepts the app's own call token (subject `app:<id>` or a path under it, no grant). The run's subject is the token's and it has no grant. Any other caller is refused with 403 `app_environment`. Charges for the run name the environment's payer.
|
|
15
|
+
|
|
10
16
|
## 0.3.753
|
|
11
17
|
|
|
12
18
|
### Charges and audit rows record the actor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.755",
|
|
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.755",
|
|
161
|
+
"@north-light/plugin": "0.3.755",
|
|
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",
|
|
@@ -34,6 +34,8 @@ import { isPortableModelToken } from '../runtime/launch.js';
|
|
|
34
34
|
import { parseDurationMs } from '../wake.js';
|
|
35
35
|
import { expandModelCandidates, parseModelSpec } from '../model-routes.js';
|
|
36
36
|
import { payerOfGrant } from '../grants/mirror.js';
|
|
37
|
+
import { ownsWithoutRow } from '../grants/owner.js';
|
|
38
|
+
import { environmentPayerOfProfile } from '../ledger/index.js';
|
|
37
39
|
import { runUsage } from '../ledger/read.js';
|
|
38
40
|
import { ZERO_RUN_USAGE } from '../../api/dto/run-events.js';
|
|
39
41
|
import { isolatedBrokerLauncherAvailable } from '../runtime/host.js';
|
|
@@ -278,6 +280,10 @@ export async function startRun(principal, input, idempotencyKey, resolveAttachme
|
|
|
278
280
|
await ensureAppSpace(principal.grantee);
|
|
279
281
|
const profile = input.profile === undefined ? await ensureAppProfile(principal.grantee) : loadExactProfileManifest(input.profile);
|
|
280
282
|
const owner = profile.manifest.grantee ?? 'app:terminal';
|
|
283
|
+
// An app environment runs with no person: only an owner principal of the environment's app (no grant row, `sub` in its namespace) may start in it.
|
|
284
|
+
if (await environmentPayerOfProfile(profile.profileId) !== null && !ownsWithoutRow(owner, principal.sub, principal.grant)) {
|
|
285
|
+
throw new RunError(403, 'app_environment', `an app environment starts runs for ${owner} only, not for ${principal.sub}`, 'profile');
|
|
286
|
+
}
|
|
281
287
|
if (owner !== principal.grantee) {
|
|
282
288
|
const permission = `crtr:memory:rw:${owner}:profile:${profile.profileId}`;
|
|
283
289
|
if (!principal.resolved.some((held) => covers(held, permission)) ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.755",
|
|
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/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.755",
|
|
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.755",
|
|
31
|
+
"@north-light/identity": "0.3.755"
|
|
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.755",
|
|
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.755",
|
|
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.755",
|
|
32
|
+
"@north-light/plugin": "0.3.755",
|
|
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.755",
|
|
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.755",
|
|
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.755",
|
|
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.755",
|
|
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.755",
|
|
11927
|
+
"@north-light/identity": "0.3.755"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.755",
|
|
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.755",
|
|
11936
|
+
"@north-light/identity": "0.3.755",
|
|
11937
|
+
"@north-light/plugin": "0.3.755",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|