@monster-orange/den 0.3.0 → 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.
Files changed (79) hide show
  1. package/CHANGELOG.md +593 -0
  2. package/docs/distributions.md +429 -18
  3. package/package.json +6 -1
  4. package/src/shared/actor-token.ts +275 -0
  5. package/src/shared/agent-actor.ts +12 -2
  6. package/src/shared/agents/default-pack/be-dev.md +20 -0
  7. package/src/shared/agents/default-pack/devops.md +14 -0
  8. package/src/shared/agents/default-pack/fe-dev.md +20 -0
  9. package/src/shared/agents/default-pack/orchestrator.md +16 -0
  10. package/src/shared/agents/default-pack/planner.md +17 -0
  11. package/src/shared/agents/default-pack/reviewer.md +14 -0
  12. package/src/shared/agents/default-pack/ux-designer.md +15 -0
  13. package/src/shared/agents/den-claude.ts +271 -0
  14. package/src/shared/agents/generic.ts +52 -0
  15. package/src/shared/agents/personas.ts +218 -0
  16. package/src/shared/agents/records.ts +118 -0
  17. package/src/shared/agents/runtime.ts +199 -0
  18. package/src/shared/agents/runtimes.ts +54 -0
  19. package/src/shared/den-config.ts +116 -0
  20. package/src/shared/engine.ts +23 -0
  21. package/src/shared/environment-manager/scope.ts +22 -0
  22. package/src/shared/environment-manager/service-runner.ts +94 -2
  23. package/src/shared/environment-manager/workspaces.ts +19 -0
  24. package/src/shared/profile.ts +15 -4
  25. package/src/shared/secret-env.ts +70 -0
  26. package/src/shared/sessions/client.ts +284 -0
  27. package/src/shared/sessions/den-pty.ts +97 -0
  28. package/src/shared/sessions/env.ts +89 -0
  29. package/src/shared/sessions/host.ts +690 -0
  30. package/src/shared/sessions/names.ts +85 -0
  31. package/src/shared/sessions/paths.ts +27 -0
  32. package/src/shared/sessions/protocol.ts +72 -0
  33. package/src/shared/sessions/pty.ts +141 -0
  34. package/src/shared/sessions/ring-buffer.ts +160 -0
  35. package/src/shared/sessions/types.ts +81 -0
  36. package/src/shared/web-secret.ts +181 -0
  37. package/src/shared/web-session.ts +491 -0
  38. package/src/ui/cli/agent-ops.ts +843 -0
  39. package/src/ui/cli/agents-command.ts +294 -0
  40. package/src/ui/cli/doctor-command.ts +138 -9
  41. package/src/ui/cli/env-probe.ts +266 -0
  42. package/src/ui/cli/flag-parser.ts +32 -3
  43. package/src/ui/cli/index.ts +128 -12
  44. package/src/ui/cli/sessions-command.ts +750 -0
  45. package/src/ui/cli/target-workspace.ts +105 -0
  46. package/src/ui/cli/web-command.ts +536 -14
  47. package/src/ui/mcp/api.ts +7 -0
  48. package/src/ui/mcp/scope.ts +123 -19
  49. package/src/ui/mcp/server.ts +100 -7
  50. package/src/ui/mcp/tools.ts +44 -5
  51. package/src/ui/server/agent-routes.ts +323 -0
  52. package/src/ui/server/audit.ts +111 -22
  53. package/src/ui/server/http-errors.ts +21 -3
  54. package/src/ui/server/index.ts +820 -65
  55. package/src/ui/server/public/agents-page.js +648 -0
  56. package/src/ui/server/public/agents-section.js +299 -0
  57. package/src/ui/server/public/agents.html +439 -0
  58. package/src/ui/server/public/appearance.js +3 -0
  59. package/src/ui/server/public/error-page.js +103 -0
  60. package/src/ui/server/public/header.js +45 -11
  61. package/src/ui/server/public/i18n/es.js +90 -1
  62. package/src/ui/server/public/i18n/ja.js +86 -1
  63. package/src/ui/server/public/local-dev.html +53 -0
  64. package/src/ui/server/public/logs.html +3 -0
  65. package/src/ui/server/public/panel.js +1 -1
  66. package/src/ui/server/public/release.html +8 -0
  67. package/src/ui/server/public/settings-page.js +5 -0
  68. package/src/ui/server/public/settings-registry.js +33 -0
  69. package/src/ui/server/public/shell.js +248 -5
  70. package/src/ui/server/public/topbar.js +51 -2
  71. package/src/ui/server/readonly-routes.ts +25 -2
  72. package/src/ui/server/request-guard.ts +670 -0
  73. package/src/ui/server/route-classes.ts +317 -0
  74. package/src/ui/server/session-routes.ts +445 -0
  75. package/src/ui/server/shutdown-guard.ts +91 -0
  76. package/src/ui/server/sudo-store.ts +29 -3
  77. package/src/ui/server/ui-assets.ts +10 -1
  78. package/src/ui/server/websocket.ts +326 -0
  79. package/src/ui/server/workspace-routes.ts +16 -22
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Which workspace a lifecycle command (`setup`, `up`, `down`, `restart`)
3
+ * names its services in, when no `-w` says.
4
+ *
5
+ * The focused workspace is the default target (WS-6.1). A name it doesn't
6
+ * hold resolves across the other active workspaces, as the web API does
7
+ * with `&workspace=` (resolveService(address, workspace)):
8
+ *
9
+ * - in the focus: the focus (nothing changes);
10
+ * - in exactly one other active workspace: that one;
11
+ * - in several: an error that lists them (`-w <workspace>` picks one);
12
+ * - nowhere: an error (exit 1, never a silent exit 0).
13
+ *
14
+ * Every name must land in one workspace; names in different workspaces are
15
+ * an error (run them one workspace at a time, with `-w`).
16
+ */
17
+ import {
18
+ resolveService,
19
+ serviceAliasCandidates,
20
+ } from "../../shared/environment-manager/service-runner.js";
21
+ import {
22
+ getActiveWorkspaces,
23
+ getFocusedWorkspaceName,
24
+ } from "../../shared/environment-manager/workspaces.js";
25
+
26
+ export type TargetWorkspace =
27
+ | { ok: true; workspace: string | null }
28
+ | { ok: false; error: string };
29
+
30
+ /** Whether `name` names a service (a repo, an address or an alias) in `ws`. */
31
+ export function nameResolvesIn(name: string, ws: string): boolean {
32
+ return (
33
+ resolveService(name, ws) !== null ||
34
+ serviceAliasCandidates(name, ws).length > 0
35
+ );
36
+ }
37
+
38
+ /**
39
+ * The workspace `names` resolve in, given the focus and the active set:
40
+ * `workspace: null` when it is the focus (or there are no names). Pure
41
+ * apart from `resolves`.
42
+ */
43
+ export function targetWorkspaceFor(
44
+ names: readonly string[],
45
+ o: {
46
+ cli: string;
47
+ command: string;
48
+ focus: string | null;
49
+ active: readonly string[];
50
+ resolves: (name: string, ws: string) => boolean;
51
+ },
52
+ ): TargetWorkspace {
53
+ if (names.length === 0) return { ok: true, workspace: null };
54
+ const others = o.active.filter((w) => w !== o.focus);
55
+ const where = new Map<string, string>();
56
+ for (const name of names) {
57
+ if (o.focus && o.resolves(name, o.focus)) {
58
+ where.set(name, o.focus);
59
+ continue;
60
+ }
61
+ const hits = others.filter((w) => o.resolves(name, w));
62
+ if (hits.length === 0) {
63
+ const looked = [o.focus, ...others].filter(Boolean).join(", ");
64
+ return {
65
+ ok: false,
66
+ error: `"${name}" is not a service in any active workspace (${looked || "none active"}).`,
67
+ };
68
+ }
69
+ if (hits.length > 1)
70
+ return {
71
+ ok: false,
72
+ error:
73
+ `"${name}" is in more than one active workspace: ` +
74
+ `${hits.map((w) => `${w} (${o.cli} ${o.command} ${name} -w ${w})`).join(", ")}. ` +
75
+ "Name one with -w.",
76
+ };
77
+ where.set(name, hits[0]);
78
+ }
79
+ const workspaces = [...new Set(where.values())];
80
+ if (workspaces.length > 1)
81
+ return {
82
+ ok: false,
83
+ error:
84
+ "These names are in different workspaces: " +
85
+ `${[...where].map(([n, w]) => `${n} (${w})`).join(", ")}. ` +
86
+ `Run ${o.cli} ${o.command} once per workspace, with -w.`,
87
+ };
88
+ const ws = workspaces[0];
89
+ return { ok: true, workspace: ws === o.focus ? null : ws };
90
+ }
91
+
92
+ /** targetWorkspaceFor over this distribution's workspaces. */
93
+ export function resolveTargetWorkspace(
94
+ names: readonly string[],
95
+ cli: string,
96
+ command: string,
97
+ ): TargetWorkspace {
98
+ return targetWorkspaceFor(names, {
99
+ cli,
100
+ command,
101
+ focus: getFocusedWorkspaceName(),
102
+ active: getActiveWorkspaces(),
103
+ resolves: nameResolvesIn,
104
+ });
105
+ }