workplane 0.3.1 → 0.4.1

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.
@@ -0,0 +1,535 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "f900e3c5-3284-48f6-be98-b3929a136698",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "artifacts": {
8
+ "name": "artifacts",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "run_id": {
18
+ "name": "run_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "type": {
25
+ "name": "type",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "name": {
32
+ "name": "name",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "path": {
39
+ "name": "path",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": true,
43
+ "autoincrement": false
44
+ },
45
+ "metadata": {
46
+ "name": "metadata",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": false,
50
+ "autoincrement": false
51
+ },
52
+ "created_at": {
53
+ "name": "created_at",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": true,
57
+ "autoincrement": false,
58
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
59
+ }
60
+ },
61
+ "indexes": {
62
+ "idx_artifacts_run_id": {
63
+ "name": "idx_artifacts_run_id",
64
+ "columns": [
65
+ "run_id"
66
+ ],
67
+ "isUnique": false
68
+ }
69
+ },
70
+ "foreignKeys": {
71
+ "artifacts_run_id_runs_id_fk": {
72
+ "name": "artifacts_run_id_runs_id_fk",
73
+ "tableFrom": "artifacts",
74
+ "tableTo": "runs",
75
+ "columnsFrom": [
76
+ "run_id"
77
+ ],
78
+ "columnsTo": [
79
+ "id"
80
+ ],
81
+ "onDelete": "no action",
82
+ "onUpdate": "no action"
83
+ }
84
+ },
85
+ "compositePrimaryKeys": {},
86
+ "uniqueConstraints": {},
87
+ "checkConstraints": {}
88
+ },
89
+ "nodes": {
90
+ "name": "nodes",
91
+ "columns": {
92
+ "id": {
93
+ "name": "id",
94
+ "type": "text",
95
+ "primaryKey": true,
96
+ "notNull": true,
97
+ "autoincrement": false
98
+ },
99
+ "name": {
100
+ "name": "name",
101
+ "type": "text",
102
+ "primaryKey": false,
103
+ "notNull": true,
104
+ "autoincrement": false
105
+ },
106
+ "capabilities": {
107
+ "name": "capabilities",
108
+ "type": "text",
109
+ "primaryKey": false,
110
+ "notNull": true,
111
+ "autoincrement": false,
112
+ "default": "'[]'"
113
+ },
114
+ "status": {
115
+ "name": "status",
116
+ "type": "text",
117
+ "primaryKey": false,
118
+ "notNull": true,
119
+ "autoincrement": false,
120
+ "default": "'online'"
121
+ },
122
+ "last_heartbeat_at": {
123
+ "name": "last_heartbeat_at",
124
+ "type": "text",
125
+ "primaryKey": false,
126
+ "notNull": false,
127
+ "autoincrement": false
128
+ },
129
+ "created_at": {
130
+ "name": "created_at",
131
+ "type": "text",
132
+ "primaryKey": false,
133
+ "notNull": true,
134
+ "autoincrement": false,
135
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
136
+ },
137
+ "updated_at": {
138
+ "name": "updated_at",
139
+ "type": "text",
140
+ "primaryKey": false,
141
+ "notNull": true,
142
+ "autoincrement": false,
143
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
144
+ }
145
+ },
146
+ "indexes": {},
147
+ "foreignKeys": {},
148
+ "compositePrimaryKeys": {},
149
+ "uniqueConstraints": {},
150
+ "checkConstraints": {}
151
+ },
152
+ "run_input_events": {
153
+ "name": "run_input_events",
154
+ "columns": {
155
+ "id": {
156
+ "name": "id",
157
+ "type": "integer",
158
+ "primaryKey": true,
159
+ "notNull": true,
160
+ "autoincrement": true
161
+ },
162
+ "run_id": {
163
+ "name": "run_id",
164
+ "type": "text",
165
+ "primaryKey": false,
166
+ "notNull": true,
167
+ "autoincrement": false
168
+ },
169
+ "sequence": {
170
+ "name": "sequence",
171
+ "type": "integer",
172
+ "primaryKey": false,
173
+ "notNull": true,
174
+ "autoincrement": false
175
+ },
176
+ "kind": {
177
+ "name": "kind",
178
+ "type": "text",
179
+ "primaryKey": false,
180
+ "notNull": true,
181
+ "autoincrement": false
182
+ },
183
+ "payload": {
184
+ "name": "payload",
185
+ "type": "text",
186
+ "primaryKey": false,
187
+ "notNull": true,
188
+ "autoincrement": false,
189
+ "default": "'{}'"
190
+ },
191
+ "created_at": {
192
+ "name": "created_at",
193
+ "type": "text",
194
+ "primaryKey": false,
195
+ "notNull": true,
196
+ "autoincrement": false,
197
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
198
+ },
199
+ "delivered_at": {
200
+ "name": "delivered_at",
201
+ "type": "text",
202
+ "primaryKey": false,
203
+ "notNull": false,
204
+ "autoincrement": false
205
+ }
206
+ },
207
+ "indexes": {
208
+ "idx_run_input_events_run_sequence": {
209
+ "name": "idx_run_input_events_run_sequence",
210
+ "columns": [
211
+ "run_id",
212
+ "sequence"
213
+ ],
214
+ "isUnique": true
215
+ },
216
+ "idx_run_input_events_undelivered": {
217
+ "name": "idx_run_input_events_undelivered",
218
+ "columns": [
219
+ "run_id",
220
+ "sequence"
221
+ ],
222
+ "isUnique": false,
223
+ "where": "\"run_input_events\".\"delivered_at\" is null"
224
+ }
225
+ },
226
+ "foreignKeys": {
227
+ "run_input_events_run_id_runs_id_fk": {
228
+ "name": "run_input_events_run_id_runs_id_fk",
229
+ "tableFrom": "run_input_events",
230
+ "tableTo": "runs",
231
+ "columnsFrom": [
232
+ "run_id"
233
+ ],
234
+ "columnsTo": [
235
+ "id"
236
+ ],
237
+ "onDelete": "no action",
238
+ "onUpdate": "no action"
239
+ }
240
+ },
241
+ "compositePrimaryKeys": {},
242
+ "uniqueConstraints": {},
243
+ "checkConstraints": {}
244
+ },
245
+ "run_logs": {
246
+ "name": "run_logs",
247
+ "columns": {
248
+ "id": {
249
+ "name": "id",
250
+ "type": "integer",
251
+ "primaryKey": true,
252
+ "notNull": true,
253
+ "autoincrement": true
254
+ },
255
+ "run_id": {
256
+ "name": "run_id",
257
+ "type": "text",
258
+ "primaryKey": false,
259
+ "notNull": true,
260
+ "autoincrement": false
261
+ },
262
+ "step_name": {
263
+ "name": "step_name",
264
+ "type": "text",
265
+ "primaryKey": false,
266
+ "notNull": false,
267
+ "autoincrement": false
268
+ },
269
+ "stream": {
270
+ "name": "stream",
271
+ "type": "text",
272
+ "primaryKey": false,
273
+ "notNull": true,
274
+ "autoincrement": false
275
+ },
276
+ "message": {
277
+ "name": "message",
278
+ "type": "text",
279
+ "primaryKey": false,
280
+ "notNull": true,
281
+ "autoincrement": false
282
+ },
283
+ "timestamp": {
284
+ "name": "timestamp",
285
+ "type": "text",
286
+ "primaryKey": false,
287
+ "notNull": true,
288
+ "autoincrement": false,
289
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
290
+ }
291
+ },
292
+ "indexes": {
293
+ "idx_run_logs_run_id_timestamp": {
294
+ "name": "idx_run_logs_run_id_timestamp",
295
+ "columns": [
296
+ "run_id",
297
+ "timestamp"
298
+ ],
299
+ "isUnique": false
300
+ }
301
+ },
302
+ "foreignKeys": {
303
+ "run_logs_run_id_runs_id_fk": {
304
+ "name": "run_logs_run_id_runs_id_fk",
305
+ "tableFrom": "run_logs",
306
+ "tableTo": "runs",
307
+ "columnsFrom": [
308
+ "run_id"
309
+ ],
310
+ "columnsTo": [
311
+ "id"
312
+ ],
313
+ "onDelete": "no action",
314
+ "onUpdate": "no action"
315
+ }
316
+ },
317
+ "compositePrimaryKeys": {},
318
+ "uniqueConstraints": {},
319
+ "checkConstraints": {}
320
+ },
321
+ "runs": {
322
+ "name": "runs",
323
+ "columns": {
324
+ "id": {
325
+ "name": "id",
326
+ "type": "text",
327
+ "primaryKey": true,
328
+ "notNull": true,
329
+ "autoincrement": false
330
+ },
331
+ "task_id": {
332
+ "name": "task_id",
333
+ "type": "text",
334
+ "primaryKey": false,
335
+ "notNull": true,
336
+ "autoincrement": false
337
+ },
338
+ "node_id": {
339
+ "name": "node_id",
340
+ "type": "text",
341
+ "primaryKey": false,
342
+ "notNull": true,
343
+ "autoincrement": false
344
+ },
345
+ "attempt": {
346
+ "name": "attempt",
347
+ "type": "integer",
348
+ "primaryKey": false,
349
+ "notNull": true,
350
+ "autoincrement": false
351
+ },
352
+ "status": {
353
+ "name": "status",
354
+ "type": "text",
355
+ "primaryKey": false,
356
+ "notNull": true,
357
+ "autoincrement": false
358
+ },
359
+ "started_at": {
360
+ "name": "started_at",
361
+ "type": "text",
362
+ "primaryKey": false,
363
+ "notNull": false,
364
+ "autoincrement": false
365
+ },
366
+ "ended_at": {
367
+ "name": "ended_at",
368
+ "type": "text",
369
+ "primaryKey": false,
370
+ "notNull": false,
371
+ "autoincrement": false
372
+ },
373
+ "error": {
374
+ "name": "error",
375
+ "type": "text",
376
+ "primaryKey": false,
377
+ "notNull": false,
378
+ "autoincrement": false
379
+ },
380
+ "created_at": {
381
+ "name": "created_at",
382
+ "type": "text",
383
+ "primaryKey": false,
384
+ "notNull": true,
385
+ "autoincrement": false,
386
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
387
+ },
388
+ "updated_at": {
389
+ "name": "updated_at",
390
+ "type": "text",
391
+ "primaryKey": false,
392
+ "notNull": true,
393
+ "autoincrement": false,
394
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
395
+ }
396
+ },
397
+ "indexes": {
398
+ "idx_runs_task_id": {
399
+ "name": "idx_runs_task_id",
400
+ "columns": [
401
+ "task_id"
402
+ ],
403
+ "isUnique": false
404
+ },
405
+ "idx_runs_node_id": {
406
+ "name": "idx_runs_node_id",
407
+ "columns": [
408
+ "node_id"
409
+ ],
410
+ "isUnique": false
411
+ }
412
+ },
413
+ "foreignKeys": {
414
+ "runs_task_id_tasks_id_fk": {
415
+ "name": "runs_task_id_tasks_id_fk",
416
+ "tableFrom": "runs",
417
+ "tableTo": "tasks",
418
+ "columnsFrom": [
419
+ "task_id"
420
+ ],
421
+ "columnsTo": [
422
+ "id"
423
+ ],
424
+ "onDelete": "no action",
425
+ "onUpdate": "no action"
426
+ },
427
+ "runs_node_id_nodes_id_fk": {
428
+ "name": "runs_node_id_nodes_id_fk",
429
+ "tableFrom": "runs",
430
+ "tableTo": "nodes",
431
+ "columnsFrom": [
432
+ "node_id"
433
+ ],
434
+ "columnsTo": [
435
+ "id"
436
+ ],
437
+ "onDelete": "no action",
438
+ "onUpdate": "no action"
439
+ }
440
+ },
441
+ "compositePrimaryKeys": {},
442
+ "uniqueConstraints": {},
443
+ "checkConstraints": {}
444
+ },
445
+ "tasks": {
446
+ "name": "tasks",
447
+ "columns": {
448
+ "id": {
449
+ "name": "id",
450
+ "type": "text",
451
+ "primaryKey": true,
452
+ "notNull": true,
453
+ "autoincrement": false
454
+ },
455
+ "kind": {
456
+ "name": "kind",
457
+ "type": "text",
458
+ "primaryKey": false,
459
+ "notNull": true,
460
+ "autoincrement": false
461
+ },
462
+ "adapter": {
463
+ "name": "adapter",
464
+ "type": "text",
465
+ "primaryKey": false,
466
+ "notNull": true,
467
+ "autoincrement": false
468
+ },
469
+ "payload": {
470
+ "name": "payload",
471
+ "type": "text",
472
+ "primaryKey": false,
473
+ "notNull": true,
474
+ "autoincrement": false,
475
+ "default": "'{}'"
476
+ },
477
+ "requires": {
478
+ "name": "requires",
479
+ "type": "text",
480
+ "primaryKey": false,
481
+ "notNull": true,
482
+ "autoincrement": false,
483
+ "default": "'[]'"
484
+ },
485
+ "status": {
486
+ "name": "status",
487
+ "type": "text",
488
+ "primaryKey": false,
489
+ "notNull": true,
490
+ "autoincrement": false
491
+ },
492
+ "created_at": {
493
+ "name": "created_at",
494
+ "type": "text",
495
+ "primaryKey": false,
496
+ "notNull": true,
497
+ "autoincrement": false,
498
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
499
+ },
500
+ "updated_at": {
501
+ "name": "updated_at",
502
+ "type": "text",
503
+ "primaryKey": false,
504
+ "notNull": true,
505
+ "autoincrement": false,
506
+ "default": "(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))"
507
+ }
508
+ },
509
+ "indexes": {
510
+ "idx_tasks_status_created_at": {
511
+ "name": "idx_tasks_status_created_at",
512
+ "columns": [
513
+ "status",
514
+ "created_at"
515
+ ],
516
+ "isUnique": false
517
+ }
518
+ },
519
+ "foreignKeys": {},
520
+ "compositePrimaryKeys": {},
521
+ "uniqueConstraints": {},
522
+ "checkConstraints": {}
523
+ }
524
+ },
525
+ "views": {},
526
+ "enums": {},
527
+ "_meta": {
528
+ "schemas": {},
529
+ "tables": {},
530
+ "columns": {}
531
+ },
532
+ "internal": {
533
+ "indexes": {}
534
+ }
535
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1780195156990,
9
+ "tag": "0000_dry_zarek",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/dist/node.js CHANGED
@@ -2,27 +2,30 @@
2
2
 
