@positronic/core 0.0.1 → 0.0.2
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/CLAUDE.md +141 -0
- package/dist/src/adapters/types.js +1 -16
- package/dist/src/clients/types.js +4 -1
- package/dist/src/dsl/brain-runner.js +487 -0
- package/dist/src/dsl/brain-runner.test.js +733 -0
- package/dist/src/dsl/brain.js +1128 -0
- package/dist/src/dsl/brain.test.js +4225 -0
- package/dist/src/dsl/constants.js +6 -6
- package/dist/src/dsl/json-patch.js +37 -9
- package/dist/src/index.js +11 -10
- package/dist/src/resources/resources.js +371 -0
- package/dist/src/test-utils.js +474 -0
- package/dist/src/testing.js +3 -0
- package/dist/types/adapters/types.d.ts +3 -8
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +46 -6
- package/dist/types/clients/types.d.ts.map +1 -1
- package/dist/types/dsl/brain-runner.d.ts +24 -0
- package/dist/types/dsl/brain-runner.d.ts.map +1 -0
- package/dist/types/dsl/brain.d.ts +136 -0
- package/dist/types/dsl/brain.d.ts.map +1 -0
- package/dist/types/dsl/constants.d.ts +5 -5
- package/dist/types/dsl/constants.d.ts.map +1 -1
- package/dist/types/dsl/json-patch.d.ts +2 -1
- package/dist/types/dsl/json-patch.d.ts.map +1 -1
- package/dist/types/index.d.ts +13 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/resource-loader.d.ts +6 -0
- package/dist/types/resources/resource-loader.d.ts.map +1 -0
- package/dist/types/resources/resources.d.ts +23 -0
- package/dist/types/resources/resources.d.ts.map +1 -0
- package/dist/types/test-utils.d.ts +94 -0
- package/dist/types/test-utils.d.ts.map +1 -0
- package/dist/types/testing.d.ts +2 -0
- package/dist/types/testing.d.ts.map +1 -0
- package/docs/core-testing-guide.md +289 -0
- package/package.json +26 -7
- package/src/adapters/types.ts +3 -22
- package/src/clients/types.ts +50 -10
- package/src/dsl/brain-runner.test.ts +384 -0
- package/src/dsl/brain-runner.ts +111 -0
- package/src/dsl/brain.test.ts +1981 -0
- package/src/dsl/brain.ts +740 -0
- package/src/dsl/constants.ts +6 -6
- package/src/dsl/json-patch.ts +24 -9
- package/src/dsl/types.ts +1 -1
- package/src/index.ts +30 -16
- package/src/resources/resource-loader.ts +8 -0
- package/src/resources/resources.ts +267 -0
- package/src/test-utils.ts +254 -0
- package/test/resources.test.ts +248 -0
- package/tsconfig.json +2 -2
- package/.swcrc +0 -31
- package/dist/src/dsl/extensions.js +0 -19
- package/dist/src/dsl/workflow-runner.js +0 -93
- package/dist/src/dsl/workflow.js +0 -308
- package/dist/src/file-stores/local-file-store.js +0 -12
- package/dist/src/utils/temp-files.js +0 -27
- package/dist/types/dsl/extensions.d.ts +0 -18
- package/dist/types/dsl/extensions.d.ts.map +0 -1
- package/dist/types/dsl/workflow-runner.d.ts +0 -28
- package/dist/types/dsl/workflow-runner.d.ts.map +0 -1
- package/dist/types/dsl/workflow.d.ts +0 -118
- package/dist/types/dsl/workflow.d.ts.map +0 -1
- package/dist/types/file-stores/local-file-store.d.ts +0 -7
- package/dist/types/file-stores/local-file-store.d.ts.map +0 -1
- package/dist/types/file-stores/types.d.ts +0 -4
- package/dist/types/file-stores/types.d.ts.map +0 -1
- package/dist/types/utils/temp-files.d.ts +0 -12
- package/dist/types/utils/temp-files.d.ts.map +0 -1
- package/src/dsl/extensions.ts +0 -58
- package/src/dsl/workflow-runner.test.ts +0 -203
- package/src/dsl/workflow-runner.ts +0 -146
- package/src/dsl/workflow.test.ts +0 -1435
- package/src/dsl/workflow.ts +0 -554
- package/src/file-stores/local-file-store.ts +0 -11
- package/src/file-stores/types.ts +0 -3
- package/src/utils/temp-files.ts +0 -46
- /package/dist/src/{file-stores/types.js → resources/resource-loader.js} +0 -0
package/dist/src/dsl/workflow.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { STATUS } from "./constants.js";
|
|
3
|
-
import { WORKFLOW_EVENTS } from "./constants.js";
|
|
4
|
-
import { createPatch } from "./json-patch.js";
|
|
5
|
-
import { applyPatches } from "./json-patch.js";
|
|
6
|
-
export class Workflow {
|
|
7
|
-
title;
|
|
8
|
-
description;
|
|
9
|
-
blocks;
|
|
10
|
-
type;
|
|
11
|
-
constructor(title, description){
|
|
12
|
-
this.title = title;
|
|
13
|
-
this.description = description;
|
|
14
|
-
this.blocks = [];
|
|
15
|
-
this.type = 'workflow';
|
|
16
|
-
}
|
|
17
|
-
step(title, action) {
|
|
18
|
-
const stepBlock = {
|
|
19
|
-
type: 'step',
|
|
20
|
-
title,
|
|
21
|
-
action
|
|
22
|
-
};
|
|
23
|
-
this.blocks.push(stepBlock);
|
|
24
|
-
return this.nextWorkflow();
|
|
25
|
-
}
|
|
26
|
-
workflow(title, innerWorkflow, action, initialState) {
|
|
27
|
-
const nestedBlock = {
|
|
28
|
-
type: 'workflow',
|
|
29
|
-
title,
|
|
30
|
-
innerWorkflow,
|
|
31
|
-
initialState: initialState || (()=>({})),
|
|
32
|
-
action: (outerState, innerState)=>action({
|
|
33
|
-
state: outerState,
|
|
34
|
-
workflowState: innerState
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
this.blocks.push(nestedBlock);
|
|
38
|
-
return this.nextWorkflow();
|
|
39
|
-
}
|
|
40
|
-
// TResponseKey:
|
|
41
|
-
// The response key must be a string literal, so if defining a response model
|
|
42
|
-
// a consumer of this workflow must use "as const" to ensure the key is a string literal
|
|
43
|
-
// this type makes sure that the will get a ts error if they don't.
|
|
44
|
-
prompt(title, config, reduce) {
|
|
45
|
-
const promptBlock = {
|
|
46
|
-
type: 'step',
|
|
47
|
-
title,
|
|
48
|
-
action: async ({ state, client: runClient, options })=>{
|
|
49
|
-
const { template, responseModel, client: stepClient } = config;
|
|
50
|
-
const client = stepClient ?? runClient;
|
|
51
|
-
const promptString = template(state);
|
|
52
|
-
const response = await client.execute(promptString, responseModel);
|
|
53
|
-
const stateWithResponse = {
|
|
54
|
-
...state,
|
|
55
|
-
[config.responseModel.name]: response
|
|
56
|
-
};
|
|
57
|
-
return reduce ? reduce({
|
|
58
|
-
state,
|
|
59
|
-
response,
|
|
60
|
-
options,
|
|
61
|
-
prompt: promptString
|
|
62
|
-
}) : stateWithResponse;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
this.blocks.push(promptBlock);
|
|
66
|
-
return this.nextWorkflow();
|
|
67
|
-
}
|
|
68
|
-
// Implementation signature
|
|
69
|
-
async *run(params) {
|
|
70
|
-
const { title, description, blocks } = this;
|
|
71
|
-
const stream = new WorkflowEventStream({
|
|
72
|
-
title,
|
|
73
|
-
description,
|
|
74
|
-
blocks,
|
|
75
|
-
...params
|
|
76
|
-
});
|
|
77
|
-
yield* stream.next();
|
|
78
|
-
}
|
|
79
|
-
withBlocks(blocks) {
|
|
80
|
-
this.blocks = blocks;
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
nextWorkflow() {
|
|
84
|
-
return new Workflow(this.title, this.description).withBlocks(this.blocks);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
class Step {
|
|
88
|
-
block;
|
|
89
|
-
id;
|
|
90
|
-
patch;
|
|
91
|
-
status;
|
|
92
|
-
constructor(block, id){
|
|
93
|
-
this.block = block;
|
|
94
|
-
this.status = STATUS.PENDING;
|
|
95
|
-
this.id = id || uuidv4();
|
|
96
|
-
}
|
|
97
|
-
withPatch(patch) {
|
|
98
|
-
this.patch = patch;
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
withStatus(status) {
|
|
102
|
-
this.status = status;
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
get serialized() {
|
|
106
|
-
return {
|
|
107
|
-
id: this.id,
|
|
108
|
-
title: this.block.title,
|
|
109
|
-
status: this.status,
|
|
110
|
-
patch: typeof this.patch === 'string' ? JSON.parse(this.patch) : this.patch
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
class WorkflowEventStream {
|
|
115
|
-
currentState;
|
|
116
|
-
steps;
|
|
117
|
-
currentStepIndex = 0;
|
|
118
|
-
initialState;
|
|
119
|
-
workflowRunId;
|
|
120
|
-
title;
|
|
121
|
-
description;
|
|
122
|
-
fileStore;
|
|
123
|
-
client;
|
|
124
|
-
options;
|
|
125
|
-
constructor(params){
|
|
126
|
-
const { initialState = {}, initialCompletedSteps, blocks, title, description, workflowRunId: providedWorkflowRunId, options = {}, fileStore, client } = params;
|
|
127
|
-
this.initialState = initialState;
|
|
128
|
-
this.title = title;
|
|
129
|
-
this.description = description;
|
|
130
|
-
this.fileStore = fileStore;
|
|
131
|
-
this.client = client;
|
|
132
|
-
this.options = options;
|
|
133
|
-
// Initialize steps array with UUIDs and pending status
|
|
134
|
-
this.steps = blocks.map((block, index)=>{
|
|
135
|
-
const completedStep = initialCompletedSteps?.[index];
|
|
136
|
-
if (completedStep) {
|
|
137
|
-
return new Step(block, completedStep.id).withStatus(completedStep.status).withPatch(completedStep.patch);
|
|
138
|
-
}
|
|
139
|
-
return new Step(block);
|
|
140
|
-
});
|
|
141
|
-
this.currentState = clone(this.initialState);
|
|
142
|
-
for (const step of this.steps){
|
|
143
|
-
if (step.serialized.status === STATUS.COMPLETE && step.serialized.patch) {
|
|
144
|
-
this.currentState = applyPatches(this.currentState, [
|
|
145
|
-
step.serialized.patch
|
|
146
|
-
]);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
this.workflowRunId = providedWorkflowRunId ?? uuidv4();
|
|
150
|
-
}
|
|
151
|
-
async *next() {
|
|
152
|
-
const { steps, title: workflowTitle, description: workflowDescription, currentState, options, workflowRunId } = this;
|
|
153
|
-
try {
|
|
154
|
-
const hasCompletedSteps = steps.some((step)=>step.serialized.status !== STATUS.PENDING);
|
|
155
|
-
yield {
|
|
156
|
-
type: hasCompletedSteps ? WORKFLOW_EVENTS.RESTART : WORKFLOW_EVENTS.START,
|
|
157
|
-
status: STATUS.RUNNING,
|
|
158
|
-
workflowTitle,
|
|
159
|
-
workflowDescription,
|
|
160
|
-
initialState: currentState,
|
|
161
|
-
options,
|
|
162
|
-
workflowRunId
|
|
163
|
-
};
|
|
164
|
-
// Emit initial step status after workflow starts
|
|
165
|
-
yield {
|
|
166
|
-
type: WORKFLOW_EVENTS.STEP_STATUS,
|
|
167
|
-
steps: steps.map((step)=>step.serialized),
|
|
168
|
-
options,
|
|
169
|
-
workflowRunId
|
|
170
|
-
};
|
|
171
|
-
// Process each step
|
|
172
|
-
while(this.currentStepIndex < steps.length){
|
|
173
|
-
const step = steps[this.currentStepIndex];
|
|
174
|
-
// Skip completed steps
|
|
175
|
-
if (step.serialized.status === STATUS.COMPLETE) {
|
|
176
|
-
this.currentStepIndex++;
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
// Step start event
|
|
180
|
-
yield {
|
|
181
|
-
type: WORKFLOW_EVENTS.STEP_START,
|
|
182
|
-
status: STATUS.RUNNING,
|
|
183
|
-
stepTitle: step.block.title,
|
|
184
|
-
stepId: step.id,
|
|
185
|
-
options,
|
|
186
|
-
workflowRunId
|
|
187
|
-
};
|
|
188
|
-
// Execute step and yield the STEP_COMPLETE event and
|
|
189
|
-
// all events from inner workflows if any
|
|
190
|
-
yield* this.executeStep(step);
|
|
191
|
-
// Step Status Event
|
|
192
|
-
yield {
|
|
193
|
-
type: WORKFLOW_EVENTS.STEP_STATUS,
|
|
194
|
-
steps: steps.map((step)=>step.serialized),
|
|
195
|
-
options,
|
|
196
|
-
workflowRunId
|
|
197
|
-
};
|
|
198
|
-
this.currentStepIndex++;
|
|
199
|
-
}
|
|
200
|
-
yield {
|
|
201
|
-
type: WORKFLOW_EVENTS.COMPLETE,
|
|
202
|
-
status: STATUS.COMPLETE,
|
|
203
|
-
workflowTitle,
|
|
204
|
-
workflowDescription,
|
|
205
|
-
workflowRunId,
|
|
206
|
-
options
|
|
207
|
-
};
|
|
208
|
-
} catch (err) {
|
|
209
|
-
const error = err;
|
|
210
|
-
const currentStep = steps[this.currentStepIndex];
|
|
211
|
-
currentStep?.withStatus(STATUS.ERROR);
|
|
212
|
-
yield {
|
|
213
|
-
type: WORKFLOW_EVENTS.ERROR,
|
|
214
|
-
status: STATUS.ERROR,
|
|
215
|
-
workflowTitle,
|
|
216
|
-
workflowDescription,
|
|
217
|
-
workflowRunId,
|
|
218
|
-
error: {
|
|
219
|
-
name: error.name,
|
|
220
|
-
message: error.message,
|
|
221
|
-
stack: error.stack
|
|
222
|
-
},
|
|
223
|
-
options
|
|
224
|
-
};
|
|
225
|
-
// Step Status Event
|
|
226
|
-
yield {
|
|
227
|
-
type: WORKFLOW_EVENTS.STEP_STATUS,
|
|
228
|
-
steps: steps.map((step)=>step.serialized),
|
|
229
|
-
options,
|
|
230
|
-
workflowRunId
|
|
231
|
-
};
|
|
232
|
-
throw error;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
async *executeStep(step) {
|
|
236
|
-
const block = step.block;
|
|
237
|
-
if (block.type === 'workflow') {
|
|
238
|
-
const initialState = typeof block.initialState === 'function' ? block.initialState(this.currentState) : block.initialState;
|
|
239
|
-
// Run inner workflow and yield all its events
|
|
240
|
-
let patches = [];
|
|
241
|
-
const innerRun = block.innerWorkflow.run({
|
|
242
|
-
fileStore: this.fileStore,
|
|
243
|
-
client: this.client,
|
|
244
|
-
initialState,
|
|
245
|
-
options: this.options ?? {}
|
|
246
|
-
});
|
|
247
|
-
for await (const event of innerRun){
|
|
248
|
-
yield event; // Forward all inner workflow events
|
|
249
|
-
if (event.type === WORKFLOW_EVENTS.STEP_COMPLETE) {
|
|
250
|
-
patches.push(event.patch);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Apply collected patches to get final inner state
|
|
254
|
-
const innerState = applyPatches(initialState, patches);
|
|
255
|
-
// Get previous state before action
|
|
256
|
-
const prevState = this.currentState;
|
|
257
|
-
// Update state with inner workflow results
|
|
258
|
-
this.currentState = await block.action(this.currentState, innerState);
|
|
259
|
-
yield* this.completeStep(step, prevState);
|
|
260
|
-
} else {
|
|
261
|
-
// Get previous state before action
|
|
262
|
-
const prevState = this.currentState;
|
|
263
|
-
// Execute regular step
|
|
264
|
-
this.currentState = await block.action({
|
|
265
|
-
state: this.currentState,
|
|
266
|
-
options: this.options ?? {},
|
|
267
|
-
client: this.client,
|
|
268
|
-
fileStore: this.fileStore
|
|
269
|
-
});
|
|
270
|
-
yield* this.completeStep(step, prevState);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
*completeStep(step, prevState) {
|
|
274
|
-
step.withStatus(STATUS.COMPLETE);
|
|
275
|
-
// Create patch for the state change
|
|
276
|
-
const patch = createPatch(prevState, this.currentState);
|
|
277
|
-
step.withPatch(patch);
|
|
278
|
-
yield {
|
|
279
|
-
type: WORKFLOW_EVENTS.STEP_COMPLETE,
|
|
280
|
-
status: STATUS.RUNNING,
|
|
281
|
-
stepTitle: step.block.title,
|
|
282
|
-
stepId: step.id,
|
|
283
|
-
patch,
|
|
284
|
-
options: this.options ?? {},
|
|
285
|
-
workflowRunId: this.workflowRunId
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
let workflowNamesAreUnique = true;
|
|
290
|
-
export function disableWorkflowNameUniqueness() {
|
|
291
|
-
workflowNamesAreUnique = false;
|
|
292
|
-
}
|
|
293
|
-
export function enableWorkflowNameUniqueness() {
|
|
294
|
-
workflowNamesAreUnique = true;
|
|
295
|
-
}
|
|
296
|
-
const workflowNames = new Set();
|
|
297
|
-
export function workflow(workflowConfig) {
|
|
298
|
-
const title = typeof workflowConfig === 'string' ? workflowConfig : workflowConfig.title;
|
|
299
|
-
const description = typeof workflowConfig === 'string' ? undefined : workflowConfig.description;
|
|
300
|
-
if (workflowNamesAreUnique && workflowNames.has(title)) {
|
|
301
|
-
throw new Error(`Workflow with name "${title}" already exists. Workflow names must be unique.`);
|
|
302
|
-
}
|
|
303
|
-
if (workflowNamesAreUnique) {
|
|
304
|
-
workflowNames.add(title);
|
|
305
|
-
}
|
|
306
|
-
return new Workflow(title, description);
|
|
307
|
-
}
|
|
308
|
-
const clone = (value)=>structuredClone(value);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import * as fs from 'fs/promises';
|
|
3
|
-
export class LocalFileStore {
|
|
4
|
-
baseDir;
|
|
5
|
-
constructor(baseDir){
|
|
6
|
-
this.baseDir = baseDir;
|
|
7
|
-
}
|
|
8
|
-
async readFile(path) {
|
|
9
|
-
const filePath = join(this.baseDir, path);
|
|
10
|
-
return fs.readFile(filePath, 'utf-8');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import * as fs from 'fs/promises';
|
|
4
|
-
import { exec } from 'child_process';
|
|
5
|
-
import { promisify } from 'util';
|
|
6
|
-
const execAsync = promisify(exec);
|
|
7
|
-
/**
|
|
8
|
-
* Writes content to a temporary file and opens it in cursor
|
|
9
|
-
*/ export async function writeAndOpenTemp(content, prefix, extension = 'txt') {
|
|
10
|
-
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'positronic-'));
|
|
11
|
-
const filename = `${prefix}-${Date.now()}.${extension}`;
|
|
12
|
-
const filepath = path.join(tempDir, filename);
|
|
13
|
-
await fs.writeFile(filepath, content, 'utf8');
|
|
14
|
-
// Open in cursor using the cursor command
|
|
15
|
-
await execAsync(`cursor ${filepath}`);
|
|
16
|
-
return filepath;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Writes both prompt and response to temp files and opens them in cursor
|
|
20
|
-
*/ export async function writePromptAndResponse(prompt, response, prefix = 'debug') {
|
|
21
|
-
const promptPath = await writeAndOpenTemp(prompt, `${prefix}-prompt`, 'md');
|
|
22
|
-
const responsePath = await writeAndOpenTemp(typeof response === 'string' ? response : JSON.stringify(response, null, 2), `${prefix}-response`, 'tsx');
|
|
23
|
-
return {
|
|
24
|
-
promptPath,
|
|
25
|
-
responsePath
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Workflow } from "./workflow";
|
|
2
|
-
import type { State } from "./types";
|
|
3
|
-
type Expand<T> = T extends infer O ? {
|
|
4
|
-
[K in keyof O]: O[K];
|
|
5
|
-
} : never;
|
|
6
|
-
type ExtensionMethods<TExtension extends Record<string, any>, TOptions extends object, TState extends State> = TExtension extends ((...args: any[]) => any) ? TExtension extends ((this: any, title: string, config: infer TConfig) => Workflow<any, infer TReturnState>) ? (title: string, config: TConfig extends ((ctx: any) => any) ? {
|
|
7
|
-
[P in keyof TConfig]: TConfig[P] extends Function ? ((ctx: TState) => any) : TConfig[P];
|
|
8
|
-
} : TConfig) => Workflow<TOptions, Expand<TState & TReturnState>> : never : {
|
|
9
|
-
[K in keyof TExtension]: TExtension[K] extends (this: any, title: string, config: infer TConfig) => Workflow<any, infer TReturnState> ? (title: string, config: TConfig extends ((ctx: any) => any) ? {
|
|
10
|
-
[P in keyof TConfig]: TConfig[P] extends Function ? ((ctx: TState) => any) : TConfig[P];
|
|
11
|
-
} : TConfig) => Workflow<TOptions, Expand<TState & TReturnState>> : never;
|
|
12
|
-
};
|
|
13
|
-
export declare function createExtension<TExtensionKey extends string, TExtension extends Record<string, any>>(key: TExtensionKey, extension: TExtension): {
|
|
14
|
-
install(): void;
|
|
15
|
-
augment<TOptions extends object, TState extends State>(): ExtensionMethods<TExtension, TOptions, TState>;
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/dsl/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS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AG,OAAO,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;KAAE,GAC3F,OAAO,KACR,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC,GACtD,KAAK;CACV,CAAC;AAEN,wBAAgB,eAAe,CAC7B,aAAa,SAAS,MAAM,EAC5B,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU;;YAa/B,QAAQ,SAAS,MAAM,EAAE,MAAM,SAAS,KAAK,KAAK,gBAAgB,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC;EAI3G"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Adapter } from "../adapters/types";
|
|
2
|
-
import type { FileStore } from "../file-stores/types";
|
|
3
|
-
import type { SerializedStep, Workflow } from './workflow';
|
|
4
|
-
import type { State } from './types';
|
|
5
|
-
import type { PromptClient } from '../clients/types';
|
|
6
|
-
interface Logger {
|
|
7
|
-
log(...args: any[]): void;
|
|
8
|
-
}
|
|
9
|
-
export declare class WorkflowRunner {
|
|
10
|
-
private options;
|
|
11
|
-
constructor(options: {
|
|
12
|
-
adapters: Adapter[];
|
|
13
|
-
fileStore: FileStore;
|
|
14
|
-
logger: Logger;
|
|
15
|
-
verbose: boolean;
|
|
16
|
-
client: PromptClient;
|
|
17
|
-
});
|
|
18
|
-
run<TOptions extends object = {}, TState extends State = {}>(workflow: Workflow<TOptions, TState>, { initialState, options, initialCompletedSteps, workflowRunId, endAfter }?: {
|
|
19
|
-
initialState?: TState;
|
|
20
|
-
options?: TOptions;
|
|
21
|
-
initialCompletedSteps?: SerializedStep[] | never;
|
|
22
|
-
workflowRunId?: string | never;
|
|
23
|
-
endAfter?: number;
|
|
24
|
-
}): Promise<void>;
|
|
25
|
-
private truncateDeep;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=workflow-runner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../../src/dsl/workflow-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,MAAM;IACd,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC3B;AAED,qBAAa,cAAc;IAEvB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE;QACf,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,SAAS,EAAE,SAAS,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,YAAY,CAAA;KACrB;IAGG,GAAG,CACP,QAAQ,SAAS,MAAM,GAAG,EAAE,EAC5B,MAAM,SAAS,KAAK,GAAG,EAAE,EAEzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EACpC,EACE,YAA2B,EAC3B,OAAO,EACP,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACT,GAAE;QACD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,QAAQ,CAAC;QACnB,qBAAqB,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QACjD,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;KACb;IAkER,OAAO,CAAC,YAAY;CAuCrB"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { PromptClient } from "../clients/types";
|
|
3
|
-
import type { State, JsonPatch } from "./types";
|
|
4
|
-
import { STATUS, WORKFLOW_EVENTS } from './constants';
|
|
5
|
-
import type { FileStore } from "../file-stores/types";
|
|
6
|
-
export type SerializedError = {
|
|
7
|
-
name: string;
|
|
8
|
-
message: string;
|
|
9
|
-
stack?: string;
|
|
10
|
-
};
|
|
11
|
-
interface BaseEvent<TOptions extends object = {}> {
|
|
12
|
-
type: typeof WORKFLOW_EVENTS[keyof typeof WORKFLOW_EVENTS];
|
|
13
|
-
options: TOptions;
|
|
14
|
-
workflowRunId: string;
|
|
15
|
-
}
|
|
16
|
-
interface WorkflowBaseEvent<TOptions extends object = {}> extends BaseEvent<TOptions> {
|
|
17
|
-
workflowTitle: string;
|
|
18
|
-
workflowDescription?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface WorkflowStartEvent<TOptions extends object = {}> extends WorkflowBaseEvent<TOptions> {
|
|
21
|
-
type: typeof WORKFLOW_EVENTS.START | typeof WORKFLOW_EVENTS.RESTART;
|
|
22
|
-
initialState: State;
|
|
23
|
-
status: typeof STATUS.RUNNING;
|
|
24
|
-
}
|
|
25
|
-
export interface WorkflowCompleteEvent<TOptions extends object = {}> extends WorkflowBaseEvent<TOptions> {
|
|
26
|
-
type: typeof WORKFLOW_EVENTS.COMPLETE;
|
|
27
|
-
status: typeof STATUS.COMPLETE;
|
|
28
|
-
}
|
|
29
|
-
export interface WorkflowErrorEvent<TOptions extends object = {}> extends WorkflowBaseEvent<TOptions> {
|
|
30
|
-
type: typeof WORKFLOW_EVENTS.ERROR;
|
|
31
|
-
status: typeof STATUS.ERROR;
|
|
32
|
-
error: SerializedError;
|
|
33
|
-
}
|
|
34
|
-
export interface StepStatusEvent<TOptions extends object = {}> extends BaseEvent<TOptions> {
|
|
35
|
-
type: typeof WORKFLOW_EVENTS.STEP_STATUS;
|
|
36
|
-
steps: SerializedStep[];
|
|
37
|
-
}
|
|
38
|
-
export interface StepStartedEvent<TOptions extends object = {}> extends BaseEvent<TOptions> {
|
|
39
|
-
type: typeof WORKFLOW_EVENTS.STEP_START;
|
|
40
|
-
status: typeof STATUS.RUNNING;
|
|
41
|
-
stepTitle: string;
|
|
42
|
-
stepId: string;
|
|
43
|
-
}
|
|
44
|
-
export interface StepCompletedEvent<TOptions extends object = {}> extends BaseEvent<TOptions> {
|
|
45
|
-
type: typeof WORKFLOW_EVENTS.STEP_COMPLETE;
|
|
46
|
-
status: typeof STATUS.RUNNING;
|
|
47
|
-
stepTitle: string;
|
|
48
|
-
stepId: string;
|
|
49
|
-
patch: JsonPatch;
|
|
50
|
-
}
|
|
51
|
-
export type WorkflowEvent<TOptions extends object = {}> = WorkflowStartEvent<TOptions> | WorkflowCompleteEvent<TOptions> | WorkflowErrorEvent<TOptions> | StepStatusEvent<TOptions> | StepStartedEvent<TOptions> | StepCompletedEvent<TOptions>;
|
|
52
|
-
export interface SerializedStep {
|
|
53
|
-
title: string;
|
|
54
|
-
status: typeof STATUS[keyof typeof STATUS];
|
|
55
|
-
id: string;
|
|
56
|
-
patch?: JsonPatch;
|
|
57
|
-
}
|
|
58
|
-
interface BaseRunParams<TOptions extends object = {}> {
|
|
59
|
-
fileStore: FileStore;
|
|
60
|
-
client: PromptClient;
|
|
61
|
-
options?: TOptions;
|
|
62
|
-
}
|
|
63
|
-
export interface InitialRunParams<TOptions extends object = {}> extends BaseRunParams<TOptions> {
|
|
64
|
-
initialState?: State;
|
|
65
|
-
initialCompletedSteps?: never;
|
|
66
|
-
workflowRunId?: never;
|
|
67
|
-
}
|
|
68
|
-
export interface RerunParams<TOptions extends object = {}> extends BaseRunParams<TOptions> {
|
|
69
|
-
initialState: State;
|
|
70
|
-
initialCompletedSteps: SerializedStep[];
|
|
71
|
-
workflowRunId: string;
|
|
72
|
-
}
|
|
73
|
-
export declare class Workflow<TOptions extends object = {}, TState extends State = {}> {
|
|
74
|
-
readonly title: string;
|
|
75
|
-
private description?;
|
|
76
|
-
private blocks;
|
|
77
|
-
type: 'workflow';
|
|
78
|
-
constructor(title: string, description?: string | undefined);
|
|
79
|
-
step<TNewState extends State>(title: string, action: (params: {
|
|
80
|
-
state: TState;
|
|
81
|
-
options: TOptions;
|
|
82
|
-
client: PromptClient;
|
|
83
|
-
fileStore: FileStore;
|
|
84
|
-
}) => TNewState | Promise<TNewState>): Workflow<TOptions, TNewState>;
|
|
85
|
-
workflow<TInnerState extends State, TNewState extends State>(title: string, innerWorkflow: Workflow<TOptions, TInnerState>, action: (params: {
|
|
86
|
-
state: TState;
|
|
87
|
-
workflowState: TInnerState;
|
|
88
|
-
}) => TNewState, initialState?: State | ((state: TState) => State)): Workflow<TOptions, TNewState>;
|
|
89
|
-
prompt<TResponseKey extends string & {
|
|
90
|
-
readonly brand?: unique symbol;
|
|
91
|
-
}, TSchema extends z.ZodObject<any>, TNewState extends State = TState & {
|
|
92
|
-
[K in TResponseKey]: z.infer<TSchema>;
|
|
93
|
-
}>(title: string, config: {
|
|
94
|
-
template: (state: TState) => string;
|
|
95
|
-
responseModel: {
|
|
96
|
-
schema: TSchema;
|
|
97
|
-
name: TResponseKey & (string extends TResponseKey ? never : unknown);
|
|
98
|
-
};
|
|
99
|
-
client?: PromptClient;
|
|
100
|
-
}, reduce?: (params: {
|
|
101
|
-
state: TState;
|
|
102
|
-
response: z.infer<TSchema>;
|
|
103
|
-
options: TOptions;
|
|
104
|
-
prompt: string;
|
|
105
|
-
}) => TNewState | Promise<TNewState>): Workflow<TOptions, TNewState>;
|
|
106
|
-
run(params: InitialRunParams<TOptions>): AsyncGenerator<WorkflowEvent<TOptions>>;
|
|
107
|
-
run(params: RerunParams<TOptions>): AsyncGenerator<WorkflowEvent<TOptions>>;
|
|
108
|
-
private withBlocks;
|
|
109
|
-
private nextWorkflow;
|
|
110
|
-
}
|
|
111
|
-
export declare function disableWorkflowNameUniqueness(): void;
|
|
112
|
-
export declare function enableWorkflowNameUniqueness(): void;
|
|
113
|
-
export declare function workflow<TOptions extends object = {}, TState extends State = {}>(workflowConfig: string | {
|
|
114
|
-
title: string;
|
|
115
|
-
description?: string;
|
|
116
|
-
}): Workflow<TOptions, TState>;
|
|
117
|
-
export {};
|
|
118
|
-
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/dsl/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAID,UAAU,SAAS,CAAC,QAAQ,SAAS,MAAM,GAAG,EAAE;IAC9C,IAAI,EAAE,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;IAC3D,OAAO,EAAE,QAAQ,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAGD,UAAU,iBAAiB,CAAC,QAAQ,SAAS,MAAM,GAAG,EAAE,CAAE,SAAQ,SAAS,CAAC,QAAQ,CAAC;IACnF,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,GAAG,EAAE,CAAE,SAAQ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QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAI9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/file-stores/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Writes content to a temporary file and opens it in cursor
|
|
3
|
-
*/
|
|
4
|
-
export declare function writeAndOpenTemp(content: string, prefix: string, extension?: string): Promise<string>;
|
|
5
|
-
/**
|
|
6
|
-
* Writes both prompt and response to temp files and opens them in cursor
|
|
7
|
-
*/
|
|
8
|
-
export declare function writePromptAndResponse(prompt: string, response: unknown, prefix?: string): Promise<{
|
|
9
|
-
promptPath: string;
|
|
10
|
-
responsePath: string;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=temp-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"temp-files.d.ts","sourceRoot":"","sources":["../../../src/utils/temp-files.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,EACjB,MAAM,GAAE,MAAgB,GACvB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CASvD"}
|
package/src/dsl/extensions.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Workflow } from "./workflow";
|
|
2
|
-
import type { State } from "./types";
|
|
3
|
-
|
|
4
|
-
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
|
5
|
-
|
|
6
|
-
type ExtensionMethods<
|
|
7
|
-
TExtension extends Record<string, any>,
|
|
8
|
-
TOptions extends object,
|
|
9
|
-
TState extends State
|
|
10
|
-
> = TExtension extends ((...args: any[]) => any)
|
|
11
|
-
? TExtension extends ((
|
|
12
|
-
this: any,
|
|
13
|
-
title: string,
|
|
14
|
-
config: infer TConfig
|
|
15
|
-
) => Workflow<any, infer TReturnState>)
|
|
16
|
-
? (
|
|
17
|
-
title: string,
|
|
18
|
-
config: TConfig extends ((ctx: any) => any)
|
|
19
|
-
? { [P in keyof TConfig]: TConfig[P] extends Function ? ((ctx: TState) => any) : TConfig[P] }
|
|
20
|
-
: TConfig
|
|
21
|
-
) => Workflow<TOptions, Expand<TState & TReturnState>>
|
|
22
|
-
: never
|
|
23
|
-
: {
|
|
24
|
-
[K in keyof TExtension]: TExtension[K] extends (
|
|
25
|
-
this: any,
|
|
26
|
-
title: string,
|
|
27
|
-
config: infer TConfig
|
|
28
|
-
) => Workflow<any, infer TReturnState>
|
|
29
|
-
? (
|
|
30
|
-
title: string,
|
|
31
|
-
config: TConfig extends ((ctx: any) => any)
|
|
32
|
-
? { [P in keyof TConfig]: TConfig[P] extends Function ? ((ctx: TState) => any) : TConfig[P] }
|
|
33
|
-
: TConfig
|
|
34
|
-
) => Workflow<TOptions, Expand<TState & TReturnState>>
|
|
35
|
-
: never;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export function createExtension<
|
|
39
|
-
TExtensionKey extends string,
|
|
40
|
-
TExtension extends Record<string, any>
|
|
41
|
-
>(key: TExtensionKey, extension: TExtension) {
|
|
42
|
-
return {
|
|
43
|
-
install() {
|
|
44
|
-
Object.defineProperty(Workflow.prototype, key, {
|
|
45
|
-
get() {
|
|
46
|
-
const boundMethods: Record<string, Function> = {};
|
|
47
|
-
for (const [methodKey, fn] of Object.entries(extension)) {
|
|
48
|
-
boundMethods[methodKey] = fn.bind(this);
|
|
49
|
-
}
|
|
50
|
-
return boundMethods;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
augment<TOptions extends object, TState extends State>(): ExtensionMethods<TExtension, TOptions, TState> {
|
|
55
|
-
return {} as ExtensionMethods<TExtension, TOptions, TState>;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|