@hyperdreamer/pi-webui 1.24.1 → 1.26.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 +1 -1
- package/dist/client/assets/CodeViewer-BbtvtABF.js +4 -0
- package/dist/client/assets/{UnifiedDiffViewer-BFBQjlJd.js → UnifiedDiffViewer-B7xq-ET5.js} +1 -1
- package/dist/client/assets/{index-Bsp7hXcN.js → index-sujNbkL3.js} +475 -468
- package/dist/client/assets/{mathjaxEngine-CVXA3FNR.js → mathjaxEngine-CBUWmGvi.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/sessions/piSessionService.js +141 -29
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionModelPolicy.js +14 -2
- package/dist/server/sessions/sessionModelPolicy.js.map +1 -1
- package/dist/server/sessions/sessionRuntimeRestore.js +107 -0
- package/dist/server/sessions/sessionRuntimeRestore.js.map +1 -0
- package/dist/shared/apiTypes.d.ts +6 -1
- package/dist/shared/apiTypes.js.map +1 -1
- package/docs/config.md +2 -1
- package/package.json +7 -7
- package/dist/client/assets/CodeViewer-DgVx_yzp.js +0 -4
|
@@ -11,7 +11,7 @@ export class SessionModelPolicyResolutionError extends Error {
|
|
|
11
11
|
this.name = "SessionModelPolicyResolutionError";
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function readPersistedSessionModelPolicy(entries) {
|
|
15
15
|
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
16
16
|
const entry = entries[index];
|
|
17
17
|
if (!isPolicyEntry(entry))
|
|
@@ -23,10 +23,22 @@ export function inspectSessionModelPolicy(entries, fallback) {
|
|
|
23
23
|
return {
|
|
24
24
|
kind: "invalid",
|
|
25
25
|
reason: error instanceof Error ? error.message : String(error),
|
|
26
|
-
fallback: exactPolicy(fallback),
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
28
|
}
|
|
29
|
+
return { kind: "none" };
|
|
30
|
+
}
|
|
31
|
+
export function inspectSessionModelPolicy(entries, fallback) {
|
|
32
|
+
const inspection = readPersistedSessionModelPolicy(entries);
|
|
33
|
+
if (inspection.kind === "persisted")
|
|
34
|
+
return inspection;
|
|
35
|
+
if (inspection.kind === "invalid") {
|
|
36
|
+
return {
|
|
37
|
+
kind: "invalid",
|
|
38
|
+
reason: inspection.reason,
|
|
39
|
+
fallback: exactPolicy(fallback),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
30
42
|
return { kind: "legacy", policy: exactPolicy(fallback) };
|
|
31
43
|
}
|
|
32
44
|
export function serializeSessionModelPolicy(policy) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionModelPolicy.js","sourceRoot":"","sources":["../../../src/server/sessions/sessionModelPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,CAAC;AAExE;;;;GAIG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IAClD,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"sessionModelPolicy.js","sourceRoot":"","sources":["../../../src/server/sessions/sessionModelPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,CAAC;AAExE;;;;GAIG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IAClD,CAAC;CACF;AAiBD,MAAM,UAAU,+BAA+B,CAC7C,OAA2B;IAE3B,KAAK,IAAI,KAAK,G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AI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,SAA8B;IAC9D,OAAO;QACL,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE;QACrE,aAAa,EAAE,SAAS,CAAC,aAAa;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export function inspectSessionRuntimeSelection(entries) {
|
|
2
|
+
let modelEntry;
|
|
3
|
+
let thinkingEntry;
|
|
4
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
5
|
+
const entry = entries[index];
|
|
6
|
+
if (!isRecord(entry))
|
|
7
|
+
continue;
|
|
8
|
+
if (modelEntry === undefined && entry["type"] === "model_change")
|
|
9
|
+
modelEntry = entry;
|
|
10
|
+
if (thinkingEntry === undefined && entry["type"] === "thinking_level_change") {
|
|
11
|
+
thinkingEntry = entry;
|
|
12
|
+
}
|
|
13
|
+
if (modelEntry !== undefined && thinkingEntry !== undefined)
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
if (modelEntry === undefined)
|
|
17
|
+
return { kind: "none" };
|
|
18
|
+
const provider = modelEntry["provider"];
|
|
19
|
+
if (typeof provider !== "string" || provider.trim() === "") {
|
|
20
|
+
return { kind: "invalid", reason: "model change provider must be a non-blank string" };
|
|
21
|
+
}
|
|
22
|
+
const modelId = modelEntry["modelId"];
|
|
23
|
+
if (typeof modelId !== "string" || modelId.trim() === "") {
|
|
24
|
+
return { kind: "invalid", reason: "model change model id must be a non-blank string" };
|
|
25
|
+
}
|
|
26
|
+
if (thinkingEntry === undefined) {
|
|
27
|
+
return { kind: "selection", model: { provider, id: modelId } };
|
|
28
|
+
}
|
|
29
|
+
const thinkingLevel = thinkingEntry["thinkingLevel"];
|
|
30
|
+
if (typeof thinkingLevel !== "string" || thinkingLevel.trim() === "") {
|
|
31
|
+
return { kind: "invalid", reason: "thinking level must be a non-blank string" };
|
|
32
|
+
}
|
|
33
|
+
return { kind: "selection", model: { provider, id: modelId }, thinkingLevel };
|
|
34
|
+
}
|
|
35
|
+
export function planSessionRuntimeRestore(input) {
|
|
36
|
+
const { selection, persistedPolicy, resolvedModel, existingBlock } = input;
|
|
37
|
+
const unproven = existingBlock?.cause === "runtime-tuple-unproven" ? existingBlock : undefined;
|
|
38
|
+
if (selection.kind === "none")
|
|
39
|
+
return { kind: "none" };
|
|
40
|
+
if (selection.kind === "invalid") {
|
|
41
|
+
return unproven === undefined
|
|
42
|
+
? { kind: "block", cause: "selection-unavailable", reason: selection.reason }
|
|
43
|
+
: { kind: "block", cause: "runtime-tuple-unproven", reason: unproven.reason };
|
|
44
|
+
}
|
|
45
|
+
const unavailableReason = unavailableSelectionReason(selection, resolvedModel);
|
|
46
|
+
if (unavailableReason !== undefined) {
|
|
47
|
+
return unproven === undefined
|
|
48
|
+
? { kind: "block", cause: "selection-unavailable", reason: unavailableReason }
|
|
49
|
+
: { kind: "block", cause: "runtime-tuple-unproven", reason: unproven.reason };
|
|
50
|
+
}
|
|
51
|
+
if (persistedPolicy.kind === "persisted" &&
|
|
52
|
+
persistedPolicy.policy.mode === "exact" &&
|
|
53
|
+
!sameExactSelection(persistedPolicy.policy.exact, selection)) {
|
|
54
|
+
return unproven === undefined
|
|
55
|
+
? {
|
|
56
|
+
kind: "block",
|
|
57
|
+
cause: "runtime-tuple-unproven",
|
|
58
|
+
reason: disagreementReason(selection, persistedPolicy.policy.exact),
|
|
59
|
+
}
|
|
60
|
+
: { kind: "block", cause: "runtime-tuple-unproven", reason: unproven.reason };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
kind: "apply",
|
|
64
|
+
model: { provider: selection.model.provider, id: selection.model.id },
|
|
65
|
+
...(selection.thinkingLevel === undefined
|
|
66
|
+
? {}
|
|
67
|
+
: { thinkingLevel: selection.thinkingLevel }),
|
|
68
|
+
clearSelectionUnavailable: existingBlock?.cause === "selection-unavailable",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function unavailableSelectionReason(selection, resolvedModel) {
|
|
72
|
+
const described = `${selection.model.provider}/${selection.model.id}`;
|
|
73
|
+
const unavailable = `the newest recorded model ${described} is unavailable in this session's catalog`;
|
|
74
|
+
if (resolvedModel === undefined)
|
|
75
|
+
return unavailable;
|
|
76
|
+
if (resolvedModel.provider !== selection.model.provider ||
|
|
77
|
+
resolvedModel.id !== selection.model.id) {
|
|
78
|
+
return unavailable;
|
|
79
|
+
}
|
|
80
|
+
if (selection.thinkingLevel !== undefined &&
|
|
81
|
+
!resolvedModel.thinkingLevels.includes(selection.thinkingLevel)) {
|
|
82
|
+
return `the newest recorded thinking level ${selection.thinkingLevel} is unsupported by ${described}`;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
function sameExactSelection(exact, selection) {
|
|
87
|
+
return (exact.model.provider === selection.model.provider &&
|
|
88
|
+
exact.model.id === selection.model.id &&
|
|
89
|
+
(selection.thinkingLevel === undefined ||
|
|
90
|
+
exact.thinkingLevel === selection.thinkingLevel));
|
|
91
|
+
}
|
|
92
|
+
function disagreementReason(selection, exact) {
|
|
93
|
+
return `the newest recorded model selection ${describeRecorded(selection)} disagrees with the persisted Exact policy ${describeExact(exact)}; apply an explicit session model policy update to repair the session`;
|
|
94
|
+
}
|
|
95
|
+
function describeRecorded(selection) {
|
|
96
|
+
const described = `${selection.model.provider}/${selection.model.id}`;
|
|
97
|
+
return selection.thinkingLevel === undefined
|
|
98
|
+
? described
|
|
99
|
+
: `${described} at thinking level ${selection.thinkingLevel}`;
|
|
100
|
+
}
|
|
101
|
+
function describeExact(exact) {
|
|
102
|
+
return `${exact.model.provider}/${exact.model.id} at thinking level ${exact.thinkingLevel}`;
|
|
103
|
+
}
|
|
104
|
+
function isRecord(value) {
|
|
105
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=sessionRuntimeRestore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRuntimeRestore.js","sourceRoot":"","sources":["../../../src/server/sessions/sessionRuntimeRestore.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,8BAA8B,CAC5C,OAA2B;IAE3B,IAAI,UAA+C,CAAC;IACpD,IAAI,aAAkD,CAAC;IACvD,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,SAAS;QAC/B,IAAI,UAAU,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,cAAc;YAAE,UAAU,GAAG,KAAK,CAAC;QACrF,IAAI,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,uBAAuB,EAAE,CAAC;YAC7E,aAAa,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS;YAAE,MAAM;IACrE,CAAC;IACD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAEtD,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,kDAAkD,EAAE,CAAC;IACzF,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,OAAO,OAAO,KAAK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,CAAC,uEAAuE,CAAC;AACrN,CAAC;AAED,SAAS,gBAAgB,CAAC,SAGzB;IACC,MAAM,SAAS,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;IACtE,OAAO,SAAS,CAAC,aAAa,KAAK,SAAS;QAC1C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,GAAG,SAAS,sBAAsB,SAAS,CAAC,aAAa,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,aAAa,CAAC,KAA0B;IAC/C,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,sBAAsB,KAAK,CAAC,aAAa,EAAE,CAAC;AAC9F,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -314,7 +314,12 @@ export type SessionModelPolicyUpdate = {
|
|
|
314
314
|
export interface ClientSessionModelPolicyStatus {
|
|
315
315
|
mode: SessionModelPolicyMode;
|
|
316
316
|
tier?: ModelTier;
|
|
317
|
-
/**
|
|
317
|
+
/**
|
|
318
|
+
* The tuple last confirmed by the policy runtime adapter in this staged slice; outside a
|
|
319
|
+
* transition it is the live runtime tuple, which a reopen can restore from the transcript's newest
|
|
320
|
+
* recorded selection. While a block is active it can be Pi's branch-restore fallback rather than
|
|
321
|
+
* the recorded selection.
|
|
322
|
+
*/
|
|
318
323
|
resolved: ExactModelSelection;
|
|
319
324
|
ladderValid: boolean;
|
|
320
325
|
blockedReason?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiTypes.js","sourceRoot":"","sources":["../../src/shared/apiTypes.ts"],"names":[],"mappings":"AA0FA,MAAM,CAAC,MAAM,qBAAqB,GAAG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BAA6B,GAAG,EAAE,GAAG,IAAI,CAAC;AACvD,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,CAAC;AACxD,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,CAAC;AAqCzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,IAAI,CAAC;AAi0B3D,MAAM,CAAC,MAAM,2CAA2C,GAAG,MAAM,CAAC;AAmDlE,oGAAoG;AACpG,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC"}
|
package/docs/config.md
CHANGED
|
@@ -343,10 +343,11 @@ Sessions can also use a per-session model policy from the composer:
|
|
|
343
343
|
|
|
344
344
|
- **Composer controls:** The composer action row has three cascading controls: a mode pill, a mode-dependent second control, and an Exact-only thinking menu. The mode pill opens a two-item mode menu: **Exact model** with the hint "Choose a model and thinking level", and **Tiered** with the hint "Use a configured model tier". A checkmark marks the current mode. There is no policy panel or Save button.
|
|
345
345
|
- **Default and restoration:** On a fully capable peer, a fresh workspace starts in Tiered mode at Standard. The starter model policy preference restores the full policy for the selected machine and normalized workspace: mode, Exact provider/model/thinking, and remembered tier.
|
|
346
|
+
- **Session-level model selection:** The session's model selection is session-level: the newest model and thinking level recorded anywhere in the session transcript are authoritative, not only the entries on the active conversation branch. **Edit from here** and the session-tree navigator change which conversation is active, not which model the session uses, and they do not change the model policy the composer displays. When a session is reopened, PI WEBUI restores the newest recorded model and thinking level. A recorded model that is unavailable (for example a virtual model whose extension is not loaded) or a recorded thinking level the model does not support blocks prompts with a visible `MODEL_POLICY_BLOCKED` reason. The block clears on the next runtime open once the recorded selection resolves again and agrees with the persisted policy (for example after adding credentials or re-enabling the extension, then reopening the session), or immediately through an explicit policy update; if the newest recorded selection disagrees with the persisted Exact policy, the session stays blocked until that explicit update.
|
|
346
347
|
- **Exact controls:** The second control is the searchable model picker, and the third is a thinking level menu whose trigger is a bar gauge showing the current level's rank, with the level name in its tooltip. The menu lists levels relevant to the selected model in canonical ascending order: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. A level the model does not support stays visible but dimmed, says `unsupported by this model`, and cannot be selected. An Exact change applies once both a model and a supported thinking level are selected.
|
|
347
348
|
- **Remembered starter policy:** Only a root created successfully through **SESSIONS +** owns future full-policy updates to this personal managed state. Imported, prompt-created, spawned, and tracked sessions never become preference sources. Selecting Exact retains the remembered tier for a later switch back.
|
|
348
349
|
- **Tiered:** In Tiered mode, the second control is a tier menu listing all six ladder tiers. An unusable tier stays visible with its specific reason inline instead of being hidden, and selecting a valid tier applies immediately. No thinking control renders in Tiered mode; it is absent rather than disabled. Switching modes is non-destructive in both directions: the remembered tier and the remembered Exact model/thinking selection stay intact.
|
|
349
|
-
- **Validation and recovery:** Unavailable active intent remains selected and shows its specific reason until the user repairs that active
|
|
350
|
+
- **Validation and recovery:** Unavailable active intent remains selected and shows its specific reason until the user repairs that active mode. When the lightweight fallback is available, a complete policy whose active intent cannot resolve still starts on the configured `lightweight` utility model (see [Utility models](#utility-models)); otherwise no other ladder tier or Exact selection is substituted and Start stays blocked. Intent remembered in the inactive Exact/Tiered mode is retained and non-blocking until that mode becomes active. A refused Start reports its reason without closing the new-session screen, and the reason is shown whether or not a session is currently selected in that workspace. The message follows the current reason and disappears once the block is repaired.
|
|
350
351
|
- **Persistence failures:** If PI WEBUI cannot read the preference, it shows the preference error without discarding the in-memory policy. A writeback failure is non-blocking: the current session retains its selected policy, and PI WEBUI warns that the choice was not remembered.
|
|
351
352
|
- **When changes are available:** You can change a policy only while its session is idle and writable. During active work and for archived sessions, the current policy and any block reason remain visible but the controls are disabled. Once the session is idle and writable, a blocked policy remains repairable through an explicit update.
|
|
352
353
|
- **Availability and compatibility:** Per-session policy uses `sessions.modelPolicy`; restoring and writing back the full starter preference additionally requires `sessions.modelPolicyStarterSelection` on both web and session daemon; the lightweight fallback for an unresolvable policy additionally requires `sessions.modelPolicyLightweightFallback` on both web and session daemon, and an older or unrestarted daemon keeps the existing hard block. `sessions.modelPolicyDefaults` remains the version-one mode/tier preference path. Older peers retain version-one behavior.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperdreamer/pi-webui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Web UI for persistent Pi Coding Agent sessions in real workspaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Federico Jaramillo Martinez and HyperDreamer",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@changesets/cli": "^2.31.0",
|
|
92
|
-
"@earendil-works/pi-agent-core": "^1.0
|
|
93
|
-
"@earendil-works/pi-ai": "^1.0
|
|
94
|
-
"@earendil-works/pi-coding-agent": "^1.0
|
|
92
|
+
"@earendil-works/pi-agent-core": "^1.2.0",
|
|
93
|
+
"@earendil-works/pi-ai": "^1.2.0",
|
|
94
|
+
"@earendil-works/pi-coding-agent": "^1.2.0",
|
|
95
95
|
"@eslint/js": "^10.0.1",
|
|
96
96
|
"@types/node": "^24.13.3",
|
|
97
97
|
"@types/ws": "^8.18.1",
|
|
@@ -126,9 +126,9 @@
|
|
|
126
126
|
"homepage": "https://pi-webui.dev/",
|
|
127
127
|
"packageManager": "npm@11.11.0",
|
|
128
128
|
"peerDependencies": {
|
|
129
|
-
"@earendil-works/pi-agent-core": ">=1.0
|
|
130
|
-
"@earendil-works/pi-ai": ">=1.0
|
|
131
|
-
"@earendil-works/pi-coding-agent": ">=1.0
|
|
129
|
+
"@earendil-works/pi-agent-core": ">=1.2.0 <2",
|
|
130
|
+
"@earendil-works/pi-ai": ">=1.2.0 <2",
|
|
131
|
+
"@earendil-works/pi-coding-agent": ">=1.2.0 <2"
|
|
132
132
|
},
|
|
133
133
|
"keywords": [
|
|
134
134
|
"pi-package",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{J as e,P as t,S as n,X as r,Z as i,l as a,tt as o,y as s}from"./vendor-editor-core-vyMPzMNA.js";import{c,i as l,l as u,n as d,r as f,s as p,t as m,u as h}from"./vendor-editor-languages-DlEQaRIv.js";import{a as g,c as _,i as v,o as y,r as b,s as x,t as S}from"./index-Bsp7hXcN.js";import{t as C}from"./vendor-editor-legacy-CYBnW6ZU.js";var w=class extends y{constructor(...e){super(...e),this.content=``}firstUpdated(){this.recreateEditor()}updated(e){(e.has(`content`)||e.has(`language`))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return x`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new e({parent:this.editorHost,state:o.create({doc:this.content,extensions:[i(),r.of(a),t(n,{fallback:!0}),o.readOnly.of(!0),e.editable.of(!1),e.lineWrapping,T,...D(this.language),...O(this.language)]})}))}static{this.styles=_`
|
|
2
|
-
:host { display: block; min-height: 0; height: 100%; }
|
|
3
|
-
.host { height: 100%; min-height: 0; overflow: auto; }
|
|
4
|
-
`}};S([v()],w.prototype,`content`,void 0),S([v()],w.prototype,`language`,void 0),S([b(`.host`)],w.prototype,`editorHost`,void 0),w=S([g(`code-viewer`)],w);var T=e.theme({"&":{height:`100%`,color:`var(--pi-text)`,backgroundColor:`var(--pi-bg)`,fontSize:`12px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,lineHeight:`1.45`},".cm-gutters":{backgroundColor:`var(--pi-bg)`,color:`var(--pi-dim)`,borderRight:`1px solid var(--pi-border-muted)`},".cm-activeLineGutter":{backgroundColor:`transparent`},".cm-activeLine":{backgroundColor:`transparent`},".cm-content":{caretColor:`transparent`},"&.cm-focused":{outline:`none`}}),E=e.theme({".cm-content":{textAlign:`start`},".cm-line":{unicodeBidi:`plaintext`}});function D(t){return t===`markdown`?[e.contentAttributes.of({dir:`auto`}),E]:[]}function O(e){if(e===void 0)return[];switch(e){case`typescript`:return[u({typescript:!0})];case`javascript`:return[u()];case`json`:return[l()];case`markdown`:return[p()];case`css`:return[h()];case`html`:return[c()];case`python`:return[f()];case`rust`:return[d()];case`go`:return[m()];case`diff`:return[s.define(C)];default:return[]}}export{w as CodeViewer};
|