opencode-dux 1.0.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/LICENSE +21 -0
- package/README.md +452 -0
- package/dist/agents/descriptions.d.ts +6 -0
- package/dist/agents/designer.d.ts +2 -0
- package/dist/agents/explorer.d.ts +2 -0
- package/dist/agents/fixer.d.ts +2 -0
- package/dist/agents/index.d.ts +22 -0
- package/dist/agents/interpreter.d.ts +2 -0
- package/dist/agents/librarian.d.ts +2 -0
- package/dist/agents/oracle.d.ts +2 -0
- package/dist/agents/orchestrator.d.ts +27 -0
- package/dist/agents/overrides.d.ts +18 -0
- package/dist/agents/prompt-blocks.d.ts +97 -0
- package/dist/agents/steward.d.ts +3 -0
- package/dist/cli/config-io.d.ts +24 -0
- package/dist/cli/config-manager.d.ts +4 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1006 -0
- package/dist/cli/install.d.ts +2 -0
- package/dist/cli/mcps.d.ts +13 -0
- package/dist/cli/model-key-normalization.d.ts +1 -0
- package/dist/cli/paths.d.ts +35 -0
- package/dist/cli/providers.d.ts +137 -0
- package/dist/cli/skills.d.ts +22 -0
- package/dist/cli/system.d.ts +5 -0
- package/dist/cli/types.d.ts +38 -0
- package/dist/config/constants.d.ts +12 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/loader.d.ts +40 -0
- package/dist/config/runtime-preset.d.ts +12 -0
- package/dist/config/schema.d.ts +281 -0
- package/dist/config/utils.d.ts +10 -0
- package/dist/discovery/local/types.d.ts +79 -0
- package/dist/discovery/local.d.ts +73 -0
- package/dist/discovery/mcp-servers.d.ts +88 -0
- package/dist/discovery/skills.d.ts +94 -0
- package/dist/hooks/apply-patch/codec.d.ts +7 -0
- package/dist/hooks/apply-patch/errors.d.ts +25 -0
- package/dist/hooks/apply-patch/execution-context.d.ts +27 -0
- package/dist/hooks/apply-patch/index.d.ts +15 -0
- package/dist/hooks/apply-patch/matching.d.ts +26 -0
- package/dist/hooks/apply-patch/operations.d.ts +3 -0
- package/dist/hooks/apply-patch/patch.d.ts +2 -0
- package/dist/hooks/apply-patch/prepared-changes.d.ts +17 -0
- package/dist/hooks/apply-patch/resolution.d.ts +19 -0
- package/dist/hooks/apply-patch/rewrite.d.ts +7 -0
- package/dist/hooks/apply-patch/test-helpers.d.ts +6 -0
- package/dist/hooks/apply-patch/types.d.ts +80 -0
- package/dist/hooks/auto-update-checker/cache.d.ts +11 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +32 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
- package/dist/hooks/auto-update-checker/index.d.ts +18 -0
- package/dist/hooks/auto-update-checker/types.d.ts +22 -0
- package/dist/hooks/chat-headers.d.ts +16 -0
- package/dist/hooks/context-pressure-reminder/index.d.ts +33 -0
- package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
- package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
- package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
- package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
- package/dist/hooks/filter-available-skills/index.d.ts +32 -0
- package/dist/hooks/foreground-fallback/index.d.ts +72 -0
- package/dist/hooks/image-hook.d.ts +5 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
- package/dist/hooks/json-error-recovery/index.d.ts +1 -0
- package/dist/hooks/phase-reminder/index.d.ts +26 -0
- package/dist/hooks/post-file-tool-nudge/index.d.ts +19 -0
- package/dist/hooks/task-session-manager/index.d.ts +52 -0
- package/dist/hooks/todo-continuation/index.d.ts +53 -0
- package/dist/hooks/todo-continuation/todo-hygiene.d.ts +35 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +31782 -0
- package/dist/mcp/context7.d.ts +6 -0
- package/dist/mcp/grep-app.d.ts +6 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/websearch.d.ts +9 -0
- package/dist/skills/registry.d.ts +29 -0
- package/dist/subscriptions/accounts-store.d.ts +57 -0
- package/dist/subscriptions/index.d.ts +13 -0
- package/dist/subscriptions/neuralwatt-scraper.d.ts +14 -0
- package/dist/subscriptions/opencode-go-scraper.d.ts +27 -0
- package/dist/subscriptions/types.d.ts +115 -0
- package/dist/subscriptions/usage-service.d.ts +74 -0
- package/dist/tools/ast-grep/cli.d.ts +15 -0
- package/dist/tools/ast-grep/constants.d.ts +25 -0
- package/dist/tools/ast-grep/downloader.d.ts +5 -0
- package/dist/tools/ast-grep/index.d.ts +10 -0
- package/dist/tools/ast-grep/tools.d.ts +3 -0
- package/dist/tools/ast-grep/types.d.ts +30 -0
- package/dist/tools/ast-grep/utils.d.ts +4 -0
- package/dist/tools/delegate.d.ts +14 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/preset-manager.d.ts +27 -0
- package/dist/tools/smartfetch/binary.d.ts +3 -0
- package/dist/tools/smartfetch/cache.d.ts +6 -0
- package/dist/tools/smartfetch/constants.d.ts +12 -0
- package/dist/tools/smartfetch/index.d.ts +3 -0
- package/dist/tools/smartfetch/network.d.ts +38 -0
- package/dist/tools/smartfetch/secondary-model.d.ts +28 -0
- package/dist/tools/smartfetch/tool.d.ts +3 -0
- package/dist/tools/smartfetch/types.d.ts +122 -0
- package/dist/tools/smartfetch/utils.d.ts +18 -0
- package/dist/tui-state.d.ts +168 -0
- package/dist/tui.d.ts +37 -0
- package/dist/tui.js +1896 -0
- package/dist/utils/agent-variant.d.ts +63 -0
- package/dist/utils/compat.d.ts +30 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/internal-initiator.d.ts +6 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/polling.d.ts +21 -0
- package/dist/utils/session-manager.d.ts +55 -0
- package/dist/utils/session.d.ts +90 -0
- package/dist/utils/subagent-depth.d.ts +35 -0
- package/dist/utils/system-collapse.d.ts +6 -0
- package/dist/utils/task.d.ts +4 -0
- package/dist/utils/zip-extractor.d.ts +1 -0
- package/index.ts +1 -0
- package/opencode-dux.schema.json +634 -0
- package/package.json +103 -0
- package/src/agents/descriptions.ts +55 -0
- package/src/agents/designer.test.ts +86 -0
- package/src/agents/designer.ts +154 -0
- package/src/agents/display-name.test.ts +186 -0
- package/src/agents/explorer.test.ts +79 -0
- package/src/agents/explorer.ts +144 -0
- package/src/agents/fixer.test.ts +79 -0
- package/src/agents/fixer.ts +145 -0
- package/src/agents/index.test.ts +472 -0
- package/src/agents/index.ts +248 -0
- package/src/agents/interpreter.ts +136 -0
- package/src/agents/librarian.test.ts +80 -0
- package/src/agents/librarian.ts +145 -0
- package/src/agents/oracle.test.ts +89 -0
- package/src/agents/oracle.ts +184 -0
- package/src/agents/orchestrator.test.ts +116 -0
- package/src/agents/orchestrator.ts +574 -0
- package/src/agents/overrides.ts +95 -0
- package/src/agents/prompt-blocks.test.ts +114 -0
- package/src/agents/prompt-blocks.ts +640 -0
- package/src/agents/steward.ts +146 -0
- package/src/cli/config-io.test.ts +536 -0
- package/src/cli/config-io.ts +473 -0
- package/src/cli/config-manager.test.ts +141 -0
- package/src/cli/config-manager.ts +4 -0
- package/src/cli/index.ts +88 -0
- package/src/cli/install.ts +282 -0
- package/src/cli/mcps.test.ts +62 -0
- package/src/cli/mcps.ts +39 -0
- package/src/cli/model-key-normalization.test.ts +21 -0
- package/src/cli/model-key-normalization.ts +60 -0
- package/src/cli/paths.test.ts +167 -0
- package/src/cli/paths.ts +144 -0
- package/src/cli/providers.test.ts +118 -0
- package/src/cli/providers.ts +141 -0
- package/src/cli/skills.test.ts +111 -0
- package/src/cli/skills.ts +103 -0
- package/src/cli/system.test.ts +91 -0
- package/src/cli/system.ts +180 -0
- package/src/cli/types.ts +43 -0
- package/src/config/constants.ts +58 -0
- package/src/config/index.ts +4 -0
- package/src/config/loader.test.ts +1194 -0
- package/src/config/loader.ts +269 -0
- package/src/config/model-resolution.test.ts +176 -0
- package/src/config/runtime-preset.test.ts +61 -0
- package/src/config/runtime-preset.ts +37 -0
- package/src/config/schema.ts +248 -0
- package/src/config/utils.test.ts +41 -0
- package/src/config/utils.ts +23 -0
- package/src/discovery/local/types.ts +85 -0
- package/src/discovery/local.ts +322 -0
- package/src/discovery/mcp-servers.ts +804 -0
- package/src/discovery/skills.ts +959 -0
- package/src/hooks/apply-patch/codec.test.ts +184 -0
- package/src/hooks/apply-patch/codec.ts +352 -0
- package/src/hooks/apply-patch/errors.ts +117 -0
- package/src/hooks/apply-patch/execution-context.ts +432 -0
- package/src/hooks/apply-patch/hook.test.ts +768 -0
- package/src/hooks/apply-patch/index.ts +126 -0
- package/src/hooks/apply-patch/matching.test.ts +215 -0
- package/src/hooks/apply-patch/matching.ts +586 -0
- package/src/hooks/apply-patch/operations.test.ts +1535 -0
- package/src/hooks/apply-patch/operations.ts +3 -0
- package/src/hooks/apply-patch/patch.ts +9 -0
- package/src/hooks/apply-patch/prepared-changes.ts +400 -0
- package/src/hooks/apply-patch/resolution.test.ts +420 -0
- package/src/hooks/apply-patch/resolution.ts +437 -0
- package/src/hooks/apply-patch/rewrite.ts +496 -0
- package/src/hooks/apply-patch/test-helpers.ts +52 -0
- package/src/hooks/apply-patch/types.ts +111 -0
- package/src/hooks/auto-update-checker/cache.test.ts +179 -0
- package/src/hooks/auto-update-checker/cache.ts +188 -0
- package/src/hooks/auto-update-checker/checker.test.ts +159 -0
- package/src/hooks/auto-update-checker/checker.ts +308 -0
- package/src/hooks/auto-update-checker/constants.ts +33 -0
- package/src/hooks/auto-update-checker/index.test.ts +282 -0
- package/src/hooks/auto-update-checker/index.ts +225 -0
- package/src/hooks/auto-update-checker/types.ts +26 -0
- package/src/hooks/chat-headers.test.ts +236 -0
- package/src/hooks/chat-headers.ts +97 -0
- package/src/hooks/context-pressure-reminder/index.test.ts +179 -0
- package/src/hooks/context-pressure-reminder/index.ts +137 -0
- package/src/hooks/delegate-task-retry/guidance.ts +41 -0
- package/src/hooks/delegate-task-retry/hook.ts +23 -0
- package/src/hooks/delegate-task-retry/index.test.ts +38 -0
- package/src/hooks/delegate-task-retry/index.ts +7 -0
- package/src/hooks/delegate-task-retry/patterns.ts +79 -0
- package/src/hooks/filter-available-skills/index.test.ts +297 -0
- package/src/hooks/filter-available-skills/index.ts +160 -0
- package/src/hooks/foreground-fallback/index.test.ts +624 -0
- package/src/hooks/foreground-fallback/index.ts +374 -0
- package/src/hooks/image-hook.ts +6 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/json-error-recovery/hook.ts +73 -0
- package/src/hooks/json-error-recovery/index.test.ts +111 -0
- package/src/hooks/json-error-recovery/index.ts +6 -0
- package/src/hooks/phase-reminder/index.test.ts +74 -0
- package/src/hooks/phase-reminder/index.ts +85 -0
- package/src/hooks/post-file-tool-nudge/index.test.ts +94 -0
- package/src/hooks/post-file-tool-nudge/index.ts +63 -0
- package/src/hooks/task-session-manager/index.test.ts +833 -0
- package/src/hooks/task-session-manager/index.ts +434 -0
- package/src/hooks/todo-continuation/index.test.ts +3026 -0
- package/src/hooks/todo-continuation/index.ts +878 -0
- package/src/hooks/todo-continuation/todo-hygiene.test.ts +204 -0
- package/src/hooks/todo-continuation/todo-hygiene.ts +207 -0
- package/src/index.ts +1672 -0
- package/src/mcp/context7.ts +14 -0
- package/src/mcp/grep-app.ts +11 -0
- package/src/mcp/index.test.ts +96 -0
- package/src/mcp/index.ts +66 -0
- package/src/mcp/types.ts +16 -0
- package/src/mcp/websearch.ts +47 -0
- package/src/skills/codemap/README.md +60 -0
- package/src/skills/codemap/SKILL.md +174 -0
- package/src/skills/codemap/scripts/codemap.mjs +483 -0
- package/src/skills/codemap/scripts/codemap.test.ts +129 -0
- package/src/skills/registry.ts +218 -0
- package/src/skills/simplify/README.md +19 -0
- package/src/skills/simplify/SKILL.md +138 -0
- package/src/subscriptions/accounts-store.test.ts +236 -0
- package/src/subscriptions/accounts-store.ts +184 -0
- package/src/subscriptions/index.ts +30 -0
- package/src/subscriptions/neuralwatt-scraper.ts +108 -0
- package/src/subscriptions/opencode-go-scraper.ts +301 -0
- package/src/subscriptions/types.ts +145 -0
- package/src/subscriptions/usage-service.test.ts +202 -0
- package/src/subscriptions/usage-service.ts +651 -0
- package/src/tools/ast-grep/cli.ts +257 -0
- package/src/tools/ast-grep/constants.ts +214 -0
- package/src/tools/ast-grep/downloader.ts +131 -0
- package/src/tools/ast-grep/index.ts +24 -0
- package/src/tools/ast-grep/tools.ts +117 -0
- package/src/tools/ast-grep/types.ts +51 -0
- package/src/tools/ast-grep/utils.ts +126 -0
- package/src/tools/delegate-handoff.test.ts +18 -0
- package/src/tools/delegate.ts +508 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/preset-manager.test.ts +795 -0
- package/src/tools/preset-manager.ts +332 -0
- package/src/tools/smartfetch/binary.ts +58 -0
- package/src/tools/smartfetch/cache.test.ts +34 -0
- package/src/tools/smartfetch/cache.ts +112 -0
- package/src/tools/smartfetch/constants.ts +29 -0
- package/src/tools/smartfetch/index.ts +8 -0
- package/src/tools/smartfetch/network.test.ts +178 -0
- package/src/tools/smartfetch/network.ts +614 -0
- package/src/tools/smartfetch/secondary-model.test.ts +85 -0
- package/src/tools/smartfetch/secondary-model.ts +276 -0
- package/src/tools/smartfetch/tool.test.ts +60 -0
- package/src/tools/smartfetch/tool.ts +832 -0
- package/src/tools/smartfetch/types.ts +135 -0
- package/src/tools/smartfetch/utils.test.ts +24 -0
- package/src/tools/smartfetch/utils.ts +456 -0
- package/src/tui-state.test.ts +867 -0
- package/src/tui-state.ts +1255 -0
- package/src/tui.test.ts +336 -0
- package/src/tui.ts +1539 -0
- package/src/utils/agent-variant.test.ts +244 -0
- package/src/utils/agent-variant.ts +187 -0
- package/src/utils/compat.ts +91 -0
- package/src/utils/env.ts +12 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/internal-initiator.ts +28 -0
- package/src/utils/logger.test.ts +220 -0
- package/src/utils/logger.ts +136 -0
- package/src/utils/polling.test.ts +191 -0
- package/src/utils/polling.ts +67 -0
- package/src/utils/session-manager.test.ts +173 -0
- package/src/utils/session-manager.ts +356 -0
- package/src/utils/session.test.ts +110 -0
- package/src/utils/session.ts +389 -0
- package/src/utils/subagent-depth.test.ts +170 -0
- package/src/utils/subagent-depth.ts +75 -0
- package/src/utils/system-collapse.test.ts +86 -0
- package/src/utils/system-collapse.ts +24 -0
- package/src/utils/task.test.ts +24 -0
- package/src/utils/task.ts +20 -0
- package/src/utils/zip-extractor.ts +102 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type PluginConfig } from '../config';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes an agent name by trimming whitespace and removing the optional @ prefix.
|
|
4
|
+
*
|
|
5
|
+
* @param agentName - The agent name to normalize (e.g., "@oracle" or "oracle")
|
|
6
|
+
* @returns The normalized agent name without @ prefix and trimmed of whitespace
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* normalizeAgentName("@oracle") // returns "oracle"
|
|
10
|
+
* normalizeAgentName(" explore ") // returns "explore"
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeAgentName(agentName: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the variant configuration for a specific agent.
|
|
15
|
+
*
|
|
16
|
+
* Looks up the agent's variant in the plugin configuration. Returns undefined if:
|
|
17
|
+
* - No config is provided
|
|
18
|
+
* - The agent has no variant configured
|
|
19
|
+
* - The variant is not a string
|
|
20
|
+
* - The variant is empty or whitespace-only
|
|
21
|
+
*
|
|
22
|
+
* @param config - The plugin configuration object
|
|
23
|
+
* @param agentName - The name of the agent (with or without @ prefix)
|
|
24
|
+
* @returns The trimmed variant string, or undefined if no valid variant is found
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* resolveAgentVariant(config, "@oracle") // returns "high" if configured
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveAgentVariant(config: PluginConfig | undefined, agentName: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a runtime-provided agent name to an internal agent name.
|
|
32
|
+
*
|
|
33
|
+
* Supports:
|
|
34
|
+
* - internal names (e.g. "oracle")
|
|
35
|
+
* - @-prefixed names (e.g. "@oracle")
|
|
36
|
+
* - displayName aliases (e.g. "advisor" -> "oracle")
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveRuntimeAgentName(config: PluginConfig | undefined, agentName: string): string;
|
|
39
|
+
export type DisplayNameMentionRewriter = (text: string) => string;
|
|
40
|
+
export declare function createDisplayNameMentionRewriter(config: PluginConfig | undefined): DisplayNameMentionRewriter;
|
|
41
|
+
/**
|
|
42
|
+
* Rewrites user-facing display-name mentions (e.g. @advisor) into internal
|
|
43
|
+
* agent mentions (e.g. @oracle) for runtime routing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function rewriteDisplayNameMentions(config: PluginConfig | undefined, text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Applies a variant to a request body if the body doesn't already have one.
|
|
48
|
+
*
|
|
49
|
+
* This function will NOT override an existing variant in the body. If no variant
|
|
50
|
+
* is provided or the body already has a variant, the original body is returned.
|
|
51
|
+
*
|
|
52
|
+
* @template T - The type of the body object, must have an optional variant property
|
|
53
|
+
* @param variant - The variant string to apply (or undefined)
|
|
54
|
+
* @param body - The request body object
|
|
55
|
+
* @returns The body with the variant applied (new object) or the original body unchanged
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* applyAgentVariant("high", { agent: "oracle" }) // returns { agent: "oracle", variant: "high" }
|
|
59
|
+
* applyAgentVariant("high", { agent: "oracle", variant: "low" }) // returns original body with variant: "low"
|
|
60
|
+
*/
|
|
61
|
+
export declare function applyAgentVariant<T extends {
|
|
62
|
+
variant?: string;
|
|
63
|
+
}>(variant: string | undefined, body: T): T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
export declare const isBun: boolean;
|
|
3
|
+
export interface CrossSpawnResult {
|
|
4
|
+
proc: ChildProcess;
|
|
5
|
+
/** Collects all stdout into a string */
|
|
6
|
+
stdout: () => Promise<string>;
|
|
7
|
+
/** Collects all stderr into a string */
|
|
8
|
+
stderr: () => Promise<string>;
|
|
9
|
+
/** Resolves when process exits with exit code */
|
|
10
|
+
exited: Promise<number>;
|
|
11
|
+
/** Kill the process */
|
|
12
|
+
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
13
|
+
/** Current exit code or null if running */
|
|
14
|
+
get exitCode(): number | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Cross-runtime spawn that works in both Bun and Node.js.
|
|
18
|
+
* API mimics Bun.spawn but uses node:child_process internally.
|
|
19
|
+
*/
|
|
20
|
+
export declare function crossSpawn(command: string[], options?: {
|
|
21
|
+
stdout?: 'pipe' | 'inherit' | 'ignore';
|
|
22
|
+
stderr?: 'pipe' | 'inherit' | 'ignore';
|
|
23
|
+
stdin?: 'pipe' | 'inherit' | 'ignore';
|
|
24
|
+
cwd?: string;
|
|
25
|
+
env?: Record<string, string | undefined>;
|
|
26
|
+
}): CrossSpawnResult;
|
|
27
|
+
/**
|
|
28
|
+
* Cross-runtime file write that works in both Bun and Node.js.
|
|
29
|
+
*/
|
|
30
|
+
export declare function crossWrite(path: string, data: ArrayBuffer | Buffer | string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEnv(name: string): string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './agent-variant';
|
|
2
|
+
export * from './env';
|
|
3
|
+
export * from './internal-initiator';
|
|
4
|
+
export { getLogDir, initLogger, log, resetLogger } from './logger';
|
|
5
|
+
export * from './polling';
|
|
6
|
+
export * from './session';
|
|
7
|
+
export * from './session-manager';
|
|
8
|
+
export * from './task';
|
|
9
|
+
export { extractZip } from './zip-extractor';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SLIM_INTERNAL_INITIATOR_MARKER = "<!-- SLIM_INTERNAL_INITIATOR -->";
|
|
2
|
+
export declare function createInternalAgentTextPart(text: string): {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function hasInternalInitiatorMarker(part: unknown): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function getLogDir(): string;
|
|
2
|
+
export declare function initLogger(sessionId: string): void;
|
|
3
|
+
/** @internal Reset logger state for testing */
|
|
4
|
+
export declare function resetLogger(): void;
|
|
5
|
+
/** @internal Wait for queued log writes in tests. */
|
|
6
|
+
export declare function flushLoggerForTesting(): Promise<void>;
|
|
7
|
+
export { getLogDir };
|
|
8
|
+
export declare function log(message: string, data?: unknown): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PollOptions {
|
|
2
|
+
pollInterval?: number;
|
|
3
|
+
maxPollTime?: number;
|
|
4
|
+
stableThreshold?: number;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export interface PollResult<T> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data?: T;
|
|
10
|
+
timedOut?: boolean;
|
|
11
|
+
aborted?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generic polling utility that waits for a condition to be met.
|
|
15
|
+
* Returns when the condition is satisfied or timeout/abort occurs.
|
|
16
|
+
*/
|
|
17
|
+
export declare function pollUntilStable<T>(fetchFn: () => Promise<T>, isStable: (current: T, previous: T | null, stableCount: number) => boolean, opts?: PollOptions): Promise<PollResult<T>>;
|
|
18
|
+
/**
|
|
19
|
+
* Simple delay utility
|
|
20
|
+
*/
|
|
21
|
+
export declare function delay(ms: number): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentName } from '../config';
|
|
2
|
+
export interface ContextFile {
|
|
3
|
+
path: string;
|
|
4
|
+
lineCount: number;
|
|
5
|
+
lineNumbers?: number[];
|
|
6
|
+
lastReadAt: number;
|
|
7
|
+
}
|
|
8
|
+
export interface RememberedTaskSession {
|
|
9
|
+
alias: string;
|
|
10
|
+
taskId: string;
|
|
11
|
+
agentType: AgentName;
|
|
12
|
+
label: string;
|
|
13
|
+
contextFiles: ContextFile[];
|
|
14
|
+
createdAt: number;
|
|
15
|
+
lastUsedAt: number;
|
|
16
|
+
}
|
|
17
|
+
interface SessionManagerOptions {
|
|
18
|
+
readContextMinLines?: number;
|
|
19
|
+
readContextMaxFiles?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function deriveTaskSessionLabel(input: {
|
|
22
|
+
description?: string;
|
|
23
|
+
prompt?: string;
|
|
24
|
+
agentType: AgentName;
|
|
25
|
+
}): string;
|
|
26
|
+
export declare class SessionManager {
|
|
27
|
+
private readonly maxSessionsPerAgent;
|
|
28
|
+
private readonly readContextMinLines;
|
|
29
|
+
private readonly readContextMaxFiles;
|
|
30
|
+
private readonly sessionsByParent;
|
|
31
|
+
private readonly nextAliasIndexByParent;
|
|
32
|
+
private orderCounter;
|
|
33
|
+
constructor(maxSessionsPerAgent: number, options?: SessionManagerOptions);
|
|
34
|
+
remember(input: {
|
|
35
|
+
parentSessionId: string;
|
|
36
|
+
taskId: string;
|
|
37
|
+
agentType: AgentName;
|
|
38
|
+
label: string;
|
|
39
|
+
}): RememberedTaskSession;
|
|
40
|
+
markUsed(parentSessionId: string, agentType: AgentName, key: string): void;
|
|
41
|
+
resolve(parentSessionId: string, agentType: AgentName, key: string): RememberedTaskSession | undefined;
|
|
42
|
+
drop(parentSessionId: string, agentType: AgentName, key: string): void;
|
|
43
|
+
dropTask(taskId: string): void;
|
|
44
|
+
taskIds(): Set<string>;
|
|
45
|
+
addContext(taskId: string, files: ContextFile[]): void;
|
|
46
|
+
clearParent(parentSessionId: string): void;
|
|
47
|
+
formatForPrompt(parentSessionId: string): string | undefined;
|
|
48
|
+
private getAgentGroup;
|
|
49
|
+
private setAgentGroup;
|
|
50
|
+
private nextAlias;
|
|
51
|
+
private trimGroup;
|
|
52
|
+
private trimContextFiles;
|
|
53
|
+
private nextOrder;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared session utilities for background managers.
|
|
3
|
+
*/
|
|
4
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
5
|
+
type OpencodeClient = PluginInput['client'];
|
|
6
|
+
type SessionPromptBody = NonNullable<Parameters<OpencodeClient['session']['prompt']>[0]['body']>;
|
|
7
|
+
/** Multimodal / text parts accepted by `session.prompt` */
|
|
8
|
+
export type PromptBodyPart = SessionPromptBody['parts'][number];
|
|
9
|
+
/** Prompt body including optional variant (supported by the host at runtime). */
|
|
10
|
+
export type PromptBody = SessionPromptBody & {
|
|
11
|
+
variant?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Extract the short model label from a "provider/model" string.
|
|
15
|
+
* E.g. "openai/gpt-5.4-mini" → "gpt-5.4-mini"
|
|
16
|
+
*/
|
|
17
|
+
export declare function shortModelLabel(model: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a model reference string into provider and model IDs.
|
|
20
|
+
* @param model - Model string in format "provider/model"
|
|
21
|
+
* @returns Object with providerID and modelID, or null if invalid
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseModelReference(model: string): {
|
|
24
|
+
providerID: string;
|
|
25
|
+
modelID: string;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* OpenCode stores pasted / attached screenshots as {@link FilePart} (`type: "file"`,
|
|
29
|
+
* `mime` starting with `image/`), not as `type: "image"`. Some stacks still emit
|
|
30
|
+
* legacy `image` parts - accept both.
|
|
31
|
+
*
|
|
32
|
+
* @see https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/message-v2.ts
|
|
33
|
+
*/
|
|
34
|
+
export declare function isForwardableImagePart(part: Record<string, unknown>): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Non-text parts (e.g. images) from the latest user message in a session.
|
|
37
|
+
* Used when forwarding multimodal context to delegated agents such as @interpreter.
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractLatestUserImageParts(client: OpencodeClient, sessionId: string, directory: string): Promise<PromptBodyPart[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Stored {@link FilePart} rows include `sessionID` / `messageID` / etc. Child
|
|
42
|
+
* `session.prompt` expects {@link FilePartInput}-shaped drafts (`type`, `mime`,
|
|
43
|
+
* `url`, optional `filename`). Some attachments omit `url` but provide
|
|
44
|
+
* `source.path` - resolve that to a `file:` URL when possible.
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeImagePartsForChildPrompt(parts: PromptBodyPart[], workspaceDirectory?: string): PromptBodyPart[];
|
|
47
|
+
/**
|
|
48
|
+
* Send a prompt to a session with optional timeout.
|
|
49
|
+
* If timeout is exceeded, the session is aborted and an error is thrown.
|
|
50
|
+
* @param client - OpenCode client instance
|
|
51
|
+
* @param args - Arguments for session.prompt()
|
|
52
|
+
* @param timeoutMs - Timeout in milliseconds (0 = no timeout)
|
|
53
|
+
* @throws Error if timeout is exceeded
|
|
54
|
+
*/
|
|
55
|
+
export declare function promptWithTimeout(client: OpencodeClient, args: Parameters<OpencodeClient['session']['prompt']>[0], timeoutMs: number): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Result of extracting session content.
|
|
58
|
+
* `empty` is true when the assistant produced zero text content -
|
|
59
|
+
* the provider returned an empty response (e.g. rate-limited silently).
|
|
60
|
+
*/
|
|
61
|
+
export interface SessionExtractionResult {
|
|
62
|
+
text: string;
|
|
63
|
+
empty: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract the result text from a session.
|
|
67
|
+
* Collects all assistant messages and concatenates their text parts.
|
|
68
|
+
* @param client - OpenCode client instance
|
|
69
|
+
* @param sessionId - Session ID to extract from
|
|
70
|
+
* @param options - Optional: `includeReasoning` (default true) controls whether
|
|
71
|
+
* reasoning/chain-of-thought parts are included;
|
|
72
|
+
* `directory` scopes workspace for `session.messages` (child sessions).
|
|
73
|
+
* @returns Object with extracted text and an `empty` flag for zero-content detection
|
|
74
|
+
*/
|
|
75
|
+
export declare function extractSessionResult(client: OpencodeClient, sessionId: string, options?: {
|
|
76
|
+
includeReasoning?: boolean;
|
|
77
|
+
directory?: string;
|
|
78
|
+
}): Promise<SessionExtractionResult>;
|
|
79
|
+
/**
|
|
80
|
+
* After `session.prompt`, optionally wait for a terminal session status.
|
|
81
|
+
* Returns immediately when per-session status is unavailable (common for some hosts),
|
|
82
|
+
* so we never block the orchestrator on a mismatched status API.
|
|
83
|
+
*/
|
|
84
|
+
export declare function waitUntilSessionIdle(client: OpencodeClient, sessionId: string, workspaceDirectory: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* After `session.prompt`, wait for idle then read assistant text. Retries if the
|
|
87
|
+
* message store lags; falls back to including reasoning parts if text is still empty.
|
|
88
|
+
*/
|
|
89
|
+
export declare function extractAssistantTextAfterPrompt(client: OpencodeClient, sessionId: string, workspaceDirectory: string): Promise<SessionExtractionResult>;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks subagent spawn depth to prevent excessive nesting.
|
|
3
|
+
*
|
|
4
|
+
* Depth 0 = root session (user's main conversation)
|
|
5
|
+
* Depth 1 = agent spawned by root (e.g., explorer)
|
|
6
|
+
* Depth 2 = agent spawned by depth-1 agent
|
|
7
|
+
* Depth 3 = agent spawned by depth-2 agent (max depth by default)
|
|
8
|
+
*
|
|
9
|
+
* When max depth is exceeded, the spawn is blocked.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SubagentDepthTracker {
|
|
12
|
+
private depthBySession;
|
|
13
|
+
private readonly _maxDepth;
|
|
14
|
+
constructor(maxDepth?: number);
|
|
15
|
+
/** Maximum allowed depth. */
|
|
16
|
+
get maxDepth(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Get the current depth of a session.
|
|
19
|
+
* Root sessions (not tracked) have depth 0.
|
|
20
|
+
*/
|
|
21
|
+
getDepth(sessionId: string): number;
|
|
22
|
+
/**
|
|
23
|
+
* Register a child session and check if the spawn is allowed.
|
|
24
|
+
* @returns true if allowed, false if max depth exceeded
|
|
25
|
+
*/
|
|
26
|
+
registerChild(parentSessionId: string, childSessionId: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Clean up session tracking when a session is deleted.
|
|
29
|
+
*/
|
|
30
|
+
cleanup(sessionId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Clean up all tracking data.
|
|
33
|
+
*/
|
|
34
|
+
cleanupAll(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapse a system message array into a single element by joining all
|
|
3
|
+
* entries with double-newline separators. Mutates the array in-place so
|
|
4
|
+
* that callers holding a reference to the original array see the change.
|
|
5
|
+
*/
|
|
6
|
+
export declare function collapseSystemInPlace(system: string[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractZip(archivePath: string, destDir: string): Promise<void>;
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './src/index';
|