@north-light/cli 0.3.712 → 0.3.713
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/input/controller.d.ts +6 -0
- package/dist/clients/attach/input/controller.js +3 -3
- package/dist/clients/attach/input/local-files.d.ts +16 -0
- package/dist/clients/attach/input/local-files.js +6 -0
- package/dist/clients/attach/session/editor-frame.d.ts +2 -2
- package/dist/clients/attach/session/editor-frame.js +1 -1
- package/dist/clients/attach/viewer.js +406 -402
- package/dist/commands/node/bash.js +1 -1
- package/dist/core/bash-guard.d.ts +10 -0
- package/dist/core/bash-guard.js +4 -4
- package/dist/core/broker-client/client.d.ts +2 -2
- package/dist/core/conversation-store/row-store.js +1 -1
- package/dist/core/graph/documents.d.ts +5 -5
- package/dist/core/graph/documents.js +9 -9
- package/dist/core/graph/kinds/custom.js +2 -2
- package/dist/core/graph/kinds/document.js +4 -4
- package/dist/core/graph/kinds/environment.js +2 -2
- package/dist/core/graph/kinds/job.js +2 -2
- package/dist/core/graph/kinds/kind.d.ts +9 -1
- package/dist/core/graph/kinds/live-read.d.ts +4 -2
- package/dist/core/graph/kinds/live-read.js +1 -1
- package/dist/core/graph/kinds/node.js +5 -5
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/runtime/bearings-render.d.ts +3 -0
- package/dist/core/runtime/bearings-render.js +7 -7
- package/dist/core/runtime/bearings.js +5 -5
- package/dist/core/runtime/broker/frame-dispatch.js +1 -1
- package/dist/core/runtime/broker/frame-read.d.ts +5 -1
- package/dist/core/runtime/broker/frame-read.js +1 -1
- package/dist/core/runtime/broker-protocol.d.ts +37 -2
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/llm.js +3 -3
- package/dist/daemon/api/handlers/objects.js +3 -3
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/map.d.ts +6 -0
- package/dist/daemon/api/map.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/docs/ci-runner.md +4 -4
- package/package.json +3 -3
- package/packages/crouter-api/dist/clients/attach/input/controller.js +43 -12
- package/packages/crouter-api/dist/clients/attach/input/local-files.js +97 -0
- package/packages/crouter-api/dist/clients/attach/session/editor-frame.js +27 -8
- package/packages/crouter-api/dist/commands/node/bash.js +2 -2
- package/packages/crouter-api/dist/core/bash-guard.js +1 -1
- package/packages/crouter-api/dist/core/conversation-store/row-store.js +1 -1
- package/packages/crouter-api/dist/core/graph/documents.js +12 -24
- package/packages/crouter-api/dist/core/graph/kinds/custom.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/document.js +8 -25
- package/packages/crouter-api/dist/core/graph/kinds/environment.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/job.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/node.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/owner.js +1 -3
- package/packages/crouter-api/dist/core/runtime/bearings-render.js +11 -0
- package/packages/crouter-api/dist/core/runtime/bearings.js +6 -2
- package/packages/crouter-api/dist/daemon/api/handlers/broker-ops.js +5 -5
- package/packages/crouter-api/dist/daemon/api/map.js +1 -1
- package/packages/crouter-api/dist/{clients/attach/chrome/git-info.js → shared/git-status.js} +5 -5
- 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/packages/crouter-api/dist/core/graph/kinds/live-read.js +0 -11
- /package/dist/{clients/attach/chrome/git-info.d.ts → shared/git-status.d.ts} +0 -0
- /package/dist/{clients/attach/chrome/git-info.js → shared/git-status.js} +0 -0
|
@@ -85,6 +85,12 @@ export declare class InputController {
|
|
|
85
85
|
* submission that classified out. */
|
|
86
86
|
private recordCompletionUse;
|
|
87
87
|
private handleSubmit;
|
|
88
|
+
/** Send one message through `deliver`, with `sent` run and the editor cleared
|
|
89
|
+
* exactly once it is accepted. A message naming files on this machine (when
|
|
90
|
+
* `files` allows it and a broker can take them) clears the editor first, sends
|
|
91
|
+
* each file to the node, then delivers the rewritten text; a refused delivery
|
|
92
|
+
* puts the typed text back. */
|
|
93
|
+
private sendMessage;
|
|
88
94
|
private handleFollowUp;
|
|
89
95
|
private handleDequeue;
|
|
90
96
|
private emitDrive;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
1
|
+
var p=Object.defineProperty;var r=(l,e)=>p(l,"name",{value:e,configurable:!0});import{spawn as u}from"node:child_process";import{readFileSync as f,unlinkSync as k,writeFileSync as g}from"node:fs";import{tmpdir as y}from"node:os";import{join as P}from"node:path";import{BROKER_READ_CAPS as v,encodeFrame as S}from"../../../core/runtime/broker-protocol.js";import{classifySubmit as x}from"../../conversation/submit.js";import{findRefTokens as w}from"../../../shared/inline-ref-grammar.js";import{dispatchSlashCommand as C,isSlashCommand as m}from"../slash/dispatch.js";import{viewerOperationForFrame as T}from"./capabilities.js";import{readClipboardImage as b,writeClipboardImageToFile as I}from"./clipboard-image.js";import{InputOverlayOwner as M}from"./overlay-owner.js";import{attachLocalFiles as D,hasLocalPaths as E}from"./local-files.js";import{announceFallbackEditor as q,NO_EDITOR_MESSAGE as A,resolveEditor as R}from"../../../core/editor-resolver.js";const B=500,F=v.maxLineBytes-4*1024*1024;class Y{static{r(this,"InputController")}tui;editor;keybindings;hooks;capabilities;overlays;state;lastEscapeAt=0;pastedImages=new Map;pasteSeq=0;constructor(e,t,o,i,s){this.tui=e,this.editor=t,this.keybindings=o,this.hooks=i,this.capabilities=s,this.overlays=new M(e,t,o,{send:r(n=>this.emitCommand(n),"send"),notify:r(n=>this.notify(n),"notify"),onDialogResponse:i.onDialogResponse,onRequest:i.onRequest,onMountPicker:i.onMountPicker,onUnmountPicker:i.onUnmountPicker,state:r(()=>this.state,"state")}),this.wire()}cycleLadder(e){this.emitCommand({type:"cycle_ladder",direction:e})}sendInterrupting(e){return this.emitDrive({type:"prompt",text:e,interrupt:!0})}abortTurn(){return this.state?.isStreaming!==!0?!1:this.emitCommand({type:"abort"})}attachDialog(e){this.overlays.attachDialog(e)}dismissDialog(e){this.overlays.dismissDialog(e)}setState(e){this.state=e}openAuthPicker(e){return this.overlays.openAuthPicker(e)}send=r(e=>{this.emitCommand(e)},"send");refuseStarting(e){return this.hooks.isStarting?.()!==!0||e!==void 0&&(e.type==="prompt"||e.type==="follow_up")?!1:(this.notify("The node is starting \u2014 try again in a moment"),!0)}emitCommand(e){if(this.refuseStarting(e))return!1;const t=T(e),o=t===void 0?void 0:this.capabilities.refusal(t);return o===void 0?(this.hooks.onCommand(e),!0):(this.notify(o),!1)}openBrokerPicker(e){if(this.refuseStarting())return;const t=this.capabilities.refusal("engine-drive");if(t!==void 0){this.notify(t);return}e()}wire(){this.editor.onSubmit=t=>this.handleSubmit(t),this.editor.onEscape=()=>{if(this.state?.isStreaming){this.emitCommand({type:"abort"});return}if(this.editor.getText().trim())return;const t=Date.now();t-this.lastEscapeAt<B?(this.lastEscapeAt=0,this.openBrokerPicker(()=>{this.overlays.openTreePicker()})):this.lastEscapeAt=t},this.editor.onPasteImage=()=>{this.handlePaste()};const e=this.editor;e.onPasteImagePath=t=>(this.attachImage(t),!0),this.editor.onAction("app.session.new",()=>this.emitCommand({type:"new_session"})),this.editor.onAction("app.model.cycleForward",()=>this.emitCommand({type:"cycle_model",direction:"forward"})),this.editor.onAction("app.model.cycleBackward",()=>this.emitCommand({type:"cycle_model",direction:"backward"})),this.editor.onAction("app.thinking.cycle",()=>this.emitCommand({type:"cycle_thinking"})),this.editor.onAction("app.message.followUp",()=>this.handleFollowUp()),this.editor.onAction("app.message.dequeue",()=>{this.handleDequeue()}),this.editor.onAction("app.tools.expand",()=>this.hooks.onMoreDetail?.()),this.editor.onAction("app.thinking.toggle",()=>this.hooks.onToggleThinking?.()),this.editor.onAction("app.editor.external",()=>{this.openExternalEditor()}),this.editor.onAction("app.model.select",()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()})),this.editor.onAction("app.session.tree",()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()})),this.editor.onAction("app.session.fork",()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()})),this.editor.onAction("app.session.resume",()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}))}slashContext(){return{send:this.send,notify:r(e=>this.notify(e),"notify"),capabilities:this.capabilities,state:this.state,cwd:process.cwd(),onGraph:this.hooks.onGraph,onInbox:this.hooks.onInbox,onHelp:this.hooks.onHelp,onQuit:this.hooks.onQuit,onCopy:this.hooks.onCopy,onCopyTarget:this.hooks.onCopyTarget,onToggleMouse:this.hooks.onToggleMouse,onColor:this.hooks.onColor,onNodeMetadata:this.hooks.onNodeMetadata,onMoreDetail:this.hooks.onMoreDetail,onLessDetail:this.hooks.onLessDetail,openModelPicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()}),"openModelPicker"),openSessionPicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}),"openSessionPicker"),openForkPicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()}),"openForkPicker"),openTreePicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()}),"openTreePicker"),openSettingsPicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openSettingsPicker()}),"openSettingsPicker"),openScopedModelsPicker:r(()=>this.openBrokerPicker(()=>{this.overlays.openScopedModelsPicker()}),"openScopedModelsPicker"),openMcpPicker:r(e=>this.overlays.openMcpPicker(e),"openMcpPicker"),openLoginPicker:this.hooks.openLoginPicker,openLogoutPicker:this.hooks.openLogoutPicker}}recordCommandUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.slice(1).split(/\s/,1)[0];o&&t.record(`command:${o}`)}recordCompletionUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.trim();if(m(o)){this.recordCommandUse(o);return}const i=this.hooks.knownRefNames?.();if(!i||i.size===0)return;const s=new Set;for(const n of w(e))i.has(n.candidate)&&!s.has(n.candidate)&&(s.add(n.candidate),t.record(`ref:${n.candidate}`))}handleSubmit(e){const t=e.trim();if(!t||m(t)&&this.refuseStarting())return;if(m(t)&&C(t,this.slashContext())){this.recordCommandUse(t),this.editor.setText("");return}const o=this.hooks.isDormant?.()===!0;if(o&&(t.startsWith("/")||t.startsWith("!"))){this.notify("This node is parked \u2014 submit a message to wake it; broker commands need a live engine");return}const i=x(e,{isDormant:o,canWakeDormant:o&&this.capabilities.permits("wake-dormant")&&this.hooks.onDormantSubmit!==void 0,isStreaming:this.state?.isStreaming===!0});if(i.kind==="empty")return;if(i.kind==="dormant"){const a=this.hooks.onDormantSubmit;if(a===void 0)return;const c=this.expandImagePlaceholders(i.text);a(c),this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.editor.setText(""),this.clearPastedImages(),this.hooks.onMessageSent?.(c,!1),this.hooks.onPromptSent?.();return}if(i.kind==="bash"){if(!this.emitDrive({type:"bash",command:i.command,excludeFromContext:i.excludeFromContext}))return;this.editor.addToHistory(i.trimmed),this.editor.setText("");return}const s=i.kind==="slash"?this.state?.isStreaming===!0?"steer":"prompt":i.kind;if(s!=="steer"&&s!=="prompt")return;const n=this.expandImagePlaceholders(i.kind==="slash"?e:i.text),h=r(()=>{this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.clearPastedImages()},"sent"),d=r(a=>this.emitDrive(s==="steer"?{type:"steer",text:a}:{type:"prompt",text:a})?(s==="prompt"&&this.hooks.onMessageSent?.(a,!0),this.hooks.onPromptSent?.(),!0):!1,"deliver");this.sendMessage(n,e,i.kind!=="slash",h,d)}sendMessage(e,t,o,i,s){const n=this.hooks.onRequest;if(!o||n===void 0||!E(e)){if(!s(e))return;i(),this.editor.setText("");return}i(),this.editor.setText(""),this.tui.requestRender(),D(e,n).then(h=>{!s(h)&&this.editor.getText().trim()===""&&(this.editor.setText(t),this.tui.requestRender())})}handleFollowUp(){const e=this.editor.getText(),t=e.trim();if(!t)return;const o=this.expandImagePlaceholders(e),i=r(()=>{this.editor.addToHistory(t),this.clearPastedImages()},"sent");this.sendMessage(o,e,!0,i,s=>this.emitDrive({type:"follow_up",text:s}))}async handleDequeue(){if(this.refuseStarting())return;const e=this.capabilities.refusal("dequeue");if(e!==void 0){this.notify(e);return}const t=this.hooks.onRequest;if(t===void 0){this.notify("Restoring queued messages isn't available in this viewer");return}let o;try{o=await t({type:"dequeue"})}catch(s){this.notify(`Could not restore queued messages: ${s instanceof Error?s.message:String(s)}`);return}if(o.kind!=="dequeue"){this.notify("Unexpected reply restoring queued messages");return}const i=[...o.steering,...o.followUp];if(i.length===0){this.notify("No queued messages to restore");return}this.editor.setText([i.join(`
|
|
2
2
|
|
|
3
3
|
`),this.editor.getText()].filter(s=>s.trim()).join(`
|
|
4
4
|
|
|
5
|
-
`)),this.tui.requestRender(),this.notify(`Restored ${i.length} queued message${i.length>1?"s":""} to editor`)}emitDrive(e){try{const t=Buffer.byteLength(S(e));if(t>
|
|
5
|
+
`)),this.tui.requestRender(),this.notify(`Restored ${i.length} queued message${i.length>1?"s":""} to editor`)}emitDrive(e){try{const t=Buffer.byteLength(S(e));if(t>F)return this.notify(`Message too large to send (${Math.round(t/(1024*1024))} MiB) \u2014 shorten the text or remove an attached image`),!1}catch{return this.notify("Message could not be encoded"),!1}return this.emitCommand(e)}async handlePaste(){try{const e=await b();if(!e){this.notify("No image in the clipboard");return}if(!e.image){this.notify(e.note??"Image not pasted");return}this.attachImage(I(e.image),e.note)}catch{this.notify("Could not read the clipboard image")}}attachImage(e,t){const o=++this.pasteSeq;this.pastedImages.set(o,e);const i=this.editor.getText();this.editor.insertTextAtCursor(`${i&&!/\s$/.test(i)?" ":""}[Image #${o}] `),this.notify(t?`Image #${o} attached (${t})`:`Image #${o} attached`),this.tui.requestRender()}expandImagePlaceholders(e){return e.replace(/\[Image #(\d+)\]/g,(t,o)=>this.pastedImages.get(Number(o))??t)}clearPastedImages(){this.pastedImages.clear(),this.pasteSeq=0}async openExternalEditor(){const e=R();if(e===null){this.notify(A);return}const t=e.command,o=this.editor,i=P(y(),`crtr-attach-editor-${Date.now()}.pi.md`);try{g(i,o.getExpandedText?.()??this.editor.getText(),"utf-8"),this.tui.stop();const[s,...n]=t.split(" ");process.stdout.write(`Launching external editor: ${t}
|
|
6
6
|
The viewer resumes when it exits.
|
|
7
|
-
`),
|
|
7
|
+
`),q(e);const h=await new Promise(d=>{const a=u(s,[...n,i],{stdio:"inherit",shell:process.platform==="win32"});a.on("error",()=>d(null)),a.on("close",c=>d(c))});h===null&&e.source==="fallback"&&this.notify(`Could not launch ${t} \u2014 set $EDITOR to an editor you have installed`),h===0&&this.editor.setText(f(i,"utf-8").replace(/\n$/,""))}catch(s){this.notify(`External editor failed: ${s instanceof Error?s.message:String(s)}`)}finally{try{k(i)}catch{}this.tui.start(),this.tui.requestRender(!0)}}notify(e){this.hooks.onNotice?.(e)}}export{Y as InputController};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BrokerDataFrame } from '../../../core/runtime/broker-protocol.js';
|
|
2
|
+
import type { ReadOpRequest } from '../../../core/broker-client/index.js';
|
|
3
|
+
/** Base64 grows the bytes by a third and the frame must fit the broker's read cap, so a file above this stays on the viewer. */
|
|
4
|
+
export declare const LOCAL_FILE_MAX_BYTES: number;
|
|
5
|
+
export interface PathMatch {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
raw: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
/** Every path token in `text`, with sentence punctuation trimmed and escapes undone. Exported for tests. */
|
|
12
|
+
export declare function findLocalPaths(text: string): PathMatch[];
|
|
13
|
+
/** True when `text` names any path, so the caller can keep the plain synchronous send otherwise. */
|
|
14
|
+
export declare function hasLocalPaths(text: string): boolean;
|
|
15
|
+
/** Send each local file `text` names to the node and rewrite its path; append a `<runtime>` note for every file that could not go. */
|
|
16
|
+
export declare function attachLocalFiles(text: string, request: (frame: ReadOpRequest) => Promise<BrokerDataFrame>): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var m=Object.defineProperty;var c=(n,o)=>m(n,"name",{value:o,configurable:!0});import{closeSync as g,constants as y,fstatSync as $,openSync as w,readFileSync as k}from"node:fs";import{homedir as L}from"node:os";const h=16*1024*1024,_=/(?<![\w/~.:-])(~?\/(?:\\ |[^\s'"`<>()[\]{}])+)/g;function p(n){const o=[];for(const i of n.matchAll(_)){const e=i[1].replace(/[.,;:!?]+$/,"");if(e==="/"||e==="~/"||e.startsWith("//"))continue;const r=e.replace(/\\ /g," "),l=r.startsWith("~/")?`${L()}${r.slice(1)}`:r;o.push({start:i.index,end:i.index+e.length,raw:e,path:l})}return o}c(p,"findLocalPaths");function x(n){let o;try{o=w(n,y.O_RDONLY)}catch{return{kind:"missing"}}try{const i=$(o);return i.isFile()?i.size>h?{kind:"too-large",size:i.size}:{kind:"file",bytes:k(o)}:{kind:"not-file"}}finally{g(o)}}c(x,"readLocal");function d(n){return`${(n/(1024*1024)).toFixed(1)} MiB`}c(d,"mib");function F(n){return p(n).length>0}c(F,"hasLocalPaths");async function z(n,o){const i=p(n);if(i.length===0)return n;const e=[],r=new Map,l=[];for(const t of i){const a=r.get(t.path);if(a!==void 0){l.push({match:t,to:a});continue}const f=x(t.path);if(f.kind!=="not-file"){if(f.kind==="missing"){e.push(`${t.raw} does not exist on the person's machine, so it was not sent to you.`);continue}if(f.kind==="too-large"){e.push(`file ${t.raw} is too large (${d(f.size)}; the limit is ${d(h)}), not uploaded.`);continue}try{const s=await o({type:"upload_file",source_path:t.path,data:f.bytes.toString("base64")});if(s.kind!=="upload_file")throw new Error("unexpected reply");r.set(t.path,s.path),l.push({match:t,to:s.path})}catch(s){e.push(`file ${t.raw} could not be uploaded (${s instanceof Error?s.message:String(s)}).`)}}}let u=n;for(const{match:t,to:a}of l.reverse())a===t.path&&t.raw===a||(u=`${u.slice(0,t.start)}${a}${u.slice(t.end)}`);return e.length===0?u:`${u}
|
|
2
|
+
|
|
3
|
+
<runtime>
|
|
4
|
+
${e.join(`
|
|
5
|
+
`)}
|
|
6
|
+
</runtime>`}c(z,"attachLocalFiles");export{h as LOCAL_FILE_MAX_BYTES,z as attachLocalFiles,p as findLocalPaths,F as hasLocalPaths};
|
|
@@ -31,7 +31,7 @@ export interface EditorChrome {
|
|
|
31
31
|
paintFrame: () => void;
|
|
32
32
|
/** Normalize pi's session name into the title chip. */
|
|
33
33
|
setTitle: (sessionName: string | undefined) => void;
|
|
34
|
-
/** Repaint the bottom-right
|
|
34
|
+
/** Repaint the bottom-right profile + persona badge. */
|
|
35
35
|
syncContextBadge: () => void;
|
|
36
36
|
/** Kick an async git-status fetch that repaints the top border. */
|
|
37
37
|
pollGit: () => void;
|
|
@@ -44,4 +44,4 @@ export declare function displayEditorTitle(sessionName: string | undefined, iden
|
|
|
44
44
|
* over `editor.onChange` is its ONE writer) and the `/color` chip override,
|
|
45
45
|
* and paints every frame-attached adornment — border hue, title chip, context
|
|
46
46
|
* badge, and git context. */
|
|
47
|
-
export declare function createEditorChrome(ctx: Pick<AttachSession, 'meta' | 'tui' | 'pal' | 'editor'>, hooks: EditorChromeHooks): EditorChrome;
|
|
47
|
+
export declare function createEditorChrome(ctx: Pick<AttachSession, 'meta' | 'tui' | 'pal' | 'editor' | 'socket'>, hooks: EditorChromeHooks): EditorChrome;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty;var n=(s,e)=>x(s,"name",{value:e,configurable:!0});import{basename as y}from"node:path";import{modeIcon as g,personaLabel as C}from"../../../core/canvas/labels.js";import{colorChipStyle as $,defaultTitleStyle as S,thinkingBorderColor as w,thinkingTitleStyle as I}from"../input/titled-editor.js";import{loadProfileManifest as M}from"../../../core/profiles/manifest.js";const T="\uF489";function B(s){const e=s.trimStart();return e.startsWith("!!")?2:e.startsWith("!")?1:0}n(B,"deriveBashMode");function _(s,e,r){return s===2?{borderColor:r.bashModeAlt,titleStyle:n(l=>`\x1B[102m\x1B[30m\x1B[1m ${l} \x1B[0m`,"titleStyle")}:s===1?{borderColor:r.bashMode,titleStyle:n(l=>`\x1B[42m\x1B[97m\x1B[1m ${l} \x1B[0m`,"titleStyle")}:{borderColor:w(e,r.border),titleStyle:I(e,S)}}n(_,"resolveEditorFrameStyles");function E(s,e){const r=s??"";if(r===""||e===void 0)return r;const l=`${g(e.mode)} `,c=r.startsWith(l)?r.slice(l.length):r,o=(e.icon??"").trim(),h=o===""?"":`${o} `,d=h!==""&&c.startsWith(h)?c.slice(h.length):c,u=d.endsWith(` ${e.kind}`)?d.slice(0,-e.kind.length-1):d,m=u===e.kind?"":u;return m===""||o===""?m:`${o} ${m}`}n(E,"displayEditorTitle");function G(s,e){const{meta:r,tui:l,pal:c,editor:o,socket:h}=s;let d=0,u=null;const m=(()=>{const t=r.profile_id;if(!t)return y(r.cwd)||r.cwd;try{return M(t).manifest.name}catch{return t}})(),b=n(()=>{const t=e.nodeIdentity(),i=t?.lifecycle==="terminal"?`${T} `:"",a=t?` \xB7 ${C(t)}`:"";o.contextBadge=`${i}${m}${a}`},"syncContextBadge"),f=n(()=>{const t=_(d,e.thinkingLevel(),c);if(o.borderColor=t.borderColor,o.titleStyle=t.titleStyle,o.contextBadgeStyle=t.titleStyle,d===0&&u!==null){const i=$(u);i!==void 0&&(o.titleStyle=i)}},"paintFrame");o.onChange=t=>{e.onTextChange(t);const i=B(t);i!==d&&(d=i,f(),e.renderFooter()),l.requestRender()};const p=n(t=>{const i=[];t.branch&&i.push(c.info(`\u2387 ${t.branch}`));const a=[];t.dirty&&a.push(c.warning("\u25CF")),t.ahead>0&&a.push(c.active(`\u21E1${t.ahead}`)),t.behind>0&&a.push(c.active(`\u21E3${t.behind}`)),a.length>0&&i.push(a.join("")),o.info=i.length>0?` ${i.join(c.muted(" \xB7 "))} `:"",l.requestRender()},"renderGitInfo");return{bashMode:n(()=>d,"bashMode"),setChipColor:n(t=>{u=t,f(),l.requestRender()},"setChipColor"),paintFrame:f,setTitle:n(t=>{o.title=E(t,e.nodeIdentity())},"setTitle"),syncContextBadge:n(()=>b(),"syncContextBadge"),pollGit:n(()=>{h.request({type:"get_git_status"}).then(t=>{t.kind==="git_status"&&p(t)},()=>{})},"pollGit")}}n(G,"createEditorChrome");export{G as createEditorChrome,B as deriveBashMode,E as displayEditorTitle,_ as resolveEditorFrameStyles};
|