@renxqoo/renx-code 0.0.9 → 0.0.12
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/README.md +31 -143
- package/bin/renx.cjs +79 -42
- package/bin/renx.exe +0 -0
- package/package.json +10 -28
- package/src/App.tsx +0 -297
- package/src/agent/runtime/event-format.ts +0 -258
- package/src/agent/runtime/model-types.ts +0 -13
- package/src/agent/runtime/runtime.context-usage.test.ts +0 -192
- package/src/agent/runtime/runtime.error-handling.test.ts +0 -235
- package/src/agent/runtime/runtime.simple.test.ts +0 -16
- package/src/agent/runtime/runtime.test.ts +0 -296
- package/src/agent/runtime/runtime.ts +0 -875
- package/src/agent/runtime/runtime.usage-forwarding.test.ts +0 -228
- package/src/agent/runtime/source-modules.test.ts +0 -38
- package/src/agent/runtime/source-modules.ts +0 -370
- package/src/agent/runtime/tool-call-buffer.test.ts +0 -65
- package/src/agent/runtime/tool-call-buffer.ts +0 -60
- package/src/agent/runtime/tool-confirmation.test.ts +0 -56
- package/src/agent/runtime/tool-confirmation.ts +0 -15
- package/src/agent/runtime/types.ts +0 -99
- package/src/commands/slash-commands.test.ts +0 -216
- package/src/commands/slash-commands.ts +0 -64
- package/src/components/chat/assistant-reply.test.tsx +0 -47
- package/src/components/chat/assistant-reply.tsx +0 -136
- package/src/components/chat/assistant-segment.test.ts +0 -99
- package/src/components/chat/assistant-segment.tsx +0 -125
- package/src/components/chat/assistant-tool-group.tsx +0 -900
- package/src/components/chat/code-block.test.tsx +0 -206
- package/src/components/chat/code-block.tsx +0 -313
- package/src/components/chat/prompt-card.tsx +0 -81
- package/src/components/chat/segment-groups.test.ts +0 -52
- package/src/components/chat/segment-groups.ts +0 -106
- package/src/components/chat/turn-item.tsx +0 -39
- package/src/components/conversation-panel.tsx +0 -43
- package/src/components/file-mention-menu.tsx +0 -77
- package/src/components/file-picker-dialog.tsx +0 -206
- package/src/components/footer-hints.tsx +0 -75
- package/src/components/model-picker-dialog.tsx +0 -248
- package/src/components/prompt.tsx +0 -233
- package/src/components/slash-command-menu.tsx +0 -65
- package/src/components/tool-confirm-dialog-content.test.ts +0 -103
- package/src/components/tool-confirm-dialog-content.ts +0 -186
- package/src/components/tool-confirm-dialog.tsx +0 -187
- package/src/components/tool-display-config.ts +0 -119
- package/src/context-usage-regressions.test.ts +0 -26
- package/src/files/attachment-capabilities.test.ts +0 -30
- package/src/files/attachment-capabilities.ts +0 -50
- package/src/files/attachment-content.ts +0 -153
- package/src/files/file-mention-query.test.ts +0 -34
- package/src/files/file-mention-query.ts +0 -32
- package/src/files/prompt-display.ts +0 -13
- package/src/files/types.ts +0 -5
- package/src/files/workspace-files.ts +0 -61
- package/src/hooks/agent-event-handlers.test.ts +0 -207
- package/src/hooks/agent-event-handlers.ts +0 -196
- package/src/hooks/chat-local-replies.fixed.test.ts +0 -119
- package/src/hooks/chat-local-replies.test.ts +0 -153
- package/src/hooks/chat-local-replies.ts +0 -63
- package/src/hooks/turn-updater.test.ts +0 -70
- package/src/hooks/turn-updater.ts +0 -166
- package/src/hooks/use-agent-chat.context.test.ts +0 -10
- package/src/hooks/use-agent-chat.status.test.ts +0 -14
- package/src/hooks/use-agent-chat.test.ts +0 -80
- package/src/hooks/use-agent-chat.ts +0 -621
- package/src/hooks/use-file-mention-menu.ts +0 -196
- package/src/hooks/use-file-picker.ts +0 -185
- package/src/hooks/use-model-picker.ts +0 -196
- package/src/hooks/use-slash-command-menu.ts +0 -154
- package/src/index.tsx +0 -55
- package/src/runtime/clipboard.test.ts +0 -43
- package/src/runtime/clipboard.ts +0 -89
- package/src/runtime/exit.test.ts +0 -177
- package/src/runtime/exit.ts +0 -98
- package/src/runtime/runtime-support.test.ts +0 -31
- package/src/runtime/terminal-theme.test.ts +0 -55
- package/src/runtime/terminal-theme.ts +0 -196
- package/src/types/chat.ts +0 -32
- package/src/types/message-content.ts +0 -48
- package/src/ui/open-code-theme.ts +0 -176
- package/src/ui/opencode-markdown.ts +0 -211
- package/src/ui/theme.simple.test.ts +0 -52
- package/src/ui/theme.test.ts +0 -151
- package/src/ui/theme.ts +0 -152
- package/src/utils/time.test.ts +0 -144
- package/src/utils/time.ts +0 -7
- package/tsconfig.json +0 -30
- package/vendor/agent-root/src/agent/ENTERPRISE_ACCEPTANCE_CHECKLIST.md +0 -95
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.html +0 -1345
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.md +0 -1353
- package/vendor/agent-root/src/agent/ERROR_CONTRACT.md +0 -60
- package/vendor/agent-root/src/agent/TEST_COVERAGE_ANALYSIS.md +0 -278
- package/vendor/agent-root/src/agent/__test__/error-contract.test.ts +0 -72
- package/vendor/agent-root/src/agent/__test__/types.test.ts +0 -137
- package/vendor/agent-root/src/agent/agent/__test__/abort-runtime.test.ts +0 -83
- package/vendor/agent-root/src/agent/agent/__test__/callback-safety.test.ts +0 -34
- package/vendor/agent-root/src/agent/agent/__test__/compaction.test.ts +0 -323
- package/vendor/agent-root/src/agent/agent/__test__/concurrency.test.ts +0 -290
- package/vendor/agent-root/src/agent/agent/__test__/error-normalizer.test.ts +0 -377
- package/vendor/agent-root/src/agent/agent/__test__/error.test.ts +0 -212
- package/vendor/agent-root/src/agent/agent/__test__/fault-injection.test.ts +0 -295
- package/vendor/agent-root/src/agent/agent/__test__/index.test.ts +0 -3607
- package/vendor/agent-root/src/agent/agent/__test__/logger.test.ts +0 -35
- package/vendor/agent-root/src/agent/agent/__test__/message-utils.test.ts +0 -517
- package/vendor/agent-root/src/agent/agent/__test__/telemetry.test.ts +0 -97
- package/vendor/agent-root/src/agent/agent/__test__/timeout-budget.test.ts +0 -479
- package/vendor/agent-root/src/agent/agent/__test__/tool-call-merge.test.ts +0 -80
- package/vendor/agent-root/src/agent/agent/__test__/tool-execution-ledger.test.ts +0 -76
- package/vendor/agent-root/src/agent/agent/__test__/write-buffer.test.ts +0 -173
- package/vendor/agent-root/src/agent/agent/__test__/write-file-session.test.ts +0 -109
- package/vendor/agent-root/src/agent/agent/abort-runtime.ts +0 -71
- package/vendor/agent-root/src/agent/agent/callback-safety.ts +0 -33
- package/vendor/agent-root/src/agent/agent/compaction.ts +0 -291
- package/vendor/agent-root/src/agent/agent/concurrency.ts +0 -103
- package/vendor/agent-root/src/agent/agent/error-normalizer.ts +0 -190
- package/vendor/agent-root/src/agent/agent/error.ts +0 -198
- package/vendor/agent-root/src/agent/agent/index.ts +0 -1772
- package/vendor/agent-root/src/agent/agent/logger.ts +0 -65
- package/vendor/agent-root/src/agent/agent/message-utils.ts +0 -101
- package/vendor/agent-root/src/agent/agent/stream-events.ts +0 -61
- package/vendor/agent-root/src/agent/agent/telemetry.ts +0 -123
- package/vendor/agent-root/src/agent/agent/timeout-budget.ts +0 -227
- package/vendor/agent-root/src/agent/agent/tool-call-merge.ts +0 -111
- package/vendor/agent-root/src/agent/agent/tool-execution-ledger.ts +0 -164
- package/vendor/agent-root/src/agent/agent/write-buffer.ts +0 -188
- package/vendor/agent-root/src/agent/agent/write-file-session.ts +0 -238
- package/vendor/agent-root/src/agent/app/__test__/agent-app-service.test.ts +0 -1053
- package/vendor/agent-root/src/agent/app/__test__/minimal-agent-application.test.ts +0 -158
- package/vendor/agent-root/src/agent/app/__test__/sqlite-agent-app-store.test.ts +0 -437
- package/vendor/agent-root/src/agent/app/agent-app-service.ts +0 -748
- package/vendor/agent-root/src/agent/app/contracts.ts +0 -109
- package/vendor/agent-root/src/agent/app/index.ts +0 -5
- package/vendor/agent-root/src/agent/app/minimal-agent-application.ts +0 -151
- package/vendor/agent-root/src/agent/app/ports.ts +0 -72
- package/vendor/agent-root/src/agent/app/sqlite-agent-app-store.ts +0 -1182
- package/vendor/agent-root/src/agent/app/sqlite-client.ts +0 -177
- package/vendor/agent-root/src/agent/docs/cli-app-layer/00-README.md +0 -36
- package/vendor/agent-root/src/agent/docs/cli-app-layer/01-scope-and-goals.md +0 -33
- package/vendor/agent-root/src/agent/docs/cli-app-layer/02-architecture-overview.md +0 -40
- package/vendor/agent-root/src/agent/docs/cli-app-layer/03-domain-model-and-contracts.md +0 -91
- package/vendor/agent-root/src/agent/docs/cli-app-layer/04-ports-and-interfaces.md +0 -116
- package/vendor/agent-root/src/agent/docs/cli-app-layer/05-run-orchestration-and-state-machine.md +0 -52
- package/vendor/agent-root/src/agent/docs/cli-app-layer/06-cli-commands-and-ux.md +0 -53
- package/vendor/agent-root/src/agent/docs/cli-app-layer/07-storage-design-local.md +0 -52
- package/vendor/agent-root/src/agent/docs/cli-app-layer/08-error-and-observability.md +0 -40
- package/vendor/agent-root/src/agent/docs/cli-app-layer/09-security-and-policy-boundary.md +0 -19
- package/vendor/agent-root/src/agent/docs/cli-app-layer/10-test-plan-and-acceptance.md +0 -28
- package/vendor/agent-root/src/agent/docs/cli-app-layer/11-implementation-phases.md +0 -26
- package/vendor/agent-root/src/agent/docs/cli-app-layer/12-open-questions-and-risks.md +0 -30
- package/vendor/agent-root/src/agent/docs/cli-app-layer/13-sqlite-schema-fields-and-rationale.md +0 -567
- package/vendor/agent-root/src/agent/docs/cli-app-layer/14-project-flow-mermaid.md +0 -583
- package/vendor/agent-root/src/agent/docs/cli-app-layer/15-openclaw-style-project-blueprint.md +0 -972
- package/vendor/agent-root/src/agent/error-contract.ts +0 -154
- package/vendor/agent-root/src/agent/prompts/system.ts +0 -246
- package/vendor/agent-root/src/agent/prompts/system1.ts +0 -208
- package/vendor/agent-root/src/agent/storage/__test__/file-history-store.test.ts +0 -98
- package/vendor/agent-root/src/agent/storage/file-history-store.ts +0 -313
- package/vendor/agent-root/src/agent/storage/file-storage-config.ts +0 -94
- package/vendor/agent-root/src/agent/storage/file-system.ts +0 -31
- package/vendor/agent-root/src/agent/storage/file-write-service.ts +0 -21
- package/vendor/agent-root/src/agent/tool/__test__/base-tool.test.ts +0 -413
- package/vendor/agent-root/src/agent/tool/__test__/bash-policy.test.ts +0 -356
- package/vendor/agent-root/src/agent/tool/__test__/bash.mocked-coverage.test.ts +0 -375
- package/vendor/agent-root/src/agent/tool/__test__/bash.test.ts +0 -372
- package/vendor/agent-root/src/agent/tool/__test__/error.test.ts +0 -108
- package/vendor/agent-root/src/agent/tool/__test__/file-edit-tool.test.ts +0 -258
- package/vendor/agent-root/src/agent/tool/__test__/file-history-tools.test.ts +0 -121
- package/vendor/agent-root/src/agent/tool/__test__/file-read-tool.test.ts +0 -210
- package/vendor/agent-root/src/agent/tool/__test__/glob.test.ts +0 -139
- package/vendor/agent-root/src/agent/tool/__test__/grep.mocked-coverage.test.ts +0 -456
- package/vendor/agent-root/src/agent/tool/__test__/grep.test.ts +0 -192
- package/vendor/agent-root/src/agent/tool/__test__/lsp.test.ts +0 -300
- package/vendor/agent-root/src/agent/tool/__test__/outside-workspace-confirmation.test.ts +0 -214
- package/vendor/agent-root/src/agent/tool/__test__/path-security.test.ts +0 -336
- package/vendor/agent-root/src/agent/tool/__test__/skill-loader.test.ts +0 -494
- package/vendor/agent-root/src/agent/tool/__test__/skill-parser.test.ts +0 -543
- package/vendor/agent-root/src/agent/tool/__test__/skill-tool.test.ts +0 -172
- package/vendor/agent-root/src/agent/tool/__test__/task-concurrency-and-version.test.ts +0 -116
- package/vendor/agent-root/src/agent/tool/__test__/task-create-get-list-update.test.ts +0 -267
- package/vendor/agent-root/src/agent/tool/__test__/task-create.test.ts +0 -519
- package/vendor/agent-root/src/agent/tool/__test__/task-errors.test.ts +0 -225
- package/vendor/agent-root/src/agent/tool/__test__/task-output-blocking.test.ts +0 -223
- package/vendor/agent-root/src/agent/tool/__test__/task-output.test.ts +0 -184
- package/vendor/agent-root/src/agent/tool/__test__/task-parent-abort.test.ts +0 -287
- package/vendor/agent-root/src/agent/tool/__test__/task-real-runner-adapter.test.ts +0 -190
- package/vendor/agent-root/src/agent/tool/__test__/task-run-lifecycle.test.ts +0 -352
- package/vendor/agent-root/src/agent/tool/__test__/task-store-runner-branches.test.ts +0 -395
- package/vendor/agent-root/src/agent/tool/__test__/task-store.test.ts +0 -391
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config-integration.test.ts +0 -176
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config.test.ts +0 -68
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-core-edges.test.ts +0 -630
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-runtime-edges.test.ts +0 -732
- package/vendor/agent-root/src/agent/tool/__test__/task-types.test.ts +0 -494
- package/vendor/agent-root/src/agent/tool/__test__/task-utils-branches.test.ts +0 -175
- package/vendor/agent-root/src/agent/tool/__test__/tool-manager.test.ts +0 -505
- package/vendor/agent-root/src/agent/tool/__test__/types.test.ts +0 -55
- package/vendor/agent-root/src/agent/tool/__test__/web-fetch.test.ts +0 -244
- package/vendor/agent-root/src/agent/tool/__test__/web-search.test.ts +0 -290
- package/vendor/agent-root/src/agent/tool/__test__/write-file.test.ts +0 -368
- package/vendor/agent-root/src/agent/tool/base-tool.ts +0 -345
- package/vendor/agent-root/src/agent/tool/bash-policy.ts +0 -636
- package/vendor/agent-root/src/agent/tool/bash.ts +0 -688
- package/vendor/agent-root/src/agent/tool/error.ts +0 -131
- package/vendor/agent-root/src/agent/tool/file-edit-tool.ts +0 -264
- package/vendor/agent-root/src/agent/tool/file-history-list.ts +0 -103
- package/vendor/agent-root/src/agent/tool/file-history-restore.ts +0 -149
- package/vendor/agent-root/src/agent/tool/file-read-tool.ts +0 -211
- package/vendor/agent-root/src/agent/tool/glob.ts +0 -171
- package/vendor/agent-root/src/agent/tool/grep.ts +0 -496
- package/vendor/agent-root/src/agent/tool/lsp.ts +0 -481
- package/vendor/agent-root/src/agent/tool/path-security.ts +0 -117
- package/vendor/agent-root/src/agent/tool/search/common.ts +0 -153
- package/vendor/agent-root/src/agent/tool/skill/index.ts +0 -13
- package/vendor/agent-root/src/agent/tool/skill/loader.ts +0 -229
- package/vendor/agent-root/src/agent/tool/skill/parser.ts +0 -124
- package/vendor/agent-root/src/agent/tool/skill/types.ts +0 -27
- package/vendor/agent-root/src/agent/tool/skill-tool.ts +0 -143
- package/vendor/agent-root/src/agent/tool/task-create.ts +0 -186
- package/vendor/agent-root/src/agent/tool/task-errors.ts +0 -42
- package/vendor/agent-root/src/agent/tool/task-get.ts +0 -116
- package/vendor/agent-root/src/agent/tool/task-graph.ts +0 -78
- package/vendor/agent-root/src/agent/tool/task-list.ts +0 -141
- package/vendor/agent-root/src/agent/tool/task-mock-runner-adapter.ts +0 -232
- package/vendor/agent-root/src/agent/tool/task-output.ts +0 -223
- package/vendor/agent-root/src/agent/tool/task-parent-abort.ts +0 -115
- package/vendor/agent-root/src/agent/tool/task-real-runner-adapter.ts +0 -336
- package/vendor/agent-root/src/agent/tool/task-runner-adapter.ts +0 -55
- package/vendor/agent-root/src/agent/tool/task-stop.ts +0 -187
- package/vendor/agent-root/src/agent/tool/task-store.ts +0 -217
- package/vendor/agent-root/src/agent/tool/task-subagent-config.ts +0 -149
- package/vendor/agent-root/src/agent/tool/task-types.ts +0 -264
- package/vendor/agent-root/src/agent/tool/task-update.ts +0 -315
- package/vendor/agent-root/src/agent/tool/task.ts +0 -209
- package/vendor/agent-root/src/agent/tool/tool-manager.ts +0 -361
- package/vendor/agent-root/src/agent/tool/tool-prompts.ts +0 -242
- package/vendor/agent-root/src/agent/tool/types.ts +0 -116
- package/vendor/agent-root/src/agent/tool/web-fetch.ts +0 -227
- package/vendor/agent-root/src/agent/tool/web-search.ts +0 -208
- package/vendor/agent-root/src/agent/tool/write-file.ts +0 -497
- package/vendor/agent-root/src/agent/types.ts +0 -232
- package/vendor/agent-root/src/agent/utils/__tests__/index.test.ts +0 -18
- package/vendor/agent-root/src/agent/utils/__tests__/message-utils.test.ts +0 -610
- package/vendor/agent-root/src/agent/utils/__tests__/message.test.ts +0 -223
- package/vendor/agent-root/src/agent/utils/__tests__/token.test.ts +0 -42
- package/vendor/agent-root/src/agent/utils/index.ts +0 -16
- package/vendor/agent-root/src/agent/utils/message.ts +0 -171
- package/vendor/agent-root/src/agent/utils/token.ts +0 -28
- package/vendor/agent-root/src/config/__tests__/load-config-to-env.test.ts +0 -238
- package/vendor/agent-root/src/config/__tests__/loader.test.ts +0 -361
- package/vendor/agent-root/src/config/__tests__/runtime.test.ts +0 -88
- package/vendor/agent-root/src/config/index.ts +0 -55
- package/vendor/agent-root/src/config/loader.ts +0 -494
- package/vendor/agent-root/src/config/paths.ts +0 -30
- package/vendor/agent-root/src/config/runtime.ts +0 -163
- package/vendor/agent-root/src/config/types.ts +0 -96
- package/vendor/agent-root/src/logger/index.ts +0 -57
- package/vendor/agent-root/src/logger/logger.ts +0 -819
- package/vendor/agent-root/src/logger/types.ts +0 -150
- package/vendor/agent-root/src/providers/__tests__/errors.test.ts +0 -441
- package/vendor/agent-root/src/providers/__tests__/index.test.ts +0 -16
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.options.test.ts +0 -318
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.test.ts +0 -600
- package/vendor/agent-root/src/providers/__tests__/registry.test.ts +0 -523
- package/vendor/agent-root/src/providers/__tests__/responses-adapter.test.ts +0 -298
- package/vendor/agent-root/src/providers/adapters/__tests__/anthropic.test.ts +0 -354
- package/vendor/agent-root/src/providers/adapters/__tests__/kimi.test.ts +0 -58
- package/vendor/agent-root/src/providers/adapters/__tests__/standard.test.ts +0 -261
- package/vendor/agent-root/src/providers/adapters/anthropic.ts +0 -572
- package/vendor/agent-root/src/providers/adapters/base.ts +0 -131
- package/vendor/agent-root/src/providers/adapters/kimi.ts +0 -48
- package/vendor/agent-root/src/providers/adapters/responses.ts +0 -732
- package/vendor/agent-root/src/providers/adapters/standard.ts +0 -120
- package/vendor/agent-root/src/providers/http/__tests__/client.timeout.test.ts +0 -313
- package/vendor/agent-root/src/providers/http/client.ts +0 -289
- package/vendor/agent-root/src/providers/http/stream-parser.ts +0 -109
- package/vendor/agent-root/src/providers/index.ts +0 -76
- package/vendor/agent-root/src/providers/kimi-headers.ts +0 -177
- package/vendor/agent-root/src/providers/openai-compatible.ts +0 -387
- package/vendor/agent-root/src/providers/registry/model-config.ts +0 -477
- package/vendor/agent-root/src/providers/registry/provider-factory.ts +0 -127
- package/vendor/agent-root/src/providers/registry.ts +0 -135
- package/vendor/agent-root/src/providers/types/api.ts +0 -284
- package/vendor/agent-root/src/providers/types/config.ts +0 -58
- package/vendor/agent-root/src/providers/types/errors.ts +0 -323
- package/vendor/agent-root/src/providers/types/index.ts +0 -72
- package/vendor/agent-root/src/providers/types/provider.ts +0 -45
- package/vendor/agent-root/src/providers/types/registry.ts +0 -68
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Renx config module.
|
|
3
|
-
*
|
|
4
|
-
* Sources:
|
|
5
|
-
* - global config: ~/.renx/config.json (or RENX_HOME/config.json)
|
|
6
|
-
* - project config: <project>/.renx/config.json
|
|
7
|
-
* - environment variables
|
|
8
|
-
*
|
|
9
|
-
* Effective precedence:
|
|
10
|
-
* env > project config > global config > defaults
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// Type exports
|
|
14
|
-
export type {
|
|
15
|
-
RenxConfig,
|
|
16
|
-
ResolvedConfig,
|
|
17
|
-
LoadConfigOptions,
|
|
18
|
-
LogConfig,
|
|
19
|
-
StorageConfig,
|
|
20
|
-
FileHistoryConfig,
|
|
21
|
-
AgentConfig,
|
|
22
|
-
ConfigModelDefinition,
|
|
23
|
-
} from './types';
|
|
24
|
-
|
|
25
|
-
// Config loaders
|
|
26
|
-
export {
|
|
27
|
-
loadConfig,
|
|
28
|
-
loadConfigToEnv,
|
|
29
|
-
getGlobalConfigDir,
|
|
30
|
-
getProjectConfigDir,
|
|
31
|
-
getGlobalConfigPath,
|
|
32
|
-
getProjectConfigPath,
|
|
33
|
-
ensureConfigDirs,
|
|
34
|
-
writeProjectConfig,
|
|
35
|
-
writeGlobalConfig,
|
|
36
|
-
} from './loader';
|
|
37
|
-
|
|
38
|
-
// Runtime env helpers
|
|
39
|
-
export type { LogFormat, RuntimeLogConfig, RuntimeConfig, LoadEnvFilesOptions } from './runtime';
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
loadEnvFiles,
|
|
43
|
-
loadRuntimeConfigFromEnv,
|
|
44
|
-
createLoggerFromRuntimeConfig,
|
|
45
|
-
createLoggerFromEnv,
|
|
46
|
-
} from './runtime';
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
RENX_HOME_ENV,
|
|
50
|
-
resolveRenxHome,
|
|
51
|
-
resolveRenxLogsDir,
|
|
52
|
-
resolveRenxStorageRoot,
|
|
53
|
-
resolveRenxTaskDir,
|
|
54
|
-
resolveRenxDatabasePath,
|
|
55
|
-
} from './paths';
|
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import { LogLevel } from '../logger';
|
|
4
|
-
import {
|
|
5
|
-
resolveRenxDatabasePath,
|
|
6
|
-
resolveRenxHome,
|
|
7
|
-
resolveRenxLogsDir,
|
|
8
|
-
resolveRenxStorageRoot,
|
|
9
|
-
} from './paths';
|
|
10
|
-
import type {
|
|
11
|
-
ConfigModelDefinition,
|
|
12
|
-
LoadConfigOptions,
|
|
13
|
-
LogConfig,
|
|
14
|
-
RenxConfig,
|
|
15
|
-
ResolvedConfig,
|
|
16
|
-
} from './types';
|
|
17
|
-
|
|
18
|
-
const PROJECT_DIR_NAME = '.renx';
|
|
19
|
-
const CONFIG_FILENAME = 'config.json';
|
|
20
|
-
const CUSTOM_MODELS_ENV_VAR = 'RENX_CUSTOM_MODELS_JSON';
|
|
21
|
-
|
|
22
|
-
const DEFAULTS: RenxConfig = {
|
|
23
|
-
log: {
|
|
24
|
-
level: 'INFO',
|
|
25
|
-
format: 'pretty',
|
|
26
|
-
console: false,
|
|
27
|
-
file: true,
|
|
28
|
-
},
|
|
29
|
-
storage: {
|
|
30
|
-
fileHistory: {
|
|
31
|
-
enabled: true,
|
|
32
|
-
maxPerFile: 20,
|
|
33
|
-
maxAgeDays: 14,
|
|
34
|
-
maxTotalMb: 500,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
agent: {
|
|
38
|
-
maxSteps: 10000,
|
|
39
|
-
confirmationMode: 'manual',
|
|
40
|
-
defaultModel: 'qwen3.5-plus',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function writeConfigFile(configPath: string, config: Partial<RenxConfig>): string {
|
|
45
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
46
|
-
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
47
|
-
return configPath;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function ensureGlobalConfigFile(globalDir: string): string {
|
|
51
|
-
const globalConfigPath = path.join(globalDir, CONFIG_FILENAME);
|
|
52
|
-
if (!fs.existsSync(globalConfigPath)) {
|
|
53
|
-
writeConfigFile(globalConfigPath, DEFAULTS);
|
|
54
|
-
}
|
|
55
|
-
return globalConfigPath;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function readJsonFile<T>(filePath: string): T | null {
|
|
59
|
-
try {
|
|
60
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
61
|
-
return JSON.parse(content) as T;
|
|
62
|
-
} catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
68
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function parseCustomModelsEnv(
|
|
72
|
-
raw: string | undefined
|
|
73
|
-
): Record<string, ConfigModelDefinition> | null {
|
|
74
|
-
if (!raw) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
const parsed = JSON.parse(raw) as unknown;
|
|
80
|
-
if (!isPlainObject(parsed)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const result: Record<string, ConfigModelDefinition> = {};
|
|
85
|
-
for (const [modelId, modelConfig] of Object.entries(parsed)) {
|
|
86
|
-
if (!isPlainObject(modelConfig)) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
result[modelId] = modelConfig as ConfigModelDefinition;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return result;
|
|
93
|
-
} catch {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function parseLogLevelValue(raw: string | undefined): LogLevel | null {
|
|
99
|
-
if (!raw) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const normalized = raw.trim().toUpperCase();
|
|
104
|
-
switch (normalized) {
|
|
105
|
-
case 'TRACE':
|
|
106
|
-
return LogLevel.TRACE;
|
|
107
|
-
case 'DEBUG':
|
|
108
|
-
return LogLevel.DEBUG;
|
|
109
|
-
case 'INFO':
|
|
110
|
-
return LogLevel.INFO;
|
|
111
|
-
case 'WARN':
|
|
112
|
-
return LogLevel.WARN;
|
|
113
|
-
case 'ERROR':
|
|
114
|
-
return LogLevel.ERROR;
|
|
115
|
-
case 'FATAL':
|
|
116
|
-
return LogLevel.FATAL;
|
|
117
|
-
default:
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function parseLogLevelString(raw: string | undefined): LogConfig['level'] | null {
|
|
123
|
-
if (!raw) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const normalized = raw.trim().toUpperCase();
|
|
128
|
-
if (['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].includes(normalized)) {
|
|
129
|
-
return normalized as LogConfig['level'];
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function parseBoolean(raw: string | undefined): boolean | null {
|
|
135
|
-
if (raw === undefined) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const normalized = raw.trim().toLowerCase();
|
|
140
|
-
if (['1', 'true', 'yes', 'on'].includes(normalized)) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
if (['0', 'false', 'no', 'off'].includes(normalized)) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function parsePositiveInt(raw: string | undefined): number | null {
|
|
150
|
-
if (!raw) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const parsed = Number.parseInt(raw, 10);
|
|
155
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
return parsed;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function parseNonNegativeInt(raw: string | undefined): number | null {
|
|
162
|
-
if (!raw) {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const parsed = Number.parseInt(raw, 10);
|
|
167
|
-
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
return parsed;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function parseConfirmationMode(
|
|
174
|
-
raw: string | undefined
|
|
175
|
-
): ResolvedConfig['agent']['confirmationMode'] | null {
|
|
176
|
-
if (!raw) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const normalized = raw.trim().toLowerCase().replace(/_/g, '-');
|
|
181
|
-
if (normalized === 'manual' || normalized === 'auto-approve' || normalized === 'auto-deny') {
|
|
182
|
-
return normalized;
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function deepMerge<T extends object>(base: T, override: Partial<T>): T {
|
|
188
|
-
const result = { ...base };
|
|
189
|
-
for (const key of Object.keys(override) as Array<keyof T>) {
|
|
190
|
-
const value = override[key];
|
|
191
|
-
if (value === undefined || value === null) {
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
typeof value === 'object' &&
|
|
197
|
-
!Array.isArray(value) &&
|
|
198
|
-
typeof base[key] === 'object' &&
|
|
199
|
-
base[key] !== null &&
|
|
200
|
-
!Array.isArray(base[key])
|
|
201
|
-
) {
|
|
202
|
-
result[key] = deepMerge(
|
|
203
|
-
base[key] as Record<string, unknown>,
|
|
204
|
-
value as Record<string, unknown>
|
|
205
|
-
) as T[keyof T];
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
result[key] = value as T[keyof T];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function applyEnvOverrides(config: RenxConfig, env: NodeJS.ProcessEnv): RenxConfig {
|
|
216
|
-
const result: RenxConfig = { ...config };
|
|
217
|
-
|
|
218
|
-
const logLevel = parseLogLevelString(env.AGENT_LOG_LEVEL);
|
|
219
|
-
const logFormat = env.AGENT_LOG_FORMAT;
|
|
220
|
-
const logConsole = parseBoolean(env.AGENT_LOG_CONSOLE);
|
|
221
|
-
const logFile = parseBoolean(env.AGENT_LOG_FILE_ENABLED);
|
|
222
|
-
|
|
223
|
-
if (logLevel || logFormat || logConsole !== null || logFile !== null) {
|
|
224
|
-
result.log = { ...(result.log ?? {}) };
|
|
225
|
-
if (logLevel) {
|
|
226
|
-
result.log.level = logLevel;
|
|
227
|
-
}
|
|
228
|
-
if (logFormat === 'json' || logFormat === 'pretty') {
|
|
229
|
-
result.log.format = logFormat;
|
|
230
|
-
}
|
|
231
|
-
if (logConsole !== null) {
|
|
232
|
-
result.log.console = logConsole;
|
|
233
|
-
}
|
|
234
|
-
if (logFile !== null) {
|
|
235
|
-
result.log.file = logFile;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const fileHistoryEnabled = parseBoolean(env.AGENT_FILE_HISTORY_ENABLED);
|
|
240
|
-
const maxPerFile = parseNonNegativeInt(env.AGENT_FILE_HISTORY_MAX_PER_FILE);
|
|
241
|
-
const maxAgeDays = parseNonNegativeInt(env.AGENT_FILE_HISTORY_MAX_AGE_DAYS);
|
|
242
|
-
const maxTotalMb = parseNonNegativeInt(env.AGENT_FILE_HISTORY_MAX_TOTAL_MB);
|
|
243
|
-
|
|
244
|
-
if (
|
|
245
|
-
fileHistoryEnabled !== null ||
|
|
246
|
-
maxPerFile !== null ||
|
|
247
|
-
maxAgeDays !== null ||
|
|
248
|
-
maxTotalMb !== null
|
|
249
|
-
) {
|
|
250
|
-
result.storage = { ...(result.storage ?? {}) };
|
|
251
|
-
result.storage.fileHistory = { ...(result.storage.fileHistory ?? {}) };
|
|
252
|
-
if (fileHistoryEnabled !== null) {
|
|
253
|
-
result.storage.fileHistory.enabled = fileHistoryEnabled;
|
|
254
|
-
}
|
|
255
|
-
if (maxPerFile !== null) {
|
|
256
|
-
result.storage.fileHistory.maxPerFile = maxPerFile;
|
|
257
|
-
}
|
|
258
|
-
if (maxAgeDays !== null) {
|
|
259
|
-
result.storage.fileHistory.maxAgeDays = maxAgeDays;
|
|
260
|
-
}
|
|
261
|
-
if (maxTotalMb !== null) {
|
|
262
|
-
result.storage.fileHistory.maxTotalMb = maxTotalMb;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const confirmationMode = parseConfirmationMode(env.AGENT_TOOL_CONFIRMATION_MODE);
|
|
267
|
-
const defaultModel = env.AGENT_MODEL?.trim();
|
|
268
|
-
const maxSteps = parsePositiveInt(env.AGENT_MAX_STEPS);
|
|
269
|
-
|
|
270
|
-
if (confirmationMode || defaultModel || maxSteps !== null) {
|
|
271
|
-
result.agent = { ...(result.agent ?? {}) };
|
|
272
|
-
if (confirmationMode) {
|
|
273
|
-
result.agent.confirmationMode = confirmationMode;
|
|
274
|
-
}
|
|
275
|
-
if (defaultModel) {
|
|
276
|
-
result.agent.defaultModel = defaultModel;
|
|
277
|
-
}
|
|
278
|
-
if (maxSteps !== null) {
|
|
279
|
-
result.agent.maxSteps = maxSteps;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const customModels = parseCustomModelsEnv(env[CUSTOM_MODELS_ENV_VAR]);
|
|
284
|
-
if (customModels) {
|
|
285
|
-
result.models = deepMerge(result.models ?? {}, customModels);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return result;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function resolveConfig(
|
|
292
|
-
merged: RenxConfig,
|
|
293
|
-
env: NodeJS.ProcessEnv,
|
|
294
|
-
sources: { global: string | null; project: string | null }
|
|
295
|
-
): ResolvedConfig {
|
|
296
|
-
const logDir = resolveRenxLogsDir(env);
|
|
297
|
-
const storageRoot = resolveRenxStorageRoot(env);
|
|
298
|
-
const dbPath = resolveRenxDatabasePath(env);
|
|
299
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
300
|
-
|
|
301
|
-
return {
|
|
302
|
-
log: {
|
|
303
|
-
level: parseLogLevelValue(merged.log?.level) ?? LogLevel.INFO,
|
|
304
|
-
format: merged.log?.format ?? 'pretty',
|
|
305
|
-
console: merged.log?.console ?? true,
|
|
306
|
-
file: merged.log?.file ?? false,
|
|
307
|
-
dir: logDir,
|
|
308
|
-
filePath: path.join(logDir, `${timestamp}.log`),
|
|
309
|
-
},
|
|
310
|
-
storage: {
|
|
311
|
-
root: storageRoot,
|
|
312
|
-
fileHistory: {
|
|
313
|
-
enabled: merged.storage?.fileHistory?.enabled ?? true,
|
|
314
|
-
maxPerFile: merged.storage?.fileHistory?.maxPerFile ?? 20,
|
|
315
|
-
maxAgeDays: merged.storage?.fileHistory?.maxAgeDays ?? 14,
|
|
316
|
-
maxTotalMb: merged.storage?.fileHistory?.maxTotalMb ?? 500,
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
db: {
|
|
320
|
-
path: dbPath,
|
|
321
|
-
},
|
|
322
|
-
agent: {
|
|
323
|
-
maxSteps: merged.agent?.maxSteps ?? 10000,
|
|
324
|
-
confirmationMode: merged.agent?.confirmationMode ?? 'manual',
|
|
325
|
-
defaultModel: merged.agent?.defaultModel ?? 'qwen3.5-plus',
|
|
326
|
-
},
|
|
327
|
-
models: merged.models ?? {},
|
|
328
|
-
sources,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export function loadConfig(options: LoadConfigOptions = {}): ResolvedConfig {
|
|
333
|
-
const env = options.env ?? process.env;
|
|
334
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
335
|
-
const globalDir = options.globalDir ?? resolveRenxHome(env);
|
|
336
|
-
|
|
337
|
-
let config: RenxConfig = { ...DEFAULTS };
|
|
338
|
-
|
|
339
|
-
const globalConfigPath = ensureGlobalConfigFile(globalDir);
|
|
340
|
-
const globalConfig = readJsonFile<RenxConfig>(globalConfigPath);
|
|
341
|
-
let globalSource: string | null = null;
|
|
342
|
-
if (globalConfig) {
|
|
343
|
-
config = deepMerge(config, globalConfig);
|
|
344
|
-
globalSource = globalConfigPath;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const projectConfigPath = path.join(projectRoot, PROJECT_DIR_NAME, CONFIG_FILENAME);
|
|
348
|
-
const projectConfig = readJsonFile<RenxConfig>(projectConfigPath);
|
|
349
|
-
let projectSource: string | null = null;
|
|
350
|
-
if (projectConfig) {
|
|
351
|
-
config = deepMerge(config, projectConfig);
|
|
352
|
-
projectSource = projectConfigPath;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (options.loadEnv !== false) {
|
|
356
|
-
config = applyEnvOverrides(config, env);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return resolveConfig(config, env, {
|
|
360
|
-
global: globalSource,
|
|
361
|
-
project: projectSource,
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export function loadConfigToEnv(options: LoadConfigOptions = {}): string[] {
|
|
366
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
367
|
-
const globalDir = options.globalDir ?? resolveRenxHome(process.env);
|
|
368
|
-
const loadedFiles: string[] = [];
|
|
369
|
-
|
|
370
|
-
const protectedEnvKeys = new Set(Object.keys(process.env));
|
|
371
|
-
const protectedCustomModels = parseCustomModelsEnv(process.env[CUSTOM_MODELS_ENV_VAR]) ?? {};
|
|
372
|
-
|
|
373
|
-
const globalConfigPath = ensureGlobalConfigFile(globalDir);
|
|
374
|
-
const globalConfig = readJsonFile<RenxConfig>(globalConfigPath);
|
|
375
|
-
if (globalConfig) {
|
|
376
|
-
applyConfigToEnv(globalConfig, protectedEnvKeys, protectedCustomModels);
|
|
377
|
-
loadedFiles.push(globalConfigPath);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
const projectConfigPath = path.join(projectRoot, PROJECT_DIR_NAME, CONFIG_FILENAME);
|
|
381
|
-
const projectConfig = readJsonFile<RenxConfig>(projectConfigPath);
|
|
382
|
-
if (projectConfig) {
|
|
383
|
-
applyConfigToEnv(projectConfig, protectedEnvKeys, protectedCustomModels);
|
|
384
|
-
loadedFiles.push(projectConfigPath);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return loadedFiles;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function applyConfigToEnv(
|
|
391
|
-
config: RenxConfig,
|
|
392
|
-
protectedEnvKeys: Set<string>,
|
|
393
|
-
protectedCustomModels: Record<string, ConfigModelDefinition>
|
|
394
|
-
): void {
|
|
395
|
-
const setIfUnset = (key: string, value: string | undefined) => {
|
|
396
|
-
if (value !== undefined && !protectedEnvKeys.has(key)) {
|
|
397
|
-
process.env[key] = value;
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
if (config.log) {
|
|
402
|
-
setIfUnset('AGENT_LOG_LEVEL', config.log.level);
|
|
403
|
-
setIfUnset('AGENT_LOG_FORMAT', config.log.format);
|
|
404
|
-
setIfUnset(
|
|
405
|
-
'AGENT_LOG_CONSOLE',
|
|
406
|
-
config.log.console !== undefined ? String(config.log.console) : undefined
|
|
407
|
-
);
|
|
408
|
-
setIfUnset(
|
|
409
|
-
'AGENT_LOG_FILE_ENABLED',
|
|
410
|
-
config.log.file !== undefined ? String(config.log.file) : undefined
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (config.storage?.fileHistory) {
|
|
415
|
-
setIfUnset(
|
|
416
|
-
'AGENT_FILE_HISTORY_ENABLED',
|
|
417
|
-
config.storage.fileHistory.enabled !== undefined
|
|
418
|
-
? String(config.storage.fileHistory.enabled)
|
|
419
|
-
: undefined
|
|
420
|
-
);
|
|
421
|
-
setIfUnset(
|
|
422
|
-
'AGENT_FILE_HISTORY_MAX_PER_FILE',
|
|
423
|
-
config.storage.fileHistory.maxPerFile !== undefined
|
|
424
|
-
? String(config.storage.fileHistory.maxPerFile)
|
|
425
|
-
: undefined
|
|
426
|
-
);
|
|
427
|
-
setIfUnset(
|
|
428
|
-
'AGENT_FILE_HISTORY_MAX_AGE_DAYS',
|
|
429
|
-
config.storage.fileHistory.maxAgeDays !== undefined
|
|
430
|
-
? String(config.storage.fileHistory.maxAgeDays)
|
|
431
|
-
: undefined
|
|
432
|
-
);
|
|
433
|
-
setIfUnset(
|
|
434
|
-
'AGENT_FILE_HISTORY_MAX_TOTAL_MB',
|
|
435
|
-
config.storage.fileHistory.maxTotalMb !== undefined
|
|
436
|
-
? String(config.storage.fileHistory.maxTotalMb)
|
|
437
|
-
: undefined
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (config.agent) {
|
|
442
|
-
setIfUnset('AGENT_TOOL_CONFIRMATION_MODE', config.agent.confirmationMode);
|
|
443
|
-
setIfUnset('AGENT_MODEL', config.agent.defaultModel);
|
|
444
|
-
setIfUnset(
|
|
445
|
-
'AGENT_MAX_STEPS',
|
|
446
|
-
config.agent.maxSteps !== undefined ? String(config.agent.maxSteps) : undefined
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
if (config.models && Object.keys(config.models).length > 0) {
|
|
451
|
-
const existingModels = parseCustomModelsEnv(process.env[CUSTOM_MODELS_ENV_VAR]) ?? {};
|
|
452
|
-
const mergedModels = deepMerge(existingModels, config.models);
|
|
453
|
-
|
|
454
|
-
if (protectedEnvKeys.has(CUSTOM_MODELS_ENV_VAR)) {
|
|
455
|
-
process.env[CUSTOM_MODELS_ENV_VAR] = JSON.stringify(
|
|
456
|
-
deepMerge(mergedModels, protectedCustomModels)
|
|
457
|
-
);
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
process.env[CUSTOM_MODELS_ENV_VAR] = JSON.stringify(mergedModels);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export function getGlobalConfigDir(): string {
|
|
466
|
-
return resolveRenxHome(process.env);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
export function getProjectConfigDir(projectRoot?: string): string {
|
|
470
|
-
return path.join(projectRoot ?? process.cwd(), PROJECT_DIR_NAME);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export function getGlobalConfigPath(): string {
|
|
474
|
-
return path.join(getGlobalConfigDir(), CONFIG_FILENAME);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
export function getProjectConfigPath(projectRoot?: string): string {
|
|
478
|
-
return path.join(getProjectConfigDir(projectRoot), CONFIG_FILENAME);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export function ensureConfigDirs(projectRoot?: string): void {
|
|
482
|
-
fs.mkdirSync(getGlobalConfigDir(), { recursive: true });
|
|
483
|
-
fs.mkdirSync(getProjectConfigDir(projectRoot), { recursive: true });
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export function writeProjectConfig(config: Partial<RenxConfig>, projectRoot?: string): string {
|
|
487
|
-
const configPath = getProjectConfigPath(projectRoot);
|
|
488
|
-
return writeConfigFile(configPath, config);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export function writeGlobalConfig(config: Partial<RenxConfig>): string {
|
|
492
|
-
const configPath = getGlobalConfigPath();
|
|
493
|
-
return writeConfigFile(configPath, config);
|
|
494
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { homedir } from 'node:os';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
|
|
4
|
-
export const RENX_HOME_ENV = 'RENX_HOME';
|
|
5
|
-
const DEFAULT_RENX_DIRNAME = '.renx';
|
|
6
|
-
|
|
7
|
-
function readEnvPath(env: NodeJS.ProcessEnv, key: string): string | undefined {
|
|
8
|
-
const value = env[key]?.trim();
|
|
9
|
-
return value && value.length > 0 ? path.resolve(value) : undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function resolveRenxHome(env: NodeJS.ProcessEnv = process.env): string {
|
|
13
|
-
return readEnvPath(env, RENX_HOME_ENV) ?? path.join(homedir(), DEFAULT_RENX_DIRNAME);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function resolveRenxLogsDir(env: NodeJS.ProcessEnv = process.env): string {
|
|
17
|
-
return path.join(resolveRenxHome(env), 'logs');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function resolveRenxStorageRoot(env: NodeJS.ProcessEnv = process.env): string {
|
|
21
|
-
return path.join(resolveRenxHome(env), 'storage');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resolveRenxTaskDir(env: NodeJS.ProcessEnv = process.env): string {
|
|
25
|
-
return path.join(resolveRenxHome(env), 'task');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function resolveRenxDatabasePath(env: NodeJS.ProcessEnv = process.env): string {
|
|
29
|
-
return path.join(resolveRenxHome(env), 'data.db');
|
|
30
|
-
}
|