pi2dsh 0.18.0 → 0.20.0
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 +46 -2
- package/README.zh.md +26 -0
- package/dist/{analyzer-BcuRfHLG.mjs → analyzer-BL7Nfvko.mjs} +2 -2
- package/dist/{analyzer-BcuRfHLG.mjs.map → analyzer-BL7Nfvko.mjs.map} +1 -1
- package/dist/cli.mjs +3 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/client.js +118 -1
- package/dist/compat/pi-coding-agent.d.mts +2 -2
- package/dist/compat/pi-coding-agent.mjs +2 -2
- package/dist/{mcp-config-NvRpjToH.mjs → compatibility-D_PV1zgF.mjs} +10 -187
- package/dist/compatibility-D_PV1zgF.mjs.map +1 -0
- package/dist/credentials-oauth.mjs +1 -1
- package/dist/host.d.mts +9 -2
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +7 -2
- package/dist/host.mjs.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +154 -8
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-config-C1K-IzzB.mjs +180 -0
- package/dist/mcp-config-C1K-IzzB.mjs.map +1 -0
- package/dist/{pi-coding-agent-DXJ_Jzo0.mjs → pi-coding-agent-CPXFo0UO.mjs} +0 -0
- package/dist/pi-coding-agent-CPXFo0UO.mjs.map +1 -0
- package/dist/{pi-coding-agent-69yY0ke-.d.mts → pi-coding-agent-Pvy0m9tS.d.mts} +6 -2
- package/dist/{pi-coding-agent-69yY0ke-.d.mts.map → pi-coding-agent-Pvy0m9tS.d.mts.map} +1 -1
- package/dist/{runtime-C-cmLDY0.mjs → runtime-CBZcd1uU.mjs} +592 -21
- package/dist/runtime-CBZcd1uU.mjs.map +1 -0
- package/dist/runtime.d.mts +106 -68
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/package.json +7 -2
- package/dist/mcp-config-NvRpjToH.mjs.map +0 -1
- package/dist/pi-coding-agent-DXJ_Jzo0.mjs.map +0 -1
- package/dist/runtime-C-cmLDY0.mjs.map +0 -1
package/dist/client.js
CHANGED
|
@@ -148,7 +148,8 @@ window.__ModuleLoader__.load({
|
|
|
148
148
|
threads: Array.isArray(payload.threads) ? payload.threads : [],
|
|
149
149
|
surfaces: Array.isArray(payload.surfaces) ? payload.surfaces : [],
|
|
150
150
|
entries: Array.isArray(payload.entries) ? payload.entries : [],
|
|
151
|
-
...payload.draft === void 0 ? {} : { draft: payload.draft }
|
|
151
|
+
...payload.draft === void 0 ? {} : { draft: payload.draft },
|
|
152
|
+
...payload.scene === void 0 ? {} : { scene: payload.scene }
|
|
152
153
|
};
|
|
153
154
|
latest.set(session, state);
|
|
154
155
|
for (const reader of subscribers.get(session) ?? []) reader(state);
|
|
@@ -227,6 +228,44 @@ window.__ModuleLoader__.load({
|
|
|
227
228
|
return out;
|
|
228
229
|
}
|
|
229
230
|
const styles = {
|
|
231
|
+
sceneBackdrop: {
|
|
232
|
+
position: "fixed",
|
|
233
|
+
inset: 0,
|
|
234
|
+
zIndex: 60,
|
|
235
|
+
display: "flex",
|
|
236
|
+
alignItems: "center",
|
|
237
|
+
justifyContent: "center",
|
|
238
|
+
background: "rgba(0,0,0,0.45)",
|
|
239
|
+
pointerEvents: "auto"
|
|
240
|
+
},
|
|
241
|
+
sceneFrame: {
|
|
242
|
+
maxWidth: "92vw",
|
|
243
|
+
maxHeight: "86vh",
|
|
244
|
+
display: "flex",
|
|
245
|
+
flexDirection: "column",
|
|
246
|
+
borderRadius: "12px",
|
|
247
|
+
border: "1px solid rgba(120,120,130,0.35)",
|
|
248
|
+
background: "var(--dsh-color-bg-elevated, rgba(18,18,21,0.98))",
|
|
249
|
+
color: "var(--dsh-color-text, #fafafa)",
|
|
250
|
+
boxShadow: "0 18px 48px rgba(0,0,0,0.45)",
|
|
251
|
+
overflow: "hidden"
|
|
252
|
+
},
|
|
253
|
+
sceneHeader: {
|
|
254
|
+
display: "flex",
|
|
255
|
+
alignItems: "center",
|
|
256
|
+
justifyContent: "space-between",
|
|
257
|
+
padding: "8px 12px",
|
|
258
|
+
borderBottom: "1px solid rgba(120,120,130,0.25)",
|
|
259
|
+
font: "500 12px/1.4 system-ui, -apple-system, sans-serif",
|
|
260
|
+
opacity: .9
|
|
261
|
+
},
|
|
262
|
+
sceneBody: {
|
|
263
|
+
margin: 0,
|
|
264
|
+
padding: "12px 14px",
|
|
265
|
+
overflow: "auto",
|
|
266
|
+
font: "400 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
267
|
+
whiteSpace: "pre"
|
|
268
|
+
},
|
|
230
269
|
panel: {
|
|
231
270
|
position: "fixed",
|
|
232
271
|
right: "20px",
|
|
@@ -509,6 +548,79 @@ window.__ModuleLoader__.load({
|
|
|
509
548
|
* pinned frame-wide — transient title and Pi's status entries, as pills.
|
|
510
549
|
* @param props - the global standard kit every root slot component receives.
|
|
511
550
|
*/
|
|
551
|
+
/** Browser KeyboardEvent -> the raw terminal sequence a Pi component expects. */
|
|
552
|
+
function terminalSequence(event) {
|
|
553
|
+
if (event.metaKey) return void 0;
|
|
554
|
+
switch (event.key) {
|
|
555
|
+
case "Enter": return "\r";
|
|
556
|
+
case "Escape": return "\x1B";
|
|
557
|
+
case "Tab": return " ";
|
|
558
|
+
case "Backspace": return "";
|
|
559
|
+
case "Delete": return "\x1B[3~";
|
|
560
|
+
case "ArrowUp": return "\x1B[A";
|
|
561
|
+
case "ArrowDown": return "\x1B[B";
|
|
562
|
+
case "ArrowRight": return "\x1B[C";
|
|
563
|
+
case "ArrowLeft": return "\x1B[D";
|
|
564
|
+
case "Home": return "\x1B[H";
|
|
565
|
+
case "End": return "\x1B[F";
|
|
566
|
+
case "PageUp": return "\x1B[5~";
|
|
567
|
+
case "PageDown": return "\x1B[6~";
|
|
568
|
+
}
|
|
569
|
+
if (event.key.length !== 1) return void 0;
|
|
570
|
+
if (event.ctrlKey) {
|
|
571
|
+
const code = event.key.toLowerCase().charCodeAt(0);
|
|
572
|
+
return code >= 97 && code <= 122 ? String.fromCharCode(code - 96) : void 0;
|
|
573
|
+
}
|
|
574
|
+
return event.key;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Pi's full-screen custom UI (`ui.custom`) on the web: the same ANSI frames a
|
|
578
|
+
* terminal scene would show, painted in a modal, with the keyboard forwarded
|
|
579
|
+
* verbatim to the live component on the server. The component owns its own
|
|
580
|
+
* lifecycle — most panels close themselves (their `done`) — and the × button
|
|
581
|
+
* is the browser's equivalent of closing the terminal scene.
|
|
582
|
+
*/
|
|
583
|
+
function SceneOverlay({ useSessions }) {
|
|
584
|
+
const { scene } = useBrowserState(useSessions((state) => state.current));
|
|
585
|
+
const open = scene?.open === true;
|
|
586
|
+
(0, react.useEffect)(() => {
|
|
587
|
+
if (!open) return;
|
|
588
|
+
const columns = Math.max(40, Math.min(240, Math.floor(window.innerWidth * .86 / 8.4)));
|
|
589
|
+
fetch("/pi2dsh/scene-input", {
|
|
590
|
+
method: "POST",
|
|
591
|
+
headers: { "content-type": "application/json" },
|
|
592
|
+
body: JSON.stringify({
|
|
593
|
+
sequence: "",
|
|
594
|
+
width: columns
|
|
595
|
+
})
|
|
596
|
+
});
|
|
597
|
+
const onKey = (event) => {
|
|
598
|
+
const sequence = terminalSequence(event);
|
|
599
|
+
if (sequence === void 0) return;
|
|
600
|
+
event.preventDefault();
|
|
601
|
+
event.stopPropagation();
|
|
602
|
+
fetch("/pi2dsh/scene-input", {
|
|
603
|
+
method: "POST",
|
|
604
|
+
headers: { "content-type": "application/json" },
|
|
605
|
+
body: JSON.stringify({ sequence })
|
|
606
|
+
});
|
|
607
|
+
};
|
|
608
|
+
window.addEventListener("keydown", onKey, true);
|
|
609
|
+
return () => window.removeEventListener("keydown", onKey, true);
|
|
610
|
+
}, [open]);
|
|
611
|
+
if (!open) return null;
|
|
612
|
+
const lines = scene?.lines ?? [];
|
|
613
|
+
return (0, react.createElement)("div", {
|
|
614
|
+
style: styles.sceneBackdrop,
|
|
615
|
+
"data-pi2dsh": "scene"
|
|
616
|
+
}, (0, react.createElement)("div", { style: styles.sceneFrame }, (0, react.createElement)("div", { style: styles.sceneHeader }, (0, react.createElement)("span", null, scene?.package ?? ""), (0, react.createElement)("button", {
|
|
617
|
+
style: styles.close,
|
|
618
|
+
title: "Close",
|
|
619
|
+
onClick: () => {
|
|
620
|
+
fetch("/pi2dsh/scene-close", { method: "POST" });
|
|
621
|
+
}
|
|
622
|
+
}, "×")), (0, react.createElement)("pre", { style: styles.sceneBody }, ...lines.map((line, index) => (0, react.createElement)("div", { key: index }, ansiText(line))))));
|
|
623
|
+
}
|
|
512
624
|
function OverlaySurfaces({ useSessions }) {
|
|
513
625
|
const { threads, surfaces } = useBrowserState(useSessions((state) => state.current));
|
|
514
626
|
const [dismissed, setDismissed] = (0, react.useState)([]);
|
|
@@ -671,6 +783,11 @@ window.__ModuleLoader__.load({
|
|
|
671
783
|
id: "pi2dsh-overlay",
|
|
672
784
|
order: 1
|
|
673
785
|
}, OverlaySurfaces));
|
|
786
|
+
scope.slots.inject("shell.overlay", () => scope.slots.register({
|
|
787
|
+
name: "shell.overlay",
|
|
788
|
+
id: "pi2dsh-scene",
|
|
789
|
+
order: 2
|
|
790
|
+
}, SceneOverlay));
|
|
674
791
|
scope.slots.inject("conversation.session.header.utilities", () => scope.slots.register({
|
|
675
792
|
name: "conversation.session.header.utilities",
|
|
676
793
|
id: "pi2dsh-header",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as generateBranchSummary, $n as
|
|
3
|
-
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, type BashExecutionMessage, BorderedLoader, type BranchPreparation, type BranchSummaryEntry, type BranchSummaryMessage, type BranchSummaryResult, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, type CollectEntriesResult, ColorMode, type CompactionEntry, type CompactionPreparation, type CompactionResult, type CompactionSettings, type CompactionSummaryMessage, CustomEditor, type CustomEntry, type CustomMessage, CustomMessageComponent, type CustomMessageEntry, type CutPointResult, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultProjectTrust, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, type ExtensionRuntime, ExtensionSelectorComponent, type FileOperations, FileSettingsStorage, FooterComponent, type GenerateBranchSummaryOptions, ImageResizeOptions, InMemorySettingsStorage, type LabelEntry, type ModelChangeEntry, ModelRegistry, ModelRuntime, PackageSource, ParsedSkillBlock, ProjectTrustStore, RegisteredToolRecord, RenderDiffOptions, ResizedImage, RetrySettings, type SessionContext, type SessionEntry, type SessionHeader, type SessionInfo, type SessionInfoEntry, SessionManager, type SessionMessageEntry, type SessionTreeNode, SettingsCallbacks, SettingsConfig, SettingsManager, SettingsManagerCreateOptions, SettingsSelectorComponent, type ShellConfig, StoredCredential, Theme, ThemeBg, ThemeColor, type ThinkingLevelChangeEntry, ToolExecutionComponent, ToolExecutionOptions, type TruncationOptions, type TruncationResult, TuiMode, UserMessageComponent, VERSION, VisualTruncateResult, __runWithSubagentSessionFactory, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
2
|
+
import { $ as generateBranchSummary, $n as assertValidSessionId, $t as calculateContextTokens, A as SettingsManagerCreateOptions, An as DEFAULT_MAX_LINES, At as truncateToVisualLines, B as VERSION, Bn as CustomEntry, Bt as wrapToolDefinitions, C as RegisteredToolRecord, Cn as createBashToolDefinition, Ct as processImage, D as SettingsCallbacks, Dn as getAgentDir, Dt as resizeImage, E as RetrySettings, En as createExtensionRuntime, Et as readStoredCredential, F as ThemeColor, Fn as truncateLine, Ft as loadSkillsFromDir, G as convertToPng, Gn as SessionEntry, Gt as CollectEntriesResult, H as __runWithSubagentSessionFactory, Hn as LabelEntry, Ht as stripFrontmatter, I as ToolExecutionComponent, In as truncateTail, It as ProjectTrustStore, J as createCodingTools, Jn as SessionInfoEntry, Jt as CompactionSettings, K as copyToClipboard, Kn as SessionHeader, Kt as CompactionPreparation, L as ToolExecutionOptions, Ln as BranchSummaryEntry, Lt as wrapRegisteredTool, M as StoredCredential, Mn as TruncationResult, Mt as getShellConfig, N as Theme, Nn as formatSize, Nt as formatSkillsForPrompt, O as SettingsConfig, On as withFileMutationQueue, Ot as theme, P as ThemeBg, Pn as truncateHead, Pt as loadSkills, Q as ensureTool, Qn as ThinkingLevelChangeEntry, Qt as GenerateBranchSummaryOptions, R as TuiMode, Rn as CURRENT_SESSION_VERSION, Rt as wrapRegisteredTools, S as ParsedSkillBlock, Sn as createBashTool, St as parseSkillBlock, T as ResizedImage, Tn as ExtensionRuntime, Tt as rawKeyHint, U as __setSubagentSessionFactory, Un as ModelChangeEntry, Ut as BranchPreparation, V as VisualTruncateResult, Vn as CustomMessageEntry, Vt as parseFrontmatter, W as compact, Wn as SessionContext, Wt as BranchSummaryResult, X as createReadOnlyTools, Xn as SessionMessageEntry, Xt as DEFAULT_COMPACTION_SETTINGS, Y as createEventBus, Yn as SessionManager, Yt as CutPointResult, Z as defineTool, Zn as SessionTreeNode, Zt as FileOperations, _ as ImageResizeOptions, _n as createEditTool, _r as bashExecutionToText, _t as isReadToolResult, a as CustomEditor, an as prepareBranchEntries, ar as loadEntriesFromFile, at as getPackageDir, b as ModelRuntime, bn as createReadToolDefinition, br as createCompactionSummaryMessage, bt as keyHint, c as DefaultProjectTrust, cn as shouldCompact, cr as sessionEntryToContextMessages, ct as getSettingsListTheme, d as ExtensionEditorComponent, dn as createFindTool, dr as BashExecutionMessage, dt as initTheme, en as collectEntriesForBranchSummary, er as buildContextEntries, et as generateSummary, f as ExtensionInputComponent, fn as createFindToolDefinition, fr as BranchSummaryMessage, ft as isBashToolResult, g as FooterComponent, gn as createWriteToolDefinition, gr as CustomMessage, gt as isLsToolResult, h as FileSettingsStorage, hn as createWriteTool, hr as CompactionSummaryMessage, ht as isGrepToolResult, i as ColorMode, in as getLastAssistantUsage, ir as getLatestCompactionEntry, it as getMarkdownTheme, j as SettingsSelectorComponent, jn as TruncationOptions, jt as ShellConfig, k as SettingsManager, kn as DEFAULT_MAX_BYTES, kt as renderDiff, l as DefaultResourceLoader, ln as createLsTool, lr as BRANCH_SUMMARY_PREFIX, lt as getToolPath, m as ExtensionSelectorComponent, mn as createGrepToolDefinition, mr as COMPACTION_SUMMARY_SUFFIX, mt as isFindToolResult, n as BorderedLoader, nn as findCutPoint, nr as findMostRecentSession, nt as getBinDir, o as CustomMessageComponent, on as prepareCompaction, or as migrateSessionEntries, ot as getReadmePath, p as ExtensionRunner, pn as createGrepTool, pr as COMPACTION_SUMMARY_PREFIX, pt as isEditToolResult, q as createAgentSession, qn as SessionInfo, qt as CompactionResult, r as CONFIG_DIR_NAME, rn as findTurnStartIndex, rr as getDefaultSessionDir, rt as getLanguageFromPath, s as DefaultPackageManager, sn as serializeConversation, sr as parseSessionEntries, st as getSelectListTheme, t as AssistantMessageComponent, tn as estimateTokens, tr as buildSessionContext, tt as generateSummaryWithUsage, u as DynamicBorder, un as createLsToolDefinition, ur as BRANCH_SUMMARY_SUFFIX, ut as highlightCode, v as InMemorySettingsStorage, vn as createEditToolDefinition, vr as convertToLlm, vt as isToolCallEventType, w as RenderDiffOptions, wn as createLocalBashOperations, wt as providePiExtensionDiscovery, x as PackageSource, xn as bashToolSystemPromptContribution, xr as createCustomMessage, xt as keyText, y as ModelRegistry, yn as createReadTool, yr as createBranchSummaryMessage, yt as isWriteToolResult, z as UserMessageComponent, zn as CompactionEntry, zt as wrapToolDefinition } from "../pi-coding-agent-Pvy0m9tS.mjs";
|
|
3
|
+
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, type BashExecutionMessage, BorderedLoader, type BranchPreparation, type BranchSummaryEntry, type BranchSummaryMessage, type BranchSummaryResult, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, type CollectEntriesResult, ColorMode, type CompactionEntry, type CompactionPreparation, type CompactionResult, type CompactionSettings, type CompactionSummaryMessage, CustomEditor, type CustomEntry, type CustomMessage, CustomMessageComponent, type CustomMessageEntry, type CutPointResult, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultProjectTrust, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, type ExtensionRuntime, ExtensionSelectorComponent, type FileOperations, FileSettingsStorage, FooterComponent, type GenerateBranchSummaryOptions, ImageResizeOptions, InMemorySettingsStorage, type LabelEntry, type ModelChangeEntry, ModelRegistry, ModelRuntime, PackageSource, ParsedSkillBlock, ProjectTrustStore, RegisteredToolRecord, RenderDiffOptions, ResizedImage, RetrySettings, type SessionContext, type SessionEntry, type SessionHeader, type SessionInfo, type SessionInfoEntry, SessionManager, type SessionMessageEntry, type SessionTreeNode, SettingsCallbacks, SettingsConfig, SettingsManager, SettingsManagerCreateOptions, SettingsSelectorComponent, type ShellConfig, StoredCredential, Theme, ThemeBg, ThemeColor, type ThinkingLevelChangeEntry, ToolExecutionComponent, ToolExecutionOptions, type TruncationOptions, type TruncationResult, TuiMode, UserMessageComponent, VERSION, VisualTruncateResult, __runWithSubagentSessionFactory, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, providePiExtensionDiscovery, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as isReadToolResult, $t as
|
|
2
|
+
import { $ as isReadToolResult, $t as DEFAULT_MAX_BYTES, A as createCodingTools, At as prepareCompaction, B as getMarkdownTheme, Bt as createWriteToolDefinition, C as VERSION, Cn as createBranchSummaryMessage, Ct as calculateContextTokens, D as convertToPng, Dt as findTurnStartIndex, E as compact, Et as findCutPoint, F as generateBranchSummary, Ft as createFindTool, G as getToolPath, Gt as createReadToolDefinition, H as getReadmePath, Ht as createEditToolDefinition, I as generateSummary, It as createFindToolDefinition, J as isBashToolResult, Jt as createBashToolDefinition, K as highlightCode, Kt as bashToolSystemPromptContribution, L as generateSummaryWithUsage, Lt as createGrepTool, M as createReadOnlyTools, Mt as shouldCompact, N as defineTool, Nt as createLsTool, O as copyToClipboard, Ot as getLastAssistantUsage, P as ensureTool, Pt as createLsToolDefinition, Q as isLsToolResult, Qt as withFileMutationQueue, R as getBinDir, Rt as createGrepToolDefinition, S as UserMessageComponent, Sn as convertToLlm, St as DEFAULT_COMPACTION_SETTINGS, T as __setSubagentSessionFactory, Tn as createCustomMessage, Tt as estimateTokens, U as getSelectListTheme, Ut as renderDiff, V as getPackageDir, Vt as createEditTool, W as getSettingsListTheme, Wt as createReadTool, X as isFindToolResult, Xt as truncateToVisualLines, Y as isEditToolResult, Yt as createLocalBashOperations, Z as isGrepToolResult, Zt as createExtensionRuntime, _ as ModelRuntime, _n as BRANCH_SUMMARY_PREFIX, _t as wrapRegisteredTools, a as CustomMessageComponent, an as CURRENT_SESSION_VERSION, at as processImage, b as Theme, bn as COMPACTION_SUMMARY_SUFFIX, bt as parseFrontmatter, c as DynamicBorder, cn as buildContextEntries, ct as readStoredCredential, d as ExtensionRunner, dn as getDefaultSessionDir, dt as getShellConfig, en as DEFAULT_MAX_LINES, et as isToolCallEventType, f as ExtensionSelectorComponent, fn as getLatestCompactionEntry, ft as formatSkillsForPrompt, g as ModelRegistry, gn as sessionEntryToContextMessages, gt as wrapRegisteredTool, h as InMemorySettingsStorage, hn as parseSessionEntries, ht as ProjectTrustStore, i as CustomEditor, in as truncateTail, it as parseSkillBlock, j as createEventBus, jt as serializeConversation, k as createAgentSession, kt as prepareBranchEntries, l as ExtensionEditorComponent, ln as buildSessionContext, lt as resizeImage, m as FooterComponent, mn as migrateSessionEntries, mt as loadSkillsFromDir, n as BorderedLoader, nn as truncateHead, nt as keyHint, o as DefaultPackageManager, on as SessionManager, ot as providePiExtensionDiscovery, p as FileSettingsStorage, pn as loadEntriesFromFile, pt as loadSkills, q as initTheme, qt as createBashTool, r as CONFIG_DIR_NAME, rn as truncateLine, rt as keyText, s as DefaultResourceLoader, sn as assertValidSessionId, st as rawKeyHint, t as AssistantMessageComponent, tn as formatSize, tt as isWriteToolResult, u as ExtensionInputComponent, un as findMostRecentSession, ut as theme, v as SettingsManager, vn as BRANCH_SUMMARY_SUFFIX, vt as wrapToolDefinition, w as __runWithSubagentSessionFactory, wn as createCompactionSummaryMessage, wt as collectEntriesForBranchSummary, x as ToolExecutionComponent, xn as bashExecutionToText, xt as stripFrontmatter, y as SettingsSelectorComponent, yn as COMPACTION_SUMMARY_PREFIX, yt as wrapToolDefinitions, z as getLanguageFromPath, zt as createWriteTool } from "../pi-coding-agent-CPXFo0UO.mjs";
|
|
3
3
|
import { t as getAgentDir } from "../pi-config-shim-CZ1wFzqM.mjs";
|
|
4
|
-
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, BorderedLoader, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, CustomEditor, CustomMessageComponent, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, ExtensionSelectorComponent, FileSettingsStorage, FooterComponent, InMemorySettingsStorage, ModelRegistry, ModelRuntime, ProjectTrustStore, SessionManager, SettingsManager, SettingsSelectorComponent, Theme, ToolExecutionComponent, UserMessageComponent, VERSION, __runWithSubagentSessionFactory, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
4
|
+
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, BorderedLoader, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, CustomEditor, CustomMessageComponent, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, ExtensionSelectorComponent, FileSettingsStorage, FooterComponent, InMemorySettingsStorage, ModelRegistry, ModelRuntime, ProjectTrustStore, SessionManager, SettingsManager, SettingsSelectorComponent, Theme, ToolExecutionComponent, UserMessageComponent, VERSION, __runWithSubagentSessionFactory, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, providePiExtensionDiscovery, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as getAgentDir } from "./pi-config-shim-CZ1wFzqM.mjs";
|
|
3
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { homedir } from "node:os";
|
|
6
2
|
//#region src/compatibility.ts
|
|
7
3
|
const rule = (level, detail) => ({
|
|
8
4
|
level,
|
|
@@ -88,10 +84,10 @@ const HOST_IMPORT_RULES = Object.freeze({
|
|
|
88
84
|
parseSkillBlock: rule("full", "Pi's skill_content block parser, reimplemented over the same wire shape."),
|
|
89
85
|
wrapRegisteredTool: rule("full", `${VENDORED} The runner argument is used exactly as Pi uses it (createContext + getActiveTools), which the pi2dsh projection provides.`),
|
|
90
86
|
ProjectTrustStore: rule("partial", `${VENDORED} The store operates on trust.json under the caller\'s agentDir — with the redirected getAgentDir convention that is package-visible state inside the DSH-owned pi2dsh directory. The DSH host never consults it; host trust stays a DSH decision (ctx.isProjectTrusted fails closed).`),
|
|
91
|
-
DefaultResourceLoader: rule("partial", "A headless resource loader honoring overrides,
|
|
87
|
+
DefaultResourceLoader: rule("partial", "A headless resource loader honoring overrides. Extension discovery is REAL: the default-discovered set is the host's installed Pi packages (each package's declared pi extension entry, as an absolute installed path), so a creator's own filtering code — pi-subagents' extensions/exclude_extensions/ext: machinery canonicalizes by entry basename and owning-manifest npm short name — runs unchanged and selects exactly what it selects on Pi. noExtensions empties the set; additionalExtensionPaths cannot be loaded fresh on this host and surface as per-entry errors (Pi's diagnostics shape). Skills/prompts/themes/agents-files discovery stays empty."),
|
|
92
88
|
DefaultPackageManager: rule("unsupported", "Installing packages is owned by the DSH host and its security gates (dsh plugin add/remove behind pnpm's build-script approval). Importing it is flagged at mount time (startup check); constructing it throws a structured PiCapabilityError, and doing so during entry setup marks the package unusable."),
|
|
93
89
|
ModelRuntime: rule("unsupported", "Standalone model stacks are owned by the DSH host llm configuration; packages read the ONE directory through ctx.modelRegistry. Importing it is flagged at mount time (startup check); constructing it throws a structured PiCapabilityError, and doing so during entry setup marks the package unusable."),
|
|
94
|
-
createAgentSession: rule("partial", "Bridged to a genuine DSH child agent through ctx.agents with the creator-exclusive setup contribution. Child tools join a preset composition in the roster's official preference order — inherit the parent's standing composition (composeFrom), else mount the roster default — which is what keeps children tooled on roster-owned surfaces (dsh-tui disables host-layer tool rows); rosterless deployments compose from the host rows as before. The Pi tools allowlist/excludeTools become official scoped restrictions, customTools register in the child scope, delegation policy travels the official way, and the child's model resolves in three tiers — the explicit Pi model on the options, else the caller's LIVE route read from its durable session log's last request/header (so a mid-session /model switch in the DSH UI is inherited, proven live on the stock TUI), else the creation-time snapshot; a truly modelless child fails its first {{model}}-keyed prompt assembly. A per-child thinkingLevel becomes the child's own reasoningEffort through the official agent/request waterfall (never leaking to siblings or the parent). session.subscribe projects tool_execution_start/end from the durable log (tool-use accounting works), steer() and followUp() are async per Pi's AgentSession face (consumers chain .catch on the returned promise; steer interrupts, followUp queues behind the running turn), and abort() follows Pi's contract: the child turn is cancelled AND post-abort wakes (a late tool result reaching quiescence) are re-cancelled on every opening event until the next explicit prompt(). The child exposes session.sessionManager (readonly projection) whose getSessionFile() names a durable archive (`<id>.jsonl`) in genuine Pi session-file format — a Pi header line plus any Pi-only entries, parseable by Pi's own SessionManager; conversation content is NOT copied there, it projects live from the native DSH log. Handing a SessionManager opened FROM such an archive back to createAgentSession reopens the SAME persisted DSH session through the registry's official resume seam, across process restarts (pi-subagents' tombstone resurrect shape). If a reopen fails, DSH's own persistence list() delivers the verdict (the check agent-loop itself uses): a POSITIVE \"gone\" retires the archive file so existsSync answers honestly from then on, while a composition merely lacking persistence keeps the token and fails loudly — absence of evidence never destroys a valid identity. Compositions without a loop factory fail explicitly."),
|
|
90
|
+
createAgentSession: rule("partial", "Bridged to a genuine DSH child agent through ctx.agents with the creator-exclusive setup contribution. Child tools join a preset composition in the roster's official preference order — inherit the parent's standing composition (composeFrom), else mount the roster default — which is what keeps children tooled on roster-owned surfaces (dsh-tui disables host-layer tool rows); rosterless deployments compose from the host rows as before. The Pi tools allowlist/excludeTools become official scoped restrictions, customTools register in the child scope, delegation policy travels the official way, and the child's model resolves in three tiers — the explicit Pi model on the options, else the caller's LIVE route read from its durable session log's last request/header (so a mid-session /model switch in the DSH UI is inherited, proven live on the stock TUI), else the creation-time snapshot; a truly modelless child fails its first {{model}}-keyed prompt assembly. A per-child thinkingLevel becomes the child's own reasoningEffort through the official agent/request waterfall (never leaking to siblings or the parent). session.subscribe projects tool_execution_start/end from the durable log (tool-use accounting works), The child is served its EXTENSION SET exactly as real Pi loads one: the host's installed Pi packages, filtered by the creator's resource loader (its own getExtensions applies noExtensions/extensionsOverride — the creator's code decides; no loader means Pi's default, everything discovered), mounted as per-child package instances on the child agent's own ctx before createAgentSession returns — their tools register in the child scope, their handlers see the child session, and everything unwinds with the agent (leak-free by scope, not by bookkeeping). bindExtensions() reports per-extension mount failures to the binding's onError in Pi's {extensionPath, error} shape; one timing nuance: session_start reaches child-bound packages at creation rather than at the bindExtensions call. steer() and followUp() are async per Pi's AgentSession face (consumers chain .catch on the returned promise; steer interrupts, followUp queues behind the running turn), and abort() follows Pi's contract: the child turn is cancelled AND post-abort wakes (a late tool result reaching quiescence) are re-cancelled on every opening event until the next explicit prompt(). The child exposes session.sessionManager (readonly projection) whose getSessionFile() names a durable archive (`<id>.jsonl`) in genuine Pi session-file format — a Pi header line plus any Pi-only entries, parseable by Pi's own SessionManager; conversation content is NOT copied there, it projects live from the native DSH log. Handing a SessionManager opened FROM such an archive back to createAgentSession reopens the SAME persisted DSH session through the registry's official resume seam, across process restarts (pi-subagents' tombstone resurrect shape). If a reopen fails, DSH's own persistence list() delivers the verdict (the check agent-loop itself uses): a POSITIVE \"gone\" retires the archive file so existsSync answers honestly from then on, while a composition merely lacking persistence keeps the token and fails loudly — absence of evidence never destroys a valid identity. Compositions without a loop factory fail explicitly."),
|
|
95
91
|
createCodingTools: rule("full", "Pi's exact tool set composed from the vendored built-in constructors."),
|
|
96
92
|
createReadOnlyTools: rule("full", "Pi's exact read-only tool set composed from the vendored built-in constructors."),
|
|
97
93
|
createBashTool: rule("full", VENDORED_TOOL),
|
|
@@ -247,8 +243,8 @@ const HOST_IMPORT_RULES = Object.freeze({
|
|
|
247
243
|
const CONTEXT_RULES = Object.freeze({
|
|
248
244
|
cwd: surface("full", "Mapped to the active DSH agent session working directory.", "Read off the live DSH agent's session; the bridge keeps no working directory of its own."),
|
|
249
245
|
signal: surface("full", "Mapped to the active DSH cancellation signal when one is available.", "The DSH cancellation signal belonging to the moment the context was built — a tool context carries its execution signal, a lifecycle context the agent's."),
|
|
250
|
-
hasUI: surface("full", "Reports whether a real interactive surface exists: true for dsh-TUI
|
|
251
|
-
mode: surface("full", "Reports tui
|
|
246
|
+
hasUI: surface("full", "Reports whether a real interactive surface exists: true for a mounted public terminal surface (dsh-TUI tuiScenes or dsh-pi-tui piTuiExtensions) or for a DSH user-question provider; false for a genuinely headless composition and for child-agent questions that DSH refuses.", "The terminal answer comes from the capability-selected TerminalSurfaceAdapter. The question answer is probed rather than guessed: the bridge registers a throwaway UserQuestion provider and reads the documented DUPLICATE_PROVIDER rejection as \"a real provider is already there\", then disposes it. Inside a child agent only the terminal seat can make this true, because DSH refuses child-agent questions."),
|
|
247
|
+
mode: surface("full", "Reports tui whenever a full-screen custom seat exists — dsh-TUI scenes, dsh-pi-tui raw mounts, or the bridge's web scene seat — and rpc only in headless compositions. Pi packages read mode as \"can I show interactive UI here?\", and each of those seats can.", "Derived from the live optional TerminalSurfaceAdapter, else from the browser half's routed scene seat. Surface selection is by public service/capability (`tuiScenes` or `piTuiExtensions` + unstable.surface.handle), never by Pi consumer package."),
|
|
252
248
|
isIdle: surface("partial", "Command contexts report idle; tool/lifecycle contexts conservatively report non-idle.", "Derived from which context the call arrived through: a command context is outside a step, a tool or lifecycle context is inside one."),
|
|
253
249
|
isProjectTrusted: surface("partial", "Fails closed as untrusted because DSH does not expose Pi project-trust state.", "No DSH seam carries Pi's project-trust state, so the bridge returns the safe constant instead of inventing one. Pi's own ProjectTrustStore is vendored and available to packages that manage their own."),
|
|
254
250
|
hasPendingMessages: surface("full", "Reads the DSH agent inbox — next-step plus next-turn input — which is exactly Pi's steering plus follow-up queue.", "Reads the DSH agent inbox — next-step plus next-turn queues — which is the same queue sendMessage/sendUserMessage write into."),
|
|
@@ -273,13 +269,13 @@ const CONTEXT_RULES = Object.freeze({
|
|
|
273
269
|
});
|
|
274
270
|
const UI_CONTEXT_RULES = Object.freeze({
|
|
275
271
|
notify: surface("full", "Captured as a command result when applicable and emitted through DSH logging at the severity the caller passed (warning and error log as warnings).", "Written to the DSH logger at the severity the caller passed, and returned as the command result when the call happens inside one."),
|
|
276
|
-
setStatus: surface("full", "Pi's keyed status entries render in the active DSH front door: dsh-TUI's native status line
|
|
272
|
+
setStatus: surface("full", "Pi's keyed status entries render in the active DSH front door: dsh-TUI's native status line, dsh-pi-tui's public footer-status slot, or package-keyed pills in the bridge's browser half. setStatus(key, undefined) removes exactly one entry.", "The selected terminal backend owns a package/key-scoped handle: tuiStatus on dsh-TUI, or a replaceable chrome.footer.status contribution on dsh-pi-tui. Browser mode writes BrowserSurfaces by (session, package, key); the client half draws the entries from the bridge route."),
|
|
277
273
|
setWidget: surface("partial", "String-array widgets render as a strip in DSH's conversation.input.dock seat (a full-width row of its own above the composer card). setWidget(key, undefined) removes one widget. Component factories are ignored, exactly like Pi's own rpc mode, where widgets travel to a host as lines.", "BrowserSurfaces.setWidget keeps the lines per widget key; the client half draws them in the conversation.input.dock slot. The factory branch is dropped at the ui seam, mirroring rpc-mode.ts's \"Only support string arrays in RPC mode\"."),
|
|
278
274
|
select: surface("full", "Mapped to one native DSH userQuestions single-select request. A terminal-oriented multi-line title becomes DSH's plain heading plus native detail; links render as Markdown on Web and OSC 8 in dsh-TUI without visible escape bytes.", "One native DSH UserQuestionService request carrying Pi's options as the choices. The turn really blocks until a human answers; the shared dialog projection separates title/body and selects the link encoding the active public renderer consumes."),
|
|
279
275
|
confirm: surface("full", "Mapped to one native DSH userQuestions Yes/No request. A terminal-oriented multi-line title becomes DSH's plain heading plus native detail; links render as Markdown on Web and OSC 8 in dsh-TUI without visible escape bytes.", "One native DSH UserQuestionService request with two choices, using the shared dialog projection for title/body and surface-native links."),
|
|
280
276
|
input: surface("full", "Mapped to one native DSH userQuestions free-text request. A terminal-oriented multi-line title becomes DSH's plain heading plus native detail; links render as Markdown on Web and OSC 8 in dsh-TUI without visible escape bytes.", "One native DSH UserQuestionService free-text request. The shared dialog projection preserves visible copy and link destinations, selects the active renderer's link encoding, and removes duplicate raw-link lines."),
|
|
281
277
|
editor: surface("partial", "Mapped to one DSH userQuestions free-text request. The prefill is shown as context but is NOT editable text: the caller receives what the user typed fresh, not an edit of the prefill. Terminal-oriented title formatting uses the same surface-native DSH heading/detail projection.", "One native DSH UserQuestionService free-text request. DSH has no editable-prefill question type, so the prefill is shown in the question body and the answer comes back as fresh text; link encoding uses the active public renderer."),
|
|
282
|
-
custom: surface("partial", "
|
|
278
|
+
custom: surface("partial", "Runs the real Pi component on every interactive front door: a dsh-TUI full-screen scene, dsh-pi-tui's raw component mount, or the Web overlay. Width, ANSI frames, raw input, render invalidation, result completion and disposal are preserved. Only genuinely headless compositions resolve undefined, Pi's own rpc-mode behavior.", "The Pi component stays Host-owned behind a transport-neutral relay whose messages are sessionId/width/lines/input/revision/close. The current local dsh-pi-tui transport wraps that relay with the public UNSTABLE_API_LEVEL=1 mountComponent facade; dsh-TUI and Web keep their public scene seats. No callback or component object is part of the relay contract, so a future DSH Server/Client split changes only the transport. One scene at a time, opening a new one finishes the previous run."),
|
|
283
279
|
onTerminalInput: surface("partial", "Raw terminal input is absent; feature-detected listeners remain disabled.", "Recorded; no DSH surface produces raw terminal input, and feature-detecting packages keep the listener disabled."),
|
|
284
280
|
setWorkingMessage: surface("partial", "A live working message, drawn in DSH's conversation.composer.dock band (under the composer card — the host's ambient-readout seat, where its own stats line sits). Calling with no argument restores the default, i.e. clears it.", "Recorded per session per package and drawn by the client half's composer-dock seat. Pi's rpc mode is a no-op here (it has no TUI loader); a browser host genuinely can show the text, so the bridge supersedes it."),
|
|
285
281
|
setWorkingVisible: surface("partial", "Hides or shows the working chrome (message, indicator, hidden-thinking label) without clearing it — Pi's exact semantics.", "A flag on the per-package surface view; the client half skips working keys while it is false. Supersedes Pi's rpc-mode no-op with a real visibility switch."),
|
|
@@ -314,8 +310,8 @@ const API_RULES = Object.freeze({
|
|
|
314
310
|
},
|
|
315
311
|
registerCommand: {
|
|
316
312
|
level: "partial",
|
|
317
|
-
detail: "Registered in ctx.commands with Pi's never-throw collision semantics: a package re-registering its own name replaces it, and cross-source collisions mount under Pi's numbered scheme (/name-2 — the earlier registration keeps the bare name, where Pi renumbers both).
|
|
318
|
-
design: "Registered on ctx.commands with an input descriptor.
|
|
313
|
+
detail: "Registered in ctx.commands with Pi's never-throw collision semantics: a package re-registering its own name replaces it, and cross-source collisions mount under Pi's numbered scheme (/name-2 — the earlier registration keeps the bare name, where Pi renumbers both). Active terminal-native commands keep their original names; a colliding Pi package command remains reachable with a pi- source prefix. A bridge fallback such as /login is omitted when the Host already owns the command and consumes the same projected authorization service.",
|
|
314
|
+
design: "Registered on ctx.commands with an input descriptor. Before projection, the selected terminal backend supplies its public native-command ownership set (dsh-pi-tui exports LOCAL_COMMANDS; the legacy dsh-TUI generation remains pinned until its public registry lands). Command policy is capability/surface based, not consumer-package based, and is resolved before registrations so plugin load order cannot create a duplicate."
|
|
319
315
|
},
|
|
320
316
|
registerShortcut: {
|
|
321
317
|
level: "partial",
|
|
@@ -601,179 +597,6 @@ function ruleForUiContextProperty(property) {
|
|
|
601
597
|
return UI_CONTEXT_RULES[property];
|
|
602
598
|
}
|
|
603
599
|
//#endregion
|
|
604
|
-
|
|
605
|
-
/** Pi's documented config precedence, lowest to highest. */
|
|
606
|
-
function piMcpConfigPaths(cwd) {
|
|
607
|
-
const home = homedir();
|
|
608
|
-
return [
|
|
609
|
-
join(home, ".config", "mcp", "mcp.json"),
|
|
610
|
-
join(home, ".agents", "mcp.json"),
|
|
611
|
-
join(home, ".agents", "mcp", "mcp.json"),
|
|
612
|
-
join(getAgentDir(), "mcp.json"),
|
|
613
|
-
join(cwd, ".mcp.json"),
|
|
614
|
-
join(cwd, ".pi", "mcp.json")
|
|
615
|
-
];
|
|
616
|
-
}
|
|
617
|
-
function stringRecord(value) {
|
|
618
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
619
|
-
const entries = Object.entries(value).filter((entry) => typeof entry[1] === "string");
|
|
620
|
-
return entries.length === 0 ? void 0 : Object.fromEntries(entries);
|
|
621
|
-
}
|
|
622
|
-
function parseServer(name, raw, sourcePath) {
|
|
623
|
-
if (typeof raw !== "object" || raw === null) return void 0;
|
|
624
|
-
const record = raw;
|
|
625
|
-
const disabled = record.disabled === true;
|
|
626
|
-
if (typeof record.url === "string") return {
|
|
627
|
-
name,
|
|
628
|
-
sourcePath,
|
|
629
|
-
transport: "streamable-http",
|
|
630
|
-
url: record.url,
|
|
631
|
-
...stringRecord(record.headers) === void 0 ? {} : { headers: stringRecord(record.headers) },
|
|
632
|
-
disabled
|
|
633
|
-
};
|
|
634
|
-
if (typeof record.command === "string") return {
|
|
635
|
-
name,
|
|
636
|
-
sourcePath,
|
|
637
|
-
transport: "stdio",
|
|
638
|
-
command: record.command,
|
|
639
|
-
...Array.isArray(record.args) ? { args: record.args.map(String) } : {},
|
|
640
|
-
...stringRecord(record.env) === void 0 ? {} : { env: stringRecord(record.env) },
|
|
641
|
-
...typeof record.cwd === "string" ? { cwd: record.cwd } : {},
|
|
642
|
-
disabled
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
function collectPiMcpServers(cwd, extraPaths = []) {
|
|
646
|
-
const servers = /* @__PURE__ */ new Map();
|
|
647
|
-
const sources = [];
|
|
648
|
-
for (const path of [...piMcpConfigPaths(cwd), ...extraPaths]) {
|
|
649
|
-
if (!existsSync(path)) continue;
|
|
650
|
-
let parsed;
|
|
651
|
-
try {
|
|
652
|
-
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
653
|
-
} catch {
|
|
654
|
-
continue;
|
|
655
|
-
}
|
|
656
|
-
const mcpServers = parsed?.mcpServers;
|
|
657
|
-
if (typeof mcpServers !== "object" || mcpServers === null) continue;
|
|
658
|
-
sources.push(path);
|
|
659
|
-
for (const [name, raw] of Object.entries(mcpServers)) {
|
|
660
|
-
const record = raw;
|
|
661
|
-
const existing = servers.get(name);
|
|
662
|
-
if (existing !== void 0 && typeof record === "object" && record !== null && record.command === void 0 && record.url === void 0 && typeof record.disabled === "boolean") {
|
|
663
|
-
servers.set(name, {
|
|
664
|
-
...existing,
|
|
665
|
-
disabled: record.disabled,
|
|
666
|
-
sourcePath: path
|
|
667
|
-
});
|
|
668
|
-
continue;
|
|
669
|
-
}
|
|
670
|
-
const server = parseServer(name, raw, path);
|
|
671
|
-
if (server !== void 0) servers.set(name, server);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
return {
|
|
675
|
-
servers,
|
|
676
|
-
sources
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
const SERVER_NAME_PATTERN = /^[A-Za-z0-9_-]{1,32}$/u;
|
|
680
|
-
const ENV_REFERENCE_PATTERN = /^\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?$/u;
|
|
681
|
-
const SECRETISH_KEY_PATTERN = /token|secret|key|password|credential/iu;
|
|
682
|
-
function js(expression) {
|
|
683
|
-
return { __pi2dshJs: expression };
|
|
684
|
-
}
|
|
685
|
-
function convertValueMap(server, kind, values, warnings) {
|
|
686
|
-
if (values === void 0) return void 0;
|
|
687
|
-
const output = {};
|
|
688
|
-
for (const [key, value] of Object.entries(values)) {
|
|
689
|
-
const reference = ENV_REFERENCE_PATTERN.exec(value);
|
|
690
|
-
if (reference !== null) {
|
|
691
|
-
output[key] = js(`process.env.${reference[1]}`);
|
|
692
|
-
continue;
|
|
693
|
-
}
|
|
694
|
-
if (SECRETISH_KEY_PATTERN.test(key)) warnings.push({
|
|
695
|
-
server,
|
|
696
|
-
message: `${kind}.${key} carries a literal value; move the secret to an environment variable and reference it as $NAME so the patch stays credential-free`
|
|
697
|
-
});
|
|
698
|
-
output[key] = value;
|
|
699
|
-
}
|
|
700
|
-
return output;
|
|
701
|
-
}
|
|
702
|
-
function convertPiMcpConfig(cwd, extraPaths = []) {
|
|
703
|
-
const { servers, sources } = collectPiMcpServers(cwd, extraPaths);
|
|
704
|
-
const warnings = [];
|
|
705
|
-
const entries = [];
|
|
706
|
-
for (const server of servers.values()) {
|
|
707
|
-
if (server.disabled) {
|
|
708
|
-
warnings.push({
|
|
709
|
-
server: server.name,
|
|
710
|
-
message: "skipped: disabled in Pi configuration"
|
|
711
|
-
});
|
|
712
|
-
continue;
|
|
713
|
-
}
|
|
714
|
-
if (!SERVER_NAME_PATTERN.test(server.name)) {
|
|
715
|
-
warnings.push({
|
|
716
|
-
server: server.name,
|
|
717
|
-
message: "skipped: DSH serverName must match [A-Za-z0-9_-]{1,32}; rename the server in the Pi config"
|
|
718
|
-
});
|
|
719
|
-
continue;
|
|
720
|
-
}
|
|
721
|
-
const config = {
|
|
722
|
-
serverName: server.name,
|
|
723
|
-
transport: server.transport
|
|
724
|
-
};
|
|
725
|
-
if (server.transport === "stdio") {
|
|
726
|
-
config.command = server.command;
|
|
727
|
-
if (server.args !== void 0) config.args = server.args;
|
|
728
|
-
const env = convertValueMap(server.name, "env", server.env, warnings);
|
|
729
|
-
if (env !== void 0) config.env = env;
|
|
730
|
-
if (server.cwd !== void 0) config.cwd = server.cwd;
|
|
731
|
-
} else {
|
|
732
|
-
config.url = server.url;
|
|
733
|
-
const headers = convertValueMap(server.name, "headers", server.headers, warnings);
|
|
734
|
-
if (headers !== void 0) config.headers = headers;
|
|
735
|
-
}
|
|
736
|
-
entries.push({
|
|
737
|
-
id: `mcp-${server.name}`,
|
|
738
|
-
name: "@deepseek-ai/dsh-mcp-client",
|
|
739
|
-
config
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
return {
|
|
743
|
-
servers: [...servers.values()],
|
|
744
|
-
entries,
|
|
745
|
-
warnings,
|
|
746
|
-
sources
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
function yamlScalar(value, indent) {
|
|
750
|
-
if (typeof value === "object" && value !== null && "__pi2dshJs" in value) return `!!js ${value.__pi2dshJs}`;
|
|
751
|
-
if (typeof value === "string") return /^[A-Za-z0-9@._\/:-]+$/u.test(value) ? value : JSON.stringify(value);
|
|
752
|
-
if (Array.isArray(value)) {
|
|
753
|
-
if (value.length === 0) return "[]";
|
|
754
|
-
return `\n${value.map((item) => `${indent} - ${yamlScalar(item, `${indent} `)}`).join("\n")}`;
|
|
755
|
-
}
|
|
756
|
-
if (typeof value === "object" && value !== null) {
|
|
757
|
-
const record = value;
|
|
758
|
-
const keys = Object.keys(record);
|
|
759
|
-
if (keys.length === 0) return "{}";
|
|
760
|
-
return `\n${keys.map((key) => `${indent} ${key}: ${yamlScalar(record[key], `${indent} `)}`).join("\n")}`;
|
|
761
|
-
}
|
|
762
|
-
return String(value);
|
|
763
|
-
}
|
|
764
|
-
/** Render the converted entries as a cordis.patch.yml `insert` block. */
|
|
765
|
-
function renderMcpPatch(result) {
|
|
766
|
-
if (result.entries.length === 0) return "# no enabled MCP servers found in Pi configuration\n";
|
|
767
|
-
const lines = ["- insert:"];
|
|
768
|
-
for (const entry of result.entries) {
|
|
769
|
-
lines.push(` - id: ${String(entry.id)}`);
|
|
770
|
-
lines.push(` name: '@deepseek-ai/dsh-mcp-client'`);
|
|
771
|
-
lines.push(` inject: [tools]`);
|
|
772
|
-
lines.push(` config:${yamlScalar(entry.config, " ")}`);
|
|
773
|
-
}
|
|
774
|
-
return `${lines.join("\n")}\n`;
|
|
775
|
-
}
|
|
776
|
-
//#endregion
|
|
777
|
-
export { CONTEXT_RULES as a, PI_AI_PACKAGES as c, UI_CONTEXT_RULES as d, ruleForApi as f, ruleForUiContextProperty as g, ruleForHostImport as h, API_RULES as i, PI_CODING_AGENT_PACKAGES as l, ruleForEvent as m, convertPiMcpConfig as n, EVENT_RULES as o, ruleForContextProperty as p, renderMcpPatch as r, HOST_IMPORT_RULES as s, collectPiMcpServers as t, PI_TUI_PACKAGES as u };
|
|
600
|
+
export { PI_AI_PACKAGES as a, UI_CONTEXT_RULES as c, ruleForEvent as d, ruleForHostImport as f, HOST_IMPORT_RULES as i, ruleForApi as l, CONTEXT_RULES as n, PI_CODING_AGENT_PACKAGES as o, ruleForUiContextProperty as p, EVENT_RULES as r, PI_TUI_PACKAGES as s, API_RULES as t, ruleForContextProperty as u };
|
|
778
601
|
|
|
779
|
-
//# sourceMappingURL=
|
|
602
|
+
//# sourceMappingURL=compatibility-D_PV1zgF.mjs.map
|