@codeqr/ts-mcp 0.9.0 → 0.19.3
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/LICENSE +1 -1
- package/README.md +16 -218
- package/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +37 -0
- package/auth.js.map +1 -0
- package/{headers.mjs → auth.mjs} +16 -2
- package/auth.mjs.map +1 -0
- package/code-tool-paths.cjs +8 -0
- package/code-tool-paths.cjs.map +1 -0
- package/code-tool-paths.d.cts +2 -0
- package/code-tool-paths.d.cts.map +1 -0
- package/code-tool-types.d.mts +7 -9
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +7 -9
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool-worker.d.mts +5 -0
- package/code-tool-worker.d.mts.map +1 -0
- package/code-tool-worker.d.ts +5 -0
- package/code-tool-worker.d.ts.map +1 -0
- package/code-tool-worker.js +249 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +244 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +12 -45
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +12 -45
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +315 -27
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +282 -27
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +10 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +10 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +29 -6
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +29 -6
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +6 -3
- package/http.d.mts.map +1 -1
- package/http.d.ts +6 -3
- package/http.d.ts.map +1 -1
- package/http.js +108 -49
- package/http.js.map +1 -1
- package/http.mjs +108 -49
- package/http.mjs.map +1 -1
- package/index.js +19 -50
- package/index.js.map +1 -1
- package/index.mjs +19 -50
- package/index.mjs.map +1 -1
- package/instructions.d.mts +2 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +2 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +42 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +39 -0
- package/instructions.mjs.map +1 -0
- package/logger.d.mts +7 -0
- package/logger.d.mts.map +1 -0
- package/logger.d.ts +7 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +29 -0
- package/logger.js.map +1 -0
- package/logger.mjs +22 -0
- package/logger.mjs.map +1 -0
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +215 -0
- package/methods.js.map +1 -0
- package/methods.mjs +211 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +9 -9
- package/options.d.mts.map +1 -1
- package/options.d.ts +9 -9
- package/options.d.ts.map +1 -1
- package/options.js +54 -359
- package/options.js.map +1 -1
- package/options.mjs +54 -359
- package/options.mjs.map +1 -1
- package/package.json +83 -60
- package/server.d.mts +11 -16
- package/server.d.mts.map +1 -1
- package/server.d.ts +11 -16
- package/server.d.ts.map +1 -1
- package/server.js +86 -101
- package/server.js.map +1 -1
- package/server.mjs +85 -96
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +18 -1
- package/src/code-tool-paths.cts +5 -0
- package/src/code-tool-types.ts +8 -9
- package/src/code-tool-worker.ts +295 -0
- package/src/code-tool.ts +371 -34
- package/src/docs-search-tool.ts +48 -7
- package/src/http.ts +128 -54
- package/src/index.ts +22 -63
- package/src/instructions.ts +60 -0
- package/src/logger.ts +28 -0
- package/src/methods.ts +236 -0
- package/src/options.ts +72 -384
- package/src/server.ts +99 -116
- package/src/stdio.ts +6 -5
- package/src/{tools/types.ts → types.ts} +14 -5
- package/src/util.ts +25 -0
- package/stdio.d.mts +1 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +5 -4
- package/stdio.js.map +1 -1
- package/stdio.mjs +5 -4
- package/stdio.mjs.map +1 -1
- package/{tools/types.d.mts → types.d.mts} +10 -2
- package/types.d.mts.map +1 -0
- package/{tools/types.d.ts → types.d.ts} +10 -2
- package/types.d.ts.map +1 -0
- package/types.js.map +1 -0
- package/types.mjs.map +1 -0
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/compat.d.mts +0 -58
- package/compat.d.mts.map +0 -1
- package/compat.d.ts +0 -58
- package/compat.d.ts.map +0 -1
- package/compat.js +0 -387
- package/compat.js.map +0 -1
- package/compat.mjs +0 -378
- package/compat.mjs.map +0 -1
- package/dynamic-tools.d.mts +0 -12
- package/dynamic-tools.d.mts.map +0 -1
- package/dynamic-tools.d.ts +0 -12
- package/dynamic-tools.d.ts.map +0 -1
- package/dynamic-tools.js +0 -135
- package/dynamic-tools.js.map +0 -1
- package/dynamic-tools.mjs +0 -132
- package/dynamic-tools.mjs.map +0 -1
- package/filtering.d.mts +0 -3
- package/filtering.d.mts.map +0 -1
- package/filtering.d.ts +0 -3
- package/filtering.d.ts.map +0 -1
- package/filtering.js +0 -24
- package/filtering.js.map +0 -1
- package/filtering.mjs +0 -16
- package/filtering.mjs.map +0 -1
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js +0 -22
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
- package/src/compat.ts +0 -483
- package/src/dynamic-tools.ts +0 -153
- package/src/filtering.ts +0 -18
- package/src/tools/analytics/retrieve-analytics.ts +0 -441
- package/src/tools/domains/create-domains.ts +0 -75
- package/src/tools/domains/delete-domains.ts +0 -55
- package/src/tools/domains/list-domains.ts +0 -68
- package/src/tools/domains/update-domains.ts +0 -79
- package/src/tools/events/list-events.ts +0 -421
- package/src/tools/index.ts +0 -133
- package/src/tools/links/bulk/create-links-bulk.ts +0 -966
- package/src/tools/links/bulk/delete-links-bulk.ts +0 -59
- package/src/tools/links/count-links.ts +0 -957
- package/src/tools/links/create-links.ts +0 -957
- package/src/tools/links/delete-links.ts +0 -56
- package/src/tools/links/list-links.ts +0 -980
- package/src/tools/links/retrieve-info-links.ts +0 -75
- package/src/tools/links/update-links.ts +0 -964
- package/src/tools/links/upsert-links.ts +0 -958
- package/src/tools/projects/list-projects.ts +0 -51
- package/src/tools/projects/retrieve-projects.ts +0 -56
- package/src/tools/qrcodes/bulk/create-qrcodes-bulk.ts +0 -1077
- package/src/tools/qrcodes/bulk/delete-qrcodes-bulk.ts +0 -59
- package/src/tools/qrcodes/count-qrcodes.ts +0 -220
- package/src/tools/qrcodes/create-qrcodes.ts +0 -1067
- package/src/tools/qrcodes/delete-qrcodes.ts +0 -56
- package/src/tools/qrcodes/list-qrcodes.ts +0 -221
- package/src/tools/qrcodes/retrieve-qrcodes.ts +0 -67
- package/src/tools/qrcodes/update-qrcodes.ts +0 -1074
- package/src/tools/qrcodes/upsert-qrcodes.ts +0 -1068
- package/src/tools/tags/create-tags.ts +0 -59
- package/src/tools/tags/delete-tags.ts +0 -55
- package/src/tools/tags/list-tags.ts +0 -87
- package/src/tools/tags/update-tags.ts +0 -63
- package/src/tools/track/track-lead-track.ts +0 -93
- package/src/tools/track/track-sale-track.ts +0 -108
- package/src/tools.ts +0 -1
- package/tools/analytics/retrieve-analytics.d.mts +0 -51
- package/tools/analytics/retrieve-analytics.d.mts.map +0 -1
- package/tools/analytics/retrieve-analytics.d.ts +0 -51
- package/tools/analytics/retrieve-analytics.d.ts.map +0 -1
- package/tools/analytics/retrieve-analytics.js +0 -438
- package/tools/analytics/retrieve-analytics.js.map +0 -1
- package/tools/analytics/retrieve-analytics.mjs +0 -431
- package/tools/analytics/retrieve-analytics.mjs.map +0 -1
- package/tools/domains/create-domains.d.mts +0 -51
- package/tools/domains/create-domains.d.mts.map +0 -1
- package/tools/domains/create-domains.d.ts +0 -51
- package/tools/domains/create-domains.d.ts.map +0 -1
- package/tools/domains/create-domains.js +0 -74
- package/tools/domains/create-domains.js.map +0 -1
- package/tools/domains/create-domains.mjs +0 -67
- package/tools/domains/create-domains.mjs.map +0 -1
- package/tools/domains/delete-domains.d.mts +0 -51
- package/tools/domains/delete-domains.d.mts.map +0 -1
- package/tools/domains/delete-domains.d.ts +0 -51
- package/tools/domains/delete-domains.d.ts.map +0 -1
- package/tools/domains/delete-domains.js +0 -55
- package/tools/domains/delete-domains.js.map +0 -1
- package/tools/domains/delete-domains.mjs +0 -48
- package/tools/domains/delete-domains.mjs.map +0 -1
- package/tools/domains/list-domains.d.mts +0 -51
- package/tools/domains/list-domains.d.mts.map +0 -1
- package/tools/domains/list-domains.d.ts +0 -51
- package/tools/domains/list-domains.d.ts.map +0 -1
- package/tools/domains/list-domains.js +0 -67
- package/tools/domains/list-domains.js.map +0 -1
- package/tools/domains/list-domains.mjs +0 -60
- package/tools/domains/list-domains.mjs.map +0 -1
- package/tools/domains/update-domains.d.mts +0 -51
- package/tools/domains/update-domains.d.mts.map +0 -1
- package/tools/domains/update-domains.d.ts +0 -51
- package/tools/domains/update-domains.d.ts.map +0 -1
- package/tools/domains/update-domains.js +0 -78
- package/tools/domains/update-domains.js.map +0 -1
- package/tools/domains/update-domains.mjs +0 -71
- package/tools/domains/update-domains.mjs.map +0 -1
- package/tools/events/list-events.d.mts +0 -51
- package/tools/events/list-events.d.mts.map +0 -1
- package/tools/events/list-events.d.ts +0 -51
- package/tools/events/list-events.d.ts.map +0 -1
- package/tools/events/list-events.js +0 -418
- package/tools/events/list-events.js.map +0 -1
- package/tools/events/list-events.mjs +0 -411
- package/tools/events/list-events.mjs.map +0 -1
- package/tools/index.d.mts +0 -10
- package/tools/index.d.mts.map +0 -1
- package/tools/index.d.ts +0 -10
- package/tools/index.d.ts.map +0 -1
- package/tools/index.js +0 -117
- package/tools/index.js.map +0 -1
- package/tools/index.mjs +0 -110
- package/tools/index.mjs.map +0 -1
- package/tools/links/bulk/create-links-bulk.d.mts +0 -51
- package/tools/links/bulk/create-links-bulk.d.mts.map +0 -1
- package/tools/links/bulk/create-links-bulk.d.ts +0 -51
- package/tools/links/bulk/create-links-bulk.d.ts.map +0 -1
- package/tools/links/bulk/create-links-bulk.js +0 -956
- package/tools/links/bulk/create-links-bulk.js.map +0 -1
- package/tools/links/bulk/create-links-bulk.mjs +0 -949
- package/tools/links/bulk/create-links-bulk.mjs.map +0 -1
- package/tools/links/bulk/delete-links-bulk.d.mts +0 -51
- package/tools/links/bulk/delete-links-bulk.d.mts.map +0 -1
- package/tools/links/bulk/delete-links-bulk.d.ts +0 -51
- package/tools/links/bulk/delete-links-bulk.d.ts.map +0 -1
- package/tools/links/bulk/delete-links-bulk.js +0 -58
- package/tools/links/bulk/delete-links-bulk.js.map +0 -1
- package/tools/links/bulk/delete-links-bulk.mjs +0 -51
- package/tools/links/bulk/delete-links-bulk.mjs.map +0 -1
- package/tools/links/count-links.d.mts +0 -51
- package/tools/links/count-links.d.mts.map +0 -1
- package/tools/links/count-links.d.ts +0 -51
- package/tools/links/count-links.d.ts.map +0 -1
- package/tools/links/count-links.js +0 -951
- package/tools/links/count-links.js.map +0 -1
- package/tools/links/count-links.mjs +0 -944
- package/tools/links/count-links.mjs.map +0 -1
- package/tools/links/create-links.d.mts +0 -51
- package/tools/links/create-links.d.mts.map +0 -1
- package/tools/links/create-links.d.ts +0 -51
- package/tools/links/create-links.d.ts.map +0 -1
- package/tools/links/create-links.js +0 -947
- package/tools/links/create-links.js.map +0 -1
- package/tools/links/create-links.mjs +0 -940
- package/tools/links/create-links.mjs.map +0 -1
- package/tools/links/delete-links.d.mts +0 -51
- package/tools/links/delete-links.d.mts.map +0 -1
- package/tools/links/delete-links.d.ts +0 -51
- package/tools/links/delete-links.d.ts.map +0 -1
- package/tools/links/delete-links.js +0 -55
- package/tools/links/delete-links.js.map +0 -1
- package/tools/links/delete-links.mjs +0 -48
- package/tools/links/delete-links.mjs.map +0 -1
- package/tools/links/list-links.d.mts +0 -51
- package/tools/links/list-links.d.mts.map +0 -1
- package/tools/links/list-links.d.ts +0 -51
- package/tools/links/list-links.d.ts.map +0 -1
- package/tools/links/list-links.js +0 -973
- package/tools/links/list-links.js.map +0 -1
- package/tools/links/list-links.mjs +0 -966
- package/tools/links/list-links.mjs.map +0 -1
- package/tools/links/retrieve-info-links.d.mts +0 -51
- package/tools/links/retrieve-info-links.d.mts.map +0 -1
- package/tools/links/retrieve-info-links.d.ts +0 -51
- package/tools/links/retrieve-info-links.d.ts.map +0 -1
- package/tools/links/retrieve-info-links.js +0 -71
- package/tools/links/retrieve-info-links.js.map +0 -1
- package/tools/links/retrieve-info-links.mjs +0 -64
- package/tools/links/retrieve-info-links.mjs.map +0 -1
- package/tools/links/update-links.d.mts +0 -51
- package/tools/links/update-links.d.mts.map +0 -1
- package/tools/links/update-links.d.ts +0 -51
- package/tools/links/update-links.d.ts.map +0 -1
- package/tools/links/update-links.js +0 -953
- package/tools/links/update-links.js.map +0 -1
- package/tools/links/update-links.mjs +0 -946
- package/tools/links/update-links.mjs.map +0 -1
- package/tools/links/upsert-links.d.mts +0 -51
- package/tools/links/upsert-links.d.mts.map +0 -1
- package/tools/links/upsert-links.d.ts +0 -51
- package/tools/links/upsert-links.d.ts.map +0 -1
- package/tools/links/upsert-links.js +0 -947
- package/tools/links/upsert-links.js.map +0 -1
- package/tools/links/upsert-links.mjs +0 -940
- package/tools/links/upsert-links.mjs.map +0 -1
- package/tools/projects/list-projects.d.mts +0 -51
- package/tools/projects/list-projects.d.mts.map +0 -1
- package/tools/projects/list-projects.d.ts +0 -51
- package/tools/projects/list-projects.d.ts.map +0 -1
- package/tools/projects/list-projects.js +0 -51
- package/tools/projects/list-projects.js.map +0 -1
- package/tools/projects/list-projects.mjs +0 -44
- package/tools/projects/list-projects.mjs.map +0 -1
- package/tools/projects/retrieve-projects.d.mts +0 -51
- package/tools/projects/retrieve-projects.d.mts.map +0 -1
- package/tools/projects/retrieve-projects.d.ts +0 -51
- package/tools/projects/retrieve-projects.d.ts.map +0 -1
- package/tools/projects/retrieve-projects.js +0 -55
- package/tools/projects/retrieve-projects.js.map +0 -1
- package/tools/projects/retrieve-projects.mjs +0 -48
- package/tools/projects/retrieve-projects.mjs.map +0 -1
- package/tools/qrcodes/bulk/create-qrcodes-bulk.d.mts +0 -51
- package/tools/qrcodes/bulk/create-qrcodes-bulk.d.mts.map +0 -1
- package/tools/qrcodes/bulk/create-qrcodes-bulk.d.ts +0 -51
- package/tools/qrcodes/bulk/create-qrcodes-bulk.d.ts.map +0 -1
- package/tools/qrcodes/bulk/create-qrcodes-bulk.js +0 -1068
- package/tools/qrcodes/bulk/create-qrcodes-bulk.js.map +0 -1
- package/tools/qrcodes/bulk/create-qrcodes-bulk.mjs +0 -1061
- package/tools/qrcodes/bulk/create-qrcodes-bulk.mjs.map +0 -1
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.d.mts +0 -51
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.d.mts.map +0 -1
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.d.ts +0 -51
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.d.ts.map +0 -1
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.js +0 -58
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.js.map +0 -1
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.mjs +0 -51
- package/tools/qrcodes/bulk/delete-qrcodes-bulk.mjs.map +0 -1
- package/tools/qrcodes/count-qrcodes.d.mts +0 -51
- package/tools/qrcodes/count-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/count-qrcodes.d.ts +0 -51
- package/tools/qrcodes/count-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/count-qrcodes.js +0 -215
- package/tools/qrcodes/count-qrcodes.js.map +0 -1
- package/tools/qrcodes/count-qrcodes.mjs +0 -208
- package/tools/qrcodes/count-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/create-qrcodes.d.mts +0 -51
- package/tools/qrcodes/create-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/create-qrcodes.d.ts +0 -51
- package/tools/qrcodes/create-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/create-qrcodes.js +0 -1059
- package/tools/qrcodes/create-qrcodes.js.map +0 -1
- package/tools/qrcodes/create-qrcodes.mjs +0 -1052
- package/tools/qrcodes/create-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/delete-qrcodes.d.mts +0 -51
- package/tools/qrcodes/delete-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/delete-qrcodes.d.ts +0 -51
- package/tools/qrcodes/delete-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/delete-qrcodes.js +0 -55
- package/tools/qrcodes/delete-qrcodes.js.map +0 -1
- package/tools/qrcodes/delete-qrcodes.mjs +0 -48
- package/tools/qrcodes/delete-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/list-qrcodes.d.mts +0 -51
- package/tools/qrcodes/list-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/list-qrcodes.d.ts +0 -51
- package/tools/qrcodes/list-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/list-qrcodes.js +0 -217
- package/tools/qrcodes/list-qrcodes.js.map +0 -1
- package/tools/qrcodes/list-qrcodes.mjs +0 -210
- package/tools/qrcodes/list-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/retrieve-qrcodes.d.mts +0 -51
- package/tools/qrcodes/retrieve-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/retrieve-qrcodes.d.ts +0 -51
- package/tools/qrcodes/retrieve-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/retrieve-qrcodes.js +0 -65
- package/tools/qrcodes/retrieve-qrcodes.js.map +0 -1
- package/tools/qrcodes/retrieve-qrcodes.mjs +0 -58
- package/tools/qrcodes/retrieve-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/update-qrcodes.d.mts +0 -51
- package/tools/qrcodes/update-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/update-qrcodes.d.ts +0 -51
- package/tools/qrcodes/update-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/update-qrcodes.js +0 -1065
- package/tools/qrcodes/update-qrcodes.js.map +0 -1
- package/tools/qrcodes/update-qrcodes.mjs +0 -1058
- package/tools/qrcodes/update-qrcodes.mjs.map +0 -1
- package/tools/qrcodes/upsert-qrcodes.d.mts +0 -51
- package/tools/qrcodes/upsert-qrcodes.d.mts.map +0 -1
- package/tools/qrcodes/upsert-qrcodes.d.ts +0 -51
- package/tools/qrcodes/upsert-qrcodes.d.ts.map +0 -1
- package/tools/qrcodes/upsert-qrcodes.js +0 -1059
- package/tools/qrcodes/upsert-qrcodes.js.map +0 -1
- package/tools/qrcodes/upsert-qrcodes.mjs +0 -1052
- package/tools/qrcodes/upsert-qrcodes.mjs.map +0 -1
- package/tools/tags/create-tags.d.mts +0 -51
- package/tools/tags/create-tags.d.mts.map +0 -1
- package/tools/tags/create-tags.d.ts +0 -51
- package/tools/tags/create-tags.d.ts.map +0 -1
- package/tools/tags/create-tags.js +0 -58
- package/tools/tags/create-tags.js.map +0 -1
- package/tools/tags/create-tags.mjs +0 -51
- package/tools/tags/create-tags.mjs.map +0 -1
- package/tools/tags/delete-tags.d.mts +0 -51
- package/tools/tags/delete-tags.d.mts.map +0 -1
- package/tools/tags/delete-tags.d.ts +0 -51
- package/tools/tags/delete-tags.d.ts.map +0 -1
- package/tools/tags/delete-tags.js +0 -55
- package/tools/tags/delete-tags.js.map +0 -1
- package/tools/tags/delete-tags.mjs +0 -48
- package/tools/tags/delete-tags.mjs.map +0 -1
- package/tools/tags/list-tags.d.mts +0 -51
- package/tools/tags/list-tags.d.mts.map +0 -1
- package/tools/tags/list-tags.d.ts +0 -51
- package/tools/tags/list-tags.d.ts.map +0 -1
- package/tools/tags/list-tags.js +0 -87
- package/tools/tags/list-tags.js.map +0 -1
- package/tools/tags/list-tags.mjs +0 -80
- package/tools/tags/list-tags.mjs.map +0 -1
- package/tools/tags/update-tags.d.mts +0 -51
- package/tools/tags/update-tags.d.mts.map +0 -1
- package/tools/tags/update-tags.d.ts +0 -51
- package/tools/tags/update-tags.d.ts.map +0 -1
- package/tools/tags/update-tags.js +0 -63
- package/tools/tags/update-tags.js.map +0 -1
- package/tools/tags/update-tags.mjs +0 -56
- package/tools/tags/update-tags.mjs.map +0 -1
- package/tools/track/track-lead-track.d.mts +0 -51
- package/tools/track/track-lead-track.d.mts.map +0 -1
- package/tools/track/track-lead-track.d.ts +0 -51
- package/tools/track/track-lead-track.d.ts.map +0 -1
- package/tools/track/track-lead-track.js +0 -87
- package/tools/track/track-lead-track.js.map +0 -1
- package/tools/track/track-lead-track.mjs +0 -80
- package/tools/track/track-lead-track.mjs.map +0 -1
- package/tools/track/track-sale-track.d.mts +0 -51
- package/tools/track/track-sale-track.d.mts.map +0 -1
- package/tools/track/track-sale-track.d.ts +0 -51
- package/tools/track/track-sale-track.d.ts.map +0 -1
- package/tools/track/track-sale-track.js +0 -99
- package/tools/track/track-sale-track.js.map +0 -1
- package/tools/track/track-sale-track.mjs +0 -92
- package/tools/track/track-sale-track.mjs.map +0 -1
- package/tools/types.d.mts.map +0 -1
- package/tools/types.d.ts.map +0 -1
- package/tools/types.js.map +0 -1
- package/tools/types.mjs.map +0 -1
- package/tools.d.mts +0 -2
- package/tools.d.mts.map +0 -1
- package/tools.d.ts +0 -2
- package/tools.d.ts.map +0 -1
- package/tools.js +0 -18
- package/tools.js.map +0 -1
- package/tools.mjs +0 -2
- package/tools.mjs.map +0 -1
- /package/{tools/types.js → types.js} +0 -0
- /package/{tools/types.mjs → types.mjs} +0 -0
|
@@ -0,0 +1,249 @@
|
|
|
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 ts_1 = require("@codeqr/ts");
|
|
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 { Codeqr } from "@codeqr/ts";',
|
|
49
|
+
functionSource.type === 'declaration' ?
|
|
50
|
+
`async function run(${functionSource.client}: Codeqr)`
|
|
51
|
+
: `const run: (${functionSource.client}: Codeqr) => 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.links.create',
|
|
99
|
+
'client.links.delete',
|
|
100
|
+
'client.links.list',
|
|
101
|
+
'client.links.retrieveInfo',
|
|
102
|
+
'client.links.update',
|
|
103
|
+
'client.links.bulk.create',
|
|
104
|
+
'client.qrcodes.create',
|
|
105
|
+
'client.qrcodes.delete',
|
|
106
|
+
'client.qrcodes.list',
|
|
107
|
+
'client.qrcodes.retrieve',
|
|
108
|
+
'client.qrcodes.update',
|
|
109
|
+
'client.qrcodes.bulk.create',
|
|
110
|
+
'client.analytics.retrieve',
|
|
111
|
+
'client.events.list',
|
|
112
|
+
'client.tags.create',
|
|
113
|
+
'client.tags.delete',
|
|
114
|
+
'client.tags.list',
|
|
115
|
+
'client.tags.update',
|
|
116
|
+
'client.domains.create',
|
|
117
|
+
'client.domains.delete',
|
|
118
|
+
'client.domains.list',
|
|
119
|
+
'client.domains.update',
|
|
120
|
+
'client.track.trackLead',
|
|
121
|
+
'client.track.trackSale',
|
|
122
|
+
'client.projects.list',
|
|
123
|
+
], { threshold: 1, shouldSort: true });
|
|
124
|
+
function getMethodSuggestions(fullyQualifiedMethodName) {
|
|
125
|
+
return fuse
|
|
126
|
+
.search(fullyQualifiedMethodName)
|
|
127
|
+
.map(({ item }) => item)
|
|
128
|
+
.slice(0, 5);
|
|
129
|
+
}
|
|
130
|
+
const proxyToObj = new WeakMap();
|
|
131
|
+
const objToProxy = new WeakMap();
|
|
132
|
+
function makeSdkProxy(obj, { path, isBelievedBad = false }) {
|
|
133
|
+
let proxy = objToProxy.get(obj);
|
|
134
|
+
if (!proxy) {
|
|
135
|
+
proxy = new Proxy(obj, {
|
|
136
|
+
get(target, prop, receiver) {
|
|
137
|
+
const propPath = [...path, String(prop)];
|
|
138
|
+
const value = Reflect.get(target, prop, receiver);
|
|
139
|
+
if (isBelievedBad || (!(prop in target) && value === undefined)) {
|
|
140
|
+
// If we're accessing a path that doesn't exist, it will probably eventually error.
|
|
141
|
+
// Let's proxy it and mark it bad so that we can control the error message.
|
|
142
|
+
// We proxy an empty class so that an invocation or construction attempt is possible.
|
|
143
|
+
return makeSdkProxy(class {
|
|
144
|
+
}, { path: propPath, isBelievedBad: true });
|
|
145
|
+
}
|
|
146
|
+
if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
|
|
147
|
+
return makeSdkProxy(value, { path: propPath, isBelievedBad });
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
},
|
|
151
|
+
apply(target, thisArg, args) {
|
|
152
|
+
if (isBelievedBad || typeof target !== 'function') {
|
|
153
|
+
const fullyQualifiedMethodName = path.join('.');
|
|
154
|
+
const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
|
|
155
|
+
throw new Error(`${fullyQualifiedMethodName} is not a function. Did you mean: ${suggestions.join(', ')}`);
|
|
156
|
+
}
|
|
157
|
+
return Reflect.apply(target, proxyToObj.get(thisArg) ?? thisArg, args);
|
|
158
|
+
},
|
|
159
|
+
construct(target, args, newTarget) {
|
|
160
|
+
if (isBelievedBad || typeof target !== 'function') {
|
|
161
|
+
const fullyQualifiedMethodName = path.join('.');
|
|
162
|
+
const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
|
|
163
|
+
throw new Error(`${fullyQualifiedMethodName} is not a constructor. Did you mean: ${suggestions.join(', ')}`);
|
|
164
|
+
}
|
|
165
|
+
return Reflect.construct(target, args, newTarget);
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
objToProxy.set(obj, proxy);
|
|
169
|
+
proxyToObj.set(proxy, obj);
|
|
170
|
+
}
|
|
171
|
+
return proxy;
|
|
172
|
+
}
|
|
173
|
+
function parseError(code, error) {
|
|
174
|
+
if (!(error instanceof Error))
|
|
175
|
+
return;
|
|
176
|
+
const message = error.name ? `${error.name}: ${error.message}` : error.message;
|
|
177
|
+
try {
|
|
178
|
+
// Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
|
|
179
|
+
const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
|
|
180
|
+
// -1 for the zero-based indexing
|
|
181
|
+
const line = lineNumber &&
|
|
182
|
+
code
|
|
183
|
+
.split('\n')
|
|
184
|
+
.at(parseInt(lineNumber, 10) - 1)
|
|
185
|
+
?.trim();
|
|
186
|
+
return line ? `${message}\n at line ${lineNumber}\n ${line}` : message;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return message;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const fetch = async (req) => {
|
|
193
|
+
const { opts, code } = (await req.json());
|
|
194
|
+
const runFunctionSource = code ? getRunFunctionSource(code) : null;
|
|
195
|
+
if (!runFunctionSource) {
|
|
196
|
+
const message = code ?
|
|
197
|
+
'The code is missing a top-level `run` function.'
|
|
198
|
+
: 'The code argument is missing. Provide one containing a top-level `run` function.';
|
|
199
|
+
return Response.json({
|
|
200
|
+
is_error: true,
|
|
201
|
+
result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(client) {\n // Fill this out\n}\n\`\`\``,
|
|
202
|
+
log_lines: [],
|
|
203
|
+
err_lines: [],
|
|
204
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
205
|
+
}
|
|
206
|
+
const diagnostics = getTSDiagnostics(code);
|
|
207
|
+
if (diagnostics.length > 0) {
|
|
208
|
+
return Response.json({
|
|
209
|
+
is_error: true,
|
|
210
|
+
result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
|
|
211
|
+
log_lines: [],
|
|
212
|
+
err_lines: [],
|
|
213
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
214
|
+
}
|
|
215
|
+
const client = new ts_1.Codeqr({
|
|
216
|
+
...opts,
|
|
217
|
+
});
|
|
218
|
+
const log_lines = [];
|
|
219
|
+
const err_lines = [];
|
|
220
|
+
const console = {
|
|
221
|
+
log: (...args) => {
|
|
222
|
+
log_lines.push(node_util_1.default.format(...args));
|
|
223
|
+
},
|
|
224
|
+
error: (...args) => {
|
|
225
|
+
err_lines.push(node_util_1.default.format(...args));
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
try {
|
|
229
|
+
let run_ = async (client) => { };
|
|
230
|
+
eval(`${code}\nrun_ = run;`);
|
|
231
|
+
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
|
|
232
|
+
return Response.json({
|
|
233
|
+
is_error: false,
|
|
234
|
+
result,
|
|
235
|
+
log_lines,
|
|
236
|
+
err_lines,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
return Response.json({
|
|
241
|
+
is_error: true,
|
|
242
|
+
result: parseError(code, e),
|
|
243
|
+
log_lines,
|
|
244
|
+
err_lines,
|
|
245
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
exports.default = { fetch };
|
|
249
|
+
//# 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,0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AAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import util from 'node:util';
|
|
4
|
+
import Fuse from 'fuse.js';
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { Codeqr } from '@codeqr/ts';
|
|
7
|
+
function getRunFunctionSource(code) {
|
|
8
|
+
const sourceFile = ts.createSourceFile('code.ts', code, ts.ScriptTarget.Latest, true);
|
|
9
|
+
const printer = ts.createPrinter();
|
|
10
|
+
for (const statement of sourceFile.statements) {
|
|
11
|
+
// Check for top-level function declarations
|
|
12
|
+
if (ts.isFunctionDeclaration(statement)) {
|
|
13
|
+
if (statement.name?.text === 'run') {
|
|
14
|
+
return {
|
|
15
|
+
type: 'declaration',
|
|
16
|
+
client: statement.parameters[0]?.name.getText(),
|
|
17
|
+
code: printer.printNode(ts.EmitHint.Unspecified, statement.body, sourceFile),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Check for variable declarations: const run = () => {} or const run = function() {}
|
|
22
|
+
if (ts.isVariableStatement(statement)) {
|
|
23
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
24
|
+
if (ts.isIdentifier(declaration.name) &&
|
|
25
|
+
declaration.name.text === 'run' &&
|
|
26
|
+
// Check if it's initialized with a function
|
|
27
|
+
declaration.initializer &&
|
|
28
|
+
(ts.isFunctionExpression(declaration.initializer) || ts.isArrowFunction(declaration.initializer))) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'expression',
|
|
31
|
+
client: declaration.initializer.parameters[0]?.name.getText(),
|
|
32
|
+
code: printer.printNode(ts.EmitHint.Unspecified, declaration.initializer, sourceFile),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function getTSDiagnostics(code) {
|
|
41
|
+
const functionSource = getRunFunctionSource(code);
|
|
42
|
+
const codeWithImport = [
|
|
43
|
+
'import { Codeqr } from "@codeqr/ts";',
|
|
44
|
+
functionSource.type === 'declaration' ?
|
|
45
|
+
`async function run(${functionSource.client}: Codeqr)`
|
|
46
|
+
: `const run: (${functionSource.client}: Codeqr) => Promise<unknown> =`,
|
|
47
|
+
functionSource.code,
|
|
48
|
+
].join('\n');
|
|
49
|
+
const sourcePath = path.resolve('code.ts');
|
|
50
|
+
const ast = ts.createSourceFile(sourcePath, codeWithImport, ts.ScriptTarget.Latest, true);
|
|
51
|
+
const options = ts.getDefaultCompilerOptions();
|
|
52
|
+
options.target = ts.ScriptTarget.Latest;
|
|
53
|
+
options.module = ts.ModuleKind.NodeNext;
|
|
54
|
+
options.moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
55
|
+
const host = ts.createCompilerHost(options, true);
|
|
56
|
+
const newHost = {
|
|
57
|
+
...host,
|
|
58
|
+
getSourceFile: (...args) => {
|
|
59
|
+
if (path.resolve(args[0]) === sourcePath) {
|
|
60
|
+
return ast;
|
|
61
|
+
}
|
|
62
|
+
return host.getSourceFile(...args);
|
|
63
|
+
},
|
|
64
|
+
readFile: (...args) => {
|
|
65
|
+
if (path.resolve(args[0]) === sourcePath) {
|
|
66
|
+
return codeWithImport;
|
|
67
|
+
}
|
|
68
|
+
return host.readFile(...args);
|
|
69
|
+
},
|
|
70
|
+
fileExists: (...args) => {
|
|
71
|
+
if (path.resolve(args[0]) === sourcePath) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return host.fileExists(...args);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const program = ts.createProgram({
|
|
78
|
+
options,
|
|
79
|
+
rootNames: [sourcePath],
|
|
80
|
+
host: newHost,
|
|
81
|
+
});
|
|
82
|
+
const diagnostics = ts.getPreEmitDiagnostics(program, ast);
|
|
83
|
+
return diagnostics.map((d) => {
|
|
84
|
+
const message = ts.flattenDiagnosticMessageText(d.messageText, '\n');
|
|
85
|
+
if (!d.file || !d.start)
|
|
86
|
+
return `- ${message}`;
|
|
87
|
+
const { line: lineNumber } = ts.getLineAndCharacterOfPosition(d.file, d.start);
|
|
88
|
+
const line = codeWithImport.split('\n').at(lineNumber)?.trim();
|
|
89
|
+
return line ? `- ${message}\n ${line}` : `- ${message}`;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const fuse = new Fuse([
|
|
93
|
+
'client.links.create',
|
|
94
|
+
'client.links.delete',
|
|
95
|
+
'client.links.list',
|
|
96
|
+
'client.links.retrieveInfo',
|
|
97
|
+
'client.links.update',
|
|
98
|
+
'client.links.bulk.create',
|
|
99
|
+
'client.qrcodes.create',
|
|
100
|
+
'client.qrcodes.delete',
|
|
101
|
+
'client.qrcodes.list',
|
|
102
|
+
'client.qrcodes.retrieve',
|
|
103
|
+
'client.qrcodes.update',
|
|
104
|
+
'client.qrcodes.bulk.create',
|
|
105
|
+
'client.analytics.retrieve',
|
|
106
|
+
'client.events.list',
|
|
107
|
+
'client.tags.create',
|
|
108
|
+
'client.tags.delete',
|
|
109
|
+
'client.tags.list',
|
|
110
|
+
'client.tags.update',
|
|
111
|
+
'client.domains.create',
|
|
112
|
+
'client.domains.delete',
|
|
113
|
+
'client.domains.list',
|
|
114
|
+
'client.domains.update',
|
|
115
|
+
'client.track.trackLead',
|
|
116
|
+
'client.track.trackSale',
|
|
117
|
+
'client.projects.list',
|
|
118
|
+
], { threshold: 1, shouldSort: true });
|
|
119
|
+
function getMethodSuggestions(fullyQualifiedMethodName) {
|
|
120
|
+
return fuse
|
|
121
|
+
.search(fullyQualifiedMethodName)
|
|
122
|
+
.map(({ item }) => item)
|
|
123
|
+
.slice(0, 5);
|
|
124
|
+
}
|
|
125
|
+
const proxyToObj = new WeakMap();
|
|
126
|
+
const objToProxy = new WeakMap();
|
|
127
|
+
function makeSdkProxy(obj, { path, isBelievedBad = false }) {
|
|
128
|
+
let proxy = objToProxy.get(obj);
|
|
129
|
+
if (!proxy) {
|
|
130
|
+
proxy = new Proxy(obj, {
|
|
131
|
+
get(target, prop, receiver) {
|
|
132
|
+
const propPath = [...path, String(prop)];
|
|
133
|
+
const value = Reflect.get(target, prop, receiver);
|
|
134
|
+
if (isBelievedBad || (!(prop in target) && value === undefined)) {
|
|
135
|
+
// If we're accessing a path that doesn't exist, it will probably eventually error.
|
|
136
|
+
// Let's proxy it and mark it bad so that we can control the error message.
|
|
137
|
+
// We proxy an empty class so that an invocation or construction attempt is possible.
|
|
138
|
+
return makeSdkProxy(class {
|
|
139
|
+
}, { path: propPath, isBelievedBad: true });
|
|
140
|
+
}
|
|
141
|
+
if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
|
|
142
|
+
return makeSdkProxy(value, { path: propPath, isBelievedBad });
|
|
143
|
+
}
|
|
144
|
+
return value;
|
|
145
|
+
},
|
|
146
|
+
apply(target, thisArg, args) {
|
|
147
|
+
if (isBelievedBad || typeof target !== 'function') {
|
|
148
|
+
const fullyQualifiedMethodName = path.join('.');
|
|
149
|
+
const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
|
|
150
|
+
throw new Error(`${fullyQualifiedMethodName} is not a function. Did you mean: ${suggestions.join(', ')}`);
|
|
151
|
+
}
|
|
152
|
+
return Reflect.apply(target, proxyToObj.get(thisArg) ?? thisArg, args);
|
|
153
|
+
},
|
|
154
|
+
construct(target, args, newTarget) {
|
|
155
|
+
if (isBelievedBad || typeof target !== 'function') {
|
|
156
|
+
const fullyQualifiedMethodName = path.join('.');
|
|
157
|
+
const suggestions = getMethodSuggestions(fullyQualifiedMethodName);
|
|
158
|
+
throw new Error(`${fullyQualifiedMethodName} is not a constructor. Did you mean: ${suggestions.join(', ')}`);
|
|
159
|
+
}
|
|
160
|
+
return Reflect.construct(target, args, newTarget);
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
objToProxy.set(obj, proxy);
|
|
164
|
+
proxyToObj.set(proxy, obj);
|
|
165
|
+
}
|
|
166
|
+
return proxy;
|
|
167
|
+
}
|
|
168
|
+
function parseError(code, error) {
|
|
169
|
+
if (!(error instanceof Error))
|
|
170
|
+
return;
|
|
171
|
+
const message = error.name ? `${error.name}: ${error.message}` : error.message;
|
|
172
|
+
try {
|
|
173
|
+
// Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
|
|
174
|
+
const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
|
|
175
|
+
// -1 for the zero-based indexing
|
|
176
|
+
const line = lineNumber &&
|
|
177
|
+
code
|
|
178
|
+
.split('\n')
|
|
179
|
+
.at(parseInt(lineNumber, 10) - 1)
|
|
180
|
+
?.trim();
|
|
181
|
+
return line ? `${message}\n at line ${lineNumber}\n ${line}` : message;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return message;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const fetch = async (req) => {
|
|
188
|
+
const { opts, code } = (await req.json());
|
|
189
|
+
const runFunctionSource = code ? getRunFunctionSource(code) : null;
|
|
190
|
+
if (!runFunctionSource) {
|
|
191
|
+
const message = code ?
|
|
192
|
+
'The code is missing a top-level `run` function.'
|
|
193
|
+
: 'The code argument is missing. Provide one containing a top-level `run` function.';
|
|
194
|
+
return Response.json({
|
|
195
|
+
is_error: true,
|
|
196
|
+
result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(client) {\n // Fill this out\n}\n\`\`\``,
|
|
197
|
+
log_lines: [],
|
|
198
|
+
err_lines: [],
|
|
199
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
200
|
+
}
|
|
201
|
+
const diagnostics = getTSDiagnostics(code);
|
|
202
|
+
if (diagnostics.length > 0) {
|
|
203
|
+
return Response.json({
|
|
204
|
+
is_error: true,
|
|
205
|
+
result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
|
|
206
|
+
log_lines: [],
|
|
207
|
+
err_lines: [],
|
|
208
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
209
|
+
}
|
|
210
|
+
const client = new Codeqr({
|
|
211
|
+
...opts,
|
|
212
|
+
});
|
|
213
|
+
const log_lines = [];
|
|
214
|
+
const err_lines = [];
|
|
215
|
+
const console = {
|
|
216
|
+
log: (...args) => {
|
|
217
|
+
log_lines.push(util.format(...args));
|
|
218
|
+
},
|
|
219
|
+
error: (...args) => {
|
|
220
|
+
err_lines.push(util.format(...args));
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
try {
|
|
224
|
+
let run_ = async (client) => { };
|
|
225
|
+
eval(`${code}\nrun_ = run;`);
|
|
226
|
+
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
|
|
227
|
+
return Response.json({
|
|
228
|
+
is_error: false,
|
|
229
|
+
result,
|
|
230
|
+
log_lines,
|
|
231
|
+
err_lines,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch (e) {
|
|
235
|
+
return Response.json({
|
|
236
|
+
is_error: true,
|
|
237
|
+
result: parseError(code, e),
|
|
238
|
+
log_lines,
|
|
239
|
+
err_lines,
|
|
240
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
export default { fetch };
|
|
244
|
+
//# sourceMappingURL=code-tool-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-worker.mjs","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,IAAI,MAAM,WAAW;OACrB,IAAI,MAAM,WAAW;OACrB,IAAI,MAAM,SAAS;OACnB,EAAE,MAAM,YAAY;OAEpB,EAAE,MAAM,EAAiB,MAAM,YAAY;AAElD,SAAS,oBAAoB,CAAC,IAAY;IAKxC,MAAM,UAAU,GAA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1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { McpTool } from "./types.mjs";
|
|
2
|
+
import { SdkMethod } from "./methods.mjs";
|
|
3
|
+
import { McpCodeExecutionMode } from "./options.mjs";
|
|
2
4
|
/**
|
|
3
5
|
* A tool that runs code against a copy of the SDK.
|
|
4
6
|
*
|
|
@@ -6,49 +8,14 @@ import { Metadata, ToolCallResult } from "./tools/types.mjs";
|
|
|
6
8
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
9
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
10
|
*
|
|
9
|
-
* @param
|
|
11
|
+
* @param blockedMethods - The methods to block for code execution. Blocking is done by simple string
|
|
12
|
+
* matching, so it is not secure against obfuscation. For stronger security, block in the downstream API
|
|
13
|
+
* with limited API keys.
|
|
14
|
+
* @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote
|
|
15
|
+
* sandbox environment hosted by Stainless.
|
|
10
16
|
*/
|
|
11
|
-
export declare function codeTool(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[x: string]: unknown;
|
|
16
|
-
type: "object";
|
|
17
|
-
properties?: {
|
|
18
|
-
[x: string]: object;
|
|
19
|
-
} | undefined;
|
|
20
|
-
required?: string[] | undefined;
|
|
21
|
-
};
|
|
22
|
-
name: string;
|
|
23
|
-
description?: string | undefined;
|
|
24
|
-
outputSchema?: {
|
|
25
|
-
[x: string]: unknown;
|
|
26
|
-
type: "object";
|
|
27
|
-
properties?: {
|
|
28
|
-
[x: string]: object;
|
|
29
|
-
} | undefined;
|
|
30
|
-
required?: string[] | undefined;
|
|
31
|
-
} | undefined;
|
|
32
|
-
annotations?: {
|
|
33
|
-
title?: string | undefined;
|
|
34
|
-
readOnlyHint?: boolean | undefined;
|
|
35
|
-
destructiveHint?: boolean | undefined;
|
|
36
|
-
idempotentHint?: boolean | undefined;
|
|
37
|
-
openWorldHint?: boolean | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
execution?: {
|
|
40
|
-
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
41
|
-
} | undefined;
|
|
42
|
-
_meta?: {
|
|
43
|
-
[x: string]: unknown;
|
|
44
|
-
} | undefined;
|
|
45
|
-
icons?: {
|
|
46
|
-
src: string;
|
|
47
|
-
mimeType?: string | undefined;
|
|
48
|
-
sizes?: string[] | undefined;
|
|
49
|
-
}[] | undefined;
|
|
50
|
-
title?: string | undefined;
|
|
51
|
-
};
|
|
52
|
-
handler: (_: unknown, args: any) => Promise<ToolCallResult>;
|
|
53
|
-
}>;
|
|
17
|
+
export declare function codeTool({ blockedMethods, codeExecutionMode, }: {
|
|
18
|
+
blockedMethods: SdkMethod[] | undefined;
|
|
19
|
+
codeExecutionMode: McpCodeExecutionMode;
|
|
20
|
+
}): McpTool;
|
|
54
21
|
//# sourceMappingURL=code-tool.d.mts.map
|
package/code-tool.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,
|
|
1
|
+
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAGL,OAAO,EAKR;OAKM,EAAE,SAAS,EAAE;OACb,EAAE,oBAAoB,EAAE;AAyB/B;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,cAAc,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IACxC,iBAAiB,EAAE,oBAAoB,CAAC;CACzC,GAAG,OAAO,CAuEV"}
|
package/code-tool.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { McpTool } from "./types.js";
|
|
2
|
+
import { SdkMethod } from "./methods.js";
|
|
3
|
+
import { McpCodeExecutionMode } from "./options.js";
|
|
2
4
|
/**
|
|
3
5
|
* A tool that runs code against a copy of the SDK.
|
|
4
6
|
*
|
|
@@ -6,49 +8,14 @@ import { Metadata, ToolCallResult } from "./tools/types.js";
|
|
|
6
8
|
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
9
|
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
10
|
*
|
|
9
|
-
* @param
|
|
11
|
+
* @param blockedMethods - The methods to block for code execution. Blocking is done by simple string
|
|
12
|
+
* matching, so it is not secure against obfuscation. For stronger security, block in the downstream API
|
|
13
|
+
* with limited API keys.
|
|
14
|
+
* @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote
|
|
15
|
+
* sandbox environment hosted by Stainless.
|
|
10
16
|
*/
|
|
11
|
-
export declare function codeTool(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[x: string]: unknown;
|
|
16
|
-
type: "object";
|
|
17
|
-
properties?: {
|
|
18
|
-
[x: string]: object;
|
|
19
|
-
} | undefined;
|
|
20
|
-
required?: string[] | undefined;
|
|
21
|
-
};
|
|
22
|
-
name: string;
|
|
23
|
-
description?: string | undefined;
|
|
24
|
-
outputSchema?: {
|
|
25
|
-
[x: string]: unknown;
|
|
26
|
-
type: "object";
|
|
27
|
-
properties?: {
|
|
28
|
-
[x: string]: object;
|
|
29
|
-
} | undefined;
|
|
30
|
-
required?: string[] | undefined;
|
|
31
|
-
} | undefined;
|
|
32
|
-
annotations?: {
|
|
33
|
-
title?: string | undefined;
|
|
34
|
-
readOnlyHint?: boolean | undefined;
|
|
35
|
-
destructiveHint?: boolean | undefined;
|
|
36
|
-
idempotentHint?: boolean | undefined;
|
|
37
|
-
openWorldHint?: boolean | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
execution?: {
|
|
40
|
-
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
41
|
-
} | undefined;
|
|
42
|
-
_meta?: {
|
|
43
|
-
[x: string]: unknown;
|
|
44
|
-
} | undefined;
|
|
45
|
-
icons?: {
|
|
46
|
-
src: string;
|
|
47
|
-
mimeType?: string | undefined;
|
|
48
|
-
sizes?: string[] | undefined;
|
|
49
|
-
}[] | undefined;
|
|
50
|
-
title?: string | undefined;
|
|
51
|
-
};
|
|
52
|
-
handler: (_: unknown, args: any) => Promise<ToolCallResult>;
|
|
53
|
-
}>;
|
|
17
|
+
export declare function codeTool({ blockedMethods, codeExecutionMode, }: {
|
|
18
|
+
blockedMethods: SdkMethod[] | undefined;
|
|
19
|
+
codeExecutionMode: McpCodeExecutionMode;
|
|
20
|
+
}): McpTool;
|
|
54
21
|
//# sourceMappingURL=code-tool.d.ts.map
|