@timurproko/a1 0.2.7-dev.1252 → 0.2.7-dev.1264
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/bin/ui.js +3 -3
- package/dist/app/session-shell/clipboard-diagnostics.d.ts +2 -2
- package/dist/app/session-shell/clipboard-image.d.ts +0 -1
- package/dist/app/session-shell/clipboard-image.js +1 -1
- package/dist/app/session-shell/dialog-coordinator.d.ts +6 -5
- package/dist/app/session-shell/dialog-coordinator.js +3 -4
- package/dist/app/session-shell/dock-chrome.d.ts +11 -6
- package/dist/app/session-shell/dock-chrome.js +5 -8
- package/dist/app/session-shell/editor-hyperlink-budget.d.ts +0 -2
- package/dist/app/session-shell/editor-hyperlink-budget.js +1 -1
- package/dist/app/session-shell/exit-notice.d.ts +2 -2
- package/dist/app/session-shell/exit-notice.js +1 -1
- package/dist/app/session-shell/extension-surface.d.ts +8 -7
- package/dist/app/session-shell/helper-pool.d.ts +3 -4
- package/dist/app/session-shell/helper-pool.js +1 -1
- package/dist/app/session-shell/image-preparation-client.d.ts +4 -3
- package/dist/app/session-shell/image-preparation.d.ts +0 -2
- package/dist/app/session-shell/image-preparation.js +2 -2
- package/dist/app/session-shell/image-source.d.ts +2 -3
- package/dist/app/session-shell/image-source.js +2 -2
- package/dist/app/session-shell/input-surface-switch.d.ts +9 -7
- package/dist/app/session-shell/input-surface-switch.js +1 -2
- package/dist/app/session-shell/login-interaction.d.ts +5 -4
- package/dist/app/session-shell/login-interaction.js +2 -3
- package/dist/app/session-shell/paste-executor.d.ts +4 -8
- package/dist/app/session-shell/paste-executor.js +2 -2
- package/dist/app/session-shell/paste-protocol.d.ts +2 -2
- package/dist/app/session-shell/path-chip-presentation.d.ts +0 -5
- package/dist/app/session-shell/path-chip-presentation.js +3 -3
- package/dist/app/session-shell/prompt-chips.d.ts +8 -7
- package/dist/app/session-shell/prompt-history-controller.d.ts +3 -3
- package/dist/app/session-shell/prompt-submission.d.ts +5 -2
- package/dist/app/session-shell/prompt-submission.js +13 -14
- package/dist/app/session-shell/quit-outro-effects.d.ts +3 -3
- package/dist/app/session-shell/quit-outro-effects.js +1 -4
- package/dist/app/session-shell/quit-outro.d.ts +9 -12
- package/dist/app/session-shell/quit-outro.js +11 -11
- package/dist/app/session-shell/resource-labels.d.ts +2 -0
- package/dist/app/session-shell/resource-labels.js +158 -0
- package/dist/app/session-shell/response-copy-protocol.d.ts +3 -2
- package/dist/app/session-shell/response-copy-transport.d.ts +2 -14
- package/dist/app/session-shell/response-copy-transport.js +1 -1
- package/dist/app/session-shell/session-lifecycle.d.ts +2 -1
- package/dist/app/session-shell/session-prompt-history.d.ts +29 -0
- package/dist/app/session-shell/session-prompt-history.js +80 -0
- package/dist/app/session-shell/session-selectors.d.ts +46 -0
- package/dist/app/session-shell/session-selectors.js +269 -0
- package/dist/app/session-shell/session-shell-root.d.ts +76 -113
- package/dist/app/session-shell/session-shell-root.js +103 -329
- package/dist/app/session-shell/session-shell.d.ts +14 -37
- package/dist/app/session-shell/session-shell.js +177 -612
- package/dist/app/session-shell/session-viewport-controller.d.ts +9 -16
- package/dist/app/session-shell/session-viewport-controller.js +42 -320
- package/dist/app/session-shell/settings-bindings.d.ts +25 -3
- package/dist/app/session-shell/settings-bindings.js +26 -2
- package/dist/app/session-shell/share-operation.d.ts +3 -3
- package/dist/app/session-shell/share-operation.js +4 -6
- package/dist/app/session-shell/shell-clipboard.d.ts +59 -0
- package/dist/app/session-shell/shell-clipboard.js +119 -0
- package/dist/app/session-shell/shell-editor-factory.d.ts +8 -4
- package/dist/app/session-shell/shell-editor-factory.js +13 -15
- package/dist/app/session-shell/shell-host.d.ts +16 -17
- package/dist/app/session-shell/shell-host.js +18 -19
- package/dist/app/session-shell/shell-layout.d.ts +2 -2
- package/dist/app/session-shell/shell-prompt-suggestions.d.ts +26 -0
- package/dist/app/session-shell/shell-prompt-suggestions.js +48 -0
- package/dist/app/session-shell/suggestion-surface.d.ts +1 -6
- package/dist/app/session-shell/suggestion-surface.js +1 -1
- package/dist/app/session-shell/system-clipboard.d.ts +2 -14
- package/dist/app/session-shell/system-clipboard.js +2 -7
- package/dist/app/session-shell/transcript-document.d.ts +11 -8
- package/dist/app/session-shell/transcript-document.js +13 -14
- package/dist/app/session-shell/viewport-layout.d.ts +2 -2
- package/dist/app/session-shell/viewport-pointer.d.ts +83 -0
- package/dist/app/session-shell/viewport-pointer.js +361 -0
- package/dist/app/session-shell/workflow-output.d.ts +5 -3
- package/dist/app/session-shell/workflow-output.js +13 -15
- package/dist/cli/package-messages.d.ts +0 -1
- package/dist/cli/package-messages.js +1 -1
- package/dist/cli/session-context.d.ts +1 -1
- package/dist/cli/uninstall.d.ts +3 -2
- package/dist/composition/owned-settings.d.ts +2 -1
- package/dist/composition/owned-settings.js +0 -3
- package/dist/composition/owned-ui.d.ts +1 -1
- package/dist/composition/owned-ui.js +77 -73
- package/dist/composition/reference-selection-options.d.ts +1 -1
- package/dist/composition/reference-selection-options.js +1 -1
- package/dist/composition/session-runtime-registry.d.ts +2 -1
- package/dist/composition/settings-route-host.js +3 -10
- package/dist/composition/settings-search-input.d.ts +2 -1
- package/dist/composition/startup-route.d.ts +2 -2
- package/dist/composition/startup-route.js +2 -2
- package/dist/contracts/owned-ui/extension-ui.d.ts +2 -1
- package/dist/contracts/owned-ui/index.d.ts +2 -1
- package/dist/contracts/owned-ui/index.js +1 -1
- package/dist/contracts/owned-ui/session-presenters.d.ts +3 -0
- package/dist/contracts/owned-ui/shell-components.d.ts +543 -0
- package/dist/contracts/owned-ui/validation.d.ts +1 -11
- package/dist/contracts/owned-ui/validation.js +8 -104
- package/dist/contracts/presentation/component.d.ts +17 -0
- package/dist/contracts/presentation/component.js +8 -0
- package/dist/contracts/presentation/index.d.ts +6 -15
- package/dist/contracts/presentation/index.js +2 -0
- package/dist/contracts/presentation/terminal.d.ts +284 -0
- package/dist/contracts/presentation/terminal.js +1 -0
- package/dist/contracts/presentation/theme.d.ts +46 -0
- package/dist/contracts/presentation/theme.js +1 -0
- package/dist/features/launch/development-launch.js +1 -1
- package/dist/features/launch/runtime-selection.d.ts +2 -2
- package/dist/features/launch/runtime-selection.js +2 -2
- package/dist/features/owned-ui/project-trust-prompt.d.ts +2 -2
- package/dist/features/owned-ui/project-trust-prompt.js +1 -1
- package/dist/features/owned-ui/release-note-state.d.ts +2 -1
- package/dist/features/owned-ui/settings-app.js +49 -425
- package/dist/features/owned-ui/settings-edits.d.ts +31 -0
- package/dist/features/owned-ui/settings-edits.js +139 -0
- package/dist/features/owned-ui/settings-model-dialog.d.ts +41 -0
- package/dist/features/owned-ui/settings-model-dialog.js +194 -0
- package/dist/features/owned-ui/settings-scroll-rail.d.ts +29 -0
- package/dist/features/owned-ui/settings-scroll-rail.js +79 -0
- package/dist/features/owned-ui/settings-search-input.d.ts +2 -1
- package/dist/features/prompt-history/service.d.ts +3 -2
- package/dist/foundation/lifecycle/claim-gate.d.ts +2 -1
- package/dist/foundation/release/automatic-update.d.ts +5 -14
- package/dist/foundation/release/automatic-update.js +15 -22
- package/dist/foundation/release/bootstrap.js +4 -4
- package/dist/foundation/release/dependency-certification.d.ts +0 -1
- package/dist/foundation/release/dependency-certification.js +1 -1
- package/dist/foundation/release/dependency-layer.js +3 -3
- package/dist/foundation/release/early-accent.d.ts +2 -2
- package/dist/foundation/release/early-accent.js +1 -1
- package/dist/foundation/release/index.d.ts +2 -2
- package/dist/foundation/release/index.js +1 -1
- package/dist/foundation/release/latest-release.d.ts +3 -18
- package/dist/foundation/release/latest-release.js +11 -11
- package/dist/foundation/release/managed-path.d.ts +10 -0
- package/dist/foundation/release/managed-path.js +26 -0
- package/dist/foundation/release/ordinary-launch-selection.d.ts +1 -1
- package/dist/foundation/release/ordinary-launch-selection.js +1 -1
- package/dist/foundation/release/release-gc.d.ts +3 -3
- package/dist/foundation/release/release-gc.js +10 -12
- package/dist/foundation/release/{cohort-state.d.ts → release-state.d.ts} +23 -23
- package/dist/foundation/release/{cohort-state.js → release-state.js} +8 -8
- package/dist/foundation/release/restart-certification.js +3 -4
- package/dist/foundation/release/update-activation.js +3 -3
- package/dist/foundation/release/update-execution-lease.d.ts +2 -3
- package/dist/foundation/release/update-execution-lease.js +2 -8
- package/dist/foundation/release/update-installer.d.ts +45 -0
- package/dist/foundation/release/update-installer.js +57 -0
- package/dist/foundation/release/update-launch.d.ts +2 -2
- package/dist/foundation/release/update-recovery.js +2 -9
- package/dist/foundation/release/update.d.ts +4 -25
- package/dist/foundation/release/update.js +164 -183
- package/dist/foundation/startup/startup-budget.d.ts +5 -5
- package/dist/foundation/startup/startup-budget.js +2 -2
- package/dist/integrations/pi/components/bracketed-paste.d.ts +33 -0
- package/dist/integrations/pi/components/bracketed-paste.js +123 -0
- package/dist/integrations/pi/components/editor-interaction.d.ts +4 -12
- package/dist/integrations/pi/components/index.d.ts +15 -9
- package/dist/integrations/pi/components/index.js +9 -5
- package/dist/integrations/pi/components/lazy-selectors.d.ts +2 -10
- package/dist/integrations/pi/components/lazy-selectors.js +1 -1
- package/dist/integrations/pi/components/modal-frame.d.ts +5 -22
- package/dist/integrations/pi/components/modal-frame.js +3 -23
- package/dist/integrations/pi/components/owned-editor-ux.d.ts +4 -3
- package/dist/integrations/pi/components/owned-editor-ux.js +46 -140
- package/dist/integrations/pi/components/prompt-input-port.d.ts +2 -19
- package/dist/integrations/pi/components/resources/builtin-themes.d.ts +2 -1
- package/dist/integrations/pi/components/shell-editor-autocomplete.d.ts +3 -2
- package/dist/integrations/pi/components/shell-footer-status.d.ts +2 -2
- package/dist/integrations/pi/components/shell-footer-status.js +3 -2
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +6 -5
- package/dist/integrations/pi/components/shell-presenters-info.js +2 -1
- package/dist/integrations/pi/components/shell-session-info-reference.d.ts +2 -1
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +33 -227
- package/dist/integrations/pi/components/shell-shared-facade.js +8 -1
- package/dist/integrations/pi/components/skills-command.d.ts +1 -9
- package/dist/integrations/pi/components/skills-command.js +5 -5
- package/dist/integrations/pi/components/theme.d.ts +9 -2
- package/dist/integrations/pi/components/theme.js +17 -2
- package/dist/integrations/pi/components/thinking-selector-dialog.d.ts +2 -1
- package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +2 -2
- package/dist/integrations/pi/engine/adapter.d.ts +4 -13
- package/dist/integrations/pi/engine/adapter.js +9 -61
- package/dist/integrations/pi/engine/changelog.d.ts +2 -2
- package/dist/integrations/pi/engine/changelog.js +3 -3
- package/dist/integrations/pi/engine/compaction-progress.d.ts +2 -3
- package/dist/integrations/pi/engine/compaction-progress.js +1 -1
- package/dist/integrations/pi/engine/conformance.d.ts +2 -1
- package/dist/integrations/pi/engine/default-model-setting.d.ts +0 -2
- package/dist/integrations/pi/engine/default-model-setting.js +1 -2
- package/dist/integrations/pi/engine/event-delivery.d.ts +2 -1
- package/dist/integrations/pi/engine/extension-ui-binding.d.ts +2 -1
- package/dist/integrations/pi/engine/host.js +3 -3
- package/dist/integrations/pi/engine/message-values.d.ts +0 -1
- package/dist/integrations/pi/engine/message-values.js +1 -1
- package/dist/integrations/pi/engine/pending-delivery.d.ts +0 -4
- package/dist/integrations/pi/engine/pending-delivery.js +3 -3
- package/dist/integrations/pi/engine/ports.d.ts +7 -1
- package/dist/integrations/pi/engine/ports.js +4 -0
- package/dist/integrations/pi/engine/project-trust-preflight.d.ts +2 -1
- package/dist/integrations/pi/engine/prompt-suggestions.d.ts +3 -2
- package/dist/integrations/pi/engine/provider-authentication.d.ts +1 -1
- package/dist/integrations/pi/engine/public-main-entry.d.ts +1 -5
- package/dist/integrations/pi/engine/public-main-entry.js +1 -1
- package/dist/integrations/pi/engine/repository-metadata.d.ts +49 -0
- package/dist/integrations/pi/engine/repository-metadata.js +189 -0
- package/dist/integrations/pi/engine/repository-pr-rest.d.ts +1 -9
- package/dist/integrations/pi/engine/repository-pr-rest.js +2 -2
- package/dist/integrations/pi/engine/repository-pr.d.ts +1 -3
- package/dist/integrations/pi/engine/repository-pr.js +1 -1
- package/dist/integrations/pi/engine/resource-catalog.d.ts +2 -1
- package/dist/integrations/pi/engine/session-integration.d.ts +1 -1
- package/dist/integrations/pi/engine/session-runtime.d.ts +7 -12
- package/dist/integrations/pi/engine/session-runtime.js +21 -178
- package/dist/integrations/pi/engine/settings-bridge.d.ts +0 -2
- package/dist/integrations/pi/engine/settings-bridge.js +1 -1
- package/dist/integrations/pi/engine/settings-port.d.ts +3 -2
- package/dist/integrations/pi/engine/transcript-projection.d.ts +2 -1
- package/dist/integrations/pi/engine/view-state.d.ts +21 -2
- package/dist/integrations/pi/engine/view-state.js +129 -1
- package/dist/integrations/pi/engine/workflow-contexts.d.ts +1 -1
- package/dist/integrations/pi/engine/workflow-runner.d.ts +1 -2
- package/dist/integrations/pi/engine/workflow-runner.js +254 -365
- package/dist/integrations/pi/engine/workflow-share.d.ts +9 -0
- package/dist/integrations/pi/engine/workflow-share.js +168 -0
- package/dist/integrations/pi/engine/workflow-support.d.ts +0 -20
- package/dist/integrations/pi/engine/workflow-support.js +4 -65
- package/dist/integrations/pi/engine/workflows.d.ts +5 -5
- package/dist/integrations/pi/session-presenters/components.d.ts +3 -0
- package/dist/integrations/pi/session-presenters/components.js +75 -0
- package/dist/integrations/pi/session-presenters/index.d.ts +1 -0
- package/dist/integrations/pi/session-presenters/index.js +1 -0
- package/dist/integrations/pi/session-presenters/presentation.d.ts +3 -0
- package/dist/integrations/pi/session-presenters/presentation.js +10 -0
- package/dist/integrations/pi/session-presenters/presenters.d.ts +2 -1
- package/dist/integrations/pi/session-presenters/presenters.js +3 -1
- package/dist/integrations/pi/tui-runtime/adapter.d.ts +9 -19
- package/dist/integrations/pi/tui-runtime/adapter.js +56 -174
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +9 -44
- package/dist/integrations/pi/tui-runtime/index.d.ts +1 -1
- package/dist/integrations/pi/tui-runtime/index.js +1 -0
- package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +4 -6
- package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +4 -10
- package/dist/integrations/pi/tui-runtime/overlay-geometry.js +3 -9
- package/dist/integrations/pi/tui-runtime/presentation-adapter.d.ts +2 -2
- package/dist/integrations/pi/tui-runtime/runtime-factory.d.ts +3 -0
- package/dist/integrations/pi/tui-runtime/runtime-factory.js +11 -0
- package/dist/ui/components/index.d.ts +2 -2
- package/dist/ui/components/index.js +1 -1
- package/dist/ui/components/selection-copy.d.ts +0 -1
- package/dist/ui/components/selection-copy.js +0 -12
- package/dist/ui/components/theme.d.ts +4 -19
- package/dist/ui/components/theme.js +6 -0
- package/dist/ui/components/transcript-viewport-frame.d.ts +120 -0
- package/dist/ui/components/transcript-viewport-frame.js +314 -0
- package/dist/ui/components/transcript-viewport-types.d.ts +147 -0
- package/dist/ui/components/transcript-viewport-types.js +1 -0
- package/dist/ui/components/transcript-viewport.d.ts +2 -147
- package/dist/ui/components/transcript-viewport.js +87 -315
- package/dist/ui/settings/declarations.d.ts +2 -3
- package/dist/ui/settings/declarations.js +2 -3
- package/dist/ui/settings/early-accent.js +1 -1
- package/dist/ui/settings/index.d.ts +3 -5
- package/dist/ui/settings/index.js +2 -3
- package/dist/ui/settings/manager.d.ts +0 -4
- package/dist/ui/settings/manager.js +6 -62
- package/dist/ui/settings/resolution.d.ts +6 -18
- package/dist/ui/settings/resolution.js +4 -103
- package/dist/ui/settings/sections.d.ts +0 -4
- package/dist/ui/settings/sections.js +1 -1
- package/docs/architecture/boundaries.md +2 -2
- package/docs/architecture/internal-naming.md +2 -0
- package/docs/architecture/project-structure.md +4 -2
- package/docs/validation.md +1 -1
- package/package.json +3 -4
- package/dist/integrations/pi/components/components.d.ts +0 -4
- package/dist/integrations/pi/components/components.js +0 -48
- package/dist/integrations/pi/components/conformance.d.ts +0 -18
- package/dist/integrations/pi/components/conformance.js +0 -70
- package/dist/integrations/pi/components/shell-components.d.ts +0 -7
- package/dist/integrations/pi/components/shell-components.js +0 -7
- package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +0 -33
- package/dist/integrations/pi/components/upstream/theme/theme-controller.js +0 -114
- package/dist/integrations/pi/engine/diagnostics-state.d.ts +0 -9
- package/dist/integrations/pi/engine/diagnostics-state.js +0 -34
- package/dist/integrations/pi/engine/usage-view.d.ts +0 -4
- package/dist/integrations/pi/engine/usage-view.js +0 -56
- package/dist/integrations/pi/tui-runtime/contracts.d.ts +0 -166
- package/dist/ui/settings/migrations.d.ts +0 -19
- package/dist/ui/settings/migrations.js +0 -225
- package/dist/ui/settings/progress-palette.generated.d.ts +0 -139
- package/dist/ui/settings/progress-palette.generated.js +0 -139
- /package/dist/{integrations/pi/tui-runtime/contracts.js → contracts/owned-ui/shell-components.js} +0 -0
- /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.d.ts +0 -0
- /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.js +0 -0
|
@@ -11,11 +11,10 @@ import { PiEngineRuntime } from "./session-runtime.js";
|
|
|
11
11
|
import { detachedEngineHostPorts } from "./host-ports.js";
|
|
12
12
|
import { PiEngineSettings } from "./settings-port.js";
|
|
13
13
|
import { PiSessionEvents } from "./session-events.js";
|
|
14
|
-
import { readUsageView } from "./usage-view.js";
|
|
15
14
|
import { PiWorkflowContexts } from "./workflow-contexts.js";
|
|
16
15
|
import { PiWorkflowRunner } from "./workflow-runner.js";
|
|
17
16
|
import { defaultWorkflowHost } from "./workflow-support.js";
|
|
18
|
-
import { EngineViewState } from "./view-state.js";
|
|
17
|
+
import { EngineViewState, projectSessionView } from "./view-state.js";
|
|
19
18
|
import { createEnginePorts } from "./ports.js";
|
|
20
19
|
/** Explicit flush failure when required delivery was interrupted rather than completed. */
|
|
21
20
|
export class EngineDeliveryError extends Error {
|
|
@@ -198,14 +197,13 @@ export class PiEngineAdapter {
|
|
|
198
197
|
get settings() { return this.#ports.settings; }
|
|
199
198
|
get catalog() { return this.#ports.catalog; }
|
|
200
199
|
get extensions() { return this.#ports.extensions; }
|
|
200
|
+
/** Pinned Pi's changelog since the profile's last seen version and extension package updates; the host announces each once per process. */
|
|
201
|
+
get announcements() { return this.#ports.announcements; }
|
|
201
202
|
/** The Pi objects behind pinned selectors and renderers, for the session presenters owner only. */
|
|
202
203
|
presentationSource() { return this.#ports.presentation; }
|
|
203
204
|
setWorkflowInteractionHost(interaction) {
|
|
204
205
|
this.#workflowInteraction = interaction;
|
|
205
206
|
}
|
|
206
|
-
#resolveTranscriptImage(assetId) {
|
|
207
|
-
return this.#projection.assets.resolve(assetId);
|
|
208
|
-
}
|
|
209
207
|
// Rationale: the startup check's newer release becomes pinned Pi's `Update Available` notice; it arrives
|
|
210
208
|
// whenever the check resolves, so a late result is appended like Pi's own fire-and-forget version check.
|
|
211
209
|
#announceReleaseUpdate(release) {
|
|
@@ -240,14 +238,6 @@ export class PiEngineAdapter {
|
|
|
240
238
|
this.#emitView();
|
|
241
239
|
return this.view();
|
|
242
240
|
}
|
|
243
|
-
/** Announce pinned Pi's changelog since the profile's last seen version; the host calls this once per process. */
|
|
244
|
-
announceStartupChangelog() {
|
|
245
|
-
return this.#engine.announceChangelog();
|
|
246
|
-
}
|
|
247
|
-
/** Probe extension packages for updates and announce them; the host calls this once per process. */
|
|
248
|
-
announcePackageUpdates() {
|
|
249
|
-
return this.#engine.announcePackageUpdates();
|
|
250
|
-
}
|
|
251
241
|
onEvent(listener) {
|
|
252
242
|
return this.#delivery.subscribe(listener, this.#delivery.stamp({ type: "session-view", view: this.view() }));
|
|
253
243
|
}
|
|
@@ -263,9 +253,6 @@ export class PiEngineAdapter {
|
|
|
263
253
|
throw new EngineDeliveryError();
|
|
264
254
|
}
|
|
265
255
|
}
|
|
266
|
-
abortBashWorkflow() {
|
|
267
|
-
this.#workflows.abortBashWorkflow();
|
|
268
|
-
}
|
|
269
256
|
async executeWorkflow(request) {
|
|
270
257
|
const result = await this.#workflows.executeWorkflow(request);
|
|
271
258
|
if (request.command === "tree" && result.outcome === "completed" && request.selection !== undefined) {
|
|
@@ -273,20 +260,10 @@ export class PiEngineAdapter {
|
|
|
273
260
|
}
|
|
274
261
|
return result;
|
|
275
262
|
}
|
|
276
|
-
/**
|
|
277
|
-
* The theme the engine is configured with, in the engine's own grammar: a
|
|
278
|
-
* theme's name, or a `light/dark` pair meaning "follow the terminal".
|
|
279
|
-
*/
|
|
280
|
-
configuredTheme() {
|
|
281
|
-
return this.#settings.configuredTheme();
|
|
282
|
-
}
|
|
283
263
|
/** Settings port for the live runtime, or null before the runtime is available. */
|
|
284
264
|
settingsPort() {
|
|
285
265
|
return this.#settings.settingsPort();
|
|
286
266
|
}
|
|
287
|
-
pinnedSettingsSnapshot() {
|
|
288
|
-
return this.#settings.pinnedSettingsSnapshot();
|
|
289
|
-
}
|
|
290
267
|
clearQueuedWorkflows() {
|
|
291
268
|
const session = this.#requireWorkflowSession();
|
|
292
269
|
const result = session.clearQueue?.();
|
|
@@ -296,42 +273,13 @@ export class PiEngineAdapter {
|
|
|
296
273
|
return [...readStringArray(result.steering), ...readStringArray(result.followUp)];
|
|
297
274
|
}
|
|
298
275
|
view() {
|
|
299
|
-
|
|
300
|
-
const routedModel = routed === undefined ? null : readModel(routed.model);
|
|
301
|
-
return {
|
|
302
|
-
contractVersion: 1,
|
|
276
|
+
return projectSessionView({
|
|
303
277
|
sessionId: this.#sessionId,
|
|
304
|
-
|
|
305
|
-
|
|
278
|
+
state: this.#state,
|
|
279
|
+
engine: this.#engine,
|
|
306
280
|
transcript: this.#projection.snapshot(),
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
...this.#state.status,
|
|
310
|
-
diagnostics: [...this.#state.status.diagnostics],
|
|
311
|
-
badges: [...this.#state.status.badges],
|
|
312
|
-
usage: this.#state.usage(() => readUsageView(this.#engine.session, this.#engine.runtime, this.#state.activeModel)),
|
|
313
|
-
footer: {
|
|
314
|
-
branch: this.#engine.gitBranch,
|
|
315
|
-
repositoryPath: this.#engine.repositoryCwd,
|
|
316
|
-
pullRequest: this.#engine.pullRequest,
|
|
317
|
-
sessionName: this.#engine.session?.sessionManager?.getSessionName() ?? null,
|
|
318
|
-
availableProviderCount: new Set(this.#engine.runtime?.services.modelRuntime.getAvailableSnapshot?.().map(model => model.provider).filter(provider => provider !== undefined) ?? []).size,
|
|
319
|
-
extensionStatuses: [],
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
terminal: { ...this.#state.terminal },
|
|
323
|
-
activeModel: this.#state.activeModel === null ? null : { ...this.#state.activeModel },
|
|
324
|
-
routedModel: routedModel === null ? null : {
|
|
325
|
-
model: routedModel,
|
|
326
|
-
...(routed?.thinkingLevel === undefined ? {} : { thinkingLevel: readThinkingLevel(routed.thinkingLevel) }),
|
|
327
|
-
},
|
|
328
|
-
thinkingLevel: this.#state.thinkingLevel,
|
|
329
|
-
activeCommandIds: [...this.#commands.activeCommandIds],
|
|
330
|
-
dialog: null,
|
|
331
|
-
overlay: null,
|
|
332
|
-
customizations: [],
|
|
333
|
-
diagnostics: this.#state.diagnostics.map(diagnostic => ({ ...diagnostic })),
|
|
334
|
-
};
|
|
281
|
+
activeCommandIds: this.#commands.activeCommandIds,
|
|
282
|
+
});
|
|
335
283
|
}
|
|
336
284
|
snapshot() {
|
|
337
285
|
const snapshot = {
|
|
@@ -395,7 +343,7 @@ export class PiEngineAdapter {
|
|
|
395
343
|
clearQueuedWorkflows: () => this.clearQueuedWorkflows(),
|
|
396
344
|
setWorkflowInteractionHost: interaction => { this.setWorkflowInteractionHost(interaction); },
|
|
397
345
|
announceReleaseUpdate: release => { this.#announceReleaseUpdate(release); },
|
|
398
|
-
resolveTranscriptImage: assetId => this.#
|
|
346
|
+
resolveTranscriptImage: assetId => this.#projection.assets.resolve(assetId),
|
|
399
347
|
extensionRunner: () => this.#requireWorkflowSession().extensionRunner,
|
|
400
348
|
});
|
|
401
349
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
/** Pinned Pi's changelog since `sinceVersion` (all of it when absent), read from the owned data resource. */
|
|
2
|
+
export declare function readPinnedCommandChangelog(sinceVersion?: string, path?: URL): Promise<string>;
|
|
@@ -2,8 +2,8 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { posix } from "node:path";
|
|
4
4
|
const REPOSITORY = "https://github.com/earendil-works/pi";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** Pinned Pi's changelog since `sinceVersion` (all of it when absent), read from the owned data resource. */
|
|
6
|
+
export async function readPinnedCommandChangelog(sinceVersion, path = new URL("./resources/changelog.json", import.meta.url)) {
|
|
7
7
|
if (!existsSync(path))
|
|
8
8
|
return sinceVersion === undefined ? "No changelog entries found." : "";
|
|
9
9
|
try {
|
|
@@ -19,7 +19,7 @@ export async function readPinnedCommandChangelog(sinceVersion) {
|
|
|
19
19
|
return sinceVersion === undefined ? "No changelog entries found." : "";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
function formatPinnedCommandChangelog(content, sinceVersion) {
|
|
23
23
|
// Provenance: behavior follows Pi 0.84.2 utils/changelog.ts at 914cf1472e715297caa30db4b9535d534a9eb718.
|
|
24
24
|
// Runtime reads only the owned data resource; maintenance tooling verifies its pinned provenance.
|
|
25
25
|
let releases = content.split(/(?=^## )/m).flatMap((section) => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/** Expected summary size for a first compaction, when no previous summary on the branch can serve as the estimate. */
|
|
2
|
-
export declare const DEFAULT_EXPECTED_COMPACTION_SUMMARY_CHARS = 4000;
|
|
3
1
|
/** The public session surface compaction progress reads: the agent's stream function and the branch entries. */
|
|
4
|
-
|
|
2
|
+
interface CompactionProgressSession {
|
|
5
3
|
readonly agent?: {
|
|
6
4
|
streamFunction?: unknown;
|
|
7
5
|
} | undefined;
|
|
@@ -22,3 +20,4 @@ export interface CompactionProgressObserver {
|
|
|
22
20
|
* when the session exposes no callable public stream function.
|
|
23
21
|
*/
|
|
24
22
|
export declare function observeCompactionProgress(session: CompactionProgressSession, onProgress: (percent: number) => void): CompactionProgressObserver | null;
|
|
23
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Expected summary size for a first compaction, when no previous summary on the branch can serve as the estimate. */
|
|
2
|
-
|
|
2
|
+
const DEFAULT_EXPECTED_COMPACTION_SUMMARY_CHARS = 4000;
|
|
3
3
|
/** Character-based estimates stay below terminal stream completion. */
|
|
4
4
|
const MAX_STREAMING_PERCENT = 99;
|
|
5
5
|
const COMPLETE_PERCENT = 100;
|
|
@@ -20,7 +20,7 @@ export declare class PiCapabilityCompatibilityError extends Error {
|
|
|
20
20
|
readonly operation: string;
|
|
21
21
|
constructor(packageVersion: string, capability: string, operation: string, detail: string);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
interface PiUpgradeConformanceReport {
|
|
24
24
|
readonly schema: "pi-engine-conformance-v1";
|
|
25
25
|
readonly packageName: "@earendil-works/pi-coding-agent";
|
|
26
26
|
readonly packageVersion: string;
|
|
@@ -37,3 +37,4 @@ export declare class PiUpgradeConformanceError extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
export declare function runPiUpgradeConformance(): Promise<PiUpgradeConformanceReport>;
|
|
39
39
|
export declare function validatePiCapabilityResults(packageVersion: string, results: readonly PiCapabilityConformanceResult[]): void;
|
|
40
|
+
export {};
|
|
@@ -5,8 +5,6 @@ interface DefaultModelChoice {
|
|
|
5
5
|
readonly label: string;
|
|
6
6
|
readonly name: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const DEFAULT_MODEL_SETTING_KEY = "defaultModel";
|
|
9
|
-
export declare const SUPPLEMENTAL_SETTING_KEYS: readonly ["defaultModel"];
|
|
10
8
|
export declare function defaultModelDescriptor(settings: SettingsManager, models: readonly DefaultModelChoice[]): AgentSettingDescriptor;
|
|
11
9
|
export declare function writeDefaultModel(settings: SettingsManager, models: readonly DefaultModelChoice[], value: unknown): Promise<AgentSettingChangeOutcome>;
|
|
12
10
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const SUPPLEMENTAL_SETTING_KEYS = [DEFAULT_MODEL_SETTING_KEY];
|
|
1
|
+
const DEFAULT_MODEL_SETTING_KEY = "defaultModel";
|
|
3
2
|
const UNSET = "not set";
|
|
4
3
|
function read(settings) {
|
|
5
4
|
const provider = settings.getDefaultProvider();
|
|
@@ -24,7 +24,7 @@ export type PiEmittedEvent = Omit<Extract<OwnedUiEvent, {
|
|
|
24
24
|
type: "diagnostic";
|
|
25
25
|
}>, "sessionId" | "sequence">;
|
|
26
26
|
/** A command outcome held back during an overload so its command can still settle after recovery. */
|
|
27
|
-
|
|
27
|
+
interface ReservedCommandOutcome {
|
|
28
28
|
readonly outcome: Extract<OwnedUiEvent, {
|
|
29
29
|
type: "command-outcome";
|
|
30
30
|
}>["outcome"];
|
|
@@ -98,3 +98,4 @@ export declare class PiEventDelivery {
|
|
|
98
98
|
/** Resolves once every queued event has been delivered or invalidated. */
|
|
99
99
|
settle(): Promise<void>;
|
|
100
100
|
}
|
|
101
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentSession } from "../startup-public.js";
|
|
2
2
|
import { type OwnedUiDiagnostics, type OwnedUiVisualExtensionSupport } from "../../../contracts/owned-ui/index.js";
|
|
3
3
|
export type OwnedPiVisualExtensionSupport = OwnedUiVisualExtensionSupport;
|
|
4
|
-
|
|
4
|
+
interface PiExtensionUiBindingPorts {
|
|
5
5
|
session(): AgentSession | undefined;
|
|
6
6
|
diagnostic(severity: OwnedUiDiagnostics["severity"], code: string, message: string, recoverable: boolean): void;
|
|
7
7
|
emitView(): void;
|
|
@@ -24,3 +24,4 @@ export declare class PiExtensionUiBinding {
|
|
|
24
24
|
/** Bind the attached bridge to the current session, reporting failures as diagnostics. */
|
|
25
25
|
rebind(): Promise<void>;
|
|
26
26
|
}
|
|
27
|
+
export {};
|
|
@@ -134,14 +134,14 @@ class ProcessPiEngineHost {
|
|
|
134
134
|
const theme = this.#options.theme;
|
|
135
135
|
theme.apply.packageBorderProjection(theme.packageBorderProjection);
|
|
136
136
|
theme.apply.accentColor(this.#accentColor);
|
|
137
|
-
theme.apply.base(theme.base === "dark" ? "dark" : adapter.configuredTheme());
|
|
137
|
+
theme.apply.base(theme.base === "dark" ? "dark" : adapter.settings.configuredTheme());
|
|
138
138
|
}
|
|
139
139
|
async #announceOnce(adapter) {
|
|
140
140
|
if (this.#announced)
|
|
141
141
|
return;
|
|
142
142
|
this.#announced = true;
|
|
143
143
|
if (this.#options.announceStartupChangelog !== false)
|
|
144
|
-
await adapter.
|
|
145
|
-
void adapter.
|
|
144
|
+
await adapter.announcements.startupChangelog();
|
|
145
|
+
void adapter.announcements.packageUpdates();
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -10,7 +10,6 @@ export declare function retainCompletedArguments(current: OwnedUiTranscriptBlock
|
|
|
10
10
|
* need re-renders it for nothing.
|
|
11
11
|
*/
|
|
12
12
|
export declare function sameBlockContent(left: OwnedUiTranscriptBlock, right: OwnedUiTranscriptBlock): boolean;
|
|
13
|
-
export declare function sameValue(left: unknown, right: unknown): boolean;
|
|
14
13
|
export declare function textFromContent(content: unknown): string;
|
|
15
14
|
export declare function assistantContent(content: readonly unknown[]): readonly Record<string, unknown>[];
|
|
16
15
|
export declare function contentImageCount(content: unknown): number;
|
|
@@ -35,7 +35,7 @@ export function sameBlockContent(left, right) {
|
|
|
35
35
|
&& sameValue(left.payload, right.payload)
|
|
36
36
|
&& sameValue(left.imageReferences ?? [], right.imageReferences ?? []);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
function sameValue(left, right) {
|
|
39
39
|
if (left === right)
|
|
40
40
|
return true;
|
|
41
41
|
if (typeof left !== typeof right || left === null || right === null)
|
|
@@ -1,8 +1,4 @@
|
|
|
1
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
2
|
/** Intrusive FIFO + segment index: replacement unlinks in O(1), never changes source ordering. */
|
|
7
3
|
export declare class PendingEngineDelivery {
|
|
8
4
|
#private;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const MAX_PENDING_EVENTS = 1024;
|
|
2
|
+
const MAX_PENDING_EVENT_BYTES = 8 * 1024 * 1024;
|
|
3
3
|
/** Actual shell semantics: only live complete block state has no independent side effect. */
|
|
4
|
-
|
|
4
|
+
function replaceableEventKey(event) {
|
|
5
5
|
switch (event.type) {
|
|
6
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
7
|
case "session-view": // Invariant: may clear compaction work, replace editor/session state, or preempt presentation.
|
|
@@ -24,6 +24,11 @@ export interface PiSessionPresentationSource {
|
|
|
24
24
|
pinnedSettingsModels(): Pick<PiPinnedSettingsSnapshot, "currentModel" | "availableDefaultModels">;
|
|
25
25
|
applyPinnedSettingValue(callback: PiPinnedSettingsCallback, value: unknown): Promise<PiWorkflowResult>;
|
|
26
26
|
}
|
|
27
|
+
/** Startup announcements the host makes once per process: pinned Pi's changelog and extension package updates. */
|
|
28
|
+
export interface PiEngineAnnouncements {
|
|
29
|
+
startupChangelog(): Promise<void>;
|
|
30
|
+
packageUpdates(): Promise<void>;
|
|
31
|
+
}
|
|
27
32
|
export interface PiEngineAdapterPorts {
|
|
28
33
|
readonly identity: OwnedUiSessionIdentityPort;
|
|
29
34
|
readonly session: OwnedUiSessionPort;
|
|
@@ -32,12 +37,13 @@ export interface PiEngineAdapterPorts {
|
|
|
32
37
|
readonly catalog: OwnedUiSessionCatalogPort;
|
|
33
38
|
readonly extensions: OwnedUiExtensionPort;
|
|
34
39
|
readonly presentation: PiSessionPresentationSource;
|
|
40
|
+
readonly announcements: PiEngineAnnouncements;
|
|
35
41
|
}
|
|
36
42
|
/** The adapter's collaborators and its own session operations, which every port member reaches at call time. */
|
|
37
43
|
export interface EnginePortParts {
|
|
38
44
|
readonly sessionId: string;
|
|
39
45
|
readonly agentDir: string;
|
|
40
|
-
readonly engine: Pick<PiEngineRuntime, "cwd" | "generation" | "bindingGeneration" | "currentSessionResumeMetadata" | "currentSessionFile" | "session">;
|
|
46
|
+
readonly engine: Pick<PiEngineRuntime, "cwd" | "generation" | "bindingGeneration" | "currentSessionResumeMetadata" | "currentSessionFile" | "session" | "announceChangelog" | "announcePackageUpdates">;
|
|
41
47
|
readonly contexts: PiWorkflowContexts;
|
|
42
48
|
readonly workflows: PiWorkflowRunner;
|
|
43
49
|
readonly settings: PiEngineSettings;
|
|
@@ -65,6 +65,10 @@ export function createEnginePorts(parts) {
|
|
|
65
65
|
bindClipboardWriter: writer => workflows.bindClipboardWriter(writer),
|
|
66
66
|
announceReleaseUpdate: release => { parts.announceReleaseUpdate(release); },
|
|
67
67
|
},
|
|
68
|
+
announcements: {
|
|
69
|
+
startupChangelog: () => engine.announceChangelog(),
|
|
70
|
+
packageUpdates: () => engine.announcePackageUpdates(),
|
|
71
|
+
},
|
|
68
72
|
presentation: {
|
|
69
73
|
pinnedModelSelectorContext: () => contexts.pinnedModelSelectorContext(),
|
|
70
74
|
pinnedSessionSelectorContext: () => contexts.pinnedSessionSelectorContext(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type PiProjectTrustChoiceId = "trust" | "trust-parent" | "trust-session" | "deny" | "deny-session";
|
|
2
2
|
export interface PiProjectTrustPreflightRequest {
|
|
3
3
|
readonly cwd: string;
|
|
4
4
|
readonly defaultDecision: "ask" | "always" | "never";
|
|
@@ -24,3 +24,4 @@ export interface ResolvePiProjectTrustPreflightOptions {
|
|
|
24
24
|
* result exists.
|
|
25
25
|
*/
|
|
26
26
|
export declare function resolvePiProjectTrustPreflight(options: ResolvePiProjectTrustPreflightOptions): Promise<PiProjectTrustPreflightResult>;
|
|
27
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AgentSession, AgentSessionRuntime } from "../startup-public.js";
|
|
2
2
|
import { type OwnedUiModelInfo, type OwnedUiPromptSuggestionGeneratorPort, type OwnedUiPromptSuggestionReasoning, type OwnedUiPromptSuggestionRequest, type OwnedUiPromptSuggestionResult } from "../../../contracts/owned-ui/index.js";
|
|
3
3
|
/** The run position a suggestion request must still match to be answered. */
|
|
4
|
-
|
|
4
|
+
interface PiPromptSuggestionIdentity {
|
|
5
5
|
readonly sessionId: string;
|
|
6
6
|
readonly sessionGeneration: number;
|
|
7
7
|
readonly runSequence: number;
|
|
8
8
|
readonly responseSequence: number;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface PiPromptSuggestionPorts {
|
|
11
11
|
session(): AgentSession | undefined;
|
|
12
12
|
runtime(): AgentSessionRuntime | undefined;
|
|
13
13
|
activeModel(): OwnedUiModelInfo | null;
|
|
@@ -28,3 +28,4 @@ export declare class PiPromptSuggestions implements OwnedUiPromptSuggestionGener
|
|
|
28
28
|
reasoningPolicy(): OwnedUiPromptSuggestionReasoning;
|
|
29
29
|
generate(request: OwnedUiPromptSuggestionRequest): Promise<OwnedUiPromptSuggestionResult>;
|
|
30
30
|
}
|
|
31
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import type { OwnedUiModelInfo } from "../../../contracts/owned-ui/index.js";
|
|
|
4
4
|
import type { PiWorkflowInteractionHost, PiWorkflowRequest, PiWorkflowResult } from "./workflows.js";
|
|
5
5
|
type PiSessionApi = AgentSession;
|
|
6
6
|
type PiRuntimeApi = AgentSessionRuntime;
|
|
7
|
-
|
|
7
|
+
interface PiProviderAuthenticationPorts {
|
|
8
8
|
runtime(): PiRuntimeApi | undefined;
|
|
9
9
|
requireSession(): PiSessionApi;
|
|
10
10
|
disposed(): boolean;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
readonly main?: (arguments_: string[]) => Promise<void>;
|
|
3
|
-
readonly stderr?: (message: string) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function runPublicMainEntry(arguments_: readonly string[], dependencies?: PublicMainEntryDependencies): Promise<number>;
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { realpathSync } from "node:fs";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { main as runPublicMain } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
|
|
5
|
+
async function runPublicMainEntry(arguments_, dependencies = {}) {
|
|
6
6
|
try {
|
|
7
7
|
await (dependencies.main ?? runPublicMain)([...arguments_]);
|
|
8
8
|
return 0;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type PiPullRequestIdentity, type PiPullRequestProbe } from "./repository-pr.js";
|
|
2
|
+
interface PiRepositoryContextSelection {
|
|
3
|
+
readonly cwd: string;
|
|
4
|
+
readonly branch: string;
|
|
5
|
+
}
|
|
6
|
+
export type PiRepositoryContextReader = (sessionId: string, sessionFile: string, signal: AbortSignal) => Promise<PiRepositoryContextSelection | null>;
|
|
7
|
+
type PiGitBranchReader = (cwd: string, signal: AbortSignal) => Promise<string | null>;
|
|
8
|
+
export interface RepositoryMetadataOptions {
|
|
9
|
+
readonly pullRequestProbe?: PiPullRequestProbe;
|
|
10
|
+
readonly pullRequestRefreshMs?: number;
|
|
11
|
+
readonly repositoryContextPollMs?: number;
|
|
12
|
+
readonly repositoryContextReader?: PiRepositoryContextReader;
|
|
13
|
+
readonly gitBranchReader?: PiGitBranchReader;
|
|
14
|
+
}
|
|
15
|
+
export interface RepositoryMetadataPorts {
|
|
16
|
+
/** The session binding generation; a probe started under an older one is dropped. */
|
|
17
|
+
bindingGeneration(): number;
|
|
18
|
+
/** The bound session's id and file, when its session manager exposes them. */
|
|
19
|
+
sessionIdentity(): {
|
|
20
|
+
readonly sessionId: unknown;
|
|
21
|
+
readonly sessionFile: unknown;
|
|
22
|
+
};
|
|
23
|
+
/** The engine cwd, used when no associated repository context is known. */
|
|
24
|
+
fallbackCwd(): string;
|
|
25
|
+
disposed(): boolean;
|
|
26
|
+
/** The branch, pull request or repository path changed. */
|
|
27
|
+
changed(): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The branch and pull request shown for the bound session: a poll loop with one probe in flight,
|
|
31
|
+
* a pending flag for a refresh requested meanwhile, a slower pull-request clock, and a guard that
|
|
32
|
+
* drops results from an aborted probe, an older binding or a disposed engine.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RepositoryMetadataPoller {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(options: RepositoryMetadataOptions, ports: RepositoryMetadataPorts);
|
|
37
|
+
get cwd(): string;
|
|
38
|
+
get branch(): string | null;
|
|
39
|
+
get pullRequest(): PiPullRequestIdentity | null;
|
|
40
|
+
/** Enable polling and probe now. */
|
|
41
|
+
start(): void;
|
|
42
|
+
/** Probe now while polling is enabled; a request made during a probe runs once it settles. */
|
|
43
|
+
refresh(): void;
|
|
44
|
+
/** Abort the running probe and forget the previous binding's metadata. */
|
|
45
|
+
reset(): void;
|
|
46
|
+
/** Stop polling; resolves once the running probe has settled. */
|
|
47
|
+
dispose(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { readPullRequest } from "./repository-pr.js";
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
const PULL_REQUEST_REFRESH_MS = 60_000;
|
|
7
|
+
const REPOSITORY_CONTEXT_POLL_MS = 5_000;
|
|
8
|
+
const GIT_BRANCH_TIMEOUT_MS = 5_000;
|
|
9
|
+
const GIT_BRANCH_MAX_BUFFER_BYTES = 4 * 1024;
|
|
10
|
+
/**
|
|
11
|
+
* The branch and pull request shown for the bound session: a poll loop with one probe in flight,
|
|
12
|
+
* a pending flag for a refresh requested meanwhile, a slower pull-request clock, and a guard that
|
|
13
|
+
* drops results from an aborted probe, an older binding or a disposed engine.
|
|
14
|
+
*/
|
|
15
|
+
export class RepositoryMetadataPoller {
|
|
16
|
+
#ports;
|
|
17
|
+
#pullRequestProbe;
|
|
18
|
+
#pullRequestRefreshMs;
|
|
19
|
+
#pollMs;
|
|
20
|
+
#contextReader;
|
|
21
|
+
#branchReader;
|
|
22
|
+
#cwd;
|
|
23
|
+
#branch = null;
|
|
24
|
+
#pullRequest = null;
|
|
25
|
+
#timer;
|
|
26
|
+
#abort;
|
|
27
|
+
#task;
|
|
28
|
+
#pending = false;
|
|
29
|
+
#lastPullRequestProbeAt = null;
|
|
30
|
+
#enabled = false;
|
|
31
|
+
constructor(options, ports) {
|
|
32
|
+
this.#ports = ports;
|
|
33
|
+
this.#cwd = ports.fallbackCwd();
|
|
34
|
+
this.#pullRequestProbe = options.pullRequestProbe ?? readPullRequest;
|
|
35
|
+
this.#pullRequestRefreshMs = options.pullRequestRefreshMs ?? PULL_REQUEST_REFRESH_MS;
|
|
36
|
+
this.#pollMs = options.repositoryContextPollMs ?? REPOSITORY_CONTEXT_POLL_MS;
|
|
37
|
+
this.#contextReader = options.repositoryContextReader ?? (async () => null);
|
|
38
|
+
this.#branchReader = options.gitBranchReader ?? readGitBranch;
|
|
39
|
+
}
|
|
40
|
+
get cwd() {
|
|
41
|
+
return this.#cwd;
|
|
42
|
+
}
|
|
43
|
+
get branch() {
|
|
44
|
+
return this.#branch;
|
|
45
|
+
}
|
|
46
|
+
get pullRequest() {
|
|
47
|
+
return this.#pullRequest;
|
|
48
|
+
}
|
|
49
|
+
/** Enable polling and probe now. */
|
|
50
|
+
start() {
|
|
51
|
+
this.#enabled = true;
|
|
52
|
+
this.refresh();
|
|
53
|
+
}
|
|
54
|
+
/** Probe now while polling is enabled; a request made during a probe runs once it settles. */
|
|
55
|
+
refresh() {
|
|
56
|
+
if (!this.#enabled || this.#ports.disposed())
|
|
57
|
+
return;
|
|
58
|
+
if (this.#task !== undefined) {
|
|
59
|
+
this.#pending = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const task = this.#probe();
|
|
63
|
+
this.#task = task;
|
|
64
|
+
const settled = () => {
|
|
65
|
+
if (this.#task === task)
|
|
66
|
+
this.#task = undefined;
|
|
67
|
+
if (!this.#pending)
|
|
68
|
+
return;
|
|
69
|
+
this.#pending = false;
|
|
70
|
+
this.refresh();
|
|
71
|
+
};
|
|
72
|
+
void task.then(settled, settled);
|
|
73
|
+
}
|
|
74
|
+
/** Abort the running probe and forget the previous binding's metadata. */
|
|
75
|
+
reset() {
|
|
76
|
+
if (this.#timer !== undefined)
|
|
77
|
+
clearTimeout(this.#timer);
|
|
78
|
+
this.#timer = undefined;
|
|
79
|
+
this.#abort?.abort();
|
|
80
|
+
this.#cwd = this.#ports.fallbackCwd();
|
|
81
|
+
this.#branch = null;
|
|
82
|
+
this.#pullRequest = null;
|
|
83
|
+
this.#lastPullRequestProbeAt = null;
|
|
84
|
+
}
|
|
85
|
+
/** Stop polling; resolves once the running probe has settled. */
|
|
86
|
+
async dispose() {
|
|
87
|
+
this.#enabled = false;
|
|
88
|
+
if (this.#timer !== undefined)
|
|
89
|
+
clearTimeout(this.#timer);
|
|
90
|
+
this.#timer = undefined;
|
|
91
|
+
this.#pending = false;
|
|
92
|
+
this.#abort?.abort();
|
|
93
|
+
await this.#task;
|
|
94
|
+
}
|
|
95
|
+
#current(controller, generation) {
|
|
96
|
+
return !controller.signal.aborted && generation === this.#ports.bindingGeneration() && this.#enabled && !this.#ports.disposed();
|
|
97
|
+
}
|
|
98
|
+
async #probe() {
|
|
99
|
+
if (this.#abort !== undefined || this.#ports.disposed())
|
|
100
|
+
return;
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
const generation = this.#ports.bindingGeneration();
|
|
103
|
+
this.#abort = controller;
|
|
104
|
+
let associatedContext = null;
|
|
105
|
+
const { sessionId, sessionFile } = this.#ports.sessionIdentity();
|
|
106
|
+
try {
|
|
107
|
+
if (typeof sessionId === "string" && sessionId.length > 0 && typeof sessionFile === "string" && sessionFile.length > 0) {
|
|
108
|
+
try {
|
|
109
|
+
associatedContext = await this.#contextReader(sessionId, sessionFile, controller.signal);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
associatedContext = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const nextCwd = associatedContext?.cwd ?? this.#ports.fallbackCwd();
|
|
116
|
+
let nextBranch = associatedContext?.branch ?? null;
|
|
117
|
+
if (associatedContext === null) {
|
|
118
|
+
try {
|
|
119
|
+
nextBranch = await this.#branchReader(nextCwd, controller.signal);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
nextBranch = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const metadataChanged = nextCwd !== this.#cwd || nextBranch !== this.#branch;
|
|
126
|
+
const remoteDue = metadataChanged || this.#lastPullRequestProbeAt === null
|
|
127
|
+
|| Date.now() - this.#lastPullRequestProbeAt >= this.#pullRequestRefreshMs;
|
|
128
|
+
if (remoteDue) {
|
|
129
|
+
let nextPullRequest = null;
|
|
130
|
+
try {
|
|
131
|
+
nextPullRequest = nextBranch === null
|
|
132
|
+
? null
|
|
133
|
+
: await this.#pullRequestProbe(nextCwd, nextBranch, controller.signal);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
nextPullRequest = null;
|
|
137
|
+
}
|
|
138
|
+
if (!this.#current(controller, generation))
|
|
139
|
+
return;
|
|
140
|
+
this.#apply(nextCwd, nextBranch, nextPullRequest);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
if (this.#current(controller, generation))
|
|
145
|
+
this.#apply(this.#ports.fallbackCwd(), null, null);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
if (this.#abort === controller)
|
|
149
|
+
this.#abort = undefined;
|
|
150
|
+
}
|
|
151
|
+
if (!this.#current(controller, generation))
|
|
152
|
+
return;
|
|
153
|
+
this.#timer = setTimeout(() => {
|
|
154
|
+
this.#timer = undefined;
|
|
155
|
+
this.refresh();
|
|
156
|
+
}, this.#pollMs);
|
|
157
|
+
this.#timer.unref?.();
|
|
158
|
+
}
|
|
159
|
+
#apply(cwd, branch, pullRequest) {
|
|
160
|
+
const changed = cwd !== this.#cwd || branch !== this.#branch || !samePullRequest(this.#pullRequest, pullRequest);
|
|
161
|
+
this.#cwd = cwd;
|
|
162
|
+
this.#branch = branch;
|
|
163
|
+
this.#pullRequest = pullRequest;
|
|
164
|
+
this.#lastPullRequestProbeAt = Date.now();
|
|
165
|
+
if (changed)
|
|
166
|
+
this.#ports.changed();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function samePullRequest(left, right) {
|
|
170
|
+
return left?.number === right?.number && left?.url === right?.url;
|
|
171
|
+
}
|
|
172
|
+
async function readGitBranch(cwd, signal) {
|
|
173
|
+
if (!existsSync(cwd))
|
|
174
|
+
return null;
|
|
175
|
+
try {
|
|
176
|
+
const { stdout } = await execFileAsync("git", ["branch", "--show-current"], {
|
|
177
|
+
cwd,
|
|
178
|
+
windowsHide: true,
|
|
179
|
+
timeout: GIT_BRANCH_TIMEOUT_MS,
|
|
180
|
+
maxBuffer: GIT_BRANCH_MAX_BUFFER_BYTES,
|
|
181
|
+
signal,
|
|
182
|
+
encoding: "utf8",
|
|
183
|
+
});
|
|
184
|
+
return stdout.trim() || null;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
}
|