@open330/oac-execution 2026.2.17
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/LICENSE +21 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.js +1479 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Open330
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { AgentProviderId, ExecutionResult, TokenEstimate, Task, OacEventBus, ExecutionPlan, OacError } from '@open330/oac-core';
|
|
2
|
+
|
|
3
|
+
interface AgentAvailability {
|
|
4
|
+
available: boolean;
|
|
5
|
+
version?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
remainingBudget?: number;
|
|
8
|
+
}
|
|
9
|
+
interface AgentExecuteParams {
|
|
10
|
+
executionId: string;
|
|
11
|
+
workingDirectory: string;
|
|
12
|
+
prompt: string;
|
|
13
|
+
targetFiles: string[];
|
|
14
|
+
tokenBudget: number;
|
|
15
|
+
allowCommits: boolean;
|
|
16
|
+
timeoutMs: number;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
interface TokenEstimateParams {
|
|
20
|
+
taskId: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
targetFiles: string[];
|
|
23
|
+
contextTokens?: number;
|
|
24
|
+
expectedOutputTokens?: number;
|
|
25
|
+
}
|
|
26
|
+
type AgentEvent = {
|
|
27
|
+
type: "output";
|
|
28
|
+
content: string;
|
|
29
|
+
stream: "stdout" | "stderr";
|
|
30
|
+
} | {
|
|
31
|
+
type: "tokens";
|
|
32
|
+
inputTokens: number;
|
|
33
|
+
outputTokens: number;
|
|
34
|
+
cumulativeTokens: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "file_edit";
|
|
37
|
+
path: string;
|
|
38
|
+
action: "create" | "modify" | "delete";
|
|
39
|
+
} | {
|
|
40
|
+
type: "tool_use";
|
|
41
|
+
tool: string;
|
|
42
|
+
input: unknown;
|
|
43
|
+
} | {
|
|
44
|
+
type: "error";
|
|
45
|
+
message: string;
|
|
46
|
+
recoverable: boolean;
|
|
47
|
+
};
|
|
48
|
+
interface AgentResult extends ExecutionResult {
|
|
49
|
+
}
|
|
50
|
+
interface AgentExecution {
|
|
51
|
+
readonly executionId: string;
|
|
52
|
+
readonly providerId: AgentProviderId;
|
|
53
|
+
events: AsyncIterable<AgentEvent>;
|
|
54
|
+
result: Promise<AgentResult>;
|
|
55
|
+
pid?: number;
|
|
56
|
+
}
|
|
57
|
+
interface AgentProvider {
|
|
58
|
+
readonly id: AgentProviderId;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
checkAvailability(): Promise<AgentAvailability>;
|
|
61
|
+
execute(params: AgentExecuteParams): AgentExecution;
|
|
62
|
+
estimateTokens(params: TokenEstimateParams): Promise<TokenEstimate>;
|
|
63
|
+
abort(executionId: string): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare class ClaudeCodeAdapter implements AgentProvider {
|
|
67
|
+
readonly id: AgentProviderId;
|
|
68
|
+
readonly name = "Claude Code";
|
|
69
|
+
private readonly runningExecutions;
|
|
70
|
+
checkAvailability(): Promise<AgentAvailability>;
|
|
71
|
+
execute(params: AgentExecuteParams): AgentExecution;
|
|
72
|
+
estimateTokens(params: TokenEstimateParams): Promise<TokenEstimate>;
|
|
73
|
+
abort(executionId: string): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare class CodexAdapter implements AgentProvider {
|
|
77
|
+
readonly id: AgentProviderId;
|
|
78
|
+
readonly name = "Codex CLI";
|
|
79
|
+
private readonly runningExecutions;
|
|
80
|
+
checkAvailability(): Promise<AgentAvailability>;
|
|
81
|
+
execute(params: AgentExecuteParams): AgentExecution;
|
|
82
|
+
estimateTokens(params: TokenEstimateParams): Promise<TokenEstimate>;
|
|
83
|
+
abort(executionId: string): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface SandboxContext {
|
|
87
|
+
path: string;
|
|
88
|
+
branchName: string;
|
|
89
|
+
cleanup(): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
declare function createSandbox(repoPath: string, branchName: string, baseBranch: string): Promise<SandboxContext>;
|
|
92
|
+
|
|
93
|
+
interface ExecuteTaskOptions {
|
|
94
|
+
executionId?: string;
|
|
95
|
+
tokenBudget?: number;
|
|
96
|
+
timeoutMs?: number;
|
|
97
|
+
allowCommits?: boolean;
|
|
98
|
+
}
|
|
99
|
+
declare function executeTask(agent: AgentProvider, task: Task, sandbox: SandboxContext, eventBus: OacEventBus, options?: ExecuteTaskOptions): Promise<ExecutionResult>;
|
|
100
|
+
|
|
101
|
+
type JobStatus = "queued" | "running" | "completed" | "failed" | "retrying" | "aborted";
|
|
102
|
+
interface Job {
|
|
103
|
+
id: string;
|
|
104
|
+
task: Task;
|
|
105
|
+
estimate: TokenEstimate;
|
|
106
|
+
status: JobStatus;
|
|
107
|
+
attempts: number;
|
|
108
|
+
maxAttempts: number;
|
|
109
|
+
createdAt: number;
|
|
110
|
+
startedAt?: number;
|
|
111
|
+
completedAt?: number;
|
|
112
|
+
result?: ExecutionResult;
|
|
113
|
+
error?: OacError;
|
|
114
|
+
workerId?: string;
|
|
115
|
+
}
|
|
116
|
+
interface ExecutionEngineConfig {
|
|
117
|
+
concurrency?: number;
|
|
118
|
+
maxAttempts?: number;
|
|
119
|
+
repoPath?: string;
|
|
120
|
+
baseBranch?: string;
|
|
121
|
+
branchPrefix?: string;
|
|
122
|
+
taskTimeoutMs?: number;
|
|
123
|
+
defaultTokenBudget?: number;
|
|
124
|
+
}
|
|
125
|
+
interface RunResult {
|
|
126
|
+
jobs: Job[];
|
|
127
|
+
completed: Job[];
|
|
128
|
+
failed: Job[];
|
|
129
|
+
aborted: Job[];
|
|
130
|
+
}
|
|
131
|
+
declare function isTransientError(error: OacError): boolean;
|
|
132
|
+
declare class ExecutionEngine {
|
|
133
|
+
private readonly agents;
|
|
134
|
+
private readonly eventBus;
|
|
135
|
+
private readonly queue;
|
|
136
|
+
private readonly jobs;
|
|
137
|
+
private readonly activeJobs;
|
|
138
|
+
private readonly concurrency;
|
|
139
|
+
private readonly maxAttempts;
|
|
140
|
+
private readonly repoPath;
|
|
141
|
+
private readonly baseBranch;
|
|
142
|
+
private readonly branchPrefix;
|
|
143
|
+
private readonly taskTimeoutMs;
|
|
144
|
+
private readonly defaultTokenBudget;
|
|
145
|
+
private aborted;
|
|
146
|
+
private nextAgentIndex;
|
|
147
|
+
constructor(agents: AgentProvider[], eventBus: OacEventBus, config?: ExecutionEngineConfig);
|
|
148
|
+
enqueue(plan: ExecutionPlan): Job[];
|
|
149
|
+
run(): Promise<RunResult>;
|
|
150
|
+
abort(): Promise<void>;
|
|
151
|
+
private schedule;
|
|
152
|
+
private runJob;
|
|
153
|
+
private handleFailure;
|
|
154
|
+
private selectAgent;
|
|
155
|
+
private createBranchName;
|
|
156
|
+
private normalizeError;
|
|
157
|
+
private buildRunResult;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { type AgentAvailability, type AgentEvent, type AgentExecuteParams, type AgentExecution, type AgentProvider, type AgentResult, ClaudeCodeAdapter, CodexAdapter, type ExecuteTaskOptions, ExecutionEngine, type ExecutionEngineConfig, type Job, type JobStatus, type RunResult, type SandboxContext, type TokenEstimateParams, createSandbox, executeTask, isTransientError };
|