@north-light/cli 0.3.581 → 0.3.583
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/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/health.d.ts +2 -0
- package/dist/api/error-codes.d.ts +5 -0
- package/dist/api/error-codes.js +1 -1
- package/dist/api/errors.js +1 -1
- package/dist/build-root.d.ts +11 -4
- package/dist/build-root.js +1 -1
- package/dist/cli.js +7 -7
- package/dist/clients/attach/viewer.js +428 -428
- package/dist/commands/api-client.d.ts +5 -0
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/sys/desktop.d.ts +5 -0
- package/dist/commands/sys/desktop.js +1 -0
- package/dist/commands/sys/import/move.d.ts +55 -0
- package/dist/commands/sys/import/move.js +8 -0
- package/dist/commands/sys/import/resume.js +1 -1
- package/dist/commands/sys/import/start.d.ts +3 -4
- package/dist/commands/sys/import/start.js +1 -4
- package/dist/commands/sys/signin.js +2 -2
- package/dist/commands/sys.js +1 -1
- package/dist/core/canvas/pid.d.ts +6 -0
- package/dist/core/canvas/pid.js +5 -5
- package/dist/core/command-plugins/compose.js +1 -1
- package/dist/core/command.d.ts +17 -8
- package/dist/core/command.js +9 -9
- package/dist/core/directory/issuer.d.ts +3 -0
- package/dist/core/directory/issuer.js +1 -1
- package/dist/core/directory/person-credential.d.ts +28 -3
- package/dist/core/directory/person-credential.js +1 -1
- package/dist/core/directory/reach.d.ts +3 -0
- package/dist/core/directory/reach.js +1 -0
- package/dist/core/grants/mirror.d.ts +3 -0
- package/dist/core/grants/mirror.js +2 -2
- package/dist/core/graph/bodies-boot-copy.d.ts +16 -2
- package/dist/core/graph/bodies-boot-copy.js +1 -1
- package/dist/core/graph/bodies.d.ts +13 -4
- package/dist/core/graph/bodies.js +1 -1
- package/dist/core/graph/documents.js +10 -10
- package/dist/core/graph/repo-sync/exchange.js +2 -2
- package/dist/core/graph/repo-sync/ref-format.d.ts +7 -2
- package/dist/core/graph/repo-sync/ref-format.js +2 -2
- package/dist/core/import/bundle/layout.d.ts +2 -1
- package/dist/core/import/export/cloud.d.ts +4 -2
- package/dist/core/import/export/cloud.js +1 -1
- package/dist/core/import/export/dump.js +3 -3
- package/dist/core/import/load/copy.js +5 -5
- package/dist/core/import/load/rewrite.js +9 -5
- package/dist/core/import/load/stage.js +1 -1
- package/dist/core/import/load/verify.js +8 -7
- package/dist/core/io.js +4 -4
- package/dist/core/northlight/previews.d.ts +22 -0
- package/dist/core/northlight/previews.js +1 -0
- package/dist/core/providers/call.js +1 -1
- package/dist/core/providers/device.js +1 -1
- package/dist/core/providers/files.d.ts +2 -1
- package/dist/core/providers/files.js +1 -1
- package/dist/core/runtime/broker/cli-relay.js +1 -1
- package/dist/core/runtime/broker/model-adapter.js +3 -3
- package/dist/core/runtime/broker-ownership.d.ts +1 -0
- package/dist/core/runtime/broker-ownership.js +1 -0
- package/dist/core/runtime/first-run-offer.d.ts +7 -2
- package/dist/core/runtime/first-run-offer.js +10 -2
- package/dist/core/runtime/front-door.js +4 -4
- package/dist/core/runtime/runner/machine/executor.d.ts +7 -1
- package/dist/core/runtime/runner/machine/executor.js +1 -1
- package/dist/core/worktree-mutation-async.js +1 -1
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/providers.js +1 -1
- package/dist/daemon/api/router.js +1 -1
- package/dist/daemon/boot-migrations.js +1 -1
- package/dist/daemon/cron/machine-exec.d.ts +6 -0
- package/dist/daemon/cron/machine-exec.js +1 -1
- package/dist/daemon/crtrd.d.ts +1 -1
- package/dist/daemon/crtrd.js +14 -14
- package/dist/daemon/machine-daemon.d.ts +7 -4
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/machine-link/config.d.ts +32 -1
- package/dist/daemon/machine-link/config.js +3 -3
- package/dist/daemon/machine-link/move-notify.d.ts +4 -0
- package/dist/daemon/machine-link/move-notify.js +1 -0
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -13
- package/scripts/sandbox-bootstrap.sh +2 -1
package/dist/api/contract.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
|
|
2
|
-
export declare const CONTRACT_LEVEL = "1.
|
|
2
|
+
export declare const CONTRACT_LEVEL = "1.42";
|
|
3
3
|
/** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
|
|
4
4
|
export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
|
|
5
5
|
/** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
|
package/dist/api/contract.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.
|
|
1
|
+
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.42",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
|
package/dist/api/dto/health.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface HealthDTO {
|
|
|
10
10
|
brokers_reconciled: boolean;
|
|
11
11
|
/** Present on a machine-role daemon only: whether its link to the control plane is up. That daemon reports `startup_phase: 'recovering'` while it is down. */
|
|
12
12
|
link_connected?: boolean;
|
|
13
|
+
/** Present on a machine-role daemon only: false when this computer has no person sign-in, so it opens no link and runs no agent or cron. */
|
|
14
|
+
signed_in?: boolean;
|
|
13
15
|
/** Present while corpus migration or normal daemon startup is incomplete. */
|
|
14
16
|
startup_blocked?: string;
|
|
15
17
|
/** Always present; only `ready` admits normal daemon work. */
|
|
@@ -224,6 +224,11 @@ export declare const errorCodes: {
|
|
|
224
224
|
readonly status: 429;
|
|
225
225
|
readonly retryable: true;
|
|
226
226
|
};
|
|
227
|
+
readonly northlight_unreachable: {
|
|
228
|
+
readonly type: "server_error";
|
|
229
|
+
readonly status: 503;
|
|
230
|
+
readonly retryable: true;
|
|
231
|
+
};
|
|
227
232
|
readonly runtime_unreachable: {
|
|
228
233
|
readonly type: "server_error";
|
|
229
234
|
readonly status: 503;
|
package/dist/api/error-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={unauthorized:{type:"authentication_error",status:401,retryable:!1},machine_revoked:{type:"authentication_error",status:401,retryable:!1},grant_revoked:{type:"authentication_error",status:401,retryable:!1},grant_removed:{type:"authentication_error",status:401,retryable:!1},grant_suspended:{type:"authentication_error",status:401,retryable:!1},refresh_token_expired:{type:"authentication_error",status:401,retryable:!1},refresh_token_reused:{type:"authentication_error",status:401,retryable:!1},scope_missing:{type:"permission_error",status:403,retryable:!1},owner_only:{type:"permission_error",status:403,retryable:!1},other_app_run:{type:"permission_error",status:403,retryable:!1},payer_not_app:{type:"permission_error",status:403,retryable:!1},approval_pending:{type:"permission_error",status:403,retryable:!1},user_denied:{type:"permission_error",status:403,retryable:!1},provider_refused:{type:"permission_error",status:403,retryable:!1},provider_not_connected:{type:"permission_error",status:403,retryable:!1},provider_setup_pending:{type:"permission_error",status:403,retryable:!1},question_pages_off:{type:"permission_error",status:403,retryable:!1},unsandboxed_machine:{type:"permission_error",status:403,retryable:!1},app_not_granted:{type:"permission_error",status:403,retryable:!1},isolated_run:{type:"permission_error",status:403,retryable:!1},provider_version_retired:{type:"permission_error",status:403,retryable:!1},invalid_scope:{type:"invalid_request_error",status:400,retryable:!1},invalid_request:{type:"invalid_request_error",status:400,retryable:!1},range_not_satisfiable:{type:"invalid_request_error",status:416,retryable:!1},not_here:{type:"invalid_request_error",status:404,retryable:!1},peer_version_too_old:{type:"invalid_request_error",status:426,retryable:!1},conflict:{type:"invalid_request_error",status:409,retryable:!1},model_sign_in_required:{type:"invalid_request_error",status:409,retryable:!1},invalid_argument:{type:"invalid_request_error",status:400,retryable:!1},machine_required:{type:"invalid_request_error",status:409,retryable:!1},device_offline:{type:"server_error",status:503,retryable:!0},device_timeout:{type:"server_error",status:504,retryable:!0},device_disconnected:{type:"server_error",status:503,retryable:!1},not_found:{type:"invalid_request_error",status:404,retryable:!1},model_unavailable:{type:"invalid_request_error",status:404,retryable:!1},upstream_model_unavailable:{type:"server_error",status:503,retryable:!0},substitution_refused:{type:"invalid_request_error",status:400,retryable:!1},idempotency_conflict:{type:"invalid_request_error",status:409,retryable:!1},run_settled:{type:"invalid_request_error",status:409,retryable:!1},cap_exhausted:{type:"rate_limit_error",status:402,retryable:!1},concurrency_limit:{type:"rate_limit_error",status:429,retryable:!0},all_routes_exhausted:{type:"rate_limit_error",status:429,retryable:!0},provider_rate_limited:{type:"rate_limit_error",status:429,retryable:!0},rate_limited:{type:"rate_limit_error",status:429,retryable:!0},busy:{type:"rate_limit_error",status:429,retryable:!0},runtime_unreachable:{type:"server_error",status:503,retryable:!0},isolated_unavailable:{type:"server_error",status:503,retryable:!0},sandbox_unavailable:{type:"server_error",status:503,retryable:!1},runtime_starting:{type:"server_error",status:503,retryable:!0},runtime_provisioning:{type:"server_error",status:503,retryable:!0},provider_unavailable:{type:"server_error",status:503,retryable:!0},upstream_refused:{type:"server_error",status:502,retryable:!1},provider_bad_response:{type:"server_error",status:502,retryable:!1},service_unavailable:{type:"server_error",status:503,retryable:!0},not_implemented:{type:"server_error",status:501,retryable:!1},permission_error:{type:"permission_error",status:403,retryable:!1},storage_unavailable:{type:"server_error",status:503,retryable:!0},server_error:{type:"server_error",status:500,retryable:!0},server_failure:{type:"server_error",status:500,retryable:!1},wake_timeout:{type:"server_error",status:504,retryable:!0}};export{e as errorCodes};
|
|
1
|
+
const e={unauthorized:{type:"authentication_error",status:401,retryable:!1},machine_revoked:{type:"authentication_error",status:401,retryable:!1},grant_revoked:{type:"authentication_error",status:401,retryable:!1},grant_removed:{type:"authentication_error",status:401,retryable:!1},grant_suspended:{type:"authentication_error",status:401,retryable:!1},refresh_token_expired:{type:"authentication_error",status:401,retryable:!1},refresh_token_reused:{type:"authentication_error",status:401,retryable:!1},scope_missing:{type:"permission_error",status:403,retryable:!1},owner_only:{type:"permission_error",status:403,retryable:!1},other_app_run:{type:"permission_error",status:403,retryable:!1},payer_not_app:{type:"permission_error",status:403,retryable:!1},approval_pending:{type:"permission_error",status:403,retryable:!1},user_denied:{type:"permission_error",status:403,retryable:!1},provider_refused:{type:"permission_error",status:403,retryable:!1},provider_not_connected:{type:"permission_error",status:403,retryable:!1},provider_setup_pending:{type:"permission_error",status:403,retryable:!1},question_pages_off:{type:"permission_error",status:403,retryable:!1},unsandboxed_machine:{type:"permission_error",status:403,retryable:!1},app_not_granted:{type:"permission_error",status:403,retryable:!1},isolated_run:{type:"permission_error",status:403,retryable:!1},provider_version_retired:{type:"permission_error",status:403,retryable:!1},invalid_scope:{type:"invalid_request_error",status:400,retryable:!1},invalid_request:{type:"invalid_request_error",status:400,retryable:!1},range_not_satisfiable:{type:"invalid_request_error",status:416,retryable:!1},not_here:{type:"invalid_request_error",status:404,retryable:!1},peer_version_too_old:{type:"invalid_request_error",status:426,retryable:!1},conflict:{type:"invalid_request_error",status:409,retryable:!1},model_sign_in_required:{type:"invalid_request_error",status:409,retryable:!1},invalid_argument:{type:"invalid_request_error",status:400,retryable:!1},machine_required:{type:"invalid_request_error",status:409,retryable:!1},device_offline:{type:"server_error",status:503,retryable:!0},device_timeout:{type:"server_error",status:504,retryable:!0},device_disconnected:{type:"server_error",status:503,retryable:!1},not_found:{type:"invalid_request_error",status:404,retryable:!1},model_unavailable:{type:"invalid_request_error",status:404,retryable:!1},upstream_model_unavailable:{type:"server_error",status:503,retryable:!0},substitution_refused:{type:"invalid_request_error",status:400,retryable:!1},idempotency_conflict:{type:"invalid_request_error",status:409,retryable:!1},run_settled:{type:"invalid_request_error",status:409,retryable:!1},cap_exhausted:{type:"rate_limit_error",status:402,retryable:!1},concurrency_limit:{type:"rate_limit_error",status:429,retryable:!0},all_routes_exhausted:{type:"rate_limit_error",status:429,retryable:!0},provider_rate_limited:{type:"rate_limit_error",status:429,retryable:!0},rate_limited:{type:"rate_limit_error",status:429,retryable:!0},busy:{type:"rate_limit_error",status:429,retryable:!0},northlight_unreachable:{type:"server_error",status:503,retryable:!0},runtime_unreachable:{type:"server_error",status:503,retryable:!0},isolated_unavailable:{type:"server_error",status:503,retryable:!0},sandbox_unavailable:{type:"server_error",status:503,retryable:!1},runtime_starting:{type:"server_error",status:503,retryable:!0},runtime_provisioning:{type:"server_error",status:503,retryable:!0},provider_unavailable:{type:"server_error",status:503,retryable:!0},upstream_refused:{type:"server_error",status:502,retryable:!1},provider_bad_response:{type:"server_error",status:502,retryable:!1},service_unavailable:{type:"server_error",status:503,retryable:!0},not_implemented:{type:"server_error",status:501,retryable:!1},permission_error:{type:"permission_error",status:403,retryable:!1},storage_unavailable:{type:"server_error",status:503,retryable:!0},server_error:{type:"server_error",status:500,retryable:!0},server_failure:{type:"server_error",status:500,retryable:!1},wake_timeout:{type:"server_error",status:504,retryable:!0}};export{e as errorCodes};
|
package/dist/api/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var r=(t,
|
|
1
|
+
var u=Object.defineProperty;var r=(t,s)=>u(t,"name",{value:s,configurable:!0});class n extends Error{static{r(this,"APIError")}status;code;details;headers;type;param;origin;retryable;retryAfterS;resetAt;requestId;runId;questionId;scope;userAction;constructor(s,i,a,o,d,e){super(a),this.name="APIError",this.status=s,this.code=i,this.headers=new Headers(d),o!==void 0&&(this.details=o),this.type=e?.type,this.param=e?.param,this.origin=e?.origin,this.retryable=e?.retryable,this.retryAfterS=e?.retry_after_s,this.resetAt=e?.reset_at,this.requestId=e?.request_id??this.headers.get("Request-Id")??void 0,this.runId=e?.run_id,this.questionId=e?.question_id,this.scope=e?.scope,this.userAction=e?.user_action}}function h(t){return t instanceof n?t.status===503&&(t.code==="daemon_unavailable"||t.code==="transport_error"||t.code==="daemon_request_interrupted"||t.code==="northlight_unreachable")||t.status===504&&(t.code==="request_timeout"||t.code==="deadline_exceeded")||t.status>=500&&t.code==="daemon_health_unavailable":!1}r(h,"isDaemonTransportApiError");function f(t){return t instanceof n&&t.status===401}r(f,"isTokenRevokedApiError");function _(t){if(typeof t!="object"||t===null)return!1;const s=t.error;if(typeof s!="object"||s===null)return!1;const{code:i,message:a}=s;return typeof i=="string"&&typeof a=="string"}r(_,"isErrorBody");export{n as APIError,n as ApiError,h as isDaemonTransportApiError,_ as isErrorBody,f as isTokenRevokedApiError};
|
package/dist/build-root.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare function declaredExtensibleCoreBranches(): Promise<ReadonlySet<st
|
|
|
22
22
|
export declare function personOnlyInvocation(argv: readonly string[]): string | null;
|
|
23
23
|
/** Select a smaller canonical tree; `runCli` still parses, renders help, and reports errors. */
|
|
24
24
|
export declare function isDaemonControlInvocation(argv: readonly string[]): boolean;
|
|
25
|
+
/** `sys signin` and `sys signout` run when the stored sign-in is gone or a move is unfinished, the states in which the settings load would refuse. */
|
|
26
|
+
export declare function isSignInInvocation(argv: readonly string[]): boolean;
|
|
25
27
|
export declare function isJoinInvocation(argv: readonly string[]): boolean;
|
|
26
28
|
export declare function isLayoutMigrationInvocation(argv: readonly string[]): boolean;
|
|
27
29
|
/** Assemble the canonical daemon-control definitions without loading settings or plugin discovery. This path exists so `crtr sys daemon restart` can start the new generation that converts pre-SQL user state. */
|
|
@@ -52,8 +54,13 @@ export declare function resolveCoreRoot(first: string): Promise<RootDef | null>;
|
|
|
52
54
|
*
|
|
53
55
|
* Order is deterministic: core subtrees in declared order first, then accepted
|
|
54
56
|
* external branches sorted by contributor name (from the unified snapshot).
|
|
55
|
-
* Composition is invocation-local
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
57
|
+
* Composition is invocation-local — no cache, no persistence — and reads only
|
|
58
|
+
* stored manifest bytes, so a plugin enable/update/remove or an HTTP-transport
|
|
59
|
+
* plugin manifest replacement takes effect on the next invocation automatically.
|
|
60
|
+
* The one network read is the granted provider catalog (`GET /v1/providers/tools`)
|
|
61
|
+
* that a sandboxed node, a fleet node and a moved computer ask their control plane
|
|
62
|
+
* or daemon for. On a moved computer a failed read does not abort the tree: the
|
|
63
|
+
* tree is built from what is known locally and the failure rides on the root
|
|
64
|
+
* (`providerCatalogFailure`), which the dispatcher raises in place of
|
|
65
|
+
* `unknown_path` when the person types a top-level name the tree lacks. */
|
|
59
66
|
export declare function buildRoot(): Promise<RootDef>;
|
package/dist/build-root.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U=Object.defineProperty;var n=(e,t)=>U(e,"name",{value:t,configurable:!0});import{defineBranch as q,defineRoot as S,GLOBAL_TOKENS as j}from"./core/command.js";import{createCoreHookCatalog as k}from"./core/command-hooks/catalog.js";import{composeCoreHooks as N}from"./core/command-hooks/compose.js";import{mark as g}from"./core/timing.js";import{ApiError as z}from"./api/errors.js";import{CrtrError as F}from"./core/errors.js";import{envNodeId as J,envScopes as W,isSandboxedNode as P,providerProjectionOverBrokerRelay as $,scopeAllowed as K}from"./shared/env.js";const b="crtr: agentic runtime.",C=[{name:"--json",desc:"stdout as the leaf's declared outputs in raw JSON instead of prose \u2014 for scripts (a cron's bash, external tooling) that must branch on canvas state; prose stays the contract for what you read yourself."}],B=Object.assign(Object.create(null),{doc:n(async()=>(await import("./commands/doc.js")).registerDoc(),"doc"),"custom-object":n(async()=>(await import("./commands/custom-object.js")).registerCustomObject(),"custom-object"),profile:n(async()=>(await import("./commands/profile.js")).registerProfile(),"profile"),pkg:n(async()=>(await import("./commands/pkg.js")).registerPkg(),"pkg"),human:n(async()=>(await import("./commands/human.js")).registerHuman(),"human"),sys:n(async()=>(await import("./commands/sys.js")).registerSys(),"sys"),node:n(async()=>(await import("./commands/node.js")).registerNode(),"node"),push:n(async()=>(await import("./commands/push.js")).registerPush(),"push"),cron:n(async()=>(await import("./commands/cron.js")).registerCron(),"cron"),canvas:n(async()=>(await import("./commands/canvas.js")).registerCanvas(),"canvas"),surface:n(async()=>(await import("./commands/surface.js")).registerSurface(),"surface")}),m=Object.freeze(Object.keys(B)),X={human:["crtr:act"],cron:["crtr:schedule"],doc:["crtr:memory:read:user","crtr:memory:rw:user"]};function L(e){const t=W();return t===null?e:e.filter(r=>{const o=X[r.name];return o===void 0||o.some(s=>K(t,s))||r.name==="doc"&&process.env.CRTR_GRANTEE?.startsWith("app:")===!0})}n(L,"allowedSubtrees");const T=new Map;function A(e){let t=T.get(e);return t===void 0&&(t=B[e](),T.set(e,t)),t}n(A,"loadSubtree");function x(e){return Promise.all(m.filter(t=>e.has(t)).map(A))}n(x,"loadCoreSubtreesNamed");function E(){return x(new Set(m))}n(E,"loadCoreSubtrees");function O(e){const t=new Set;for(const r of e){const o=r.split(" ")[0];m.includes(o)&&t.add(o)}return t}n(O,"subtreesNamedBy");let _;function pe(){return g("cli.hooks.catalog"),_??=E().then(k),_}n(pe,"coreHookCatalog");function M(){let e;return()=>(e??=(async()=>{const{compileHookRegistry:t,declaredCommandHookTargets:r,effectiveHookPlugins:o}=await import("./core/command-hooks/discovery.js"),s=o(),a=P()&&J()!==void 0?await(await import("./core/command-hooks/transport/plan.js")).remoteHookPlan(process.cwd()):[];if(g("cli.hooks.effective_plugins",{count:s.length+a.length}),s.length===0&&a.length===0)return g("cli.hooks.empty_registry"),t(k([]),[]);const c=P()?s.filter(l=>l.scope==="project"):s,i=O([...r(c),...a.map(l=>l.target)]);return g("cli.hooks.catalog",{subtrees:[...i].join(",")}),t(k(await x(i)),c,a)})(),e)}n(M,"hookRegistryLoader");function y(e){const t=new Set,r=n((o,s)=>{if(!(o.kind==="branch"&&o.passthrough!==void 0)&&(t.add(s),o.kind==="branch"))for(const a of o.children)r(a,`${s} ${a.name}`)},"visit");for(const o of e)r(o,o.name);return t}n(y,"commandPathsFor");async function me(){return y(await E())}n(me,"coreCommandPaths");async function fe(e){return y(await x(O(e)))}n(fe,"coreCommandPathsCovering");function Y(e){const t=[],r=n((o,s)=>{o.extensible===!0&&t.push(s);for(const a of o.children)a.kind==="branch"&&r(a,[...s,a.name])},"visit");for(const o of e)r(o,[o.name]);return t}n(Y,"extensibleBranchPaths");const Q=Object.freeze(["human","sys tutorial"]);async function H(){return new Set(Q)}n(H,"extensibleCoreBranches");async function ge(){return new Set(Y(await E()).map(e=>e.join(" ")))}n(ge,"declaredExtensibleCoreBranches");function V(e,t){const{listing:r,...o}=e.help;return q({name:e.name,description:e.description,whenToUse:e.whenToUse,tier:e.tier,help:o,rootEntry:e.rootEntry,extensible:e.extensible,plugin:e.plugin,slash:e.slash,passthrough:e.passthrough,children:t})}n(V,"rebuildBranch");async function I(e,t,r){if(t.size===0)return e;const[{buildExternalCommandSnapshot:o},{composeCoreBranchMounts:s}]=await Promise.all([import("./core/command-plugins/discovery.js"),import("./core/command-plugins/compose.js")]),a=o(new Set(m),void 0,void 0,r,t),c=n((i,l)=>{let f=!1;const h=i.children.map(d=>{if(d.kind!=="branch")return d;const p=c(d,[...l,d.name]);return p!==d&&(f=!0),p}),w=i.extensible===!0?s(a.coreMounts,l):[];return f||w.length>0?V(i,[...h,...w]):i},"composeBranch");return e.map(i=>c(i,[i.name]))}n(I,"composeCorePluginMounts");async function Z(e,t){const{validateEffectiveCommandPlugins:r}=await import("./core/command-plugins/discovery.js"),s=r(new Set(m),void 0,void 0,void 0,t).flatMap(c=>c.manifest===void 0?[]:[c.manifest]).filter(c=>c.coreMounts.some(i=>i.parent[0]===e));if(s.length===0)return null;const a=O(s.flatMap(c=>[...c.coreMounts.map(i=>i.parent.join(" ")),...Object.keys(c.helpAddenda??{})]));return a.add(e),y(await x(a))}n(Z,"dispatchCommandPaths");function v(e,t){const r=e.slice(2).filter(o=>!j.has(o));return r[0]==="sys"&&r[1]===t}n(v,"isSysInvocation");const ee=[["surface"],["sys"],["pkg"],["profile","default"],["canvas","chord"],["canvas","config"],["canvas","use"],["canvas","browse"],["canvas","issue"]],te=[["sys","feedback"]];function D(e,t){return t.every((r,o)=>e[o]===r)}n(D,"startsWithPath");function he(e){const t=e.slice(2).filter(o=>!j.has(o));if(te.some(o=>D(t,o)))return null;const r=ee.find(o=>D(t,o));return r===void 0?null:r.join(" ")}n(he,"personOnlyInvocation");function we(e){return v(e,"daemon")}n(we,"isDaemonControlInvocation");function ye(e){return v(e,"signin")||v(e,"signout")}n(ye,"isSignInInvocation");function ve(e){return v(e,"join")}n(ve,"isJoinInvocation");function Se(e){return v(e,"migrate")}n(Se,"isLayoutMigrationInvocation");async function be(){const{registerDaemonControlSys:e}=await import("./commands/sys/daemon.js");return S({tagline:b,globals:C,subtrees:[e()]})}n(be,"resolveDaemonControlRoot");async function Ce(){const[{defineSysBranch:e},{sysMigrateLeaf:t}]=await Promise.all([import("./commands/sys/branch.js"),import("./commands/sys/migrate.js")]);return S({tagline:b,globals:C,subtrees:[e([t])]})}n(Ce,"resolveLayoutMigrationRoot");async function xe(e){return(e!==void 0?await ne(e):null)??oe()}n(xe,"resolveRoot");async function ne(e){if(B[e]===void 0)return null;const t=await A(e),r=await H(),o=[...r].some(a=>a.split(" ")[0]===e)?await Z(e,r):null,s=L(o===null?[t]:await I([t],r,o));return s.length>0?S({tagline:b,globals:C,subtrees:N(s,M())}):null}n(ne,"resolveCoreRoot");async function oe(){const e=await E(),[{buildExternalCommandSnapshot:t},{composeExternalSubtrees:r,composeSandboxProviderSubtrees:o},{qualifiedTopLevelCommandName:s}]=await Promise.all([import("./core/command-plugins/discovery.js"),import("./core/command-plugins/compose.js"),import("./core/command-manifests/registry.js")]),a=await H(),c=await I(e,a,y(e)),i=t(new Set(m),void 0,void 0,y(e),a);let l=r(i);const f=(await import("./daemon/machine-link/config.js")).readMachineConfig()!==void 0;let h;if(P()||$()||f){const{cliClient:d}=await import("./commands/api-client.js");g("cli.providers.request");let p=[];try{p=(await d().request("GET","/v1/providers/tools")).providers}catch(u){if(!f||!(u instanceof z||u instanceof F))throw u;h=u}g("cli.providers.fetched",{providers:p.length});const R=o(p,new Set(m)),G=new Set(R.map(u=>u.name));l=[...R,...r({...i,contributions:i.contributions.map(u=>G.has(u.node.name)?{...u,node:{...u.node,name:s(u.contributor,u.node.name)}}:u)})]}if(!f){const{previewBranches:d}=await import("./core/northlight/previews.js");l=[...l,...d(process.platform,new Set(l.map(p=>p.name)))]}const w=S({tagline:b,globals:C,subtrees:[...N(L(c),M()),...l]});return h===void 0?w:{...w,providerCatalogFailure:h}}n(oe,"buildRoot");export{Q as EXTENSIBLE_CORE_BRANCHES,m as SUBTREE_NAMES,oe as buildRoot,me as coreCommandPaths,fe as coreCommandPathsCovering,pe as coreHookCatalog,ge as declaredExtensibleCoreBranches,H as extensibleCoreBranches,we as isDaemonControlInvocation,ve as isJoinInvocation,Se as isLayoutMigrationInvocation,ye as isSignInInvocation,he as personOnlyInvocation,ne as resolveCoreRoot,be as resolveDaemonControlRoot,Ce as resolveLayoutMigrationRoot,xe as resolveRoot};
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var R=Object.defineProperty;var s=(r,o)=>R(r,"name",{value:o,configurable:!0});import"./suppress-experimental-warnings.js";import{mkdirSync as
|
|
3
|
-
`,"utf8"),
|
|
4
|
-
`);return}try{if(
|
|
2
|
+
var R=Object.defineProperty;var s=(r,o)=>R(r,"name",{value:o,configurable:!0});import"./suppress-experimental-warnings.js";import{mkdirSync as _,openSync as b,readFileSync as E,renameSync as I,rmSync as C,statSync as g,writeFileSync as A}from"node:fs";import{dirname as h,join as a}from"node:path";import{enableCompileCache as N}from"node:module";import{fileURLToPath as y}from"node:url";import{isDaemonControlInvocation as f,isJoinInvocation as O,isLayoutMigrationInvocation as x,isSignInInvocation as $,personOnlyInvocation as k,resolveDaemonControlRoot as T,resolveLayoutMigrationRoot as P,resolveRoot as F}from"./build-root.js";import{maybeBootRoot as M}from"./core/runtime/front-door.js";import{maybeAutoUpdate as D}from"./core/auto-update.js";import{ensureProjectScope as L}from"./core/bootstrap.js";import{provisionExports as U,pruneLegacyExports as j}from"./core/host-exports/export.js";import{revalidateBundlePlugins as K}from"./core/command-plugins/revalidate.js";import{renderNode as B,runCli as w,walk as J}from"./core/command.js";import{dispatchWithStaleRecovery as V}from"./core/manifest-recovery.js";import{installStdoutErrorPolicy as W}from"./core/stdout-errors.js";import{handle as q}from"./core/io.js";import{CrtrError as m,ownerOnly as G}from"./core/errors.js";import{ExitCode as z}from"./types.js";import{layoutNeedsMigration as H,runtimeRoot as Q}from"./core/layout.js";import{ApiError as v}from"./api/index.js";import{mark as i}from"./core/timing.js";import{launchSnapshotFile as X,sandboxCliNodeId as Y}from"./shared/env.js";import{nodeRunDir as d}from"./core/canvas/paths.js";import{installBrokerConfigSnapshot as Z}from"./core/config.js";b(y(import.meta.url),"r"),W(),i("cli.entry",{cmd:process.argv[2]??"(bare)"});try{N()}catch{}i("cli.compile_cache");const rr=a(h(y(import.meta.url)),".."),l=a(Q(),"first-run.json");function c(r){return(r instanceof Error?r.message:String(r)).split(/\r?\n/,1)[0]??""}s(c,"errorMessage");function or(r){const o=h(l);_(o,{recursive:!0});const t=`${l}.${process.pid}.${Date.now()}.tmp`;try{A(t,JSON.stringify({packageVersion:r,completedAt:new Date().toISOString()})+`
|
|
3
|
+
`,"utf8"),I(t,l)}finally{C(t,{force:!0})}}s(or,"writeFirstRunMarker");async function er(){if(process.env.CRTR_NO_AUTO_INIT==="1")return;try{if(g(l,{throwIfNoEntry:!1})!==void 0)return}catch(o){process.stderr.write(`crtr: first-run reconcile marker check failed: ${c(o)}
|
|
4
|
+
`);return}try{if(g(a(rr,".git"),{throwIfNoEntry:!1})!==void 0)return}catch(o){process.stderr.write(`crtr: first-run reconcile source check failed: ${c(o)}
|
|
5
5
|
`);return}let r;try{const{reconcileFirstRun:o}=await import("./commands/sys/setup-core.js");r=await o((t,p)=>{process.stderr.write(`crtr: first-run reconcile ${t} failed: ${c(p)}
|
|
6
6
|
`)})}catch(o){process.stderr.write(`crtr: first-run reconcile failed: ${c(o)}
|
|
7
|
-
`)}finally{if(r!==void 0)try{
|
|
8
|
-
`)}}}s(
|
|
9
|
-
`);return}await
|
|
10
|
-
`),process.exit(130)),(r instanceof v||r instanceof
|
|
7
|
+
`)}finally{if(r!==void 0)try{or(r)}catch(o){process.stderr.write(`crtr: first-run reconcile marker failed: ${c(o)}
|
|
8
|
+
`)}}}s(er,"maybeReconcileFirstRun");async function tr(){const r=x(process.argv),o=Y(),t=o!==void 0;if(o!==void 0){process.env.CRTR_API_SOCKET=a(d(o),"cli.sock");const e=k(process.argv);if(e!==null)throw G(`crtr ${e} is not available to an app's node`,"Run this command from the person's terminal.");const n=JSON.parse(E(X(d(o))??a(d(o),"broker-launch.json"),"utf8"));if(!n.configSnapshot)throw new Error("node launch is missing its config snapshot");Z(n.configSnapshot)}if(!t&&H()&&!f(process.argv)&&!r)throw new m("layout_migration_required","run crtr sys migrate while the runtime is offline",z.NETWORK,{next:"Run `crtr sys migrate` while the runtime is offline, then restart it."});if(r){const e=await P();if(process.argv.slice(4).some(n=>n==="-h"||n==="--help")){process.stdout.write(B(J(e,["sys","migrate"]).node)+`
|
|
9
|
+
`);return}await w(e,process.argv);return}if(!t&&!f(process.argv)&&!O(process.argv)&&!$(process.argv)){try{await(await import("./commands/person-settings.js")).loadPersonSettingsViaApi()}catch(e){const n=process.argv.slice(2).some(u=>u==="-h"||u==="--help"),S=e instanceof v&&(e.code==="daemon_unavailable"||e.code==="northlight_unreachable")||e instanceof m&&(e.code==="not_signed_in"||e.code==="move_unfinished"||e.code==="northlight_unreachable");if(!(n&&S))throw e;(await import("./core/scoped-state/person-store.js")).installPreludeSnapshot({profiles:[],defaults:{},settings:{},state:{}})}i("cli.settings_loaded")}if(t||(j(process.argv),await er()),await M(process.argv),i("cli.front_door_passed"),f(process.argv)){await w(await T(),process.argv);return}t||await K(process.argv),i("cli.plugins_revalidated");const p=await F(process.argv[2]);i("cli.root_resolved"),t||(U(p,process.argv),await L(process.argv),await D(process.argv)),i("cli.dispatch_start"),await V(p,process.argv),i("cli.dispatch_done")}s(tr,"main"),tr().catch(r=>{(r instanceof Error&&r.name==="AbortError"||r instanceof Error&&/operation was aborted/i.test(r.message))&&(process.stderr.write(`crtr: Interrupted
|
|
10
|
+
`),process.exit(130)),(r instanceof v||r instanceof m)&&(q(r),process.exit(typeof process.exitCode=="number"?process.exitCode:1));const t=r instanceof Error?r.message:String(r);process.stderr.write(`crtr: ${t}
|
|
11
11
|
`),process.exit(1)});
|