crossroom 0.2.0 → 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.
@@ -0,0 +1,20 @@
1
+ import { createRequire as __parleyRequire } from 'node:module'; const require = __parleyRequire(import.meta.url);
2
+ import {
3
+ child_process,
4
+ crypto,
5
+ fs,
6
+ os,
7
+ path,
8
+ stream,
9
+ util
10
+ } from "./chunk-NXBBMDR5.mjs";
11
+ import "./chunk-P7MSGDOB.mjs";
12
+ export {
13
+ child_process,
14
+ crypto,
15
+ fs,
16
+ os,
17
+ path,
18
+ stream,
19
+ util
20
+ };
@@ -11,11 +11,12 @@ import {
11
11
  instanceFromEnv,
12
12
  realFetch,
13
13
  signedIn
14
- } from "./chunk-IX24JXWC.mjs";
15
- import "./chunk-IU22ASGZ.mjs";
14
+ } from "./chunk-PN2OQIQ5.mjs";
15
+ import "./chunk-UYXRRLXZ.mjs";
16
+ import "./chunk-GWFVXAVQ.mjs";
17
+ import "./chunk-O3GNP4DR.mjs";
16
18
  import "./chunk-EIMFGA2U.mjs";
17
- import "./chunk-27AE3JXP.mjs";
18
- import "./chunk-B22BPJRW.mjs";
19
+ import "./chunk-KJTOBYEN.mjs";
19
20
  import "./chunk-P7MSGDOB.mjs";
20
21
  export {
21
22
  API_KEY_ENV,
@@ -0,0 +1,49 @@
1
+ import { createRequire as __parleyRequire } from 'node:module'; const require = __parleyRequire(import.meta.url);
2
+ import {
3
+ APIConnectionError,
4
+ APIConnectionTimeoutError,
5
+ APIError,
6
+ APIPromise,
7
+ APIUserAbortError,
8
+ Anthropic,
9
+ AnthropicError,
10
+ AuthenticationError,
11
+ BadRequestError,
12
+ BaseAnthropic,
13
+ BetaFallbackState,
14
+ ConflictError,
15
+ InternalServerError,
16
+ NotFoundError,
17
+ PagePromise,
18
+ PermissionDeniedError,
19
+ RateLimitError,
20
+ RetryableError,
21
+ UnprocessableEntityError,
22
+ betaRefusalFallbackMiddleware,
23
+ toFile
24
+ } from "./chunk-7CTZAMHT.mjs";
25
+ import "./chunk-P7MSGDOB.mjs";
26
+ export {
27
+ APIConnectionError,
28
+ APIConnectionTimeoutError,
29
+ APIError,
30
+ APIPromise,
31
+ APIUserAbortError,
32
+ Anthropic,
33
+ AnthropicError,
34
+ AuthenticationError,
35
+ BadRequestError,
36
+ BaseAnthropic,
37
+ BetaFallbackState,
38
+ ConflictError,
39
+ InternalServerError,
40
+ NotFoundError,
41
+ PagePromise,
42
+ PermissionDeniedError,
43
+ RateLimitError,
44
+ RetryableError,
45
+ UnprocessableEntityError,
46
+ betaRefusalFallbackMiddleware,
47
+ Anthropic as default,
48
+ toFile
49
+ };
@@ -0,0 +1,21 @@
1
+ import { createRequire as __parleyRequire } from 'node:module'; const require = __parleyRequire(import.meta.url);
2
+ import {
3
+ WAIT_FOR_DEFAULT_S,
4
+ WAIT_FOR_MAX_S,
5
+ waitFor,
6
+ waitSeat,
7
+ waitTarget
8
+ } from "./chunk-ZJ3UBXDU.mjs";
9
+ import "./chunk-5TLKYAI3.mjs";
10
+ import "./chunk-UYXRRLXZ.mjs";
11
+ import "./chunk-GWFVXAVQ.mjs";
12
+ import "./chunk-O3GNP4DR.mjs";
13
+ import "./chunk-EIMFGA2U.mjs";
14
+ import "./chunk-P7MSGDOB.mjs";
15
+ export {
16
+ WAIT_FOR_DEFAULT_S,
17
+ WAIT_FOR_MAX_S,
18
+ waitFor,
19
+ waitSeat,
20
+ waitTarget
21
+ };
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "crossroom",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Your AI agents in one room, from the terminal, editor or browser: they share knowledge, coordinate repositories and hand work over. Crossroom keeps the recap.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
7
+ "crossroom",
8
+ "cli",
7
9
  "ai-agents",
8
10
  "multi-agent",
11
+ "agent-collaboration",
12
+ "agent-handoff",
9
13
  "mcp",
10
14
  "claude-code",
11
15
  "codex",
@@ -39,6 +43,7 @@
39
43
  "prepublishOnly": "node build.mjs"
40
44
  },