3
3
  // ../node/src/index.ts
4
4
  import { mkdir as mkdir2, writeFile as writeFile3 } from "fs/promises";
5
- import { join as join6, resolve } from "path";
5
+ import { join as join7, resolve } from "path";
6
6
 
7
7
  // ../core/src/config.ts
8
8
  import { z } from "zod";
9
9
 
10
10
  // ../core/src/env.ts
11
11
  import { config as dotenvConfig } from "dotenv";
12
+ import { homedir } from "os";
13
+ import { join } from "path";
12
14
  var envLoaded = false;
13
15
  function loadLocalEnv() {
14
16
  if (envLoaded) {
15
17
  return;
16
18
  }
19
+ dotenvConfig({ path: ".env.local" });
20
+ dotenvConfig({ path: join(homedir(), ".workplane", ".env") });
17
21
  dotenvConfig({ path: ".env" });
18
- dotenvConfig({ path: ".env.local", override: true });
19
22
  envLoaded = true;
20
23
  }
21
24
 
22
25
  // ../core/src/config.ts
23
26
  loadLocalEnv();
24
27
  var serverEnvSchema = z.object({
25
- DATABASE_URL: z.string().min(1),
28
+ DATABASE_URL: z.string().optional().default("sqlite://~/.workplane/workplane.db"),
26
29
  WORKPLANE_SERVER_PORT: z.string().optional().default("8787").transform((value) => Number.parseInt(value, 10)),
27
30
  WORKPLANE_NODE_TOKEN: z.string().optional(),
28
31
  WORKPLANE_OPERATOR_TOKEN: z.string().optional(),
@@ -93,9 +96,9 @@ async function workplaneFetch(serverUrl, path, options = {}) {
93
96
  }
94
97
 
95
98
  // ../core/src/git.ts
96
- import { join } from "path";
99
+ import { join as join2 } from "path";
97
100
  function repoPath(workspacePath) {
98
- return join(workspacePath, "repo");
101
+ return join2(workspacePath, "repo");
99
102
  }
100
103
  async function createTaskBranch(context, branchName) {
101
104
  const cwd = repoPath(context.workspacePath);
@@ -112,7 +115,7 @@ async function captureGitDiff(context, adapterName, artifactName = "changes.diff
112
115
  const cwd = repoPath(context.workspacePath);
113
116
  const diffResult = await context.exec("git", ["diff"], { cwd });
114
117
  const artifactsPath = await context.ensureWorkspace("artifacts");
115
- const diffPath = join(artifactsPath, artifactName);
118
+ const diffPath = join2(artifactsPath, artifactName);
116
119
  const { writeFile: writeFile4 } = await import("fs/promises");
117
120
  await writeFile4(diffPath, diffResult.stdout, "utf8");
118
121
  await context.emitArtifact({
@@ -127,7 +130,7 @@ async function captureGitDiff(context, adapterName, artifactName = "changes.diff
127
130
  // ../adapter-sdk/src/index.ts
128
131
  import { spawn } from "child_process";
129
132
  import { mkdir } from "fs/promises";
130
- import { join as join2 } from "path";
133
+ import { join as join3 } from "path";
131
134
  function pickEnv(allowlist) {
132
135
  if (!allowlist || allowlist.length === 0) {
133
136
  return { ...process.env };
@@ -212,7 +215,7 @@ ${childError.message}`.trim() : stderr
212
215
  return { exec, kill, writeStdin };
213
216
  }
214
217
  async function ensureWorkspacePath(workspacePath, ...segments) {
215
- const fullPath = join2(workspacePath, ...segments);
218
+ const fullPath = join3(workspacePath, ...segments);
216
219
  await mkdir(fullPath, { recursive: true });
217
220
  return fullPath;
218
221
  }
@@ -305,17 +308,17 @@ function createPtyExec(context) {
305
308
  }
306
309
 
307
310
  // ../adapter-shell/src/index.ts
308
- import { join as join3 } from "path";
311
+ import { join as join4 } from "path";
309
312
  import { writeFile } from "fs/promises";
310
313
  var shellAdapter = {
311
314
  name: "shell",
312
315
  kind: "shell.exec",
313
316
  async run(context, payload) {
314
317
  const renderedCommand = payload.args && payload.args.length > 0 ? `${payload.command} ${payload.args.join(" ")}` : payload.command;
315
- const commandCwd = payload.cwd ? payload.cwd.startsWith("/") ? payload.cwd : join3(context.workspacePath, payload.cwd) : context.workspacePath;
318
+ const commandCwd = payload.cwd ? payload.cwd.startsWith("/") ? payload.cwd : join4(context.workspacePath, payload.cwd) : context.workspacePath;
316
319
  const result = await context.exec("/bin/sh", ["-lc", renderedCommand], { cwd: commandCwd });
317
320
  const artifactsDir = await context.ensureWorkspace("artifacts");
318
- const resultPath = join3(artifactsDir, "shell-result.json");
321
+ const resultPath = join4(artifactsDir, "shell-result.json");
319
322
  await writeFile(
320
323
  resultPath,
321
324
  JSON.stringify(
@@ -369,7 +372,7 @@ var aiderAdapter = {
369
372
 
370
373
  // ../adapter-ollama/src/index.ts
371
374
  import { writeFile as writeFile2 } from "fs/promises";
372
- import { join as join4 } from "path";
375
+ import { join as join5 } from "path";
373
376
  var ollamaAdapter = {
374
377
  name: "ollama",
375
378
  kind: "inference.batch",
@@ -380,7 +383,7 @@ var ollamaAdapter = {
380
383
  throw new Error(`ollama failed with exit code ${result.exitCode}`);
381
384
  }
382
385
  const artifactsPath = await context.ensureWorkspace("artifacts");
383
- const outputPath = join4(artifactsPath, "inference-output.txt");
386
+ const outputPath = join5(artifactsPath, "inference-output.txt");
384
387
  const output = `${result.stdout}${result.stderr}`.trim();
385
388
  await writeFile2(outputPath, output, "utf8");
386
389
  await context.emitArtifact({
@@ -396,7 +399,7 @@ var ollamaAdapter = {
396
399
  };
397
400
 
398
401
  // ../adapter-harness/src/index.ts
399
- import { join as join5 } from "path";
402
+ import { join as join6 } from "path";
400
403
  function resolveBinary(binary) {
401
404
  return typeof binary === "function" ? binary() : binary;
402
405
  }
@@ -433,7 +436,7 @@ function createHarnessAdapter(options) {
433
436
  if (payload.testCommand) {
434
437
  await context.log("system", `running test command: ${payload.testCommand}`, "run-tests");
435
438
  const testResult = await context.exec("/bin/sh", ["-lc", payload.testCommand], { cwd });
436
- const testArtifactPath = join5(await context.ensureWorkspace("artifacts"), "test-output.txt");
439
+ const testArtifactPath = join6(await context.ensureWorkspace("artifacts"), "test-output.txt");
437
440
  const { writeFile: writeFile4 } = await import("fs/promises");
438
441
  await writeFile4(testArtifactPath, `${testResult.stdout}
439
442
  ${testResult.stderr}`, "utf8");
@@ -616,14 +619,14 @@ async function executeAssignment(config, assignment) {
616
619
  await updateStatus(config, runId, "failed", `adapter not registered: ${task.adapter}`);
617
620
  return;
618
621
  }
619
- const runWorkspace = join6(workspaceRoot(), `${runId}_${nowStamp()}`);
622
+ const runWorkspace = join7(workspaceRoot(), `${runId}_${nowStamp()}`);
620
623
  const mirrorLogs = shouldMirrorNodeLogs();
621
624
  await mkdir2(runWorkspace, { recursive: true });
622
625
  await ensureWorkspacePath(runWorkspace, "logs");
623
626
  await ensureWorkspacePath(runWorkspace, "artifacts");
624
627
  await ensureWorkspacePath(runWorkspace, "tmp");
625
628
  await writeFile3(
626
- join6(runWorkspace, "metadata.json"),
629
+ join7(runWorkspace, "metadata.json"),
627
630
  JSON.stringify({ runId, taskId: task.id, adapter: task.adapter, createdAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2),
628
631
  "utf8"
629
632
  );