@openmuster/muster 0.3.1-alpha.5 → 0.3.1-alpha.7

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 (33) hide show
  1. package/README.md +2 -2
  2. package/dist/{args-CaFBa2IP.js → args-C_XaUVTS.js} +456 -65
  3. package/dist/cli.js +3 -3
  4. package/dist/index.d.ts +231 -85
  5. package/dist/index.js +156 -10
  6. package/dist/main-C-3gchLr.js +6 -0
  7. package/dist/{main-BeEB08iI.js → main-D8R2IP1C.js} +1080 -119
  8. package/dist/mcp-uFonN-GE.js +6 -0
  9. package/dist/{module-BX2IjSiv.js → module-D6Kgl3Do.js} +2 -2
  10. package/dist/{module-D9KdbEpS.js → module-DkA_1NkG.js} +1 -1
  11. package/dist/skills/loop-card/SKILL.md +22 -3
  12. package/dist/{steps-FNDWY1P_.js → steps-DVxqtI61.js} +405 -9
  13. package/docs/01-concepts/06-actors.md +3 -1
  14. package/docs/01-concepts/08-tasks.md +3 -0
  15. package/docs/01-concepts/10-schedules.md +9 -1
  16. package/docs/01-concepts/11-access.md +86 -2
  17. package/docs/01-concepts/12-files-and-data.md +139 -6
  18. package/docs/01-concepts/16-workflows.md +20 -0
  19. package/docs/01-concepts/17-board-module.md +3 -1
  20. package/docs/01-quickstart.md +1 -1
  21. package/docs/02-sync/04-slack.md +5 -0
  22. package/docs/03-guides/06-sandboxed-agents.md +47 -0
  23. package/docs/03-guides/17-mcp.md +44 -7
  24. package/docs/03-guides/20-a-feedback-loop.md +114 -1
  25. package/docs/03-guides/22-building-from-linear.md +19 -6
  26. package/docs/04-reference/01-cli.md +10 -1
  27. package/docs/04-reference/02-handle.md +1 -0
  28. package/docs/04-reference/03-http.md +56 -5
  29. package/docs/04-reference/05-errors.md +8 -1
  30. package/docs/04-reference/06-conformance.md +17 -5
  31. package/package.json +2 -2
  32. package/dist/main-CLzQkYeG.js +0 -6
  33. package/dist/mcp-CAAZRJgv.js +0 -6
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { A as boardPath, C as listen, G as noteOut, H as declared, J as withLines, K as refused, L as verify, M as boardKey, P as mint, T as SANDBOX_ROUTES, U as env, W as fetchFile, Y as SEND_MS, f as board, j as file, lt as misuse, nt as channelPath, q as sizeOf, st as Failure, x as createHandler } from "./args-CaFBa2IP.js";
2
- import { A as claude, C as boardPolicy, D as agentEnv, F as conformance, M as generic, O as runLocal, P as http, S as applyPolicy, T as installationToken, a as workflowResult, d as workflowsPath, f as e2b, h as vercel, j as codex, k as AGENTS, m as cloudflare, o as fenced, u as loadWorkflows, w as githubApp } from "./steps-FNDWY1P_.js";
1
+ import { A as boardPath, C as listen, G as nameOf, H as declared, J as refused, K as fetchFile, L as verify, M as boardKey, P as mint, T as SANDBOX_ROUTES, U as env, W as isEnv, X as withLines, Y as sizeOf, Z as SEND_MS, et as backToDisk, f as board, ht as misuse, j as file, pt as Failure, q as noteOut, st as channelPath, tt as memoryFiles, x as createHandler } from "./args-C_XaUVTS.js";
2
+ import { A as boardPolicy, D as pullRequests, F as runLocal, H as conformance, I as AGENTS, L as claude, M as installationToken, P as agentEnv, R as codex, V as http, _ as e2b, b as vercel, d as fenced, g as workflowsPath, h as loadWorkflows, j as githubApp, k as applyPolicy, u as workflowResult, y as cloudflare, z as generic } from "./steps-DVxqtI61.js";
3
3
  import { mkdirSync, writeFileSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
5
  import { basename, dirname, join } from "node:path";
6
- import { createHmac, timingSafeEqual } from "node:crypto";
6
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
7
7
  import { spawn } from "node:child_process";
8
8
 
9
9
  //#region src/watch/command.ts
@@ -158,6 +158,143 @@ function command(argv, options = {}) {
158
158
  };
159
159
  }
160
160
 
