@dmrlzz/davecode 0.5.3 → 0.7.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.
Files changed (87) hide show
  1. package/README.md +1 -0
  2. package/dist/{ChatApp-IF5D7XNH.js → ChatApp-C23NVTME.js} +6 -6
  3. package/dist/{account-KBXJ5KR7.js → account-GG7UFSNY.js} +3 -3
  4. package/dist/{accounts-XUJNDCFH.js → accounts-IPOGUMHF.js} +5 -5
  5. package/dist/{budget-PHV4NRUS.js → budget-7QJGPYPF.js} +4 -4
  6. package/dist/{chat-HGTX76DU.js → chat-3K2KXS3E.js} +8 -8
  7. package/dist/{chunk-FZJNOG2T.js → chunk-3BTE76UD.js} +2 -2
  8. package/dist/{chunk-FPSLYBLU.js → chunk-4FE2YV5U.js} +2 -2
  9. package/dist/{chunk-YSD6W27K.js → chunk-FKGZERYB.js} +283 -5
  10. package/dist/chunk-FKGZERYB.js.map +1 -0
  11. package/dist/{chunk-AFCQURO5.js → chunk-JBX6J74G.js} +3 -3
  12. package/dist/{chunk-EBV5A33R.js → chunk-KEURMO75.js} +4 -4
  13. package/dist/{chunk-DFQW3MRD.js → chunk-LK2K73DC.js} +2 -2
  14. package/dist/{chunk-ING5HCIO.js → chunk-NBQIMB43.js} +3430 -1063
  15. package/dist/chunk-NBQIMB43.js.map +1 -0
  16. package/dist/{goal-ETZWLVKO.js → chunk-PGZPSJS7.js} +8 -8
  17. package/dist/chunk-PGZPSJS7.js.map +1 -0
  18. package/dist/{chunk-ZVNX7CSO.js → chunk-U42YONUN.js} +3 -3
  19. package/dist/{config-DG2E4VDW.js → config-BFEQFGAR.js} +3 -3
  20. package/dist/dashboard/assets/Accounts-CUMFzGls.js +1 -0
  21. package/dist/dashboard/assets/{Callout-1E8Wsl9W.js → Callout-DDtTG_BA.js} +1 -1
  22. package/dist/dashboard/assets/Goals-CBGiTkcP.js +1 -0
  23. package/dist/dashboard/assets/{Library-DZxBVUo_.js → Library-CKWa3h0E.js} +1 -1
  24. package/dist/dashboard/assets/{Panes-C-TJekjs.js → Panes-ziAz-CZa.js} +4 -4
  25. package/dist/dashboard/assets/RoutesPage-D2iW-KhM.js +4 -0
  26. package/dist/dashboard/assets/Runner-4e79FB1J.js +1 -0
  27. package/dist/dashboard/assets/Settings-CSae84S0.js +1 -0
  28. package/dist/dashboard/assets/Tasks-CnbZ5PvX.js +2 -0
  29. package/dist/dashboard/assets/Traffic-B12xKOUm.js +1 -0
  30. package/dist/dashboard/assets/Workspace-CMPHlw4f.js +1 -0
  31. package/dist/dashboard/assets/chevron-down-DT349Fth.js +1 -0
  32. package/dist/dashboard/assets/external-link-DCIUScea.js +1 -0
  33. package/dist/dashboard/assets/format-C7Q-B9fI.js +112 -0
  34. package/dist/dashboard/assets/index-4RIBvhr9.css +2 -0
  35. package/dist/dashboard/assets/index-z8TlFwRe.js +50 -0
  36. package/dist/dashboard/assets/task-errors-3F3vbQ7k.js +1 -0
  37. package/dist/dashboard/assets/x-UBQsC1rW.js +1 -0
  38. package/dist/dashboard/index.html +4 -3
  39. package/dist/{dist-IPMBGFJD.js → dist-VTC5E7Z5.js} +48 -2
  40. package/dist/{doctor-5APOWJ5D.js → doctor-JLFYQ3EP.js} +3 -3
  41. package/dist/goal-JM7QYTL2.js +26 -0
  42. package/dist/index.js +64 -31
  43. package/dist/index.js.map +1 -1
  44. package/dist/{init-YDLNA3GD.js → init-6K4EGMTV.js} +3 -3
  45. package/dist/orchestrate-QC5P6IUZ.js +382 -0
  46. package/dist/orchestrate-QC5P6IUZ.js.map +1 -0
  47. package/dist/{run-I6N7TLHV.js → run-ABQNQ722.js} +3 -3
  48. package/dist/runtime.js +6 -2
  49. package/dist/{start-ECLELJGJ.js → start-MSO7TGBX.js} +3 -3
  50. package/dist/{status-QQPP67I4.js → status-U6C4LUCM.js} +4 -4
  51. package/dist/status-U6C4LUCM.js.map +1 -0
  52. package/dist/{tasks-RNMC2XFN.js → tasks-HEVT67YM.js} +4 -4
  53. package/package.json +4 -4
  54. package/dist/chunk-ING5HCIO.js.map +0 -1
  55. package/dist/chunk-YSD6W27K.js.map +0 -1
  56. package/dist/dashboard/assets/Accounts-DXiGsutB.js +0 -1
  57. package/dist/dashboard/assets/Badge-DUGKlx3Z.js +0 -55
  58. package/dist/dashboard/assets/Goals-kL4VAxw3.js +0 -1
  59. package/dist/dashboard/assets/RoutesPage-DWYm9tW8.js +0 -4
  60. package/dist/dashboard/assets/Runner-CmHBjECR.js +0 -1
  61. package/dist/dashboard/assets/Settings-BANphxva.js +0 -1
  62. package/dist/dashboard/assets/Tasks-cSx1PKyQ.js +0 -2
  63. package/dist/dashboard/assets/Traffic-DEAuM6jq.js +0 -1
  64. package/dist/dashboard/assets/Workspace-BQFjc1jH.js +0 -1
  65. package/dist/dashboard/assets/index-B8kld9xo.js +0 -104
  66. package/dist/dashboard/assets/index-BEmBgsbP.css +0 -2
  67. package/dist/dashboard/assets/task-errors-r-WYZ_S3.js +0 -1
  68. package/dist/goal-ETZWLVKO.js.map +0 -1
  69. /package/dist/{ChatApp-IF5D7XNH.js.map → ChatApp-C23NVTME.js.map} +0 -0
  70. /package/dist/{account-KBXJ5KR7.js.map → account-GG7UFSNY.js.map} +0 -0
  71. /package/dist/{accounts-XUJNDCFH.js.map → accounts-IPOGUMHF.js.map} +0 -0
  72. /package/dist/{budget-PHV4NRUS.js.map → budget-7QJGPYPF.js.map} +0 -0
  73. /package/dist/{chat-HGTX76DU.js.map → chat-3K2KXS3E.js.map} +0 -0
  74. /package/dist/{chunk-FZJNOG2T.js.map → chunk-3BTE76UD.js.map} +0 -0
  75. /package/dist/{chunk-FPSLYBLU.js.map → chunk-4FE2YV5U.js.map} +0 -0
  76. /package/dist/{chunk-AFCQURO5.js.map → chunk-JBX6J74G.js.map} +0 -0
  77. /package/dist/{chunk-EBV5A33R.js.map → chunk-KEURMO75.js.map} +0 -0
  78. /package/dist/{chunk-DFQW3MRD.js.map → chunk-LK2K73DC.js.map} +0 -0
  79. /package/dist/{chunk-ZVNX7CSO.js.map → chunk-U42YONUN.js.map} +0 -0
  80. /package/dist/{config-DG2E4VDW.js.map → config-BFEQFGAR.js.map} +0 -0
  81. /package/dist/{dist-IPMBGFJD.js.map → dist-VTC5E7Z5.js.map} +0 -0
  82. /package/dist/{doctor-5APOWJ5D.js.map → doctor-JLFYQ3EP.js.map} +0 -0
  83. /package/dist/{status-QQPP67I4.js.map → goal-JM7QYTL2.js.map} +0 -0
  84. /package/dist/{init-YDLNA3GD.js.map → init-6K4EGMTV.js.map} +0 -0
  85. /package/dist/{run-I6N7TLHV.js.map → run-ABQNQ722.js.map} +0 -0
  86. /package/dist/{start-ECLELJGJ.js.map → start-MSO7TGBX.js.map} +0 -0
  87. /package/dist/{tasks-RNMC2XFN.js.map → tasks-HEVT67YM.js.map} +0 -0
