@tickernelz/paperclip-pro-adapter-opencode-local 2026.925.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 (78) hide show
  1. package/LICENSE +22 -0
  2. package/dist/cli/format-event.d.ts +2 -0
  3. package/dist/cli/format-event.d.ts.map +1 -0
  4. package/dist/cli/format-event.js +115 -0
  5. package/dist/cli/format-event.js.map +1 -0
  6. package/dist/cli/index.d.ts +2 -0
  7. package/dist/cli/index.d.ts.map +1 -0
  8. package/dist/cli/index.js +2 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/index.d.ts +11 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +113 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/server/execute.d.ts +13 -0
  15. package/dist/server/execute.d.ts.map +1 -0
  16. package/dist/server/execute.js +595 -0
  17. package/dist/server/execute.js.map +1 -0
  18. package/dist/server/execute.remote.test.d.ts +2 -0
  19. package/dist/server/execute.remote.test.d.ts.map +1 -0
  20. package/dist/server/execute.remote.test.js +351 -0
  21. package/dist/server/execute.remote.test.js.map +1 -0
  22. package/dist/server/execute.test.d.ts +2 -0
  23. package/dist/server/execute.test.d.ts.map +1 -0
  24. package/dist/server/execute.test.js +290 -0
  25. package/dist/server/execute.test.js.map +1 -0
  26. package/dist/server/index.d.ts +8 -0
  27. package/dist/server/index.d.ts.map +1 -0
  28. package/dist/server/index.js +63 -0
  29. package/dist/server/index.js.map +1 -0
  30. package/dist/server/models.d.ts +24 -0
  31. package/dist/server/models.d.ts.map +1 -0
  32. package/dist/server/models.js +281 -0
  33. package/dist/server/models.js.map +1 -0
  34. package/dist/server/models.test.d.ts +2 -0
  35. package/dist/server/models.test.d.ts.map +1 -0
  36. package/dist/server/models.test.js +258 -0
  37. package/dist/server/models.test.js.map +1 -0
  38. package/dist/server/parse.d.ts +14 -0
  39. package/dist/server/parse.d.ts.map +1 -0
  40. package/dist/server/parse.js +99 -0
  41. package/dist/server/parse.js.map +1 -0
  42. package/dist/server/parse.test.d.ts +2 -0
  43. package/dist/server/parse.test.d.ts.map +1 -0
  44. package/dist/server/parse.test.js +73 -0
  45. package/dist/server/parse.test.js.map +1 -0
  46. package/dist/server/runtime-config.d.ts +20 -0
  47. package/dist/server/runtime-config.d.ts.map +1 -0
  48. package/dist/server/runtime-config.js +216 -0
  49. package/dist/server/runtime-config.js.map +1 -0
  50. package/dist/server/runtime-config.test.d.ts +2 -0
  51. package/dist/server/runtime-config.test.d.ts.map +1 -0
  52. package/dist/server/runtime-config.test.js +255 -0
  53. package/dist/server/runtime-config.test.js.map +1 -0
  54. package/dist/server/skills.d.ts +8 -0
  55. package/dist/server/skills.d.ts.map +1 -0
  56. package/dist/server/skills.js +73 -0
  57. package/dist/server/skills.js.map +1 -0
  58. package/dist/server/test.d.ts +3 -0
  59. package/dist/server/test.d.ts.map +1 -0
  60. package/dist/server/test.js +416 -0
  61. package/dist/server/test.js.map +1 -0
  62. package/dist/server/test.remote.test.d.ts +2 -0
  63. package/dist/server/test.remote.test.d.ts.map +1 -0
  64. package/dist/server/test.remote.test.js +132 -0
  65. package/dist/server/test.remote.test.js.map +1 -0
  66. package/dist/ui/build-config.d.ts +3 -0
  67. package/dist/ui/build-config.d.ts.map +1 -0
  68. package/dist/ui/build-config.js +32 -0
  69. package/dist/ui/build-config.js.map +1 -0
  70. package/dist/ui/index.d.ts +3 -0
  71. package/dist/ui/index.d.ts.map +1 -0
  72. package/dist/ui/index.js +3 -0
  73. package/dist/ui/index.js.map +1 -0
  74. package/dist/ui/parse-stdout.d.ts +3 -0
  75. package/dist/ui/parse-stdout.d.ts.map +1 -0
  76. package/dist/ui/parse-stdout.js +141 -0
  77. package/dist/ui/parse-stdout.js.map +1 -0
  78. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Paperclip AI
