subconscious-cli 6.0.1 → 6.2.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.
Files changed (73) hide show
  1. package/README.md +167 -43
  2. package/bin/agent-data.js +278 -0
  3. package/bin/agent-help.js +114 -0
  4. package/bin/agent-install.js +238 -0
  5. package/bin/agent-launch.js +199 -0
  6. package/bin/agent-spawn.js +137 -0
  7. package/bin/agents.js +236 -931
  8. package/bin/auth.js +9 -1
  9. package/bin/claude-picker.js +143 -0
  10. package/bin/cli.js +62 -2
  11. package/bin/clipboard-image.js +2 -0
  12. package/bin/feedback.js +14 -3
  13. package/bin/harness-manifest.js +286 -0
  14. package/bin/headless-args.js +35 -0
  15. package/bin/launch-values.js +25 -0
  16. package/bin/model-capabilities.js +10 -9
  17. package/bin/models.js +25 -13
  18. package/bin/native/subc-tui-darwin-amd64 +0 -0
  19. package/bin/native/subc-tui-darwin-arm64 +0 -0
  20. package/bin/native/subc-tui-linux-amd64 +0 -0
  21. package/bin/native/subc-tui-linux-arm64 +0 -0
  22. package/bin/native/subc-tui-windows-amd64.exe +0 -0
  23. package/bin/native/subc-tui-windows-arm64.exe +0 -0
  24. package/bin/opencode-provider.js +21 -0
  25. package/bin/profile-settings.js +129 -0
  26. package/bin/profiles.js +29 -424
  27. package/bin/runbook/README.md +77 -23
  28. package/bin/runbook/claude-code/agent.json +300 -0
  29. package/bin/runbook/claude-code/install.sh +9 -252
  30. package/bin/runbook/codex/agent.json +462 -0
  31. package/bin/runbook/codex/hooks-lib.sh +17 -4
  32. package/bin/runbook/codex/install.sh +0 -4
  33. package/bin/runbook/codex/run.sh +16 -235
  34. package/bin/runbook/copilot/agent.json +186 -0
  35. package/bin/runbook/copilot/install.sh +45 -63
  36. package/bin/runbook/cursor/agent.json +138 -0
  37. package/bin/runbook/cursor/install.sh +8 -35
  38. package/bin/runbook/deepseek-harness/agent.json +164 -0
  39. package/bin/runbook/deepseek-harness/run.sh +20 -59
  40. package/bin/runbook/image-window/index.ts +14 -0
  41. package/bin/runbook/image-window/window.d.ts +19 -0
  42. package/bin/runbook/image-window/window.js +140 -0
  43. package/bin/runbook/lib.sh +41 -0
  44. package/bin/runbook/opencode/agent.json +159 -0
  45. package/bin/runbook/opencode/install.sh +9 -183
  46. package/bin/runbook/opencode/opencode-plugin.d.ts +10 -3
  47. package/bin/runbook/opencode/subconscious-image-window.ts +24 -0
  48. package/bin/runbook/pi/agent.json +217 -0
  49. package/bin/runbook/pi/install.sh +18 -44
  50. package/bin/runbook/pi/run.sh +6 -18
  51. package/bin/runbook/pi/subconscious-compaction.ts +3 -1
  52. package/bin/runbook/shared.json +57 -0
  53. package/bin/sessions.js +53 -48
  54. package/bin/tui.js +13 -0
  55. package/bin/update-check.js +35 -1
  56. package/bin/upgrade.js +27 -34
  57. package/bin/usage.js +21 -10
  58. package/bin/windows/agents.js +28 -60
  59. package/bin/windows/common.js +2 -28
  60. package/bin/windows/launch.js +252 -231
  61. package/bin/windows/process.js +12 -1
  62. package/bin/windows/setup.js +29 -9
  63. package/package.json +2 -4
  64. package/bin/registry.generated.json +0 -406
  65. package/bin/runbook/claude-code/run.sh +0 -254
  66. package/bin/runbook/model-capabilities.generated.sh +0 -9
  67. package/bin/runbook/opencode/provider.sh +0 -93
  68. package/bin/runbook/opencode/run.sh +0 -99
  69. package/bin/runbook/opencode/subconscious-compaction.ts +0 -100
  70. package/bin/runbook/subconscious-code/install.sh +0 -154
  71. package/bin/runbook/subconscious-code/run.sh +0 -21
  72. package/bin/windows/claude.js +0 -100
  73. package/bin/windows/install.js +0 -188
