@oh-my-pi/pi-coding-agent 16.1.23 → 16.2.1
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 +82 -0
- package/dist/cli.js +3785 -3695
- package/dist/types/advisor/__tests__/emission-guard.test.d.ts +1 -0
- package/dist/types/advisor/emission-guard.d.ts +73 -0
- package/dist/types/advisor/index.d.ts +1 -0
- package/dist/types/advisor/runtime.d.ts +7 -0
- package/dist/types/advisor/watchdog.d.ts +13 -0
- package/dist/types/cli/flag-tables.d.ts +1 -0
- package/dist/types/cli/gallery-fixtures/search.d.ts +1 -1
- package/dist/types/collab/display-name.d.ts +3 -0
- package/dist/types/collab/host.d.ts +0 -2
- package/dist/types/commands/worktree.d.ts +0 -3
- package/dist/types/config/inline-tool-descriptors-mode.d.ts +13 -0
- package/dist/types/config/model-discovery.d.ts +6 -1
- package/dist/types/config/model-registry.d.ts +6 -2
- package/dist/types/config/model-resolver.d.ts +12 -0
- package/dist/types/config/models-config-schema.d.ts +29 -2
- package/dist/types/config/models-config.d.ts +22 -1
- package/dist/types/config/settings-schema.d.ts +91 -21
- package/dist/types/config/settings.d.ts +2 -0
- package/dist/types/dap/config.d.ts +1 -1
- package/dist/types/edit/hashline/filesystem.d.ts +4 -2
- package/dist/types/edit/renderer.d.ts +4 -0
- package/dist/types/extensibility/extensions/types.d.ts +17 -17
- package/dist/types/extensibility/hooks/types.d.ts +10 -10
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +1 -0
- package/dist/types/internal-urls/__tests__/ssh-protocol.test.d.ts +1 -0
- package/dist/types/internal-urls/index.d.ts +1 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +2 -0
- package/dist/types/internal-urls/router.d.ts +1 -1
- package/dist/types/internal-urls/ssh-protocol.d.ts +10 -0
- package/dist/types/internal-urls/types.d.ts +19 -2
- package/dist/types/irc/bus.d.ts +6 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +1 -0
- package/dist/types/modes/components/__tests__/move-overlay.test.d.ts +1 -0
- package/dist/types/modes/components/custom-editor.d.ts +7 -0
- package/dist/types/modes/components/move-overlay.d.ts +23 -0
- package/dist/types/modes/components/plugin-selector.d.ts +2 -1
- package/dist/types/modes/components/queue-mode-selector.d.ts +2 -1
- package/dist/types/modes/components/select-list-mouse-routing.d.ts +2 -0
- package/dist/types/modes/components/settings-defs.d.ts +4 -1
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/components/show-images-selector.d.ts +2 -1
- package/dist/types/modes/components/status-line/component.d.ts +2 -0
- package/dist/types/modes/components/status-line/types.d.ts +2 -0
- package/dist/types/modes/components/theme-selector.d.ts +2 -1
- package/dist/types/modes/components/thinking-selector.d.ts +2 -1
- package/dist/types/modes/controllers/command-controller.d.ts +10 -1
- package/dist/types/modes/controllers/streaming-reveal.d.ts +6 -0
- package/dist/types/modes/interactive-mode.d.ts +10 -1
- package/dist/types/modes/internal-url-autocomplete.d.ts +1 -1
- package/dist/types/modes/running-subagent-badge.d.ts +6 -0
- package/dist/types/modes/theme/theme.d.ts +1 -1
- package/dist/types/modes/types.d.ts +9 -1
- package/dist/types/sdk.d.ts +2 -2
- package/dist/types/session/agent-session.d.ts +8 -1
- package/dist/types/session/blob-store.d.ts +4 -0
- package/dist/types/session/session-manager.d.ts +13 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +1 -1
- package/dist/types/ssh/__tests__/connection-manager-args.test.d.ts +1 -0
- package/dist/types/ssh/__tests__/file-transfer-posix-guard.test.d.ts +1 -0
- package/dist/types/ssh/connection-manager.d.ts +2 -0
- package/dist/types/ssh/file-transfer.d.ts +79 -0
- package/dist/types/ssh/utils.d.ts +6 -0
- package/dist/types/system-prompt.d.ts +3 -0
- package/dist/types/task/executor.d.ts +16 -0
- package/dist/types/tiny/text.d.ts +1 -1
- package/dist/types/tools/builtin-names.d.ts +5 -1
- package/dist/types/tools/{find.d.ts → glob.d.ts} +15 -15
- package/dist/types/tools/{search.d.ts → grep.d.ts} +14 -14
- package/dist/types/tools/index.d.ts +3 -3
- package/dist/types/tools/path-utils.d.ts +29 -0
- package/dist/types/tools/read.d.ts +2 -2
- package/dist/types/tools/render-utils.d.ts +8 -0
- package/dist/types/tools/renderers.d.ts +11 -0
- package/dist/types/tools/ssh.d.ts +2 -0
- package/dist/types/tools/todo.d.ts +0 -16
- package/dist/types/tools/write.d.ts +2 -2
- package/dist/types/utils/active-repo-context.d.ts +8 -0
- package/dist/types/utils/image-resize.d.ts +1 -0
- package/dist/types/utils/markit-cache.d.ts +23 -0
- package/dist/types/utils/markit.d.ts +5 -1
- package/dist/types/utils/prompt-path.d.ts +1 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +14 -0
- package/dist/types/web/search/providers/firecrawl.d.ts +28 -0
- package/dist/types/web/search/providers/tinyfish.d.ts +29 -0
- package/dist/types/web/search/providers/xai.d.ts +13 -0
- package/dist/types/web/search/types.d.ts +18 -2
- package/package.json +30 -15
- package/scripts/build-binary.ts +9 -9
- package/scripts/bundle-dist.ts +2 -2
- package/src/advisor/__tests__/advisor.test.ts +61 -4
- package/src/advisor/__tests__/emission-guard.test.ts +147 -0
- package/src/advisor/advise-tool.ts +1 -1
- package/src/advisor/emission-guard.ts +172 -0
- package/src/advisor/index.ts +1 -0
- package/src/advisor/runtime.ts +11 -0
- package/src/advisor/watchdog.ts +27 -1
- package/src/cli/args.ts +5 -2
- package/src/cli/auth-broker-cli.ts +17 -0
- package/src/cli/config-cli.ts +4 -0
- package/src/cli/flag-tables.ts +7 -4
- package/src/cli/gallery-cli.ts +14 -2
- package/src/cli/gallery-fixtures/edit.ts +60 -0
- package/src/cli/gallery-fixtures/fs.ts +17 -17
- package/src/cli/gallery-fixtures/search.ts +4 -4
- package/src/cli/usage-cli.ts +20 -1
- package/src/cli/web-search-cli.ts +1 -1
- package/src/collab/display-name.ts +13 -0
- package/src/collab/guest.ts +5 -1
- package/src/collab/host.ts +2 -13
- package/src/commands/worktree.ts +6 -0
- package/src/config/inline-tool-descriptors-mode.ts +27 -0
- package/src/config/model-discovery.ts +77 -8
- package/src/config/model-registry.ts +89 -11
- package/src/config/model-resolver.ts +39 -1
- package/src/config/models-config-schema.ts +41 -5
- package/src/config/models-config.ts +4 -1
- package/src/config/settings-schema.ts +85 -27
- package/src/config/settings.ts +172 -1
- package/src/cursor.ts +1 -1
- package/src/dap/config.ts +152 -8
- package/src/dap/session.ts +1 -1
- package/src/discovery/claude-plugins.ts +3 -2
- package/src/discovery/helpers.ts +3 -1
- package/src/edit/hashline/diff.ts +14 -3
- package/src/edit/hashline/execute.ts +42 -6
- package/src/edit/hashline/filesystem.ts +38 -2
- package/src/edit/index.ts +1 -0
- package/src/edit/modes/patch.ts +11 -1
- package/src/edit/renderer.ts +140 -13
- package/src/eval/__tests__/agent-bridge.test.ts +101 -0
- package/src/eval/agent-bridge.ts +26 -3
- package/src/eval/js/tool-bridge.ts +2 -2
- package/src/export/html/index.ts +1 -1
- package/src/export/html/template.js +3 -1
- package/src/export/html/tool-views.generated.js +20 -20
- package/src/extensibility/extensions/types.ts +22 -22
- package/src/extensibility/hooks/types.ts +11 -11
- package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +8 -3
- package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +25 -10
- package/src/extensibility/plugins/marketplace/manager.ts +22 -0
- package/src/extensibility/plugins/marketplace/types.ts +1 -0
- package/src/internal-urls/__tests__/ssh-protocol.test.ts +331 -0
- package/src/internal-urls/docs-index.generated.txt +2 -2
- package/src/internal-urls/docs-index.ts +2 -3
- package/src/internal-urls/index.ts +1 -0
- package/src/internal-urls/registry-helpers.ts +19 -4
- package/src/internal-urls/router.ts +5 -3
- package/src/internal-urls/ssh-protocol.ts +367 -0
- package/src/internal-urls/types.ts +19 -2
- package/src/irc/bus.ts +11 -3
- package/src/mcp/tool-bridge.ts +32 -2
- package/src/memories/index.ts +1 -1
- package/src/modes/acp/acp-agent.ts +14 -1
- package/src/modes/acp/acp-event-mapper.ts +91 -27
- package/src/modes/components/__tests__/move-overlay.test.ts +166 -0
- package/src/modes/components/agent-hub.ts +3 -0
- package/src/modes/components/agent-transcript-viewer.ts +9 -7
- package/src/modes/components/custom-editor.ts +90 -5
- package/src/modes/components/move-overlay.ts +282 -0
- package/src/modes/components/plan-review-overlay.ts +35 -35
- package/src/modes/components/plugin-selector.ts +6 -1
- package/src/modes/components/queue-mode-selector.ts +6 -1
- package/src/modes/components/select-list-mouse-routing.ts +35 -0
- package/src/modes/components/session-selector.ts +11 -10
- package/src/modes/components/settings-defs.ts +14 -1
- package/src/modes/components/settings-selector.ts +196 -29
- package/src/modes/components/show-images-selector.ts +6 -1
- package/src/modes/components/status-line/component.ts +108 -28
- package/src/modes/components/status-line/segments.ts +5 -1
- package/src/modes/components/status-line/types.ts +2 -0
- package/src/modes/components/theme-selector.ts +6 -1
- package/src/modes/components/thinking-selector.ts +6 -1
- package/src/modes/components/tool-execution.ts +25 -9
- package/src/modes/components/tree-selector.ts +5 -5
- package/src/modes/controllers/command-controller.ts +140 -47
- package/src/modes/controllers/event-controller.ts +59 -3
- package/src/modes/controllers/input-controller.ts +68 -2
- package/src/modes/controllers/selector-controller.ts +5 -2
- package/src/modes/controllers/streaming-reveal.ts +17 -0
- package/src/modes/controllers/tool-args-reveal.ts +1 -1
- package/src/modes/interactive-mode.ts +116 -50
- package/src/modes/internal-url-autocomplete.ts +17 -2
- package/src/modes/prompt-action-autocomplete.ts +3 -1
- package/src/modes/running-subagent-badge.ts +13 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +2 -13
- package/src/modes/setup-wizard/scenes/providers.ts +2 -1
- package/src/modes/setup-wizard/scenes/theme.ts +6 -12
- package/src/modes/setup-wizard/scenes/web-search.ts +8 -13
- package/src/modes/setup-wizard/wizard-overlay.ts +6 -5
- package/src/modes/theme/theme.ts +9 -1
- package/src/modes/types.ts +9 -1
- package/src/modes/utils/interactive-context-helpers.ts +1 -1
- package/src/priority.json +15 -0
- package/src/prompts/advisor/active-repo-watchdog.md +6 -0
- package/src/prompts/advisor/context-files.md +8 -0
- package/src/prompts/advisor/system.md +21 -7
- package/src/prompts/agents/designer.md +1 -1
- package/src/prompts/agents/explore.md +1 -1
- package/src/prompts/agents/librarian.md +2 -2
- package/src/prompts/agents/plan.md +2 -2
- package/src/prompts/agents/reviewer.md +1 -1
- package/src/prompts/agents/task.md +2 -2
- package/src/prompts/system/active-repo-context.md +4 -0
- package/src/prompts/system/gemini-tool-call-reminder.md +9 -0
- package/src/prompts/system/plan-mode-active.md +3 -3
- package/src/prompts/system/project-prompt.md +2 -2
- package/src/prompts/system/system-prompt.md +6 -6
- package/src/prompts/tools/bash.md +2 -2
- package/src/prompts/tools/checkpoint.md +1 -1
- package/src/prompts/tools/{find.md → glob.md} +1 -1
- package/src/prompts/tools/{search.md → grep.md} +3 -3
- package/src/prompts/tools/read.md +4 -2
- package/src/sdk.ts +65 -25
- package/src/session/agent-session.ts +519 -132
- package/src/session/blob-store.ts +24 -0
- package/src/session/session-history-format.ts +2 -2
- package/src/session/session-manager.ts +46 -0
- package/src/slash-commands/builtin-registry.ts +138 -20
- package/src/slash-commands/helpers/usage-report.ts +23 -2
- package/src/ssh/__tests__/connection-manager-args.test.ts +69 -0
- package/src/ssh/__tests__/file-transfer-posix-guard.test.ts +68 -0
- package/src/ssh/connection-manager.ts +12 -15
- package/src/ssh/file-transfer.ts +209 -0
- package/src/ssh/utils.ts +24 -0
- package/src/system-prompt.ts +56 -28
- package/src/task/executor.ts +96 -36
- package/src/task/index.ts +3 -3
- package/src/task/render.ts +14 -13
- package/src/task/worktree.ts +38 -1
- package/src/tiny/text.ts +49 -4
- package/src/tiny/worker.ts +3 -3
- package/src/tools/bash.ts +2 -2
- package/src/tools/builtin-names.ts +26 -2
- package/src/tools/{find.ts → glob.ts} +48 -42
- package/src/tools/{search.ts → grep.ts} +311 -129
- package/src/tools/index.ts +13 -14
- package/src/tools/irc.ts +6 -2
- package/src/tools/path-utils.ts +64 -1
- package/src/tools/read.ts +35 -6
- package/src/tools/render-utils.ts +14 -0
- package/src/tools/renderers.ts +15 -4
- package/src/tools/ssh.ts +17 -2
- package/src/tools/todo.ts +4 -26
- package/src/tools/write.ts +25 -9
- package/src/utils/active-repo-context.ts +143 -0
- package/src/utils/image-resize.ts +88 -7
- package/src/utils/lang-from-path.ts +3 -3
- package/src/utils/markit-cache.ts +166 -0
- package/src/utils/markit.ts +86 -18
- package/src/utils/prompt-path.ts +3 -0
- package/src/utils/title-generator.ts +1 -1
- package/src/web/search/provider.ts +54 -34
- package/src/web/search/providers/duckduckgo.ts +140 -0
- package/src/web/search/providers/firecrawl.ts +144 -0
- package/src/web/search/providers/tinyfish.ts +159 -0
- package/src/web/search/providers/xai.ts +292 -0
- package/src/web/search/providers/zai.ts +142 -56
- package/src/web/search/types.ts +6 -2
package/src/sdk.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type AgentTelemetryConfig,
|
|
6
6
|
type AgentTool,
|
|
7
7
|
AppendOnlyContextManager,
|
|
8
|
+
filterProviderReplayMessages,
|
|
8
9
|
type ThinkingLevel,
|
|
9
10
|
} from "@oh-my-pi/pi-agent-core";
|
|
10
11
|
import {
|
|
@@ -24,13 +25,19 @@ import { FALLBACK_DIALECT, preferredDialect } from "@oh-my-pi/pi-catalog/identit
|
|
|
24
25
|
import type { Component } from "@oh-my-pi/pi-tui";
|
|
25
26
|
import { $env, $flag, getAgentDir, getProjectDir, logger, postmortem, prompt, Snowflake } from "@oh-my-pi/pi-utils";
|
|
26
27
|
import { INTENT_FIELD } from "@oh-my-pi/pi-wire";
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
ADVISOR_READONLY_TOOL_NAMES,
|
|
30
|
+
discoverWatchdogFiles,
|
|
31
|
+
formatActiveRepoWatchdogPrompt,
|
|
32
|
+
formatAdvisorContextPrompt,
|
|
33
|
+
} from "./advisor";
|
|
28
34
|
import { type AsyncJob, AsyncJobManager } from "./async";
|
|
29
35
|
import { AutoLearnController, buildAutoLearnInstructions } from "./autolearn/controller";
|
|
30
36
|
import { loadCapability } from "./capability";
|
|
31
37
|
import { type Rule, ruleCapability, setActiveRules } from "./capability/rule";
|
|
32
38
|
import { bucketRules } from "./capability/rule-buckets";
|
|
33
39
|
import { shouldEnableAppendOnlyContext } from "./config/append-only-context-mode";
|
|
40
|
+
import { shouldInlineToolDescriptors } from "./config/inline-tool-descriptors-mode";
|
|
34
41
|
import { ModelRegistry } from "./config/model-registry";
|
|
35
42
|
import {
|
|
36
43
|
formatModelString,
|
|
@@ -42,7 +49,7 @@ import {
|
|
|
42
49
|
resolveModelRoleValue,
|
|
43
50
|
} from "./config/model-resolver";
|
|
44
51
|
import { loadPromptTemplates as loadPromptTemplatesInternal, type PromptTemplate } from "./config/prompt-templates";
|
|
45
|
-
import { Settings, type SkillsSettings } from "./config/settings";
|
|
52
|
+
import { Settings, type SkillsSettings, validateProviderMaxInFlightRequests } from "./config/settings";
|
|
46
53
|
import { CursorExecHandlers } from "./cursor";
|
|
47
54
|
import "./discovery";
|
|
48
55
|
import { initializeWithSettings } from "./discovery";
|
|
@@ -158,8 +165,9 @@ import {
|
|
|
158
165
|
discoverStartupLspServers,
|
|
159
166
|
EditTool,
|
|
160
167
|
EvalTool,
|
|
161
|
-
FindTool,
|
|
162
168
|
filterInitialToolsForDiscoveryAll,
|
|
169
|
+
GlobTool,
|
|
170
|
+
GrepTool,
|
|
163
171
|
getSearchTools,
|
|
164
172
|
HIDDEN_TOOLS,
|
|
165
173
|
isImageProviderPreference,
|
|
@@ -170,7 +178,6 @@ import {
|
|
|
170
178
|
ReadTool,
|
|
171
179
|
ResolveTool,
|
|
172
180
|
renderSearchToolBm25Description,
|
|
173
|
-
SearchTool,
|
|
174
181
|
SearchToolBm25Tool,
|
|
175
182
|
setExcludedSearchProviders,
|
|
176
183
|
setPreferredImageProvider,
|
|
@@ -181,11 +188,13 @@ import {
|
|
|
181
188
|
WriteTool,
|
|
182
189
|
warmupLspServers,
|
|
183
190
|
} from "./tools";
|
|
191
|
+
import { normalizeToolName, normalizeToolNames } from "./tools/builtin-names";
|
|
184
192
|
import { ToolContextStore } from "./tools/context";
|
|
185
193
|
import { getImageGenTools } from "./tools/image-gen";
|
|
186
194
|
import { wrapToolWithMetaNotice } from "./tools/output-meta";
|
|
187
195
|
import { queueResolveHandler } from "./tools/resolve";
|
|
188
196
|
import { ttsTool } from "./tools/tts";
|
|
197
|
+
import { resolveActiveRepoContext } from "./utils/active-repo-context";
|
|
189
198
|
import { EventBus } from "./utils/event-bus";
|
|
190
199
|
import { buildNamedToolChoice } from "./utils/tool-choice";
|
|
191
200
|
import { buildWorkspaceTree, type WorkspaceTree } from "./workspace-tree";
|
|
@@ -606,12 +615,12 @@ export {
|
|
|
606
615
|
createTools,
|
|
607
616
|
EditTool,
|
|
608
617
|
EvalTool,
|
|
609
|
-
|
|
618
|
+
GlobTool,
|
|
619
|
+
GrepTool,
|
|
610
620
|
HIDDEN_TOOLS,
|
|
611
621
|
loadSshTool,
|
|
612
622
|
ReadTool,
|
|
613
623
|
ResolveTool,
|
|
614
|
-
SearchTool,
|
|
615
624
|
type ToolSession,
|
|
616
625
|
WebSearchTool,
|
|
617
626
|
WriteTool,
|
|
@@ -1143,6 +1152,15 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1143
1152
|
? Promise.resolve(options.contextFiles)
|
|
1144
1153
|
: logger.time("discoverContextFiles", discoverContextFiles, cwd, agentDir);
|
|
1145
1154
|
contextFilesPromise.catch(() => {});
|
|
1155
|
+
const activeRepoContextPromise = logger.time("resolveActiveRepoContext", async () => {
|
|
1156
|
+
try {
|
|
1157
|
+
return await resolveActiveRepoContext(cwd);
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
logger.debug("Failed to resolve active repo context", { err: String(err) });
|
|
1160
|
+
return null;
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
activeRepoContextPromise.catch(() => {});
|
|
1146
1164
|
const watchdogFilesPromise = logger.time("discoverWatchdogFiles", () => discoverWatchdogFiles(cwd, agentDir));
|
|
1147
1165
|
watchdogFilesPromise.catch(() => {});
|
|
1148
1166
|
const promptTemplatesPromise = options.promptTemplates
|
|
@@ -1390,10 +1408,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1390
1408
|
}
|
|
1391
1409
|
return result;
|
|
1392
1410
|
};
|
|
1393
|
-
const [contextFiles, resolvedWorkspaceTree, watchdogFiles] = await Promise.all([
|
|
1411
|
+
const [contextFiles, resolvedWorkspaceTree, watchdogFiles, activeRepoContext] = await Promise.all([
|
|
1394
1412
|
contextFilesPromise,
|
|
1395
1413
|
raceWithDeadline("buildWorkspaceTree", workspaceTreePromise),
|
|
1396
1414
|
watchdogFilesPromise,
|
|
1415
|
+
activeRepoContextPromise,
|
|
1397
1416
|
]);
|
|
1398
1417
|
|
|
1399
1418
|
let agent: Agent;
|
|
@@ -1489,9 +1508,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1489
1508
|
hasUI: options.hasUI ?? false,
|
|
1490
1509
|
enableLsp,
|
|
1491
1510
|
get hasEditTool() {
|
|
1492
|
-
const requestedToolNames = options.toolNames
|
|
1493
|
-
? [...new Set(options.toolNames.map(name => name.toLowerCase()))]
|
|
1494
|
-
: undefined;
|
|
1511
|
+
const requestedToolNames = options.toolNames ? normalizeToolNames(options.toolNames) : undefined;
|
|
1495
1512
|
return !requestedToolNames || requestedToolNames.includes("edit");
|
|
1496
1513
|
},
|
|
1497
1514
|
skipPythonPreflight: options.skipPythonPreflight,
|
|
@@ -2157,7 +2174,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2157
2174
|
emitEvent: event => cursorEventEmitter?.(event),
|
|
2158
2175
|
});
|
|
2159
2176
|
|
|
2160
|
-
|
|
2177
|
+
// Resolve the inline-descriptors setting against the session-start model.
|
|
2178
|
+
// `auto` enforces the per-model policy (inline for Gemini, off otherwise);
|
|
2179
|
+
// like the rest of the prune machinery this is fixed for the session, so a
|
|
2180
|
+
// mid-session model switch keeps the start-time decision.
|
|
2181
|
+
const inlineToolDescriptors = shouldInlineToolDescriptors(
|
|
2182
|
+
settings.get("inlineToolDescriptors"),
|
|
2183
|
+
model ? (modelRegistry.getCanonicalId(model) ?? model.id) : undefined,
|
|
2184
|
+
);
|
|
2161
2185
|
const eagerTasks = settings.get("task.eager") !== "default";
|
|
2162
2186
|
const eagerTasksAlways = settings.get("task.eager") === "always";
|
|
2163
2187
|
const intentField = $flag("PI_INTENT_TRACING", settings.get("tools.intentTracing")) ? INTENT_FIELD : undefined;
|
|
@@ -2260,6 +2284,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2260
2284
|
model: settings.get("includeModelInPrompt") ? getActiveModelString() : undefined,
|
|
2261
2285
|
personality: agentKind === "sub" ? "none" : settings.get("personality"),
|
|
2262
2286
|
renderMermaid: settings.get("tui.renderMermaid"),
|
|
2287
|
+
activeRepoContext,
|
|
2263
2288
|
});
|
|
2264
2289
|
|
|
2265
2290
|
if (options.systemPrompt === undefined) {
|
|
@@ -2275,9 +2300,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2275
2300
|
};
|
|
2276
2301
|
|
|
2277
2302
|
const toolNamesFromRegistry = Array.from(toolRegistry.keys());
|
|
2278
|
-
const explicitlyRequestedToolNames = options.toolNames
|
|
2279
|
-
? [...new Set(options.toolNames.map(name => name.toLowerCase()))]
|
|
2280
|
-
: undefined;
|
|
2303
|
+
const explicitlyRequestedToolNames = options.toolNames ? normalizeToolNames(options.toolNames) : undefined;
|
|
2281
2304
|
// When `requireYieldTool` is set, the subagent's prompts and idle-reminders demand a
|
|
2282
2305
|
// `yield` call to terminate. The tool registry already includes `yield` (see
|
|
2283
2306
|
// `createTools`), but an explicit `toolNames` list would otherwise drop it from the
|
|
@@ -2327,13 +2350,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2327
2350
|
discoveryDefaultServers,
|
|
2328
2351
|
)
|
|
2329
2352
|
: [];
|
|
2353
|
+
const normalizeRenamedBuiltinToolName = normalizeToolName;
|
|
2330
2354
|
let initialSelectedMCPToolNames: string[] = [];
|
|
2331
2355
|
let defaultSelectedMCPToolNames: string[] = [];
|
|
2332
2356
|
let initialToolNames = [...initialRequestedActiveToolNames];
|
|
2333
2357
|
if (mcpDiscoveryEnabled) {
|
|
2334
|
-
const restoredSelectedMCPToolNames = existingSession.selectedMCPToolNames
|
|
2335
|
-
|
|
2336
|
-
|
|
2358
|
+
const restoredSelectedMCPToolNames = existingSession.selectedMCPToolNames
|
|
2359
|
+
.map(normalizeRenamedBuiltinToolName)
|
|
2360
|
+
.filter(name => toolRegistry.has(name));
|
|
2337
2361
|
defaultSelectedMCPToolNames = [
|
|
2338
2362
|
...new Set([...discoveryDefaultServerToolNames, ...explicitlyRequestedMCPToolNames]),
|
|
2339
2363
|
];
|
|
@@ -2382,10 +2406,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2382
2406
|
initialToolNames = filterInitialToolsForDiscoveryAll(initialToolNames, {
|
|
2383
2407
|
loadModeOf: name => toolRegistry.get(name)?.loadMode,
|
|
2384
2408
|
essentialNames: new Set(computeEssentialBuiltinNames(settings)),
|
|
2385
|
-
explicitlyRequested: new Set(options.toolNames
|
|
2409
|
+
explicitlyRequested: new Set(options.toolNames ? normalizeToolNames(options.toolNames) : []),
|
|
2386
2410
|
// Back-compat: persisted activations live under selectedMCPToolNames today (built-in
|
|
2387
2411
|
// activation persistence is a follow-up). MCP names won't collide with built-in names.
|
|
2388
|
-
restored: new Set(existingSession.selectedMCPToolNames),
|
|
2412
|
+
restored: new Set(existingSession.selectedMCPToolNames.map(normalizeRenamedBuiltinToolName)),
|
|
2389
2413
|
forceActive,
|
|
2390
2414
|
});
|
|
2391
2415
|
}
|
|
@@ -2449,9 +2473,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2449
2473
|
});
|
|
2450
2474
|
};
|
|
2451
2475
|
|
|
2452
|
-
// Final convertToLlm:
|
|
2476
|
+
// Final convertToLlm: live provider replay drops API-level refusal errors,
|
|
2477
|
+
// then applies secret obfuscation to the remaining outbound context.
|
|
2453
2478
|
const convertToLlmFinal = (messages: AgentMessage[]): Message[] => {
|
|
2454
|
-
const converted = convertToLlmWithBlockImages(messages);
|
|
2479
|
+
const converted = filterProviderReplayMessages(convertToLlmWithBlockImages(messages));
|
|
2455
2480
|
if (!obfuscator?.hasSecrets()) return converted;
|
|
2456
2481
|
return obfuscateMessages(obfuscator, converted);
|
|
2457
2482
|
};
|
|
@@ -2519,6 +2544,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2519
2544
|
disableReasoning: shouldDisableReasoning(effectiveThinkingLevel),
|
|
2520
2545
|
tools: initialTools,
|
|
2521
2546
|
},
|
|
2547
|
+
cwd,
|
|
2548
|
+
// Live cwd: `/move` updates SessionManager (and process cwd) without
|
|
2549
|
+
// reconstructing the Agent, so a static cwd would strand GitLab Duo Agent
|
|
2550
|
+
// namespace/project discovery on the original repo's git remote. Re-read it
|
|
2551
|
+
// per turn from the SessionManager.
|
|
2552
|
+
cwdResolver: () => sessionManager.getCwd(),
|
|
2522
2553
|
convertToLlm: convertToLlmFinal,
|
|
2523
2554
|
onPayload,
|
|
2524
2555
|
onResponse,
|
|
@@ -2563,6 +2594,9 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2563
2594
|
...streamOptions,
|
|
2564
2595
|
openrouterVariant: streamOptions?.openrouterVariant ?? openrouterVariant,
|
|
2565
2596
|
antigravityEndpointMode: streamOptions?.antigravityEndpointMode ?? antigravityEndpointMode,
|
|
2597
|
+
maxInFlightRequests: validateProviderMaxInFlightRequests(
|
|
2598
|
+
streamOptions?.maxInFlightRequests ?? settings.get("providers.maxInFlightRequests"),
|
|
2599
|
+
),
|
|
2566
2600
|
loopGuard: {
|
|
2567
2601
|
enabled: settings.get("model.loopGuard.enabled"),
|
|
2568
2602
|
checkAssistantContent: settings.get("model.loopGuard.checkAssistantContent"),
|
|
@@ -2616,7 +2650,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2616
2650
|
}
|
|
2617
2651
|
|
|
2618
2652
|
// Hard-isolated read-only toolset for the advisor (built unconditionally so
|
|
2619
|
-
// it can be toggled at runtime). Fresh ReadTool/
|
|
2653
|
+
// it can be toggled at runtime). Fresh ReadTool/GrepTool/GlobTool bound to a
|
|
2620
2654
|
// DISTINCT ToolSession so the advisor's investigative reads never touch the
|
|
2621
2655
|
// primary's snapshot, seen-lines, conflict, or summary caches (all keyed on
|
|
2622
2656
|
// session identity). `cwd` stays dynamic; edit/yield capabilities are off.
|
|
@@ -2644,15 +2678,21 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2644
2678
|
.filter((tool): tool is Tool => tool != null)
|
|
2645
2679
|
.map(wrapToolWithMetaNotice);
|
|
2646
2680
|
|
|
2647
|
-
|
|
2648
|
-
if (
|
|
2649
|
-
|
|
2681
|
+
const advisorWatchdogPrompts = [...watchdogFiles];
|
|
2682
|
+
if (activeRepoContext) {
|
|
2683
|
+
advisorWatchdogPrompts.push(formatActiveRepoWatchdogPrompt(activeRepoContext));
|
|
2650
2684
|
}
|
|
2685
|
+
const advisorWatchdogPrompt = advisorWatchdogPrompts.length > 0 ? advisorWatchdogPrompts.join("\n\n") : undefined;
|
|
2686
|
+
// Hand the advisor the same project context files (AGENTS.md, etc.) the
|
|
2687
|
+
// primary agent gets in its system prompt, so the read-only reviewer judges
|
|
2688
|
+
// against the user's standing project rules instead of advising blind.
|
|
2689
|
+
const advisorContextPrompt = formatAdvisorContextPrompt(contextFiles);
|
|
2651
2690
|
// Owned only when this session created the manager; subagents receive a
|
|
2652
2691
|
// parent's manager via `options.mcpManager` and MUST NOT disconnect it.
|
|
2653
2692
|
const ownedMcpManager = options.mcpManager ? undefined : mcpManager;
|
|
2654
2693
|
session = new AgentSession({
|
|
2655
2694
|
advisorWatchdogPrompt,
|
|
2695
|
+
advisorContextPrompt,
|
|
2656
2696
|
agent,
|
|
2657
2697
|
pruneToolDescriptions: inlineToolDescriptors,
|
|
2658
2698
|
thinkingLevel: autoThinking ? AUTO_THINKING : effectiveThinkingLevel,
|