@right-link/paperclip-plugin-codex-remote 0.3.1 → 0.3.2

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 (60) hide show
  1. package/dist/chunk-FULSN5VN.js +5348 -0
  2. package/dist/chunk-YJYVA7CY.js +99 -0
  3. package/dist/chunk-ZLN6QQMX.js +3267 -0
  4. package/dist/cli/index.js +190 -2
  5. package/dist/index.js +28 -84
  6. package/dist/server/adapter.js +140 -135
  7. package/dist/server/index.js +41 -56
  8. package/dist/server-utils-C4H4WJOG.js +104 -0
  9. package/dist/ui/index.js +318 -3
  10. package/package.json +7 -5
  11. package/dist/cli/format-event.js +0 -213
  12. package/dist/cli/format-event.js.map +0 -1
  13. package/dist/cli/index.js.map +0 -1
  14. package/dist/cli/quota-probe.js +0 -97
  15. package/dist/cli/quota-probe.js.map +0 -1
  16. package/dist/index.js.map +0 -1
  17. package/dist/server/adapter.js.map +0 -1
  18. package/dist/server/adapter.test.js +0 -84
  19. package/dist/server/adapter.test.js.map +0 -1
  20. package/dist/server/codex-args.js +0 -60
  21. package/dist/server/codex-args.js.map +0 -1
  22. package/dist/server/codex-args.test.js +0 -94
  23. package/dist/server/codex-args.test.js.map +0 -1
  24. package/dist/server/codex-home.js +0 -378
  25. package/dist/server/codex-home.js.map +0 -1
  26. package/dist/server/codex-home.test.js +0 -244
  27. package/dist/server/codex-home.test.js.map +0 -1
  28. package/dist/server/execute.js +0 -906
  29. package/dist/server/execute.js.map +0 -1
  30. package/dist/server/execute.remote.test.js +0 -487
  31. package/dist/server/execute.remote.test.js.map +0 -1
  32. package/dist/server/index.js.map +0 -1
  33. package/dist/server/parse.js +0 -213
  34. package/dist/server/parse.js.map +0 -1
  35. package/dist/server/parse.test.js +0 -107
  36. package/dist/server/parse.test.js.map +0 -1
  37. package/dist/server/quota-spawn-error.test.js +0 -77
  38. package/dist/server/quota-spawn-error.test.js.map +0 -1
  39. package/dist/server/quota.js +0 -432
  40. package/dist/server/quota.js.map +0 -1
  41. package/dist/server/sandbox-env.js +0 -23
  42. package/dist/server/sandbox-env.js.map +0 -1
  43. package/dist/server/skills.js +0 -24
  44. package/dist/server/skills.js.map +0 -1
  45. package/dist/server/tailscale.js +0 -95
  46. package/dist/server/tailscale.js.map +0 -1
  47. package/dist/server/test.js +0 -811
  48. package/dist/server/test.js.map +0 -1
  49. package/dist/server/test.remote.test.js +0 -257
  50. package/dist/server/test.remote.test.js.map +0 -1
  51. package/dist/ui/build-config.js +0 -113
  52. package/dist/ui/build-config.js.map +0 -1
  53. package/dist/ui/build-config.test.js +0 -49
  54. package/dist/ui/build-config.test.js.map +0 -1
  55. package/dist/ui/index.js.map +0 -1
  56. package/dist/ui/parse-stdout.js +0 -261
  57. package/dist/ui/parse-stdout.js.map +0 -1
  58. package/dist/ui/parse-stdout.test.js +0 -77
  59. package/dist/ui/parse-stdout.test.js.map +0 -1
  60. package/dist/ui-parser.js.map +0 -1
