@famonfa/mono 0.0.0-stage → 0.3.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 (64) hide show
  1. package/bin/mono.mjs +211 -0
  2. package/node_modules/@anthropic-ai/claude-agent-sdk/LICENSE.md +1 -0
  3. package/node_modules/@anthropic-ai/claude-agent-sdk/README.md +69 -0
  4. package/node_modules/@anthropic-ai/claude-agent-sdk/agentSdkTypes.d.ts +1 -0
  5. package/node_modules/@anthropic-ai/claude-agent-sdk/bridge.d.ts +396 -0
  6. package/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +142 -0
  7. package/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.d.ts +208 -0
  8. package/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +145 -0
  9. package/node_modules/@anthropic-ai/claude-agent-sdk/core-36zyfan5.mjs +52 -0
  10. package/node_modules/@anthropic-ai/claude-agent-sdk/core-5682eevd.mjs +27 -0
  11. package/node_modules/@anthropic-ai/claude-agent-sdk/core-nne0e2ds.mjs +40 -0
  12. package/node_modules/@anthropic-ai/claude-agent-sdk/core-xpxe8nzb.mjs +26 -0
  13. package/node_modules/@anthropic-ai/claude-agent-sdk/core.d.ts +22 -0
  14. package/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +34 -0
  15. package/node_modules/@anthropic-ai/claude-agent-sdk/extractFromBunfs.d.ts +1 -0
  16. package/node_modules/@anthropic-ai/claude-agent-sdk/extractFromBunfs.js +156 -0
  17. package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +82 -0
  18. package/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +90 -0
  19. package/node_modules/@anthropic-ai/claude-agent-sdk/package.json +94 -0
  20. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk-tools.d.ts +4222 -0
  21. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.d.ts +10277 -0
  22. package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +169 -0
  23. package/node_modules/ws/LICENSE +20 -0
  24. package/node_modules/ws/README.md +548 -0
  25. package/node_modules/ws/browser.js +8 -0
  26. package/node_modules/ws/index.js +22 -0
  27. package/node_modules/ws/lib/buffer-util.js +131 -0
  28. package/node_modules/ws/lib/constants.js +19 -0
  29. package/node_modules/ws/lib/event-target.js +292 -0
  30. package/node_modules/ws/lib/extension.js +203 -0
  31. package/node_modules/ws/lib/limiter.js +55 -0
  32. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  33. package/node_modules/ws/lib/receiver.js +743 -0
  34. package/node_modules/ws/lib/sender.js +607 -0
  35. package/node_modules/ws/lib/stream.js +161 -0
  36. package/node_modules/ws/lib/subprotocol.js +62 -0
  37. package/node_modules/ws/lib/validation.js +152 -0
  38. package/node_modules/ws/lib/websocket-server.js +562 -0
  39. package/node_modules/ws/lib/websocket.js +1421 -0
  40. package/node_modules/ws/package.json +74 -0
  41. package/node_modules/ws/wrapper.mjs +21 -0
  42. package/package.json +126 -3
  43. package/skills/workspace/SKILL.md +108 -0
  44. package/src/api.mjs +298 -0
  45. package/src/chats.mjs +446 -0
  46. package/src/commands.mjs +100 -0
  47. package/src/groups.mjs +84 -0
  48. package/src/launcher.mjs +276 -0
  49. package/src/main.mjs +42 -0
  50. package/src/paths.mjs +44 -0
  51. package/src/projects.mjs +199 -0
  52. package/src/refresh.mjs +124 -0
  53. package/src/remote.mjs +137 -0
  54. package/src/sessions.mjs +422 -0
  55. package/src/store.mjs +253 -0
  56. package/web/apple-touch-icon.png +0 -0
  57. package/web/assets/index-DGdmgZ2P.css +1 -0
  58. package/web/assets/index-TOP7citk.js +55 -0
  59. package/web/icon-192.png +0 -0
  60. package/web/icon-512.png +0 -0
  61. package/web/icon.svg +1 -0
  62. package/web/index.html +19 -0
  63. package/web/manifest.webmanifest +13 -0
  64. package/README.md +0 -3
