@north-light/cli 0.3.743 → 0.3.745
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/README.md +2 -2
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +1 -1
- package/dist/builtin-memory/crouter-sdk/client.md +1 -1
- package/dist/builtin-memory/crouter-sdk/getting-started.md +3 -38
- package/dist/clients/attach/viewer.js +1 -1
- package/dist/commands/sys/provider-login.js +2 -2
- package/dist/commands/sys.js +1 -1
- package/dist/core/canvas/daemon-owner.d.ts +1 -1
- package/dist/core/canvas/paths.d.ts +1 -1
- package/dist/core/canvas/person-state.d.ts +3 -0
- package/dist/core/canvas/person-state.js +1 -1
- package/dist/core/canvas/person.d.ts +2 -3
- package/dist/core/canvas/person.js +7 -7
- package/dist/core/canvas/tree.js +4 -4
- package/dist/core/environments.d.ts +0 -10
- package/dist/core/environments.js +1 -1
- package/dist/core/runtime/blaxel-environment.js +1 -1
- package/dist/core/secrets.d.ts +2 -4
- package/dist/core/secrets.js +1 -1
- package/dist/core/spaces/space.js +2 -2
- package/dist/core/user-settings.js +1 -1
- package/dist/daemon/api/environment-of.d.ts +1 -1
- package/dist/daemon/api/environment-of.js +3 -3
- package/dist/daemon/api/handlers/document-access.js +1 -1
- package/dist/daemon/api/router.d.ts +1 -1
- package/dist/daemon/crtrd-cli.js +1 -1
- package/dist/daemon/crtrd.d.ts +4 -2
- package/dist/daemon/crtrd.js +20 -20
- package/dist/daemon/manage.d.ts +0 -8
- package/dist/daemon/manage.js +3 -3
- package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +0 -2
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/docs/concepts/scopes-and-trust.md +2 -2
- package/docs/public-api.md +1 -7
- package/docs/sdk/README.md +1 -1
- package/docs/sdk/client.md +1 -1
- package/docs/sdk/getting-started.md +3 -38
- package/package.json +3 -3
- package/packages/crouter-api/dist/commands/sys/provider-login.js +2 -2
- package/packages/crouter-api/dist/commands/sys.js +1 -3
- package/packages/crouter-api/dist/core/canvas/paths.js +1 -1
- package/packages/crouter-api/dist/core/canvas/person-state.js +4 -0
- package/packages/crouter-api/dist/core/canvas/person.js +2 -14
- package/packages/crouter-api/dist/core/canvas/tree.js +3 -1
- package/packages/crouter-api/dist/core/environments.js +2 -38
- package/packages/crouter-api/dist/core/model-auth/daemon-login.js +2 -2
- package/packages/crouter-api/dist/core/runtime/blaxel-environment.js +3 -3
- package/packages/crouter-api/dist/core/secrets.js +1 -11
- package/packages/crouter-api/dist/core/spaces/space.js +2 -2
- package/packages/crouter-api/dist/core/user-settings.js +1 -1
- package/packages/crouter-api/dist/daemon/api/environment-of.js +7 -4
- package/packages/crouter-api/dist/daemon/manage.js +0 -4
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- 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/dist/commands/sys/connect.d.ts +0 -1
- package/dist/commands/sys/connect.js +0 -3
- package/dist/commands/sys/db.d.ts +0 -1
- package/dist/commands/sys/db.js +0 -1
- package/dist/core/canvas/export-sqlite.d.ts +0 -14
- package/dist/core/canvas/export-sqlite.js +0 -3
- package/dist/daemon/api/document-listener.d.ts +0 -7
- package/dist/daemon/api/document-listener.js +0 -1
- package/dist/daemon/api/document-secret.d.ts +0 -2
- package/dist/daemon/api/document-secret.js +0 -1
- package/dist/daemon/export-sqlite-run.d.ts +0 -1
- package/dist/daemon/export-sqlite-run.js +0 -4
- package/packages/crouter-api/dist/commands/sys/connect.js +0 -185
- package/packages/crouter-api/dist/commands/sys/db.js +0 -69
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var g=Object.defineProperty;var o=(e,r)=>g(e,"name",{value:r,configurable:!0});import{execFile as h}from"node:child_process";import{createInterface as w}from"node:readline/promises";import{join as y}from"node:path";import{ModelRuntime as $}from"@earendil-works/pi-coding-agent";import{cliClient as s}from"../api-client.js";import{InputError as l}from"../../core/io.js";import{ApiCredentialStore as b}from"../../core/model-auth/api-credential-store.js";import{isManagedProvider as _}from"../../core/managed-providers.js";import{daemonManagedLogin as x}from"../../core/model-auth/daemon-login.js";import{piAgentDir as k}from"../../core/runtime/package-health.js";async function E(){const e=k();return $.create({credentials:new b(()=>s()),modelsPath:y(e,"models.json")})}o(E,"openProviderLoginRuntime");async function U(e,r,n,t={}){if(_(r))return await x(s(),r,n,t.label?{label:t.label}:{}),!0;const a=e.getProvider(r)?.auth.oauth;if(a===void 0)throw new l({error:"provider_login_unavailable",message:`provider ${r} has no OAuth login flow`,next:"Configure an API key through `crtr sys setup`, then
|
|
1
|
+
var g=Object.defineProperty;var o=(e,r)=>g(e,"name",{value:r,configurable:!0});import{execFile as h}from"node:child_process";import{createInterface as w}from"node:readline/promises";import{join as y}from"node:path";import{ModelRuntime as $}from"@earendil-works/pi-coding-agent";import{cliClient as s}from"../api-client.js";import{InputError as l}from"../../core/io.js";import{ApiCredentialStore as b}from"../../core/model-auth/api-credential-store.js";import{isManagedProvider as _}from"../../core/managed-providers.js";import{daemonManagedLogin as x}from"../../core/model-auth/daemon-login.js";import{piAgentDir as k}from"../../core/runtime/package-health.js";async function E(){const e=k();return $.create({credentials:new b(()=>s()),modelsPath:y(e,"models.json")})}o(E,"openProviderLoginRuntime");async function U(e,r,n,t={}){if(_(r))return await x(s(),r,n,t.label?{label:t.label}:{}),!0;const a=e.getProvider(r)?.auth.oauth;if(a===void 0)throw new l({error:"provider_login_unavailable",message:`provider ${r} has no OAuth login flow`,next:"Configure an API key through `crtr sys setup`, then try again."});const f=await a.login(n);if(t.beforeInstall?.()===!1)return!1;const{type:A,access:d,refresh:p,expires:m,...c}=f;return await s().installCredential(r,{kind:"oauth",access_token:d,refresh_token:p,expires_at:new Date(m).toISOString(),...Object.keys(c).length>0?{extra:c}:{}}),!0}o(U,"loginProvider");function u(e){const r=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",n=process.platform==="win32"?["/c","start","",e]:[e];h(r,n,{timeout:5e3},()=>{})}o(u,"openBrowser");function C(e){switch(e.type){case"auth_url":process.stderr.write(`${e.instructions}
|
|
2
2
|
${e.url}
|
|
3
3
|
`),u(e.url);break;case"device_code":process.stderr.write(`${e.verificationUri}
|
|
4
4
|
Code: ${e.userCode}
|
|
5
5
|
`),u(e.verificationUri);break;case"info":case"progress":process.stderr.write(`${e.message}
|
|
6
|
-
`);break}}o(C,"notify");async function v(e){if(!process.stdin.isTTY||!process.stderr.isTTY)throw new l({error:"interactive_login_required",message:"provider login requires an interactive terminal",next:"Run
|
|
6
|
+
`);break}}o(C,"notify");async function v(e){if(!process.stdin.isTTY||!process.stderr.isTTY)throw new l({error:"interactive_login_required",message:"provider login requires an interactive terminal",next:"Run this from an interactive terminal, or configure the provider credential through `crtr sys setup` first."});const r=e.type==="select"?`${e.message}
|
|
7
7
|
${e.options.map((t,i)=>`${i+1}. ${t.label}`).join(`
|
|
8
8
|
`)}
|
|
9
9
|
Select: `:`${e.message}${e.placeholder?` (${e.placeholder})`:""}: `,n=w({input:process.stdin,output:process.stderr});try{const t=await n.question(r,{signal:e.signal});if(e.type!=="select")return t;const i=e.options[Number.parseInt(t,10)-1]?.id;if(i===void 0)throw new Error("Login cancelled");return i}finally{n.close()}}o(v,"promptTerminal");function Y(){return{signal:new AbortController().signal,notify:C,prompt:v}}o(Y,"terminalAuthInteraction");export{U as loginProvider,E as openProviderLoginRuntime,Y as terminalAuthInteraction};
|
package/dist/commands/sys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var r=(o,m)=>s(o,"name",{value:m,configurable:!0});import{defineSysBranch as t}from"./sys/branch.js";import{configBranch as f}from"./sys/config.js";import{sysEnvBranch as i}from"./sys/env.js";import{daemonBranch as e}from"./sys/daemon.js";import{sysDoctorLeaf as a}from"./sys/doctor.js";import{sysFeedbackLeaf as p}from"./sys/feedback.js";import{sysLogsLeaf as n}from"./sys/logs.js";import{sysRetryDeliveryLeaf as y}from"./sys/retry-delivery.js";import{sysWorktreesLeaf as c}from"./sys/worktrees.js";import{sysSpacesLeaf as L}from"./sys/spaces.js";import{sysLimitsBranch as h}from"./sys/limits.js";import{sysSpendBranch as B}from"./sys/spend.js";import{sysSettingsLeaf as S}from"./sys/settings.js";import{
|
|
1
|
+
var s=Object.defineProperty;var r=(o,m)=>s(o,"name",{value:m,configurable:!0});import{defineSysBranch as t}from"./sys/branch.js";import{configBranch as f}from"./sys/config.js";import{sysEnvBranch as i}from"./sys/env.js";import{daemonBranch as e}from"./sys/daemon.js";import{sysDoctorLeaf as a}from"./sys/doctor.js";import{sysFeedbackLeaf as p}from"./sys/feedback.js";import{sysLogsLeaf as n}from"./sys/logs.js";import{sysRetryDeliveryLeaf as y}from"./sys/retry-delivery.js";import{sysWorktreesLeaf as c}from"./sys/worktrees.js";import{sysSpacesLeaf as L}from"./sys/spaces.js";import{sysLimitsBranch as h}from"./sys/limits.js";import{sysSpendBranch as B}from"./sys/spend.js";import{sysSettingsLeaf as S}from"./sys/settings.js";import{sysSetupLeaf as g}from"./sys/setup.js";import{tutorialBranch as u}from"./sys/tutorial/branch.js";import{supportBranch as d}from"./sys/support.js";import{contextBranch as k}from"./sys/context.js";import{sysSyncBranch as D}from"./sys/sync.js";import{sysMigrateLeaf as l}from"./sys/migrate.js";import{sysJoinLeaf as v}from"./sys/join.js";import{sysImportBranch as x}from"./sys/import/start.js";import{sysMachineBranch as M}from"./sys/machine/rotate.js";import{sysDesktopBranch as b}from"./sys/desktop.js";import{sysSigninLeaf as E,sysSignoutLeaf as F}from"./sys/signin.js";import{sysUpdateLeaf as I,sysVersionLeaf as J}from"./sys/update.js";function sr(){return t([S,f,i,g,u,a,k,p,n,c,y,L,h,B,d,I,J,l,v,D,x,M,E,F,b,e])}r(sr,"registerSys");export{sr as registerSys};
|
|
@@ -15,7 +15,7 @@ export interface DaemonOwnerClaim {
|
|
|
15
15
|
* process running both roles); the cloud's `--role api` and `--role reconcile` processes are several per database by design, so
|
|
16
16
|
* they never claim, never release, and never read the row. The caller (`crtrd.ts`) checks this before
|
|
17
17
|
* `claimDaemonOwnership` / `releaseDaemonOwnership` / `daemonOwnershipClaimed`. */
|
|
18
|
-
export declare function daemonOwnershipApplies(role: 'api' | 'reconcile' | 'machine' | undefined): boolean;
|
|
18
|
+
export declare function daemonOwnershipApplies(role: 'api' | 'reconcile' | 'machine' | 'all' | undefined): boolean;
|
|
19
19
|
/** Every terminal, non-retriable way `claimDaemonOwnership` can lose. A loss
|
|
20
20
|
* never deletes or otherwise mutates the incumbent row — only a positively
|
|
21
21
|
* DEAD incumbent is ever CAS-replaced. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Runtime-owned records; never a bind source for an app sandbox. */
|
|
2
2
|
export declare function crtrHome(): string;
|
|
3
|
-
/** The pre-Postgres SQLite canvas file. Read only by the one-time import into Postgres
|
|
3
|
+
/** The pre-Postgres SQLite canvas file. Read only by the one-time import into Postgres. */
|
|
4
4
|
export declare function canvasDbPath(): string;
|
|
5
5
|
export declare function onDiskMigrationLockPath(): string;
|
|
6
6
|
export declare function onDiskMigrationMarkerPath(): string;
|
|
@@ -15,6 +15,9 @@ export declare function setPersonId(id: string): void;
|
|
|
15
15
|
export declare function markCloudRole(): void;
|
|
16
16
|
/** Whether this process is a cloud role (`markCloudRole` ran at boot). */
|
|
17
17
|
export declare function isCloudRole(): boolean;
|
|
18
|
+
/** `crtrd --role all` (tests and crouter development) runs every node's engine on its own host: no Blaxel sandbox, no remote machine. */
|
|
19
|
+
export declare function markEnginesInProcess(): void;
|
|
20
|
+
export declare function areEnginesInProcess(): boolean;
|
|
18
21
|
/** Run `fn` as `person` (`user:<id>`, the request token's `sub`): every `personId()` inside it, across awaits, answers `person`. */
|
|
19
22
|
export declare function runAsPerson<T>(person: string, fn: () => T): T;
|
|
20
23
|
/** The request's person; else, on a Mac, the boot-set person. Throws `PersonOutsideRequestError` on a cloud role outside a request and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=Object.defineProperty;var e=(r,n)=>i(r,"name",{value:n,configurable:!0});import{AsyncLocalStorage as d}from"node:async_hooks";class c extends Error{static{e(this,"PersonUnresolvedError")}code="person_unresolved";constructor(){super("the install's person is not resolved yet"),this.name="PersonUnresolvedError"}}class l extends Error{static{e(this,"PersonOutsideRequestError")}code="person_outside_request";constructor(){super("no person: a cloud role reads the person only inside a request, from its token"),this.name="PersonOutsideRequestError"}}let o,t=!1;const s=new d;function a(r){o=r}e(a,"setPersonId");function x(){t=!0}e(x,"markCloudRole");function P(){return t}e(P,"isCloudRole");let u=!1;function m(){u=!0}e(m,"markEnginesInProcess");function E(){return u}e(E,"areEnginesInProcess");function I(r,n){return s.run(r,n)}e(I,"runAsPerson");function q(){const r=s.getStore();if(r!==void 0)return r;if(t)throw new l;if(o===void 0)throw new c;return o}e(q,"personId");function g(){return o}e(g,"bootPersonId");function h(){return s.getStore()}e(h,"requestPersonId");export{l as PersonOutsideRequestError,c as PersonUnresolvedError,E as areEnginesInProcess,g as bootPersonId,P as isCloudRole,x as markCloudRole,m as markEnginesInProcess,q as personId,h as requestPersonId,I as runAsPerson,a as setPersonId};
|
|
@@ -2,13 +2,12 @@ import { PersonUnresolvedError, PersonOutsideRequestError, setPersonId, markClou
|
|
|
2
2
|
import { type CanvasDb } from './db.js';
|
|
3
3
|
import { LEGACY_LOCAL_PERSON } from './legacy-person.js';
|
|
4
4
|
export { LEGACY_LOCAL_PERSON };
|
|
5
|
-
export type PersonSource = 'stored' | 'joined' | 'grants'
|
|
5
|
+
export type PersonSource = 'stored' | 'joined' | 'grants';
|
|
6
6
|
export { PersonUnresolvedError, PersonOutsideRequestError, setPersonId, markCloudRole, isCloudRole, runAsPerson, personId };
|
|
7
7
|
/** As `personId()`, but a process that is not the daemon gets a lazy get-or-create keyed by the active canvas database. */
|
|
8
8
|
export declare function personIdAsync(): Promise<string>;
|
|
9
9
|
/** Get-or-create the person and say where it came from. Order: stored, the join file's owner, the single `sub` of the
|
|
10
|
-
* mirrored grants (a runtime with an issuer and no join file), else
|
|
11
|
-
* Null when an issuer runtime has no mirrored grants yet; nothing is stored then. */
|
|
10
|
+
* mirrored grants (a runtime with an issuer and no join file), else null (nothing is stored): no person is ever minted. */
|
|
12
11
|
export declare function resolvePerson(): Promise<{
|
|
13
12
|
id: string;
|
|
14
13
|
source: PersonSource;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U=Object.defineProperty;var c=(n,e)=>U(n,"name",{value:e,configurable:!0});import{CrtrError as N}from"../errors.js";import{PersonUnresolvedError as R,PersonOutsideRequestError as A,setPersonId as y,markCloudRole as H,isCloudRole as D,runAsPerson as W,personId as v,bootPersonId as b,requestPersonId as $}from"./person-state.js";import{readConfig as S}from"../config.js";import{joinedIssuer as k,joinedOwner as h}from"../directory/join.js";import{installLocalTerminalGrant as C}from"../grants/local.js";import{dropLocalGrantMirror as M}from"../grants/mirror.js";import{ownerForGrantee as F,ensureOwner as x}from"../graph/objects.js";import{canvasDatabaseUrl as G,CanvasConstraintError as J,withCanvasWrite as j}from"./db.js";import{LEGACY_LOCAL_PERSON as E,LEGACY_LOCAL_TERMINAL_GRANT as Y}from"./legacy-person.js";import{rebuildTotalsFor as q}from"../ledger/totals.js";const d="person_id",O="local_person_retired",z=/^user:[A-Za-z0-9._-]+$/,I=new Map;async function de(){const n=$();if(n!==void 0)return n;if(D())throw new A;const e=b();if(e!==void 0)return e;const r=await G(),t=I.get(r);if(t!==void 0)return t;const s=await K();if(s===null)throw new R;return I.set(r,s),s}c(de,"personIdAsync");async function T(n,e){return(await n.prepare("SELECT value FROM canvas_meta WHERE key = ?").get(e))?.value??null}c(T,"readMeta");async function g(n,e,r){await n.prepare("INSERT INTO canvas_meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(e,r)}c(g,"writeMeta");async function B(){return await j(async n=>{const e=await T(n,d);if(e!==null)return{id:e,source:"stored"};const r=h();if(r!==null)return await g(n,d,r),{id:r,source:"joined"};if(S("user").runtime?.issuer){const t=await n.prepare("SELECT DISTINCT sub FROM grants").all();return t.length!==1?null:(await g(n,d,t[0].sub),{id:t[0].sub,source:"grants"})}return null})}c(B,"resolvePerson");async function K(){return(await B())?.id??null}c(K,"resolvePersonId");const a=c(n=>Number(n.changes),"changes"),X=[["nodes","sub"],["node_tokens","sub"],["grants","sub"],["crons","sub"],["audit_rows","sub"],["provider_approvals","sub"],["audit_rows","grantee"],["run_events","grantee"],["node_tokens","grantee"],["uploads","grantee"],["uploads","sub"],["files","sub"],["files","grantee"],["shares","sub"],["provider_approvals","grantee"]],V=["profiles","profile_defaults","scope_settings","scope_bookkeeping","scope_marketplaces","scope_plugins","person_settings","model_accounts","model_account_cooldowns","model_api_keys","model_settings","model_sign_in_flows","env_vars","hosted_endpoints"],Z=[["charges","sub"],["charges","payer"],["charges","grantee"],["limits","payer"],["limits","sub"],["limits","grantee"]];function L(n,e){if(!z.test(e))throw new N("invalid_person",`${n} must be a user:<id> principal, got ${JSON.stringify(e)}`)}c(L,"assertPerson");async function Q(n,e){return await n.prepare("SELECT 1 AS found FROM charge_totals WHERE payer = ? OR sub = ? OR grantee = ? UNION ALL SELECT 1 FROM charge_chunks WHERE payer = ? LIMIT 1").get(e,e,e,e)!==void 0}c(Q,"namesPerson");async function P(n,e,r){if(L("from",e),L("to",r),e===r)throw new N("invalid_person","cannot substitute a person with itself");const t={};try{t.identities=a(await n.prepare("UPDATE identities SET scheme = 'user', external_id = ? WHERE scheme IN ('local-user', 'user') AND external_id = ?").run(r,e)),t["identities.person"]=a(await n.prepare("UPDATE identities SET person = ? WHERE person = ?").run(r,e))}catch(o){throw o instanceof J?new N("person_conflict",`another person object or repo identity already holds ${r}; merging two persons is not supported (${o.message})`,void 0,{from:e,to:r}):o}t["daemon_actions.principal_sub"]=a(await n.prepare(`UPDATE daemon_actions SET adapter_json = jsonb_set(adapter_json::jsonb, '{principal,sub}', to_jsonb(?::text))::text
|
|
2
2
|
WHERE state IN ('pending', 'handed_off') AND adapter_json::jsonb ->> 'adapter' = 'cron_spawn'
|
|
3
|
-
AND adapter_json::jsonb #>> '{principal,sub}' = ?`).run(r,e));for(const[o,i]of
|
|
3
|
+
AND adapter_json::jsonb #>> '{principal,sub}' = ?`).run(r,e));for(const[o,i]of X)t[`${o}.${i}`]=a(await n.prepareUncached(`UPDATE ${o} SET ${i} = ? WHERE ${i} = ?`).run(r,e));t["idempotency_keys.grantee"]=a(await n.prepare("DELETE FROM idempotency_keys WHERE grantee = ? AND key IN (SELECT key FROM idempotency_keys WHERE grantee = ?)").run(e,r))+a(await n.prepare("UPDATE idempotency_keys SET grantee = ? WHERE grantee = ?").run(r,e));const s=e.replace(/^user:/,""),p=r.replace(/^user:/,"");t["relations.subject_id"]=a(await n.prepare(`DELETE FROM relations r WHERE r.subject_type = 'user' AND r.subject_id = ?
|
|
4
4
|
AND EXISTS (SELECT 1 FROM relations n WHERE n.subject_type = 'user' AND n.subject_id = ? AND n.resource_type = r.resource_type
|
|
5
|
-
AND n.resource_id = r.resource_id AND n.relation = r.relation AND n.subject_relation = r.subject_relation)`).run(
|
|
6
|
-
WHERE o.type = 'node' AND i.scheme = 'local-user' AND i.external_id = '${E}'`;return(await n.prepareUncached(`${e} LIMIT 1`).get()!==void 0?
|
|
5
|
+
AND n.resource_id = r.resource_id AND n.relation = r.relation AND n.subject_relation = r.subject_relation)`).run(s,p))+a(await n.prepare("UPDATE relations SET subject_id = ? WHERE subject_type = 'user' AND subject_id = ?").run(p,s)),t["relations.written_by"]=a(await n.prepare("UPDATE relations SET written_by = ? WHERE written_by = ?").run(r,e)),t["revisions.acting_for"]=a(await n.prepare("UPDATE revisions SET acting_for = ? WHERE acting_for = ?").run(r,e));for(const[o,i]of Z)t[`${o}.${i}`]=a(await n.prepareUncached(`UPDATE ${o} SET ${i} = ? WHERE ${i} = ?`).run(r,e));for(const o of V){const l=a(await n.prepareUncached(`DELETE FROM ${o} WHERE person = ? AND EXISTS (SELECT 1 FROM ${o} WHERE person = ?)`).run(e,r))+a(await n.prepareUncached(`UPDATE ${o} SET person = ? WHERE person = ?`).run(r,e));l!==0&&(t[`${o}.person`]=l)}const u=a(await n.prepare("UPDATE credential_activations SET person = ? WHERE person = ?").run(r,e));return u!==0&&(t["credential_activations.person"]=u),(Object.entries(t).some(([o,i])=>o.startsWith("charges.")&&i!==0)||await Q(n,e))&&(await q(n,e,r),t["charge_totals.rebuilt"]=1),t}c(P,"substitutePerson");async function ee(n){const e=`SELECT o.id FROM objects o JOIN identities i ON i.object = o.owner JOIN nodes n ON n.node_id = o.id
|
|
6
|
+
WHERE o.type = 'node' AND i.scheme = 'local-user' AND i.external_id = '${E}'`;return(await n.prepareUncached(`${e} LIMIT 1`).get()!==void 0?a(await n.prepareUncached(`UPDATE objects SET owner = ? WHERE id IN (${e})`).run((await F(n,"app:terminal")).id)):0)+a(await n.prepare("UPDATE node_tokens SET grantee = 'app:terminal' WHERE grantee = ?").run(E))+a(await n.prepare("UPDATE run_events SET grantee = 'app:terminal' WHERE grantee = ?").run(E))+a(await n.prepare("DELETE FROM idempotency_keys WHERE grantee = ? AND key IN (SELECT key FROM idempotency_keys WHERE grantee = 'app:terminal')").run(E))+a(await n.prepare("UPDATE idempotency_keys SET grantee = 'app:terminal' WHERE grantee = ?").run(E))}c(ee,"rewriteLegacyGrantees");async function ne(n,e,r){const t=[Y,`terminal:${e}`].filter(o=>o!==r),s=t.map(()=>"?").join(", "),p={};p["nodes.grant_id"]=a(await n.prepareUncached(`UPDATE nodes SET grant_id = ? WHERE grant_id IN (${s})`).run(r,...t)),p["node_tokens.grant"]=a(await n.prepareUncached(`UPDATE node_tokens SET "grant" = ? WHERE "grant" IN (${s})`).run(r,...t)),p["crons.grant_id"]=a(await n.prepareUncached(`UPDATE crons SET grant_id = ? WHERE grant_id IN (${s})`).run(r,...t));const u=r===null?"'null'::jsonb":"to_jsonb(?::text)";return p["daemon_actions.principal_grant_id"]=a(await n.prepareUncached(`UPDATE daemon_actions SET adapter_json = jsonb_set(adapter_json::jsonb, '{principal,grant_id}', ${u})::text
|
|
7
7
|
WHERE state IN ('pending', 'handed_off') AND adapter_json::jsonb ->> 'adapter' = 'cron_spawn'
|
|
8
|
-
AND adapter_json::jsonb #>> '{principal,grant_id}' IN (${
|
|
9
|
-
WHERE o.type = 'node' AND o.reception = 2 AND s.envelope_json ->> 'app' IS NULL AND i.scheme = 'app' AND i.external_id = 'app:terminal'`;if(await e.prepareUncached(`${
|
|
8
|
+
AND adapter_json::jsonb #>> '{principal,grant_id}' IN (${s})`).run(...r===null?[]:[r],...t)),p}c(ne,"repointGrantReferences");async function _e(){const n=await j(async e=>{const r={},t=c((_,w="")=>{for(const[m,f]of Object.entries(_))f!==0&&(r[w+m]=(r[w+m]??0)+f)},"add");let s=await T(e,d);if(s===null)throw new R;let p=null;const u=h();u!==null&&u!==s&&(t(await P(e,s,u),"join."),await g(e,d,u),p=s,s=u);const o=k()??S("user").runtime?.issuer,i=await T(e,"install_id");if(i===null)throw new Error("retireLocalPerson: the install id is not stored");const l=await T(e,O)!==s;if(l){t({legacy_grantees:await ee(e)}),t(await P(e,E,s));const _=`SELECT o.id FROM objects o JOIN peer_stubs s ON s.object = o.id JOIN identities i ON i.object = o.owner
|
|
9
|
+
WHERE o.type = 'node' AND o.reception = 2 AND s.envelope_json ->> 'app' IS NULL AND i.scheme = 'app' AND i.external_id = 'app:terminal'`;if(await e.prepareUncached(`${_} LIMIT 1`).get()!==void 0){const w=await x(e,"person","user",s,"user");t({repaired_stubs:a(await e.prepareUncached(`UPDATE objects SET owner = ? WHERE id IN (${_})`).run(w.id))})}t({"nodes.sub_null_terminal":a(await e.prepare(`UPDATE nodes SET sub = ? WHERE sub IS NULL AND node_id IN (
|
|
10
10
|
SELECT n.node_id FROM nodes n JOIN identities i ON i.object = n.app
|
|
11
|
-
WHERE i.scheme = 'app' AND i.external_id = 'app:terminal')`).run(
|
|
11
|
+
WHERE i.scheme = 'app' AND i.external_id = 'app:terminal')`).run(s))}),t(await ne(e,i,o?null:`terminal:${i}`)),o&&t({local_grant_mirror:await M(e)}),await g(e,O,s)}return o||await C(i,s),{person:s,joinedFrom:p,retired:l,columns:r}});return y(n.person),n}c(_e,"retireLocalPerson");export{E as LEGACY_LOCAL_PERSON,A as PersonOutsideRequestError,R as PersonUnresolvedError,D as isCloudRole,H as markCloudRole,v as personId,de as personIdAsync,B as resolvePerson,K as resolvePersonId,_e as retireLocalPerson,W as runAsPerson,y as setPersonId,P as substitutePerson};
|
package/dist/core/canvas/tree.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});import{openDb as r,withCanvasWrite as u}from"./db.js";import{getById as N,nodeObject as w}from"../graph/objects.js";import{recordWatch as
|
|
1
|
+
var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});import{openDb as r,withCanvasWrite as u}from"./db.js";import{getById as N,nodeObject as w}from"../graph/objects.js";import{recordWatch as I,unwatch as b,configFromJson as E,configToJson as T}from"../graph/watches.js";import{publish as D}from"../graph/events.js";import{DEFAULT_LISTEN as v}from"../graph/types.js";const R=["spawn","job-start","ask"],S="('spawn','job-start','ask')",j=[{threshold:3,delivery:"next-turn"}];function h(o){const t=o.find(n=>n.threshold<=7);return t!==void 0&&t.delivery!=="next-turn"}i(h,"wakesAtSeven");async function d(o,t,...n){const a=await o.prepareUncached(`SELECT wo.id AS from_id, oo.id AS to_id, ws.config_json, ws.created_at,
|
|
2
2
|
wo.listen_json, wn.status AS from_status, onode.status AS to_status
|
|
3
3
|
FROM watches w
|
|
4
4
|
JOIN objects wo ON wo.id = w.watcher AND wo.type = 'node'
|
|
@@ -7,13 +7,13 @@ var O=Object.defineProperty;var i=(o,t)=>O(o,"name",{value:t,configurable:!0});i
|
|
|
7
7
|
JOIN nodes wn ON wn.node_id = wo.id
|
|
8
8
|
JOIN nodes onode ON onode.node_id = oo.id
|
|
9
9
|
WHERE w.in_tree = 1 ${t}
|
|
10
|
-
ORDER BY ws.created_at, ws.seq`).all(...
|
|
10
|
+
ORDER BY ws.created_at, ws.seq`).all(...n),s=new Map;for(const e of a){const c=e.config_json,f=e.listen_json,_=c!=null?E(c):f!=null?E(f):v,p=`${e.from_id}\0${e.to_id}`,l=s.get(p);if(l){l.active||=h(_);continue}s.set(p,{from_id:e.from_id,to_id:e.to_id,active:h(_),created:e.created_at,from_status:e.from_status??null,to_status:e.to_status??null})}return[...s.values()]}i(d,"treeEdges");async function F(o=null){const t=o===null?null:[...o];return(t===null?await d(await r(),""):await d(await r(),"AND wo.id IN (SELECT unnest(?::text[])) AND oo.id IN (SELECT unnest(?::text[]))",t,t)).map(({from_id:a,to_id:s,active:e,created:c})=>({from_id:a,to_id:s,active:e,created:c}))}i(F,"rosterEdges");async function W(o,t,n=!0){await u(async a=>{const s=await w(a,o),e=await w(a,t);await I(a,s,e,"ask"),await x(o,t,n),await D(a,{event:"watched",object:e,actor:s,attrs:{}})})}i(W,"subscribe");async function M(o,t){await u(async n=>{const a=await w(n,o),s=await w(n,t);for(const e of R)await b(n,a,s,{startedBy:e})})}i(M,"unsubscribe");async function x(o,t,n){await u(async a=>{await a.prepareUncached(`UPDATE watch_subscriptions SET config_json = ?
|
|
11
11
|
WHERE started_by IN ${S}
|
|
12
|
-
AND watch IN (SELECT watch_id FROM watches WHERE watcher = ? AND object = ?)`).run(
|
|
12
|
+
AND watch IN (SELECT watch_id FROM watches WHERE watcher = ? AND object = ?)`).run(n?null:T(j),(await w(a,o)).id,(await w(a,t)).id)})}i(x,"setSubscriptionActive");async function $(o){const t=await r(),n=await N(t,o);if(n?.type!=="node")return[];let a=n.id;const s=new Set([a]);for(;;){const c=(await d(t,"AND oo.id = ?",a))[0]?.from_id;if(c===void 0||s.has(c))break;s.add(c),a=c}const e=(await t.prepareUncached(m).all(a,a)).map(c=>c.id);return[a,...e]}i($,"treeContaining");async function B(o){return(await d(await r(),"AND oo.id = ?",o)).map(t=>({node_id:t.from_id,active:t.active,created:t.created}))}i(B,"subscribersOf");async function H(o){return(await d(await r(),"AND wo.id = ?",o)).map(t=>({node_id:t.to_id,active:t.active,created:t.created}))}i(H,"subscriptionsOf");function A(o){return`WITH RECURSIVE walk(id) AS (
|
|
13
13
|
SELECT CAST(? AS text)
|
|
14
14
|
UNION
|
|
15
15
|
SELECT w.object FROM walk
|
|
16
16
|
JOIN watches w ON w.watcher = walk.id AND w.in_tree = 1
|
|
17
17
|
${o?`JOIN objects oo ON oo.id = w.object AND oo.type = 'node' AND oo.kind IS DISTINCT FROM 'human'
|
|
18
18
|
JOIN nodes onode ON onode.node_id = oo.id`:"JOIN nodes onode ON onode.node_id = w.object"}
|
|
19
|
-
) SELECT id FROM walk WHERE id != ?`}i(
|
|
19
|
+
) SELECT id FROM walk WHERE id != ?`}i(A,"subtreeSql");const P=A(!0),m=A(!1);async function Q(o){const t=await r(),n=await N(t,o);return n?.type!=="node"?[]:(await t.prepareUncached(m).all(n.id,n.id)).map(a=>a.id)}i(Q,"view");const y=new Set(["active","idle"]);async function V(o){return(await d(await r(),"AND wo.id = ?",o)).some(t=>t.active&&y.has(t.to_status??""))}i(V,"hasActiveLiveSubscription");async function q(o){return(await d(await r(),"AND oo.id = ?",o)).some(t=>t.active&&y.has(t.from_status??""))}i(q,"hasLiveSubscriber");export{m as SUBTREE_ALL_IDS_SQL,P as SUBTREE_IDS_SQL,V as hasActiveLiveSubscription,q as hasLiveSubscriber,F as rosterEdges,x as setSubscriptionActive,W as subscribe,B as subscribersOf,H as subscriptionsOf,$ as treeContaining,M as unsubscribe,Q as view};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { CanvasDb } from './canvas/db.js';
|
|
2
2
|
import { type EnvironmentRecipeInput } from './environment-recipe.js';
|
|
3
|
-
/** Find the `environments` row for `installId`, or create its object and row; either way set `last_seen_at`, and cache
|
|
4
|
-
* the environment id and install id for {@link machineEnvironmentId} and {@link touchMachineEnvironment}. */
|
|
5
|
-
export declare function registerMachineEnvironment(installId: string): Promise<{
|
|
6
|
-
environmentId: string;
|
|
7
|
-
created: boolean;
|
|
8
|
-
}>;
|
|
9
3
|
/** A cloud profile's own `blaxel` environment (D105): an `environment` object owned by the profile's object, acting for `person`, and
|
|
10
4
|
* its `environments` row with the `memory_mb` (default 2048), no recipe (so the Blaxel base image) and no machine id. Runs in the
|
|
11
5
|
* caller's write, before the profile row exists, so the profile and its environment commit together. The profile object is made
|
|
@@ -18,7 +12,3 @@ export declare function createProfileBlaxelEnvironment(db: CanvasDb, spec: {
|
|
|
18
12
|
memoryMb?: number;
|
|
19
13
|
recipe?: EnvironmentRecipeInput;
|
|
20
14
|
}): Promise<string>;
|
|
21
|
-
/** Stamp `last_seen_at` on the machine environment: one statement, no read. A no-op before {@link registerMachineEnvironment}. */
|
|
22
|
-
export declare function touchMachineEnvironment(now: string): Promise<void>;
|
|
23
|
-
/** The machine environment's object id; throws before {@link registerMachineEnvironment} has run. */
|
|
24
|
-
export declare function machineEnvironmentId(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var o=(r,e)=>n(r,"name",{value:e,configurable:!0});import{withCanvasWrite as l}from"./canvas/db.js";import{createObject as m,ensureOwner as p,ownerForGrantee as w}from"./graph/objects.js";import{writeActsFor as f}from"./permissions/facts.js";import{writeEnvironmentRecipe as c}from"./environment-recipe.js";import{setCloudProfileWriter as d}from"./profiles/manifest.js";async function u(r,e){const t=await w(r,e.grantee),a=await p(r,"profile","profile",e.profileId,e.profileId,t),i=await m(r,{type:"environment",kind:"blaxel",owner:a.id,privacy:"private",name:e.profileId,preview:"blaxel"});return await f(r,i.id,e.person),await r.prepare("INSERT INTO environments (object, kind, machine_id, memory_mb, allow_pull_request_write, last_seen_at) VALUES (?, 'blaxel', NULL, ?, true, ?)").run(i.id,e.memoryMb??2048,new Date().toISOString()),e.recipe!==void 0&&await c(r,i.id,e.recipe),i.id}o(u,"createProfileBlaxelEnvironment"),d((r,e)=>l(async t=>{await e(await u(t,r))}));export{u as createProfileBlaxelEnvironment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o=Object.defineProperty;var e=(n,
|
|
1
|
+
var o=Object.defineProperty;var e=(n,r)=>o(n,"name",{value:r,configurable:!0});import{openDb as i}from"../canvas/db.js";import{areEnginesInProcess as t,isCloudRole as l}from"../canvas/person-state.js";import{machineEnvironmentOfProfile as a}from"./runner/machine/environment.js";async function m(n){return n===null||t()?null:(await(await i()).prepare("SELECT e.object AS object FROM profiles p JOIN environments e ON e.object = p.environment_id WHERE p.id = ? AND e.kind = 'blaxel'").get(n))?.object??null}e(m,"blaxelEnvironmentOf");async function s(n){return n===null?null:await m(n)??(l()&&!t()?await a(n):null)}e(s,"remoteEnvironmentOf");export{m as blaxelEnvironmentOf,s as remoteEnvironmentOf};
|
package/dist/core/secrets.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface SecretsStore {
|
|
|
11
11
|
apiToken?: string;
|
|
12
12
|
scopedApiTokens?: ScopedApiToken[];
|
|
13
13
|
}
|
|
14
|
-
/** A bearer token minted
|
|
14
|
+
/** A bearer token minted for an app whose `scopes` list is
|
|
15
15
|
* the ceiling for every scope-gated daemon operation the holder performs. The
|
|
16
16
|
* owner token (`apiToken`) has no ceiling. */
|
|
17
17
|
export interface ScopedApiToken {
|
|
@@ -29,15 +29,13 @@ export declare function getRelayToken(ref: string, scope: Scope): string | undef
|
|
|
29
29
|
export declare function setRelayToken(ref: string, token: string, scope: Scope): void;
|
|
30
30
|
export declare function deleteRelayToken(ref: string, scope: Scope): void;
|
|
31
31
|
export declare function getApiToken(scope: Scope): string | undefined;
|
|
32
|
-
export declare function setApiToken(token: string, scope: Scope): void;
|
|
33
32
|
export declare function listScopedApiTokens(scope: Scope): ScopedApiToken[];
|
|
34
|
-
export declare function addScopedApiToken(entry: ScopedApiToken, scope: Scope): void;
|
|
35
33
|
/** The `crtr_app_` token minted for an installed plugin, if it holds one. */
|
|
36
34
|
export declare function pluginAppToken(plugin: string): ScopedApiToken | undefined;
|
|
37
35
|
/** Mint the plugin's `crtr_app_` token when absent; rewrite its `scopes` in place (same token) when they
|
|
38
36
|
* differ; otherwise write nothing. */
|
|
39
37
|
export declare function ensurePluginAppToken(plugin: string, scopes: readonly string[]): ScopedApiToken;
|
|
40
|
-
/** Remove the plugin's `crtr_app_` tokens.
|
|
38
|
+
/** Remove the plugin's `crtr_app_` tokens. Other entries are never touched. */
|
|
41
39
|
export declare function revokePluginAppTokens(plugin: string): boolean;
|
|
42
40
|
/** Look a raw scoped bearer up in the user store. Cached; the cache is dropped by every in-process
|
|
43
41
|
* `writeSecrets` and re-read when the file's (inode, size, mtime) changes, so a revocation by any
|
package/dist/core/secrets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var
|
|
1
|
+
var h=Object.defineProperty;var s=(e,n)=>h(e,"name",{value:n,configurable:!0});import{createHash as E,randomBytes as R}from"node:crypto";import{existsSync as $,readFileSync as _,statSync as b}from"node:fs";import{join as w}from"node:path";import{scopeRoot as d,requireScopeRoot as P,userScopeRoot as g}from"./scope.js";import{secretsDir as A}from"./layout.js";import{atomicWriteJson as z,ensureDir as F}from"./fs-utils.js";const N="secrets.json";function l(e){return w(e===g()?A():e,N)}s(l,"secretsPathFor");function c(e){const n=d(e);if(!n)return{relayTokens:{}};const t=l(n);if(!$(t))return{relayTokens:{}};try{const o=JSON.parse(_(t,"utf8")),i=Array.isArray(o.scopedApiTokens)?o.scopedApiTokens.filter(r=>typeof r?.token=="string"&&r.token!==""&&typeof r.grantee=="string"&&/^app:[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(r.grantee)&&Array.isArray(r.scopes)&&typeof r.created=="string"):[];return{relayTokens:o.relayTokens??{},...typeof o.apiToken=="string"&&o.apiToken!==""?{apiToken:o.apiToken}:{},...i.length>0?{scopedApiTokens:i}:{}}}catch{return{relayTokens:{}}}}s(c,"readSecrets");function f(e,n){const t=P(e),o=l(t);F(t===g()?A():t),z(o,n,{mode:384,durable:!0}),a=void 0}s(f,"writeSecrets");function L(e,n){return c(n).relayTokens[e]}s(L,"getRelayToken");function W(e,n,t){const o=c(t);o.relayTokens[e]=n,f(t,o)}s(W,"setRelayToken");function q(e,n){const t=c(n);delete t.relayTokens[e],f(n,t)}s(q,"deleteRelayToken");function B(e){return c(e).apiToken}s(B,"getApiToken");function m(e){return c(e).scopedApiTokens??[]}s(m,"listScopedApiTokens");const O=/^app:[a-zA-Z0-9][a-zA-Z0-9._-]*$/,x="crtr_app_";function T(e){const n=`app:${e}`;if(!O.test(n))throw new Error(`invalid plugin name for an app token: ${JSON.stringify(e)}`);return n}s(T,"appGrantee");const y=s(e=>e.token.startsWith(x),"isAppEntry");function C(e){const n=T(e);return m("user").find(t=>t.grantee===n&&y(t))}s(C,"pluginAppToken");function H(e,n){const t=T(e),o=c("user"),i=o.scopedApiTokens??[],r=i.find(p=>p.grantee===t&&y(p)),u=[...n];if(r&&r.scopes.length===u.length&&r.scopes.every((p,S)=>p===u[S]))return r;const k=r?{...r,scopes:u}:{token:`${x}${R(32).toString("base64url")}`,grantee:t,scopes:u,created:new Date().toISOString()};return o.scopedApiTokens=r?i.map(p=>p===r?k:p):[...i,k],f("user",o),k}s(H,"ensurePluginAppToken");function M(e){const n=T(e),t=c("user"),o=t.scopedApiTokens??[],i=o.filter(r=>!(r.grantee===n&&y(r)));return i.length===o.length?!1:(i.length>0?t.scopedApiTokens=i:delete t.scopedApiTokens,f("user",t),!0)}s(M,"revokePluginAppTokens");let a;function Z(){const e=d("user");if(!e)return"none";try{const n=b(l(e),{bigint:!0});return`${n.ino}:${n.size}:${n.mtimeNs}`}catch{return"absent"}}s(Z,"secretsFileKey");function X(e){const n=Z();return(!a||a.key!==n)&&(a={key:n,byToken:new Map(m("user").map(t=>[t.token,t]))}),a.byToken.get(e)}s(X,"findScopedApiToken");function Q(e){return E("sha256").update(e).digest("hex").slice(0,12)}s(Q,"fingerprint");export{q as deleteRelayToken,H as ensurePluginAppToken,X as findScopedApiToken,Q as fingerprint,B as getApiToken,L as getRelayToken,m as listScopedApiTokens,C as pluginAppToken,c as readSecrets,M as revokePluginAppTokens,W as setRelayToken,f as writeSecrets};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=Object.defineProperty;var s=(o,r)=>f(o,"name",{value:r,configurable:!0});import{chownSync as a,chmodSync as d,existsSync as l,mkdirSync as c,readFileSync as m,statSync as
|
|
2
|
-
`).find(e=>e.startsWith("crtr-data:"));if(!o)throw new Error("crtr-data group is required on sandboxed Linux");const r=Number(o.split(":")[2]);if(!Number.isInteger(r))throw new Error("invalid crtr-data group id");return r}s(p,"dataGroup");function
|
|
1
|
+
var f=Object.defineProperty;var s=(o,r)=>f(o,"name",{value:r,configurable:!0});import{chownSync as a,chmodSync as d,existsSync as l,mkdirSync as c,readFileSync as m,statSync as g}from"node:fs";import{appSpace as h,appsRoot as w,userFilesRoot as y}from"../layout.js";import{launcherRequest as S}from"../../launcher/client.js";import{LAUNCHER_SOCKET as x}from"../../launcher/spec.js";import{allocateAppUser as E,uidForApp as v}from"./users.js";import{areEnginesInProcess as $,isCloudRole as R}from"../canvas/person-state.js";function p(){const o=m("/etc/group","utf8").split(`
|
|
2
|
+
`).find(e=>e.startsWith("crtr-data:"));if(!o)throw new Error("crtr-data group is required on sandboxed Linux");const r=Number(o.split(":")[2]);if(!Number.isInteger(r))throw new Error("invalid crtr-data group id");return r}s(p,"dataGroup");function U(){const o=y(),r=p();c(o,{recursive:!0,mode:1528});const e=g(o),t=e.mode&4095;if(!e.isDirectory()||e.gid!==r||t!==1528){if(!e.isDirectory()||e.uid!==process.getuid())throw new Error(`${o} has owner ${e.uid}, group ${e.gid}, mode ${t.toString(8).padStart(4,"0")}; requires an crtr-data (${r}) directory with mode 2770; only its owner can repair it`);e.gid!==r&&a(o,e.uid,r),t!==1528&&d(o,1528)}}s(U,"ensureUserFiles");async function D(o){const r=h(o);if(R()&&!$())return{uid:process.getuid(),gid:process.getgid(),root:r.root};if(!(process.platform==="linux"&&l(x))){if(process.platform==="linux")throw new Error("app space requires the root launcher on Linux");for(const i of[r.root,r.profiles,r.conversations,r.nodes,r.files,r.home,r.cache])c(i,{recursive:!0});return{uid:await v(o),gid:process.getgid(),root:r.root}}const t=p(),n=await E(o),u=await S({operation:"user.create",app:r.root.slice(w().length+1),uid:n.uid});if(!("uid"in u)||u.uid!==n.uid)throw new Error(`launcher did not create OS user for ${o}`);for(const i of[r.root,r.profiles,r.conversations,r.nodes,r.files,r.home,r.cache])c(i,{recursive:!0,mode:1528}),a(i,process.getuid(),t),d(i,1528);return{uid:n.uid,gid:t,root:r.root}}s(D,"ensureAppSpace");export{D as ensureAppSpace,U as ensureUserFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var y=Object.defineProperty;var r=(e,t)=>y(e,"name",{value:t,configurable:!0});import{MOUSE_MODE_DEFAULTS as u,VERBOSITY_LEVELS as a,WHIP_MESSAGE_MODES as p}from"../types.js";const w={replies:"Replies only",summaries:"Messages + summaries",tools:"Tool calls",previews:"Previews",full:"Full"};function v(e){const t=a.indexOf(e);return`less ${a.map((n,s)=>s===t?"\u25CF":"\u25CB").map((n,s)=>s===0?n:`${s<=t?"\u2501\u2501\u2501\u2501":"\u2500\u2500\u2500\u2500"}${n}`).join("")} more ${w[e]}`}r(v,"verbositySpectrum");function d(e,t,o){const n=e.indexOf(t),s=n>=0?n:0;return e[(s+o+e.length)%e.length]}r(d,"cycleChoice");function c(e,t,o){const n=e.indexOf(t);return n>=0?e[(n+o+e.length)%e.length]:o>=0?e.find(s=>s>t)??e[0]:[...e].reverse().find(s=>s<t)??e[e.length-1]}r(c,"cycleNumber");function i(e,t){return e==="true"?!0:e==="false"?!1:`${t} must be true or false`}r(i,"booleanFromString");function f(e,t){if(!/^\d+$/.test(e))return`${t} must be an integer >= 0`;const o=Number(e);return Number.isSafeInteger(o)?o:`${t} must be an integer >= 0`}r(f,"nonNegativeIntegerFromString");function b(e,t){const o=f(e,t);return typeof o=="string"||o<1?`${t} must be an integer >= 1`:o}r(b,"positiveIntegerFromString");const m=[!1,"notify","apply"],x=[0,1,6,12,24,48,72,168],S=[1,2,3,4,5,6,8,10,12],l="openai-codex";function _(e,t){const o=e.providerOptions[t];if(o!==void 0)return o;const n={};return e.providerOptions[t]=n,n}r(_,"providerOptionsFor");const g={schema_version:{surface:"specialized",owner:"internal schema migration"},marketplaces:{surface:"specialized",owner:"Plugins and pkg market commands"},plugins:{surface:"specialized",owner:"Plugins tab and pkg plugin commands"},auto_update:{surface:"settings",settings:{crtr:{key:"auto_update.crtr",label:"crouter updates",description:"Notify about crouter releases, install them automatically, or turn checks off.",valueConstraint:"true|false|notify|apply; true stores notify",applies:"Applies on the next crouter command.",group:"updates",order:70,format:r(e=>e.auto_update.crtr===!1?"off":e.auto_update.crtr,"format"),cycle:r((e,t)=>{e.auto_update.crtr=d(m,e.auto_update.crtr,t)},"cycle"),setFromString:r((e,t)=>{const o=t==="true"?"notify":t;return o!=="notify"&&o!=="apply"&&o!=="false"?"auto_update.crtr must be notify, apply, or false":(e.auto_update.crtr=o==="false"?!1:o,null)},"setFromString")},content:{key:"auto_update.content",label:"Content updates",description:"Notify about plugin and marketplace updates, apply them automatically, or turn checks off.",valueConstraint:"false|notify|apply",applies:"Applies on the next crouter command.",group:"updates",order:80,format:r(e=>e.auto_update.content===!1?"off":e.auto_update.content,"format"),cycle:r((e,t)=>{e.auto_update.content=d(m,e.auto_update.content,t)},"cycle"),setFromString:r((e,t)=>t!=="notify"&&t!=="apply"&&t!=="false"?"auto_update.content must be notify, apply, or false":(e.auto_update.content=t==="false"?!1:t,null),"setFromString")},interval_hours:{key:"auto_update.interval_hours",label:"Update interval",description:"Minimum hours between automatic update checks. Zero checks on every command.",valueConstraint:"integer >= 0",applies:"Applies on the next crouter command.",group:"updates",order:90,format:r(e=>`${e.auto_update.interval_hours}h`,"format"),cycle:r((e,t)=>{e.auto_update.interval_hours=c(x,e.auto_update.interval_hours,t)},"cycle"),setFromString:r((e,t)=>{const o=f(t,"auto_update.interval_hours");return typeof o=="string"?o:(e.auto_update.interval_hours=o,null)},"setFromString")}}},max_panes_per_window:{surface:"settings",setting:{key:"max_panes_per_window",label:"Maximum panes",description:"Maximum human-review panes placed in one tmux window before using another window.",valueConstraint:"integer >= 1",applies:"Applies to the next pane placement.",group:"panes",order:20,format:r(e=>String(e.max_panes_per_window),"format"),cycle:r((e,t)=>{e.max_panes_per_window=c(S,e.max_panes_per_window,t)},"cycle"),setFromString:r((e,t)=>{const o=b(t,"max_panes_per_window");return typeof o=="string"?o:(e.max_panes_per_window=o,null)},"setFromString")}},auto_open_child_viewers:{surface:"settings",setting:{key:"auto_open_child_viewers",label:"Open child panes",description:"Open each managed child beside its watched parent. Off keeps new children running in the background.",valueConstraint:"true|false",applies:"Applies to the next managed child created; independent roots still open their attended viewer.",group:"panes",order:10,format:r(e=>e.auto_open_child_viewers?"on":"off","format"),cycle:r(e=>{e.auto_open_child_viewers=!e.auto_open_child_viewers},"cycle"),setFromString:r((e,t)=>{const o=i(t,"auto_open_child_viewers");return typeof o=="string"?o:(e.auto_open_child_viewers=o,null)},"setFromString")}},brokerThresholds:{surface:"specialized",owner:"Broker limits tab"},lifecycle:{surface:"specialized",owner:"sys config set lifecycle.unattendedParkMs"},completion_bell:{surface:"settings",setting:{key:"completion_bell",label:"Completion bell",description:"Ring a short sound when the node in an attached viewer finishes a turn.",valueConstraint:"true|false",applies:"Applies on the next turn end.",group:"display",order:41,format:r(e=>e.completion_bell?"on":"off","format"),cycle:r(e=>{e.completion_bell=!e.completion_bell},"cycle"),setFromString:r((e,t)=>{const o=i(t,"completion_bell");return typeof o=="string"?o:(e.completion_bell=o,null)},"setFromString")}},working_gerunds:{surface:"specialized",owner:"sys config set working_gerunds"},whip_mode:{surface:"settings",setting:{key:"whip_mode",label:"Whip mode",description:"Play the whip animation when you send a prompt and when a viewer opens for an agent with an initial prompt.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:39,format:r(e=>e.whip_mode?"on":"off","format"),cycle:r(e=>{e.whip_mode=!e.whip_mode},"cycle"),setFromString:r((e,t)=>{const o=i(t,"whip_mode");return typeof o=="string"?o:(e.whip_mode=o,null)},"setFromString")}},page_surface:{surface:"settings",setting:{key:"page_surface",label:"Page human surface",description:"This host reads pages in a browser rather than a terminal. Agents are told the page module runs as written, HTML pages are offered, and document review and live display leave the command tree.",valueConstraint:"true|false",applies:"Applies when human command help is assembled.",group:"display",order:37,format:r(e=>e.page_surface?"on":"off","format"),cycle:r(e=>{e.page_surface=!e.page_surface},"cycle"),setFromString:r((e,t)=>{const o=i(t,"page_surface");return typeof o=="string"?o:(e.page_surface=o,null)},"setFromString")}},whip_messages:{surface:"specialized",owner:"sys config set whip_messages"},whip_message_mode:{surface:"settings",setting:{key:"whip_message_mode",label:"Whip message",description:"What the whip action sends: a random line from whip_messages, or the fixed \u201CGo faster\u201D.",valueConstraint:p.join("|"),applies:"Applies on the next attach.",group:"display",order:40,format:r(e=>e.whip_message_mode==="go-faster"?"go faster":"random","format"),cycle:r((e,t)=>{e.whip_message_mode=d(p,e.whip_message_mode,t)},"cycle"),setFromString:r((e,t)=>p.includes(t)?(e.whip_message_mode=t,null):`whip_message_mode must be one of: ${p.join("|")}`,"setFromString")}},mouse_mode_default:{surface:"settings",setting:{key:"mouse_mode_default",label:"Default mouse mode",description:"Initial mouse wheel scrolling for each attached viewer.",valueConstraint:u.join("|"),applies:"Applies on the next attach.",group:"display",order:38,format:r(e=>e.mouse_mode_default==="tmux"?"follow tmux":e.mouse_mode_default,"format"),cycle:r((e,t)=>{e.mouse_mode_default=d(u,e.mouse_mode_default,t)},"cycle"),setFromString:r((e,t)=>u.includes(t)?(e.mouse_mode_default=t,null):`mouse_mode_default must be one of: ${u.join("|")}`,"setFromString")}},bash_tool_purpose:{surface:"settings",setting:{key:"bash_tool_purpose",label:"Bash purpose field",description:"Expose the optional purpose label to agents in the bash tool schema. Off removes the field without disabling the bash valve.",valueConstraint:"true|false",applies:"Applies on the next node session.",group:"display",order:25,format:r(e=>e.bash_tool_purpose?"on":"off","format"),cycle:r(e=>{e.bash_tool_purpose=!e.bash_tool_purpose},"cycle"),setFromString:r((e,t)=>{const o=i(t,"bash_tool_purpose");return typeof o=="string"?o:(e.bash_tool_purpose=o,null)},"setFromString")}},verbosity:{surface:"settings",setting:{key:"verbosity",label:"Verbosity",description:"How much of a transcript the viewer shows, from one rewritten reply per message to every tool call untruncated. Ctrl+O shows more and Ctrl+Shift+O less in the open viewer only; this sets where every viewer starts.",valueConstraint:a.join("|"),applies:"Applies on the next attach.",group:"display",order:30,format:r(e=>e.verbosity,"format"),display:r(e=>v(e.verbosity),"display"),cycle:r((e,t)=>{const o=a.indexOf(e.verbosity)+t;e.verbosity=a[Math.max(0,Math.min(a.length-1,o))]},"cycle"),setFromString:r((e,t)=>a.includes(t)?(e.verbosity=t,null):`verbosity must be one of: ${a.join("|")}`,"setFromString")}},document_port:{surface:"settings",setting:{key:"document_port",label:"Document browser port",description:"Fixed localhost port where crtrd serves editable document pages.",valueConstraint:"1-65535",applies:"Applies after daemon handover and on the next attach.",group:"display",order:37.5,format:r(e=>String(e.document_port),"format"),cycle:r((e,t)=>{e.document_port=Math.max(1,Math.min(65535,e.document_port+t))},"cycle"),setFromString:r((e,t)=>{const o=Number(t);return!/^\d+$/.test(t)||!Number.isInteger(o)||o<1||o>65535?"document_port must be an integer from 1 to 65535":(e.document_port=o,null)},"setFromString")}},detailed_tool_recaps:{surface:"settings",setting:{key:"detailed_tool_recaps",label:"Detailed tool recaps",description:"Show each document read and edited file in folded tool recaps. Off shows a compact count line instead.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:36,format:r(e=>e.detailed_tool_recaps?"on":"off","format"),cycle:r(e=>{e.detailed_tool_recaps=!e.detailed_tool_recaps},"cycle"),setFromString:r((e,t)=>{const o=i(t,"detailed_tool_recaps");return typeof o=="string"?o:(e.detailed_tool_recaps=o,null)},"setFromString")}},keybindings:{surface:"specialized",owner:"Keybindings tab"},tmux_passthrough:{surface:"specialized",owner:"Keybindings tab"},providerOptions:{surface:"settings",settings:{"openai-codex.fastMode":{key:`providerOptions.${l}.fastMode`,label:"Codex fast mode",description:"Serve Codex turns at the ChatGPT priority tier: about 1.5x faster generation for about 2x the credits. Displayed cost does not reflect the premium.",valueConstraint:"true|false",applies:"Applies on each node's next turn.",group:"providers",order:40,format:r(e=>e.providerOptions[l]?.fastMode?"on":"off","format"),cycle:r(e=>{const t=_(e,l);t.fastMode=!t.fastMode},"cycle"),setFromString:r((e,t)=>{const o=i(t,`providerOptions.${l}.fastMode`);return typeof o=="string"?o:(_(e,l).fastMode=o,null)},"setFromString")}}},modelLadders:{surface:"specialized",owner:"Models tab"},modelRoutes:{surface:"specialized",owner:"Models route declarations"},modelRouting:{surface:"specialized",owner:"Models route declarations"},kinds:{surface:"specialized",owner:"Models tab and kind registry"},page_components:{surface:"specialized",owner:"Page component catalog: product-registered page component kinds"},remoteCanvas:{surface:"specialized",owner:"canvas config commands"},api:{surface:"specialized",owner:"sys connect"},paths:{surface:"specialized",owner:"runtime layout"},store:{surface:"specialized",owner:"daemon conversation store"},runtime:{surface:"specialized",owner:"app-facing listener"},spawnEnv:{surface:"specialized",owner:"spawn environment allow-list"},bin:{surface:"specialized",owner:"bare-binary contributions on every node PATH"},humanActions:{surface:"specialized",owner:"scope-configured human completion actions"}},C=Object.keys(g);function k(){const e=[];for(const t of Object.values(g))t.surface==="settings"&&("setting"in t?e.push(t.setting):e.push(...Object.values(t.settings)));return e.sort((t,o)=>t.order-o.order)}r(k,"collectUserSettings");const h=k();function E(e){return h.find(t=>t.key===e)}r(E,"findUserSetting");function M(e){return h.filter(t=>t.group===e)}r(M,"userSettingsInGroup");export{g as CONFIG_SETTINGS_COVERAGE,C as SCOPE_CONFIG_KEYS,h as USER_SETTINGS,w as VERBOSITY_LABELS,E as findUserSetting,M as userSettingsInGroup,v as verbositySpectrum};
|
|
1
|
+
var y=Object.defineProperty;var r=(e,t)=>y(e,"name",{value:t,configurable:!0});import{MOUSE_MODE_DEFAULTS as u,VERBOSITY_LEVELS as a,WHIP_MESSAGE_MODES as p}from"../types.js";const w={replies:"Replies only",summaries:"Messages + summaries",tools:"Tool calls",previews:"Previews",full:"Full"};function v(e){const t=a.indexOf(e);return`less ${a.map((n,s)=>s===t?"\u25CF":"\u25CB").map((n,s)=>s===0?n:`${s<=t?"\u2501\u2501\u2501\u2501":"\u2500\u2500\u2500\u2500"}${n}`).join("")} more ${w[e]}`}r(v,"verbositySpectrum");function d(e,t,o){const n=e.indexOf(t),s=n>=0?n:0;return e[(s+o+e.length)%e.length]}r(d,"cycleChoice");function c(e,t,o){const n=e.indexOf(t);return n>=0?e[(n+o+e.length)%e.length]:o>=0?e.find(s=>s>t)??e[0]:[...e].reverse().find(s=>s<t)??e[e.length-1]}r(c,"cycleNumber");function i(e,t){return e==="true"?!0:e==="false"?!1:`${t} must be true or false`}r(i,"booleanFromString");function f(e,t){if(!/^\d+$/.test(e))return`${t} must be an integer >= 0`;const o=Number(e);return Number.isSafeInteger(o)?o:`${t} must be an integer >= 0`}r(f,"nonNegativeIntegerFromString");function b(e,t){const o=f(e,t);return typeof o=="string"||o<1?`${t} must be an integer >= 1`:o}r(b,"positiveIntegerFromString");const m=[!1,"notify","apply"],x=[0,1,6,12,24,48,72,168],S=[1,2,3,4,5,6,8,10,12],l="openai-codex";function _(e,t){const o=e.providerOptions[t];if(o!==void 0)return o;const n={};return e.providerOptions[t]=n,n}r(_,"providerOptionsFor");const g={schema_version:{surface:"specialized",owner:"internal schema migration"},marketplaces:{surface:"specialized",owner:"Plugins and pkg market commands"},plugins:{surface:"specialized",owner:"Plugins tab and pkg plugin commands"},auto_update:{surface:"settings",settings:{crtr:{key:"auto_update.crtr",label:"crouter updates",description:"Notify about crouter releases, install them automatically, or turn checks off.",valueConstraint:"true|false|notify|apply; true stores notify",applies:"Applies on the next crouter command.",group:"updates",order:70,format:r(e=>e.auto_update.crtr===!1?"off":e.auto_update.crtr,"format"),cycle:r((e,t)=>{e.auto_update.crtr=d(m,e.auto_update.crtr,t)},"cycle"),setFromString:r((e,t)=>{const o=t==="true"?"notify":t;return o!=="notify"&&o!=="apply"&&o!=="false"?"auto_update.crtr must be notify, apply, or false":(e.auto_update.crtr=o==="false"?!1:o,null)},"setFromString")},content:{key:"auto_update.content",label:"Content updates",description:"Notify about plugin and marketplace updates, apply them automatically, or turn checks off.",valueConstraint:"false|notify|apply",applies:"Applies on the next crouter command.",group:"updates",order:80,format:r(e=>e.auto_update.content===!1?"off":e.auto_update.content,"format"),cycle:r((e,t)=>{e.auto_update.content=d(m,e.auto_update.content,t)},"cycle"),setFromString:r((e,t)=>t!=="notify"&&t!=="apply"&&t!=="false"?"auto_update.content must be notify, apply, or false":(e.auto_update.content=t==="false"?!1:t,null),"setFromString")},interval_hours:{key:"auto_update.interval_hours",label:"Update interval",description:"Minimum hours between automatic update checks. Zero checks on every command.",valueConstraint:"integer >= 0",applies:"Applies on the next crouter command.",group:"updates",order:90,format:r(e=>`${e.auto_update.interval_hours}h`,"format"),cycle:r((e,t)=>{e.auto_update.interval_hours=c(x,e.auto_update.interval_hours,t)},"cycle"),setFromString:r((e,t)=>{const o=f(t,"auto_update.interval_hours");return typeof o=="string"?o:(e.auto_update.interval_hours=o,null)},"setFromString")}}},max_panes_per_window:{surface:"settings",setting:{key:"max_panes_per_window",label:"Maximum panes",description:"Maximum human-review panes placed in one tmux window before using another window.",valueConstraint:"integer >= 1",applies:"Applies to the next pane placement.",group:"panes",order:20,format:r(e=>String(e.max_panes_per_window),"format"),cycle:r((e,t)=>{e.max_panes_per_window=c(S,e.max_panes_per_window,t)},"cycle"),setFromString:r((e,t)=>{const o=b(t,"max_panes_per_window");return typeof o=="string"?o:(e.max_panes_per_window=o,null)},"setFromString")}},auto_open_child_viewers:{surface:"settings",setting:{key:"auto_open_child_viewers",label:"Open child panes",description:"Open each managed child beside its watched parent. Off keeps new children running in the background.",valueConstraint:"true|false",applies:"Applies to the next managed child created; independent roots still open their attended viewer.",group:"panes",order:10,format:r(e=>e.auto_open_child_viewers?"on":"off","format"),cycle:r(e=>{e.auto_open_child_viewers=!e.auto_open_child_viewers},"cycle"),setFromString:r((e,t)=>{const o=i(t,"auto_open_child_viewers");return typeof o=="string"?o:(e.auto_open_child_viewers=o,null)},"setFromString")}},brokerThresholds:{surface:"specialized",owner:"Broker limits tab"},lifecycle:{surface:"specialized",owner:"sys config set lifecycle.unattendedParkMs"},completion_bell:{surface:"settings",setting:{key:"completion_bell",label:"Completion bell",description:"Ring a short sound when the node in an attached viewer finishes a turn.",valueConstraint:"true|false",applies:"Applies on the next turn end.",group:"display",order:41,format:r(e=>e.completion_bell?"on":"off","format"),cycle:r(e=>{e.completion_bell=!e.completion_bell},"cycle"),setFromString:r((e,t)=>{const o=i(t,"completion_bell");return typeof o=="string"?o:(e.completion_bell=o,null)},"setFromString")}},working_gerunds:{surface:"specialized",owner:"sys config set working_gerunds"},whip_mode:{surface:"settings",setting:{key:"whip_mode",label:"Whip mode",description:"Play the whip animation when you send a prompt and when a viewer opens for an agent with an initial prompt.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:39,format:r(e=>e.whip_mode?"on":"off","format"),cycle:r(e=>{e.whip_mode=!e.whip_mode},"cycle"),setFromString:r((e,t)=>{const o=i(t,"whip_mode");return typeof o=="string"?o:(e.whip_mode=o,null)},"setFromString")}},page_surface:{surface:"settings",setting:{key:"page_surface",label:"Page human surface",description:"This host reads pages in a browser rather than a terminal. Agents are told the page module runs as written, HTML pages are offered, and document review and live display leave the command tree.",valueConstraint:"true|false",applies:"Applies when human command help is assembled.",group:"display",order:37,format:r(e=>e.page_surface?"on":"off","format"),cycle:r(e=>{e.page_surface=!e.page_surface},"cycle"),setFromString:r((e,t)=>{const o=i(t,"page_surface");return typeof o=="string"?o:(e.page_surface=o,null)},"setFromString")}},whip_messages:{surface:"specialized",owner:"sys config set whip_messages"},whip_message_mode:{surface:"settings",setting:{key:"whip_message_mode",label:"Whip message",description:"What the whip action sends: a random line from whip_messages, or the fixed \u201CGo faster\u201D.",valueConstraint:p.join("|"),applies:"Applies on the next attach.",group:"display",order:40,format:r(e=>e.whip_message_mode==="go-faster"?"go faster":"random","format"),cycle:r((e,t)=>{e.whip_message_mode=d(p,e.whip_message_mode,t)},"cycle"),setFromString:r((e,t)=>p.includes(t)?(e.whip_message_mode=t,null):`whip_message_mode must be one of: ${p.join("|")}`,"setFromString")}},mouse_mode_default:{surface:"settings",setting:{key:"mouse_mode_default",label:"Default mouse mode",description:"Initial mouse wheel scrolling for each attached viewer.",valueConstraint:u.join("|"),applies:"Applies on the next attach.",group:"display",order:38,format:r(e=>e.mouse_mode_default==="tmux"?"follow tmux":e.mouse_mode_default,"format"),cycle:r((e,t)=>{e.mouse_mode_default=d(u,e.mouse_mode_default,t)},"cycle"),setFromString:r((e,t)=>u.includes(t)?(e.mouse_mode_default=t,null):`mouse_mode_default must be one of: ${u.join("|")}`,"setFromString")}},bash_tool_purpose:{surface:"settings",setting:{key:"bash_tool_purpose",label:"Bash purpose field",description:"Expose the optional purpose label to agents in the bash tool schema. Off removes the field without disabling the bash valve.",valueConstraint:"true|false",applies:"Applies on the next node session.",group:"display",order:25,format:r(e=>e.bash_tool_purpose?"on":"off","format"),cycle:r(e=>{e.bash_tool_purpose=!e.bash_tool_purpose},"cycle"),setFromString:r((e,t)=>{const o=i(t,"bash_tool_purpose");return typeof o=="string"?o:(e.bash_tool_purpose=o,null)},"setFromString")}},verbosity:{surface:"settings",setting:{key:"verbosity",label:"Verbosity",description:"How much of a transcript the viewer shows, from one rewritten reply per message to every tool call untruncated. Ctrl+O shows more and Ctrl+Shift+O less in the open viewer only; this sets where every viewer starts.",valueConstraint:a.join("|"),applies:"Applies on the next attach.",group:"display",order:30,format:r(e=>e.verbosity,"format"),display:r(e=>v(e.verbosity),"display"),cycle:r((e,t)=>{const o=a.indexOf(e.verbosity)+t;e.verbosity=a[Math.max(0,Math.min(a.length-1,o))]},"cycle"),setFromString:r((e,t)=>a.includes(t)?(e.verbosity=t,null):`verbosity must be one of: ${a.join("|")}`,"setFromString")}},document_port:{surface:"settings",setting:{key:"document_port",label:"Document browser port",description:"Fixed localhost port where crtrd serves editable document pages.",valueConstraint:"1-65535",applies:"Applies after daemon handover and on the next attach.",group:"display",order:37.5,format:r(e=>String(e.document_port),"format"),cycle:r((e,t)=>{e.document_port=Math.max(1,Math.min(65535,e.document_port+t))},"cycle"),setFromString:r((e,t)=>{const o=Number(t);return!/^\d+$/.test(t)||!Number.isInteger(o)||o<1||o>65535?"document_port must be an integer from 1 to 65535":(e.document_port=o,null)},"setFromString")}},detailed_tool_recaps:{surface:"settings",setting:{key:"detailed_tool_recaps",label:"Detailed tool recaps",description:"Show each document read and edited file in folded tool recaps. Off shows a compact count line instead.",valueConstraint:"true|false",applies:"Applies on the next attach.",group:"display",order:36,format:r(e=>e.detailed_tool_recaps?"on":"off","format"),cycle:r(e=>{e.detailed_tool_recaps=!e.detailed_tool_recaps},"cycle"),setFromString:r((e,t)=>{const o=i(t,"detailed_tool_recaps");return typeof o=="string"?o:(e.detailed_tool_recaps=o,null)},"setFromString")}},keybindings:{surface:"specialized",owner:"Keybindings tab"},tmux_passthrough:{surface:"specialized",owner:"Keybindings tab"},providerOptions:{surface:"settings",settings:{"openai-codex.fastMode":{key:`providerOptions.${l}.fastMode`,label:"Codex fast mode",description:"Serve Codex turns at the ChatGPT priority tier: about 1.5x faster generation for about 2x the credits. Displayed cost does not reflect the premium.",valueConstraint:"true|false",applies:"Applies on each node's next turn.",group:"providers",order:40,format:r(e=>e.providerOptions[l]?.fastMode?"on":"off","format"),cycle:r(e=>{const t=_(e,l);t.fastMode=!t.fastMode},"cycle"),setFromString:r((e,t)=>{const o=i(t,`providerOptions.${l}.fastMode`);return typeof o=="string"?o:(_(e,l).fastMode=o,null)},"setFromString")}}},modelLadders:{surface:"specialized",owner:"Models tab"},modelRoutes:{surface:"specialized",owner:"Models route declarations"},modelRouting:{surface:"specialized",owner:"Models route declarations"},kinds:{surface:"specialized",owner:"Models tab and kind registry"},page_components:{surface:"specialized",owner:"Page component catalog: product-registered page component kinds"},remoteCanvas:{surface:"specialized",owner:"canvas config commands"},api:{surface:"specialized",owner:"daemon API listener"},paths:{surface:"specialized",owner:"runtime layout"},store:{surface:"specialized",owner:"daemon conversation store"},runtime:{surface:"specialized",owner:"app-facing listener"},spawnEnv:{surface:"specialized",owner:"spawn environment allow-list"},bin:{surface:"specialized",owner:"bare-binary contributions on every node PATH"},humanActions:{surface:"specialized",owner:"scope-configured human completion actions"}},C=Object.keys(g);function k(){const e=[];for(const t of Object.values(g))t.surface==="settings"&&("setting"in t?e.push(t.setting):e.push(...Object.values(t.settings)));return e.sort((t,o)=>t.order-o.order)}r(k,"collectUserSettings");const h=k();function E(e){return h.find(t=>t.key===e)}r(E,"findUserSetting");function M(e){return h.filter(t=>t.group===e)}r(M,"userSettingsInGroup");export{g as CONFIG_SETTINGS_COVERAGE,C as SCOPE_CONFIG_KEYS,h as USER_SETTINGS,w as VERBOSITY_LABELS,E as findUserSetting,M as userSettingsInGroup,v as verbositySpectrum};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StartBundleRecipeDTO } from '../../api/index.js';
|
|
2
|
-
/** The environment object id a node runs in: its profile's `environment_id
|
|
2
|
+
/** The environment object id a node runs in: its profile's `environment_id`. A node whose profile names none is a defect: the environment is set when the profile is made. */
|
|
3
3
|
export declare function environmentOfNode(profileId: string | null): Promise<string>;
|
|
4
4
|
/** SQL predicate over `environments`: the recipe has content (a repository, a setup script or pi packages). A recipe cleared back to nothing
|
|
5
5
|
* has none, whatever its `recipe_revision` counter says: the counter only orders edits, it does not say whether a recipe exists. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
OR EXISTS (SELECT 1 FROM environment_repos r WHERE r.environment = environments.object))`,
|
|
1
|
+
var E=Object.defineProperty;var o=(n,e)=>E(n,"name",{value:e,configurable:!0});import{ApiError as l}from"../../api/errors.js";import{openDb as i}from"../../core/canvas/db.js";async function u(n){if(n===null)throw new Error("a node with no profile has no environment");const e=await(await i()).prepare("SELECT environment_id FROM profiles WHERE id = ?").get(n);if(e?.environment_id==null)throw new Error(`profile ${n} has no environment`);return e.environment_id}o(u,"environmentOfNode");const m=`(btrim(COALESCE(environments.setup_script, '')) <> '' OR btrim(COALESCE(environments.pi_packages, '')) <> ''
|
|
2
|
+
OR EXISTS (SELECT 1 FROM environment_repos r WHERE r.environment = environments.object))`,_="northlight-systems/";async function b(n){const e=process.env.CRTR_PACKAGES_TOKEN;if(e===void 0||e==="")return null;const r=await(await i()).prepare("SELECT github_full_name FROM environment_repos WHERE environment = ?").all(n);return r.length>0&&r.every(t=>t.github_full_name.toLowerCase().startsWith(_))?e:null}o(b,"packagesTokenFor");async function c(n){const e=await(await i()).prepare(`SELECT recipe_revision, setup_script, pi_packages, ${m} AS has_content,
|
|
3
3
|
(SELECT COALESCE(json_agg(json_build_object('name', r.name, 'github_full_name', r.github_full_name, 'default_branch', r.default_branch) ORDER BY r.position), '[]'::json)
|
|
4
4
|
FROM environment_repos r WHERE r.environment = environments.object) AS repositories
|
|
5
|
-
FROM environments WHERE object = ?`).get(n);return e===void 0||!e.has_content?null:{revision:Number(e.recipe_revision),repositories:JSON.parse(e.repositories),setup_script:e.setup_script,pi_packages:e.pi_packages}}o(
|
|
5
|
+
FROM environments WHERE object = ?`).get(n);return e===void 0||!e.has_content?null:{revision:Number(e.recipe_revision),repositories:JSON.parse(e.repositories),setup_script:e.setup_script,pi_packages:e.pi_packages}}o(c,"recipeOf");async function h(n){return n===null?!1:(await(await i()).prepare("SELECT kind FROM environments WHERE object = ?").get(await u(n)))?.kind==="blaxel"}o(h,"runsOnBlaxel");async function d(n,e,r,t){const a=((await c(await u(n)))?.repositories??[]).find(p=>e===`/work/${p.name}`||e.startsWith(`/work/${p.name}/`));if(a===void 0)throw new l(400,"invalid_request",`--worktree needs a cwd inside one of the environment's repositories under /work, not ${e}`,{param:"worktree"});return{repository:a.name,branch:`crtr/${r}`,base:t??a.default_branch}}o(d,"sandboxWorktreeRequest");async function O(n,e){if(n===null)return null;const r=await(await i()).prepare("SELECT e.object, e.kind FROM profiles p JOIN environments e ON e.object = p.environment_id WHERE p.id = ?").get(n);if(r?.kind!=="blaxel")return null;const t=(await c(r.object))?.repositories??[];return t.length===0?null:t.some(s=>e===`/work/${s.name}`||e.startsWith(`/work/${s.name}/`))?e:`/work/${t[0].name}`}o(O,"devEnvironmentCwd");export{m as RECIPE_HAS_CONTENT_SQL,O as devEnvironmentCwd,u as environmentOfNode,b as packagesTokenFor,c as recipeOf,h as runsOnBlaxel,d as sandboxWorktreeRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var t=Object.defineProperty;var n=(e,r)=>t(e,"name",{value:r,configurable:!0});import{ApiError as o}from"../../../api/errors.js";import{canvasOrigin as s}from"../canvas-host.js";const u=[{method:"GET",pattern:"/v1/documents/browser-access",handler:n(()=>{const e=s();if(e===void 0)throw new o(503,"document_listener_unavailable","this API serves no document page (CRTR_CANVAS_URL is unset)");return{status:200,body:{canvas_url:e}}},"handler")}];export{u as documentAccessRoutes};
|
|
@@ -3,7 +3,7 @@ import { ApiError } from '../../api/errors.js';
|
|
|
3
3
|
import type { AppPrincipal } from './principal.js';
|
|
4
4
|
import { type Operation } from './operations.js';
|
|
5
5
|
/** What the caller's bearer token may reach: `null` is the owner (every scope,
|
|
6
|
-
* every route); a list is the ceiling minted by
|
|
6
|
+
* every route); a list is the ceiling minted by an app token. */
|
|
7
7
|
export type Ceiling = readonly string[] | null;
|
|
8
8
|
export type RequestPrincipal = {
|
|
9
9
|
class: 'anonymous';
|
package/dist/daemon/crtrd-cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import"../suppress-experimental-warnings.js";import{runDaemon as
|
|
1
|
+
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import"../suppress-experimental-warnings.js";import{runDaemon as a}from"./crtrd.js";import{configureDaemonHttpDispatcher as s}from"./http-dispatcher.js";import{hasLocalCanvas as p,readMachineConfig as u}from"./machine-link/config.js";function l(e){for(let r=0;r<e.length;r++){const n=e[r];if(n==="--tcp")return e[r+1];if(n!==void 0&&n.startsWith("--tcp="))return n.slice(6)}}o(l,"parseTcpArg");function f(e){for(let r=0;r<e.length;r++){const n=e[r],t=n==="--role"?e[r+1]:n?.startsWith("--role=")?n.slice(7):void 0;if(t!==void 0){if(t!=="api"&&t!=="reconcile"&&t!=="machine"&&t!=="all")throw new Error(`--role must be api, reconcile, all or machine, got ${t}`);return t}}if(u()!==void 0)return"machine";if(!p())throw new Error("this computer is not signed in to Northlight. Run `crtr sys signin`.")}o(f,"parseRoleArg");function m(e){return e.includes("--prepare")}o(m,"parsePrepareArg");const i=process.argv.slice(2);if(i[0]==="import-dump"){const{runImportDump:e}=await import("./import-dump-run.js");process.exitCode=await e(i[1],i[2])}else s(),await a({tcp:l(i),prepare:m(i),role:f(i)});
|
package/dist/daemon/crtrd.d.ts
CHANGED
|
@@ -22,10 +22,12 @@ export interface DaemonOpts {
|
|
|
22
22
|
/** Hold after storage preparation until `POST /v1/daemon/admit`. */
|
|
23
23
|
prepare?: boolean;
|
|
24
24
|
/** `api`: serves requests, runs no reconciler lane. `reconcile`: runs the lanes and serves only the probe API.
|
|
25
|
-
* `
|
|
25
|
+
* `all`: api and reconcile in one process with cloud-role semantics (tests and crouter development only).
|
|
26
|
+
* `machine`: a person's computer; holds the machine link and executes runner calls, no database.
|
|
27
|
+
* Absent: the legacy local control plane of a computer that has not moved to Northlight yet, holding the `daemon_owner` claim. */
|
|
26
28
|
role?: DaemonRole;
|
|
27
29
|
}
|
|
28
|
-
export type DaemonRole = 'api' | 'reconcile' | 'machine';
|
|
30
|
+
export type DaemonRole = 'api' | 'reconcile' | 'machine' | 'all';
|
|
29
31
|
/** Whether a process of this role runs the reconciler lanes and their boot sweeps (an api process does not). */
|
|
30
32
|
export declare function roleRunsLanes(role: DaemonRole | undefined): boolean;
|
|
31
33
|
/** Whether a process of this role serves conversations, documents and the app listener (a reconcile process does not). */
|