@north-light/cli 0.3.714 → 0.3.716
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +3 -1
- package/dist/api/client.js +2 -2
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/environments.d.ts +4 -0
- package/dist/api/dto/execution-start.d.ts +9 -0
- package/dist/api/routes.d.ts +1 -0
- package/dist/api/routes.js +1 -1
- package/dist/clients/attach/viewer.js +222 -222
- package/dist/commands/profile/environment.js +2 -2
- package/dist/commands/sys/feedback.js +5 -5
- package/dist/core/canvas/executions.d.ts +0 -2
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/schema-pg/030-environment-pull-request-write.sql +2 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/environment-recipe.d.ts +1 -0
- package/dist/core/environment-recipe.js +1 -1
- package/dist/core/import/load/rewrite.js +14 -14
- package/dist/core/ledger/rates.d.ts +0 -2
- package/dist/core/ledger/rates.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/runner/blaxel/image-build.d.ts +3 -0
- package/dist/core/runtime/runner/blaxel/image-build.js +6 -6
- package/dist/core/runtime/runner/types.d.ts +0 -2
- package/dist/core/runtime/spawn.js +1 -1
- package/dist/daemon/api/handlers/environments.js +1 -1
- package/dist/daemon/api/handlers/feedback.d.ts +2 -0
- package/dist/daemon/api/handlers/feedback.js +9 -0
- package/dist/daemon/api/handlers/git-credential.d.ts +3 -2
- package/dist/daemon/api/handlers/git-credential.js +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/reconcilers/ledger-storage.js +2 -4
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/client.js +4 -0
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/api/routes.js +1 -0
- package/packages/crouter-api/dist/commands/profile/environment.js +6 -2
- package/packages/crouter-api/dist/commands/sys/feedback.js +12 -2
- package/packages/crouter-api/dist/core/canvas/executions.js +2 -3
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/environment-recipe.js +3 -0
- package/packages/crouter-api/dist/core/import/load/rewrite.js +8 -4
- package/packages/crouter-api/dist/core/ledger/rates.js +0 -3
- package/packages/crouter-api/dist/core/runtime/revive.js +1 -1
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/image-build.js +11 -1
- package/packages/crouter-api/dist/core/runtime/runner/types.js +1 -1
- package/packages/crouter-api/dist/core/runtime/spawn.js +1 -1
- package/packages/crouter-api/dist/daemon/api/handlers/git-credential.js +7 -5
- package/packages/crouter-api/dist/daemon/api/operations.js +1 -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
- package/scripts/sandbox-start.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var Y=Object.defineProperty;var i=(t,r)=>Y(t,"name",{value:r,configurable:!0});import{chmodSync as F,closeSync as L,existsSync as G,mkdirSync as k,openSync as $,unlinkSync as J,writeFileSync as X,rmSync as R}from"node:fs";import{createServer as K}from"node:http";import{dirname as x,join as P}from"node:path";import{spawn as z}from"node:child_process";import{SELF_UPDATE_SCRIPT as C}from"../core/self-update.js";import{apiSocketPath as V,crtrHome as D}from"../core/canvas/paths.js";import{bindDaemonEventSource as W}from"../core/events/source.js";import{emitEvent as p}from"../core/events/emit.js";import{brokerCommandDeclaresCanvasHome as Q}from"../core/runtime/broker-ownership.js";import{createMachineExecutor as Z,findBrokers as q,stopAllBrokers as ee}from"../core/runtime/runner/machine/executor.js";import{machineCheckoutHandlers as ne}from"../core/checkout-identities.js";import{machineWorktreeHandlers as te}from"../core/worktree-machine.js";import{readPersonCredential as oe}from"../core/directory/person-credential.js";import{socketDir as re}from"../core/layout.js";import{isDaemonRunning as ie,pidfilePath as S,readPidfile as ae}from"./pidfile.js";import{cancelMachineCron as se,runMachineCron as ce,stopOrphanedMachineCrons as de}from"./cron/machine-exec.js";import{startMachineLink as me}from"./machine-link/client.js";import{deleteMoveRecord as O,readMachineConfig as fe,readMachineCredential as j,readMoveRecord as le,writeMoveRecord as pe}from"./machine-link/config.js";import{jobExitReporting as ue,stopMachineJob as he}from"./machine-link/job-sweep.js";import{notifyMoveFinished as ve}from"./machine-link/move-notify.js";import{machineSupervision as we,SUPERVISION_TICK_MS as ye}from"./machine-supervision.js";import{startBrokerMemoryCap as _e}from"./broker-memory-cap.js";const B=10*6e4,Se=3e4,Ie=75;let I=0;function ge(t){if(Date.now()-I<B||!/^\d+\.\d+\.\d+$/.test(t))return;I=Date.now(),p({level:"warn",event:"daemon.machine.updating",fields:{release:t}});const r=P(x(C),"..","bin","crtr"),a=$(P(D(),"crtrd.err"),"a"),n=z("/bin/sh",["-c",'"$0" "$1" --version "$2" && "$0" "$3" sys daemon restart',process.execPath,C,t,r],{detached:!0,stdio:["ignore",a,a]});n.on("exit",d=>{d===Ie&&(I=Date.now()-B+Se)}),n.unref(),L(a)}i(ge,"updateToRelease");const H=1024;function Ee(t,r){return{ok:!0,daemon_up:!0,store_accessible:!1,brokers_reconciled:!1,link_connected:t,signed_in:r,startup_phase:t?"ready":"recovering"}}i(Ee,"machineHealth");async function Qe(){const t=fe();if(t===void 0)throw new Error("crtrd --role machine needs runtime/machine.json: this install has not been imported as a machine");const r=oe()!==void 0;if(r&&j(),ie())throw new Error("a crtrd is already running for this home");W(),r||(await ee(),await de(),p({level:"info",event:"daemon.machine.signed_out",fields:{environment:t.environmentId}})),k(re(),{recursive:!0,mode:493});const a=V();G(a)&&J(a);let n;const d=ue(()=>n),s=K((e,o)=>{const c=(e.url??"").split("?")[0];if(e.method==="POST"&&(c==="/job-exit"||c==="/job-activity")){const T=[];let _=0;e.on("data",m=>{_+=m.length,_<=H&&T.push(m)}),e.on("end",()=>{if(_>H){o.writeHead(413),o.end();return}let m={};try{m=JSON.parse(Buffer.concat(T).toString("utf8"))}catch{}const b=typeof m.node=="string"&&typeof m.job=="string";o.writeHead(b?202:400,{"content-type":"application/json; charset=utf-8"}),o.end("{}"),b&&(c==="/job-exit"?d.notice:d.activity)(m.node,m.job)});return}const M=(e.method??"GET")==="GET"&&(e.url??"/").split("?")[0]==="/healthz";o.writeHead(M?200:404,{"content-type":"application/json; charset=utf-8"}),o.end(JSON.stringify(M?Ee(n?.connected()===!0,r):{error:{code:"not_found",message:"a machine-role crtrd serves only /healthz",origin:"runtime"}}))});await new Promise((e,o)=>{s.once("error",o),s.listen(a,()=>{s.off("error",o),F(a,384),e()})}),k(x(S()),{recursive:!0}),X(S(),String(process.pid),"utf8");let l;await be(t.runId,r,()=>l!==void 0);const u=new Set,v=new Set;let w=!1;const f=Z({apiUrl:t.apiUrl,environmentId:t.environmentId,onExit:i(e=>n?.reportExit(e),"onExit")}),
|
|
1
|
+
var Y=Object.defineProperty;var i=(t,r)=>Y(t,"name",{value:r,configurable:!0});import{chmodSync as F,closeSync as L,existsSync as G,mkdirSync as k,openSync as $,unlinkSync as J,writeFileSync as X,rmSync as R}from"node:fs";import{createServer as K}from"node:http";import{dirname as x,join as P}from"node:path";import{spawn as z}from"node:child_process";import{SELF_UPDATE_SCRIPT as C}from"../core/self-update.js";import{apiSocketPath as V,crtrHome as D}from"../core/canvas/paths.js";import{bindDaemonEventSource as W}from"../core/events/source.js";import{emitEvent as p}from"../core/events/emit.js";import{brokerCommandDeclaresCanvasHome as Q}from"../core/runtime/broker-ownership.js";import{createMachineExecutor as Z,findBrokers as q,stopAllBrokers as ee}from"../core/runtime/runner/machine/executor.js";import{machineCheckoutHandlers as ne}from"../core/checkout-identities.js";import{machineWorktreeHandlers as te}from"../core/worktree-machine.js";import{readPersonCredential as oe}from"../core/directory/person-credential.js";import{socketDir as re}from"../core/layout.js";import{isDaemonRunning as ie,pidfilePath as S,readPidfile as ae}from"./pidfile.js";import{cancelMachineCron as se,runMachineCron as ce,stopOrphanedMachineCrons as de}from"./cron/machine-exec.js";import{startMachineLink as me}from"./machine-link/client.js";import{deleteMoveRecord as O,readMachineConfig as fe,readMachineCredential as j,readMoveRecord as le,writeMoveRecord as pe}from"./machine-link/config.js";import{jobExitReporting as ue,stopMachineJob as he}from"./machine-link/job-sweep.js";import{notifyMoveFinished as ve}from"./machine-link/move-notify.js";import{machineSupervision as we,SUPERVISION_TICK_MS as ye}from"./machine-supervision.js";import{startBrokerMemoryCap as _e}from"./broker-memory-cap.js";const B=10*6e4,Se=3e4,Ie=75;let I=0;function ge(t){if(Date.now()-I<B||!/^\d+\.\d+\.\d+$/.test(t))return;I=Date.now(),p({level:"warn",event:"daemon.machine.updating",fields:{release:t}});const r=P(x(C),"..","bin","crtr"),a=$(P(D(),"crtrd.err"),"a"),n=z("/bin/sh",["-c",'"$0" "$1" --version "$2" && "$0" "$3" sys daemon restart',process.execPath,C,t,r],{detached:!0,stdio:["ignore",a,a]});n.on("exit",d=>{d===Ie&&(I=Date.now()-B+Se)}),n.unref(),L(a)}i(ge,"updateToRelease");const H=1024;function Ee(t,r){return{ok:!0,daemon_up:!0,store_accessible:!1,brokers_reconciled:!1,link_connected:t,signed_in:r,startup_phase:t?"ready":"recovering"}}i(Ee,"machineHealth");async function Qe(){const t=fe();if(t===void 0)throw new Error("crtrd --role machine needs runtime/machine.json: this install has not been imported as a machine");const r=oe()!==void 0;if(r&&j(),ie())throw new Error("a crtrd is already running for this home");W(),r||(await ee(),await de(),p({level:"info",event:"daemon.machine.signed_out",fields:{environment:t.environmentId}})),k(re(),{recursive:!0,mode:493});const a=V();G(a)&&J(a);let n;const d=ue(()=>n),s=K((e,o)=>{const c=(e.url??"").split("?")[0];if(e.method==="POST"&&(c==="/job-exit"||c==="/job-activity")){const T=[];let _=0;e.on("data",m=>{_+=m.length,_<=H&&T.push(m)}),e.on("end",()=>{if(_>H){o.writeHead(413),o.end();return}let m={};try{m=JSON.parse(Buffer.concat(T).toString("utf8"))}catch{}const b=typeof m.node=="string"&&typeof m.job=="string";o.writeHead(b?202:400,{"content-type":"application/json; charset=utf-8"}),o.end("{}"),b&&(c==="/job-exit"?d.notice:d.activity)(m.node,m.job)});return}const M=(e.method??"GET")==="GET"&&(e.url??"/").split("?")[0]==="/healthz";o.writeHead(M?200:404,{"content-type":"application/json; charset=utf-8"}),o.end(JSON.stringify(M?Ee(n?.connected()===!0,r):{error:{code:"not_found",message:"a machine-role crtrd serves only /healthz",origin:"runtime"}}))});await new Promise((e,o)=>{s.once("error",o),s.listen(a,()=>{s.off("error",o),F(a,384),e()})}),k(x(S()),{recursive:!0}),X(S(),String(process.pid),"utf8");let l;await be(t.runId,r,()=>l!==void 0);const u=new Set,v=new Set;let w=!1;const f=Z({apiUrl:t.apiUrl,environmentId:t.environmentId,onExit:i(e=>n?.reportExit(e),"onExit")}),U=i(async(e,o)=>{u.add(e.executionId);for(const c of v)c.add(e.executionId);try{return await f.start(e,o)}finally{u.delete(e.executionId)}},"start");n=r?me({apiUrl:t.apiUrl,environmentId:t.environmentId,credential:j,onOpen:i(()=>{d.onOpen(),w=!0},"onOpen"),onBehind:ge,handlers:{start:U,wake:f.wake,stop:f.stop,status:f.status,delete:f.delete,viewer:f.viewer,"cron.run":ce,"cron.cancel":se,"job.stop":i(e=>he(e),"job.stop"),...te,...ne}}):void 0;const g=n===void 0?void 0:we({link:n,brokers:i(async()=>{const e=new Set(u);v.add(e);const o=await q().finally(()=>v.delete(e));return w&&(w=!1,n?.reportRunning([...new Set([...e,...o.filter(c=>Q(c.command,D())).map(c=>c.execution)])])),o},"brokers"),stop:i((e,o)=>f.stop({execution:{executionId:e,nodeId:o,attempt:0},options:{reason:"yield_stall"}}),"stop")});let y=!1;const A=g===void 0?void 0:setInterval(()=>{y||(y=!0,g(Date.now()).catch(e=>p({level:"error",event:"daemon.machine.supervision_failed",error:e})).finally(()=>{y=!1}))},ye),N=_e();p({level:"info",event:"daemon.machine.started",fields:{environment:t.environmentId}});const E=i(()=>l??=(async()=>{n?.stop(),clearInterval(A),N(),await new Promise(e=>{s.close(()=>e()),s.closeAllConnections()}),ae()===process.pid&&(R(a,{force:!0}),R(S(),{force:!0})),process.off("SIGINT",h),process.off("SIGTERM",h)})(),"teardown"),h=i(()=>{E().then(()=>process.exit(0),()=>process.exit(1))},"onSignal");return process.on("SIGINT",h),process.on("SIGTERM",h),E}i(Qe,"runMachineDaemon");const Me=5e3,Te=3e5;async function be(t,r,a){let n;try{n=le()}catch(s){p({level:"warn",event:"daemon.machine.move_record_unreadable",fields:{error:s.message}});return}if(n===void 0||n.state==="running"||n.runId!==t)return;if(n.notified||n.notify===null){O();return}if(n.state==="committed"&&(n={...n,state:"activated"},pe(n)),!r)return;const d=n;(async()=>{let s=Me;for(;;){try{await ve(d),O();return}catch(l){p({level:"warn",event:"daemon.machine.move_notify_failed",fields:{node:d.notify??"",error:l.message}})}if(await new Promise(l=>{setTimeout(l,s).unref()}),a())return;s=Math.min(s*2,Te)}})()}i(be,"settleFinishedMove");export{Ee as machineHealth,Qe as runMachineDaemon};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=Object.defineProperty;var f=(n,e)=>D(n,"name",{value:e,configurable:!0});import{openDb as w}from"../../core/canvas/db.js";import{getNode as M}from"../../core/canvas/canvas.js";import{LEDGER_ENV as O,storageUsdPerGbMonth as E,warnRateUnset as N}from"../../core/ledger/rates.js";import{emitEvent as g}from"../../core/events/emit.js";import{operationIdContext as _}from"../../core/events/operation-id.js";import{billingAccountOf as T}from"../../core/ledger/account.js";import{writeInfraCharge as L}from"../../core/ledger/infra-allowance.js";import{usageMonth as y}from"../../core/ledger/months.js";import{startCandidateOf as A}from"../../core/runtime/start-check.js";import{runThrottledLane as C}from"./throttled-lane.js";const v=60*6e4,I=10*6e4,U=1024**3;async function K(){if(E()===null)return;const n=await(await w()).prepare("SELECT cursor FROM reconciler_leases WHERE lane = 'ledger-storage' AND key = ''").get(),e=n?.cursor==null?null:JSON.parse(n.cursor).state;return e===null?null:e.slice(0,7)}f(K,"storageSettledThrough");function G(n){const[e,r]=n.split("-").map(Number);return y(new Date(Date.UTC(e,r-2,1)))}f(G,"previousMonth");const S=f(n=>{const[e,r]=n.split("-").map(Number);return y(new Date(Date.UTC(e,r,1)))},"nextMonth"),x=f(n=>{const[e,r]=n.split("-").map(Number);return new Date(Date.UTC(e,r,1)).toISOString()},"endOf");class q{static{f(this,"LedgerStorageReconciler")}run(e,r){if(!r.lifecycle.acceptsDetachedWork())return;const a=_.fresh(()=>C("ledger-storage","",e,v,I,async o=>{await this.pass(e,o)})).then(()=>{}).catch(o=>{_.fresh(()=>g({level:"error",event:"ledger.storage.failed",error:o}))});r.lifecycle.registerDetached(a)}async pass(e,r){const a=G(y(new Date(e))),o={month:null,rows:0,failed:0},l=E();if(l===null)return N("ledger-storage",O.storageUsdPerGbMonth),o;const i=r?.state?.slice(0,7)??null,c=[];if(i===null)c.push(a);else for(let s=S(i);s<=a;s=S(s))c.push(s);for(const s of c){if(o.month=s,!await this.settleMonth(s,l,r,o))break;await r?.save(s)}return(o.rows>0||o.failed>0)&&g({level:"info",event:"ledger.storage.settled",outcome:"succeeded",fields:{...o}}),o}async settleMonth(e,r,a,o){const l=x(e),i=await w(),c=new Map,s=f((t,d)=>{c.set(t,(c.get(t)??0)+Number(d))},"add");for(const t of await i.prepare("SELECT split_part(blob_key, '/', 2) AS node, sum(bytes) AS bytes FROM conversation_parts WHERE created < ? GROUP BY 1").all(l))s(t.node,t.bytes);for(const t of await i.prepare(`SELECT x.node, sum(u.size) AS bytes FROM (
|
|
2
2
|
SELECT DISTINCT upload_id, split_part(blob_key, '/', 2) AS node FROM upload_uses WHERE blob_key LIKE 'attachments/%') x
|
|
3
|
-
JOIN uploads u ON u.upload_id = x.upload_id WHERE u.created_at < ? GROUP BY x.node`).all(
|
|
4
|
-
SELECT DISTINCT node_id, sandbox_name FROM executions WHERE runner = 'blaxel' AND sandbox_name IS NOT NULL AND started_at < ?) x
|
|
5
|
-
JOIN nodes n ON n.node_id = x.node_id JOIN objects o ON o.id = n.node_id AND (o.deleted_at IS NULL OR o.deleted_at >= ?) JOIN profiles p ON p.id = n.profile_id JOIN environments e ON e.object = p.environment_id GROUP BY x.node_id`).all(i,i))g(e.node).diskGb+=Number(e.mb)/2/1024;const y=new Map;for(const[e,a]of _){const p=await A(e),u=p===null?null:await v(p);if(u===null)continue;const f=y.get(u.payer)??{sub:u.sub,grantee:u.grantee,bytes:0,diskGb:0,node:e};f.bytes+=a.bytes,f.diskGb+=a.diskGb,y.set(u.payer,f)}const x=new Date(Date.parse(i)-1);let w=0;for(const[e,a]of y){if(d&&!await d.holds())return!1;try{const{account:p,billable:u}=await G(n,e),f=[{id:`storage:${e}:${t}:r2`,provider:"r2",gbMonths:a.bytes/F,rate:c},{id:`storage:${e}:${t}:blaxel`,provider:"blaxel",gbMonths:a.diskGb,rate:m}];for(const l of f){if(l.rate===null||l.gbMonths<=0)continue;const L=l.gbMonths*l.rate;(await I({id:l.id,at:x,kind:"storage",what:l.provider==="r2"?"object storage":"sandbox disk",units:{gb_months:l.gbMonths},usd:L,payer:e,funding:"bill",sub:a.sub,grantee:a.grantee,provider:l.provider,causedBy:null,account:p},u)).written&&(r.rows+=1)}}catch(p){r.failed+=1,w+=1,E({level:"warn",event:"ledger.storage.payer_failed",error:p,fields:{payer:e,month:t}})}}return w===0}}export{U as LEDGER_STORAGE_INTERVAL_MS,te as LedgerStorageReconciler,ee as storageSettledThrough};
|
|
3
|
+
JOIN uploads u ON u.upload_id = x.upload_id WHERE u.created_at < ? GROUP BY x.node`).all(l))s(t.node,t.bytes);for(const t of await i.prepare("SELECT node_id AS node, sum(size) AS bytes FROM files WHERE completed_at IS NOT NULL AND completed_at < ? GROUP BY node_id").all(l))s(t.node,t.bytes);const b=new Map;for(const[t,d]of c){const p=await M(t),u=p===null?null:await A(p);if(u===null)continue;const m=b.get(u.payer)??{sub:u.sub,grantee:u.grantee,bytes:0,node:t};m.bytes+=d,b.set(u.payer,m)}const R=new Date(Date.parse(l)-1);let h=0;for(const[t,d]of b){if(a&&!await a.holds())return!1;try{const{account:p,billable:u}=await T(i,t),m=d.bytes/U;if(m<=0)continue;(await L({id:`storage:${t}:${e}:r2`,at:R,kind:"storage",what:"object storage",units:{gb_months:m},usd:m*r,payer:t,funding:"bill",sub:d.sub,grantee:d.grantee,provider:"r2",causedBy:null,account:p},u)).written&&(o.rows+=1)}catch(p){o.failed+=1,h+=1,g({level:"warn",event:"ledger.storage.payer_failed",error:p,fields:{payer:t,month:e}})}}return h===0}}export{v as LEDGER_STORAGE_INTERVAL_MS,q as LedgerStorageReconciler,K as storageSettledThrough};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.716",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -158,8 +158,8 @@
|
|
|
158
158
|
},
|
|
159
159
|
"license": "UNLICENSED",
|
|
160
160
|
"dependencies": {
|
|
161
|
-
"@north-light/identity": "0.3.
|
|
162
|
-
"@north-light/plugin": "0.3.
|
|
161
|
+
"@north-light/identity": "0.3.716",
|
|
162
|
+
"@north-light/plugin": "0.3.716",
|
|
163
163
|
"@earendil-works/chord": "1.5.2",
|
|
164
164
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
165
165
|
"@earendil-works/pi-ai": "1.5.2",
|
|
@@ -417,6 +417,10 @@ export class CrtrClient {
|
|
|
417
417
|
gitCredential(environmentId, req) {
|
|
418
418
|
return this.request('POST', routes.environmentGitCredential(environmentId), req);
|
|
419
419
|
}
|
|
420
|
+
/** File a crtr harness report as an issue on the crouter repository (a cloud node's report; the control plane attaches the node, environment and person). */
|
|
421
|
+
postFeedback(req) {
|
|
422
|
+
return this.request('POST', routes.feedback(), req);
|
|
423
|
+
}
|
|
420
424
|
brokerExtensionState(id) {
|
|
421
425
|
return this.request('GET', routes.nodeBrokerExtensionState(this.nodePath(id)));
|
|
422
426
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
//
|
|
13
13
|
// PURITY (spec §3.1): Node built-ins + `src/api/*` only.
|
|
14
14
|
/** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
|
|
15
|
-
export const CONTRACT_LEVEL = '1.
|
|
15
|
+
export const CONTRACT_LEVEL = '1.70';
|
|
16
16
|
/** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
|
|
17
17
|
export const REQUIRED_CONTRACT_HEADER = 'Crouter-Required-Contract';
|
|
18
18
|
/** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
|
|
@@ -32,6 +32,7 @@ export const routes = {
|
|
|
32
32
|
executionStart: (id) => `${V}/executions/${id}/start`,
|
|
33
33
|
executionImportUnpacked: (id) => `${V}/executions/${id}/import-unpacked`,
|
|
34
34
|
environmentGitCredential: (id) => `${V}/environments/${id}/git-credential`,
|
|
35
|
+
feedback: () => `${V}/feedback`,
|
|
35
36
|
nodeOutcome: (id) => `${V}/nodes/${id}/outcome`,
|
|
36
37
|
nodeOutcomeDelivery: (id) => `${V}/nodes/${id}/outcome-delivery`,
|
|
37
38
|
nodeEvents: (id) => `${V}/nodes/${id}/events`,
|
|
@@ -13,6 +13,7 @@ const ENVIRONMENT_OUTPUT = [
|
|
|
13
13
|
{ name: 'setup_script', type: 'string', required: false, constraint: 'The script the image build runs; null when none.' },
|
|
14
14
|
{ name: 'pi_packages', type: 'string', required: false, constraint: 'pi package sources, one per line; null when none.' },
|
|
15
15
|
{ name: 'memory_mb', type: 'number', required: true, constraint: 'Memory of new sandboxes: 2048, 4096 or 8192.' },
|
|
16
|
+
{ name: 'allow_pull_request_write', type: 'boolean', required: true, constraint: 'Whether sandboxes may merge pull requests: their GitHub credential carries pull_requests write besides contents write.' },
|
|
16
17
|
{ name: 'recipe_revision', type: 'number', required: true, constraint: 'Raised by one each time the recipe changes.' },
|
|
17
18
|
{ name: 'image_revision', type: 'number', required: false, constraint: 'The recipe revision the current image was built from; the image is ready when it equals recipe_revision. Null before the first build.' },
|
|
18
19
|
{ name: 'image_error', type: 'string', required: false, constraint: 'Why the last image build failed; null when it did not.' },
|
|
@@ -40,7 +41,7 @@ const showLeaf = defineLeaf({
|
|
|
40
41
|
});
|
|
41
42
|
const setLeaf = defineLeaf({
|
|
42
43
|
name: 'set',
|
|
43
|
-
description: "change a cloud profile's repositories, setup script, pi packages or
|
|
44
|
+
description: "change a cloud profile's repositories, setup script, pi packages, memory or pull request merging",
|
|
44
45
|
whenToUse: 'a dev profile needs other repositories, a setup script for its image (run as root in the build, working directory `/work`), pi packages, or more memory. A flag left out keeps its value.',
|
|
45
46
|
help: {
|
|
46
47
|
name: 'profile environment set',
|
|
@@ -50,6 +51,7 @@ const setLeaf = defineLeaf({
|
|
|
50
51
|
{ kind: 'flag', name: 'repo', type: 'string', required: false, repeatable: true, constraint: 'GitHub repository `owner/name` (repeat per repository); replaces the whole list. The GitHub App must be installed on each.' },
|
|
51
52
|
{ kind: 'flag', name: 'setup-script-file', type: 'path', required: false, constraint: 'File holding the setup script the image build runs as root.' },
|
|
52
53
|
{ kind: 'flag', name: 'pi-package', type: 'string', required: false, repeatable: true, constraint: 'pi package source (repeat per package); replaces the whole list.' },
|
|
54
|
+
{ kind: 'flag', name: 'allow-pull-request-write', type: 'bool', required: false, constraint: 'Pass it to let the sandboxes merge pull requests (their GitHub credential adds pull_requests write); `--no-allow-pull-request-write` returns to contents write only. Takes effect on the next credential a sandbox fetches; builds no image.' },
|
|
53
55
|
{ kind: 'flag', name: 'memory', type: 'int', required: false, constraint: 'Sandbox memory in GB: 2, 4 or 8. Reaches sandboxes created after the change; a running sandbox keeps its memory.' },
|
|
54
56
|
],
|
|
55
57
|
output: [...ENVIRONMENT_OUTPUT],
|
|
@@ -62,6 +64,7 @@ const setLeaf = defineLeaf({
|
|
|
62
64
|
const file = input['setupScriptFile'];
|
|
63
65
|
const packages = input['piPackage'];
|
|
64
66
|
const memory = input['memory'];
|
|
67
|
+
const allowPrWrite = input['allowPullRequestWrite'];
|
|
65
68
|
if (memory !== undefined && ![2, 4, 8].includes(memory))
|
|
66
69
|
throw usage('`--memory` is 2, 4 or 8 (GB).');
|
|
67
70
|
const req = {
|
|
@@ -69,9 +72,10 @@ const setLeaf = defineLeaf({
|
|
|
69
72
|
...(file !== undefined ? { setup_script: readFileSync(resolve(file), 'utf8') } : {}),
|
|
70
73
|
...(packages !== undefined && packages.length > 0 ? { pi_packages: packages.join('\n') } : {}),
|
|
71
74
|
...(memory !== undefined ? { memory_mb: memory * 1024 } : {}),
|
|
75
|
+
...(allowPrWrite !== undefined ? { allow_pull_request_write: allowPrWrite } : {}),
|
|
72
76
|
};
|
|
73
77
|
if (Object.keys(req).length === 0)
|
|
74
|
-
throw usage('pass at least one of `--repo`, `--setup-script-file`, `--pi-package`, `--memory`.');
|
|
78
|
+
throw usage('pass at least one of `--repo`, `--setup-script-file`, `--pi-package`, `--memory`, `--allow-pull-request-write`.');
|
|
75
79
|
return output(await cliClient().setProfileEnvironment(id, req));
|
|
76
80
|
},
|
|
77
81
|
});
|
|
@@ -21,7 +21,7 @@ import { defineLeaf } from '../../core/command.js';
|
|
|
21
21
|
import { usage } from '../../core/errors.js';
|
|
22
22
|
import { userScopeRoot } from '../../core/scope.js';
|
|
23
23
|
import { readTelemetry } from '../../core/canvas/telemetry.js';
|
|
24
|
-
import { ApiError } from '../../api/index.js';
|
|
24
|
+
import { ApiError, routes } from '../../api/index.js';
|
|
25
25
|
import { cliClient } from '../api-client.js';
|
|
26
26
|
import { projectTier1Event, readLogSnapshot } from '../../core/events/read.js';
|
|
27
27
|
import { readPackageVersion } from './shared.js';
|
|
@@ -125,6 +125,16 @@ function buildBody(message, ctx) {
|
|
|
125
125
|
* answer with a `url` naming where the report landed; anything else about the
|
|
126
126
|
* response body is the backend's business, not ours. */
|
|
127
127
|
async function deliverToEndpoint(endpoint, title, body, message, ctx) {
|
|
128
|
+
// The endpoint is the control plane's own feedback route (a cloud sandbox): the node token lives in the broker's relay, so the call goes through it.
|
|
129
|
+
const apiUrl = process.env['CRTR_API_URL'];
|
|
130
|
+
if (apiUrl !== undefined && apiUrl !== '' && endpoint === `${apiUrl.replace(/\/$/, '')}${routes.feedback()}`) {
|
|
131
|
+
try {
|
|
132
|
+
return { url: (await cliClient().postFeedback({ title, body })).url };
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return { error: `${ENDPOINT_ENV} failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
128
138
|
const token = process.env[TOKEN_ENV];
|
|
129
139
|
try {
|
|
130
140
|
const res = await fetch(endpoint, {
|
|
@@ -201,7 +211,7 @@ export const sysFeedbackLeaf = defineLeaf({
|
|
|
201
211
|
],
|
|
202
212
|
outputKind: 'object',
|
|
203
213
|
effects: [
|
|
204
|
-
`Sends the report where this install delivers harness feedback: the ${ENDPOINT_ENV} endpoint when the deployment sets one, otherwise a
|
|
214
|
+
`Sends the report where this install delivers harness feedback: the ${ENDPOINT_ENV} endpoint when the deployment sets one, otherwise a GitHub issue on ${FEEDBACK_REPO} via gh.`,
|
|
205
215
|
'On delivery failure, writes the report to ~/.crouter/feedback/ instead — never lost.',
|
|
206
216
|
],
|
|
207
217
|
},
|
|
@@ -21,7 +21,6 @@ function hydrate(row) {
|
|
|
21
21
|
endedAt: row['ended_at'] ?? null,
|
|
22
22
|
exitReason: row['exit_reason'] ?? null,
|
|
23
23
|
runner: row['runner'],
|
|
24
|
-
sandboxName: row['sandbox_name'] ?? null,
|
|
25
24
|
attempt: Number(row['attempt']),
|
|
26
25
|
release: row['release'] ?? null,
|
|
27
26
|
heartbeatAt: row['heartbeat_at'] ?? null,
|
|
@@ -91,8 +90,8 @@ export async function beginExecution(nodeId, input) {
|
|
|
91
90
|
await revokeNodeTokens(db, 'node_id', nodeId, at);
|
|
92
91
|
const executionId = randomUUID();
|
|
93
92
|
const attempt = input.attempt ?? Number((await db.prepare('SELECT COALESCE(MAX(attempt), 0) + 1 AS next FROM executions WHERE node_id = ?').get(nodeId)).next);
|
|
94
|
-
await db.prepare("INSERT INTO executions (execution_id, node_id, daemon_epoch, pid, process_identity, state, started_at, ended_at, exit_reason, runner,
|
|
95
|
-
.run(executionId, nodeId, input.daemonEpoch, at, input.runner ?? 'process',
|
|
93
|
+
await db.prepare("INSERT INTO executions (execution_id, node_id, daemon_epoch, pid, process_identity, state, started_at, ended_at, exit_reason, runner, attempt, release, launch_json) VALUES (?, ?, ?, NULL, NULL, 'launching', ?, NULL, NULL, ?, ?, ?, ?)")
|
|
94
|
+
.run(executionId, nodeId, input.daemonEpoch, at, input.runner ?? 'process', attempt, input.release ?? null, input.launchJson ?? null);
|
|
96
95
|
return executionId;
|
|
97
96
|
});
|
|
98
97
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/** The canvas schema version this build supports: the number of the highest delta in `schema-pg/` (the baseline
|
|
7
7
|
* `schema-pg.sql` is version 1). `scripts/install-runtime.mjs` reads this module from a candidate generation to refuse
|
|
8
8
|
* one below the live database's `schema_min_reader`. */
|
|
9
|
-
export const CANVAS_SCHEMA_VERSION =
|
|
9
|
+
export const CANVAS_SCHEMA_VERSION = 30;
|
|
10
10
|
/** The Postgres schema holding the canvas tables: `CRTR_DATABASE_SCHEMA` (`crtr` in the cloud deploy). Unset or empty
|
|
11
11
|
* means the role's own search_path (`public` on a Mac and on a VM). A name that is not a plain identifier is an error:
|
|
12
12
|
* it is put in a `search_path` connection option. */
|
|
@@ -55,5 +55,8 @@ export async function patchEnvironment(environmentId, patch) {
|
|
|
55
55
|
}
|
|
56
56
|
if (patch.memory_mb !== undefined)
|
|
57
57
|
await db.prepare('UPDATE environments SET memory_mb = ? WHERE object = ?').run(patch.memory_mb, environmentId);
|
|
58
|
+
// Not part of the recipe: the credential route reads it per request, so it raises no revision and builds no image.
|
|
59
|
+
if (patch.allow_pull_request_write !== undefined)
|
|
60
|
+
await db.prepare('UPDATE environments SET allow_pull_request_write = ? WHERE object = ?').run(String(patch.allow_pull_request_write), environmentId);
|
|
58
61
|
});
|
|
59
62
|
}
|
|
@@ -259,11 +259,15 @@ export async function dropStubRows(input) {
|
|
|
259
259
|
dropped[table] = (dropped[table] ?? 0) + n; };
|
|
260
260
|
await db.exec(`CREATE TABLE ${S('_dropped')} (tbl text NOT NULL, key text NOT NULL, PRIMARY KEY (tbl, key))`);
|
|
261
261
|
// Stub objects are the ones another machine owns (`home_machine`); they and their keyed rows are not copied.
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
// A staged object whose (owner, name) a live target object already holds under another id (the `objects_named` unique index) is dropped too: the target's copy is kept.
|
|
263
|
+
const named = catalog.uniqueKeys.find((u) => u.table === 'objects' && u.name === 'objects_named');
|
|
264
|
+
if (named === undefined || named.predicate === null)
|
|
265
|
+
throw new ImportLaneError('drop', 'import_failed', 'the target has no objects_named unique index with a predicate');
|
|
266
|
+
const collides = `s.id IN (SELECT s2.id FROM (SELECT * FROM ${S('objects')} WHERE ${named.predicate}) s2 JOIN (SELECT * FROM ${sq(target, 'objects')} WHERE ${named.predicate}) t ON t.owner = s2.owner AND t.name = s2.name AND t.id <> s2.id)`;
|
|
267
|
+
await run(db, `INSERT INTO ${S('_dropped')} SELECT 'objects', s.id FROM ${S('objects')} s WHERE s.home_machine IS NOT NULL OR ${collides}`);
|
|
264
268
|
for (const [table, column] of Object.entries(OBJECT_KEYED))
|
|
265
|
-
count(table, await run(db, `DELETE FROM ${S(table)} WHERE ${column} IN ${
|
|
266
|
-
count('objects', await run(db, `DELETE FROM ${S('objects')} WHERE
|
|
269
|
+
count(table, await run(db, `DELETE FROM ${S(table)} WHERE ${column} IN (SELECT key FROM ${S('_dropped')} WHERE tbl = 'objects')`));
|
|
270
|
+
count('objects', await run(db, `DELETE FROM ${S('objects')} WHERE id IN (SELECT key FROM ${S('_dropped')} WHERE tbl = 'objects')`));
|
|
267
271
|
// The columns that hold an object id (foreign keys onto `objects`, then the ones without one: `OBJECT_ID_COLUMNS`), the same list rewrite 2 remaps. A row naming a dropped object in
|
|
268
272
|
// one of them is dropped too; ordinary text (a title, a body) that happens to equal an id is never touched. `messages` keeps the ids of stubs (I16).
|
|
269
273
|
const textColumns = new Map();
|
|
@@ -7,7 +7,6 @@ export const LEDGER_ENV = {
|
|
|
7
7
|
sandboxUsdPerGbHour: 'CRTR_LEDGER_SANDBOX_USD_PER_GB_HOUR',
|
|
8
8
|
sandboxStandbyS: 'CRTR_LEDGER_SANDBOX_STANDBY_S',
|
|
9
9
|
storageUsdPerGbMonth: 'CRTR_LEDGER_STORAGE_USD_PER_GB_MONTH',
|
|
10
|
-
sandboxDiskUsdPerGbMonth: 'CRTR_LEDGER_SANDBOX_DISK_USD_PER_GB_MONTH',
|
|
11
10
|
infraFreeUsdPerMonth: 'CRTR_LEDGER_INFRA_FREE_USD_PER_MONTH',
|
|
12
11
|
takePct: 'CRTR_LEDGER_TAKE_PCT',
|
|
13
12
|
r2Move: 'CRTR_LEDGER_R2_MOVE',
|
|
@@ -37,7 +36,6 @@ function flag(name) {
|
|
|
37
36
|
export const sandboxUsdPerGbHour = () => number(LEDGER_ENV.sandboxUsdPerGbHour);
|
|
38
37
|
export const sandboxStandbyS = () => number(LEDGER_ENV.sandboxStandbyS) ?? DEFAULT_STANDBY_S;
|
|
39
38
|
export const storageUsdPerGbMonth = () => number(LEDGER_ENV.storageUsdPerGbMonth);
|
|
40
|
-
export const sandboxDiskUsdPerGbMonth = () => number(LEDGER_ENV.sandboxDiskUsdPerGbMonth);
|
|
41
39
|
export const infraFreeUsdPerMonth = () => number(LEDGER_ENV.infraFreeUsdPerMonth) ?? DEFAULT_INFRA_FREE_USD;
|
|
42
40
|
/** Northlight's take on each priced model or tool charge, in percent; 0 (the default) writes no take rows. */
|
|
43
41
|
export const takePercent = () => number(LEDGER_ENV.takePct, 100) ?? 0;
|
|
@@ -48,7 +46,6 @@ export function assertLedgerEnv() {
|
|
|
48
46
|
sandboxUsdPerGbHour();
|
|
49
47
|
sandboxStandbyS();
|
|
50
48
|
storageUsdPerGbMonth();
|
|
51
|
-
sandboxDiskUsdPerGbMonth();
|
|
52
49
|
infraFreeUsdPerMonth();
|
|
53
50
|
takePercent();
|
|
54
51
|
r2MoveEnabled();
|
|
@@ -651,7 +651,7 @@ async function launchRevive(nodeId, meta, opts) {
|
|
|
651
651
|
let launched;
|
|
652
652
|
try {
|
|
653
653
|
const row = await liveExecutionForNode(nodeId);
|
|
654
|
-
const started = await runner.start({ executionId, nodeId, attempt: row?.attempt ?? 1,
|
|
654
|
+
const started = await runner.start({ executionId, nodeId, attempt: row?.attempt ?? 1,
|
|
655
655
|
release: row?.release ?? '', launchJson, cwd: meta.cwd, resuming });
|
|
656
656
|
launched = started;
|
|
657
657
|
if (!remote && launched.pid === null) {
|
|
@@ -27,6 +27,15 @@ export const REPOS_DIR = 'repos';
|
|
|
27
27
|
/** Where the image keeps the setup script's output, and its exit status when it failed. `sandbox-start.mjs` reads both (it derives them from `/work/.crtr`). */
|
|
28
28
|
export const SETUP_LOG_FILE = '/work/.crtr/setup.log';
|
|
29
29
|
export const SETUP_FAILED_FILE = '/work/.crtr/setup-failed';
|
|
30
|
+
/** `gh` for a sandbox: /usr/local/bin comes before /usr/bin, so this wrapper runs first. It asks git's credential helper (set at sandbox start, so it reaches the control plane's
|
|
31
|
+
* git-credential route) for a fresh installation token, exports it as GH_TOKEN for this one call and runs the real gh. No token is stored on disk. */
|
|
32
|
+
export const GH_WRAPPER_PATH = '/usr/local/bin/gh';
|
|
33
|
+
const GH_WRAPPER_LINES = [
|
|
34
|
+
'#!/bin/sh',
|
|
35
|
+
'token=$(printf "protocol=https\\nhost=github.com\\n\\n" | git credential fill 2>/dev/null | sed -n "s/^password=//p")',
|
|
36
|
+
'[ -n "$token" ] && export GH_TOKEN="$token"',
|
|
37
|
+
'exec /usr/bin/gh "$@"',
|
|
38
|
+
];
|
|
30
39
|
const shellQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
31
40
|
const lines = (text) => (text ?? '').split('\n').map((l) => l.trim()).filter((l) => l !== '');
|
|
32
41
|
/** A RUN step that cannot fail the build (Blaxel hangs on a failed step and its build log is unreadable): its output goes to `SETUP_LOG_FILE` and a
|
|
@@ -40,7 +49,8 @@ export function recipeDockerfile(recipe, revision, packagesToken = false) {
|
|
|
40
49
|
const hasScript = recipe.setup_script !== null && recipe.setup_script.trim() !== '';
|
|
41
50
|
const base = [
|
|
42
51
|
`FROM ${NODE_BASE_IMAGE}`,
|
|
43
|
-
'RUN apk add --no-cache bash git curl ripgrep',
|
|
52
|
+
'RUN apk add --no-cache bash git curl ripgrep github-cli',
|
|
53
|
+
`RUN printf '%s\\n' ${GH_WRAPPER_LINES.map(shellQuote).join(' ')} > ${GH_WRAPPER_PATH} && chmod 755 ${GH_WRAPPER_PATH}`,
|
|
44
54
|
`COPY --from=${SANDBOX_API_IMAGE} /sandbox-api /usr/local/bin/sandbox-api`,
|
|
45
55
|
`RUN adduser -D -h /home/${RUN_USER} -s /bin/sh ${RUN_USER} && mkdir -p /work/.crtr ${RECIPE_PI_AGENT_DIR} && chown -R ${RUN_USER} /work /var/lib/crtr`,
|
|
46
56
|
];
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// Boundaries: the runner does not decide when to wake (the node-lifecycle lane
|
|
9
9
|
// does), holds no mail, and writes the `executions` row only through its runner
|
|
10
|
-
// columns (`pid`, `process_identity`, `
|
|
10
|
+
// columns (`pid`, `process_identity`, `heartbeat_at`). Every
|
|
11
11
|
// method is safe to call twice: a reconciler whose lease was taken may repeat a
|
|
12
12
|
// call, so a repeat must be harmless (design D76).
|
|
13
13
|
//
|
|
@@ -333,7 +333,7 @@ async function startOnMachine(meta, environmentId, inv) {
|
|
|
333
333
|
const start = await renderCarriedStart(meta.node_id);
|
|
334
334
|
const nodeToken = await mintNodeToken(db, execId, meta.node_id, new Date().toISOString());
|
|
335
335
|
return await enqueueMachineCall(environmentId, 'start', {
|
|
336
|
-
executionId: execId, nodeId: meta.node_id, attempt: 1,
|
|
336
|
+
executionId: execId, nodeId: meta.node_id, attempt: 1, release: acceptedRelease(), launchJson, cwd: meta.cwd, resuming: false,
|
|
337
337
|
nodeToken, bundle, start,
|
|
338
338
|
});
|
|
339
339
|
}, { timingName: 'render_tx' }));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// `POST /v1/environments/:environment_id/git-credential` — a GitHub token limited to the environment's recipe repositories.
|
|
2
2
|
// The control plane asks the GitHub app's internal route with its service credential; GitHub enforces the restriction.
|
|
3
3
|
import { ApiError } from '../../../api/errors.js';
|
|
4
|
+
import { openDb } from '../../../core/canvas/db.js';
|
|
4
5
|
import { getNode } from '../../../core/canvas/canvas.js';
|
|
5
6
|
import { environmentOfNode, recipeOf } from '../environment-of.js';
|
|
6
7
|
import { invalidRequest, objectBody, optionalString, requiredString } from './validate.js';
|
|
7
|
-
function requiredEnv(name) {
|
|
8
|
+
export function requiredEnv(name) {
|
|
8
9
|
const value = process.env[name];
|
|
9
10
|
if (value === undefined || value === '')
|
|
10
11
|
throw new ApiError(500, 'github_service_unconfigured', `${name} is not set on this control plane`);
|
|
@@ -31,15 +32,16 @@ async function handleGitCredential(ctx) {
|
|
|
31
32
|
const repositories = (await recipeOf(environmentId))?.repositories.map((r) => r.github_full_name) ?? [];
|
|
32
33
|
if (repositories.length === 0)
|
|
33
34
|
throw new ApiError(409, 'no_recipe_repositories', `environment ${environmentId} has no recipe repositories`);
|
|
34
|
-
const
|
|
35
|
+
const allow = await (await openDb()).prepare('SELECT allow_pull_request_write FROM environments WHERE object = ?').get(environmentId);
|
|
36
|
+
const minted = await mintInstallationToken(principal.sub, repositories, allow?.allow_pull_request_write === true);
|
|
35
37
|
return { status: 200, body: { username: 'x-access-token', password: minted.token, expiry: minted.expires_at } };
|
|
36
38
|
}
|
|
37
|
-
/** The GitHub app's internal route: a token limited to `repositories` for the person, and the commit author for their GitHub link (null when unlinked). */
|
|
38
|
-
export async function mintInstallationToken(sub, repositories) {
|
|
39
|
+
/** The GitHub app's internal route: a token limited to `repositories` for the person (with pull_requests write too when `allowPullRequestWrite`), and the commit author for their GitHub link (null when unlinked). */
|
|
40
|
+
export async function mintInstallationToken(sub, repositories, allowPullRequestWrite = false) {
|
|
39
41
|
const response = await fetch(`${requiredEnv('GITHUB_SERVICE_URL').replace(/\/$/, '')}/internal/installation-token`, {
|
|
40
42
|
method: 'POST',
|
|
41
43
|
headers: { 'content-type': 'application/json', authorization: `Bearer ${requiredEnv('CROUTER_SERVICE_TOKEN')}` },
|
|
42
|
-
body: JSON.stringify({ sub, repositories }),
|
|
44
|
+
body: JSON.stringify({ sub, repositories, allow_pull_request_write: allowPullRequestWrite }),
|
|
43
45
|
});
|
|
44
46
|
const text = await response.text();
|
|
45
47
|
const parsed = text === '' ? {} : JSON.parse(text);
|
|
@@ -208,6 +208,7 @@ export const OPERATIONS = [
|
|
|
208
208
|
{ name: 'execution.import-unpacked', method: 'POST', path: '/v1/executions/:execution_id/import-unpacked', classes: ['broker'], resource: 'none' },
|
|
209
209
|
{ name: 'execution.start', method: 'GET', path: '/v1/executions/:execution_id/start', classes: ['broker'], resource: 'none' },
|
|
210
210
|
{ name: 'environment.git-credential', method: 'POST', path: '/v1/environments/:environment_id/git-credential', classes: ['broker'], resource: 'none' },
|
|
211
|
+
{ name: 'feedback.file', method: 'POST', path: '/v1/feedback', classes: ['broker'], resource: 'none' },
|
|
211
212
|
{ name: 'node-outcomes.get.119', method: 'GET', path: '/v1/nodes/:id/outcome', classes: ['person', 'broker', 'cron'], resource: 'node-read' },
|
|
212
213
|
{ name: 'node-outcomes.put.120', method: 'PUT', path: '/v1/nodes/:id/outcome-delivery', classes: ['person', 'broker'], resource: 'node-write' },
|
|
213
214
|
{ name: 'node-outcomes.get.121', method: 'GET', path: '/v1/nodes/:id/outcome-delivery', classes: ['person', 'broker', 'cron'], resource: 'node-read' },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.716",
|
|
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.716",
|
|
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.716",
|
|
31
|
+
"@north-light/identity": "0.3.716"
|
|
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.716",
|
|
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.716",
|
|
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.716",
|
|
32
|
+
"@north-light/plugin": "0.3.716",
|
|
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.716",
|
|
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.716",
|
|
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.716",
|
|
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.716",
|
|
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.716",
|
|
11927
|
+
"@north-light/identity": "0.3.716"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.716",
|
|
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.716",
|
|
11936
|
+
"@north-light/identity": "0.3.716",
|
|
11937
|
+
"@north-light/plugin": "0.3.716",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|
|
@@ -538,7 +538,7 @@ async function start(env) {
|
|
|
538
538
|
|
|
539
539
|
// 5.9 the broker, with the token on fd 3 and not in its environment.
|
|
540
540
|
const brokerEnv = { ...env, ...launch.env, HOME: home, PI_CODING_AGENT_DIR: agentDir, CRTR_HOME: root, CRTR_RUNTIME_HOME: join(root, 'runtime'),
|
|
541
|
-
CRTR_FRONT_DOOR: '1', CRTR_EXECUTION_ID: executionId, CRTR_API_URL: apiUrl, CRTR_NO_AUTO_INIT: '1',
|
|
541
|
+
CRTR_FRONT_DOOR: '1', CRTR_EXECUTION_ID: executionId, CRTR_API_URL: apiUrl, CRTR_FEEDBACK_ENDPOINT: `${apiUrl.replace(/\/$/, '')}/v1/feedback`, CRTR_NO_AUTO_INIT: '1',
|
|
542
542
|
CRTR_PLUGINS_REVISION: String(bundle.plugins_revision), ...(environmentId ? { CRTR_ENVIRONMENT_ID: environmentId } : {}), ...(scopesFile ? { CRTR_SCOPES_FILE: scopesFile } : {}),
|
|
543
543
|
PATH: `${join(releaseDir, 'bin')}:${env.PATH ?? '/usr/local/bin:/usr/bin:/bin'}` };
|
|
544
544
|
for (const name of ['CRTR_NODE_TOKEN', 'CRTR_RELEASE_URL', 'CRTR_RELEASE_SHA256', 'CRTR_BOOT_START_UP', 'CRTR_BOOT_RELEASE_UP', 'CRTR_BOOT_RELEASE_SOURCE', 'CRTR_BOOT_RG']) delete brokerEnv[name];
|