@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
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
2
|
import { dirname, join } from "node:path";
|
|
5
|
-
import { PRODUCT_IDENTITY } from "../../../product-identity.js";
|
|
6
3
|
import { isRecord, readModel, readThinkingLevel, requireCapability, stringProperty } from "./message-values.js";
|
|
7
|
-
import { AUTH_REFRESH_TIMEOUT_MS,
|
|
4
|
+
import { AUTH_REFRESH_TIMEOUT_MS, errorMessage, findExactWorkflowModel, pathArgument, pinnedHotkeySummary, pinnedSessionInfoPresentation, workflowConfirmation, workflowResult, } from "./workflow-support.js";
|
|
8
5
|
import { PiProviderAuthentication } from "./provider-authentication.js";
|
|
9
6
|
/** How many workflows and engine commands may be admitted together before new work is rejected. */
|
|
10
7
|
const MAX_PENDING_WORK = 32;
|
|
@@ -91,61 +88,6 @@ export class PiWorkflowRunner {
|
|
|
91
88
|
await this.#host.copyText(text);
|
|
92
89
|
return true;
|
|
93
90
|
}
|
|
94
|
-
// Protocol: the pinned Radius `/share` route. Undefined means Radius has no provider or credential,
|
|
95
|
-
// so the caller may fall back to a gist; any other outcome, including an upload failure, is final.
|
|
96
|
-
async #shareViaRadius(session, runtime, request) {
|
|
97
|
-
const signal = request.signal;
|
|
98
|
-
const models = runtime.services.modelRuntime;
|
|
99
|
-
if (models.getProvider?.("radius") === undefined)
|
|
100
|
-
return undefined;
|
|
101
|
-
const token = radiusAuthCredential(await models.getAuth("radius", { minOAuthValidityMs: RADIUS_AUTH_MIN_VALIDITY_MS }));
|
|
102
|
-
if (!token)
|
|
103
|
-
return undefined;
|
|
104
|
-
if (signal?.aborted)
|
|
105
|
-
return workflowResult(request.command, "cancelled", "Share cancelled", undefined, "status");
|
|
106
|
-
request.onProgress?.("Uploading to Radius…");
|
|
107
|
-
const temporary = join(tmpdir(), `${PRODUCT_IDENTITY.filesystem.temporaryPrefix}pi-session-${process.pid}.jsonl`);
|
|
108
|
-
let body;
|
|
109
|
-
try {
|
|
110
|
-
requireCapability(session.exportToJsonl, "exportToJsonl").call(session, temporary);
|
|
111
|
-
body = withRadiusShareTrailingEntry(await readFile(temporary, "utf8"), session.state ?? {}, randomUUID().slice(0, 8));
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
return workflowResult(request.command, "failed", `Failed to export session: ${errorMessage(error, "Unknown error")}`);
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
await rm(temporary, { force: true });
|
|
118
|
-
}
|
|
119
|
-
const url = new URL("/v1/artifacts", RADIUS_SHARE_GATEWAY);
|
|
120
|
-
url.searchParams.set("visibility", "organization");
|
|
121
|
-
url.searchParams.set("title", "Pi session");
|
|
122
|
-
try {
|
|
123
|
-
const response = await (this.#host.fetch ?? fetch)(url, {
|
|
124
|
-
method: "POST",
|
|
125
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/x-ndjson" },
|
|
126
|
-
body,
|
|
127
|
-
...(signal === undefined ? {} : { signal }),
|
|
128
|
-
});
|
|
129
|
-
const json = await response.json().catch(() => null);
|
|
130
|
-
if (signal?.aborted)
|
|
131
|
-
return workflowResult(request.command, "cancelled", "Share cancelled", undefined, "status");
|
|
132
|
-
const artifact = isRecord(json) && isRecord(json.artifact) ? json.artifact : undefined;
|
|
133
|
-
const shareUrl = artifact === undefined ? undefined : stringProperty(artifact, "canonical_url");
|
|
134
|
-
if (!response.ok || shareUrl === undefined) {
|
|
135
|
-
const detail = (isRecord(json) ? stringProperty(json, "error") : undefined) || response.statusText || String(response.status);
|
|
136
|
-
return workflowResult(request.command, "failed", `Failed to upload Radius artifact: ${detail}`);
|
|
137
|
-
}
|
|
138
|
-
return workflowResult(request.command, "completed", `Share URL: ${shareUrl}`);
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
if (signal?.aborted || isAbortError(error))
|
|
142
|
-
return workflowResult(request.command, "cancelled", "Share cancelled", undefined, "status");
|
|
143
|
-
return workflowResult(request.command, "failed", `Failed to upload Radius artifact: ${errorMessage(error, "Unknown error")}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
abortBashWorkflow() {
|
|
147
|
-
this.#requireSession().abortBash?.();
|
|
148
|
-
}
|
|
149
91
|
async executeBashWorkflow(command, excludeFromContext) {
|
|
150
92
|
const session = this.#requireSession();
|
|
151
93
|
const result = await requireCapability(session.executeBash, "executeBash").call(session, command, undefined, { excludeFromContext });
|
|
@@ -288,313 +230,260 @@ export class PiWorkflowRunner {
|
|
|
288
230
|
const runtime = this.#ports.runtime();
|
|
289
231
|
if (!runtime)
|
|
290
232
|
throw new Error("engine runtime is unavailable");
|
|
291
|
-
const argument = request.argument.trim();
|
|
292
233
|
const selected = request.selection?.trim();
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
case "
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
case "
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
catch (error) {
|
|
540
|
-
return workflowResult(request.command, "failed", error instanceof Error ? error.message : String(error));
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
case "resume": {
|
|
544
|
-
if (!selection && !argument)
|
|
545
|
-
return workflowResult(request.command, "failed", "Resume requires the owned session controller");
|
|
546
|
-
const sessionPath = selection ?? argument;
|
|
547
|
-
try {
|
|
548
|
-
const result = await runtime.switchSession(sessionPath);
|
|
549
|
-
if (isRecord(result) && result.cancelled === true)
|
|
550
|
-
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "silent");
|
|
551
|
-
return workflowResult(request.command, "completed", "Resumed session");
|
|
552
|
-
}
|
|
553
|
-
catch (error) {
|
|
554
|
-
const issue = isRecord(error) && isRecord(error.issue) ? error.issue : undefined;
|
|
555
|
-
const fallbackCwd = issue === undefined ? undefined : stringProperty(issue, "fallbackCwd");
|
|
556
|
-
if (fallbackCwd === undefined)
|
|
557
|
-
throw error;
|
|
558
|
-
if (request.confirmed === undefined) {
|
|
559
|
-
const sessionCwd = stringProperty(issue, "sessionCwd") ?? "the session working directory";
|
|
560
|
-
return workflowConfirmation(request.command, `cwd from session file does not exist\n${sessionCwd}\n\ncontinue in current cwd\n${fallbackCwd}`);
|
|
561
|
-
}
|
|
562
|
-
if (!request.confirmed)
|
|
563
|
-
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "status");
|
|
564
|
-
const result = await runtime.switchSession(sessionPath, { cwdOverride: fallbackCwd });
|
|
565
|
-
if (isRecord(result) && result.cancelled === true)
|
|
566
|
-
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "silent");
|
|
567
|
-
return workflowResult(request.command, "completed", "Resumed session in current cwd");
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
case "reload": {
|
|
571
|
-
const blocked = this.reloadBlockedResult();
|
|
572
|
-
if (blocked)
|
|
573
|
-
return blocked;
|
|
574
|
-
await requireCapability(session.reload, "reload").call(session);
|
|
575
|
-
await this.#ports.bindExtensionUiToSession();
|
|
576
|
-
const message = "Reloaded keybindings, extensions, skills, prompts, themes, and context files";
|
|
577
|
-
const modelError = runtime.services.modelRuntime.getError?.();
|
|
578
|
-
return workflowResult(request.command, "completed", message, undefined, "status", modelError ? [
|
|
579
|
-
{ kind: "error", message: `models.json error: ${modelError}` },
|
|
580
|
-
{ kind: "status", message },
|
|
581
|
-
] : undefined);
|
|
582
|
-
}
|
|
583
|
-
case "quit": {
|
|
584
|
-
await this.#ports.dispose();
|
|
585
|
-
return workflowResult(request.command, "completed", "Shutdown complete");
|
|
586
|
-
}
|
|
587
|
-
case "debug": {
|
|
588
|
-
const debugPath = join(this.#agentDir, "pi-debug.log");
|
|
589
|
-
await mkdir(dirname(debugPath), { recursive: true });
|
|
590
|
-
await writeFile(debugPath, `${JSON.stringify(this.#ports.snapshot(), null, 2)}\n`, "utf8");
|
|
591
|
-
return workflowResult(request.command, "completed", "✓ Debug log written", debugPath);
|
|
592
|
-
}
|
|
593
|
-
case "arminsayshi":
|
|
594
|
-
return workflowResult(request.command, "completed", "Armin says hi");
|
|
595
|
-
case "dementedelves":
|
|
596
|
-
return workflowResult(request.command, "completed", "Demented elves announcement");
|
|
234
|
+
const call = { request, session, runtime, argument: request.argument.trim(), selection: selected && selected.length > 0 ? selected : undefined };
|
|
235
|
+
const { command } = request;
|
|
236
|
+
const { argument, selection } = call;
|
|
237
|
+
switch (command) {
|
|
238
|
+
case "settings": return selection ? await this.#ports.applyPinnedSetting(selection) : workflowResult(command, "failed", "Settings requires the owned settings controller");
|
|
239
|
+
case "thinking": return thinkingWorkflow(call, this.#ports);
|
|
240
|
+
case "model": return this.#modelWorkflow(call);
|
|
241
|
+
case "models": return this.#modelsWorkflow(call);
|
|
242
|
+
case "scoped-models": return scopedModelsWorkflow(call);
|
|
243
|
+
case "export": return exportWorkflow(call);
|
|
244
|
+
case "import": return importWorkflow(call);
|
|
245
|
+
case "share": return (await import("./workflow-share.js")).runShareWorkflow({ request, session, runtime, host: this.#host });
|
|
246
|
+
case "copy": return copyWorkflow(call, text => this.copyWorkflowText(text));
|
|
247
|
+
case "name": return nameWorkflow(call, this.#ports);
|
|
248
|
+
case "session": return sessionInfoWorkflow(call);
|
|
249
|
+
case "changelog": return workflowResult(command, "completed", "What's New", await this.#host.readChangelog());
|
|
250
|
+
case "hotkeys": return workflowResult(command, "completed", "Keyboard Shortcuts", pinnedHotkeySummary());
|
|
251
|
+
case "fork": return forkWorkflow(call);
|
|
252
|
+
case "clone": return cloneWorkflow(call);
|
|
253
|
+
case "tree": return treeWorkflow(call);
|
|
254
|
+
case "trust": return trustWorkflow(call);
|
|
255
|
+
case "login": return await this.#authentication.login(request, session, runtime, argument, selection);
|
|
256
|
+
case "logout": return selection ? await this.#authentication.logout(request, runtime, selection) : workflowResult(command, "failed", "Logout requires the owned authentication controller");
|
|
257
|
+
case "new": return newSessionWorkflow(call);
|
|
258
|
+
case "compact": return compactWorkflow(call);
|
|
259
|
+
case "resume": return resumeWorkflow(call);
|
|
260
|
+
case "reload": return this.#reloadWorkflow(call);
|
|
261
|
+
case "quit": return this.#ports.dispose().then(() => workflowResult(command, "completed", "Shutdown complete"));
|
|
262
|
+
case "debug": return this.#debugWorkflow(request);
|
|
263
|
+
case "arminsayshi": return workflowResult(command, "completed", "Armin says hi");
|
|
264
|
+
case "dementedelves": return workflowResult(command, "completed", "Demented elves announcement");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
#modelWorkflow({ request, session, runtime, argument, selection }) {
|
|
268
|
+
const reference = selection ?? argument;
|
|
269
|
+
if (!reference)
|
|
270
|
+
return Promise.resolve(workflowResult(request.command, "failed", "Model requires the owned model controller"));
|
|
271
|
+
const scopedModels = Array.isArray(session.scopedModels)
|
|
272
|
+
? session.scopedModels.map(item => item.model)
|
|
273
|
+
: [];
|
|
274
|
+
// Compatibility: pinned Pi searches the session scope when one exists and refreshes catalogs only for an unscoped miss.
|
|
275
|
+
return this.#selectModel(request, reference, {
|
|
276
|
+
pool: scopedModels.length > 0 ? scopedModels : [...(runtime.services.modelRuntime.getAvailableSnapshot?.() ?? [])],
|
|
277
|
+
refreshOnMiss: scopedModels.length === 0,
|
|
278
|
+
persist: request.persist === true,
|
|
279
|
+
onMiss: "requires-selection",
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
#modelsWorkflow({ request, runtime, argument, selection }) {
|
|
283
|
+
// Invariant: the bare dialog seeds its query from the argument; only an explicit selection switches the current session.
|
|
284
|
+
if (!selection)
|
|
285
|
+
return Promise.resolve(workflowResult(request.command, "requires-selection", "Select a model", argument || undefined, "silent"));
|
|
286
|
+
return this.#selectModel(request, selection, {
|
|
287
|
+
pool: [...(runtime.services.modelRuntime.getAvailableSnapshot?.() ?? [])],
|
|
288
|
+
refreshOnMiss: true,
|
|
289
|
+
persist: false,
|
|
290
|
+
onMiss: "failed",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async #reloadWorkflow({ request, session, runtime }) {
|
|
294
|
+
const blocked = this.reloadBlockedResult();
|
|
295
|
+
if (blocked)
|
|
296
|
+
return blocked;
|
|
297
|
+
await requireCapability(session.reload, "reload").call(session);
|
|
298
|
+
await this.#ports.bindExtensionUiToSession();
|
|
299
|
+
const message = "Reloaded keybindings, extensions, skills, prompts, themes, and context files";
|
|
300
|
+
const modelError = runtime.services.modelRuntime.getError?.();
|
|
301
|
+
return workflowResult(request.command, "completed", message, undefined, "status", modelError ? [
|
|
302
|
+
{ kind: "error", message: `models.json error: ${modelError}` },
|
|
303
|
+
{ kind: "status", message },
|
|
304
|
+
] : undefined);
|
|
305
|
+
}
|
|
306
|
+
async #debugWorkflow(request) {
|
|
307
|
+
const debugPath = join(this.#agentDir, "pi-debug.log");
|
|
308
|
+
await mkdir(dirname(debugPath), { recursive: true });
|
|
309
|
+
await writeFile(debugPath, `${JSON.stringify(this.#ports.snapshot(), null, 2)}\n`, "utf8");
|
|
310
|
+
return workflowResult(request.command, "completed", "✓ Debug log written", debugPath);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function thinkingWorkflow({ request, session, argument, selection }, ports) {
|
|
314
|
+
const requested = (selection ?? argument).trim();
|
|
315
|
+
if (!requested)
|
|
316
|
+
return workflowResult(request.command, "requires-selection", "Select a thinking level", undefined, "silent");
|
|
317
|
+
const available = (session.getAvailableThinkingLevels?.() ?? []).map(String);
|
|
318
|
+
// Compatibility: pinned Pi matches the argument case-insensitively and words the failure with the available levels.
|
|
319
|
+
const level = available.find(candidate => candidate.toLowerCase() === requested.toLowerCase());
|
|
320
|
+
if (level === undefined) {
|
|
321
|
+
return workflowResult(request.command, "failed", `Unknown thinking level "${requested}". Available levels: ${available.join(", ")}.`);
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
session.setThinkingLevel(readThinkingLevel(level), { persist: request.persist === true });
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
return workflowResult(request.command, "failed", error instanceof Error ? error.message : String(error));
|
|
328
|
+
}
|
|
329
|
+
ports.setThinkingLevel(readThinkingLevel(session.thinkingLevel));
|
|
330
|
+
ports.emitView();
|
|
331
|
+
return workflowResult(request.command, "completed", request.persist === true ? `Default thinking level: ${level}` : `Thinking level: ${level}`);
|
|
332
|
+
}
|
|
333
|
+
function scopedModelsWorkflow({ request, session, runtime, selection }) {
|
|
334
|
+
if (!selection)
|
|
335
|
+
return workflowResult(request.command, "failed", "Scoped models requires the owned scoped-model controller");
|
|
336
|
+
const [providerId, modelId] = selection.split("/", 2);
|
|
337
|
+
const model = providerId && modelId ? runtime.services.modelRuntime.getModel(providerId, modelId) : undefined;
|
|
338
|
+
if (!model)
|
|
339
|
+
return workflowResult(request.command, "failed", `Model is unavailable: ${selection}`);
|
|
340
|
+
requireCapability(session.setScopedModels, "setScopedModels").call(session, [{ model }]);
|
|
341
|
+
return workflowResult(request.command, "completed", `Enabled scoped model ${selection}`);
|
|
342
|
+
}
|
|
343
|
+
async function exportWorkflow({ request, session, argument }) {
|
|
344
|
+
const path = pathArgument(argument);
|
|
345
|
+
const file = path?.toLowerCase().endsWith(".jsonl")
|
|
346
|
+
? requireCapability(session.exportToJsonl, "exportToJsonl").call(session, path)
|
|
347
|
+
: await requireCapability(session.exportToHtml, "exportToHtml").call(session, path);
|
|
348
|
+
return workflowResult(request.command, "completed", `Session exported to: ${String(file)}`);
|
|
349
|
+
}
|
|
350
|
+
async function importWorkflow({ request, runtime, argument }) {
|
|
351
|
+
const path = pathArgument(argument);
|
|
352
|
+
if (!path)
|
|
353
|
+
return workflowResult(request.command, "failed", "Usage: /import <path.jsonl>");
|
|
354
|
+
if (request.confirmed === undefined) {
|
|
355
|
+
return workflowConfirmation(request.command, `Replace current session with ${path}?`);
|
|
356
|
+
}
|
|
357
|
+
if (!request.confirmed)
|
|
358
|
+
return workflowResult(request.command, "cancelled", "Import cancelled", undefined, "status");
|
|
359
|
+
try {
|
|
360
|
+
const result = await requireCapability(runtime.importFromJsonl, "importFromJsonl").call(runtime, path, request.cwdOverride);
|
|
361
|
+
if (isRecord(result) && result.cancelled === true)
|
|
362
|
+
return workflowResult(request.command, "cancelled", "Import cancelled", undefined, "status");
|
|
363
|
+
return workflowResult(request.command, "completed", `Session imported from: ${path}`);
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
const issue = isRecord(error) && isRecord(error.issue) ? error.issue : undefined;
|
|
367
|
+
const fallbackCwd = issue === undefined ? undefined : stringProperty(issue, "fallbackCwd");
|
|
368
|
+
if (fallbackCwd !== undefined && request.cwdOverride === undefined) {
|
|
369
|
+
const sessionCwd = stringProperty(issue, "sessionCwd") ?? "the session working directory";
|
|
370
|
+
return workflowConfirmation(request.command, `cwd from session file does not exist\n${sessionCwd}\n\ncontinue in current cwd\n${fallbackCwd}`, fallbackCwd);
|
|
371
|
+
}
|
|
372
|
+
throw error;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async function copyWorkflow({ request, session }, copy) {
|
|
376
|
+
const text = requireCapability(session.getLastAssistantText, "getLastAssistantText").call(session);
|
|
377
|
+
if (typeof text !== "string" || text.length === 0)
|
|
378
|
+
return workflowResult(request.command, "completed", "", undefined, "silent");
|
|
379
|
+
const acknowledged = await copy(text);
|
|
380
|
+
return workflowResult(request.command, "completed", acknowledged ? "Copied last agent message to clipboard" : "Submitted last agent message to clipboard");
|
|
381
|
+
}
|
|
382
|
+
function nameWorkflow({ request, session, argument }, ports) {
|
|
383
|
+
const manager = session.sessionManager;
|
|
384
|
+
if (!argument) {
|
|
385
|
+
const current = manager?.getSessionName();
|
|
386
|
+
return typeof current === "string"
|
|
387
|
+
? workflowResult(request.command, "completed", `Session name: ${current}`)
|
|
388
|
+
: workflowResult(request.command, "failed", "Usage: /name <name>", undefined, "warning");
|
|
389
|
+
}
|
|
390
|
+
requireCapability(session.setSessionName, "setSessionName").call(session, argument);
|
|
391
|
+
ports.emitView();
|
|
392
|
+
const actual = sessionNameOr(manager?.getSessionName(), argument);
|
|
393
|
+
return workflowResult(request.command, "completed", `Session name set: ${actual}`, actual === argument ? undefined : `Session name was normalized from ${JSON.stringify(argument)} to ${JSON.stringify(actual)}`);
|
|
394
|
+
}
|
|
395
|
+
function sessionInfoWorkflow({ request, session, runtime }) {
|
|
396
|
+
const manager = session.sessionManager;
|
|
397
|
+
const stats = requireCapability(session.getSessionStats, "getSessionStats").call(session);
|
|
398
|
+
const entries = manager?.getEntries();
|
|
399
|
+
return {
|
|
400
|
+
...workflowResult(request.command, "completed", "Session Info"),
|
|
401
|
+
presentation: pinnedSessionInfoPresentation(stats, manager?.getSessionName(), Array.isArray(entries) ? entries : [], runtime.services.modelRuntime, {
|
|
402
|
+
mode: runtime.services.settingsManager?.getCacheWarmingMode?.(),
|
|
403
|
+
status: session.cacheWarmingStatus,
|
|
404
|
+
}),
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
async function forkWorkflow({ request, runtime, selection }) {
|
|
408
|
+
if (!selection)
|
|
409
|
+
return workflowResult(request.command, "failed", "Fork requires the owned user-message controller");
|
|
410
|
+
const result = await requireCapability(runtime.fork, "fork").call(runtime, selection, { position: "before" });
|
|
411
|
+
if (isRecord(result) && result.cancelled === true)
|
|
412
|
+
return workflowResult(request.command, "cancelled", "Fork cancelled", undefined, "silent");
|
|
413
|
+
return workflowResult(request.command, "completed", "Forked to new session");
|
|
414
|
+
}
|
|
415
|
+
async function cloneWorkflow({ request, session, runtime }) {
|
|
416
|
+
const leaf = session.sessionManager?.getLeafId?.();
|
|
417
|
+
if (typeof leaf !== "string")
|
|
418
|
+
return workflowResult(request.command, "completed", "Nothing to clone yet", undefined, "status");
|
|
419
|
+
const result = await requireCapability(runtime.fork, "fork").call(runtime, leaf, { position: "at" });
|
|
420
|
+
if (isRecord(result) && result.cancelled === true)
|
|
421
|
+
return workflowResult(request.command, "cancelled", "Clone cancelled", undefined, "silent");
|
|
422
|
+
return workflowResult(request.command, "completed", "Cloned to new session");
|
|
423
|
+
}
|
|
424
|
+
async function treeWorkflow({ request, session, selection }) {
|
|
425
|
+
if (!selection)
|
|
426
|
+
return workflowResult(request.command, "failed", "Tree navigation requires the owned tree controller");
|
|
427
|
+
const navigateTree = requireCapability(session.navigateTree, "navigateTree");
|
|
428
|
+
const result = request.treeSummary === undefined
|
|
429
|
+
? await navigateTree.call(session, selection)
|
|
430
|
+
: await navigateTree.call(session, selection, {
|
|
431
|
+
summarize: request.treeSummary.summarize,
|
|
432
|
+
...(request.treeSummary.customInstructions === undefined ? {} : { customInstructions: request.treeSummary.customInstructions }),
|
|
433
|
+
});
|
|
434
|
+
if (isRecord(result) && result.aborted === true)
|
|
435
|
+
return workflowResult(request.command, "cancelled", "Branch summarization cancelled", undefined, "status");
|
|
436
|
+
if (isRecord(result) && result.cancelled === true)
|
|
437
|
+
return workflowResult(request.command, "cancelled", "Navigation cancelled", undefined, "status");
|
|
438
|
+
const editorText = isRecord(result) && typeof result.editorText === "string" ? result.editorText : undefined;
|
|
439
|
+
return workflowResult(request.command, "completed", "Navigated to selected point", editorText);
|
|
440
|
+
}
|
|
441
|
+
function trustWorkflow({ request, runtime, selection }) {
|
|
442
|
+
if (!selection)
|
|
443
|
+
return workflowResult(request.command, "failed", "Trust requires the owned trust controller");
|
|
444
|
+
requireCapability(runtime.services.settingsManager?.setProjectTrusted, "setProjectTrusted").call(runtime.services.settingsManager, selection === "trust");
|
|
445
|
+
return workflowResult(request.command, "completed", selection === "trust" ? "Project trusted" : "Project trust removed");
|
|
446
|
+
}
|
|
447
|
+
async function newSessionWorkflow({ request, runtime }) {
|
|
448
|
+
const result = await runtime.newSession();
|
|
449
|
+
if (isRecord(result) && result.cancelled === true)
|
|
450
|
+
return workflowResult(request.command, "cancelled", "New session cancelled", undefined, "silent");
|
|
451
|
+
return workflowResult(request.command, "completed", "✓ New session started", undefined, "accent");
|
|
452
|
+
}
|
|
453
|
+
async function compactWorkflow({ request, session, argument }) {
|
|
454
|
+
try {
|
|
455
|
+
await session.compact(argument || undefined);
|
|
456
|
+
return workflowResult(request.command, "completed", "Compaction requested", undefined, "silent");
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
return workflowResult(request.command, "failed", error instanceof Error ? error.message : String(error));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
async function resumeWorkflow({ request, runtime, argument, selection }) {
|
|
463
|
+
if (!selection && !argument)
|
|
464
|
+
return workflowResult(request.command, "failed", "Resume requires the owned session controller");
|
|
465
|
+
const sessionPath = selection ?? argument;
|
|
466
|
+
try {
|
|
467
|
+
const result = await runtime.switchSession(sessionPath);
|
|
468
|
+
if (isRecord(result) && result.cancelled === true)
|
|
469
|
+
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "silent");
|
|
470
|
+
return workflowResult(request.command, "completed", "Resumed session");
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
const issue = isRecord(error) && isRecord(error.issue) ? error.issue : undefined;
|
|
474
|
+
const fallbackCwd = issue === undefined ? undefined : stringProperty(issue, "fallbackCwd");
|
|
475
|
+
if (fallbackCwd === undefined)
|
|
476
|
+
throw error;
|
|
477
|
+
if (request.confirmed === undefined) {
|
|
478
|
+
const sessionCwd = stringProperty(issue, "sessionCwd") ?? "the session working directory";
|
|
479
|
+
return workflowConfirmation(request.command, `cwd from session file does not exist\n${sessionCwd}\n\ncontinue in current cwd\n${fallbackCwd}`);
|
|
597
480
|
}
|
|
481
|
+
if (!request.confirmed)
|
|
482
|
+
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "status");
|
|
483
|
+
const result = await runtime.switchSession(sessionPath, { cwdOverride: fallbackCwd });
|
|
484
|
+
if (isRecord(result) && result.cancelled === true)
|
|
485
|
+
return workflowResult(request.command, "cancelled", "Resume cancelled", undefined, "silent");
|
|
486
|
+
return workflowResult(request.command, "completed", "Resumed session in current cwd");
|
|
598
487
|
}
|
|
599
488
|
}
|
|
600
489
|
/**
|