@metronome/mcp 3.0.0 → 3.4.1

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 (137) hide show
  1. package/README.md +3 -3
  2. package/auth.d.mts +6 -0
  3. package/auth.d.mts.map +1 -0
  4. package/auth.d.ts +6 -0
  5. package/auth.d.ts.map +1 -0
  6. package/auth.js +37 -0
  7. package/auth.js.map +1 -0
  8. package/{headers.js → auth.mjs} +16 -6
  9. package/auth.mjs.map +1 -0
  10. package/code-tool-paths.cjs +6 -0
  11. package/code-tool-paths.cjs.map +1 -0
  12. package/code-tool-paths.d.cts +2 -0
  13. package/code-tool-paths.d.cts.map +1 -0
  14. package/code-tool-types.d.mts.map +1 -1
  15. package/code-tool-types.d.ts.map +1 -1
  16. package/code-tool-worker.d.mts +5 -0
  17. package/code-tool-worker.d.mts.map +1 -0
  18. package/code-tool-worker.d.ts +5 -0
  19. package/code-tool-worker.d.ts.map +1 -0
  20. package/code-tool-worker.js +341 -0
  21. package/code-tool-worker.js.map +1 -0
  22. package/code-tool-worker.mjs +336 -0
  23. package/code-tool-worker.mjs.map +1 -0
  24. package/code-tool.d.mts +11 -2
  25. package/code-tool.d.mts.map +1 -1
  26. package/code-tool.d.ts +11 -2
  27. package/code-tool.d.ts.map +1 -1
  28. package/code-tool.js +277 -41
  29. package/code-tool.js.map +1 -1
  30. package/code-tool.mjs +242 -42
  31. package/code-tool.mjs.map +1 -1
  32. package/docs-search-tool.d.mts +9 -3
  33. package/docs-search-tool.d.mts.map +1 -1
  34. package/docs-search-tool.d.ts +9 -3
  35. package/docs-search-tool.d.ts.map +1 -1
  36. package/docs-search-tool.js +28 -5
  37. package/docs-search-tool.js.map +1 -1
  38. package/docs-search-tool.mjs +28 -5
  39. package/docs-search-tool.mjs.map +1 -1
  40. package/http.d.mts +6 -3
  41. package/http.d.mts.map +1 -1
  42. package/http.d.ts +6 -3
  43. package/http.d.ts.map +1 -1
  44. package/http.js +70 -30
  45. package/http.js.map +1 -1
  46. package/http.mjs +70 -30
  47. package/http.mjs.map +1 -1
  48. package/index.js +17 -12
  49. package/index.js.map +1 -1
  50. package/index.mjs +17 -12
  51. package/index.mjs.map +1 -1
  52. package/instructions.d.mts +2 -0
  53. package/instructions.d.mts.map +1 -0
  54. package/instructions.d.ts +2 -0
  55. package/instructions.d.ts.map +1 -0
  56. package/instructions.js +46 -0
  57. package/instructions.js.map +1 -0
  58. package/instructions.mjs +43 -0
  59. package/instructions.mjs.map +1 -0
  60. package/logger.d.mts +7 -0
  61. package/logger.d.mts.map +1 -0
  62. package/logger.d.ts +7 -0
  63. package/logger.d.ts.map +1 -0
  64. package/logger.js +29 -0
  65. package/logger.js.map +1 -0
  66. package/logger.mjs +22 -0
  67. package/logger.mjs.map +1 -0
  68. package/methods.d.mts +10 -0
  69. package/methods.d.mts.map +1 -0
  70. package/methods.d.ts +10 -0
  71. package/methods.d.ts.map +1 -0
  72. package/methods.js +767 -0
  73. package/methods.js.map +1 -0
  74. package/methods.mjs +763 -0
  75. package/methods.mjs.map +1 -0
  76. package/options.d.mts +9 -0
  77. package/options.d.mts.map +1 -1
  78. package/options.d.ts +9 -0
  79. package/options.d.ts.map +1 -1
  80. package/options.js +62 -12
  81. package/options.js.map +1 -1
  82. package/options.mjs +62 -12
  83. package/options.mjs.map +1 -1
  84. package/package.json +78 -15
  85. package/server.d.mts +9 -10
  86. package/server.d.mts.map +1 -1
  87. package/server.d.ts +9 -10
  88. package/server.d.ts.map +1 -1
  89. package/server.js +79 -42
  90. package/server.js.map +1 -1
  91. package/server.mjs +78 -39
  92. package/server.mjs.map +1 -1
  93. package/src/{headers.ts → auth.ts} +18 -1
  94. package/src/code-tool-paths.cts +3 -0
  95. package/src/code-tool-types.ts +1 -0
  96. package/src/code-tool-worker.ts +387 -0
  97. package/src/code-tool.ts +326 -49
  98. package/src/docs-search-tool.ts +48 -7
  99. package/src/http.ts +86 -33
  100. package/src/index.ts +19 -13
  101. package/src/instructions.ts +65 -0
  102. package/src/logger.ts +28 -0
  103. package/src/methods.ts +788 -0
  104. package/src/options.ts +81 -12
  105. package/src/server.ts +90 -49
  106. package/src/stdio.ts +6 -4
  107. package/src/types.ts +12 -4
  108. package/src/util.ts +25 -0
  109. package/stdio.d.mts +2 -1
  110. package/stdio.d.mts.map +1 -1
  111. package/stdio.d.ts +2 -1
  112. package/stdio.d.ts.map +1 -1
  113. package/stdio.js +5 -4
  114. package/stdio.js.map +1 -1
  115. package/stdio.mjs +5 -4
  116. package/stdio.mjs.map +1 -1
  117. package/types.d.mts +8 -1
  118. package/types.d.mts.map +1 -1
  119. package/types.d.ts +8 -1
  120. package/types.d.ts.map +1 -1
  121. package/types.js.map +1 -1
  122. package/types.mjs.map +1 -1
  123. package/util.d.mts +4 -0
  124. package/util.d.mts.map +1 -0
  125. package/util.d.ts +4 -0
  126. package/util.d.ts.map +1 -0
  127. package/util.js +30 -0
  128. package/util.js.map +1 -0
  129. package/util.mjs +24 -0
  130. package/util.mjs.map +1 -0
  131. package/headers.d.mts +0 -4
  132. package/headers.d.mts.map +0 -1
  133. package/headers.d.ts +0 -4
  134. package/headers.d.ts.map +0 -1
  135. package/headers.js.map +0 -1
  136. package/headers.mjs +0 -18
  137. package/headers.mjs.map +0 -1
