@north-light/cli 0.3.606 → 0.3.607
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/clients/attach/viewer.js +504 -504
- package/dist/core/import/bundle/layout.d.ts +4 -5
- package/dist/core/import/bundle/layout.js +3 -4
- package/dist/core/import/export/dump.d.ts +1 -1
- package/dist/core/import/export/dump.js +4 -4
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** `bodies` (revision text, design-fleet D106) is copied like any table but dumped apart: its 667 MB do not fit one row file (
|
|
1
|
+
/** `bodies` (revision text, design-fleet D106) is copied like any table but dumped apart: its 667 MB do not fit one row file (a whole table as one string exceeds V8's string limit), so its rows
|
|
2
2
|
* travel as the part files named in `source.bodyParts` (see `rowKeys`), each written and read a line at a time (`RowFileWriter`, `rowLines`).
|
|
3
3
|
* Every row is canonical: `hash` is the sha256 of `text`, which holds no NUL. The exporter dumps only such rows and the lane refuses a bundle with any other (`stage`). */
|
|
4
4
|
export declare const BODIES_TABLE = "bodies";
|
|
@@ -66,13 +66,12 @@ export type PathMap = readonly PathMapEntry[];
|
|
|
66
66
|
/** Rewrite one path through the map: the longest matching prefix wins; a path under no prefix is returned unchanged. */
|
|
67
67
|
export declare function mapPath(map: PathMap, path: string): string;
|
|
68
68
|
export type RowObject = Record<string, unknown>;
|
|
69
|
-
/** Row-file codec: one JSON object per line, newline-terminated, zstd-compressed
|
|
70
|
-
export declare function encodeRows(rows: Iterable<RowObject>): Buffer;
|
|
69
|
+
/** Row-file codec: one JSON object per line, newline-terminated, zstd-compressed; written by `RowFileWriter`. */
|
|
71
70
|
export declare function decodeRows(data: Buffer | Uint8Array): RowObject[];
|
|
72
71
|
/** One JSON object per line, newline-terminated: the line `RowFileWriter.write` takes. */
|
|
73
72
|
export declare function rowLine(row: RowObject): string;
|
|
74
|
-
/** Writes a row file as a zstd stream, a line at a time, so no string larger than one line exists (
|
|
75
|
-
* ~512 MiB string limit for a large
|
|
73
|
+
/** Writes a row file as a zstd stream, a line at a time, so no string larger than one line exists (a whole file as one string is past V8's
|
|
74
|
+
* ~512 MiB string limit for a large table). `bytes` is the size of the JSON written so far, before compression. */
|
|
76
75
|
export declare class RowFileWriter {
|
|
77
76
|
private readonly zst;
|
|
78
77
|
private readonly finished;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var a=Object.defineProperty;var
|
|
2
|
-
`;return l(Buffer.from(e,"utf8"))}r(j,"encodeRows");function A(s){const e=_(s).toString("utf8");if(e==="")return[];if(!e.endsWith(`
|
|
1
|
+
var a=Object.defineProperty;var o=(s,e)=>a(s,"name",{value:e,configurable:!0});import{once as d}from"node:events";import{createWriteStream as u}from"node:fs";import{pipeline as f}from"node:stream/promises";import{createZstdCompress as m,createZstdDecompress as p,zstdDecompressSync as l}from"node:zlib";const _="bodies",h=["objects","documents","revisions","revision_parents","identities","jobs","custom_objects","context_sessions","environments","object_kinds","edges","watches","watch_subscriptions","exposures","rules","unresolved_links","nodes","sessions","worktrees","node_faults","waits","structured_requests","memory_reads","deleted_isolated_nodes","node_outcome_deliveries","run_events","messages","message_causes","deliveries","crons","cron_runs","daemon_actions","human_requests","human_action_deliveries","review_comments","review_comment_events","audit_rows","app_users","idempotency_keys","uploads","upload_uses","shares","provider_approvals","relations","charges","limits","conversation_parts","conversation_entries","profiles","bodies"],w=["grants"],E=[...h,...w],S={audit_rows:"id",review_comment_events:"seq",app_users:"uid"},z=["objects","revisions","watches","watch_subscriptions","sessions","waits","structured_requests","deliveries","run_events"],c={prefix:o(s=>`imports/${s}/`,"prefix"),rows:o((s,e)=>`imports/${s}/rows/${e}.jsonl.zst`,"rows"),source:o(s=>`imports/${s}/source.json`,"source"),manifest:o(s=>`imports/${s}/manifest.jsonl.zst`,"manifest"),nodeFiles:o((s,e)=>`imports/${s}/node-files/${e}.tar.zst`,"nodeFiles"),bodyRows:o((s,e)=>`imports/${s}/rows/bodies/${e}.jsonl.zst`,"bodyRows"),request:o((s,e)=>`requests/${s}/${e}`,"request")};function $(s,e,t){return e===_?(t.bodyParts??[]).map(r=>c.bodyRows(s,r)):[c.rows(s,e)]}o($,"rowKeys");function L(s,e){let t;for(const r of s)(e===r.from||e.startsWith(r.from.endsWith("/")?r.from:`${r.from}/`))&&(t===void 0||r.from.length>t.from.length)&&(t=r);return t===void 0?e:t.to+e.slice(t.from.length)}o(L,"mapPath");function j(s){const e=l(s).toString("utf8");if(e==="")return[];if(!e.endsWith(`
|
|
3
2
|
`))throw new Error("row file is truncated: the last line is not newline-terminated");return e.slice(0,-1).split(`
|
|
4
|
-
`).map(t=>JSON.parse(t))}
|
|
5
|
-
`}
|
|
3
|
+
`).map(t=>JSON.parse(t))}o(j,"decodeRows");function B(s){return`${JSON.stringify(s)}
|
|
4
|
+
`}o(B,"rowLine");class A{static{o(this,"RowFileWriter")}zst=m();finished;written=0;constructor(e){this.finished=f(this.zst,u(e)),this.finished.catch(()=>{})}get bytes(){return this.written}async write(e,t=Buffer.byteLength(e,"utf8")){this.written+=t,this.zst.write(e,"utf8")||await Promise.race([d(this.zst,"drain"),this.finished])}async close(){this.zst.end(),await this.finished}destroy(){this.zst.destroy()}}async function*D(s){const e=p({chunkSize:1048576});e.end(s);let t=[];for await(const r of e){let n=0;for(let i=r.indexOf(10,n);i!==-1;i=r.indexOf(10,n))t.push(r.subarray(n,i)),yield(t.length===1?t[0]:Buffer.concat(t)).toString("utf8"),t=[],n=i+1;n<r.length&&t.push(r.subarray(n))}if(t.length>0)throw new Error("row file is truncated: the last line is not newline-terminated")}o(D,"rowLines");export{_ as BODIES_TABLE,h as COPIED_TABLES,E as DUMPED_TABLES,S as KEY_MAPPED_TABLES,A as RowFileWriter,z as SEQ_TABLES,w as STAGED_ONLY_TABLES,c as bundleKeys,j as decodeRows,L as mapPath,$ as rowKeys,B as rowLine,D as rowLines};
|
|
@@ -31,4 +31,4 @@ export declare function dumpBodiesPre(out: string): Promise<{
|
|
|
31
31
|
parts: string[];
|
|
32
32
|
count: number;
|
|
33
33
|
}>;
|
|
34
|
-
export declare function dumpRows(out: string, kind: SourceJson['kind']): Promise<DumpResult>;
|
|
34
|
+
export declare function dumpRows(out: string, kind: SourceJson['kind'], maxPageRows?: number): Promise<DumpResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = k.attnum) AS cols FROM pg_constraint c WHERE c.contype = 'p' AND c.connamespace = current_schema()::regnamespace`).all(),
|
|
3
|
-
WHERE d.source_path IS NOT NULL AND NOT EXISTS (SELECT 1 FROM revision_parents p WHERE p.parent = r.rev_id) ORDER BY d.object, r.number DESC, r.rev_id`).all(),
|
|
4
|
-
WHERE n.status IN ('active', 'idle') ORDER BY n.node_id`).all();return
|
|
1
|
+
var K=Object.defineProperty;var o=(e,r)=>K(e,"name",{value:r,configurable:!0});import{mkdirSync as M,readFileSync as $,writeFileSync as Q}from"node:fs";import{join as m}from"node:path";import{openDb as Z,withCanvasWrite as ee}from"../../canvas/db.js";import{hashOf as te}from"../../graph/bodies.js";import{personIdAsync as re}from"../../canvas/person.js";import{CANVAS_SCHEMA_VERSION as ne}from"../../canvas/schema-version.js";import{crtrVersion as ae}from"../../../shared/crtr-version.js";import{BODIES_TABLE as T,DUMPED_TABLES as k,RowFileWriter as v,SEQ_TABLES as oe,bundleKeys as se,rowLine as Y}from"../bundle/layout.js";import{inlineMessageBody as ie}from"./inline.js";const ce=16*1024*1024,le=8*1024*1024,j=32*1024*1024,he=500,W=5e3,N="bodies-pre.json",L=o(e=>`"${e.replace(/"/g,'""')}"`,"q");function de(e){try{const r=$(e,"utf8");return r.trim()===""?null:r}catch(r){if(r.code==="ENOENT")return null;throw r}}o(de,"readText");function pe(e,r){return new Error(`revision text ${e} is ${r} bytes; the import carries at most ${j} bytes of text per body`)}o(pe,"tooLarge");function ue(e){const r=te(e.text);if(r!==e.hash)throw new Error(`body ${e.hash} does not hash to its key (its text hashes to ${r}); upgrade and restart the daemon so its boot repair rekeys the row, then export again`)}o(ue,"assertCanonical");async function H(e,r,s,h){const n=m(r,"rows",T);M(n,{recursive:!0});const f=[];let i=null;const y=o(async()=>{const a=i;i=null,a!==null&&await a.close()},"close"),g=o(async a=>{ue(a);const E=Y(a),c=Buffer.byteLength(E,"utf8");if(i!==null&&i.bytes>0&&i.bytes+c>ce&&await y(),i===null){const d=`${s}-${f.length}`;i=new v(m(n,`${d}.jsonl.zst`)),f.push(d)}await i.write(E,c)},"add");try{for(let a=0;a<h.length;){const E=await e.prepare("SELECT hash, octet_length(text) AS n FROM bodies WHERE hash = ANY(?::text[]) ORDER BY hash").all(h.slice(a,a+W));let c=[],d=0;const R=o(async()=>{if(c.length===0)return;const u=await e.prepare("SELECT hash, text FROM bodies WHERE hash = ANY(?::text[]) ORDER BY hash").all(c);for(const w of u)await g(w);c=[],d=0},"fetchPage");for(const{hash:u,n:w}of E){const p=Number(w);if(p>j)throw pe(u,p);c.length>0&&d+p>le&&await R(),c.push(u),d+=p}await R(),a+=W}await y()}catch(a){throw i?.destroy(),a}return f}o(H,"writeBodyParts");const P=o(async e=>(await e.prepare("SELECT hash FROM bodies ORDER BY hash").all()).map(r=>r.hash),"allHashes");async function Ne(e){const r=await Z(),s=await P(r),h=await H(r,e,"pre",s),n={hashes:s,parts:h,count:s.length,canonical:!0};return Q(m(e,N),JSON.stringify(n)),{parts:h,count:s.length}}o(Ne,"dumpBodiesPre");function Ee(e){try{return JSON.parse($(m(e,N),"utf8"))}catch(r){if(r.code==="ENOENT")return{hashes:[],parts:[],count:0};throw r}}o(Ee,"readPre");function we(e,r){if(e.count===0&&e.parts.length===0)return;if(e.canonical!==!0)throw new Error(`${N} was written before bodies were checked against their keys; discard the export directory and run the pre-pause dump again`);const s=e.hashes.filter(h=>!r.has(h));if(s.length>0)throw new Error(`the pre-pause dump holds ${s.length} body row(s) the database no longer has (first: ${s[0]}); the boot repair ran after it. Discard the export directory and run the pre-pause dump again`)}o(we,"assertPreCurrent");async function Le(e,r,s=he){const h=await re();return M(m(e,"rows"),{recursive:!0}),ee(async n=>{await n.exec("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ");const f=new Set((await n.prepareUncached("SELECT table_name FROM information_schema.tables WHERE table_schema = current_schema()").all()).map(t=>t.table_name)),i=k.filter(t=>!f.has(t));if(i.length>0)throw new Error(`the canvas database lacks tables the bundle needs: ${i.join(", ")}`);const y=await n.prepareUncached(`SELECT c.conrelid::regclass::text AS tbl, (SELECT array_agg(a.attname::text ORDER BY k.ord) FROM unnest(c.conkey) WITH ORDINALITY k(attnum, ord)
|
|
2
|
+
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = k.attnum) AS cols FROM pg_constraint c WHERE c.contype = 'p' AND c.connamespace = current_schema()::regnamespace`).all(),g=new Map(y.map(t=>[t.tbl.replace(/"/g,"").replace(/^.*\./,""),t.cols])),a=await n.prepareUncached("SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = current_schema() ORDER BY table_name, ordinal_position").all(),E=new Set(oe),c={};let d=0,R=0;for(const t of k.filter(_=>_!==T)){const _=E.has(t)?["seq"]:g.get(t),D=_!==void 0&&_.length>0?_.map(l=>`t.${L(l)}`):a.filter(l=>l.table_name===t).map(l=>`t.${L(l.column_name)}::text`);if(D.length===0)throw new Error(`table ${t} has no columns to order its dump by`);const b=new v(m(e,se.rows("",t).replace(/^imports\/\//,"")));let x=0;try{for(await n.exec(`DECLARE dump_cursor NO SCROLL CURSOR FOR SELECT row_to_json(t)::text AS j FROM ${L(t)} t ORDER BY ${D.join(", ")}`);;){const l=await n.prepareUncached(`FETCH FORWARD ${s} FROM dump_cursor`).all();for(const G of l){let O=JSON.parse(G.j);if(t==="messages"){const F=O.body_ref,I=ie(O,de);typeof F=="string"&&F.startsWith("/")&&(I===O?R+=1:d+=1),O=I}await b.write(Y(O))}if(x+=l.length,l.length<s)break}await n.exec("CLOSE dump_cursor"),await b.close()}catch(l){throw b.destroy(),l}c[t]=x}const u=(await n.prepare("SELECT value FROM canvas_meta WHERE key = 'install_id'").get())?.value;if(u===void 0)throw new Error("this canvas database has no install id");const w=await n.prepare("SELECT object FROM environments WHERE kind = 'machine' ORDER BY object LIMIT 1").get(),p={installId:u,kind:r,person:h,release:ae(),schemaVersion:ne,counts:c,...w===void 0?{}:{environmentObject:w.object}},q=await n.prepare("SELECT request_id, request_dir, file FROM human_requests ORDER BY request_id").all(),J=await n.prepare(`SELECT d.object, r.body_hash FROM documents d JOIN revisions r ON r.document = d.object
|
|
3
|
+
WHERE d.source_path IS NOT NULL AND NOT EXISTS (SELECT 1 FROM revision_parents p WHERE p.parent = r.rev_id) ORDER BY d.object, r.number DESC, r.rev_id`).all(),A={};for(const t of J)A[t.object]??=t.body_hash;const S=Ee(e),U=new Set(S.hashes),C=await P(n);we(S,new Set(C));const B=C.filter(t=>!U.has(t)),V=await H(n,e,"pause",B),z=S.count+B.length;c[T]=z,p.bodyParts=[...S.parts,...V];const X=await n.prepare(`SELECT n.node_id, r.grantee, n.cwd, w.path AS worktree FROM nodes n JOIN node_rows r ON r.node_id = n.node_id LEFT JOIN worktrees w ON w.node_id = n.node_id AND w.state = 'open'
|
|
4
|
+
WHERE n.status IN ('active', 'idle') ORDER BY n.node_id`).all();return p.shippedBodies=A,{source:p,requests:q.map(t=>({id:t.request_id,dir:t.request_dir,file:t.file})),runningNodes:X.map(t=>({node:t.node_id,app:t.grantee,cwd:t.cwd,worktree:t.worktree})),bodiesInlined:d,bodiesMissing:R}})}o(Le,"dumpRows");export{j as BODY_MAX_BYTES,ce as PART_JSON_BYTES,Ne as dumpBodiesPre,Le as dumpRows};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.607",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
},
|
|
146
146
|
"license": "UNLICENSED",
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@north-light/identity": "0.3.
|
|
148
|
+
"@north-light/identity": "0.3.607",
|
|
149
149
|
"@earendil-works/chord": "1.1.0",
|
|
150
150
|
"@earendil-works/pi-agent-core": "1.1.0",
|
|
151
151
|
"@earendil-works/pi-ai": "1.1.0",
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.607",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.607",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.607",
|
|
32
32
|
"cron-parser": "^5.6.0",
|
|
33
33
|
"esbuild": "^0.27.7",
|
|
34
34
|
"jose": "^6.2.12",
|
|
@@ -11956,17 +11956,17 @@
|
|
|
11956
11956
|
},
|
|
11957
11957
|
"packages/crouter-api": {
|
|
11958
11958
|
"name": "@north-light/api",
|
|
11959
|
-
"version": "0.3.
|
|
11959
|
+
"version": "0.3.607",
|
|
11960
11960
|
"license": "UNLICENSED"
|
|
11961
11961
|
},
|
|
11962
11962
|
"packages/crouter-env-docker": {
|
|
11963
11963
|
"name": "@north-light/env-docker",
|
|
11964
|
-
"version": "0.3.
|
|
11964
|
+
"version": "0.3.607",
|
|
11965
11965
|
"license": "UNLICENSED"
|
|
11966
11966
|
},
|
|
11967
11967
|
"packages/crouter-identity": {
|
|
11968
11968
|
"name": "@north-light/identity",
|
|
11969
|
-
"version": "0.3.
|
|
11969
|
+
"version": "0.3.607",
|
|
11970
11970
|
"license": "UNLICENSED",
|
|
11971
11971
|
"dependencies": {
|
|
11972
11972
|
"jose": "^6.2.1"
|
|
@@ -11974,21 +11974,21 @@
|
|
|
11974
11974
|
},
|
|
11975
11975
|
"packages/crouter-plugin": {
|
|
11976
11976
|
"name": "@north-light/plugin",
|
|
11977
|
-
"version": "0.3.
|
|
11977
|
+
"version": "0.3.607",
|
|
11978
11978
|
"license": "UNLICENSED",
|
|
11979
11979
|
"dependencies": {
|
|
11980
|
-
"@north-light/api": "0.3.
|
|
11981
|
-
"@north-light/identity": "0.3.
|
|
11980
|
+
"@north-light/api": "0.3.607",
|
|
11981
|
+
"@north-light/identity": "0.3.607"
|
|
11982
11982
|
}
|
|
11983
11983
|
},
|
|
11984
11984
|
"packages/crouter-sdk": {
|
|
11985
11985
|
"name": "@north-light/sdk",
|
|
11986
|
-
"version": "0.3.
|
|
11986
|
+
"version": "0.3.607",
|
|
11987
11987
|
"license": "UNLICENSED",
|
|
11988
11988
|
"dependencies": {
|
|
11989
|
-
"@north-light/api": "0.3.
|
|
11990
|
-
"@north-light/identity": "0.3.
|
|
11991
|
-
"@north-light/plugin": "0.3.
|
|
11989
|
+
"@north-light/api": "0.3.607",
|
|
11990
|
+
"@north-light/identity": "0.3.607",
|
|
11991
|
+
"@north-light/plugin": "0.3.607",
|
|
11992
11992
|
"jose": "^6.2.1"
|
|
11993
11993
|
},
|
|
11994
11994
|
"bin": {
|