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,122 @@
|
|
|
1
|
+
export type SmartfetchOptions = {
|
|
2
|
+
binaryDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type SecondaryModel = {
|
|
5
|
+
providerID: string;
|
|
6
|
+
modelID: string;
|
|
7
|
+
};
|
|
8
|
+
export type RedirectStep = {
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
status: number;
|
|
12
|
+
};
|
|
13
|
+
export type CachedFetch = {
|
|
14
|
+
requestedUrl: string;
|
|
15
|
+
finalUrl: string;
|
|
16
|
+
statusCode: number;
|
|
17
|
+
contentType: string;
|
|
18
|
+
charset?: string;
|
|
19
|
+
etag?: string;
|
|
20
|
+
lastModified?: string;
|
|
21
|
+
contentLength?: number;
|
|
22
|
+
filename?: string;
|
|
23
|
+
canonicalUrl?: string;
|
|
24
|
+
headings?: string[];
|
|
25
|
+
title?: string;
|
|
26
|
+
rawContent: string;
|
|
27
|
+
markdown: string;
|
|
28
|
+
text: string;
|
|
29
|
+
html: string;
|
|
30
|
+
extractedMain: boolean;
|
|
31
|
+
usedLlmsTxt: boolean;
|
|
32
|
+
sourceKind: 'llms_txt' | 'html' | 'text';
|
|
33
|
+
upgradedToHttps: boolean;
|
|
34
|
+
redirectChain: RedirectStep[];
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
wordCount: number;
|
|
37
|
+
qualitySignals?: string[];
|
|
38
|
+
llmsProbeError?: string;
|
|
39
|
+
llmsProbeTruncated?: boolean;
|
|
40
|
+
cacheRevalidated?: boolean;
|
|
41
|
+
upstreamStatusCode?: number;
|
|
42
|
+
cacheHit?: boolean;
|
|
43
|
+
decodedCharset?: string;
|
|
44
|
+
decodeFallback?: boolean;
|
|
45
|
+
decodeWarning?: string;
|
|
46
|
+
secondaryModelInputTruncated?: boolean;
|
|
47
|
+
secondaryModelInputChars?: number;
|
|
48
|
+
secondaryModelSourceChars?: number;
|
|
49
|
+
};
|
|
50
|
+
export type BinaryFetch = {
|
|
51
|
+
requestedUrl: string;
|
|
52
|
+
finalUrl: string;
|
|
53
|
+
statusCode: number;
|
|
54
|
+
contentType: string;
|
|
55
|
+
charset?: string;
|
|
56
|
+
etag?: string;
|
|
57
|
+
lastModified?: string;
|
|
58
|
+
contentLength?: number;
|
|
59
|
+
filename?: string;
|
|
60
|
+
canonicalUrl?: string;
|
|
61
|
+
redirectChain: RedirectStep[];
|
|
62
|
+
upgradedToHttps: boolean;
|
|
63
|
+
truncated: boolean;
|
|
64
|
+
binary: true;
|
|
65
|
+
binaryKind: 'image' | 'audio' | 'video' | 'pdf' | 'binary';
|
|
66
|
+
downloadLimitBytes?: number;
|
|
67
|
+
metadataOnly?: boolean;
|
|
68
|
+
data?: Uint8Array;
|
|
69
|
+
llmsProbeError?: string;
|
|
70
|
+
llmsProbeTruncated?: boolean;
|
|
71
|
+
cacheRevalidated?: boolean;
|
|
72
|
+
upstreamStatusCode?: number;
|
|
73
|
+
cacheHit?: boolean;
|
|
74
|
+
};
|
|
75
|
+
export type FetchResult = CachedFetch | BinaryFetch;
|
|
76
|
+
export type DecodedBody = {
|
|
77
|
+
text: string;
|
|
78
|
+
decodedCharset: string;
|
|
79
|
+
decodeFallback: boolean;
|
|
80
|
+
decodeWarning?: string;
|
|
81
|
+
};
|
|
82
|
+
export type ExtractedContent = {
|
|
83
|
+
title?: string;
|
|
84
|
+
rawContent: string;
|
|
85
|
+
markdown: string;
|
|
86
|
+
text: string;
|
|
87
|
+
html: string;
|
|
88
|
+
extractedMain: boolean;
|
|
89
|
+
canonicalUrl?: string;
|
|
90
|
+
headings?: string[];
|
|
91
|
+
};
|
|
92
|
+
export type FetchWithRedirectsResult = {
|
|
93
|
+
blockedRedirect: true;
|
|
94
|
+
redirectUrl: string;
|
|
95
|
+
statusCode: number;
|
|
96
|
+
redirectChain: RedirectStep[];
|
|
97
|
+
} | {
|
|
98
|
+
response: Response;
|
|
99
|
+
finalUrl: string;
|
|
100
|
+
redirectChain: RedirectStep[];
|
|
101
|
+
};
|
|
102
|
+
export type LlmsProbeResult = {
|
|
103
|
+
url: string;
|
|
104
|
+
statusCode: number;
|
|
105
|
+
redirectChain: RedirectStep[];
|
|
106
|
+
text: string;
|
|
107
|
+
headers: {
|
|
108
|
+
contentType?: string;
|
|
109
|
+
charset?: string;
|
|
110
|
+
etag?: string;
|
|
111
|
+
lastModified?: string;
|
|
112
|
+
contentLength?: number;
|
|
113
|
+
filename?: string;
|
|
114
|
+
};
|
|
115
|
+
truncated: boolean;
|
|
116
|
+
decodedCharset: string;
|
|
117
|
+
decodeFallback: boolean;
|
|
118
|
+
decodeWarning?: string;
|
|
119
|
+
upgradedToHttps: boolean;
|
|
120
|
+
} | {
|
|
121
|
+
error?: string;
|
|
122
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CachedFetch, ExtractedContent } from './types';
|
|
2
|
+
export declare function wordCount(text: string): number;
|
|
3
|
+
export declare function frontmatter(metadata: Record<string, unknown>): string;
|
|
4
|
+
export declare function trimBlankRuns(input: string): string;
|
|
5
|
+
export declare function cleanHeadingText(input: string): string;
|
|
6
|
+
export declare function cleanFetchedMarkdown(input: string): string;
|
|
7
|
+
export declare function cleanFetchedText(input: string): string;
|
|
8
|
+
export declare function escapeHtml(input: string): string;
|
|
9
|
+
export declare function withTruncationMarker(content: string, format: 'text' | 'markdown' | 'html', truncated: boolean): string;
|
|
10
|
+
export declare function joinRenderedContent(metadata: string, content: string, format: 'text' | 'markdown' | 'html'): string;
|
|
11
|
+
export declare function renderMessageForFormat(content: string, format: 'text' | 'markdown' | 'html'): string;
|
|
12
|
+
export declare function buildRedirectResultMessage(originalUrl: string, redirectUrl: string, statusCode: number): string;
|
|
13
|
+
export declare function buildLlmsRequiredMessage(originalUrl: string, reason?: string): string;
|
|
14
|
+
export declare function extractFromHtml(html: string, finalUrl: string, extractMain: boolean): Promise<ExtractedContent>;
|
|
15
|
+
export declare function inferCanonicalUrlFromText(content: string, finalUrl: string): string | undefined;
|
|
16
|
+
export declare function extractHeadingsFromMarkdown(content: string): string[] | undefined;
|
|
17
|
+
export declare function detectQualitySignals(fetchResult: Pick<CachedFetch, 'text' | 'markdown' | 'rawContent' | 'wordCount' | 'sourceKind' | 'extractedMain'>): string[];
|
|
18
|
+
export declare function pickContent(fetchResult: CachedFetch, format: 'text' | 'markdown' | 'html'): string;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { SubscriptionProvider, SubscriptionUsageEntry } from './subscriptions/types';
|
|
2
|
+
export type { SubscriptionUsageEntry };
|
|
3
|
+
/** Sidebar state for one OpenCode session (orchestrator or subagent). */
|
|
4
|
+
export interface SessionNode {
|
|
5
|
+
title: string;
|
|
6
|
+
agent: string;
|
|
7
|
+
model: string;
|
|
8
|
+
variant?: string;
|
|
9
|
+
parentId?: string;
|
|
10
|
+
childIds: string[];
|
|
11
|
+
status: 'busy' | 'idle' | 'retry';
|
|
12
|
+
mode?: 'blocking' | 'fire_forget';
|
|
13
|
+
createdAt: number;
|
|
14
|
+
finishedAt?: number;
|
|
15
|
+
usage?: SessionUsageEntry;
|
|
16
|
+
}
|
|
17
|
+
export interface SessionUsageEntry {
|
|
18
|
+
contextUsed: number;
|
|
19
|
+
contextLimit: number;
|
|
20
|
+
contextPct: number;
|
|
21
|
+
input: number;
|
|
22
|
+
output: number;
|
|
23
|
+
reasoning: number;
|
|
24
|
+
cacheRead: number;
|
|
25
|
+
cacheWrite: number;
|
|
26
|
+
updatedAt: number;
|
|
27
|
+
}
|
|
28
|
+
export interface OrchestrationSigmaAccum {
|
|
29
|
+
contextUsed: number;
|
|
30
|
+
input: number;
|
|
31
|
+
output: number;
|
|
32
|
+
cacheRead: number;
|
|
33
|
+
cacheWrite: number;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionUsageDeltaBasis {
|
|
36
|
+
contextUsed: number;
|
|
37
|
+
input: number;
|
|
38
|
+
output: number;
|
|
39
|
+
cacheRead: number;
|
|
40
|
+
cacheWrite: number;
|
|
41
|
+
}
|
|
42
|
+
/** One OpenCode orchestration/session tree keyed by root session id. */
|
|
43
|
+
export interface TuiSessionBundle {
|
|
44
|
+
rootSessionId: string;
|
|
45
|
+
lastActivityAt: number;
|
|
46
|
+
projectPath?: string;
|
|
47
|
+
tree: Record<string, SessionNode>;
|
|
48
|
+
orchestrationSigmaAccum?: OrchestrationSigmaAccum;
|
|
49
|
+
orchestrationUsageLastSeen: Record<string, SessionUsageDeltaBasis>;
|
|
50
|
+
}
|
|
51
|
+
export interface TuiSnapshot {
|
|
52
|
+
version: 6;
|
|
53
|
+
updatedAt: number;
|
|
54
|
+
sessions: Record<string, TuiSessionBundle>;
|
|
55
|
+
subscriptionUsage: Record<string, SubscriptionUsageEntry>;
|
|
56
|
+
activeSubscriptionByProvider: Partial<Record<SubscriptionProvider, string>>;
|
|
57
|
+
}
|
|
58
|
+
export declare const sessionTreeStore: Record<string, SessionNode>;
|
|
59
|
+
export declare const SESSION_BUNDLE_RETENTION_MS: number;
|
|
60
|
+
/** Normalized resolved directory for comparisons. */
|
|
61
|
+
export declare function normalizeProjectDirectory(raw: string): string;
|
|
62
|
+
export declare function mergedSessionTree(snapshot: TuiSnapshot): Record<string, SessionNode>;
|
|
63
|
+
/** 0-100, from current context used ÷ limit (single source of truth for CTX %). */
|
|
64
|
+
export declare function deriveSessionContextPct(used: number, limit: number): number;
|
|
65
|
+
/** Token / model telemetry merged from nodes (see {@link SessionNode.usage}). */
|
|
66
|
+
export declare function mergedSessionUsage(snapshot: TuiSnapshot): Record<string, SessionUsageEntry>;
|
|
67
|
+
export declare function mergedSessionModels(snapshot: TuiSnapshot): Record<string, string>;
|
|
68
|
+
export declare function mergedSessionVariants(snapshot: TuiSnapshot): Record<string, string>;
|
|
69
|
+
export declare function mergedOrchestrationUsageLastSeen(snapshot: TuiSnapshot): Record<string, SessionUsageDeltaBasis>;
|
|
70
|
+
export declare function mergedOrchestrationSigmaAccum(snapshot: TuiSnapshot): Record<string, OrchestrationSigmaAccum>;
|
|
71
|
+
export declare function mapOpenCodeStatusToTreeStatus(raw: string): 'busy' | 'idle' | 'retry';
|
|
72
|
+
export declare function syncOpenCodeStatusesIntoSessionTree(snapshot: TuiSnapshot, statuses: Record<string, {
|
|
73
|
+
type: string;
|
|
74
|
+
}>): void;
|
|
75
|
+
export declare function expandMissingSessionCascade(mergedTree: Record<string, SessionNode>, seeds: Iterable<string>): Set<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Drop idle bundles (TTL, whole-tree gone from OpenCode) and soft-prune
|
|
78
|
+
* sessions missing from {@link input.opencodeIds}. Soft-prune skips any id
|
|
79
|
+
* still present in that set so incomplete polls cannot idle a busy child
|
|
80
|
+
* whose parent row was omitted. Ancestors are skipped while any polled id is
|
|
81
|
+
* still their descendant (avoids idling the orchestrator and clearing sigma
|
|
82
|
+
* when the poll omits the root). If incomplete polls persist, callers may add
|
|
83
|
+
* debouncing or skip soft-prune when poll cardinality collapses abruptly.
|
|
84
|
+
*/
|
|
85
|
+
export declare function pruneStaleTuiSessionBundles(snapshot: TuiSnapshot, input: {
|
|
86
|
+
opencodeIds: ReadonlySet<string>;
|
|
87
|
+
currentProjectDir: string;
|
|
88
|
+
now: number;
|
|
89
|
+
}): Set<string>;
|
|
90
|
+
export declare function getTuiStatePath(): string;
|
|
91
|
+
export declare function readTuiSnapshot(): TuiSnapshot;
|
|
92
|
+
export declare function readTuiSnapshotAsync(): Promise<TuiSnapshot>;
|
|
93
|
+
export declare function updateSnapshot(mutator: (snapshot: TuiSnapshot) => void): void;
|
|
94
|
+
/**
|
|
95
|
+
* Resolves after any pending synchronous `updateSnapshot` work on this thread
|
|
96
|
+
* has finished (writes are synchronous today).
|
|
97
|
+
*/
|
|
98
|
+
export declare function flushTuiSnapshot(): Promise<void>;
|
|
99
|
+
export type RecordSessionUsageInput = {
|
|
100
|
+
sessionID: string;
|
|
101
|
+
contextUsed?: number;
|
|
102
|
+
contextLimit?: number;
|
|
103
|
+
contextPct?: number;
|
|
104
|
+
input: number;
|
|
105
|
+
output: number;
|
|
106
|
+
reasoning: number;
|
|
107
|
+
cacheRead: number;
|
|
108
|
+
cacheWrite: number;
|
|
109
|
+
};
|
|
110
|
+
export declare function recordSessionUsagesBatch(inputs: RecordSessionUsageInput[]): void;
|
|
111
|
+
/**
|
|
112
|
+
* One persisted write for delegate-spawned subagent: tree node + parent
|
|
113
|
+
* `childIds` + {@link sessionTreeStore} parent link.
|
|
114
|
+
*/
|
|
115
|
+
export declare function recordDelegatedSubagentSession(input: {
|
|
116
|
+
sessionID: string;
|
|
117
|
+
parentSessionId: string;
|
|
118
|
+
agent: string;
|
|
119
|
+
variant?: string;
|
|
120
|
+
mode?: 'blocking' | 'fire_forget';
|
|
121
|
+
}): void;
|
|
122
|
+
/**
|
|
123
|
+
* One persisted write for `session.created`: node, optional parent `childIds`,
|
|
124
|
+
* optional project path.
|
|
125
|
+
*/
|
|
126
|
+
export declare function recordChildSessionSnapshot(input: {
|
|
127
|
+
sessionID: string;
|
|
128
|
+
title: string;
|
|
129
|
+
parentSessionId?: string;
|
|
130
|
+
projectPath?: string;
|
|
131
|
+
}): void;
|
|
132
|
+
export declare function patchSessionTreeStatusFromOpenCode(sessionID: string, rawType: string): void;
|
|
133
|
+
export declare function recordSessionEnd(sessionID: string): void;
|
|
134
|
+
export declare function recordSessionModel(input: {
|
|
135
|
+
sessionID: string;
|
|
136
|
+
model: string;
|
|
137
|
+
}): void;
|
|
138
|
+
export declare function recordSessionVariant(input: {
|
|
139
|
+
sessionID: string;
|
|
140
|
+
variant: string;
|
|
141
|
+
}): void;
|
|
142
|
+
export declare function recordSessionNode(input: {
|
|
143
|
+
sessionID: string;
|
|
144
|
+
/** Omit to keep the existing title (e.g. from `session.created`). Pass `''` to clear. */
|
|
145
|
+
title?: string;
|
|
146
|
+
agent: string;
|
|
147
|
+
model?: string;
|
|
148
|
+
variant?: string;
|
|
149
|
+
parentId?: string;
|
|
150
|
+
mode?: 'blocking' | 'fire_forget';
|
|
151
|
+
status?: 'busy' | 'idle' | 'retry';
|
|
152
|
+
}): void;
|
|
153
|
+
/** Persist session title from OpenCode when the SDK reports a non-empty name. */
|
|
154
|
+
export declare function recordSessionTitle(input: {
|
|
155
|
+
sessionID: string;
|
|
156
|
+
title: string;
|
|
157
|
+
}): void;
|
|
158
|
+
export declare function recordSessionDone(sessionID: string): void;
|
|
159
|
+
export declare function recordSessionUsage(input: RecordSessionUsageInput): void;
|
|
160
|
+
export declare function subscriptionUsageKey(provider: SubscriptionProvider, accountName: string): string;
|
|
161
|
+
export declare function recordSubscriptionUsage(usage: SubscriptionUsageEntry[]): void;
|
|
162
|
+
export declare function removeSubscriptionUsageEntry(provider: SubscriptionProvider, name: string): void;
|
|
163
|
+
export declare function recordSessionProject(input: {
|
|
164
|
+
sessionID: string;
|
|
165
|
+
projectPath: string;
|
|
166
|
+
}): void;
|
|
167
|
+
export declare function deleteSessionEntries(sessionID: string): void;
|
|
168
|
+
export declare function recordActiveSubscriptionForProvider(provider: SubscriptionProvider, name: string | null): void;
|
package/dist/tui.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TuiPluginModule } from '@opencode-ai/plugin/tui';
|
|
2
|
+
import { type TuiSnapshot } from './tui-state';
|
|
3
|
+
export declare function formatTokenAbbrev(value: number): string;
|
|
4
|
+
export declare function formatTokenAbbrevDecimal(value: number): string;
|
|
5
|
+
export declare function formatSidebarModelName(model: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Show `provider/model-id` compactly: shorten long basenames on hyphen
|
|
8
|
+
* boundaries, then append the OpenCode `variant` in full (`model… - High`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatSidebarModelAndVariant(rawModel: string | undefined, variant: string | undefined, maxModelDisplayLen?: number): string;
|
|
11
|
+
export declare function formatAgentName(name: string): string;
|
|
12
|
+
export declare function formatDuration(ms: number): string;
|
|
13
|
+
export declare function formatSessionUsageRows(snapshot: TuiSnapshot, sessionID: string, options?: {
|
|
14
|
+
abbreviateLeft?: boolean;
|
|
15
|
+
}): {
|
|
16
|
+
contextPct: number;
|
|
17
|
+
ctxLabel: string;
|
|
18
|
+
ctxValue: string;
|
|
19
|
+
ioInputAbbrev: string;
|
|
20
|
+
ioOutputAbbrev: string;
|
|
21
|
+
cacheLabel: string;
|
|
22
|
+
cacheValue: string;
|
|
23
|
+
cacheReadAbbrev: string;
|
|
24
|
+
cacheWriteAbbrev: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function aggregateOrchestrationUsage(snapshot: TuiSnapshot, rootSessionID: string): {
|
|
27
|
+
inputTotal: number;
|
|
28
|
+
outputTotal: number;
|
|
29
|
+
cacheRead: number;
|
|
30
|
+
cacheWrite: number;
|
|
31
|
+
contextUsed: number;
|
|
32
|
+
};
|
|
33
|
+
export declare function getSidebarAgentNames(snapshot: TuiSnapshot): string[];
|
|
34
|
+
declare const plugin: TuiPluginModule & {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
export default plugin;
|