@timurproko/a1 0.2.6-dev.727 → 0.2.6-dev.736

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.
Files changed (116) hide show
  1. package/dist/app/session-shell/clipboard-services.d.ts +19 -0
  2. package/dist/app/session-shell/clipboard-services.js +7 -0
  3. package/dist/app/session-shell/exit-notice.d.ts +9 -5
  4. package/dist/app/session-shell/exit-notice.js +5 -5
  5. package/dist/app/session-shell/index.d.ts +4 -2
  6. package/dist/app/session-shell/index.js +2 -1
  7. package/dist/app/session-shell/paste-preparation-client.d.ts +3 -0
  8. package/dist/app/session-shell/paste-preparation-client.js +5 -2
  9. package/dist/app/session-shell/path-chip-presentation.d.ts +10 -3
  10. package/dist/app/session-shell/path-chip-presentation.js +48 -6
  11. package/dist/app/session-shell/prompt-chips.js +30 -4
  12. package/dist/app/session-shell/quit-outro.d.ts +3 -1
  13. package/dist/app/session-shell/quit-outro.js +23 -8
  14. package/dist/app/session-shell/response-copy-transport.d.ts +6 -1
  15. package/dist/app/session-shell/response-copy-transport.js +8 -2
  16. package/dist/app/session-shell/session-shell-root.d.ts +29 -11
  17. package/dist/app/session-shell/session-shell-root.js +62 -53
  18. package/dist/app/session-shell/session-shell.d.ts +55 -29
  19. package/dist/app/session-shell/session-shell.js +748 -1132
  20. package/dist/app/session-shell/shell-host.d.ts +105 -0
  21. package/dist/app/session-shell/shell-host.js +523 -0
  22. package/dist/cli/session-context.js +6 -3
  23. package/dist/composition/owned-ui.d.ts +20 -2
  24. package/dist/composition/owned-ui.js +107 -56
  25. package/dist/composition/session-info-reference.d.ts +2 -2
  26. package/dist/composition/session-info-reference.js +2 -2
  27. package/dist/contracts/agent-engine/capability-ports.d.ts +1 -85
  28. package/dist/contracts/agent-engine/capability-ports.js +1 -35
  29. package/dist/contracts/agent-engine/index.d.ts +1 -7
  30. package/dist/contracts/agent-engine/index.js +0 -4
  31. package/dist/contracts/owned-ui/index.d.ts +5 -1
  32. package/dist/contracts/owned-ui/index.js +1 -0
  33. package/dist/contracts/owned-ui/model.d.ts +6 -0
  34. package/dist/contracts/owned-ui/session-backend.d.ts +119 -0
  35. package/dist/contracts/owned-ui/session-presenters.d.ts +82 -0
  36. package/dist/contracts/owned-ui/session-presenters.js +1 -0
  37. package/dist/contracts/owned-ui/session-workflows.d.ts +342 -0
  38. package/dist/contracts/owned-ui/session-workflows.js +30 -0
  39. package/dist/features/launch/index.d.ts +1 -1
  40. package/dist/features/launch/index.js +1 -1
  41. package/dist/features/launch/session-context.d.ts +1 -0
  42. package/dist/features/launch/session-context.js +1 -0
  43. package/dist/features/owned-ui/settings-app.js +35 -15
  44. package/dist/foundation/lifecycle/index.d.ts +1 -1
  45. package/dist/foundation/lifecycle/index.js +1 -1
  46. package/dist/foundation/lifecycle/session-repository-context.d.ts +8 -2
  47. package/dist/foundation/lifecycle/session-repository-context.js +200 -65
  48. package/dist/foundation/release/bootstrap.js +1 -2
  49. package/dist/foundation/release/release-gc.js +1 -1
  50. package/dist/foundation/release/update.js +0 -4
  51. package/dist/foundation/storage/control-store.js +0 -12
  52. package/dist/integrations/pi/components/components.js +0 -16
  53. package/dist/integrations/pi/components/index.d.ts +3 -3
  54. package/dist/integrations/pi/components/index.js +2 -2
  55. package/dist/integrations/pi/components/models-dialog.js +1 -30
  56. package/dist/integrations/pi/components/shell-editor-autocomplete.js +11 -9
  57. package/dist/integrations/pi/components/shell-extension-ui.d.ts +3 -3
  58. package/dist/integrations/pi/components/shell-extension-ui.js +6 -2
  59. package/dist/integrations/pi/components/shell-presenters-transcript.js +4 -4
  60. package/dist/integrations/pi/components/shell-shared-facade.d.ts +21 -1
  61. package/dist/integrations/pi/components/shell-shared-facade.js +18 -2
  62. package/dist/integrations/pi/components/upstream/theme/theme.d.ts +5 -1
  63. package/dist/integrations/pi/components/upstream/theme/theme.js +20 -2
  64. package/dist/integrations/pi/engine/adapter.d.ts +44 -24
  65. package/dist/integrations/pi/engine/adapter.js +130 -22
  66. package/dist/integrations/pi/engine/command-dispatch.d.ts +2 -5
  67. package/dist/integrations/pi/engine/extension-ui-binding.d.ts +2 -11
  68. package/dist/integrations/pi/engine/host-ports.d.ts +20 -0
  69. package/dist/integrations/pi/engine/host-ports.js +13 -0
  70. package/dist/integrations/pi/engine/host.d.ts +70 -0
  71. package/dist/integrations/pi/engine/host.js +147 -0
  72. package/dist/integrations/pi/engine/index.d.ts +8 -4
  73. package/dist/integrations/pi/engine/index.js +3 -1
  74. package/dist/integrations/pi/engine/resource-catalog.d.ts +4 -23
  75. package/dist/integrations/pi/engine/runtime-integration.d.ts +8 -2
  76. package/dist/integrations/pi/engine/runtime-integration.js +12 -7
  77. package/dist/integrations/pi/engine/session-integration.d.ts +3 -8
  78. package/dist/integrations/pi/engine/session-integration.js +0 -49
  79. package/dist/integrations/pi/engine/session-runtime.d.ts +18 -3
  80. package/dist/integrations/pi/engine/session-runtime.js +18 -7
  81. package/dist/integrations/pi/engine/settings-bridge.d.ts +2 -2
  82. package/dist/integrations/pi/engine/settings-bridge.js +0 -2
  83. package/dist/integrations/pi/engine/settings-port.d.ts +2 -0
  84. package/dist/integrations/pi/engine/settings-port.js +3 -5
  85. package/dist/integrations/pi/engine/workflows.d.ts +33 -260
  86. package/dist/integrations/pi/engine/workflows.js +6 -28
  87. package/dist/integrations/pi/session-presenters/index.d.ts +2 -0
  88. package/dist/integrations/pi/session-presenters/index.js +1 -0
  89. package/dist/integrations/pi/session-presenters/presenters.d.ts +16 -0
  90. package/dist/integrations/pi/session-presenters/presenters.js +341 -0
  91. package/dist/integrations/pi/tui-runtime/adapter.js +0 -2
  92. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +18 -0
  93. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +84 -3
  94. package/dist/integrations/pi/tui-runtime/index.d.ts +1 -1
  95. package/dist/integrations/pi/tui-runtime/index.js +1 -1
  96. package/dist/native/darwin-arm64/manifest.json +1 -1
  97. package/dist/native/linux-x64/manifest.json +1 -1
  98. package/dist/native/win32-x64/manifest.json +2 -2
  99. package/dist/native/win32-x64/process-guardian.exe +0 -0
  100. package/dist/ui/settings/declarations.d.ts +13 -1
  101. package/dist/ui/settings/declarations.js +12 -1
  102. package/dist/ui/settings/migrations.js +7 -0
  103. package/docs/architecture/boundaries.md +9 -1
  104. package/docs/architecture/project-structure.md +3 -2
  105. package/docs/architecture/ui-reference-provenance.md +1 -1
  106. package/package.json +1 -1
  107. package/dist/contracts/agent-engine/model.d.ts +0 -78
  108. package/dist/contracts/agent-engine/model.js +0 -1
  109. package/dist/contracts/agent-engine/ports.d.ts +0 -18
  110. package/dist/contracts/agent-engine/serialization.d.ts +0 -7
  111. package/dist/contracts/agent-engine/serialization.js +0 -58
  112. package/dist/contracts/agent-engine/validation.d.ts +0 -5
  113. package/dist/contracts/agent-engine/validation.js +0 -128
  114. package/dist/integrations/pi/components/upstream/theme/system-theme.d.ts +0 -61
  115. package/dist/integrations/pi/components/upstream/theme/system-theme.js +0 -709
  116. /package/dist/contracts/{agent-engine/ports.js → owned-ui/session-backend.js} +0 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The session backend the owned shell presents. The shell and composition depend on this port,