package/bin/mono.mjs ADDED
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { execFileSync } from "node:child_process";
5
+ import * as store from "../src/store.mjs";
6
+ import * as sessions from "../src/sessions.mjs";
7
+ import * as groups from "../src/groups.mjs";
8
+ import * as launcher from "../src/launcher.mjs";
9
+
10
+ launcher.runFromRuntime();
11
+
12
+ const USAGE = `mono (alias: ws) — CLI de Mono (http://localhost:4600)
13
+
14
+ mono [--web] Arranca el server si hace falta y abre la app de escritorio (o el navegador)
15
+ mono serve Corre el server en primer plano
16
+ mono status Estado del server, del servicio y de la conexión remota
17
+ mono connect <relay-url> Conecta esta máquina al relay (Google) para usarla desde el celu/web
18
+ mono disconnect Corta la conexión remota
19
+ mono service install|uninstall Arranca Mono solo al iniciar sesión (launchd) y pone mono/ws en el PATH
20
+
21
+ ws list Lista las tareas
22
+ ws show <task> Muestra task.json + boards/docs/assets
23
+ ws get <task> <board> Imprime un board (nodos y conexiones) para editarlo
24
+ ws task <task> <file.json|-> Crea/actualiza metadatos (merge superficial)
25
+ ws board <task> <board> <file.json|-> [--relayout | --patch]
26
+ Crea/actualiza un board conservando lo que movió el usuario.
27
+ --patch solo agrega/actualiza nodos, nunca borra.
28
+ ws undo <task> <board> Vuelve el board a la versión anterior a la última escritura
29
+ ws doc <task> <name.md> <file.md|-> Escribe un documento
30
+ ws asset <task> <image...> Copia imágenes a assets/
31
+ ws sessions [task] [--since ISO] Actividad reciente de los agentes (de una tarea o todos)
32
+ ws groups Lista los grupos de sesiones (canvas de chats)
33
+ ws group <grupo> <session-id...> Manda sesiones al canvas de un grupo (lo crea si no existe)
34
+ ws open [task] Abre la app en el navegador
35
+ ws path [task] Imprime la carpeta de datos`;
36
+
37
+ const [, , command, ...args] = process.argv;
38
+
39
+ function readInput(source) {
40
+ return source === "-" ? fs.readFileSync(0, "utf8") : fs.readFileSync(source, "utf8");
41
+ }
42
+
43
+ function fail(message) {
44
+ console.error(message);
45
+ process.exit(1);
46
+ }
47
+
48
+ function requireArgs(count) {
49
+ if (args.filter((a) => !a.startsWith("--")).length < count) fail(USAGE);
50
+ }
51
+
52
+ // `ws` with no args keeps printing usage (the /workspace skill relies on it); `mono` opens the app.
53
+ const invokedAs = path.basename(process.argv[1] ?? "");
54
+
55
+ // `mono --web` is still the launch command, just opened in the browser.
56
+ switch (command === "--web" ? "launch" : (command ?? (invokedAs === "ws" ? "help" : "launch"))) {
57
+ case "launch":
58
+ await launcher.launch({ web: process.argv.includes("--web") });
59
+ break;
60
+ case "serve":
61
+ await import("../src/main.mjs");
62
+ break;
63
+ case "status":
64
+ await launcher.status();
65
+ break;
66
+ case "connect":
67
+ await launcher.connect(args[0], args[1]);
68
+ break;
69
+ case "disconnect":
70
+ launcher.disconnect();
71
+ break;
72
+ case "service":
73
+ if (args[0] === "install") launcher.installService({ ifMissing: args.includes("--if-missing") });
74
+ else if (args[0] === "uninstall") launcher.uninstallService();
75
+ else fail(USAGE);
76
+ break;
77
+ case "list": {
78
+ for (const t of store.listTasks()) {
79
+ console.log(`${t.id.padEnd(14)} ${String(t.status).padEnd(10)} ${t.title} [${t.boards.map((b) => b.id).join(", ")}]`);
80
+ }
81
+ break;
82
+ }
83
+ case "show": {
84
+ requireArgs(1);
85
+ const task = store.getTask(args[0]);
86
+ if (!task) fail(`No existe la tarea ${args[0]}`);
87
+ console.log(JSON.stringify(task, null, 2));
88
+ break;
89
+ }
90
+ case "get": {
91
+ requireArgs(2);
92
+ const board = store.getBoard(args[0], args[1]);
93
+ if (!board) fail(`No existe el board ${args[0]}/${args[1]}`);
94
+ const compact = {
95
+ ...board,
96
+ // Lanes, parents and positions are the app's layout; agents place nodes with the \`lane\` name.
97
+ nodes: board.nodes.filter((n) => n.type !== "lane").map(({ id, type, data }) => ({ id, type, ...data })),
98
+ };
99
+ console.log(JSON.stringify(compact, null, 2));
100
+ break;
101
+ }
102
+ case "task": {
103
+ requireArgs(2);
104
+ const [id, source] = args;
105
+ store.assertSafe(id);
106
+ const task = store.saveTask(id, JSON.parse(readInput(source)));
107
+ console.log(`✓ tarea ${task.id} actualizada`);
108
+ break;
109
+ }
110
+ case "board": {
111
+ requireArgs(3);
112
+ const [id, boardId, source] = args.filter((a) => !a.startsWith("--"));
113
+ const incoming = JSON.parse(readInput(source));
114
+ const existing = store.getBoard(id, boardId);
115
+ const merged = store.mergeBoard(existing, incoming, { relayout: args.includes("--relayout"), patch: args.includes("--patch") });
116
+ store.snapshotBoard(id, boardId);
117
+ store.saveBoard(id, boardId, merged);
118
+ const kept = existing ? merged.nodes.filter((n) => n.position).length : 0;
119
+ console.log(`✓ board ${id}/${boardId}: ${merged.nodes.length} nodos, ${merged.edges.length} conexiones${kept ? ` (${kept} conservaron su posición)` : ""}`);
120
+ break;
121
+ }
122
+ case "undo": {
123
+ requireArgs(2);
124
+ const restored = store.restoreBoard(args[0], args[1]);
125
+ console.log(`✓ board ${args[0]}/${args[1]} restaurado a ${restored.replace(".json", "")}`);
126
+ break;
127
+ }
128
+ case "doc": {
129
+ requireArgs(3);
130
+ const [id, name, source] = args;
131
+ store.saveDoc(id, name, readInput(source));
132
+ console.log(`✓ doc ${id}/docs/${name}`);
133
+ break;
134
+ }
135
+ case "asset": {
136
+ requireArgs(2);
137
+ const [id, ...files] = args;
138
+ store.assertSafe(id);
139
+ const dir = path.join(store.TASKS_DIR, id, "assets");
140
+ fs.mkdirSync(dir, { recursive: true });
141
+ for (const file of files) {
142
+ const name = path.basename(file).replace(/[^A-Za-z0-9._-]/g, "-");
143
+ fs.copyFileSync(file, path.join(dir, name));
144
+ console.log(`✓ assets/${name}`);
145
+ }
146
+ break;
147
+ }
148
+ case "sessions": {
149
+ const [id] = args.filter((a) => !a.startsWith("--"));
150
+ const sinceArg = args.indexOf("--since");
151
+ const since = sinceArg >= 0 ? args[sinceArg + 1] : undefined;
152
+ const all = sessions.listSessions({ days: 7 });
153
+ const task = id ? store.getTask(id) : null;
154
+ if (id && !task) fail(`No existe la tarea ${id}`);
155
+ const list = task ? sessions.sessionsForTask(task, all) : all.filter((x) => x.status !== "inactive");
156
+ if (!list.length) console.log("Sin sesiones vinculadas.");
157
+ for (const session of list) printSessionDigest(session, since);
158
+ break;
159
+ }
160
+ case "groups": {
161
+ for (const g of groups.listGroups()) console.log(`${g.id}\t${g.name}\t${g.panes.length} sesiones\thttp://localhost:4600/#/g/${g.id}`);
162
+ break;
163
+ }
164
+ case "group": {
165
+ requireArgs(2);
166
+ const [ref, ...ids] = args;
167
+ const titles = new Map(sessions.listSessions({ days: 30 }).map((s) => [s.id, s.title]));
168
+ let group = groups.findGroup(ref) ?? groups.createGroup({ name: ref });
169
+ for (const id of ids) group = groups.addSession(group.id, id, titles.get(id));
170
+ console.log(`${group.name}: ${group.panes.length} sesiones · http://localhost:4600/#/g/${group.id}`);
171
+ break;
172
+ }
173
+ case "open": {
174
+ await launcher.ensureServer();
175
+ const url = `${launcher.APP_URL}/${args[0] ? `#/t/${args[0]}` : ""}`;
176
+ execFileSync("open", [url]);
177
+ console.log(url);
178
+ break;
179
+ }
180
+ case "path": {
181
+ console.log(args[0] ? path.join(store.TASKS_DIR, args[0]) : store.TASKS_DIR);
182
+ break;
183
+ }
184
+ default:
185
+ console.log(USAGE);
186
+ }
187
+
188
+ function printSessionDigest(session, since) {
189
+ const short = (text, max) => (text && text.length > max ? `${text.slice(0, max)}…` : text ?? "");
190
+ console.log(`\n## ${session.title} [${session.status}] ${session.id}`);
191
+ console.log(`${session.project} · ${session.gitBranch ?? "-"} · última actividad ${session.lastTs}${session.prLinks.length ? ` · PRs ${session.prLinks.map((u) => "#" + u.split("/").pop()).join(" ")}` : ""}`);
192
+ const detail = sessions.readSessionEvents(session.id);
193
+ const events = detail.events.filter((e) => !since || e.ts > since);
194
+ const results = new Map(events.filter((e) => e.kind === "result").map((e) => [e.toolUseId, e]));
195
+ console.log("\n### Línea de tiempo (más reciente al final)");
196
+ for (const e of events.slice(-70)) {
197
+ if (e.kind === "prompt") console.log(`\n👤 ${short(e.text, 500)}`);
198
+ if (e.kind === "text") console.log(`\n🤖 ${short(e.text, 700)}`);
199
+ if (e.kind === "notice") console.log(`ℹ️ ${short(e.text, 200)}`);
200
+ if (e.kind === "tool") {
201
+ const r = results.get(e.id);
202
+ console.log(`→ ${e.name}: ${short(e.title, 140)}${r?.isError ? ` ✗ ${short(r.text, 300)}` : ""}`);
203
+ }
204
+ }
205
+ for (const agent of session.subagents.filter((a) => !since || (a.lastTs ?? "") > since)) {
206
+ const agentDetail = sessions.readSessionEvents(session.id, { agent: agent.id });
207
+ const finalTexts = agentDetail?.events.filter((e) => e.kind === "text").slice(-2).map((e) => e.text) ?? [];
208
+ console.log(`\n### Subagente: ${agent.description} [${agent.status}]`);
209
+ console.log(short(finalTexts.join("\n\n"), 2500) || "(sin texto todavía)");
210
+ }
211
+ }
@@ -0,0 +1 @@
1
+ © Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
@@ -0,0 +1,69 @@
1
+ # Claude Agent SDK
2
+
3
+ ![](https://img.shields.io/badge/Node.js-18%2B-brightgreen?style=flat-square) [![npm]](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk)
4
+
5
+ [npm]: https://img.shields.io/npm/v/@anthropic-ai/claude-agent-sdk.svg?style=flat-square
6
+
7
+ The Claude Agent SDK enables you to programmatically build AI agents with Claude Code's capabilities. Create autonomous agents that can understand codebases, edit files, run commands, and execute complex workflows.
8
+
9
+ **Learn more in the [official documentation](https://platform.claude.com/docs/en/agent-sdk/overview)**.
10
+
11
+ ## Get started
12
+
13
+ Install the Claude Agent SDK:
14
+
15
+ ```sh
16
+ npm install @anthropic-ai/claude-agent-sdk
17
+ ```
18
+
19
+ ## The `/core` entry (for apps that bundle the SDK)
20
+
21
+ `@anthropic-ai/claude-agent-sdk/core` exports the same `query()`, `startup()`, `tool()`, `createSdkMcpServer()`, `renameSession()`/`tagSession()`/`deleteSession()`, `resolveSettings()`/`filterEscalatingDefaultMode()` and runtime constants as the root entry, and nothing else — no session listing/reading/import helpers — so its eagerly loaded code is about a quarter of the root's; the settings resolver behind `resolveSettings()` and the code behind the three session mutations load on first call. Unlike the root entry it does **not** inline the SDK's peer dependencies: `zod` (^4, as declared in this package's `peerDependencies`) and `@modelcontextprotocol/sdk` (^1.29) are imported from your install — specifically the `zod/v4` subpath, plus `zod/v3` when the settings resolver loads — which is what you want when your bundler already carries them. (zod 3.25+, which carries the v4 engine under `zod/v4`, also works in practice, but ^4 is the supported range.) Import from **either** the root **or** `/core` in a given process, not both — they are separate bundles, and mixing them loads two copies of the SDK's classes and state. Its types require TypeScript 5.0+.
22
+
23
+ ## Compiled binaries (`bun build --compile`)
24
+
25
+ When bundling your application into a single executable with `bun build --compile`, the SDK cannot resolve the native CLI binary at runtime — `require.resolve` doesn't work from inside the compiled `$bunfs` (or `B:\~BUN\...` on Windows) virtual filesystem.
26
+
27
+ Embed the platform-specific binary as a file asset, extract it to a real path, and pass it explicitly:
28
+
29
+ ```js
30
+ import binPath from '@anthropic-ai/claude-agent-sdk-darwin-arm64/claude' with { type: 'file' }
31
+ import { extractFromBunfs } from '@anthropic-ai/claude-agent-sdk/extract'
32
+ import { query } from '@anthropic-ai/claude-agent-sdk'
33
+
34
+ const cliPath = extractFromBunfs(binPath)
35
+
36
+ for await (const message of query({
37
+ prompt: '…',
38
+ options: { pathToClaudeCodeExecutable: cliPath },
39
+ })) { /* … */ }
40
+ ```
41
+
42
+ Each compiled executable embeds one platform's binary, matching your `--target`. Cross-compiling requires installing the non-matching platform package (e.g. `npm install @anthropic-ai/claude-agent-sdk-linux-x64 --force`). On Windows the binary subpath is `/claude.exe` (e.g. `@anthropic-ai/claude-agent-sdk-win32-x64/claude.exe`).
43
+
44
+ ## Migrating from the Claude Code SDK
45
+
46
+ The Claude Code SDK is now the Claude Agent SDK. Please check out the [migration guide](https://platform.claude.com/docs/en/agent-sdk/migration-guide) for details on breaking changes.
47
+
48
+ ## Reporting Bugs
49
+
50
+ We welcome your feedback. File a [GitHub issue](https://github.com/anthropics/claude-agent-sdk-typescript/issues) to report bugs or request features.
51
+
52
+ ## Connect on Discord
53
+
54
+ Join the [Claude Developers Discord](https://anthropic.com/discord) to connect with other developers building with the Claude Agent SDK. Get help, share feedback, and discuss your projects with the community.
55
+
56
+ ## Data collection, usage, and retention
57
+
58
+ When you use the Claude Agent SDK, we collect feedback, which includes usage data (such as code acceptance or rejections), associated conversation data, and user feedback submitted via the /bug command.
59
+
60
+ ### How we use your data
61
+
62
+ See our [data usage policies](https://code.claude.com/docs/en/data-usage).
63
+
64
+ ### Privacy safeguards
65
+
66
+ We have implemented several safeguards to protect your data, including limited retention periods for sensitive information and restricted access to user session data.
67
+
68
+ For full details, please review our [Commercial Terms of Service](https://www.anthropic.com/legal/commercial-terms) and [Privacy Policy](https://www.anthropic.com/legal/privacy).
69
+
@@ -0,0 +1 @@
1
+ export * from './sdk.js'