@orion-agents/orion-code 0.4.3 → 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.
Files changed (105) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -4
  3. package/README.zh-CN.md +4 -4
  4. package/dist/acp/session-updates.d.ts +4 -3
  5. package/dist/acp/session-updates.js +23 -2
  6. package/dist/acp/sessions.js +19 -6
  7. package/dist/commands/core-command-handlers.js +10 -22
  8. package/dist/commands/diagnostic-command-handlers.js +48 -52
  9. package/dist/commands/registry.js +1 -1
  10. package/dist/commands/target-command.js +49 -6
  11. package/dist/commands/workflow-commands.js +2 -2
  12. package/dist/core/tool-artifacts.js +17 -4
  13. package/dist/framework/loop-budget-contract.d.ts +1 -12
  14. package/dist/framework/loop-budget-contract.js +1 -7
  15. package/dist/framework/loop-progress.d.ts +3 -7
  16. package/dist/framework/loop-progress.js +7 -23
  17. package/dist/framework/query.d.ts +12 -24
  18. package/dist/framework/query.js +294 -301
  19. package/dist/framework/tool-state.d.ts +4 -0
  20. package/dist/harness/assembler.js +1 -1
  21. package/dist/harness/context-harness.d.ts +12 -2
  22. package/dist/harness/context-harness.js +288 -60
  23. package/dist/harness/contract.js +3 -1
  24. package/dist/harness/drift-guard.js +67 -17
  25. package/dist/harness/goal-verification.d.ts +11 -0
  26. package/dist/harness/goal-verification.js +62 -0
  27. package/dist/harness/index.d.ts +1 -1
  28. package/dist/harness/ledger.d.ts +1 -0
  29. package/dist/harness/ledger.js +28 -4
  30. package/dist/harness/progress-controller.js +57 -35
  31. package/dist/harness/state.js +4 -0
  32. package/dist/harness/stop-controller.d.ts +0 -5
  33. package/dist/harness/stop-controller.js +11 -31
  34. package/dist/harness/task-checklist.d.ts +12 -2
  35. package/dist/harness/task-checklist.js +50 -9
  36. package/dist/harness/types.d.ts +15 -0
  37. package/dist/harness/verification.d.ts +11 -1
  38. package/dist/harness/verification.js +47 -2
  39. package/dist/print-ui/event-stream.d.ts +5 -0
  40. package/dist/print-ui/event-stream.js +22 -5
  41. package/dist/runtime/agent-loop.d.ts +2 -1
  42. package/dist/runtime/agent-loop.js +23 -17
  43. package/dist/runtime/agent-runtime-controller.d.ts +1 -1
  44. package/dist/runtime/agent-runtime-controller.js +21 -11
  45. package/dist/runtime/batch-read-service.js +21 -4
  46. package/dist/runtime/goal-lifecycle-v2.d.ts +6 -4
  47. package/dist/runtime/goal-lifecycle-v2.js +164 -56
  48. package/dist/runtime/goal-runtime-coordinator.d.ts +6 -3
  49. package/dist/runtime/goal-runtime-coordinator.js +91 -36
  50. package/dist/runtime/goals/presentation.js +3 -1
  51. package/dist/runtime/goals/types.d.ts +1 -3
  52. package/dist/runtime/goals/types.js +0 -3
  53. package/dist/runtime/loop-budget.d.ts +0 -7
  54. package/dist/runtime/loop-budget.js +8 -54
  55. package/dist/runtime/orion-runtime-v1.js +55 -14
  56. package/dist/runtime/product-orion-runtime.js +30 -13
  57. package/dist/runtime/rsi/evaluation.js +1 -7
  58. package/dist/runtime/step-snapshot.d.ts +3 -1
  59. package/dist/runtime/step-snapshot.js +11 -1
  60. package/dist/runtime/subagent-thread-runtime.js +27 -5
  61. package/dist/runtime/subagents/production.js +0 -4
  62. package/dist/runtime/task-context-recovery.js +30 -7
  63. package/dist/runtime/task-context-service.d.ts +7 -1
  64. package/dist/runtime/task-context-service.js +40 -8
  65. package/dist/runtime/thread-admission.d.ts +2 -0
  66. package/dist/runtime/thread-admission.js +9 -1
  67. package/dist/runtime/thread-runtime.d.ts +3 -0
  68. package/dist/runtime/thread-runtime.js +42 -3
  69. package/dist/runtime/thread-ui-adapter.js +1 -11
  70. package/dist/runtime/tool-gateway.d.ts +2 -0
  71. package/dist/runtime/tool-gateway.js +4 -0
  72. package/dist/runtime/tool-receipt-validator.js +4 -0
  73. package/dist/runtime/ui-events.d.ts +3 -1
  74. package/dist/runtime/ui-view-model.js +62 -59
  75. package/dist/runtime/workspace-verification.d.ts +7 -0
  76. package/dist/runtime/workspace-verification.js +98 -0
  77. package/dist/services/chat-completion-sse.d.ts +9 -0
  78. package/dist/services/chat-completion-sse.js +50 -0
  79. package/dist/services/compact/summary-generator.d.ts +1 -1
  80. package/dist/services/compact/summary-generator.js +12 -0
  81. package/dist/services/config.js +3 -7
  82. package/dist/services/global-config.d.ts +3 -11
  83. package/dist/services/global-config.js +36 -26
  84. package/dist/services/llm.d.ts +3 -1
  85. package/dist/services/llm.js +171 -285
  86. package/dist/services/provider-diagnostics.d.ts +2 -1
  87. package/dist/services/provider-diagnostics.js +15 -4
  88. package/dist/services/provider-resilience/error-classifier.d.ts +3 -0
  89. package/dist/services/provider-resilience/error-classifier.js +14 -0
  90. package/dist/tools/core/common.d.ts +0 -11
  91. package/dist/tools/core/common.js +0 -18
  92. package/dist/tools/core/edit-file.js +61 -88
  93. package/dist/tools/core/exec-command.js +61 -80
  94. package/dist/tools/core/grep.js +84 -24
  95. package/dist/tools/core/read-file.js +3 -2
  96. package/dist/tools/core/write-file.js +5 -3
  97. package/dist/tools/todo.d.ts +2 -2
  98. package/dist/tools/todo.js +29 -10
  99. package/dist/tui-ui/chrome-view-model.js +15 -6
  100. package/dist/utils/utf8.d.ts +6 -0
  101. package/dist/utils/utf8.js +14 -0
  102. package/docs/cli-guide.md +58 -40
  103. package/docs/orion.example.yaml +4 -3
  104. package/npm-shrinkwrap.json +2 -2
  105. package/package.json +1 -1
