flow-agent-bridge 0.32.0 → 0.34.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,52 @@
1
+ import { existsSync, promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { Worker } from 'node:worker_threads';
4
+ import { attachmentFilename } from './attachments.js';
5
+ export const MAX_SHARED_FILE_BYTES = 20 * 1024 * 1024;
6
+ /** A cancellable worker keeps malformed/expensive documents off the audio loop. */
7
+ export async function prepareSharedFile(file, directory, download, signal) {
8
+ if (!/^[a-zA-Z0-9_-]{1,100}$/.test(file.id))
9
+ throw new Error('Invalid attachment identifier');
10
+ if (file.sizeBytes > MAX_SHARED_FILE_BYTES)
11
+ throw new Error('File exceeds the 20 MB call limit');
12
+ signal.throwIfAborted();
13
+ const data = await download(file.id, signal);
14
+ signal.throwIfAborted();
15
+ if (data.length > MAX_SHARED_FILE_BYTES)
16
+ throw new Error('File exceeds the 20 MB call limit');
17
+ const filePath = path.join(directory, attachmentFilename(file.id, file.name));
18
+ await fs.writeFile(filePath, data, { mode: 0o600 });
19
+ signal.throwIfAborted();
20
+ return new Promise((resolve, reject) => {
21
+ const adjacent = new URL('./shared-file-worker.js', import.meta.url);
22
+ // tsx development uses the built worker too: Node workers cannot load TS unaided.
23
+ const worker = new Worker(existsSync(adjacent) ? adjacent : new URL('../dist/shared-file-worker.js', import.meta.url), {
24
+ workerData: { filePath, name: file.name, mimeType: file.mimeType },
25
+ resourceLimits: { maxOldGenerationSizeMb: 192 },
26
+ });
27
+ let settled = false;
28
+ const finish = (error, result) => {
29
+ if (settled)
30
+ return;
31
+ settled = true;
32
+ clearTimeout(timer);
33
+ signal.removeEventListener('abort', abort);
34
+ // Wait for termination before the caller can remove its temporary directory.
35
+ void worker.terminate().finally(() => error ? reject(error) : resolve(result));
36
+ };
37
+ const abort = () => finish(new Error('File preparation cancelled'));
38
+ const timer = setTimeout(() => finish(new Error('Document took too long to open (20 seconds)')), 20_000);
39
+ signal.addEventListener('abort', abort, { once: true });
40
+ if (signal.aborted)
41
+ abort();
42
+ worker.once('message', (message) => {
43
+ if (message.result)
44
+ finish(undefined, message.result);
45
+ else
46
+ finish(new Error(message.error ?? 'Could not read document'));
47
+ });
48
+ worker.once('error', (error) => finish(error));
49
+ worker.once('exit', () => finish(new Error('Document reader stopped unexpectedly')));
50
+ });
51
+ }
52
+ //# sourceMappingURL=shared-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-files.js","sourceRoot":"","sources":["../src/shared-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAStD,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAa,EACb,SAAiB,EACjB,QAA8D,EAC9D,MAAmB;IAEnB,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC9F,IAAI,IAAI,CAAC,SAAS,GAAG,qBAAqB;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACjG,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,IAAI,IAAI,CAAC,MAAM,GAAG,qBAAqB;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,C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C,CAAC,OAAO,CAAC,MAAO,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;QACpE,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzG,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,IAAI,MAAM,CAAC,OAAO;YAAE,KAAK,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAwD,EAAE,EAAE;YAClF,IAAI,OAAO,CAAC,MAAM;gBAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;;gBACjD,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-agent-bridge",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "type": "module",
5
5
  "description": "Flow agent bridge: joins a Flow workspace as a first-class AI agent and execs a coding-agent CLI (Claude Code, Codex) headlessly per conversation",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "bridge"
19
19
  ],
20
20
  "engines": {
21
- "node": ">=20"
21
+ "node": ">=20.16.0 <21 || >=22.3.0"
22
22
  },
23
23
  "bin": {
24
24
  "flow-agent-bridge": "dist/index.js"
@@ -29,20 +29,25 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "build": "tsc -p tsconfig.json",
32
- "dev": "tsx src/index.ts",
33
- "test": "vitest run",
32
+ "dev": "pnpm build && tsx src/index.ts",
33
+ "test": "pnpm build && vitest run",
34
34
  "prepack": "pnpm build",
35
35
  "pack:tarball": "pnpm pack"
36
36
  },
37
37
  "dependencies": {
38
38
  "@livekit/agents": "1.7.1",
39
39
  "@livekit/rtc-node": "0.13.34",
40
+ "@napi-rs/canvas": "0.1.100",
41
+ "exceljs": "4.4.0",
42
+ "mammoth": "1.11.0",
43
+ "pdfjs-dist": "5.4.624",
40
44
  "ws": "^8.18.0"
41
45
  },
42
46
  "devDependencies": {
43
47
  "@flow/shared": "workspace:*",
44
48
  "@types/node": "^22.10.0",
45
49
  "@types/ws": "^8.5.13",
50
+ "jszip": "3.10.1",
46
51
  "tsx": "^4.19.2",
47
52
  "typescript": "^5.6.0",
48
53
  "vitest": "^2.1.8"