@@ -1,57 +1,42 @@
1
- export { execute, ensureCodexSkillsInjected } from "./execute.js";
2
- export { listCodexSkills, syncCodexSkills } from "./skills.js";
3
- export { testEnvironment } from "./test.js";
4
- export { parseCodexJsonl, isCodexTransientUpstreamError, isCodexUnknownSessionError } from "./parse.js";
5
- export { getQuotaWindows, readCodexAuthInfo, readCodexToken, fetchCodexQuota, fetchCodexRpcQuota, mapCodexRpcQuota, secondsToWindowLabel, fetchWithTimeout, codexHomeDir, } from "./quota.js";
6
- function readNonEmptyString(value) {
7
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
8
- }
9
- export const sessionCodec = {
10
- deserialize(raw) {
11
- if (typeof raw !== "object" || raw === null || Array.isArray(raw))
12
- return null;
13
- const record = raw;
14
- const sessionId = readNonEmptyString(record.sessionId) ?? readNonEmptyString(record.session_id);
15
- if (!sessionId)
16
- return null;
17
- const cwd = readNonEmptyString(record.cwd) ??
18
- readNonEmptyString(record.workdir) ??
19
- readNonEmptyString(record.folder);
20
- const workspaceId = readNonEmptyString(record.workspaceId) ?? readNonEmptyString(record.workspace_id);
21
- const repoUrl = readNonEmptyString(record.repoUrl) ?? readNonEmptyString(record.repo_url);
22
- const repoRef = readNonEmptyString(record.repoRef) ?? readNonEmptyString(record.repo_ref);
23
- return {
24
- sessionId,
25
- ...(cwd ? { cwd } : {}),
26
- ...(workspaceId ? { workspaceId } : {}),
27
- ...(repoUrl ? { repoUrl } : {}),
28
- ...(repoRef ? { repoRef } : {}),
29
- };
30
- },
31
- serialize(params) {
32
- if (!params)
33
- return null;
34
- const sessionId = readNonEmptyString(params.sessionId) ?? readNonEmptyString(params.session_id);
35
- if (!sessionId)
36
- return null;
37
- const cwd = readNonEmptyString(params.cwd) ??
38
- readNonEmptyString(params.workdir) ??
39
- readNonEmptyString(params.folder);
40
- const workspaceId = readNonEmptyString(params.workspaceId) ?? readNonEmptyString(params.workspace_id);
41
- const repoUrl = readNonEmptyString(params.repoUrl) ?? readNonEmptyString(params.repo_url);
42
- const repoRef = readNonEmptyString(params.repoRef) ?? readNonEmptyString(params.repo_ref);
43
- return {
44
- sessionId,
45
- ...(cwd ? { cwd } : {}),
46
- ...(workspaceId ? { workspaceId } : {}),
47
- ...(repoUrl ? { repoUrl } : {}),
48
- ...(repoRef ? { repoRef } : {}),
49
- };
50
- },
51
- getDisplayId(params) {
52
- if (!params)
53
- return null;
54
- return readNonEmptyString(params.sessionId) ?? readNonEmptyString(params.session_id);
55
- },
1
+ import {
2
+ codexHomeDir,
3
+ ensureCodexSkillsInjected,
4
+ execute,
5
+ fetchCodexQuota,
6
+ fetchCodexRpcQuota,
7
+ fetchWithTimeout,
8
+ getQuotaWindows,
9
+ isCodexTransientUpstreamError,
10
+ isCodexUnknownSessionError,
11
+ listCodexSkills,
12
+ mapCodexRpcQuota,
13
+ parseCodexJsonl,
14
+ readCodexAuthInfo,
15
+ readCodexToken,
16
+ secondsToWindowLabel,
17
+ sessionCodec,
18
+ syncCodexSkills,
19
+ testEnvironment
20
+ } from "../chunk-FULSN5VN.js";
21
+ import "../chunk-YJYVA7CY.js";
22
+ import "../chunk-ZLN6QQMX.js";
23
+ export {
24
+ codexHomeDir,
25
+ ensureCodexSkillsInjected,
26
+ execute,
27
+ fetchCodexQuota,
28
+ fetchCodexRpcQuota,
29
+ fetchWithTimeout,
30
+ getQuotaWindows,
31
+ isCodexTransientUpstreamError,
32
+ isCodexUnknownSessionError,
33
+ listCodexSkills,
34
+ mapCodexRpcQuota,
35
+ parseCodexJsonl,
36
+ readCodexAuthInfo,
37
+ readCodexToken,
38
+ secondsToWindowLabel,
39
+ sessionCodec,
40
+ syncCodexSkills,
41
+ testEnvironment
56
42
  };
57
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,104 @@
1
+ import {
2
+ DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
3
+ MAX_CAPTURE_BYTES,
4
+ MAX_EXCERPT_BYTES,
5
+ WATCHDOG_DEFAULT_MANDATE,
6
+ appendWithByteCap,
7
+ appendWithCap,
8
+ applyPaperclipWorkspaceEnv,
9
+ asBoolean,
10
+ asNumber,
11
+ asString,
12
+ asStringArray,
13
+ buildInvocationEnvForLogs,
14
+ buildPaperclipEnv,
15
+ buildPersistentSkillSnapshot,
16
+ buildRuntimeMountedSkillSnapshot,
17
+ defaultPathForPlatform,
18
+ ensureAbsoluteDirectory,
19
+ ensureCommandResolvable,
20
+ ensurePaperclipSkillSymlink,
21
+ ensurePathInEnv,
22
+ joinPromptSections,
23
+ listPaperclipSkillEntries,
24
+ materializePaperclipSkillCopy,
25
+ normalizePaperclipWakePayload,
26
+ parseJson,
27
+ parseObject,
28
+ readInstalledSkillTargets,
29
+ readPaperclipIssueWorkModeFromContext,
30
+ readPaperclipRuntimeSkillEntries,
31
+ readPaperclipSkillMarkdown,
32
+ readPaperclipSkillSyncPreference,
33
+ redactCommandTextForLogs,
34
+ redactEnvForLogs,
35
+ refreshPaperclipWorkspaceEnvForExecution,
36
+ removeMaintainerOnlySkillSymlinks,
37
+ renderPaperclipWakePrompt,
38
+ renderTemplate,
39
+ resolveCommandForLogs,
40
+ resolvePaperclipDesiredSkillNames,
41
+ resolvePaperclipInstanceRootForAdapter,
42
+ resolvePaperclipSkillsDir,
43
+ resolvePathValue,
44
+ rewriteWorkspaceCwdEnvVarsForExecution,
45
+ runChildProcess,
46
+ runningProcesses,
47
+ sanitizeInheritedPaperclipEnv,
48
+ sanitizeSshRemoteEnv,
49
+ shapePaperclipWorkspaceEnvForExecution,
50
+ stringifyPaperclipWakePayload,
51
+ writePaperclipSkillSyncPreference
52
+ } from "./chunk-ZLN6QQMX.js";
53
+ export {
54
+ DEFAULT_PAPERCLIP_AGENT_PROMPT_TEMPLATE,
55
+ MAX_CAPTURE_BYTES,
56
+ MAX_EXCERPT_BYTES,
57
+ WATCHDOG_DEFAULT_MANDATE,
58
+ appendWithByteCap,
59
+ appendWithCap,
60
+ applyPaperclipWorkspaceEnv,
61
+ asBoolean,
62
+ asNumber,
63
+ asString,
64
+ asStringArray,
65
+ buildInvocationEnvForLogs,
66
+ buildPaperclipEnv,
67
+ buildPersistentSkillSnapshot,
68
+ buildRuntimeMountedSkillSnapshot,
69
+ defaultPathForPlatform,
70
+ ensureAbsoluteDirectory,
71
+ ensureCommandResolvable,
72
+ ensurePaperclipSkillSymlink,
73
+ ensurePathInEnv,
74
+ joinPromptSections,
75
+ listPaperclipSkillEntries,
76
+ materializePaperclipSkillCopy,
77
+ normalizePaperclipWakePayload,
78
+ parseJson,
79
+ parseObject,
80
+ readInstalledSkillTargets,
81
+ readPaperclipIssueWorkModeFromContext,
82
+ readPaperclipRuntimeSkillEntries,
83
+ readPaperclipSkillMarkdown,
84
+ readPaperclipSkillSyncPreference,
85
+ redactCommandTextForLogs,
86
+ redactEnvForLogs,
87
+ refreshPaperclipWorkspaceEnvForExecution,
88
+ removeMaintainerOnlySkillSymlinks,
89
+ renderPaperclipWakePrompt,
90
+ renderTemplate,
91
+ resolveCommandForLogs,
92
+ resolvePaperclipDesiredSkillNames,
93
+ resolvePaperclipInstanceRootForAdapter,
94
+ resolvePaperclipSkillsDir,
95
+ resolvePathValue,
96
+ rewriteWorkspaceCwdEnvVarsForExecution,
97
+ runChildProcess,
98
+ runningProcesses,
99
+ sanitizeInheritedPaperclipEnv,
100
+ sanitizeSshRemoteEnv,
101
+ shapePaperclipWorkspaceEnvForExecution,
102
+ stringifyPaperclipWakePayload,
103
+ writePaperclipSkillSyncPreference
104
+ };
package/dist/ui/index.js CHANGED
@@ -1,3 +1,318 @@
1
- export { parseCodexStdoutLine } from "./parse-stdout.js";
2
- export { buildCodexRemoteConfig } from "./build-config.js";
3
- //# sourceMappingURL=index.js.map
1
+ import {
2
+ DEFAULT_CODEX_REMOTE_BYPASS_APPROVALS_AND_SANDBOX,
3
+ DEFAULT_CODEX_REMOTE_MODEL
4
+ } from "../chunk-YJYVA7CY.js";
5
+
6
+ // src/ui/parse-stdout.ts
7
+ function safeJsonParse(text) {
8
+ try {
9
+ return JSON.parse(text);
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ function asRecord(value) {
15
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
16
+ return value;
17
+ }
18
+ function asString(value, fallback = "") {
19
+ return typeof value === "string" ? value : fallback;
20
+ }
21
+ function asNumber(value, fallback = 0) {
22
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
23
+ }
24
+ function errorText(value) {
25
+ if (typeof value === "string") return value;
26
+ const rec = asRecord(value);
27
+ if (!rec) return "";
28
+ const msg = typeof rec.message === "string" && rec.message || typeof rec.error === "string" && rec.error || typeof rec.code === "string" && rec.code || "";
29
+ if (msg) return msg;
30
+ try {
31
+ return JSON.stringify(rec);
32
+ } catch {
33
+ return "";
34
+ }
35
+ }
36
+ function stringifyUnknown(value) {
37
+ if (typeof value === "string") return value;
38
+ if (value === null || value === void 0) return "";
39
+ try {
40
+ return JSON.stringify(value, null, 2);
41
+ } catch {
42
+ return String(value);
43
+ }
44
+ }
45
+ function parseCommandExecutionItem(item, ts, phase) {
46
+ const id = asString(item.id);
47
+ const command = asString(item.command);
48
+ const status = asString(item.status);
49
+ const exitCode = typeof item.exit_code === "number" && Number.isFinite(item.exit_code) ? item.exit_code : null;
50
+ const safeCommand = command;
51
+ const output = asString(item.aggregated_output).replace(/\s+$/, "");
52
+ if (phase === "started") {
53
+ return [{
54
+ kind: "tool_call",
55
+ ts,
56
+ name: "command_execution",
57
+ toolUseId: id || command || "command_execution",
58
+ input: {
59
+ id,
60
+ command: safeCommand
61
+ }
62
+ }];
63
+ }
64
+ const lines = [];
65
+ if (safeCommand) lines.push(`command: ${safeCommand}`);
66
+ if (status) lines.push(`status: ${status}`);
67
+ if (exitCode !== null) lines.push(`exit_code: ${exitCode}`);
68
+ if (output) {
69
+ if (lines.length > 0) lines.push("");
70
+ lines.push(output);
71
+ }
72
+ const isError = exitCode !== null && exitCode !== 0 || status === "failed" || status === "errored" || status === "error" || status === "cancelled";
73
+ return [{
74
+ kind: "tool_result",
75
+ ts,
76
+ toolUseId: id || command || "command_execution",
77
+ content: lines.join("\n").trim() || "command completed",
78
+ isError
79
+ }];
80
+ }
81
+ function parseFileChangeItem(item, ts) {
82
+ const changes = Array.isArray(item.changes) ? item.changes : [];
83
+ const entries = changes.map((changeRaw) => asRecord(changeRaw)).filter((change) => Boolean(change)).map((change) => {
84
+ const kind = asString(change.kind, "update");
85
+ const path = asString(change.path, "unknown");
86
+ return `${kind} ${path}`;
87
+ });
88
+ if (entries.length === 0) {
89
+ return [{ kind: "system", ts, text: "file changes applied" }];
90
+ }
91
+ const preview = entries.slice(0, 6).join(", ");
92
+ const more = entries.length > 6 ? ` (+${entries.length - 6} more)` : "";
93
+ return [{ kind: "system", ts, text: `file changes: ${preview}${more}` }];
94
+ }
95
+ function parseToolUseItem(item, ts, phase) {
96
+ const name = asString(item.name, "unknown");
97
+ const toolUseId = asString(item.id, name || "tool_use");
98
+ if (phase === "started") {
99
+ return [{
100
+ kind: "tool_call",
101
+ ts,
102
+ name,
103
+ toolUseId,
104
+ input: item.input ?? {}
105
+ }];
106
+ }
107
+ const status = asString(item.status);
108
+ const isError = item.is_error === true || status === "failed" || status === "errored" || status === "error" || status === "cancelled";
109
+ const rawContent = item.content ?? item.output ?? item.result ?? item.error ?? item.message;
110
+ const content = asString(rawContent) || errorText(rawContent) || stringifyUnknown(rawContent) || `${name} ${isError ? "failed" : "completed"}`;
111
+ return [{
112
+ kind: "tool_result",
113
+ ts,
114
+ toolUseId,
115
+ content,
116
+ isError
117
+ }];
118
+ }
119
+ function parseCodexItem(item, ts, phase) {
120
+ const itemType = asString(item.type);
121
+ if (itemType === "agent_message") {
122
+ const text = asString(item.text);
123
+ if (text) return [{ kind: "assistant", ts, text }];
124
+ return [];
125
+ }
126
+ if (itemType === "reasoning") {
127
+ const text = asString(item.text);
128
+ if (text) return [{ kind: "thinking", ts, text }];
129
+ return [{ kind: "system", ts, text: phase === "started" ? "reasoning started" : "reasoning completed" }];
130
+ }
131
+ if (itemType === "command_execution") {
132
+ return parseCommandExecutionItem(item, ts, phase);
133
+ }
134
+ if (itemType === "file_change" && phase === "completed") {
135
+ return parseFileChangeItem(item, ts);
136
+ }
137
+ if (itemType === "tool_use") {
138
+ return parseToolUseItem(item, ts, phase);
139
+ }
140
+ if (itemType === "tool_result" && phase === "completed") {
141
+ const toolUseId = asString(item.tool_use_id, asString(item.id));
142
+ const content = asString(item.content) || asString(item.output) || asString(item.result) || stringifyUnknown(item.content ?? item.output ?? item.result);
143
+ const isError = item.is_error === true || asString(item.status) === "error";
144
+ return [{ kind: "tool_result", ts, toolUseId, content, isError }];
145
+ }
146
+ if (itemType === "error" && phase === "completed") {
147
+ const text = errorText(item.message ?? item.error ?? item);
148
+ return [{ kind: "stderr", ts, text: text || "error" }];
149
+ }
150
+ const id = asString(item.id);
151
+ const status = asString(item.status);
152
+ const meta = [id ? `id=${id}` : "", status ? `status=${status}` : ""].filter(Boolean).join(" ");
153
+ return [{
154
+ kind: "system",
155
+ ts,
156
+ text: `item ${phase}: ${itemType || "unknown"}${meta ? ` (${meta})` : ""}`
157
+ }];
158
+ }
159
+ function parseCodexStdoutLine(line, ts) {
160
+ const parsed = asRecord(safeJsonParse(line));
161
+ if (!parsed) {
162
+ return [{ kind: "stdout", ts, text: line }];
163
+ }
164
+ const type = asString(parsed.type);
165
+ if (type === "thread.started") {
166
+ const threadId = asString(parsed.thread_id);
167
+ return [{
168
+ kind: "init",
169
+ ts,
170
+ model: asString(parsed.model, "codex"),
171
+ sessionId: threadId
172
+ }];
173
+ }
174
+ if (type === "turn.started") {
175
+ return [{ kind: "system", ts, text: "turn started" }];
176
+ }
177
+ if (type === "item.started" || type === "item.completed") {
178
+ const item = asRecord(parsed.item);
179
+ if (!item) return [{ kind: "system", ts, text: type.replace(".", " ") }];
180
+ return parseCodexItem(item, ts, type === "item.started" ? "started" : "completed");
181
+ }
182
+ if (type === "turn.completed") {
183
+ const usage = asRecord(parsed.usage);
184
+ const inputTokens = asNumber(usage?.input_tokens);
185
+ const outputTokens = asNumber(usage?.output_tokens);
186
+ const cachedTokens = asNumber(usage?.cached_input_tokens, asNumber(usage?.cache_read_input_tokens));
187
+ return [{
188
+ kind: "result",
189
+ ts,
190
+ text: asString(parsed.result),
191
+ inputTokens,
192
+ outputTokens,
193
+ cachedTokens,
194
+ costUsd: asNumber(parsed.total_cost_usd),
195
+ subtype: asString(parsed.subtype),
196
+ isError: parsed.is_error === true,
197
+ errors: Array.isArray(parsed.errors) ? parsed.errors.map(errorText).filter(Boolean) : []
198
+ }];
199
+ }
200
+ if (type === "turn.failed") {
201
+ const usage = asRecord(parsed.usage);
202
+ const inputTokens = asNumber(usage?.input_tokens);
203
+ const outputTokens = asNumber(usage?.output_tokens);
204
+ const cachedTokens = asNumber(usage?.cached_input_tokens, asNumber(usage?.cache_read_input_tokens));
205
+ const message = errorText(parsed.error ?? parsed.message);
206
+ return [{
207
+ kind: "result",
208
+ ts,
209
+ text: asString(parsed.result),
210
+ inputTokens,
211
+ outputTokens,
212
+ cachedTokens,
213
+ costUsd: asNumber(parsed.total_cost_usd),
214
+ subtype: asString(parsed.subtype, "turn.failed"),
215
+ isError: true,
216
+ errors: message ? [message] : []
217
+ }];
218
+ }
219
+ if (type === "error") {
220
+ const message = errorText(parsed.message ?? parsed.error ?? parsed);
221
+ return [{ kind: "stderr", ts, text: message || line }];
222
+ }
223
+ return [{ kind: "stdout", ts, text: line }];
224
+ }
225
+
226
+ // src/ui/build-config.ts
227
+ function parseCommaArgs(value) {
228
+ return value.split(",").map((item) => item.trim()).filter(Boolean);
229
+ }
230
+ function parseEnvVars(text) {
231
+ const env = {};
232
+ for (const line of text.split(/\r?\n/)) {
233
+ const trimmed = line.trim();
234
+ if (!trimmed || trimmed.startsWith("#")) continue;
235
+ const eq = trimmed.indexOf("=");
236
+ if (eq <= 0) continue;
237
+ const key = trimmed.slice(0, eq).trim();
238
+ const value = trimmed.slice(eq + 1);
239
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue;
240
+ env[key] = value;
241
+ }
242
+ return env;
243
+ }
244
+ function parseEnvBindings(bindings) {
245
+ if (typeof bindings !== "object" || bindings === null || Array.isArray(bindings)) return {};
246
+ const env = {};
247
+ for (const [key, raw] of Object.entries(bindings)) {
248
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue;
249
+ if (typeof raw === "string") {
250
+ env[key] = { type: "plain", value: raw };
251
+ continue;
252
+ }
253
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) continue;
254
+ const rec = raw;
255
+ if (rec.type === "plain" && typeof rec.value === "string") {
256
+ env[key] = { type: "plain", value: rec.value };
257
+ continue;
258
+ }
259
+ if (rec.type === "secret_ref" && typeof rec.secretId === "string") {
260
+ env[key] = {
261
+ type: "secret_ref",
262
+ secretId: rec.secretId,
263
+ ...typeof rec.version === "number" || rec.version === "latest" ? { version: rec.version } : {}
264
+ };
265
+ }
266
+ }
267
+ return env;
268
+ }
269
+ function parseJsonObject(text) {
270
+ const trimmed = text.trim();
271
+ if (!trimmed) return null;
272
+ try {
273
+ const parsed = JSON.parse(trimmed);
274
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
275
+ return parsed;
276
+ } catch {
277
+ return null;
278
+ }
279
+ }
280
+ function buildCodexRemoteConfig(v) {
281
+ const ac = {};
282
+ if (v.cwd) ac.cwd = v.cwd;
283
+ if (v.instructionsFilePath) ac.instructionsFilePath = v.instructionsFilePath;
284
+ ac.model = v.model || DEFAULT_CODEX_REMOTE_MODEL;
285
+ if (v.thinkingEffort) ac.modelReasoningEffort = v.thinkingEffort;
286
+ ac.timeoutSec = 0;
287
+ ac.graceSec = 15;
288
+ const env = parseEnvBindings(v.envBindings);
289
+ const legacy = parseEnvVars(v.envVars);
290
+ for (const [key, value] of Object.entries(legacy)) {
291
+ if (!Object.prototype.hasOwnProperty.call(env, key)) {
292
+ env[key] = { type: "plain", value };
293
+ }
294
+ }
295
+ if (Object.keys(env).length > 0) ac.env = env;
296
+ ac.search = v.search;
297
+ ac.fastMode = v.fastMode;
298
+ ac.dangerouslyBypassApprovalsAndSandbox = typeof v.dangerouslyBypassSandbox === "boolean" ? v.dangerouslyBypassSandbox : DEFAULT_CODEX_REMOTE_BYPASS_APPROVALS_AND_SANDBOX;
299
+ if (v.workspaceStrategyType === "git_worktree") {
300
+ ac.workspaceStrategy = {
301
+ type: "git_worktree",
302
+ ...v.workspaceBaseRef ? { baseRef: v.workspaceBaseRef } : {},
303
+ ...v.workspaceBranchTemplate ? { branchTemplate: v.workspaceBranchTemplate } : {},
304
+ ...v.worktreeParentDir ? { worktreeParentDir: v.worktreeParentDir } : {}
305
+ };
306
+ }
307
+ const runtimeServices = parseJsonObject(v.runtimeServicesJson ?? "");
308
+ if (runtimeServices && Array.isArray(runtimeServices.services)) {
309
+ ac.workspaceRuntime = runtimeServices;
310
+ }
311
+ if (v.command) ac.command = v.command;
312
+ if (v.extraArgs) ac.extraArgs = parseCommaArgs(v.extraArgs);
313
+ return ac;
314
+ }
315
+ export {
316
+ buildCodexRemoteConfig,
317
+ parseCodexStdoutLine
318
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@right-link/paperclip-plugin-codex-remote",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Standalone external Codex sandbox adapter for Paperclip (fork add-on, installed via the adapter plugin store)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/paperclipai/paperclip",
@@ -50,15 +50,17 @@
50
50
  "skills"
51
51
  ],
52
52
  "dependencies": {
53
- "picocolors": "^1.1.1",
54
- "@paperclipai/adapter-utils": "0.3.1"
53
+ "picocolors": "^1.1.1"
55
54
  },
56
55
  "devDependencies": {
57
56
  "@types/node": "^24.6.0",
58
- "typescript": "^5.7.3"
57
+ "esbuild": "^0.28.0",
58
+ "typescript": "^5.7.3",
59
+ "@paperclipai/adapter-utils": "0.3.1"
59
60
  },
60
61
  "scripts": {
61
- "build": "tsc && pnpm run build:ui-parser",
62
+ "build": "tsc --emitDeclarationOnly && pnpm run build:bundle && pnpm run build:ui-parser",
63
+ "build:bundle": "pnpm exec esbuild src/server/adapter.ts src/server/index.ts src/index.ts src/ui/index.ts src/cli/index.ts --bundle --splitting --format=esm --platform=node --outdir=dist --external:picocolors",
62
64
  "build:ui-parser": "pnpm exec esbuild src/ui-parser.ts --bundle --format=cjs --platform=browser --outfile=dist/ui-parser.js",
63
65
  "clean": "rm -rf dist",
64
66
  "typecheck": "tsc --noEmit",