@galaxy-stack/ai-coder-core 0.1.0 → 0.3.0-alpha.7
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/CHANGELOG.d/2026-09-19-advisory-guard-policy.md +25 -0
- package/CHANGELOG.d/2026-09-19-research-citation-parsing.md +16 -0
- package/CHANGELOG.d/2026-09-19-research-rejection-evidence.md +15 -0
- package/CHANGELOG.d/2026-09-19-test-journal-reporter.md +8 -0
- package/CHANGELOG.d/2026-09-21-evidence-missing-remediation.md +15 -0
- package/CHANGELOG.d/2026-09-21-observation-nudge-context.md +12 -0
- package/CHANGELOG.d/2026-09-22-model-retry-budget.md +18 -0
- package/CHANGELOG.d/2026-09-22-no-progress-recovery-turn.md +19 -0
- package/CHANGELOG.d/2026-09-23-agent-platform.md +5 -0
- package/CHANGELOG.d/2026-09-23-conservative-output-reserve.md +16 -0
- package/CHANGELOG.d/2026-09-24-approval-workspace-review.md +7 -0
- package/CHANGELOG.d/2026-09-24-incremental-ollama.md +5 -0
- package/CHANGELOG.d/README.md +16 -0
- package/CHANGELOG.md +166 -0
- package/README.md +119 -8
- package/dist/adapters/node/config/manual-provider-config.d.ts +19 -0
- package/dist/adapters/node/config/manual-provider-config.d.ts.map +1 -0
- package/dist/adapters/node/config/manual-provider-config.js +91 -0
- package/dist/adapters/node/config/manual-provider-config.js.map +1 -0
- package/dist/adapters/node/host/command-containment.d.ts +45 -0
- package/dist/adapters/node/host/command-containment.d.ts.map +1 -0
- package/dist/adapters/node/host/command-containment.js +580 -0
- package/dist/adapters/node/host/command-containment.js.map +1 -0
- package/dist/adapters/node/host/content-hash.d.ts +2 -0
- package/dist/adapters/node/host/content-hash.d.ts.map +1 -0
- package/dist/adapters/node/host/content-hash.js +5 -0
- package/dist/adapters/node/host/content-hash.js.map +1 -0
- package/dist/adapters/node/host/file-run-store.d.ts +29 -0
- package/dist/adapters/node/host/file-run-store.d.ts.map +1 -0
- package/dist/adapters/node/host/file-run-store.js +94 -0
- package/dist/adapters/node/host/file-run-store.js.map +1 -0
- package/dist/adapters/node/host/host-environment.d.ts +9 -0
- package/dist/adapters/node/host/host-environment.d.ts.map +1 -0
- package/dist/adapters/node/host/host-environment.js +29 -0
- package/dist/adapters/node/host/host-environment.js.map +1 -0
- package/dist/adapters/node/host/node-command-port.d.ts +21 -0
- package/dist/adapters/node/host/node-command-port.d.ts.map +1 -0
- package/dist/adapters/node/host/node-command-port.js +281 -0
- package/dist/adapters/node/host/node-command-port.js.map +1 -0
- package/dist/adapters/node/host/node-workspace-evidence-verifier.d.ts +22 -0
- package/dist/adapters/node/host/node-workspace-evidence-verifier.d.ts.map +1 -0
- package/dist/adapters/node/host/node-workspace-evidence-verifier.js +384 -0
- package/dist/adapters/node/host/node-workspace-evidence-verifier.js.map +1 -0
- package/dist/adapters/node/host/node-workspace-port.d.ts +87 -0
- package/dist/adapters/node/host/node-workspace-port.d.ts.map +1 -0
- package/dist/adapters/node/host/node-workspace-port.js +860 -0
- package/dist/adapters/node/host/node-workspace-port.js.map +1 -0
- package/dist/adapters/node/host/node-workspace-snapshot.d.ts +61 -0
- package/dist/adapters/node/host/node-workspace-snapshot.d.ts.map +1 -0
- package/dist/adapters/node/host/node-workspace-snapshot.js +281 -0
- package/dist/adapters/node/host/node-workspace-snapshot.js.map +1 -0
- package/dist/adapters/node/host/path-scope.d.ts +17 -0
- package/dist/adapters/node/host/path-scope.d.ts.map +1 -0
- package/dist/adapters/node/host/path-scope.js +89 -0
- package/dist/adapters/node/host/path-scope.js.map +1 -0
- package/dist/adapters/node/host/project-tools.d.ts +42 -0
- package/dist/adapters/node/host/project-tools.d.ts.map +1 -0
- package/dist/adapters/node/host/project-tools.js +362 -0
- package/dist/adapters/node/host/project-tools.js.map +1 -0
- package/dist/adapters/node/mcp/mcp-client.d.ts +206 -0
- package/dist/adapters/node/mcp/mcp-client.d.ts.map +1 -0
- package/dist/adapters/node/mcp/mcp-client.js +123 -0
- package/dist/adapters/node/mcp/mcp-client.js.map +1 -0
- package/dist/adapters/node/mcp/oauth-provider.d.ts +39 -0
- package/dist/adapters/node/mcp/oauth-provider.d.ts.map +1 -0
- package/dist/adapters/node/mcp/oauth-provider.js +168 -0
- package/dist/adapters/node/mcp/oauth-provider.js.map +1 -0
- package/dist/adapters/node/memory/sqlite-memory.d.ts +22 -0
- package/dist/adapters/node/memory/sqlite-memory.d.ts.map +1 -0
- package/dist/adapters/node/memory/sqlite-memory.js +83 -0
- package/dist/adapters/node/memory/sqlite-memory.js.map +1 -0
- package/dist/adapters/node/provider/ollama-chat-stream.d.ts +17 -0
- package/dist/adapters/node/provider/ollama-chat-stream.d.ts.map +1 -0
- package/dist/adapters/node/provider/ollama-chat-stream.js +176 -0
- package/dist/adapters/node/provider/ollama-chat-stream.js.map +1 -0
- package/dist/adapters/node/provider/ollama-coding-model.d.ts +89 -0
- package/dist/adapters/node/provider/ollama-coding-model.d.ts.map +1 -0
- package/dist/adapters/node/provider/ollama-coding-model.js +464 -0
- package/dist/adapters/node/provider/ollama-coding-model.js.map +1 -0
- package/dist/adapters/node/provider/ollama-research-port.d.ts +32 -0
- package/dist/adapters/node/provider/ollama-research-port.d.ts.map +1 -0
- package/dist/adapters/node/provider/ollama-research-port.js +346 -0
- package/dist/adapters/node/provider/ollama-research-port.js.map +1 -0
- package/dist/adapters/node/skills/directory-skills.d.ts +12 -0
- package/dist/adapters/node/skills/directory-skills.d.ts.map +1 -0
- package/dist/adapters/node/skills/directory-skills.js +90 -0
- package/dist/adapters/node/skills/directory-skills.js.map +1 -0
- package/dist/adapters/node/tools/tool-executor.d.ts +91 -0
- package/dist/adapters/node/tools/tool-executor.d.ts.map +1 -0
- package/dist/adapters/node/tools/tool-executor.js +948 -0
- package/dist/adapters/node/tools/tool-executor.js.map +1 -0
- package/dist/adapters/node/tools/workspace-review.d.ts +13 -0
- package/dist/adapters/node/tools/workspace-review.d.ts.map +1 -0
- package/dist/adapters/node/tools/workspace-review.js +81 -0
- package/dist/adapters/node/tools/workspace-review.js.map +1 -0
- package/dist/agent/index.d.ts +79 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +97 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/approval/approval-policy.d.ts.map +1 -1
- package/dist/approval/approval-policy.js +4 -1
- package/dist/approval/approval-policy.js.map +1 -1
- package/dist/context/checkpoint.d.ts +3 -0
- package/dist/context/checkpoint.d.ts.map +1 -1
- package/dist/context/checkpoint.js +30 -1
- package/dist/context/checkpoint.js.map +1 -1
- package/dist/context/context-profile.d.ts +1 -1
- package/dist/context/context-profile.js +2 -2
- package/dist/prompt/prompt-assembler.d.ts +2 -1
- package/dist/prompt/prompt-assembler.d.ts.map +1 -1
- package/dist/prompt/prompt-assembler.js +40 -3
- package/dist/prompt/prompt-assembler.js.map +1 -1
- package/dist/runtime/completion-gate.d.ts +1 -1
- package/dist/runtime/completion-gate.d.ts.map +1 -1
- package/dist/runtime/completion-gate.js +12 -0
- package/dist/runtime/completion-gate.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/research-citations.d.ts +15 -0
- package/dist/runtime/research-citations.d.ts.map +1 -0
- package/dist/runtime/research-citations.js +49 -0
- package/dist/runtime/research-citations.js.map +1 -0
- package/dist/runtime/run-controller.d.ts +6 -0
- package/dist/runtime/run-controller.d.ts.map +1 -1
- package/dist/runtime/run-controller.js +267 -62
- package/dist/runtime/run-controller.js.map +1 -1
- package/dist/runtime/runtime-types.d.ts +29 -0
- package/dist/runtime/runtime-types.d.ts.map +1 -1
- package/docs/AGENT_PLATFORM.md +91 -0
- package/docs/ARCHITECTURE.md +13 -2
- package/docs/GALAXY_AGENT_PLATFORM_PLAN.md +318 -0
- package/docs/GALAXY_AGENT_PLATFORM_TODO.md +158 -0
- package/docs/HOST_CONFORMANCE.md +38 -0
- package/docs/PROMPT_CONTRACT.md +9 -0
- package/package.json +25 -9
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Advisory guard policy cho observation (2026-09-19 00:15 +07:00)
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- `AiCoderRunBudget.noProgressPolicy`: `advisory` (mặc định) và `strict`.
|
|
6
|
+
- `AiCoderRunBudget.observationNudgeThresholds` (mặc định `[3, 5, 8]`, theo
|
|
7
|
+
tư tưởng repeat-tool-reminder của DeepSeek Harness): các mốc nhắc advisory
|
|
8
|
+
cho observation đọc-only; block chỉ xảy ra sau mốc cuối.
|
|
9
|
+
- Checkpoint lưu `noProgress.policy` và `noProgress.observationNudgeThresholds`;
|
|
10
|
+
resume với cấu hình khác bị từ chối `CHECKPOINT_INCOMPATIBLE`, checkpoint cũ
|
|
11
|
+
không có trường này vẫn resume được (legacy).
|
|
12
|
+
- Trace `policy_decision` cho `observation_nudge` và `observation_blocked`.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Nudge advisory không còn tăng `noProgressEpisodes`; quyết định pause chỉ đến
|
|
17
|
+
từ block thật hoặc guard mutation/validation/cycle. Chế độ `strict` giữ nguyên
|
|
18
|
+
hành vi cũ (nudge đầu tiên đếm episode, block theo `maxRepeatedToolRequests`).
|
|
19
|
+
- Bộ đếm observation family đếm mọi lượt dispatch (kể cả thất bại), khớp hợp
|
|
20
|
+
đồng "requested" trong ARCHITECTURE.md.
|
|
21
|
+
|
|
22
|
+
### Tests
|
|
23
|
+
|
|
24
|
+
- 3 test runtime mới: advisory thresholds + block sau mốc cuối; advisory không
|
|
25
|
+
đếm episode; cấu hình fail-loud + checkpoint-bound trên resume.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Sửa parser citation bị nhiễu Markdown (2026-09-19 11:55 +07:00)
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- `researchCitations` strip đuôi emphasis/punctuation lặp (`**`, `*`, `_`,
|
|
6
|
+
backtick, `:`, `;`) trước khi canonicalize, nên URL được model viết kiểu
|
|
7
|
+
`**https://example.com/a**:` khớp với URL đã fetch. Trước đó report
|
|
8
|
+
durable-research bị oracle từ chối sai hai citation hợp lệ
|
|
9
|
+
(INC-001 trong `galaxy-code/docs/TEST_FAILURE_ANALYSIS.md`).
|
|
10
|
+
- Giữ nguyên xử lý ngoặc cân bằng; URL chỉ-search (model tự ghi "not fetched")
|
|
11
|
+
vẫn bị từ chối đúng.
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
- Test mới: bold/italic/backtick/colon, dedupe, và trường hợp URL thật kết thúc
|
|
16
|
+
bằng `*` (được strip — trade-off đã ghi trong incident register).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Lưu evidence khi citation bị từ chối (2026-09-19 23:15 +07:00)
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Event `completion_rejected` lưu nguyên candidate và ba tập URL: fetch thành
|
|
6
|
+
công, chỉ xuất hiện ở search, và citation không có fetch evidence; source
|
|
7
|
+
ledger giữ `toolCallId` và `contentHash` để ghép lại tool result.
|
|
8
|
+
- Feedback cho model liệt kê nguồn đã fetch để model sửa report thay vì lặp
|
|
9
|
+
nguyên candidate hoặc tự đoán URL khác. Đây là phần core của INC-010 trong
|
|
10
|
+
`galaxy-code/docs/TEST_FAILURE_ANALYSIS.md`.
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
|
|
14
|
+
- Regression runtime tạo search-only + fetched source, từ chối candidate đầu,
|
|
15
|
+
kiểm tra event/feedback có đủ ledger, rồi hoàn thành bằng citation đã fetch.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Node test reporter ghi nhật ký (2026-09-18 23:45 +07:00)
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Reporter Node development-only (`scripts/test-journal-reporter.mjs`): `npm test`
|
|
6
|
+
ghi `TEST_ERROR_LOG.md` và `.galaxy/tests/<run>/` (events.jsonl, summary.json,
|
|
7
|
+
summary.md) với timestamp từng assertion, stack lỗi, số đếm test, commit và
|
|
8
|
+
source fingerprint. Không thêm dependency runtime, không đổi public exports.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Remediation cho RESEARCH_EVIDENCE_MISSING (2026-09-21 02:20 +07:00)
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- Completion rejection giờ có dòng remediation riêng cho `RESEARCH_EVIDENCE_MISSING`,
|
|
6
|
+
nêu tên tool (`search_web` cho discovery, `fetch_url` cho đọc nguồn) và nói rõ
|
|
7
|
+
fetch-only không thỏa search requirement. Trước đây issue chỉ nêu số lượng
|
|
8
|
+
("search calls 0/1") nên model dưới compaction cao không có hướng hành động
|
|
9
|
+
(run [OycseO](../../galaxy-code/.galaxy/audit/2026-09-20T18-36-41-606Z-OycseO/summary.json)
|
|
10
|
+
durable repeat-3: 0 search, 3 fetch, 2 rejection, NO_PROGRESS).
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
|
|
14
|
+
- Core 108/108 pass, thêm regression: model fetch-only bị từ chối, nhận feedback
|
|
15
|
+
nêu tên tool, gọi `search_web` sau rejection rồi hoàn thành.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Nudge nhận diện bằng arguments hash (2026-09-21 00:55 +07:00)
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- Advisory observation nudge giờ kèm `arguments_hash` để model thấy chính xác
|
|
6
|
+
lệnh nào đang lặp, thay vì chỉ biết có sự lặp. Đây là phiên bản tiết kiệm
|
|
7
|
+
budget của tư tưởng deepseek-harness "giữ full canonical arguments để nhận
|
|
8
|
+
diện": nhận diện vẫn dùng toàn bộ arguments, lời nhắc chỉ mang hash.
|
|
9
|
+
|
|
10
|
+
### Tests
|
|
11
|
+
|
|
12
|
+
- Core 107/107 pass (`npm test`), không có test assert nội dung nudge cũ bị phá.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Retry delay theo scenario budget + deadline-aware skip (2026-09-22 07:25 +07:00)
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- Bảng backoff giữa các model request retry trở thành budget knob
|
|
6
|
+
`modelRetryDelaysMs` (1-8 số nguyên dương, tối đa 600 000 ms mỗi entry) thay
|
|
7
|
+
vì `MODEL_RETRY_DELAYS` hardcode. Schedule được dùng theo thứ tự attempt và
|
|
8
|
+
báo trong sự kiện `model_retry`.
|
|
9
|
+
- Retry deadline-aware: trước khi sleep, runtime kiểm tra budget còn lại; nếu
|
|
10
|
+
`deadline - now <= delay + thời gian attempt vừa fail` thì bỏ attempt, fail
|
|
11
|
+
loud với message nêu rõ còn bao nhiêu budget, backoff bao nhiêu và attempt
|
|
12
|
+
trước kéo dài bao nhiêu, thay vì dispatch một request chắc chắn chết.
|
|
13
|
+
|
|
14
|
+
### Tests
|
|
15
|
+
|
|
16
|
+
- Core 111/111 pass: budget schedule được dùng đúng thứ tự và report qua
|
|
17
|
+
`onEvent`; retry không đủ budget bị skip trước khi sleep; 6 case schedule
|
|
18
|
+
invalid fail loud tại validation.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Recovery turn trước no-progress pause (2026-09-22 01:07 +07:00)
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- Khi `noProgressEpisodes` chạm ngưỡng pause lần đầu, runtime không pause ngay
|
|
6
|
+
mà chèn một feedback turn `[GALAXY NO-PROGRESS RECOVERY]` liệt kê failed
|
|
7
|
+
tools của round kèm remediation (re-read vùng đúng, whole-file write, đổi
|
|
8
|
+
nguồn), rồi cho model đúng một round nữa. Nếu round đó vẫn không tiến triển
|
|
9
|
+
thì pause như cũ. Đây là phiên bản two-strike của Gemini CLI
|
|
10
|
+
loopDetectionService cho Galaxy: giữ nguyên ngưỡng 2/2/2, không bỏ pause,
|
|
11
|
+
chỉ thêm đúng một cơ hội phục hồi có kiểm soát.
|
|
12
|
+
- Trace runtime ghi `policy_decision` với `action:
|
|
13
|
+
"no_progress_recovery_turn"` để audit phân biệt lượt recovery với lượt pause.
|
|
14
|
+
|
|
15
|
+
### Tests
|
|
16
|
+
|
|
17
|
+
- Core 108/108 pass. Hash-cycle, resume-cycle, observation recovery, validation
|
|
18
|
+
recovery có fixture xác minh: recovery round được cấp đúng một lần; round
|
|
19
|
+
phục hồi thành công (đổi chiến lược) thì complete; round vẫn lặp thì pause.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Agent platform foundation
|
|
2
|
+
|
|
3
|
+
Add general agent profiles, optional MCP/skill/SQLite adapters and move the private live/replay lab into testing.
|
|
4
|
+
|
|
5
|
+
Package and repository names are unchanged. See README and architecture/migration docs for current limitations and the release order.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## 0.3.0-alpha.7 — 2026-09-23 07:00 +07:00
|
|
2
|
+
|
|
3
|
+
### Conservative profile output reserve bump (Mode B fix)
|
|
4
|
+
|
|
5
|
+
**Lỗi:** `INVALID_MODEL_STREAM "length"` — model dùng hết output tokens (conservative profile chỉ reserve 24 000) chỉ để sinh thinking + tool-call JSON, chưa kịp write file nào (0 writes trên 14 chat requests).
|
|
6
|
+
|
|
7
|
+
**Hệ thống khác xử lý:**
|
|
8
|
+
- Codex CLI: tách budget riêng cho thinking và tool-call JSON, không chia sẻ cùng một output cap.
|
|
9
|
+
- Claude Code: mỗi tool call có output budget riêng, không trộn với thinking.
|
|
10
|
+
- Gemini CLI: dùng `thinking_config` để cấp thinking budget riêng khỏi output budget.
|
|
11
|
+
|
|
12
|
+
**Fix Galaxy:** nâng `outputReserveTokens` của profile `conservative` từ 24 000 lên 32 768 (khớp balanced/extended). Không đổi toolDefinitionBudget hay softInputTokens. `AI_CODER_CONTEXT_PROFILE_CONFIG_VERSION` bump thành `"1.1.0"`.
|
|
13
|
+
|
|
14
|
+
**File sửa:** `src/context/context-profile.ts`.
|
|
15
|
+
|
|
16
|
+
**Test:** 112/112 core offline (chạy sau build). Không cần unit test mới — profile không được assert trực tiếp trong unit suite.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Request-scoped approvals and scratch workspace review
|
|
2
|
+
|
|
3
|
+
Abort host approval prompts when their request expires or resolves; reject late approvals without canceling the parent run. Allow NodeToolExecutor hosts to choose their approval timeout.
|
|
4
|
+
|
|
5
|
+
Add the optional NodeWorkspaceReviewExecutor for stable, bounded before/after text review without Git. It attests real diff-review evidence without weakening validation requirements. Update the prompt to use this tool when available.
|
|
6
|
+
|
|
7
|
+
Validation: core verify (121 tests), 16 lab executor regressions and CLI end-to-end scratch-project completion, including a live provider run.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Incremental Ollama streaming
|
|
2
|
+
|
|
3
|
+
Decode NDJSON as bytes arrive instead of buffering the complete HTTP response. Share the stateful normalizer with replay, retain byte limits and UTF-8 correctness, and cancel body readers when requests or consumers stop. Late errors do not emit a duplicate started event.
|
|
4
|
+
|
|
5
|
+
Validation: core verify, 13 transport tests, 7 normalizer tests and recorded replay; delayed HTTP→CLI rendering verifies deltas before EOF.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# CHANGELOG.d
|
|
2
|
+
|
|
3
|
+
Mỗi bản sửa đáng chú ý (behavior/API/tooling) được ghi thành một fragment trong
|
|
4
|
+
thư mục này ngay khi hoàn thành, đặt tên `YYYY-MM-DD-ten-ngan.md`. Khi cắt một
|
|
5
|
+
version, gom các fragment thành một mục trong [CHANGELOG.md](../CHANGELOG.md)
|
|
6
|
+
với version, ngày, giờ (+07:00), rồi chuyển trạng thái fragment sang đã phát
|
|
7
|
+
hành. Không sửa nội dung fragment đã gom; chỉ xóa khi mục tương ứng đã nằm
|
|
8
|
+
trong CHANGELOG.md.
|
|
9
|
+
|
|
10
|
+
Nội dung fragment phải ghi: vùng thay đổi (runtime/prompt/tools/docs/dev), hành
|
|
11
|
+
vi trước và sau, yêu cầu test hồi quy hoặc link incident tương ứng trong
|
|
12
|
+
`galaxy-code/docs/TEST_FAILURE_ANALYSIS.md` khi bản sửa xuất phát từ một lỗi
|
|
13
|
+
live.
|
|
14
|
+
|
|
15
|
+
CHANGELOG.md (file công khai trên npm/GitHub) viết tiếng Anh; fragment ở đây là
|
|
16
|
+
ghi chú làm việc nội bộ, viết tiếng Việt cũng được.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
Times are recorded in Asia/Ho_Chi_Minh (+07:00). Per-fix fragments are filed in
|
|
8
|
+
[CHANGELOG.d](CHANGELOG.d/README.md) and compiled here at release time.
|
|
9
|
+
|
|
10
|
+
## [0.3.0-alpha.7] - 2026-09-23 07:00 +07:00
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Conservative context profile `outputReserveTokens` raised from 24 000 to
|
|
15
|
+
32 768 (matching balanced/extended) to prevent `INVALID_MODEL_STREAM
|
|
16
|
+
"length"` failures when the model spends the full reserve on thinking plus
|
|
17
|
+
tool-call JSON before writing any file. Profile config version bumped to
|
|
18
|
+
`1.1.0`. See
|
|
19
|
+
[CHANGELOG.d fragment](CHANGELOG.d/2026-09-23-conservative-output-reserve.md).
|
|
20
|
+
|
|
21
|
+
## [0.3.0-alpha.6] - 2026-09-22 07:25 +07:00
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Model retry backoff is now a budget knob (`modelRetryDelaysMs`, 1-8 entries,
|
|
26
|
+
up to 600 000 ms each) consumed in order by retry attempt and reported in
|
|
27
|
+
`model_retry` events, replacing the hardcoded delay table. Retries are also
|
|
28
|
+
deadline-aware: when the remaining run budget cannot cover the backoff plus
|
|
29
|
+
the failed attempt's duration, the runtime skips the attempt and fails loud
|
|
30
|
+
with the full budget math. See
|
|
31
|
+
[CHANGELOG.d fragment](CHANGELOG.d/2026-09-22-model-retry-budget.md).
|
|
32
|
+
|
|
33
|
+
## [0.3.0-alpha.5] - 2026-09-22 01:07 +07:00
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- No-progress pause now grants exactly one recovery feedback round before
|
|
38
|
+
pausing: the runtime injects `[GALAXY NO-PROGRESS RECOVERY]` listing the
|
|
39
|
+
round's failed tools with their remediation and expects a materially
|
|
40
|
+
different strategy. Thresholds (2/2/2), pause semantics, and
|
|
41
|
+
fail-loud-after-budget behavior are unchanged; a trace
|
|
42
|
+
`policy_decision(action: "no_progress_recovery_turn")` marks the granted
|
|
43
|
+
round. Inspired by Gemini CLI's two-strike loop detection; see
|
|
44
|
+
[CHANGELOG.d fragment](CHANGELOG.d/2026-09-22-no-progress-recovery-turn.md).
|
|
45
|
+
|
|
46
|
+
## [0.3.0-alpha.4] - 2026-09-21 02:20 +07:00
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- `RESEARCH_EVIDENCE_MISSING` completion rejections now carry actionable
|
|
51
|
+
remediation naming `search_web` (discovery) and `fetch_url` (reading), and
|
|
52
|
+
state that fetch-only runs do not satisfy a search requirement.
|
|
53
|
+
|
|
54
|
+
## [0.3.0-alpha.3] - 2026-09-21 00:55 +07:00
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- Advisory observation nudges include the repeated call's `arguments_hash` so
|
|
59
|
+
the model can identify exactly which call is repeating while the guard keeps
|
|
60
|
+
recognition on the full canonical arguments.
|
|
61
|
+
|
|
62
|
+
## [0.3.0-alpha.2] - 2026-09-19 23:15 +07:00
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- `completion_rejected` runtime events now retain the rejected candidate and a
|
|
67
|
+
structured research ledger: successfully fetched URLs, search-only URLs,
|
|
68
|
+
unsupported citations, and source tool-call correlation. Hosts can persist
|
|
69
|
+
enough evidence to diagnose a repeated citation failure without
|
|
70
|
+
reconstructing model output from prose.
|
|
71
|
+
- README installation, lifecycle usage, public API, adapter ownership, and
|
|
72
|
+
alpha-upgrade guidance.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- Research citation rejection feedback lists the successfully fetched sources
|
|
77
|
+
available to the model and tells it to fetch or remove unsupported URLs.
|
|
78
|
+
Search snippets and plausible URLs remain insufficient completion evidence.
|
|
79
|
+
|
|
80
|
+
## [0.3.0-alpha.1] - 2026-09-19 12:17 +07:00 (published; first alpha-tagged release)
|
|
81
|
+
|
|
82
|
+
The first release after `0.1.0` is alpha-tagged because the no-progress guard
|
|
83
|
+
policy changes the default runtime behavior. All changes since `0.1.0` ship in
|
|
84
|
+
this version; the internal working versions `0.2.0`–`0.2.2` were never published.
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
|
|
88
|
+
- Configurable observation guard policy:
|
|
89
|
+
- `AiCoderRunBudget.noProgressPolicy`: `advisory` (default) and `strict`.
|
|
90
|
+
- `AiCoderRunBudget.observationNudgeThresholds` (default `[3, 5, 8]`,
|
|
91
|
+
following the DeepSeek Harness `repeat-tool-reminder` design): escalating
|
|
92
|
+
trusted nudges for repeated read-only observations; blocking only after the
|
|
93
|
+
final threshold. Advisory nudges no longer count toward
|
|
94
|
+
`maxNoProgressEpisodes`; the `strict` policy preserves the older
|
|
95
|
+
first-incident accounting.
|
|
96
|
+
- Checkpoints persist `noProgress.policy` and
|
|
97
|
+
`noProgress.observationNudgeThresholds`; resuming with a different guard
|
|
98
|
+
configuration fails with `CHECKPOINT_INCOMPATIBLE` (legacy checkpoints
|
|
99
|
+
without these fields still resume).
|
|
100
|
+
- `policy_decision` trace events for `observation_nudge` and
|
|
101
|
+
`observation_blocked`.
|
|
102
|
+
- Development-only Node test reporter: `npm test` writes a timestamped journal
|
|
103
|
+
(`TEST_ERROR_LOG.md`, `.galaxy/tests/<run>/`) with assertion results,
|
|
104
|
+
failure stacks, test counts, commit, and source fingerprint. Excluded from
|
|
105
|
+
the published bundle.
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
- Observation-family counters now count every dispatched identical observation
|
|
110
|
+
attempt, including failed results, matching the documented "requested"
|
|
111
|
+
contract.
|
|
112
|
+
|
|
113
|
+
### Fixed
|
|
114
|
+
|
|
115
|
+
- Research citation parsing: trailing Markdown emphasis and punctuation
|
|
116
|
+
(`**url**:`, `*url*`, backtick-quoted URLs, trailing `:`/`;`) are
|
|
117
|
+
stripped before canonicalization, so citations of successfully fetched
|
|
118
|
+
sources are no longer rejected when the model decorates them. Search-only
|
|
119
|
+
URLs cited as unfetched are still rejected. See
|
|
120
|
+
[2026-09-19-research-citation-parsing.md](CHANGELOG.d/2026-09-19-research-citation-parsing.md).
|
|
121
|
+
|
|
122
|
+
## [0.2.2] - 2026-09-19 11:54 +07:00 (internal working version)
|
|
123
|
+
|
|
124
|
+
- Working version carrying the citation parsing fix; superseded by
|
|
125
|
+
`0.3.0-alpha.1` before publishing.
|
|
126
|
+
|
|
127
|
+
## [0.2.1] - 2026-09-19 00:00 +07:00 (internal working version)
|
|
128
|
+
|
|
129
|
+
- Working version for the advisory guard policy and the test journal reporter;
|
|
130
|
+
the first two live audits on the advisory guard ran with this version.
|
|
131
|
+
|
|
132
|
+
## [0.2.0] - 2026-09-18 02:00 +07:00 (internal working version)
|
|
133
|
+
|
|
134
|
+
### Added
|
|
135
|
+
|
|
136
|
+
- Prompt version `ai-coder-single/2.6.0` ships two new static modules:
|
|
137
|
+
- `code-minimalism-policy`: ordered resolution ladder before writing new code
|
|
138
|
+
(unnecessary behavior → repository → standard library → platform →
|
|
139
|
+
installed dependency → focused one-line change), and forbids weakening
|
|
140
|
+
validation, security handling, accessibility, or error reporting to reduce
|
|
141
|
+
code size.
|
|
142
|
+
- `evidence-provenance-policy`: requires `EXTRACTED`, `INFERRED`, or
|
|
143
|
+
`AMBIGUOUS` labels for non-obvious internal code claims.
|
|
144
|
+
- Completion gate now rejects `RESEARCH_CITATION_UNSUPPORTED`: every cited
|
|
145
|
+
research URL must carry successful fetch evidence before completion.
|
|
146
|
+
- Optional MCP port definition checklist in `docs/HOST_CONFORMANCE.md`
|
|
147
|
+
(Definition / Effect policy / Provider / Consumer / Conformance scenarios).
|
|
148
|
+
- Optional fast pre-push gate via `git config core.hooksPath .githooks`.
|
|
149
|
+
|
|
150
|
+
### Changed
|
|
151
|
+
|
|
152
|
+
- Project is the core exception of the Galaxy Stack plan: npm scope stays
|
|
153
|
+
`@galaxy-stack/ai-coder-core`, GitHub repository moves to the
|
|
154
|
+
[galaxy-blackhole](https://github.com/galaxy-blackhole) organization.
|
|
155
|
+
|
|
156
|
+
## [0.1.0] - 2026-09-17 14:46 +07:00 (published on npm and GitHub)
|
|
157
|
+
|
|
158
|
+
### Added
|
|
159
|
+
|
|
160
|
+
- Initial npm release of the platform-neutral single-agent runtime for
|
|
161
|
+
Galaxy AI Coder.
|
|
162
|
+
- Deterministic run controller, context manager with tamper-evident
|
|
163
|
+
checkpoints, prompt assembler, tool registry, approval policy, lexical
|
|
164
|
+
retrieval, completion gate, and trace protocol.
|
|
165
|
+
- 100 deterministic tests covering runtime, registry, approval, retrieval,
|
|
166
|
+
and checkpoint behavior.
|
package/README.md
CHANGED
|
@@ -17,9 +17,96 @@ completion gate are implemented and covered by deterministic tests.
|
|
|
17
17
|
not copy runtime logic; they should implement the same ports and pass the same
|
|
18
18
|
host conformance fixtures first.
|
|
19
19
|
|
|
20
|
-
This package is still pre-integration
|
|
21
|
-
|
|
22
|
-
the current runtime baseline.
|
|
20
|
+
This package is still pre-integration: only `galaxy-code` passes the full
|
|
21
|
+
conformance gate today. Optional MCP, semantic retrieval, background terminal
|
|
22
|
+
sessions, and subagents are outside the current runtime baseline.
|
|
23
|
+
|
|
24
|
+
## Versioning and release policy
|
|
25
|
+
|
|
26
|
+
All releases before `1.0.0` are development quality. Every release carries an
|
|
27
|
+
explicit semver pre-release tag (`x.y.z-alpha.N`) while the host conformance
|
|
28
|
+
gate is still running; stable-looking `x.y.z` numbers are reserved for
|
|
29
|
+
post-`1.0.0` releases. Publish pre-releases with a dist tag
|
|
30
|
+
(`npm publish --tag alpha`) so `npm install @galaxy-stack/ai-coder-core@latest`
|
|
31
|
+
never upgrades a consumer to an unverified alpha.
|
|
32
|
+
|
|
33
|
+
Every behavior- or API-level fix lands in [CHANGELOG.d](CHANGELOG.d/README.md)
|
|
34
|
+
as a dated fragment (date, time, area, before/after, regression requirement)
|
|
35
|
+
and is compiled into [CHANGELOG.md](CHANGELOG.md) at release time. When reading
|
|
36
|
+
any audit or live run, compare the recorded `packageVersion` against
|
|
37
|
+
[CHANGELOG.md](CHANGELOG.md) before concluding that a fixed defect recurred.
|
|
38
|
+
|
|
39
|
+
Publishing is automated through npm trusted publishing (OIDC, no stored npm
|
|
40
|
+
token): every push to `main` runs the conformance gate and
|
|
41
|
+
[.github/workflows/publish.yml](.github/workflows/publish.yml) publishes the
|
|
42
|
+
package only when `package.json` carries a version that npm does not have yet.
|
|
43
|
+
Pre-release versions publish under the `alpha` dist tag, so
|
|
44
|
+
`npm install @galaxy-stack/ai-coder-core@latest` never jumps to an unverified
|
|
45
|
+
alpha.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
Install the current development line explicitly; `latest` intentionally stays
|
|
50
|
+
on the last non-alpha release:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
npm install @galaxy-stack/ai-coder-core@alpha
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The package is ESM-only and requires Node.js 20 or newer. It does not bundle a
|
|
57
|
+
model provider, filesystem adapter, command runner, credential store, or UI.
|
|
58
|
+
Each host supplies those capabilities through typed ports.
|
|
59
|
+
|
|
60
|
+
## Basic usage
|
|
61
|
+
|
|
62
|
+
`AiCoderRunController` owns each run lifecycle; one controller may host
|
|
63
|
+
multiple distinct run IDs, while every run still has exactly one AI. A host
|
|
64
|
+
constructs the adapter set once, passes a complete request to `start`, observes
|
|
65
|
+
typed runtime events, and awaits the handle result. The same request fields
|
|
66
|
+
plus a trusted durable checkpoint are used by `resume`.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import {
|
|
70
|
+
AiCoderRunController,
|
|
71
|
+
type AiCoderRunDependencies,
|
|
72
|
+
type AiCoderRunRequest,
|
|
73
|
+
} from "@galaxy-stack/ai-coder-core";
|
|
74
|
+
|
|
75
|
+
export async function runCoder(
|
|
76
|
+
dependencies: AiCoderRunDependencies,
|
|
77
|
+
request: AiCoderRunRequest,
|
|
78
|
+
) {
|
|
79
|
+
const controller = new AiCoderRunController(dependencies);
|
|
80
|
+
const handle = controller.start(request);
|
|
81
|
+
|
|
82
|
+
// A UI may call handle.pause(), handle.cancel(), or
|
|
83
|
+
// handle.resolveApproval(requestId, decision) while result is pending.
|
|
84
|
+
return await handle.result;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Required dependencies are a `CodingModelAdapter` and an
|
|
89
|
+
`AiCoderRuntimeToolExecutor`. Production hosts should also provide a trusted
|
|
90
|
+
run store, trace port, workspace verifier, and output-spill adapter when their
|
|
91
|
+
completion requirements enable those guarantees. `galaxy-code` is the
|
|
92
|
+
reference implementation and conformance test host.
|
|
93
|
+
|
|
94
|
+
## Public API
|
|
95
|
+
|
|
96
|
+
| Export | Purpose |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `AiCoderRunController` | Start, resume, pause, cancel, and resolve approvals for a run. |
|
|
99
|
+
| `AiCoderRunRequest` / `AiCoderRunResult` | Typed task input, budgets, completion requirements, and terminal result. |
|
|
100
|
+
| `AiCoderRunDependencies` | Model, tools, persistence, trace, workspace verification, clock, and event adapters. |
|
|
101
|
+
| `AiCoderRuntimeEvent` | Model, tool, checkpoint, retry, context-pressure, state, and completion-rejection telemetry. |
|
|
102
|
+
| `evaluateAiCoderCompletion` | Pure completion-evidence evaluation for tests and host diagnostics. |
|
|
103
|
+
| `createAiCoderRunCheckpoint` / `assertAiCoderRunCheckpoint` | Durable checkpoint creation and validation. |
|
|
104
|
+
| `AiCoderToolRegistry` | Canonical tool registration and model-facing registry snapshots. |
|
|
105
|
+
|
|
106
|
+
Focused subpath exports are available at `/ports`, `/tools`, `/context`,
|
|
107
|
+
`/prompt`, `/approval`, `/retrieval`, and `/runtime`. The API is pre-1.0:
|
|
108
|
+
pin an exact alpha version in production-like hosts and review
|
|
109
|
+
[CHANGELOG.md](CHANGELOG.md) before upgrading.
|
|
23
110
|
|
|
24
111
|
## Non-negotiable invariants
|
|
25
112
|
|
|
@@ -59,7 +146,10 @@ the current runtime baseline.
|
|
|
59
146
|
fingerprint, and returning content hashes are bounded. Semantically
|
|
60
147
|
identical validation, diff, and criterion evidence does not manufacture a
|
|
61
148
|
new state transition; unresolved no-progress episodes pause with a
|
|
62
|
-
checkpoint.
|
|
149
|
+
checkpoint. Read-only observations follow the configured `noProgressPolicy`
|
|
150
|
+
(`advisory` by default: escalating nudges at `observationNudgeThresholds`,
|
|
151
|
+
blocked only after the final threshold; `strict` preserves the older
|
|
152
|
+
first-incident accounting).
|
|
63
153
|
13. Provider-reported context overflow checkpoints, compacts, and recounts
|
|
64
154
|
before another model request. Mandatory state is never silently dropped to
|
|
65
155
|
force a round through.
|
|
@@ -112,20 +202,41 @@ src/
|
|
|
112
202
|
|
|
113
203
|
## Development
|
|
114
204
|
|
|
115
|
-
|
|
205
|
+
The platform-neutral root supports Node.js 20+. Full development checks and optional SQLite adapters require Node.js 22.13+ (CI covers Node 22 and 24).
|
|
116
206
|
|
|
117
207
|
```bash
|
|
118
208
|
npm install
|
|
119
209
|
npm run verify
|
|
120
210
|
```
|
|
121
211
|
|
|
212
|
+
Optional fast pre-push gate:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
git config core.hooksPath .githooks
|
|
216
|
+
```
|
|
217
|
+
|
|
122
218
|
`npm run verify` runs strict TypeScript checks, all source tests, a clean build,
|
|
123
219
|
and a public `dist` smoke test. `npm pack --dry-run` should also be checked
|
|
124
220
|
before publishing or consuming the package from another repository.
|
|
125
221
|
|
|
126
|
-
|
|
222
|
+
`npm test` writes [TEST_ERROR_LOG.md](TEST_ERROR_LOG.md) and per-run evidence under
|
|
223
|
+
`.galaxy/tests/`: timestamped assertion results, failure stacks, test counts,
|
|
224
|
+
commit and source fingerprint. The reporter is development-only and runs without
|
|
225
|
+
a galaxy-code checkout. Raw `tsx --test` invocations bypass this reporter.
|
|
226
|
+
|
|
227
|
+
The deterministic/live/replay host gate lives in the private `testing/` workspace:
|
|
127
228
|
|
|
128
229
|
```bash
|
|
129
|
-
cd
|
|
130
|
-
npm
|
|
230
|
+
cd testing
|
|
231
|
+
npm ci
|
|
232
|
+
npm run test:local
|
|
131
233
|
```
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Agent platform and optional adapters
|
|
237
|
+
|
|
238
|
+
The runtime also supports `prompt.agentProfile: "assistant" | "research"` alongside the default coding profile. `contextData` is bounded, snapshotted and wrapped as untrusted context; it never changes approval or validation evidence.
|
|
239
|
+
|
|
240
|
+
`@galaxy-stack/ai-coder-core/agent` exports `AgentMemoryPort`, `AgentSkillsPort`, `AgentToolExecutor`, `CompositeToolExecutor`, memory/skill tool factories and profile types. Optional `.../adapters/node/*` exports provide the shared Ollama/Node tools, MCP SDK client, directory skill loader and SQLite memory. They are not imported through the platform-neutral root. The SQLite adapter requires Node >=22.13.
|
|
241
|
+
|
|
242
|
+
The executable lab moved into [testing/](testing/README.md); it is private and excluded from the npm package. Production CLI/TUI lives in the sibling `galaxy-code` repository. See [docs/AGENT_PLATFORM.md](docs/AGENT_PLATFORM.md) for APIs, current scope, commands and rollout boundaries.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type CredentialSource = "environment" | "manual-config" | "none";
|
|
2
|
+
export interface ResolvedOllamaConnection {
|
|
3
|
+
readonly apiKey?: string;
|
|
4
|
+
readonly baseUrl: string;
|
|
5
|
+
readonly configPath: string;
|
|
6
|
+
readonly credentialSource: CredentialSource;
|
|
7
|
+
readonly model: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ResolveOllamaConnectionOptions {
|
|
10
|
+
readonly baseUrl?: string;
|
|
11
|
+
readonly configPath?: string;
|
|
12
|
+
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
13
|
+
readonly model?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function resolveOllamaConnection(options?: ResolveOllamaConnectionOptions): Promise<ResolvedOllamaConnection>;
|
|
16
|
+
export declare function publicOllamaConnection(connection: ResolvedOllamaConnection): Omit<ResolvedOllamaConnection, "apiKey" | "configPath"> & Readonly<{
|
|
17
|
+
configPath: string;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=manual-provider-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-provider-config.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node/config/manual-provider-config.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,eAAe,GAAG,MAAM,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAkDD,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,wBAAwB,CAAC,CA2BnC;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,wBAAwB,GACnC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,YAAY,CAAC,GAAG,QAAQ,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAO5F"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DEFAULT_AI_CODER_CORE_SETTINGS } from "../../../index.js";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
function isObject(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function optionalNonEmpty(value) {
|
|
9
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
10
|
+
}
|
|
11
|
+
function safeProviderBaseUrl(value) {
|
|
12
|
+
let parsed;
|
|
13
|
+
try {
|
|
14
|
+
parsed = new URL(value);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new Error("Ollama base URL must be an absolute HTTP(S) URL.");
|
|
18
|
+
}
|
|
19
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
20
|
+
throw new Error("Ollama base URL must use HTTP or HTTPS.");
|
|
21
|
+
}
|
|
22
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
|
|
23
|
+
throw new Error("Ollama base URL must not contain credentials, query parameters, or a fragment.");
|
|
24
|
+
}
|
|
25
|
+
return parsed.href.replace(/\/+$/, "");
|
|
26
|
+
}
|
|
27
|
+
async function readManualAgent(configPath) {
|
|
28
|
+
let raw;
|
|
29
|
+
try {
|
|
30
|
+
raw = await readFile(configPath, "utf8");
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")
|
|
34
|
+
return null;
|
|
35
|
+
throw new Error(`Unable to read Galaxy manual config: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
if (Buffer.byteLength(raw, "utf8") > 1024 * 1024)
|
|
38
|
+
throw new Error("Galaxy manual config exceeds 1 MiB.");
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = JSON.parse(raw);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new Error("Galaxy manual config is not valid JSON.");
|
|
45
|
+
}
|
|
46
|
+
if (!isObject(parsed) || !Array.isArray(parsed.agent)) {
|
|
47
|
+
throw new Error("Galaxy manual config must contain an agent array.");
|
|
48
|
+
}
|
|
49
|
+
const manual = parsed.agent.find((entry) => isObject(entry) && entry.type === "manual");
|
|
50
|
+
if (manual === undefined)
|
|
51
|
+
return null;
|
|
52
|
+
if (!isObject(manual))
|
|
53
|
+
throw new Error("Galaxy manual provider entry is invalid.");
|
|
54
|
+
return manual;
|
|
55
|
+
}
|
|
56
|
+
export async function resolveOllamaConnection(options = {}) {
|
|
57
|
+
const configPath = options.configPath ?? join(homedir(), ".galaxy", "config.json");
|
|
58
|
+
const manual = await readManualAgent(configPath);
|
|
59
|
+
const manualApiKey = optionalNonEmpty(manual?.apiKey);
|
|
60
|
+
const environmentApiKey = optionalNonEmpty((options.environment ?? process.env).OLLAMA_API_KEY);
|
|
61
|
+
const apiKey = manualApiKey ?? environmentApiKey;
|
|
62
|
+
const credentialSource = manualApiKey !== undefined
|
|
63
|
+
? "manual-config"
|
|
64
|
+
: environmentApiKey !== undefined
|
|
65
|
+
? "environment"
|
|
66
|
+
: "none";
|
|
67
|
+
const baseUrl = safeProviderBaseUrl(options.baseUrl
|
|
68
|
+
?? optionalNonEmpty(manual?.baseUrl)
|
|
69
|
+
?? DEFAULT_AI_CODER_CORE_SETTINGS.singleAgent.baseUrl);
|
|
70
|
+
const model = options.model
|
|
71
|
+
?? optionalNonEmpty(manual?.model)
|
|
72
|
+
?? DEFAULT_AI_CODER_CORE_SETTINGS.singleAgent.model;
|
|
73
|
+
if (model.trim().length === 0)
|
|
74
|
+
throw new Error("Ollama model must be non-empty.");
|
|
75
|
+
return Object.freeze({
|
|
76
|
+
...(apiKey === undefined ? {} : { apiKey }),
|
|
77
|
+
baseUrl,
|
|
78
|
+
configPath,
|
|
79
|
+
credentialSource,
|
|
80
|
+
model: model.trim(),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export function publicOllamaConnection(connection) {
|
|
84
|
+
return Object.freeze({
|
|
85
|
+
baseUrl: connection.baseUrl,
|
|
86
|
+
configPath: connection.configPath.replace(homedir(), "~"),
|
|
87
|
+
credentialSource: connection.credentialSource,
|
|
88
|
+
model: connection.model,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=manual-provider-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-provider-config.js","sourceRoot":"","sources":["../../../../src/adapters/node/config/manual-provider-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAqBjC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;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