@north-light/crouter 0.3.354 → 0.3.356

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.
Files changed (104) hide show
  1. package/dist/api/dto/delivery.d.ts +13 -3
  2. package/dist/api/dto/docs.d.ts +2 -0
  3. package/dist/api/dto/objects.d.ts +25 -22
  4. package/dist/api/dto/objects.js +1 -1
  5. package/dist/api/dto/reviews.d.ts +6 -4
  6. package/dist/builtin-memory/02-turn-lifecycle/02-resident.md +1 -0
  7. package/dist/builtin-memory/04-orchestration-kernel.md +10 -31
  8. package/dist/builtin-memory/internal/memory-loading.md +1 -1
  9. package/dist/clients/attach/overlays/file-review.d.ts +1 -0
  10. package/dist/clients/attach/overlays/file-review.js +2 -2
  11. package/dist/clients/attach/render/chat-view.d.ts +6 -0
  12. package/dist/clients/attach/render/chat-view.js +2 -2
  13. package/dist/clients/attach/render/doc-links.d.ts +34 -0
  14. package/dist/clients/attach/render/doc-links.js +1 -0
  15. package/dist/clients/attach/render/markdown-source.js +5 -5
  16. package/dist/clients/attach/session/doc-materialize.d.ts +53 -0
  17. package/dist/clients/attach/session/doc-materialize.js +3 -0
  18. package/dist/clients/attach/session/document-links.d.ts +21 -0
  19. package/dist/clients/attach/session/document-links.js +1 -0
  20. package/dist/clients/attach/session/file-links.d.ts +2 -0
  21. package/dist/clients/attach/session/file-links.js +1 -1
  22. package/dist/clients/attach/viewer.js +837 -761
  23. package/dist/clients/inbox/review/review-client.d.ts +5 -1
  24. package/dist/clients/inbox/review/review-client.js +1 -1
  25. package/dist/commands/canvas/list.js +3 -3
  26. package/dist/commands/canvas/read.d.ts +2 -4
  27. package/dist/commands/canvas/read.js +3 -5
  28. package/dist/commands/canvas/search.js +1 -1
  29. package/dist/commands/doc/write.js +1 -1
  30. package/dist/commands/node/lifecycle.js +2 -2
  31. package/dist/commands/sys/context/admin/actions.js +1 -1
  32. package/dist/commands/sys/sync-deps.js +1 -1
  33. package/dist/commands/sys/sync-shared.js +1 -1
  34. package/dist/core/canvas/daemon-actions.d.ts +43 -0
  35. package/dist/core/canvas/daemon-actions.js +26 -0
  36. package/dist/core/canvas/deliveries.d.ts +1 -0
  37. package/dist/core/canvas/deliveries.js +1 -1
  38. package/dist/core/canvas/migrations.js +106 -46
  39. package/dist/core/feed/messages.d.ts +2 -20
  40. package/dist/core/feed/messages.js +6 -10
  41. package/dist/core/graph/deletion.d.ts +5 -4
  42. package/dist/core/graph/deletion.js +3 -3
  43. package/dist/core/graph/documents.d.ts +8 -1
  44. package/dist/core/graph/documents.js +9 -6
  45. package/dist/core/graph/edges.d.ts +3 -2
  46. package/dist/core/graph/edges.js +1 -1
  47. package/dist/core/graph/events.d.ts +11 -6
  48. package/dist/core/graph/events.js +5 -4
  49. package/dist/core/graph/jobs.js +2 -2
  50. package/dist/core/graph/kinds/document.d.ts +19 -0
  51. package/dist/core/graph/kinds/document.js +5 -0
  52. package/dist/core/graph/kinds/dto.d.ts +5 -0
  53. package/dist/core/graph/kinds/dto.js +1 -0
  54. package/dist/core/graph/kinds/job.d.ts +2 -0
  55. package/dist/core/graph/kinds/job.js +2 -0
  56. package/dist/core/graph/kinds/kind.d.ts +39 -0
  57. package/dist/core/graph/kinds/kind.js +1 -0
  58. package/dist/core/graph/kinds/node.d.ts +2 -0
  59. package/dist/core/graph/kinds/node.js +4 -0
  60. package/dist/core/graph/kinds/owner.d.ts +2 -0
  61. package/dist/core/graph/kinds/owner.js +2 -0
  62. package/dist/core/graph/kinds/registry.d.ts +8 -0
  63. package/dist/core/graph/kinds/registry.js +1 -0
  64. package/dist/core/graph/kinds/render.d.ts +9 -0
  65. package/dist/core/graph/kinds/render.js +1 -0
  66. package/dist/core/graph/names.d.ts +3 -1
  67. package/dist/core/graph/names.js +3 -3
  68. package/dist/core/graph/objects.d.ts +5 -4
  69. package/dist/core/graph/objects.js +5 -5
  70. package/dist/core/graph/repo-sync/exchange.js +2 -2
  71. package/dist/core/graph/types.d.ts +6 -5
  72. package/dist/core/runs/operations.js +5 -5
  73. package/dist/core/runtime/broker-persona-guidance.js +2 -2
  74. package/dist/core/runtime/broker-protocol.d.ts +2 -7
  75. package/dist/core/runtime/persona.js +2 -2
  76. package/dist/core/runtime/roadmap.d.ts +3 -0
  77. package/dist/core/runtime/roadmap.js +8 -4
  78. package/dist/core/substrate/delivery/deliver.js +1 -1
  79. package/dist/core/substrate/delivery/listings.d.ts +3 -0
  80. package/dist/core/substrate/delivery/listings.js +5 -2
  81. package/dist/core/substrate/delivery/render-boot.js +26 -26
  82. package/dist/core/substrate/delivery/render-event.d.ts +13 -6
  83. package/dist/core/substrate/delivery/render-event.js +6 -4
  84. package/dist/daemon/api/handlers/docs.js +1 -1
  85. package/dist/daemon/api/handlers/human-requests.js +1 -1
  86. package/dist/daemon/api/handlers/objects.js +2 -5
  87. package/dist/daemon/api/handlers/reviews.d.ts +4 -1
  88. package/dist/daemon/api/handlers/reviews.js +1 -1
  89. package/dist/daemon/cron/settle.js +1 -1
  90. package/dist/daemon/cron/sinks.d.ts +3 -3
  91. package/dist/daemon/cron/sinks.js +2 -2
  92. package/dist/daemon/crtrd.js +6 -6
  93. package/dist/daemon/human/finish.js +6 -6
  94. package/dist/daemon/human/settle.d.ts +2 -3
  95. package/dist/daemon/human/settle.js +1 -1
  96. package/dist/daemon/reconcilers/action-lane.d.ts +8 -0
  97. package/dist/daemon/reconcilers/action-lane.js +1 -0
  98. package/dist/daemon/reconcilers/delivery-lane.d.ts +1 -1
  99. package/dist/daemon/reconcilers/delivery-lane.js +1 -1
  100. package/dist/shared/inbox-entry-body.js +7 -7
  101. package/package.json +2 -2
  102. package/packages/crouter-identity/package.json +1 -1
  103. package/runtime.lock.json +11 -11
  104. package/scripts/lib/isolation-env.mjs +8 -2