41
45
  "devDependencies": {
46
+ "@anthropic-ai/sdk": "1.3.0",
42
47
  "@modelcontextprotocol/sdk": "^1.32.1",
43
48
  "@parley/shared": "workspace:*",
44
49
  "@types/node": "^22.0.0",
@@ -1,82 +0,0 @@
1
- import { createRequire as __parleyRequire } from 'node:module'; const require = __parleyRequire(import.meta.url);
2
-
3
- // src/client-version.ts
4
- import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
- import path from "node:path";
6
- var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
7
- var CHECK_TIMEOUT_MS = 2e3;
8
- var noted = /* @__PURE__ */ new Set();
9
- function noteInstance(base) {
10
- try {
11
- noted.add(new URL(base).origin);
12
- } catch {
13
- }
14
- }
15
- var notedInstances = () => [...noted];
16
- function versionParts(v) {
17
- const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(v.trim());
18
- return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
19
- }
20
- function olderThan(have, min) {
21
- const a = versionParts(have);
22
- const b = versionParts(min);
23
- if (!a || !b) return false;
24
- for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i];
25
- return false;
26
- }
27
- function readSeen(file) {
28
- try {
29
- const v = JSON.parse(readFileSync(file, "utf8"));
30
- return v && typeof v === "object" && !Array.isArray(v) ? v : {};
31
- } catch {
32
- return {};
33
- }
34
- }
35
- async function warnIfOutdated(o) {
36
- if (!noted.size || !versionParts(o.version) || process.env.CROSSROOM_NO_VERSION_CHECK === "1") return;
37
- const file = path.join(o.dataDir, "client-check.json");
38
- const now = (o.now ?? Date.now)();
39
- const seen = readSeen(file);
40
- let changed = false;
41
- for (const origin of noted) {
42
- let entry = seen[origin];
43
- if (!entry || now - entry.at > CHECK_EVERY_MS) {
44
- const min = await readMin(origin, o.fetch ?? fetch);
45
- if (min !== void 0) {
46
- entry = { at: now, min };
47
- seen[origin] = entry;
48
- changed = true;
49
- }
50
- }
51
- if (entry?.min && olderThan(o.version, entry.min))
52
- o.say(`This crossroom is ${o.version}; ${new URL(origin).host} supports ${entry.min} and newer. Update with: npm install -g crossroom`);
53
- }
54
- if (changed) {
55
- try {
56
- mkdirSync(o.dataDir, { recursive: true });
57
- writeFileSync(file, `${JSON.stringify(seen, null, 2)}
58
- `);
59
- } catch {
60
- }
61
- }
62
- }
63
- async function readMin(origin, f) {
64
- try {
65
- const res = await f(`${origin}/api/features`, { headers: { accept: "application/json" }, redirect: "error", signal: AbortSignal.timeout(CHECK_TIMEOUT_MS) });
66
- if (!res.ok) return void 0;
67
- const body = await res.json();
68
- const min = body?.client?.min;
69
- return typeof min === "string" && versionParts(min) ? min : null;
70
- } catch {
71
- return void 0;
72
- }
73
- }
74
-
75
- export {
76
- CHECK_EVERY_MS,
77
- noteInstance,
78
- notedInstances,
79
- versionParts,
80
- olderThan,
81
- warnIfOutdated
82
- };
@@ -1,219 +0,0 @@
1
- import { createRequire as __parleyRequire } from 'node:module'; const require = __parleyRequire(import.meta.url);
2
- import {
3
- noteInstance
4
- } from "./chunk-IU22ASGZ.mjs";
5
- import {
6
- DEFAULT_RELAY
7
- } from "./chunk-EIMFGA2U.mjs";
8
- import {
9
- Usage,
10
- dataDir,
11
- text
12
- } from "./chunk-27AE3JXP.mjs";
13
- import {
14
- external_exports
15
- } from "./chunk-B22BPJRW.mjs";
16
-
17
- // ../shared/src/accounts.ts
18
- var AuthProvider = external_exports.enum(["github", "google", "microsoft"]);
19
- var PROVIDER_LABELS = { github: "GitHub", google: "Google", microsoft: "Microsoft" };
20
- var SAME_ORIGIN_PATH = /^\/(?![/\\])[A-Za-z0-9._~!$&'()*+,;=:@%/-]*(?:\?[^#\s]*)?$/;
21
- var isSameOriginPath = (p) => typeof p === "string" && p.length <= 512 && SAME_ORIGIN_PATH.test(p);
22
- var AuthStartQuery = external_exports.object({ return: external_exports.string().refine(isSameOriginPath, "return must be a path on this site").optional() }).strict();
23
- var API_TOKEN = /^pa_[A-Za-z0-9_-]{43}$/;
24
- var Plan = external_exports.enum(["free"]);
25
- var RoomVia = external_exports.enum(["browser", "created", "cli"]);
26
- var AccountRoomsInput = external_exports.object({ rooms: external_exports.array(external_exports.object({ id: external_exports.string().min(1).max(64), owner: external_exports.string().min(1).max(128) }).strict()).max(50) }).strict();
27
- var CliApproveInput = external_exports.object({ userCode: external_exports.string().regex(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/), confirm: external_exports.boolean().optional() }).strict();
28
- var CliTokenInput = external_exports.object({ deviceCode: external_exports.string().min(16).max(128) }).strict();
29
- var API_KEY_LABEL_MAX = 60;
30
- var API_KEYS_MAX = 20;
31
- var API_KEYS_FULL = `This account already has ${API_KEYS_MAX} live API keys. Revoke one you no longer use, then make a new one.`;
32
- var CreateApiTokenInput = external_exports.object({ label: external_exports.string().min(1).max(API_KEY_LABEL_MAX) }).strict();
33
-
34
- // src/commands/credentials.ts
35
- import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeSync } from "node:fs";
36
- import path from "node:path";
37
- var credentialsPath = () => path.join(dataDir(), "credentials.json");
38
- function isLoopbackHost(hostname) {
39
- const h = hostname.toLowerCase();
40
- return h === "localhost" || h === "[::1]" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);
41
- }
42
- function relayOrigin(raw) {
43
- const typed = raw.trim();
44
- let u;
45
- try {
46
- u = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(typed) ? typed : `https://${typed}`);
47
- } catch {
48
- throw new Usage(`--relay must be a Crossroom's address, like ${DEFAULT_RELAY}; got "${raw}".`);
49
- }
50
- if (u.protocol !== "https:" && u.protocol !== "http:") throw new Usage(`--relay must be an https address, like ${DEFAULT_RELAY}; got "${raw}".`);
51
- if (u.username || u.password) throw new Usage("--relay must not carry a user name or a password.");
52
- if (u.protocol === "http:" && !isLoopbackHost(u.hostname))
53
- throw new Usage(`Not signing in to ${u.origin} over plain http: the token would cross the network unencrypted. Use its https address.`);
54
- return u.origin;
55
- }
56
- var isEntry = (v) => {
57
- const e = v;
58
- return !!e && typeof e === "object" && typeof e.token === "string" && API_TOKEN.test(e.token) && typeof e.accountId === "string" && typeof e.createdAt === "string";
59
- };
60
- function readCredentials(file = credentialsPath()) {
61
- if (!existsSync(file)) return {};
62
- let raw;
63
- try {
64
- raw = JSON.parse(readFileSync(file, "utf8"));
65
- } catch {
66
- raw = null;
67
- }
68
- if (!raw || typeof raw !== "object" || Array.isArray(raw))
69
- throw new Usage(`${file} is not a credentials file Crossroom wrote. Move it aside, then run this again.`);
70
- const out = {};
71
- for (const [relay, entry] of Object.entries(raw)) if (isEntry(entry)) out[relay] = { token: entry.token, accountId: entry.accountId, createdAt: entry.createdAt };
72
- return out;
73
- }
74
- function writeCredentials(creds, file = credentialsPath()) {
75
- mkdirSync(path.dirname(file), { recursive: true, mode: 448 });
76
- const tmp = `${file}.${process.pid}.tmp`;
77
- rmSync(tmp, { force: true });
78
- const fd = openSync(tmp, "wx", 384);
79
- try {
80
- writeSync(fd, `${JSON.stringify(creds, null, 2)}
81
- `);
82
- } finally {
83
- closeSync(fd);
84
- }
85
- renameSync(tmp, file);
86
- if (process.platform !== "win32") chmodSync(file, 384);
87
- }
88
- function credentialFor(relay, file = credentialsPath()) {
89
- return readCredentials(file)[relayOrigin(relay)] ?? null;
90
- }
91
-
92
- // src/commands/relay-call.ts
93
- var API_KEY_ENV = "CROSSROOM_API_KEY";
94
- var URL_ENV = "CROSSROOM_URL";
95
- var RelayRefused = class extends Usage {
96
- constructor(message, status) {
97
- super(message);
98
- this.status = status;
99
- }
100
- status;
101
- };
102
- var saidBy = (parsed, status) => typeof parsed?.error === "string" ? parsed.error : `HTTP ${status}`;
103
- async function send(relay, token, fetchImpl, method, path2, body, accept) {
104
- let res;
105
- try {
106
- res = await fetchImpl(`${relay}${path2}`, {
107
- method,
108
- headers: { accept, authorization: `Bearer ${token}`, ...body === void 0 ? {} : { "content-type": "application/json" } },
109
- body: body === void 0 ? void 0 : JSON.stringify(body),
110
- redirect: "error",
111
- signal: AbortSignal.timeout(15e3)
112
- });
113
- } catch (e) {
114
- throw new Usage(`Could not reach ${relay}: ${e.name === "TimeoutError" ? "it did not answer in 15 seconds" : "the request failed"}.`);
115
- }
116
- return { res, raw: await res.text() };
117
- }
118
- function refusal(relay, token, res, parsed) {
119
- if (res.status === 401)
120
- return new RelayRefused(
121
- token === envKey() ? `${relay} does not accept the key in ${API_KEY_ENV}: it was revoked, has expired, or is for another Crossroom (${URL_ENV} names the instance).` : `${relay} no longer knows this machine's sign-in. Run \`crossroom login --relay ${relay}\` again.`,
122
- 401
123
- );
124
- if (!res.ok) return new RelayRefused(`${relay} refused: ${saidBy(parsed, res.status)}`, res.status);
125
- return null;
126
- }
127
- async function call(relay, token, fetchImpl, method, path2, body) {
128
- const { res, raw } = await send(relay, token, fetchImpl, method, path2, body, "application/json");
129
- let parsed = null;
130
- try {
131
- parsed = raw ? JSON.parse(raw) : null;
132
- } catch {
133
- parsed = null;
134
- }
135
- const refused = refusal(relay, token, res, parsed);
136
- if (refused) throw refused;
137
- return parsed;
138
- }
139
- async function callText(relay, token, fetchImpl, method, path2, accept) {
140
- const { res, raw } = await send(relay, token, fetchImpl, method, path2, void 0, accept);
141
- let parsed = null;
142
- if (!res.ok) {
143
- try {
144
- parsed = JSON.parse(raw);
145
- } catch {
146
- parsed = null;
147
- }
148
- }
149
- const refused = refusal(relay, token, res, parsed);
150
- if (refused) throw refused;
151
- return raw;
152
- }
153
- var envKey = (env = process.env) => env[API_KEY_ENV]?.trim() || void 0;
154
- var hideKeys = (s) => s.replace(/pa_[A-Za-z0-9_-]+/g, "pa_\u2026");
155
- function instanceFromEnv(raw) {
156
- const typed = raw.trim();
157
- const shown = hideKeys(typed);
158
- let u;
159
- try {
160
- u = new URL(typed);
161
- } catch {
162
- throw new Usage(`${URL_ENV} must be an instance's address, like ${DEFAULT_RELAY}; got "${shown}".`);
163
- }
164
- if (u.pathname !== "/" && u.pathname !== "" || u.search || u.hash)
165
- throw new Usage(`${URL_ENV} must be an instance's address with no path, like ${DEFAULT_RELAY}; got "${shown}".`);
166
- try {
167
- return relayOrigin(u.origin);
168
- } catch (e) {
169
- throw new Usage(`${URL_ENV}: ${hideKeys(e.message).replace(/--relay/g, URL_ENV)}`);
170
- }
171
- }
172
- function chosenInstance(args, fallback, env = process.env) {
173
- const named = text(args.flags.relay) ?? text(args.flags.instance);
174
- const url = env[URL_ENV]?.trim();
175
- const base = named !== void 0 ? relayOrigin(named) : url ? instanceFromEnv(url) : relayOrigin(fallback);
176
- noteInstance(base);
177
- return base;
178
- }
179
- function accountCredential(args, env = process.env) {
180
- const key = envKey(env);
181
- if (key !== void 0) {
182
- if (!API_TOKEN.test(key))
183
- throw new Usage(`${API_KEY_ENV} is set, but not to a Crossroom API key (a key starts with pa_; make one on your account page). Nothing was sent.`);
184
- return { relay: chosenInstance(args, DEFAULT_RELAY, env), token: key, via: "env" };
185
- }
186
- const relay = chosenInstance(args, DEFAULT_RELAY, env);
187
- const held = credentialFor(relay);
188
- return held ? { relay, token: held.token, via: "login" } : null;
189
- }
190
- function signedIn(args, env = process.env) {
191
- const got = accountCredential(args, env);
192
- if (got) return { relay: got.relay, token: got.token };
193
- const relay = chosenInstance(args, DEFAULT_RELAY, env);
194
- throw new Usage(`This machine is not signed in to ${relay}. Run \`crossroom login --relay ${relay}\` first, or set ${API_KEY_ENV} to an API key from your account page.`);
195
- }
196
- var credentialWhere = (c) => c.via === "env" ? `the ${API_KEY_ENV} environment variable` : credentialsPath();
197
- var realFetch = (input, init) => fetch(input, init);
198
-
199
- export {
200
- PROVIDER_LABELS,
201
- isSameOriginPath,
202
- API_TOKEN,
203
- credentialsPath,
204
- relayOrigin,
205
- readCredentials,
206
- writeCredentials,
207
- credentialFor,
208
- API_KEY_ENV,
209
- URL_ENV,
210
- RelayRefused,
211
- call,
212
- callText,
213
- instanceFromEnv,
214
- chosenInstance,
215
- accountCredential,
216
- signedIn,
217
- credentialWhere,
218
- realFetch
219
- };