@timurproko/a1 0.1.8-dev.299 → 0.1.8-dev.332
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 +16 -4
- package/bin/guardian.js +4 -3
- package/bin/ui.js +4 -2
- package/bin/update-recovery.js +3 -1
- package/dist/cli/dispatch.js +1 -1
- package/dist/composition/owned-ui.js +2 -1
- package/dist/features/launch/profile-paths.d.ts +2 -0
- package/dist/features/launch/profile-paths.js +11 -0
- package/dist/features/owned-ui/project-trust-prompt.js +1 -1
- package/dist/features/owned-ui/settings-app.js +1 -1
- package/dist/features/prompt-history/service.d.ts +31 -1
- package/dist/features/prompt-history/service.js +294 -129
- package/dist/features/prompt-history/store.d.ts +2 -1
- package/dist/features/prompt-history/store.js +17 -4
- package/dist/features/prompt-history/worker.js +6 -3
- package/dist/foundation/launch-context/index.d.ts +59 -0
- package/dist/foundation/launch-context/index.js +136 -0
- package/dist/foundation/launch-guardian/main.js +6 -4
- package/dist/foundation/release/bootstrap.d.ts +6 -1
- package/dist/foundation/release/bootstrap.js +59 -13
- package/dist/foundation/release/cohort-state.d.ts +1 -0
- package/dist/foundation/release/cohort-state.js +1 -0
- package/dist/foundation/release/dependency-certification-retention.d.ts +7 -0
- package/dist/foundation/release/dependency-certification-retention.js +88 -0
- package/dist/foundation/release/dependency-certification.d.ts +24 -0
- package/dist/foundation/release/dependency-certification.js +208 -0
- package/dist/foundation/release/dependency-layer.d.ts +3 -4
- package/dist/foundation/release/dependency-layer.js +6 -37
- package/dist/foundation/release/release-gc.js +74 -46
- package/dist/foundation/release/release-store.d.ts +2 -0
- package/dist/foundation/release/release-store.js +11 -3
- package/dist/foundation/release/release.d.ts +3 -1
- package/dist/foundation/release/release.js +7 -3
- package/dist/foundation/release/restart-certification.d.ts +1 -0
- package/dist/foundation/release/restart-certification.js +17 -1
- package/dist/foundation/release/update-recovery.d.ts +2 -0
- package/dist/foundation/release/update-recovery.js +4 -0
- package/dist/foundation/release/update.js +1 -1
- package/dist/foundation/release/warmup.d.ts +1 -1
- package/dist/foundation/release/warmup.js +18 -6
- package/dist/foundation/startup/startup-runtime.js +13 -11
- package/dist/foundation/supervision/main.js +8 -7
- package/dist/integrations/pi/components/owned-editor-ux.d.ts +2 -1
- package/dist/integrations/pi/components/owned-editor-ux.js +105 -30
- package/dist/integrations/pi/components/shell-editor-autocomplete.js +3 -0
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +9 -2
- package/dist/integrations/pi/components/shell-presenters-info.js +35 -4
- package/dist/integrations/pi/components/shell-selectors-dialogs.d.ts +3 -2
- package/dist/integrations/pi/components/shell-selectors-dialogs.js +8 -5
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +9 -2
- package/dist/integrations/pi/components/upstream/assets/earendil-image.json +12 -0
- package/dist/integrations/pi/components/upstream/components/earendil-announcement.js +25 -2
- package/dist/integrations/pi/engine/adapter.d.ts +33 -1
- package/dist/integrations/pi/engine/adapter.js +309 -112
- package/dist/integrations/pi/engine/changelog.d.ts +2 -0
- package/dist/integrations/pi/engine/changelog.js +63 -0
- package/dist/integrations/pi/engine/pending-delivery.d.ts +26 -0
- package/dist/integrations/pi/engine/pending-delivery.js +149 -0
- package/dist/integrations/pi/engine/resources/changelog.json +12 -0
- package/dist/integrations/pi/engine/workflow-controllers.d.ts +1 -1
- package/dist/integrations/pi/engine/workflows.d.ts +1 -1
- package/dist/integrations/pi/session-ui/prompt-chips.d.ts +3 -1
- package/dist/integrations/pi/session-ui/prompt-chips.js +74 -37
- package/dist/integrations/pi/session-ui/prompt-history-controller.d.ts +0 -2
- package/dist/integrations/pi/session-ui/prompt-history-controller.js +3 -8
- package/dist/integrations/pi/session-ui/session-shell-root.d.ts +26 -1
- package/dist/integrations/pi/session-ui/session-shell-root.js +70 -75
- package/dist/integrations/pi/session-ui/session-shell.d.ts +1 -1
- package/dist/integrations/pi/session-ui/session-shell.js +67 -13
- package/dist/integrations/pi/session-ui/session-viewport-controller.d.ts +7 -2
- package/dist/integrations/pi/session-ui/session-viewport-controller.js +25 -20
- package/dist/integrations/pi/session-ui/text-paste.d.ts +5 -0
- package/dist/integrations/pi/session-ui/text-paste.js +16 -0
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +9 -2
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +87 -43
- package/dist/native/darwin-arm64/manifest.json +1 -1
- package/dist/native/linux-x64/manifest.json +1 -1
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/native/win32-x64/process-guardian.exe +0 -0
- package/dist/product-identity.d.ts +1 -1
- package/dist/product-identity.js +2 -35
- package/dist/product-identity.json +1 -23
- package/dist/ui/components/transcript-viewport.d.ts +8 -0
- package/dist/ui/components/transcript-viewport.js +23 -2
- package/dist/ui/components/visible-hyperlinks.d.ts +7 -0
- package/dist/ui/components/visible-hyperlinks.js +1 -0
- package/dist/ui/settings/declarations.js +1 -0
- package/dist/ui/settings/sections.js +11 -1
- package/docs/architecture/boundaries.md +2 -1
- package/docs/architecture/internal-naming.md +91 -0
- package/docs/architecture/resource-and-data-policy.md +9 -4
- package/docs/architecture/toolchain.md +15 -1
- package/docs/features/prompt-history.md +39 -11
- package/docs/manual-code-streaming-cleanup.md +88 -0
- package/package.json +8 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { posix } from "node:path";
|
|
4
|
+
const REPOSITORY = "https://github.com/earendil-works/pi";
|
|
5
|
+
export async function readPinnedCommandChangelog(sinceVersion) {
|
|
6
|
+
const path = new URL("./resources/changelog.json", import.meta.url);
|
|
7
|
+
if (!existsSync(path))
|
|
8
|
+
return sinceVersion === undefined ? "No changelog entries found." : "";
|
|
9
|
+
try {
|
|
10
|
+
const resource = JSON.parse(await readFile(path, "utf8"));
|
|
11
|
+
if (!resource || typeof resource !== "object" || !("data" in resource) || typeof resource.data !== "string")
|
|
12
|
+
throw new TypeError("Invalid owned changelog resource");
|
|
13
|
+
const markdown = resource.data;
|
|
14
|
+
return formatPinnedCommandChangelog(markdown, sinceVersion);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// Compatibility: Pi's data-file parser reports a warning and supplies an empty changelog.
|
|
18
|
+
console.error(`Warning: Could not parse changelog: ${error}`);
|
|
19
|
+
return sinceVersion === undefined ? "No changelog entries found." : "";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function formatPinnedCommandChangelog(content, sinceVersion) {
|
|
23
|
+
// Provenance: behavior follows Pi 0.84.2 utils/changelog.ts at 914cf1472e715297caa30db4b9535d534a9eb718.
|
|
24
|
+
// Runtime reads only the owned data resource; maintenance tooling verifies its pinned provenance.
|
|
25
|
+
let releases = content.split(/(?=^## )/m).flatMap((section) => {
|
|
26
|
+
const version = /^##\s+\[?(\d+)\.(\d+)\.(\d+)\]?/.exec(section);
|
|
27
|
+
return version ? [{ version: version.slice(1).map(Number), markdown: section.trim() }] : [];
|
|
28
|
+
});
|
|
29
|
+
if (sinceVersion !== undefined) {
|
|
30
|
+
const previous = sinceVersion.split(".").map(value => Number(value) || 0);
|
|
31
|
+
releases = releases.filter(release => {
|
|
32
|
+
for (let index = 0; index < 3; index++) {
|
|
33
|
+
const difference = release.version[index] - (previous[index] ?? 0);
|
|
34
|
+
if (difference !== 0)
|
|
35
|
+
return difference > 0;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
releases.reverse();
|
|
42
|
+
if (releases.length === 0)
|
|
43
|
+
return sinceVersion === undefined ? "No changelog entries found." : "";
|
|
44
|
+
return releases.map(release => release.markdown.replace(/(!?\[[^\]\n]+\]\()([^\s)]+)((?:\s+[^)]*)?\))/g, (_match, prefix, target, suffix) => `${prefix}${releaseLink(target, `v${release.version.join(".")}`)}${suffix}`)).join("\n\n");
|
|
45
|
+
}
|
|
46
|
+
function releaseLink(target, tag) {
|
|
47
|
+
const canonical = target
|
|
48
|
+
.replace(/^https:\/\/github\.com\/(?:badlogic|earendil-works)\/pi-mono(?=\/|$)/, REPOSITORY)
|
|
49
|
+
.replace(/^(https:\/\/github\.com\/earendil-works\/pi\/(?:blob|tree)\/)(?:main|master)\//, `$1${tag}/`);
|
|
50
|
+
if (/^(?:#|\/\/|[a-z][a-z0-9+.-]*:)/i.test(canonical))
|
|
51
|
+
return canonical;
|
|
52
|
+
const boundary = canonical.search(/[?#]/);
|
|
53
|
+
const path = boundary === -1 ? canonical : canonical.slice(0, boundary);
|
|
54
|
+
const suffix = boundary === -1 ? "" : canonical.slice(boundary);
|
|
55
|
+
if (!path)
|
|
56
|
+
return canonical;
|
|
57
|
+
const normalized = path.replaceAll("\\", "/");
|
|
58
|
+
const repositoryPath = posix.normalize(normalized.startsWith("/") ? normalized.replace(/^\/+/, "") : posix.join("packages/coding-agent", normalized));
|
|
59
|
+
if (repositoryPath === "." || repositoryPath === ".." || repositoryPath.startsWith("../"))
|
|
60
|
+
return canonical;
|
|
61
|
+
const route = path.endsWith("/") || !posix.basename(repositoryPath).includes(".") ? "tree" : "blob";
|
|
62
|
+
return `${REPOSITORY}/${route}/${tag}/${encodeURI(repositoryPath)}${suffix}`;
|
|
63
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { OwnedUiEvent } from "../../../contracts/owned-ui/index.js";
|
|
2
|
+
export declare const MAX_PENDING_EVENTS = 1024;
|
|
3
|
+
export declare const MAX_PENDING_EVENT_BYTES: number;
|
|
4
|
+
/** Actual shell semantics: only live complete block state has no independent side effect. */
|
|
5
|
+
export declare function replaceableEventKey(event: OwnedUiEvent): string | null;
|
|
6
|
+
/** Intrusive FIFO + segment index: replacement unlinks in O(1), never changes source ordering. */
|
|
7
|
+
export declare class PendingEngineDelivery {
|
|
8
|
+
#private;
|
|
9
|
+
get size(): number;
|
|
10
|
+
diagnostics(): {
|
|
11
|
+
pending: number;
|
|
12
|
+
bytes: number;
|
|
13
|
+
protected: number;
|
|
14
|
+
superseded: number;
|
|
15
|
+
peakNodes: number;
|
|
16
|
+
peakBytes: number;
|
|
17
|
+
};
|
|
18
|
+
/** False means not admitted. The caller must enter its reserved recovery protocol, never evict. */
|
|
19
|
+
push(event: OwnedUiEvent, generation: number, reconcile?: () => OwnedUiEvent): boolean;
|
|
20
|
+
/** Session replacement invalidates old view state without resolving its lazy block references. */
|
|
21
|
+
discardObsolete(generation: number): number;
|
|
22
|
+
shift(): {
|
|
23
|
+
event: OwnedUiEvent;
|
|
24
|
+
generation: number;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export const MAX_PENDING_EVENTS = 1024;
|
|
2
|
+
export const MAX_PENDING_EVENT_BYTES = 8 * 1024 * 1024;
|
|
3
|
+
/** Actual shell semantics: only live complete block state has no independent side effect. */
|
|
4
|
+
export function replaceableEventKey(event) {
|
|
5
|
+
switch (event.type) {
|
|
6
|
+
case "transcript-block": return event.block.status === "live" && !(typeof event.block.payload === "object" && event.block.payload !== null && "isError" in event.block.payload && event.block.payload.isError === true) ? event.block.id : null;
|
|
7
|
+
case "session-view": // Invariant: may clear compaction work, replace editor/session state, or preempt presentation.
|
|
8
|
+
case "status": // Invariant: retry/compaction transitions invalidate suggestion work.
|
|
9
|
+
case "editor-state":
|
|
10
|
+
case "terminal-surface":
|
|
11
|
+
case "session-lifecycle":
|
|
12
|
+
case "agent-run-started":
|
|
13
|
+
case "agent-run-settled":
|
|
14
|
+
case "assistant-message-completed":
|
|
15
|
+
case "command-outcome":
|
|
16
|
+
case "diagnostic":
|
|
17
|
+
case "dialog":
|
|
18
|
+
case "overlay":
|
|
19
|
+
case "customization": return null;
|
|
20
|
+
default: {
|
|
21
|
+
const exhaustive = event;
|
|
22
|
+
return exhaustive;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Intrusive FIFO + segment index: replacement unlinks in O(1), never changes source ordering. */
|
|
27
|
+
export class PendingEngineDelivery {
|
|
28
|
+
#replaceable = new Map();
|
|
29
|
+
#head;
|
|
30
|
+
#tail;
|
|
31
|
+
#size = 0;
|
|
32
|
+
#bytes = 0;
|
|
33
|
+
#protected = 0;
|
|
34
|
+
#generation = -1;
|
|
35
|
+
#superseded = 0;
|
|
36
|
+
#peakNodes = 0;
|
|
37
|
+
#peakBytes = 0;
|
|
38
|
+
get size() { return this.#size; }
|
|
39
|
+
diagnostics() {
|
|
40
|
+
return { pending: this.#size, bytes: this.#bytes, protected: this.#protected,
|
|
41
|
+
superseded: this.#superseded, peakNodes: this.#peakNodes, peakBytes: this.#peakBytes };
|
|
42
|
+
}
|
|
43
|
+
/** False means not admitted. The caller must enter its reserved recovery protocol, never evict. */
|
|
44
|
+
push(event, generation, reconcile) {
|
|
45
|
+
const key = replaceableEventKey(event);
|
|
46
|
+
if (generation !== this.#generation || key === null) {
|
|
47
|
+
if (!this.#seal())
|
|
48
|
+
return false;
|
|
49
|
+
this.#generation = generation;
|
|
50
|
+
}
|
|
51
|
+
const prior = key === null ? undefined : this.#replaceable.get(key);
|
|
52
|
+
let bytes = retainedEventBytes(event);
|
|
53
|
+
const marker = key !== null && bytes > 64 * 1024 && reconcile !== undefined;
|
|
54
|
+
if (marker)
|
|
55
|
+
bytes = 128;
|
|
56
|
+
if (this.#size - (prior === undefined ? 0 : 1) >= MAX_PENDING_EVENTS
|
|
57
|
+
|| this.#bytes - (prior?.bytes ?? 0) + bytes > MAX_PENDING_EVENT_BYTES)
|
|
58
|
+
return false;
|
|
59
|
+
if (prior !== undefined) {
|
|
60
|
+
this.#unlink(prior);
|
|
61
|
+
this.#superseded = Math.min(Number.MAX_SAFE_INTEGER, this.#superseded + 1);
|
|
62
|
+
}
|
|
63
|
+
const node = { key, generation, bytes, ...(marker ? { resolve: reconcile } : { event }) };
|
|
64
|
+
node.previous = this.#tail;
|
|
65
|
+
if (this.#tail !== undefined)
|
|
66
|
+
this.#tail.next = node;
|
|
67
|
+
else
|
|
68
|
+
this.#head = node;
|
|
69
|
+
this.#tail = node;
|
|
70
|
+
this.#size++;
|
|
71
|
+
this.#bytes += bytes;
|
|
72
|
+
if (key === null)
|
|
73
|
+
this.#protected++;
|
|
74
|
+
else
|
|
75
|
+
this.#replaceable.set(key, node);
|
|
76
|
+
this.#peakNodes = Math.max(this.#peakNodes, this.#size);
|
|
77
|
+
this.#peakBytes = Math.max(this.#peakBytes, this.#bytes);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/** Session replacement invalidates old view state without resolving its lazy block references. */
|
|
81
|
+
discardObsolete(generation) {
|
|
82
|
+
let discarded = 0;
|
|
83
|
+
let node = this.#head;
|
|
84
|
+
while (node !== undefined) {
|
|
85
|
+
const next = node.next;
|
|
86
|
+
if (node.generation !== generation && node.event?.type !== "command-outcome") {
|
|
87
|
+
this.#unlink(node);
|
|
88
|
+
discarded++;
|
|
89
|
+
}
|
|
90
|
+
node = next;
|
|
91
|
+
}
|
|
92
|
+
this.#replaceable.clear();
|
|
93
|
+
this.#generation = generation;
|
|
94
|
+
return discarded;
|
|
95
|
+
}
|
|
96
|
+
shift() {
|
|
97
|
+
const node = this.#head;
|
|
98
|
+
if (node === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
const event = node.event ?? node.resolve();
|
|
101
|
+
this.#unlink(node);
|
|
102
|
+
return { event, generation: node.generation };
|
|
103
|
+
}
|
|
104
|
+
// Invariant: a barrier freezes lazy authoritative markers before a later segment can change them.
|
|
105
|
+
#seal() {
|
|
106
|
+
for (const node of this.#replaceable.values()) {
|
|
107
|
+
if (node.resolve === undefined)
|
|
108
|
+
continue;
|
|
109
|
+
const event = node.resolve();
|
|
110
|
+
const bytes = retainedEventBytes(event);
|
|
111
|
+
if (this.#bytes - node.bytes + bytes > MAX_PENDING_EVENT_BYTES)
|
|
112
|
+
return false;
|
|
113
|
+
this.#bytes += bytes - node.bytes;
|
|
114
|
+
node.bytes = bytes;
|
|
115
|
+
node.event = event;
|
|
116
|
+
node.resolve = undefined;
|
|
117
|
+
this.#peakBytes = Math.max(this.#peakBytes, this.#bytes);
|
|
118
|
+
}
|
|
119
|
+
this.#replaceable.clear();
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
#unlink(node) {
|
|
123
|
+
if (node.previous !== undefined)
|
|
124
|
+
node.previous.next = node.next;
|
|
125
|
+
else
|
|
126
|
+
this.#head = node.next;
|
|
127
|
+
if (node.next !== undefined)
|
|
128
|
+
node.next.previous = node.previous;
|
|
129
|
+
else
|
|
130
|
+
this.#tail = node.previous;
|
|
131
|
+
this.#size--;
|
|
132
|
+
this.#bytes -= node.bytes;
|
|
133
|
+
if (node.key === null)
|
|
134
|
+
this.#protected--;
|
|
135
|
+
else if (this.#replaceable.get(node.key) === node)
|
|
136
|
+
this.#replaceable.delete(node.key);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Conservative UTF-16 payload bound. String length is O(1); never encode accumulated text per chunk. */
|
|
140
|
+
function retainedEventBytes(value) {
|
|
141
|
+
if (typeof value === "string")
|
|
142
|
+
return 16 + value.length * 2;
|
|
143
|
+
if (value === null || typeof value !== "object")
|
|
144
|
+
return 8;
|
|
145
|
+
let bytes = 32;
|
|
146
|
+
for (const [key, item] of Object.entries(value))
|
|
147
|
+
bytes += 16 + key.length * 2 + retainedEventBytes(item);
|
|
148
|
+
return bytes;
|
|
149
|
+
}
|