@@ -54,9 +54,11 @@ async function writeFileSync_(path, content, cwd) {
54
54
  const previous = (0, common_1.safeStatSync)(resolved);
55
55
  const bytes = Buffer.byteLength(content, 'utf8');
56
56
  const previousText = previous && previous.size === bytes && previous.isFile() ? (0, common_1.safeReadFileSync)(resolved) : null;
57
- const changed = !previous || previous.size !== bytes || (previousText !== null && previousText !== content);
58
- (0, fs_1.mkdirSync)((0, path_1.dirname)(resolved), { recursive: true });
59
- (0, fs_1.writeFileSync)(resolved, content, 'utf-8');
57
+ const changed = previousText !== content;
58
+ if (changed) {
59
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(resolved), { recursive: true });
60
+ (0, fs_1.writeFileSync)(resolved, content, 'utf-8');
61
+ }
60
62
  return {
61
63
  success: true,
62
64
  output: `Wrote ${content.split('\n').length} lines to ${normalizedPath}`,
@@ -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[]) => 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[];
@@ -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 a separate verification step.
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 the descriptions of existing steps stable. Add new steps as needed.
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;
@@ -70,6 +71,10 @@ ${TODO_PROMPT}`,
70
71
  parameters: {
71
72
  type: 'object',
72
73
  properties: {
74
+ blockedReason: {
75
+ type: 'string',
76
+ description: 'Report a concrete blocker and finish the current turn with the active step open.',
77
+ },
73
78
  todos: {
74
79
  type: 'array',
75
80
  minItems: 1,
@@ -150,16 +155,30 @@ ${TODO_PROMPT}`,
150
155
  error: 'Only one task can be in_progress at a time',
