@oh-my-pi/pi-coding-agent 16.2.0 → 16.2.2
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/CHANGELOG.md +35 -0
- package/dist/cli.js +2709 -2715
- package/dist/types/advisor/runtime.d.ts +15 -1
- package/dist/types/advisor/watchdog.d.ts +11 -0
- package/dist/types/config/model-roles.d.ts +1 -1
- package/dist/types/config/settings-schema.d.ts +32 -12
- package/dist/types/discovery/omp-extension-roots.d.ts +3 -3
- package/dist/types/edit/index.d.ts +18 -0
- package/dist/types/edit/streaming.d.ts +30 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +1 -0
- package/dist/types/extensibility/shared-events.d.ts +1 -0
- package/dist/types/mcp/oauth-discovery.d.ts +0 -11
- package/dist/types/modes/acp/acp-event-mapper.d.ts +1 -0
- package/dist/types/modes/components/status-line/component.d.ts +0 -2
- package/dist/types/sdk.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +32 -2
- package/dist/types/session/blob-store.d.ts +4 -0
- package/dist/types/session/messages.d.ts +6 -7
- package/dist/types/session/settings-stream-fn.d.ts +21 -0
- package/dist/types/session/turn-persistence.d.ts +88 -0
- package/package.json +12 -12
- package/src/advisor/__tests__/advisor.test.ts +217 -0
- package/src/advisor/runtime.ts +65 -2
- package/src/advisor/watchdog.ts +15 -0
- package/src/auto-thinking/classifier.ts +2 -2
- package/src/config/model-resolver.ts +5 -1
- package/src/config/model-roles.ts +3 -3
- package/src/config/settings-schema.ts +30 -8
- package/src/discovery/claude-plugins.ts +3 -2
- package/src/discovery/omp-extension-roots.ts +38 -13
- package/src/edit/index.ts +21 -0
- package/src/edit/streaming.ts +170 -0
- package/src/extensibility/custom-tools/types.ts +1 -0
- package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +18 -1
- package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +59 -2
- package/src/extensibility/plugins/manager.ts +74 -4
- package/src/extensibility/shared-events.ts +1 -0
- package/src/internal-urls/docs-index.generated.txt +1 -1
- package/src/mcp/oauth-discovery.ts +5 -29
- package/src/mcp/transports/http.ts +3 -1
- package/src/mnemopi/backend.ts +2 -2
- package/src/modes/acp/acp-agent.ts +15 -2
- package/src/modes/acp/acp-event-mapper.ts +89 -25
- package/src/modes/components/assistant-message.ts +5 -5
- package/src/modes/components/status-line/component.ts +1 -9
- package/src/modes/components/status-line/segments.ts +1 -1
- package/src/modes/controllers/event-controller.ts +8 -11
- package/src/modes/interactive-mode.ts +0 -5
- package/src/modes/print-mode.ts +1 -1
- package/src/modes/utils/transcript-render-helpers.ts +2 -2
- package/src/modes/utils/ui-helpers.ts +5 -4
- package/src/prompts/advisor/context-files.md +8 -0
- package/src/sdk.ts +23 -27
- package/src/session/agent-session.ts +330 -219
- package/src/session/blob-store.ts +24 -0
- package/src/session/messages.ts +20 -12
- package/src/session/session-persistence.ts +1 -2
- package/src/session/settings-stream-fn.ts +49 -0
- package/src/session/turn-persistence.ts +142 -0
- package/src/session/unexpected-stop-classifier.ts +2 -2
- package/src/slash-commands/helpers/mcp.ts +2 -1
- package/src/tiny/models.ts +8 -6
- package/src/tiny/text.ts +14 -7
- package/src/tools/image-gen.ts +2 -1
- package/src/tools/tts.ts +2 -1
- package/src/utils/title-generator.ts +1 -1
- package/src/web/search/providers/tavily.ts +36 -19
package/src/sdk.ts
CHANGED
|
@@ -8,14 +8,7 @@ import {
|
|
|
8
8
|
filterProviderReplayMessages,
|
|
9
9
|
type ThinkingLevel,
|
|
10
10
|
} from "@oh-my-pi/pi-agent-core";
|
|
11
|
-
import {
|
|
12
|
-
type Context,
|
|
13
|
-
type CredentialDisabledEvent,
|
|
14
|
-
type Message,
|
|
15
|
-
type Model,
|
|
16
|
-
type SimpleStreamOptions,
|
|
17
|
-
streamSimple,
|
|
18
|
-
} from "@oh-my-pi/pi-ai";
|
|
11
|
+
import type { Context, CredentialDisabledEvent, Message, Model, SimpleStreamOptions } from "@oh-my-pi/pi-ai";
|
|
19
12
|
import type { Dialect } from "@oh-my-pi/pi-ai/dialect";
|
|
20
13
|
import {
|
|
21
14
|
getOpenAICodexTransportDetails,
|
|
@@ -25,7 +18,12 @@ import { FALLBACK_DIALECT, preferredDialect } from "@oh-my-pi/pi-catalog/identit
|
|
|
25
18
|
import type { Component } from "@oh-my-pi/pi-tui";
|
|
26
19
|
import { $env, $flag, getAgentDir, getProjectDir, logger, postmortem, prompt, Snowflake } from "@oh-my-pi/pi-utils";
|
|
27
20
|
import { INTENT_FIELD } from "@oh-my-pi/pi-wire";
|
|
28
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
ADVISOR_READONLY_TOOL_NAMES,
|
|
23
|
+
discoverWatchdogFiles,
|
|
24
|
+
formatActiveRepoWatchdogPrompt,
|
|
25
|
+
formatAdvisorContextPrompt,
|
|
26
|
+
} from "./advisor";
|
|
29
27
|
import { type AsyncJob, AsyncJobManager } from "./async";
|
|
30
28
|
import { AutoLearnController, buildAutoLearnInstructions } from "./autolearn/controller";
|
|
31
29
|
import { loadCapability } from "./capability";
|
|
@@ -44,7 +42,7 @@ import {
|
|
|
44
42
|
resolveModelRoleValue,
|
|
45
43
|
} from "./config/model-resolver";
|
|
46
44
|
import { loadPromptTemplates as loadPromptTemplatesInternal, type PromptTemplate } from "./config/prompt-templates";
|
|
47
|
-
import { Settings, type SkillsSettings
|
|
45
|
+
import { Settings, type SkillsSettings } from "./config/settings";
|
|
48
46
|
import { CursorExecHandlers } from "./cursor";
|
|
49
47
|
import "./discovery";
|
|
50
48
|
import { initializeWithSettings } from "./discovery";
|
|
@@ -120,6 +118,7 @@ import {
|
|
|
120
118
|
import { clampProviderContextImages } from "./session/provider-image-budget";
|
|
121
119
|
import { getRestorableSessionModels } from "./session/session-context";
|
|
122
120
|
import { SessionManager } from "./session/session-manager";
|
|
121
|
+
import { createSettingsAwareStreamFn } from "./session/settings-stream-fn";
|
|
123
122
|
import { SnapcompactInlineTransformer } from "./session/snapcompact-inline";
|
|
124
123
|
import { createSnapcompactSavingsRecorder } from "./session/snapcompact-savings-journal";
|
|
125
124
|
import { closeAllConnections } from "./ssh/connection-manager";
|
|
@@ -970,6 +969,7 @@ function createCustomToolsExtension(tools: CustomTool[]): ExtensionFactory {
|
|
|
970
969
|
maxAttempts: event.maxAttempts,
|
|
971
970
|
delayMs: event.delayMs,
|
|
972
971
|
errorMessage: event.errorMessage,
|
|
972
|
+
errorId: event.errorId,
|
|
973
973
|
},
|
|
974
974
|
ctx,
|
|
975
975
|
),
|
|
@@ -2531,6 +2531,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2531
2531
|
// One-shot launch-latency marker: fired the first time the loop dispatches
|
|
2532
2532
|
// a chat request to the provider transport. See onFirstChatDispatch.
|
|
2533
2533
|
let notifyFirstChatDispatch = options.onFirstChatDispatch;
|
|
2534
|
+
// Shared, settings-aware stream wrapper used by both the main agent and
|
|
2535
|
+
// the advisor (via AgentSessionConfig.streamFn). Keeps OpenRouter
|
|
2536
|
+
// sticky-routing variants, antigravity endpoint routing, in-flight caps,
|
|
2537
|
+
// and the loop guard consistent across every agent the session drives.
|
|
2538
|
+
const settingsAwareStreamFn = createSettingsAwareStreamFn(settings);
|
|
2534
2539
|
agent = new Agent({
|
|
2535
2540
|
initialState: {
|
|
2536
2541
|
systemPrompt,
|
|
@@ -2581,23 +2586,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2581
2586
|
});
|
|
2582
2587
|
}
|
|
2583
2588
|
}
|
|
2584
|
-
|
|
2585
|
-
const openrouterVariant =
|
|
2586
|
-
openrouterRoutingPreset && openrouterRoutingPreset !== "default" ? openrouterRoutingPreset : undefined;
|
|
2587
|
-
const antigravityEndpointMode = settings.get("providers.antigravityEndpoint");
|
|
2588
|
-
return streamSimple(streamModel, context, {
|
|
2589
|
-
...streamOptions,
|
|
2590
|
-
openrouterVariant: streamOptions?.openrouterVariant ?? openrouterVariant,
|
|
2591
|
-
antigravityEndpointMode: streamOptions?.antigravityEndpointMode ?? antigravityEndpointMode,
|
|
2592
|
-
maxInFlightRequests: validateProviderMaxInFlightRequests(
|
|
2593
|
-
streamOptions?.maxInFlightRequests ?? settings.get("providers.maxInFlightRequests"),
|
|
2594
|
-
),
|
|
2595
|
-
loopGuard: {
|
|
2596
|
-
enabled: settings.get("model.loopGuard.enabled"),
|
|
2597
|
-
checkAssistantContent: settings.get("model.loopGuard.checkAssistantContent"),
|
|
2598
|
-
...streamOptions?.loopGuard,
|
|
2599
|
-
},
|
|
2600
|
-
});
|
|
2589
|
+
return settingsAwareStreamFn(streamModel, context, streamOptions);
|
|
2601
2590
|
},
|
|
2602
2591
|
cursorExecHandlers,
|
|
2603
2592
|
transformToolCallArguments: (args, _toolName) => {
|
|
@@ -2678,11 +2667,16 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2678
2667
|
advisorWatchdogPrompts.push(formatActiveRepoWatchdogPrompt(activeRepoContext));
|
|
2679
2668
|
}
|
|
2680
2669
|
const advisorWatchdogPrompt = advisorWatchdogPrompts.length > 0 ? advisorWatchdogPrompts.join("\n\n") : undefined;
|
|
2670
|
+
// Hand the advisor the same project context files (AGENTS.md, etc.) the
|
|
2671
|
+
// primary agent gets in its system prompt, so the read-only reviewer judges
|
|
2672
|
+
// against the user's standing project rules instead of advising blind.
|
|
2673
|
+
const advisorContextPrompt = formatAdvisorContextPrompt(contextFiles);
|
|
2681
2674
|
// Owned only when this session created the manager; subagents receive a
|
|
2682
2675
|
// parent's manager via `options.mcpManager` and MUST NOT disconnect it.
|
|
2683
2676
|
const ownedMcpManager = options.mcpManager ? undefined : mcpManager;
|
|
2684
2677
|
session = new AgentSession({
|
|
2685
2678
|
advisorWatchdogPrompt,
|
|
2679
|
+
advisorContextPrompt,
|
|
2686
2680
|
agent,
|
|
2687
2681
|
pruneToolDescriptions: inlineToolDescriptors,
|
|
2688
2682
|
thinkingLevel: autoThinking ? AUTO_THINKING : effectiveThinkingLevel,
|
|
@@ -2708,8 +2702,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2708
2702
|
toolRegistry,
|
|
2709
2703
|
builtInToolNames: builtInRegistryToolNames,
|
|
2710
2704
|
transformContext,
|
|
2705
|
+
transformProviderContext,
|
|
2711
2706
|
onPayload,
|
|
2712
2707
|
onResponse,
|
|
2708
|
+
advisorStreamFn: settingsAwareStreamFn,
|
|
2713
2709
|
convertToLlm: convertToLlmFinal,
|
|
2714
2710
|
rebuildSystemPrompt,
|
|
2715
2711
|
reloadSshTool,
|