package/README.md CHANGED
@@ -41,14 +41,14 @@ For clients with a configuration JSON, it might look something like this:
41
41
  If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
42
42
  in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
43
43
 
44
- [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJuYW1lIjoiQG1ldHJvbm9tZS9tY3AiLCJ0cmFuc3BvcnQiOiJzc2UiLCJ1cmwiOiJodHRwczovL21ldHJvbm9tZS5zdGxtY3AuY29tL3NzZSIsImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiU2V0IHlvdXIgTUVUUk9OT01FX0JFQVJFUl9UT0tFTiBoZXJlLiIsIk1FVFJPTk9NRV9XRUJIT09LX1NFQ1JFVCI6IlNldCB5b3VyIE1FVFJPTk9NRV9XRUJIT09LX1NFQ1JFVCBoZXJlLiJ9fQ)
44
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJuYW1lIjoiQG1ldHJvbm9tZS9tY3AiLCJ0cmFuc3BvcnQiOiJodHRwIiwidXJsIjoiaHR0cHM6Ly9tZXRyb25vbWUuc3RsbWNwLmNvbSIsImhlYWRlcnMiOnsieC1tZXRyb25vbWUtYmVhcmVyLXRva2VuIjoiTXkgQmVhcmVyIFRva2VuIn19)
45
45
 
46
46
  ### VS Code
47
47
 
48
48
  If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
49
49
  in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
50
50
 
51
- [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22type%22%3A%22sse%22%2C%22url%22%3A%22https%3A%2F%2Fmetronome.stlmcp.com%2Fsse%22%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22Set%20your%20METRONOME_BEARER_TOKEN%20here.%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22Set%20your%20METRONOME_WEBHOOK_SECRET%20here.%22%7D%7D)
51
+ [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmetronome.stlmcp.com%22%2C%22headers%22%3A%7B%22x-metronome-bearer-token%22%3A%22My%20Bearer%20Token%22%7D%7D)
52
52
 
53
53
  ### Claude Code
