cursor-opencode-provider 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/README.md +204 -37
- package/SECURITY.md +20 -8
- package/dist/activity.d.ts +73 -1
- package/dist/activity.js +231 -5
- package/dist/agent-url.js +37 -9
- package/dist/auth-renewal.d.ts +1 -1
- package/dist/auth-renewal.js +58 -26
- package/dist/billing.d.ts +105 -0
- package/dist/billing.js +212 -0
- package/dist/classic-tool-results.d.ts +1 -0
- package/dist/classic-tool-results.js +42 -0
- package/dist/context/build.d.ts +1 -0
- package/dist/context/build.js +32 -5
- package/dist/context/env.js +27 -3
- package/dist/context/epoch.js +9 -5
- package/dist/context/git.d.ts +5 -2
- package/dist/context/git.js +17 -7
- package/dist/context/paths.d.ts +1 -1
- package/dist/context/paths.js +7 -4
- package/dist/debug.js +13 -2
- package/dist/early-tool-rows.d.ts +60 -0
- package/dist/early-tool-rows.js +96 -0
- package/dist/errors.d.ts +49 -7
- package/dist/errors.js +163 -8
- package/dist/host-interrupt.d.ts +12 -0
- package/dist/host-interrupt.js +18 -0
- package/dist/host-steer.d.ts +71 -0
- package/dist/host-steer.js +232 -0
- package/dist/image-input.js +4 -3
- package/dist/index.d.ts +2 -2
- package/dist/language-model.d.ts +114 -23
- package/dist/language-model.js +2290 -469
- package/dist/lost-request.d.ts +39 -0
- package/dist/lost-request.js +111 -0
- package/dist/model-config.d.ts +3 -1
- package/dist/model-config.js +50 -29
- package/dist/models.d.ts +26 -3
- package/dist/models.js +101 -45
- package/dist/opencode2/tool-results.d.ts +18 -0
- package/dist/opencode2/tool-results.js +66 -0
- package/dist/plugin-opencode2.js +185 -25
- package/dist/plugin.js +28 -5
- package/dist/pricing-data.d.ts +26 -2
- package/dist/pricing-data.js +26 -2
- package/dist/pricing.d.ts +1 -1
- package/dist/pricing.js +7 -4
- package/dist/process-shared.d.ts +14 -0
- package/dist/process-shared.js +18 -0
- package/dist/protocol/apply-patch.d.ts +25 -13
- package/dist/protocol/apply-patch.js +79 -30
- package/dist/protocol/blob-store.d.ts +5 -1
- package/dist/protocol/blob-store.js +10 -6
- package/dist/protocol/client-version.js +6 -4
- package/dist/protocol/conversation-cache-header.d.ts +23 -0
- package/dist/protocol/conversation-cache-header.js +149 -0
- package/dist/protocol/conversation-persistence.d.ts +27 -1
- package/dist/protocol/conversation-persistence.js +628 -126
- package/dist/protocol/conversation-state.d.ts +8 -1
- package/dist/protocol/conversation-state.js +28 -7
- package/dist/protocol/host-notes.d.ts +31 -0
- package/dist/protocol/host-notes.js +85 -0
- package/dist/protocol/messages.js +91 -8
- package/dist/protocol/request.d.ts +35 -19
- package/dist/protocol/request.js +53 -28
- package/dist/protocol/sent-history-images.d.ts +49 -0
- package/dist/protocol/sent-history-images.js +102 -0
- package/dist/protocol/tool-call-bridge.d.ts +2 -0
- package/dist/protocol/tool-call-bridge.js +10 -0
- package/dist/protocol/tools.d.ts +74 -8
- package/dist/protocol/tools.js +431 -141
- package/dist/protocol/turn-provenance.d.ts +19 -4
- package/dist/protocol/turn-provenance.js +77 -20
- package/dist/replay-safety.d.ts +16 -4
- package/dist/replay-safety.js +34 -25
- package/dist/retry-budget.d.ts +21 -0
- package/dist/retry-budget.js +94 -0
- package/dist/runtime-files.d.ts +23 -0
- package/dist/runtime-files.js +581 -0
- package/dist/session.d.ts +94 -9
- package/dist/session.js +153 -34
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/shell-timeout.d.ts +54 -10
- package/dist/shell-timeout.js +362 -92
- package/dist/stream-write.d.ts +20 -0
- package/dist/stream-write.js +87 -0
- package/dist/terminal-runner.d.ts +15 -0
- package/dist/terminal-runner.js +528 -0
- package/dist/transport/connect.d.ts +8 -1
- package/dist/transport/connect.js +103 -23
- package/dist/usage.d.ts +37 -17
- package/dist/usage.js +63 -29
- package/package.json +3 -2
- package/dist/protocol/thinking.d.ts +0 -15
- package/dist/protocol/thinking.js +0 -17
package/dist/shell-timeout.d.ts
CHANGED
|
@@ -11,10 +11,16 @@ export type CursorShellPolicy = {
|
|
|
11
11
|
hardTimeoutMs?: number;
|
|
12
12
|
/** Immediate nohup detach for Cursor `background_shell_spawn_args`. */
|
|
13
13
|
backgroundSpawn?: boolean;
|
|
14
|
+
description?: string;
|
|
15
|
+
managedCommand?: string;
|
|
16
|
+
managedJobDirectory?: string;
|
|
17
|
+
shellPath?: string;
|
|
14
18
|
};
|
|
15
19
|
export type CursorShellOutcome = {
|
|
16
20
|
kind: "exit";
|
|
17
21
|
code: number;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "aborted";
|
|
18
24
|
} | {
|
|
19
25
|
kind: "timeout";
|
|
20
26
|
timeoutMs: number;
|
|
@@ -26,9 +32,27 @@ export type CursorShellOutcome = {
|
|
|
26
32
|
workingDirectory: string;
|
|
27
33
|
msToWait: number;
|
|
28
34
|
reason: 1;
|
|
35
|
+
/** Managed terminal record holding the command's output. */
|
|
36
|
+
outputFile?: string;
|
|
29
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Serialize OpenCode 2 shell creates onto their owning tool call. Call from
|
|
40
|
+
* `execute.before` after `prepareCursorShellArgs`, passing the hook event the
|
|
41
|
+
* host later executes. Every call arms, so an ordinary call cannot take a
|
|
42
|
+
* wrapped call's adapter; `prepareCursorShellCreate` releases the holder at
|
|
43
|
+
* its create. Only a create whose command a `create.before` hook rewrote
|
|
44
|
+
* cannot be attributed; that call keeps its own command's lane until
|
|
45
|
+
* `execute.after` or its failure.
|
|
46
|
+
*/
|
|
47
|
+
export declare function armCursorShellCreate(toolCallId: string, call: {
|
|
48
|
+
readonly input: unknown;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/** Release a create-before arm when the call is claimed, fails, or finishes. */
|
|
51
|
+
export declare function disarmCursorShellCreate(toolCallId: string): void;
|
|
30
52
|
/** Track OpenCode's configured shell from the classic config hook. */
|
|
31
|
-
export declare function setCursorShellPath(shell: string | undefined): void;
|
|
53
|
+
export declare function setCursorShellPath(shell: string | undefined, directory?: string): void;
|
|
54
|
+
/** The executable selected by native OpenCode config, with its POSIX fallback. */
|
|
55
|
+
export declare function resolveCursorShellPath(shell?: string, directory?: string): string;
|
|
32
56
|
/**
|
|
33
57
|
* Mirror the relevant part of OpenCode Shell.acceptable(): fish/nu are denied,
|
|
34
58
|
* then POSIX falls back to bash when installed and `/bin/sh` otherwise.
|
|
@@ -61,20 +85,22 @@ export declare function buildSoftBackgroundCommand(policy: CursorShellPolicy): s
|
|
|
61
85
|
* Residual: the detached child is not reaped by this provider after OpenCode
|
|
62
86
|
* completes the tool call; cleanup is left to the user / OS.
|
|
63
87
|
*/
|
|
64
|
-
export declare function buildBackgroundShellCommand(command: string): string;
|
|
88
|
+
export declare function buildBackgroundShellCommand(command: string, shellPath?: string): string;
|
|
65
89
|
/**
|
|
66
90
|
* Prepare OpenCode Bash args before execution when Cursor requested wrapping.
|
|
67
91
|
*
|
|
68
92
|
* bash/zsh source the shell.env injector, so the original command remains in
|
|
69
|
-
* OpenCode's permission/UI state. sh/dash ignore those startup variables;
|
|
70
|
-
*
|
|
93
|
+
* OpenCode's permission/UI state. sh/dash ignore those startup variables;
|
|
94
|
+
* managed jobs expose the complete launcher and payload for host approval.
|
|
71
95
|
*
|
|
72
96
|
* background_shell_spawn may already contain the inline non-plugin fallback.
|
|
73
97
|
* The classic hook replaces it with the original command (bash/zsh) or the
|
|
74
|
-
*
|
|
98
|
+
* inline managed launcher (sh/dash), avoiding duplicate execution.
|
|
75
99
|
*/
|
|
76
100
|
export declare function prepareCursorShellArgs(toolCallId: string, args: Record<string, unknown>, options?: {
|
|
77
101
|
preferWrapperCommand?: boolean;
|
|
102
|
+
deferToShellHook?: boolean;
|
|
103
|
+
shellPath?: string;
|
|
78
104
|
}): void;
|
|
79
105
|
/** Restore the model-facing command in OpenCode's completed tool title. */
|
|
80
106
|
export declare function cursorShellOriginalCommand(toolCallId: string): string | undefined;
|
|
@@ -86,11 +112,26 @@ export declare function releaseCursorShellEnv(toolCallId: string): void;
|
|
|
86
112
|
*/
|
|
87
113
|
export declare function cursorShellEnvForCall(toolCallId: string | undefined): Record<string, string> | undefined;
|
|
88
114
|
/**
|
|
89
|
-
* OpenCode 2.0
|
|
90
|
-
*
|
|
91
|
-
*
|
|
115
|
+
* OpenCode 2.0.27 calls create.before before its permission scanner, then
|
|
116
|
+
* spawns the selected executable with [-c, command]. Preserve that command
|
|
117
|
+
* and the shell basename the scanner uses. The adapter runs only after host
|
|
118
|
+
* approval, and uses the host's selected executable for the actual payload.
|
|
119
|
+
* Sources: upstream packages/core/src/shell.ts:274-305 and
|
|
120
|
+
* packages/core/src/tool/plugin/shell.ts:125-145 at v2.0.27.
|
|
121
|
+
*/
|
|
122
|
+
export declare function prepareCursorShellCreate(event: {
|
|
123
|
+
command: string;
|
|
124
|
+
cwd: string;
|
|
125
|
+
shell: string;
|
|
126
|
+
env: Record<string, string | undefined>;
|
|
127
|
+
}): void;
|
|
128
|
+
/**
|
|
129
|
+
* Turn a stored timeout display back into OpenCode's own timeout block, so a
|
|
130
|
+
* replayed result parses as the timeout it was after its saved outcome is gone.
|
|
92
131
|
*/
|
|
93
|
-
export declare function
|
|
132
|
+
export declare function restoreOpenCodeTimeout(display: string, timeoutMs: number): string;
|
|
133
|
+
/** The timeout recorded for a call whose result has not been consumed yet. */
|
|
134
|
+
export declare function cursorShellTimeoutMs(toolCallId: string): number | undefined;
|
|
94
135
|
/**
|
|
95
136
|
* Strip private wrapper sentinels / OpenCode timeout envelopes for display.
|
|
96
137
|
* Does not record outcomes — use {@link captureCursorShellResult} for that.
|
|
@@ -99,7 +140,7 @@ export declare function cursorShellEnvForCommand(command: string | undefined, wo
|
|
|
99
140
|
* a string. Non-string input is returned unchanged so the 2.0 after-hook can
|
|
100
141
|
* pass structured output through safely.
|
|
101
142
|
*/
|
|
102
|
-
export declare function sanitizeCursorShellDisplayOutput(output: string, policy?: CursorShellPolicy): string;
|
|
143
|
+
export declare function sanitizeCursorShellDisplayOutput(output: string, policy?: CursorShellPolicy, capturedOutcome?: CursorShellOutcome): string;
|
|
103
144
|
/** Sanitize a secondary display string (e.g. Bash `metadata.output`) for a registered call. */
|
|
104
145
|
export declare function sanitizeRegisteredCursorShellOutput(toolCallId: string, output: string): string;
|
|
105
146
|
/**
|
|
@@ -110,10 +151,13 @@ export declare function sanitizeRegisteredCursorShellOutput(toolCallId: string,
|
|
|
110
151
|
* by returning it unchanged.
|
|
111
152
|
*/
|
|
112
153
|
export declare function captureCursorShellResult(toolCallId: string, output: string, metadata?: Record<string, unknown>): string;
|
|
154
|
+
/** Record the host's authoritative error status, even if its SDK drops that flag. */
|
|
155
|
+
export declare function captureCursorShellFailure(toolCallId: string, error: unknown): void;
|
|
113
156
|
/** Consume the structured result, with an inline fallback when no plugin hook ran. */
|
|
114
157
|
export declare function consumeCursorShellResult(toolCallId: string, output: string): {
|
|
115
158
|
output: string;
|
|
116
159
|
outcome?: CursorShellOutcome;
|
|
160
|
+
error?: string;
|
|
117
161
|
};
|
|
118
162
|
/** Test/process cleanup. */
|
|
119
163
|
export declare function resetCursorShellCalls(): void;
|