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,13 @@
|
|
|
1
|
+
import type { WebsearchConfig } from '../config';
|
|
2
|
+
import type { McpConfig } from './types';
|
|
3
|
+
export type { LocalMcpConfig, McpConfig, RemoteMcpConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates MCP configurations, excluding disabled ones.
|
|
6
|
+
* Accepts an optional websearchConfig to override the default Exa provider.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createBuiltinMcps(disabledMcps?: readonly string[], websearchConfig?: WebsearchConfig): Record<string, McpConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* Filter MCP configs for a specific agent based on its MCP permissions.
|
|
11
|
+
* When no permission rules exist, all MCPs are available.
|
|
12
|
+
*/
|
|
13
|
+
export declare function filterMcpsForAgent(allMcps: Record<string, McpConfig>, _agentName: string, mcpPermissionRules?: Record<string, 'allow' | 'ask' | 'deny'>): Record<string, McpConfig>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RemoteMcpConfig = {
|
|
2
|
+
type: 'remote';
|
|
3
|
+
url: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
oauth?: false;
|
|
6
|
+
};
|
|
7
|
+
export type LocalMcpConfig = {
|
|
8
|
+
type: 'local';
|
|
9
|
+
command: string[];
|
|
10
|
+
environment?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
export type McpConfig = RemoteMcpConfig | LocalMcpConfig;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WebsearchConfig } from '../config';
|
|
2
|
+
import type { RemoteMcpConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a websearch MCP config based on the provided configuration.
|
|
5
|
+
* Supports Exa (default) and Tavily providers.
|
|
6
|
+
* @see https://exa.ai @see https://tavily.com
|
|
7
|
+
*/
|
|
8
|
+
export declare function createWebsearchConfig(config?: WebsearchConfig): RemoteMcpConfig;
|
|
9
|
+
export declare const websearch: RemoteMcpConfig;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for a discovered skill.
|
|
3
|
+
*/
|
|
4
|
+
export interface SkillMetadata {
|
|
5
|
+
/** Unique skill name (derived from folder name) */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Human-readable description */
|
|
8
|
+
description: string;
|
|
9
|
+
/** Absolute path to the SKILL.md file */
|
|
10
|
+
path: string;
|
|
11
|
+
/** Tags for categorisation and matching */
|
|
12
|
+
tags: string[];
|
|
13
|
+
/** Agents that are recommended to use this skill */
|
|
14
|
+
recommendedAgents: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reset the skill discovery cache (for testing).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resetSkillsCache(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Scan the skills directory and return parsed skill metadata.
|
|
22
|
+
* Results are cached to avoid repeated filesystem scans;
|
|
23
|
+
* call {@link resetSkillsCache} to invalidate.
|
|
24
|
+
*
|
|
25
|
+
* Files with missing or invalid frontmatter are skipped with a warning.
|
|
26
|
+
*
|
|
27
|
+
* @param pluginRoot - Absolute path to the plugin root directory.
|
|
28
|
+
*/
|
|
29
|
+
export declare function discoverSkills(pluginRoot: string): Promise<SkillMetadata[]>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local file-based storage for subscription accounts.
|
|
3
|
+
*
|
|
4
|
+
* Stores account credentials in a local JSON file alongside tui-state.json,
|
|
5
|
+
* NOT in the plugin config, so auth tokens are never committed to repos or
|
|
6
|
+
* exposed in the published schema.
|
|
7
|
+
*
|
|
8
|
+
* Supports multiple providers (OpenCode Go, Neuralwatt) via discriminated
|
|
9
|
+
* unions on the `provider` field.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import type { StoredAccount, SubscriptionProvider } from './types';
|
|
13
|
+
export type { StoredAccount };
|
|
14
|
+
export type LoadAccountsResult = {
|
|
15
|
+
ok: true;
|
|
16
|
+
accounts: StoredAccount[];
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
accounts: StoredAccount[];
|
|
20
|
+
};
|
|
21
|
+
declare function loadAccountsResult(): LoadAccountsResult;
|
|
22
|
+
/**
|
|
23
|
+
* Load all stored accounts.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadAccounts(): StoredAccount[];
|
|
26
|
+
export { loadAccountsResult };
|
|
27
|
+
/**
|
|
28
|
+
* Load accounts filtered by provider.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAccountsByProvider(provider: SubscriptionProvider): StoredAccount[];
|
|
31
|
+
/**
|
|
32
|
+
* Add a new account. If an account with the same name already exists,
|
|
33
|
+
* overwrites it (update).
|
|
34
|
+
*/
|
|
35
|
+
export declare function saveAccount(account: StoredAccount): void;
|
|
36
|
+
/**
|
|
37
|
+
* Remove an account by name. Returns true if deleted, false if not found.
|
|
38
|
+
*/
|
|
39
|
+
export declare function removeAccount(name: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Update the auth cookie for an existing OpenCode Go account.
|
|
42
|
+
* Returns true if updated, false if account not found or not an opencode-go account.
|
|
43
|
+
*/
|
|
44
|
+
export declare function updateAccountCookie(name: string, authCookie: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Mask an auth cookie for display (show first 8 + last 4 chars).
|
|
47
|
+
*/
|
|
48
|
+
export declare function maskCookie(cookie: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Look up a stored account by name.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAccount(name: string): StoredAccount | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Set the provider and API key for an existing account.
|
|
55
|
+
* Returns true if updated, false if account not found.
|
|
56
|
+
*/
|
|
57
|
+
export declare function setAccountKey(name: string, provider: string, apiKey: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-provider subscription tracking module.
|
|
3
|
+
*
|
|
4
|
+
* Provides account management (local storage), provider-specific scrapers,
|
|
5
|
+
* caching, and slash-command support for subscription usage data displayed
|
|
6
|
+
* in the TUI sidebar and via /subscriptions command.
|
|
7
|
+
*/
|
|
8
|
+
export type { StoredAccount } from './accounts-store';
|
|
9
|
+
export { getAccount, getAccountsByProvider, loadAccounts, loadAccountsResult, maskCookie, removeAccount, saveAccount, setAccountKey, updateAccountCookie, } from './accounts-store';
|
|
10
|
+
export { scrapeNeuralwattQuota } from './neuralwatt-scraper';
|
|
11
|
+
export { scrapeQuota, scrapeUsagePage } from './opencode-go-scraper';
|
|
12
|
+
export type { NeuralwattUsageEntry, OpenCodeGoUsageEntry, SubscriptionUsageEntry, UsageDetail, UsageWindow, } from './types';
|
|
13
|
+
export { createUsageService, UsageService } from './usage-service';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralwatt quota API scraper.
|
|
3
|
+
*
|
|
4
|
+
* Fetches usage data from the Neuralwatt REST API using Bearer token
|
|
5
|
+
* authentication. Returns structured quota data including credit balance,
|
|
6
|
+
* energy usage (kWh), and subscription details.
|
|
7
|
+
*
|
|
8
|
+
* Rate limit: 1 request per second per customer.
|
|
9
|
+
*/
|
|
10
|
+
import type { NeuralwattUsageEntry } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Fetch Neuralwatt quota data via the REST API.
|
|
13
|
+
*/
|
|
14
|
+
export declare function scrapeNeuralwattQuota(apiKey: string, signal?: AbortSignal): Promise<NeuralwattUsageEntry>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Go dashboard scraper.
|
|
3
|
+
*
|
|
4
|
+
* Fetches the OpenCode Go workspace dashboard page and parses SolidJS SSR
|
|
5
|
+
* hydration output for known usage windows (rollingUsage, weeklyUsage,
|
|
6
|
+
* monthlyUsage) containing usagePercent and resetInSec fields.
|
|
7
|
+
*/
|
|
8
|
+
import type { OpenCodeGoUsageEntry, UsageDetail } from './types';
|
|
9
|
+
interface ScrapedWindowUsage {
|
|
10
|
+
usagePercent: number;
|
|
11
|
+
resetInSec: number;
|
|
12
|
+
}
|
|
13
|
+
declare function parseWindowUsage(html: string, rePctFirst: RegExp, reResetFirst: RegExp): ScrapedWindowUsage | null;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch the OpenCode Go dashboard /go page and extract quota usage data.
|
|
16
|
+
*/
|
|
17
|
+
export declare function scrapeQuota(workspaceId: string, authCookie: string, signal?: AbortSignal): Promise<OpenCodeGoUsageEntry>;
|
|
18
|
+
/**
|
|
19
|
+
* Scrape detailed usage data from the /usage page.
|
|
20
|
+
* The page embeds individual usage records in SolidJS SSR hydration format
|
|
21
|
+
* as $R[N]={id:"usg_...} records with model, inputTokens, outputTokens, cost fields.
|
|
22
|
+
* No total or summary is present - we aggregate from individual records.
|
|
23
|
+
*/
|
|
24
|
+
export declare function scrapeUsagePage(workspaceId: string, authCookie: string, signal?: AbortSignal): Promise<UsageDetail | {
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
export { parseWindowUsage as _parseWindowUsage };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for multi-provider subscription usage tracking.
|
|
3
|
+
*
|
|
4
|
+
* Supports OpenCode Go (dashboard scraping) and Neuralwatt (REST API)
|
|
5
|
+
* as discriminated unions on the `provider` field.
|
|
6
|
+
*/
|
|
7
|
+
/** Provider discriminator. */
|
|
8
|
+
export type SubscriptionProvider = 'opencode-go' | 'neuralwatt';
|
|
9
|
+
export interface OpenCodeGoAccount {
|
|
10
|
+
provider: 'opencode-go';
|
|
11
|
+
name: string;
|
|
12
|
+
workspaceId: string;
|
|
13
|
+
authCookie: string;
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface NeuralwattAccount {
|
|
17
|
+
provider: 'neuralwatt';
|
|
18
|
+
name: string;
|
|
19
|
+
apiKey: string;
|
|
20
|
+
}
|
|
21
|
+
export type StoredAccount = OpenCodeGoAccount | NeuralwattAccount;
|
|
22
|
+
/** Per-time-window usage data scraped from the OpenCode Go dashboard. */
|
|
23
|
+
export interface UsageWindow {
|
|
24
|
+
/** Usage percentage [0..100] */
|
|
25
|
+
usagePercent: number;
|
|
26
|
+
/** Seconds until usage resets */
|
|
27
|
+
resetInSec: number;
|
|
28
|
+
/** Remaining percentage [0..100] */
|
|
29
|
+
percentRemaining: number;
|
|
30
|
+
/** ISO reset timestamp */
|
|
31
|
+
resetTimeIso: string;
|
|
32
|
+
}
|
|
33
|
+
/** Snapshot entry per OpenCode Go account - stored in tui-state.json. */
|
|
34
|
+
export interface OpenCodeGoUsageEntry {
|
|
35
|
+
provider: 'opencode-go';
|
|
36
|
+
/** Display name for this account (from config). */
|
|
37
|
+
accountName: string;
|
|
38
|
+
/** OpenCode Go workspace ID. */
|
|
39
|
+
workspaceId: string;
|
|
40
|
+
/** Rolling (~5h) usage window, when present. */
|
|
41
|
+
rolling?: UsageWindow;
|
|
42
|
+
/** Weekly usage window, when present. */
|
|
43
|
+
weekly?: UsageWindow;
|
|
44
|
+
/** Monthly usage window, when present. */
|
|
45
|
+
monthly?: UsageWindow;
|
|
46
|
+
/** Timestamp when data was fetched. */
|
|
47
|
+
fetchedAt: number;
|
|
48
|
+
/** Error message if the scrape failed for this account. */
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface NeuralwattBalance {
|
|
52
|
+
credits_remaining_usd: number;
|
|
53
|
+
total_credits_usd: number;
|
|
54
|
+
credits_used_usd: number;
|
|
55
|
+
accounting_method: string;
|
|
56
|
+
}
|
|
57
|
+
export interface NeuralwattUsagePeriod {
|
|
58
|
+
cost_usd: number;
|
|
59
|
+
requests: number;
|
|
60
|
+
tokens: number;
|
|
61
|
+
energy_kwh: number;
|
|
62
|
+
}
|
|
63
|
+
export interface NeuralwattUsage {
|
|
64
|
+
lifetime: NeuralwattUsagePeriod;
|
|
65
|
+
current_month: NeuralwattUsagePeriod;
|
|
66
|
+
}
|
|
67
|
+
export interface NeuralwattSubscription {
|
|
68
|
+
plan: string;
|
|
69
|
+
status: 'active' | 'canceling' | 'past_due' | 'paused' | 'trialing';
|
|
70
|
+
billing_interval: string | null;
|
|
71
|
+
current_period_start: string | null;
|
|
72
|
+
current_period_end: string | null;
|
|
73
|
+
auto_renew: boolean | null;
|
|
74
|
+
kwh_included: number | null;
|
|
75
|
+
kwh_used: number | null;
|
|
76
|
+
kwh_remaining: number | null;
|
|
77
|
+
in_overage: boolean | null;
|
|
78
|
+
}
|
|
79
|
+
/** Snapshot entry per Neuralwatt account - stored in tui-state.json. */
|
|
80
|
+
export interface NeuralwattUsageEntry {
|
|
81
|
+
provider: 'neuralwatt';
|
|
82
|
+
/** Display name for this account. */
|
|
83
|
+
accountName: string;
|
|
84
|
+
/** ISO timestamp from the API response. */
|
|
85
|
+
snapshot_at: string;
|
|
86
|
+
/** Credit balance. */
|
|
87
|
+
balance: NeuralwattBalance;
|
|
88
|
+
/** Usage data (lifetime + current month). */
|
|
89
|
+
usage: NeuralwattUsage;
|
|
90
|
+
/** Subscription details, null if no active subscription. */
|
|
91
|
+
subscription: NeuralwattSubscription | null;
|
|
92
|
+
/** Timestamp when data was fetched. */
|
|
93
|
+
fetchedAt: number;
|
|
94
|
+
/** Error message if the fetch failed. */
|
|
95
|
+
error?: string;
|
|
96
|
+
}
|
|
97
|
+
export type SubscriptionUsageEntry = OpenCodeGoUsageEntry | NeuralwattUsageEntry;
|
|
98
|
+
/** Detailed usage data from the /usage page. */
|
|
99
|
+
export interface UsageDetail {
|
|
100
|
+
/** Total number of API calls. */
|
|
101
|
+
totalCalls: number;
|
|
102
|
+
/** Total estimated cost in USD. */
|
|
103
|
+
totalCost: number;
|
|
104
|
+
/** Per-model breakdown. */
|
|
105
|
+
perModel: Array<{
|
|
106
|
+
model: string;
|
|
107
|
+
calls: number;
|
|
108
|
+
cost: number;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
/** Config for the subscription tracking feature. */
|
|
112
|
+
export interface SubscriptionsConfig {
|
|
113
|
+
/** Minimum interval between auto-refreshes in ms (default: 60000). */
|
|
114
|
+
refreshIntervalMs: number;
|
|
115
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage service for multi-provider subscription tracking.
|
|
3
|
+
*
|
|
4
|
+
* Manages account storage, refresh lifecycle, rate limiting, and the
|
|
5
|
+
* /subscriptions slash command.
|
|
6
|
+
*
|
|
7
|
+
* Accounts are stored locally (not in plugin config) to keep auth tokens
|
|
8
|
+
* out of version control and the published schema.
|
|
9
|
+
*/
|
|
10
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
11
|
+
import type { SubscriptionProvider, SubscriptionUsageEntry } from './types';
|
|
12
|
+
export declare class UsageService {
|
|
13
|
+
private client;
|
|
14
|
+
private lastRefresh;
|
|
15
|
+
private pendingRefresh;
|
|
16
|
+
private cached;
|
|
17
|
+
private refreshIntervalMs;
|
|
18
|
+
private periodicTimer;
|
|
19
|
+
private periodicIntervalMs;
|
|
20
|
+
constructor(client: PluginInput['client'], refreshIntervalMs?: number, periodicIntervalMs?: number);
|
|
21
|
+
/** Get accounts from local storage. */
|
|
22
|
+
private getAccounts;
|
|
23
|
+
private getAccountsResult;
|
|
24
|
+
/**
|
|
25
|
+
* Refresh all accounts' usage data, respecting rate limit unless forced.
|
|
26
|
+
* Returns the scraped results.
|
|
27
|
+
*/
|
|
28
|
+
refresh(force?: boolean): Promise<SubscriptionUsageEntry[]>;
|
|
29
|
+
private _doRefresh;
|
|
30
|
+
/**
|
|
31
|
+
* Called when orchestrator goes idle - triggers a non-forced refresh.
|
|
32
|
+
*/
|
|
33
|
+
onOrchestratorIdle(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Sync the active account by comparing stored API keys against
|
|
36
|
+
* auth.json. If a stored account's apiKey matches the opencode-go
|
|
37
|
+
* key in auth.json, that account is marked active. Otherwise active
|
|
38
|
+
* is cleared. This keeps the sidebar accurate even if auth.json
|
|
39
|
+
* was edited externally.
|
|
40
|
+
*/
|
|
41
|
+
syncActiveAccounts(): Partial<Record<SubscriptionProvider, string>>;
|
|
42
|
+
/**
|
|
43
|
+
* Start the periodic background refresh timer.
|
|
44
|
+
*/
|
|
45
|
+
private startPeriodicRefresh;
|
|
46
|
+
/**
|
|
47
|
+
* Reset the periodic timer - called after any actual refresh to
|
|
48
|
+
* restart the countdown.
|
|
49
|
+
*/
|
|
50
|
+
private resetPeriodicTimer;
|
|
51
|
+
/**
|
|
52
|
+
* Clean up the periodic timer. Call when the plugin is shutting down.
|
|
53
|
+
*/
|
|
54
|
+
dispose(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Handle slash command: /subscriptions.
|
|
57
|
+
*/
|
|
58
|
+
handleCommandExecuteBefore(input: {
|
|
59
|
+
command: string;
|
|
60
|
+
sessionID: string;
|
|
61
|
+
arguments: string;
|
|
62
|
+
}, output: {
|
|
63
|
+
parts: Array<{
|
|
64
|
+
type: string;
|
|
65
|
+
text?: string;
|
|
66
|
+
}>;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
private handleSubscriptionsCommand;
|
|
69
|
+
/**
|
|
70
|
+
* Register /subscriptions command in OpenCode config.
|
|
71
|
+
*/
|
|
72
|
+
registerCommand(opencodeConfig: Record<string, unknown>): void;
|
|
73
|
+
}
|
|
74
|
+
export declare function createUsageService(client: PluginInput['client'], refreshIntervalMs?: number, periodicIntervalMs?: number): UsageService;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CliLanguage, SgResult } from './types';
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
pattern: string;
|
|
4
|
+
lang: CliLanguage;
|
|
5
|
+
paths?: string[];
|
|
6
|
+
globs?: string[];
|
|
7
|
+
rewrite?: string;
|
|
8
|
+
context?: number;
|
|
9
|
+
updateAll?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function getAstGrepPath(): Promise<string | null>;
|
|
12
|
+
export declare function startBackgroundInit(): void;
|
|
13
|
+
export declare function runSg(options: RunOptions): Promise<SgResult>;
|
|
14
|
+
export declare function isCliAvailable(): boolean;
|
|
15
|
+
export declare function ensureCliAvailable(): Promise<boolean>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CLI_LANGUAGES } from './types';
|
|
2
|
+
export declare function findSgCliPathSync(): string | null;
|
|
3
|
+
export declare function getSgCliPath(): string;
|
|
4
|
+
export declare function setSgCliPath(path: string): void;
|
|
5
|
+
export { CLI_LANGUAGES };
|
|
6
|
+
export declare const DEFAULT_TIMEOUT_MS = 300000;
|
|
7
|
+
export declare const DEFAULT_MAX_OUTPUT_BYTES: number;
|
|
8
|
+
export declare const DEFAULT_MAX_MATCHES = 500;
|
|
9
|
+
export declare const LANG_EXTENSIONS: Record<string, string[]>;
|
|
10
|
+
export interface EnvironmentCheckResult {
|
|
11
|
+
cli: {
|
|
12
|
+
available: boolean;
|
|
13
|
+
path: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if ast-grep CLI is available.
|
|
19
|
+
* Call this at startup to provide early feedback about missing dependencies.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkEnvironment(): EnvironmentCheckResult;
|
|
22
|
+
/**
|
|
23
|
+
* Format environment check result as user-friendly message.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatEnvironmentCheck(result: EnvironmentCheckResult): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getCacheDir(): string;
|
|
2
|
+
export declare function getBinaryName(): string;
|
|
3
|
+
export declare function getCachedBinaryPath(): string | null;
|
|
4
|
+
export declare function downloadAstGrep(version?: string): Promise<string | null>;
|
|
5
|
+
export declare function ensureAstGrepBinary(): Promise<string | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@opencode-ai/plugin';
|
|
2
|
+
import { ast_grep_replace, ast_grep_search } from './tools';
|
|
3
|
+
export declare const builtinTools: Record<string, ToolDefinition>;
|
|
4
|
+
export { ensureCliAvailable, getAstGrepPath, isCliAvailable, startBackgroundInit, } from './cli';
|
|
5
|
+
export type { EnvironmentCheckResult } from './constants';
|
|
6
|
+
export { checkEnvironment, formatEnvironmentCheck } from './constants';
|
|
7
|
+
export { ensureAstGrepBinary, getCacheDir, getCachedBinaryPath, } from './downloader';
|
|
8
|
+
export type { CliLanguage, CliMatch, SgResult } from './types';
|
|
9
|
+
export { CLI_LANGUAGES } from './types';
|
|
10
|
+
export { ast_grep_replace, ast_grep_search };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const CLI_LANGUAGES: readonly ["bash", "c", "cpp", "csharp", "css", "elixir", "go", "haskell", "html", "java", "javascript", "json", "kotlin", "lua", "nix", "php", "python", "ruby", "rust", "scala", "solidity", "swift", "typescript", "tsx", "yaml"];
|
|
2
|
+
export type CliLanguage = (typeof CLI_LANGUAGES)[number];
|
|
3
|
+
export interface CliMatch {
|
|
4
|
+
file: string;
|
|
5
|
+
range: {
|
|
6
|
+
byteOffset: {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
};
|
|
10
|
+
start: {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
};
|
|
14
|
+
end: {
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
lines: string;
|
|
20
|
+
text: string;
|
|
21
|
+
replacement?: string;
|
|
22
|
+
language: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SgResult {
|
|
25
|
+
matches: CliMatch[];
|
|
26
|
+
totalMatches: number;
|
|
27
|
+
truncated: boolean;
|
|
28
|
+
truncatedReason?: 'timeout' | 'max_output_bytes' | 'max_matches';
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CliLanguage, SgResult } from './types';
|
|
2
|
+
export declare function formatSearchResult(result: SgResult): string;
|
|
3
|
+
export declare function formatReplaceResult(result: SgResult, isDryRun: boolean): string;
|
|
4
|
+
export declare function getEmptyResultHint(pattern: string, lang: CliLanguage): string | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@opencode-ai/plugin';
|
|
2
|
+
import type { PluginConfig } from '../config';
|
|
3
|
+
import type { SubagentDepthTracker } from '../utils/subagent-depth';
|
|
4
|
+
/**
|
|
5
|
+
* When true, blocking `delegate_subagent` keeps the child session open and
|
|
6
|
+
* appends `<delegate_session_continue .../>` for `continue_session_id` flows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function subagentOutputRequestsUserHandoff(text: string): boolean;
|
|
9
|
+
type OpencodeClient = import('@opencode-ai/plugin').PluginInput['client'];
|
|
10
|
+
export declare function createDelegateTools(ctx: {
|
|
11
|
+
client: OpencodeClient;
|
|
12
|
+
directory: string;
|
|
13
|
+
}, config: PluginConfig | undefined, depthTracker: SubagentDepthTracker | undefined): Record<string, ToolDefinition>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ast_grep_replace, ast_grep_search } from './ast-grep';
|
|
2
|
+
export { createDelegateTools, subagentOutputRequestsUserHandoff, } from './delegate';
|
|
3
|
+
export type { PresetManager } from './preset-manager';
|
|
4
|
+
export { createPresetManager } from './preset-manager';
|
|
5
|
+
export { createWebfetchTool } from './smartfetch';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
import type { PluginConfig } from '../config';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a preset manager for the /preset slash command.
|
|
5
|
+
*
|
|
6
|
+
* Uses the OpenCode SDK's client.config.update() to change agent models
|
|
7
|
+
* and temperatures without restarting. The server invalidates its agent
|
|
8
|
+
* cache and re-reads config on the next prompt.
|
|
9
|
+
*
|
|
10
|
+
* Note: activePreset is tracked in-memory only and resets on plugin reload.
|
|
11
|
+
* If the user manually edits config or another mechanism changes agents,
|
|
12
|
+
* this tracker may become stale until the next /preset call.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createPresetManager(ctx: PluginInput, config: PluginConfig): {
|
|
15
|
+
handleCommandExecuteBefore: (input: {
|
|
16
|
+
command: string;
|
|
17
|
+
sessionID: string;
|
|
18
|
+
arguments: string;
|
|
19
|
+
}, output: {
|
|
20
|
+
parts: Array<{
|
|
21
|
+
type: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
registerCommand: (opencodeConfig: Record<string, unknown>) => void;
|
|
26
|
+
};
|
|
27
|
+
export type PresetManager = ReturnType<typeof createPresetManager>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BinaryFetch } from './types';
|
|
2
|
+
export declare function buildBinaryResultMessage(fetchResult: BinaryFetch, savedPath?: string): string;
|
|
3
|
+
export declare function saveBinary(binaryDir: string, data: Uint8Array, contentType: string, filename?: string): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-cache';
|
|
2
|
+
import type { FetchResult } from './types';
|
|
3
|
+
export declare const CACHE: LRUCache<string, FetchResult, unknown>;
|
|
4
|
+
export declare function buildCacheKey(url: string, extractMain: boolean, preferLlmsTxt: 'auto' | 'always' | 'never', saveBinary: boolean): string;
|
|
5
|
+
export declare function cacheFetchResult(fetchResult: FetchResult, extractMain: boolean, preferLlmsTxt: 'auto' | 'always' | 'never', saveBinary: boolean): void;
|
|
6
|
+
export declare function isInvalidLlmsResult(fetchResult: FetchResult | undefined): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DOCS_HOST_SUFFIXES: string[];
|
|
2
|
+
export declare const DOCS_HOST_PREFIXES: string[];
|
|
3
|
+
export declare const MAX_REDIRECTS = 10;
|
|
4
|
+
export declare const MAX_RESPONSE_BYTES: number;
|
|
5
|
+
export declare const MAX_BINARY_DOWNLOAD_BYTES: number;
|
|
6
|
+
export declare const DEFAULT_TIMEOUT_SECONDS = 30;
|
|
7
|
+
export declare const MAX_TIMEOUT_SECONDS = 120;
|
|
8
|
+
export declare const MAX_LLMS_PROBE_TIMEOUT_MS = 8000;
|
|
9
|
+
export declare const MAX_MODEL_CONTENT_CHARS = 100000;
|
|
10
|
+
export declare const DEFAULT_ACCEPT_LANGUAGE = "en;q=0.8,*;q=0.5";
|
|
11
|
+
export declare const BINARY_PREFIXES: string[];
|
|
12
|
+
export declare const WEBFETCH_DESCRIPTION = "Fetch a URL with better extraction for static/docs pages. Supports llms.txt probing, content-focused HTML extraction, metadata, redirects, and an optional prompt processed by a cheap secondary model.";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BinaryFetch, DecodedBody, FetchResult, FetchWithRedirectsResult, LlmsProbeResult } from './types';
|
|
2
|
+
export declare function normalizeUrl(input: string): {
|
|
3
|
+
url: string;
|
|
4
|
+
upgradedToHttps: boolean;
|
|
5
|
+
fallbackUrl: string | undefined;
|
|
6
|
+
originalUrl: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function isDocsLikeUrl(url: URL): boolean;
|
|
9
|
+
export declare function buildPermissionPatterns(normalized: ReturnType<typeof normalizeUrl>, shouldProbeLlmsTxt: boolean): string[];
|
|
10
|
+
export declare function buildAllowedOrigins(patterns: string[]): Set<string>;
|
|
11
|
+
export declare function canUseCanonicalCacheAlias(baseUrl: string, aliasUrl: string): boolean;
|
|
12
|
+
export declare function isBinaryContentType(contentType: string): boolean;
|
|
13
|
+
export declare function getBinaryKind(contentType: string): BinaryFetch['binaryKind'];
|
|
14
|
+
export declare function looksLikeHtmlText(text: string): boolean;
|
|
15
|
+
export declare function runWithScopedTimeout<T>(parentSignal: AbortSignal, timeoutMs: number, fn: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
16
|
+
export declare function readBodyLimited(response: Response, maxBytes?: number): Promise<{
|
|
17
|
+
data: Uint8Array<ArrayBuffer>;
|
|
18
|
+
truncated: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function fetchWithRedirects(url: string, _timeoutMs: number, format: 'text' | 'markdown' | 'html', signal: AbortSignal, extraHeaders?: Record<string, string>, method?: 'GET' | 'HEAD', allowedOrigins?: Set<string>): Promise<FetchWithRedirectsResult>;
|
|
21
|
+
export declare function fetchWithUpgradeFallback(normalized: ReturnType<typeof normalizeUrl>, timeoutMs: number, format: 'text' | 'markdown' | 'html', signal: AbortSignal, extraHeaders?: Record<string, string>, method?: 'GET' | 'HEAD', allowedOrigins?: Set<string>): Promise<{
|
|
22
|
+
result: FetchWithRedirectsResult;
|
|
23
|
+
upgradedToHttps: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function isHtmlLikeContentType(contentType: string): boolean;
|
|
26
|
+
export declare function decodeBody(data: Uint8Array, charset: string | undefined, contentType?: string): DecodedBody;
|
|
27
|
+
export declare function looksLikeTextBody(data: Uint8Array): boolean;
|
|
28
|
+
export declare function isGenericBinaryMime(contentType: string): boolean;
|
|
29
|
+
export declare function extractHeaderMetadata(headers: Headers, finalUrl: string): {
|
|
30
|
+
contentType: string | undefined;
|
|
31
|
+
charset: string | undefined;
|
|
32
|
+
etag: string | undefined;
|
|
33
|
+
lastModified: string | undefined;
|
|
34
|
+
contentLength: number | undefined;
|
|
35
|
+
filename: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
export declare function buildConditionalHeaders(cached: FetchResult | undefined): Record<string, string> | undefined;
|
|
38
|
+
export declare function probeLlmsText(url: URL, timeoutMs: number, signal: AbortSignal, fallbackOrigin?: string): Promise<LlmsProbeResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
import type { CachedFetch, SecondaryModel } from './types';
|
|
3
|
+
type OpenCodeClient = PluginInput['client'];
|
|
4
|
+
export declare function readSecondaryModelFromConfig(directory: string): Promise<SecondaryModel[]>;
|
|
5
|
+
export declare function decideSecondaryModelUse(fetchResult: CachedFetch, prompt: string | undefined, secondaryModels: SecondaryModel[]): {
|
|
6
|
+
use: boolean;
|
|
7
|
+
reason: "no_prompt";
|
|
8
|
+
} | {
|
|
9
|
+
use: boolean;
|
|
10
|
+
reason: "no_secondary_model_configured";
|
|
11
|
+
} | {
|
|
12
|
+
use: boolean;
|
|
13
|
+
reason: "empty_content";
|
|
14
|
+
} | {
|
|
15
|
+
use: boolean;
|
|
16
|
+
reason: "content_too_short";
|
|
17
|
+
} | {
|
|
18
|
+
use: boolean;
|
|
19
|
+
reason: "prompt_present";
|
|
20
|
+
};
|
|
21
|
+
export declare function runSecondaryModelWithFallback(client: OpenCodeClient, directory: string, models: SecondaryModel[], prompt: string, content: string): Promise<{
|
|
22
|
+
model: SecondaryModel;
|
|
23
|
+
text: string;
|
|
24
|
+
inputTruncated: boolean;
|
|
25
|
+
inputChars: number;
|
|
26
|
+
sourceChars: number;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|