151
156
  };
152
157
  }
153
- const error = save(normalized);
154
- if (error)
155
- return { success: false, output: '', error };
156
- const completed = normalized.filter(todo => todo.status === 'completed').length;
157
- const current = normalized.find(todo => todo.status === 'in_progress');
158
+ const blocker = args.blockedReason;
159
+ if (blocker !== undefined &&
160
+ (typeof blocker !== 'string' ||
161
+ !blocker.trim() ||
162
+ blocker.length > 400 ||
163
+ inProgressCount !== 1)) {
164
+ return {
165
+ success: false,
166
+ output: '',
167
+ error: 'A blocker requires one active todo and a reason of up to 400 characters.',
168
+ };
169
+ }
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');
158
177
  return {
159
178
  success: true,
160
- output: formatTodosForDisplay(normalized),
161
- summary: `${completed}/${normalized.length} complete${current ? ` · ${current.activeForm}` : ''}`,
162
- metadata: { taskTodos: normalized },
179
+ output,
180
+ summary: `${completed}/${applied.length} complete${current ? ` · ${current.activeForm}` : ''}`,
181
+ metadata: { taskTodos: applied },
163
182
  };
164
183
  },
165
184
  isReadOnly: () => false,
@@ -44,7 +44,7 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
44
44
  ? 'BUILD'
45
45
  : state.agentMode.pendingBaseMode.toUpperCase()
46
46
  : null;
47
- const goalMode = Boolean(state.goal);
47
+ const goalMode = state.goal?.status === 'active';
48
48
  const modeLabel = `${goalMode ? `GOAL · ${baseModeLabel}` : baseModeLabel}${pendingModeLabel ? ` → ${pendingModeLabel} NEXT` : ''}`;
49
49
  const baseTone = state.agentMode.baseMode === 'plan'
50
50
  ? 'mode-plan'
@@ -63,7 +63,14 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
63
63
  : '';
64
64
  const objective = ` ${state.goal.objective}`;
65
65
  const plan = state.goal.planPhase ? ` ${state.goal.planPhase}` : '';
66
- const usage = ` tokens:${formatGoalTokenUsage(state.goal.tokensUsed)}`;
66
+ const budgetLimited = state.goal.status === 'budget_limited';
67
+ const tokenLimit = budgetLimited ? state.goal.tokenBudget : undefined;
68
+ const timeLimit = budgetLimited ? state.goal.timeBudgetMs : undefined;
69
+ const tokens = formatGoalTokenUsage(state.goal.tokensUsed);
70
+ const usage = `tokens:${tokens}${tokenLimit === undefined ? '' : `/${formatGoalTokenUsage(tokenLimit)}`}`;
71
+ const time = timeLimit === undefined
72
+ ? ''
73
+ : ` time:${Math.floor(state.goal.timeUsedMs / 1000)}/${timeLimit / 1000}s`;
67
74
  const statusShowsAudit = state.statusMessage.startsWith('Goal audit failed (');
68
75
  const audit = !statusShowsAudit && state.goal.auditRemaining?.[0]
69
76
  ? ` audit:${state.goal.auditRemaining[0]}`
@@ -71,10 +78,12 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
71
78
  const next = state.goal.nextAction && !state.statusMessage.includes(state.goal.nextAction)
