ultracode-for-codex 0.2.0
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/README.md +182 -0
- package/ULTRACODE_INSTALL.md +133 -0
- package/dist/cli.d.ts +24 -0
- package/dist/cli.js +616 -0
- package/dist/codex/env.d.ts +2 -0
- package/dist/codex/env.js +45 -0
- package/dist/codex/subagent-backend.d.ts +72 -0
- package/dist/codex/subagent-backend.js +685 -0
- package/dist/runtime/async-queue.d.ts +10 -0
- package/dist/runtime/async-queue.js +55 -0
- package/dist/runtime/types.d.ts +61 -0
- package/dist/runtime/types.js +18 -0
- package/dist/runtime/workflow-journal.d.ts +135 -0
- package/dist/runtime/workflow-journal.js +681 -0
- package/dist/runtime/workflow-runtime.d.ts +266 -0
- package/dist/runtime/workflow-runtime.js +3280 -0
- package/dist/settings.d.ts +38 -0
- package/dist/settings.js +153 -0
- package/dist/ultracode-install-guide.d.ts +4 -0
- package/dist/ultracode-install-guide.js +22 -0
- package/docs/ultracode-p3a-journal-design.md +78 -0
- package/docs/ultracode-p3b-resume-cache.md +43 -0
- package/docs/ultracode-p3c-worktree-isolation.md +60 -0
- package/package.json +77 -0
- package/postinstall.mjs +23 -0
- package/settings.json +20 -0
- package/skills/ultracode-for-codex/SKILL.md +102 -0
- package/skills/ultracode-for-codex/agents/openai.yaml +4 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import type { SubagentBackend } from './types.js';
|
|
2
|
+
import type { WorkflowJournalDurability } from './workflow-journal.js';
|
|
3
|
+
export type WorkflowTaskStatus = 'running' | 'completed' | 'failed';
|
|
4
|
+
export type WorkflowTaskType = 'local_workflow';
|
|
5
|
+
export type WorkflowSource = 'inline' | 'script_path' | 'project' | 'user' | 'plugin' | 'built_in';
|
|
6
|
+
export type WorkflowPermissionDecision = 'allow' | 'deny';
|
|
7
|
+
export type WorkflowEvent = {
|
|
8
|
+
readonly type: 'workflow.started';
|
|
9
|
+
readonly taskId: string;
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
readonly workflowName: string;
|
|
12
|
+
readonly scriptPath: string;
|
|
13
|
+
readonly workflowSource: WorkflowSource;
|
|
14
|
+
readonly workflowSourcePath?: string;
|
|
15
|
+
readonly scriptHash: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: 'workflow.phase.started';
|
|
18
|
+
readonly taskId: string;
|
|
19
|
+
readonly runId: string;
|
|
20
|
+
readonly phaseIndex: number;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly detail?: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: 'workflow.log';
|
|
25
|
+
readonly taskId: string;
|
|
26
|
+
readonly runId: string;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: 'workflow.agent.started';
|
|
30
|
+
readonly taskId: string;
|
|
31
|
+
readonly runId: string;
|
|
32
|
+
readonly agentIndex: number;
|
|
33
|
+
readonly agentId: string;
|
|
34
|
+
readonly label: string;
|
|
35
|
+
readonly phase?: string;
|
|
36
|
+
readonly promptPreview: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: 'workflow.agent.completed';
|
|
39
|
+
readonly taskId: string;
|
|
40
|
+
readonly runId: string;
|
|
41
|
+
readonly agentIndex: number;
|
|
42
|
+
readonly agentId: string;
|
|
43
|
+
readonly label: string;
|
|
44
|
+
readonly phase?: string;
|
|
45
|
+
readonly tokens: number;
|
|
46
|
+
readonly toolCalls: number;
|
|
47
|
+
readonly resultPreview?: string;
|
|
48
|
+
readonly cached?: boolean;
|
|
49
|
+
readonly worktreePath?: string;
|
|
50
|
+
readonly worktreePreserved?: boolean;
|
|
51
|
+
readonly preservedWorktrees?: readonly WorkflowAgentPreservedWorktree[];
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'workflow.agent.failed';
|
|
54
|
+
readonly taskId: string;
|
|
55
|
+
readonly runId: string;
|
|
56
|
+
readonly agentIndex: number;
|
|
57
|
+
readonly agentId: string;
|
|
58
|
+
readonly label: string;
|
|
59
|
+
readonly phase?: string;
|
|
60
|
+
readonly error: string;
|
|
61
|
+
readonly skipped?: boolean;
|
|
62
|
+
readonly worktreePath?: string;
|
|
63
|
+
readonly worktreePreserved?: boolean;
|
|
64
|
+
readonly preservedWorktrees?: readonly WorkflowAgentPreservedWorktree[];
|
|
65
|
+
} | {
|
|
66
|
+
readonly type: 'workflow.completed';
|
|
67
|
+
readonly taskId: string;
|
|
68
|
+
readonly runId: string;
|
|
69
|
+
readonly resultPath: string;
|
|
70
|
+
readonly agentCount: number;
|
|
71
|
+
readonly tokens: number;
|
|
72
|
+
readonly toolCalls: number;
|
|
73
|
+
readonly durationMs: number;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: 'workflow.failed';
|
|
76
|
+
readonly taskId: string;
|
|
77
|
+
readonly runId: string;
|
|
78
|
+
readonly error: string;
|
|
79
|
+
readonly recovery?: {
|
|
80
|
+
readonly retryable: boolean;
|
|
81
|
+
readonly reason: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export interface WorkflowLaunchInput {
|
|
85
|
+
readonly script?: string;
|
|
86
|
+
readonly name?: string;
|
|
87
|
+
readonly scriptPath?: string;
|
|
88
|
+
readonly args?: unknown;
|
|
89
|
+
readonly resumeFromRunId?: string;
|
|
90
|
+
readonly toolName?: string;
|
|
91
|
+
}
|
|
92
|
+
export type WorkflowLaunchResult = WorkflowAsyncLaunchResult | WorkflowPermissionRequiredResult;
|
|
93
|
+
export interface WorkflowAsyncLaunchResult {
|
|
94
|
+
readonly status: 'async_launched';
|
|
95
|
+
readonly taskId: string;
|
|
96
|
+
readonly taskType: 'local_workflow';
|
|
97
|
+
readonly workflowName: string;
|
|
98
|
+
readonly runId: string;
|
|
99
|
+
readonly summary?: string;
|
|
100
|
+
readonly transcriptDir: string;
|
|
101
|
+
readonly scriptPath: string;
|
|
102
|
+
readonly workflowSource: WorkflowSource;
|
|
103
|
+
readonly workflowSourcePath?: string;
|
|
104
|
+
readonly scriptHash: string;
|
|
105
|
+
}
|
|
106
|
+
export interface WorkflowPermissionRequiredResult {
|
|
107
|
+
readonly status: 'permission_required';
|
|
108
|
+
readonly taskType: WorkflowTaskType;
|
|
109
|
+
readonly workflowName: string;
|
|
110
|
+
readonly summary?: string;
|
|
111
|
+
readonly workflowSource: WorkflowSource;
|
|
112
|
+
readonly workflowSourcePath?: string;
|
|
113
|
+
readonly scriptHash: string;
|
|
114
|
+
readonly permissionRequestId: string;
|
|
115
|
+
readonly review: WorkflowPermissionReview;
|
|
116
|
+
}
|
|
117
|
+
export interface WorkflowPermissionDeniedResult {
|
|
118
|
+
readonly status: 'permission_denied';
|
|
119
|
+
readonly taskType: WorkflowTaskType;
|
|
120
|
+
readonly workflowName: string;
|
|
121
|
+
readonly workflowSource: WorkflowSource;
|
|
122
|
+
readonly workflowSourcePath?: string;
|
|
123
|
+
readonly scriptHash: string;
|
|
124
|
+
readonly permissionRequestId: string;
|
|
125
|
+
readonly reason: 'workflow_permission_denied';
|
|
126
|
+
}
|
|
127
|
+
export interface WorkflowPermissionReview {
|
|
128
|
+
readonly permissionRequestId: string;
|
|
129
|
+
readonly reviewVersion: number;
|
|
130
|
+
readonly workflowName: string;
|
|
131
|
+
readonly summary?: string;
|
|
132
|
+
readonly workflowSource: WorkflowSource;
|
|
133
|
+
readonly workflowSourcePath?: string;
|
|
134
|
+
readonly scriptHash: string;
|
|
135
|
+
readonly phases: readonly string[];
|
|
136
|
+
readonly requestedIsolationModes: readonly string[];
|
|
137
|
+
readonly dynamicIsolation: boolean;
|
|
138
|
+
readonly riskSummary: string;
|
|
139
|
+
readonly scriptPreview: string;
|
|
140
|
+
}
|
|
141
|
+
export interface WorkflowTaskSnapshot {
|
|
142
|
+
readonly taskId: string;
|
|
143
|
+
readonly runId: string;
|
|
144
|
+
readonly workflowName: string;
|
|
145
|
+
readonly status: WorkflowTaskStatus;
|
|
146
|
+
readonly taskType: WorkflowTaskType;
|
|
147
|
+
readonly transcriptDir: string;
|
|
148
|
+
readonly scriptPath: string;
|
|
149
|
+
readonly workflowSource: WorkflowSource;
|
|
150
|
+
readonly workflowSourcePath?: string;
|
|
151
|
+
readonly scriptHash: string;
|
|
152
|
+
readonly resultPath?: string;
|
|
153
|
+
readonly result?: unknown;
|
|
154
|
+
readonly error?: string;
|
|
155
|
+
readonly failureReason?: string;
|
|
156
|
+
readonly events: readonly WorkflowEvent[];
|
|
157
|
+
}
|
|
158
|
+
export interface WorkflowRuntime {
|
|
159
|
+
launch(input: WorkflowLaunchInput): Promise<WorkflowLaunchResult>;
|
|
160
|
+
get(taskId: string): WorkflowTaskSnapshot | null;
|
|
161
|
+
cancel(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
162
|
+
retry(taskId: string): Promise<WorkflowLaunchResult>;
|
|
163
|
+
getPermissionRequest(permissionRequestId: string): WorkflowPermissionReview | null;
|
|
164
|
+
approvePermissionRequest(permissionRequestId: string): Promise<WorkflowLaunchResult>;
|
|
165
|
+
denyPermissionRequest(permissionRequestId: string): Promise<WorkflowPermissionDeniedResult>;
|
|
166
|
+
streamEvents(taskId: string, signal?: AbortSignal): AsyncIterable<WorkflowEvent>;
|
|
167
|
+
close?(): Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
interface WorkflowTaskRegistryOptions {
|
|
170
|
+
readonly backend: SubagentBackend;
|
|
171
|
+
readonly cwd?: string;
|
|
172
|
+
readonly stateDir?: string;
|
|
173
|
+
readonly requestTimeoutMs: number;
|
|
174
|
+
readonly agentStallTimeoutMs?: number;
|
|
175
|
+
readonly agentStallRetryLimit?: number;
|
|
176
|
+
readonly userWorkflowDirs?: readonly string[];
|
|
177
|
+
readonly pluginWorkflows?: readonly WorkflowPluginRegistry[];
|
|
178
|
+
readonly builtinWorkflows?: readonly BuiltinWorkflow[];
|
|
179
|
+
readonly journalDurability?: WorkflowJournalDurability;
|
|
180
|
+
}
|
|
181
|
+
interface WorkflowPluginRegistry {
|
|
182
|
+
readonly pluginName: string;
|
|
183
|
+
readonly workflowsDir?: string;
|
|
184
|
+
readonly workflowsDirs?: readonly string[];
|
|
185
|
+
readonly workflowsPath?: string;
|
|
186
|
+
readonly workflowsPaths?: readonly string[];
|
|
187
|
+
}
|
|
188
|
+
interface BuiltinWorkflow {
|
|
189
|
+
readonly name: string;
|
|
190
|
+
readonly script: string;
|
|
191
|
+
}
|
|
192
|
+
export interface WorkflowAgentPreservedWorktree {
|
|
193
|
+
readonly path: string;
|
|
194
|
+
readonly attemptIndex: number;
|
|
195
|
+
readonly reason: 'changed' | 'stalled' | 'aborted' | 'status_unavailable' | 'cleanup_failed';
|
|
196
|
+
}
|
|
197
|
+
export declare class WorkflowTaskRegistry implements WorkflowRuntime {
|
|
198
|
+
private readonly options;
|
|
199
|
+
private readonly tasks;
|
|
200
|
+
private readonly permissionRequests;
|
|
201
|
+
private permissionRecords?;
|
|
202
|
+
private closed;
|
|
203
|
+
private readonly stateDir;
|
|
204
|
+
private readonly agentStallTimeoutMs;
|
|
205
|
+
private readonly agentStallRetryLimit;
|
|
206
|
+
constructor(options: WorkflowTaskRegistryOptions);
|
|
207
|
+
launch(input: WorkflowLaunchInput): Promise<WorkflowLaunchResult>;
|
|
208
|
+
private prepareResumePlan;
|
|
209
|
+
private workflowTaskByRunId;
|
|
210
|
+
private createResumeCache;
|
|
211
|
+
private resolveLaunchInput;
|
|
212
|
+
private workflowPermissionRequired;
|
|
213
|
+
private resolveTrustedScriptPathMetadata;
|
|
214
|
+
getPermissionRequest(permissionRequestId: string): WorkflowPermissionReview | null;
|
|
215
|
+
approvePermissionRequest(permissionRequestId: string): Promise<WorkflowLaunchResult>;
|
|
216
|
+
denyPermissionRequest(permissionRequestId: string): Promise<WorkflowPermissionDeniedResult>;
|
|
217
|
+
private consumePendingWorkflowPermission;
|
|
218
|
+
private deletePendingWorkflowPermissions;
|
|
219
|
+
private workflowPermissionRecord;
|
|
220
|
+
private recordWorkflowPermission;
|
|
221
|
+
private recordWorkflowSourceAllow;
|
|
222
|
+
private recordWorkflowPermissionRecord;
|
|
223
|
+
private workflowPermissionRecords;
|
|
224
|
+
private writeWorkflowPermissionRecords;
|
|
225
|
+
private workflowPermissionStorePath;
|
|
226
|
+
private resolveNamedWorkflow;
|
|
227
|
+
private userWorkflowDirs;
|
|
228
|
+
private findNamedWorkflowInDirs;
|
|
229
|
+
private findBuiltinWorkflow;
|
|
230
|
+
private workflowScriptsDir;
|
|
231
|
+
private workflowScriptPath;
|
|
232
|
+
private persistInlineWorkflowScript;
|
|
233
|
+
private writeWorkflowScriptMetadata;
|
|
234
|
+
private readRuntimeWorkflowScript;
|
|
235
|
+
private readWorkflowScriptMetadata;
|
|
236
|
+
get(taskId: string): WorkflowTaskSnapshot | null;
|
|
237
|
+
cancel(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
238
|
+
retry(taskId: string): Promise<WorkflowLaunchResult>;
|
|
239
|
+
streamEvents(taskId: string, signal?: AbortSignal): AsyncIterable<WorkflowEvent>;
|
|
240
|
+
close(): Promise<void>;
|
|
241
|
+
private runTask;
|
|
242
|
+
private createVmGlobals;
|
|
243
|
+
private runAgent;
|
|
244
|
+
private runAgentInner;
|
|
245
|
+
private createAgentWorktree;
|
|
246
|
+
private finalizeAgentWorktree;
|
|
247
|
+
private runAgentWithStallRetries;
|
|
248
|
+
private gitStatusArgsExcludingRuntimeState;
|
|
249
|
+
private runAgentAttempt;
|
|
250
|
+
private parallel;
|
|
251
|
+
private pipeline;
|
|
252
|
+
private phase;
|
|
253
|
+
private completeTask;
|
|
254
|
+
private failTask;
|
|
255
|
+
private finalizeTask;
|
|
256
|
+
private failTaskFromCallback;
|
|
257
|
+
private drainWorkflowFinalizers;
|
|
258
|
+
private trackWorkflowPromise;
|
|
259
|
+
private emit;
|
|
260
|
+
private notifyTaskWaiters;
|
|
261
|
+
}
|
|
262
|
+
export declare function workflowResultUsage(events: readonly WorkflowEvent[]): {
|
|
263
|
+
readonly inputTokens: number;
|
|
264
|
+
readonly outputTokens: number;
|
|
265
|
+
};
|
|
266
|
+
export {};
|