@timurproko/a1 0.1.8-dev.157 → 0.1.8-dev.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/bin/cli.js +2 -2
- package/bin/sync-pi-tui-proxy.js +1 -1
- package/bin/ui.js +18 -3
- package/dist/cli/dispatch.js +3 -3
- package/dist/cli/packages.js +1 -1
- package/dist/cli/version-stats.js +3 -3
- package/dist/composition/owned-ui.d.ts +4 -1
- package/dist/composition/owned-ui.js +9 -6
- package/dist/composition/settings-route-host.js +6 -4
- package/dist/contracts/agent-engine/capability-ports.d.ts +2 -2
- package/dist/contracts/agent-engine/domain-validation.js +22 -4
- package/dist/contracts/agent-engine/domain.d.ts +17 -0
- package/dist/contracts/owned-ui/model.d.ts +8 -0
- package/dist/contracts/owned-ui/validation.js +11 -0
- package/dist/features/launch/development-launch.js +1 -1
- package/dist/features/owned-ui/customization.d.ts +2 -0
- package/dist/features/owned-ui/customization.js +2 -0
- package/dist/features/owned-ui/diagnostics.d.ts +1 -0
- package/dist/features/owned-ui/diagnostics.js +1 -0
- package/dist/features/owned-ui/index.d.ts +1 -0
- package/dist/features/owned-ui/index.js +1 -0
- package/dist/features/owned-ui/project-trust-prompt.d.ts +25 -0
- package/dist/features/owned-ui/project-trust-prompt.js +149 -0
- package/dist/features/owned-ui/settings-app.js +69 -44
- package/dist/features/workspace/reducer.d.ts +1 -0
- package/dist/features/workspace/reducer.js +1 -0
- package/dist/features/workspace/router.d.ts +1 -0
- package/dist/features/workspace/router.js +1 -0
- package/dist/features/workspace/store.d.ts +1 -0
- package/dist/features/workspace/store.js +1 -0
- package/dist/foundation/launch-guardian/main.js +1 -1
- package/dist/foundation/native-host-protocol/codec.d.ts +2 -0
- package/dist/foundation/native-host-protocol/codec.js +2 -0
- package/dist/foundation/process-containment/linux-process-inspector.d.ts +1 -0
- package/dist/foundation/process-containment/linux-process-inspector.js +1 -0
- package/dist/foundation/process-containment/native-guardian-containment.d.ts +1 -0
- package/dist/foundation/process-containment/native-guardian-containment.js +1 -0
- package/dist/foundation/process-containment/windows-process-inspector.d.ts +1 -0
- package/dist/foundation/process-containment/windows-process-inspector.js +1 -0
- package/dist/foundation/protocol/client.d.ts +1 -0
- package/dist/foundation/protocol/client.js +1 -0
- package/dist/foundation/protocol/messages.d.ts +1 -0
- package/dist/foundation/protocol/messages.js +1 -0
- package/dist/foundation/release/bootstrap.js +6 -6
- package/dist/foundation/release/cohort-state.d.ts +1 -0
- package/dist/foundation/release/cohort-state.js +1 -0
- package/dist/foundation/release/release-gc.js +1 -1
- package/dist/foundation/release/release.js +1 -1
- package/dist/foundation/release/update-transaction.d.ts +1 -0
- package/dist/foundation/release/update-transaction.js +1 -0
- package/dist/foundation/release/update.js +12 -12
- package/dist/foundation/storage/control-store.d.ts +1 -0
- package/dist/foundation/storage/control-store.js +1 -0
- package/dist/foundation/structured-agent-runtime/backpressure.d.ts +1 -0
- package/dist/foundation/structured-agent-runtime/backpressure.js +1 -0
- package/dist/foundation/structured-agent-runtime/commands.d.ts +1 -0
- package/dist/foundation/structured-agent-runtime/commands.js +1 -0
- package/dist/foundation/structured-agent-runtime/reconnection.d.ts +1 -0
- package/dist/foundation/structured-agent-runtime/reconnection.js +1 -0
- package/dist/foundation/structured-agent-runtime/state.d.ts +1 -0
- package/dist/foundation/structured-agent-runtime/state.js +1 -0
- package/dist/foundation/supervision/main.js +1 -1
- package/dist/foundation/supervision/server.d.ts +1 -0
- package/dist/foundation/supervision/server.js +4 -6
- package/dist/integrations/pi/components/conformance.d.ts +1 -0
- package/dist/integrations/pi/components/conformance.js +1 -0
- package/dist/integrations/pi/components/shell-components.d.ts +1 -0
- package/dist/integrations/pi/components/shell-components.js +1 -0
- package/dist/integrations/pi/components/shell-editor-autocomplete.js +10 -0
- package/dist/integrations/pi/components/shell-footer-status.d.ts +1 -1
- package/dist/integrations/pi/components/shell-footer-status.js +19 -13
- package/dist/integrations/pi/components/shell-presenters-info.d.ts +36 -0
- package/dist/integrations/pi/components/shell-presenters-info.js +78 -0
- package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +3 -36
- package/dist/integrations/pi/components/shell-presenters-transcript.js +88 -128
- package/dist/integrations/pi/components/shell-shared-facade.d.ts +11 -1
- package/dist/integrations/pi/components/shell-shared-facade.js +1 -1
- package/dist/integrations/pi/engine/adapter.d.ts +22 -4
- package/dist/integrations/pi/engine/adapter.js +220 -70
- package/dist/integrations/pi/engine/conformance.d.ts +2 -0
- package/dist/integrations/pi/engine/conformance.js +2 -0
- package/dist/integrations/pi/engine/http-dispatcher.d.ts +4 -0
- package/dist/integrations/pi/engine/http-dispatcher.js +25 -0
- package/dist/integrations/pi/engine/index.d.ts +3 -0
- package/dist/integrations/pi/engine/index.js +3 -0
- package/dist/integrations/pi/engine/model-auth-integration.d.ts +1 -0
- package/dist/integrations/pi/engine/model-auth-integration.js +1 -0
- package/dist/integrations/pi/engine/package-integration.js +1 -1
- package/dist/integrations/pi/engine/project-trust-preflight.d.ts +22 -0
- package/dist/integrations/pi/engine/project-trust-preflight.js +50 -0
- package/dist/integrations/pi/engine/resource-extension-integration.d.ts +1 -0
- package/dist/integrations/pi/engine/resource-extension-integration.js +1 -0
- package/dist/integrations/pi/engine/runtime-integration.d.ts +16 -1
- package/dist/integrations/pi/engine/runtime-integration.js +34 -4
- package/dist/integrations/pi/engine/session-integration.d.ts +1 -0
- package/dist/integrations/pi/engine/session-integration.js +2 -1
- package/dist/integrations/pi/engine/settings-effects.d.ts +66 -0
- package/dist/integrations/pi/engine/settings-effects.js +249 -0
- package/dist/integrations/pi/engine/settings-integration.d.ts +14 -26
- package/dist/integrations/pi/engine/settings-integration.js +102 -108
- package/dist/integrations/pi/engine/workflow-controllers.d.ts +2 -1
- package/dist/integrations/pi/engine/workflow-controllers.js +1 -0
- package/dist/integrations/pi/session-ui/clipboard-image.d.ts +11 -0
- package/dist/integrations/pi/session-ui/clipboard-image.js +29 -0
- package/dist/integrations/pi/session-ui/index.d.ts +1 -0
- package/dist/integrations/pi/session-ui/index.js +1 -0
- package/dist/integrations/pi/session-ui/prompt-chips.js +6 -2
- package/dist/integrations/pi/session-ui/session-shell-root.d.ts +39 -4
- package/dist/integrations/pi/session-ui/session-shell-root.js +215 -80
- package/dist/integrations/pi/session-ui/session-shell.d.ts +10 -1
- package/dist/integrations/pi/session-ui/session-shell.js +256 -45
- package/dist/integrations/pi/session-ui/session-viewport-controller.d.ts +5 -0
- package/dist/integrations/pi/session-ui/session-viewport-controller.js +76 -11
- package/dist/integrations/pi/session-ui/stream-presentation-coalescer.d.ts +29 -0
- package/dist/integrations/pi/session-ui/stream-presentation-coalescer.js +79 -0
- package/dist/integrations/pi/session-ui/system-clipboard.d.ts +9 -0
- package/dist/integrations/pi/session-ui/system-clipboard.js +38 -9
- package/dist/integrations/pi/tui-runtime/adapter.d.ts +6 -0
- package/dist/integrations/pi/tui-runtime/adapter.js +166 -8
- package/dist/integrations/pi/tui-runtime/contracts.d.ts +25 -0
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +63 -0
- package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +240 -0
- package/dist/integrations/pi/tui-runtime/index.d.ts +2 -0
- package/dist/integrations/pi/tui-runtime/index.js +2 -0
- package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +39 -0
- package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.js +139 -0
- package/dist/native/darwin-arm64/manifest.json +1 -1
- package/dist/native/linux-x64/manifest.json +1 -1
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/native/win32-x64/process-guardian.exe +0 -0
- package/dist/ui/apps/host.js +5 -9
- package/dist/ui/apps/registry.d.ts +1 -0
- package/dist/ui/apps/registry.js +1 -0
- package/dist/ui/components/dialog-panel.js +5 -3
- package/dist/ui/components/frame.d.ts +1 -0
- package/dist/ui/components/frame.js +1 -0
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/components/line-input.d.ts +1 -6
- package/dist/ui/components/line-input.js +4 -9
- package/dist/ui/components/list-view.d.ts +0 -6
- package/dist/ui/components/list-view.js +14 -7
- package/dist/ui/components/progress-status.d.ts +2 -0
- package/dist/ui/components/progress-status.js +4 -0
- package/dist/ui/components/scrollbar.js +1 -1
- package/dist/ui/components/shortcuts.d.ts +1 -0
- package/dist/ui/components/shortcuts.js +1 -0
- package/dist/ui/components/spans.d.ts +2 -5
- package/dist/ui/components/spans.js +28 -8
- package/dist/ui/components/surface.d.ts +0 -5
- package/dist/ui/components/surface.js +1 -5
- package/dist/ui/components/text-selection.d.ts +10 -1
- package/dist/ui/components/text-selection.js +96 -29
- package/dist/ui/components/text.js +3 -3
- package/dist/ui/components/transcript-viewport.d.ts +42 -0
- package/dist/ui/components/transcript-viewport.js +287 -39
- package/dist/ui/settings/sections.d.ts +6 -19
- package/dist/ui/settings/sections.js +17 -15
- package/dist/ui/settings/session.d.ts +8 -18
- package/dist/ui/settings/session.js +60 -52
- package/dist/ui/settings/store.d.ts +1 -0
- package/dist/ui/settings/store.js +2 -1
- package/docs/architecture/code-documentation.md +77 -0
- package/docs/architecture/project-structure.md +15 -1
- package/docs/architecture/ui-reference-provenance.md +23 -3
- package/docs/ci-release-runbook.md +98 -7
- package/docs/manual-owned-ui-checkpoint.md +28 -1
- package/docs/manual-terminal-colour-check.md +4 -3
- package/docs/repository-governance-live-acceptance.md +77 -0
- package/package.json +11 -3
|
@@ -4,6 +4,9 @@ export * from "./runtime-integration.js";
|
|
|
4
4
|
export * from "./session-integration.js";
|
|
5
5
|
export * from "./model-auth-integration.js";
|
|
6
6
|
export * from "./settings-integration.js";
|
|
7
|
+
export * from "./settings-effects.js";
|
|
8
|
+
export * from "./project-trust-preflight.js";
|
|
9
|
+
export * from "./http-dispatcher.js";
|
|
7
10
|
export * from "./package-integration.js";
|
|
8
11
|
export * from "./resource-extension-integration.js";
|
|
9
12
|
export * from "./workflow-controllers.js";
|
|
@@ -9,6 +9,7 @@ export interface PiModelAuthenticationOptions {
|
|
|
9
9
|
readonly timeoutMs?: number;
|
|
10
10
|
readonly scopedModelIds?: () => readonly string[] | undefined;
|
|
11
11
|
}
|
|
12
|
+
/** Adapts the pinned model runtime to neutral model selection and authentication operations. */
|
|
12
13
|
export declare class PiModelAuthenticationIntegration implements AgentModelPort, AgentAuthenticationPort {
|
|
13
14
|
#private;
|
|
14
15
|
private readonly options;
|
|
@@ -52,7 +52,7 @@ export function createPiPackagesPort(input) {
|
|
|
52
52
|
},
|
|
53
53
|
async update(source) {
|
|
54
54
|
return await attempt("update", source ?? null, async () => {
|
|
55
|
-
//
|
|
55
|
+
// Rationale: asking first keeps "that package is not installed here" a structural
|
|
56
56
|
// answer rather than a string a caller would have to recognize.
|
|
57
57
|
if (source !== undefined && !isConfigured(source))
|
|
58
58
|
return agentPackageOutcome("update", "not-found", null, source);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface PiProjectTrustPreflightRequest {
|
|
2
|
+
readonly cwd: string;
|
|
3
|
+
readonly defaultDecision: "ask" | "always" | "never";
|
|
4
|
+
}
|
|
5
|
+
export type PiProjectTrustPreflightPrompt = (request: PiProjectTrustPreflightRequest) => Promise<boolean | null>;
|
|
6
|
+
export interface PiProjectTrustPreflightResult {
|
|
7
|
+
readonly trusted: boolean;
|
|
8
|
+
readonly source: "no-project-resources" | "saved" | "default" | "interactive" | "fail-closed";
|
|
9
|
+
readonly diagnostic: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolvePiProjectTrustPreflightOptions {
|
|
12
|
+
readonly cwd: string;
|
|
13
|
+
readonly agentDir: string;
|
|
14
|
+
readonly prompt?: PiProjectTrustPreflightPrompt;
|
|
15
|
+
readonly hasProjectResources?: (cwd: string) => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolves trust from global state only. It never constructs a project-trusted
|
|
19
|
+
* settings manager or resource loader; callers may do that only after this
|
|
20
|
+
* result exists.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolvePiProjectTrustPreflight(options: ResolvePiProjectTrustPreflightOptions): Promise<PiProjectTrustPreflightResult>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { hasTrustRequiringProjectResources, ProjectTrustStore, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves trust from global state only. It never constructs a project-trusted
|
|
4
|
+
* settings manager or resource loader; callers may do that only after this
|
|
5
|
+
* result exists.
|
|
6
|
+
*/
|
|
7
|
+
export async function resolvePiProjectTrustPreflight(options) {
|
|
8
|
+
const hasProjectResources = options.hasProjectResources ?? hasTrustRequiringProjectResources;
|
|
9
|
+
if (!hasProjectResources(options.cwd)) {
|
|
10
|
+
return { trusted: true, source: "no-project-resources", diagnostic: null };
|
|
11
|
+
}
|
|
12
|
+
const trustStore = new ProjectTrustStore(options.agentDir);
|
|
13
|
+
const saved = trustStore.get(options.cwd);
|
|
14
|
+
if (saved !== null)
|
|
15
|
+
return { trusted: saved, source: "saved", diagnostic: null };
|
|
16
|
+
// Security: projectTrusted:false is the boundary: this read may see global
|
|
17
|
+
// settings but cannot consume project settings or construct project resources.
|
|
18
|
+
const globalSettings = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });
|
|
19
|
+
const fallback = globalSettings.getDefaultProjectTrust();
|
|
20
|
+
if (fallback === "always")
|
|
21
|
+
return { trusted: true, source: "default", diagnostic: null };
|
|
22
|
+
if (fallback === "never")
|
|
23
|
+
return { trusted: false, source: "default", diagnostic: null };
|
|
24
|
+
if (options.prompt === undefined) {
|
|
25
|
+
return {
|
|
26
|
+
trusted: false,
|
|
27
|
+
source: "fail-closed",
|
|
28
|
+
diagnostic: `Project resources in ${options.cwd} were withheld because trust requires interaction`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const decision = await options.prompt({ cwd: options.cwd, defaultDecision: fallback });
|
|
33
|
+
if (decision === null) {
|
|
34
|
+
return {
|
|
35
|
+
trusted: false,
|
|
36
|
+
source: "fail-closed",
|
|
37
|
+
diagnostic: `Project resources in ${options.cwd} were withheld because trust selection was cancelled`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
trustStore.set(options.cwd, decision);
|
|
41
|
+
return { trusted: decision, source: "interactive", diagnostic: null };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
trusted: false,
|
|
46
|
+
source: "fail-closed",
|
|
47
|
+
diagnostic: `Project resources in ${options.cwd} were withheld because trust resolution failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -5,6 +5,7 @@ export interface PiResourceExtensionOptions {
|
|
|
5
5
|
readonly bindUi: () => Promise<void>;
|
|
6
6
|
readonly unbindUi: () => Promise<void>;
|
|
7
7
|
}
|
|
8
|
+
/** Adapts Pi resource discovery and extension binding while containing extension failures at the port. */
|
|
8
9
|
export declare class PiResourceExtensionIntegration implements AgentResourcesPort, AgentExtensionPort {
|
|
9
10
|
#private;
|
|
10
11
|
private readonly options;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { type AgentSession, type AgentSessionRuntime, type AgentSessionServices, type ScopedModel } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { createAgentSessionServices, SettingsManager, type AgentSession, type AgentSessionRuntime, type AgentSessionServices, type ScopedModel } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { resolvePiProjectTrustPreflight, type PiProjectTrustPreflightPrompt } from "./project-trust-preflight.js";
|
|
2
3
|
export interface PiRuntimeIntegrationOptions {
|
|
3
4
|
readonly cwd: string;
|
|
4
5
|
readonly agentDir: string;
|
|
5
6
|
readonly sessionDir?: string;
|
|
7
|
+
readonly sessionPath?: string;
|
|
8
|
+
readonly projectTrustPrompt?: PiProjectTrustPreflightPrompt;
|
|
9
|
+
readonly preflightDependencies?: PiRuntimePreflightDependencies;
|
|
10
|
+
}
|
|
11
|
+
export interface PiRuntimePreflightDependencies {
|
|
12
|
+
readonly resolveTrust?: typeof resolvePiProjectTrustPreflight;
|
|
13
|
+
readonly createSettingsManager?: (cwd: string, agentDir: string, projectTrusted: boolean) => SettingsManager;
|
|
14
|
+
readonly createServices?: typeof createAgentSessionServices;
|
|
6
15
|
}
|
|
7
16
|
export type PiSessionReplacement = {
|
|
8
17
|
readonly kind: "new";
|
|
@@ -26,6 +35,12 @@ interface ConfiguredModelScope {
|
|
|
26
35
|
* saved default when it is in scope, otherwise the first scoped model.
|
|
27
36
|
*/
|
|
28
37
|
export declare function resolveConfiguredModelScope(services: Pick<AgentSessionServices, "settingsManager" | "modelRuntime">): Promise<ConfiguredModelScope>;
|
|
38
|
+
export declare function createPiRuntimeServicesAfterTrust(options: Pick<PiRuntimeIntegrationOptions, "agentDir" | "projectTrustPrompt" | "preflightDependencies"> & {
|
|
39
|
+
readonly cwd: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
readonly services: AgentSessionServices;
|
|
42
|
+
readonly trust: Awaited<ReturnType<typeof resolvePiProjectTrustPreflight>>;
|
|
43
|
+
}>;
|
|
29
44
|
export declare function createPiRuntimeIntegration(options: PiRuntimeIntegrationOptions): Promise<AgentSessionRuntime>;
|
|
30
45
|
export declare function bindPiRuntimeSession(runtime: AgentSessionRuntime, rebind: (session: AgentSession) => Promise<void>): () => void;
|
|
31
46
|
export declare function replacePiRuntimeSession(runtime: AgentSessionRuntime, replacement: PiSessionReplacement): Promise<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, resolveModelScopeWithDiagnostics, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, resolveModelScopeWithDiagnostics, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { resolvePiProjectTrustPreflight, } from "./project-trust-preflight.js";
|
|
2
3
|
/**
|
|
3
4
|
* Mirrors pinned Pi's CLI startup: resolve the `models` patterns from settings
|
|
4
5
|
* into a scoped model list, keep the resolver's warnings (e.g. "No models match
|
|
@@ -29,10 +30,32 @@ export async function resolveConfiguredModelScope(services) {
|
|
|
29
30
|
diagnostics: diagnostics.map(diagnostic => ({ type: diagnostic.type, message: diagnostic.message })),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
export async function createPiRuntimeServicesAfterTrust(options) {
|
|
34
|
+
const resolveTrust = options.preflightDependencies?.resolveTrust ?? resolvePiProjectTrustPreflight;
|
|
35
|
+
const createSettingsManager = options.preflightDependencies?.createSettingsManager
|
|
36
|
+
?? ((targetCwd, agentDir, projectTrusted) => SettingsManager.create(targetCwd, agentDir, { projectTrusted }));
|
|
37
|
+
const createServices = options.preflightDependencies?.createServices ?? createAgentSessionServices;
|
|
38
|
+
const trust = await resolveTrust({
|
|
39
|
+
cwd: options.cwd,
|
|
40
|
+
agentDir: options.agentDir,
|
|
41
|
+
...(options.projectTrustPrompt === undefined ? {} : { prompt: options.projectTrustPrompt }),
|
|
42
|
+
});
|
|
43
|
+
const settingsManager = createSettingsManager(options.cwd, options.agentDir, trust.trusted);
|
|
44
|
+
const services = await createServices({ cwd: options.cwd, agentDir: options.agentDir, settingsManager });
|
|
45
|
+
return { services, trust };
|
|
46
|
+
}
|
|
32
47
|
export async function createPiRuntimeIntegration(options) {
|
|
33
|
-
const
|
|
48
|
+
const sessionDir = options.sessionDir ?? process.env.PI_CODING_AGENT_SESSION_DIR;
|
|
49
|
+
const sessionManager = options.sessionPath === undefined
|
|
50
|
+
? SessionManager.create(options.cwd, sessionDir)
|
|
51
|
+
: SessionManager.open(options.sessionPath, sessionDir, options.cwd);
|
|
34
52
|
const createRuntime = async ({ cwd, sessionManager: targetSessionManager, sessionStartEvent, }) => {
|
|
35
|
-
const services = await
|
|
53
|
+
const { services, trust } = await createPiRuntimeServicesAfterTrust({
|
|
54
|
+
cwd,
|
|
55
|
+
agentDir: options.agentDir,
|
|
56
|
+
...(options.projectTrustPrompt === undefined ? {} : { projectTrustPrompt: options.projectTrustPrompt }),
|
|
57
|
+
...(options.preflightDependencies === undefined ? {} : { preflightDependencies: options.preflightDependencies }),
|
|
58
|
+
});
|
|
36
59
|
const modelScope = await resolveConfiguredModelScope(services);
|
|
37
60
|
const hasExistingSession = targetSessionManager.buildSessionContext().messages.length > 0;
|
|
38
61
|
const created = await createAgentSessionFromServices({
|
|
@@ -43,7 +66,14 @@ export async function createPiRuntimeIntegration(options) {
|
|
|
43
66
|
...(modelScope.thinkingLevel && !hasExistingSession ? { thinkingLevel: modelScope.thinkingLevel } : {}),
|
|
44
67
|
...(modelScope.scopedModels.length > 0 ? { scopedModels: [...modelScope.scopedModels] } : {}),
|
|
45
68
|
});
|
|
46
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
...created,
|
|
71
|
+
services,
|
|
72
|
+
diagnostics: [
|
|
73
|
+
...(trust.diagnostic === null ? [] : [{ type: "warning", message: trust.diagnostic }]),
|
|
74
|
+
...modelScope.diagnostics,
|
|
75
|
+
],
|
|
76
|
+
};
|
|
47
77
|
};
|
|
48
78
|
return createAgentSessionRuntime(createRuntime, {
|
|
49
79
|
cwd: options.cwd,
|
|
@@ -31,6 +31,7 @@ export interface PiSessionCommandResult {
|
|
|
31
31
|
readonly outcome: AgentCommandOutcome;
|
|
32
32
|
readonly value?: unknown;
|
|
33
33
|
}
|
|
34
|
+
/** Routes neutral session commands to Pi while preserving Pi streaming and retry semantics. */
|
|
34
35
|
export declare class PiSessionCommandIntegration {
|
|
35
36
|
#private;
|
|
36
37
|
private readonly session;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AGENT_ENGINE_CONTRACT_VERSION, } from "../../../contracts/agent-engine/index.js";
|
|
2
|
+
/** Routes neutral session commands to Pi while preserving Pi streaming and retry semantics. */
|
|
2
3
|
export class PiSessionCommandIntegration {
|
|
3
4
|
session;
|
|
4
5
|
#lastPrompt = null;
|
|
@@ -18,7 +19,7 @@ export class PiSessionCommandIntegration {
|
|
|
18
19
|
return { outcome: "completed" };
|
|
19
20
|
case "steer":
|
|
20
21
|
this.#lastPrompt = command.text;
|
|
21
|
-
//
|
|
22
|
+
// Compatibility: match interactive Pi: prompt() owns template/extension expansion and
|
|
22
23
|
// turns the accepted steering message into the visible user row while
|
|
23
24
|
// later messages remain in the pending queue.
|
|
24
25
|
await this.session.prompt(command.text, {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentJsonValue, AgentSettingApplicationBoundary, AgentSettingChangeOutcome, AgentSettingOwner } from "../../../contracts/agent-engine/index.js";
|
|
2
|
+
export type PiSettingKey = "autoCompact" | "showImages" | "imageWidthCells" | "autoResizeImages" | "blockImages" | "enableSkillCommands" | "steeringMode" | "followUpMode" | "transport" | "httpIdleTimeoutMs" | "thinkingLevel" | "theme" | "hideThinkingBlock" | "mermaidRenderingMode" | "showCacheMissNotices" | "collapseChangelog" | "enableInstallTelemetry" | "quietStartup" | "defaultProjectTrust" | "doubleEscapeAction" | "treeFilterMode" | "showHardwareCursor" | "editorPaddingX" | "outputPad" | "autocompleteMaxVisible" | "clearOnShrink" | "showTerminalProgress" | "tuiMode" | "fullscreenExitOutput" | "fullscreenScrollbar" | "warnings";
|
|
3
|
+
export type PiSettingVisualClass = "none" | "transcript" | "transcript-geometry" | "editor-menu" | "queue-transcript" | "status-error" | "retry-error" | "footer-transcript" | "markdown" | "transcript-notice" | "startup-transcript" | "startup-selector" | "selector" | "terminal-cursor" | "editor-geometry" | "menu-geometry" | "terminal-frame" | "terminal-status" | "restored-parent-output" | "hidden";
|
|
4
|
+
export interface PiSettingVisualEvidence {
|
|
5
|
+
/** Reviewed visual family; `none` still names the behavior that can emit styled diagnostics. */
|
|
6
|
+
readonly class: PiSettingVisualClass;
|
|
7
|
+
/** Pinned component, lifecycle, or provider-visible failure surface used as the visual authority. */
|
|
8
|
+
readonly pinnedSurface: string;
|
|
9
|
+
/** Independent pinned/A1 test or physical checkpoint that owns acceptance. */
|
|
10
|
+
readonly evidence: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PiSettingEffectDefinition {
|
|
13
|
+
readonly application: AgentSettingApplicationBoundary;
|
|
14
|
+
readonly owner: AgentSettingOwner;
|
|
15
|
+
readonly visual: PiSettingVisualEvidence;
|
|
16
|
+
/** Bare A1 deliberately replaces this Pi behavior, so its settings UI omits the entry. */
|
|
17
|
+
readonly hiddenInBare?: true;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reviewed effect authority for every generated Pi setting. Presentation remains
|
|
21
|
+
* generated; this table states who must make each accepted value observable.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PI_SETTING_EFFECTS: Readonly<Record<PiSettingKey, PiSettingEffectDefinition>>;
|
|
24
|
+
export interface PiSettingEffectHandler {
|
|
25
|
+
/** Install one value in the active owner. Handlers must be idempotent and reversible. */
|
|
26
|
+
apply(value: AgentJsonValue): void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export type PiSettingOwnerHandlers = Partial<Record<PiSettingKey, PiSettingEffectHandler>>;
|
|
29
|
+
export interface PiSettingStorageOperation {
|
|
30
|
+
readonly key: PiSettingKey;
|
|
31
|
+
read(): AgentJsonValue;
|
|
32
|
+
validate(value: AgentJsonValue): void;
|
|
33
|
+
write(value: AgentJsonValue): void;
|
|
34
|
+
}
|
|
35
|
+
export interface PiSettingsCoordinatorOptions {
|
|
36
|
+
readonly productMode?: "bare" | "comparison";
|
|
37
|
+
readonly flush: () => Promise<void>;
|
|
38
|
+
readonly drainErrors?: () => readonly {
|
|
39
|
+
readonly error: Error;
|
|
40
|
+
}[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One transactional authority for Pi setting validation, active effects,
|
|
44
|
+
* persistence, durability, rollback, and owner lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
export declare class PiSettingsCoordinator {
|
|
47
|
+
#private;
|
|
48
|
+
constructor(operations: readonly PiSettingStorageOperation[], options: PiSettingsCoordinatorOptions);
|
|
49
|
+
bindOwner(owner: AgentSettingOwner, handlers: PiSettingOwnerHandlers): () => void;
|
|
50
|
+
unbindOwner(owner: AgentSettingOwner, keys?: readonly PiSettingKey[]): void;
|
|
51
|
+
definition(key: PiSettingKey): PiSettingEffectDefinition;
|
|
52
|
+
storedValue(key: PiSettingKey): AgentJsonValue;
|
|
53
|
+
effectiveValue(key: PiSettingKey): AgentJsonValue;
|
|
54
|
+
limitationReason(key: PiSettingKey): string | null;
|
|
55
|
+
available(key: PiSettingKey): boolean;
|
|
56
|
+
validate(key: PiSettingKey, value: AgentJsonValue): void;
|
|
57
|
+
apply(key: PiSettingKey, value: AgentJsonValue): Promise<AgentSettingChangeOutcome>;
|
|
58
|
+
flush(): Promise<void>;
|
|
59
|
+
rollback(key: PiSettingKey, value: AgentJsonValue): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare function settingsEffectInventoryDrift(presented: readonly string[], reviewed?: readonly string[]): {
|
|
62
|
+
readonly unmapped: readonly string[];
|
|
63
|
+
readonly stale: readonly string[];
|
|
64
|
+
readonly duplicated: readonly string[];
|
|
65
|
+
};
|
|
66
|
+
export declare function settingsVisualInventoryViolations(presented: readonly string[], reviewed?: Readonly<Partial<Record<PiSettingKey, PiSettingEffectDefinition>>>): readonly string[];
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reviewed effect authority for every generated Pi setting. Presentation remains
|
|
3
|
+
* generated; this table states who must make each accepted value observable.
|
|
4
|
+
*/
|
|
5
|
+
export const PI_SETTING_EFFECTS = Object.freeze({
|
|
6
|
+
autoCompact: effect("live", "agent", "transcript", "compaction status, summary, completion, and failure rows", "pinned-transcript-lifecycle-parity"),
|
|
7
|
+
showImages: effect("live", "shell", "transcript", "pinned inline image and textual fallback components", "pinned-transcript-image-parity"),
|
|
8
|
+
imageWidthCells: effect("live", "shell", "transcript-geometry", "pinned image component width and clipping", "pinned-transcript-image-parity"),
|
|
9
|
+
autoResizeImages: effect("live", "agent", "none", "provider image preparation and pinned warning row", "settings-effects-provider-parity"),
|
|
10
|
+
blockImages: effect("live", "agent", "none", "provider context conversion and pinned blocked-image notice", "settings-effects-provider-parity"),
|
|
11
|
+
enableSkillCommands: effect("live", "shell", "editor-menu", "pinned command autocomplete list", "pinned-editor-input-parity"),
|
|
12
|
+
steeringMode: effect("live", "agent", "queue-transcript", "pinned steering queue and submitted prompt rows", "pinned-status-indicator-parity"),
|
|
13
|
+
followUpMode: effect("live", "agent", "queue-transcript", "pinned follow-up queue and submitted prompt rows", "pinned-status-indicator-parity"),
|
|
14
|
+
transport: effect("live", "agent", "status-error", "pinned provider request status and failure rows", "settings-effects-provider-parity"),
|
|
15
|
+
httpIdleTimeoutMs: effect("live", "agent", "retry-error", "pinned timeout, retry, and terminal failure rows", "pinned-transcript-lifecycle-parity"),
|
|
16
|
+
thinkingLevel: effect("live", "agent", "footer-transcript", "pinned footer indicator, thinking rows, and clamp notice", "pinned-status-indicator-parity"),
|
|
17
|
+
theme: hiddenEffect("live", "shell", "pinned theme selector and complete themed shell", "pinned-theme-parity"),
|
|
18
|
+
hideThinkingBlock: effect("live", "shell", "transcript", "pinned thinking block presence and spacing", "pinned-transcript-lifecycle-parity"),
|
|
19
|
+
mermaidRenderingMode: effect("live", "shell", "markdown", "pinned Mermaid Markdown transformation", "pinned-assistant-content-parity"),
|
|
20
|
+
showCacheMissNotices: effect("live", "shell", "transcript-notice", "pinned cache-miss transcript notice", "pinned-transcript-lifecycle-parity"),
|
|
21
|
+
collapseChangelog: effect("next-start", "startup", "startup-transcript", "pinned startup and command changelog components", "pi-startup-composition-parity"),
|
|
22
|
+
enableInstallTelemetry: effect("next-start", "installation", "none", "install lifecycle and its pinned failure diagnostic", "settings-effects-installation-parity"),
|
|
23
|
+
quietStartup: hiddenEffect("next-start", "startup", "pinned startup suppression lifecycle", "pi-startup-composition-parity"),
|
|
24
|
+
defaultProjectTrust: effect("next-start", "startup", "startup-selector", "pinned pre-resource project trust selector", "project-trust-startup-parity"),
|
|
25
|
+
doubleEscapeAction: effect("live", "shell", "selector", "pinned tree or fork selector", "pinned-selector-parity"),
|
|
26
|
+
treeFilterMode: effect("live", "shell", "selector", "pinned tree selector filter, rows, and hints", "pinned-selector-parity"),
|
|
27
|
+
showHardwareCursor: effect("live", "terminal", "terminal-cursor", "pinned editor, overlay, blur, failure, and exit cursor operations", "pi-terminal-operation-parity"),
|
|
28
|
+
editorPaddingX: effect("live", "shell", "editor-geometry", "pinned editor border, padding, wrapping, and cursor column", "pinned-editor-input-parity"),
|
|
29
|
+
outputPad: effect("live", "shell", "transcript-geometry", "pinned transcript, tool, status, and error horizontal padding", "pinned-transcript-lifecycle-parity"),
|
|
30
|
+
autocompleteMaxVisible: effect("live", "shell", "menu-geometry", "pinned autocomplete clipping and editor anchoring", "pinned-editor-input-parity"),
|
|
31
|
+
clearOnShrink: effect("live", "terminal", "terminal-frame", "pinned resize clearing and resulting terminal frame", "pi-terminal-operation-parity"),
|
|
32
|
+
showTerminalProgress: effect("live", "terminal", "terminal-status", "pinned OSC progress lifecycle", "pi-terminal-operation-parity"),
|
|
33
|
+
tuiMode: hiddenEffect("next-session", "shell", "pinned regular/fullscreen selector and terminal lifecycle", "pi-terminal-operation-parity"),
|
|
34
|
+
fullscreenExitOutput: effect("current-exit", "shutdown", "restored-parent-output", "pinned styled transcript and compact dim resume hint", "pinned-fullscreen-exit-parity"),
|
|
35
|
+
fullscreenScrollbar: hiddenEffect("live", "shell", "pinned fullscreen scrollbar reservation", "pi-terminal-operation-parity"),
|
|
36
|
+
warnings: effect("live", "agent", "transcript-notice", "pinned warning rows by warning part", "pinned-transcript-lifecycle-parity"),
|
|
37
|
+
});
|
|
38
|
+
function effect(application, owner, visualClass, pinnedSurface, evidence) {
|
|
39
|
+
return { application, owner, visual: { class: visualClass, pinnedSurface, evidence } };
|
|
40
|
+
}
|
|
41
|
+
function hiddenEffect(application, owner, pinnedSurface, evidence) {
|
|
42
|
+
return { application, owner, hiddenInBare: true, visual: { class: "hidden", pinnedSurface, evidence } };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One transactional authority for Pi setting validation, active effects,
|
|
46
|
+
* persistence, durability, rollback, and owner lifecycle.
|
|
47
|
+
*/
|
|
48
|
+
export class PiSettingsCoordinator {
|
|
49
|
+
#operations;
|
|
50
|
+
#handlers = new Map();
|
|
51
|
+
#state = new Map();
|
|
52
|
+
#productMode;
|
|
53
|
+
#flushStorage;
|
|
54
|
+
#drainErrors;
|
|
55
|
+
constructor(operations, options) {
|
|
56
|
+
this.#operations = new Map(operations.map(operation => [operation.key, operation]));
|
|
57
|
+
this.#productMode = options.productMode ?? "bare";
|
|
58
|
+
this.#flushStorage = options.flush;
|
|
59
|
+
this.#drainErrors = options.drainErrors;
|
|
60
|
+
for (const operation of operations) {
|
|
61
|
+
const stored = operation.read();
|
|
62
|
+
this.#state.set(operation.key, { stored, effective: stored, inconsistentReason: null });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
bindOwner(owner, handlers) {
|
|
66
|
+
const bound = [];
|
|
67
|
+
for (const [candidate, handler] of Object.entries(handlers)) {
|
|
68
|
+
if (handler === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
const key = candidate;
|
|
71
|
+
const definition = PI_SETTING_EFFECTS[key];
|
|
72
|
+
if (definition === undefined)
|
|
73
|
+
throw new Error(`unknown Pi setting effect: ${key}`);
|
|
74
|
+
if (definition.owner !== owner)
|
|
75
|
+
throw new Error(`${key} belongs to ${definition.owner}, not ${owner}`);
|
|
76
|
+
if (this.#productMode === "bare" && definition.hiddenInBare === true) {
|
|
77
|
+
throw new Error(`${key} is hidden in bare A1`);
|
|
78
|
+
}
|
|
79
|
+
this.#handlers.set(key, handler);
|
|
80
|
+
bound.push(key);
|
|
81
|
+
}
|
|
82
|
+
return () => this.unbindOwner(owner, bound);
|
|
83
|
+
}
|
|
84
|
+
unbindOwner(owner, keys) {
|
|
85
|
+
const candidates = keys ?? [...this.#handlers.keys()];
|
|
86
|
+
for (const key of candidates)
|
|
87
|
+
if (PI_SETTING_EFFECTS[key].owner === owner)
|
|
88
|
+
this.#handlers.delete(key);
|
|
89
|
+
}
|
|
90
|
+
definition(key) {
|
|
91
|
+
return PI_SETTING_EFFECTS[key];
|
|
92
|
+
}
|
|
93
|
+
storedValue(key) {
|
|
94
|
+
const operation = this.#requireOperation(key);
|
|
95
|
+
const stored = operation.read();
|
|
96
|
+
const state = this.#requireState(key);
|
|
97
|
+
state.stored = stored;
|
|
98
|
+
return stored;
|
|
99
|
+
}
|
|
100
|
+
effectiveValue(key) {
|
|
101
|
+
return this.#requireState(key).effective;
|
|
102
|
+
}
|
|
103
|
+
limitationReason(key) {
|
|
104
|
+
const definition = PI_SETTING_EFFECTS[key];
|
|
105
|
+
if (this.#productMode === "bare" && definition.hiddenInBare === true)
|
|
106
|
+
return "setting is not available in the active product mode";
|
|
107
|
+
const inconsistent = this.#requireState(key).inconsistentReason;
|
|
108
|
+
if (inconsistent !== null)
|
|
109
|
+
return inconsistent;
|
|
110
|
+
if (!this.#handlers.has(key))
|
|
111
|
+
return `${definition.owner} effect is not bound for ${definition.application} application`;
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
available(key) {
|
|
115
|
+
return this.limitationReason(key) === null;
|
|
116
|
+
}
|
|
117
|
+
validate(key, value) {
|
|
118
|
+
this.#requireOperation(key).validate(value);
|
|
119
|
+
}
|
|
120
|
+
async apply(key, value) {
|
|
121
|
+
const operation = this.#requireOperation(key);
|
|
122
|
+
operation.validate(value);
|
|
123
|
+
const definition = PI_SETTING_EFFECTS[key];
|
|
124
|
+
const previousStored = operation.read();
|
|
125
|
+
const state = this.#requireState(key);
|
|
126
|
+
const previousEffective = state.effective;
|
|
127
|
+
const limitationReason = this.limitationReason(key);
|
|
128
|
+
if (limitationReason !== null) {
|
|
129
|
+
return outcome("unavailable", definition.application, previousStored, previousEffective, null, limitationReason);
|
|
130
|
+
}
|
|
131
|
+
const handler = this.#handlers.get(key);
|
|
132
|
+
if (definition.application !== "live") {
|
|
133
|
+
try {
|
|
134
|
+
operation.write(value);
|
|
135
|
+
await this.flush();
|
|
136
|
+
state.stored = value;
|
|
137
|
+
return outcome("deferred", definition.application, value, previousEffective, null, null);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const failure = await this.#restorePersistence(operation, previousStored, error);
|
|
141
|
+
state.stored = operation.read();
|
|
142
|
+
return outcome("failed", definition.application, state.stored, previousEffective, failure, null);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
await handler.apply(value);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return outcome("failed", definition.application, previousStored, previousEffective, describe(error), null);
|
|
150
|
+
}
|
|
151
|
+
state.effective = value;
|
|
152
|
+
try {
|
|
153
|
+
operation.write(value);
|
|
154
|
+
await this.flush();
|
|
155
|
+
state.stored = value;
|
|
156
|
+
state.inconsistentReason = null;
|
|
157
|
+
return outcome("applied", definition.application, value, value, null, null);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
const persistenceFailure = await this.#restorePersistence(operation, previousStored, error);
|
|
161
|
+
try {
|
|
162
|
+
await handler.apply(previousEffective);
|
|
163
|
+
state.effective = previousEffective;
|
|
164
|
+
state.stored = operation.read();
|
|
165
|
+
return outcome("failed", definition.application, state.stored, previousEffective, persistenceFailure, null);
|
|
166
|
+
}
|
|
167
|
+
catch (rollbackError) {
|
|
168
|
+
state.stored = operation.read();
|
|
169
|
+
state.inconsistentReason = `rollback failed after ${persistenceFailure}: ${describe(rollbackError)}`;
|
|
170
|
+
return outcome("failed", definition.application, state.stored, state.effective, state.inconsistentReason, state.inconsistentReason);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async flush() {
|
|
175
|
+
await this.#flushStorage();
|
|
176
|
+
const errors = this.#drainErrors?.() ?? [];
|
|
177
|
+
if (errors.length > 0)
|
|
178
|
+
throw new Error(errors.map(value => value.error.message).join("; "));
|
|
179
|
+
}
|
|
180
|
+
async rollback(key, value) {
|
|
181
|
+
const handler = this.#handlers.get(key);
|
|
182
|
+
if (handler === undefined)
|
|
183
|
+
throw new Error(`cannot roll back unbound setting: ${key}`);
|
|
184
|
+
await handler.apply(value);
|
|
185
|
+
this.#requireState(key).effective = value;
|
|
186
|
+
}
|
|
187
|
+
async #restorePersistence(operation, previous, cause) {
|
|
188
|
+
const original = describe(cause);
|
|
189
|
+
try {
|
|
190
|
+
operation.write(previous);
|
|
191
|
+
await this.flush();
|
|
192
|
+
return original;
|
|
193
|
+
}
|
|
194
|
+
catch (rollbackError) {
|
|
195
|
+
return `${original}; persistence rollback failed: ${describe(rollbackError)}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
#requireOperation(key) {
|
|
199
|
+
const operation = this.#operations.get(key);
|
|
200
|
+
if (operation === undefined)
|
|
201
|
+
throw new Error(`setting is unavailable: ${key}`);
|
|
202
|
+
return operation;
|
|
203
|
+
}
|
|
204
|
+
#requireState(key) {
|
|
205
|
+
const state = this.#state.get(key);
|
|
206
|
+
if (state === undefined)
|
|
207
|
+
throw new Error(`setting state is unavailable: ${key}`);
|
|
208
|
+
return state;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export function settingsEffectInventoryDrift(presented, reviewed = Object.keys(PI_SETTING_EFFECTS)) {
|
|
212
|
+
const reviewedSet = new Set(reviewed);
|
|
213
|
+
const presentedSet = new Set(presented);
|
|
214
|
+
const counts = new Map();
|
|
215
|
+
for (const key of reviewed)
|
|
216
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
217
|
+
return {
|
|
218
|
+
unmapped: presented.filter(key => !reviewedSet.has(key)),
|
|
219
|
+
stale: reviewed.filter(key => !presentedSet.has(key)),
|
|
220
|
+
duplicated: [...counts].filter(([, count]) => count > 1).map(([key]) => key),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export function settingsVisualInventoryViolations(presented, reviewed = PI_SETTING_EFFECTS) {
|
|
224
|
+
const violations = [];
|
|
225
|
+
for (const candidate of presented) {
|
|
226
|
+
const key = candidate;
|
|
227
|
+
const definition = reviewed[key];
|
|
228
|
+
if (definition === undefined) {
|
|
229
|
+
violations.push(`${candidate}: missing visual classification`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const visual = definition.visual;
|
|
233
|
+
if (!visual || visual.pinnedSurface.trim().length === 0)
|
|
234
|
+
violations.push(`${candidate}: missing pinned visual source`);
|
|
235
|
+
if (!visual || visual.evidence.trim().length === 0)
|
|
236
|
+
violations.push(`${candidate}: missing independent visual evidence`);
|
|
237
|
+
if (definition.hiddenInBare === true && visual?.class !== "hidden")
|
|
238
|
+
violations.push(`${candidate}: hidden setting declares a visible frame`);
|
|
239
|
+
if (definition.hiddenInBare !== true && visual?.class === "hidden")
|
|
240
|
+
violations.push(`${candidate}: visible setting declares hidden evidence`);
|
|
241
|
+
}
|
|
242
|
+
return violations;
|
|
243
|
+
}
|
|
244
|
+
function outcome(status, application, storedValue, effectiveValue, failure, limitationReason) {
|
|
245
|
+
return { status, application, storedValue, effectiveValue, failure, limitationReason };
|
|
246
|
+
}
|
|
247
|
+
function describe(error) {
|
|
248
|
+
return error instanceof Error ? error.message : String(error);
|
|
249
|
+
}
|
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
import type { SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AgentJsonValue, AgentSettingDescriptor, AgentSettingsPort } from "../../../contracts/agent-engine/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* the thinking levels this session supports. The boundary asks for them as it is
|
|
6
|
-
* read, so no layer above has to know they are not fixed.
|
|
7
|
-
*/
|
|
2
|
+
import type { AgentJsonValue, AgentSettingChangeOutcome, AgentSettingDescriptor, AgentSettingOwner, AgentSettingsPort } from "../../../contracts/agent-engine/index.js";
|
|
3
|
+
import { type PiSettingOwnerHandlers } from "./settings-effects.js";
|
|
4
|
+
/** Values only the running engine knows. */
|
|
8
5
|
export interface PiSettingsProviders {
|
|
9
6
|
readonly themes?: () => readonly string[];
|
|
10
7
|
readonly thinkingLevels?: () => readonly string[];
|
|
8
|
+
readonly productMode?: "bare" | "comparison";
|
|
11
9
|
}
|
|
12
|
-
/**
|
|
13
|
-
* The engine stores a theme as one string with two forms: a theme's name, or a
|
|
14
|
-
* `light/dark` pair meaning "follow the terminal". That grammar is the engine's,
|
|
15
|
-
* so it is parsed and composed here and reaches the surfaces above as ordinary
|
|
16
|
-
* settings — a theme entry that offers `automatic`, and, while automatic, one
|
|
17
|
-
* entry per terminal appearance.
|
|
18
|
-
*/
|
|
19
10
|
export declare const AUTOMATIC_THEME = "automatic";
|
|
20
11
|
interface AutomaticTheme {
|
|
21
12
|
readonly light: string;
|
|
22
13
|
readonly dark: string;
|
|
23
14
|
}
|
|
24
|
-
/** A stored theme is automatic when it names one theme per terminal appearance. */
|
|
25
15
|
export declare function parseAutomaticTheme(stored: string): AutomaticTheme | null;
|
|
26
|
-
/**
|
|
27
|
-
* The settings A1 exposes: the ones the engine presents. Kept as the engine's
|
|
28
|
-
* own inventory rather than a list beside it, so a setting it adds or renames
|
|
29
|
-
* shows up as a named test failure instead of quietly going missing.
|
|
30
|
-
*/
|
|
31
16
|
export declare const EXPOSED_SETTING_KEYS: readonly string[];
|
|
32
|
-
/**
|
|
33
|
-
* What has drifted between the settings the engine presents and the settings A1
|
|
34
|
-
* maps to its API: the ones A1 has not caught up with, and the ones it kept
|
|
35
|
-
* after the engine dropped them. Either is a build failure with a name in it.
|
|
36
|
-
*/
|
|
37
17
|
export declare function settingsInventoryDrift(presented: readonly string[], mapped: readonly string[]): {
|
|
38
18
|
readonly unmapped: readonly string[];
|
|
39
19
|
readonly stale: readonly string[];
|
|
40
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Pi settings boundary backed by the transactional settings coordinator. The
|
|
23
|
+
* generated metadata owns presentation while the reviewed effect registry owns
|
|
24
|
+
* timing, availability, and active behavior.
|
|
25
|
+
*/
|
|
41
26
|
export declare class PiSettingsIntegration implements AgentSettingsPort {
|
|
42
27
|
#private;
|
|
43
28
|
private readonly settings;
|
|
@@ -46,10 +31,13 @@ export declare class PiSettingsIntegration implements AgentSettingsPort {
|
|
|
46
31
|
flush: boolean;
|
|
47
32
|
};
|
|
48
33
|
constructor(settings: SettingsManager, providers?: PiSettingsProviders);
|
|
34
|
+
bindOwner(owner: AgentSettingOwner, handlers: PiSettingOwnerHandlers): () => void;
|
|
35
|
+
unbindOwner(owner: AgentSettingOwner): void;
|
|
49
36
|
listSettings(): Promise<readonly AgentSettingDescriptor[]>;
|
|
50
37
|
readSetting(key: string): Promise<AgentJsonValue | undefined>;
|
|
51
|
-
writeSetting(key: string, value: AgentJsonValue): Promise<
|
|
52
|
-
|
|
38
|
+
writeSetting(key: string, value: AgentJsonValue): Promise<AgentSettingChangeOutcome>;
|
|
39
|
+
/** Shared route used by the pinned selector and owned settings surface. */
|
|
40
|
+
writeSettingNow(key: string, value: AgentJsonValue): Promise<AgentSettingChangeOutcome>;
|
|
53
41
|
flush(): Promise<void>;
|
|
54
42
|
}
|
|
55
43
|
export {};
|