@oh-my-pi/pi-coding-agent 15.0.0 → 15.0.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 +79 -0
- package/examples/extensions/plan-mode.ts +0 -1
- package/package.json +10 -10
- package/scripts/build-binary.ts +5 -0
- package/src/autoresearch/helpers.ts +17 -0
- package/src/autoresearch/tools/log-experiment.ts +9 -17
- package/src/autoresearch/tools/run-experiment.ts +2 -17
- package/src/capability/skill.ts +7 -0
- package/src/cli/list-models.ts +1 -1
- package/src/cli/shell-cli.ts +3 -13
- package/src/cli/update-cli.ts +1 -1
- package/src/cli.ts +10 -29
- package/src/commands/commit.ts +10 -0
- package/src/commit/agentic/tools/propose-changelog.ts +8 -1
- package/src/commit/analysis/conventional.ts +8 -66
- package/src/commit/map-reduce/reduce-phase.ts +6 -65
- package/src/commit/pipeline.ts +2 -2
- package/src/commit/shared-llm.ts +89 -0
- package/src/config/config-file.ts +210 -0
- package/src/config/model-equivalence.ts +8 -11
- package/src/config/model-registry.ts +44 -3
- package/src/config/model-resolver.ts +1 -4
- package/src/config/settings-schema.ts +82 -1
- package/src/config/settings.ts +1 -1
- package/src/config.ts +3 -219
- package/src/discovery/claude-plugins.ts +19 -7
- package/src/edit/renderer.ts +7 -1
- package/src/eval/js/executor.ts +3 -0
- package/src/eval/js/shared/rewrite-imports.ts +2 -2
- package/src/eval/py/executor.ts +5 -0
- package/src/eval/py/runner.py +42 -11
- package/src/eval/py/runtime.ts +1 -0
- package/src/exa/factory.ts +2 -2
- package/src/exa/mcp-client.ts +74 -1
- package/src/exec/bash-executor.ts +5 -1
- package/src/export/html/template.generated.ts +1 -1
- package/src/export/html/template.js +0 -11
- package/src/extensibility/extensions/get-commands-handler.ts +77 -0
- package/src/extensibility/extensions/runner.ts +1 -1
- package/src/extensibility/extensions/types.ts +89 -223
- package/src/extensibility/hooks/types.ts +89 -314
- package/src/extensibility/plugins/legacy-pi-compat.ts +48 -31
- package/src/extensibility/shared-events.ts +343 -0
- package/src/extensibility/skills.ts +9 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +500 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +237 -0
- package/src/hashline/anchors.ts +2 -2
- package/src/hashline/input.ts +2 -1
- package/src/hashline/parser.ts +27 -3
- package/src/hindsight/mental-models.ts +1 -1
- package/src/internal-urls/agent-protocol.ts +1 -20
- package/src/internal-urls/artifact-protocol.ts +1 -19
- package/src/internal-urls/docs-index.generated.ts +11 -12
- package/src/internal-urls/registry-helpers.ts +25 -0
- package/src/internal-urls/router.ts +8 -0
- package/src/internal-urls/types.ts +21 -0
- package/src/lsp/config.ts +15 -6
- package/src/lsp/defaults.json +6 -2
- package/src/main.ts +11 -2
- package/src/mcp/oauth-flow.ts +20 -0
- package/src/modes/acp/acp-agent.ts +327 -95
- package/src/modes/components/assistant-message.ts +14 -8
- package/src/modes/components/bash-execution.ts +24 -63
- package/src/modes/components/custom-message.ts +14 -40
- package/src/modes/components/eval-execution.ts +27 -57
- package/src/modes/components/execution-shared.ts +102 -0
- package/src/modes/components/hook-message.ts +17 -49
- package/src/modes/components/mcp-add-wizard.ts +26 -5
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1 -1
- package/src/modes/components/session-observer-overlay.ts +6 -2
- package/src/modes/components/session-selector.ts +1 -1
- package/src/modes/components/status-line/segments.ts +93 -8
- package/src/modes/components/status-line/types.ts +4 -0
- package/src/modes/components/status-line.ts +28 -10
- package/src/modes/components/tool-execution.ts +7 -8
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +13 -4
- package/src/modes/controllers/event-controller.ts +36 -7
- package/src/modes/controllers/extension-ui-controller.ts +3 -2
- package/src/modes/controllers/input-controller.ts +13 -0
- package/src/modes/controllers/mcp-command-controller.ts +56 -61
- package/src/modes/controllers/ssh-command-controller.ts +18 -57
- package/src/modes/interactive-mode.ts +624 -52
- package/src/modes/print-mode.ts +16 -86
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-mode.ts +41 -88
- package/src/modes/rpc/rpc-types.ts +57 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/theme/defaults/dark-poimandres.json +3 -0
- package/src/modes/theme/defaults/light-poimandres.json +3 -0
- package/src/modes/theme/theme.ts +24 -6
- package/src/modes/types.ts +14 -3
- package/src/modes/utils/context-usage.ts +13 -13
- package/src/modes/utils/ui-helpers.ts +10 -3
- package/src/plan-mode/approved-plan.ts +35 -1
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/system/plan-mode-active.md +5 -5
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +1 -1
- package/src/prompts/tools/bash.md +6 -0
- package/src/prompts/tools/github.md +4 -4
- package/src/prompts/tools/goal.md +13 -0
- package/src/prompts/tools/hashline.md +101 -117
- package/src/prompts/tools/read.md +55 -36
- package/src/prompts/tools/resolve.md +6 -5
- package/src/sdk.ts +12 -5
- package/src/session/agent-session.ts +428 -106
- package/src/session/blob-store.ts +36 -3
- package/src/session/messages.ts +67 -2
- package/src/session/session-manager.ts +131 -12
- package/src/session/session-storage.ts +33 -15
- package/src/session/streaming-output.ts +309 -13
- package/src/slash-commands/builtin-registry.ts +18 -0
- package/src/ssh/ssh-executor.ts +5 -0
- package/src/system-prompt.ts +4 -2
- package/src/task/discovery.ts +5 -2
- package/src/task/executor.ts +19 -8
- package/src/task/index.ts +3 -0
- package/src/task/render.ts +21 -15
- package/src/task/types.ts +4 -0
- package/src/tools/ast-edit.ts +21 -120
- package/src/tools/ast-grep.ts +21 -119
- package/src/tools/bash-command-fixup.ts +47 -0
- package/src/tools/bash-interactive.ts +9 -1
- package/src/tools/bash.ts +66 -19
- package/src/tools/browser/attach.ts +3 -3
- package/src/tools/browser/launch.ts +81 -18
- package/src/tools/browser/registry.ts +1 -5
- package/src/tools/browser/render.ts +2 -2
- package/src/tools/browser/tab-supervisor.ts +51 -14
- package/src/tools/conflict-detect.ts +15 -4
- package/src/tools/eval.ts +12 -2
- package/src/tools/find.ts +20 -38
- package/src/tools/gh.ts +44 -10
- package/src/tools/index.ts +22 -11
- package/src/tools/inspect-image.ts +3 -10
- package/src/tools/job.ts +16 -7
- package/src/tools/output-meta.ts +202 -37
- package/src/tools/path-utils.ts +125 -2
- package/src/tools/read.ts +548 -237
- package/src/tools/render-utils.ts +92 -0
- package/src/tools/renderers.ts +2 -0
- package/src/tools/resolve.ts +72 -44
- package/src/tools/search.ts +120 -186
- package/src/tools/ssh.ts +3 -2
- package/src/tools/write.ts +64 -9
- package/src/utils/file-mentions.ts +1 -1
- package/src/utils/image-loading.ts +7 -3
- package/src/utils/image-resize.ts +32 -43
- package/src/vim/parser.ts +0 -17
- package/src/vim/render.ts +1 -1
- package/src/vim/types.ts +1 -1
- package/src/web/search/providers/anthropic.ts +5 -0
- package/src/web/search/providers/exa.ts +3 -0
- package/src/web/search/providers/gemini.ts +40 -95
- package/src/web/search/providers/jina.ts +5 -2
- package/src/web/search/providers/zai.ts +5 -2
- package/src/prompts/tools/exit-plan-mode.md +0 -6
- package/src/tools/exit-plan-mode.ts +0 -97
- package/src/utils/fuzzy.ts +0 -108
- package/src/utils/image-convert.ts +0 -27
|
@@ -1155,16 +1155,6 @@
|
|
|
1155
1155
|
return html;
|
|
1156
1156
|
}
|
|
1157
1157
|
|
|
1158
|
-
function renderExitPlanMode(name, args, result, ctx) {
|
|
1159
|
-
const badges = args.title ? [String(args.title)] : null;
|
|
1160
|
-
let html = toolHead('exit_plan_mode', '', badges);
|
|
1161
|
-
if (result) {
|
|
1162
|
-
const output = ctx.getResultText();
|
|
1163
|
-
if (output) html += formatExpandableOutput(output, 8);
|
|
1164
|
-
}
|
|
1165
|
-
return html;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
1158
|
function renderResolve(name, args, result, ctx) {
|
|
1169
1159
|
const action = str(args.action) || '?';
|
|
1170
1160
|
let html = toolHead('resolve', '', [action]);
|
|
@@ -1562,7 +1552,6 @@
|
|
|
1562
1552
|
inspect_image: renderInspectImage,
|
|
1563
1553
|
generate_image: renderGenerateImage,
|
|
1564
1554
|
ask: renderAsk,
|
|
1565
|
-
exit_plan_mode: renderExitPlanMode,
|
|
1566
1555
|
resolve: renderResolve,
|
|
1567
1556
|
github: renderGh,
|
|
1568
1557
|
render_mermaid: renderMermaid,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper for wiring the `getCommands` action of {@link ExtensionAPI}.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes the union over the three slash-command sources the runtime
|
|
5
|
+
* exposes so the five wiring sites (interactive UI, ACP, RPC, print, child
|
|
6
|
+
* task executor) cannot drift:
|
|
7
|
+
* - extension-registered hook commands (`source: "extension"`)
|
|
8
|
+
* - prompt commands loaded as `LoadedCustomCommand` — user/project/bundled
|
|
9
|
+
* custom commands and MCP prompts (`source: "prompt"`)
|
|
10
|
+
* - skill commands derived from `session.skills`, gated on
|
|
11
|
+
* `skillsSettings.enableSkillCommands` (`source: "skill"`)
|
|
12
|
+
*
|
|
13
|
+
* Built-in slash commands are intentionally excluded; `getCommands()` is the
|
|
14
|
+
* surface extensions use to discover dynamic commands they did not register
|
|
15
|
+
* themselves. Each frontend (interactive-mode, ACP) prepends its own builtins.
|
|
16
|
+
*/
|
|
17
|
+
import type { SkillsSettings } from "../../config/settings";
|
|
18
|
+
import type { CustomCommandSource, LoadedCustomCommand } from "../custom-commands";
|
|
19
|
+
import { getSkillSlashCommandName, type Skill } from "../skills";
|
|
20
|
+
import type { SlashCommandInfo, SlashCommandLocation } from "../slash-commands";
|
|
21
|
+
import type { ExtensionRunner } from "./runner";
|
|
22
|
+
|
|
23
|
+
interface CommandsCapableSession {
|
|
24
|
+
readonly extensionRunner?: ExtensionRunner;
|
|
25
|
+
readonly customCommands: ReadonlyArray<LoadedCustomCommand>;
|
|
26
|
+
readonly skills: ReadonlyArray<Skill>;
|
|
27
|
+
readonly skillsSettings?: SkillsSettings;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getSessionSlashCommands(session: CommandsCapableSession): SlashCommandInfo[] {
|
|
31
|
+
const out: SlashCommandInfo[] = [];
|
|
32
|
+
|
|
33
|
+
const runner = session.extensionRunner;
|
|
34
|
+
if (runner) {
|
|
35
|
+
for (const cmd of runner.getRegisteredCommands()) {
|
|
36
|
+
out.push({
|
|
37
|
+
name: cmd.name,
|
|
38
|
+
description: cmd.description,
|
|
39
|
+
source: "extension",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (const cmd of session.customCommands) {
|
|
45
|
+
out.push({
|
|
46
|
+
name: cmd.command.name,
|
|
47
|
+
description: cmd.command.description,
|
|
48
|
+
source: "prompt",
|
|
49
|
+
location: customCommandLocation(cmd.source),
|
|
50
|
+
path: cmd.resolvedPath,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (session.skillsSettings?.enableSkillCommands) {
|
|
55
|
+
for (const skill of session.skills) {
|
|
56
|
+
out.push({
|
|
57
|
+
name: getSkillSlashCommandName(skill),
|
|
58
|
+
description: skill.description || undefined,
|
|
59
|
+
source: "skill",
|
|
60
|
+
path: skill.filePath,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function customCommandLocation(source: CustomCommandSource): SlashCommandLocation | undefined {
|
|
69
|
+
switch (source) {
|
|
70
|
+
case "user":
|
|
71
|
+
return "user";
|
|
72
|
+
case "project":
|
|
73
|
+
return "project";
|
|
74
|
+
case "bundled":
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -63,7 +63,7 @@ export type ExtensionErrorListener = (error: ExtensionError) => void;
|
|
|
63
63
|
export const EXTENSION_HANDLER_TIMEOUT_MS = 30_000;
|
|
64
64
|
let extensionHandlerTimeoutMs = EXTENSION_HANDLER_TIMEOUT_MS;
|
|
65
65
|
|
|
66
|
-
export function
|
|
66
|
+
export function testSetExtensionHandlerTimeoutMs(timeoutMs: number): void {
|
|
67
67
|
extensionHandlerTimeoutMs = timeoutMs;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -18,13 +18,11 @@ import type {
|
|
|
18
18
|
ProviderResponseMetadata,
|
|
19
19
|
SimpleStreamOptions,
|
|
20
20
|
TextContent,
|
|
21
|
-
ToolResultMessage,
|
|
22
21
|
} from "@oh-my-pi/pi-ai";
|
|
23
22
|
import type { OAuthCredentials, OAuthLoginCallbacks } from "@oh-my-pi/pi-ai/utils/oauth/types";
|
|
24
23
|
import type * as piCodingAgent from "@oh-my-pi/pi-coding-agent";
|
|
25
24
|
import type { AutocompleteItem, Component, EditorTheme, KeyId, TUI } from "@oh-my-pi/pi-tui";
|
|
26
25
|
import type { Static, TSchema } from "@sinclair/typebox";
|
|
27
|
-
import type { Rule } from "../../capability/rule";
|
|
28
26
|
import type { KeybindingsManager } from "../../config/keybindings";
|
|
29
27
|
import type { ModelRegistry } from "../../config/model-registry";
|
|
30
28
|
import type { EditToolDetails } from "../../edit";
|
|
@@ -33,15 +31,9 @@ import type { BashResult } from "../../exec/bash-executor";
|
|
|
33
31
|
import type { ExecOptions, ExecResult } from "../../exec/exec";
|
|
34
32
|
import type { CustomEditor } from "../../modes/components/custom-editor";
|
|
35
33
|
import type { Theme } from "../../modes/theme/theme";
|
|
36
|
-
import type {
|
|
34
|
+
import type { CompactionResult } from "../../session/compaction";
|
|
37
35
|
import type { CustomMessage } from "../../session/messages";
|
|
38
|
-
import type {
|
|
39
|
-
BranchSummaryEntry,
|
|
40
|
-
CompactionEntry,
|
|
41
|
-
ReadonlySessionManager,
|
|
42
|
-
SessionEntry,
|
|
43
|
-
SessionManager,
|
|
44
|
-
} from "../../session/session-manager";
|
|
36
|
+
import type { ReadonlySessionManager, SessionManager } from "../../session/session-manager";
|
|
45
37
|
import type {
|
|
46
38
|
BashToolDetails,
|
|
47
39
|
BashToolInput,
|
|
@@ -53,8 +45,40 @@ import type {
|
|
|
53
45
|
SearchToolInput,
|
|
54
46
|
WriteToolInput,
|
|
55
47
|
} from "../../tools";
|
|
56
|
-
import type { TodoItem } from "../../tools/todo-write";
|
|
57
48
|
import type { EventBus } from "../../utils/event-bus";
|
|
49
|
+
import type {
|
|
50
|
+
AgentEndEvent,
|
|
51
|
+
AgentStartEvent,
|
|
52
|
+
AutoCompactionEndEvent,
|
|
53
|
+
AutoCompactionStartEvent,
|
|
54
|
+
AutoRetryEndEvent,
|
|
55
|
+
AutoRetryStartEvent,
|
|
56
|
+
ContextEvent,
|
|
57
|
+
GoalUpdatedEvent,
|
|
58
|
+
SessionBeforeBranchEvent,
|
|
59
|
+
SessionBeforeBranchResult,
|
|
60
|
+
SessionBeforeCompactEvent,
|
|
61
|
+
SessionBeforeCompactResult,
|
|
62
|
+
SessionBeforeSwitchEvent,
|
|
63
|
+
SessionBeforeSwitchResult,
|
|
64
|
+
SessionBeforeTreeEvent,
|
|
65
|
+
SessionBeforeTreeResult,
|
|
66
|
+
SessionBranchEvent,
|
|
67
|
+
SessionCompactEvent,
|
|
68
|
+
SessionCompactingEvent,
|
|
69
|
+
SessionCompactingResult,
|
|
70
|
+
SessionEvent,
|
|
71
|
+
SessionShutdownEvent,
|
|
72
|
+
SessionStartEvent,
|
|
73
|
+
SessionSwitchEvent,
|
|
74
|
+
SessionTreeEvent,
|
|
75
|
+
TodoReminderEvent,
|
|
76
|
+
ToolCallEventResult,
|
|
77
|
+
ToolResultEventResult,
|
|
78
|
+
TtsrTriggeredEvent,
|
|
79
|
+
TurnEndEvent,
|
|
80
|
+
TurnStartEvent,
|
|
81
|
+
} from "../shared-events";
|
|
58
82
|
import type { SlashCommandInfo } from "../slash-commands";
|
|
59
83
|
|
|
60
84
|
export type { AppKeybinding, KeybindingsManager } from "../../config/keybindings";
|
|
@@ -104,6 +128,11 @@ export type ExtensionWidgetContent = string[] | ExtensionUiComponentFactory | un
|
|
|
104
128
|
* UI context for extensions to request interactive UI.
|
|
105
129
|
* Each mode (interactive, RPC, print) provides its own implementation.
|
|
106
130
|
*/
|
|
131
|
+
// fallow-ignore-next-line code-duplication
|
|
132
|
+
// Parallel to HookUIContext: extensions expose a strictly larger UI surface
|
|
133
|
+
// (custom editor component, header/footer, widgets, theming, terminal input)
|
|
134
|
+
// and may be invoked from event handlers that have already taken the agent
|
|
135
|
+
// loop's lock — hooks intentionally cannot.
|
|
107
136
|
export interface ExtensionUIContext {
|
|
108
137
|
/** Show a selector and return the user's choice. */
|
|
109
138
|
select(title: string, options: string[], dialogOptions?: ExtensionUIDialogOptions): Promise<string | undefined>;
|
|
@@ -221,6 +250,11 @@ export interface CompactOptions {
|
|
|
221
250
|
/**
|
|
222
251
|
* Context passed to extension event handlers.
|
|
223
252
|
*/
|
|
253
|
+
// fallow-ignore-next-line code-duplication
|
|
254
|
+
// Parallel to HookContext: extensions expose a strictly larger runtime
|
|
255
|
+
// surface (model registry, system prompt, shutdown, full session manager
|
|
256
|
+
// access). Field overlap is incidental; merging into a base would require
|
|
257
|
+
// hooks to widen their public contract.
|
|
224
258
|
export interface ExtensionContext {
|
|
225
259
|
/** UI methods for user interaction */
|
|
226
260
|
ui: ExtensionUIContext;
|
|
@@ -256,6 +290,10 @@ export interface ExtensionContext {
|
|
|
256
290
|
* Extended context for command handlers.
|
|
257
291
|
* Includes session control methods only safe in user-initiated commands.
|
|
258
292
|
*/
|
|
293
|
+
// fallow-ignore-next-line code-duplication
|
|
294
|
+
// Parallel to HookCommandContext: same method names, different invariants —
|
|
295
|
+
// extension commands additionally permit `switchSession` and `reload`,
|
|
296
|
+
// which hooks must not call to avoid deadlocking the agent loop.
|
|
259
297
|
export interface ExtensionCommandContext extends ExtensionContext {
|
|
260
298
|
/** Get current context usage for the active model. */
|
|
261
299
|
getContextUsage(): ContextUsage | undefined;
|
|
@@ -373,115 +411,30 @@ export interface ResourcesDiscoverResult {
|
|
|
373
411
|
}
|
|
374
412
|
|
|
375
413
|
// ============================================================================
|
|
376
|
-
// Session Events
|
|
414
|
+
// Session Events (shared with hooks subsystem)
|
|
377
415
|
// ============================================================================
|
|
378
416
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
reason: "new" | "resume" | "fork";
|
|
395
|
-
previousSessionFile: string | undefined;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/** Fired before branching a session (can be cancelled) */
|
|
399
|
-
export interface SessionBeforeBranchEvent {
|
|
400
|
-
type: "session_before_branch";
|
|
401
|
-
entryId: string;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/** Fired after branching a session */
|
|
405
|
-
export interface SessionBranchEvent {
|
|
406
|
-
type: "session_branch";
|
|
407
|
-
previousSessionFile: string | undefined;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** Fired before context compaction (can be cancelled or customized) */
|
|
411
|
-
export interface SessionBeforeCompactEvent {
|
|
412
|
-
type: "session_before_compact";
|
|
413
|
-
preparation: CompactionPreparation;
|
|
414
|
-
branchEntries: SessionEntry[];
|
|
415
|
-
customInstructions?: string;
|
|
416
|
-
signal: AbortSignal;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/** Fired before compaction summarization to customize prompts/context */
|
|
420
|
-
export interface SessionCompactingEvent {
|
|
421
|
-
type: "session.compacting";
|
|
422
|
-
sessionId: string;
|
|
423
|
-
messages: AgentMessage[];
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/** Fired after context compaction */
|
|
427
|
-
export interface SessionCompactEvent {
|
|
428
|
-
type: "session_compact";
|
|
429
|
-
compactionEntry: CompactionEntry;
|
|
430
|
-
fromExtension: boolean;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/** Fired on process exit */
|
|
434
|
-
export interface SessionShutdownEvent {
|
|
435
|
-
type: "session_shutdown";
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/** Preparation data for tree navigation */
|
|
439
|
-
export interface TreePreparation {
|
|
440
|
-
targetId: string;
|
|
441
|
-
oldLeafId: string | null;
|
|
442
|
-
commonAncestorId: string | null;
|
|
443
|
-
entriesToSummarize: SessionEntry[];
|
|
444
|
-
userWantsSummary: boolean;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/** Fired before navigating in the session tree (can be cancelled) */
|
|
448
|
-
export interface SessionBeforeTreeEvent {
|
|
449
|
-
type: "session_before_tree";
|
|
450
|
-
preparation: TreePreparation;
|
|
451
|
-
signal: AbortSignal;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/** Fired after navigating in the session tree */
|
|
455
|
-
export interface SessionTreeEvent {
|
|
456
|
-
type: "session_tree";
|
|
457
|
-
newLeafId: string | null;
|
|
458
|
-
oldLeafId: string | null;
|
|
459
|
-
summaryEntry?: BranchSummaryEntry;
|
|
460
|
-
fromExtension?: boolean;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export type SessionEvent =
|
|
464
|
-
| SessionStartEvent
|
|
465
|
-
| SessionBeforeSwitchEvent
|
|
466
|
-
| SessionSwitchEvent
|
|
467
|
-
| SessionBeforeBranchEvent
|
|
468
|
-
| SessionBranchEvent
|
|
469
|
-
| SessionBeforeCompactEvent
|
|
470
|
-
| SessionCompactingEvent
|
|
471
|
-
| SessionCompactEvent
|
|
472
|
-
| SessionShutdownEvent
|
|
473
|
-
| SessionBeforeTreeEvent
|
|
474
|
-
| SessionTreeEvent;
|
|
417
|
+
export type {
|
|
418
|
+
SessionBeforeBranchEvent,
|
|
419
|
+
SessionBeforeCompactEvent,
|
|
420
|
+
SessionBeforeSwitchEvent,
|
|
421
|
+
SessionBeforeTreeEvent,
|
|
422
|
+
SessionBranchEvent,
|
|
423
|
+
SessionCompactEvent,
|
|
424
|
+
SessionCompactingEvent,
|
|
425
|
+
SessionEvent,
|
|
426
|
+
SessionShutdownEvent,
|
|
427
|
+
SessionStartEvent,
|
|
428
|
+
SessionSwitchEvent,
|
|
429
|
+
SessionTreeEvent,
|
|
430
|
+
TreePreparation,
|
|
431
|
+
} from "../shared-events";
|
|
475
432
|
|
|
476
433
|
// ============================================================================
|
|
477
434
|
// Agent Events
|
|
478
435
|
// ============================================================================
|
|
479
436
|
|
|
480
|
-
|
|
481
|
-
export interface ContextEvent {
|
|
482
|
-
type: "context";
|
|
483
|
-
messages: AgentMessage[];
|
|
484
|
-
}
|
|
437
|
+
export type { ContextEvent } from "../shared-events";
|
|
485
438
|
|
|
486
439
|
/** Fired before a provider request is sent. Can replace the payload. */
|
|
487
440
|
export interface BeforeProviderRequestEvent {
|
|
@@ -502,31 +455,7 @@ export interface BeforeAgentStartEvent {
|
|
|
502
455
|
systemPrompt: string[];
|
|
503
456
|
}
|
|
504
457
|
|
|
505
|
-
|
|
506
|
-
export interface AgentStartEvent {
|
|
507
|
-
type: "agent_start";
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/** Fired when an agent loop ends */
|
|
511
|
-
export interface AgentEndEvent {
|
|
512
|
-
type: "agent_end";
|
|
513
|
-
messages: AgentMessage[];
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/** Fired at the start of each turn */
|
|
517
|
-
export interface TurnStartEvent {
|
|
518
|
-
type: "turn_start";
|
|
519
|
-
turnIndex: number;
|
|
520
|
-
timestamp: number;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/** Fired at the end of each turn */
|
|
524
|
-
export interface TurnEndEvent {
|
|
525
|
-
type: "turn_end";
|
|
526
|
-
turnIndex: number;
|
|
527
|
-
message: AgentMessage;
|
|
528
|
-
toolResults: ToolResultMessage[];
|
|
529
|
-
}
|
|
458
|
+
export type { AgentEndEvent, AgentStartEvent, TurnEndEvent, TurnStartEvent } from "../shared-events";
|
|
530
459
|
|
|
531
460
|
/** Fired when a message starts (user, assistant, or toolResult) */
|
|
532
461
|
export interface MessageStartEvent {
|
|
@@ -574,55 +503,14 @@ export interface ToolExecutionEndEvent {
|
|
|
574
503
|
isError: boolean;
|
|
575
504
|
}
|
|
576
505
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
export interface AutoCompactionEndEvent {
|
|
586
|
-
type: "auto_compaction_end";
|
|
587
|
-
action: "context-full" | "handoff";
|
|
588
|
-
result: CompactionResult | undefined;
|
|
589
|
-
aborted: boolean;
|
|
590
|
-
willRetry: boolean;
|
|
591
|
-
errorMessage?: string;
|
|
592
|
-
/** True when compaction was skipped for a benign reason (no model, no candidates, nothing to compact). */
|
|
593
|
-
skipped?: boolean;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/** Fired when auto-retry starts */
|
|
597
|
-
export interface AutoRetryStartEvent {
|
|
598
|
-
type: "auto_retry_start";
|
|
599
|
-
attempt: number;
|
|
600
|
-
maxAttempts: number;
|
|
601
|
-
delayMs: number;
|
|
602
|
-
errorMessage: string;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/** Fired when auto-retry ends */
|
|
606
|
-
export interface AutoRetryEndEvent {
|
|
607
|
-
type: "auto_retry_end";
|
|
608
|
-
success: boolean;
|
|
609
|
-
attempt: number;
|
|
610
|
-
finalError?: string;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
/** Fired when TTSR rule matching interrupts generation */
|
|
614
|
-
export interface TtsrTriggeredEvent {
|
|
615
|
-
type: "ttsr_triggered";
|
|
616
|
-
rules: Rule[];
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
/** Fired when todo reminder logic detects unfinished todos */
|
|
620
|
-
export interface TodoReminderEvent {
|
|
621
|
-
type: "todo_reminder";
|
|
622
|
-
todos: TodoItem[];
|
|
623
|
-
attempt: number;
|
|
624
|
-
maxAttempts: number;
|
|
625
|
-
}
|
|
506
|
+
export type {
|
|
507
|
+
AutoCompactionEndEvent,
|
|
508
|
+
AutoCompactionStartEvent,
|
|
509
|
+
AutoRetryEndEvent,
|
|
510
|
+
AutoRetryStartEvent,
|
|
511
|
+
TodoReminderEvent,
|
|
512
|
+
TtsrTriggeredEvent,
|
|
513
|
+
} from "../shared-events";
|
|
626
514
|
|
|
627
515
|
/** Fired when AuthStorage automatically soft-disables a credential (e.g. OAuth `invalid_grant`). Not fired for user-initiated `remove()` or duplicate-credential dedup. */
|
|
628
516
|
export interface CredentialDisabledEvent {
|
|
@@ -840,6 +728,7 @@ export type ExtensionEvent =
|
|
|
840
728
|
| AutoRetryEndEvent
|
|
841
729
|
| TtsrTriggeredEvent
|
|
842
730
|
| TodoReminderEvent
|
|
731
|
+
| GoalUpdatedEvent
|
|
843
732
|
| CredentialDisabledEvent
|
|
844
733
|
| UserBashEvent
|
|
845
734
|
| UserPythonEvent
|
|
@@ -857,10 +746,7 @@ export interface ContextEventResult {
|
|
|
857
746
|
|
|
858
747
|
export type BeforeProviderRequestEventResult = unknown;
|
|
859
748
|
|
|
860
|
-
export
|
|
861
|
-
block?: boolean;
|
|
862
|
-
reason?: string;
|
|
863
|
-
}
|
|
749
|
+
export type { ToolCallEventResult } from "../shared-events";
|
|
864
750
|
|
|
865
751
|
/** Result from input event handler */
|
|
866
752
|
export interface InputEventResult {
|
|
@@ -884,11 +770,7 @@ export interface UserPythonEventResult {
|
|
|
884
770
|
result?: PythonResult;
|
|
885
771
|
}
|
|
886
772
|
|
|
887
|
-
export
|
|
888
|
-
content?: (TextContent | ImageContent)[];
|
|
889
|
-
details?: unknown;
|
|
890
|
-
isError?: boolean;
|
|
891
|
-
}
|
|
773
|
+
export type { ToolResultEventResult } from "../shared-events";
|
|
892
774
|
|
|
893
775
|
export interface BeforeAgentStartEventResult {
|
|
894
776
|
message?: Pick<CustomMessage, "customType" | "content" | "display" | "details" | "attribution">;
|
|
@@ -896,33 +778,13 @@ export interface BeforeAgentStartEventResult {
|
|
|
896
778
|
systemPrompt?: string[];
|
|
897
779
|
}
|
|
898
780
|
|
|
899
|
-
export
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
export interface SessionBeforeCompactResult {
|
|
909
|
-
cancel?: boolean;
|
|
910
|
-
compaction?: CompactionResult;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
export interface SessionCompactingResult {
|
|
914
|
-
context?: string[];
|
|
915
|
-
prompt?: string;
|
|
916
|
-
preserveData?: Record<string, unknown>;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
export interface SessionBeforeTreeResult {
|
|
920
|
-
cancel?: boolean;
|
|
921
|
-
summary?: {
|
|
922
|
-
summary: string;
|
|
923
|
-
details?: unknown;
|
|
924
|
-
};
|
|
925
|
-
}
|
|
781
|
+
export type {
|
|
782
|
+
SessionBeforeBranchResult,
|
|
783
|
+
SessionBeforeCompactResult,
|
|
784
|
+
SessionBeforeSwitchResult,
|
|
785
|
+
SessionBeforeTreeResult,
|
|
786
|
+
SessionCompactingResult,
|
|
787
|
+
} from "../shared-events";
|
|
926
788
|
|
|
927
789
|
// ============================================================================
|
|
928
790
|
// Message Rendering
|
|
@@ -942,6 +804,9 @@ export type MessageRenderer<T = unknown> = (
|
|
|
942
804
|
// Command Registration
|
|
943
805
|
// ============================================================================
|
|
944
806
|
|
|
807
|
+
// fallow-ignore-next-line code-duplication
|
|
808
|
+
// Parallel to HookAPI's RegisteredCommand: extensions add
|
|
809
|
+
// `getArgumentCompletions` and bind handlers to ExtensionCommandContext.
|
|
945
810
|
export interface RegisteredCommand {
|
|
946
811
|
name: string;
|
|
947
812
|
description?: string;
|
|
@@ -1022,6 +887,7 @@ export interface ExtensionAPI {
|
|
|
1022
887
|
on(event: "auto_retry_end", handler: ExtensionHandler<AutoRetryEndEvent>): void;
|
|
1023
888
|
on(event: "ttsr_triggered", handler: ExtensionHandler<TtsrTriggeredEvent>): void;
|
|
1024
889
|
on(event: "todo_reminder", handler: ExtensionHandler<TodoReminderEvent>): void;
|
|
890
|
+
on(event: "goal_updated", handler: ExtensionHandler<GoalUpdatedEvent>): void;
|
|
1025
891
|
on(event: "credential_disabled", handler: ExtensionHandler<CredentialDisabledEvent>): void;
|
|
1026
892
|
on(event: "input", handler: ExtensionHandler<InputEvent, InputEventResult>): void;
|
|
1027
893
|
on(event: "tool_call", handler: ExtensionHandler<ToolCallEvent, ToolCallEventResult>): void;
|