161
+ //#endregion
162
+ //#region src/files/s3.ts
163
+ const EMPTY = createHash("sha256").update("").digest("hex");
164
+ const BUCKET = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
165
+ const PREFIX = /^([A-Za-z0-9._-]+\/)*$/;
166
+ /** How long one request may take, so a store that hangs fails a file instead of holding the board. */
167
+ const S3_MS = 3e4;
168
+ const sha256 = (data) => createHash("sha256").update(data).digest("hex");
169
+ const hmac$1 = (key, data) => createHmac("sha256", key).update(data).digest();
170
+ /** A path as SigV4 signs it for S3: each segment encoded as RFC 3986 says, the slashes kept. */
171
+ const canonicalPath = (path) => path.split("/").map((part) => encodeURIComponent(decodeURIComponent(part)).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`)).join("/");
172
+ /**
173
+ * Signs a request with AWS Signature Version 4, as its headers: what every S3-compatible store checks. Exported
174
+ * for its test against AWS's own test suite. `headers` are the ones signed, `host` and `x-amz-date` among them.
175
+ */
176
+ function signV4(request) {
177
+ const names = Object.keys(request.headers).map((name) => name.toLowerCase()).sort();
178
+ const lower = Object.fromEntries(Object.entries(request.headers).map(([name, value]) => [name.toLowerCase(), value.trim().replace(/\s+/g, " ")]));
179
+ const amzDate = lower["x-amz-date"];
180
+ const scope = `${amzDate.slice(0, 8)}/${request.region}/${request.service}/aws4_request`;
181
+ const signedHeaders = names.join(";");
182
+ const query = [...request.url.searchParams].map(([key$1, value]) => `${encodeURIComponent(key$1)}=${encodeURIComponent(value)}`).sort().join("&");
183
+ const canonical = [
184
+ request.method,
185
+ canonicalPath(request.url.pathname),
186
+ query,
187
+ names.map((name) => `${name}:${lower[name]}\n`).join(""),
188
+ signedHeaders,
189
+ request.payloadHash
190
+ ].join("\n");
191
+ const toSign = [
192
+ "AWS4-HMAC-SHA256",
193
+ amzDate,
194
+ scope,
195
+ sha256(canonical)
196
+ ].join("\n");
197
+ let key = hmac$1(`AWS4${request.secretAccessKey}`, amzDate.slice(0, 8));
198
+ for (const part of [
199
+ request.region,
200
+ request.service,
201
+ "aws4_request"
202
+ ]) key = hmac$1(key, part);
203
+ const signature = createHmac("sha256", key).update(toSign).digest("hex");
204
+ return {
205
+ canonical,
206
+ toSign,
207
+ authorization: `AWS4-HMAC-SHA256 Credential=${request.accessKeyId}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
208
+ };
209
+ }
210
+ const isLoopback = (host) => host === "127.0.0.1" || host === "localhost" || host === "[::1]";
211
+ /**
212
+ * A board's files in an S3 bucket, or any store that speaks S3's API: Cloudflare R2, MinIO, Backblaze B2,
213
+ * Google Cloud Storage's interoperability mode. Each file is one object, `<prefix><id>`, written once.
214
+ * Secrets named with `env()` are read on first use, never when the module is imported.
215
+ */
216
+ function s3Files(options) {
217
+ if (typeof options.bucket !== "string" || !BUCKET.test(options.bucket)) throw misuse("invalid_files", `"${String(options.bucket)}" isn't a bucket name.`, "A bucket is 3 to 63 lowercase letters, numbers, \".\" and \"-\".");
218
+ if (options.endpoint === void 0 && options.bucket.includes(".")) throw misuse("invalid_files", `"${options.bucket}" has a ".", which AWS's https addresses for a bucket don't take.`, `Give endpoint: 'https://s3.${options.region ?? "us-east-1"}.amazonaws.com', and it is reached by path instead.`);
219
+ const prefix = options.prefix ?? "";
220
+ if (!PREFIX.test(prefix)) throw misuse("invalid_files", `"${prefix}" isn't a prefix: folders of letters, numbers, ".", "_" and "-", each ending in "/".`);
221
+ const region = options.region ?? "us-east-1";
222
+ let base;
223
+ try {
224
+ base = new URL(options.endpoint ?? `https://${options.bucket}.s3.${region}.amazonaws.com`);
225
+ } catch {
226
+ throw misuse("invalid_files", `"${options.endpoint}" isn't a URL.`);
227
+ }
228
+ if (base.protocol !== "https:" && !(base.protocol === "http:" && isLoopback(base.hostname))) throw misuse("invalid_files", `The S3 endpoint must be https: ${base.href}`);
229
+ const pathStyle = options.endpoint !== void 0;
230
+ const at = (id) => new URL(`${base.origin}${base.pathname.replace(/\/$/, "")}${pathStyle ? `/${options.bucket}` : ""}/${prefix}${id}`);
231
+ const reveal = (secret, field) => {
232
+ if (secret === void 0) return void 0;
233
+ if (!isEnv(secret)) return secret;
234
+ const value = process.env[nameOf(secret)];
235
+ if (!value) throw new Error(`${nameOf(secret)} ${value === void 0 ? "isn't set" : "is empty"}, and the S3 store's ${field} names it`);
236
+ return value;
237
+ };
238
+ const doFetch = options.fetch ?? fetch;
239
+ const send$1 = async (method, id, body) => {
240
+ if (!/^[0-9a-f]{64}$/.test(id)) throw new Error(`"${id}" isn't a file's ID`);
241
+ const url = at(id);
242
+ const amzDate = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
243
+ const payloadHash = body ? id : EMPTY;
244
+ const token = reveal(options.sessionToken, "sessionToken");
245
+ const headers = {
246
+ host: url.host,
247
+ "x-amz-date": amzDate,
248
+ "x-amz-content-sha256": payloadHash,
249
+ ...token ? { "x-amz-security-token": token } : {}
250
+ };
251
+ const { authorization } = signV4({
252
+ method,
253
+ url,
254
+ headers,
255
+ payloadHash,
256
+ region,
257
+ service: "s3",
258
+ accessKeyId: reveal(options.accessKeyId, "accessKeyId"),
259
+ secretAccessKey: reveal(options.secretAccessKey, "secretAccessKey")
260
+ });
261
+ const { host: _host,...sent } = headers;
262
+ return doFetch(url, {
263
+ method,
264
+ headers: {
265
+ ...sent,
266
+ authorization
267
+ },
268
+ ...body ? { body } : {},
269
+ redirect: "manual",
270
+ signal: AbortSignal.timeout(S3_MS)
271
+ });
272
+ };
273
+ /** What S3 said went wrong, by its error code where it gave one: never the request, which is signed. */
274
+ const refused$1 = async (response, what) => {
275
+ const text = await response.text().catch(() => "");
276
+ const code = /<Code>([^<]{1,64})<\/Code>/.exec(text)?.[1];
277
+ return /* @__PURE__ */ new Error(`S3 answered ${response.status}${code ? ` ${code}` : ""} to ${what}`);
278
+ };
279
+ return {
280
+ name: `s3://${pathStyle ? `${base.host}/` : ""}${options.bucket}/${prefix}`,
281
+ async put(id, bytes) {
282
+ const response = await send$1("PUT", id, bytes);
283
+ if (!response.ok) throw await refused$1(response, `storing ${id.slice(0, 12)}`);
284
+ await response.body?.cancel();
285
+ },
286
+ async get(id) {
287
+ const response = await send$1("GET", id);
288
+ if (response.status === 404) {
289
+ await response.body?.cancel();
290
+ return null;
291
+ }
292
+ if (!response.ok) throw await refused$1(response, `reading ${id.slice(0, 12)}`);
293
+ return new Uint8Array(await response.arrayBuffer());
294
+ }
295
+ };
296
+ }
297
+
161
298
  //#endregion