@@ -0,0 +1,41 @@
1
+ # shellcheck shell=bash
2
+ # subc sets every value a runbook reads, so a runbook declares no defaults
3
+ # of its own.
4
+
5
+ # Exact IDs only: similarly named models do not inherit capabilities.
6
+ subc_model_supports_vision() {
7
+ local model
8
+ while IFS= read -r model; do
9
+ [[ -n "$model" && "$model" == "${1:-}" ]] && return 0
10
+ done <<< "${SUBC_VISION_MODELS:-}"
11
+ return 1
12
+ }
13
+
14
+ # Replace this shell with the agent argv subc built:
15
+ # subc_exec [PLACEHOLDER VALUE]... -- ARGV...
16
+ # Only the first SUBC_TEMPLATE_WORDS words came from the agent's argv
17
+ # template; passed-through arguments and the prompt after them are never
18
+ # rewritten, whatever they contain.
19
+ subc_exec() {
20
+ local names=() values=() argv=() word index=0 i
21
+ while [[ $# -gt 0 && "$1" != "--" ]]; do
22
+ names+=("$1")
23
+ values+=("$2")
24
+ shift 2
25
+ done
26
+ shift
27
+ local limit="${SUBC_TEMPLATE_WORDS:-0}"
28
+ unset SUBC_TEMPLATE_WORDS SUBC_MODEL_IDS SUBC_VISION_MODELS
29
+ for word in "$@"; do
30
+ if [[ "$index" -lt "$limit" ]]; then
31
+ for ((i = 0; i < ${#names[@]}; i++)); do
32
+ if [[ "$word" == *"${names[i]}"* ]]; then
33
+ word="${word%%"${names[i]}"*}${values[i]}${word#*"${names[i]}"}"
34
+ fi
35
+ done
36
+ fi
37
+ argv+=("$word")
38
+ index=$((index + 1))
39
+ done
40
+ exec "${argv[@]}"
41
+ }
@@ -0,0 +1,159 @@
1
+ {
2
+ "id": "opencode",
3
+ "command": "opencode",
4
+ "aliases": ["open-code"],
5
+ "name": "OpenCode",
6
+ "description": "Run OpenCode on your hosted Subconscious model with the Subconscious provider and context settings.",
7
+ "protocol": "openai",
8
+ "homepage": "https://opencode.ai",
9
+ "install": {
10
+ "commands": {
11
+ "darwin": "npm i -g {package}",
12
+ "linux": "npm i -g {package}",
13
+ "win32": "npm i -g {package}"
14
+ },
15
+ "url": "https://opencode.ai/docs",
16
+ "method": "npm",
17
+ "package": "opencode-ai",
18
+ "version": null,
19
+ "channel": "latest (unpinned)",
20
+ "install_dir": "~/.opencode/bin",
21
+ "minimum_version": null,
22
+ "verified": true
23
+ },
24
+ "runbook": {
25
+ "mode": "launch",
26
+ "setup_script": "install.sh",
27
+ "setup_actions": ["status", "uninstall"]
28
+ },
29
+ "help": {
30
+ "usage": "subc [-p NAME] opencode [help|status|uninstall] [OpenCode arguments...]",
31
+ "behavior": "Launches OpenCode with an ephemeral provider containing every Subconscious model. Persistent files are leftover-only: subc opencode uninstall.",
32
+ "options": [
33
+ ["help", "Show this help"],
34
+ ["status", "Inspect leftover OpenCode Subconscious config"],
35
+ [
36
+ "uninstall",
37
+ "Remove only the Subconscious OpenCode provider and plugin"
38
+ ],
39
+ ["--model MODEL", "Override the profile model for this launch"]
40
+ ],
41
+ "args": ["ARGS...", "Pass arguments directly to OpenCode"]
42
+ },
43
+ "sessions": { "key": "opencode", "portable": true },
44
+ "prerequisites": [],
45
+ "launch": {
46
+ "argv": ["opencode", "{args}"],
47
+ "headless_argv": ["opencode", "run", "{args}"],
48
+ "headless_stdin": "{prompt}",
49
+ "headless_platforms": ["darwin", "linux"],
50
+ "resume": ["--session", "{sessionId}"],
51
+ "handoff": ["--prompt", "{prompt}"],
52
+ "persistent_setup": false
53
+ },
54
+ "inputs": [
55
+ {
56
+ "name": "OPENCODE_API_KEY",
57
+ "label": "OpenCode API key",
58
+ "description": "OpenCode-specific credential override; blank uses API_KEY.",
59
+ "type": "secret"
60
+ },
61
+ {
62
+ "name": "OPENCODE_CONTEXT_LIMIT",
63
+ "default": 5000000,
64
+ "label": "Context limit",
65
+ "description": "OpenCode provider context limit used for compaction.",
66
+ "type": "integer",
67
+ "min": 1
68
+ },
69
+ {
70
+ "name": "OPENCODE_OUTPUT_LIMIT",
71
+ "default": 65536,
72
+ "label": "Output limit",
73
+ "description": "Maximum output tokens advertised to OpenCode.",
74
+ "type": "integer",
75
+ "min": 1
76
+ }
77
+ ],
78
+ "env": [
79
+ {
80
+ "name": "SUBCONSCIOUS_API_KEY",
81
+ "value": "{apiKey}",
82
+ "description": "Credential, referenced as {env:SUBCONSCIOUS_API_KEY} in the provider config."
83
+ },
84
+ {
85
+ "name": "SUBCONSCIOUS_GATEWAY_URL",
86
+ "value": "{baseUrl}",
87
+ "description": "Gateway origin for the compaction plugin, when one is installed."
88
+ },
89
+ {
90
+ "name": "OPENCODE_CONFIG_CONTENT",
91
+ "value": "{opencodeConfig}",
92
+ "description": "Whole OpenCode config for this launch; see the config entry. Nothing is written to disk."
93
+ }
94
+ ],
95
+ "config": [
96
+ {
97
+ "kind": "env-json",
98
+ "name": "OPENCODE_CONFIG_CONTENT",
99
+ "lifetime": "launch",
100
+ "value": "{opencodeConfig}",
101
+ "description": "Provider, models, limits and image-window plugin, built for every catalog model."
102
+ },
103
+ {
104
+ "kind": "file",
105
+ "path": "~/.config/opencode/plugins/subconscious-compaction.ts",
106
+ "lifetime": "legacy",
107
+ "description": "Compaction plugin from older persistent setup. Launch never writes it; subc opencode uninstall removes it."
108
+ }
109
+ ],
110
+ "capabilities": {
111
+ "compaction": {
112
+ "default": "on",
113
+ "on": {
114
+ "set_by_subc": true,
115
+ "kind": "config-field",
116
+ "name": "provider.subconscious.models.<id>.limit.context",
117
+ "value": "${OPENCODE_CONTEXT_LIMIT}",
118
+ "verified": false,
119
+ "note": "subc sets limit.context. That auto-compaction keys off it comes only from an install.sh comment and the profile setting description.",
120
+ "config": "OPENCODE_CONFIG_CONTENT"
121
+ },
122
+ "off": {
123
+ "set_by_subc": false,
124
+ "kind": "config-field",
125
+ "name": "compaction.auto",
126
+ "value": false,
127
+ "verified": false,
128
+ "note": "Upstream OpenCode setting. subc never sets it, and this repo does not confirm its name or behaviour.",
129
+ "config": "OpenCode config"
130
+ },
131
+ "threshold": {
132
+ "set_by_subc": true,
133
+ "kind": "config-field",
134
+ "name": "provider.subconscious.models.<id>.limit.context",
135
+ "value": "${OPENCODE_CONTEXT_LIMIT}",
136
+ "verified": false,
137
+ "semantics": "window",
138
+ "config": "OPENCODE_CONFIG_CONTENT",
139
+ "note": "subc sets limit.context. That auto-compaction keys off it comes only from an install.sh comment and the profile setting description."
140
+ }
141
+ },
142
+ "mcp": {
143
+ "configured_by_subc": false,
144
+ "transports": null,
145
+ "verified": false,
146
+ "note": "OPENCODE_CONFIG_CONTENT carries no mcp block. Whether OpenCode merges user MCP config with it is not confirmed here."
147
+ },
148
+ "headers": [
149
+ {
150
+ "name": "x-subconscious-client",
151
+ "value": "opencode",
152
+ "on": "model requests",
153
+ "set_by_subc": true,
154
+ "verified": true
155
+ }
156
+ ],
157
+ "hooks": []
158
+ }
159
+ }
@@ -1,75 +1,17 @@
1
1
  #!/usr/bin/env bash
2
- # ── Subconscious API Gateway — OpenCode setup ─────────────────────────────────
3
- # Point OpenCode at your gateway. Writes a provider config with session headers
4
- # so the gateway can correlate OpenCode requests into Conversations.
2
+ # ── Subconscious API Gateway — OpenCode leftovers ─────────────────────────────
3
+ # OpenCode is launch-only: `subc opencode` passes the provider config in
4
+ # OPENCODE_CONFIG_CONTENT and writes nothing. Older persistent setups wrote a
5
+ # provider into ~/.opencode/opencode.json, an env file, and a compaction
6
+ # plugin; this script reports and removes those.
5
7
  #
6
- # Quick start:
7
- # ./install.sh --gateway-url https://your-gateway.example --api-key sk-gw-...
8
- # ./install.sh status # show current config
9
- # ./install.sh uninstall # revert to default opencode config
10
- #
11
- # Writes ~/.opencode/opencode.json (user config). Does not touch project-level
12
- # opencode.json files. Restart opencode after install.
13
- #
14
- # ── What this does under the hood ────────────────────────────────────────────
15
- # Equivalent manual setup (writes ~/.opencode/opencode.json + env var):
16
- #
17
- # export SUBCONSCIOUS_API_KEY=sk-gw-...
18
- # cat > ~/.opencode/opencode.json <<'EOF'
19
- # {
20
- # "$schema": "https://opencode.ai/config.json",
21
- # "provider": {
22
- # "subconscious": {
23
- # "npm": "@ai-sdk/openai-compatible",
24
- # "name": "Subconscious Gateway",
25
- # "options": {
26
- # "baseURL": "https://your-gateway.example/v1",
27
- # "apiKey": "{env:SUBCONSCIOUS_API_KEY}",
28
- # "headers": { "x-subconscious-client": "opencode" }
29
- # },
30
- # "models": {
31
- # "subconscious/glm-5.3-marathon": {
32
- # "name": "subconscious/glm-5.3-marathon",
33
- # "tools": true,
34
- # "limit": { "context": 5000000, "output": 65536 }
35
- # }
36
- # }
37
- # }
38
- # },
39
- # "model": "subconscious/subconscious/glm-5.3-marathon"
40
- # }
41
- # EOF
42
- # opencode
43
- #
44
- # The x-subconscious-client header tells the gateway to classify traffic as
45
- # OpenCode. OpenCode also sends native x-session-affinity / x-session-id
46
- # headers for conversation correlation. Model limit.context drives auto
47
- # compaction (default on); custom providers do not inherit models.dev limits.
48
- #
49
- # Also installs a plugin that reports compactions to the gateway. OpenCode
50
- # summarizes through the configured provider, so without it the gateway counts
51
- # that summarization as a normal main-thread turn.
8
+ # subc opencode status
9
+ # subc opencode uninstall
52
10
  # ─────────────────────────────────────────────────────────────────────────────
53
11
 
54
12
  set -euo pipefail
55
13
 
56
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
57
- source "${SCRIPT_DIR}/../model-capabilities.generated.sh"
58
- source "${SCRIPT_DIR}/provider.sh"
59
-
60
- # Load shared env from SUBC_ENV_FILE, or a sibling .env / env.example.
61
- SHARED_ENV="${SUBC_ENV_FILE:-${SCRIPT_DIR}/../.env}"
62
- [[ -f "$SHARED_ENV" ]] || SHARED_ENV="${SCRIPT_DIR}/../env.example"
63
- if [[ -f "$SHARED_ENV" ]]; then set -a; source "$SHARED_ENV"; set +a; fi
64
-
65
- COMMAND="install"
66
- GATEWAY_URL="${GATEWAY_URL:-}"
67
- API_KEY="${OPENCODE_API_KEY:-${API_KEY:-}}"
68
- MODEL="${MODEL:-subconscious/glm-5.3-marathon}"
69
- # OpenCode auto-compaction uses model limit.context. Custom openai-compatible
70
- # providers do not get that from baseURL/models.dev; set it explicitly.
71
- CONTEXT_LIMIT="${OPENCODE_CONTEXT_LIMIT:-5000000}"
72
- OUTPUT_LIMIT="${OPENCODE_OUTPUT_LIMIT:-65536}"
14
+ COMMAND="status"
73
15
 
74
16
  usage() {
75
17
  cat <<'EOF'
@@ -85,30 +27,10 @@ EOF
85
27
 
86
28
  while [[ $# -gt 0 ]]; do
87
29
  case "$1" in
88
- install|uninstall|status)
30
+ uninstall|status)
89
31
  COMMAND="$1"
90
32
  shift
91
33
  ;;
92
- --gateway-url)
93
- GATEWAY_URL="${2:-}"
94
- shift 2
95
- ;;
96
- --api-key)
97
- API_KEY="${2:-}"
98
- shift 2
99
- ;;
100
- --model)
101
- MODEL="${2:-}"
102
- shift 2
103
- ;;
104
- --context-limit)
105
- CONTEXT_LIMIT="${2:-}"
106
- shift 2
107
- ;;
108
- --output-limit)
109
- OUTPUT_LIMIT="${2:-}"
110
- shift 2
111
- ;;
112
34
  -h|--help)
