@rcs-campaigns/agent-toolkit 0.1.6 → 0.1.9

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.
package/dist/client.d.ts CHANGED
@@ -42,12 +42,25 @@ export interface GatewayConfig {
42
42
  */
43
43
  export declare function detectSkin(argv?: readonly string[]): 'wa' | 'rcs';
44
44
  /**
45
- * The package's own version, read at runtime rather than restated in a
46
- * constant. A hardcoded copy silently goes stale the first time anyone bumps
47
- * for a release, and both skins show this string to a user. From dist/ and from
48
- * src/ alike the package root is one level up.
45
+ * The version of the package the user actually installed, read at runtime rather
46
+ * than restated in a constant. A hardcoded copy silently goes stale the first
47
+ * time anyone bumps for a release, and both skins show this string to a user —
48
+ * as `serverInfo.version` over MCP and in the CLI's usage banner.
49
+ *
50
+ * It resolves from the INVOKED BIN, not from `__dirname`, because the two skins
51
+ * are two npm packages: `wa-mcp` lives in @wa-campaigns/agent-toolkit, which
52
+ * delegates to this file inside @rcs-campaigns/agent-toolkit. `__dirname` alone
53
+ * therefore always reports the CORE's number, so a user who installed
54
+ * @wa-campaigns/agent-toolkit\@0.1.7 was told 0.1.6 — true of the code, but not
55
+ * of the thing they installed, and not a version they could go and fetch.
56
+ *
57
+ * Only the bin names we ship are trusted to locate a package (a test runner or a
58
+ * bundler entry would otherwise point at ITS package.json); everything else, and
59
+ * every library import, falls back to this package — the previous behaviour. For
60
+ * both layouts the package root is one level up from the bin: `bin/wa-mcp.js`
61
+ * and `dist/mcp.js` alike.
49
62
  */
50
- export declare function readVersion(): string;
63
+ export declare function readVersion(argv?: readonly string[]): string;
51
64
  /** Human-readable product + channel names for the running skin. */
52
65
  export declare function skinLabels(skin?: 'wa' | 'rcs'): {
53
66
  product: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,O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AAO,CAAC;CAChB;AAED,8EAA8E;AAC9E,qBAAa,YAAa,SAAQ,KAAK;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;gBACN,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CA4B7E;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa;IAI/D,+EAA+E;IACzE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;CAmCvD"}
package/dist/client.js CHANGED
@@ -18,28 +18,68 @@ const node_path_1 = require("node:path");
18
18
  * argv, a bundler-rewritten path, or a direct import all fall through to 'rcs'.
19
19
  */
20
20
  function detectSkin(argv = process.argv) {
21
+ const name = invokedBinName(argv);
22
+ return name === 'wa' || name === 'wa-mcp' ? 'wa' : 'rcs';
23
+ }
24
+ /**
25
+ * The bin basename this process was launched as — "wa-mcp", "mcp", "cli" — or
26
+ * '' when argv carries no usable path (a library import, a bundler-rewritten
27
+ * entry, a test runner). Shared by {@link detectSkin} and {@link readVersion} so
28
+ * the two can never disagree about which skin is running.
29
+ */
30
+ function invokedBinName(argv) {
21
31
  const invoked = argv[1];
22
32
  if (typeof invoked !== 'string')
23
- return 'rcs';
33
+ return '';
24
34
  // basename without extension, so ".../bin/wa-mcp.js" → "wa-mcp".
25
35
  const base = invoked.split(/[\\/]/).pop() ?? '';
26
- const name = base.replace(/\.(js|cjs|mjs|ts)$/, '');
27
- return name === 'wa' || name === 'wa-mcp' ? 'wa' : 'rcs';
36
+ return base.replace(/\.(js|cjs|mjs|ts)$/, '');
28
37
  }
29
38
  /**
30
- * The package's own version, read at runtime rather than restated in a
31
- * constant. A hardcoded copy silently goes stale the first time anyone bumps
32
- * for a release, and both skins show this string to a user. From dist/ and from
33
- * src/ alike the package root is one level up.
39
+ * Every bin basename the two skins ship, as it appears in argv[1]. The WhatsApp
40
+ * skin's bins are named files (`bin/wa-mcp.js`); the RCS skin's are this
41
+ * package's own build outputs, which npm resolves to `dist/mcp.js` / `dist/cli.js`
42
+ * — hence "mcp" and "cli" rather than "rcs-mcp" and "rcs". Anything not in this
43
+ * set is not one of ours, and is never trusted to locate a package.
34
44
  */
35
- function readVersion() {
45
+ const OWN_BINS = new Set(['wa', 'wa-mcp', 'rcs', 'rcs-mcp', 'mcp', 'cli']);
46
+ /** The `version` of the package.json in `dir`, or undefined if unreadable. */
47
+ function packageVersionAt(dir) {
36
48
  try {
37
- const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8'));
38
- return typeof pkg.version === 'string' ? pkg.version : '0.0.0';
49
+ const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, 'package.json'), 'utf8'));
50
+ return typeof pkg.version === 'string' ? pkg.version : undefined;
39
51
  }
40
52
  catch {
41
- return '0.0.0';
53
+ return undefined;
54
+ }
55
+ }
56
+ /**
57
+ * The version of the package the user actually installed, read at runtime rather
58
+ * than restated in a constant. A hardcoded copy silently goes stale the first
59
+ * time anyone bumps for a release, and both skins show this string to a user —
60
+ * as `serverInfo.version` over MCP and in the CLI's usage banner.
61
+ *
62
+ * It resolves from the INVOKED BIN, not from `__dirname`, because the two skins
63
+ * are two npm packages: `wa-mcp` lives in @wa-campaigns/agent-toolkit, which
64
+ * delegates to this file inside @rcs-campaigns/agent-toolkit. `__dirname` alone
65
+ * therefore always reports the CORE's number, so a user who installed
66
+ * @wa-campaigns/agent-toolkit\@0.1.7 was told 0.1.6 — true of the code, but not
67
+ * of the thing they installed, and not a version they could go and fetch.
68
+ *
69
+ * Only the bin names we ship are trusted to locate a package (a test runner or a
70
+ * bundler entry would otherwise point at ITS package.json); everything else, and
71
+ * every library import, falls back to this package — the previous behaviour. For
72
+ * both layouts the package root is one level up from the bin: `bin/wa-mcp.js`
73
+ * and `dist/mcp.js` alike.
74
+ */
75
+ function readVersion(argv = process.argv) {
76
+ const invoked = argv[1];
77
+ if (typeof invoked === 'string' && OWN_BINS.has(invokedBinName(argv))) {
78
+ const own = packageVersionAt((0, node_path_1.join)((0, node_path_1.dirname)(invoked), '..'));
79
+ if (own)
80
+ return own;
42
81
  }
82
+ return packageVersionAt((0, node_path_1.join)(__dirname, '..')) ?? '0.0.0';
43
83
  }
44
84
  /** Human-readable product + channel names for the running skin. */
45
85
  function skinLabels(skin = detectSkin()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcs-campaigns/agent-toolkit",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "mcpName": "com.rcs-campaigns/campaigns",
5
5
  "description": "Agent skins for the RCS Campaigns gateway: an MCP server (rcs-mcp / wa-mcp) and a CLI (rcs / wa) over one shared client.",
6
6
  "license": "UNLICENSED",