package/README.md CHANGED
@@ -17,6 +17,7 @@ davecode start # gateway on http://localhost:4040/v1 + dashboard a
17
17
  davecode # chat TUI in your terminal
18
18
  davecode init && davecode run # let the autonomous runner work through .davecode/TASK_GRAPH.json
19
19
  davecode goal "<objective>" # a team of agents plans, executes, reviews and re-plans
20
+ davecode orchestrate "<objective>" # split it across Claude Code, Codex and Antigravity worktrees
20
21
  davecode budget # plans, renewals and remaining quota per account
21
22
  ```
22
23
 
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  formatTaskTree,
3
3
  summaryLine
4
- } from "./chunk-DFQW3MRD.js";
4
+ } from "./chunk-LK2K73DC.js";
5
5
  import {
6
6
  brandBanner
7
- } from "./chunk-FZJNOG2T.js";
7
+ } from "./chunk-3BTE76UD.js";
8
8
  import {
9
9
  Spinner
10
10
  } from "./chunk-5LKOJBUL.js";
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  emptyUsage,
17
17
  renderAccounts
18
- } from "./chunk-ZVNX7CSO.js";
18
+ } from "./chunk-U42YONUN.js";
19
19
  import {
20
20
  bar,
21
21
  formatTokens,
@@ -25,10 +25,10 @@ import {
25
25
  visibleWidth
26
26
  } from "./chunk-SF5ZEAP4.js";
27
27
  import "./chunk-QA3O6RA2.js";
28
- import "./chunk-YSD6W27K.js";
28
+ import "./chunk-FKGZERYB.js";
29
29
  import "./chunk-7XVXEO7U.js";
30
30
  import "./chunk-732GIHRQ.js";
31
- import "./chunk-ING5HCIO.js";
31
+ import "./chunk-NBQIMB43.js";
32
32
  import "./chunk-MC7RIPL7.js";
33
33
 
34
34
  // src/tui/ChatApp.tsx
@@ -1043,4 +1043,4 @@ function ChatApp(props) {
1043
1043
  export {
1044
1044
  ChatApp
1045
1045
  };
1046
- //# sourceMappingURL=ChatApp-IF5D7XNH.js.map
1046
+ //# sourceMappingURL=ChatApp-C23NVTME.js.map
@@ -7,10 +7,10 @@ import {
7
7
  loginCommand,
8
8
  logoutCommand,
9
9
  signIn
10
- } from "./chunk-FPSLYBLU.js";
10
+ } from "./chunk-4FE2YV5U.js";
11
11
  import "./chunk-7XVXEO7U.js";
12
12
  import "./chunk-732GIHRQ.js";
13
- import "./chunk-ING5HCIO.js";
13
+ import "./chunk-NBQIMB43.js";
14
14
  export {
15
15
  accountCommand,
16
16
  accountsEnabled,
@@ -21,4 +21,4 @@ export {
21
21
  logoutCommand,
22
22
  signIn
23
23
  };
24
- //# sourceMappingURL=account-KBXJ5KR7.js.map
24
+ //# sourceMappingURL=account-GG7UFSNY.js.map
@@ -11,15 +11,15 @@ import {
11
11
  loginArgs,
12
12
  renderAccountList,
13
13
  subscriptionFromFlags
14
- } from "./chunk-EBV5A33R.js";
15
- import "./chunk-AFCQURO5.js";
14
+ } from "./chunk-KEURMO75.js";
15
+ import "./chunk-JBX6J74G.js";
16
16
  import "./chunk-IC3TDONV.js";
17
17
  import "./chunk-SF5ZEAP4.js";
18
18
  import "./chunk-QA3O6RA2.js";
19
- import "./chunk-YSD6W27K.js";
19
+ import "./chunk-FKGZERYB.js";
20
20
  import "./chunk-7XVXEO7U.js";
21
21
  import "./chunk-732GIHRQ.js";
22
- import "./chunk-ING5HCIO.js";
22
+ import "./chunk-NBQIMB43.js";
23
23
  import "./chunk-MC7RIPL7.js";
24
24
  export {
25
25
  accountsAdd,
@@ -35,4 +35,4 @@ export {
35
35
  renderAccountList,
36
36
  subscriptionFromFlags
37
37
  };
38
- //# sourceMappingURL=accounts-XUJNDCFH.js.map
38
+ //# sourceMappingURL=accounts-IPOGUMHF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openAccounts
3
- } from "./chunk-AFCQURO5.js";
3
+ } from "./chunk-JBX6J74G.js";
4
4
  import {
5
5
  bar,
6
6
  levelStyle,
@@ -13,12 +13,12 @@ import {
13
13
  } from "./chunk-QA3O6RA2.js";
14
14
  import {
15
15
  detectProjectRoot
16
- } from "./chunk-YSD6W27K.js";
16
+ } from "./chunk-FKGZERYB.js";
17
17
  import {
18
18
  EXIT
19
19
  } from "./chunk-7XVXEO7U.js";
20
20
  import "./chunk-732GIHRQ.js";
21
- import "./chunk-ING5HCIO.js";
21
+ import "./chunk-NBQIMB43.js";
22
22
  import "./chunk-MC7RIPL7.js";
23
23
 
24
24
  // src/commands/budget.ts
@@ -113,4 +113,4 @@ export {
113
113
  budgetCommand,
114
114
  renderBudget
115
115
  };
116
- //# sourceMappingURL=budget-PHV4NRUS.js.map
116
+ //# sourceMappingURL=budget-7QJGPYPF.js.map
@@ -4,19 +4,19 @@ import {
4
4
  currentAccount,
5
5
  describeUser,
6
6
  signIn
7
- } from "./chunk-FPSLYBLU.js";
7
+ } from "./chunk-4FE2YV5U.js";
8
8
  import {
9
9
  accountsLogin
10
- } from "./chunk-EBV5A33R.js";
10
+ } from "./chunk-KEURMO75.js";
11
11
  import {
12
12
  openAccounts
13
- } from "./chunk-AFCQURO5.js";
13
+ } from "./chunk-JBX6J74G.js";
14
14
  import {
15
15
  PromptCancelledError
16
16
  } from "./chunk-IC3TDONV.js";
17
17
  import {
18
18
  brandBanner
19
- } from "./chunk-FZJNOG2T.js";
19
+ } from "./chunk-3BTE76UD.js";
20
20
  import "./chunk-SF5ZEAP4.js";
21
21
  import {
22
22
  readPreferences,
@@ -28,7 +28,7 @@ import {
28
28
  findGateway,
29
29
  startRuntime,
30
30
  which
31
- } from "./chunk-YSD6W27K.js";
31
+ } from "./chunk-FKGZERYB.js";
32
32
  import {
33
33
  CliError,
34
34
  EXIT
@@ -39,7 +39,7 @@ import {
39
39
  VERSION,
40
40
  loadConfig,
41
41
  writeGlobalRouting
42
- } from "./chunk-ING5HCIO.js";
42
+ } from "./chunk-NBQIMB43.js";
43
43
  import {
44
44
  createTheme
45
45
  } from "./chunk-MC7RIPL7.js";
@@ -329,7 +329,7 @@ async function runChat(ctx, opts, projectRoot) {
329
329
  const [{ render }, { createElement }, { ChatApp }] = await Promise.all([
330
330
  import("ink"),
331
331
  import("react"),
332
- import("./ChatApp-IF5D7XNH.js")
332
+ import("./ChatApp-C23NVTME.js")
333
333
  ]);
334
334
  const instance = render(
335
335
  createElement(ChatApp, {
@@ -357,4 +357,4 @@ async function runChat(ctx, opts, projectRoot) {
357
357
  export {
358
358
  chatCommand
359
359
  };
360
- //# sourceMappingURL=chat-HGTX76DU.js.map
360
+ //# sourceMappingURL=chat-3K2KXS3E.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  brandLogo
3
- } from "./chunk-ING5HCIO.js";
3
+ } from "./chunk-NBQIMB43.js";
4
4
 
5
5
  // src/ui/banner.ts
6
6
  function brandBanner(theme, text, columns = 80, minColumns = 56) {
@@ -17,4 +17,4 @@ function brandBanner(theme, text, columns = 80, minColumns = 56) {
17
17
  export {
18
18
  brandBanner
19
19
  };
20
- //# sourceMappingURL=chunk-FZJNOG2T.js.map
20
+ //# sourceMappingURL=chunk-3BTE76UD.js.map
@@ -10,7 +10,7 @@ import {
10
10
  AccountStore,
11
11
  accountService,
12
12
  startAccountLogin
13
- } from "./chunk-ING5HCIO.js";
13
+ } from "./chunk-NBQIMB43.js";
14
14
 
15
15
  // src/commands/account.ts
16
16
  function serviceFor(ctx, deps) {
@@ -125,4 +125,4 @@ export {
125
125
  accountCommand,
126
126
  chatAccountActions
127
127
  };
128
- //# sourceMappingURL=chunk-FPSLYBLU.js.map
128
+ //# sourceMappingURL=chunk-4FE2YV5U.js.map
@@ -2,7 +2,9 @@ import {
2
2
  openBrowser
3
3
  } from "./chunk-732GIHRQ.js";
4
4
  import {
5
+ ChangesError,
5
6
  ConfigError,
7
+ OrchestratorError,
6
8
  PROVIDER_KINDS,
7
9
  ProjectBrain,
8
10
  ProjectBrainSource,
@@ -15,19 +17,31 @@ import {
15
17
  apiConfigIssues,
16
18
  connectionMethod,
17
19
  createAccountControl,
20
+ createChangesService,
21
+ createCliAgentRunner,
18
22
  createEngine,
23
+ createGitWorkspace,
19
24
  createGoalService,
25
+ createOrchestratorService,
20
26
  createRunner,
27
+ createWorkspaceSchema,
21
28
  endpointRebindIssue,
22
29
  loginCommandFor,
23
30
  loginFromEnv,
24
31
  mergeApiConfig,
32
+ mergeSchema,
25
33
  newId2,
34
+ removeSchema,
26
35
  routeSchema,
27
- taskIdSchema
28
- } from "./chunk-ING5HCIO.js";
36
+ shipSchema,
37
+ startRunSchema,
38
+ suggestSchema,
39
+ taskIdSchema,
40
+ workspaceIdSchema
41
+ } from "./chunk-NBQIMB43.js";
29
42
 
30
43
  // src/runtime.ts
44
+ import { createHash } from "crypto";
31
45
  import { existsSync as existsSync3 } from "fs";
32
46
  import { access } from "fs/promises";
33
47
  import { createRequire } from "module";
@@ -47,8 +61,10 @@ import { z as z2 } from "zod";
47
61
  import { z as z3 } from "zod";
48
62
  import { z as z4 } from "zod";
49
63
  import { z as z6 } from "zod";
50
- import { Readable } from "stream";
51
64
  import { z as z7 } from "zod";
65
+ import { z as z8 } from "zod";
66
+ import { Readable } from "stream";
67
+ import { z as z9 } from "zod";
52
68
  function sendApiError(reply, status, code, message, extra = {}) {
53
69
  return reply.code(status).send({ error: { message, code, ...extra } });
54
70
  }
@@ -796,6 +812,131 @@ function registerAuthRoutes(app, login) {
796
812
  });
797
813
  }
798
814
  }
815
+ var STATUS = {
816
+ not_found: 404,
817
+ not_a_repository: 409,
818
+ invalid: 400,
819
+ limit: 409,
820
+ nothing_to_commit: 409,
821
+ dirty: 409,
822
+ conflict: 409,
823
+ unavailable: 409
824
+ };
825
+ function changesError(error) {
826
+ if (error instanceof ChangesError) return error;
827
+ if (!(error instanceof Error) || error.name !== "ChangesError") return void 0;
828
+ const { code } = error;
829
+ return typeof code === "string" && Object.hasOwn(STATUS, code) ? error : void 0;
830
+ }
831
+ function registerChangesRoutes(app, engine, changes) {
832
+ if (!changes) return;
833
+ const { audit } = engine;
834
+ const guarded = async (reply, work) => {
835
+ try {
836
+ return { ok: true, value: await work() };
837
+ } catch (error) {
838
+ const known = changesError(error);
839
+ if (!known) throw error;
840
+ return {
841
+ ok: false,
842
+ reply: sendApiError(reply, STATUS[known.code], known.code, known.message)
843
+ };
844
+ }
845
+ };
846
+ const body = (schema, raw, reply) => {
847
+ const parsed = schema.safeParse(raw ?? {});
848
+ if (parsed.success) return parsed.data;
849
+ sendApiError(reply, 400, "invalid_body", z7.prettifyError(parsed.error));
850
+ return void 0;
851
+ };
852
+ const workspaceId = (id, reply) => {
853
+ if (workspaceIdSchema.safeParse(id).success) return id;
854
+ sendApiError(reply, 404, "not_found", `unknown workspace "${id.slice(0, 40)}"`);
855
+ return void 0;
856
+ };
857
+ app.get("/api/changes/workspaces", async (_request, reply) => {
858
+ reply.header("Cache-Control", "no-store");
859
+ const result = await guarded(reply, () => changes.list());
860
+ return result.ok ? { workspaces: result.value } : result.reply;
861
+ });
862
+ app.post("/api/changes/workspaces", async (request, reply) => {
863
+ const input = body(createWorkspaceSchema, request.body, reply);
864
+ if (!input) return reply;
865
+ const result = await guarded(reply, () => changes.create(input));
866
+ if (!result.ok) return result.reply;
867
+ audit.record({ actor: "api", action: "changes.create", target: result.value.id });
868
+ return reply.code(201).send(result.value);
869
+ });
870
+ app.get("/api/changes/workspaces/:id", async (request, reply) => {
871
+ reply.header("Cache-Control", "no-store");
872
+ const id = workspaceId(request.params.id, reply);
873
+ if (!id) return reply;
874
+ const result = await guarded(reply, () => changes.get(id));
875
+ return result.ok ? result.value : result.reply;
876
+ });
877
+ app.get(
878
+ "/api/changes/workspaces/:id/diff",
879
+ async (request, reply) => {
880
+ reply.header("Cache-Control", "no-store");
881
+ const id = workspaceId(request.params.id, reply);
882
+ if (!id) return reply;
883
+ const file = request.query.path;
884
+ if (file !== void 0 && (typeof file !== "string" || file.length === 0 || file.length > 4096)) {
885
+ return sendApiError(reply, 400, "invalid_query", "`path` must be a file path");
886
+ }
887
+ const result = await guarded(reply, () => changes.diff(id, file));
888
+ return result.ok ? result.value : result.reply;
889
+ }
890
+ );
891
+ app.post("/api/changes/workspaces/:id/suggest", async (request, reply) => {
892
+ const id = workspaceId(request.params.id, reply);
893
+ if (!id) return reply;
894
+ const input = body(suggestSchema, request.body, reply);
895
+ if (!input) return reply;
896
+ const result = await guarded(reply, () => changes.suggest(id, input));
897
+ return result.ok ? result.value : result.reply;
898
+ });
899
+ app.post("/api/changes/workspaces/:id/ship", async (request, reply) => {
900
+ const id = workspaceId(request.params.id, reply);
901
+ if (!id) return reply;
902
+ const input = body(shipSchema, request.body, reply);
903
+ if (!input) return reply;
904
+ const result = await guarded(reply, () => changes.ship(id, input));
905
+ if (!result.ok) return result.reply;
906
+ audit.record({
907
+ actor: "api",
908
+ action: "changes.ship",
909
+ target: id,
910
+ details: {
911
+ ok: result.value.ok,
912
+ steps: result.value.steps.map((s) => `${s.phase}:${s.ok ? "ok" : "failed"}`)
913
+ }
914
+ });
915
+ return result.value;
916
+ });
917
+ app.post("/api/changes/workspaces/:id/merge", async (request, reply) => {
918
+ const id = workspaceId(request.params.id, reply);
919
+ if (!id) return reply;
920
+ const input = body(mergeSchema, request.body, reply);
921
+ if (!input) return reply;
922
+ const result = await guarded(reply, () => changes.merge(id, input));
923
+ if (!result.ok) return result.reply;
924
+ audit.record({ actor: "api", action: "changes.merge", target: id });
925
+ return result.value;
926
+ });
927
+ app.delete(
928
+ "/api/changes/workspaces/:id",
929
+ async (request, reply) => {
930
+ const id = workspaceId(request.params.id, reply);
931
+ if (!id) return reply;
932
+ const input = removeSchema.parse({ deleteBranch: request.query.deleteBranch === "true" });
933
+ const result = await guarded(reply, () => changes.remove(id, input));
934
+ if (!result.ok) return result.reply;
935
+ audit.record({ actor: "api", action: "changes.remove", target: id, details: input });
936
+ return reply.code(204).send();
937
+ }
938
+ );
939
+ }
799
940
  function frame(event, seq) {
800
941
  return `id: ${seq}
