@orion-agents/orion-code 0.4.4 → 0.4.5
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.md +8 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/core/tool-artifacts.js +17 -4
- package/dist/framework/query.js +150 -16
- package/dist/framework/tool-state.d.ts +4 -0
- package/dist/harness/context-harness.d.ts +6 -2
- package/dist/harness/context-harness.js +221 -47
- package/dist/harness/contract.js +3 -1
- package/dist/harness/drift-guard.js +67 -17
- package/dist/harness/goal-verification.d.ts +11 -0
- package/dist/harness/goal-verification.js +62 -0
- package/dist/harness/ledger.js +16 -3
- package/dist/harness/state.js +3 -0
- package/dist/harness/task-checklist.d.ts +11 -1
- package/dist/harness/task-checklist.js +48 -4
- package/dist/harness/types.d.ts +10 -0
- package/dist/harness/verification.d.ts +11 -1
- package/dist/harness/verification.js +47 -2
- package/dist/runtime/agent-loop.js +4 -1
- package/dist/runtime/batch-read-service.js +21 -4
- package/dist/runtime/goal-runtime-coordinator.js +1 -0
- package/dist/runtime/product-orion-runtime.js +24 -2
- package/dist/runtime/task-context-recovery.js +21 -5
- package/dist/runtime/task-context-service.d.ts +3 -1
- package/dist/runtime/task-context-service.js +3 -0
- package/dist/runtime/workspace-verification.d.ts +2 -2
- package/dist/runtime/workspace-verification.js +24 -9
- package/dist/services/chat-completion-sse.d.ts +9 -0
- package/dist/services/chat-completion-sse.js +50 -0
- package/dist/services/compact/summary-generator.d.ts +1 -1
- package/dist/services/compact/summary-generator.js +12 -0
- package/dist/services/llm.d.ts +1 -1
- package/dist/services/llm.js +165 -292
- package/dist/services/provider-diagnostics.d.ts +1 -1
- package/dist/services/provider-diagnostics.js +7 -2
- package/dist/services/provider-resilience/error-classifier.d.ts +3 -0
- package/dist/services/provider-resilience/error-classifier.js +14 -0
- package/dist/tools/core/common.d.ts +0 -11
- package/dist/tools/core/common.js +0 -18
- package/dist/tools/core/edit-file.js +57 -86
- package/dist/tools/core/exec-command.js +61 -80
- package/dist/tools/core/grep.js +84 -24
- package/dist/tools/core/read-file.js +3 -2
- package/dist/tools/todo.d.ts +2 -2
- package/dist/tools/todo.js +13 -10
- package/dist/utils/utf8.d.ts +6 -0
- package/dist/utils/utf8.js +14 -0
- package/docs/cli-guide.md +7 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const tool_1 = require("../../framework/tool");
|
|
6
6
|
const descriptors_1 = require("../../runtime/core-tools/descriptors");
|
|
7
7
|
const errors_1 = require("../../utils/errors");
|
|
8
|
+
const utf8_1 = require("../../utils/utf8");
|
|
8
9
|
const common_1 = require("./common");
|
|
9
10
|
const descriptor = (0, descriptors_1.coreToolDescriptorV1)('read_file');
|
|
10
11
|
exports.coreTool = (0, tool_1.buildTool)({
|
|
@@ -103,7 +104,7 @@ async function readFileSync_(path, maxLines, offset, cwd) {
|
|
|
103
104
|
const byteLen = Buffer.byteLength(selected, 'utf8');
|
|
104
105
|
const notice = `\n\n[... truncated, ${remainingLines} more lines; showing lines ${offset}-${offset + selectedLines.length - 1} of ${lines.length}]`;
|
|
105
106
|
if (byteLen > maxBytes) {
|
|
106
|
-
const cut = (0,
|
|
107
|
+
const cut = (0, utf8_1.truncateToBytes)(selected, maxBytes);
|
|
107
108
|
return {
|
|
108
109
|
success: true,
|
|
109
110
|
output: cut.text + `\n\n[... truncated at ${cut.bytes}B]`,
|
|
@@ -114,7 +115,7 @@ async function readFileSync_(path, maxLines, offset, cwd) {
|
|
|
114
115
|
// Also apply byte limit to the selected page.
|
|
115
116
|
const byteLen = Buffer.byteLength(selected, 'utf8');
|
|
116
117
|
if (byteLen > maxBytes) {
|
|
117
|
-
const cut = (0,
|
|
118
|
+
const cut = (0, utf8_1.truncateToBytes)(selected, maxBytes);
|
|
118
119
|
return {
|
|
119
120
|
success: true,
|
|
120
121
|
output: cut.text + `\n\n[... truncated at ${cut.bytes}B of ${byteLen}B]`,
|
package/dist/tools/todo.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* The caller owns the checklist state. The production runtime saves it in TaskContext.
|
|
7
7
|
*/
|
|
8
8
|
import { type OrionCodeTool } from '../framework/tool';
|
|
9
|
-
import type { TodoItem, ToolStateStore } from '../framework/tool-state';
|
|
9
|
+
import type { TodoItem, TodoWriteAdjustment, ToolStateStore } from '../framework/tool-state';
|
|
10
10
|
export declare const MAX_TODOS = 8;
|
|
11
11
|
export declare const MAX_TODO_TEXT = 120;
|
|
12
|
-
export declare function createTodoWriteTool(save: (todos: TodoItem[], blockedReason?: string) => string | void): OrionCodeTool;
|
|
12
|
+
export declare function createTodoWriteTool(save: (todos: TodoItem[], blockedReason?: string) => TodoWriteAdjustment | string | void): OrionCodeTool;
|
|
13
13
|
export declare function createTodoTools(state: ToolStateStore): OrionCodeTool[];
|
|
14
14
|
/** Get current todos (for UI display) */
|
|
15
15
|
export declare function getCurrentTodos(state: ToolStateStore): TodoItem[];
|
package/dist/tools/todo.js
CHANGED
|
@@ -21,7 +21,7 @@ const TODO_PROMPT = `Use this tool to create and manage a structured task list f
|
|
|
21
21
|
|
|
22
22
|
## When to Use This Tool
|
|
23
23
|
|
|
24
|
-
If the task context requires a checklist, create it before changing the workspace. Name the exact target paths in the implementation steps and include
|
|
24
|
+
If the task context requires a checklist, create it before changing the workspace. Name the exact target paths in the implementation steps and include verification.
|
|
25
25
|
|
|
26
26
|
1. Complex multi-step tasks - When a task requires 3 or more distinct steps
|
|
27
27
|
2. Non-trivial tasks - Tasks that require careful planning or multiple operations
|
|
@@ -56,8 +56,9 @@ For verification steps, also include verification with the required check kinds
|
|
|
56
56
|
|
|
57
57
|
- Keep at most ONE task in_progress at a time
|
|
58
58
|
- Mark tasks complete IMMEDIATELY after finishing
|
|
59
|
-
- Keep
|
|
59
|
+
- Keep descriptions stable. To clarify an unfinished step, replace its bare filename with the exact workspace-relative path.
|
|
60
60
|
- Only mark a step completed after running its work and checks while it is in progress.
|
|
61
|
+
- An implementation step with verification requires both a file change and a passing check.
|
|
61
62
|
- Run each verification command directly with exec_command and use its cwd argument for the project directory. If a check fails, retry that check successfully before completing the step.`;
|
|
62
63
|
exports.MAX_TODOS = 8;
|
|
63
64
|
exports.MAX_TODO_TEXT = 120;
|
|
@@ -166,16 +167,18 @@ ${TODO_PROMPT}`,
|
|
|
166
167
|
error: 'A blocker requires one active todo and a reason of up to 400 characters.',
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
return { success: false, output: '', error };
|
|
172
|
-
const
|
|
173
|
-
const
|
|
170
|
+
const saved = typeof blocker === 'string' ? save(normalized, blocker.trim()) : save(normalized);
|
|
171
|
+
if (typeof saved === 'string')
|
|
172
|
+
return { success: false, output: '', error: saved };
|
|
173
|
+
const applied = saved?.todos ?? normalized;
|
|
174
|
+
const completed = applied.filter(todo => todo.status === 'completed').length;
|
|
175
|
+
const current = applied.find(todo => todo.status === 'in_progress');
|
|
176
|
+
const output = [formatTodosForDisplay(applied), ...(saved?.warnings ?? [])].join('\n');
|
|
174
177
|
return {
|
|
175
178
|
success: true,
|
|
176
|
-
output
|
|
177
|
-
summary: `${completed}/${
|
|
178
|
-
metadata: { taskTodos:
|
|
179
|
+
output,
|
|
180
|
+
summary: `${completed}/${applied.length} complete${current ? ` · ${current.activeForm}` : ''}`,
|
|
181
|
+
metadata: { taskTodos: applied },
|
|
179
182
|
};
|
|
180
183
|
},
|
|
181
184
|
isReadOnly: () => false,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.truncateToBytes = truncateToBytes;
|
|
4
|
+
/** Clip UTF-8 text to a byte budget without splitting a character. */
|
|
5
|
+
function truncateToBytes(text, maxBytes) {
|
|
6
|
+
const buffer = Buffer.from(text, 'utf8');
|
|
7
|
+
if (buffer.length <= maxBytes)
|
|
8
|
+
return { text, bytes: buffer.length };
|
|
9
|
+
let cut = Math.max(0, maxBytes);
|
|
10
|
+
while (cut > 0 && (buffer[cut] & 0xc0) === 0x80)
|
|
11
|
+
cut--;
|
|
12
|
+
return { text: buffer.subarray(0, cut).toString('utf8'), bytes: cut };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=utf8.js.map
|
package/docs/cli-guide.md
CHANGED
|
@@ -127,6 +127,10 @@ JSONL stdout 每行是一个独立的 JSON 对象。每条记录有 `schemaVersi
|
|
|
127
127
|
和 Goal 状态。仍处于活动状态的 Goal 在会话空闲时续跑,已排队的用户输入优先。`manual` 在每个
|
|
128
128
|
需要继续的 Goal 回合后暂停,由 `/goal resume` 启动下一回合。
|
|
129
129
|
|
|
130
|
+
Goal 运行时,可直接发送同类检查的更正,例如「把 `npm test -- alpha` 替换成 `npm test -- beta`」。
|
|
131
|
+
如果同一命令在多个目录都是必需检查,请同时指定原检查的工作区相对目录。更正会随 Goal 保存,
|
|
132
|
+
新检查通过后才满足该项验收。选不出唯一原检查时,Goal 会提示明确指定。
|
|
133
|
+
|
|
130
134
|
模型选择完成时,TaskContext 核对成功验证及其他验收证据。背景调查和失败后的排查可以继续推进。
|
|
131
135
|
切换策略、等待压缩或单次测试失败产生的状态随回合落盘。Goal 只有在证据满足时才显示 `completed`,
|
|
132
136
|
此时可在 `/goal status` 查看完成证据与累计用量。用 `/usage` 可分别查看文件改动、验证、任务状态、
|
|
@@ -228,8 +232,9 @@ registry、tag、Release 与本地安装状态需要独立核验。
|
|
|
228
232
|
|
|
229
233
|
正式版以 `main` 上的 `package.json` 中 `version` 为准。发布 PR 同步更新
|
|
230
234
|
`npm-shrinkwrap.json`、`CHANGELOG.md` 和两份 README 的版本说明及安装命令。
|
|
231
|
-
版本须是高于 npm 当前 `latest`
|
|
232
|
-
|
|
235
|
+
版本须是高于 npm 当前 `latest` 的新稳定版。当前版本和预发布版本会跳过。
|
|
236
|
+
首次上传后会等待 npm Registry 处理。目标版本已经可见但 `latest` 尚未更新时,
|
|
237
|
+
重新运行会验证已有包的完整性并继续等待,避免重复上传。
|
|
233
238
|
|
|
234
239
|
`main` 的 CI 通过后,`npm-publish.yml` 下载该次 CI 的 `release-package` 和
|
|
235
240
|
`release-receipt`。它核对 `GO`、源提交、版本与 tarball 校验值,再将同一个包发布到
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-agents/orion-code",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@orion-agents/orion-code",
|
|
9
|
-
"version": "0.4.
|
|
9
|
+
"version": "0.4.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "2.12.0",
|