4
+ Copyright (c) 2026 Zhafron Adani Kautsar (paperclip-pro fork modifications)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export declare function printOpenCodeStreamEvent(raw: string, _debug: boolean): void;
2
+ //# sourceMappingURL=format-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-event.d.ts","sourceRoot":"","sources":["../../src/cli/format-event.ts"],"names":[],"mappings":"AAyCA,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CA+E3E"}
@@ -0,0 +1,115 @@
1
+ import pc from "picocolors";
2
+ function safeJsonParse(text) {
3
+ try {
4
+ return JSON.parse(text);
5
+ }
6
+ catch {
7
+ return null;
8
+ }
9
+ }
10
+ function asRecord(value) {
11
+ if (typeof value !== "object" || value === null || Array.isArray(value))
12
+ return null;
13
+ return value;
14
+ }
15
+ function asString(value, fallback = "") {
16
+ return typeof value === "string" ? value : fallback;
17
+ }
18
+ function asNumber(value, fallback = 0) {
19
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
20
+ }
21
+ function errorText(value) {
22
+ if (typeof value === "string")
23
+ return value;
24
+ const rec = asRecord(value);
25
+ if (!rec)
26
+ return "";
27
+ const data = asRecord(rec.data);
28
+ const message = asString(rec.message) ||
29
+ asString(data?.message) ||
30
+ asString(rec.name) ||
31
+ "";
32
+ if (message)
33
+ return message;
34
+ try {
35
+ return JSON.stringify(rec);
36
+ }
37
+ catch {
38
+ return "";
39
+ }
40
+ }
41
+ export function printOpenCodeStreamEvent(raw, _debug) {
42
+ const line = raw.trim();
43
+ if (!line)
44
+ return;
45
+ const parsed = asRecord(safeJsonParse(line));
46
+ if (!parsed) {
47
+ console.log(line);
48
+ return;
49
+ }
50
+ const type = asString(parsed.type);
51
+ if (type === "step_start") {
52
+ const sessionId = asString(parsed.sessionID);
53
+ console.log(pc.blue(`step started${sessionId ? ` (session: ${sessionId})` : ""}`));
54
+ return;
55
+ }
56
+ if (type === "text") {
57
+ const part = asRecord(parsed.part);
58
+ const text = asString(part?.text).trim();
59
+ if (text)
60
+ console.log(pc.green(`assistant: ${text}`));
61
+ return;
62
+ }
63
+ if (type === "reasoning") {
64
+ const part = asRecord(parsed.part);
65
+ const text = asString(part?.text).trim();
66
+ if (text)
67
+ console.log(pc.gray(`thinking: ${text}`));
68
+ return;
69
+ }
70
+ if (type === "tool_use") {
71
+ const part = asRecord(parsed.part);
72
+ const tool = asString(part?.tool, "tool");
73
+ const callID = asString(part?.callID);
74
+ const state = asRecord(part?.state);
75
+ const status = asString(state?.status);
76
+ const isError = status === "error";
77
+ const metadata = asRecord(state?.metadata);
78
+ console.log(pc.yellow(`tool_call: ${tool}${callID ? ` (${callID})` : ""}`));
79
+ if (status) {
80
+ const metaParts = [`status=${status}`];
81
+ if (metadata) {
82
+ for (const [key, value] of Object.entries(metadata)) {
83
+ if (value !== undefined && value !== null)
84
+ metaParts.push(`${key}=${value}`);
85
+ }
86
+ }
87
+ console.log((isError ? pc.red : pc.gray)(`tool_result ${metaParts.join(" ")}`));
88
+ }
89
+ const output = (asString(state?.output) || asString(state?.error)).trim();
90
+ if (output)
91
+ console.log((isError ? pc.red : pc.gray)(output));
92
+ return;
93
+ }
94
+ if (type === "step_finish") {
95
+ const part = asRecord(parsed.part);
96
+ const tokens = asRecord(part?.tokens);
97
+ const cache = asRecord(tokens?.cache);
98
+ const input = asNumber(tokens?.input, 0);
99
+ const output = asNumber(tokens?.output, 0) + asNumber(tokens?.reasoning, 0);
100
+ const cached = asNumber(cache?.read, 0);
101
+ const cost = asNumber(part?.cost, 0);
102
+ const reason = asString(part?.reason, "step");
103
+ console.log(pc.blue(`step finished: reason=${reason}`));
104
+ console.log(pc.blue(`tokens: in=${input} out=${output} cached=${cached} cost=$${cost.toFixed(6)}`));
105
+ return;
106
+ }
107
+ if (type === "error") {
108
+ const message = errorText(parsed.error ?? parsed.message);
109
+ if (message)
110
+ console.log(pc.red(`error: ${message}`));
111
+ return;
112
+ }
113
+ console.log(line);
114
+ }
115
+ //# sourceMappingURL=format-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-event.js","sourceRoot":"","sources":["../../src/cli/format-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrF,OAAO,KAAgC,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc,EAAE,QAAQ,GAAG,EAAE;IAC7C,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AC,CAAC;QAC1D,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { printOpenCodeStreamEvent } from "./format-event.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { printOpenCodeStreamEvent } from "./format-event.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const type = "opencode_local";
2
+ export declare const label = "OpenCode";
3
+ export declare const SANDBOX_INSTALL_COMMAND: string;
4
+ export declare const DEFAULT_OPENCODE_LOCAL_MODEL = "openai/gpt-5.2-codex";
5
+ export declare function isValidOpenCodeModelId(value: unknown): value is string;
6
+ export declare const models: Array<{
7
+ id: string;
8
+ label: string;
9
+ }>;
10
+ export declare const agentConfigurationDoc = "# opencode_local agent configuration\n\nAdapter: opencode_local\n\nUse when:\n- You want Paperclip to run OpenCode locally as the agent runtime\n- You want provider/model routing in OpenCode format (provider/model)\n- You want OpenCode session resume across heartbeats via --session\n\nDon't use when:\n- You need webhook-style external invocation (use openclaw_gateway or http)\n- You only need one-shot shell commands (use process)\n- OpenCode CLI is not installed on the machine\n\nCore fields:\n- cwd (string, optional): default absolute working directory fallback for the agent process (created if missing when possible)\n- instructionsFilePath (string, optional): absolute path to a markdown instructions file prepended to the run prompt\n- model (string, required): OpenCode model id in provider/model format (for example anthropic/claude-sonnet-4-5)\n- variant (string, optional): provider-specific reasoning/profile variant passed as --variant (for example minimal|low|medium|high|xhigh|max)\n- dangerouslySkipPermissions (boolean, optional): inject a runtime OpenCode config with `permission=allow` for all tools and connections; defaults to true for unattended Paperclip runs\n- promptTemplate (string, optional): run prompt template\n- command (string, optional): defaults to \"opencode\"\n- extraArgs (string[], optional): additional CLI args\n- env (object, optional): KEY=VALUE environment variables\n\nOperational fields:\n- timeoutSec (number, optional): run timeout in seconds\n- graceSec (number, optional): SIGTERM grace period in seconds\n\nNotes:\n- OpenCode supports multiple providers and models. Use `opencode models` to list available options in provider/model format.\n- Paperclip requires an explicit `model` value for `opencode_local` agents.\n- Runs are executed with: opencode run --format json ...\n- Sessions are resumed with --session when stored session cwd matches current cwd.\n- The adapter sets OPENCODE_DISABLE_PROJECT_CONFIG=true to prevent OpenCode from writing an opencode.json config file into the project working directory. Model selection is passed via the --model CLI flag instead.\n- When `dangerouslySkipPermissions` is enabled, Paperclip injects a temporary runtime config with `permission=allow` so headless runs do not stall on approval prompts.\n";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,mBAAmB,CAAC;AACrC,eAAO,MAAM,KAAK,aAAa,CAAC;AA8BhC,eAAO,MAAM,uBAAuB,QAW9B,CAAC;AAEP,eAAO,MAAM,4BAA4B,yBAAyB,CAAC;AAEnE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKtE;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAoBvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,0wEAyCjC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,113 @@
1
+ export const type = "opencode_local";
2
+ export const label = "OpenCode";
3
+ // Use OpenCode's official installer instead of `npm install -g opencode-ai`.
4
+ // The npm package reifies four large Linux x64 prebuilt-binary subpackages
5
+ // (linux-x64, linux-x64-musl, linux-x64-baseline, linux-x64-baseline-musl) in
6
+ // parallel even though only one matches the sandbox; on bandwidth-constrained
7
+ // sandboxes (e.g. Cloudflare) that exceeded the 240s install budget. The
8
+ // official installer fetches a single arch-specific binary into
9
+ // `$HOME/.opencode/bin` and tries to add it to PATH via `~/.bashrc`. That
10
+ // rc-file path is only sourced by interactive/login shells, so non-login
11
+ // `sh -c` probe invocations (used by the runtime PATH check) cannot find the
12
+ // binary. We fix that by symlinking the installed binary into a directory on
13
+ // the non-login `sh -c` PATH: prefer `/usr/local/bin` (universally on the
14
+ // default PATH on Linux distros) when root or passwordless sudo is available,
15
+ // otherwise fall back to `$HOME/.local/bin` (which is on the default PATH on
16
+ // the exe.dev sandbox image and most modern home-managed Linux images).
17
+ //
18
+ // Security tradeoff: this is `curl | bash` without a SHA-256 verification of
19
+ // the install script. We accept this because:
20
+ // 1. The install runs inside an isolated, ephemeral sandbox — blast radius
21
+ // is bounded to that sandbox's secrets and disk.
22
+ // 2. The prior `npm install -g opencode-ai` is also unverified code
23
+ // execution from a third-party registry; this is not strictly worse.
24
+ // 3. OpenCode does not publish per-release SHA-256 checksums in a stable
25
+ // location, and pinning a version + hash here would require manual
26
+ // version bumps on every OpenCode release.
27
+ // The `set -e` (implied by Bash's default with `-fsSL` upstream of a piped
28
+ // shell) and `curl -fsSL` give us fail-fast behavior on HTTP errors. If
29
+ // OpenCode starts publishing a stable checksum/signature, switch to fetching
30
+ // a versioned tarball + verifying the digest before exec.
31
+ export const SANDBOX_INSTALL_COMMAND = 'curl -fsSL https://opencode.ai/install | bash && ' +
32
+ 'if [ -x "$HOME/.opencode/bin/opencode" ]; then ' +
33
+ 'if [ "$(id -u)" -eq 0 ]; then ' +
34
+ 'ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' +
35
+ 'elif command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then ' +
36
+ 'sudo ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' +
37
+ 'else ' +
38
+ 'mkdir -p "$HOME/.local/bin" && ' +
39
+ 'ln -sf "$HOME/.opencode/bin/opencode" "$HOME/.local/bin/opencode"; ' +
40
+ 'fi; ' +
41
+ 'fi';
42
+ export const DEFAULT_OPENCODE_LOCAL_MODEL = "openai/gpt-5.2-codex";
43
+ export function isValidOpenCodeModelId(value) {
44
+ if (typeof value !== "string")
45
+ return false;
46
+ const trimmed = value.trim();
47
+ const slashIndex = trimmed.indexOf("/");
48
+ return Boolean(trimmed) && slashIndex > 0 && slashIndex !== trimmed.length - 1;
49
+ }
50
+ export const models = [
51
+ { id: DEFAULT_OPENCODE_LOCAL_MODEL, label: DEFAULT_OPENCODE_LOCAL_MODEL },
52
+ { id: "openai/gpt-6-astra", label: "openai/gpt-6-astra" },
53
+ { id: "openai/gpt-6-sol", label: "openai/gpt-6-sol" },
54
+ { id: "openai/gpt-6-luna", label: "openai/gpt-6-luna" },
55
+ { id: "openai/gpt-5.6-sol", label: "openai/gpt-5.6-sol" },
56
+ { id: "openai/gpt-5.6-terra", label: "openai/gpt-5.6-terra" },
57
+ { id: "openai/gpt-5.6-luna", label: "openai/gpt-5.6-luna" },
58
+ { id: "anthropic/claude-opus-5-5", label: "anthropic/claude-opus-5-5" },
59
+ { id: "anthropic/claude-opus-5", label: "anthropic/claude-opus-5" },
60
+ { id: "anthropic/claude-fable-5-1", label: "anthropic/claude-fable-5-1" },
61
+ { id: "anthropic/claude-sonnet-5", label: "anthropic/claude-sonnet-5" },
62
+ { id: "google/gemini-3.8-flash", label: "google/gemini-3.8-flash" },
63
+ { id: "xai/grok-4.7", label: "xai/grok-4.7" },
64
+ { id: "openai/gpt-5.5", label: "openai/gpt-5.5" },
65
+ { id: "openai/gpt-5.4", label: "openai/gpt-5.4" },
66
+ { id: "openai/gpt-5.4-mini", label: "openai/gpt-5.4-mini" },
67
+ { id: "openai/gpt-5.2", label: "openai/gpt-5.2" },
68
+ { id: "openai/gpt-5.1-codex-max", label: "openai/gpt-5.1-codex-max" },
69
+ { id: "openai/gpt-5.1-codex-mini", label: "openai/gpt-5.1-codex-mini" },
70
+ ];
71
+ export const agentConfigurationDoc = `# opencode_local agent configuration
72
+
73
+ Adapter: opencode_local
74
+
75
+ Use when:
76
+ - You want Paperclip to run OpenCode locally as the agent runtime
77
+ - You want provider/model routing in OpenCode format (provider/model)
78
+ - You want OpenCode session resume across heartbeats via --session
79
+
80
+ Don't use when:
81
+ - You need webhook-style external invocation (use openclaw_gateway or http)
82
+ - You only need one-shot shell commands (use process)
83
+ - OpenCode CLI is not installed on the machine
84
+
85
+ Core fields:
86
+ - cwd (string, optional): default absolute working directory fallback for the agent process (created if missing when possible)
87
+ - instructionsFilePath (string, optional): absolute path to a markdown instructions file prepended to the run prompt
88
+ - model (string, required): OpenCode model id in provider/model format (for example anthropic/claude-sonnet-4-5)
89
+ - variant (string, optional): provider-specific reasoning/profile variant passed as --variant (for example minimal|low|medium|high|xhigh|max)
90
+ - dangerouslySkipPermissions (boolean, optional): inject a runtime OpenCode config with \`permission=allow\` for all tools and connections; defaults to true for unattended Paperclip runs
91
+ - promptTemplate (string, optional): run prompt template
92
+ - command (string, optional): defaults to "opencode"
93
+ - extraArgs (string[], optional): additional CLI args
94
+ - env (object, optional): KEY=VALUE environment variables
95
+
96
+ Operational fields:
97
+ - timeoutSec (number, optional): run timeout in seconds
98
+ - graceSec (number, optional): SIGTERM grace period in seconds
99
+
100
+ Notes:
101
+ - OpenCode supports multiple providers and models. Use \
102
+ \`opencode models\` to list available options in provider/model format.
103
+ - Paperclip requires an explicit \`model\` value for \`opencode_local\` agents.
104
+ - Runs are executed with: opencode run --format json ...
105
+ - Sessions are resumed with --session when stored session cwd matches current cwd.
106
+ - The adapter sets OPENCODE_DISABLE_PROJECT_CONFIG=true to prevent OpenCode from \
107
+ writing an opencode.json config file into the project working directory. Model \
108
+ selection is passed via the --model CLI flag instead.
109
+ - When \`dangerouslySkipPermissions\` is enabled, Paperclip injects a temporary \
110
+ runtime config with \`permission=allow\` so headless runs do \
111
+ not stall on approval prompts.
112
+ `;
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,gBAAgB,CAAC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC;AAEhC,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,yEAAyE;AACzE,gEAAgE;AAChE,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,8CAA8C;AAC9C,6EAA6E;AAC7E,sDAAsD;AACtD,sEAAsE;AACtE,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,gDAAgD;AAChD,2EAA2E;AAC3E,wEAAwE;AACxE,6EAA6E;AAC7E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAClC,mDAAmD;IACnD,iDAAiD;IACjD,gCAAgC;IAChC,iEAAiE;IACjE,6EAA6E;IAC7E,sEAAsE;IACtE,OAAO;IACP,iCAAiC;IACjC,qEAAqE;IACrE,MAAM;IACN,IAAI,CAAC;AAEP,MAAM,CAAC,MAAM,4BAA4B,GAAG,sBAAsB,CAAC;AAEnE,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,U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K,EAAE,qBAAqB,EAAE;IAC3D,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,EAAE;IACjD,EAAE,EAAE,EAAE,0BAA0B,EAAE,KAAK,EAAE,0BAA0B,EAAE;IACrE,EAAE,EAAE,EAAE,2BAA2B,EAAE,KAAK,EAAE,2BAA2B,EAAE;CACxE,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCpC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type AdapterExecutionContext, type AdapterExecutionResult } from "@tickernelz/paperclip-pro-adapter-utils";
2
+ export declare function ensureRemoteOpenCodeModelConfiguredAndAvailable(input: {
3
+ runId: string;
4
+ executionTarget: NonNullable<AdapterExecutionContext["executionTarget"]>;
5
+ command: string;
6
+ model: string;
7
+ cwd: string;
8
+ env: Record<string, string>;
9
+ timeoutSec: number;
10
+ graceSec: number;
11
+ }): Promise<void>;
12
+ export declare function execute(ctx: AdapterExecutionContext): Promise<AdapterExecutionResult>;
13
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/server/execute.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+B,KAAK,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAsFjJ,wBAAsB,+CAA+C,CAAC,KAAK,EAAE;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,WAAW,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAsEA;AAsDD,wBAAsB,OAAO,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA+hB3F"}