801
942
  event: ${event.type}
@@ -850,6 +991,88 @@ function registerEventRoutes(app, engine, heartbeatMs) {
850
991
  res.on("error", cleanup);
851
992
  });
852
993
  }
994
+ var STATUS2 = {
995
+ not_found: 404,
996
+ no_agents: 409,
997
+ not_a_repository: 409,
998
+ busy: 409,
999
+ not_appliable: 409
1000
+ };
1001
+ function orchestratorError(error) {
1002
+ if (error instanceof OrchestratorError) return error;
1003
+ if (!(error instanceof Error) || error.name !== "OrchestratorError") return void 0;
1004
+ const { code } = error;
1005
+ return typeof code === "string" && Object.hasOwn(STATUS2, code) ? error : void 0;
1006
+ }
1007
+ function registerOrchestratorRoutes(app, engine, orchestrator) {
1008
+ if (!orchestrator) return;
1009
+ const { audit } = engine;
1010
+ const guarded = async (reply, work) => {
1011
+ try {
1012
+ return { ok: true, value: await work() };
1013
+ } catch (error) {
1014
+ const known = orchestratorError(error);
1015
+ if (!known) throw error;
1016
+ return {
1017
+ ok: false,
1018
+ reply: sendApiError(reply, STATUS2[known.code], known.code, known.message)
1019
+ };
1020
+ }
1021
+ };
1022
+ const unknownRun = (reply, id) => sendApiError(reply, 404, "not_found", `unknown run "${id}"`);
1023
+ app.get("/api/orchestrator/agents", async (_request, reply) => {
1024
+ reply.header("Cache-Control", "no-store");
1025
+ return { agents: await orchestrator.agents() };
1026
+ });
1027
+ app.get("/api/orchestrator/runs", async (_request, reply) => {
1028
+ reply.header("Cache-Control", "no-store");
1029
+ return { runs: orchestrator.list() };
1030
+ });
1031
+ app.post("/api/orchestrator/runs", async (request, reply) => {
1032
+ const parsed = startRunSchema.safeParse(request.body);
1033
+ if (!parsed.success) {
1034
+ return sendApiError(reply, 400, "invalid_body", z8.prettifyError(parsed.error));
1035
+ }
1036
+ const result = await guarded(reply, () => orchestrator.start(parsed.data));
1037
+ if (!result.ok) return result.reply;
1038
+ audit.record({
1039
+ actor: "api",
1040
+ action: "orchestrator.start",
1041
+ target: result.value.id,
1042
+ details: { agents: result.value.agents }
1043
+ });
1044
+ return reply.code(202).send(result.value);
1045
+ });
1046
+ app.get("/api/orchestrator/runs/:id", async (request, reply) => {
1047
+ reply.header("Cache-Control", "no-store");
1048
+ const run = orchestrator.get(request.params.id);
1049
+ if (!run) return unknownRun(reply, request.params.id);
1050
+ return run;
1051
+ });
1052
+ app.post(
1053
+ "/api/orchestrator/runs/:id/cancel",
1054
+ async (request, reply) => {
1055
+ const { id } = request.params;
1056
+ if (orchestrator.cancel(id)) {
1057
+ audit.record({ actor: "api", action: "orchestrator.cancel", target: id });
1058
+ return reply.code(204).send();
1059
+ }
1060
+ const run = orchestrator.get(id);
1061
+ if (!run) return unknownRun(reply, id);
1062
+ return sendApiError(reply, 409, "not_active", `run "${id}" is already ${run.status}`);
1063
+ }
1064
+ );
1065
+ app.post(
1066
+ "/api/orchestrator/runs/:id/apply",
1067
+ async (request, reply) => {
1068
+ const { id } = request.params;
1069
+ const result = await guarded(reply, () => orchestrator.apply(id));
1070
+ if (!result.ok) return result.reply;
1071
+ audit.record({ actor: "api", action: "orchestrator.apply", target: id });
1072
+ return result.value;
1073
+ }
1074
+ );
1075
+ }
853
1076
  function setRoutingHeaders(reply, meta) {
854
1077
  reply.header("x-davecode-request-id", meta.requestId).header("x-davecode-account", meta.accountId).header("x-davecode-provider", meta.provider).header("x-davecode-failovers", String(meta.failovers));
855
1078
  }