@@ -0,0 +1,53 @@
1
+ /** Environment variable carrying the edited document path to the reattached viewer. */
2
+ export declare const DOC_SAVEBACK_ENV = "CRTR_ATTACH_DOC_SAVEBACK";
3
+ /** The document a materialized file was read from. */
4
+ export interface MaterializedDoc {
5
+ /** The ref as the transcript wrote it (no brackets). */
6
+ ref: string;
7
+ id: string;
8
+ /** Canonical `<owner>/<name>` (or the ref when no owner). */
9
+ name: string;
10
+ revision: number;
11
+ /** The heads the body was read at — the base a save-back is made from. */
12
+ heads_key: string;
13
+ /** sha256 of the body as written. */
14
+ sha256: string;
15
+ }
16
+ /** The subset of a document read this module needs. */
17
+ export interface DocumentSnapshot {
18
+ id: string;
19
+ name: string;
20
+ revision: number;
21
+ heads_key: string;
22
+ body: string;
23
+ }
24
+ export declare function docMaterializeRoot(): string;
25
+ /** Write the snapshot's body to its stable path (idempotent) and return the path.
26
+ * An existing file at that path is kept: it may hold the person's unsaved edit. */
27
+ export declare function materializeDocument(ref: string, snap: DocumentSnapshot, root?: string): string;
28
+ /** The document a local path was materialized from, or undefined for a plain file. */
29
+ export declare function documentForPath(path: string, root?: string): MaterializedDoc | undefined;
30
+ /** Save a person's edit of a materialized document. */
31
+ export type DocSaveOutcome = {
32
+ outcome: 'unchanged';
33
+ } | {
34
+ outcome: 'saved';
35
+ revision: number;
36
+ } | {
37
+ outcome: 'stale';
38
+ path: string;
39
+ } | {
40
+ outcome: 'missing';
41
+ } | {
42
+ outcome: 'failed';
43
+ message: string;
44
+ };
45
+ /** The document write the save-back uses: `crtr doc edit`'s body replacement,
46
+ * made from an explicit base. Resolves `stale` rather than throwing on a
47
+ * moved document. */
48
+ export type DocEditFn = (id: string, body: string, base: string) => Promise<{
49
+ revision: number;
50
+ } | 'stale'>;
51
+ export declare function saveDocumentEdit(path: string, edit: DocEditFn, root?: string): Promise<DocSaveOutcome>;
52
+ /** The notice a save-back outcome shows, or undefined for none. */
53
+ export declare function saveOutcomeNotice(name: string, outcome: DocSaveOutcome): string | undefined;
@@ -0,0 +1,3 @@
1
+ var l=Object.defineProperty;var o=(e,t)=>l(e,"name",{value:t,configurable:!0});import{createHash as S}from"node:crypto";import{existsSync as d,mkdirSync as $,readFileSync as y,renameSync as _,writeFileSync as p}from"node:fs";import{tmpdir as x}from"node:os";import{basename as A,dirname as g,join as c}from"node:path";const N="CRTR_ATTACH_DOC_SAVEBACK",a=".crtr-doc.json";function u(){return c(x(),"crtr-docs")}o(u,"docMaterializeRoot");const f=o(e=>S("sha256").update(e).digest("hex"),"sha");function h(e){return e.replace(/[^A-Za-z0-9._-]/g,"_").slice(0,120)||"doc"}o(h,"safeSegment");function b(e,t,r=u()){const n=c(r,h(t.id),`r${t.revision}`),s=c(n,`${h(A(t.name))}.md`),i=c(n,a);if(d(s)&&d(i))return s;$(n,{recursive:!0});const v={ref:e,id:t.id,name:t.name,revision:t.revision,heads_key:t.heads_key,sha256:f(t.body)};return m(s,t.body),m(i,`${JSON.stringify(v)}
2
+ `),s}o(b,"materializeDocument");function m(e,t){const r=`${e}.${process.pid}.tmp`;p(r,t),_(r,e)}o(m,"writeAtomic");function C(e,t=u()){if(e.startsWith(`${t}/`))try{const r=JSON.parse(y(c(g(e),a),"utf8"));return typeof r.id=="string"&&typeof r.heads_key=="string"?r:void 0}catch{return}}o(C,"documentForPath");async function R(e,t,r=u()){const n=C(e,r);if(n===void 0||!d(e))return{outcome:"missing"};const s=y(e,"utf8");if(f(s)===n.sha256)return{outcome:"unchanged"};try{const i=await t(n.id,s,n.heads_key);return i==="stale"?{outcome:"stale",path:e}:(m(c(g(e),a),`${JSON.stringify({...n,sha256:f(s)})}
3
+ `),{outcome:"saved",revision:i.revision})}catch(i){return{outcome:"failed",message:i instanceof Error?i.message:String(i)}}}o(R,"saveDocumentEdit");function z(e,t){switch(t.outcome){case"unchanged":return;case"saved":return`Saved ${e} as revision ${t.revision}`;case"stale":return`${e} changed while you edited it \u2014 not saved; your text is kept at ${t.path}`;case"missing":return`Could not find the edited copy of ${e}`;case"failed":return`Could not save ${e}: ${t.message}`}}o(z,"saveOutcomeNotice");export{N as DOC_SAVEBACK_ENV,u as docMaterializeRoot,C as documentForPath,b as materializeDocument,R as saveDocumentEdit,z as saveOutcomeNotice};
@@ -0,0 +1,21 @@
1
+ import type { CanvasSource } from '../../../core/canvas/source.js';
2
+ export interface DocumentLinks {
3
+ /** Whether a clicked local path is a materialized document. */
4
+ isDocumentPath(path: string): boolean;
5
+ /** Re-read a clicked document and return the path to open (its current revision). */
6
+ prepareOpen(path: string): Promise<{
7
+ path: string;
8
+ } | {
9
+ notice: string;
10
+ }>;
11
+ /** The save-back a reattaching viewer was handed, if any. */
12
+ consumeSaveBack(notify: (message: string) => void): Promise<void>;
13
+ dispose(): void;
14
+ }
15
+ export declare function createDocumentLinks(opts: {
16
+ selfNodeId: string;
17
+ remote: boolean;
18
+ canvasSource: CanvasSource;
19
+ /** Re-render the transcript's Markdown after a name or path lands. */
20
+ refresh: () => void;
21
+ }): DocumentLinks;
@@ -0,0 +1 @@
1
+ var k=Object.defineProperty;var i=(n,o)=>k(n,"name",{value:o,configurable:!0});import{APIError as C}from"../../../api/errors.js";import{cliClient as v}from"../../../commands/api-client.js";import{setDocLinkContext as y}from"../render/doc-links.js";import{DOC_SAVEBACK_ENV as g,documentForPath as h,materializeDocument as b,saveDocumentEdit as E,saveOutcomeNotice as L}from"./doc-materialize.js";async function w(n){const o=await v().objects.read(n);if(o.state!=="object"||o.type!=="document")return`${n} is not a readable document`;const a=o.data;if(a.needs_merge||a.bodies.length!==1)return`${n} has ${a.heads.length} heads and needs a merge`;const s=o.object.owner?.handle;return{id:o.object.id,name:s===void 0?o.object.name:`${s}/${o.object.name}`,revision:a.revision,heads_key:a.heads.map(d=>d.rev_id).sort().join(","),body:a.bodies[0]}}i(w,"readSnapshot");function z(n){const o=new Map,a=new Map,s=new Set,d=new Set;let m=!1,f=!1,l=!1;const j=i(()=>{m||f||(f=!0,n.canvasSource.listNodes().then(t=>{for(const e of t)o.set(e.node_id,e.name);m=!0,l||n.refresh()}).catch(()=>{m=!0}).finally(()=>{f=!1}))},"loadRoster"),N=i(t=>{n.remote||s.has(t)||d.has(t)||(s.add(t),w(t).then(e=>{if(typeof e=="string"){d.add(t);return}a.set(t,b(t,e)),l||n.refresh()}).catch(()=>{d.add(t)}).finally(()=>{s.delete(t)}))},"materialize"),S={selfNodeId:n.selfNodeId,nodeName:i(t=>{const e=o.get(t);return e===void 0&&j(),e},"nodeName"),pathFor:i(t=>{const e=a.get(t);return e===void 0&&N(t),e},"pathFor")};return y(S),{isDocumentPath:i(t=>h(t)!==void 0,"isDocumentPath"),async prepareOpen(t){if(n.remote)return{notice:"Opening a document is unavailable in a remote attach"};const e=h(t);if(e===void 0)return{notice:"Not a document link"};try{const r=await w(e.id);if(typeof r=="string")return{notice:r};const c=b(e.ref,r);return a.set(e.ref,c),{path:c}}catch(r){return{notice:`Could not read ${e.name}: ${r instanceof Error?r.message:String(r)}`}}},async consumeSaveBack(t){const e=process.env[g];if(e===void 0||e==="")return;delete process.env[g];const r=h(e),c=await E(e,async(_,$,D)=>{try{return{revision:(await v().docs.edit(_,{body:$,base:D,rationale:"edited by the person in the attach viewer"})).revision}}catch(u){if(u instanceof C&&u.code==="stale_revision")return"stale";throw u}}),p=L(r?.name??e,c);p!==void 0&&t(p)},dispose(){l=!0,y(void 0)}}}i(z,"createDocumentLinks");export{z as createDocumentLinks};
@@ -17,6 +17,8 @@ export declare function openLinkedFileInPane(opts: {
17
17
  cwd: string;
18
18
  nodeId: string;
19
19
  observer: boolean;
20
+ /** A materialized canvas document: the reattaching viewer saves its edit back. */
21
+ saveBackEnv?: string;
20
22
  /** Clear viewer-local pane identity immediately before the pane runs Neovim. */
21
23
  beforeRespawn: () => void;
22
24
  }): LinkedFileOpenResult;
