cursor-opencode-provider 0.8.0 → 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.
Files changed (132) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/README.md +230 -44
  3. package/SECURITY.md +60 -12
  4. package/dist/activity.d.ts +73 -1
  5. package/dist/activity.js +231 -5
  6. package/dist/agent-url.js +37 -9
  7. package/dist/auth-renewal.d.ts +1 -1
  8. package/dist/auth-renewal.js +58 -26
  9. package/dist/billing.d.ts +105 -0
  10. package/dist/billing.js +212 -0
  11. package/dist/classic-tool-results.d.ts +1 -0
  12. package/dist/classic-tool-results.js +42 -0
  13. package/dist/context/build.d.ts +23 -4
  14. package/dist/context/build.js +65 -10
  15. package/dist/context/dynamic-catalog.js +6 -1
  16. package/dist/context/env.js +27 -3
  17. package/dist/context/epoch.js +9 -5
  18. package/dist/context/frozen.js +6 -2
  19. package/dist/context/git.d.ts +5 -2
  20. package/dist/context/git.js +17 -7
  21. package/dist/context/index.d.ts +2 -0
  22. package/dist/context/index.js +2 -0
  23. package/dist/context/paths.d.ts +45 -18
  24. package/dist/context/paths.js +72 -22
  25. package/dist/context/skills-bridge.d.ts +22 -0
  26. package/dist/context/skills-bridge.js +20 -0
  27. package/dist/context/skills.d.ts +34 -0
  28. package/dist/context/skills.js +211 -0
  29. package/dist/debug.js +13 -2
  30. package/dist/early-tool-rows.d.ts +60 -0
  31. package/dist/early-tool-rows.js +96 -0
  32. package/dist/errors.d.ts +49 -7
  33. package/dist/errors.js +163 -8
  34. package/dist/host-agent-mode.d.ts +53 -4
  35. package/dist/host-agent-mode.js +117 -13
  36. package/dist/host-interrupt.d.ts +12 -0
  37. package/dist/host-interrupt.js +18 -0
  38. package/dist/host-plan-file.d.ts +28 -0
  39. package/dist/host-plan-file.js +76 -0
  40. package/dist/host-steer.d.ts +71 -0
  41. package/dist/host-steer.js +232 -0
  42. package/dist/image-input.d.ts +18 -0
  43. package/dist/image-input.js +122 -30
  44. package/dist/image-save.d.ts +10 -2
  45. package/dist/image-save.js +33 -21
  46. package/dist/index.d.ts +2 -2
  47. package/dist/language-model.d.ts +149 -30
  48. package/dist/language-model.js +3127 -673
  49. package/dist/lost-request.d.ts +39 -0
  50. package/dist/lost-request.js +111 -0
  51. package/dist/model-config.d.ts +12 -1
  52. package/dist/model-config.js +78 -30
  53. package/dist/models.d.ts +26 -3
  54. package/dist/models.js +101 -45
  55. package/dist/opencode2/catalog.d.ts +1 -0
  56. package/dist/opencode2/catalog.js +2 -0
  57. package/dist/opencode2/image-save-tool.d.ts +8 -0
  58. package/dist/opencode2/image-save-tool.js +84 -0
  59. package/dist/opencode2/tool-results.d.ts +18 -0
  60. package/dist/opencode2/tool-results.js +66 -0
  61. package/dist/opencode2/types.d.ts +15 -0
  62. package/dist/parallel-step.d.ts +65 -0
  63. package/dist/parallel-step.js +102 -0
  64. package/dist/plugin-opencode2.js +233 -65
  65. package/dist/plugin.js +97 -23
  66. package/dist/pricing-data.d.ts +40 -3
  67. package/dist/pricing-data.js +40 -3
  68. package/dist/pricing.d.ts +1 -1
  69. package/dist/pricing.js +7 -4
  70. package/dist/process-shared.d.ts +14 -0
  71. package/dist/process-shared.js +18 -0
  72. package/dist/protocol/apply-patch.d.ts +25 -13
  73. package/dist/protocol/apply-patch.js +79 -30
  74. package/dist/protocol/ask-question.d.ts +12 -1
  75. package/dist/protocol/ask-question.js +77 -3
  76. package/dist/protocol/blob-store.d.ts +5 -1
  77. package/dist/protocol/blob-store.js +10 -6
  78. package/dist/protocol/client-version.js +6 -4
  79. package/dist/protocol/conversation-cache-header.d.ts +23 -0
  80. package/dist/protocol/conversation-cache-header.js +149 -0
  81. package/dist/protocol/conversation-persistence.d.ts +27 -1
  82. package/dist/protocol/conversation-persistence.js +628 -126
  83. package/dist/protocol/conversation-state.d.ts +8 -1
  84. package/dist/protocol/conversation-state.js +28 -7
  85. package/dist/protocol/create-plan.d.ts +47 -25
  86. package/dist/protocol/create-plan.js +33 -23
  87. package/dist/protocol/host-notes.d.ts +31 -0
  88. package/dist/protocol/host-notes.js +85 -0
  89. package/dist/protocol/interactions.d.ts +26 -17
  90. package/dist/protocol/interactions.js +80 -31
  91. package/dist/protocol/messages.js +164 -21
  92. package/dist/protocol/request.d.ts +40 -19
  93. package/dist/protocol/request.js +55 -28
  94. package/dist/protocol/sent-history-images.d.ts +49 -0
  95. package/dist/protocol/sent-history-images.js +102 -0
  96. package/dist/protocol/switch-mode.d.ts +66 -27
  97. package/dist/protocol/switch-mode.js +147 -73
  98. package/dist/protocol/token-details.d.ts +2 -0
  99. package/dist/protocol/token-details.js +11 -1
  100. package/dist/protocol/tool-call-bridge.d.ts +6 -0
  101. package/dist/protocol/tool-call-bridge.js +24 -0
  102. package/dist/protocol/tools.d.ts +90 -9
  103. package/dist/protocol/tools.js +543 -151
  104. package/dist/protocol/turn-provenance.d.ts +19 -4
  105. package/dist/protocol/turn-provenance.js +77 -20
  106. package/dist/replay-safety.d.ts +22 -4
  107. package/dist/replay-safety.js +86 -27
  108. package/dist/retry-budget.d.ts +21 -0
  109. package/dist/retry-budget.js +94 -0
  110. package/dist/runtime-files.d.ts +23 -0
  111. package/dist/runtime-files.js +581 -0
  112. package/dist/session.d.ts +129 -10
  113. package/dist/session.js +198 -35
  114. package/dist/shared.d.ts +1 -1
  115. package/dist/shared.js +1 -1
  116. package/dist/shell-timeout.d.ts +54 -10
  117. package/dist/shell-timeout.js +362 -92
  118. package/dist/stream-write.d.ts +20 -0
  119. package/dist/stream-write.js +87 -0
  120. package/dist/terminal-runner.d.ts +15 -0
  121. package/dist/terminal-runner.js +528 -0
  122. package/dist/todo-store.d.ts +2 -0
  123. package/dist/todo-store.js +19 -0
  124. package/dist/transport/connect.d.ts +10 -1
  125. package/dist/transport/connect.js +124 -27
  126. package/dist/usage.d.ts +37 -17
  127. package/dist/usage.js +85 -34
  128. package/package.json +5 -3
  129. package/dist/plan-execution-kickoff.d.ts +0 -57
  130. package/dist/plan-execution-kickoff.js +0 -186
  131. package/dist/protocol/thinking.d.ts +0 -15
  132. package/dist/protocol/thinking.js +0 -17
@@ -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; for
70
- * them, use a short `exec wrapper.sh` command that contains no user payload.
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
- * shorter wrapper-file command (sh/dash), avoiding duplicate execution.
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 `shell.create.before` has no tool-call id. Correlate the pending
90
- * wrap by command + working directory when possible, then fall back to the
91
- * original command for hosts that omit the directory.
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 cursorShellEnvForCommand(command: string | undefined, workingDirectory?: string): Record<string, string> | undefined;
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;