@pushpalsdev/cli 1.0.18 → 1.0.20
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/dist/pushpals-cli.js +291 -44
- package/package.json +1 -1
- package/runtime/configs/backend.toml +1 -1
- package/runtime/configs/default.toml +1 -1
- package/runtime/sandbox/apps/workerpals/.python-version +1 -0
- package/runtime/sandbox/apps/workerpals/Dockerfile.sandbox +71 -0
- package/runtime/sandbox/apps/workerpals/package.json +25 -0
- package/runtime/sandbox/apps/workerpals/pyproject.toml +8 -0
- package/runtime/sandbox/apps/workerpals/src/backends/backend_config.ts +119 -0
- package/runtime/sandbox/apps/workerpals/src/backends/miniswe/miniswe_executor.py +2029 -0
- package/runtime/sandbox/apps/workerpals/src/backends/miniswe_backend.ts +48 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openai_codex/openai_codex_executor.py +1259 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openai_codex/test_openai_codex_runtime_config.py +110 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openai_codex_backend.ts +67 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openhands/openhands_executor.py +563 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openhands_backend.ts +161 -0
- package/runtime/sandbox/apps/workerpals/src/backends/openhands_task_execute.ts +536 -0
- package/runtime/sandbox/apps/workerpals/src/backends/shared/executor_base.py +746 -0
- package/runtime/sandbox/apps/workerpals/src/backends/shared/test_settings_resolver.py +60 -0
- package/runtime/sandbox/apps/workerpals/src/backends/task_execute_registry.ts +21 -0
- package/runtime/sandbox/apps/workerpals/src/backends/types.ts +52 -0
- package/runtime/sandbox/apps/workerpals/src/common/execution_utils.ts +149 -0
- package/runtime/sandbox/apps/workerpals/src/common/executor_backend.ts +15 -0
- package/runtime/sandbox/apps/workerpals/src/common/generic_python_executor.ts +210 -0
- package/runtime/sandbox/apps/workerpals/src/common/logger.ts +65 -0
- package/runtime/sandbox/apps/workerpals/src/common/types.ts +9 -0
- package/runtime/sandbox/apps/workerpals/src/common/worktree_cleanup.ts +66 -0
- package/runtime/sandbox/apps/workerpals/src/context_manager.ts +45 -0
- package/runtime/sandbox/apps/workerpals/src/docker_executor.ts +1842 -0
- package/runtime/sandbox/apps/workerpals/src/execute_job.ts +3063 -0
- package/runtime/sandbox/apps/workerpals/src/job_runner.ts +194 -0
- package/runtime/sandbox/apps/workerpals/src/shell_manager.ts +210 -0
- package/runtime/sandbox/apps/workerpals/src/timeout_policy.ts +24 -0
- package/runtime/sandbox/apps/workerpals/src/workerpals_main.ts +1436 -0
- package/runtime/sandbox/apps/workerpals/tsconfig.json +15 -0
- package/runtime/sandbox/apps/workerpals/uv.lock +2014 -0
- package/runtime/sandbox/bun.lock +2591 -0
- package/runtime/sandbox/configs/backend.toml +79 -0
- package/runtime/sandbox/configs/default.toml +260 -0
- package/runtime/sandbox/configs/dev.toml +2 -0
- package/runtime/sandbox/configs/local.example.toml +129 -0
- package/runtime/sandbox/package.json +65 -0
- package/runtime/sandbox/packages/protocol/README.md +168 -0
- package/runtime/sandbox/packages/protocol/package.json +37 -0
- package/runtime/sandbox/packages/protocol/scripts/copy-schemas.js +17 -0
- package/runtime/sandbox/packages/protocol/src/a2a/README.md +52 -0
- package/runtime/sandbox/packages/protocol/src/a2a/mapping.ts +55 -0
- package/runtime/sandbox/packages/protocol/src/index.browser.ts +25 -0
- package/runtime/sandbox/packages/protocol/src/index.ts +25 -0
- package/runtime/sandbox/packages/protocol/src/schemas/approvals.schema.json +6 -0
- package/runtime/sandbox/packages/protocol/src/schemas/envelope.schema.json +96 -0
- package/runtime/sandbox/packages/protocol/src/schemas/events.schema.json +679 -0
- package/runtime/sandbox/packages/protocol/src/schemas/http.schema.json +50 -0
- package/runtime/sandbox/packages/protocol/src/types.ts +267 -0
- package/runtime/sandbox/packages/protocol/src/validate.browser.ts +154 -0
- package/runtime/sandbox/packages/protocol/src/validate.ts +233 -0
- package/runtime/sandbox/packages/protocol/src/version.ts +1 -0
- package/runtime/sandbox/packages/protocol/tsconfig.json +20 -0
- package/runtime/sandbox/packages/shared/package.json +19 -0
- package/runtime/sandbox/packages/shared/src/autonomy_policy.ts +400 -0
- package/runtime/sandbox/packages/shared/src/client_preflight.ts +286 -0
- package/runtime/sandbox/packages/shared/src/communication.ts +313 -0
- package/runtime/sandbox/packages/shared/src/config.ts +2180 -0
- package/runtime/sandbox/packages/shared/src/config_template_parity.ts +70 -0
- package/runtime/sandbox/packages/shared/src/git_backend.ts +205 -0
- package/runtime/sandbox/packages/shared/src/index.ts +101 -0
- package/runtime/sandbox/packages/shared/src/local_network.ts +101 -0
- package/runtime/sandbox/packages/shared/src/localbuddy_runtime.ts +314 -0
- package/runtime/sandbox/packages/shared/src/prompts.ts +64 -0
- package/runtime/sandbox/packages/shared/src/repo.ts +134 -0
- package/runtime/sandbox/packages/shared/src/session_event_visibility.ts +25 -0
- package/runtime/sandbox/packages/shared/src/vision.ts +247 -0
- package/runtime/sandbox/packages/shared/tsconfig.json +16 -0
- package/runtime/sandbox/prompts/workerpals/codex_quality_critic_instruction_prompt.md +14 -0
- package/runtime/sandbox/prompts/workerpals/commit_message_prompt.md +36 -0
- package/runtime/sandbox/prompts/workerpals/commit_message_user_prompt.md +7 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_broker_system_prompt.md +33 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_broker_task_prompt.md +5 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_completion_requirement.md +1 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_context_compaction_retry_prompt.md +1 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_explicit_targets_block.md +2 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_recovery_guidance_base.md +4 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_recovery_guidance_blocker_line.md +1 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_strict_tool_use_guidance.md +6 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_supplemental_guidance_section.md +2 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_timeout_note.md +1 -0
- package/runtime/sandbox/prompts/workerpals/miniswe_toolcall_retry_guidance.md +1 -0
- package/runtime/sandbox/prompts/workerpals/openai_codex_default_system_prompt.md +4 -0
- package/runtime/sandbox/prompts/workerpals/openai_codex_instruction_wrapper.md +5 -0
- package/runtime/sandbox/prompts/workerpals/openai_codex_runtime_policy_appendix.md +5 -0
- package/runtime/sandbox/prompts/workerpals/openai_codex_supplemental_guidance_section.md +2 -0
- package/runtime/sandbox/prompts/workerpals/openai_codex_task_execute_system_prompt.md +12 -0
- package/runtime/sandbox/prompts/workerpals/openhands_minimal_security_policy.j2 +8 -0
- package/runtime/sandbox/prompts/workerpals/openhands_minimal_system_prompt.j2 +20 -0
- package/runtime/sandbox/prompts/workerpals/openhands_strict_tool_use_message.md +1 -0
- package/runtime/sandbox/prompts/workerpals/openhands_supplemental_guidance_message.md +2 -0
- package/runtime/sandbox/prompts/workerpals/openhands_task_execute_fallback_system_prompt.md +1 -0
- package/runtime/sandbox/prompts/workerpals/openhands_task_execute_system_prompt.md +21 -0
- package/runtime/sandbox/prompts/workerpals/openhands_task_user_prompt.md +6 -0
- package/runtime/sandbox/prompts/workerpals/openhands_timeout_note.md +1 -0
- package/runtime/sandbox/prompts/workerpals/pr_description.md +42 -0
- package/runtime/sandbox/prompts/workerpals/task_quality_critic_system_prompt.md +9 -0
- package/runtime/sandbox/prompts/workerpals/task_quality_critic_user_prompt.md +17 -0
- package/runtime/sandbox/prompts/workerpals/workerpals_system_prompt.md +115 -0
- package/runtime/sandbox/protocol/schemas/approvals.schema.json +6 -0
- package/runtime/sandbox/protocol/schemas/envelope.schema.json +96 -0
- package/runtime/sandbox/protocol/schemas/events.schema.json +679 -0
- package/runtime/sandbox/protocol/schemas/http.schema.json +50 -0
|
@@ -0,0 +1,2180 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { join, resolve, isAbsolute } from "path";
|
|
3
|
+
import { normalizeAutonomyComponentArea } from "./autonomy_policy.js";
|
|
4
|
+
import { normalizeLoopbackHost, normalizeLoopbackHttpUrl } from "./local_network.js";
|
|
5
|
+
|
|
6
|
+
type TomlValue = string | number | boolean | null | TomlObject | TomlValue[];
|
|
7
|
+
interface TomlObject {
|
|
8
|
+
[key: string]: TomlValue;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const PROJECT_ROOT = resolve(import.meta.dir, "..", "..", "..");
|
|
12
|
+
const DEFAULT_CONFIG_DIR = "configs";
|
|
13
|
+
|
|
14
|
+
const TRUTHY = new Set(["1", "true", "yes", "on"]);
|
|
15
|
+
const FALSY = new Set(["0", "false", "no", "off"]);
|
|
16
|
+
const DEFAULT_WORKERPALS_QUALITY_CRITIC_MIN_SCORE = 8;
|
|
17
|
+
const DEFAULT_WORKERPALS_QUALITY_MAX_AUTO_REVISIONS = 1;
|
|
18
|
+
const DEFAULT_WORKERPALS_FILE_MODIFYING_JOBS = ["task.execute"];
|
|
19
|
+
const DEFAULT_WORKERPALS_OUTPUT_MAX_CHARS = 192 * 1024;
|
|
20
|
+
const DEFAULT_WORKERPALS_OUTPUT_MAX_LINES = 600;
|
|
21
|
+
const DEFAULT_WORKERPALS_OUTPUT_MAX_HEAD_LINES = 120;
|
|
22
|
+
const DEFAULT_WORKERPALS_QUALITY_VALIDATION_STEP_TIMEOUT_MS = 180_000;
|
|
23
|
+
const DEFAULT_WORKERPALS_QUALITY_CRITIC_TIMEOUT_MS = 45_000;
|
|
24
|
+
const DEFAULT_WORKERPALS_QUALITY_CRITIC_MAX_DIFF_CHARS = 16_000;
|
|
25
|
+
const DEFAULT_WORKERPALS_QUALITY_CRITIC_MAX_VALIDATION_OUTPUT_CHARS = 8_000;
|
|
26
|
+
export const DEFAULT_WORKERPALS_EXECUTOR = "openai_codex";
|
|
27
|
+
const DEFAULT_WORKERPALS_EXECUTOR_RESULT_PREFIX = "__PUSHPALS_OH_RESULT__ ";
|
|
28
|
+
const DEFAULT_REMOTEBUDDY_MEMORY_MAX_RECALL_ITEMS = 12;
|
|
29
|
+
const DEFAULT_REMOTEBUDDY_MEMORY_MAX_RECALL_CHARS = 2400;
|
|
30
|
+
const DEFAULT_REMOTEBUDDY_MEMORY_MAX_SUMMARY_CHARS = 420;
|
|
31
|
+
const DEFAULT_REMOTEBUDDY_MEMORY_RETENTION_DAYS = 30;
|
|
32
|
+
const REDACTED_LOG_VALUE = "[REDACTED]";
|
|
33
|
+
const SENSITIVE_CONFIG_KEY_PATTERN =
|
|
34
|
+
/(token|secret|password|api[_-]?key|private[_-]?key|access[_-]?key)/i;
|
|
35
|
+
|
|
36
|
+
export interface PushPalsLlmConfig {
|
|
37
|
+
backend: string;
|
|
38
|
+
endpoint: string;
|
|
39
|
+
model: string;
|
|
40
|
+
apiKey: string;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
reasoningEffort: string;
|
|
43
|
+
codexAuthMode: string;
|
|
44
|
+
codexBin: string;
|
|
45
|
+
codexTimeoutMs: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PushPalsLmStudioConfig {
|
|
49
|
+
contextWindow: number;
|
|
50
|
+
minOutputTokens: number;
|
|
51
|
+
tokenSafetyMargin: number;
|
|
52
|
+
batchTailMessages: number;
|
|
53
|
+
batchChunkTokens: number;
|
|
54
|
+
batchMemoryChars: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PushPalsCheckConfig {
|
|
58
|
+
name: string;
|
|
59
|
+
command: string;
|
|
60
|
+
timeoutMs: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface PushPalsConfig {
|
|
64
|
+
projectRoot: string;
|
|
65
|
+
configDir: string;
|
|
66
|
+
profile: string;
|
|
67
|
+
sessionId: string;
|
|
68
|
+
authToken: string | null;
|
|
69
|
+
gitToken: string | null;
|
|
70
|
+
llm: {
|
|
71
|
+
lmstudio: PushPalsLmStudioConfig;
|
|
72
|
+
};
|
|
73
|
+
paths: {
|
|
74
|
+
dataDir: string;
|
|
75
|
+
sharedDbPath: string;
|
|
76
|
+
remotebuddyDbPath: string;
|
|
77
|
+
};
|
|
78
|
+
server: {
|
|
79
|
+
url: string;
|
|
80
|
+
host: string;
|
|
81
|
+
port: number;
|
|
82
|
+
debugHttp: boolean;
|
|
83
|
+
staleClaimTtlMs: number;
|
|
84
|
+
staleClaimSweepIntervalMs: number;
|
|
85
|
+
};
|
|
86
|
+
localbuddy: {
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
port: number;
|
|
89
|
+
statusHeartbeatMs: number;
|
|
90
|
+
llm: PushPalsLlmConfig;
|
|
91
|
+
};
|
|
92
|
+
remotebuddy: {
|
|
93
|
+
pollMs: number;
|
|
94
|
+
statusHeartbeatMs: number;
|
|
95
|
+
workerpalOnlineTtlMs: number;
|
|
96
|
+
waitForWorkerpalMs: number;
|
|
97
|
+
autoSpawnWorkerpals: boolean;
|
|
98
|
+
maxWorkerpals: number;
|
|
99
|
+
workerpalStartupTimeoutMs: number;
|
|
100
|
+
workerpalDocker: boolean;
|
|
101
|
+
workerpalRequireDocker: boolean;
|
|
102
|
+
workerpalImage: string | null;
|
|
103
|
+
workerpalPollMs: number | null;
|
|
104
|
+
workerpalHeartbeatMs: number | null;
|
|
105
|
+
workerpalLabels: string[];
|
|
106
|
+
executionBudgetInteractiveMs: number;
|
|
107
|
+
executionBudgetNormalMs: number;
|
|
108
|
+
executionBudgetBackgroundMs: number;
|
|
109
|
+
finalizationBudgetMs: number;
|
|
110
|
+
crashRestartEnabled: boolean;
|
|
111
|
+
crashRestartMaxRestarts: number;
|
|
112
|
+
crashRestartBackoffMs: number;
|
|
113
|
+
memory: {
|
|
114
|
+
enabled: boolean;
|
|
115
|
+
includeCrossSession: boolean;
|
|
116
|
+
maxRecallItems: number;
|
|
117
|
+
maxRecallChars: number;
|
|
118
|
+
maxSummaryChars: number;
|
|
119
|
+
retentionDays: number;
|
|
120
|
+
};
|
|
121
|
+
autonomy: {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
killSwitchEnabled: boolean;
|
|
124
|
+
tickIntervalMs: number;
|
|
125
|
+
heartbeatLogMs: number;
|
|
126
|
+
visionContextMaxChars: number;
|
|
127
|
+
ideationBudgetMs: number;
|
|
128
|
+
llmTimeoutMs: number;
|
|
129
|
+
allowDirtyWorktree: boolean;
|
|
130
|
+
ideationMaxCandidates: number;
|
|
131
|
+
topK: number;
|
|
132
|
+
exploreRate: number;
|
|
133
|
+
minConfidence: number;
|
|
134
|
+
maxConcurrentObjectives: number;
|
|
135
|
+
maxDispatchPerHour: number;
|
|
136
|
+
maxDispatchPerHourByType: Record<string, number>;
|
|
137
|
+
maxDispatchPerHourByComponent: Record<string, number>;
|
|
138
|
+
maxTokenUsagePerHour: number;
|
|
139
|
+
maxRuntimeMsPerHour: number;
|
|
140
|
+
cooldownFailStreakThreshold: number;
|
|
141
|
+
cooldownMs: number;
|
|
142
|
+
staleObjectiveTtlMs: number;
|
|
143
|
+
staleObjectiveSweepIntervalMs: number;
|
|
144
|
+
autoFreezeFailStreakThreshold: number;
|
|
145
|
+
autoFreezeDurationMs: number;
|
|
146
|
+
evaluatorWindowHours: number;
|
|
147
|
+
evaluatorMinSamples: number;
|
|
148
|
+
evaluatorMinSuccessRate: number;
|
|
149
|
+
evaluatorMaxRegretRate: number;
|
|
150
|
+
evaluatorRunIntervalMs: number;
|
|
151
|
+
alertQueuePendingThreshold: number;
|
|
152
|
+
alertJobFailureRateThreshold: number;
|
|
153
|
+
alertAutonomyFailureRateThreshold: number;
|
|
154
|
+
allowReadAnywhere: boolean;
|
|
155
|
+
prFeedbackCommentRows: number;
|
|
156
|
+
prFeedbackCommentChars: number;
|
|
157
|
+
prFeedbackSummaryChars: number;
|
|
158
|
+
questionTtlMs: number;
|
|
159
|
+
policyVersion: string;
|
|
160
|
+
impactModelVersion: string;
|
|
161
|
+
replay: {
|
|
162
|
+
storePromptPayloads: boolean;
|
|
163
|
+
maxRunsWithPayloads: number;
|
|
164
|
+
maxPayloadBytes: number;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
llm: PushPalsLlmConfig;
|
|
168
|
+
};
|
|
169
|
+
workerpals: {
|
|
170
|
+
pollMs: number;
|
|
171
|
+
heartbeatMs: number;
|
|
172
|
+
executor: string;
|
|
173
|
+
openhandsPython: string;
|
|
174
|
+
openhandsTimeoutMs: number;
|
|
175
|
+
miniswePython: string;
|
|
176
|
+
minisweTimeoutMs: number;
|
|
177
|
+
openaiCodexPython: string;
|
|
178
|
+
openaiCodexTimeoutMs: number;
|
|
179
|
+
openhandsStuckGuardEnabled: boolean;
|
|
180
|
+
openhandsStuckGuardExploreLimit: number;
|
|
181
|
+
openhandsStuckGuardMinElapsedMs: number;
|
|
182
|
+
openhandsStuckGuardBroadScanLimit: number;
|
|
183
|
+
openhandsStuckGuardNoProgressMaxMs: number;
|
|
184
|
+
openhandsAutoSteerEnabled: boolean;
|
|
185
|
+
openhandsAutoSteerInitialDelaySec: number;
|
|
186
|
+
openhandsAutoSteerIntervalSec: number;
|
|
187
|
+
openhandsAutoSteerMaxNudges: number;
|
|
188
|
+
requirePush: boolean;
|
|
189
|
+
pushAgentBranch: boolean;
|
|
190
|
+
requireDocker: boolean;
|
|
191
|
+
skipDockerSelfCheck: boolean;
|
|
192
|
+
dockerImage: string;
|
|
193
|
+
dockerTimeoutMs: number;
|
|
194
|
+
dockerIdleTimeoutMs: number;
|
|
195
|
+
dockerAgentStartupTimeoutMs: number;
|
|
196
|
+
dockerWarmMaxAttempts: number;
|
|
197
|
+
dockerWarmRetryBackoffMs: number;
|
|
198
|
+
dockerJobMaxAttempts: number;
|
|
199
|
+
dockerJobRetryBackoffMs: number;
|
|
200
|
+
dockerNetworkMode: string;
|
|
201
|
+
dockerWarmMemoryMb: number;
|
|
202
|
+
dockerWarmCpus: number;
|
|
203
|
+
fileModifyingJobs: string[];
|
|
204
|
+
outputMaxChars: number;
|
|
205
|
+
outputMaxLines: number;
|
|
206
|
+
outputMaxHeadLines: number;
|
|
207
|
+
qualityMaxAutoRevisions: number;
|
|
208
|
+
qualityValidationStepTimeoutMs: number;
|
|
209
|
+
qualityCriticTimeoutMs: number;
|
|
210
|
+
qualitySoftPassOnExhausted: boolean;
|
|
211
|
+
qualityCriticMinScore: number;
|
|
212
|
+
qualityCriticMaxDiffChars: number;
|
|
213
|
+
qualityCriticMaxValidationOutputChars: number;
|
|
214
|
+
executorResultPrefix: string;
|
|
215
|
+
baseRef: string;
|
|
216
|
+
labels: string[];
|
|
217
|
+
failureCooldownMs: number;
|
|
218
|
+
llm: PushPalsLlmConfig;
|
|
219
|
+
};
|
|
220
|
+
sourceControlManager: {
|
|
221
|
+
repoPath: string;
|
|
222
|
+
remote: string;
|
|
223
|
+
mainBranch: string;
|
|
224
|
+
baseBranch: string;
|
|
225
|
+
branchPrefix: string;
|
|
226
|
+
pollIntervalSeconds: number;
|
|
227
|
+
checks: PushPalsCheckConfig[];
|
|
228
|
+
stateDir: string;
|
|
229
|
+
port: number;
|
|
230
|
+
deleteAfterMerge: boolean;
|
|
231
|
+
maxAttempts: number;
|
|
232
|
+
mergeStrategy: "cherry-pick" | "no-ff" | "ff-only";
|
|
233
|
+
pushMainAfterMerge: boolean;
|
|
234
|
+
openPrAfterPush: boolean;
|
|
235
|
+
prBaseBranch: string;
|
|
236
|
+
prTitle: string | null;
|
|
237
|
+
prBody: string | null;
|
|
238
|
+
prDraft: boolean;
|
|
239
|
+
statusHeartbeatMs: number;
|
|
240
|
+
skipCleanCheck: boolean;
|
|
241
|
+
autoCreateMainBranch: boolean;
|
|
242
|
+
reviewAgent: {
|
|
243
|
+
enabled: boolean;
|
|
244
|
+
pollIntervalMs: number;
|
|
245
|
+
reviewerMdPath: string;
|
|
246
|
+
passThreshold: number;
|
|
247
|
+
maxPrCommentsBeforeGiveUp: number;
|
|
248
|
+
mergeMethod: "squash" | "merge" | "rebase";
|
|
249
|
+
codexBin: string;
|
|
250
|
+
codexAuthMode: string;
|
|
251
|
+
codexHomeDir: string;
|
|
252
|
+
codexTimeoutMs: number;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
startup: {
|
|
256
|
+
workerImageRebuild: "auto" | "always" | "never";
|
|
257
|
+
logConfigOnStart: boolean;
|
|
258
|
+
syncIntegrationWithMain: boolean;
|
|
259
|
+
skipLlmPreflight: boolean;
|
|
260
|
+
autoStartLmStudio: boolean;
|
|
261
|
+
lmStudioReadyTimeoutMs: number;
|
|
262
|
+
lmStudioCli: string;
|
|
263
|
+
lmStudioPort: number;
|
|
264
|
+
lmStudioStartArgs: string;
|
|
265
|
+
startupWarmup: boolean;
|
|
266
|
+
startupWarmupTimeoutMs: number;
|
|
267
|
+
startupWarmupPollMs: number;
|
|
268
|
+
allowExternalClean: boolean;
|
|
269
|
+
portPreflight: boolean;
|
|
270
|
+
portConflictPolicy: "fail" | "terminate_pushpals";
|
|
271
|
+
};
|
|
272
|
+
client: {
|
|
273
|
+
localAgentUrl: string;
|
|
274
|
+
traceTailLines: number;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface LoadOptions {
|
|
279
|
+
projectRoot?: string;
|
|
280
|
+
configDir?: string;
|
|
281
|
+
reload?: boolean;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
let cachedConfig: PushPalsConfig | null = null;
|
|
285
|
+
let cachedConfigKey = "";
|
|
286
|
+
|
|
287
|
+
export function invalidatePushPalsConfigCache(): void {
|
|
288
|
+
cachedConfig = null;
|
|
289
|
+
cachedConfigKey = "";
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function firstNonEmpty(...values: Array<string | null | undefined>): string {
|
|
293
|
+
for (const value of values) {
|
|
294
|
+
const trimmed = (value ?? "").trim();
|
|
295
|
+
if (trimmed) return trimmed;
|
|
296
|
+
}
|
|
297
|
+
return "";
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function parseBoolEnv(name: string): boolean | null {
|
|
301
|
+
const raw = (process.env[name] ?? "").trim().toLowerCase();
|
|
302
|
+
if (!raw) return null;
|
|
303
|
+
if (TRUTHY.has(raw)) return true;
|
|
304
|
+
if (FALSY.has(raw)) return false;
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function parseIntEnv(name: string): number | null {
|
|
309
|
+
const raw = (process.env[name] ?? "").trim();
|
|
310
|
+
if (!raw) return null;
|
|
311
|
+
const parsed = Number.parseInt(raw, 10);
|
|
312
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function parseTomlFile(path: string): TomlObject {
|
|
316
|
+
if (!existsSync(path)) return {};
|
|
317
|
+
const raw = readFileSync(path, "utf-8");
|
|
318
|
+
const parsed = Bun.TOML.parse(raw) as unknown;
|
|
319
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
320
|
+
return parsed as TomlObject;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function parseRequiredTomlFile(path: string): TomlObject {
|
|
324
|
+
if (!existsSync(path)) {
|
|
325
|
+
throw new Error(`Missing required runtime config file: ${path}`);
|
|
326
|
+
}
|
|
327
|
+
return parseTomlFile(path);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function isObject(value: unknown): value is TomlObject {
|
|
331
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function mergeDeep(base: TomlObject, override: TomlObject): TomlObject {
|
|
335
|
+
const out: TomlObject = { ...base };
|
|
336
|
+
for (const [key, value] of Object.entries(override)) {
|
|
337
|
+
const existing = out[key];
|
|
338
|
+
if (isObject(existing) && isObject(value)) {
|
|
339
|
+
out[key] = mergeDeep(existing, value);
|
|
340
|
+
} else {
|
|
341
|
+
out[key] = value;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function getObject(parent: TomlObject, key: string): TomlObject {
|
|
348
|
+
const value = parent[key];
|
|
349
|
+
if (isObject(value)) return value;
|
|
350
|
+
return {};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function asString(value: unknown, fallback: string): string {
|
|
354
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
355
|
+
return fallback;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function asBoolean(value: unknown, fallback: boolean): boolean {
|
|
359
|
+
if (typeof value === "boolean") return value;
|
|
360
|
+
if (typeof value === "string") {
|
|
361
|
+
const lowered = value.trim().toLowerCase();
|
|
362
|
+
if (TRUTHY.has(lowered)) return true;
|
|
363
|
+
if (FALSY.has(lowered)) return false;
|
|
364
|
+
}
|
|
365
|
+
return fallback;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function asInt(value: unknown, fallback: number): number {
|
|
369
|
+
if (typeof value === "number" && Number.isFinite(value)) return Math.floor(value);
|
|
370
|
+
if (typeof value === "string") {
|
|
371
|
+
const parsed = Number.parseInt(value.trim(), 10);
|
|
372
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
373
|
+
}
|
|
374
|
+
return fallback;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function asIntOrNull(value: unknown): number | null {
|
|
378
|
+
if (typeof value === "number" && Number.isFinite(value)) return Math.floor(value);
|
|
379
|
+
if (typeof value === "string" && value.trim()) {
|
|
380
|
+
const parsed = Number.parseInt(value.trim(), 10);
|
|
381
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
382
|
+
}
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function asStringArray(value: unknown): string[] {
|
|
387
|
+
if (!Array.isArray(value)) return [];
|
|
388
|
+
return value.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter(Boolean);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function asCheckArray(value: unknown): PushPalsCheckConfig[] {
|
|
392
|
+
if (!Array.isArray(value)) return [];
|
|
393
|
+
const checks: PushPalsCheckConfig[] = [];
|
|
394
|
+
for (const entry of value) {
|
|
395
|
+
if (!isObject(entry)) continue;
|
|
396
|
+
const name = asString(entry.name, "").trim();
|
|
397
|
+
const command = asString(entry.command, "").trim();
|
|
398
|
+
if (!name || !command) continue;
|
|
399
|
+
const timeoutMs = Math.max(1_000, asInt(entry.timeout_ms ?? entry.timeoutMs, 300_000));
|
|
400
|
+
checks.push({ name, command, timeoutMs });
|
|
401
|
+
}
|
|
402
|
+
return checks;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function asStringNumberRecord(value: unknown): Record<string, number> {
|
|
406
|
+
if (!isObject(value)) return {};
|
|
407
|
+
const out: Record<string, number> = {};
|
|
408
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
409
|
+
const name = key.trim();
|
|
410
|
+
if (!name) continue;
|
|
411
|
+
const num =
|
|
412
|
+
typeof raw === "number"
|
|
413
|
+
? raw
|
|
414
|
+
: typeof raw === "string"
|
|
415
|
+
? Number.parseInt(raw.trim(), 10)
|
|
416
|
+
: Number.NaN;
|
|
417
|
+
if (!Number.isFinite(num)) continue;
|
|
418
|
+
out[name] = Math.max(0, Math.floor(num));
|
|
419
|
+
}
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function resolvePathFromRoot(projectRoot: string, value: string): string {
|
|
424
|
+
if (!value) return projectRoot;
|
|
425
|
+
if (isAbsolute(value)) return resolve(value);
|
|
426
|
+
return resolve(projectRoot, value);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function resolveRuntimeConfigDir(projectRoot: string, configuredDir?: string): string {
|
|
430
|
+
if (configuredDir && configuredDir.trim()) {
|
|
431
|
+
return resolvePathFromRoot(projectRoot, configuredDir);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return resolvePathFromRoot(projectRoot, DEFAULT_CONFIG_DIR);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function normalizeBackend(value: string): string {
|
|
438
|
+
const text = value.trim().toLowerCase();
|
|
439
|
+
if (!text) return "lmstudio";
|
|
440
|
+
if (text === "openai_compatible") return "lmstudio";
|
|
441
|
+
if (text === "ollama_chat") return "ollama";
|
|
442
|
+
return text;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function normalizeWorkerImageRebuildMode(value: string): "auto" | "always" | "never" {
|
|
446
|
+
const text = value.trim().toLowerCase();
|
|
447
|
+
if (text === "always" || text === "1" || text === "true" || text === "yes" || text === "on") {
|
|
448
|
+
return "always";
|
|
449
|
+
}
|
|
450
|
+
if (text === "never" || text === "0" || text === "false" || text === "no" || text === "off") {
|
|
451
|
+
return "never";
|
|
452
|
+
}
|
|
453
|
+
return "auto";
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function normalizeStartupPortConflictPolicy(value: string): "fail" | "terminate_pushpals" {
|
|
457
|
+
const text = value.trim().toLowerCase().replace(/-/g, "_");
|
|
458
|
+
if (
|
|
459
|
+
text === "terminate_pushpals" ||
|
|
460
|
+
text === "kill_pushpals" ||
|
|
461
|
+
text === "auto_kill_pushpals"
|
|
462
|
+
) {
|
|
463
|
+
return "terminate_pushpals";
|
|
464
|
+
}
|
|
465
|
+
return "fail";
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function defaultApiKeyForBackend(backend: string, endpoint: string): string {
|
|
469
|
+
const normalizedBackend = backend.trim().toLowerCase();
|
|
470
|
+
const normalizedEndpoint = endpoint.trim().toLowerCase();
|
|
471
|
+
const openAiKey = (process.env.OPENAI_API_KEY ?? "").trim();
|
|
472
|
+
|
|
473
|
+
if (normalizedBackend === "openai") {
|
|
474
|
+
return openAiKey;
|
|
475
|
+
}
|
|
476
|
+
if (normalizedBackend === "lmstudio") {
|
|
477
|
+
return "lmstudio";
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Safety: if backend is omitted/legacy but endpoint points to OpenAI,
|
|
481
|
+
// still allow OPENAI_API_KEY as fallback.
|
|
482
|
+
if (normalizedEndpoint.includes("api.openai.com")) {
|
|
483
|
+
return openAiKey;
|
|
484
|
+
}
|
|
485
|
+
return "";
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function resolveLlmConfig(
|
|
489
|
+
serviceNode: TomlObject,
|
|
490
|
+
envPrefix: "LOCALBUDDY" | "REMOTEBUDDY" | "WORKERPALS",
|
|
491
|
+
defaults: { backend: string; endpoint: string; model: string; sessionId: string },
|
|
492
|
+
globalSessionId: string,
|
|
493
|
+
): PushPalsLlmConfig {
|
|
494
|
+
const llmNode = getObject(serviceNode, "llm");
|
|
495
|
+
const backend = normalizeBackend(
|
|
496
|
+
firstNonEmpty(
|
|
497
|
+
process.env[`${envPrefix}_LLM_BACKEND`],
|
|
498
|
+
asString(llmNode.backend, defaults.backend),
|
|
499
|
+
defaults.backend,
|
|
500
|
+
),
|
|
501
|
+
);
|
|
502
|
+
const endpoint = firstNonEmpty(
|
|
503
|
+
process.env[`${envPrefix}_LLM_ENDPOINT`],
|
|
504
|
+
asString(llmNode.endpoint, defaults.endpoint),
|
|
505
|
+
defaults.endpoint,
|
|
506
|
+
);
|
|
507
|
+
const model = firstNonEmpty(
|
|
508
|
+
process.env[`${envPrefix}_LLM_MODEL`],
|
|
509
|
+
asString(llmNode.model, defaults.model),
|
|
510
|
+
defaults.model,
|
|
511
|
+
);
|
|
512
|
+
const sessionId = firstNonEmpty(
|
|
513
|
+
process.env[`${envPrefix}_LLM_SESSION_ID`],
|
|
514
|
+
asString(llmNode.session_id, defaults.sessionId),
|
|
515
|
+
process.env.PUSHPALS_LLM_SESSION_ID,
|
|
516
|
+
globalSessionId,
|
|
517
|
+
);
|
|
518
|
+
const apiKey = firstNonEmpty(
|
|
519
|
+
process.env[`${envPrefix}_LLM_API_KEY`],
|
|
520
|
+
defaultApiKeyForBackend(backend, endpoint),
|
|
521
|
+
);
|
|
522
|
+
const reasoningEffort = firstNonEmpty(
|
|
523
|
+
process.env[`${envPrefix}_LLM_REASONING_EFFORT`],
|
|
524
|
+
asString(llmNode.reasoning_effort, ""),
|
|
525
|
+
);
|
|
526
|
+
const codexAuthMode = firstNonEmpty(
|
|
527
|
+
process.env[`${envPrefix}_LLM_CODEX_AUTH_MODE`],
|
|
528
|
+
asString(llmNode.codex_auth_mode, ""),
|
|
529
|
+
);
|
|
530
|
+
const codexBin = firstNonEmpty(
|
|
531
|
+
process.env[`${envPrefix}_LLM_CODEX_BIN`],
|
|
532
|
+
asString(llmNode.codex_bin, ""),
|
|
533
|
+
);
|
|
534
|
+
const codexTimeoutMs = Math.max(
|
|
535
|
+
10_000,
|
|
536
|
+
asInt(
|
|
537
|
+
parseIntEnv(`${envPrefix}_LLM_CODEX_TIMEOUT_MS`) ?? llmNode.codex_timeout_ms,
|
|
538
|
+
120_000,
|
|
539
|
+
),
|
|
540
|
+
);
|
|
541
|
+
return {
|
|
542
|
+
backend,
|
|
543
|
+
endpoint,
|
|
544
|
+
model,
|
|
545
|
+
sessionId,
|
|
546
|
+
apiKey,
|
|
547
|
+
reasoningEffort,
|
|
548
|
+
codexAuthMode,
|
|
549
|
+
codexBin,
|
|
550
|
+
codexTimeoutMs,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export function loadPushPalsConfig(options: LoadOptions = {}): PushPalsConfig {
|
|
555
|
+
const projectRootOverride = firstNonEmpty(
|
|
556
|
+
options.projectRoot,
|
|
557
|
+
process.env.PUSHPALS_PROJECT_ROOT_OVERRIDE,
|
|
558
|
+
PROJECT_ROOT,
|
|
559
|
+
);
|
|
560
|
+
const projectRoot = resolve(projectRootOverride);
|
|
561
|
+
const configDirOverride = firstNonEmpty(
|
|
562
|
+
options.configDir,
|
|
563
|
+
process.env.PUSHPALS_CONFIG_DIR_OVERRIDE,
|
|
564
|
+
"",
|
|
565
|
+
);
|
|
566
|
+
const configDir = resolveRuntimeConfigDir(projectRoot, configDirOverride);
|
|
567
|
+
const cacheKey = `${projectRoot}::${configDir}::${process.env.PUSHPALS_PROFILE ?? ""}`;
|
|
568
|
+
if (!options.reload && cachedConfig && cachedConfigKey === cacheKey) {
|
|
569
|
+
return cachedConfig;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const defaultToml = parseRequiredTomlFile(join(configDir, "default.toml"));
|
|
573
|
+
const preferredProfile = firstNonEmpty(
|
|
574
|
+
process.env.PUSHPALS_PROFILE,
|
|
575
|
+
asString(defaultToml.profile, "dev"),
|
|
576
|
+
"dev",
|
|
577
|
+
);
|
|
578
|
+
const profileToml = parseTomlFile(join(configDir, `${preferredProfile}.toml`));
|
|
579
|
+
const localExampleToml = parseTomlFile(join(configDir, "local.example.toml"));
|
|
580
|
+
const localToml = parseTomlFile(join(configDir, "local.toml"));
|
|
581
|
+
const merged = mergeDeep(
|
|
582
|
+
mergeDeep(mergeDeep(defaultToml, profileToml), localExampleToml),
|
|
583
|
+
localToml,
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
const profile = firstNonEmpty(
|
|
587
|
+
process.env.PUSHPALS_PROFILE,
|
|
588
|
+
asString(merged.profile, preferredProfile),
|
|
589
|
+
preferredProfile,
|
|
590
|
+
);
|
|
591
|
+
const sessionId = firstNonEmpty(
|
|
592
|
+
process.env.PUSHPALS_SESSION_ID,
|
|
593
|
+
asString(merged.session_id, "dev"),
|
|
594
|
+
"dev",
|
|
595
|
+
);
|
|
596
|
+
|
|
597
|
+
const llmNode = getObject(merged, "llm");
|
|
598
|
+
const lmStudioNode = getObject(llmNode, "lmstudio");
|
|
599
|
+
const lmStudioContextWindow = Math.max(
|
|
600
|
+
512,
|
|
601
|
+
asInt(parseIntEnv("PUSHPALS_LMSTUDIO_CONTEXT_WINDOW") ?? lmStudioNode.context_window, 4096),
|
|
602
|
+
);
|
|
603
|
+
const lmStudioMinOutputTokens = Math.max(
|
|
604
|
+
64,
|
|
605
|
+
asInt(
|
|
606
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_MIN_OUTPUT_TOKENS") ?? lmStudioNode.min_output_tokens,
|
|
607
|
+
256,
|
|
608
|
+
),
|
|
609
|
+
);
|
|
610
|
+
const lmStudioTokenSafetyMargin = Math.max(
|
|
611
|
+
16,
|
|
612
|
+
asInt(
|
|
613
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_TOKEN_SAFETY_MARGIN") ?? lmStudioNode.token_safety_margin,
|
|
614
|
+
64,
|
|
615
|
+
),
|
|
616
|
+
);
|
|
617
|
+
const lmStudioBatchTailMessages = Math.max(
|
|
618
|
+
1,
|
|
619
|
+
asInt(
|
|
620
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_BATCH_TAIL_MESSAGES") ?? lmStudioNode.batch_tail_messages,
|
|
621
|
+
3,
|
|
622
|
+
),
|
|
623
|
+
);
|
|
624
|
+
const lmStudioBatchChunkTokens = Math.max(
|
|
625
|
+
0,
|
|
626
|
+
asInt(
|
|
627
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_BATCH_CHUNK_TOKENS") ?? lmStudioNode.batch_chunk_tokens,
|
|
628
|
+
0,
|
|
629
|
+
),
|
|
630
|
+
);
|
|
631
|
+
const lmStudioBatchMemoryChars = Math.max(
|
|
632
|
+
0,
|
|
633
|
+
asInt(
|
|
634
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_BATCH_MEMORY_CHARS") ?? lmStudioNode.batch_memory_chars,
|
|
635
|
+
0,
|
|
636
|
+
),
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
const pathsNode = getObject(merged, "paths");
|
|
640
|
+
const dataDir = resolvePathFromRoot(
|
|
641
|
+
projectRoot,
|
|
642
|
+
firstNonEmpty(process.env.PUSHPALS_DATA_DIR, asString(pathsNode.data_dir, "outputs/data")),
|
|
643
|
+
);
|
|
644
|
+
const sharedDbPath = resolvePathFromRoot(
|
|
645
|
+
projectRoot,
|
|
646
|
+
firstNonEmpty(
|
|
647
|
+
process.env.PUSHPALS_DB_PATH,
|
|
648
|
+
asString(pathsNode.shared_db_path, join(dataDir, "pushpals.db")),
|
|
649
|
+
),
|
|
650
|
+
);
|
|
651
|
+
const remotebuddyDbPath = resolvePathFromRoot(
|
|
652
|
+
projectRoot,
|
|
653
|
+
firstNonEmpty(
|
|
654
|
+
process.env.REMOTEBUDDY_DB_PATH,
|
|
655
|
+
asString(pathsNode.remotebuddy_db_path, join(dataDir, "remotebuddy-state.db")),
|
|
656
|
+
),
|
|
657
|
+
);
|
|
658
|
+
|
|
659
|
+
const serverNode = getObject(merged, "server");
|
|
660
|
+
const serverPort = Math.max(1, asInt(parseIntEnv("PUSHPALS_PORT") ?? serverNode.port, 3001));
|
|
661
|
+
const serverUrl = normalizeLoopbackHttpUrl(
|
|
662
|
+
firstNonEmpty(
|
|
663
|
+
process.env.PUSHPALS_SERVER_URL,
|
|
664
|
+
asString(serverNode.url, `http://127.0.0.1:${serverPort}`),
|
|
665
|
+
`http://127.0.0.1:${serverPort}`,
|
|
666
|
+
),
|
|
667
|
+
serverPort,
|
|
668
|
+
);
|
|
669
|
+
const serverHost = normalizeLoopbackHost(
|
|
670
|
+
firstNonEmpty(process.env.PUSHPALS_HOST, asString(serverNode.host, "127.0.0.1")),
|
|
671
|
+
);
|
|
672
|
+
const debugHttp = parseBoolEnv("PUSHPALS_DEBUG_HTTP") ?? asBoolean(serverNode.debug_http, false);
|
|
673
|
+
const staleClaimTtlMs = Math.max(
|
|
674
|
+
5_000,
|
|
675
|
+
asInt(parseIntEnv("PUSHPALS_STALE_CLAIM_TTL_MS") ?? serverNode.stale_claim_ttl_ms, 120_000),
|
|
676
|
+
);
|
|
677
|
+
const staleClaimSweepIntervalMs = Math.max(
|
|
678
|
+
1_000,
|
|
679
|
+
asInt(
|
|
680
|
+
parseIntEnv("PUSHPALS_STALE_CLAIM_SWEEP_INTERVAL_MS") ??
|
|
681
|
+
serverNode.stale_claim_sweep_interval_ms,
|
|
682
|
+
5_000,
|
|
683
|
+
),
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
const globalStatusHeartbeatMs = parseIntEnv("PUSHPALS_STATUS_HEARTBEAT_MS");
|
|
687
|
+
|
|
688
|
+
const localNode = getObject(merged, "localbuddy");
|
|
689
|
+
const localEnabled = parseBoolEnv("LOCALBUDDY_ENABLED") ?? asBoolean(localNode.enabled, false);
|
|
690
|
+
const localPort = Math.max(1, asInt(parseIntEnv("LOCAL_AGENT_PORT") ?? localNode.port, 3003));
|
|
691
|
+
const localStatusHeartbeatMs = Math.max(
|
|
692
|
+
0,
|
|
693
|
+
asInt(
|
|
694
|
+
parseIntEnv("LOCALBUDDY_STATUS_HEARTBEAT_MS") ??
|
|
695
|
+
globalStatusHeartbeatMs ??
|
|
696
|
+
localNode.status_heartbeat_ms,
|
|
697
|
+
120_000,
|
|
698
|
+
),
|
|
699
|
+
);
|
|
700
|
+
const localLlm = resolveLlmConfig(
|
|
701
|
+
localNode,
|
|
702
|
+
"LOCALBUDDY",
|
|
703
|
+
{
|
|
704
|
+
backend: "lmstudio",
|
|
705
|
+
endpoint: "http://127.0.0.1:1234",
|
|
706
|
+
model: "local-model",
|
|
707
|
+
sessionId: "localbuddy-dev",
|
|
708
|
+
},
|
|
709
|
+
sessionId,
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
const remoteNode = getObject(merged, "remotebuddy");
|
|
713
|
+
const remoteStatusHeartbeatMs = Math.max(
|
|
714
|
+
0,
|
|
715
|
+
asInt(
|
|
716
|
+
parseIntEnv("REMOTEBUDDY_STATUS_HEARTBEAT_MS") ??
|
|
717
|
+
globalStatusHeartbeatMs ??
|
|
718
|
+
remoteNode.status_heartbeat_ms,
|
|
719
|
+
120_000,
|
|
720
|
+
),
|
|
721
|
+
);
|
|
722
|
+
const remotePollMs = Math.max(
|
|
723
|
+
200,
|
|
724
|
+
asInt(parseIntEnv("REMOTEBUDDY_POLL_MS") ?? remoteNode.poll_ms, 2_000),
|
|
725
|
+
);
|
|
726
|
+
const remoteLlm = resolveLlmConfig(
|
|
727
|
+
remoteNode,
|
|
728
|
+
"REMOTEBUDDY",
|
|
729
|
+
{
|
|
730
|
+
backend: "lmstudio",
|
|
731
|
+
endpoint: "http://127.0.0.1:1234",
|
|
732
|
+
model: "local-model",
|
|
733
|
+
sessionId: "remotebuddy-dev",
|
|
734
|
+
},
|
|
735
|
+
sessionId,
|
|
736
|
+
);
|
|
737
|
+
const remoteMemoryNode = getObject(remoteNode, "memory");
|
|
738
|
+
const remoteMemoryEnabled =
|
|
739
|
+
parseBoolEnv("REMOTEBUDDY_MEMORY_ENABLED") ?? asBoolean(remoteMemoryNode.enabled, true);
|
|
740
|
+
const remoteMemoryIncludeCrossSession =
|
|
741
|
+
parseBoolEnv("REMOTEBUDDY_MEMORY_INCLUDE_CROSS_SESSION") ??
|
|
742
|
+
asBoolean(remoteMemoryNode.include_cross_session, true);
|
|
743
|
+
const remoteMemoryMaxRecallItems = Math.max(
|
|
744
|
+
1,
|
|
745
|
+
Math.min(
|
|
746
|
+
128,
|
|
747
|
+
asInt(
|
|
748
|
+
parseIntEnv("REMOTEBUDDY_MEMORY_MAX_RECALL_ITEMS") ?? remoteMemoryNode.max_recall_items,
|
|
749
|
+
DEFAULT_REMOTEBUDDY_MEMORY_MAX_RECALL_ITEMS,
|
|
750
|
+
),
|
|
751
|
+
),
|
|
752
|
+
);
|
|
753
|
+
const remoteMemoryMaxRecallChars = Math.max(
|
|
754
|
+
120,
|
|
755
|
+
Math.min(
|
|
756
|
+
64_000,
|
|
757
|
+
asInt(
|
|
758
|
+
parseIntEnv("REMOTEBUDDY_MEMORY_MAX_RECALL_CHARS") ?? remoteMemoryNode.max_recall_chars,
|
|
759
|
+
DEFAULT_REMOTEBUDDY_MEMORY_MAX_RECALL_CHARS,
|
|
760
|
+
),
|
|
761
|
+
),
|
|
762
|
+
);
|
|
763
|
+
const remoteMemoryMaxSummaryChars = Math.max(
|
|
764
|
+
64,
|
|
765
|
+
Math.min(
|
|
766
|
+
16_000,
|
|
767
|
+
asInt(
|
|
768
|
+
parseIntEnv("REMOTEBUDDY_MEMORY_MAX_SUMMARY_CHARS") ?? remoteMemoryNode.max_summary_chars,
|
|
769
|
+
DEFAULT_REMOTEBUDDY_MEMORY_MAX_SUMMARY_CHARS,
|
|
770
|
+
),
|
|
771
|
+
),
|
|
772
|
+
);
|
|
773
|
+
const remoteMemoryRetentionDays = Math.max(
|
|
774
|
+
1,
|
|
775
|
+
Math.min(
|
|
776
|
+
3650,
|
|
777
|
+
asInt(
|
|
778
|
+
parseIntEnv("REMOTEBUDDY_MEMORY_RETENTION_DAYS") ?? remoteMemoryNode.retention_days,
|
|
779
|
+
DEFAULT_REMOTEBUDDY_MEMORY_RETENTION_DAYS,
|
|
780
|
+
),
|
|
781
|
+
),
|
|
782
|
+
);
|
|
783
|
+
const remoteAutonomyNode = getObject(remoteNode, "autonomy");
|
|
784
|
+
const remoteAutonomyReplayNode = getObject(remoteAutonomyNode, "replay");
|
|
785
|
+
const remoteAutonomyDispatchByTypeCfg = {
|
|
786
|
+
flaky_test: 4,
|
|
787
|
+
lint_fix: 3,
|
|
788
|
+
type_fix: 3,
|
|
789
|
+
small_refactor: 2,
|
|
790
|
+
feature_small: 2,
|
|
791
|
+
feature_medium: 1,
|
|
792
|
+
feature_large: 0,
|
|
793
|
+
docs: 1,
|
|
794
|
+
dep_bump: 0,
|
|
795
|
+
};
|
|
796
|
+
const remoteAutonomyDispatchByType = {
|
|
797
|
+
...remoteAutonomyDispatchByTypeCfg,
|
|
798
|
+
...asStringNumberRecord(remoteAutonomyNode.max_dispatch_per_hour_by_type),
|
|
799
|
+
};
|
|
800
|
+
const remoteAutonomyDispatchByComponentCfg = {
|
|
801
|
+
"apps/server": 3,
|
|
802
|
+
"apps/remotebuddy": 2,
|
|
803
|
+
"apps/workerpals": 2,
|
|
804
|
+
"apps/client": 2,
|
|
805
|
+
"packages/protocol": 1,
|
|
806
|
+
"packages/shared": 2,
|
|
807
|
+
"tests/integration": 2,
|
|
808
|
+
"tests/unit": 2,
|
|
809
|
+
};
|
|
810
|
+
const remoteAutonomyDispatchByComponentRaw = asStringNumberRecord(
|
|
811
|
+
remoteAutonomyNode.max_dispatch_per_hour_by_component,
|
|
812
|
+
);
|
|
813
|
+
const legacyAutonomyComponentAliasMap = new Map<string, string>(
|
|
814
|
+
Object.keys(remoteAutonomyDispatchByComponentCfg).flatMap((key) => {
|
|
815
|
+
const direct = normalizeAutonomyComponentArea(key);
|
|
816
|
+
const legacyUnderscore = normalizeAutonomyComponentArea(key.replace(/\//g, "_"));
|
|
817
|
+
const legacyHyphen = normalizeAutonomyComponentArea(key.replace(/\//g, "-"));
|
|
818
|
+
return [direct, legacyUnderscore, legacyHyphen]
|
|
819
|
+
.filter((value): value is string => Boolean(value))
|
|
820
|
+
.map((value) => [value, key] as const);
|
|
821
|
+
}),
|
|
822
|
+
);
|
|
823
|
+
const coerceAutonomyComponentConfigKey = (value: string): string | null => {
|
|
824
|
+
const direct = normalizeAutonomyComponentArea(value);
|
|
825
|
+
const legacyAliasCandidate = normalizeAutonomyComponentArea(
|
|
826
|
+
value
|
|
827
|
+
.trim()
|
|
828
|
+
.toLowerCase()
|
|
829
|
+
.replace(/\\/g, "/")
|
|
830
|
+
.replace(/_+/g, "/")
|
|
831
|
+
.replace(/-+/g, "/")
|
|
832
|
+
.replace(/\/+/g, "/"),
|
|
833
|
+
);
|
|
834
|
+
if (legacyAliasCandidate && legacyAutonomyComponentAliasMap.has(legacyAliasCandidate)) {
|
|
835
|
+
return legacyAutonomyComponentAliasMap.get(legacyAliasCandidate) ?? legacyAliasCandidate;
|
|
836
|
+
}
|
|
837
|
+
return direct;
|
|
838
|
+
};
|
|
839
|
+
const remoteAutonomyDispatchByComponent = Object.fromEntries(
|
|
840
|
+
Object.entries(remoteAutonomyDispatchByComponentCfg).map(([key, value]) => [
|
|
841
|
+
coerceAutonomyComponentConfigKey(key) ?? key,
|
|
842
|
+
value,
|
|
843
|
+
]),
|
|
844
|
+
) as Record<string, number>;
|
|
845
|
+
for (const [rawKey, rawValue] of Object.entries(remoteAutonomyDispatchByComponentRaw)) {
|
|
846
|
+
const canonical = coerceAutonomyComponentConfigKey(rawKey);
|
|
847
|
+
if (!canonical) continue;
|
|
848
|
+
const parsed =
|
|
849
|
+
typeof rawValue === "number"
|
|
850
|
+
? rawValue
|
|
851
|
+
: typeof rawValue === "string"
|
|
852
|
+
? Number.parseInt(rawValue.trim(), 10)
|
|
853
|
+
: Number.NaN;
|
|
854
|
+
remoteAutonomyDispatchByComponent[canonical] = Number.isFinite(parsed)
|
|
855
|
+
? Math.max(0, Math.floor(parsed))
|
|
856
|
+
: 0;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const workerNode = getObject(merged, "workerpals");
|
|
860
|
+
const workerOpenHandsNode = getObject(workerNode, "openhands");
|
|
861
|
+
const workerPollMs = Math.max(
|
|
862
|
+
200,
|
|
863
|
+
asInt(parseIntEnv("WORKERPALS_POLL_MS") ?? workerNode.poll_ms, 2_000),
|
|
864
|
+
);
|
|
865
|
+
const workerHeartbeatMs = Math.max(
|
|
866
|
+
200,
|
|
867
|
+
asInt(parseIntEnv("WORKERPALS_HEARTBEAT_MS") ?? workerNode.heartbeat_ms, 5_000),
|
|
868
|
+
);
|
|
869
|
+
const workerExecutor = firstNonEmpty(
|
|
870
|
+
process.env.WORKERPALS_EXECUTOR,
|
|
871
|
+
asString(workerNode.executor, DEFAULT_WORKERPALS_EXECUTOR),
|
|
872
|
+
DEFAULT_WORKERPALS_EXECUTOR,
|
|
873
|
+
).toLowerCase();
|
|
874
|
+
const workerOpenHandsPython = firstNonEmpty(
|
|
875
|
+
process.env.WORKERPALS_OPENHANDS_PYTHON,
|
|
876
|
+
asString(workerNode.openhands_python, "python"),
|
|
877
|
+
"python",
|
|
878
|
+
);
|
|
879
|
+
const workerOpenHandsTimeoutMs = Math.max(
|
|
880
|
+
10_000,
|
|
881
|
+
asInt(
|
|
882
|
+
parseIntEnv("WORKERPALS_OPENHANDS_TIMEOUT_MS") ?? workerNode.openhands_timeout_ms,
|
|
883
|
+
1_800_000,
|
|
884
|
+
),
|
|
885
|
+
);
|
|
886
|
+
const workerMiniswePython = firstNonEmpty(
|
|
887
|
+
process.env.WORKERPALS_MINISWE_PYTHON,
|
|
888
|
+
asString(workerNode.miniswe_python, "python"),
|
|
889
|
+
"python",
|
|
890
|
+
);
|
|
891
|
+
const workerMinisweTimeoutMs = Math.max(
|
|
892
|
+
10_000,
|
|
893
|
+
asInt(parseIntEnv("WORKERPALS_MINISWE_TIMEOUT_MS") ?? workerNode.miniswe_timeout_ms, 1_800_000),
|
|
894
|
+
);
|
|
895
|
+
const workerOpenAICodexPython = firstNonEmpty(
|
|
896
|
+
process.env.PUSHPALS_OPENAI_CODEX_PYTHON,
|
|
897
|
+
asString(workerNode.openai_codex_python, "python"),
|
|
898
|
+
"python",
|
|
899
|
+
);
|
|
900
|
+
const workerOpenAICodexTimeoutMs = Math.max(
|
|
901
|
+
10_000,
|
|
902
|
+
asInt(workerNode.openai_codex_timeout_ms, 7_200_000),
|
|
903
|
+
);
|
|
904
|
+
const workerQualityMaxAutoRevisions = Math.max(
|
|
905
|
+
0,
|
|
906
|
+
Math.min(
|
|
907
|
+
10,
|
|
908
|
+
asInt(
|
|
909
|
+
parseIntEnv("WORKERPALS_QUALITY_MAX_AUTO_REVISIONS") ?? workerNode.quality_max_auto_revisions,
|
|
910
|
+
DEFAULT_WORKERPALS_QUALITY_MAX_AUTO_REVISIONS,
|
|
911
|
+
),
|
|
912
|
+
),
|
|
913
|
+
);
|
|
914
|
+
const workerFileModifyingJobs = (() => {
|
|
915
|
+
const envRaw = firstNonEmpty(process.env.WORKERPALS_FILE_MODIFYING_JOBS);
|
|
916
|
+
const parsed = envRaw
|
|
917
|
+
? envRaw
|
|
918
|
+
.split(",")
|
|
919
|
+
.map((entry) => entry.trim())
|
|
920
|
+
.filter(Boolean)
|
|
921
|
+
: asStringArray(workerNode.file_modifying_jobs);
|
|
922
|
+
const out = parsed.length > 0 ? parsed : DEFAULT_WORKERPALS_FILE_MODIFYING_JOBS;
|
|
923
|
+
return [...new Set(out)];
|
|
924
|
+
})();
|
|
925
|
+
const workerOutputMaxChars = Math.max(
|
|
926
|
+
8_192,
|
|
927
|
+
Math.min(
|
|
928
|
+
4_194_304,
|
|
929
|
+
asInt(
|
|
930
|
+
parseIntEnv("WORKERPALS_OUTPUT_MAX_CHARS") ?? workerNode.output_max_chars,
|
|
931
|
+
DEFAULT_WORKERPALS_OUTPUT_MAX_CHARS,
|
|
932
|
+
),
|
|
933
|
+
),
|
|
934
|
+
);
|
|
935
|
+
const workerOutputMaxLines = Math.max(
|
|
936
|
+
50,
|
|
937
|
+
Math.min(
|
|
938
|
+
20_000,
|
|
939
|
+
asInt(
|
|
940
|
+
parseIntEnv("WORKERPALS_OUTPUT_MAX_LINES") ?? workerNode.output_max_lines,
|
|
941
|
+
DEFAULT_WORKERPALS_OUTPUT_MAX_LINES,
|
|
942
|
+
),
|
|
943
|
+
),
|
|
944
|
+
);
|
|
945
|
+
const workerOutputMaxHeadLines = Math.max(
|
|
946
|
+
1,
|
|
947
|
+
Math.min(
|
|
948
|
+
workerOutputMaxLines,
|
|
949
|
+
asInt(
|
|
950
|
+
parseIntEnv("WORKERPALS_OUTPUT_MAX_HEAD_LINES") ?? workerNode.output_max_head_lines,
|
|
951
|
+
DEFAULT_WORKERPALS_OUTPUT_MAX_HEAD_LINES,
|
|
952
|
+
),
|
|
953
|
+
),
|
|
954
|
+
);
|
|
955
|
+
const workerQualityValidationStepTimeoutMs = Math.max(
|
|
956
|
+
1_000,
|
|
957
|
+
asInt(
|
|
958
|
+
parseIntEnv("WORKERPALS_QUALITY_VALIDATION_STEP_TIMEOUT_MS") ??
|
|
959
|
+
workerNode.quality_validation_step_timeout_ms,
|
|
960
|
+
DEFAULT_WORKERPALS_QUALITY_VALIDATION_STEP_TIMEOUT_MS,
|
|
961
|
+
),
|
|
962
|
+
);
|
|
963
|
+
const workerQualityCriticTimeoutMs = Math.max(
|
|
964
|
+
1_000,
|
|
965
|
+
asInt(
|
|
966
|
+
parseIntEnv("WORKERPALS_QUALITY_CRITIC_TIMEOUT_MS") ??
|
|
967
|
+
workerNode.quality_critic_timeout_ms,
|
|
968
|
+
DEFAULT_WORKERPALS_QUALITY_CRITIC_TIMEOUT_MS,
|
|
969
|
+
),
|
|
970
|
+
);
|
|
971
|
+
const workerQualitySoftPassOnExhausted =
|
|
972
|
+
parseBoolEnv("WORKERPALS_QUALITY_SOFT_PASS_ON_EXHAUSTED") ??
|
|
973
|
+
asBoolean(workerNode.quality_soft_pass_on_exhausted, true);
|
|
974
|
+
const workerQualityCriticMinScore = (() => {
|
|
975
|
+
const configThresholdRaw =
|
|
976
|
+
workerNode.quality_critic_min_score == null
|
|
977
|
+
? ""
|
|
978
|
+
: String(workerNode.quality_critic_min_score);
|
|
979
|
+
const raw = firstNonEmpty(
|
|
980
|
+
process.env.WORKERPALS_QUALITY_CRITIC_MIN_SCORE,
|
|
981
|
+
configThresholdRaw,
|
|
982
|
+
String(DEFAULT_WORKERPALS_QUALITY_CRITIC_MIN_SCORE),
|
|
983
|
+
);
|
|
984
|
+
const parsed = Number.parseFloat(raw);
|
|
985
|
+
if (!Number.isFinite(parsed)) return DEFAULT_WORKERPALS_QUALITY_CRITIC_MIN_SCORE;
|
|
986
|
+
return Math.max(0, Math.min(10, parsed));
|
|
987
|
+
})();
|
|
988
|
+
const workerQualityCriticMaxDiffChars = Math.max(
|
|
989
|
+
256,
|
|
990
|
+
Math.min(
|
|
991
|
+
524_288,
|
|
992
|
+
asInt(
|
|
993
|
+
parseIntEnv("WORKERPALS_QUALITY_CRITIC_MAX_DIFF_CHARS") ??
|
|
994
|
+
workerNode.quality_critic_max_diff_chars,
|
|
995
|
+
DEFAULT_WORKERPALS_QUALITY_CRITIC_MAX_DIFF_CHARS,
|
|
996
|
+
),
|
|
997
|
+
),
|
|
998
|
+
);
|
|
999
|
+
const workerQualityCriticMaxValidationOutputChars = Math.max(
|
|
1000
|
+
256,
|
|
1001
|
+
Math.min(
|
|
1002
|
+
524_288,
|
|
1003
|
+
asInt(
|
|
1004
|
+
parseIntEnv("WORKERPALS_QUALITY_CRITIC_MAX_VALIDATION_OUTPUT_CHARS") ??
|
|
1005
|
+
workerNode.quality_critic_max_validation_output_chars,
|
|
1006
|
+
DEFAULT_WORKERPALS_QUALITY_CRITIC_MAX_VALIDATION_OUTPUT_CHARS,
|
|
1007
|
+
),
|
|
1008
|
+
),
|
|
1009
|
+
);
|
|
1010
|
+
const workerExecutorResultPrefix = (() => {
|
|
1011
|
+
if (process.env.WORKERPALS_EXECUTOR_RESULT_PREFIX !== undefined) {
|
|
1012
|
+
const raw = process.env.WORKERPALS_EXECUTOR_RESULT_PREFIX;
|
|
1013
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
1014
|
+
}
|
|
1015
|
+
if (
|
|
1016
|
+
Object.prototype.hasOwnProperty.call(workerNode, "executor_result_prefix") &&
|
|
1017
|
+
typeof workerNode.executor_result_prefix === "string" &&
|
|
1018
|
+
workerNode.executor_result_prefix.length > 0
|
|
1019
|
+
) {
|
|
1020
|
+
return workerNode.executor_result_prefix;
|
|
1021
|
+
}
|
|
1022
|
+
return DEFAULT_WORKERPALS_EXECUTOR_RESULT_PREFIX;
|
|
1023
|
+
})();
|
|
1024
|
+
const workerOpenHandsStuckGuardEnabled =
|
|
1025
|
+
parseBoolEnv("WORKERPALS_OPENHANDS_STUCK_GUARD_ENABLED") ??
|
|
1026
|
+
asBoolean(workerNode.openhands_stuck_guard_enabled, true);
|
|
1027
|
+
const workerOpenHandsStuckGuardExploreLimit = Math.max(
|
|
1028
|
+
6,
|
|
1029
|
+
asInt(
|
|
1030
|
+
parseIntEnv("WORKERPALS_OPENHANDS_STUCK_GUARD_EXPLORE_LIMIT") ??
|
|
1031
|
+
workerNode.openhands_stuck_guard_explore_limit,
|
|
1032
|
+
18,
|
|
1033
|
+
),
|
|
1034
|
+
);
|
|
1035
|
+
const workerOpenHandsStuckGuardMinElapsedMs = Math.max(
|
|
1036
|
+
60_000,
|
|
1037
|
+
asInt(
|
|
1038
|
+
parseIntEnv("WORKERPALS_OPENHANDS_STUCK_GUARD_MIN_ELAPSED_MS") ??
|
|
1039
|
+
workerNode.openhands_stuck_guard_min_elapsed_ms,
|
|
1040
|
+
180_000,
|
|
1041
|
+
),
|
|
1042
|
+
);
|
|
1043
|
+
const workerOpenHandsStuckGuardBroadScanLimit = Math.max(
|
|
1044
|
+
1,
|
|
1045
|
+
asInt(
|
|
1046
|
+
parseIntEnv("WORKERPALS_OPENHANDS_STUCK_GUARD_BROAD_SCAN_LIMIT") ??
|
|
1047
|
+
workerNode.openhands_stuck_guard_broad_scan_limit,
|
|
1048
|
+
2,
|
|
1049
|
+
),
|
|
1050
|
+
);
|
|
1051
|
+
const workerOpenHandsStuckGuardNoProgressMaxMs = Math.max(
|
|
1052
|
+
60_000,
|
|
1053
|
+
asInt(
|
|
1054
|
+
parseIntEnv("WORKERPALS_OPENHANDS_STUCK_GUARD_NO_PROGRESS_MAX_MS") ??
|
|
1055
|
+
workerNode.openhands_stuck_guard_no_progress_max_ms,
|
|
1056
|
+
300_000,
|
|
1057
|
+
),
|
|
1058
|
+
);
|
|
1059
|
+
const workerOpenHandsAutoSteerEnabled =
|
|
1060
|
+
parseBoolEnv("WORKERPALS_OPENHANDS_AUTO_STEER_ENABLED") ??
|
|
1061
|
+
asBoolean(workerOpenHandsNode.auto_steer_enabled, true);
|
|
1062
|
+
const workerOpenHandsAutoSteerInitialDelaySec = Math.max(
|
|
1063
|
+
0,
|
|
1064
|
+
Math.min(
|
|
1065
|
+
600,
|
|
1066
|
+
asInt(
|
|
1067
|
+
parseIntEnv("WORKERPALS_OPENHANDS_AUTO_STEER_INITIAL_DELAY_SEC") ??
|
|
1068
|
+
workerOpenHandsNode.auto_steer_initial_delay_sec,
|
|
1069
|
+
90,
|
|
1070
|
+
),
|
|
1071
|
+
),
|
|
1072
|
+
);
|
|
1073
|
+
const workerOpenHandsAutoSteerIntervalSec = Math.max(
|
|
1074
|
+
15,
|
|
1075
|
+
Math.min(
|
|
1076
|
+
600,
|
|
1077
|
+
asInt(
|
|
1078
|
+
parseIntEnv("WORKERPALS_OPENHANDS_AUTO_STEER_INTERVAL_SEC") ??
|
|
1079
|
+
workerOpenHandsNode.auto_steer_interval_sec,
|
|
1080
|
+
60,
|
|
1081
|
+
),
|
|
1082
|
+
),
|
|
1083
|
+
);
|
|
1084
|
+
const workerOpenHandsAutoSteerMaxNudges = Math.max(
|
|
1085
|
+
0,
|
|
1086
|
+
Math.min(
|
|
1087
|
+
120,
|
|
1088
|
+
asInt(
|
|
1089
|
+
parseIntEnv("WORKERPALS_OPENHANDS_AUTO_STEER_MAX_NUDGES") ??
|
|
1090
|
+
workerOpenHandsNode.auto_steer_max_nudges,
|
|
1091
|
+
30,
|
|
1092
|
+
),
|
|
1093
|
+
),
|
|
1094
|
+
);
|
|
1095
|
+
const workerRequirePush =
|
|
1096
|
+
parseBoolEnv("WORKERPALS_REQUIRE_PUSH") ?? asBoolean(workerNode.require_push, false);
|
|
1097
|
+
const workerPushAgentBranchEnv = parseBoolEnv("WORKERPALS_PUSH_AGENT_BRANCH");
|
|
1098
|
+
const workerPushAgentBranch =
|
|
1099
|
+
workerRequirePush ||
|
|
1100
|
+
(workerPushAgentBranchEnv ?? asBoolean(workerNode.push_agent_branch, false));
|
|
1101
|
+
const workerSkipDockerSelfCheck =
|
|
1102
|
+
parseBoolEnv("WORKERPALS_SKIP_DOCKER_SELF_CHECK") ??
|
|
1103
|
+
asBoolean(workerNode.skip_docker_self_check, false);
|
|
1104
|
+
const workerDockerAgentStartupTimeoutMs = Math.max(
|
|
1105
|
+
10_000,
|
|
1106
|
+
Math.min(
|
|
1107
|
+
180_000,
|
|
1108
|
+
asInt(
|
|
1109
|
+
parseIntEnv("WORKERPALS_DOCKER_AGENT_STARTUP_TIMEOUT_MS") ??
|
|
1110
|
+
workerNode.docker_agent_startup_timeout_ms,
|
|
1111
|
+
45_000,
|
|
1112
|
+
),
|
|
1113
|
+
),
|
|
1114
|
+
);
|
|
1115
|
+
const workerDockerWarmMaxAttempts = Math.max(
|
|
1116
|
+
1,
|
|
1117
|
+
Math.min(
|
|
1118
|
+
5,
|
|
1119
|
+
asInt(
|
|
1120
|
+
parseIntEnv("WORKERPALS_DOCKER_WARM_MAX_ATTEMPTS") ?? workerNode.docker_warm_max_attempts,
|
|
1121
|
+
3,
|
|
1122
|
+
),
|
|
1123
|
+
),
|
|
1124
|
+
);
|
|
1125
|
+
const workerDockerWarmRetryBackoffMs = Math.max(
|
|
1126
|
+
250,
|
|
1127
|
+
Math.min(
|
|
1128
|
+
60_000,
|
|
1129
|
+
asInt(
|
|
1130
|
+
parseIntEnv("WORKERPALS_DOCKER_WARM_RETRY_BACKOFF_MS") ??
|
|
1131
|
+
workerNode.docker_warm_retry_backoff_ms,
|
|
1132
|
+
2_000,
|
|
1133
|
+
),
|
|
1134
|
+
),
|
|
1135
|
+
);
|
|
1136
|
+
const workerDockerJobMaxAttempts = Math.max(
|
|
1137
|
+
1,
|
|
1138
|
+
Math.min(
|
|
1139
|
+
3,
|
|
1140
|
+
asInt(
|
|
1141
|
+
parseIntEnv("WORKERPALS_DOCKER_JOB_MAX_ATTEMPTS") ?? workerNode.docker_job_max_attempts,
|
|
1142
|
+
2,
|
|
1143
|
+
),
|
|
1144
|
+
),
|
|
1145
|
+
);
|
|
1146
|
+
const workerDockerJobRetryBackoffMs = Math.max(
|
|
1147
|
+
250,
|
|
1148
|
+
Math.min(
|
|
1149
|
+
60_000,
|
|
1150
|
+
asInt(
|
|
1151
|
+
parseIntEnv("WORKERPALS_DOCKER_JOB_RETRY_BACKOFF_MS") ??
|
|
1152
|
+
workerNode.docker_job_retry_backoff_ms,
|
|
1153
|
+
3_000,
|
|
1154
|
+
),
|
|
1155
|
+
),
|
|
1156
|
+
);
|
|
1157
|
+
const workerDockerWarmMemoryMb = Math.max(
|
|
1158
|
+
512,
|
|
1159
|
+
Math.min(
|
|
1160
|
+
32_768,
|
|
1161
|
+
asInt(
|
|
1162
|
+
parseIntEnv("WORKERPALS_DOCKER_WARM_MEMORY_MB") ?? workerNode.docker_warm_memory_mb,
|
|
1163
|
+
2_048,
|
|
1164
|
+
),
|
|
1165
|
+
),
|
|
1166
|
+
);
|
|
1167
|
+
const workerDockerWarmCpus = Math.max(
|
|
1168
|
+
1,
|
|
1169
|
+
Math.min(
|
|
1170
|
+
16,
|
|
1171
|
+
asInt(parseIntEnv("WORKERPALS_DOCKER_WARM_CPUS") ?? workerNode.docker_warm_cpus, 2),
|
|
1172
|
+
),
|
|
1173
|
+
);
|
|
1174
|
+
const workerLlm = resolveLlmConfig(
|
|
1175
|
+
workerNode,
|
|
1176
|
+
"WORKERPALS",
|
|
1177
|
+
{
|
|
1178
|
+
backend: "lmstudio",
|
|
1179
|
+
endpoint: "http://127.0.0.1:1234",
|
|
1180
|
+
model: "local-model",
|
|
1181
|
+
sessionId: "workerpals-dev",
|
|
1182
|
+
},
|
|
1183
|
+
sessionId,
|
|
1184
|
+
);
|
|
1185
|
+
|
|
1186
|
+
const scmNode = getObject(merged, "source_control_manager");
|
|
1187
|
+
const scmRepoPath = resolvePathFromRoot(
|
|
1188
|
+
projectRoot,
|
|
1189
|
+
firstNonEmpty(
|
|
1190
|
+
process.env.SOURCE_CONTROL_MANAGER_REPO_PATH,
|
|
1191
|
+
asString(scmNode.repo_path, ".worktrees/source_control_manager"),
|
|
1192
|
+
".worktrees/source_control_manager",
|
|
1193
|
+
),
|
|
1194
|
+
);
|
|
1195
|
+
const scmRemote = asString(process.env.SOURCE_CONTROL_MANAGER_REMOTE ?? scmNode.remote, "origin");
|
|
1196
|
+
const scmMainBranch = firstNonEmpty(
|
|
1197
|
+
process.env.SOURCE_CONTROL_MANAGER_MAIN_BRANCH,
|
|
1198
|
+
process.env.PUSHPALS_INTEGRATION_BRANCH,
|
|
1199
|
+
asString(scmNode.pushpals_branch, "main_agents"),
|
|
1200
|
+
"main_agents",
|
|
1201
|
+
);
|
|
1202
|
+
const scmBaseBranch = firstNonEmpty(
|
|
1203
|
+
process.env.PUSHPALS_INTEGRATION_BASE_BRANCH,
|
|
1204
|
+
asString(scmNode.base_branch, "main"),
|
|
1205
|
+
"main",
|
|
1206
|
+
);
|
|
1207
|
+
const scmBranchPrefix = asString(
|
|
1208
|
+
process.env.SOURCE_CONTROL_MANAGER_BRANCH_PREFIX ?? scmNode.branch_prefix,
|
|
1209
|
+
"agent/",
|
|
1210
|
+
);
|
|
1211
|
+
const scmPollIntervalSeconds = Math.max(
|
|
1212
|
+
1,
|
|
1213
|
+
asInt(
|
|
1214
|
+
parseIntEnv("SOURCE_CONTROL_MANAGER_POLL_INTERVAL_SECONDS") ?? scmNode.poll_interval_seconds,
|
|
1215
|
+
10,
|
|
1216
|
+
),
|
|
1217
|
+
);
|
|
1218
|
+
const scmChecks = asCheckArray(scmNode.checks);
|
|
1219
|
+
const scmStateDir = resolvePathFromRoot(
|
|
1220
|
+
projectRoot,
|
|
1221
|
+
firstNonEmpty(
|
|
1222
|
+
process.env.SOURCE_CONTROL_MANAGER_STATE_DIR,
|
|
1223
|
+
asString(scmNode.state_dir, join(dataDir, "source_control_manager")),
|
|
1224
|
+
join(dataDir, "source_control_manager"),
|
|
1225
|
+
),
|
|
1226
|
+
);
|
|
1227
|
+
const scmPort = Math.max(
|
|
1228
|
+
1,
|
|
1229
|
+
Math.min(65_535, asInt(parseIntEnv("SOURCE_CONTROL_MANAGER_PORT") ?? scmNode.port, 3002)),
|
|
1230
|
+
);
|
|
1231
|
+
const scmDeleteAfterMerge =
|
|
1232
|
+
parseBoolEnv("SOURCE_CONTROL_MANAGER_DELETE_AFTER_MERGE") ??
|
|
1233
|
+
asBoolean(scmNode.delete_after_merge, false);
|
|
1234
|
+
const scmMaxAttempts = Math.max(
|
|
1235
|
+
1,
|
|
1236
|
+
asInt(parseIntEnv("SOURCE_CONTROL_MANAGER_MAX_ATTEMPTS") ?? scmNode.max_attempts, 3),
|
|
1237
|
+
);
|
|
1238
|
+
const scmMergeStrategyRaw = firstNonEmpty(
|
|
1239
|
+
process.env.SOURCE_CONTROL_MANAGER_MERGE_STRATEGY,
|
|
1240
|
+
asString(scmNode.merge_strategy, "cherry-pick"),
|
|
1241
|
+
"cherry-pick",
|
|
1242
|
+
);
|
|
1243
|
+
const scmMergeStrategy =
|
|
1244
|
+
scmMergeStrategyRaw === "no-ff" || scmMergeStrategyRaw === "ff-only"
|
|
1245
|
+
? scmMergeStrategyRaw
|
|
1246
|
+
: "cherry-pick";
|
|
1247
|
+
let scmPushMainAfterMerge = asBoolean(scmNode.push_main_after_merge, true);
|
|
1248
|
+
const scmPushMainAfterMergeEnv = parseBoolEnv("SOURCE_CONTROL_MANAGER_PUSH_MAIN_AFTER_MERGE");
|
|
1249
|
+
if (scmPushMainAfterMergeEnv != null) scmPushMainAfterMerge = scmPushMainAfterMergeEnv;
|
|
1250
|
+
const scmNoPushEnv = parseBoolEnv("SOURCE_CONTROL_MANAGER_NO_PUSH");
|
|
1251
|
+
if (scmNoPushEnv != null) scmPushMainAfterMerge = !scmNoPushEnv;
|
|
1252
|
+
let scmOpenPrAfterPush = asBoolean(scmNode.open_pr_after_push, true);
|
|
1253
|
+
const scmOpenPrAfterPushEnv = parseBoolEnv("SOURCE_CONTROL_MANAGER_OPEN_PR_AFTER_PUSH");
|
|
1254
|
+
if (scmOpenPrAfterPushEnv != null) scmOpenPrAfterPush = scmOpenPrAfterPushEnv;
|
|
1255
|
+
const scmDisableAutoPrEnv = parseBoolEnv("SOURCE_CONTROL_MANAGER_DISABLE_AUTO_PR");
|
|
1256
|
+
if (scmDisableAutoPrEnv != null) scmOpenPrAfterPush = !scmDisableAutoPrEnv;
|
|
1257
|
+
const scmPrBaseBranch = firstNonEmpty(
|
|
1258
|
+
process.env.SOURCE_CONTROL_MANAGER_PR_BASE_BRANCH,
|
|
1259
|
+
asString(scmNode.pr_base_branch, scmBaseBranch),
|
|
1260
|
+
scmBaseBranch,
|
|
1261
|
+
);
|
|
1262
|
+
const scmPrTitle = firstNonEmpty(
|
|
1263
|
+
process.env.SOURCE_CONTROL_MANAGER_PR_TITLE,
|
|
1264
|
+
asString(scmNode.pr_title, ""),
|
|
1265
|
+
);
|
|
1266
|
+
const scmPrBody = firstNonEmpty(
|
|
1267
|
+
process.env.SOURCE_CONTROL_MANAGER_PR_BODY,
|
|
1268
|
+
asString(scmNode.pr_body, ""),
|
|
1269
|
+
);
|
|
1270
|
+
const scmPrDraft =
|
|
1271
|
+
parseBoolEnv("SOURCE_CONTROL_MANAGER_PR_DRAFT") ?? asBoolean(scmNode.pr_draft, false);
|
|
1272
|
+
const scmStatusHeartbeatMs = Math.max(
|
|
1273
|
+
0,
|
|
1274
|
+
asInt(
|
|
1275
|
+
parseIntEnv("SOURCE_CONTROL_MANAGER_STATUS_HEARTBEAT_MS") ??
|
|
1276
|
+
globalStatusHeartbeatMs ??
|
|
1277
|
+
scmNode.status_heartbeat_ms,
|
|
1278
|
+
120_000,
|
|
1279
|
+
),
|
|
1280
|
+
);
|
|
1281
|
+
const scmSkipCleanCheck =
|
|
1282
|
+
parseBoolEnv("SOURCE_CONTROL_MANAGER_SKIP_CLEAN_CHECK") ??
|
|
1283
|
+
asBoolean(scmNode.skip_clean_check, false);
|
|
1284
|
+
const scmAutoCreateMainBranch =
|
|
1285
|
+
parseBoolEnv("SOURCE_CONTROL_MANAGER_AUTO_CREATE_MAIN_BRANCH") ??
|
|
1286
|
+
asBoolean(scmNode.auto_create_main_branch, false);
|
|
1287
|
+
|
|
1288
|
+
const scmReviewAgentNode = getObject(scmNode, "review_agent");
|
|
1289
|
+
const scmReviewAgentEnabled =
|
|
1290
|
+
parseBoolEnv("SOURCE_CONTROL_MANAGER_REVIEW_AGENT_ENABLED") ??
|
|
1291
|
+
asBoolean(scmReviewAgentNode.enabled, false);
|
|
1292
|
+
const scmReviewAgentPollIntervalMs = Math.max(
|
|
1293
|
+
5_000,
|
|
1294
|
+
asInt(
|
|
1295
|
+
parseIntEnv("SOURCE_CONTROL_MANAGER_REVIEW_AGENT_POLL_INTERVAL_MS") ??
|
|
1296
|
+
scmReviewAgentNode.poll_interval_ms,
|
|
1297
|
+
60_000,
|
|
1298
|
+
),
|
|
1299
|
+
);
|
|
1300
|
+
const scmReviewAgentReviewerMdPath = firstNonEmpty(
|
|
1301
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_REVIEWER_MD_PATH,
|
|
1302
|
+
asString(scmReviewAgentNode.reviewer_md_path, "prompts/review_agent/reviewer.md"),
|
|
1303
|
+
"prompts/review_agent/reviewer.md",
|
|
1304
|
+
);
|
|
1305
|
+
const scmReviewAgentPassThreshold = (() => {
|
|
1306
|
+
const configThresholdRaw =
|
|
1307
|
+
scmReviewAgentNode.pass_threshold == null ? "" : String(scmReviewAgentNode.pass_threshold);
|
|
1308
|
+
const raw = firstNonEmpty(
|
|
1309
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_PASS_THRESHOLD,
|
|
1310
|
+
configThresholdRaw,
|
|
1311
|
+
"9.5",
|
|
1312
|
+
);
|
|
1313
|
+
const parsed = Number.parseFloat(raw);
|
|
1314
|
+
return Number.isFinite(parsed) ? Math.max(1, Math.min(10, parsed)) : 9.5;
|
|
1315
|
+
})();
|
|
1316
|
+
const scmReviewAgentMaxPrCommentsBeforeGiveUp = Math.max(
|
|
1317
|
+
1,
|
|
1318
|
+
Math.min(
|
|
1319
|
+
100,
|
|
1320
|
+
asInt(
|
|
1321
|
+
parseIntEnv("SOURCE_CONTROL_MANAGER_REVIEW_AGENT_MAX_PR_COMMENTS_BEFORE_GIVE_UP") ??
|
|
1322
|
+
scmReviewAgentNode.max_pr_comments_before_give_up,
|
|
1323
|
+
10,
|
|
1324
|
+
),
|
|
1325
|
+
),
|
|
1326
|
+
);
|
|
1327
|
+
const scmReviewAgentMergeMethodRaw = firstNonEmpty(
|
|
1328
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_MERGE_METHOD,
|
|
1329
|
+
asString(scmReviewAgentNode.merge_method, "squash"),
|
|
1330
|
+
"squash",
|
|
1331
|
+
).toLowerCase();
|
|
1332
|
+
const scmReviewAgentMergeMethod: "squash" | "merge" | "rebase" =
|
|
1333
|
+
scmReviewAgentMergeMethodRaw === "merge" || scmReviewAgentMergeMethodRaw === "rebase"
|
|
1334
|
+
? scmReviewAgentMergeMethodRaw
|
|
1335
|
+
: "squash";
|
|
1336
|
+
const scmReviewAgentCodexBin = firstNonEmpty(
|
|
1337
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_CODEX_BIN,
|
|
1338
|
+
asString(scmReviewAgentNode.codex_bin, "bun x --yes @openai/codex"),
|
|
1339
|
+
"bun x --yes @openai/codex",
|
|
1340
|
+
);
|
|
1341
|
+
const scmReviewAgentCodexAuthMode = firstNonEmpty(
|
|
1342
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_CODEX_AUTH_MODE,
|
|
1343
|
+
asString(scmReviewAgentNode.codex_auth_mode, "chatgpt"),
|
|
1344
|
+
"chatgpt",
|
|
1345
|
+
);
|
|
1346
|
+
const scmReviewAgentCodexHomeDir = firstNonEmpty(
|
|
1347
|
+
process.env.SOURCE_CONTROL_MANAGER_REVIEW_AGENT_CODEX_HOME_DIR,
|
|
1348
|
+
asString(scmReviewAgentNode.codex_home_dir, ""),
|
|
1349
|
+
);
|
|
1350
|
+
const scmReviewAgentCodexTimeoutMs = Math.max(
|
|
1351
|
+
30_000,
|
|
1352
|
+
asInt(
|
|
1353
|
+
parseIntEnv("SOURCE_CONTROL_MANAGER_REVIEW_AGENT_CODEX_TIMEOUT_MS") ??
|
|
1354
|
+
scmReviewAgentNode.codex_timeout_ms,
|
|
1355
|
+
300_000,
|
|
1356
|
+
),
|
|
1357
|
+
);
|
|
1358
|
+
|
|
1359
|
+
const startupNode = getObject(merged, "startup");
|
|
1360
|
+
const startupWorkerImageRebuild = normalizeWorkerImageRebuildMode(
|
|
1361
|
+
firstNonEmpty(
|
|
1362
|
+
process.env.PUSHPALS_WORKER_IMAGE_REBUILD,
|
|
1363
|
+
asString(startupNode.worker_image_rebuild, "auto"),
|
|
1364
|
+
"auto",
|
|
1365
|
+
),
|
|
1366
|
+
);
|
|
1367
|
+
const startupLogConfigOnStart =
|
|
1368
|
+
parseBoolEnv("PUSHPALS_LOG_CONFIG_ON_START") ??
|
|
1369
|
+
asBoolean(startupNode.log_config_on_start, true);
|
|
1370
|
+
const startupSyncIntegrationWithMain =
|
|
1371
|
+
parseBoolEnv("PUSHPALS_SYNC_INTEGRATION_WITH_MAIN") ??
|
|
1372
|
+
asBoolean(startupNode.sync_integration_with_main, true);
|
|
1373
|
+
const startupSkipLlmPreflight =
|
|
1374
|
+
parseBoolEnv("PUSHPALS_SKIP_LLM_PREFLIGHT") ?? asBoolean(startupNode.skip_llm_preflight, false);
|
|
1375
|
+
const startupAutoStartLmStudio =
|
|
1376
|
+
parseBoolEnv("PUSHPALS_AUTO_START_LMSTUDIO") ??
|
|
1377
|
+
asBoolean(startupNode.auto_start_lmstudio, true);
|
|
1378
|
+
const startupLmStudioReadyTimeoutMs = Math.max(
|
|
1379
|
+
1_000,
|
|
1380
|
+
asInt(
|
|
1381
|
+
parseIntEnv("PUSHPALS_LMSTUDIO_READY_TIMEOUT_MS") ?? startupNode.lmstudio_ready_timeout_ms,
|
|
1382
|
+
120_000,
|
|
1383
|
+
),
|
|
1384
|
+
);
|
|
1385
|
+
const startupLmStudioCli = firstNonEmpty(
|
|
1386
|
+
process.env.PUSHPALS_LMSTUDIO_CLI,
|
|
1387
|
+
asString(startupNode.lmstudio_cli, "lms"),
|
|
1388
|
+
"lms",
|
|
1389
|
+
);
|
|
1390
|
+
const startupLmStudioPort = Math.max(
|
|
1391
|
+
1,
|
|
1392
|
+
Math.min(
|
|
1393
|
+
65_535,
|
|
1394
|
+
asInt(parseIntEnv("PUSHPALS_LMSTUDIO_PORT") ?? startupNode.lmstudio_port, 1234),
|
|
1395
|
+
),
|
|
1396
|
+
);
|
|
1397
|
+
const startupLmStudioStartArgs = firstNonEmpty(
|
|
1398
|
+
process.env.PUSHPALS_LMSTUDIO_START_ARGS,
|
|
1399
|
+
asString(startupNode.lmstudio_start_args, ""),
|
|
1400
|
+
);
|
|
1401
|
+
const startupWarmup =
|
|
1402
|
+
parseBoolEnv("PUSHPALS_STARTUP_WARMUP") ?? asBoolean(startupNode.startup_warmup, true);
|
|
1403
|
+
const startupWarmupTimeoutMs = Math.max(
|
|
1404
|
+
15_000,
|
|
1405
|
+
asInt(
|
|
1406
|
+
parseIntEnv("PUSHPALS_STARTUP_WARMUP_TIMEOUT_MS") ?? startupNode.startup_warmup_timeout_ms,
|
|
1407
|
+
120_000,
|
|
1408
|
+
),
|
|
1409
|
+
);
|
|
1410
|
+
const startupWarmupPollMs = Math.max(
|
|
1411
|
+
250,
|
|
1412
|
+
Math.min(
|
|
1413
|
+
5_000,
|
|
1414
|
+
asInt(
|
|
1415
|
+
parseIntEnv("PUSHPALS_STARTUP_WARMUP_POLL_MS") ?? startupNode.startup_warmup_poll_ms,
|
|
1416
|
+
1_000,
|
|
1417
|
+
),
|
|
1418
|
+
),
|
|
1419
|
+
);
|
|
1420
|
+
const startupAllowExternalClean =
|
|
1421
|
+
parseBoolEnv("PUSHPALS_ALLOW_EXTERNAL_CLEAN") ??
|
|
1422
|
+
asBoolean(startupNode.allow_external_clean, false);
|
|
1423
|
+
const startupPortPreflight =
|
|
1424
|
+
parseBoolEnv("PUSHPALS_STARTUP_PORT_PREFLIGHT") ??
|
|
1425
|
+
asBoolean(startupNode.port_preflight, true);
|
|
1426
|
+
const startupPortConflictPolicy = normalizeStartupPortConflictPolicy(
|
|
1427
|
+
firstNonEmpty(
|
|
1428
|
+
process.env.PUSHPALS_STARTUP_PORT_CONFLICT_POLICY,
|
|
1429
|
+
asString(startupNode.port_conflict_policy, "terminate_pushpals"),
|
|
1430
|
+
"terminate_pushpals",
|
|
1431
|
+
),
|
|
1432
|
+
);
|
|
1433
|
+
|
|
1434
|
+
const clientNode = getObject(merged, "client");
|
|
1435
|
+
|
|
1436
|
+
const authToken = firstNonEmpty(process.env.PUSHPALS_AUTH_TOKEN) || null;
|
|
1437
|
+
const gitToken =
|
|
1438
|
+
firstNonEmpty(process.env.PUSHPALS_GIT_TOKEN, process.env.GITHUB_TOKEN, process.env.GH_TOKEN) ||
|
|
1439
|
+
null;
|
|
1440
|
+
|
|
1441
|
+
const config: PushPalsConfig = {
|
|
1442
|
+
projectRoot,
|
|
1443
|
+
configDir,
|
|
1444
|
+
profile,
|
|
1445
|
+
sessionId,
|
|
1446
|
+
authToken,
|
|
1447
|
+
gitToken,
|
|
1448
|
+
llm: {
|
|
1449
|
+
lmstudio: {
|
|
1450
|
+
contextWindow: lmStudioContextWindow,
|
|
1451
|
+
minOutputTokens: lmStudioMinOutputTokens,
|
|
1452
|
+
tokenSafetyMargin: lmStudioTokenSafetyMargin,
|
|
1453
|
+
batchTailMessages: lmStudioBatchTailMessages,
|
|
1454
|
+
batchChunkTokens: lmStudioBatchChunkTokens,
|
|
1455
|
+
batchMemoryChars: lmStudioBatchMemoryChars,
|
|
1456
|
+
},
|
|
1457
|
+
},
|
|
1458
|
+
paths: {
|
|
1459
|
+
dataDir,
|
|
1460
|
+
sharedDbPath,
|
|
1461
|
+
remotebuddyDbPath,
|
|
1462
|
+
},
|
|
1463
|
+
server: {
|
|
1464
|
+
url: serverUrl,
|
|
1465
|
+
host: serverHost,
|
|
1466
|
+
port: serverPort,
|
|
1467
|
+
debugHttp,
|
|
1468
|
+
staleClaimTtlMs,
|
|
1469
|
+
staleClaimSweepIntervalMs,
|
|
1470
|
+
},
|
|
1471
|
+
localbuddy: {
|
|
1472
|
+
enabled: localEnabled,
|
|
1473
|
+
port: localPort,
|
|
1474
|
+
statusHeartbeatMs: localStatusHeartbeatMs,
|
|
1475
|
+
llm: localLlm,
|
|
1476
|
+
},
|
|
1477
|
+
remotebuddy: {
|
|
1478
|
+
pollMs: remotePollMs,
|
|
1479
|
+
statusHeartbeatMs: remoteStatusHeartbeatMs,
|
|
1480
|
+
workerpalOnlineTtlMs: Math.max(
|
|
1481
|
+
1_000,
|
|
1482
|
+
asInt(
|
|
1483
|
+
parseIntEnv("REMOTEBUDDY_WORKERPAL_ONLINE_TTL_MS") ?? remoteNode.workerpal_online_ttl_ms,
|
|
1484
|
+
15_000,
|
|
1485
|
+
),
|
|
1486
|
+
),
|
|
1487
|
+
waitForWorkerpalMs: Math.max(
|
|
1488
|
+
0,
|
|
1489
|
+
asInt(
|
|
1490
|
+
parseIntEnv("REMOTEBUDDY_WAIT_FOR_WORKERPAL_MS") ?? remoteNode.wait_for_workerpal_ms,
|
|
1491
|
+
15_000,
|
|
1492
|
+
),
|
|
1493
|
+
),
|
|
1494
|
+
autoSpawnWorkerpals:
|
|
1495
|
+
parseBoolEnv("REMOTEBUDDY_AUTO_SPAWN_WORKERPALS") ??
|
|
1496
|
+
asBoolean(remoteNode.auto_spawn_workerpals, true),
|
|
1497
|
+
maxWorkerpals: Math.max(
|
|
1498
|
+
1,
|
|
1499
|
+
asInt(remoteNode.max_workerpals, 20),
|
|
1500
|
+
),
|
|
1501
|
+
workerpalStartupTimeoutMs: Math.max(
|
|
1502
|
+
1_000,
|
|
1503
|
+
asInt(
|
|
1504
|
+
parseIntEnv("REMOTEBUDDY_WORKERPAL_STARTUP_TIMEOUT_MS") ??
|
|
1505
|
+
remoteNode.workerpal_startup_timeout_ms,
|
|
1506
|
+
10_000,
|
|
1507
|
+
),
|
|
1508
|
+
),
|
|
1509
|
+
workerpalDocker:
|
|
1510
|
+
parseBoolEnv("REMOTEBUDDY_WORKERPAL_DOCKER") ??
|
|
1511
|
+
asBoolean(remoteNode.workerpal_docker, true),
|
|
1512
|
+
workerpalRequireDocker:
|
|
1513
|
+
parseBoolEnv("REMOTEBUDDY_WORKERPAL_REQUIRE_DOCKER") ??
|
|
1514
|
+
asBoolean(remoteNode.workerpal_require_docker, true),
|
|
1515
|
+
workerpalImage:
|
|
1516
|
+
firstNonEmpty(
|
|
1517
|
+
process.env.REMOTEBUDDY_WORKERPAL_IMAGE,
|
|
1518
|
+
asString(remoteNode.workerpal_image, ""),
|
|
1519
|
+
) || null,
|
|
1520
|
+
workerpalPollMs:
|
|
1521
|
+
asIntOrNull(parseIntEnv("REMOTEBUDDY_WORKERPAL_POLL_MS")) ??
|
|
1522
|
+
asIntOrNull(remoteNode.workerpal_poll_ms),
|
|
1523
|
+
workerpalHeartbeatMs:
|
|
1524
|
+
asIntOrNull(parseIntEnv("REMOTEBUDDY_WORKERPAL_HEARTBEAT_MS")) ??
|
|
1525
|
+
asIntOrNull(remoteNode.workerpal_heartbeat_ms),
|
|
1526
|
+
workerpalLabels: firstNonEmpty(process.env.REMOTEBUDDY_WORKERPAL_LABELS)
|
|
1527
|
+
? firstNonEmpty(process.env.REMOTEBUDDY_WORKERPAL_LABELS)
|
|
1528
|
+
.split(",")
|
|
1529
|
+
.map((value) => value.trim())
|
|
1530
|
+
.filter(Boolean)
|
|
1531
|
+
: asStringArray(remoteNode.workerpal_labels),
|
|
1532
|
+
executionBudgetInteractiveMs: Math.max(
|
|
1533
|
+
60_000,
|
|
1534
|
+
asInt(
|
|
1535
|
+
parseIntEnv("REMOTEBUDDY_EXECUTION_BUDGET_INTERACTIVE_MS") ??
|
|
1536
|
+
remoteNode.execution_budget_interactive_ms,
|
|
1537
|
+
300_000,
|
|
1538
|
+
),
|
|
1539
|
+
),
|
|
1540
|
+
executionBudgetNormalMs: Math.max(
|
|
1541
|
+
120_000,
|
|
1542
|
+
asInt(
|
|
1543
|
+
parseIntEnv("REMOTEBUDDY_EXECUTION_BUDGET_NORMAL_MS") ??
|
|
1544
|
+
remoteNode.execution_budget_normal_ms,
|
|
1545
|
+
900_000,
|
|
1546
|
+
),
|
|
1547
|
+
),
|
|
1548
|
+
executionBudgetBackgroundMs: Math.max(
|
|
1549
|
+
180_000,
|
|
1550
|
+
asInt(
|
|
1551
|
+
parseIntEnv("REMOTEBUDDY_EXECUTION_BUDGET_BACKGROUND_MS") ??
|
|
1552
|
+
remoteNode.execution_budget_background_ms,
|
|
1553
|
+
1_800_000,
|
|
1554
|
+
),
|
|
1555
|
+
),
|
|
1556
|
+
finalizationBudgetMs: Math.max(
|
|
1557
|
+
30_000,
|
|
1558
|
+
asInt(
|
|
1559
|
+
parseIntEnv("REMOTEBUDDY_FINALIZATION_BUDGET_MS") ?? remoteNode.finalization_budget_ms,
|
|
1560
|
+
120_000,
|
|
1561
|
+
),
|
|
1562
|
+
),
|
|
1563
|
+
crashRestartEnabled:
|
|
1564
|
+
parseBoolEnv("REMOTEBUDDY_CRASH_RESTART_ENABLED") ??
|
|
1565
|
+
asBoolean(remoteNode.crash_restart_enabled, true),
|
|
1566
|
+
crashRestartMaxRestarts: Math.max(
|
|
1567
|
+
0,
|
|
1568
|
+
asInt(
|
|
1569
|
+
parseIntEnv("REMOTEBUDDY_CRASH_RESTART_MAX_RESTARTS") ??
|
|
1570
|
+
remoteNode.crash_restart_max_restarts,
|
|
1571
|
+
3,
|
|
1572
|
+
),
|
|
1573
|
+
),
|
|
1574
|
+
crashRestartBackoffMs: Math.max(
|
|
1575
|
+
0,
|
|
1576
|
+
asInt(
|
|
1577
|
+
parseIntEnv("REMOTEBUDDY_CRASH_RESTART_BACKOFF_MS") ??
|
|
1578
|
+
remoteNode.crash_restart_backoff_ms,
|
|
1579
|
+
3_000,
|
|
1580
|
+
),
|
|
1581
|
+
),
|
|
1582
|
+
memory: {
|
|
1583
|
+
enabled: remoteMemoryEnabled,
|
|
1584
|
+
includeCrossSession: remoteMemoryIncludeCrossSession,
|
|
1585
|
+
maxRecallItems: remoteMemoryMaxRecallItems,
|
|
1586
|
+
maxRecallChars: remoteMemoryMaxRecallChars,
|
|
1587
|
+
maxSummaryChars: remoteMemoryMaxSummaryChars,
|
|
1588
|
+
retentionDays: remoteMemoryRetentionDays,
|
|
1589
|
+
},
|
|
1590
|
+
autonomy: {
|
|
1591
|
+
enabled:
|
|
1592
|
+
parseBoolEnv("REMOTEBUDDY_AUTONOMY_ENABLED") ??
|
|
1593
|
+
asBoolean(remoteAutonomyNode.enabled, true),
|
|
1594
|
+
killSwitchEnabled:
|
|
1595
|
+
parseBoolEnv("REMOTEBUDDY_AUTONOMY_KILL_SWITCH_ENABLED") ??
|
|
1596
|
+
asBoolean(remoteAutonomyNode.kill_switch_enabled, false),
|
|
1597
|
+
tickIntervalMs: Math.max(
|
|
1598
|
+
5_000,
|
|
1599
|
+
asInt(
|
|
1600
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_TICK_INTERVAL_MS") ??
|
|
1601
|
+
remoteAutonomyNode.tick_interval_ms,
|
|
1602
|
+
120_000,
|
|
1603
|
+
),
|
|
1604
|
+
),
|
|
1605
|
+
heartbeatLogMs: Math.max(
|
|
1606
|
+
1_000,
|
|
1607
|
+
asInt(
|
|
1608
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_HEARTBEAT_LOG_MS") ??
|
|
1609
|
+
remoteAutonomyNode.heartbeat_log_ms,
|
|
1610
|
+
30_000,
|
|
1611
|
+
),
|
|
1612
|
+
),
|
|
1613
|
+
visionContextMaxChars: Math.max(
|
|
1614
|
+
1_000,
|
|
1615
|
+
Math.min(
|
|
1616
|
+
1_000_000,
|
|
1617
|
+
asInt(
|
|
1618
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_VISION_CONTEXT_MAX_CHARS") ??
|
|
1619
|
+
remoteAutonomyNode.vision_context_max_chars,
|
|
1620
|
+
65_536,
|
|
1621
|
+
),
|
|
1622
|
+
),
|
|
1623
|
+
),
|
|
1624
|
+
ideationBudgetMs: Math.max(
|
|
1625
|
+
1_000,
|
|
1626
|
+
asInt(
|
|
1627
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_IDEATION_BUDGET_MS") ??
|
|
1628
|
+
remoteAutonomyNode.ideation_budget_ms,
|
|
1629
|
+
20_000,
|
|
1630
|
+
),
|
|
1631
|
+
),
|
|
1632
|
+
llmTimeoutMs: Math.max(
|
|
1633
|
+
1_000,
|
|
1634
|
+
asInt(
|
|
1635
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_LLM_TIMEOUT_MS") ??
|
|
1636
|
+
remoteAutonomyNode.llm_timeout_ms,
|
|
1637
|
+
12_000,
|
|
1638
|
+
),
|
|
1639
|
+
),
|
|
1640
|
+
allowDirtyWorktree:
|
|
1641
|
+
parseBoolEnv("REMOTEBUDDY_AUTONOMY_ALLOW_DIRTY_WORKTREE") ??
|
|
1642
|
+
asBoolean(remoteAutonomyNode.allow_dirty_worktree, false),
|
|
1643
|
+
ideationMaxCandidates: Math.max(
|
|
1644
|
+
1,
|
|
1645
|
+
Math.min(
|
|
1646
|
+
100,
|
|
1647
|
+
asInt(
|
|
1648
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_IDEATION_MAX_CANDIDATES") ??
|
|
1649
|
+
remoteAutonomyNode.ideation_max_candidates,
|
|
1650
|
+
20,
|
|
1651
|
+
),
|
|
1652
|
+
),
|
|
1653
|
+
),
|
|
1654
|
+
topK: Math.max(
|
|
1655
|
+
1,
|
|
1656
|
+
Math.min(
|
|
1657
|
+
20,
|
|
1658
|
+
asInt(parseIntEnv("REMOTEBUDDY_AUTONOMY_TOP_K") ?? remoteAutonomyNode.top_k, 3),
|
|
1659
|
+
),
|
|
1660
|
+
),
|
|
1661
|
+
exploreRate: Math.max(
|
|
1662
|
+
0,
|
|
1663
|
+
Math.min(
|
|
1664
|
+
1,
|
|
1665
|
+
(() => {
|
|
1666
|
+
const parsed = Number.parseFloat(
|
|
1667
|
+
String(
|
|
1668
|
+
firstNonEmpty(
|
|
1669
|
+
process.env.REMOTEBUDDY_AUTONOMY_EXPLORE_RATE,
|
|
1670
|
+
asString(remoteAutonomyNode.explore_rate, "0.3"),
|
|
1671
|
+
"0.3",
|
|
1672
|
+
),
|
|
1673
|
+
),
|
|
1674
|
+
);
|
|
1675
|
+
return Number.isFinite(parsed) ? parsed : 0.3;
|
|
1676
|
+
})(),
|
|
1677
|
+
),
|
|
1678
|
+
),
|
|
1679
|
+
minConfidence: Math.max(
|
|
1680
|
+
0,
|
|
1681
|
+
Math.min(
|
|
1682
|
+
1,
|
|
1683
|
+
(() => {
|
|
1684
|
+
const parsed = Number.parseFloat(
|
|
1685
|
+
String(
|
|
1686
|
+
firstNonEmpty(
|
|
1687
|
+
process.env.REMOTEBUDDY_AUTONOMY_MIN_CONFIDENCE,
|
|
1688
|
+
asString(remoteAutonomyNode.min_confidence, "0.65"),
|
|
1689
|
+
"0.65",
|
|
1690
|
+
),
|
|
1691
|
+
),
|
|
1692
|
+
);
|
|
1693
|
+
return Number.isFinite(parsed) ? parsed : 0.65;
|
|
1694
|
+
})(),
|
|
1695
|
+
),
|
|
1696
|
+
),
|
|
1697
|
+
maxConcurrentObjectives: Math.max(
|
|
1698
|
+
1,
|
|
1699
|
+
asInt(
|
|
1700
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_MAX_CONCURRENT_OBJECTIVES") ??
|
|
1701
|
+
remoteAutonomyNode.max_concurrent_objectives,
|
|
1702
|
+
2,
|
|
1703
|
+
),
|
|
1704
|
+
),
|
|
1705
|
+
maxDispatchPerHour: Math.max(
|
|
1706
|
+
1,
|
|
1707
|
+
asInt(
|
|
1708
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_MAX_DISPATCH_PER_HOUR") ??
|
|
1709
|
+
remoteAutonomyNode.max_dispatch_per_hour,
|
|
1710
|
+
6,
|
|
1711
|
+
),
|
|
1712
|
+
),
|
|
1713
|
+
maxDispatchPerHourByType: remoteAutonomyDispatchByType,
|
|
1714
|
+
maxDispatchPerHourByComponent: remoteAutonomyDispatchByComponent,
|
|
1715
|
+
maxTokenUsagePerHour: Math.max(
|
|
1716
|
+
0,
|
|
1717
|
+
asInt(
|
|
1718
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_MAX_TOKEN_USAGE_PER_HOUR") ??
|
|
1719
|
+
remoteAutonomyNode.max_token_usage_per_hour,
|
|
1720
|
+
120_000,
|
|
1721
|
+
),
|
|
1722
|
+
),
|
|
1723
|
+
maxRuntimeMsPerHour: Math.max(
|
|
1724
|
+
0,
|
|
1725
|
+
asInt(
|
|
1726
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_MAX_RUNTIME_MS_PER_HOUR") ??
|
|
1727
|
+
remoteAutonomyNode.max_runtime_ms_per_hour,
|
|
1728
|
+
5_400_000,
|
|
1729
|
+
),
|
|
1730
|
+
),
|
|
1731
|
+
cooldownFailStreakThreshold: Math.max(
|
|
1732
|
+
1,
|
|
1733
|
+
asInt(
|
|
1734
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_COOLDOWN_FAIL_STREAK_THRESHOLD") ??
|
|
1735
|
+
remoteAutonomyNode.cooldown_fail_streak_threshold,
|
|
1736
|
+
2,
|
|
1737
|
+
),
|
|
1738
|
+
),
|
|
1739
|
+
cooldownMs: Math.max(
|
|
1740
|
+
1_000,
|
|
1741
|
+
asInt(
|
|
1742
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_COOLDOWN_MS") ?? remoteAutonomyNode.cooldown_ms,
|
|
1743
|
+
1_800_000,
|
|
1744
|
+
),
|
|
1745
|
+
),
|
|
1746
|
+
staleObjectiveTtlMs: Math.max(
|
|
1747
|
+
60_000,
|
|
1748
|
+
asInt(
|
|
1749
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_STALE_OBJECTIVE_TTL_MS") ??
|
|
1750
|
+
remoteAutonomyNode.stale_objective_ttl_ms,
|
|
1751
|
+
2_700_000,
|
|
1752
|
+
),
|
|
1753
|
+
),
|
|
1754
|
+
staleObjectiveSweepIntervalMs: Math.max(
|
|
1755
|
+
5_000,
|
|
1756
|
+
asInt(
|
|
1757
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_STALE_OBJECTIVE_SWEEP_INTERVAL_MS") ??
|
|
1758
|
+
remoteAutonomyNode.stale_objective_sweep_interval_ms,
|
|
1759
|
+
60_000,
|
|
1760
|
+
),
|
|
1761
|
+
),
|
|
1762
|
+
autoFreezeFailStreakThreshold: Math.max(
|
|
1763
|
+
1,
|
|
1764
|
+
asInt(
|
|
1765
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_AUTO_FREEZE_FAIL_STREAK_THRESHOLD") ??
|
|
1766
|
+
remoteAutonomyNode.auto_freeze_fail_streak_threshold,
|
|
1767
|
+
3,
|
|
1768
|
+
),
|
|
1769
|
+
),
|
|
1770
|
+
autoFreezeDurationMs: Math.max(
|
|
1771
|
+
60_000,
|
|
1772
|
+
asInt(
|
|
1773
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_AUTO_FREEZE_DURATION_MS") ??
|
|
1774
|
+
remoteAutonomyNode.auto_freeze_duration_ms,
|
|
1775
|
+
1_800_000,
|
|
1776
|
+
),
|
|
1777
|
+
),
|
|
1778
|
+
evaluatorWindowHours: Math.max(
|
|
1779
|
+
1,
|
|
1780
|
+
Math.min(
|
|
1781
|
+
168,
|
|
1782
|
+
asInt(
|
|
1783
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_EVALUATOR_WINDOW_HOURS") ??
|
|
1784
|
+
remoteAutonomyNode.evaluator_window_hours,
|
|
1785
|
+
24,
|
|
1786
|
+
),
|
|
1787
|
+
),
|
|
1788
|
+
),
|
|
1789
|
+
evaluatorMinSamples: Math.max(
|
|
1790
|
+
1,
|
|
1791
|
+
asInt(
|
|
1792
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_EVALUATOR_MIN_SAMPLES") ??
|
|
1793
|
+
remoteAutonomyNode.evaluator_min_samples,
|
|
1794
|
+
6,
|
|
1795
|
+
),
|
|
1796
|
+
),
|
|
1797
|
+
evaluatorMinSuccessRate: Math.max(
|
|
1798
|
+
0,
|
|
1799
|
+
Math.min(
|
|
1800
|
+
1,
|
|
1801
|
+
(() => {
|
|
1802
|
+
const parsed = Number.parseFloat(
|
|
1803
|
+
String(
|
|
1804
|
+
firstNonEmpty(
|
|
1805
|
+
process.env.REMOTEBUDDY_AUTONOMY_EVALUATOR_MIN_SUCCESS_RATE,
|
|
1806
|
+
asString(remoteAutonomyNode.evaluator_min_success_rate, "0.45"),
|
|
1807
|
+
"0.45",
|
|
1808
|
+
),
|
|
1809
|
+
),
|
|
1810
|
+
);
|
|
1811
|
+
return Number.isFinite(parsed) ? parsed : 0.45;
|
|
1812
|
+
})(),
|
|
1813
|
+
),
|
|
1814
|
+
),
|
|
1815
|
+
evaluatorMaxRegretRate: Math.max(
|
|
1816
|
+
0,
|
|
1817
|
+
Math.min(
|
|
1818
|
+
1,
|
|
1819
|
+
(() => {
|
|
1820
|
+
const parsed = Number.parseFloat(
|
|
1821
|
+
String(
|
|
1822
|
+
firstNonEmpty(
|
|
1823
|
+
process.env.REMOTEBUDDY_AUTONOMY_EVALUATOR_MAX_REGRET_RATE,
|
|
1824
|
+
asString(remoteAutonomyNode.evaluator_max_regret_rate, "0.35"),
|
|
1825
|
+
"0.35",
|
|
1826
|
+
),
|
|
1827
|
+
),
|
|
1828
|
+
);
|
|
1829
|
+
return Number.isFinite(parsed) ? parsed : 0.35;
|
|
1830
|
+
})(),
|
|
1831
|
+
),
|
|
1832
|
+
),
|
|
1833
|
+
evaluatorRunIntervalMs: Math.max(
|
|
1834
|
+
10_000,
|
|
1835
|
+
asInt(
|
|
1836
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_EVALUATOR_RUN_INTERVAL_MS") ??
|
|
1837
|
+
remoteAutonomyNode.evaluator_run_interval_ms,
|
|
1838
|
+
120_000,
|
|
1839
|
+
),
|
|
1840
|
+
),
|
|
1841
|
+
alertQueuePendingThreshold: Math.max(
|
|
1842
|
+
1,
|
|
1843
|
+
asInt(
|
|
1844
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_ALERT_QUEUE_PENDING_THRESHOLD") ??
|
|
1845
|
+
remoteAutonomyNode.alert_queue_pending_threshold,
|
|
1846
|
+
20,
|
|
1847
|
+
),
|
|
1848
|
+
),
|
|
1849
|
+
alertJobFailureRateThreshold: Math.max(
|
|
1850
|
+
0,
|
|
1851
|
+
Math.min(
|
|
1852
|
+
1,
|
|
1853
|
+
(() => {
|
|
1854
|
+
const parsed = Number.parseFloat(
|
|
1855
|
+
String(
|
|
1856
|
+
firstNonEmpty(
|
|
1857
|
+
process.env.REMOTEBUDDY_AUTONOMY_ALERT_JOB_FAILURE_RATE_THRESHOLD,
|
|
1858
|
+
asString(remoteAutonomyNode.alert_job_failure_rate_threshold, "0.3"),
|
|
1859
|
+
"0.3",
|
|
1860
|
+
),
|
|
1861
|
+
),
|
|
1862
|
+
);
|
|
1863
|
+
return Number.isFinite(parsed) ? parsed : 0.3;
|
|
1864
|
+
})(),
|
|
1865
|
+
),
|
|
1866
|
+
),
|
|
1867
|
+
alertAutonomyFailureRateThreshold: Math.max(
|
|
1868
|
+
0,
|
|
1869
|
+
Math.min(
|
|
1870
|
+
1,
|
|
1871
|
+
(() => {
|
|
1872
|
+
const parsed = Number.parseFloat(
|
|
1873
|
+
String(
|
|
1874
|
+
firstNonEmpty(
|
|
1875
|
+
process.env.REMOTEBUDDY_AUTONOMY_ALERT_AUTONOMY_FAILURE_RATE_THRESHOLD,
|
|
1876
|
+
asString(remoteAutonomyNode.alert_autonomy_failure_rate_threshold, "0.45"),
|
|
1877
|
+
"0.45",
|
|
1878
|
+
),
|
|
1879
|
+
),
|
|
1880
|
+
);
|
|
1881
|
+
return Number.isFinite(parsed) ? parsed : 0.45;
|
|
1882
|
+
})(),
|
|
1883
|
+
),
|
|
1884
|
+
),
|
|
1885
|
+
allowReadAnywhere:
|
|
1886
|
+
parseBoolEnv("REMOTEBUDDY_AUTONOMY_ALLOW_READ_ANYWHERE") ??
|
|
1887
|
+
asBoolean(remoteAutonomyNode.allow_read_anywhere, false),
|
|
1888
|
+
prFeedbackCommentRows: Math.max(
|
|
1889
|
+
1,
|
|
1890
|
+
Math.min(
|
|
1891
|
+
200,
|
|
1892
|
+
asInt(
|
|
1893
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_PR_FEEDBACK_COMMENT_ROWS") ??
|
|
1894
|
+
remoteAutonomyNode.pr_feedback_comment_rows,
|
|
1895
|
+
16,
|
|
1896
|
+
),
|
|
1897
|
+
),
|
|
1898
|
+
),
|
|
1899
|
+
prFeedbackCommentChars: Math.max(
|
|
1900
|
+
32,
|
|
1901
|
+
Math.min(
|
|
1902
|
+
20_000,
|
|
1903
|
+
asInt(
|
|
1904
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_PR_FEEDBACK_COMMENT_CHARS") ??
|
|
1905
|
+
remoteAutonomyNode.pr_feedback_comment_chars,
|
|
1906
|
+
600,
|
|
1907
|
+
),
|
|
1908
|
+
),
|
|
1909
|
+
),
|
|
1910
|
+
prFeedbackSummaryChars: Math.max(
|
|
1911
|
+
32,
|
|
1912
|
+
Math.min(
|
|
1913
|
+
20_000,
|
|
1914
|
+
asInt(
|
|
1915
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_PR_FEEDBACK_SUMMARY_CHARS") ??
|
|
1916
|
+
remoteAutonomyNode.pr_feedback_summary_chars,
|
|
1917
|
+
600,
|
|
1918
|
+
),
|
|
1919
|
+
),
|
|
1920
|
+
),
|
|
1921
|
+
questionTtlMs: Math.max(
|
|
1922
|
+
60_000,
|
|
1923
|
+
asInt(
|
|
1924
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_QUESTION_TTL_MS") ??
|
|
1925
|
+
remoteAutonomyNode.question_ttl_ms,
|
|
1926
|
+
259_200_000,
|
|
1927
|
+
),
|
|
1928
|
+
),
|
|
1929
|
+
policyVersion: firstNonEmpty(
|
|
1930
|
+
process.env.REMOTEBUDDY_AUTONOMY_POLICY_VERSION,
|
|
1931
|
+
asString(remoteAutonomyNode.policy_version, "policy-v3.3"),
|
|
1932
|
+
"policy-v3.3",
|
|
1933
|
+
),
|
|
1934
|
+
impactModelVersion: firstNonEmpty(
|
|
1935
|
+
process.env.REMOTEBUDDY_AUTONOMY_IMPACT_MODEL_VERSION,
|
|
1936
|
+
asString(remoteAutonomyNode.impact_model_version, "impact-v1"),
|
|
1937
|
+
"impact-v1",
|
|
1938
|
+
),
|
|
1939
|
+
replay: {
|
|
1940
|
+
storePromptPayloads:
|
|
1941
|
+
parseBoolEnv("REMOTEBUDDY_AUTONOMY_REPLAY_STORE_PROMPT_PAYLOADS") ??
|
|
1942
|
+
asBoolean(remoteAutonomyReplayNode.store_prompt_payloads, false),
|
|
1943
|
+
maxRunsWithPayloads: Math.max(
|
|
1944
|
+
0,
|
|
1945
|
+
asInt(
|
|
1946
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_REPLAY_MAX_RUNS_WITH_PAYLOADS") ??
|
|
1947
|
+
remoteAutonomyReplayNode.max_runs_with_payloads,
|
|
1948
|
+
50,
|
|
1949
|
+
),
|
|
1950
|
+
),
|
|
1951
|
+
maxPayloadBytes: Math.max(
|
|
1952
|
+
1024,
|
|
1953
|
+
asInt(
|
|
1954
|
+
parseIntEnv("REMOTEBUDDY_AUTONOMY_REPLAY_MAX_PAYLOAD_BYTES") ??
|
|
1955
|
+
remoteAutonomyReplayNode.max_payload_bytes,
|
|
1956
|
+
262_144,
|
|
1957
|
+
),
|
|
1958
|
+
),
|
|
1959
|
+
},
|
|
1960
|
+
},
|
|
1961
|
+
llm: remoteLlm,
|
|
1962
|
+
},
|
|
1963
|
+
workerpals: {
|
|
1964
|
+
pollMs: workerPollMs,
|
|
1965
|
+
heartbeatMs: workerHeartbeatMs,
|
|
1966
|
+
executor: workerExecutor,
|
|
1967
|
+
openhandsPython: workerOpenHandsPython,
|
|
1968
|
+
openhandsTimeoutMs: workerOpenHandsTimeoutMs,
|
|
1969
|
+
miniswePython: workerMiniswePython,
|
|
1970
|
+
minisweTimeoutMs: workerMinisweTimeoutMs,
|
|
1971
|
+
openaiCodexPython: workerOpenAICodexPython,
|
|
1972
|
+
openaiCodexTimeoutMs: workerOpenAICodexTimeoutMs,
|
|
1973
|
+
openhandsStuckGuardEnabled: workerOpenHandsStuckGuardEnabled,
|
|
1974
|
+
openhandsStuckGuardExploreLimit: workerOpenHandsStuckGuardExploreLimit,
|
|
1975
|
+
openhandsStuckGuardMinElapsedMs: workerOpenHandsStuckGuardMinElapsedMs,
|
|
1976
|
+
openhandsStuckGuardBroadScanLimit: workerOpenHandsStuckGuardBroadScanLimit,
|
|
1977
|
+
openhandsStuckGuardNoProgressMaxMs: workerOpenHandsStuckGuardNoProgressMaxMs,
|
|
1978
|
+
openhandsAutoSteerEnabled: workerOpenHandsAutoSteerEnabled,
|
|
1979
|
+
openhandsAutoSteerInitialDelaySec: workerOpenHandsAutoSteerInitialDelaySec,
|
|
1980
|
+
openhandsAutoSteerIntervalSec: workerOpenHandsAutoSteerIntervalSec,
|
|
1981
|
+
openhandsAutoSteerMaxNudges: workerOpenHandsAutoSteerMaxNudges,
|
|
1982
|
+
requirePush: workerRequirePush,
|
|
1983
|
+
pushAgentBranch: workerPushAgentBranch,
|
|
1984
|
+
requireDocker:
|
|
1985
|
+
parseBoolEnv("WORKERPALS_REQUIRE_DOCKER") ?? asBoolean(workerNode.require_docker, false),
|
|
1986
|
+
skipDockerSelfCheck: workerSkipDockerSelfCheck,
|
|
1987
|
+
dockerImage: firstNonEmpty(
|
|
1988
|
+
process.env.WORKERPALS_DOCKER_IMAGE,
|
|
1989
|
+
asString(workerNode.docker_image, "pushpals-worker-sandbox:latest"),
|
|
1990
|
+
"pushpals-worker-sandbox:latest",
|
|
1991
|
+
),
|
|
1992
|
+
dockerTimeoutMs: Math.max(
|
|
1993
|
+
10_000,
|
|
1994
|
+
asInt(
|
|
1995
|
+
parseIntEnv("WORKERPALS_DOCKER_TIMEOUT_MS") ?? workerNode.docker_timeout_ms,
|
|
1996
|
+
7_260_000,
|
|
1997
|
+
),
|
|
1998
|
+
),
|
|
1999
|
+
dockerIdleTimeoutMs: Math.max(
|
|
2000
|
+
0,
|
|
2001
|
+
asInt(
|
|
2002
|
+
parseIntEnv("WORKERPALS_DOCKER_IDLE_TIMEOUT_MS") ?? workerNode.docker_idle_timeout_ms,
|
|
2003
|
+
600_000,
|
|
2004
|
+
),
|
|
2005
|
+
),
|
|
2006
|
+
dockerAgentStartupTimeoutMs: workerDockerAgentStartupTimeoutMs,
|
|
2007
|
+
dockerWarmMaxAttempts: workerDockerWarmMaxAttempts,
|
|
2008
|
+
dockerWarmRetryBackoffMs: workerDockerWarmRetryBackoffMs,
|
|
2009
|
+
dockerJobMaxAttempts: workerDockerJobMaxAttempts,
|
|
2010
|
+
dockerJobRetryBackoffMs: workerDockerJobRetryBackoffMs,
|
|
2011
|
+
dockerWarmMemoryMb: workerDockerWarmMemoryMb,
|
|
2012
|
+
dockerWarmCpus: workerDockerWarmCpus,
|
|
2013
|
+
fileModifyingJobs: workerFileModifyingJobs,
|
|
2014
|
+
outputMaxChars: workerOutputMaxChars,
|
|
2015
|
+
outputMaxLines: workerOutputMaxLines,
|
|
2016
|
+
outputMaxHeadLines: workerOutputMaxHeadLines,
|
|
2017
|
+
qualityMaxAutoRevisions: workerQualityMaxAutoRevisions,
|
|
2018
|
+
qualityValidationStepTimeoutMs: workerQualityValidationStepTimeoutMs,
|
|
2019
|
+
qualityCriticTimeoutMs: workerQualityCriticTimeoutMs,
|
|
2020
|
+
qualitySoftPassOnExhausted: workerQualitySoftPassOnExhausted,
|
|
2021
|
+
qualityCriticMinScore: workerQualityCriticMinScore,
|
|
2022
|
+
qualityCriticMaxDiffChars: workerQualityCriticMaxDiffChars,
|
|
2023
|
+
qualityCriticMaxValidationOutputChars: workerQualityCriticMaxValidationOutputChars,
|
|
2024
|
+
executorResultPrefix: workerExecutorResultPrefix,
|
|
2025
|
+
dockerNetworkMode: asString(
|
|
2026
|
+
process.env.WORKERPALS_DOCKER_NETWORK_MODE ?? workerNode.docker_network_mode,
|
|
2027
|
+
"bridge",
|
|
2028
|
+
),
|
|
2029
|
+
baseRef: firstNonEmpty(
|
|
2030
|
+
process.env.WORKERPALS_BASE_REF,
|
|
2031
|
+
asString(workerNode.base_ref, "origin/main_agents"),
|
|
2032
|
+
"origin/main_agents",
|
|
2033
|
+
),
|
|
2034
|
+
labels: firstNonEmpty(process.env.WORKERPALS_LABELS)
|
|
2035
|
+
? firstNonEmpty(process.env.WORKERPALS_LABELS)
|
|
2036
|
+
.split(",")
|
|
2037
|
+
.map((value) => value.trim())
|
|
2038
|
+
.filter(Boolean)
|
|
2039
|
+
: asStringArray(workerNode.labels),
|
|
2040
|
+
failureCooldownMs: Math.max(
|
|
2041
|
+
0,
|
|
2042
|
+
asInt(
|
|
2043
|
+
parseIntEnv("WORKERPALS_FAILURE_COOLDOWN_MS") ??
|
|
2044
|
+
parseIntEnv("WORKERPALS_DOCKER_FAILURE_COOLDOWN_MS") ??
|
|
2045
|
+
workerNode.failure_cooldown_ms,
|
|
2046
|
+
20_000,
|
|
2047
|
+
),
|
|
2048
|
+
),
|
|
2049
|
+
llm: workerLlm,
|
|
2050
|
+
},
|
|
2051
|
+
sourceControlManager: {
|
|
2052
|
+
repoPath: scmRepoPath,
|
|
2053
|
+
remote: scmRemote,
|
|
2054
|
+
mainBranch: scmMainBranch,
|
|
2055
|
+
baseBranch: scmBaseBranch,
|
|
2056
|
+
branchPrefix: scmBranchPrefix,
|
|
2057
|
+
pollIntervalSeconds: scmPollIntervalSeconds,
|
|
2058
|
+
checks: scmChecks,
|
|
2059
|
+
stateDir: scmStateDir,
|
|
2060
|
+
port: scmPort,
|
|
2061
|
+
deleteAfterMerge: scmDeleteAfterMerge,
|
|
2062
|
+
maxAttempts: scmMaxAttempts,
|
|
2063
|
+
mergeStrategy: scmMergeStrategy,
|
|
2064
|
+
pushMainAfterMerge: scmPushMainAfterMerge,
|
|
2065
|
+
openPrAfterPush: scmOpenPrAfterPush,
|
|
2066
|
+
prBaseBranch: scmPrBaseBranch,
|
|
2067
|
+
prTitle: scmPrTitle || null,
|
|
2068
|
+
prBody: scmPrBody || null,
|
|
2069
|
+
prDraft: scmPrDraft,
|
|
2070
|
+
statusHeartbeatMs: scmStatusHeartbeatMs,
|
|
2071
|
+
skipCleanCheck: scmSkipCleanCheck,
|
|
2072
|
+
autoCreateMainBranch: scmAutoCreateMainBranch,
|
|
2073
|
+
reviewAgent: {
|
|
2074
|
+
enabled: scmReviewAgentEnabled,
|
|
2075
|
+
pollIntervalMs: scmReviewAgentPollIntervalMs,
|
|
2076
|
+
reviewerMdPath: scmReviewAgentReviewerMdPath,
|
|
2077
|
+
passThreshold: scmReviewAgentPassThreshold,
|
|
2078
|
+
maxPrCommentsBeforeGiveUp: scmReviewAgentMaxPrCommentsBeforeGiveUp,
|
|
2079
|
+
mergeMethod: scmReviewAgentMergeMethod,
|
|
2080
|
+
codexBin: scmReviewAgentCodexBin,
|
|
2081
|
+
codexAuthMode: scmReviewAgentCodexAuthMode,
|
|
2082
|
+
codexHomeDir: scmReviewAgentCodexHomeDir,
|
|
2083
|
+
codexTimeoutMs: scmReviewAgentCodexTimeoutMs,
|
|
2084
|
+
},
|
|
2085
|
+
},
|
|
2086
|
+
startup: {
|
|
2087
|
+
workerImageRebuild: startupWorkerImageRebuild,
|
|
2088
|
+
logConfigOnStart: startupLogConfigOnStart,
|
|
2089
|
+
syncIntegrationWithMain: startupSyncIntegrationWithMain,
|
|
2090
|
+
skipLlmPreflight: startupSkipLlmPreflight,
|
|
2091
|
+
autoStartLmStudio: startupAutoStartLmStudio,
|
|
2092
|
+
lmStudioReadyTimeoutMs: startupLmStudioReadyTimeoutMs,
|
|
2093
|
+
lmStudioCli: startupLmStudioCli,
|
|
2094
|
+
lmStudioPort: startupLmStudioPort,
|
|
2095
|
+
lmStudioStartArgs: startupLmStudioStartArgs,
|
|
2096
|
+
startupWarmup,
|
|
2097
|
+
startupWarmupTimeoutMs: startupWarmupTimeoutMs,
|
|
2098
|
+
startupWarmupPollMs: startupWarmupPollMs,
|
|
2099
|
+
allowExternalClean: startupAllowExternalClean,
|
|
2100
|
+
portPreflight: startupPortPreflight,
|
|
2101
|
+
portConflictPolicy: startupPortConflictPolicy,
|
|
2102
|
+
},
|
|
2103
|
+
client: {
|
|
2104
|
+
localAgentUrl: normalizeLoopbackHttpUrl(
|
|
2105
|
+
firstNonEmpty(
|
|
2106
|
+
process.env.EXPO_PUBLIC_LOCAL_AGENT_URL,
|
|
2107
|
+
asString(clientNode.local_agent_url, `http://127.0.0.1:${localPort}`),
|
|
2108
|
+
`http://127.0.0.1:${localPort}`,
|
|
2109
|
+
),
|
|
2110
|
+
localPort,
|
|
2111
|
+
),
|
|
2112
|
+
traceTailLines: Math.max(
|
|
2113
|
+
10,
|
|
2114
|
+
asInt(
|
|
2115
|
+
parseIntEnv("EXPO_PUBLIC_PUSHPALS_TRACE_TAIL_LINES") ?? clientNode.trace_tail_lines,
|
|
2116
|
+
100,
|
|
2117
|
+
),
|
|
2118
|
+
),
|
|
2119
|
+
},
|
|
2120
|
+
};
|
|
2121
|
+
|
|
2122
|
+
cachedConfig = config;
|
|
2123
|
+
cachedConfigKey = cacheKey;
|
|
2124
|
+
return config;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
function sanitizeConfigString(value: string): string {
|
|
2128
|
+
let out = String(value ?? "");
|
|
2129
|
+
if (!out) return out;
|
|
2130
|
+
// redact URL userinfo credentials: https://user:pass@host -> https://***@host
|
|
2131
|
+
out = out.replace(/(https?:\/\/)[^@\s/]+@/gi, "$1***@");
|
|
2132
|
+
// redact malformed/encoded scheme userinfo from legacy rewrite bugs: https%3A//user%3Apass@host
|
|
2133
|
+
out = out.replace(/https%3a\/\/[^@\s/]+@/gi, "https%3A//***@");
|
|
2134
|
+
// redact bearer tokens
|
|
2135
|
+
out = out.replace(/\b(Bearer\s+)[A-Za-z0-9._\-:+/=]+\b/gi, "$1***");
|
|
2136
|
+
// redact common token formats
|
|
2137
|
+
out = out.replace(/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g, "gh***");
|
|
2138
|
+
out = out.replace(/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g, "github_pat_***");
|
|
2139
|
+
out = out.replace(/\bglpat-[A-Za-z0-9\-_]{20,}\b/gi, "glpat-***");
|
|
2140
|
+
out = out.replace(/\bsk-[A-Za-z0-9]{20,}\b/g, "sk-***");
|
|
2141
|
+
return out;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
function sanitizeConfigValueForLogging(
|
|
2145
|
+
value: unknown,
|
|
2146
|
+
parentKey = "",
|
|
2147
|
+
): unknown {
|
|
2148
|
+
if (
|
|
2149
|
+
typeof value === "string" ||
|
|
2150
|
+
typeof value === "number" ||
|
|
2151
|
+
typeof value === "boolean" ||
|
|
2152
|
+
value == null
|
|
2153
|
+
) {
|
|
2154
|
+
if (typeof value === "string") {
|
|
2155
|
+
if (SENSITIVE_CONFIG_KEY_PATTERN.test(parentKey)) {
|
|
2156
|
+
return value.trim() ? REDACTED_LOG_VALUE : "";
|
|
2157
|
+
}
|
|
2158
|
+
return sanitizeConfigString(value);
|
|
2159
|
+
}
|
|
2160
|
+
return value;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
if (Array.isArray(value)) {
|
|
2164
|
+
return value.map((entry) => sanitizeConfigValueForLogging(entry, parentKey));
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
if (typeof value === "object") {
|
|
2168
|
+
const out: Record<string, unknown> = {};
|
|
2169
|
+
for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
|
|
2170
|
+
out[key] = sanitizeConfigValueForLogging(entry, key);
|
|
2171
|
+
}
|
|
2172
|
+
return out;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
return String(value);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
export function sanitizePushPalsConfigForLogging<T>(value: T): T {
|
|
2179
|
+
return sanitizeConfigValueForLogging(value) as T;
|
|
2180
|
+
}
|