@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.
- package/CHANGELOG.md +14 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/acp/session-updates.d.ts +4 -3
- package/dist/acp/session-updates.js +23 -2
- package/dist/acp/sessions.js +19 -6
- package/dist/commands/core-command-handlers.js +10 -22
- package/dist/commands/diagnostic-command-handlers.js +48 -52
- package/dist/commands/registry.js +1 -1
- package/dist/commands/target-command.js +49 -6
- package/dist/commands/workflow-commands.js +2 -2
- package/dist/core/tool-artifacts.js +17 -4
- package/dist/framework/loop-budget-contract.d.ts +1 -12
- package/dist/framework/loop-budget-contract.js +1 -7
- package/dist/framework/loop-progress.d.ts +3 -7
- package/dist/framework/loop-progress.js +7 -23
- package/dist/framework/query.d.ts +12 -24
- package/dist/framework/query.js +294 -301
- package/dist/framework/tool-state.d.ts +4 -0
- package/dist/harness/assembler.js +1 -1
- package/dist/harness/context-harness.d.ts +12 -2
- package/dist/harness/context-harness.js +288 -60
- 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/index.d.ts +1 -1
- package/dist/harness/ledger.d.ts +1 -0
- package/dist/harness/ledger.js +28 -4
- package/dist/harness/progress-controller.js +57 -35
- package/dist/harness/state.js +4 -0
- package/dist/harness/stop-controller.d.ts +0 -5
- package/dist/harness/stop-controller.js +11 -31
- package/dist/harness/task-checklist.d.ts +12 -2
- package/dist/harness/task-checklist.js +50 -9
- package/dist/harness/types.d.ts +15 -0
- package/dist/harness/verification.d.ts +11 -1
- package/dist/harness/verification.js +47 -2
- package/dist/print-ui/event-stream.d.ts +5 -0
- package/dist/print-ui/event-stream.js +22 -5
- package/dist/runtime/agent-loop.d.ts +2 -1
- package/dist/runtime/agent-loop.js +23 -17
- package/dist/runtime/agent-runtime-controller.d.ts +1 -1
- package/dist/runtime/agent-runtime-controller.js +21 -11
- package/dist/runtime/batch-read-service.js +21 -4
- package/dist/runtime/goal-lifecycle-v2.d.ts +6 -4
- package/dist/runtime/goal-lifecycle-v2.js +164 -56
- package/dist/runtime/goal-runtime-coordinator.d.ts +6 -3
- package/dist/runtime/goal-runtime-coordinator.js +91 -36
- package/dist/runtime/goals/presentation.js +3 -1
- package/dist/runtime/goals/types.d.ts +1 -3
- package/dist/runtime/goals/types.js +0 -3
- package/dist/runtime/loop-budget.d.ts +0 -7
- package/dist/runtime/loop-budget.js +8 -54
- package/dist/runtime/orion-runtime-v1.js +55 -14
- package/dist/runtime/product-orion-runtime.js +30 -13
- package/dist/runtime/rsi/evaluation.js +1 -7
- package/dist/runtime/step-snapshot.d.ts +3 -1
- package/dist/runtime/step-snapshot.js +11 -1
- package/dist/runtime/subagent-thread-runtime.js +27 -5
- package/dist/runtime/subagents/production.js +0 -4
- package/dist/runtime/task-context-recovery.js +30 -7
- package/dist/runtime/task-context-service.d.ts +7 -1
- package/dist/runtime/task-context-service.js +40 -8
- package/dist/runtime/thread-admission.d.ts +2 -0
- package/dist/runtime/thread-admission.js +9 -1
- package/dist/runtime/thread-runtime.d.ts +3 -0
- package/dist/runtime/thread-runtime.js +42 -3
- package/dist/runtime/thread-ui-adapter.js +1 -11
- package/dist/runtime/tool-gateway.d.ts +2 -0
- package/dist/runtime/tool-gateway.js +4 -0
- package/dist/runtime/tool-receipt-validator.js +4 -0
- package/dist/runtime/ui-events.d.ts +3 -1
- package/dist/runtime/ui-view-model.js +62 -59
- package/dist/runtime/workspace-verification.d.ts +7 -0
- package/dist/runtime/workspace-verification.js +98 -0
- 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/config.js +3 -7
- package/dist/services/global-config.d.ts +3 -11
- package/dist/services/global-config.js +36 -26
- package/dist/services/llm.d.ts +3 -1
- package/dist/services/llm.js +171 -285
- package/dist/services/provider-diagnostics.d.ts +2 -1
- package/dist/services/provider-diagnostics.js +15 -4
- 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 +61 -88
- 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/core/write-file.js +5 -3
- package/dist/tools/todo.d.ts +2 -2
- package/dist/tools/todo.js +29 -10
- package/dist/tui-ui/chrome-view-model.js +15 -6
- package/dist/utils/utf8.d.ts +6 -0
- package/dist/utils/utf8.js +14 -0
- package/docs/cli-guide.md +58 -40
- package/docs/orion.example.yaml +4 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ChatCompletionSseStream = void 0;
|
|
7
|
+
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const streaming_1 = require("openai/core/streaming");
|
|
9
|
+
/** Keep the SDK's SSE framing while exposing the Chat Completions end marker. */
|
|
10
|
+
class ChatCompletionSseStream extends streaming_1.Stream {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.doneEvent = false;
|
|
14
|
+
}
|
|
15
|
+
get sawDoneEvent() {
|
|
16
|
+
return this.doneEvent;
|
|
17
|
+
}
|
|
18
|
+
static fromSSEResponse(response, controller, client) {
|
|
19
|
+
let consumed = false;
|
|
20
|
+
async function* chunks() {
|
|
21
|
+
if (consumed)
|
|
22
|
+
throw new openai_1.default.OpenAIError('Cannot iterate over a consumed completion stream.');
|
|
23
|
+
consumed = true;
|
|
24
|
+
let exhaustedBody = false;
|
|
25
|
+
try {
|
|
26
|
+
for await (const event of (0, streaming_1._iterSSEMessages)(response, controller)) {
|
|
27
|
+
if (event.data.trim() === '[DONE]') {
|
|
28
|
+
stream.doneEvent = true;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const data = JSON.parse(event.data);
|
|
32
|
+
if (data?.error) {
|
|
33
|
+
throw new openai_1.default.APIError(undefined, data.error, undefined, response.headers);
|
|
34
|
+
}
|
|
35
|
+
if (data && typeof data === 'object')
|
|
36
|
+
yield data;
|
|
37
|
+
}
|
|
38
|
+
exhaustedBody = true;
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
if (!exhaustedBody && !stream.doneEvent)
|
|
42
|
+
controller.abort();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const stream = new ChatCompletionSseStream(chunks, controller, client);
|
|
46
|
+
return stream;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ChatCompletionSseStream = ChatCompletionSseStream;
|
|
50
|
+
//# sourceMappingURL=chat-completion-sse.js.map
|
|
@@ -43,7 +43,7 @@ export interface GeneratedSummary {
|
|
|
43
43
|
semanticSummary: CompactSummary;
|
|
44
44
|
diagnostics: SummaryDiagnostic[];
|
|
45
45
|
}
|
|
46
|
-
export type SummaryDiagnosticCode = 'llm_request_failed' | 'llm_empty_response' | 'llm_chunked_input' | 'llm_summary_budget' | 'background_summary_reused' | 'heuristic_fallback' | 'deterministic_projection';
|
|
46
|
+
export type SummaryDiagnosticCode = 'llm_request_failed' | 'llm_empty_response' | 'llm_incomplete_response' | 'llm_chunked_input' | 'llm_summary_budget' | 'background_summary_reused' | 'heuristic_fallback' | 'deterministic_projection';
|
|
47
47
|
export interface SummaryDiagnostic {
|
|
48
48
|
code: SummaryDiagnosticCode;
|
|
49
49
|
message: string;
|
|
@@ -333,6 +333,18 @@ Summary:`;
|
|
|
333
333
|
const response = await llm.chat([{ role: 'user', content: prompt }], undefined, {
|
|
334
334
|
abortSignal,
|
|
335
335
|
});
|
|
336
|
+
if ((response.finishReason !== undefined && response.finishReason !== 'stop') ||
|
|
337
|
+
response.endTurn === false ||
|
|
338
|
+
response.toolCalls?.length) {
|
|
339
|
+
diagnostics.push({
|
|
340
|
+
code: 'llm_incomplete_response',
|
|
341
|
+
message: `Summary model did not complete chunk ${chunkIndex + 1} (${response.finishReason ?? 'non-final response'}).`,
|
|
342
|
+
fallbackUsed: true,
|
|
343
|
+
chunkIndex,
|
|
344
|
+
chunkCount: chunks.length,
|
|
345
|
+
});
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
336
348
|
if (!response.content?.trim()) {
|
|
337
349
|
diagnostics.push({
|
|
338
350
|
code: 'llm_empty_response',
|
package/dist/services/config.js
CHANGED
|
@@ -129,19 +129,15 @@ function loadUIConfig(globalConfig, overrides) {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
function loadAgentLoopConfig(globalConfig, overrides) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
...overrides.agentLoop?.budget,
|
|
135
|
-
};
|
|
132
|
+
const maxModelVisibleToolBytes = overrides.agentLoop?.budget?.maxModelVisibleToolBytes ??
|
|
133
|
+
globalConfig.agentLoop?.budget?.maxModelVisibleToolBytes;
|
|
136
134
|
const continuation = overrides.agentLoop?.continuation ?? globalConfig.agentLoop?.continuation;
|
|
137
|
-
const budgetPolicy = overrides.agentLoop?.budgetPolicy ?? globalConfig.agentLoop?.budgetPolicy;
|
|
138
135
|
const goalBudget = {
|
|
139
136
|
...globalConfig.agentLoop?.goalBudget,
|
|
140
137
|
...overrides.agentLoop?.goalBudget,
|
|
141
138
|
};
|
|
142
139
|
const result = {
|
|
143
|
-
...(
|
|
144
|
-
...(Object.keys(budget).length > 0 ? { budget } : {}),
|
|
140
|
+
...(maxModelVisibleToolBytes === undefined ? {} : { budget: { maxModelVisibleToolBytes } }),
|
|
145
141
|
...(continuation ? { continuation } : {}),
|
|
146
142
|
...(Object.keys(goalBudget).length > 0 ? { goalBudget } : {}),
|
|
147
143
|
};
|
|
@@ -98,25 +98,17 @@ export interface SkillsConfig {
|
|
|
98
98
|
/** Paths to skill roots or direct skill directories. */
|
|
99
99
|
paths?: string[];
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
101
|
+
/** Model-visible tool output compression. */
|
|
102
102
|
export interface AgentLoopBudgetConfig {
|
|
103
|
-
/** Maximum LLM requests allowed for one user turn. */
|
|
104
|
-
maxLlmRequestsPerUserTurn?: number;
|
|
105
|
-
/** Maximum tool calls allowed for one user turn. */
|
|
106
|
-
maxToolCallsPerUserTurn?: number;
|
|
107
|
-
/** Consecutive single read-only tool turns before injecting a batch_read hint. */
|
|
108
|
-
maxReadOnlyFragmentation?: number;
|
|
109
103
|
/** Shared tool-output compression allowance; bounded per-result recovery previews remain. */
|
|
110
104
|
maxModelVisibleToolBytes?: number;
|
|
111
105
|
}
|
|
112
106
|
export interface AgentLoopConfig {
|
|
113
|
-
/**
|
|
114
|
-
budgetPolicy?: 'adaptive' | 'fixed';
|
|
115
|
-
/** Optional budget overrides. Orion Code may still raise defaults for complex tasks. */
|
|
107
|
+
/** Optional tool-output compression allowance overrides. */
|
|
116
108
|
budget?: AgentLoopBudgetConfig;
|
|
117
109
|
/** Whether an explicitly created Goal may schedule another turn without user input. */
|
|
118
110
|
continuation?: 'agent' | 'manual';
|
|
119
|
-
/**
|
|
111
|
+
/** Optional defaults and authorization ceilings for newly assigned Goal budgets. */
|
|
120
112
|
goalBudget?: {
|
|
121
113
|
maxTokens?: number;
|
|
122
114
|
maxElapsedMs?: number;
|
|
@@ -272,12 +272,7 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
272
272
|
if (value.agentLoop !== undefined) {
|
|
273
273
|
if (!isRecord(value.agentLoop))
|
|
274
274
|
invalidField('agentLoop');
|
|
275
|
-
validateKnownKeys(value.agentLoop, ['
|
|
276
|
-
if (value.agentLoop.budgetPolicy !== undefined &&
|
|
277
|
-
value.agentLoop.budgetPolicy !== 'adaptive' &&
|
|
278
|
-
value.agentLoop.budgetPolicy !== 'fixed') {
|
|
279
|
-
invalidField('agentLoop.budgetPolicy');
|
|
280
|
-
}
|
|
275
|
+
validateKnownKeys(value.agentLoop, ['budget', 'continuation', 'goalBudget'], 'agentLoop');
|
|
281
276
|
if (value.agentLoop.continuation !== undefined &&
|
|
282
277
|
value.agentLoop.continuation !== 'agent' &&
|
|
283
278
|
value.agentLoop.continuation !== 'manual') {
|
|
@@ -297,20 +292,8 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
297
292
|
if (value.agentLoop.budget !== undefined) {
|
|
298
293
|
if (!isRecord(value.agentLoop.budget))
|
|
299
294
|
invalidField('agentLoop.budget');
|
|
300
|
-
validateKnownKeys(value.agentLoop.budget, [
|
|
301
|
-
|
|
302
|
-
'maxToolCallsPerUserTurn',
|
|
303
|
-
'maxReadOnlyFragmentation',
|
|
304
|
-
'maxModelVisibleToolBytes',
|
|
305
|
-
], 'agentLoop.budget');
|
|
306
|
-
for (const key of [
|
|
307
|
-
'maxLlmRequestsPerUserTurn',
|
|
308
|
-
'maxToolCallsPerUserTurn',
|
|
309
|
-
'maxReadOnlyFragmentation',
|
|
310
|
-
'maxModelVisibleToolBytes',
|
|
311
|
-
]) {
|
|
312
|
-
validateOptionalPositiveInteger(value.agentLoop.budget, key, `agentLoop.budget.${key}`);
|
|
313
|
-
}
|
|
295
|
+
validateKnownKeys(value.agentLoop.budget, ['maxModelVisibleToolBytes'], 'agentLoop.budget');
|
|
296
|
+
validateOptionalPositiveInteger(value.agentLoop.budget, 'maxModelVisibleToolBytes', 'agentLoop.budget.maxModelVisibleToolBytes');
|
|
314
297
|
}
|
|
315
298
|
}
|
|
316
299
|
if (value.subagents !== undefined) {
|
|
@@ -429,6 +412,30 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
429
412
|
invalidField('providers/models');
|
|
430
413
|
}
|
|
431
414
|
}
|
|
415
|
+
/** Make retired turn counters inert while retaining supported settings and strict tree checks. */
|
|
416
|
+
function withoutRetiredAgentLoopSettings(document) {
|
|
417
|
+
if (!isRecord(document) || !isRecord(document.agentLoop))
|
|
418
|
+
return document;
|
|
419
|
+
validateDocumentTree(document);
|
|
420
|
+
const agentLoop = { ...document.agentLoop };
|
|
421
|
+
delete agentLoop.budgetPolicy;
|
|
422
|
+
if (isRecord(agentLoop.budget)) {
|
|
423
|
+
const budget = { ...agentLoop.budget };
|
|
424
|
+
delete budget.maxLlmRequestsPerUserTurn;
|
|
425
|
+
delete budget.maxToolCallsPerUserTurn;
|
|
426
|
+
delete budget.maxReadOnlyFragmentation;
|
|
427
|
+
if (Object.keys(budget).length > 0)
|
|
428
|
+
agentLoop.budget = budget;
|
|
429
|
+
else
|
|
430
|
+
delete agentLoop.budget;
|
|
431
|
+
}
|
|
432
|
+
const normalized = { ...document };
|
|
433
|
+
if (Object.keys(agentLoop).length > 0)
|
|
434
|
+
normalized.agentLoop = agentLoop;
|
|
435
|
+
else
|
|
436
|
+
delete normalized.agentLoop;
|
|
437
|
+
return normalized;
|
|
438
|
+
}
|
|
432
439
|
/** Parse exact file bytes through the strict Settings validator. */
|
|
433
440
|
function parseGlobalConfigDocumentStrict(content) {
|
|
434
441
|
const text = typeof content === 'string' ? content : content.toString('utf8');
|
|
@@ -468,13 +475,15 @@ function parseGlobalConfigDocumentStrict(content) {
|
|
|
468
475
|
})),
|
|
469
476
|
};
|
|
470
477
|
}
|
|
471
|
-
|
|
472
|
-
|
|
478
|
+
const document = withoutRetiredAgentLoopSettings(parsed);
|
|
479
|
+
validateGlobalConfigDocumentStrict(document);
|
|
480
|
+
return document;
|
|
473
481
|
}
|
|
474
482
|
/** Canonical YAML write path. Comments are not retained after a settings mutation. */
|
|
475
483
|
function serializeGlobalConfigDocumentStrict(document) {
|
|
476
|
-
|
|
477
|
-
|
|
484
|
+
const normalized = withoutRetiredAgentLoopSettings(document);
|
|
485
|
+
validateGlobalConfigDocumentStrict(normalized);
|
|
486
|
+
return (0, js_yaml_1.dump)(normalized, { noRefs: true, lineWidth: -1, sortKeys: false });
|
|
478
487
|
}
|
|
479
488
|
const TUI_THEME_PREFERENCES = new Set([
|
|
480
489
|
'orion-pixel',
|
|
@@ -664,8 +673,9 @@ function saveGlobalConfig(config) {
|
|
|
664
673
|
}, { waitMs: 10000 });
|
|
665
674
|
}
|
|
666
675
|
function saveGlobalConfigUnlocked(path, config) {
|
|
667
|
-
|
|
668
|
-
(
|
|
676
|
+
const document = withoutRetiredAgentLoopSettings(config);
|
|
677
|
+
validateGlobalConfigDocumentStrict(document);
|
|
678
|
+
(0, atomic_write_1.atomicWriteFileSync)(path, serializeGlobalConfigDocumentStrict(sanitizeGlobalConfig(document)), { mode: 0o600, fsync: true });
|
|
669
679
|
}
|
|
670
680
|
/**
|
|
671
681
|
* 更新全局配置(部分更新)
|
package/dist/services/llm.d.ts
CHANGED
|
@@ -157,6 +157,8 @@ export interface LLMResponse {
|
|
|
157
157
|
finishReason?: LLMFinishReason;
|
|
158
158
|
/** Exact non-empty provider finish_reason for diagnostics and compatibility. */
|
|
159
159
|
rawFinishReason?: string;
|
|
160
|
+
/** Explicit provider signal about ending the turn, when supplied. */
|
|
161
|
+
endTurn?: boolean;
|
|
160
162
|
/** 工具调用 */
|
|
161
163
|
toolCalls?: Array<{
|
|
162
164
|
id: string;
|
|
@@ -167,7 +169,7 @@ export interface LLMResponse {
|
|
|
167
169
|
};
|
|
168
170
|
}>;
|
|
169
171
|
}
|
|
170
|
-
export type LLMFinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'unknown';
|
|
172
|
+
export type LLMFinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'incomplete' | 'unknown';
|
|
171
173
|
export declare function normalizeFinishReason(value: unknown): LLMFinishReason | undefined;
|
|
172
174
|
/** 流式回调 */
|
|
173
175
|
export type StreamCallback = (chunk: string) => void;
|