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,55 @@
|
|
|
1
|
+
export class AsyncQueue {
|
|
2
|
+
values = [];
|
|
3
|
+
resolvers = [];
|
|
4
|
+
error = null;
|
|
5
|
+
closed = false;
|
|
6
|
+
push(value) {
|
|
7
|
+
if (this.closed)
|
|
8
|
+
return;
|
|
9
|
+
const resolve = this.resolvers.shift();
|
|
10
|
+
if (resolve)
|
|
11
|
+
resolve({ done: false, value });
|
|
12
|
+
else
|
|
13
|
+
this.values.push(value);
|
|
14
|
+
}
|
|
15
|
+
fail(err) {
|
|
16
|
+
if (this.closed)
|
|
17
|
+
return;
|
|
18
|
+
this.error = err;
|
|
19
|
+
this.closed = true;
|
|
20
|
+
while (this.resolvers.length > 0) {
|
|
21
|
+
const resolve = this.resolvers.shift();
|
|
22
|
+
resolve?.({ done: true, value: undefined });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
close() {
|
|
26
|
+
if (this.closed)
|
|
27
|
+
return;
|
|
28
|
+
this.closed = true;
|
|
29
|
+
while (this.resolvers.length > 0) {
|
|
30
|
+
const resolve = this.resolvers.shift();
|
|
31
|
+
resolve?.({ done: true, value: undefined });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async *[Symbol.asyncIterator]() {
|
|
35
|
+
while (true) {
|
|
36
|
+
if (this.values.length > 0) {
|
|
37
|
+
yield this.values.shift();
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (this.error)
|
|
41
|
+
throw this.error;
|
|
42
|
+
if (this.closed)
|
|
43
|
+
return;
|
|
44
|
+
const next = await new Promise((resolve) => {
|
|
45
|
+
this.resolvers.push(resolve);
|
|
46
|
+
});
|
|
47
|
+
if (next.done) {
|
|
48
|
+
if (this.error)
|
|
49
|
+
throw this.error;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
yield next.value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
2
|
+
export type Verbosity = 'low' | 'medium' | 'high';
|
|
3
|
+
export interface SubagentMessage {
|
|
4
|
+
readonly role: 'user';
|
|
5
|
+
readonly content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SubagentTool {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
readonly inputSchema?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export type SubagentToolChoice = {
|
|
13
|
+
readonly type: 'auto';
|
|
14
|
+
} | {
|
|
15
|
+
readonly type: 'required';
|
|
16
|
+
};
|
|
17
|
+
export interface SubagentRequest {
|
|
18
|
+
readonly model: string;
|
|
19
|
+
readonly messages: readonly SubagentMessage[];
|
|
20
|
+
readonly reasoningEffort?: ReasoningEffort;
|
|
21
|
+
readonly tools: readonly SubagentTool[];
|
|
22
|
+
readonly toolChoice: SubagentToolChoice;
|
|
23
|
+
readonly worktreePath?: string;
|
|
24
|
+
readonly raw?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface SubagentUsage {
|
|
27
|
+
readonly inputTokens: number;
|
|
28
|
+
readonly outputTokens: number;
|
|
29
|
+
readonly totalTokens?: number;
|
|
30
|
+
readonly cachedInputTokens?: number;
|
|
31
|
+
readonly reasoningOutputTokens?: number;
|
|
32
|
+
readonly source?: 'provider' | 'estimated';
|
|
33
|
+
readonly raw?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface SubagentToolCall {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly arguments: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SubagentResult {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly model: string;
|
|
43
|
+
readonly text: string;
|
|
44
|
+
readonly toolCalls: readonly SubagentToolCall[];
|
|
45
|
+
readonly usage: SubagentUsage;
|
|
46
|
+
readonly latencyMs: number;
|
|
47
|
+
}
|
|
48
|
+
export interface SubagentBackend {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly model: string;
|
|
51
|
+
generate(request: SubagentRequest, signal?: AbortSignal): Promise<SubagentResult>;
|
|
52
|
+
close(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export declare class UltracodeRequestError extends Error {
|
|
55
|
+
readonly statusCode: number;
|
|
56
|
+
readonly type: string;
|
|
57
|
+
readonly param: string | null;
|
|
58
|
+
readonly code: string | null;
|
|
59
|
+
constructor(message: string, statusCode: number, type?: string, param?: string | null, code?: string | null);
|
|
60
|
+
}
|
|
61
|
+
export declare function estimateTokens(text: string): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class UltracodeRequestError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
type;
|
|
4
|
+
param;
|
|
5
|
+
code;
|
|
6
|
+
constructor(message, statusCode, type = 'invalid_request_error', param = null, code = null) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.param = param;
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function estimateTokens(text) {
|
|
15
|
+
if (!text)
|
|
16
|
+
return 0;
|
|
17
|
+
return Math.max(1, Math.ceil(text.length / 4));
|
|
18
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
2
|
+
readonly [key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
export interface WorkflowJournalUsage {
|
|
5
|
+
readonly inputTokens: number;
|
|
6
|
+
readonly outputTokens: number;
|
|
7
|
+
readonly totalTokens: number;
|
|
8
|
+
}
|
|
9
|
+
export interface WorkflowAgentSemanticOpts {
|
|
10
|
+
readonly schema?: JsonValue;
|
|
11
|
+
readonly model: string;
|
|
12
|
+
readonly effort?: string;
|
|
13
|
+
readonly isolation?: string;
|
|
14
|
+
readonly agentType?: string;
|
|
15
|
+
}
|
|
16
|
+
export type WorkflowJournalEntry = WorkflowRunStartedEntry | WorkflowAgentStartedEntry | WorkflowAgentCompletedEntry | WorkflowAgentFailedEntry | WorkflowRunCompletedEntry | WorkflowRunFailedEntry;
|
|
17
|
+
interface WorkflowJournalEntryEnvelope {
|
|
18
|
+
readonly version: 1;
|
|
19
|
+
readonly seq: number;
|
|
20
|
+
readonly previousEntryHash: string;
|
|
21
|
+
readonly entryHash: string;
|
|
22
|
+
readonly recordedAt: string;
|
|
23
|
+
readonly taskId: string;
|
|
24
|
+
readonly runId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WorkflowRunStartedEntry extends WorkflowJournalEntryEnvelope {
|
|
27
|
+
readonly kind: 'workflow.run.started';
|
|
28
|
+
readonly workflowName: string;
|
|
29
|
+
readonly workflowSource: string;
|
|
30
|
+
readonly workflowSourcePath?: string;
|
|
31
|
+
readonly scriptPath: string;
|
|
32
|
+
readonly scriptHash: string;
|
|
33
|
+
readonly args: JsonValue;
|
|
34
|
+
readonly runtime: {
|
|
35
|
+
readonly schemaVersion: 1;
|
|
36
|
+
readonly cwd: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface WorkflowAgentStartedEntry extends WorkflowJournalEntryEnvelope {
|
|
40
|
+
readonly kind: 'workflow.agent.started';
|
|
41
|
+
readonly agentIndex: number;
|
|
42
|
+
readonly agentId: string;
|
|
43
|
+
readonly agentCallKey: string;
|
|
44
|
+
readonly previousAgentCallKey: string;
|
|
45
|
+
readonly prompt: string;
|
|
46
|
+
readonly semanticOpts: WorkflowAgentSemanticOpts;
|
|
47
|
+
}
|
|
48
|
+
export interface WorkflowAgentCompletedEntry extends WorkflowJournalEntryEnvelope {
|
|
49
|
+
readonly kind: 'workflow.agent.completed';
|
|
50
|
+
readonly agentIndex: number;
|
|
51
|
+
readonly agentId: string;
|
|
52
|
+
readonly agentCallKey: string;
|
|
53
|
+
readonly result: JsonValue;
|
|
54
|
+
readonly usage: WorkflowJournalUsage;
|
|
55
|
+
readonly toolCalls: number;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkflowAgentFailedEntry extends WorkflowJournalEntryEnvelope {
|
|
58
|
+
readonly kind: 'workflow.agent.failed';
|
|
59
|
+
readonly agentIndex: number;
|
|
60
|
+
readonly agentId: string;
|
|
61
|
+
readonly agentCallKey: string;
|
|
62
|
+
readonly reason: string;
|
|
63
|
+
readonly message: string;
|
|
64
|
+
}
|
|
65
|
+
export interface WorkflowRunCompletedEntry extends WorkflowJournalEntryEnvelope {
|
|
66
|
+
readonly kind: 'workflow.run.completed';
|
|
67
|
+
readonly result: JsonValue;
|
|
68
|
+
readonly resultPath: string;
|
|
69
|
+
readonly agentCount: number;
|
|
70
|
+
readonly usage: WorkflowJournalUsage;
|
|
71
|
+
readonly toolCalls: number;
|
|
72
|
+
readonly durationMs: number;
|
|
73
|
+
}
|
|
74
|
+
export interface WorkflowRunFailedEntry extends WorkflowJournalEntryEnvelope {
|
|
75
|
+
readonly kind: 'workflow.run.failed';
|
|
76
|
+
readonly reason: string;
|
|
77
|
+
readonly message: string;
|
|
78
|
+
readonly recovery?: {
|
|
79
|
+
readonly retryable: boolean;
|
|
80
|
+
readonly reason: string;
|
|
81
|
+
};
|
|
82
|
+
readonly durationMs: number;
|
|
83
|
+
}
|
|
84
|
+
export type WorkflowJournalEntryPayload = Omit<WorkflowRunStartedEntry, keyof WorkflowJournalEntryEnvelope> | Omit<WorkflowAgentStartedEntry, keyof WorkflowJournalEntryEnvelope> | Omit<WorkflowAgentCompletedEntry, keyof WorkflowJournalEntryEnvelope> | Omit<WorkflowAgentFailedEntry, keyof WorkflowJournalEntryEnvelope> | Omit<WorkflowRunCompletedEntry, keyof WorkflowJournalEntryEnvelope> | Omit<WorkflowRunFailedEntry, keyof WorkflowJournalEntryEnvelope>;
|
|
85
|
+
export interface WorkflowJournalReadResult {
|
|
86
|
+
readonly entries: readonly WorkflowJournalEntry[];
|
|
87
|
+
readonly truncatedTail: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface WorkflowJournalDurability {
|
|
90
|
+
readonly syncFile?: (journalPath: string, entry: WorkflowJournalEntry) => Promise<void>;
|
|
91
|
+
readonly syncDirectory?: (directoryPath: string) => Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export interface WorkflowJournalWriterOptions {
|
|
94
|
+
readonly transcriptDir: string;
|
|
95
|
+
readonly taskId: string;
|
|
96
|
+
readonly runId: string;
|
|
97
|
+
readonly durability?: WorkflowJournalDurability;
|
|
98
|
+
}
|
|
99
|
+
export declare class WorkflowJournalError extends Error {
|
|
100
|
+
readonly cause?: unknown | undefined;
|
|
101
|
+
readonly code = "workflow_journal_write_failed";
|
|
102
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
103
|
+
}
|
|
104
|
+
export declare class WorkflowJournalValidationError extends Error {
|
|
105
|
+
readonly code = "workflow_journal_invalid";
|
|
106
|
+
constructor(message: string);
|
|
107
|
+
}
|
|
108
|
+
export declare class WorkflowJournalWriter {
|
|
109
|
+
private readonly options;
|
|
110
|
+
private readonly journalPath;
|
|
111
|
+
private queue;
|
|
112
|
+
private poisoned?;
|
|
113
|
+
private seq;
|
|
114
|
+
private previousEntryHash;
|
|
115
|
+
private constructor();
|
|
116
|
+
static create(options: WorkflowJournalWriterOptions): Promise<WorkflowJournalWriter>;
|
|
117
|
+
append(payload: WorkflowJournalEntryPayload): Promise<WorkflowJournalEntry>;
|
|
118
|
+
private nextEntry;
|
|
119
|
+
}
|
|
120
|
+
export declare const WORKFLOW_JOURNAL_GENESIS_HASH: string;
|
|
121
|
+
export declare const WORKFLOW_JOURNAL_GENESIS_AGENT_CALL_KEY: string;
|
|
122
|
+
export declare const WORKFLOW_JOURNAL_WRITE_FAILED_REASON = "workflow_journal_write_failed";
|
|
123
|
+
export declare function workflowJournalPath(transcriptDir: string): string;
|
|
124
|
+
export declare function isWorkflowJournalError(err: unknown): err is WorkflowJournalError;
|
|
125
|
+
export declare function normalizeJournalJsonValue(value: unknown, label: string): JsonValue;
|
|
126
|
+
export declare function stableJson(value: unknown): string;
|
|
127
|
+
export declare function computeWorkflowAgentCallKey(input: {
|
|
128
|
+
readonly previousAgentCallKey: string;
|
|
129
|
+
readonly prompt: string;
|
|
130
|
+
readonly semanticOpts: WorkflowAgentSemanticOpts;
|
|
131
|
+
}): string;
|
|
132
|
+
export declare function workflowJournalHash(entryWithoutEntryHash: unknown): string;
|
|
133
|
+
export declare function readWorkflowJournal(journalPath: string): Promise<WorkflowJournalReadResult>;
|
|
134
|
+
export declare function cleanupWorkflowJournalTranscriptDir(transcriptDir: string): Promise<void>;
|
|
135
|
+
export {};
|