54
54
 
@@ -56,7 +56,7 @@ If you use Claude Code, you can install the MCP server by running the command be
56
56
  environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
57
57
 
58
58
  ```
59
- claude mcp add metronome_mcp_api --env METRONOME_BEARER_TOKEN="Your METRONOME_BEARER_TOKEN here." METRONOME_WEBHOOK_SECRET="Your METRONOME_WEBHOOK_SECRET here." --transport sse https://metronome.stlmcp.com/sse
59
+ claude mcp add metronome_mcp_api --header "x-metronome-bearer-token: My Bearer Token" --transport http https://metronome.stlmcp.com
60
60
  ```
61
61
 
62
62
  ## Code Mode
package/auth.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@metronome/sdk';
3
+ import { McpOptions } from "./options.mjs";
4
+ export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
5
+ export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
6
+ //# sourceMappingURL=auth.d.mts.map
package/auth.d.mts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,gBAAgB;OACvC,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
package/auth.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@metronome/sdk';
3
+ import { McpOptions } from "./options.js";
4
+ export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
5
+ export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
6
+ //# sourceMappingURL=auth.d.ts.map
package/auth.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,gBAAgB;OACvC,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
package/auth.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getStainlessApiKey = exports.parseClientAuthHeaders = void 0;
5
+ const parseClientAuthHeaders = (req, required) => {
6
+ if (req.headers.authorization) {
7
+ const scheme = req.headers.authorization.split(' ')[0];
8
+ const value = req.headers.authorization.slice(scheme.length + 1);
9
+ switch (scheme) {
10
+ case 'Bearer':
11
+ return { bearerToken: req.headers.authorization.slice('Bearer '.length) };
12
+ default:
13
+ throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
14
+ }
15
+ }
16
+ else if (required) {
17
+ throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
18
+ }
19
+ const bearerToken = Array.isArray(req.headers['x-metronome-bearer-token']) ?
20
+ req.headers['x-metronome-bearer-token'][0]
21
+ : req.headers['x-metronome-bearer-token'];
22
+ return { bearerToken };
23
+ };
24
+ exports.parseClientAuthHeaders = parseClientAuthHeaders;
25
+ const getStainlessApiKey = (req, mcpOptions) => {
26
+ // Try to get the key from the x-stainless-api-key header
27
+ const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
28
+ req.headers['x-stainless-api-key'][0]
29
+ : req.headers['x-stainless-api-key'];
30
+ if (headerKey && typeof headerKey === 'string') {
31
+ return headerKey;
32
+ }
33
+ // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
34
+ return mcpOptions.stainlessApiKey;
35
+ };
36
+ exports.getStainlessApiKey = getStainlessApiKey;
37
+ //# sourceMappingURL=auth.js.map
package/auth.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAM/E,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;QACtD,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AArBW,QAAA,sBAAsB,0BAqBjC;AAEK,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B"}
@@ -1,8 +1,5 @@
1
- "use strict";
2
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.parseAuthHeaders = void 0;
5
- const parseAuthHeaders = (req) => {
2
+ export const parseClientAuthHeaders = (req, required) => {
6
3
  if (req.headers.authorization) {
7
4
  const scheme = req.headers.authorization.split(' ')[0];
8
5
  const value = req.headers.authorization.slice(scheme.length + 1);
@@ -13,10 +10,23 @@ const parseAuthHeaders = (req) => {
13
10
  throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
14
11
  }
15
12
  }
13
+ else if (required) {
14
+ throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
15
+ }
16
16
  const bearerToken = Array.isArray(req.headers['x-metronome-bearer-token']) ?
17
17
  req.headers['x-metronome-bearer-token'][0]
18
18
  : req.headers['x-metronome-bearer-token'];
19
19
  return { bearerToken };
20
20
  };
21
- exports.parseAuthHeaders = parseAuthHeaders;
22
- //# sourceMappingURL=headers.js.map
21
+ export const getStainlessApiKey = (req, mcpOptions) => {
22
+ // Try to get the key from the x-stainless-api-key header
23
+ const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
24
+ req.headers['x-stainless-api-key'][0]
25
+ : req.headers['x-stainless-api-key'];
26
+ if (headerKey && typeof headerKey === 'string') {
27
+ return headerKey;
28
+ }
29
+ // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
30
+ return mcpOptions.stainlessApiKey;
31
+ };
32
+ //# sourceMappingURL=auth.mjs.map
package/auth.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.mjs","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAMtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;QACtD,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.workerPath = void 0;
5
+ exports.workerPath = require.resolve('./code-tool-worker.mjs');
6
+ //# sourceMappingURL=code-tool-paths.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-paths.cjs","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEzE,QAAA,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const workerPath: string;
2
+ //# sourceMappingURL=code-tool-paths.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-paths.d.cts","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA4C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,gBAAgB;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,gBAAgB;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,gBAAgB;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,gBAAgB;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ fetch: (req: Request) => Promise<Response>;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=code-tool-worker.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA4T0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ fetch: (req: Request) => Promise<Response>;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=code-tool-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA4T0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_util_1 = __importDefault(require("node:util"));
9
+ const fuse_js_1 = __importDefault(require("fuse.js"));
10
+ const typescript_1 = __importDefault(require("typescript"));
11
+ const sdk_1 = require("@metronome/sdk");
12
+ function getRunFunctionSource(code) {
13
+ const sourceFile = typescript_1.default.createSourceFile('code.ts', code, typescript_1.default.ScriptTarget.Latest, true);
14
+ const printer = typescript_1.default.createPrinter();
15
+ for (const statement of sourceFile.statements) {
16
+ // Check for top-level function declarations
17
+ if (typescript_1.default.isFunctionDeclaration(statement)) {
18
+ if (statement.name?.text === 'run') {
19
+ return {
20
+ type: 'declaration',
21
+ client: statement.parameters[0]?.name.getText(),
22
+ code: printer.printNode(typescript_1.default.EmitHint.Unspecified, statement.body, sourceFile),
23
+ };
24
+ }
25
+ }
26
+ // Check for variable declarations: const run = () => {} or const run = function() {}
27
+ if (typescript_1.default.isVariableStatement(statement)) {
28
+ for (const declaration of statement.declarationList.declarations) {
29
+ if (typescript_1.default.isIdentifier(declaration.name) &&
30
+ declaration.name.text === 'run' &&
31
+ // Check if it's initialized with a function
32
+ declaration.initializer &&
33
+ (typescript_1.default.isFunctionExpression(declaration.initializer) || typescript_1.default.isArrowFunction(declaration.initializer))) {
34
+ return {
35
+ type: 'expression',
36
+ client: declaration.initializer.parameters[0]?.name.getText(),
37
+ code: printer.printNode(typescript_1.default.EmitHint.Unspecified, declaration.initializer, sourceFile),
38
+ };
39
+ }
40
+ }
41
+ }
42
+ }
43
+ return null;
44
+ }
45
+ function getTSDiagnostics(code) {
46
+ const functionSource = getRunFunctionSource(code);
47
+ const codeWithImport = [
48
+ 'import { Metronome } from "@metronome/sdk";',
49
+ functionSource.type === 'declaration' ?
50
+ `async function run(${functionSource.client}: Metronome)`
51
+ : `const run: (${functionSource.client}: Metronome) => Promise<unknown> =`,
52
+ functionSource.code,
53
+ ].join('\n');
54
+ const sourcePath = node_path_1.default.resolve('code.ts');
55
+ const ast = typescript_1.default.createSourceFile(sourcePath, codeWithImport, typescript_1.default.ScriptTarget.Latest, true);
56
+ const options = typescript_1.default.getDefaultCompilerOptions();
57
+ options.target = typescript_1.default.ScriptTarget.Latest;
58
+ options.module = typescript_1.default.ModuleKind.NodeNext;
59
+ options.moduleResolution = typescript_1.default.ModuleResolutionKind.NodeNext;
60
+ const host = typescript_1.default.createCompilerHost(options, true);
61
+ const newHost = {
62
+ ...host,
63
+ getSourceFile: (...args) => {
64
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
65
+ return ast;
66
+ }
67
+ return host.getSourceFile(...args);
68
+ },
69
+ readFile: (...args) => {
70
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
71
+ return codeWithImport;
72
+ }
73
+ return host.readFile(...args);
74
+ },
75
+ fileExists: (...args) => {
76
+ if (node_path_1.default.resolve(args[0]) === sourcePath) {
77
+ return true;
78
+ }
79
+ return host.fileExists(...args);
80
+ },
81
+ };
82
+ const program = typescript_1.default.createProgram({
83
+ options,
84
+ rootNames: [sourcePath],
85
+ host: newHost,
86
+ });
87
+ const diagnostics = typescript_1.default.getPreEmitDiagnostics(program, ast);
88
+ return diagnostics.map((d) => {
89
+ const message = typescript_1.default.flattenDiagnosticMessageText(d.messageText, '\n');
90
+ if (!d.file || !d.start)
91
+ return `- ${message}`;
92
+ const { line: lineNumber } = typescript_1.default.getLineAndCharacterOfPosition(d.file, d.start);
93
+ const line = codeWithImport.split('\n').at(lineNumber)?.trim();
94
+ return line ? `- ${message}\n ${line}` : `- ${message}`;
95
+ });
96
+ }
97
+ const fuse = new fuse_js_1.default([
98
+ 'client.v2.contracts.edit',
99
+ 'client.v2.contracts.editCommit',
100
+ 'client.v2.contracts.editCredit',
101
+ 'client.v2.contracts.getEditHistory',
102
+ 'client.v2.contracts.list',
103
+ 'client.v2.contracts.retrieve',
104
+ 'client.v1.alerts.archive',
105
+ 'client.v1.alerts.create',
106
+ 'client.v1.plans.getDetails',
107
+ 'client.v1.plans.list',
108
+ 'client.v1.plans.listCharges',
109
+ 'client.v1.plans.listCustomers',
110
+ 'client.v1.creditGrants.create',
111
+ 'client.v1.creditGrants.edit',
112
+ 'client.v1.creditGrants.list',
113
+ 'client.v1.creditGrants.listEntries',
114
+ 'client.v1.creditGrants.void',
115
+ 'client.v1.pricingUnits.list',
116
+ 'client.v1.customers.archive',
117
+ 'client.v1.customers.archiveBillingConfigurations',
118
+ 'client.v1.customers.create',
119
+ 'client.v1.customers.list',
120
+ 'client.v1.customers.listBillableMetrics',
121
+ 'client.v1.customers.listCosts',
122
+ 'client.v1.customers.previewEvents',
123
+ 'client.v1.customers.retrieve',
124
+ 'client.v1.customers.retrieveBillingConfigurations',
125
+ 'client.v1.customers.setBillingConfigurations',
126
+ 'client.v1.customers.setIngestAliases',
127
+ 'client.v1.customers.setName',
128
+ 'client.v1.customers.updateConfig',
129
+ 'client.v1.customers.alerts.list',
130
+ 'client.v1.customers.alerts.reset',
131
+ 'client.v1.customers.alerts.retrieve',
132
+ 'client.v1.customers.plans.add',
133
+ 'client.v1.customers.plans.end',
134
+ 'client.v1.customers.plans.list',
135
+ 'client.v1.customers.plans.listPriceAdjustments',
136
+ 'client.v1.customers.invoices.addCharge',
137
+ 'client.v1.customers.invoices.list',
138
+ 'client.v1.customers.invoices.listBreakdowns',
139
+ 'client.v1.customers.invoices.retrieve',
140
+ 'client.v1.customers.invoices.retrievePdf',
141
+ 'client.v1.customers.billingConfig.create',
142
+ 'client.v1.customers.billingConfig.delete',
143
+ 'client.v1.customers.billingConfig.retrieve',
144
+ 'client.v1.customers.commits.create',
145
+ 'client.v1.customers.commits.list',
146
+ 'client.v1.customers.commits.updateEndDate',
147
+ 'client.v1.customers.credits.create',
148
+ 'client.v1.customers.credits.list',
149
+ 'client.v1.customers.credits.updateEndDate',
150
+ 'client.v1.customers.namedSchedules.retrieve',
151
+ 'client.v1.customers.namedSchedules.update',
152
+ 'client.v1.dashboards.getEmbeddableURL',
153
+ 'client.v1.usage.ingest',
154
+ 'client.v1.usage.list',
155
+ 'client.v1.usage.listWithGroups',
156
+ 'client.v1.usage.search',
157
+ 'client.v1.auditLogs.list',
158
+ 'client.v1.customFields.addKey',
159
+ 'client.v1.customFields.deleteValues',
160
+ 'client.v1.customFields.listKeys',
161
+ 'client.v1.customFields.removeKey',
162
+ 'client.v1.customFields.setValues',
163
+ 'client.v1.billableMetrics.archive',
164
+ 'client.v1.billableMetrics.create',
165
+ 'client.v1.billableMetrics.list',
166
+ 'client.v1.billableMetrics.retrieve',
167
+ 'client.v1.services.list',
168
+ 'client.v1.invoices.regenerate',
169
+ 'client.v1.invoices.void',
170
+ 'client.v1.contracts.addManualBalanceEntry',
171
+ 'client.v1.contracts.amend',
172
+ 'client.v1.contracts.archive',
173
+ 'client.v1.contracts.create',
174
+ 'client.v1.contracts.createHistoricalInvoices',
175
+ 'client.v1.contracts.getNetBalance',
176
+ 'client.v1.contracts.list',
177
+ 'client.v1.contracts.listBalances',
178
+ 'client.v1.contracts.retrieve',
179
+ 'client.v1.contracts.retrieveRateSchedule',
180
+ 'client.v1.contracts.retrieveSubscriptionQuantityHistory',
181
+ 'client.v1.contracts.scheduleProServicesInvoice',
182
+ 'client.v1.contracts.setUsageFilter',
183
+ 'client.v1.contracts.updateEndDate',
184
+ 'client.v1.contracts.products.archive',
185
+ 'client.v1.contracts.products.create',
186
+ 'client.v1.contracts.products.list',
187
+ 'client.v1.contracts.products.retrieve',
188
+ 'client.v1.contracts.products.update',
189
+ 'client.v1.contracts.rateCards.archive',
190
+ 'client.v1.contracts.rateCards.create',
191
+ 'client.v1.contracts.rateCards.list',
192
+ 'client.v1.contracts.rateCards.retrieve',
193
+ 'client.v1.contracts.rateCards.retrieveRateSchedule',
194
+ 'client.v1.contracts.rateCards.update',
195
+ 'client.v1.contracts.rateCards.productOrders.set',
196
+ 'client.v1.contracts.rateCards.productOrders.update',
197
+ 'client.v1.contracts.rateCards.rates.add',
198
+ 'client.v1.contracts.rateCards.rates.addMany',
199
+ 'client.v1.contracts.rateCards.rates.list',
200
+ 'client.v1.contracts.rateCards.namedSchedules.retrieve',
201
+ 'client.v1.contracts.rateCards.namedSchedules.update',
202
+ 'client.v1.contracts.namedSchedules.retrieve',
203
+ 'client.v1.contracts.namedSchedules.update',
204
+ 'client.v1.packages.archive',
205
+ 'client.v1.packages.create',
206
+ 'client.v1.packages.list',
207
+ 'client.v1.packages.listContractsOnPackage',
208
+ 'client.v1.packages.retrieve',
209
+ 'client.v1.payments.attempt',
210
+ 'client.v1.payments.cancel',
211
+ 'client.v1.payments.list',
212
+ 'client.v1.settings.upsertAvalaraCredentials',
213
+ 'client.v1.settings.billingProviders.create',
214
+ 'client.v1.settings.billingProviders.list',
215
+ ], { threshold: 1, shouldSort: true });
216
+ function getMethodSuggestions(fullyQualifiedMethodName) {
217
+ return fuse
218
+ .search(fullyQualifiedMethodName)
219
+ .map(({ item }) => item)
220
+ .slice(0, 5);
221
+ }
222
+ const proxyToObj = new WeakMap();
223
+ const objToProxy = new WeakMap();
224
+ function makeSdkProxy(obj, { path, isBelievedBad = false }) {
225
+ let proxy = objToProxy.get(obj);
226
+ if (!proxy) {
227
+ proxy = new Proxy(obj, {
228
+ get(target, prop, receiver) {
229
+ const propPath = [...path, String(prop)];
230
+ const value = Reflect.get(target, prop, receiver);
231
+ if (isBelievedBad || (!(prop in target) && value === undefined)) {
232
+ // If we're accessing a path that doesn't exist, it will probably eventually error.
233
+ // Let's proxy it and mark it bad so that we can control the error message.
234
+ // We proxy an empty class so that an invocation or construction attempt is possible.
235
+ return makeSdkProxy(class {
236
+ }, { path: propPath, isBelievedBad: true });
237
+ }
238
+ if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
239
+ return makeSdkProxy(value, { path: propPath, isBelievedBad });
240
+ }
241
+ return value;
242
+ },
243
+ apply(target, thisArg, args) {
244
+ if (isBelievedBad || typeof target !== 'function') {
245
+ const fullyQualifiedMethodName = path.join('.');
246
+ const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
247
+ throw new Error(`${fullyQualifiedMethodName} is not a function. Did you mean: ${suggestions.join(', ')}`);
248
+ }
249
+ return Reflect.apply(target, proxyToObj.get(thisArg) ?? thisArg, args);
250
+ },
251
+ construct(target, args, newTarget) {
252
+ if (isBelievedBad || typeof target !== 'function') {
253
+ const fullyQualifiedMethodName = path.join('.');
254
+ const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
255
+ throw new Error(`${fullyQualifiedMethodName} is not a constructor. Did you mean: ${suggestions.join(', ')}`);
256
+ }
257
+ return Reflect.construct(target, args, newTarget);
258
+ },
259
+ });
260
+ objToProxy.set(obj, proxy);
261
+ proxyToObj.set(proxy, obj);
262
+ }
263
+ return proxy;
264
+ }
265
+ function parseError(code, error) {
266
+ if (!(error instanceof Error))
267
+ return;
268
+ const message = error.name ? `${error.name}: ${error.message}` : error.message;
269
+ try {
270
+ // Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
271
+ const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
272
+ // -1 for the zero-based indexing
273
+ const line = lineNumber &&
274
+ code
275
+ .split('\n')
276
+ .at(parseInt(lineNumber, 10) - 1)
277
+ ?.trim();
278
+ return line ? `${message}\n at line ${lineNumber}\n ${line}` : message;
279
+ }
280
+ catch {
281
+ return message;
282
+ }
283
+ }
284
+ const fetch = async (req) => {
285
+ const { opts, code } = (await req.json());
286
+ const runFunctionSource = code ? getRunFunctionSource(code) : null;
287
+ if (!runFunctionSource) {
288
+ const message = code ?
289
+ 'The code is missing a top-level `run` function.'
290
+ : 'The code argument is missing. Provide one containing a top-level `run` function.';
291
+ return Response.json({
292
+ is_error: true,
293
+ result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(client) {\n // Fill this out\n}\n\`\`\``,
294
+ log_lines: [],
295
+ err_lines: [],
296
+ }, { status: 400, statusText: 'Code execution error' });
297
+ }
298
+ const diagnostics = getTSDiagnostics(code);
299
+ if (diagnostics.length > 0) {
300
+ return Response.json({
301
+ is_error: true,
302
+ result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
303
+ log_lines: [],
304
+ err_lines: [],
305
+ }, { status: 400, statusText: 'Code execution error' });
306
+ }
307
+ const client = new sdk_1.Metronome({
308
+ ...opts,
309
+ });
310
+ const log_lines = [];
311
+ const err_lines = [];
312
+ const console = {
313
+ log: (...args) => {
314
+ log_lines.push(node_util_1.default.format(...args));
315
+ },
316
+ error: (...args) => {
317
+ err_lines.push(node_util_1.default.format(...args));
318
+ },
319
+ };
320
+ try {
321
+ let run_ = async (client) => { };
322
+ eval(`${code}\nrun_ = run;`);
323
+ const result = await run_(makeSdkProxy(client, { path: ['client'] }));
324
+ return Response.json({
325
+ is_error: false,
326
+ result,
327
+ log_lines,
328
+ err_lines,
329
+ });
330
+ }
331
+ catch (e) {
332
+ return Response.json({
333
+ is_error: true,
334
+ result: parseError(code, e),
335
+ log_lines,
336
+ err_lines,
337
+ }, { status: 400, statusText: 'Code execution error' });
338
+ }
339
+ };
340
+ exports.default = { fetch };
341
+ //# sourceMappingURL=code-tool-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-worker.js","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;AAEtF,0DAA6B;AAC7B,0DAA6B;AAC7B,sDAA2B;AAC3B,4DAA4B;AAE5B,wCAA0D;AAE1D,SAAS,oBAAoB,CAAC,IAAY;IAKxC,MAAM,UAAU,GAAG,oBAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,EAAE,oBAAE,CAAC,YAAY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