@sleep2agi/agent-network 2.3.0-preview.46 → 2.3.0-preview.47

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,66 @@
1
+ /**
2
+ * What gets written to `<project>/.anet/node-server.js` (issue #1216).
3
+ *
4
+ * The target name is not negotiable: `agent-node`'s grok co-presence spawn
5
+ * gate pins the CommHub MCP payload to exactly that path, so whatever the
6
+ * source is, the file that lands there is called `.js`.
7
+ *
8
+ * 🔴 The bug this module exists to remove: the old code copied the source
9
+ * verbatim and justified it with a comment claiming
10
+ *
11
+ * "bun runs .ts content under a .js extension fine"
12
+ *
13
+ * which is false — bun selects its parser from the extension:
14
+ *
15
+ * $ printf 'function f(x: string): void {}\nf("hi");\n' > probe.ts
16
+ * $ cp probe.ts probe.js
17
+ * $ bun probe.ts → runs
18
+ * $ bun probe.js → error: Expected ")" but found ":"
19
+ *
20
+ * An installed npm package never hit it, because its first resolver candidate
21
+ * (`dist/src/node-server.js`) is compiled. Only a source checkout fell through
22
+ * to `src/node-server.ts` — i.e. every local run and every hand-verified PR.
23
+ *
24
+ * And the symptom was three layers from the cause: the node died on
25
+ * `grok copresence CommHub MCP readiness preflight failed (1)`, which names
26
+ * neither a file nor a parse error.
27
+ */
28
+ /** Injected so the decision is testable without spawning anything. */
29
+ export interface TypeScriptBundler {
30
+ /** Returns the self-contained JavaScript for `entryPath`, or throws. */
31
+ bundleSync(entryPath: string): string;
32
+ }
33
+ export declare class NodeServerPayloadError extends Error {
34
+ constructor(message: string);
35
+ }
36
+ /**
37
+ * Decide what bytes belong at the `.js` target for a given source path.
38
+ *
39
+ * A `.js` source is passed through untouched — the published package ships a
40
+ * compiled bundle there, and re-processing it risks changing bytes for no gain.
41
+ *
42
+ * 🔴 A `.ts` source must be **bundled, not merely transpiled**. Stripping types
43
+ * fixes the parse error but leaves the file's relative imports pointing at
44
+ * siblings that do not exist beside the destination:
45
+ *
46
+ * import { inboundChannelMeta } from "./channel-meta.js";
47
+ * → Cannot find module './channel-meta.js' from '<project>/.anet/node-server.js'
48
+ *
49
+ * That second failure is why transpiling alone still ended at
50
+ * "CommHub MCP readiness preflight failed (1)". The published
51
+ * `dist/src/node-server.js` works precisely because it is a self-contained
52
+ * bundle, so a source checkout has to produce the same shape.
53
+ */
54
+ export declare function nodeServerPayloadFor(source: string, sourcePath: string, bundler: TypeScriptBundler | null): string;
55
+ /**
56
+ * The bundler available on this runtime, or null.
57
+ *
58
+ * bun can bundle; the published CLI runs under node and cannot — but it also
59
+ * never resolves a `.ts` candidate (its `dist/` copy wins), so null there is
60
+ * correct rather than a gap.
61
+ *
62
+ * `spawnSync` rather than `Bun.build()` because both call sites are
63
+ * synchronous, and making them async would change the ordering of the file
64
+ * writes around them.
65
+ */
66
+ export declare function ambientTypeScriptTranspiler(): TypeScriptBundler | null;