3
+ * never on an engine adapter class, so a per-tab or non-Pi backend can stand behind the shell.
4
+ */
5
+ import type { OwnedUiExtensionUiPort } from "./extension-ui.js";
6
+ import type { OwnedUiCommand, OwnedUiEvent, OwnedUiImageAttachment, OwnedUiSessionViewModel, OwnedUiSnapshot } from "./model.js";
7
+ import type { OwnedUiAmbientAuthentication, OwnedUiAuthenticationProviderOption, OwnedUiBashWorkflowResult, OwnedUiCommandResult, OwnedUiExtensionResourceSummary, OwnedUiModelsContext, OwnedUiModelsRefreshResult, OwnedUiProjectTrustContext, OwnedUiProjectTrustUpdate, OwnedUiReleaseUpdate, OwnedUiResourceSummary, OwnedUiScopedModelsContext, OwnedUiScopedModelsRefreshResult, OwnedUiSessionProductMode, OwnedUiSessionResumeMetadata, OwnedUiSessionSettingsSnapshot, OwnedUiSettingOwner, OwnedUiSettingOwnerHandlers, OwnedUiSettingsThinkingLevel, OwnedUiVisualExtensionSupport, OwnedUiWorkflowAutocompleteCommand, OwnedUiWorkflowInteractionHost, OwnedUiWorkflowOption, OwnedUiWorkflowRequest, OwnedUiWorkflowResult } from "./session-workflows.js";
8
+ export interface OwnedUiSessionBackend {
9
+ readonly identity: OwnedUiSessionIdentityPort;
10
+ readonly session: OwnedUiSessionPort;
11
+ readonly workflows: OwnedUiWorkflowPort;
12
+ readonly settings: OwnedUiSessionSettingsPort;
13
+ readonly catalog: OwnedUiSessionCatalogPort;
14
+ readonly extensions: OwnedUiExtensionPort;
15
+ }
16
+ /** What a caller states about the session it wants; everything process-wide stays with the factory. */
17
+ export interface OwnedUiSessionRequest {
18
+ /** Unique within the process. Omitted means the factory assigns one that is. */
19
+ readonly sessionId?: string;
20
+ readonly cwd: string;
21
+ }
22
+ /**
23
+ * The one place sessions come from. The factory owns the state that is process-wide, so two
24
+ * sessions in one process never install, announce, or trace the same thing twice.
25
+ */
26
+ export interface OwnedUiSessionFactory {
27
+ create(request: OwnedUiSessionRequest): Promise<OwnedUiSessionBackend>;
28
+ }
29
+ /** Which session this is, where it lives, and how often it has been replaced. */
30
+ export interface OwnedUiSessionIdentityPort {
31
+ readonly sessionId: string;
32
+ readonly agentDir: string;
33
+ readonly cwd: string;
34
+ /** Advances on every session replacement and on delivery-only callback invalidation. */
35
+ readonly sessionGeneration: number;
36
+ /** Actual session replacements, excluding delivery-only invalidation of callbacks. */
37
+ readonly sessionBindingGeneration: number;
38
+ readonly disposed: boolean;
39
+ currentSessionResumeMetadata(): OwnedUiSessionResumeMetadata | null;
40
+ }
41
+ /** The session lifecycle, its view, its event stream, and command admission. */
42
+ export interface OwnedUiSessionPort {
43
+ start(): Promise<OwnedUiSessionViewModel>;
44
+ view(): OwnedUiSessionViewModel;
45
+ snapshot(): OwnedUiSnapshot;
46
+ /** Subscribe to events; the listener first receives the current view. Returns the unsubscribe. */
47
+ onEvent(listener: (event: OwnedUiEvent) => void): () => void;
48
+ execute(command: OwnedUiCommand): Promise<OwnedUiCommandResult>;
49
+ /** Settle queued delivery; rejects when required delivery was interrupted. */
50
+ flushEvents(): Promise<void>;
51
+ dispose(): Promise<void>;
52
+ }
53
+ /** Slash-command workflows and the shell-side host their interactive steps call back into. */
54
+ export interface OwnedUiWorkflowPort {
55
+ executeWorkflow(request: OwnedUiWorkflowRequest): Promise<OwnedUiWorkflowResult>;
56
+ executeBashWorkflow(command: string, excludeFromContext: boolean): Promise<OwnedUiBashWorkflowResult>;
57
+ cycleModelWorkflow(direction: "forward" | "backward"): Promise<OwnedUiWorkflowResult>;
58
+ workflowAutocompleteCommands(): readonly OwnedUiWorkflowAutocompleteCommand[];
59
+ /** Clear queued steering and follow-up submissions, returning their texts in order. */
60
+ clearQueuedWorkflows(): readonly string[];
61
+ /** The result a blocked `/reload` reported, or null when reload is available. */
62
+ reloadBlockedResult(): OwnedUiWorkflowResult | null;
63
+ /** Copy through the active clipboard owner; true means acknowledged delivery. */
64
+ copyWorkflowText(text: string): Promise<boolean>;
65
+ setWorkflowInteractionHost(interaction: OwnedUiWorkflowInteractionHost): void;
66
+ }
67
+ /**
68
+ * Engine settings the shell reads and the live effects it installs. Settings writes stay here
69
+ * rather than in `OwnedUiCommand`: commands are admitted per session, and a global default must
70
+ * not be gated by one session's admission or overload state.
71
+ */
72
+ export interface OwnedUiSessionSettingsPort {
73
+ readonly productMode: OwnedUiSessionProductMode;
74
+ snapshot(): OwnedUiSessionSettingsSnapshot;
75
+ /** Bind live effects for one owner; returns the unbind. */
76
+ bindOwner(owner: OwnedUiSettingOwner, handlers: OwnedUiSettingOwnerHandlers): () => void;
77
+ /** Persist the global thinking default without changing the live session level. */
78
+ setDefaultThinkingLevel(level: OwnedUiSettingsThinkingLevel): void;
79
+ /**
80
+ * The theme the engine is configured with, in the engine's own grammar: a theme's name, or a
81
+ * `light/dark` pair meaning "follow the terminal".
82
+ */
83
+ configuredTheme(): string | undefined;
84
+ }
85
+ /** Models, scopes, project trust, and authentication choices. */
86
+ export interface OwnedUiSessionCatalogPort {
87
+ modelsContext(): OwnedUiModelsContext;
88
+ setSessionModelScope(scopeIds: readonly string[]): void;
89
+ persistModelScope(scopeIds: readonly string[]): void;
90
+ refreshModels(signal: AbortSignal): Promise<OwnedUiModelsRefreshResult>;
91
+ pinnedScopedModelsContext(): OwnedUiScopedModelsContext;
92
+ updateScopedModels(enabledModelIds: readonly string[] | null): void;
93
+ persistScopedModels(enabledModelIds: readonly string[] | null): void;
94
+ refreshScopedModels(signal: AbortSignal): Promise<OwnedUiScopedModelsRefreshResult>;
95
+ pinnedProjectTrustContext(): OwnedUiProjectTrustContext;
96
+ persistProjectTrust(updates: readonly OwnedUiProjectTrustUpdate[]): void;
97
+ pinnedLoginOptions(authType?: "oauth" | "api_key"): readonly OwnedUiAuthenticationProviderOption[];
98
+ pinnedLoginMethodOptions(providerReference: string): {
99
+ readonly title: string;
100
+ readonly options: readonly OwnedUiWorkflowOption[];
101
+ };
102
+ pinnedAmbientAuthentication(selection: string): OwnedUiAmbientAuthentication | null;
103
+ pinnedLogoutOptions(): Promise<readonly OwnedUiAuthenticationProviderOption[]>;
104
+ pinnedForkOptions(): readonly OwnedUiWorkflowOption[];
105
+ }
106
+ /** Loaded resources, the extension UI bridge, transcript images, and clipboard binding. */
107
+ export interface OwnedUiExtensionPort {
108
+ nonVisualResources(): readonly OwnedUiResourceSummary[];
109
+ extensionResources(): readonly OwnedUiExtensionResourceSummary[];
110
+ resolveTranscriptImage(assetId: string): OwnedUiImageAttachment | null;
111
+ visualExtensionSupport(): OwnedUiVisualExtensionSupport;
112
+ /** Attach the shell's extension UI and bind it to the current session. */
113
+ bindExtensionUi(ui: OwnedUiExtensionUiPort, shutdown?: () => void | Promise<void>): Promise<void>;
114
+ unbindExtensionUi(): Promise<void>;
115
+ /** Bind the owned UI's clipboard lifecycle; true from the writer means acknowledged delivery. Returns the unbind. */
116
+ bindClipboardWriter(writer: (text: string) => Promise<boolean>): () => void;
117
+ /** Report a newer release found by the startup check. */
118
+ announceReleaseUpdate(release: OwnedUiReleaseUpdate): void;
119
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Presenters for the selectors and transcript renderers whose inputs are engine objects. The shell opens them
3
+ * through this port and never holds those objects; the Pi session presenters owner implements it.
4
+ */
5
+ import type { OwnedUiCommandResult, OwnedUiWorkflowRequest, OwnedUiWorkflowResult } from "./session-workflows.js";
6
+ /** A component that replaces the prompt editor while a selector is open. */
7
+ export interface OwnedUiInputSurface {
8
+ render(width: number): readonly string[];
9
+ invalidate(): void;
10
+ handleInput?(data: string): void;
11
+ setFocused?(focused: boolean): void;
12
+ dispose?(): void;
13
+ }
14
+ /**
15
+ * The terminal as one session presenter sees it. A render request from a presenter that is not the host's
16
+ * active presenter paints nothing; the presenter keeps its state current and paints once it is attached.
17
+ */
18
+ export interface OwnedUiPresenterHost {
19
+ requestRender(force?: boolean): void;
20
+ viewport(): {
21
+ readonly columns: number;
22
+ readonly rows: number;
23
+ };
24
+ /** Present only where the shell holds frames while an optional selector module loads. */
25
+ beginPresentationHold?(): () => void;
26
+ }
27
+ /** One engine session's presentation: its transcript, editor, controllers, and dialogs, and nothing terminal-wide. */
28
+ export interface OwnedUiSessionPresenter {
29
+ render(width: number): readonly string[];
30
+ handleInput(data: string): void;
31
+ invalidate(): void;
32
+ setFocused(focused: boolean): void;
33
+ start(): void;
34
+ waitUntilStopped(): Promise<void>;
35
+ dispose(): Promise<void>;
36
+ }
37
+ /** Owns the process terminal and shows exactly one active presenter. */
38
+ export interface OwnedUiTerminalHost<Presenter extends OwnedUiSessionPresenter = OwnedUiSessionPresenter> {
39
+ /** Makes the presenter active; its first frame is a full paint. */
40
+ attach(presenter: Presenter): void;
41
+ active(): Presenter | null;
42
+ /** No-op unless `from` is the active presenter. */
43
+ requestRender(from: Presenter, force?: boolean): void;
44
+ start(): void;
45
+ /** Ends the terminal: every presenter is released, the quit presentation plays, and the terminal is restored. */
46
+ dispose(): Promise<void>;
47
+ }
48
+ /** The shell's side of a presenter: where the selector is shown and how its choices reach the session. */
49
+ export interface OwnedUiDialogHost extends OwnedUiPresenterHost {
50
+ /** True once the shell is disposed; a presenter that awaited stops before showing anything. */
51
+ readonly disposed: boolean;
52
+ setInputSurface(surface: OwnedUiInputSurface | null): void;
53
+ appendWorkflowStatus(text: string): void;
54
+ appendWorkflowResult(result: OwnedUiWorkflowResult): void;
55
+ runWorkflow(request: OwnedUiWorkflowRequest): Promise<OwnedUiCommandResult>;
56
+ /** Present only where the surface can change TUI mode; false means overlays block the switch. */
57
+ switchTuiMode?(mode: "regular" | "fullscreen"): boolean;
58
+ }
59
+ /** One extension shortcut row in the hotkeys document. */
60
+ export interface OwnedUiShortcutDescription {
61
+ readonly key: string;
62
+ readonly description: string;
63
+ }
64
+ /**
65
+ * Extension renderer lookups for transcript components. Renderers are opaque objects that only the component
66
+ * adapter inspects and validates; the shell passes this port through without reading them.
67
+ */
68
+ export interface OwnedUiTranscriptRendererPort {
69
+ getMessageRenderer(customType: string): object | undefined;
70
+ getToolRenderers(toolName: string): object | undefined;
71
+ getShortcuts(bindings: Readonly<Record<string, string | readonly string[] | undefined>>): readonly OwnedUiShortcutDescription[];
72
+ }
73
+ export interface OwnedUiSessionPresenters {
74
+ transcriptRenderers(): OwnedUiTranscriptRendererPort;
75
+ openModelSelector(host: OwnedUiDialogHost, initialSearchInput?: string): void;
76
+ openSessionSelector(host: OwnedUiDialogHost, onExit: () => void): Promise<void>;
77
+ /** `navigate` completes a selection that leaves the current leaf, including any summary prompt. */
78
+ openTreeSelector(host: OwnedUiDialogHost, navigate: (entryId: string, skipSummaryPrompt: boolean) => void, initialSelectedId?: string): Promise<void>;
79
+ openSettingsSelector(host: OwnedUiDialogHost): void;
80
+ openModelsDialog(host: OwnedUiDialogHost, initialQuery?: string): void;
81
+ openScopedModelsSelector(host: OwnedUiDialogHost): void;
82
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Payloads that cross the session backend port: workflow requests and results, catalog and
3
+ * settings snapshots, resource summaries, and the slash-command names the shell routes. Every
4
+ * declaration is plain data, so a backend other than pinned Pi can produce it.
5
+ */
6
+ import type { OWNED_UI_EXTENSION_CONTRACT_VERSION, OWNED_UI_EXTENSION_RENDER_CALLBACKS, OWNED_UI_EXTENSION_UI_CALLBACKS, OWNED_UI_EXTENSION_UI_PROPERTIES } from "./extension-ui.js";
7
+ import type { OwnedUiCommandOutcome, OwnedUiThinkingLevel } from "./model.js";
8
+ /** Every workflow command the session engine advertises, in its own catalog order. */
9
+ export declare const OWNED_UI_WORKFLOW_COMMAND_NAMES: readonly ["settings", "model", "tree", "thinking", "scoped-models", "export", "import", "share", "copy", "name", "session", "changelog", "hotkeys", "fork", "clone", "trust", "login", "logout", "new", "compact", "resume", "reload", "quit"];
10
+ /** Routes the engine answers but never advertises. */
11
+ export declare const OWNED_UI_HIDDEN_COMMAND_NAMES: readonly ["debug", "arminsayshi", "dementedelves"];
12
+ /** The one bare-A1 model command; it replaces the `model` and `scoped-models` routes there. */
13
+ export declare const OWNED_UI_MODELS_COMMAND_NAME: "models";
14
+ export type OwnedUiWorkflowCommandName = typeof OWNED_UI_WORKFLOW_COMMAND_NAMES[number];
15
+ export type OwnedUiHiddenWorkflowCommandName = typeof OWNED_UI_HIDDEN_COMMAND_NAMES[number];
16
+ export type OwnedUiModelsCommandName = typeof OWNED_UI_MODELS_COMMAND_NAME;
17
+ export type OwnedUiWorkflowRoute = OwnedUiWorkflowCommandName | OwnedUiHiddenWorkflowCommandName | OwnedUiModelsCommandName;
18
+ /** Which settings surface a backend serves; hidden-in-bare effects are unbindable in bare mode. */
19
+ export type OwnedUiSessionProductMode = "bare" | "comparison";
20
+ export interface OwnedUiWorkflowOption {
21
+ readonly id: string;
22
+ readonly label: string;
23
+ readonly description?: string;
24
+ }
25
+ export interface OwnedUiAuthenticationProviderStatus {
26
+ readonly type: "oauth" | "api_key";
27
+ readonly source?: string;
28
+ }
29
+ export interface OwnedUiAuthenticationProviderOption extends OwnedUiWorkflowOption {
30
+ readonly providerId: string;
31
+ readonly authType: "oauth" | "api_key";
32
+ readonly status?: OwnedUiAuthenticationProviderStatus;
33
+ }
34
+ /** A provider configured outside the engine, which the login route explains instead of running. */
35
+ export interface OwnedUiAmbientAuthentication {
36
+ readonly providerId: string;
37
+ readonly providerName: string;
38
+ readonly title: string;
39
+ readonly message: string;
40
+ }
41
+ export interface OwnedUiWorkflowRequest {
42
+ readonly command: OwnedUiWorkflowRoute;
43
+ readonly argument: string;
44
+ readonly selection?: string;
45
+ /** For the model route: also persist the selection as the default model. The bare `models` route always persists. */
46
+ readonly persist?: boolean;
47
+ readonly confirmed?: boolean;
48
+ /** Recovery cwd selected after an import/resume source cwd is unavailable. */
49
+ readonly cwdOverride?: string;
50
+ /** Cancellation for an owned operation surface such as `/share`. */
51
+ readonly signal?: AbortSignal;
52
+ readonly treeSummary?: {
53
+ readonly summarize: boolean;
54
+ readonly customInstructions?: string;
55
+ };
56
+ }
57
+ export type OwnedUiWorkflowOutcome = "completed" | "cancelled" | "failed" | "requires-selection" | "requires-confirmation";
58
+ export interface OwnedUiSessionInfoPresentation {
59
+ readonly kind: "session-info";
60
+ readonly sessionName?: string;
61
+ readonly stats: {
62
+ readonly sessionFile?: string;
63
+ readonly sessionId: string;
64
+ readonly userMessages: number;
65
+ readonly assistantMessages: number;
66
+ readonly toolCalls: number;
67
+ readonly toolResults: number;
68
+ readonly totalMessages: number;
69
+ readonly tokens: {
70
+ readonly input: number;
71
+ readonly output: number;
72
+ readonly cacheRead: number;
73
+ readonly cacheWrite: number;
74
+ readonly total: number;
75
+ };
76
+ readonly cost: number;
77
+ };
78
+ readonly cacheWaste: {
79
+ readonly missedTokens: number;
80
+ readonly missedCost: number;
81
+ readonly missCount: number;
82
+ };
83
+ readonly usageBreakdown: readonly {
84
+ readonly key: string;
85
+ readonly cost: number;
86
+ readonly tokens: number;
87
+ }[];
88
+ readonly cacheWarming: OwnedUiCacheWarmingPresentation;
89
+ }
90
+ /** The engine's prompt-cache warming mode and, once warming has acted, the decision behind it. */
91
+ export interface OwnedUiCacheWarmingPresentation {
92
+ readonly mode: string;
93
+ readonly status?: {
94
+ readonly state: "inactive" | "scheduled" | "refreshing";
95
+ readonly reason?: string;
96
+ readonly nextWarmAt?: number;
97
+ readonly extensionOverride?: boolean;
98
+ readonly decision?: {
99
+ readonly phase: "streaming" | "idle";
100
+ readonly action: string;
101
+ readonly warmCost: number;
102
+ readonly missCost: number;
103
+ readonly continuationProbability: number;
104
+ readonly expectedSavings: number;
105
+ readonly economicsAvailable: boolean;
106
+ };
107
+ };
108
+ }
109
+ export type OwnedUiWorkflowPresentation = OwnedUiSessionInfoPresentation;
110
+ export type OwnedUiWorkflowMessageKind = "status" | "warning" | "error" | "accent" | "silent";
111
+ export interface OwnedUiWorkflowMessage {
112
+ readonly kind: Exclude<OwnedUiWorkflowMessageKind, "silent">;
113
+ readonly message: string;
114
+ }
115
+ export interface OwnedUiWorkflowResult {
116
+ readonly command: OwnedUiWorkflowRoute;
117
+ readonly outcome: OwnedUiWorkflowOutcome;
118
+ readonly message: string;
119
+ /** Explicit presentation semantics; never inferred from message prefixes. */
120
+ readonly messageKind?: OwnedUiWorkflowMessageKind;
121
+ /** Ordered messages for truthful partial-success outcomes. */
122
+ readonly messages?: readonly OwnedUiWorkflowMessage[];
123
+ readonly detail?: string;
124
+ readonly selectorTitle?: string;
125
+ readonly options?: readonly OwnedUiWorkflowOption[];
126
+ readonly presentation?: OwnedUiWorkflowPresentation;
127
+ }
128
+ export interface OwnedUiWorkflowAutocompleteCommand {
129
+ readonly name: string;
130
+ readonly description?: string;
131
+ readonly argumentHint?: string;
132
+ readonly argumentOptions?: readonly OwnedUiWorkflowOption[];
133
+ readonly source: "builtin" | "prompt" | "skill" | "extension";
134
+ }
135
+ export interface OwnedUiWorkflowInteractionRequest {
136
+ readonly type: "text" | "secret" | "manual-code" | "select";
137
+ readonly message: string;
138
+ readonly placeholder?: string;
139
+ readonly options?: readonly {
140
+ readonly id: string;
141
+ readonly label: string;
142
+ }[];
143
+ }
144
+ export interface OwnedUiWorkflowLoginStart {
145
+ readonly providerId: string;
146
+ readonly providerName: string;
147
+ readonly authType: "oauth" | "api_key";
148
+ }
149
+ export type OwnedUiWorkflowLoginNotification = {
150
+ readonly type: "auth_url";
151
+ readonly url: string;
152
+ readonly instructions?: string;
153
+ } | {
154
+ readonly type: "device_code";
155
+ readonly verificationUri: string;
156
+ readonly userCode: string;
157
+ } | {
158
+ readonly type: "info";
159
+ readonly message: string;
160
+ readonly links?: readonly {
161
+ readonly label?: string;
162
+ readonly url: string;
163
+ }[];
164
+ } | {
165
+ readonly type: "waiting" | "progress";
166
+ readonly message: string;
167
+ };
168
+ /** The shell's side of an interactive workflow such as `/login`. */
169
+ export interface OwnedUiWorkflowInteractionHost {
170
+ startLogin?(request: OwnedUiWorkflowLoginStart): void;
171
+ prompt(request: OwnedUiWorkflowInteractionRequest): Promise<string | null>;
172
+ notify(event: OwnedUiWorkflowLoginNotification): void;
173
+ /** Deliver a post-login status or warning after the authentication dialog closes. */
174
+ publish?(message: OwnedUiWorkflowMessage): void;
175
+ finishLogin?(): void;
176
+ }
177
+ export interface OwnedUiBashWorkflowResult {
178
+ readonly command: string;
179
+ readonly output: string;
180
+ readonly exitCode: number | undefined;
181
+ readonly cancelled: boolean;
182
+ readonly truncated: boolean;
183
+ readonly excludeFromContext: boolean;
184
+ }
185
+ export interface OwnedUiScopedModelDescriptor {
186
+ readonly provider: string;
187
+ readonly id: string;
188
+ readonly name: string;
189
+ }
190
+ export interface OwnedUiScopedModelsContext {
191
+ readonly models: readonly OwnedUiScopedModelDescriptor[];
192
+ readonly enabledModelIds: readonly string[] | null;
193
+ }
194
+ export interface OwnedUiScopedModelsRefreshResult extends OwnedUiScopedModelsContext {
195
+ readonly status: string;
196
+ readonly statusKind: "success" | "warning";
197
+ }
198
+ /** What the bare-A1 Models dialog reads: the authenticated catalog and the explicit session and persisted scopes, kept apart. */
199
+ export interface OwnedUiModelsContext {
200
+ readonly models: readonly OwnedUiScopedModelDescriptor[];
201
+ /** `provider/id` of the active model, or null before one is set. */
202
+ readonly activeModelId: string | null;
203
+ /** Ordered `provider/id` references the session cycles; empty is the all-model fallback, not an explicit full scope. */
204
+ readonly sessionScopeIds: readonly string[];
205
+ /** The persisted `enabledModels` patterns resolved against the catalog, in order; unmatched patterns stay verbatim. */
206
+ readonly persistedScopeIds: readonly string[];
207
+ }
208
+ export interface OwnedUiModelsRefreshResult {
209
+ readonly models: readonly OwnedUiScopedModelDescriptor[];
210
+ readonly status: string;
211
+ readonly statusKind: "success" | "warning";
212
+ }
213
+ export interface OwnedUiProjectTrustUpdate {
214
+ readonly path: string;
215
+ readonly decision: boolean | null;
216
+ }
217
+ export interface OwnedUiProjectTrustContext {
218
+ readonly cwd: string;
219
+ readonly savedDecision: {
220
+ readonly path: string;
221
+ readonly decision: boolean;
222
+ } | null;
223
+ readonly projectTrusted: boolean;
224
+ readonly trustOptions: readonly {
225
+ readonly label: string;
226
+ readonly trusted: boolean;
227
+ readonly updates: readonly OwnedUiProjectTrustUpdate[];
228
+ readonly savedPath?: string;
229
+ }[];
230
+ }
231
+ export interface OwnedUiSessionResumeMetadata {
232
+ readonly sessionId: string;
233
+ readonly sessionDir: string;
234
+ readonly usesDefaultSessionDir: boolean;
235
+ }
236
+ /** Settings-level thinking: the session's levels plus `max`, which only models that map it offer. */
237
+ export type OwnedUiSettingsThinkingLevel = OwnedUiThinkingLevel | "max";
238
+ /** The engine settings the shell reads to configure itself and to seed its settings surfaces. */
239
+ export interface OwnedUiSessionSettingsSnapshot {
240
+ readonly autoCompact: boolean;
241
+ readonly showImages: boolean;
242
+ readonly imageWidthCells: number;
243
+ readonly autoResizeImages: boolean;
244
+ readonly blockImages: boolean;
245
+ readonly enableSkillCommands: boolean;
246
+ readonly steeringMode: "all" | "one-at-a-time";
247
+ readonly followUpMode: "all" | "one-at-a-time";
248
+ readonly transport: "sse" | "websocket" | "websocket-cached" | "auto";
249
+ readonly httpIdleTimeoutMs: number;
250
+ readonly cacheWarmingMode: "off" | "streaming" | "idle";
251
+ readonly thinkingLevel: OwnedUiSettingsThinkingLevel;
252
+ readonly availableThinkingLevels: readonly OwnedUiSettingsThinkingLevel[];
253
+ /** The stored global default the selector offers to restore; the session's level may differ. */
254
+ readonly defaultThinkingLevel: OwnedUiSettingsThinkingLevel;
255
+ /** Per-model thinking overrides keyed `provider/modelId`. */
256
+ readonly modelThinkingLevels: Readonly<Record<string, string>>;
257
+ /** `provider/modelId` of the persisted default model, or the engine's "not set" wording. */
258
+ readonly defaultModel: string;
259
+ readonly currentTheme: string;
260
+ readonly terminalTheme: "dark" | "light";
261
+ readonly availableThemes: readonly string[];
262
+ readonly hideThinkingBlock: boolean;
263
+ readonly mermaidRenderingMode: "off" | "final" | "streaming";
264
+ readonly showCacheMissNotices: boolean;
265
+ readonly collapseChangelog: boolean;
266
+ readonly enableInstallTelemetry: boolean;
267
+ readonly doubleEscapeAction: "fork" | "tree" | "none";
268
+ readonly treeFilterMode: "default" | "no-tools" | "user-only" | "labeled-only" | "all";
269
+ readonly showHardwareCursor: boolean;
270
+ readonly editorPaddingX: number;
271
+ readonly outputPad: 0 | 1;
272
+ readonly autocompleteMaxVisible: number;
273
+ readonly quietStartup: boolean | "header";
274
+ readonly defaultProjectTrust: "ask" | "always" | "never";
275
+ readonly clearOnShrink: boolean;
276
+ readonly showTerminalProgress: boolean;
277
+ readonly tuiMode: "regular" | "fullscreen";
278
+ readonly fullscreenExitOutput: "transcript" | "resume-hint";
279
+ readonly fullscreenScrollbar: "hidden" | "auto" | "always";
280
+ readonly fullscreenCopyOnSelect: boolean;
281
+ readonly fullscreenWheelScrollLines: number | "auto";
282
+ readonly warnings: {
283
+ readonly anthropicExtraUsage?: boolean;
284
+ };
285
+ }
286
+ export type OwnedUiJsonValue = null | boolean | number | string | readonly OwnedUiJsonValue[] | {
287
+ readonly [key: string]: OwnedUiJsonValue;
288
+ };
289
+ /** The layer that installs a setting's live effect. */
290
+ export type OwnedUiSettingOwner = "agent" | "shell" | "terminal" | "startup" | "shutdown" | "installation";
291
+ /** Engine settings whose live effect an owner may bind. */
292
+ export type OwnedUiSessionSettingKey = "autoCompact" | "showImages" | "imageWidthCells" | "autoResizeImages" | "blockImages" | "enableSkillCommands" | "steeringMode" | "followUpMode" | "transport" | "httpIdleTimeoutMs" | "cacheWarmingMode" | "modelThinkingLevels" | "theme" | "hideThinkingBlock" | "mermaidRenderingMode" | "showCacheMissNotices" | "collapseChangelog" | "enableInstallTelemetry" | "quietStartup" | "defaultProjectTrust" | "doubleEscapeAction" | "treeFilterMode" | "showHardwareCursor" | "editorPaddingX" | "outputPad" | "autocompleteMaxVisible" | "clearOnShrink" | "showTerminalProgress" | "tuiMode" | "fullscreenExitOutput" | "fullscreenScrollbar" | "fullscreenCopyOnSelect" | "fullscreenWheelScrollLines" | "warnings";
293
+ export interface OwnedUiSettingEffectHandler {
294
+ /** Install one value in the active owner. Handlers must be idempotent and reversible. */
295
+ apply(value: OwnedUiJsonValue): void | Promise<void>;
296
+ }
297
+ export type OwnedUiSettingOwnerHandlers = Partial<Record<OwnedUiSessionSettingKey, OwnedUiSettingEffectHandler>>;
298
+ /** How the backend settled one owned UI command. */
299
+ export interface OwnedUiCommandResult {
300
+ readonly outcome: OwnedUiCommandOutcome;
301
+ readonly diagnostic: string | null;
302
+ }
303
+ export interface OwnedUiResourceSummary {
304
+ readonly kind: "skill" | "prompt-template" | "agent-context" | "system-prompt" | "theme";
305
+ readonly id: string;
306
+ readonly label: string;
307
+ readonly sourcePath: string | null;
308
+ readonly diagnostic: string | null;
309
+ }
310
+ export interface OwnedUiExtensionSourceSummary {
311
+ readonly source: string;
312
+ readonly scope: "user" | "project" | "temporary";
313
+ readonly origin: "package" | "top-level";
314
+ readonly baseDir: string | null;
315
+ }
316
+ export interface OwnedUiExtensionResourceSummary {
317
+ readonly kind: "extension";
318
+ readonly id: string;
319
+ readonly sourcePath: string | null;
320
+ readonly resolvedPath: string | null;
321
+ readonly sourceInfo: OwnedUiExtensionSourceSummary | null;
322
+ readonly loaded: boolean;
323
+ readonly hidden: boolean;
324
+ readonly diagnostic: string | null;
325
+ }
326
+ /** Whether the owned extension UI bridge is bound to the current session, and the contract it offers. */
327
+ export interface OwnedUiVisualExtensionSupport {
328
+ readonly available: boolean;
329
+ readonly contractComplete: true;
330
+ readonly contractVersion: typeof OWNED_UI_EXTENSION_CONTRACT_VERSION;
331
+ readonly binding: "bound" | "unbound";
332
+ readonly uiCallbacks: typeof OWNED_UI_EXTENSION_UI_CALLBACKS;
333
+ readonly uiProperties: typeof OWNED_UI_EXTENSION_UI_PROPERTIES;
334
+ readonly renderCallbacks: typeof OWNED_UI_EXTENSION_RENDER_CALLBACKS;
335
+ readonly diagnostic: string;
336
+ }
337
+ /** A newer release found by the startup check. */
338
+ export interface OwnedUiReleaseUpdate {
339
+ readonly version: string;
340
+ readonly command: string;
341
+ readonly changelogUrl: string | null;
342
+ }
@@ -0,0 +1,30 @@
1
+ /** Every workflow command the session engine advertises, in its own catalog order. */
2
+ export const OWNED_UI_WORKFLOW_COMMAND_NAMES = [
3
+ "settings",
4
+ "model",
5
+ "tree",
6
+ "thinking",
7
+ "scoped-models",
8
+ "export",
9
+ "import",
10
+ "share",
11
+ "copy",
12
+ "name",
13
+ "session",
14
+ "changelog",
15
+ "hotkeys",
16
+ "fork",
17
+ "clone",
18
+ "trust",
19
+ "login",
20
+ "logout",
21
+ "new",
22
+ "compact",
23
+ "resume",
24
+ "reload",
25
+ "quit",
26
+ ];
27
+ /** Routes the engine answers but never advertises. */
28
+ export const OWNED_UI_HIDDEN_COMMAND_NAMES = ["debug", "arminsayshi", "dementedelves"];
29
+ /** The one bare-A1 model command; it replaces the `model` and `scoped-models` routes there. */
30
+ export const OWNED_UI_MODELS_COMMAND_NAME = "models";
@@ -8,7 +8,7 @@ export { configurationRootForProfile, resolveLaunchProfilePaths, resolvePromptHi
8
8
  export type { LaunchProfilePathOptions, LaunchProfilePaths } from "./profile-paths.js";
9
9
  export { prepareInteractiveLaunch } from "./prepare-launch.js";
10
10
  export type { PrepareInteractiveLaunchOptions, PreparedInteractiveLaunch } from "./prepare-launch.js";
11
- export { updateSessionRepositoryContext } from "./session-context.js";
11
+ export { PRIMARY_SESSION_AGENT_ID, updateSessionRepositoryContext } from "./session-context.js";
12
12
  export type { SessionContextOutcome, SessionContextRequest, SessionContextRuntime } from "./session-context.js";
13
13
  export { runSelectedInteractiveRuntime, selectInteractiveRuntime } from "./runtime-selection.js";
14
14
  export type { InteractiveRuntimeRunners, InteractiveRuntimeSelection, OwnedUiProfileId } from "./runtime-selection.js";
@@ -3,5 +3,5 @@ export { PI_PROFILE_RESOURCE_DIRECTORIES, initializeProductProfile } from "./ini
3
3
  export { interactiveLaunchIntent, parseSessionSelection } from "./intent.js";
4
4
  export { configurationRootForProfile, resolveLaunchProfilePaths, resolvePromptHistoryDataDir } from "./profile-paths.js";
5
5
  export { prepareInteractiveLaunch } from "./prepare-launch.js";
6
- export { updateSessionRepositoryContext } from "./session-context.js";
6
+ export { PRIMARY_SESSION_AGENT_ID, updateSessionRepositoryContext } from "./session-context.js";
7
7
  export { runSelectedInteractiveRuntime, selectInteractiveRuntime } from "./runtime-selection.js";
@@ -1,4 +1,5 @@
1
1
  import { type NativeProcessIdentity, type SessionRepositoryIdentity, type SessionWorktreeInventoryEntry } from "../../foundation/lifecycle/index.js";
2
+ export { PRIMARY_SESSION_AGENT_ID } from "../../foundation/lifecycle/index.js";
2
3
  export type SessionContextRequest = {
3
4
  readonly action: "link-worktree";
4
5
  readonly path: string;
@@ -1,4 +1,5 @@
1
1
  import { clearSessionRepositoryContext, listSessionRepositoryWorktrees, setSessionRepositoryContext, } from "../../foundation/lifecycle/index.js";
2
+ export { PRIMARY_SESSION_AGENT_ID } from "../../foundation/lifecycle/index.js";
2
3
  export async function updateSessionRepositoryContext(identity, request, runtime) {
3
4
  const options = { runtimeId: runtime.runtimeId, inspectProcess: runtime.inspectProcess };
4
5
  if (request.action === "unlink-worktree") {