@@ -879,7 +1102,7 @@ function registerV1Routes(app, engine) {
879
1102
  const parsed = chatRequestSchema.safeParse(request.body);
880
1103
  if (!parsed.success) {
881
1104
  return sendOpenAIError(reply, 400, {
882
- message: z7.prettifyError(parsed.error),
1105
+ message: z9.prettifyError(parsed.error),
883
1106
  type: "invalid_request_error",
884
1107
  code: "invalid_body"
885
1108
  });
@@ -1127,6 +1350,8 @@ async function buildGateway(engine, options = {}) {
1127
1350
  registerV1Routes(app, engine);
1128
1351
  registerAuthRoutes(app, login);
1129
1352
  registerAccountRoutes(app, options.account);
1353
+ registerOrchestratorRoutes(app, engine, options.orchestrator);
1354
+ registerChangesRoutes(app, engine, options.changes);
1130
1355
  registerApiRoutes(app, engine, options);
1131
1356
  registerEventRoutes(app, engine, options.heartbeatMs ?? 15e3);
1132
1357
  return app;
@@ -1629,6 +1854,23 @@ function wireProject(engine, root, options = {}) {
1629
1854
  lock
1630
1855
  };
1631
1856
  }
1857
+ function orchestratorWorktreesDir(home, projectDir) {
1858
+ const key = createHash("sha256").update(resolve2(projectDir)).digest("hex").slice(0, 16);
1859
+ return join(home, "worktrees", key);
1860
+ }
1861
+ function createProjectOrchestrator(options) {
1862
+ const projectDir = resolve2(options.projectDir);
1863
+ return createOrchestratorService({
1864
+ projectDir,
1865
+ home: options.home,
1866
+ events: options.events,
1867
+ runner: createCliAgentRunner({ env: options.env }),
1868
+ workspace: createGitWorkspace({
1869
+ projectDir,
1870
+ worktreesDir: orchestratorWorktreesDir(options.home, projectDir)
1871
+ })
1872
+ });
1873
+ }
1632
1874
  function isDashboard(dir) {
1633
1875
  return dir !== void 0 && existsSync3(join(dir, "index.html"));
1634
1876
  }
@@ -1666,6 +1908,8 @@ async function startRuntime(options) {
1666
1908
  ...options.config ? { config: options.config } : {}
1667
1909
  });
1668
1910
  let account;
1911
+ let orchestrator;
1912
+ let changes;
1669
1913
  try {
1670
1914
  const project = projectRoot ? wireProject(engine, projectRoot, { env: options.env }) : void 0;
1671
1915
  const wantDashboard = options.dashboard !== false && engine.config.server.dashboard;
@@ -1681,9 +1925,37 @@ async function startRuntime(options) {
1681
1925
  env: options.env,
1682
1926
  open: (url) => openBrowser(url)
1683
1927
  }) : void 0;
1928
+ if (options.orchestrator !== void 0) {
1929
+ orchestrator = options.orchestrator || void 0;
1930
+ } else if (projectRoot && LOOPBACK_HOSTS.has(bindHost)) {
1931
+ try {
1932
+ orchestrator = createProjectOrchestrator({
1933
+ projectDir: projectRoot,
1934
+ home: options.home,
1935
+ env: options.env,
1936
+ events: engine.events
1937
+ });
1938
+ } catch {
1939
+ const message = "The pane orchestrator could not start; continuing without it.";
1940
+ engine.events.emit({ type: "log", level: "warn", scope: "orchestrator", message });
1941
+ options.onWarning?.(message);
1942
+ }
1943
+ }
1944
+ if (options.changes !== void 0) {
1945
+ changes = options.changes || void 0;
1946
+ } else if (projectRoot && LOOPBACK_HOSTS.has(bindHost)) {
1947
+ changes = createChangesService({
1948
+ projectDir: projectRoot,
1949
+ home: options.home,
1950
+ env: options.env,
1951
+ writer: createCliAgentRunner({ env: options.env })
1952
+ });
1953
+ }
1684
1954
  const app = await startGateway(engine, {
1685
1955
  logger: options.logger ?? false,
1686
1956
  ...account ? { account } : {},
1957
+ ...orchestrator ? { orchestrator } : {},
1958
+ ...changes ? { changes } : {},
1687
1959
  ...options.loginLauncher ?? loginLauncher ? { loginLauncher: options.loginLauncher ?? loginLauncher } : {},
1688
1960
  ...dashboardDir ? { dashboardDir } : {},
1689
1961
  ...project ? { brain: project.source, runner: project.runner, goals: project.goals } : {},
@@ -1702,6 +1974,8 @@ async function startRuntime(options) {
1702
1974
  project: project?.source.project(),
1703
1975
  runner,
1704
1976
  goals,
1977
+ orchestrator,
1978
+ changes,
1705
1979
  url: `http://${connectHost(host)}:${port}`,
1706
1980
  host,
1707
1981
  port,
@@ -1713,6 +1987,7 @@ async function startRuntime(options) {
1713
1987
  const active = goals?.activeGoalId;
1714
1988
  if (active) await goals?.cancel(active);
1715
1989
  await runner?.stop();
1990
+ await orchestrator?.close().catch(() => void 0);
1716
1991
  await account?.close();
1717
1992
  await app.close();
1718
1993
  } finally {
@@ -1721,6 +1996,7 @@ async function startRuntime(options) {
1721
1996
  }
1722
1997
  };
1723
1998
  } catch (err) {
1999
+ await orchestrator?.close().catch(() => void 0);
1724
2000
  await account?.close();
1725
2001
  engine.close();
1726
2002
  throw err;
@@ -1740,8 +2016,10 @@ export {
1740
2016
  launchLoginTerminal,
1741
2017
  detectProjectRoot,
1742
2018
  wireProject,
2019
+ orchestratorWorktreesDir,
2020
+ createProjectOrchestrator,
1743
2021
  resolveDashboardDir,
1744
2022
  resolveProjectRoot,
1745
2023
  startRuntime
1746
2024
  };
1747
- //# sourceMappingURL=chunk-YSD6W27K.js.map
2025
+ //# sourceMappingURL=chunk-FKGZERYB.js.map