@gajae-code/coding-agent 0.16.3 → 0.16.6
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 +113 -0
- package/dist/types/capability/types.d.ts +4 -0
- package/dist/types/cli/args.d.ts +2 -2
- package/dist/types/cli/customize-doctor.d.ts +22 -0
- package/dist/types/cli/root-flags.d.ts +4 -2
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/commands/launch.d.ts +1 -1
- package/dist/types/config/autorouting-tier-map.d.ts +3 -0
- package/dist/types/config/file-lock.d.ts +31 -3
- package/dist/types/config/model-registry.d.ts +4 -0
- package/dist/types/config/model-resolver.d.ts +9 -0
- package/dist/types/config/settings-schema.d.ts +29 -1
- package/dist/types/coordinator-mcp/question-state.d.ts +7 -0
- package/dist/types/coordinator-mcp/server.d.ts +7 -0
- package/dist/types/discovery/claude-plugins.d.ts +3 -1
- package/dist/types/discovery/helpers.d.ts +35 -0
- package/dist/types/exec/bash-executor.d.ts +17 -1
- package/dist/types/exec/bash-shell-guardian.d.ts +15 -0
- package/dist/types/exec/bash-shell-runtime-entry.d.ts +2 -0
- package/dist/types/exec/bash-shell-signals.d.ts +2 -0
- package/dist/types/exec/bash-shell-supervisor-entry.d.ts +1 -0
- package/dist/types/exec/bash-shell-supervisor.d.ts +10 -0
- package/dist/types/exec/bash-shell-worker-entry.d.ts +2 -0
- package/dist/types/exec/bash-shell-worker-protocol.d.ts +63 -0
- package/dist/types/exec/bash-shell-worker.d.ts +1 -0
- package/dist/types/exec/isolated-shell.d.ts +19 -0
- package/dist/types/extensibility/extensions/function-hooks-internal.d.ts +9 -0
- package/dist/types/extensibility/extensions/function-hooks.d.ts +169 -0
- package/dist/types/extensibility/extensions/index.d.ts +1 -0
- package/dist/types/extensibility/extensions/runner.d.ts +46 -6
- package/dist/types/extensibility/extensions/types.d.ts +16 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +3 -1
- package/dist/types/extensibility/gjc-plugins/constrained-hooks.d.ts +35 -2
- package/dist/types/extensibility/gjc-plugins/mcp-policy.d.ts +16 -0
- package/dist/types/extensibility/gjc-plugins/paths.d.ts +2 -0
- package/dist/types/extensibility/gjc-plugins/types.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +4 -0
- package/dist/types/extensibility/runtime-skill-discovery.d.ts +5 -2
- package/dist/types/extensibility/shared-events.d.ts +1 -1
- package/dist/types/extensibility/skill-management.d.ts +9 -4
- package/dist/types/extensibility/skills.d.ts +2 -0
- package/dist/types/gjc-runtime/empty-delete-gc.d.ts +4 -1
- package/dist/types/gjc-runtime/linux-proc.d.ts +2 -0
- package/dist/types/gjc-runtime/session-state-lock.d.ts +14 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +41 -3
- package/dist/types/gjc-runtime/ultragoal-succession.d.ts +251 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -2
- package/dist/types/modes/components/bash-execution.d.ts +1 -0
- package/dist/types/modes/components/execution-shared.d.ts +1 -0
- package/dist/types/modes/components/settings-selector.d.ts +6 -1
- package/dist/types/modes/components/status-line/command.d.ts +35 -0
- package/dist/types/modes/components/status-line/index.d.ts +1 -0
- package/dist/types/modes/components/status-line/types.d.ts +5 -0
- package/dist/types/modes/components/tool-status-header.d.ts +14 -0
- package/dist/types/modes/controllers/event-controller.d.ts +6 -0
- package/dist/types/modes/interactive-mode.d.ts +3 -0
- package/dist/types/modes/types.d.ts +7 -0
- package/dist/types/runtime-mcp/client.d.ts +9 -1
- package/dist/types/runtime-mcp/manager.d.ts +7 -1
- package/dist/types/runtime-mcp/pool.d.ts +22 -3
- package/dist/types/runtime-mcp/transports/stdio.d.ts +0 -4
- package/dist/types/runtime-mcp/types.d.ts +22 -0
- package/dist/types/sdk/broker/ensure.d.ts +32 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +0 -1
- package/dist/types/sdk/broker/lifecycle.d.ts +6 -0
- package/dist/types/sdk/broker/startup-failure.d.ts +4 -1
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +2 -0
- package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +12 -0
- package/dist/types/sdk/bus/chat-effect-journal.d.ts +17 -2
- package/dist/types/sdk/bus/conversation-store.d.ts +11 -0
- package/dist/types/sdk/bus/lifecycle-commands.d.ts +8 -8
- package/dist/types/sdk/bus/slack-daemon.d.ts +1 -1
- package/dist/types/sdk/bus/slack-live-provider.d.ts +6 -0
- package/dist/types/sdk/bus/slack-provider.d.ts +12 -0
- package/dist/types/sdk/bus/topic-registry.d.ts +8 -0
- package/dist/types/sdk/client/client.d.ts +6 -0
- package/dist/types/sdk/host/host.d.ts +3 -1
- package/dist/types/sdk/host/session-runtime.d.ts +26 -1
- package/dist/types/sdk/lifecycle/service.d.ts +1 -0
- package/dist/types/sdk/router/session-router.d.ts +10 -2
- package/dist/types/sdk/session-api-key.d.ts +26 -0
- package/dist/types/sdk/session.d.ts +5 -1
- package/dist/types/sdk/transport/serve-cli.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +11 -0
- package/dist/types/session/fallback-chain-controller.d.ts +15 -0
- package/dist/types/session/internal/managed-session-storage.d.ts +7 -0
- package/dist/types/session/messages.d.ts +1 -0
- package/dist/types/session/session-manager.d.ts +3 -1
- package/dist/types/setup/paseo/announce.d.ts +112 -0
- package/dist/types/setup/paseo/setup-deps.d.ts +2 -1
- package/dist/types/skill-state/canonical-skills.d.ts +4 -0
- package/dist/types/system-prompt.d.ts +10 -0
- package/dist/types/task/executor.d.ts +5 -1
- package/dist/types/tools/bash.d.ts +1 -0
- package/dist/types/tools/fetch.d.ts +7 -0
- package/dist/types/tools/github-cache.d.ts +2 -1
- package/dist/types/tools/index.d.ts +10 -0
- package/dist/types/tools/path-utils.d.ts +2 -0
- package/dist/types/tools/search.d.ts +6 -0
- package/package.json +9 -7
- package/scripts/capture-status-line-custom-editor-showcase.ts +151 -0
- package/scripts/generate-sdk-operation-inventory.ts +11 -0
- package/scripts/verify-status-line-custom-editor-showcase.ts +309 -0
- package/src/capability/index.ts +14 -2
- package/src/capability/types.ts +4 -0
- package/src/cli/args.ts +20 -9
- package/src/cli/customize-doctor.ts +155 -12
- package/src/cli/root-flags.ts +5 -3
- package/src/cli.ts +22 -0
- package/src/commands/sdk.ts +74 -31
- package/src/config/autorouting-tier-map.ts +1 -0
- package/src/config/file-lock-gc.ts +40 -2
- package/src/config/file-lock.ts +379 -31
- package/src/config/model-preset-registry.ts +120 -19
- package/src/config/model-profiles.ts +40 -0
- package/src/config/model-registry.ts +73 -23
- package/src/config/model-resolver.ts +48 -0
- package/src/config/settings-schema.ts +33 -1
- package/src/config/settings.ts +1 -0
- package/src/coordinator-mcp/question-state.ts +33 -2
- package/src/coordinator-mcp/server.ts +477 -101
- package/src/crash/sanitize.ts +1 -1
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/models/catalog.ts +11 -11
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/register.ts +13 -2
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +22 -0
- package/src/discovery/builtin.ts +52 -55
- package/src/discovery/claude-plugins.ts +12 -4
- package/src/discovery/helpers.ts +307 -34
- package/src/exec/bash-executor.ts +330 -50
- package/src/exec/bash-shell-guardian.ts +388 -0
- package/src/exec/bash-shell-runtime-entry.ts +5 -0
- package/src/exec/bash-shell-signals.ts +29 -0
- package/src/exec/bash-shell-supervisor-entry.ts +3 -0
- package/src/exec/bash-shell-supervisor.ts +359 -0
- package/src/exec/bash-shell-worker-entry.ts +5 -0
- package/src/exec/bash-shell-worker-protocol.ts +36 -0
- package/src/exec/bash-shell-worker.ts +116 -0
- package/src/exec/isolated-shell.ts +393 -0
- package/src/extensibility/extensions/function-hooks-internal.ts +73 -0
- package/src/extensibility/extensions/function-hooks.ts +959 -0
- package/src/extensibility/extensions/index.ts +22 -0
- package/src/extensibility/extensions/loader.ts +53 -2
- package/src/extensibility/extensions/runner.ts +895 -264
- package/src/extensibility/extensions/types.ts +42 -0
- package/src/extensibility/extensions/wrapper.ts +56 -15
- package/src/extensibility/gjc-plugins/compiler.ts +228 -60
- package/src/extensibility/gjc-plugins/constrained-hooks.ts +321 -23
- package/src/extensibility/gjc-plugins/installer.ts +13 -12
- package/src/extensibility/gjc-plugins/mcp-policy.ts +81 -52
- package/src/extensibility/gjc-plugins/paths.ts +13 -0
- package/src/extensibility/gjc-plugins/registry.ts +113 -1
- package/src/extensibility/gjc-plugins/runtime-adapters.ts +758 -16
- package/src/extensibility/gjc-plugins/runtime-quarantine.ts +20 -2
- package/src/extensibility/gjc-plugins/schema.ts +121 -4
- package/src/extensibility/gjc-plugins/types.ts +25 -0
- package/src/extensibility/hooks/loader.ts +133 -16
- package/src/extensibility/hooks/types.ts +28 -0
- package/src/extensibility/runtime-skill-discovery.ts +149 -190
- package/src/extensibility/shared-events.ts +1 -1
- package/src/extensibility/skill-management.ts +200 -52
- package/src/extensibility/skills.ts +73 -25
- package/src/gjc-runtime/empty-delete-gc.ts +94 -4
- package/src/gjc-runtime/gc-runtime.ts +29 -0
- package/src/gjc-runtime/linux-proc.ts +14 -0
- package/src/gjc-runtime/repository-binding.ts +1 -1
- package/src/gjc-runtime/session-state-lock.ts +143 -10
- package/src/gjc-runtime/session-state-sidecar.ts +27 -11
- package/src/gjc-runtime/state-writer.ts +30 -29
- package/src/gjc-runtime/ultragoal-runtime.ts +189 -47
- package/src/gjc-runtime/ultragoal-succession.ts +1667 -0
- package/src/gjc-runtime/workflow-manifest.generated.json +52 -1
- package/src/gjc-runtime/workflow-manifest.ts +16 -0
- package/src/harness-control-plane/session-lease.ts +2 -2
- package/src/internal-urls/docs-index.generated.ts +12 -12
- package/src/lsp/config.ts +10 -3
- package/src/lsp/index.ts +1 -1
- package/src/lsp/path-trust.ts +69 -14
- package/src/main.ts +78 -35
- package/src/modes/DESIGN.md +54 -0
- package/src/modes/acp/acp-agent.ts +16 -3
- package/src/modes/components/assistant-message.ts +22 -9
- package/src/modes/components/bash-execution.ts +4 -1
- package/src/modes/components/execution-shared.ts +4 -1
- package/src/modes/components/model-selector.ts +166 -33
- package/src/modes/components/session-observer-overlay.ts +1 -1
- package/src/modes/components/settings-selector.ts +1075 -235
- package/src/modes/components/status-line/command.ts +190 -0
- package/src/modes/components/status-line/index.ts +1 -0
- package/src/modes/components/status-line/segments.ts +32 -5
- package/src/modes/components/status-line/types.ts +5 -0
- package/src/modes/components/tool-status-header.ts +396 -22
- package/src/modes/controllers/command-controller.ts +3 -0
- package/src/modes/controllers/event-controller.ts +151 -7
- package/src/modes/controllers/extension-ui-controller.ts +1 -0
- package/src/modes/controllers/input-controller.ts +6 -3
- package/src/modes/controllers/selector-controller.ts +21 -0
- package/src/modes/interactive-mode.ts +53 -6
- package/src/modes/print-mode.ts +5 -1
- package/src/modes/prompt-action-autocomplete.ts +54 -27
- package/src/modes/runtime-init.ts +2 -0
- package/src/modes/types.ts +17 -3
- package/src/modes/utils/ui-helpers.ts +2 -0
- package/src/prompts/system/system-prompt.md +8 -0
- package/src/prompts/tools/search.md +2 -0
- package/src/prompts/tools/subagent.md +1 -0
- package/src/runtime-mcp/client.ts +60 -17
- package/src/runtime-mcp/manager.ts +189 -14
- package/src/runtime-mcp/pool.test.ts +218 -0
- package/src/runtime-mcp/pool.ts +224 -23
- package/src/runtime-mcp/transports/stdio.ts +158 -24
- package/src/runtime-mcp/types.ts +24 -0
- package/src/sdk/broker/broker.ts +124 -32
- package/src/sdk/broker/ensure.ts +248 -41
- package/src/sdk/broker/lifecycle-ledger.ts +7 -17
- package/src/sdk/broker/lifecycle.ts +56 -6
- package/src/sdk/broker/startup-failure.ts +15 -6
- package/src/sdk/bus/chat-daemon-control.ts +3 -1
- package/src/sdk/bus/chat-daemon-runtime.ts +72 -6
- package/src/sdk/bus/chat-effect-journal.ts +132 -7
- package/src/sdk/bus/conversation-store.ts +29 -0
- package/src/sdk/bus/lifecycle-commands.ts +17 -11
- package/src/sdk/bus/slack-conversation.ts +1 -0
- package/src/sdk/bus/slack-daemon.ts +478 -49
- package/src/sdk/bus/slack-live-provider.ts +12 -0
- package/src/sdk/bus/slack-provider.ts +5 -0
- package/src/sdk/bus/telegram-daemon.ts +16 -2
- package/src/sdk/bus/topic-registry.ts +19 -0
- package/src/sdk/cli/master-cli.ts +1 -1
- package/src/sdk/cli/session-cli.ts +11 -8
- package/src/sdk/client/client.ts +66 -17
- package/src/sdk/host/host.ts +29 -9
- package/src/sdk/host/query/revision-store.ts +19 -13
- package/src/sdk/host/reverse-leases.ts +7 -4
- package/src/sdk/host/session-runtime.test.ts +52 -10
- package/src/sdk/host/session-runtime.ts +383 -44
- package/src/sdk/lifecycle/service.ts +4 -0
- package/src/sdk/protocol/operation-inventory.generated.json +77 -0
- package/src/sdk/router/session-router.ts +89 -38
- package/src/sdk/session-api-key.ts +94 -0
- package/src/sdk/session.ts +228 -55
- package/src/sdk/transport/relay.ts +35 -13
- package/src/sdk/transport/serve-cli.ts +3 -3
- package/src/session/agent-session.ts +240 -90
- package/src/session/contribution-prep.ts +214 -21
- package/src/session/fallback-chain-controller.ts +38 -0
- package/src/session/internal/managed-session-storage.ts +19 -5
- package/src/session/messages.ts +5 -0
- package/src/session/session-manager.ts +29 -5
- package/src/session-import/redact.ts +5 -1
- package/src/setup/paseo/announce.ts +456 -0
- package/src/setup/paseo/setup-deps.ts +15 -3
- package/src/skill-state/canonical-skills.ts +12 -0
- package/src/skills/skills.test.ts +41 -21
- package/src/slash-commands/builtin-registry.ts +1 -0
- package/src/system-prompt.ts +29 -3
- package/src/task/executor.ts +7 -1
- package/src/task/index.ts +21 -4
- package/src/tools/bash.ts +63 -19
- package/src/tools/cron.ts +1 -1
- package/src/tools/fetch.ts +29 -1
- package/src/tools/gh.ts +26 -3
- package/src/tools/github-cache.ts +68 -16
- package/src/tools/index.ts +10 -0
- package/src/tools/job.ts +21 -4
- package/src/tools/monitor.ts +8 -2
- package/src/tools/path-utils.ts +7 -0
- package/src/tools/read.ts +14 -2
- package/src/tools/render-utils.ts +1 -3
- package/src/tools/resource-gc.ts +28 -8
- package/src/tools/search.ts +116 -58
- package/src/tools/skill-discovery.ts +5 -0
- package/src/tools/skill.ts +37 -2
- package/src/tools/subagent.ts +6 -3
- package/src/tools/tool-catalog.generated.ts +10 -3
- package/src/tools/ultragoal-ask-guard.ts +2 -2
- package/src/web/insane/bridge.ts +113 -23
- package/src/web/search/providers/perplexity.ts +102 -41
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type BashShellWorkerResponse } from "./bash-shell-worker-protocol";
|
|
2
|
+
export declare function createUtf8LineDecoder(onLine: (line: string) => void, options?: {
|
|
3
|
+
maxBufferedBytes?: number;
|
|
4
|
+
onOverflow?: () => void;
|
|
5
|
+
}): {
|
|
6
|
+
push(chunk: Uint8Array): void;
|
|
7
|
+
end(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseAuthenticatedWorkerResponse(line: string, protocolToken: string | undefined): BashShellWorkerResponse | undefined;
|
|
10
|
+
export declare function runBashShellSupervisor(): Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MinimizerOptions, ShellOptions, ShellRunOptions, ShellRunResult } from "@gajae-code/natives";
|
|
2
|
+
export declare const BASH_SHELL_WORKER_ARG = "--internal-bash-shell-worker";
|
|
3
|
+
export declare const BASH_SHELL_SUPERVISOR_ARG = "--internal-bash-shell-supervisor";
|
|
4
|
+
export declare const BASH_SHELL_RUNTIME_ARG = "--internal-bash-shell-runtime";
|
|
5
|
+
export type IsolatedShellOptions = Pick<ShellOptions, "sessionEnv" | "snapshotPath"> & {
|
|
6
|
+
minimizer?: MinimizerOptions;
|
|
7
|
+
containedProcessGroup?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type IsolatedShellRunOptions = Omit<ShellRunOptions, "signal">;
|
|
10
|
+
export type IsolatedShellRunResult = ShellRunResult & {
|
|
11
|
+
/** POSIX signal that terminated the isolated shell worker, when applicable. */
|
|
12
|
+
signal?: string;
|
|
13
|
+
};
|
|
14
|
+
export type BashShellWorkerRequest = {
|
|
15
|
+
type: "init";
|
|
16
|
+
token: string;
|
|
17
|
+
options?: IsolatedShellOptions;
|
|
18
|
+
ownershipLedger?: {
|
|
19
|
+
path: string;
|
|
20
|
+
token: string;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
type: "run";
|
|
24
|
+
token: string;
|
|
25
|
+
id: number;
|
|
26
|
+
options: IsolatedShellRunOptions;
|
|
27
|
+
} | {
|
|
28
|
+
type: "abort";
|
|
29
|
+
token: string;
|
|
30
|
+
id: number;
|
|
31
|
+
} | {
|
|
32
|
+
type: "close";
|
|
33
|
+
token: string;
|
|
34
|
+
id: number;
|
|
35
|
+
};
|
|
36
|
+
export type BashShellWorkerResponse = {
|
|
37
|
+
type: "ready";
|
|
38
|
+
token: string;
|
|
39
|
+
supervisorPid?: number;
|
|
40
|
+
} | {
|
|
41
|
+
type: "chunk";
|
|
42
|
+
token: string;
|
|
43
|
+
id: number;
|
|
44
|
+
chunk: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "result";
|
|
47
|
+
token: string;
|
|
48
|
+
id: number;
|
|
49
|
+
result: IsolatedShellRunResult;
|
|
50
|
+
} | {
|
|
51
|
+
type: "void";
|
|
52
|
+
token: string;
|
|
53
|
+
id: number;
|
|
54
|
+
} | {
|
|
55
|
+
type: "retiring";
|
|
56
|
+
token: string;
|
|
57
|
+
message: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "error";
|
|
60
|
+
token: string;
|
|
61
|
+
id?: number;
|
|
62
|
+
message: string;
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runBashShellWorker(): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ShellRunOptions } from "@gajae-code/natives";
|
|
2
|
+
import { type IsolatedShellOptions, type IsolatedShellRunResult } from "./bash-shell-worker-protocol";
|
|
3
|
+
export interface IsolatedShellLifecycle {
|
|
4
|
+
onTerminal?: (shell: IsolatedShell) => void;
|
|
5
|
+
workerArgv?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class IsolatedShell {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options?: IsolatedShellOptions, lifecycle?: IsolatedShellLifecycle);
|
|
10
|
+
isTerminal(): boolean;
|
|
11
|
+
ready(): Promise<void>;
|
|
12
|
+
supervisorPid(): number | undefined;
|
|
13
|
+
isRunSignalActive(signal: AbortSignal): boolean;
|
|
14
|
+
wasRunSignalDispatched(signal: AbortSignal): boolean;
|
|
15
|
+
run(options: ShellRunOptions, onChunk?: (error: Error | null, chunk: string) => void): Promise<IsolatedShellRunResult>;
|
|
16
|
+
abort(): Promise<void>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function smokeTestIsolatedShell(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FunctionHookRegistration } from "./function-hooks";
|
|
2
|
+
export type TaggedFunctionHookHandler = (...args: unknown[]) => Promise<unknown>;
|
|
3
|
+
export declare function tagExtensionHandlerRegistrationOrder<T extends (...args: never[]) => unknown>(handler: T, registrationOrder: number): T;
|
|
4
|
+
export declare function wrapExtensionHandlerRegistration<T extends (...args: never[]) => unknown>(handler: T, registrationOrder: number): T;
|
|
5
|
+
export declare function getExtensionHandlerRegistrationOrder(value: unknown): number | undefined;
|
|
6
|
+
export declare function tagFunctionHookHandler(registration: FunctionHookRegistration): TaggedFunctionHookHandler;
|
|
7
|
+
export declare function getFunctionHookRegistration(value: unknown): FunctionHookRegistration | undefined;
|
|
8
|
+
/** Host-only root-confined read used by the mediated filesystem capability. */
|
|
9
|
+
export declare function readConstrainedFunctionHookFile(filePath: string, cwd: string, roots: readonly string[]): Promise<string>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { ImageContent, TextContent } from "@gajae-code/ai/core";
|
|
2
|
+
import type { CustomMessage } from "../../session/messages";
|
|
3
|
+
import type { ExtensionEvent, ExtensionSessionMetadata, ExtensionUIContext } from "./types";
|
|
4
|
+
/** Function hooks use the existing extension event stream; `*` is observation middleware. */
|
|
5
|
+
export type FunctionHookEventType = ExtensionEvent["type"] | "*";
|
|
6
|
+
export type FunctionHookPayloadFor<T extends FunctionHookEventType> = T extends "*" ? ExtensionEvent : Extract<ExtensionEvent, {
|
|
7
|
+
type: T;
|
|
8
|
+
}>;
|
|
9
|
+
/** Narrow capability vocabulary. Parent names expand only to their children. */
|
|
10
|
+
export type FunctionHookCapability = "tool" | "tool.inspect" | "tool.transform" | "tool.deny" | "ui" | "ui.status" | "ui.widget" | "ui.notify" | "ui.transform" | "session" | "session.read" | "session.message" | "session.deny" | "audit" | "audit.append" | "network" | "network.fetch" | "filesystem" | "filesystem.read";
|
|
11
|
+
export declare const FUNCTION_HOOK_CAPABILITIES: readonly FunctionHookCapability[];
|
|
12
|
+
export type FunctionHookOperation = Exclude<FunctionHookCapability, "tool" | "ui" | "session" | "audit" | "network" | "filesystem">;
|
|
13
|
+
export interface FunctionHookGrantInput {
|
|
14
|
+
capabilities?: readonly FunctionHookCapability[];
|
|
15
|
+
networkDestinations?: readonly string[];
|
|
16
|
+
filesystemRoots?: readonly string[];
|
|
17
|
+
/** An attenuation boundary can only remove downstream operations. */
|
|
18
|
+
attenuateDownstream?: readonly FunctionHookCapability[];
|
|
19
|
+
}
|
|
20
|
+
export interface FunctionHookGrant {
|
|
21
|
+
readonly capabilities: readonly FunctionHookCapability[];
|
|
22
|
+
readonly networkDestinations: readonly string[];
|
|
23
|
+
readonly filesystemRoots: readonly string[];
|
|
24
|
+
readonly attenuateDownstream?: readonly FunctionHookCapability[];
|
|
25
|
+
}
|
|
26
|
+
export interface FunctionHookRegistrationOptions extends FunctionHookGrantInput {
|
|
27
|
+
target?: string;
|
|
28
|
+
registrationId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface FunctionHookProvenance {
|
|
31
|
+
readonly source: "builtin" | "user" | "project" | "extension" | "plugin-bundle";
|
|
32
|
+
readonly scope?: "user" | "project" | "native";
|
|
33
|
+
readonly plugin?: string;
|
|
34
|
+
readonly extensionId?: string;
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly activationGeneration?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface FunctionHookInvocation<TEvent extends ExtensionEvent = ExtensionEvent> {
|
|
39
|
+
readonly eventId: string;
|
|
40
|
+
readonly correlationId: string;
|
|
41
|
+
readonly eventType: TEvent["type"];
|
|
42
|
+
readonly provenance: FunctionHookProvenance;
|
|
43
|
+
readonly registrationOrder: number;
|
|
44
|
+
readonly payload: Readonly<TEvent>;
|
|
45
|
+
readonly signal: AbortSignal;
|
|
46
|
+
}
|
|
47
|
+
export interface FunctionHookMessage {
|
|
48
|
+
customType: string;
|
|
49
|
+
content: string | (TextContent | ImageContent)[];
|
|
50
|
+
display?: boolean;
|
|
51
|
+
details?: unknown;
|
|
52
|
+
attribution?: CustomMessage["attribution"];
|
|
53
|
+
triggerTurn?: boolean;
|
|
54
|
+
deliverAs?: "steer" | "followUp";
|
|
55
|
+
}
|
|
56
|
+
export interface FunctionHookAuditRecord {
|
|
57
|
+
readonly sequence: number;
|
|
58
|
+
readonly eventId: string;
|
|
59
|
+
readonly correlationId: string;
|
|
60
|
+
readonly eventType: string;
|
|
61
|
+
readonly action: "continue" | "deny" | "return" | "error" | "timeout";
|
|
62
|
+
readonly registrationOrder: number;
|
|
63
|
+
readonly provenance: {
|
|
64
|
+
source: FunctionHookProvenance["source"];
|
|
65
|
+
scope?: FunctionHookProvenance["scope"];
|
|
66
|
+
plugin?: string;
|
|
67
|
+
extensionId?: string;
|
|
68
|
+
path: string;
|
|
69
|
+
};
|
|
70
|
+
readonly reason?: string;
|
|
71
|
+
readonly payloadHash?: string;
|
|
72
|
+
readonly evidence?: unknown;
|
|
73
|
+
readonly requestedCapabilities?: readonly FunctionHookCapability[];
|
|
74
|
+
readonly effectiveCapabilities?: readonly FunctionHookCapability[];
|
|
75
|
+
readonly capabilityHash?: string;
|
|
76
|
+
readonly activationGeneration?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface FunctionHookCapabilities {
|
|
79
|
+
readonly tool?: {
|
|
80
|
+
readonly canInspect: boolean;
|
|
81
|
+
readonly canTransform: boolean;
|
|
82
|
+
readonly canDeny: boolean;
|
|
83
|
+
};
|
|
84
|
+
readonly ui?: {
|
|
85
|
+
readonly canTransform: boolean;
|
|
86
|
+
readonly setStatus: (key: string, text: string | undefined) => void;
|
|
87
|
+
readonly setWidget: (key: string, content: string[] | undefined) => void;
|
|
88
|
+
readonly notify: (message: string, type?: "info" | "warning" | "error") => void;
|
|
89
|
+
};
|
|
90
|
+
readonly session?: {
|
|
91
|
+
readonly canRead: boolean;
|
|
92
|
+
readonly canDeny: boolean;
|
|
93
|
+
readonly metadata: Readonly<ExtensionSessionMetadata> | undefined;
|
|
94
|
+
readonly emitMessage: (message: FunctionHookMessage, options?: {
|
|
95
|
+
triggerTurn?: boolean;
|
|
96
|
+
deliverAs?: "steer" | "followUp";
|
|
97
|
+
}) => void;
|
|
98
|
+
};
|
|
99
|
+
readonly audit?: {
|
|
100
|
+
readonly append: (evidence: Record<string, unknown>) => void;
|
|
101
|
+
};
|
|
102
|
+
readonly network?: {
|
|
103
|
+
readonly fetch: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
104
|
+
};
|
|
105
|
+
readonly filesystem?: {
|
|
106
|
+
readonly readFile: (filePath: string) => Promise<string>;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export type FunctionHookResult<TEvent extends ExtensionEvent = ExtensionEvent> = {
|
|
110
|
+
action: "continue";
|
|
111
|
+
event?: TEvent;
|
|
112
|
+
} | {
|
|
113
|
+
action: "deny";
|
|
114
|
+
reason: string;
|
|
115
|
+
} | {
|
|
116
|
+
action: "return";
|
|
117
|
+
value: unknown;
|
|
118
|
+
};
|
|
119
|
+
export type FunctionHookNext<TEvent extends ExtensionEvent = ExtensionEvent> = (event?: TEvent) => Promise<FunctionHookResult<TEvent>>;
|
|
120
|
+
export type FunctionHook<TEvent extends ExtensionEvent = ExtensionEvent> = (invocation: FunctionHookInvocation<TEvent>, capabilities: FunctionHookCapabilities, next: FunctionHookNext<TEvent>) => FunctionHookResult<TEvent> | undefined | Promise<FunctionHookResult<TEvent> | undefined>;
|
|
121
|
+
export interface FunctionHookRegistration {
|
|
122
|
+
readonly event: FunctionHookEventType;
|
|
123
|
+
readonly target?: string;
|
|
124
|
+
readonly registrationId?: string;
|
|
125
|
+
readonly handler: FunctionHook;
|
|
126
|
+
readonly grant: FunctionHookGrant;
|
|
127
|
+
readonly provenance: FunctionHookProvenance;
|
|
128
|
+
readonly registrationOrder?: number;
|
|
129
|
+
}
|
|
130
|
+
export declare function validateFunctionHookTarget(target: string): string;
|
|
131
|
+
export declare function normalizeFunctionHookGrant(input?: FunctionHookGrantInput): FunctionHookGrant;
|
|
132
|
+
export declare function compatibilityFunctionHookGrant(event: string): FunctionHookGrant;
|
|
133
|
+
export declare function functionHookGrantOperations(grant: FunctionHookGrant): ReadonlySet<FunctionHookOperation>;
|
|
134
|
+
export declare function intersectFunctionHookGrants(grant: FunctionHookGrant, allowed: FunctionHookGrant | undefined): FunctionHookGrant;
|
|
135
|
+
/** Host-owned ceiling for caller-registered in-process extension and hook middleware. */
|
|
136
|
+
export declare const DEFAULT_EXTENSION_FUNCTION_HOOK_GRANT: FunctionHookGrant;
|
|
137
|
+
export declare function attenuateFunctionHookGrant(grant: FunctionHookGrant, removed: readonly FunctionHookCapability[] | undefined): FunctionHookGrant;
|
|
138
|
+
export declare function functionHookGrantHash(grant: FunctionHookGrant): string;
|
|
139
|
+
/** Bounded JSON-shaped redaction for diagnostics and audit sinks. Accessors are never invoked. */
|
|
140
|
+
export declare function redactFunctionHookValue(value: unknown, depth?: number, seen?: WeakSet<object>): unknown;
|
|
141
|
+
export declare function functionHookPayloadHash(value: unknown): string;
|
|
142
|
+
export declare function isPlainFunctionHookData(value: unknown, seen?: WeakSet<object>): boolean;
|
|
143
|
+
export declare function isSafeFunctionHookValue(value: unknown, seen?: WeakSet<object>): boolean;
|
|
144
|
+
export declare function isValidFunctionHookEventValue(event: ExtensionEvent): boolean;
|
|
145
|
+
export declare function functionHookEventIdentityMatches(original: ExtensionEvent, candidate: ExtensionEvent): boolean;
|
|
146
|
+
export declare function cloneFunctionHookData<T>(value: T): T;
|
|
147
|
+
/** Security-boundary clone for transformed events; never aliases caller-owned data. */
|
|
148
|
+
export declare function cloneFunctionHookDataStrict<T>(value: T): T;
|
|
149
|
+
export interface FunctionHookCapabilityBindings {
|
|
150
|
+
readonly cwd: string;
|
|
151
|
+
readonly ui: ExtensionUIContext;
|
|
152
|
+
readonly sessionMetadata?: ExtensionSessionMetadata;
|
|
153
|
+
readonly isActive?: () => boolean;
|
|
154
|
+
readonly emitMessage: (message: FunctionHookMessage, options?: {
|
|
155
|
+
triggerTurn?: boolean;
|
|
156
|
+
deliverAs?: "steer" | "followUp";
|
|
157
|
+
}) => void;
|
|
158
|
+
readonly appendAudit: (evidence: Record<string, unknown>) => void;
|
|
159
|
+
readonly fetch: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
160
|
+
readonly readFile: (filePath: string, roots: readonly string[]) => Promise<string>;
|
|
161
|
+
}
|
|
162
|
+
export declare function createFunctionHookCapabilities(grant: FunctionHookGrant, bindings: FunctionHookCapabilityBindings): FunctionHookCapabilities;
|
|
163
|
+
export declare function compatibilityPayloadForFunctionHook(event: ExtensionEvent, grant: FunctionHookGrant, wildcard: boolean): ExtensionEvent;
|
|
164
|
+
export declare function functionHookInspectAllowed(event: ExtensionEvent, grant: FunctionHookGrant, wildcard: boolean): boolean;
|
|
165
|
+
export declare function functionHookTransformAllowed(event: ExtensionEvent, grant: FunctionHookGrant): boolean;
|
|
166
|
+
export declare function functionHookDenyAllowed(event: ExtensionEvent, grant: FunctionHookGrant): boolean;
|
|
167
|
+
export declare function sanitizeFunctionHookReason(reason: unknown, fallback: string): string;
|
|
168
|
+
/** Validate terminal short-circuit values before they enter event-specific host control flow. */
|
|
169
|
+
export declare function isValidFunctionHookReturnValue(event: ExtensionEvent, value: unknown): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Extension system for lifecycle events and custom tools.
|
|
3
3
|
*/
|
|
4
4
|
export type { SlashCommandInfo, SlashCommandLocation, SlashCommandSource } from "../slash-commands";
|
|
5
|
+
export { attenuateFunctionHookGrant, cloneFunctionHookData, compatibilityFunctionHookGrant, createFunctionHookCapabilities, DEFAULT_EXTENSION_FUNCTION_HOOK_GRANT, FUNCTION_HOOK_CAPABILITIES, functionHookDenyAllowed, functionHookEventIdentityMatches, functionHookGrantHash, functionHookGrantOperations, functionHookPayloadHash, functionHookTransformAllowed, intersectFunctionHookGrants, isPlainFunctionHookData, isSafeFunctionHookValue, isValidFunctionHookEventValue, normalizeFunctionHookGrant, redactFunctionHookValue, sanitizeFunctionHookReason, validateFunctionHookTarget, } from "./function-hooks";
|
|
5
6
|
export { discoverAndLoadExtensions, ExtensionRuntimeNotInitializedError, loadExtensionFromFactory, loadExtensions, } from "./loader";
|
|
6
7
|
export * from "./ouroboros-ooo-bridge";
|
|
7
8
|
export * from "./prefix-command-bridge";
|
|
@@ -8,11 +8,14 @@ import type { ModelRegistry } from "../../config/model-registry";
|
|
|
8
8
|
import type { Settings } from "../../config/settings";
|
|
9
9
|
import type { AttemptRecordStore } from "../../session/attempt-record-store";
|
|
10
10
|
import { type SessionManager } from "../../session/session-manager";
|
|
11
|
+
import { type FunctionHookAuditRecord, type FunctionHookRegistration } from "./function-hooks";
|
|
11
12
|
import type { AfterProviderResponseEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, ContextEvent, Extension, ExtensionActions, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFlag, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, InputEvent, InputEventResult, MessageRenderer, RegisteredCommand, RegisteredTool, ResourcesDiscoverEvent, SessionBeforeBranchResult, SessionBeforeCompactResult, SessionBeforeSwitchResult, SessionBeforeTreeResult, SessionCompactingResult, ToolCallEvent, ToolCallEventResult, ToolResultEvent, ToolResultEventResult, UserBashEvent, UserBashEventResult, UserPythonEvent, UserPythonEventResult } from "./types";
|
|
12
13
|
/** Combined result from all before_agent_start handlers */
|
|
13
14
|
interface BeforeAgentStartCombinedResult {
|
|
14
15
|
messages?: NonNullable<BeforeAgentStartEventResult["message"]>[];
|
|
15
16
|
systemPrompt?: string[];
|
|
17
|
+
prompt?: string;
|
|
18
|
+
images?: ImageContent[];
|
|
16
19
|
}
|
|
17
20
|
export type ExtensionErrorListener = (error: ExtensionError) => void;
|
|
18
21
|
/** Bounded timeout for session_shutdown handlers — generous but never infinite. */
|
|
@@ -36,6 +39,24 @@ type RunnerEmitResult<TEvent extends RunnerEmitEvent> = TEvent extends {
|
|
|
36
39
|
} ? SessionBeforeTreeResult | undefined : TEvent extends {
|
|
37
40
|
type: "session.compacting";
|
|
38
41
|
} ? SessionCompactingResult | undefined : undefined;
|
|
42
|
+
type Handler = Extension["handlers"] extends Map<string, Array<infer T>> ? T : never;
|
|
43
|
+
type IndexedHandler = {
|
|
44
|
+
ext: Extension;
|
|
45
|
+
handler: Handler;
|
|
46
|
+
registrationOrder: number;
|
|
47
|
+
};
|
|
48
|
+
export type FunctionHookDispatchResult<TEvent extends ExtensionEvent> = {
|
|
49
|
+
action: "continue";
|
|
50
|
+
event: TEvent;
|
|
51
|
+
transformed?: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
action: "deny";
|
|
54
|
+
reason: string;
|
|
55
|
+
} | {
|
|
56
|
+
action: "return";
|
|
57
|
+
value: unknown;
|
|
58
|
+
};
|
|
59
|
+
export type FunctionHookAuditSink = (record: FunctionHookAuditRecord) => void;
|
|
39
60
|
export type NewSessionHandler = (options?: {
|
|
40
61
|
parentSession?: string;
|
|
41
62
|
setup?: (sessionManager: SessionManager) => Promise<void>;
|
|
@@ -97,6 +118,12 @@ export declare class ExtensionRunner {
|
|
|
97
118
|
onError(listener: ExtensionErrorListener): () => void;
|
|
98
119
|
emitError(error: ExtensionError): void;
|
|
99
120
|
hasHandlers(eventType: string): boolean;
|
|
121
|
+
hasToolResultMediation(toolName: string): boolean;
|
|
122
|
+
/** Return immutable registration metadata in authoritative registration order. */
|
|
123
|
+
getFunctionHookRegistrations(): readonly FunctionHookRegistration[];
|
|
124
|
+
/** Install the optional deterministic audit sink used by hosts and tests. */
|
|
125
|
+
setFunctionHookAuditSink(sink: FunctionHookAuditSink | undefined): void;
|
|
126
|
+
getFunctionHookAudit(): readonly FunctionHookAuditRecord[];
|
|
100
127
|
setAttemptRecordStore(store: AttemptRecordStore): void;
|
|
101
128
|
getMessageRenderer(customType: string): MessageRenderer | undefined;
|
|
102
129
|
getRegisteredCommands(reserved?: Set<string>): RegisteredCommand[];
|
|
@@ -112,9 +139,22 @@ export declare class ExtensionRunner {
|
|
|
112
139
|
*/
|
|
113
140
|
shutdown(): void;
|
|
114
141
|
createCommandContext(): ExtensionCommandContext;
|
|
142
|
+
/** Execute capability-scoped middleware stored in Extension.handlers. */
|
|
143
|
+
emitFunctionHooks<TEvent extends ExtensionEvent>(event: TEvent, options?: {
|
|
144
|
+
signal?: AbortSignal;
|
|
145
|
+
correlationId?: string;
|
|
146
|
+
scope?: AttemptScopeRef;
|
|
147
|
+
legacyHandler?: (handler: IndexedHandler, event: TEvent) => Promise<FunctionHookDispatchResult<TEvent>>;
|
|
148
|
+
}): Promise<FunctionHookDispatchResult<TEvent>>;
|
|
115
149
|
emit<TEvent extends RunnerEmitEvent>(event: TEvent, continueWhile?: () => boolean, scope?: AttemptScopeRef): Promise<RunnerEmitResult<TEvent>>;
|
|
116
|
-
emitToolResult(event: ToolResultEvent, scope?: AttemptScopeRef
|
|
117
|
-
|
|
150
|
+
emitToolResult(event: ToolResultEvent, scope?: AttemptScopeRef, options?: {
|
|
151
|
+
signal?: AbortSignal;
|
|
152
|
+
correlationId?: string;
|
|
153
|
+
}): Promise<ToolResultEventResult | undefined>;
|
|
154
|
+
emitToolCall(event: ToolCallEvent, scope?: AttemptScopeRef, options?: {
|
|
155
|
+
signal?: AbortSignal;
|
|
156
|
+
correlationId?: string;
|
|
157
|
+
}): Promise<ToolCallEventResult | undefined>;
|
|
118
158
|
emitUserBash(event: UserBashEvent): Promise<UserBashEventResult | undefined>;
|
|
119
159
|
emitUserPython(event: UserPythonEvent): Promise<UserPythonEventResult | undefined>;
|
|
120
160
|
private emitUserEvent;
|
|
@@ -134,9 +174,9 @@ export declare class ExtensionRunner {
|
|
|
134
174
|
}>;
|
|
135
175
|
/** Emit input event. Transforms chain, "handled" short-circuits. */
|
|
136
176
|
emitInput(text: string, images: ImageContent[] | undefined, source: "interactive" | "sdk" | "extension"): Promise<InputEventResult>;
|
|
137
|
-
emitContext(messages: AgentMessage[], scope?: AttemptScopeRef): Promise<AgentMessage[]>;
|
|
138
|
-
emitBeforeProviderRequest(payload: unknown, scope?: AttemptScopeRef): Promise<BeforeProviderRequestEventResult>;
|
|
139
|
-
emitAfterProviderResponse(response: ProviderResponseMetadata, _model?: Model, scope?: AttemptScopeRef): Promise<void>;
|
|
140
|
-
emitBeforeAgentStart(prompt: string, images: ImageContent[] | undefined, systemPrompt: string[]): Promise<BeforeAgentStartCombinedResult | undefined>;
|
|
177
|
+
emitContext(messages: AgentMessage[], scope?: AttemptScopeRef, signal?: AbortSignal): Promise<AgentMessage[]>;
|
|
178
|
+
emitBeforeProviderRequest(payload: unknown, scope?: AttemptScopeRef, signal?: AbortSignal): Promise<BeforeProviderRequestEventResult>;
|
|
179
|
+
emitAfterProviderResponse(response: ProviderResponseMetadata, _model?: Model, scope?: AttemptScopeRef, signal?: AbortSignal): Promise<void>;
|
|
180
|
+
emitBeforeAgentStart(prompt: string, images: ImageContent[] | undefined, systemPrompt: string[], signal?: AbortSignal): Promise<BeforeAgentStartCombinedResult | undefined>;
|
|
141
181
|
}
|
|
142
182
|
export {};
|
|
@@ -27,6 +27,7 @@ import type { ExecOptions, ExecResult } from "../../exec/exec";
|
|
|
27
27
|
import type { CustomEditor } from "../../modes/components/custom-editor";
|
|
28
28
|
import type { WorkflowGateEmitter } from "../../modes/shared/agent-wire/workflow-gate-broker";
|
|
29
29
|
import type { Theme } from "../../modes/theme/theme";
|
|
30
|
+
import type { AgentSessionEventListener } from "../../session/agent-session";
|
|
30
31
|
import type { ClientBridge, ClientBridgePermissionOption, ClientBridgePermissionOutcome, ClientBridgePermissionToolCall } from "../../session/client-bridge";
|
|
31
32
|
import type { CustomMessage } from "../../session/messages";
|
|
32
33
|
import type { ReadonlySessionManager, SessionManager } from "../../session/session-manager";
|
|
@@ -34,6 +35,7 @@ import type { BashToolDetails, BashToolInput, FindToolDetails, FindToolInput, Re
|
|
|
34
35
|
import type { EventBus } from "../../utils/event-bus";
|
|
35
36
|
import type { AgentEndEvent, AutoCompactionEndEvent, AutoCompactionStartEvent, AutoRetryEndEvent, AutoRetryStartEvent, ContextEvent, GoalUpdatedEvent, SessionBeforeBranchEvent, SessionBeforeBranchResult, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionBranchEvent, SessionCompactEvent, SessionCompactingEvent, SessionCompactingResult, SessionEvent, SessionShutdownEvent, SessionStartEvent, SessionSwitchEvent, SessionTreeEvent, AgentStartEvent as SharedAgentStartEvent, TodoReminderEvent, ToolCallEventResult, ToolResultEventResult, TtsrTriggeredEvent, TurnEndEvent, TurnStartEvent } from "../shared-events";
|
|
36
37
|
import type { SlashCommandInfo } from "../slash-commands";
|
|
38
|
+
import type { FunctionHook, FunctionHookEventType, FunctionHookPayloadFor, FunctionHookRegistrationOptions } from "./function-hooks";
|
|
37
39
|
export type { AppKeybinding, KeybindingsManager } from "../../config/keybindings";
|
|
38
40
|
export type { ExecOptions, ExecResult } from "../../exec/exec";
|
|
39
41
|
export type { AgentToolResult, AgentToolUpdateCallback };
|
|
@@ -336,6 +338,8 @@ export interface ExtensionContext {
|
|
|
336
338
|
getJobs(): unknown;
|
|
337
339
|
/** Subscribe to foreground-wait folds (`bash_folded`). Returns an unsubscribe function. */
|
|
338
340
|
onJobFold?(listener: (event: JobFoldEvent) => void): () => void;
|
|
341
|
+
/** Observe session events synchronously in producer order. Returns an unsubscribe function. */
|
|
342
|
+
onSessionEvent?(listener: AgentSessionEventListener): () => void;
|
|
339
343
|
/** Typed skill and mode controls exposed to the SDK host. */
|
|
340
344
|
invokeSkill?(name: string, args?: string, options?: {
|
|
341
345
|
onPreflightAccepted?: () => void;
|
|
@@ -489,6 +493,8 @@ export type { AgentEndEvent, TurnEndEvent, TurnStartEvent } from "../shared-even
|
|
|
489
493
|
/** Fired when an agent loop starts. `sdkRunToken` is an internal SDK queue-owner binding. */
|
|
490
494
|
export interface AgentStartEvent extends SharedAgentStartEvent {
|
|
491
495
|
sdkRunToken?: string;
|
|
496
|
+
/** Complete set of SDK queue owners consumed together by this run. */
|
|
497
|
+
sdkRunTokens?: string[];
|
|
492
498
|
}
|
|
493
499
|
/** Fired when an agent run fails before emitting agent_end. The error is the
|
|
494
500
|
* sanitized `{ code, message }` diagnostic from the agent runtime — never the raw
|
|
@@ -796,6 +802,13 @@ export interface ExtensionAPI {
|
|
|
796
802
|
on(event: "tool_result", handler: ExtensionHandler<ToolResultEvent, ToolResultEventResult>): void;
|
|
797
803
|
on(event: "user_bash", handler: ExtensionHandler<UserBashEvent, UserBashEventResult>): void;
|
|
798
804
|
on(event: "user_python", handler: ExtensionHandler<UserPythonEvent, UserPythonEventResult>): void;
|
|
805
|
+
/**
|
|
806
|
+
* Register capability-scoped middleware on the authoritative ExtensionRunner.
|
|
807
|
+
* The host supplies grants; an extension cannot self-grant capabilities.
|
|
808
|
+
* Wildcard registrations receive a redacted payload unless the host explicitly
|
|
809
|
+
* grants a tool inspection/transform capability.
|
|
810
|
+
*/
|
|
811
|
+
registerFunctionHook<T extends FunctionHookEventType>(event: T, handler: FunctionHook<FunctionHookPayloadFor<T>>, options?: FunctionHookRegistrationOptions): void;
|
|
799
812
|
/** Register a tool that the LLM can call. */
|
|
800
813
|
registerTool<TParams extends TSchema = TSchema, TDetails = unknown>(tool: ToolDefinition<TParams, TDetails>): void;
|
|
801
814
|
/** Register a custom command. */
|
|
@@ -1157,6 +1170,8 @@ export interface ExtensionContextActions {
|
|
|
1157
1170
|
getJobs?: () => unknown;
|
|
1158
1171
|
/** Subscribe to foreground-wait folds so the SDK host can publish `bash_folded`. Returns an unsubscribe. */
|
|
1159
1172
|
onJobFold?: (listener: (event: JobFoldEvent) => void) => () => void;
|
|
1173
|
+
/** Ordered, synchronous AgentSession subscription, independent of async extension hooks. */
|
|
1174
|
+
onSessionEvent?: (listener: AgentSessionEventListener) => () => void;
|
|
1160
1175
|
setSdkPermissionProvider?: (provider: ((toolCall: ClientBridgePermissionToolCall, options: ClientBridgePermissionOption[], signal?: AbortSignal) => Promise<ClientBridgePermissionOutcome>) | undefined) => void;
|
|
1161
1176
|
setSdkClientBridge?: (bridge: ClientBridge | undefined) => void;
|
|
1162
1177
|
sdkControl?: (operation: string, input: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
@@ -1214,6 +1229,7 @@ export interface Extension {
|
|
|
1214
1229
|
flags: Map<string, ExtensionFlag>;
|
|
1215
1230
|
shortcuts: Map<KeyId, ExtensionShortcut>;
|
|
1216
1231
|
}
|
|
1232
|
+
export type { FunctionHook, FunctionHookAuditRecord, FunctionHookCapabilities, FunctionHookCapability, FunctionHookEventType, FunctionHookGrant, FunctionHookGrantInput, FunctionHookNext, FunctionHookOperation, FunctionHookPayloadFor, FunctionHookProvenance, FunctionHookRegistration, FunctionHookRegistrationOptions, FunctionHookResult, } from "./function-hooks";
|
|
1217
1233
|
/** Result of loading extensions. */
|
|
1218
1234
|
export interface LoadExtensionsResult {
|
|
1219
1235
|
extensions: Extension[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Tool wrappers for extensions.
|
|
3
3
|
*/
|
|
4
4
|
import type { AgentTool, AgentToolContext, AgentToolUpdateCallback } from "@gajae-code/agent-core";
|
|
5
|
-
import type
|
|
5
|
+
import { type Static, type TSchema } from "@gajae-code/ai/core";
|
|
6
6
|
import type { ExtensionRunner } from "./runner";
|
|
7
7
|
import type { RegisteredTool } from "./types";
|
|
8
8
|
/**
|
|
@@ -44,6 +44,8 @@ export declare class ExtensionToolWrapper<TParameters extends TSchema = TSchema,
|
|
|
44
44
|
label: string;
|
|
45
45
|
strict: boolean;
|
|
46
46
|
constructor(tool: AgentTool<TParameters, TDetails>, runner: ExtensionRunner);
|
|
47
|
+
/** Host composition hook: guards must run inside Function Hook preflight. */
|
|
48
|
+
getInnerTool(): AgentTool<TParameters, TDetails>;
|
|
47
49
|
/**
|
|
48
50
|
* Forward browser mode changes when available.
|
|
49
51
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FunctionHookGrant } from "../extensions/function-hooks";
|
|
1
2
|
import { type SessionQuarantine } from "./session-validation";
|
|
2
3
|
import { type GjcPluginScope } from "./types";
|
|
3
4
|
/**
|
|
@@ -11,10 +12,23 @@ import { type GjcPluginScope } from "./types";
|
|
|
11
12
|
*/
|
|
12
13
|
export interface ConstrainedPluginHook {
|
|
13
14
|
plugin: string;
|
|
15
|
+
scope?: GjcPluginScope;
|
|
16
|
+
extensionId?: string;
|
|
14
17
|
event: string;
|
|
15
18
|
target?: string;
|
|
16
19
|
phase?: "before" | "after";
|
|
17
|
-
handler: (...args:
|
|
20
|
+
handler: (...args: never[]) => unknown;
|
|
21
|
+
grant?: FunctionHookGrant;
|
|
22
|
+
provenance?: {
|
|
23
|
+
source: "plugin-bundle";
|
|
24
|
+
scope: GjcPluginScope;
|
|
25
|
+
plugin: string;
|
|
26
|
+
path: string;
|
|
27
|
+
extensionId: string;
|
|
28
|
+
activationGeneration?: number;
|
|
29
|
+
};
|
|
30
|
+
functionHook?: boolean;
|
|
31
|
+
activationGeneration?: number;
|
|
18
32
|
}
|
|
19
33
|
export interface ConstrainedHookLoadResult {
|
|
20
34
|
hooks: ConstrainedPluginHook[];
|
|
@@ -23,21 +37,39 @@ export interface ConstrainedHookLoadResult {
|
|
|
23
37
|
export interface DeclaredHook {
|
|
24
38
|
plugin: string;
|
|
25
39
|
scope: GjcPluginScope;
|
|
40
|
+
extensionId?: string;
|
|
26
41
|
event: string;
|
|
27
42
|
target?: string;
|
|
28
43
|
phase?: "before" | "after";
|
|
29
44
|
relativePath: string;
|
|
30
45
|
implementationHash?: string;
|
|
46
|
+
capabilities?: string[];
|
|
47
|
+
networkDestinations?: string[];
|
|
48
|
+
filesystemRoots?: string[];
|
|
49
|
+
capabilityHash?: string;
|
|
50
|
+
pluginRoot?: string;
|
|
51
|
+
functionHook?: boolean;
|
|
52
|
+
activationGeneration?: number;
|
|
31
53
|
}
|
|
32
54
|
/** Lazy declaration for one constrained hook. Importing this descriptor is metadata-only. */
|
|
33
55
|
export declare class ConstrainedPluginHookDescriptor {
|
|
34
56
|
readonly plugin: string;
|
|
35
|
-
readonly scope
|
|
57
|
+
readonly scope?: GjcPluginScope;
|
|
58
|
+
readonly extensionId?: string;
|
|
36
59
|
readonly event: string;
|
|
37
60
|
readonly target?: string;
|
|
38
61
|
readonly phase?: "before" | "after";
|
|
39
62
|
readonly relativePath: string;
|
|
40
63
|
readonly implementationHash?: string;
|
|
64
|
+
readonly capabilities?: string[];
|
|
65
|
+
readonly networkDestinations?: string[];
|
|
66
|
+
readonly filesystemRoots?: string[];
|
|
67
|
+
readonly capabilityHash?: string;
|
|
68
|
+
readonly pluginRoot?: string;
|
|
69
|
+
readonly grant: FunctionHookGrant;
|
|
70
|
+
readonly functionHook: boolean;
|
|
71
|
+
readonly activationGeneration?: number;
|
|
72
|
+
readonly persistedFunctionHook?: unknown;
|
|
41
73
|
constructor(input: DeclaredHook);
|
|
42
74
|
load(): Promise<ConstrainedPluginHook>;
|
|
43
75
|
}
|
|
@@ -48,4 +80,5 @@ export declare class ConstrainedPluginHookDescriptor {
|
|
|
48
80
|
*/
|
|
49
81
|
export declare function loadConstrainedPluginHooks(input: {
|
|
50
82
|
cwd: string;
|
|
83
|
+
activationGeneration?: number;
|
|
51
84
|
}): Promise<ConstrainedHookLoadResult>;
|
|
@@ -16,6 +16,22 @@ export declare function assertDnsResolvesPublic(hostname: string, label?: string
|
|
|
16
16
|
export interface StdioPolicyContext {
|
|
17
17
|
pluginRoot: string;
|
|
18
18
|
}
|
|
19
|
+
export interface StdioInvocationTarget {
|
|
20
|
+
kind: "launcher";
|
|
21
|
+
launcher: "node" | "bun";
|
|
22
|
+
entrypoint: string;
|
|
23
|
+
executablePath: string;
|
|
24
|
+
ownedRelativePath: string;
|
|
25
|
+
ownedRelativePaths: string[];
|
|
26
|
+
cwd: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the exact executable file selected by the supported stdio grammar.
|
|
30
|
+
* Bare Node/Bun launchers accept a direct bundled entrypoint as argv[0]; no
|
|
31
|
+
* manifest-controlled runtime options or subcommands precede it. Path-qualified
|
|
32
|
+
* commands are unsupported because they bypass the verified module wrapper.
|
|
33
|
+
*/
|
|
34
|
+
export declare function classifyStdioInvocation(entry: GjcPluginMcpManifestEntry, ctx: StdioPolicyContext): StdioInvocationTarget;
|
|
19
35
|
/** stdio launcher/path confinement policy. */
|
|
20
36
|
export declare function assertStdioAllowed(entry: GjcPluginMcpManifestEntry, ctx: StdioPolicyContext): void;
|
|
21
37
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function gjcPluginUserRoot(): string;
|
|
2
2
|
export declare function gjcPluginProjectRoot(cwd: string): string;
|
|
3
|
+
export declare function gjcPluginSafeDirectoryName(name: string): string;
|
|
4
|
+
export declare function gjcPluginInstallRoot(scope: "user" | "project", cwd: string, name: string): string;
|
|
3
5
|
export declare function rootContainsGjcManifest(dir: string): Promise<boolean>;
|
|
4
6
|
export declare function discoverGjcPluginRoots({ cwd }: {
|
|
5
7
|
cwd: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CanonicalGjcWorkflowSkill } from "../../skill-state/active-state";
|
|
2
|
+
import type { FunctionHookCapability } from "../extensions/function-hooks";
|
|
2
3
|
export declare const GJC_PLUGIN_MANIFEST_FILENAME = "gajae-plugin.json";
|
|
3
4
|
export declare const GJC_PLUGIN_KIND = "gajae-code-plugin";
|
|
4
5
|
export declare const GJC_SUBSKILL_PARENT_SKILLS: readonly ["deep-interview", "ralplan", "ultragoal", "autoresearch"];
|
|
@@ -35,6 +36,10 @@ export interface GjcPluginHookManifestEntry {
|
|
|
35
36
|
phase?: "before" | "after";
|
|
36
37
|
path: string;
|
|
37
38
|
sha256?: string;
|
|
39
|
+
/** Requested capability families; the runtime never grants more than declared. */
|
|
40
|
+
capabilities?: FunctionHookCapability[];
|
|
41
|
+
networkDestinations?: string[];
|
|
42
|
+
filesystemRoots?: string[];
|
|
38
43
|
}
|
|
39
44
|
export type GjcPluginMcpTransport = "stdio" | "http" | "sse";
|
|
40
45
|
export interface GjcPluginMcpManifestEntry {
|
|
@@ -206,6 +211,11 @@ export interface NormalizedHookSurface {
|
|
|
206
211
|
relativePath: string;
|
|
207
212
|
sha256: string;
|
|
208
213
|
implementationHash?: string;
|
|
214
|
+
capabilities?: FunctionHookCapability[];
|
|
215
|
+
networkDestinations?: string[];
|
|
216
|
+
filesystemRoots?: string[];
|
|
217
|
+
capabilityHash?: string;
|
|
218
|
+
functionHook?: boolean;
|
|
209
219
|
}
|
|
210
220
|
export interface NormalizedMcpSurface {
|
|
211
221
|
extensionId: string;
|
|
@@ -406,6 +416,21 @@ export interface GjcRuntimeFinding {
|
|
|
406
416
|
surfaceId: string;
|
|
407
417
|
code: GjcPluginLoadErrorCode;
|
|
408
418
|
message: string;
|
|
419
|
+
decision?: "loaded" | "quarantined" | "blocked" | "error";
|
|
420
|
+
event?: string;
|
|
421
|
+
phase?: "before" | "after";
|
|
422
|
+
requestedCapabilities?: readonly FunctionHookCapability[];
|
|
423
|
+
effectiveCapabilities?: readonly FunctionHookCapability[];
|
|
424
|
+
capabilityHash?: string;
|
|
425
|
+
provenance?: {
|
|
426
|
+
source: "builtin" | "user" | "project" | "extension" | "plugin-bundle";
|
|
427
|
+
scope?: "user" | "project" | "native";
|
|
428
|
+
plugin?: string;
|
|
429
|
+
path?: string;
|
|
430
|
+
extensionId?: string;
|
|
431
|
+
};
|
|
432
|
+
audit?: Record<string, unknown>;
|
|
433
|
+
generation?: number;
|
|
409
434
|
}
|
|
410
435
|
export interface GjcRuntimeSnapshot {
|
|
411
436
|
/** Monotonic activation generation this snapshot describes. */
|
|
@@ -7,8 +7,11 @@ import type { Theme } from "../../modes/theme/theme";
|
|
|
7
7
|
import type { HookMessage } from "../../session/messages";
|
|
8
8
|
import type { ReadonlySessionManager, SessionManager } from "../../session/session-manager";
|
|
9
9
|
import type { BashToolDetails, FindToolDetails, ReadToolDetails, SearchToolDetails } from "../../tools";
|
|
10
|
+
import type { FunctionHook, FunctionHookEventType, FunctionHookPayloadFor, FunctionHookRegistrationOptions } from "../extensions/function-hooks";
|
|
10
11
|
import type { AgentEndEvent, AgentStartEvent, AutoCompactionEndEvent, AutoCompactionStartEvent, AutoRetryEndEvent, AutoRetryStartEvent, ContextEvent, SessionBeforeBranchEvent, SessionBeforeBranchResult, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionBranchEvent, SessionCompactEvent, SessionCompactingEvent, SessionCompactingResult, SessionEvent, SessionShutdownEvent, SessionStartEvent, SessionSwitchEvent, SessionTreeEvent, TodoReminderEvent, ToolCallEventResult, ToolResultEventResult, TtsrTriggeredEvent, TurnEndEvent, TurnStartEvent } from "../shared-events";
|
|
11
12
|
export type { ExecOptions, ExecResult } from "../../exec/exec";
|
|
13
|
+
/** Capability-scoped Function Hooks share the ExtensionRunner event contract. */
|
|
14
|
+
export type { FunctionHook, FunctionHookAuditRecord, FunctionHookCapabilities, FunctionHookCapability, FunctionHookEventType, FunctionHookGrant, FunctionHookGrantInput, FunctionHookNext, FunctionHookOperation, FunctionHookPayloadFor, FunctionHookProvenance, FunctionHookRegistration, FunctionHookRegistrationOptions, FunctionHookResult, } from "../extensions/function-hooks";
|
|
12
15
|
/**
|
|
13
16
|
* UI context for hooks to request interactive UI from the harness.
|
|
14
17
|
* Interactive and headless callers provide their own implementation.
|
|
@@ -340,6 +343,7 @@ export interface HookAPI {
|
|
|
340
343
|
on(event: "todo_reminder", handler: HookHandler<TodoReminderEvent>): void;
|
|
341
344
|
on(event: "tool_call", handler: HookHandler<ToolCallEvent, ToolCallEventResult>): void;
|
|
342
345
|
on(event: "tool_result", handler: HookHandler<ToolResultEvent, ToolResultEventResult>): void;
|
|
346
|
+
registerFunctionHook<T extends FunctionHookEventType>(event: T, handler: FunctionHook<FunctionHookPayloadFor<T>>, options?: FunctionHookRegistrationOptions): void;
|
|
343
347
|
/**
|
|
344
348
|
* Send a custom message to the session. Creates a CustomMessageEntry that
|
|
345
349
|
* participates in LLM context and can be displayed in the TUI.
|