@@ -1 +1 @@
1
- var o=Object.defineProperty;var r=(e,n)=>o(e,"name",{value:n,configurable:!0});import{existsSync as s}from"node:fs";import{respawnPaneInBackground as u,shellQuote as c,viewerSplitEnv as l}from"../../../core/runtime/placement-tmux.js";const d="\x1B_crtr-file-open;",f="\x1B\\";function P(e){const n=e.indexOf(d);if(n===-1)return;const t=n+d.length,i=e.indexOf(f,t);return i===-1?void 0:{file:h(e.slice(t,i)),remaining:e.slice(0,n)+e.slice(i+f.length)}}r(P,"extractFileOpenInput");function h(e){const n=e.startsWith("'")?x(e):a(e);return n!==void 0&&n.startsWith("/")&&!/[\x00-\x1f\x7f]/.test(n)?n:void 0}r(h,"decodeShellEscapedPath");function x(e){let n="",t=1;for(;;){const i=e.indexOf("'",t);if(i===-1)return;if(n+=e.slice(t,i),t=i+1,t===e.length)return n;if(e.slice(t,t+3)!=="\\''")return;n+="'",t+=3}}r(x,"decodeSingleQuotedPath");function a(e){let n="";for(let t=0;t<e.length;t++){if(e[t]!=="\\"){n+=e[t];continue}const i=e[++t];if(i===void 0)return;n+=i}return n}r(a,"decodeBackslashPath");function w(e){if(!s(e.file))return"missing";const n=`crtr surface attach to ${c(e.nodeId)}${e.observer?" --observer":""}`,t=`nvim ${c(e.file)} || :; exec ${n}`;return e.beforeRespawn(),u({pane:e.pane,cwd:e.cwd,env:l(),command:t})?"opened":"failed"}r(w,"openLinkedFileInPane");export{P as extractFileOpenInput,w as openLinkedFileInPane};
1
+ var s=Object.defineProperty;var r=(e,n)=>s(e,"name",{value:n,configurable:!0});import{existsSync as o}from"node:fs";import{respawnPaneInBackground as u,shellQuote as c,viewerSplitEnv as l}from"../../../core/runtime/placement-tmux.js";const d="\x1B_crtr-file-open;",f="\x1B\\";function I(e){const n=e.indexOf(d);if(n===-1)return;const t=n+d.length,i=e.indexOf(f,t);return i===-1?void 0:{file:a(e.slice(t,i)),remaining:e.slice(0,n)+e.slice(i+f.length)}}r(I,"extractFileOpenInput");function a(e){const n=e.startsWith("'")?h(e):x(e);return n!==void 0&&n.startsWith("/")&&!/[\x00-\x1f\x7f]/.test(n)?n:void 0}r(a,"decodeShellEscapedPath");function h(e){let n="",t=1;for(;;){const i=e.indexOf("'",t);if(i===-1)return;if(n+=e.slice(t,i),t=i+1,t===e.length)return n;if(e.slice(t,t+3)!=="\\''")return;n+="'",t+=3}}r(h,"decodeSingleQuotedPath");function x(e){let n="";for(let t=0;t<e.length;t++){if(e[t]!=="\\"){n+=e[t];continue}const i=e[++t];if(i===void 0)return;n+=i}return n}r(x,"decodeBackslashPath");function P(e){if(!o(e.file))return"missing";const n=`crtr surface attach to ${c(e.nodeId)}${e.observer?" --observer":""}`,t=e.saveBackEnv===void 0?"":`env ${e.saveBackEnv}=${c(e.file)} `,i=`nvim ${c(e.file)} || :; exec ${t}${n}`;return e.beforeRespawn(),u({pane:e.pane,cwd:e.cwd,env:l(),command:i})?"opened":"failed"}r(P,"openLinkedFileInPane");export{I as extractFileOpenInput,P as openLinkedFileInPane};