113
35
  usage
114
36
  exit 0
@@ -121,35 +43,6 @@ while [[ $# -gt 0 ]]; do
121
43
  esac
122
44
  done
123
45
 
124
- DEFAULT_SUBCONSCIOUS_MODELS="subconscious/glm-5.3-marathon
125
- subconscious/glm-5.2
126
- subconscious/tim-qwen3.6-27b
127
- subconscious/deepseek-v4-flash-marathon
128
- subconscious/deepseek-v4.1-flash-marathon"
129
- SUPPORTED_MODELS=()
130
-
131
- add_supported_model() {
132
- local model_id="$1" existing
133
- [[ -n "$model_id" ]] || return 0
134
- if [[ ! "$model_id" =~ ^[-A-Za-z0-9._:/+]+$ ]]; then
135
- echo "error: invalid model id: $model_id" >&2
136
- exit 1
137
- fi
138
- if [[ "${#SUPPORTED_MODELS[@]}" -gt 0 ]]; then
139
- for existing in "${SUPPORTED_MODELS[@]}"; do
140
- [[ "$existing" == "$model_id" ]] && return 0
141
- done
142
- fi
143
- SUPPORTED_MODELS+=("$model_id")
144
- }
145
-
146
- add_supported_model "$MODEL"
147
- while IFS= read -r model_id; do
148
- add_supported_model "$model_id"
149
- done <<< "${SUBCONSCIOUS_MODELS:-$DEFAULT_SUBCONSCIOUS_MODELS}"
150
-
151
- subc_opencode_build_models_json
152
-
153
46
  OPENCODE_DIR="${HOME}/.opencode"
154
47
  OPENCODE_CONFIG="${OPENCODE_DIR}/opencode.json"
155
48
  MARKER='x-subconscious-client'
@@ -157,59 +50,6 @@ MARKER='x-subconscious-client'
157
50
  # config path above. Docs: https://opencode.ai/docs/plugins/
158
51
  PLUGIN_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/opencode/plugins"
159
52
  PLUGIN_FILE="${PLUGIN_DIR}/subconscious-compaction.ts"
160
- PLUGIN_SOURCE="${SCRIPT_DIR}/subconscious-compaction.ts"
161
-
162
- require_cmds() {
163
- local missing=0
164
- for c in jq; do
165
- if ! command -v "$c" >/dev/null 2>&1; then
166
- echo "missing required command: $c" >&2
167
- missing=1
168
- fi
169
- done
170
- if [[ "$missing" -ne 0 ]]; then
171
- exit 1
172
- fi
173
- }
174
-
175
- write_config() {
176
- mkdir -p "$OPENCODE_DIR"
177
- local base_url="${GATEWAY_URL%/}/v1"
178
- local provider selected_model
179
- provider="$(subc_opencode_build_provider_json "$base_url")"
180
- selected_model="${SUBC_OPENCODE_PROVIDER_ID}/${MODEL}"
181
- if [[ -f "$OPENCODE_CONFIG" ]]; then
182
- local tmp
183
- tmp="$(mktemp)"
184
- jq --argjson provider "$provider" --arg model "$selected_model" --arg provider_id "$SUBC_OPENCODE_PROVIDER_ID" '
185
- .provider = (.provider // {})
186
- | .provider[$provider_id] = $provider
187
- | .model = $model
188
- ' "$OPENCODE_CONFIG" >"$tmp"
189
- mv "$tmp" "$OPENCODE_CONFIG"
190
- else
191
- jq -n --argjson provider "$provider" --arg model "$selected_model" --arg provider_id "$SUBC_OPENCODE_PROVIDER_ID" \
192
- '{ "$schema": "https://opencode.ai/config.json", provider: {($provider_id): $provider}, model: $model }' \
193
- >"$OPENCODE_CONFIG"
194
- fi
195
- local env_file="${OPENCODE_DIR}/subconscious.env"
196
- umask 077
197
- cat >"$env_file" <<EOF
198
- # Generated by subc — do not commit secrets.
199
- export SUBCONSCIOUS_API_KEY='${API_KEY}'
200
- export SUBCONSCIOUS_GATEWAY_URL='${GATEWAY_URL%/}'
201
- EOF
202
- chmod 600 "$env_file"
203
- }
204
-
205
- write_plugin() {
206
- if [[ ! -f "$PLUGIN_SOURCE" ]]; then
207
- echo "warning: ${PLUGIN_SOURCE} missing; skipping compaction plugin" >&2
208
- return
209
- fi
210
- mkdir -p "$PLUGIN_DIR"
211
- cp "$PLUGIN_SOURCE" "$PLUGIN_FILE"
212
- }
213
53
 
214
54
  uninstall_config() {
215
55
  if [[ -f "$OPENCODE_CONFIG" ]]; then
@@ -257,20 +97,6 @@ status() {
257
97
  }
258
98
 
259
99
  case "$COMMAND" in
260
- install)
261
- require_cmds
262
- if [[ -z "$GATEWAY_URL" || -z "$API_KEY" ]]; then
263
- echo "--gateway-url and --api-key are required for install" >&2
264
- exit 1
265
- fi
266
- write_config
267
- write_plugin
268
- echo "Merged Subconscious OpenCode provider into $OPENCODE_CONFIG"
269
- if [[ -f "$PLUGIN_FILE" ]]; then
270
- echo "Installed compaction reporting plugin at $PLUGIN_FILE"
271
- fi
272
- echo "Launch OpenCode with: subc opencode"
273
- ;;
274
100
  uninstall)
275
101
  uninstall_config
276
102
  echo "Removed Subconscious OpenCode files; left $OPENCODE_CONFIG in place"
@@ -1,9 +1,16 @@
1
- // OpenCode loads this plugin. The host package is not a dependency of the CLI.
1
+ // OpenCode loads these plugins. The host package is not a dependency of the CLI,
2
+ // so only the hooks our plugins use are declared.
2
3
  declare module '@opencode-ai/plugin' {
4
+ type ProviderConfig = {
5
+ options?: Record<string, unknown> & { fetch?: typeof fetch };
6
+ };
3
7
  export type Plugin = () => Promise<{
4
- 'experimental.session.compacting': (input: {
8
+ 'experimental.session.compacting'?: (input: {
5
9
  sessionID: string;
6
10
  }) => Promise<void>;
7
- event: (args: { event: { type: string } }) => Promise<void>;
11
+ event?: (args: { event: { type: string } }) => Promise<void>;
12
+ config?: (config: {
13
+ provider?: Record<string, ProviderConfig>;
14
+ }) => Promise<void>;
8
15
  }>;
9
16
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Keep OpenCode's requests to Subconscious at the newest 30 images.
3
+ *
4
+ * OpenCode resends every screenshot on every turn, so a long session's upload
5
+ * grows until the gateway refuses it. This gives the `subconscious` provider a
6
+ * fetch that trims the request body before it leaves (bin/runbook/image-window),
7
+ * the same rule the gateway applies, so Subconscious Cache still reuses the
8
+ * rest. OpenCode reads provider settings after plugins' config hooks run, so a
9
+ * function set here becomes the provider's fetch.
10
+ *
11
+ * Loaded by path from the launch config; nothing is written to disk.
12
+ */
13
+
14
+ import type { Plugin } from '@opencode-ai/plugin';
15
+ import { windowFetch } from '../image-window/window.js';
16
+
17
+ export const SubconsciousImageWindow: Plugin = async () => ({
18
+ config: async (config) => {
19
+ const provider = config.provider?.subconscious;
20
+ if (!provider) return;
21
+ const base = provider.options?.fetch ?? fetch;
22
+ provider.options = { ...provider.options, fetch: windowFetch(base) };
23
+ },
24
+ });