@oh-my-pi/pi-coding-agent 15.5.15 → 15.7.0
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 +81 -0
- package/dist/types/capability/rule-buckets.d.ts +30 -0
- package/dist/types/capability/rule.d.ts +7 -0
- package/dist/types/cli/classify-install-target.d.ts +0 -10
- package/dist/types/cli/completion-gen.d.ts +80 -0
- package/dist/types/cli/initial-message.d.ts +1 -1
- package/dist/types/cli/tiny-models-cli.d.ts +9 -0
- package/dist/types/commands/complete.d.ts +6 -0
- package/dist/types/commands/completions.d.ts +13 -0
- package/dist/types/commands/setup.d.ts +10 -1
- package/dist/types/commands/tiny-models.d.ts +22 -0
- package/dist/types/commit/analysis/conventional.d.ts +1 -1
- package/dist/types/commit/analysis/summary.d.ts +1 -1
- package/dist/types/commit/changelog/generate.d.ts +1 -1
- package/dist/types/commit/changelog/index.d.ts +2 -2
- package/dist/types/commit/map-reduce/map-phase.d.ts +1 -1
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +1 -1
- package/dist/types/config/model-id-affixes.d.ts +10 -0
- package/dist/types/config/settings-schema.d.ts +402 -17
- package/dist/types/discovery/builtin-defaults.d.ts +1 -0
- package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
- package/dist/types/discovery/helpers.d.ts +1 -1
- package/dist/types/discovery/index.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +0 -4
- package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
- package/dist/types/edit/hashline/index.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +16 -1
- package/dist/types/eval/py/kernel.d.ts +3 -0
- package/dist/types/eval/py/runtime.d.ts +11 -1
- package/dist/types/export/html/template.generated.d.ts +1 -1
- package/dist/types/internal-urls/agent-protocol.d.ts +2 -1
- package/dist/types/internal-urls/artifact-protocol.d.ts +2 -1
- package/dist/types/internal-urls/local-protocol.d.ts +2 -1
- package/dist/types/internal-urls/memory-protocol.d.ts +2 -1
- package/dist/types/internal-urls/omp-protocol.d.ts +2 -1
- package/dist/types/internal-urls/router.d.ts +8 -1
- package/dist/types/internal-urls/rule-protocol.d.ts +2 -1
- package/dist/types/internal-urls/skill-protocol.d.ts +2 -1
- package/dist/types/internal-urls/types.d.ts +26 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/memory-backend/index.d.ts +1 -0
- package/dist/types/memory-backend/resolve.d.ts +2 -1
- package/dist/types/memory-backend/types.d.ts +7 -1
- package/dist/types/mnemosyne/backend.d.ts +4 -0
- package/dist/types/mnemosyne/config.d.ts +29 -0
- package/dist/types/mnemosyne/index.d.ts +3 -0
- package/dist/types/mnemosyne/state.d.ts +72 -0
- package/dist/types/modes/components/custom-editor.d.ts +2 -3
- package/dist/types/modes/components/hook-selector.d.ts +27 -0
- package/dist/types/modes/components/index.d.ts +2 -0
- package/dist/types/modes/components/segment-track.d.ts +22 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +6 -0
- package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
- package/dist/types/modes/components/welcome.d.ts +22 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +4 -1
- package/dist/types/modes/gradient-highlight.d.ts +23 -0
- package/dist/types/modes/interactive-mode.d.ts +7 -4
- package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
- package/dist/types/modes/orchestrate.d.ts +10 -0
- package/dist/types/modes/setup-wizard/index.d.ts +16 -0
- package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +19 -0
- package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
- package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +43 -0
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +19 -0
- package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +14 -0
- package/dist/types/modes/theme/defaults/index.d.ts +8406 -8406
- package/dist/types/modes/theme/shimmer.d.ts +2 -0
- package/dist/types/modes/theme/theme.d.ts +11 -0
- package/dist/types/modes/types.d.ts +5 -1
- package/dist/types/modes/ultrathink.d.ts +3 -3
- package/dist/types/modes/utils/keybinding-matchers.d.ts +5 -0
- package/dist/types/sdk.d.ts +3 -0
- package/dist/types/session/agent-session.d.ts +33 -0
- package/dist/types/system-prompt.d.ts +2 -0
- package/dist/types/task/executor.d.ts +2 -0
- package/dist/types/task/render.d.ts +5 -1
- package/dist/types/tiny/device.d.ts +78 -0
- package/dist/types/tiny/dtype.d.ts +85 -0
- package/dist/types/tiny/models.d.ts +185 -0
- package/dist/types/tiny/text.d.ts +19 -0
- package/dist/types/tiny/title-client.d.ts +32 -0
- package/dist/types/tiny/title-protocol.d.ts +74 -0
- package/dist/types/tiny/worker.d.ts +2 -0
- package/dist/types/tools/bash.d.ts +3 -2
- package/dist/types/tools/eval.d.ts +1 -1
- package/dist/types/tools/index.d.ts +7 -4
- package/dist/types/tools/memory-edit.d.ts +40 -0
- package/dist/types/tools/{hindsight-recall.d.ts → memory-recall.d.ts} +6 -6
- package/dist/types/tools/{hindsight-reflect.d.ts → memory-reflect.d.ts} +6 -6
- package/dist/types/tools/memory-render.d.ts +60 -0
- package/dist/types/tools/{hindsight-retain.d.ts → memory-retain.d.ts} +6 -6
- package/dist/types/tools/todo-write.d.ts +8 -0
- package/dist/types/tools/tool-result.d.ts +2 -0
- package/dist/types/tui/code-cell.d.ts +2 -0
- package/dist/types/tui/output-block.d.ts +17 -0
- package/dist/types/utils/title-generator.d.ts +3 -0
- package/package.json +18 -14
- package/scripts/build-binary.ts +1 -0
- package/src/capability/rule-buckets.ts +64 -0
- package/src/capability/rule.ts +8 -0
- package/src/cli/completion-gen.ts +550 -0
- package/src/cli/setup-cli.ts +5 -3
- package/src/cli/tiny-models-cli.ts +127 -0
- package/src/cli-commands.ts +3 -0
- package/src/cli.ts +9 -15
- package/src/commands/complete.ts +66 -0
- package/src/commands/completions.ts +60 -0
- package/src/commands/setup.ts +29 -4
- package/src/commands/tiny-models.ts +36 -0
- package/src/config/model-equivalence.ts +43 -2
- package/src/config/model-id-affixes.ts +64 -0
- package/src/config/model-registry.ts +84 -10
- package/src/config/settings-schema.ts +275 -15
- package/src/discovery/builtin-defaults.ts +39 -0
- package/src/discovery/builtin-rules/index.ts +48 -0
- package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
- package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
- package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
- package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
- package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
- package/src/discovery/builtin-rules/rs-result-type.md +19 -0
- package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
- package/src/discovery/builtin-rules/ts-import-type.md +42 -0
- package/src/discovery/builtin-rules/ts-no-any.md +56 -0
- package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
- package/src/discovery/builtin-rules/ts-no-return-type.md +45 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +50 -0
- package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
- package/src/discovery/builtin-rules/ts-set-map.md +28 -0
- package/src/discovery/index.ts +1 -0
- package/src/edit/hashline/block-resolver.ts +14 -0
- package/src/edit/hashline/diff.ts +9 -8
- package/src/edit/hashline/execute.ts +2 -1
- package/src/edit/hashline/index.ts +1 -0
- package/src/eval/__tests__/shared-executors.test.ts +36 -0
- package/src/eval/js/shared/local-module-loader.ts +13 -1
- package/src/eval/js/shared/rewrite-imports.ts +31 -26
- package/src/eval/py/kernel.ts +37 -15
- package/src/eval/py/runtime.ts +57 -28
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +0 -12
- package/src/export/ttsr.ts +2 -0
- package/src/internal-urls/agent-protocol.ts +18 -1
- package/src/internal-urls/artifact-protocol.ts +19 -1
- package/src/internal-urls/docs-index.generated.ts +8 -7
- package/src/internal-urls/local-protocol.ts +14 -1
- package/src/internal-urls/memory-protocol.ts +6 -1
- package/src/internal-urls/omp-protocol.ts +5 -1
- package/src/internal-urls/router.ts +20 -1
- package/src/internal-urls/rule-protocol.ts +8 -1
- package/src/internal-urls/skill-protocol.ts +8 -1
- package/src/internal-urls/types.ts +27 -0
- package/src/lsp/render.ts +1 -1
- package/src/main.ts +18 -1
- package/src/mcp/oauth-flow.ts +2 -2
- package/src/memory-backend/index.ts +1 -0
- package/src/memory-backend/resolve.ts +4 -1
- package/src/memory-backend/types.ts +8 -1
- package/src/mnemosyne/backend.ts +374 -0
- package/src/mnemosyne/config.ts +160 -0
- package/src/mnemosyne/index.ts +3 -0
- package/src/mnemosyne/state.ts +548 -0
- package/src/modes/acp/acp-agent.ts +11 -6
- package/src/modes/components/agent-dashboard.ts +4 -4
- package/src/modes/components/custom-editor.ts +3 -2
- package/src/modes/components/diff.ts +2 -2
- package/src/modes/components/extensions/extension-list.ts +3 -2
- package/src/modes/components/footer.ts +5 -6
- package/src/modes/components/history-search.ts +3 -3
- package/src/modes/components/hook-selector.ts +92 -8
- package/src/modes/components/index.ts +2 -0
- package/src/modes/components/mcp-add-wizard.ts +3 -3
- package/src/modes/components/model-selector.ts +5 -4
- package/src/modes/components/oauth-selector.ts +3 -3
- package/src/modes/components/segment-track.ts +52 -0
- package/src/modes/components/session-observer-overlay.ts +19 -13
- package/src/modes/components/session-selector.ts +3 -3
- package/src/modes/components/settings-defs.ts +7 -0
- package/src/modes/components/status-line/context-thresholds.ts +11 -0
- package/src/modes/components/status-line/segments.ts +2 -2
- package/src/modes/components/tiny-title-download-progress.ts +90 -0
- package/src/modes/components/tips.txt +13 -0
- package/src/modes/components/tool-execution.ts +72 -4
- package/src/modes/components/tree-selector.ts +3 -3
- package/src/modes/components/user-message-selector.ts +3 -3
- package/src/modes/components/welcome.ts +102 -43
- package/src/modes/controllers/command-controller.ts +16 -1
- package/src/modes/controllers/extension-ui-controller.ts +3 -1
- package/src/modes/controllers/input-controller.ts +69 -21
- package/src/modes/gradient-highlight.ts +70 -0
- package/src/modes/interactive-mode.ts +75 -114
- package/src/modes/internal-url-autocomplete.ts +143 -0
- package/src/modes/orchestrate.ts +36 -0
- package/src/modes/prompt-action-autocomplete.ts +12 -0
- package/src/modes/setup-wizard/index.ts +88 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +96 -0
- package/src/modes/setup-wizard/scenes/outro.ts +35 -0
- package/src/modes/setup-wizard/scenes/providers.ts +69 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +193 -0
- package/src/modes/setup-wizard/scenes/splash.ts +201 -0
- package/src/modes/setup-wizard/scenes/theme.ts +299 -0
- package/src/modes/setup-wizard/scenes/types.ts +48 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +128 -0
- package/src/modes/setup-wizard/wizard-overlay.ts +275 -0
- package/src/modes/theme/shimmer.ts +5 -0
- package/src/modes/theme/theme.ts +44 -20
- package/src/modes/types.ts +6 -1
- package/src/modes/ultrathink.ts +9 -53
- package/src/modes/utils/keybinding-matchers.ts +11 -0
- package/src/prompts/system/memory-consolidation-system.md +8 -0
- package/src/prompts/system/memory-extraction-system.md +26 -0
- package/src/prompts/{commands/orchestrate.md → system/orchestrate-notice.md} +6 -17
- package/src/prompts/system/system-prompt.md +2 -0
- package/src/prompts/system/tiny-title-system.md +8 -0
- package/src/prompts/tools/memory-edit.md +8 -0
- package/src/prompts/tools/read.md +4 -0
- package/src/prompts/tools/task.md +4 -7
- package/src/sdk.ts +13 -21
- package/src/session/agent-session.ts +128 -44
- package/src/slash-commands/builtin-registry.ts +18 -1
- package/src/system-prompt.ts +4 -0
- package/src/task/commands.ts +1 -5
- package/src/task/executor.ts +8 -0
- package/src/task/index.ts +2 -0
- package/src/task/render.ts +69 -26
- package/src/tiny/device.ts +117 -0
- package/src/tiny/dtype.ts +101 -0
- package/src/tiny/models.ts +218 -0
- package/src/tiny/text.ts +54 -0
- package/src/tiny/title-client.ts +395 -0
- package/src/tiny/title-protocol.ts +51 -0
- package/src/tiny/worker.ts +587 -0
- package/src/tools/bash.ts +74 -29
- package/src/tools/browser/tab-worker.ts +1 -1
- package/src/tools/eval.ts +9 -4
- package/src/tools/index.ts +17 -22
- package/src/tools/memory-edit.ts +59 -0
- package/src/tools/memory-recall.ts +100 -0
- package/src/tools/memory-reflect.ts +88 -0
- package/src/tools/memory-render.ts +185 -0
- package/src/tools/memory-retain.ts +91 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/renderers.ts +4 -2
- package/src/tools/todo-write.ts +128 -29
- package/src/tools/tool-result.ts +8 -0
- package/src/tui/code-cell.ts +6 -1
- package/src/tui/output-block.ts +199 -38
- package/src/utils/title-generator.ts +115 -13
- package/dist/types/tools/recipe/index.d.ts +0 -46
- package/dist/types/tools/recipe/render.d.ts +0 -36
- package/dist/types/tools/recipe/runner.d.ts +0 -60
- package/dist/types/tools/recipe/runners/cargo.d.ts +0 -16
- package/dist/types/tools/recipe/runners/index.d.ts +0 -2
- package/dist/types/tools/recipe/runners/just.d.ts +0 -2
- package/dist/types/tools/recipe/runners/make.d.ts +0 -2
- package/dist/types/tools/recipe/runners/pkg.d.ts +0 -2
- package/dist/types/tools/recipe/runners/task.d.ts +0 -2
- package/src/prompts/tools/recipe.md +0 -16
- package/src/tools/hindsight-recall.ts +0 -69
- package/src/tools/hindsight-reflect.ts +0 -58
- package/src/tools/hindsight-retain.ts +0 -57
- package/src/tools/recipe/index.ts +0 -81
- package/src/tools/recipe/render.ts +0 -19
- package/src/tools/recipe/runner.ts +0 -219
- package/src/tools/recipe/runners/cargo.ts +0 -131
- package/src/tools/recipe/runners/index.ts +0 -8
- package/src/tools/recipe/runners/just.ts +0 -73
- package/src/tools/recipe/runners/make.ts +0 -101
- package/src/tools/recipe/runners/pkg.ts +0 -167
- package/src/tools/recipe/runners/task.ts +0 -72
package/src/sdk.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { type AsyncJob, AsyncJobManager, isBackgroundJobSupportEnabled } from ".
|
|
|
38
38
|
import { createAutoresearchExtension } from "./autoresearch";
|
|
39
39
|
import { loadCapability } from "./capability";
|
|
40
40
|
import { type Rule, ruleCapability, setActiveRules } from "./capability/rule";
|
|
41
|
+
import { bucketRules } from "./capability/rule-buckets";
|
|
41
42
|
import { ModelRegistry } from "./config/model-registry";
|
|
42
43
|
import {
|
|
43
44
|
formatModelString,
|
|
@@ -86,8 +87,8 @@ import type { HindsightSessionState } from "./hindsight/state";
|
|
|
86
87
|
import { LocalProtocolHandler, type LocalProtocolOptions } from "./internal-urls";
|
|
87
88
|
import { LSP_STARTUP_EVENT_CHANNEL, type LspStartupEvent } from "./lsp/startup-events";
|
|
88
89
|
import { discoverAndLoadMCPTools, MCPManager, type MCPToolsLoadResult } from "./mcp";
|
|
89
|
-
|
|
90
90
|
import { resolveMemoryBackend } from "./memory-backend";
|
|
91
|
+
import { getMnemosyneSessionState, type MnemosyneSessionState } from "./mnemosyne/state";
|
|
91
92
|
import asyncResultTemplate from "./prompts/tools/async-result.md" with { type: "text" };
|
|
92
93
|
import { AgentRegistry, MAIN_AGENT_ID } from "./registry/agent-registry";
|
|
93
94
|
import {
|
|
@@ -313,6 +314,8 @@ export interface CreateAgentSessionOptions {
|
|
|
313
314
|
taskDepth?: number;
|
|
314
315
|
/** Parent Hindsight state to alias for subagent memory tools. */
|
|
315
316
|
parentHindsightSessionState?: HindsightSessionState;
|
|
317
|
+
/** Parent Mnemosyne state to alias for subagent memory tools. */
|
|
318
|
+
parentMnemosyneSessionState?: MnemosyneSessionState;
|
|
316
319
|
/** Pre-allocated agent identity for IRC routing. Default: "0-Main" for top-level, parentTaskPrefix-derived for sub. */
|
|
317
320
|
agentId?: string;
|
|
318
321
|
/** Display name for the agent in IRC. Default: "main" or "sub". */
|
|
@@ -1043,21 +1046,10 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1043
1046
|
options.rules !== undefined
|
|
1044
1047
|
? { items: options.rules, warnings: undefined }
|
|
1045
1048
|
: await loadCapability<Rule>(ruleCapability.id, { cwd });
|
|
1046
|
-
const rulebookRules
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
if (isTtsrRule) {
|
|
1051
|
-
continue;
|
|
1052
|
-
}
|
|
1053
|
-
if (rule.alwaysApply === true) {
|
|
1054
|
-
alwaysApplyRules.push(rule);
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
if (rule.description) {
|
|
1058
|
-
rulebookRules.push(rule);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1049
|
+
const { rulebookRules, alwaysApplyRules } = bucketRules(rulesResult.items, ttsrManager, {
|
|
1050
|
+
builtinRules: ttsrSettings.builtinRules,
|
|
1051
|
+
disabledRules: ttsrSettings.disabledRules,
|
|
1052
|
+
});
|
|
1061
1053
|
if (existingSession.injectedTtsrRules.length > 0) {
|
|
1062
1054
|
ttsrManager.restoreInjected(existingSession.injectedTtsrRules);
|
|
1063
1055
|
}
|
|
@@ -1187,6 +1179,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1187
1179
|
session ? session.trackEvalExecution(execution, abortController) : execution,
|
|
1188
1180
|
getSessionId: () => sessionManager.getSessionId?.() ?? null,
|
|
1189
1181
|
getHindsightSessionState: () => session?.getHindsightSessionState(),
|
|
1182
|
+
getMnemosyneSessionState: () => getMnemosyneSessionState(session),
|
|
1190
1183
|
getAgentId: () => resolvedAgentId,
|
|
1191
1184
|
getToolByName: name => session?.getToolByName(name),
|
|
1192
1185
|
agentRegistry,
|
|
@@ -1593,11 +1586,8 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1593
1586
|
const promptTools = buildSystemPromptToolMetadata(tools, {
|
|
1594
1587
|
search_tool_bm25: { description: renderSearchToolBm25Description(discoverableToolsForDesc) },
|
|
1595
1588
|
});
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
settings,
|
|
1599
|
-
session,
|
|
1600
|
-
);
|
|
1589
|
+
const memoryBackend = resolveMemoryBackend(settings);
|
|
1590
|
+
const memoryInstructions = await memoryBackend.buildDeveloperInstructions(agentDir, settings, session);
|
|
1601
1591
|
|
|
1602
1592
|
// Build combined append prompt: memory instructions + MCP server instructions
|
|
1603
1593
|
const serverInstructions = mcpManager?.getServerInstructions();
|
|
@@ -1634,6 +1624,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
1634
1624
|
eagerTasks,
|
|
1635
1625
|
secretsEnabled,
|
|
1636
1626
|
workspaceTree: workspaceTreePromise,
|
|
1627
|
+
memoryRootEnabled: memoryBackend.id === "local",
|
|
1637
1628
|
});
|
|
1638
1629
|
|
|
1639
1630
|
if (options.systemPrompt === undefined) {
|
|
@@ -2123,6 +2114,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|
|
2123
2114
|
agentDir,
|
|
2124
2115
|
taskDepth,
|
|
2125
2116
|
parentHindsightSessionState: options.parentHindsightSessionState,
|
|
2117
|
+
parentMnemosyneSessionState: options.parentMnemosyneSessionState,
|
|
2126
2118
|
}),
|
|
2127
2119
|
),
|
|
2128
2120
|
);
|
|
@@ -147,6 +147,8 @@ import type { Goal, GoalModeState } from "../goals/state";
|
|
|
147
147
|
import type { HindsightSessionState } from "../hindsight/state";
|
|
148
148
|
import { type LocalProtocolOptions, resolveLocalUrlToPath } from "../internal-urls";
|
|
149
149
|
import { resolveMemoryBackend } from "../memory-backend";
|
|
150
|
+
import { getMnemosyneSessionState, type MnemosyneSessionState, setMnemosyneSessionState } from "../mnemosyne/state";
|
|
151
|
+
import { containsOrchestrate, ORCHESTRATE_NOTICE } from "../modes/orchestrate";
|
|
150
152
|
import { getCurrentThemeName, theme } from "../modes/theme/theme";
|
|
151
153
|
import { containsUltrathink, ULTRATHINK_NOTICE } from "../modes/ultrathink";
|
|
152
154
|
import type { PlanModeState } from "../plan-mode/state";
|
|
@@ -164,6 +166,7 @@ import { type AgentRegistry, MAIN_AGENT_ID } from "../registry/agent-registry";
|
|
|
164
166
|
import { deobfuscateSessionContext, type SecretObfuscator } from "../secrets/obfuscator";
|
|
165
167
|
import { invalidateHostMetadata } from "../ssh/connection-manager";
|
|
166
168
|
import { resolveThinkingLevelForModel, toReasoningEffort } from "../thinking";
|
|
169
|
+
import { shutdownTinyTitleClient } from "../tiny/title-client";
|
|
167
170
|
import {
|
|
168
171
|
buildDiscoverableToolSearchIndex,
|
|
169
172
|
collectDiscoverableTools,
|
|
@@ -385,6 +388,22 @@ export interface RoleModelCycleResult {
|
|
|
385
388
|
role: string;
|
|
386
389
|
}
|
|
387
390
|
|
|
391
|
+
/** A configured role resolved to a concrete model, used by role cycling and
|
|
392
|
+
* the plan-approval model slider. */
|
|
393
|
+
export interface ResolvedRoleModel {
|
|
394
|
+
role: string;
|
|
395
|
+
model: Model;
|
|
396
|
+
thinkingLevel?: ThinkingLevel;
|
|
397
|
+
explicitThinkingLevel: boolean;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** The set of resolvable role models plus the index of the currently active
|
|
401
|
+
* one within {@link ResolvedRoleModel.role} order. */
|
|
402
|
+
export interface RoleModelCycle {
|
|
403
|
+
models: ResolvedRoleModel[];
|
|
404
|
+
currentIndex: number;
|
|
405
|
+
}
|
|
406
|
+
|
|
388
407
|
/** Session statistics for /session command */
|
|
389
408
|
export interface SessionStats {
|
|
390
409
|
sessionFile: string | undefined;
|
|
@@ -1240,6 +1259,10 @@ export class AgentSession {
|
|
|
1240
1259
|
return previous;
|
|
1241
1260
|
}
|
|
1242
1261
|
|
|
1262
|
+
getMnemosyneSessionState(): MnemosyneSessionState | undefined {
|
|
1263
|
+
return getMnemosyneSessionState(this);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1243
1266
|
/** TTSR manager for time-traveling stream rules */
|
|
1244
1267
|
get ttsrManager(): TtsrManager | undefined {
|
|
1245
1268
|
return this.#ttsrManager;
|
|
@@ -2787,6 +2810,13 @@ export class AgentSession {
|
|
|
2787
2810
|
this.getHindsightSessionState()?.setSessionId(sid);
|
|
2788
2811
|
}
|
|
2789
2812
|
|
|
2813
|
+
#rekeyMnemosyneMemoryForCurrentSessionId(): void {
|
|
2814
|
+
if (resolveMemoryBackend(this.settings).id !== "mnemosyne") return;
|
|
2815
|
+
const sid = this.agent.sessionId;
|
|
2816
|
+
if (!sid) return;
|
|
2817
|
+
this.getMnemosyneSessionState()?.setSessionId(sid);
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2790
2820
|
/** New session file: reset auto-recall / retain-threshold counters for the new transcript. */
|
|
2791
2821
|
#resetHindsightConversationTrackingIfHindsight(): void {
|
|
2792
2822
|
if (resolveMemoryBackend(this.settings).id !== "hindsight") return;
|
|
@@ -2795,6 +2825,13 @@ export class AgentSession {
|
|
|
2795
2825
|
state.resetConversationTracking();
|
|
2796
2826
|
}
|
|
2797
2827
|
|
|
2828
|
+
#resetMnemosyneConversationTrackingIfMnemosyne(): void {
|
|
2829
|
+
if (resolveMemoryBackend(this.settings).id !== "mnemosyne") return;
|
|
2830
|
+
const state = this.getMnemosyneSessionState();
|
|
2831
|
+
if (!state || state.aliasOf) return;
|
|
2832
|
+
state.resetConversationTracking();
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2798
2835
|
/**
|
|
2799
2836
|
* Remove all listeners, flush pending writes, and disconnect from agent.
|
|
2800
2837
|
* Call this when completely done with the session.
|
|
@@ -2851,12 +2888,15 @@ export class AgentSession {
|
|
|
2851
2888
|
);
|
|
2852
2889
|
}
|
|
2853
2890
|
await disposeKernelSessionsByOwner(this.#evalKernelOwnerId);
|
|
2891
|
+
await shutdownTinyTitleClient();
|
|
2854
2892
|
this.#releasePowerAssertion();
|
|
2855
2893
|
await this.sessionManager.close();
|
|
2856
2894
|
this.#closeAllProviderSessions("dispose");
|
|
2857
2895
|
const hindsightState = this.setHindsightSessionState(undefined);
|
|
2858
2896
|
await hindsightState?.flushRetainQueue();
|
|
2859
2897
|
hindsightState?.dispose();
|
|
2898
|
+
const mnemosyneState = setMnemosyneSessionState(this, undefined);
|
|
2899
|
+
mnemosyneState?.dispose();
|
|
2860
2900
|
this.#disconnectFromAgent();
|
|
2861
2901
|
if (this.#unsubscribeAppendOnly) {
|
|
2862
2902
|
this.#unsubscribeAppendOnly();
|
|
@@ -4012,20 +4052,33 @@ export class AgentSession {
|
|
|
4012
4052
|
// Expand file-based prompt templates if requested
|
|
4013
4053
|
const expandedText = expandPromptTemplates ? expandPromptTemplate(text, [...this.#promptTemplates]) : text;
|
|
4014
4054
|
|
|
4015
|
-
// "ultrathink"
|
|
4016
|
-
//
|
|
4017
|
-
//
|
|
4018
|
-
const
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4055
|
+
// Magic keywords ("ultrathink", "orchestrate"): append hidden system notices after the
|
|
4056
|
+
// user's message that steer this turn. User-authored prompts only — synthetic /
|
|
4057
|
+
// agent-initiated turns never trigger them.
|
|
4058
|
+
const keywordNotices: CustomMessage[] = [];
|
|
4059
|
+
if (!options?.synthetic) {
|
|
4060
|
+
const timestamp = Date.now();
|
|
4061
|
+
if (containsUltrathink(expandedText)) {
|
|
4062
|
+
keywordNotices.push({
|
|
4063
|
+
role: "custom",
|
|
4064
|
+
customType: "ultrathink-notice",
|
|
4065
|
+
content: ULTRATHINK_NOTICE,
|
|
4066
|
+
display: false,
|
|
4067
|
+
attribution: "user",
|
|
4068
|
+
timestamp,
|
|
4069
|
+
});
|
|
4070
|
+
}
|
|
4071
|
+
if (containsOrchestrate(expandedText)) {
|
|
4072
|
+
keywordNotices.push({
|
|
4073
|
+
role: "custom",
|
|
4074
|
+
customType: "orchestrate-notice",
|
|
4075
|
+
content: ORCHESTRATE_NOTICE,
|
|
4076
|
+
display: false,
|
|
4077
|
+
attribution: "user",
|
|
4078
|
+
timestamp,
|
|
4079
|
+
});
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4029
4082
|
|
|
4030
4083
|
// If streaming, queue via steer() or followUp() based on option
|
|
4031
4084
|
if (this.isStreaming) {
|
|
@@ -4037,9 +4090,9 @@ export class AgentSession {
|
|
|
4037
4090
|
} else {
|
|
4038
4091
|
await this.#queueSteer(expandedText, options?.images);
|
|
4039
4092
|
}
|
|
4040
|
-
// Steer/follow-up the
|
|
4041
|
-
|
|
4042
|
-
await this.sendCustomMessage(
|
|
4093
|
+
// Steer/follow-up the keyword notices alongside the queued user message.
|
|
4094
|
+
for (const notice of keywordNotices) {
|
|
4095
|
+
await this.sendCustomMessage(notice, { deliverAs: options.streamingBehavior });
|
|
4043
4096
|
}
|
|
4044
4097
|
return;
|
|
4045
4098
|
}
|
|
@@ -4069,7 +4122,7 @@ export class AgentSession {
|
|
|
4069
4122
|
await this.#promptWithMessage(message, expandedText, {
|
|
4070
4123
|
...options,
|
|
4071
4124
|
prependMessages: eagerTodoPrelude ? [eagerTodoPrelude.message] : undefined,
|
|
4072
|
-
appendMessages:
|
|
4125
|
+
appendMessages: keywordNotices.length > 0 ? keywordNotices : undefined,
|
|
4073
4126
|
});
|
|
4074
4127
|
} finally {
|
|
4075
4128
|
// Clean up residual eager-todo directive if the prompt never consumed it
|
|
@@ -4866,7 +4919,9 @@ export class AgentSession {
|
|
|
4866
4919
|
this.setTodoPhases([]);
|
|
4867
4920
|
this.#syncAgentSessionId();
|
|
4868
4921
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
4922
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
4869
4923
|
this.#resetHindsightConversationTrackingIfHindsight();
|
|
4924
|
+
this.#resetMnemosyneConversationTrackingIfMnemosyne();
|
|
4870
4925
|
this.#steeringMessages = [];
|
|
4871
4926
|
this.#followUpMessages = [];
|
|
4872
4927
|
this.#pendingNextTurnMessages = [];
|
|
@@ -4961,6 +5016,8 @@ export class AgentSession {
|
|
|
4961
5016
|
// Update agent session ID
|
|
4962
5017
|
this.#syncAgentSessionId();
|
|
4963
5018
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
5019
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
5020
|
+
this.#resetMnemosyneConversationTrackingIfMnemosyne();
|
|
4964
5021
|
|
|
4965
5022
|
// Emit session_switch event with reason "fork" to hooks
|
|
4966
5023
|
if (this.#extensionRunner) {
|
|
@@ -5046,27 +5103,23 @@ export class AgentSession {
|
|
|
5046
5103
|
}
|
|
5047
5104
|
|
|
5048
5105
|
/**
|
|
5049
|
-
*
|
|
5050
|
-
*
|
|
5051
|
-
*
|
|
5052
|
-
*
|
|
5106
|
+
* Resolve the configured role models in the given order plus the index of
|
|
5107
|
+
* the currently active one. Roles that have no configured model, or whose
|
|
5108
|
+
* configured model is not currently available, are skipped. The `default`
|
|
5109
|
+
* role falls back to the active model when no explicit assignment exists.
|
|
5110
|
+
*
|
|
5111
|
+
* Returns `undefined` only when there is no current model or no available
|
|
5112
|
+
* models at all; an empty `models` array is never returned (callers should
|
|
5113
|
+
* still guard on `models.length`).
|
|
5053
5114
|
*/
|
|
5054
|
-
|
|
5055
|
-
roleOrder: readonly string[],
|
|
5056
|
-
options?: { temporary?: boolean },
|
|
5057
|
-
): Promise<RoleModelCycleResult | undefined> {
|
|
5115
|
+
getRoleModelCycle(roleOrder: readonly string[]): RoleModelCycle | undefined {
|
|
5058
5116
|
const availableModels = this.#modelRegistry.getAvailable();
|
|
5059
5117
|
if (availableModels.length === 0) return undefined;
|
|
5060
5118
|
|
|
5061
5119
|
const currentModel = this.model;
|
|
5062
5120
|
if (!currentModel) return undefined;
|
|
5063
5121
|
const matchPreferences = { usageOrder: this.settings.getStorage()?.getModelUsageOrder() };
|
|
5064
|
-
const
|
|
5065
|
-
role: string;
|
|
5066
|
-
model: Model;
|
|
5067
|
-
thinkingLevel?: ThinkingLevel;
|
|
5068
|
-
explicitThinkingLevel: boolean;
|
|
5069
|
-
}> = [];
|
|
5122
|
+
const models: ResolvedRoleModel[] = [];
|
|
5070
5123
|
|
|
5071
5124
|
for (const role of roleOrder) {
|
|
5072
5125
|
const roleModelStr =
|
|
@@ -5082,7 +5135,7 @@ export class AgentSession {
|
|
|
5082
5135
|
});
|
|
5083
5136
|
if (!resolved.model) continue;
|
|
5084
5137
|
|
|
5085
|
-
|
|
5138
|
+
models.push({
|
|
5086
5139
|
role,
|
|
5087
5140
|
model: resolved.model,
|
|
5088
5141
|
thinkingLevel: resolved.thinkingLevel,
|
|
@@ -5090,25 +5143,49 @@ export class AgentSession {
|
|
|
5090
5143
|
});
|
|
5091
5144
|
}
|
|
5092
5145
|
|
|
5093
|
-
if (
|
|
5146
|
+
if (models.length === 0) return undefined;
|
|
5094
5147
|
|
|
5095
5148
|
const lastRole = this.sessionManager.getLastModelChangeRole();
|
|
5096
|
-
let currentIndex = lastRole ?
|
|
5149
|
+
let currentIndex = lastRole ? models.findIndex(entry => entry.role === lastRole) : -1;
|
|
5097
5150
|
if (currentIndex === -1) {
|
|
5098
|
-
currentIndex =
|
|
5151
|
+
currentIndex = models.findIndex(entry => modelsAreEqual(entry.model, currentModel));
|
|
5099
5152
|
}
|
|
5100
5153
|
if (currentIndex === -1) currentIndex = 0;
|
|
5101
5154
|
|
|
5102
|
-
|
|
5103
|
-
|
|
5155
|
+
return { models, currentIndex };
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
/**
|
|
5159
|
+
* Apply a resolved role model as the active model, persisting the choice to
|
|
5160
|
+
* settings under its role. Mirrors the non-temporary branch of
|
|
5161
|
+
* {@link cycleRoleModels} and is shared with the plan-approval model slider.
|
|
5162
|
+
*/
|
|
5163
|
+
async applyRoleModel(entry: ResolvedRoleModel): Promise<void> {
|
|
5164
|
+
await this.setModel(entry.model, entry.role);
|
|
5165
|
+
if (entry.explicitThinkingLevel && entry.thinkingLevel !== undefined) {
|
|
5166
|
+
this.setThinkingLevel(entry.thinkingLevel);
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
|
|
5170
|
+
/**
|
|
5171
|
+
* Cycle through configured role models in a fixed order.
|
|
5172
|
+
* Skips missing roles.
|
|
5173
|
+
* @param roleOrder - Order of roles to cycle through (e.g., ["slow", "default", "smol"])
|
|
5174
|
+
* @param options - Optional settings: `temporary` to not persist to settings
|
|
5175
|
+
*/
|
|
5176
|
+
async cycleRoleModels(
|
|
5177
|
+
roleOrder: readonly string[],
|
|
5178
|
+
options?: { temporary?: boolean },
|
|
5179
|
+
): Promise<RoleModelCycleResult | undefined> {
|
|
5180
|
+
const cycle = this.getRoleModelCycle(roleOrder);
|
|
5181
|
+
if (!cycle || cycle.models.length <= 1) return undefined;
|
|
5182
|
+
|
|
5183
|
+
const next = cycle.models[(cycle.currentIndex + 1) % cycle.models.length];
|
|
5104
5184
|
|
|
5105
5185
|
if (options?.temporary) {
|
|
5106
5186
|
await this.setModelTemporary(next.model, next.explicitThinkingLevel ? next.thinkingLevel : undefined);
|
|
5107
5187
|
} else {
|
|
5108
|
-
await this.
|
|
5109
|
-
if (next.explicitThinkingLevel && next.thinkingLevel !== undefined) {
|
|
5110
|
-
this.setThinkingLevel(next.thinkingLevel);
|
|
5111
|
-
}
|
|
5188
|
+
await this.applyRoleModel(next);
|
|
5112
5189
|
}
|
|
5113
5190
|
|
|
5114
5191
|
return { model: next.model, thinkingLevel: this.thinkingLevel, role: next.role };
|
|
@@ -5712,7 +5789,9 @@ export class AgentSession {
|
|
|
5712
5789
|
this.agent.reset();
|
|
5713
5790
|
this.#syncAgentSessionId();
|
|
5714
5791
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
5792
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
5715
5793
|
this.#resetHindsightConversationTrackingIfHindsight();
|
|
5794
|
+
this.#resetMnemosyneConversationTrackingIfMnemosyne();
|
|
5716
5795
|
this.#steeringMessages = [];
|
|
5717
5796
|
this.#followUpMessages = [];
|
|
5718
5797
|
this.#pendingNextTurnMessages = [];
|
|
@@ -6184,7 +6263,7 @@ export class AgentSession {
|
|
|
6184
6263
|
|
|
6185
6264
|
#closeCodexProviderSessionsForHistoryRewrite(): void {
|
|
6186
6265
|
const currentModel = this.model;
|
|
6187
|
-
if (
|
|
6266
|
+
if (currentModel?.api !== "openai-codex-responses") return;
|
|
6188
6267
|
this.#closeProviderSessionsForModelSwitch(currentModel, currentModel);
|
|
6189
6268
|
}
|
|
6190
6269
|
|
|
@@ -8183,6 +8262,7 @@ export class AgentSession {
|
|
|
8183
8262
|
await this.sessionManager.setSessionFile(sessionPath);
|
|
8184
8263
|
this.#syncAgentSessionId();
|
|
8185
8264
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
8265
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
8186
8266
|
|
|
8187
8267
|
const sessionContext = this.buildDisplaySessionContext();
|
|
8188
8268
|
const didReloadConversationChange =
|
|
@@ -8255,6 +8335,7 @@ export class AgentSession {
|
|
|
8255
8335
|
|
|
8256
8336
|
if (switchingToDifferentSession) {
|
|
8257
8337
|
this.#resetHindsightConversationTrackingIfHindsight();
|
|
8338
|
+
this.#resetMnemosyneConversationTrackingIfMnemosyne();
|
|
8258
8339
|
}
|
|
8259
8340
|
this.#reconnectToAgent();
|
|
8260
8341
|
return true;
|
|
@@ -8262,6 +8343,7 @@ export class AgentSession {
|
|
|
8262
8343
|
this.sessionManager.restoreState(previousSessionState);
|
|
8263
8344
|
this.#syncAgentSessionId(previousSessionState.sessionId);
|
|
8264
8345
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
8346
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
8265
8347
|
let restoreMcpError: unknown;
|
|
8266
8348
|
try {
|
|
8267
8349
|
await this.#restoreMCPSelectionsForSessionContext(previousSessionContext, {
|
|
@@ -8320,7 +8402,7 @@ export class AgentSession {
|
|
|
8320
8402
|
const previousSessionFile = this.sessionFile;
|
|
8321
8403
|
const selectedEntry = this.sessionManager.getEntry(entryId);
|
|
8322
8404
|
|
|
8323
|
-
if (
|
|
8405
|
+
if (selectedEntry?.type !== "message" || selectedEntry.message.role !== "user") {
|
|
8324
8406
|
throw new Error("Invalid entry ID for branching");
|
|
8325
8407
|
}
|
|
8326
8408
|
|
|
@@ -8357,7 +8439,9 @@ export class AgentSession {
|
|
|
8357
8439
|
this.#syncTodoPhasesFromBranch();
|
|
8358
8440
|
this.#syncAgentSessionId();
|
|
8359
8441
|
this.#rekeyHindsightMemoryForCurrentSessionId();
|
|
8442
|
+
this.#rekeyMnemosyneMemoryForCurrentSessionId();
|
|
8360
8443
|
this.#resetHindsightConversationTrackingIfHindsight();
|
|
8444
|
+
this.#resetMnemosyneConversationTrackingIfMnemosyne();
|
|
8361
8445
|
|
|
8362
8446
|
// Reload messages from entries (works for both file and in-memory mode)
|
|
8363
8447
|
const sessionContext = this.buildDisplaySessionContext();
|
|
@@ -160,6 +160,14 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
|
|
160
160
|
runtime.ctx.editor.setText("");
|
|
161
161
|
},
|
|
162
162
|
},
|
|
163
|
+
{
|
|
164
|
+
name: "switch",
|
|
165
|
+
description: "Switch model for this session (same as alt+p)",
|
|
166
|
+
handleTui: (_command, runtime) => {
|
|
167
|
+
runtime.ctx.showModelSelector({ temporaryOnly: true });
|
|
168
|
+
runtime.ctx.editor.setText("");
|
|
169
|
+
},
|
|
170
|
+
},
|
|
163
171
|
{
|
|
164
172
|
name: "fast",
|
|
165
173
|
description: "Toggle priority service tier (OpenAI service_tier=priority, Anthropic speed=fast)",
|
|
@@ -891,6 +899,8 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
|
|
891
899
|
acpInputHint: "<subcommand>",
|
|
892
900
|
subcommands: [
|
|
893
901
|
{ name: "view", description: "Show current memory injection payload" },
|
|
902
|
+
{ name: "stats", description: "Show memory backend statistics" },
|
|
903
|
+
{ name: "diagnose", description: "Run memory backend diagnostics" },
|
|
894
904
|
{ name: "clear", description: "Clear persisted memory data and artifacts" },
|
|
895
905
|
{ name: "reset", description: "Alias for clear" },
|
|
896
906
|
{ name: "enqueue", description: "Enqueue memory consolidation maintenance" },
|
|
@@ -933,13 +943,20 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
|
|
933
943
|
await runtime.output("Memory consolidation enqueued.");
|
|
934
944
|
return commandConsumed();
|
|
935
945
|
}
|
|
946
|
+
case "stats":
|
|
947
|
+
case "diagnose": {
|
|
948
|
+
const hook = verb === "stats" ? backend.stats : backend.diagnose;
|
|
949
|
+
const payload = await hook?.(runtime.settings.getAgentDir(), runtime.cwd, runtime.session);
|
|
950
|
+
await runtime.output(payload ?? `Memory ${verb} is not available for the ${backend.id} backend.`);
|
|
951
|
+
return commandConsumed();
|
|
952
|
+
}
|
|
936
953
|
case "mm":
|
|
937
954
|
return usage(
|
|
938
955
|
"Mental-model maintenance via /memory mm is unsupported in ACP mode; use the hindsight HTTP API directly.",
|
|
939
956
|
runtime,
|
|
940
957
|
);
|
|
941
958
|
default:
|
|
942
|
-
return usage("Usage: /memory <view|clear|reset|enqueue|rebuild>", runtime);
|
|
959
|
+
return usage("Usage: /memory <view|stats|diagnose|clear|reset|enqueue|rebuild>", runtime);
|
|
943
960
|
}
|
|
944
961
|
},
|
|
945
962
|
handleTui: async (command, runtime) => {
|
package/src/system-prompt.ts
CHANGED
|
@@ -361,6 +361,8 @@ export interface BuildSystemPromptOptions {
|
|
|
361
361
|
secretsEnabled?: boolean;
|
|
362
362
|
/** Pre-loaded workspace tree (skips discovery if provided). May be a Promise to allow early kick-off. */
|
|
363
363
|
workspaceTree?: WorkspaceTree | Promise<WorkspaceTree>;
|
|
364
|
+
/** Whether the local memory://root summary is active. */
|
|
365
|
+
memoryRootEnabled?: boolean;
|
|
364
366
|
}
|
|
365
367
|
|
|
366
368
|
/** Result of building provider-facing system prompt messages. */
|
|
@@ -393,6 +395,7 @@ export async function buildSystemPrompt(options: BuildSystemPromptOptions = {}):
|
|
|
393
395
|
eagerTasks = false,
|
|
394
396
|
secretsEnabled = false,
|
|
395
397
|
workspaceTree: providedWorkspaceTree,
|
|
398
|
+
memoryRootEnabled = false,
|
|
396
399
|
} = options;
|
|
397
400
|
const resolvedCwd = cwd ?? getProjectDir();
|
|
398
401
|
|
|
@@ -570,6 +573,7 @@ export async function buildSystemPrompt(options: BuildSystemPromptOptions = {}):
|
|
|
570
573
|
mcpDiscoveryServerSummaries,
|
|
571
574
|
eagerTasks,
|
|
572
575
|
secretsEnabled,
|
|
576
|
+
hasMemoryRoot: memoryRootEnabled,
|
|
573
577
|
hasObsidian: hasObsidian(),
|
|
574
578
|
};
|
|
575
579
|
const rendered = prompt.render(resolvedCustomPrompt ? customSystemPromptTemplate : systemPromptTemplate, data);
|
package/src/task/commands.ts
CHANGED
|
@@ -9,12 +9,8 @@ import { type SlashCommand, slashCommandCapability } from "../capability/slash-c
|
|
|
9
9
|
import { loadCapability } from "../discovery";
|
|
10
10
|
// Embed command markdown files at build time
|
|
11
11
|
import initMd from "../prompts/agents/init.md" with { type: "text" };
|
|
12
|
-
import orchestrateMd from "../prompts/commands/orchestrate.md" with { type: "text" };
|
|
13
12
|
|
|
14
|
-
const EMBEDDED_COMMANDS: { name: string; content: string }[] = [
|
|
15
|
-
{ name: "init.md", content: prompt.render(initMd) },
|
|
16
|
-
{ name: "orchestrate.md", content: prompt.render(orchestrateMd) },
|
|
17
|
-
];
|
|
13
|
+
const EMBEDDED_COMMANDS: { name: string; content: string }[] = [{ name: "init.md", content: prompt.render(initMd) }];
|
|
18
14
|
|
|
19
15
|
export const EMBEDDED_COMMAND_TEMPLATES: ReadonlyArray<{ name: string; content: string }> = EMBEDDED_COMMANDS;
|
|
20
16
|
|
package/src/task/executor.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type { HindsightSessionState } from "../hindsight/state";
|
|
|
21
21
|
import type { LocalProtocolOptions } from "../internal-urls";
|
|
22
22
|
import { callTool } from "../mcp/client";
|
|
23
23
|
import type { MCPManager } from "../mcp/manager";
|
|
24
|
+
import type { MnemosyneSessionState } from "../mnemosyne/state";
|
|
24
25
|
import subagentSystemPromptTemplate from "../prompts/system/subagent-system-prompt.md" with { type: "text" };
|
|
25
26
|
import submitReminderTemplate from "../prompts/system/subagent-yield-reminder.md" with { type: "text" };
|
|
26
27
|
import { AgentRegistry } from "../registry/agent-registry";
|
|
@@ -185,6 +186,7 @@ export interface ExecutorOptions {
|
|
|
185
186
|
*/
|
|
186
187
|
parentArtifactManager?: ArtifactManager;
|
|
187
188
|
parentHindsightSessionState?: HindsightSessionState;
|
|
189
|
+
parentMnemosyneSessionState?: MnemosyneSessionState;
|
|
188
190
|
/** Parent agent's eval executor session id. Subagents reuse it so eval state is shared. */
|
|
189
191
|
parentEvalSessionId?: string;
|
|
190
192
|
/**
|
|
@@ -631,6 +633,11 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
|
|
631
633
|
if (atMaxDepth && toolNames?.includes("task")) {
|
|
632
634
|
toolNames = toolNames.filter(name => name !== "task");
|
|
633
635
|
}
|
|
636
|
+
// IRC is always available; the [COOP] prompt advertises it, so a restricted
|
|
637
|
+
// whitelist must still carry `irc` for the subagent to actually use it.
|
|
638
|
+
if (toolNames && !toolNames.includes("irc")) {
|
|
639
|
+
toolNames = [...toolNames, "irc"];
|
|
640
|
+
}
|
|
634
641
|
if (toolNames?.includes("exec")) {
|
|
635
642
|
const allowEvalPy = settings.get("eval.py") ?? true;
|
|
636
643
|
const allowEvalJs = settings.get("eval.js") ?? true;
|
|
@@ -1238,6 +1245,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
|
|
|
1238
1245
|
spawns: spawnsEnv,
|
|
1239
1246
|
taskDepth: childDepth,
|
|
1240
1247
|
parentHindsightSessionState: options.parentHindsightSessionState,
|
|
1248
|
+
parentMnemosyneSessionState: options.parentMnemosyneSessionState,
|
|
1241
1249
|
parentTaskPrefix: id,
|
|
1242
1250
|
agentId: id,
|
|
1243
1251
|
agentDisplayName: agent.name,
|
package/src/task/index.ts
CHANGED
|
@@ -930,6 +930,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
|
|
|
930
930
|
localProtocolOptions,
|
|
931
931
|
parentArtifactManager,
|
|
932
932
|
parentHindsightSessionState: this.session.getHindsightSessionState?.(),
|
|
933
|
+
parentMnemosyneSessionState: this.session.getMnemosyneSessionState?.(),
|
|
933
934
|
parentTelemetry: this.session.getTelemetry?.(),
|
|
934
935
|
parentEvalSessionId,
|
|
935
936
|
});
|
|
@@ -986,6 +987,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
|
|
|
986
987
|
localProtocolOptions,
|
|
987
988
|
parentArtifactManager,
|
|
988
989
|
parentHindsightSessionState: this.session.getHindsightSessionState?.(),
|
|
990
|
+
parentMnemosyneSessionState: this.session.getMnemosyneSessionState?.(),
|
|
989
991
|
parentTelemetry: this.session.getTelemetry?.(),
|
|
990
992
|
parentEvalSessionId,
|
|
991
993
|
});
|