162
299
  //#region src/sync/providers.ts
163
300
  const hmac = (secret, body) => createHmac("sha256", secret).update(body).digest("hex");
@@ -1113,7 +1250,7 @@ function linearWith(options) {
1113
1250
  const post = (query, variables) => postAs(query, variables, fetcher);
1114
1251
  const lines = [];
1115
1252
  for (const file$1 of message.attachments) {
1116
- const bytes = read(file$1.id);
1253
+ const bytes = await read(file$1.id);
1117
1254
  if (!bytes) {
1118
1255
  lines.push(noteOut(file$1.name, "the board no longer has it"));
1119
1256
  continue;
@@ -1205,6 +1342,14 @@ const fromTs = (ts) => {
1205
1342
  const toTs = (us) => `${Math.floor(us / 1e6)}.${String(us % 1e6).padStart(6, "0")}`;
1206
1343
  /** Slack: messages in mapped channels come in as threads, and board replies go back into the Slack thread. */
1207
1344
  const slack = (options) => declared("slack", options, slackWith);
1345
+ /**
1346
+ * Slack text with its broadcasts and group mentions (`<!channel>`, `<!here>`, `<!everyone>`, `<!subteam^S1>`)
1347
+ * broken by a word joiner, so they read the same and notify nobody. For text written on another platform: anyone
1348
+ * who can comment on a synced GitHub issue could otherwise ping a whole Slack channel. Code spans are not spared,
1349
+ * as Slack and a regex disagree on where code is. Follows `withoutBroadcasts` in @vercel/board's Slack provider
1350
+ * (Apache-2.0, Copyright Vercel, Inc.).
1351
+ */
1352
+ const withoutBroadcasts = (text) => text.replace(/<!(?=[a-z^])/gi, "<⁠!");
1208
1353
  function slackWith(options) {
1209
1354
  const now = options.now ?? (() => Date.now());
1210
1355
  const base = options.api ?? "https://slack.com/api";
@@ -1394,7 +1539,7 @@ function slackWith(options) {
1394
1539
  for (const [id, to] of Object.entries(options.channels)) if ((typeof to === "string" ? to : to.channel) === channel) return id;
1395
1540
  return null;
1396
1541
  },
1397
- async update(external, text, _place, fetcher) {
1542
+ async update(external, text, _place, fetcher, from) {
1398
1543
  const [channel, ts] = external.split(":");
1399
1544
  await send(fetcher, `${base}/chat.update`, {
1400
1545
  method: "POST",
@@ -1405,7 +1550,7 @@ function slackWith(options) {
1405
1550
  body: JSON.stringify({
1406
1551
  channel,
1407
1552
  ts,
1408
- text
1553
+ text: from?.external ? withoutBroadcasts(text) : text
1409
1554
  })
1410
1555
  });
1411
1556
  },
@@ -1511,7 +1656,7 @@ function slackWith(options) {
1511
1656
  const uploaded = [];
1512
1657
  const lines = [];
1513
1658
  for (const file$1 of message.attachments) {
1514
- const bytes = read(file$1.id);
1659
+ const bytes = await read(file$1.id);
1515
1660
  if (!bytes) {
1516
1661
  lines.push(noteOut(file$1.name, "the board no longer has it"));
1517
1662
  continue;
@@ -1546,7 +1691,8 @@ function slackWith(options) {
1546
1691
  lines.push(noteOut(file$1.name, "Slack did not take it"));
1547
1692
  }
1548
1693
  }
1549
- const text = withLines(message.text, lines);
1694
+ const written = withLines(message.text, lines);
1695
+ const text = target.external ? withoutBroadcasts(written) : written;
1550
1696
  const made = await send(fetcher, `${base}/chat.postMessage`, {
1551
1697
  method: "POST",
1552
1698
  headers: {
@@ -1972,7 +2118,7 @@ function notionWith(options) {
1972
2118
  } : out;
1973
2119
  },
1974
2120
  async deliver(message, target, fetcher, read) {
1975
- const lines = message.attachments.map((file$1) => read(file$1.id) ? noteOut(file$1.name, "the Notion sync sends no files yet") : noteOut(file$1.name, "the board no longer has it"));
2121
+ const lines = await Promise.all(message.attachments.map(async (file$1) => await read(file$1.id) ? noteOut(file$1.name, "the Notion sync sends no files yet") : noteOut(file$1.name, "the board no longer has it")));
1976
2122
  if (target.threadExternal === null) {
1977
2123
  const source = await call(fetcher, `/data_sources/${target.place}`);
1978
2124
  const title = Object.entries(source?.properties ?? {}).find(([, property]) => property?.type === "title")?.[0];
@@ -2013,4 +2159,4 @@ function notionWith(options) {
2013
2159
  }
2014
2160
 
2015
2161
  //#endregion
2016
- export { AGENTS, Failure, LINEAR_SCOPES, SANDBOX_ROUTES, agentEnv, applyPolicy, board, boardKey, boardPath, boardPolicy, claude, cloudflare, codex, command, conformance, createHandler, e2b, env, fenced, file, generic, github, http, linear, listen, loadWorkflows, mint, notion, runLocal, slack, vercel, verify, workflowResult, workflowsPath };
2162
+ export { AGENTS, Failure, LINEAR_SCOPES, SANDBOX_ROUTES, agentEnv, applyPolicy, backToDisk, board, boardKey, boardPath, boardPolicy, claude, cloudflare, codex, command, conformance, createHandler, e2b, env, fenced, file, generic, github, http, linear, listen, loadWorkflows, memoryFiles, mint, notion, pullRequests, runLocal, s3Files, slack, vercel, verify, workflowResult, workflowsPath };
@@ -0,0 +1,6 @@
1
+ import { D as VERSION } from "./args-C_XaUVTS.js";
2
+ import "./steps-DVxqtI61.js";
3
+ import { a as main, i as attend, n as agentPrompt, o as meantCommand, r as agentToken, s as repoUrl, t as SPECS } from "./main-D8R2IP1C.js";
4
+ import "./module-DkA_1NkG.js";
5
+
6
+ export { SPECS, VERSION, agentPrompt, agentToken, attend, main, meantCommand, repoUrl };