@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
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoopProgress = exports.ADAPTIVE_CHECKPOINT_REQUESTS = void 0;
3
+ exports.LoopProgress = void 0;
4
4
  const path_1 = require("path");
5
5
  const canonical_1 = require("../runtime/protocol/canonical");
6
6
  const verification_command_1 = require("./verification-command");
7
- exports.ADAPTIVE_CHECKPOINT_REQUESTS = 8;
8
7
  const DIRECT_REPOSITORY_READ = /^(?:(?:rg|grep|cat|head|tail|ls)|git\s+(?:grep|show|log|status|diff|ls-files))(?=\s|$)/u;
9
8
  // Credit bounded line printing, without interpreting arbitrary sed programs as reads.
10
9
  const SED_LINE_PRINT = /^sed\s+-n\s+(?:-e\s+)?(['"]?)\d+(?:,\d+)?p\1\s+(?:--\s+)?(?:'[^'-][^']*'|"[^"-][^"]*"|[^-\s'"<>][^\s'"<>]*)$/u;
11
10
  const READ_TRUNCATION_NOTE = /\n\n\[\.\.\. truncated(?:, \d+ more lines; showing lines \d+-\d+ of \d+| at \d+B(?: of \d+B)?)\]$/u;
12
- /** Request-scoped evidence. Assistant prose, failed actions and repeated probes earn no progress. */
11
+ /** Distinct evidence observations for diagnostics. They do not govern sampling or tool execution. */
13
12
  class LoopProgress {
14
13
  constructor(cwd) {
15
14
  this.cwd = cwd;
16
15
  this.seen = new Set();
17
- this.lastProgress = 0;
18
16
  }
19
- observe(observation, requests) {
17
+ get observations() {
18
+ return this.seen.size;
19
+ }
20
+ observe(observation) {
20
21
  const { name, args, output, fileEdit, assertion } = observation;
21
22
  if (name === 'todo_write')
22
23
  return;
@@ -55,24 +56,7 @@ class LoopProgress {
55
56
  name === 'git_diff'
56
57
  ? [name, observed]
57
58
  : [name, args];
58
- const digest = (0, canonical_1.digestRuntimeValue)(identity);
59
- if (this.seen.has(digest))
60
- return;
61
- this.seen.add(digest);
62
- this.lastProgress = requests;
63
- this.recoveryAt = undefined;
64
- }
65
- checkpoint(requests) {
66
- if (requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS)
67
- return 'working';
68
- if (this.recoveryAt !== undefined) {
69
- return requests - this.recoveryAt < exports.ADAPTIVE_CHECKPOINT_REQUESTS ? 'working' : 'stop';
70
- }
71
- this.recoveryAt = requests;
72
- return 'recover';
73
- }
74
- recentlyAdvanced(requests) {
75
- return this.lastProgress > 0 && requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS;
59
+ this.seen.add((0, canonical_1.digestRuntimeValue)(identity));
76
60
  }
77
61
  }
78
62
  exports.LoopProgress = LoopProgress;
@@ -12,7 +12,7 @@ import type { LLMRequestDiagnostics, LLMService, Message, StreamCallbacks } from
12
12
  import type { ProviderErrorType } from '../services/provider-diagnostics';
13
13
  import type { OrionCodeTool, ToolContext } from './tool';
14
14
  import type { CostTracker } from '../core/cost-tracker';
15
- import { type StrategyTracker } from '../core/strategy-tracker';
15
+ import type { StrategyTracker } from '../core/strategy-tracker';
16
16
  import { type CompactPauseFailure } from '../services/compact/auto-compact';
17
17
  import type { CompactResult } from '../services/compact/compact';
18
18
  import type { CompactCoordinator } from '../services/compact/coordinator';
@@ -23,7 +23,7 @@ import { type AuthoritativeToolExecutor, type ToolPermissionDecision } from './t
23
23
  import { type ContextUsageSnapshot } from '../services/model-context';
24
24
  import type { ToolExternalAssertion } from './external-assertion';
25
25
  import { type StopDecision } from './stop-decision';
26
- import { type LoopBudget, type LoopBudgetBaseProfile, type LoopBudgetSource, type RequestBudgetPolicy } from './loop-budget-contract';
26
+ import { type LoopBudget, type LoopBudgetBaseProfile, type LoopBudgetSource } from './loop-budget-contract';
27
27
  export { DEFAULT_LOOP_BUDGET } from './loop-budget-contract';
28
28
  export type { LoopBudget, LoopBudgetBaseProfile, LoopBudgetSource } from './loop-budget-contract';
29
29
  export declare const DEFAULT_MAX_MODEL_VISIBLE_TOOL_RESULT_BYTES = 4096;
@@ -31,6 +31,7 @@ export declare const DEFAULT_MAX_MODEL_VISIBLE_TOOL_RESULT_BYTES = 4096;
31
31
  export declare const MIN_MODEL_VISIBLE_TOOL_RESULT_BYTES = 2048;
32
32
  export type LoopFinishReason = 'completed' | 'cancelled' | 'failed' | 'blocked' | 'completion_gate' | 'budget_exceeded' | 'compact_paused' | 'running';
33
33
  export type LoopContinuationAction = 'reply_continue' | 'narrow_instruction' | 'inspect_loop_stats' | 'raise_budget';
34
+ type RequestResourceStopCode = 'goal_token_budget' | 'goal_time_budget' | 'provider_preflight_budget';
34
35
  export interface LoopStats {
35
36
  turnsStarted: number;
36
37
  llmRequests: number;
@@ -47,22 +48,16 @@ export interface LoopStats {
47
48
  /** Structured compact failure when the request pauses to protect context integrity. */
48
49
  compactFailure?: CompactPauseFailure;
49
50
  budgetExceededReason?: string;
50
- budgetExhaustedWithoutProgress?: true;
51
+ budgetStopCode?: RequestResourceStopCode;
52
+ toolProgressObservations?: number;
51
53
  budgetCompaction?: 'compacted' | 'disabled' | 'unavailable';
52
- budgetCompactPending?: true;
53
- loopBudgetBaseLlmRequests?: number;
54
54
  missingAssistantOutput?: 'empty_output' | 'no_visible_output';
55
55
  providerStop?: {
56
56
  code: string;
57
57
  message: string;
58
58
  };
59
59
  loopBudgetSource?: LoopBudgetSource;
60
- loopBudgetRequestPolicy?: RequestBudgetPolicy;
61
- adaptiveStop?: 'no_progress_after_recovery' | 'request_safety_limit';
62
60
  loopBudgetBaseProfile?: LoopBudgetBaseProfile;
63
- loopBudgetMaxLlmRequests?: number;
64
- loopBudgetMaxToolCalls?: number;
65
- loopBudgetMaxReadOnlyFragmentation?: number;
66
61
  loopBudgetMaxModelVisibleBytes?: number;
67
62
  loopBudgetConfigOverride?: boolean;
68
63
  providerRetryCount?: number;
@@ -93,8 +88,6 @@ export interface LoopStats {
93
88
  verificationFailedCommands?: string[];
94
89
  verificationMissingCommands?: string[];
95
90
  verificationSkippedReason?: string;
96
- singleReadOnlyStreak: number;
97
- batchReadSuggestionCount: number;
98
91
  localFastPathUsed: boolean;
99
92
  }
100
93
  export declare class QueryLoopError extends Error {
@@ -120,10 +113,6 @@ export type QueryEvent = {
120
113
  type: 'request_start';
121
114
  model: string;
122
115
  turn: number;
123
- } | {
124
- type: 'budget_recovery';
125
- additionalRequests: number;
126
- reason: 'progress' | 'recovery';
127
116
  } | {
128
117
  type: 'prompt_assembly';
129
118
  modelId: string;
@@ -181,9 +170,6 @@ export type QueryEvent = {
181
170
  outputBytes?: number;
182
171
  batchCount?: number;
183
172
  batchIndex?: number;
184
- } | {
185
- type: 'strategy_exhausted';
186
- suggestion: string;
187
173
  } | {
188
174
  type: 'message';
189
175
  role: 'assistant';
@@ -236,8 +222,6 @@ export interface QueryParams {
236
222
  resolveStep?: (input: QueryStepResolveInput) => QueryStepRuntime | Promise<QueryStepRuntime>;
237
223
  /** LLM service instance */
238
224
  llm: LLMService;
239
- /** @deprecated Use loopBudget.maxLlmRequestsPerUserTurn. This alias is resource-only. */
240
- maxTurns?: number;
241
225
  /** Abort signal for cancellation */
242
226
  abortSignal?: AbortSignal;
243
227
  /** Streaming callbacks (onChunk writes to stdout, etc.) */
@@ -260,12 +244,16 @@ export interface QueryParams {
260
244
  maxParallelToolCalls?: number;
261
245
  /** Maximum bytes of one tool result to expose to the next model request. */
262
246
  maxModelVisibleToolResultBytes?: number;
263
- /** Per-user-turn budget guardrails for model requests, tools, and model-visible tool output. */
247
+ /** Shared tool-output compression allowance for this turn. */
264
248
  loopBudget?: Partial<LoopBudget>;
265
249
  /** Remaining reported tokens for an active Goal at turn admission. */
266
250
  remainingGoalTokens?: number;
267
- /** Allow same-turn compact recovery for root BUILD/AUTO work. */
268
- allowBudgetRecovery?: boolean;
251
+ /** Absolute deadline for the remaining elapsed Goal budget. */
252
+ goalDeadlineAt?: number;
253
+ /** Permit proactive compaction when tool results approach their visibility allowance. */
254
+ allowToolPressureCompaction?: boolean;
255
+ /** Take durably admitted user input. Seal steering when requested and the inbox is empty. */
256
+ takePendingSteering?: (closeIfEmpty?: boolean) => readonly string[];
269
257
  /** Runtime observer for current context pressure. Renderers consume Store state instead. */
270
258
  onContextUsage?: (usage: ContextUsageSnapshot) => void;
271
259
  /** Runtime observer for autonomous core compaction. */