72
79
  ? ` next:${state.goal.nextAction}`
73
80
  : '';
74
- const actions = state.goal.stopReason
75
- ? ` ${(state.goal.stopReason.match(/\/goal\s+(?:resume|clear)\b/giu) ?? []).join(' ')}`
76
- : '';
77
- const progressLabel = `${usage.trim()}${actions} goal:${state.goal.status}${progress}`;
81
+ const actions = budgetLimited
82
+ ? ' /goal budget'
83
+ : ['paused', 'blocked', 'usage_limited'].includes(state.goal.status)
84
+ ? ' /goal resume /goal clear'
85
+ : '';
86
+ const progressLabel = `goal:${state.goal.status}${progress}${actions} ${usage}${time}`;
78
87
  all.set('goal', {
79
88
  id: 'goal',
80
89
  // Usage is the durable progress signal operators need most. Keep it at
@@ -0,0 +1,6 @@
1
+ /** Clip UTF-8 text to a byte budget without splitting a character. */
2
+ export declare function truncateToBytes(text: string, maxBytes: number): {
3
+ text: string;
4
+ bytes: number;
5
+ };
6
+ //# sourceMappingURL=utf8.d.ts.map
@@ -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
@@ -63,6 +63,7 @@ JSONL stdout 每行是一个独立的 JSON 对象。每条记录有 `schemaVersi
63
63
 
64
64
  最后一行始终为 `result`,包含 `status`、`reasonCode`、`exitCode` 与 `resumable`。
65
65
  进程退出码与该行一致。
66
+ 当当前回合的持久化回执包含用量时,`result.metrics.llmRequests` 和 `result.metrics.toolCalls` 提供模型请求数和工具调用数。
66
67
 
67
68
  | `status` | 退出码 | 含义 |
68
69
  | --- | ---: | --- |
@@ -72,7 +73,7 @@ JSONL stdout 每行是一个独立的 JSON 对象。每条记录有 `schemaVersi
72
73
  | `approval_required` | 3 | 需要交互式授权,待审批操作未执行 |
73
74
  | `cancelled` | 130 | 请求被中断 |
74
75
 
75
- `reasonCode` 细化原因,例如 `llm_request_budget`、`provider_auth_failed` 和
76
+ `reasonCode` 细化原因,例如 `goal_time_budget`、`provider_auth_failed` 和
76
77
  `resume_failed`。选择默认文本或 `--output-format json` 时,输出和默认退出行为继续适用。
77
78
  为这两类输出加 `--strict-exit` 可启用上表退出码。
78
79
 
@@ -101,30 +102,39 @@ JSONL stdout 每行是一个独立的 JSON 对象。每条记录有 `schemaVersi
101
102
 
102
103
  启动方式遵循 [ACP v1 stdio 规范](https://agentclientprotocol.com/protocol/v1/transports)。
103
104
 
104
- ## Goal 续跑与检查点
105
+ ## Goal 续跑
105
106
 
106
- 只有明确创建的 Goal 可以自动续跑;普通对话不会自动升级为 Goal。新建 Goal 默认总预算为
107
- 100 万 tokens、2 小时活动回合时间,可在 `agentLoop.goalBudget.maxTokens` 和
108
- `maxElapsedMs` 中设置。总用量和预算随 Goal 一起保存,暂停、恢复和重启不会清零;
109
- 重启不自动恢复已暂停的 Goal。该时间是活动回合累计时间,不包含用户暂停期间。
110
- `/goal status` 展示已用与总量;已耗尽的 Goal 不能通过 `/goal resume` 重新获得预算。
111
- 需要更多资源时先检查证据、清除当前 Goal,再以适当配置明确新建 Goal。
107
+ 明确创建的 Goal 会按会话续跑。`/goal status` 显示当前状态、累计用量、预算和可采取的操作。
108
+ 新建 Goal 默认不设 token 或活动时间上限。可用 `agentLoop.goalBudget` 设置默认总量和授权上限,
109
+ 也可在创建时指定单个 Goal 的限额。时间预算以毫秒计,仅累计 Goal 自身的活动回合时间。
112
110
 
113
- `agentLoop.continuation: agent` 为默认值;`manual` 在每次 Goal 回合后保存并暂停,
114
- 由 `/goal resume` 启动下一回合。配置只影响新建 Goal 的总预算,不能通过重启绕开既有预算。
115
- 每轮的请求/工具预算使用明确的用户目标与配置选择任务档位,不使用模型生成的续跑文字
116
- 提升档位;当前 CLI 运行链路不会套用旧的 8 请求固定上限。
111
+ ```text
112
+ /goal --max-tokens 50000 --max-elapsed-ms 600000 -- 修复失败的测试并验证
113
+ /goal status
114
+ /goal budget --max-tokens 100000
115
+ /goal resume
116
+ ```
117
+
118
+ 进入 `budget_limited` 后,先用 `/goal budget` 授权高于已用量和原上限的新总量。如果两个资源均已
119
+ 耗尽,需要分别提高。调整会保存新额度,随后用 `/goal resume` 继续原 Goal。Goal ID、历史、累计用量、
120
+ 清单与证据随会话恢复。如果配置的上限较低,需要先在 `orion.yaml` 中调整上限。
121
+
122
+ `paused` 和 `blocked` 显示暂停原因。Provider 配额耗尽进入 `usage_limited`,提供方给出重试时间
123
+ 时会一并显示。恢复服务或解决阻塞后执行 `/goal resume`。已经停止的 Goal 所在会话里,发送普通
124
+ `continue` 仍会走对话回合,Goal 的预算和状态保持原值。
125
+
126
+ `agentLoop.continuation: agent` 为默认值。Goal 回合结束后,运行时先保存完整工具分组、TaskContext
127
+ 和 Goal 状态。仍处于活动状态的 Goal 在会话空闲时续跑,已排队的用户输入优先。`manual` 在每个
128
+ 需要继续的 Goal 回合后暂停,由 `/goal resume` 启动下一回合。
117
129
 
118
- 达到单轮请求或工具预算时先保存 TaskContext、完整工具分组和 Goal 状态。仅当尚有未完成
119
- 工作,且这一轮实际产生结构化、成功、带零退出码的验证证据时,才输出检查点并自动进入
120
- 下一轮。同一个旧验证记录不能在后续检查点重复换取续跑。读取文件、修改计划、模型声称
121
- “已完成”或失败测试都不能代替成功验证。没有 Agent 编写的 todo 时,TaskContext 使用
122
- 自身验收项作为工作列表,以稳定 criterion id 和证据状态展示;已通过或用户授权豁免的
123
- 验收项显示完成,未通过项保持待办。显式 todo 的展示优先。
130
+ Goal 运行时,可直接发送同类检查的更正,例如「把 `npm test -- alpha` 替换成 `npm test -- beta`」。
131
+ 如果同一命令在多个目录都是必需检查,请同时指定原检查的工作区相对目录。更正会随 Goal 保存,
132
+ 新检查通过后才满足该项验收。选不出唯一原检查时,Goal 会提示明确指定。
124
133
 
125
- 没有剩余计划/验证证据时会暂停并解释原因,使用 `/goal resume` 需要先检查当前状态。
126
- Goal 总预算、连续无进展、持续阻塞、Provider 故障和用户中断仍优先停止续跑。
127
- 检查点说明以持久化会话活动显示,实际证据引用和累计资源保存在对应 TurnCommit 中。
134
+ 模型选择完成时,TaskContext 核对成功验证及其他验收证据。背景调查和失败后的排查可以继续推进。
135
+ 切换策略、等待压缩或单次测试失败产生的状态随回合落盘。Goal 只有在证据满足时才显示 `completed`,
136
+ 此时可在 `/goal status` 查看完成证据与累计用量。用 `/usage` 可分别查看文件改动、验证、任务状态、
137
+ 只读探索和可见输出。
128
138
 
129
139
  ## RSI 优化项目 Skill
130
140
 
@@ -140,7 +150,7 @@ orion rsi resume --run ./rsi-run
140
150
 
141
151
  `selection.json` 包含 `version: 1`、仓库根目录的绝对路径 `repository`、完整的 Git `baseCommit`、以及 1–16 条已完成或失败的持久化回合 `turns`。每条回合包含 `sessionId`、`turnId`、`category`、`result`,也可指定 `skill`。类别为 `cross_module_callers`、`local_edit_cost`、`missing_verification`、`missing_tool`,反馈结果为 `corrected`、`failed`、`accepted`。
142
152
 
143
- `suite.json` 使用 `version: 1`、本地 OpenAI 兼容 `endpoint`(`http://127.0.0.1:端口/v1`)、`model`、`repeats`、`maxRequests`、`maxTools`、`maxTokens`、`timeoutMs`。每个 `tasks` 条目包含 `id`、`split`、`category`、`prompt`、初始 `files` 和 `expected`。`expected` 指定允许修改的路径及其验收全文,其余文件保持原样。留出组覆盖四类任务,开发组使用独立样本。为本地兼容服务选择固定模型,两组共用同一模型档案。每轮的请求、工具和时间有单组限制,记录到的 token 超预算时结果为 `inconclusive`。样本提示和 fixture 文件可能进入操作者选中的本地模型服务,输入应使用获准的测试数据。
153
+ `suite.json` 使用 `version: 1`、本地 OpenAI 兼容 `endpoint`(`http://127.0.0.1:端口/v1`)、`model`、`repeats`、`maxRequests`、`maxTools`、`maxTokens`、`timeoutMs`。每个 `tasks` 条目包含 `id`、`split`、`category`、`prompt`、初始 `files` 和 `expected`。`expected` 指定允许修改的路径及其验收全文,其余文件保持原样。留出组覆盖四类任务,开发组使用独立样本。为本地兼容服务选择固定模型,两组共用同一模型档案。`timeoutMs` 限制每组评估进程的运行时间。请求数、工具数或 token 超出评估额度时,结果为 `inconclusive`。样本提示和 fixture 文件可能进入操作者选中的本地模型服务,输入应使用获准的测试数据。
144
154
 
145
155
  `propose --input selection.json --out ./rsi-run` 可单独生成提案;之后运行 `evaluate --run ./rsi-run --suite suite.json`。取消或中断后,`resume` 继续还未领取的配对,已发起但未完整记录的配对保留为 `indeterminate`。重复执行复用已有收据。源代码中 `scripts/smoke/rsi-proposal-smoke.py` 的 `task_suite` 函数提供完整样本。
146
156
 
@@ -174,14 +184,11 @@ orion rsi observe --run ./rsi-run --input rollback-follow-up.json
174
184
  额度耗尽后,每个结果仍保留最多 2 KiB 的恢复预览(显式单结果上限更低时取较低值),
175
185
  保留实际成功/失败、错误及可容纳的正文,不再用同一遗漏提示替代随后的小结果。
176
186
  完整输出及 artifact 引用仍通过原始工具事件保存。预览不是完整文件,截断不代表命令失败。
177
- 共享额度是压缩阈值;模型可见总量仍受“额度 + 工具调用数上限 × 恢复预览上限”约束,
178
- 实际字节数包含 JSON 信封并如实计入统计,不通过少计字节规避预算。
187
+ 共享额度是压缩阈值。实际字节数包含 JSON 信封,模型上下文达到容量边界时由压缩恢复处理。
179
188
 
180
189
  普通 BUILD/AUTO 回合有成功工具结果、模型可见工具输出用到共享额度的 90% 时,可尝试一次本地
181
- 压缩。压缩会保留完整工具分组和原始记录,并且无需额外模型摘要请求。复杂或发布档位到达默认请求
182
- 上限时,如果压缩后仍留有足够上下文,本轮最多继续 8 次模型请求。显式配置的请求上限严格执行,
183
- 工具调用上限和累计字节统计照常生效。达到最终上限时,终端显示停止原因和恢复方式,可用 `/usage`
184
- 查看档位、用量及上限。Goal 续跑仍由 Goal 自己的检查点和总预算决定。
190
+ 压缩。压缩会保留完整工具分组和原始记录,且无需额外模型摘要请求。`/usage` 显示模型请求数、
191
+ 工具调用数和当前的工具结果压缩额度。
185
192
 
186
193
  每个模型可见结果的 `metadata` 包含 `budgetLimitBytes`、`budgetRemainingBytes`、
187
194
  `budgetExhausted` 和 `budgetSnapshot: before_result`,明确表示该结果加入前的余额。
@@ -221,6 +228,25 @@ Agent 应按预估字节安排批量读取,优先读取行范围或搜索命
221
228
  [变更记录](../CHANGELOG.md)和[中文快速开始](../README.zh-CN.md)不承诺 npm 已发布;
222
229
  registry、tag、Release 与本地安装状态需要独立核验。
223
230
 
231
+ ### npm 自动发布
232
+
233
+ 正式版以 `main` 上的 `package.json` 中 `version` 为准。发布 PR 同步更新
234
+ `npm-shrinkwrap.json`、`CHANGELOG.md` 和两份 README 的版本说明及安装命令。
235
+ 版本须是高于 npm 当前 `latest` 的新稳定版。当前版本和预发布版本会跳过。
236
+ 首次上传后会等待 npm Registry 处理。目标版本已经可见但 `latest` 尚未更新时,
237
+ 重新运行会验证已有包的完整性并继续等待,避免重复上传。
238
+
239
+ `main` 的 CI 通过后,`npm-publish.yml` 下载该次 CI 的 `release-package` 和
240
+ `release-receipt`。它核对 `GO`、源提交、版本与 tarball 校验值,再将同一个包发布到
241
+ `@orion-agents/orion-code` 的 `latest`,并从 npm registry 核对标签和包完整性。
242
+ `main` 已推进时由新提交的 CI 接续。重新通过门禁即可处理仍未发布的版本。
243
+
244
+ 首次在 [npm 包设置](https://www.npmjs.com/package/@orion-agents/orion-code/access) 绑定 GitHub Actions
245
+ Trusted Publisher。仓库填 `orion-agents/orion-code`,工作流填 `npm-publish.yml`,环境填
246
+ `npm-release`,启用 **Allow npm publish**。GitHub 的 `npm-release` 环境限定 `main` 分支。
247
+ 绑定后两天内完成首次正式发布,后续由工作流通过 OIDC 自动认证。
248
+ [npm Trusted Publishing 说明](https://docs.npmjs.com/trusted-publishers/)
249
+
224
250
  ## YAML 配置参数参考
225
251
 
226
252
  初始化只需配置模型连接,内置工具和已接入的扩展工具默认可用。
@@ -404,16 +430,12 @@ projects:
404
430
  会话存储维护最近激活的会话。`/resume --last` 优先加载当前项目最近激活且可恢复的会话,
405
431
  否则按项目历史选择。`/resume` 仍可从列表选择。
406
432
 
407
- ### 单轮预算与 Goal
433
+ ### 工具输出与 Goal 预算
408
434
 
409
435
  ```yaml
410
436
  agentLoop:
411
437
  continuation: agent
412
- budgetPolicy: fixed
413
438
  budget:
414
- maxLlmRequestsPerUserTurn: 24
415
- maxToolCallsPerUserTurn: 120
416
- maxReadOnlyFragmentation: 3
417
439
  maxModelVisibleToolBytes: 65536
418
440
  goalBudget:
419
441
  maxTokens: 1000000
@@ -423,17 +445,13 @@ agentLoop:
423
445
  | 字段 | 省略时的行为/单位 |
424
446
  | --- | --- |
425
447
  | `continuation` | 默认 `agent`;`manual` 每次 Goal 回合后暂停,等待明确 resume |
426
- | `budgetPolicy` | BUILD / AUTO 默认 `adaptive`,依据实际工具结果判断是否继续。`fixed` 按设定的请求上限停止 |
427
- | `budget.maxLlmRequestsPerUserTurn` | 显式填写即启用硬上限。默认 `24`、复杂 `48`、发布 `64` 在自适应模式下用作进度检查点 |
428
- | `budget.maxToolCallsPerUserTurn` | 默认 `120` 次工具调用;复杂/发布档位 `180 / 240` |
429
- | `budget.maxReadOnlyFragmentation` | 默认 `3`;连续单个只读调用后注入批量读取建议,不是并发数 |
430
448
  | `budget.maxModelVisibleToolBytes` | 默认 `65536` bytes;复杂/发布档位 `98304 / 131072`;是压缩额度,详见工具输出预算 |
431
449
  | `goalBudget.maxTokens` | 新建 Goal 默认总预算 `1000000` tokens,含模型请求累计用量 |
432
450
  | `goalBudget.maxElapsedMs` | 新建 Goal 默认 `7200000` 毫秒,即两小时活动回合累计时间 |
433
451
 
434
- 这些数字均须为正安全整数。自适应模式连续 8 次请求未获得新工具证据时提示改变做法,再尝试一个同样长度的窗口,仍无进展则暂停。单回合最多 256 次模型请求以保护资源,工具调用上限继续生效。`/usage` 显示本轮策略和停止原因。
435
- 新建 Goal 使用新总预算,已保存 Goal 的预算/用量不会因修改 YAML 或重启清零。
436
- 开启 `agent` 不会把普通对话自动变成 Goal;检查点依旧需要未完成工作与本轮成功验证证据。
452
+ 这些数字均须为正安全整数。模型根据收到的工具结果决定是否继续,`/usage` 显示模型请求数、工具调用数和停止原因。
453
+ Orion 读取旧配置时会忽略 `budgetPolicy`、`maxLlmRequestsPerUserTurn`、`maxToolCallsPerUserTurn` 和 `maxReadOnlyFragmentation`,下次保存规范 YAML 时移除这些键。
454
+ 新建 Goal 使用配置中的累计 token 和活跃耗时预算。修改 YAML 或重启后,已有 Goal 继续使用保存的预算和用量。预算到期会停止活动回合并暂停 Goal。只有用户明确创建的 Goal 才能自动续作。
437
455
 
438
456
  ### TUI
439
457
 
@@ -28,11 +28,12 @@ defaultModel: example-model
28
28
 
29
29
  # Optional: only explicitly created Goals may continue autonomously.
30
30
  # agentLoop:
31
- # budgetPolicy: adaptive # fixed uses the selected profile's request cap
32
31
  # continuation: agent # manual pauses after each Goal turn
32
+ # budget:
33
+ # maxModelVisibleToolBytes: 65536
33
34
  # goalBudget:
34
- # maxTokens: 1000000
35
- # maxElapsedMs: 7200000 # accumulated active turn time, not paused time
35
+ # maxTokens: 1000000 # optional default and authorization ceiling
36
+ # maxElapsedMs: 7200000 # optional default and ceiling for active Goal time
36
37
 
37
38
  # Optional TUI settings
38
39
  # ui:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@orion-agents/orion-code",
3
- "version": "0.4.3",
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.3",
9
+ "version": "0.4.5",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "2.12.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-agents/orion-code",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Orion Code - local-first goal-driven coding agent for the terminal.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",