@superblocksteam/cli 2.0.156-next.3 → 2.0.156
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/README.md +1 -1
- package/bin/dev.js +0 -6
- package/bin/run.js +0 -6
- package/dist/{acorn-TMWPUFQG.js → acorn-KZYRJBVA.js} +3 -3
- package/dist/{angular-KZIHF7CJ.js → angular-WM5LU6FD.js} +3 -3
- package/dist/{api-UZP75F4Z.js → api-TERRF4V4.js} +4 -4
- package/dist/{babel-RJK2C7EU.js → babel-3ORNE6FM.js} +3 -3
- package/dist/{chunk-BQG6N3ZR.js → chunk-2CTGMPIU.js} +3 -3
- package/dist/{chunk-2ZWURVFG.js → chunk-4UNLK7GB.js} +2 -2
- package/dist/{chunk-4XPVGAYD.js → chunk-7UYNZ23S.js} +4 -4
- package/dist/{chunk-R2FV5KNZ.js → chunk-A6SIMKPR.js} +4 -4
- package/dist/{chunk-CGQCBGVF.js → chunk-B5T5WKNP.js} +3 -3
- package/dist/{chunk-NLUOWNO3.js → chunk-BBQHGV6R.js} +3 -3
- package/dist/{chunk-32XJOR53.js → chunk-BLVM23DR.js} +3 -3
- package/dist/{chunk-2URXIYVU.js → chunk-ENQ6K4XH.js} +3 -3
- package/dist/{chunk-UQGYVHIZ.js → chunk-H7AUOU4W.js} +3 -3
- package/dist/{chunk-YNW6MUP5.js → chunk-HGAO2HOW.js} +3 -3
- package/dist/{chunk-2DTO2X63.js → chunk-I5UAWLVZ.js} +2868 -4863
- package/dist/{chunk-2DTO2X63.js.map → chunk-I5UAWLVZ.js.map} +1 -1
- package/dist/{chunk-F4CCTRCM.js → chunk-KAPL5FDL.js} +4 -4
- package/dist/{chunk-LHYIOFKC.js → chunk-MIE7VILH.js} +3 -3
- package/dist/{chunk-HMIUX737.js → chunk-O6QF4SNO.js} +140 -3741
- package/dist/chunk-O6QF4SNO.js.map +1 -0
- package/dist/{chunk-46E5UOLD.js → chunk-OK6QICRM.js} +4 -4
- package/dist/{chunk-EEGO7C4X.js → chunk-QC7LVFFV.js} +8 -8
- package/dist/{chunk-H4I6B2UL.js → chunk-STRD7EJ5.js} +5 -5
- package/dist/{chunk-OAPQSNAK.js → chunk-U7TCJUOB.js} +3 -3
- package/dist/{chunk-22PT2J7V.js → chunk-XCW3AUST.js} +3 -3
- package/dist/{chunk-KPA7OQTC.js → chunk-XX27DB7R.js} +3 -3
- package/dist/{cli-truncate-MX2AWOJ7.js → cli-truncate-QSJMM2L4.js} +5 -5
- package/dist/commands/dev-parent.js +3 -3
- package/dist/{dd-trace-4C2W5TQV.js → dd-trace-GEZRXO5P.js} +6 -6
- package/dist/{dist-FNND45SG.js → dist-GGA2IIFF.js} +15 -15
- package/dist/{dist-FJQXEI3G.js → dist-P7G6RMCF.js} +200 -839
- package/dist/dist-P7G6RMCF.js.map +1 -0
- package/dist/{embedded-playwright-mcp-server-HQ6VQWA5.js → embedded-playwright-mcp-server-5QDLVHBN.js} +3 -3
- package/dist/{enquirer-RUYU3SIH.js → enquirer-BJV23Q6P.js} +4 -4
- package/dist/{estree-7CTGOHFD.js → estree-WFZOS4H2.js} +3 -3
- package/dist/{flow-OCLX6VIV.js → flow-HCW5HOIG.js} +3 -3
- package/dist/{getMachineId-bsd-OLUXYN45.js → getMachineId-bsd-APENRPFT.js} +5 -5
- package/dist/{getMachineId-darwin-SOPTABR6.js → getMachineId-darwin-SCM25SYO.js} +5 -5
- package/dist/{getMachineId-linux-TSCH4IGN.js → getMachineId-linux-ZP45LG2W.js} +4 -4
- package/dist/{getMachineId-unsupported-F24HTUPS.js → getMachineId-unsupported-3T3LBBHH.js} +4 -4
- package/dist/{getMachineId-win-MG35EYA2.js → getMachineId-win-WMUPYKYI.js} +5 -5
- package/dist/{glimmer-5RPVMR5C.js → glimmer-ZXDX6EOO.js} +3 -3
- package/dist/{graphql-NMMN75ZS.js → graphql-UMXWGGZR.js} +3 -3
- package/dist/{html-P647KPPD.js → html-2SZBLK3T.js} +3 -3
- package/dist/{http-3WJTRYM7.js → http-3L4EJ6YP.js} +14 -14
- package/dist/index.js +23 -23
- package/dist/{jiti-SVV756JW.js → jiti-YWBYU73T.js} +3 -3
- package/dist/{log-update-LATI254T.js → log-update-XOJDFO2A.js} +6 -6
- package/dist/{markdown-ZKX4GK5C.js → markdown-76GI7OP5.js} +3 -3
- package/dist/{meriyah-SYZHFXP7.js → meriyah-65Z3CGQ6.js} +3 -3
- package/dist/{postcss-RALLE2D4.js → postcss-RW7LFWNO.js} +3 -3
- package/dist/{read-pkg-IF66MSVN.js → read-pkg-GMF4ZZKW.js} +4 -4
- package/dist/{spans-FYQ3APUD.js → spans-QHMLXVJR.js} +4 -4
- package/dist/{src-YWXJNPE5.js → src-QMR65BY4.js} +3 -3
- package/dist/{token-BSBSA7GR.js → token-Z6Q7YMEB.js} +5 -5
- package/dist/{token-util-HR6A5A2A.js → token-util-DEN4UW5Y.js} +5 -5
- package/dist/{typescript-VUAAMRWP.js → typescript-S3EJOMRS.js} +3 -3
- package/dist/{v4-HUJDSTDO.js → v4-7CGFD7UI.js} +4 -4
- package/dist/{wrap-ansi-23LLRH6P.js → wrap-ansi-F4EVLPXN.js} +5 -5
- package/dist/{yaml-WCTC57Z3.js → yaml-5Q2LTOLJ.js} +3 -3
- package/oclif.manifest.json +1 -1
- package/package.json +7 -7
- package/dist/chunk-HMIUX737.js.map +0 -1
- package/dist/dist-FJQXEI3G.js.map +0 -1
- /package/dist/{acorn-TMWPUFQG.js.map → acorn-KZYRJBVA.js.map} +0 -0
- /package/dist/{angular-KZIHF7CJ.js.map → angular-WM5LU6FD.js.map} +0 -0
- /package/dist/{api-UZP75F4Z.js.map → api-TERRF4V4.js.map} +0 -0
- /package/dist/{babel-RJK2C7EU.js.map → babel-3ORNE6FM.js.map} +0 -0
- /package/dist/{chunk-BQG6N3ZR.js.map → chunk-2CTGMPIU.js.map} +0 -0
- /package/dist/{chunk-2ZWURVFG.js.map → chunk-4UNLK7GB.js.map} +0 -0
- /package/dist/{chunk-4XPVGAYD.js.map → chunk-7UYNZ23S.js.map} +0 -0
- /package/dist/{chunk-R2FV5KNZ.js.map → chunk-A6SIMKPR.js.map} +0 -0
- /package/dist/{chunk-CGQCBGVF.js.map → chunk-B5T5WKNP.js.map} +0 -0
- /package/dist/{chunk-NLUOWNO3.js.map → chunk-BBQHGV6R.js.map} +0 -0
- /package/dist/{chunk-32XJOR53.js.map → chunk-BLVM23DR.js.map} +0 -0
- /package/dist/{chunk-2URXIYVU.js.map → chunk-ENQ6K4XH.js.map} +0 -0
- /package/dist/{chunk-UQGYVHIZ.js.map → chunk-H7AUOU4W.js.map} +0 -0
- /package/dist/{chunk-YNW6MUP5.js.map → chunk-HGAO2HOW.js.map} +0 -0
- /package/dist/{chunk-F4CCTRCM.js.map → chunk-KAPL5FDL.js.map} +0 -0
- /package/dist/{chunk-LHYIOFKC.js.map → chunk-MIE7VILH.js.map} +0 -0
- /package/dist/{chunk-46E5UOLD.js.map → chunk-OK6QICRM.js.map} +0 -0
- /package/dist/{chunk-EEGO7C4X.js.map → chunk-QC7LVFFV.js.map} +0 -0
- /package/dist/{chunk-H4I6B2UL.js.map → chunk-STRD7EJ5.js.map} +0 -0
- /package/dist/{chunk-OAPQSNAK.js.map → chunk-U7TCJUOB.js.map} +0 -0
- /package/dist/{chunk-22PT2J7V.js.map → chunk-XCW3AUST.js.map} +0 -0
- /package/dist/{chunk-KPA7OQTC.js.map → chunk-XX27DB7R.js.map} +0 -0
- /package/dist/{cli-truncate-MX2AWOJ7.js.map → cli-truncate-QSJMM2L4.js.map} +0 -0
- /package/dist/{dd-trace-4C2W5TQV.js.map → dd-trace-GEZRXO5P.js.map} +0 -0
- /package/dist/{dist-FNND45SG.js.map → dist-GGA2IIFF.js.map} +0 -0
- /package/dist/{embedded-playwright-mcp-server-HQ6VQWA5.js.map → embedded-playwright-mcp-server-5QDLVHBN.js.map} +0 -0
- /package/dist/{enquirer-RUYU3SIH.js.map → enquirer-BJV23Q6P.js.map} +0 -0
- /package/dist/{estree-7CTGOHFD.js.map → estree-WFZOS4H2.js.map} +0 -0
- /package/dist/{flow-OCLX6VIV.js.map → flow-HCW5HOIG.js.map} +0 -0
- /package/dist/{getMachineId-bsd-OLUXYN45.js.map → getMachineId-bsd-APENRPFT.js.map} +0 -0
- /package/dist/{getMachineId-darwin-SOPTABR6.js.map → getMachineId-darwin-SCM25SYO.js.map} +0 -0
- /package/dist/{getMachineId-linux-TSCH4IGN.js.map → getMachineId-linux-ZP45LG2W.js.map} +0 -0
- /package/dist/{getMachineId-unsupported-F24HTUPS.js.map → getMachineId-unsupported-3T3LBBHH.js.map} +0 -0
- /package/dist/{getMachineId-win-MG35EYA2.js.map → getMachineId-win-WMUPYKYI.js.map} +0 -0
- /package/dist/{glimmer-5RPVMR5C.js.map → glimmer-ZXDX6EOO.js.map} +0 -0
- /package/dist/{graphql-NMMN75ZS.js.map → graphql-UMXWGGZR.js.map} +0 -0
- /package/dist/{html-P647KPPD.js.map → html-2SZBLK3T.js.map} +0 -0
- /package/dist/{http-3WJTRYM7.js.map → http-3L4EJ6YP.js.map} +0 -0
- /package/dist/{jiti-SVV756JW.js.map → jiti-YWBYU73T.js.map} +0 -0
- /package/dist/{log-update-LATI254T.js.map → log-update-XOJDFO2A.js.map} +0 -0
- /package/dist/{markdown-ZKX4GK5C.js.map → markdown-76GI7OP5.js.map} +0 -0
- /package/dist/{meriyah-SYZHFXP7.js.map → meriyah-65Z3CGQ6.js.map} +0 -0
- /package/dist/{postcss-RALLE2D4.js.map → postcss-RW7LFWNO.js.map} +0 -0
- /package/dist/{read-pkg-IF66MSVN.js.map → read-pkg-GMF4ZZKW.js.map} +0 -0
- /package/dist/{spans-FYQ3APUD.js.map → spans-QHMLXVJR.js.map} +0 -0
- /package/dist/{src-YWXJNPE5.js.map → src-QMR65BY4.js.map} +0 -0
- /package/dist/{token-BSBSA7GR.js.map → token-Z6Q7YMEB.js.map} +0 -0
- /package/dist/{token-util-HR6A5A2A.js.map → token-util-DEN4UW5Y.js.map} +0 -0
- /package/dist/{typescript-VUAAMRWP.js.map → typescript-S3EJOMRS.js.map} +0 -0
- /package/dist/{v4-HUJDSTDO.js.map → v4-7CGFD7UI.js.map} +0 -0
- /package/dist/{wrap-ansi-23LLRH6P.js.map → wrap-ansi-F4EVLPXN.js.map} +0 -0
- /package/dist/{yaml-WCTC57Z3.js.map → yaml-5Q2LTOLJ.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
if (typeof process === 'object' && process !== null &&
|
|
2
2
|
process.env !== null && typeof process.env === 'object') {
|
|
3
3
|
process.env.DD_GIT_REPOSITORY_URL = 'https://token@github.com/superblocksteam/superblocks.git';
|
|
4
|
-
process.env.DD_GIT_COMMIT_SHA = '
|
|
4
|
+
process.env.DD_GIT_COMMIT_SHA = 'a5b422b6464068a2d19d8b6b1893a1276d5274f9';
|
|
5
5
|
}
|
|
6
6
|
import { createRequire as $dd_createRequire } from 'module';
|
|
7
7
|
import { fileURLToPath as $dd_fileURLToPath } from 'url';
|
|
@@ -13,7 +13,7 @@ globalThis.__dirname ??= $dd_dirname(globalThis.__filename);
|
|
|
13
13
|
import {
|
|
14
14
|
McpServer,
|
|
15
15
|
StdioServerTransport
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QC7LVFFV.js";
|
|
17
17
|
import {
|
|
18
18
|
CallToolResultSchema,
|
|
19
19
|
ContentBlockSchema,
|
|
@@ -27,37 +27,30 @@ import {
|
|
|
27
27
|
executeToolCall,
|
|
28
28
|
runWithAuthContext,
|
|
29
29
|
toolDefinitions
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-O6QF4SNO.js";
|
|
31
31
|
import {
|
|
32
32
|
external_exports
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
33
|
+
} from "./chunk-MIE7VILH.js";
|
|
34
|
+
import "./chunk-A6SIMKPR.js";
|
|
35
35
|
import {
|
|
36
|
-
getDefaultPolicy,
|
|
37
|
-
import_shared,
|
|
38
36
|
import_websocket,
|
|
39
|
-
initNodeTelemetry,
|
|
40
|
-
parseDeploymentType,
|
|
41
37
|
require_dist
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import "./chunk-
|
|
44
|
-
import "./chunk-
|
|
45
|
-
import "./chunk-
|
|
46
|
-
import "./chunk-
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./chunk-
|
|
38
|
+
} from "./chunk-I5UAWLVZ.js";
|
|
39
|
+
import "./chunk-HGAO2HOW.js";
|
|
40
|
+
import "./chunk-2CTGMPIU.js";
|
|
41
|
+
import "./chunk-STRD7EJ5.js";
|
|
42
|
+
import "./chunk-H7AUOU4W.js";
|
|
43
|
+
import "./chunk-B5T5WKNP.js";
|
|
44
|
+
import "./chunk-XCW3AUST.js";
|
|
49
45
|
import {
|
|
50
|
-
SpanStatusCode,
|
|
51
|
-
context,
|
|
52
46
|
init_esm,
|
|
53
|
-
metrics
|
|
54
|
-
|
|
55
|
-
} from "./chunk-OAPQSNAK.js";
|
|
47
|
+
metrics
|
|
48
|
+
} from "./chunk-U7TCJUOB.js";
|
|
56
49
|
import {
|
|
57
50
|
__require,
|
|
58
51
|
__toESM,
|
|
59
52
|
init_cjs_shims
|
|
60
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-4UNLK7GB.js";
|
|
61
54
|
|
|
62
55
|
// ../../../gateway/dist/index.js
|
|
63
56
|
init_cjs_shims();
|
|
@@ -239,7 +232,7 @@ function formatCaptureModeSummary(input) {
|
|
|
239
232
|
|
|
240
233
|
// ../../../gateway/dist/capabilities/lifecycle.js
|
|
241
234
|
init_cjs_shims();
|
|
242
|
-
var
|
|
235
|
+
var import_shared2 = __toESM(require_dist());
|
|
243
236
|
import { randomUUID } from "node:crypto";
|
|
244
237
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
245
238
|
import path2 from "node:path";
|
|
@@ -444,7 +437,7 @@ function buildOpenablePreviewUrls(input) {
|
|
|
444
437
|
|
|
445
438
|
// ../../../gateway/dist/server/client.js
|
|
446
439
|
init_cjs_shims();
|
|
447
|
-
var
|
|
440
|
+
var import_shared = __toESM(require_dist());
|
|
448
441
|
|
|
449
442
|
// ../../../gateway/dist/telemetry/metrics.js
|
|
450
443
|
init_cjs_shims();
|
|
@@ -848,7 +841,7 @@ var HttpSuperblocksServerClient = class {
|
|
|
848
841
|
}
|
|
849
842
|
async uploadAttachment(input) {
|
|
850
843
|
const mimeType = input.mimeType ?? "application/zip";
|
|
851
|
-
const response = await (0,
|
|
844
|
+
const response = await (0, import_shared.uploadAttachmentToServerApi)({
|
|
852
845
|
applicationId: input.applicationId,
|
|
853
846
|
authorization: `Bearer ${input.apiKey}`,
|
|
854
847
|
baseUrl: this.baseUrl(),
|
|
@@ -895,18 +888,10 @@ var HttpSuperblocksServerClient = class {
|
|
|
895
888
|
*/
|
|
896
889
|
async issueScopedToken(input) {
|
|
897
890
|
const scope = input.scope ?? "apps:update";
|
|
898
|
-
const body = {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
}
|
|
903
|
-
body.integrationId = input.integrationId;
|
|
904
|
-
} else {
|
|
905
|
-
if (!input.applicationId?.trim()) {
|
|
906
|
-
throw new Error(`${scope} scoped tokens require an applicationId`);
|
|
907
|
-
}
|
|
908
|
-
body.applicationId = input.applicationId;
|
|
909
|
-
}
|
|
891
|
+
const body = {
|
|
892
|
+
applicationId: input.applicationId,
|
|
893
|
+
scope
|
|
894
|
+
};
|
|
910
895
|
if (scope === "apps:preview") {
|
|
911
896
|
if (!input.commitId?.trim()) {
|
|
912
897
|
throw new Error("apps:preview scoped tokens require a commitId so the viewer can load that commit");
|
|
@@ -1846,36 +1831,36 @@ async function captureModeOf(ctx) {
|
|
|
1846
1831
|
});
|
|
1847
1832
|
}
|
|
1848
1833
|
function libraryCaptureInput(ctx, applicationId) {
|
|
1849
|
-
const
|
|
1850
|
-
if (!
|
|
1834
|
+
const context = ctx.sessionPeer.libraryBrowserContext?.(applicationId);
|
|
1835
|
+
if (!context) {
|
|
1851
1836
|
return void 0;
|
|
1852
1837
|
}
|
|
1853
|
-
const auth =
|
|
1838
|
+
const auth = context.initData.devServerAuthorization;
|
|
1854
1839
|
if (!auth) {
|
|
1855
1840
|
console.error("gateway live canvas skipped: missing_dev_server_authorization", { applicationId });
|
|
1856
1841
|
return void 0;
|
|
1857
1842
|
}
|
|
1858
1843
|
return {
|
|
1859
1844
|
bootstrapData: {
|
|
1860
|
-
accessToken:
|
|
1861
|
-
agents:
|
|
1862
|
-
...
|
|
1863
|
-
appId:
|
|
1864
|
-
...
|
|
1865
|
-
...
|
|
1866
|
-
...
|
|
1867
|
-
token:
|
|
1868
|
-
...
|
|
1869
|
-
userId:
|
|
1870
|
-
...
|
|
1845
|
+
accessToken: context.bootstrapData.accessToken,
|
|
1846
|
+
agents: context.bootstrapData.agents ?? [],
|
|
1847
|
+
...context.bootstrapData.agentUrls ? { agentUrls: context.bootstrapData.agentUrls } : {},
|
|
1848
|
+
appId: context.bootstrapData.appId,
|
|
1849
|
+
...context.bootstrapData.featureFlags ? { featureFlags: context.bootstrapData.featureFlags } : {},
|
|
1850
|
+
...context.bootstrapData.orgId ? { orgId: context.bootstrapData.orgId } : {},
|
|
1851
|
+
...context.bootstrapData.profiles ? { profiles: context.bootstrapData.profiles } : {},
|
|
1852
|
+
token: context.bootstrapData.token,
|
|
1853
|
+
...context.bootstrapData.userEmail ? { userEmail: context.bootstrapData.userEmail } : {},
|
|
1854
|
+
userId: context.bootstrapData.userId,
|
|
1855
|
+
...context.bootstrapData.windowOriginUrl ? { windowOriginUrl: context.bootstrapData.windowOriginUrl } : {}
|
|
1871
1856
|
},
|
|
1872
|
-
iframeBaseUrl:
|
|
1857
|
+
iframeBaseUrl: context.iframeBaseUrl,
|
|
1873
1858
|
initData: {
|
|
1874
|
-
appId:
|
|
1859
|
+
appId: context.initData.appId,
|
|
1875
1860
|
devServerAuthorization: auth,
|
|
1876
|
-
peerId:
|
|
1877
|
-
...
|
|
1878
|
-
...
|
|
1861
|
+
peerId: context.initData.peerId,
|
|
1862
|
+
...context.initData.userId ? { userId: context.initData.userId } : {},
|
|
1863
|
+
...context.initData.windowOriginUrl ? { windowOriginUrl: context.initData.windowOriginUrl } : {}
|
|
1879
1864
|
}
|
|
1880
1865
|
};
|
|
1881
1866
|
}
|
|
@@ -1999,15 +1984,13 @@ function defaultAppName(prompt) {
|
|
|
1999
1984
|
async function ensurePrincipal(ctx) {
|
|
2000
1985
|
const { principal } = ctx;
|
|
2001
1986
|
if (principal.organizationId && principal.userId) {
|
|
2002
|
-
const resolved2 = {
|
|
2003
|
-
...principal,
|
|
2004
|
-
organizationId: principal.organizationId,
|
|
2005
|
-
userId: principal.userId
|
|
2006
|
-
};
|
|
2007
|
-
ctx.onPrincipalResolved?.(resolved2);
|
|
2008
1987
|
return {
|
|
2009
1988
|
kind: "ok",
|
|
2010
|
-
value:
|
|
1989
|
+
value: {
|
|
1990
|
+
...principal,
|
|
1991
|
+
organizationId: principal.organizationId,
|
|
1992
|
+
userId: principal.userId
|
|
1993
|
+
}
|
|
2011
1994
|
};
|
|
2012
1995
|
}
|
|
2013
1996
|
let validated;
|
|
@@ -2037,16 +2020,14 @@ async function ensurePrincipal(ctx) {
|
|
|
2037
2020
|
message: "The Superblocks API rejected the credential issued for this caller."
|
|
2038
2021
|
};
|
|
2039
2022
|
}
|
|
2040
|
-
const resolved = {
|
|
2041
|
-
...principal,
|
|
2042
|
-
email: validated.email,
|
|
2043
|
-
organizationId: validated.organizationId,
|
|
2044
|
-
userId: validated.userId
|
|
2045
|
-
};
|
|
2046
|
-
ctx.onPrincipalResolved?.(resolved);
|
|
2047
2023
|
return {
|
|
2048
2024
|
kind: "ok",
|
|
2049
|
-
value:
|
|
2025
|
+
value: {
|
|
2026
|
+
...principal,
|
|
2027
|
+
email: validated.email,
|
|
2028
|
+
organizationId: validated.organizationId,
|
|
2029
|
+
userId: validated.userId
|
|
2030
|
+
}
|
|
2050
2031
|
};
|
|
2051
2032
|
}
|
|
2052
2033
|
async function nameWithClark(ctx, input) {
|
|
@@ -2239,7 +2220,7 @@ function turnSummary(turn) {
|
|
|
2239
2220
|
return "Superblocks is still working, but only the editor can show it \u2014 open the edit URL";
|
|
2240
2221
|
}
|
|
2241
2222
|
if (turn.generationStatus === "live_edit_terminated") {
|
|
2242
|
-
return
|
|
2223
|
+
return "The Superblocks live-edit session terminated before anything was built \u2014 send the prompt again with edit_app";
|
|
2243
2224
|
}
|
|
2244
2225
|
if (turn.checkpointCommitId) {
|
|
2245
2226
|
return `Application ready \u2014 checkpoint saved. ${NEXT_STEPS}`;
|
|
@@ -2365,7 +2346,6 @@ async function forwardClarkPrompt(ctx, input) {
|
|
|
2365
2346
|
generationStatus: forward.generationStatus,
|
|
2366
2347
|
...forward.liveEditId ? { liveEditId: forward.liveEditId } : {},
|
|
2367
2348
|
...forward.recentRuns && forward.recentRuns.length > 0 ? { recentRuns: forward.recentRuns } : {},
|
|
2368
|
-
...forward.retryAction ? { retryAction: forward.retryAction } : {},
|
|
2369
2349
|
viewStatus: forward.viewStatus
|
|
2370
2350
|
}
|
|
2371
2351
|
};
|
|
@@ -2411,7 +2391,7 @@ function namingCreatedApplication(applicationId, capability, result) {
|
|
|
2411
2391
|
return namingApplication(applicationId, result);
|
|
2412
2392
|
}
|
|
2413
2393
|
function retryIfReplayable(attachments) {
|
|
2414
|
-
return attachments && attachments.length > 0 ?
|
|
2394
|
+
return attachments && attachments.length > 0 ? void 0 : { pendingAction: "retry_build" };
|
|
2415
2395
|
}
|
|
2416
2396
|
function liveEditUnavailable(error, attachments) {
|
|
2417
2397
|
return {
|
|
@@ -2432,8 +2412,7 @@ function rememberFailedStart(ctx, input) {
|
|
|
2432
2412
|
organizationId: input.principal.organizationId,
|
|
2433
2413
|
// Reaches the caller as the dead start's reply on its next poll, so it
|
|
2434
2414
|
// has to stand on its own there rather than lean on this call's error.
|
|
2435
|
-
reason:
|
|
2436
|
-
...input.retryAction ? { retryAction: input.retryAction } : {},
|
|
2415
|
+
reason: `The Superblocks live-edit session for application ${input.applicationId} never opened, so the prompt never reached Superblocks and nothing was built. Nothing is running for that application; send the same instruction again to retry it. (${cause})`,
|
|
2437
2416
|
userId: input.principal.userId
|
|
2438
2417
|
});
|
|
2439
2418
|
} catch (error) {
|
|
@@ -2463,12 +2442,7 @@ async function promptNewApplication(ctx, args) {
|
|
|
2463
2442
|
organizationId: principal.organizationId
|
|
2464
2443
|
});
|
|
2465
2444
|
} catch (error) {
|
|
2466
|
-
rememberFailedStart(ctx, {
|
|
2467
|
-
applicationId,
|
|
2468
|
-
error,
|
|
2469
|
-
principal,
|
|
2470
|
-
...args.attachments?.length ? { retryAction: "retry_import" } : {}
|
|
2471
|
-
});
|
|
2445
|
+
rememberFailedStart(ctx, { applicationId, error, principal });
|
|
2472
2446
|
return liveEditUnavailable(error, args.attachments);
|
|
2473
2447
|
}
|
|
2474
2448
|
ctx.onProgress?.({
|
|
@@ -2663,7 +2637,7 @@ async function resolveImportArchive(input, searchDirs) {
|
|
|
2663
2637
|
if (bytes.byteLength > IMPORT_ZIP_MAX_BYTES) {
|
|
2664
2638
|
return tooLargeError(bytes.byteLength);
|
|
2665
2639
|
}
|
|
2666
|
-
const archiveType = (0,
|
|
2640
|
+
const archiveType = (0, import_shared2.detectAttachmentArchiveType)({ fileName });
|
|
2667
2641
|
if (archiveType === null) {
|
|
2668
2642
|
return {
|
|
2669
2643
|
kind: "error",
|
|
@@ -2705,15 +2679,14 @@ function normalizeImportSource(source) {
|
|
|
2705
2679
|
}
|
|
2706
2680
|
}
|
|
2707
2681
|
async function importApp(ctx, input) {
|
|
2708
|
-
const resumedApplicationId = input.applicationId?.trim();
|
|
2709
2682
|
const archiveResult = await resolveImportArchive(input, ctx.config.importSearchDirs);
|
|
2710
2683
|
if (archiveResult.kind !== "ok") {
|
|
2711
|
-
return
|
|
2684
|
+
return archiveResult;
|
|
2712
2685
|
}
|
|
2713
2686
|
const archive = archiveResult.value;
|
|
2714
2687
|
const principalResult = await ensurePrincipal(ctx);
|
|
2715
2688
|
if (principalResult.kind !== "ok") {
|
|
2716
|
-
return
|
|
2689
|
+
return principalResult;
|
|
2717
2690
|
}
|
|
2718
2691
|
const principal = principalResult.value;
|
|
2719
2692
|
const source = normalizeImportSource(input.source);
|
|
@@ -2724,26 +2697,23 @@ async function importApp(ctx, input) {
|
|
|
2724
2697
|
});
|
|
2725
2698
|
const explicitName = input.name?.trim();
|
|
2726
2699
|
const name = explicitName || defaultAppName(migrationPrompt);
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
if (created.kind !== "ok") {
|
|
2740
|
-
return created;
|
|
2741
|
-
}
|
|
2742
|
-
applicationId = created.value.id;
|
|
2700
|
+
ctx.onProgress?.({
|
|
2701
|
+
message: "Creating application for import",
|
|
2702
|
+
type: "progress"
|
|
2703
|
+
});
|
|
2704
|
+
const created = await createApplicationForPrompt(ctx, {
|
|
2705
|
+
apiKey: principal.apiKey,
|
|
2706
|
+
name,
|
|
2707
|
+
organizationId: principal.organizationId,
|
|
2708
|
+
templateName: "app-fullstack"
|
|
2709
|
+
});
|
|
2710
|
+
if (created.kind !== "ok") {
|
|
2711
|
+
return created;
|
|
2743
2712
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2713
|
+
const app = created.value;
|
|
2714
|
+
await rememberApplication(ctx, principal, app.id);
|
|
2715
|
+
return namingCreatedApplication(app.id, "import_app", await migrateArchiveIntoApplication(ctx, {
|
|
2716
|
+
applicationId: app.id,
|
|
2747
2717
|
archive,
|
|
2748
2718
|
explicitName,
|
|
2749
2719
|
input,
|
|
@@ -2751,8 +2721,7 @@ async function importApp(ctx, input) {
|
|
|
2751
2721
|
name,
|
|
2752
2722
|
principal,
|
|
2753
2723
|
source
|
|
2754
|
-
});
|
|
2755
|
-
return resumedApplicationId ? namingApplication(applicationId, result) : namingCreatedApplication(applicationId, "import_app", result);
|
|
2724
|
+
}));
|
|
2756
2725
|
}
|
|
2757
2726
|
async function migrateArchiveIntoApplication(ctx, args) {
|
|
2758
2727
|
const { applicationId, archive, principal } = args;
|
|
@@ -2771,18 +2740,10 @@ async function migrateArchiveIntoApplication(ctx, args) {
|
|
|
2771
2740
|
});
|
|
2772
2741
|
} catch (error) {
|
|
2773
2742
|
const message = error instanceof Error ? error.message : String(error);
|
|
2774
|
-
rememberFailedStart(ctx, {
|
|
2775
|
-
applicationId,
|
|
2776
|
-
error,
|
|
2777
|
-
principal,
|
|
2778
|
-
reason: `The archive for application ${applicationId} could not be uploaded, so the migration never started and nothing was built. Send the same archive again with import_app to retry it. (${message})`,
|
|
2779
|
-
retryAction: "retry_import"
|
|
2780
|
-
});
|
|
2781
2743
|
return {
|
|
2782
2744
|
kind: "error",
|
|
2783
2745
|
code: "import_upload_failed",
|
|
2784
|
-
message
|
|
2785
|
-
pendingAction: "retry_import"
|
|
2746
|
+
message
|
|
2786
2747
|
};
|
|
2787
2748
|
}
|
|
2788
2749
|
return promptNewApplication(ctx, {
|
|
@@ -2867,7 +2828,7 @@ async function checkAppProgress(ctx, input) {
|
|
|
2867
2828
|
}
|
|
2868
2829
|
const applicationId = resolved.value;
|
|
2869
2830
|
if (ctx.signal?.aborted) {
|
|
2870
|
-
return
|
|
2831
|
+
return cancelled("check_app_progress");
|
|
2871
2832
|
}
|
|
2872
2833
|
const cursorKey2 = cursorKeyFor(ctx, principal, applicationId);
|
|
2873
2834
|
const stored = cursorKey2 ? await ctx.progressCursors?.getCursor(cursorKey2) : void 0;
|
|
@@ -2879,7 +2840,7 @@ async function checkAppProgress(ctx, input) {
|
|
|
2879
2840
|
waitMs: hostCallBudgetMs(ctx, ctx.config.clarkProgressWaitMs)
|
|
2880
2841
|
});
|
|
2881
2842
|
if (ctx.signal?.aborted) {
|
|
2882
|
-
return
|
|
2843
|
+
return cancelled("check_app_progress");
|
|
2883
2844
|
}
|
|
2884
2845
|
const snapshot = await readSnapshot(ctx, {
|
|
2885
2846
|
applicationId,
|
|
@@ -2953,7 +2914,6 @@ async function checkAppProgress(ctx, input) {
|
|
|
2953
2914
|
reply: update.reply,
|
|
2954
2915
|
...update.decision ? { decision: update.decision } : {},
|
|
2955
2916
|
generationStatus: update.generationStatus,
|
|
2956
|
-
...update.retryAction && emptyTurnStatus(update.generationStatus) ? { pendingAction: update.retryAction } : {},
|
|
2957
2917
|
status,
|
|
2958
2918
|
viewStatus: update.viewStatus
|
|
2959
2919
|
}
|
|
@@ -3375,11 +3335,7 @@ function localUnbuiltReason(turn, pending) {
|
|
|
3375
3335
|
return void 0;
|
|
3376
3336
|
}
|
|
3377
3337
|
const status = emptyTurnStatus(turn.generationStatus);
|
|
3378
|
-
return status ? {
|
|
3379
|
-
kind: "empty_turn",
|
|
3380
|
-
retryAction: turn.retryAction ?? "retry_build",
|
|
3381
|
-
status
|
|
3382
|
-
} : void 0;
|
|
3338
|
+
return status ? { kind: "empty_turn", status } : void 0;
|
|
3383
3339
|
}
|
|
3384
3340
|
async function persistedUnbuiltReason(ctx, principal, applicationId) {
|
|
3385
3341
|
let snapshot;
|
|
@@ -3422,8 +3378,6 @@ function persistedTurnEnd(status) {
|
|
|
3422
3378
|
// plain question and cannot be approved.
|
|
3423
3379
|
case "needs_decision":
|
|
3424
3380
|
return { kind: "awaiting_decision" };
|
|
3425
|
-
// The stream never recorded whether the prompt carried an archive, so
|
|
3426
|
-
// this path cannot pick retry_build vs retry_import. Omit rather than guess.
|
|
3427
3381
|
case "live_edit_terminated":
|
|
3428
3382
|
return { kind: "empty_turn", status };
|
|
3429
3383
|
// A `cancelled` in the tail may still have a real app behind it: the
|
|
@@ -3482,11 +3436,7 @@ async function unbuiltApp(ctx, principal, applicationId) {
|
|
|
3482
3436
|
if (reason.kind === "empty_turn") {
|
|
3483
3437
|
return {
|
|
3484
3438
|
kind: "ok",
|
|
3485
|
-
value: {
|
|
3486
|
-
...app,
|
|
3487
|
-
...reason.retryAction ? { pendingAction: reason.retryAction } : {},
|
|
3488
|
-
status: reason.status
|
|
3489
|
-
}
|
|
3439
|
+
value: { ...app, pendingAction: "retry_build", status: reason.status }
|
|
3490
3440
|
};
|
|
3491
3441
|
}
|
|
3492
3442
|
return {
|
|
@@ -3588,7 +3538,7 @@ async function waitForBuild(ctx, input) {
|
|
|
3588
3538
|
let started = false;
|
|
3589
3539
|
for (; ; ) {
|
|
3590
3540
|
if (ctx.signal?.aborted) {
|
|
3591
|
-
return
|
|
3541
|
+
return cancelled("get_app");
|
|
3592
3542
|
}
|
|
3593
3543
|
if (nowMs(ctx) >= deadline) {
|
|
3594
3544
|
return { kind: "ok", value: { built: false } };
|
|
@@ -4242,7 +4192,7 @@ async function createStores() {
|
|
|
4242
4192
|
// ../../../gateway/dist/sabs/websocket-session-peer.js
|
|
4243
4193
|
init_cjs_shims();
|
|
4244
4194
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4245
|
-
var
|
|
4195
|
+
var import_shared5 = __toESM(require_dist());
|
|
4246
4196
|
|
|
4247
4197
|
// ../../../gateway/dist/agents/resolve-orchestrator-url.js
|
|
4248
4198
|
init_cjs_shims();
|
|
@@ -4563,15 +4513,15 @@ var HttpOrchestratorClient = class {
|
|
|
4563
4513
|
|
|
4564
4514
|
// ../../../gateway/dist/sabs/browser-context.js
|
|
4565
4515
|
init_cjs_shims();
|
|
4566
|
-
var
|
|
4516
|
+
var import_shared3 = __toESM(require_dist());
|
|
4567
4517
|
function toProfile(row) {
|
|
4568
|
-
return new
|
|
4518
|
+
return new import_shared3.Profile({
|
|
4569
4519
|
allowedInEditor: row.allowedInEditor,
|
|
4570
4520
|
description: "",
|
|
4571
4521
|
displayName: row.displayName ?? row.key,
|
|
4572
4522
|
id: row.id ?? row.key,
|
|
4573
4523
|
key: row.key,
|
|
4574
|
-
type:
|
|
4524
|
+
type: import_shared3.ProfileType.RESERVED
|
|
4575
4525
|
});
|
|
4576
4526
|
}
|
|
4577
4527
|
function selectProfiles(input) {
|
|
@@ -4634,7 +4584,7 @@ function buildBrowserContext(input) {
|
|
|
4634
4584
|
|
|
4635
4585
|
// ../../../gateway/dist/sabs/editor-client-methods.js
|
|
4636
4586
|
init_cjs_shims();
|
|
4637
|
-
var
|
|
4587
|
+
var import_shared4 = __toESM(require_dist());
|
|
4638
4588
|
|
|
4639
4589
|
// ../../../gateway/dist/integrations/map.js
|
|
4640
4590
|
init_cjs_shims();
|
|
@@ -4789,7 +4739,7 @@ function sanitizeAgentFacingValue(value) {
|
|
|
4789
4739
|
}
|
|
4790
4740
|
|
|
4791
4741
|
// ../../../gateway/dist/sabs/editor-client-methods.js
|
|
4792
|
-
var ADMIN_MCP_SETUP_MESSAGE = "Integrations CRUD is available on this Superblocks MCP via
|
|
4742
|
+
var ADMIN_MCP_SETUP_MESSAGE = "Integrations CRUD is available on this Superblocks MCP via create_integration, update_integration, and list_integrations (same connector as start_app). Use those Admin tools, then continue with edit_app. The headless editor session cannot open the Integrations UI.";
|
|
4793
4743
|
var HEADLESS_AUTO_APPROVED_TOOLS = /* @__PURE__ */ new Set([
|
|
4794
4744
|
"build_deleteFile",
|
|
4795
4745
|
"build_installPackages",
|
|
@@ -4875,27 +4825,27 @@ function clarifySdkExecutionErrorMessage(message) {
|
|
|
4875
4825
|
}
|
|
4876
4826
|
return sanitizeAgentFacingText(clarified);
|
|
4877
4827
|
}
|
|
4878
|
-
async function executeRequestToIntegrationViaOrchestrator(
|
|
4828
|
+
async function executeRequestToIntegrationViaOrchestrator(context, payload) {
|
|
4879
4829
|
let pluginId = payload.integrationHint?.type;
|
|
4880
4830
|
let integrationName = payload.integrationHint?.displayName ?? payload.integrationHint?.name ?? "Integration";
|
|
4881
4831
|
if (!pluginId) {
|
|
4882
4832
|
let row;
|
|
4883
4833
|
try {
|
|
4884
|
-
row = await
|
|
4885
|
-
apiKey:
|
|
4834
|
+
row = await context.server.getIntegration({
|
|
4835
|
+
apiKey: context.apiKey,
|
|
4886
4836
|
integrationId: payload.integrationId
|
|
4887
4837
|
});
|
|
4888
4838
|
if (!row) {
|
|
4889
|
-
const rows = await
|
|
4890
|
-
apiKey:
|
|
4891
|
-
applicationId:
|
|
4892
|
-
organizationId:
|
|
4839
|
+
const rows = await context.server.getSupersetIntegrations({
|
|
4840
|
+
apiKey: context.apiKey,
|
|
4841
|
+
applicationId: context.applicationId,
|
|
4842
|
+
organizationId: context.organizationId
|
|
4893
4843
|
});
|
|
4894
4844
|
row = rows.find((candidate) => candidate.id === payload.integrationId);
|
|
4895
4845
|
}
|
|
4896
4846
|
} catch (error) {
|
|
4897
4847
|
console.warn("gateway failed to resolve integration for execute", {
|
|
4898
|
-
applicationId:
|
|
4848
|
+
applicationId: context.applicationId,
|
|
4899
4849
|
integrationId: payload.integrationId,
|
|
4900
4850
|
message: error instanceof Error ? error.message : String(error)
|
|
4901
4851
|
});
|
|
@@ -4908,7 +4858,7 @@ async function executeRequestToIntegrationViaOrchestrator(context2, payload) {
|
|
|
4908
4858
|
pluginId = row.pluginId;
|
|
4909
4859
|
integrationName = row.name || integrationName;
|
|
4910
4860
|
}
|
|
4911
|
-
const pluginIdForStep = (0,
|
|
4861
|
+
const pluginIdForStep = (0, import_shared4.getBasePluginId)(pluginId);
|
|
4912
4862
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4913
4863
|
const inlineApiId = `ai-inline-${payload.integrationId}-${Date.now()}`;
|
|
4914
4864
|
const definition = {
|
|
@@ -4924,14 +4874,14 @@ async function executeRequestToIntegrationViaOrchestrator(context2, payload) {
|
|
|
4924
4874
|
metadata: {
|
|
4925
4875
|
id: inlineApiId,
|
|
4926
4876
|
name: `${integrationName} AI Query`,
|
|
4927
|
-
organization:
|
|
4877
|
+
organization: context.organizationId,
|
|
4928
4878
|
timestamps: { created: now, updated: now }
|
|
4929
4879
|
},
|
|
4930
4880
|
trigger: { application: {} }
|
|
4931
4881
|
};
|
|
4932
4882
|
try {
|
|
4933
|
-
const result = await
|
|
4934
|
-
apiKey:
|
|
4883
|
+
const result = await context.orchestrator.executeV2Api({
|
|
4884
|
+
apiKey: context.apiKey,
|
|
4935
4885
|
body: {
|
|
4936
4886
|
definition: { api: definition },
|
|
4937
4887
|
inputs: {},
|
|
@@ -4942,10 +4892,10 @@ async function executeRequestToIntegrationViaOrchestrator(context2, payload) {
|
|
|
4942
4892
|
isAiTriggered: true,
|
|
4943
4893
|
suppressTracking: true
|
|
4944
4894
|
},
|
|
4945
|
-
...
|
|
4895
|
+
...context.profileKey ? { profile: { name: context.profileKey } } : {}
|
|
4946
4896
|
},
|
|
4947
|
-
profileKey:
|
|
4948
|
-
scopedToken:
|
|
4897
|
+
profileKey: context.profileKey,
|
|
4898
|
+
scopedToken: context.sessionToken
|
|
4949
4899
|
});
|
|
4950
4900
|
if (result && typeof result === "object" && "systemError" in result) {
|
|
4951
4901
|
const systemError = String(result.systemError ?? "Integration execution failed");
|
|
@@ -4981,11 +4931,11 @@ async function executeRequestToIntegrationViaOrchestrator(context2, payload) {
|
|
|
4981
4931
|
return { error: clarifySdkExecutionErrorMessage(message) };
|
|
4982
4932
|
}
|
|
4983
4933
|
}
|
|
4984
|
-
async function loadIntegrationsForPrompt(
|
|
4985
|
-
const rows = await
|
|
4986
|
-
apiKey:
|
|
4987
|
-
applicationId:
|
|
4988
|
-
organizationId:
|
|
4934
|
+
async function loadIntegrationsForPrompt(context) {
|
|
4935
|
+
const rows = await context.server.getSupersetIntegrations({
|
|
4936
|
+
apiKey: context.apiKey,
|
|
4937
|
+
applicationId: context.applicationId,
|
|
4938
|
+
organizationId: context.organizationId
|
|
4989
4939
|
});
|
|
4990
4940
|
return listIntegrationsForClark(rows);
|
|
4991
4941
|
}
|
|
@@ -5130,9 +5080,10 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5130
5080
|
],
|
|
5131
5081
|
updateApiInputs: ack,
|
|
5132
5082
|
updateScope: ack,
|
|
5133
|
-
// No browser tab means no viewport to photograph.
|
|
5134
|
-
//
|
|
5135
|
-
//
|
|
5083
|
+
// No browser tab means no viewport to photograph. The flag matters more
|
|
5084
|
+
// than the message: it tells the ai-service this was a refusal, not a
|
|
5085
|
+
// failed capture, so Clark can fall back to the sandbox's own browser
|
|
5086
|
+
// instead of reporting that it cannot see the app it just built.
|
|
5136
5087
|
aiCaptureScreenshot: [
|
|
5137
5088
|
async () => ({
|
|
5138
5089
|
error: "the headless gateway session has no browser viewport",
|
|
@@ -5144,13 +5095,13 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5144
5095
|
aiDeleteIntegration: setupUnavailable,
|
|
5145
5096
|
aiExecuteRequestToIntegration: [
|
|
5146
5097
|
async (payload) => {
|
|
5147
|
-
const
|
|
5148
|
-
if (!
|
|
5098
|
+
const context = deps?.getContext();
|
|
5099
|
+
if (!context) {
|
|
5149
5100
|
return {
|
|
5150
5101
|
error: "the headless gateway session cannot execute integration requests without an active prompt session"
|
|
5151
5102
|
};
|
|
5152
5103
|
}
|
|
5153
|
-
const result = await executeRequestToIntegrationViaOrchestrator(
|
|
5104
|
+
const result = await executeRequestToIntegrationViaOrchestrator(context, payload);
|
|
5154
5105
|
const name = payload.integrationHint?.name || payload.integrationId || "integration";
|
|
5155
5106
|
deps?.onToolRun?.({
|
|
5156
5107
|
detail: result,
|
|
@@ -5163,8 +5114,8 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5163
5114
|
],
|
|
5164
5115
|
aiExecuteSdkApi: [
|
|
5165
5116
|
async (payload) => {
|
|
5166
|
-
const
|
|
5167
|
-
if (!
|
|
5117
|
+
const context = deps?.getContext();
|
|
5118
|
+
if (!context) {
|
|
5168
5119
|
throw missingSessionError("execute SDK APIs");
|
|
5169
5120
|
}
|
|
5170
5121
|
if (!payload.entryPoint) {
|
|
@@ -5184,7 +5135,7 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5184
5135
|
return missing;
|
|
5185
5136
|
}
|
|
5186
5137
|
try {
|
|
5187
|
-
const inSync = await
|
|
5138
|
+
const inSync = await context.waitUntilFilesSynced();
|
|
5188
5139
|
if (!inSync) {
|
|
5189
5140
|
const syncing = {
|
|
5190
5141
|
success: false,
|
|
@@ -5201,15 +5152,15 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5201
5152
|
});
|
|
5202
5153
|
return syncing;
|
|
5203
5154
|
}
|
|
5204
|
-
const response = await
|
|
5205
|
-
apiKey:
|
|
5206
|
-
applicationId:
|
|
5207
|
-
branchName:
|
|
5155
|
+
const response = await context.orchestrator.executeSdkApiV3({
|
|
5156
|
+
apiKey: context.apiKey,
|
|
5157
|
+
applicationId: context.applicationId,
|
|
5158
|
+
branchName: context.branchName,
|
|
5208
5159
|
entryPoint: payload.entryPoint,
|
|
5209
5160
|
exportName: payload.exportName,
|
|
5210
5161
|
inputs: payload.input ?? {},
|
|
5211
|
-
profileKey:
|
|
5212
|
-
scopedToken:
|
|
5162
|
+
profileKey: context.profileKey,
|
|
5163
|
+
scopedToken: context.sessionToken
|
|
5213
5164
|
});
|
|
5214
5165
|
const mapped = mapSdkExecutionResponse(response);
|
|
5215
5166
|
deps?.onToolRun?.({
|
|
@@ -5239,8 +5190,8 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5239
5190
|
],
|
|
5240
5191
|
aiExecuteV2Api: [
|
|
5241
5192
|
async (payload) => {
|
|
5242
|
-
const
|
|
5243
|
-
if (!
|
|
5193
|
+
const context = deps?.getContext();
|
|
5194
|
+
if (!context) {
|
|
5244
5195
|
throw missingSessionError("execute V2 APIs");
|
|
5245
5196
|
}
|
|
5246
5197
|
if (payload.api.type === "fetch") {
|
|
@@ -5253,14 +5204,14 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5253
5204
|
...payload.api.definition,
|
|
5254
5205
|
metadata: {
|
|
5255
5206
|
...payload.api.definition.metadata ?? {},
|
|
5256
|
-
organization:
|
|
5207
|
+
organization: context.organizationId,
|
|
5257
5208
|
timestamps: { created: now, updated: now }
|
|
5258
5209
|
},
|
|
5259
5210
|
trigger: { application: {} }
|
|
5260
5211
|
};
|
|
5261
5212
|
try {
|
|
5262
|
-
const result = await
|
|
5263
|
-
apiKey:
|
|
5213
|
+
const result = await context.orchestrator.executeV2Api({
|
|
5214
|
+
apiKey: context.apiKey,
|
|
5264
5215
|
body: {
|
|
5265
5216
|
definition: { api: definition },
|
|
5266
5217
|
inputs: payload.inputs ?? {},
|
|
@@ -5271,10 +5222,10 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5271
5222
|
isAiTriggered: true,
|
|
5272
5223
|
suppressTracking: true
|
|
5273
5224
|
},
|
|
5274
|
-
...
|
|
5225
|
+
...context.profileKey ? { profile: { name: context.profileKey } } : {}
|
|
5275
5226
|
},
|
|
5276
|
-
profileKey:
|
|
5277
|
-
scopedToken:
|
|
5227
|
+
profileKey: context.profileKey,
|
|
5228
|
+
scopedToken: context.sessionToken
|
|
5278
5229
|
});
|
|
5279
5230
|
if (result && typeof result === "object" && "systemError" in result) {
|
|
5280
5231
|
return result;
|
|
@@ -5296,27 +5247,27 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5296
5247
|
],
|
|
5297
5248
|
aiGetIntegration: [
|
|
5298
5249
|
async (payload) => {
|
|
5299
|
-
const
|
|
5300
|
-
if (!
|
|
5250
|
+
const context = deps?.getContext();
|
|
5251
|
+
if (!context) {
|
|
5301
5252
|
throw missingSessionError("provide integration metadata");
|
|
5302
5253
|
}
|
|
5303
5254
|
let row;
|
|
5304
5255
|
try {
|
|
5305
|
-
row = await
|
|
5306
|
-
apiKey:
|
|
5256
|
+
row = await context.server.getIntegration({
|
|
5257
|
+
apiKey: context.apiKey,
|
|
5307
5258
|
integrationId: payload.integrationId
|
|
5308
5259
|
});
|
|
5309
5260
|
if (!row) {
|
|
5310
|
-
const rows = await
|
|
5311
|
-
apiKey:
|
|
5312
|
-
applicationId:
|
|
5313
|
-
organizationId:
|
|
5261
|
+
const rows = await context.server.getSupersetIntegrations({
|
|
5262
|
+
apiKey: context.apiKey,
|
|
5263
|
+
applicationId: context.applicationId,
|
|
5264
|
+
organizationId: context.organizationId
|
|
5314
5265
|
});
|
|
5315
5266
|
row = rows.find((candidate) => candidate.id === payload.integrationId);
|
|
5316
5267
|
}
|
|
5317
5268
|
} catch (error) {
|
|
5318
5269
|
console.warn("gateway failed to load integration for Clark", {
|
|
5319
|
-
applicationId:
|
|
5270
|
+
applicationId: context.applicationId,
|
|
5320
5271
|
integrationId: payload.integrationId,
|
|
5321
5272
|
message: error instanceof Error ? error.message : String(error)
|
|
5322
5273
|
});
|
|
@@ -5332,11 +5283,11 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5332
5283
|
}
|
|
5333
5284
|
let metadata = {};
|
|
5334
5285
|
try {
|
|
5335
|
-
metadata = await
|
|
5336
|
-
apiKey:
|
|
5286
|
+
metadata = await context.orchestrator.getMetadata({
|
|
5287
|
+
apiKey: context.apiKey,
|
|
5337
5288
|
integrationId: payload.integrationId,
|
|
5338
|
-
profileKey:
|
|
5339
|
-
scopedToken:
|
|
5289
|
+
profileKey: context.profileKey,
|
|
5290
|
+
scopedToken: context.sessionToken
|
|
5340
5291
|
});
|
|
5341
5292
|
} catch {
|
|
5342
5293
|
metadata = {};
|
|
@@ -5358,15 +5309,15 @@ function createEditorClientMethods(getListener, onInbound, deps) {
|
|
|
5358
5309
|
],
|
|
5359
5310
|
aiGetIntegrations: [
|
|
5360
5311
|
async () => {
|
|
5361
|
-
const
|
|
5362
|
-
if (!
|
|
5312
|
+
const context = deps?.getContext();
|
|
5313
|
+
if (!context) {
|
|
5363
5314
|
return [];
|
|
5364
5315
|
}
|
|
5365
5316
|
try {
|
|
5366
|
-
return await loadIntegrationsForPrompt(
|
|
5317
|
+
return await loadIntegrationsForPrompt(context);
|
|
5367
5318
|
} catch (error) {
|
|
5368
5319
|
console.warn("gateway failed to list integrations for Clark", {
|
|
5369
|
-
applicationId:
|
|
5320
|
+
applicationId: context.applicationId,
|
|
5370
5321
|
message: error instanceof Error ? error.message : String(error)
|
|
5371
5322
|
});
|
|
5372
5323
|
return [];
|
|
@@ -5467,7 +5418,6 @@ function truncate(text, max = RECENT_TOOL_RUN_SUMMARY_MAX) {
|
|
|
5467
5418
|
var GENERATE_METHOD = "editor.aiGenerateWithQueue";
|
|
5468
5419
|
var ACCEPT_DRAFT_METHOD = "editor.aiAcceptDraft";
|
|
5469
5420
|
var RELOAD_CHAT_METHOD = "editor.aiChatGetMessages";
|
|
5470
|
-
var RELEASE_TURN_LOCK_METHOD = "editor.releaseTurnLock";
|
|
5471
5421
|
var RESPOND_TOOL_PERMISSION_METHOD = "editor.aiRespondToToolPermission";
|
|
5472
5422
|
var PING_METHOD = "editor.ping";
|
|
5473
5423
|
var DEFAULT_TIMEOUT_MS3 = 12e4;
|
|
@@ -5809,7 +5759,6 @@ var WebSocketSessionPeer = class {
|
|
|
5809
5759
|
this.failedStarts.set(input, {
|
|
5810
5760
|
generationStatus: "live_edit_terminated",
|
|
5811
5761
|
reply: input.reason,
|
|
5812
|
-
...input.retryAction ? { retryAction: input.retryAction } : {},
|
|
5813
5762
|
// Nothing ran, so nothing is viewable. Reporting "ready" here is how a
|
|
5814
5763
|
// caller comes to show the untouched starter template as the app.
|
|
5815
5764
|
viewStatus: "unknown"
|
|
@@ -5842,11 +5791,7 @@ var WebSocketSessionPeer = class {
|
|
|
5842
5791
|
}
|
|
5843
5792
|
const failed = this.failedStarts.get(input);
|
|
5844
5793
|
if (failed) {
|
|
5845
|
-
return {
|
|
5846
|
-
generationStatus: failed.generationStatus,
|
|
5847
|
-
phase: "finished",
|
|
5848
|
-
...failed.retryAction ? { retryAction: failed.retryAction } : {}
|
|
5849
|
-
};
|
|
5794
|
+
return { generationStatus: failed.generationStatus, phase: "finished" };
|
|
5850
5795
|
}
|
|
5851
5796
|
if (!turn?.finished) {
|
|
5852
5797
|
return void 0;
|
|
@@ -5854,8 +5799,7 @@ var WebSocketSessionPeer = class {
|
|
|
5854
5799
|
return {
|
|
5855
5800
|
...turn.finished.checkpointCommitId ? { checkpointCommitId: turn.finished.checkpointCommitId } : {},
|
|
5856
5801
|
generationStatus: turn.finished.generationStatus,
|
|
5857
|
-
phase: "finished"
|
|
5858
|
-
...turn.retryAction ? { retryAction: turn.retryAction } : {}
|
|
5802
|
+
phase: "finished"
|
|
5859
5803
|
};
|
|
5860
5804
|
}
|
|
5861
5805
|
clearPendingPlan(applicationId) {
|
|
@@ -6001,7 +5945,6 @@ var WebSocketSessionPeer = class {
|
|
|
6001
5945
|
normalized: void 0,
|
|
6002
5946
|
recentRuns: [],
|
|
6003
5947
|
reconnects: 0,
|
|
6004
|
-
...input.attachments?.length ? { retryAction: "retry_import" } : {},
|
|
6005
5948
|
startedAt: Date.now(),
|
|
6006
5949
|
turnId: randomUUID3(),
|
|
6007
5950
|
unsubscribe: () => void 0,
|
|
@@ -6062,7 +6005,6 @@ var WebSocketSessionPeer = class {
|
|
|
6062
6005
|
jwt: input.sessionToken,
|
|
6063
6006
|
llmConfig: {
|
|
6064
6007
|
coreModel: this.options.coreModel ?? DEFAULT_LLM.coreModel,
|
|
6065
|
-
disabledTools: ["build_captureScreenshot", "build_navigatePreview"],
|
|
6066
6008
|
// The ai-service gates Clark's testing tools on this flag *and* a
|
|
6067
6009
|
// browser context, so the two travel together or not at all.
|
|
6068
6010
|
...browserContext ? { flags: { isTestingEnabled: true } } : {},
|
|
@@ -6168,7 +6110,6 @@ var WebSocketSessionPeer = class {
|
|
|
6168
6110
|
elapsedMs,
|
|
6169
6111
|
status: "finished",
|
|
6170
6112
|
...turn.finished,
|
|
6171
|
-
...turn.retryAction ? { retryAction: turn.retryAction } : {},
|
|
6172
6113
|
...recentRuns ? { recentRuns } : {}
|
|
6173
6114
|
};
|
|
6174
6115
|
}
|
|
@@ -6309,15 +6250,6 @@ var WebSocketSessionPeer = class {
|
|
|
6309
6250
|
collector.dispose();
|
|
6310
6251
|
const stillMapped = this.turns.get(input.applicationId) === turn;
|
|
6311
6252
|
if (stillMapped) {
|
|
6312
|
-
try {
|
|
6313
|
-
await turn.held.client.requestWithTracing(RELEASE_TURN_LOCK_METHOD, this.turnCorrelator(turn.turnId), {}, `Bearer ${input.sessionToken}`);
|
|
6314
|
-
} catch (error) {
|
|
6315
|
-
console.warn("gateway could not release the live-edit turn lock", {
|
|
6316
|
-
applicationId: input.applicationId,
|
|
6317
|
-
message: describeSocketError(error),
|
|
6318
|
-
turnId: turn.turnId
|
|
6319
|
-
});
|
|
6320
|
-
}
|
|
6321
6253
|
if (turn.finished?.generationStatus === "needs_decision") {
|
|
6322
6254
|
this.armIdle(turn.held);
|
|
6323
6255
|
} else {
|
|
@@ -6734,7 +6666,7 @@ var WebSocketSessionPeer = class {
|
|
|
6734
6666
|
const heldRef = {
|
|
6735
6667
|
current: void 0
|
|
6736
6668
|
};
|
|
6737
|
-
const socket = new
|
|
6669
|
+
const socket = new import_shared5.ISocket(ws, createEditorClientMethods(() => {
|
|
6738
6670
|
const listeners = heldRef.current?.listeners;
|
|
6739
6671
|
if (!listeners || listeners.size === 0) {
|
|
6740
6672
|
return void 0;
|
|
@@ -6811,7 +6743,7 @@ var WebSocketSessionPeer = class {
|
|
|
6811
6743
|
noResponseTimeoutInSeconds: (this.options.timeoutMs ?? DEFAULT_TIMEOUT_MS3) / 1e3
|
|
6812
6744
|
}
|
|
6813
6745
|
});
|
|
6814
|
-
const client = (0,
|
|
6746
|
+
const client = (0, import_shared5.createISocketClient)(socket);
|
|
6815
6747
|
const heartbeat = this.buildHeartbeat(heldRef);
|
|
6816
6748
|
const held = {
|
|
6817
6749
|
applicationId: input.applicationId,
|
|
@@ -6847,7 +6779,7 @@ var WebSocketSessionPeer = class {
|
|
|
6847
6779
|
* who to tell.
|
|
6848
6780
|
*/
|
|
6849
6781
|
buildHeartbeat(heldRef) {
|
|
6850
|
-
return new
|
|
6782
|
+
return new import_shared5.SocketHeartbeat({
|
|
6851
6783
|
beat: async () => {
|
|
6852
6784
|
const held = heldRef.current;
|
|
6853
6785
|
if (!held?.sessionToken) {
|
|
@@ -7374,233 +7306,6 @@ var WebSocketSessionPeer = class {
|
|
|
7374
7306
|
}
|
|
7375
7307
|
};
|
|
7376
7308
|
|
|
7377
|
-
// ../../../gateway/dist/telemetry/runtime.js
|
|
7378
|
-
init_cjs_shims();
|
|
7379
|
-
|
|
7380
|
-
// ../../../gateway/dist/telemetry/mcp-client.js
|
|
7381
|
-
init_cjs_shims();
|
|
7382
|
-
init_esm();
|
|
7383
|
-
function bounded(value, maxLength) {
|
|
7384
|
-
return value.slice(0, maxLength);
|
|
7385
|
-
}
|
|
7386
|
-
function stringProperty(value, key2) {
|
|
7387
|
-
if (typeof value !== "object" || value === null || !(key2 in value)) {
|
|
7388
|
-
return void 0;
|
|
7389
|
-
}
|
|
7390
|
-
const property = Reflect.get(value, key2);
|
|
7391
|
-
return typeof property === "string" ? property : void 0;
|
|
7392
|
-
}
|
|
7393
|
-
var McpClientTelemetry = class {
|
|
7394
|
-
tracer;
|
|
7395
|
-
ended = false;
|
|
7396
|
-
hadError = false;
|
|
7397
|
-
organizationId;
|
|
7398
|
-
sessionContext;
|
|
7399
|
-
sessionSpan;
|
|
7400
|
-
constructor(tracer) {
|
|
7401
|
-
this.tracer = tracer;
|
|
7402
|
-
this.sessionSpan = tracer.startSpan("gen_ai.request", {
|
|
7403
|
-
attributes: {
|
|
7404
|
-
"gen_ai.operation.name": "invoke_agent"
|
|
7405
|
-
}
|
|
7406
|
-
});
|
|
7407
|
-
this.sessionContext = trace.setSpan(context.active(), this.sessionSpan);
|
|
7408
|
-
}
|
|
7409
|
-
setOrganizationId(organizationId) {
|
|
7410
|
-
this.organizationId = organizationId;
|
|
7411
|
-
this.sessionSpan.setAttribute("organization.id", organizationId);
|
|
7412
|
-
}
|
|
7413
|
-
async runTool(call, operation) {
|
|
7414
|
-
const attributes = {
|
|
7415
|
-
"gen_ai.operation.name": "execute_tool",
|
|
7416
|
-
...call.client ? {
|
|
7417
|
-
"mcp.client.name": bounded(call.client.name, 80),
|
|
7418
|
-
...call.client.version ? {
|
|
7419
|
-
"mcp.client.version": bounded(call.client.version, 40)
|
|
7420
|
-
} : {}
|
|
7421
|
-
} : {},
|
|
7422
|
-
...this.organizationId ? { "organization.id": this.organizationId } : {},
|
|
7423
|
-
"tool.name": bounded(call.toolName, 80)
|
|
7424
|
-
};
|
|
7425
|
-
if (call.client) {
|
|
7426
|
-
this.sessionSpan.setAttributes({
|
|
7427
|
-
"mcp.client.name": bounded(call.client.name, 80),
|
|
7428
|
-
...call.client.version ? { "mcp.client.version": bounded(call.client.version, 40) } : {}
|
|
7429
|
-
});
|
|
7430
|
-
}
|
|
7431
|
-
let span;
|
|
7432
|
-
try {
|
|
7433
|
-
span = this.tracer.startSpan("gen_ai.tool_call", { attributes }, this.sessionContext);
|
|
7434
|
-
} catch {
|
|
7435
|
-
return operation();
|
|
7436
|
-
}
|
|
7437
|
-
const startedAt = Date.now();
|
|
7438
|
-
try {
|
|
7439
|
-
const result = await context.with(trace.setSpan(this.sessionContext, span), operation);
|
|
7440
|
-
span.setAttribute("tool.duration_ms", Date.now() - startedAt);
|
|
7441
|
-
if (this.organizationId) {
|
|
7442
|
-
span.setAttribute("organization.id", this.organizationId);
|
|
7443
|
-
}
|
|
7444
|
-
if (result.kind === "error") {
|
|
7445
|
-
this.hadError = true;
|
|
7446
|
-
span.setAttributes({
|
|
7447
|
-
...result.applicationId ? { "application.id": result.applicationId } : {},
|
|
7448
|
-
"mcp.error.code": bounded(result.code, 80),
|
|
7449
|
-
"tool.error_category": result.code === "cancelled" ? "timeout" : "execution_error",
|
|
7450
|
-
"tool.status": "error"
|
|
7451
|
-
});
|
|
7452
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
7453
|
-
} else if (result.kind === "auth_required") {
|
|
7454
|
-
this.hadError = true;
|
|
7455
|
-
span.setAttributes({
|
|
7456
|
-
"mcp.result.status": "auth_required",
|
|
7457
|
-
"tool.error_category": "permission_denied",
|
|
7458
|
-
"tool.status": "error"
|
|
7459
|
-
});
|
|
7460
|
-
} else {
|
|
7461
|
-
const applicationId = stringProperty(result.value, "applicationId");
|
|
7462
|
-
const resultStatus = stringProperty(result.value, "status");
|
|
7463
|
-
span.setAttributes({
|
|
7464
|
-
...applicationId ? { "application.id": applicationId } : {},
|
|
7465
|
-
...resultStatus ? { "mcp.result.status": bounded(resultStatus, 80) } : {},
|
|
7466
|
-
"tool.error_category": "none",
|
|
7467
|
-
"tool.status": "success"
|
|
7468
|
-
});
|
|
7469
|
-
}
|
|
7470
|
-
return result;
|
|
7471
|
-
} catch (error) {
|
|
7472
|
-
this.hadError = true;
|
|
7473
|
-
span.setAttributes({
|
|
7474
|
-
"tool.duration_ms": Date.now() - startedAt,
|
|
7475
|
-
"tool.error_category": "execution_error",
|
|
7476
|
-
"tool.status": "error"
|
|
7477
|
-
});
|
|
7478
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
7479
|
-
throw error;
|
|
7480
|
-
} finally {
|
|
7481
|
-
span.end();
|
|
7482
|
-
}
|
|
7483
|
-
}
|
|
7484
|
-
endSession() {
|
|
7485
|
-
if (this.ended) {
|
|
7486
|
-
return;
|
|
7487
|
-
}
|
|
7488
|
-
this.ended = true;
|
|
7489
|
-
this.sessionSpan.setAttribute("gen_ai.request.status", this.hadError ? "error" : "success");
|
|
7490
|
-
this.sessionSpan.end();
|
|
7491
|
-
}
|
|
7492
|
-
};
|
|
7493
|
-
|
|
7494
|
-
// ../../../gateway/dist/telemetry/runtime.js
|
|
7495
|
-
var TELEMETRY_SHUTDOWN_MS = 2e3;
|
|
7496
|
-
function logToStderr(first, message) {
|
|
7497
|
-
if (message === void 0) {
|
|
7498
|
-
console.error(first);
|
|
7499
|
-
return;
|
|
7500
|
-
}
|
|
7501
|
-
console.error(first, message);
|
|
7502
|
-
}
|
|
7503
|
-
var stderrLogger = {
|
|
7504
|
-
error: logToStderr,
|
|
7505
|
-
info: logToStderr,
|
|
7506
|
-
warn: logToStderr
|
|
7507
|
-
};
|
|
7508
|
-
function telemetryBaseUrl(serverUrl) {
|
|
7509
|
-
try {
|
|
7510
|
-
const url = new URL(serverUrl);
|
|
7511
|
-
url.hash = "";
|
|
7512
|
-
url.pathname = `${url.pathname.replace(/\/$/u, "")}/api`;
|
|
7513
|
-
url.search = "";
|
|
7514
|
-
return url.toString().replace(/\/$/u, "");
|
|
7515
|
-
} catch {
|
|
7516
|
-
console.error("gateway telemetry skipped: server URL is not parseable");
|
|
7517
|
-
return void 0;
|
|
7518
|
-
}
|
|
7519
|
-
}
|
|
7520
|
-
function environmentName(config) {
|
|
7521
|
-
if (config.deploymentEnvironmentName !== "unknown") {
|
|
7522
|
-
return config.deploymentEnvironmentName;
|
|
7523
|
-
}
|
|
7524
|
-
try {
|
|
7525
|
-
return environmentFromHostname(new URL(config.serverUrl).hostname);
|
|
7526
|
-
} catch {
|
|
7527
|
-
return "unknown";
|
|
7528
|
-
}
|
|
7529
|
-
}
|
|
7530
|
-
function environmentFromHostname(hostname) {
|
|
7531
|
-
if (hostname.match(/^app\.superblocks(?:hq)?\.com$/u)) {
|
|
7532
|
-
return "prod";
|
|
7533
|
-
}
|
|
7534
|
-
if (hostname.match(/^eu\.superblocks(?:hq)?\.com$/u)) {
|
|
7535
|
-
return "prod-eu";
|
|
7536
|
-
}
|
|
7537
|
-
if (hostname.match(/^staging\.superblocks(?:hq)?\.com$/u)) {
|
|
7538
|
-
return "staging";
|
|
7539
|
-
}
|
|
7540
|
-
if (hostname.match(/^dev\.superblocks(?:hq)?\.com$/u)) {
|
|
7541
|
-
return "dev";
|
|
7542
|
-
}
|
|
7543
|
-
if (hostname.match(/^pr-[0-9]+\.superblocks(?:hq)?\.dev$/u)) {
|
|
7544
|
-
return "ephemeral";
|
|
7545
|
-
}
|
|
7546
|
-
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
7547
|
-
return "local";
|
|
7548
|
-
}
|
|
7549
|
-
return "other";
|
|
7550
|
-
}
|
|
7551
|
-
function deploymentTypeFor(config) {
|
|
7552
|
-
if (config.localAgentMode) {
|
|
7553
|
-
return import_shared.DeploymentTypeEnum.CLOUD_PREM;
|
|
7554
|
-
}
|
|
7555
|
-
try {
|
|
7556
|
-
return parseDeploymentType(process.env.SUPERBLOCKS_DEPLOYMENT_TYPE);
|
|
7557
|
-
} catch {
|
|
7558
|
-
return import_shared.DeploymentTypeEnum.CLOUD;
|
|
7559
|
-
}
|
|
7560
|
-
}
|
|
7561
|
-
async function settleWithin(work, timeoutMs) {
|
|
7562
|
-
let timer;
|
|
7563
|
-
try {
|
|
7564
|
-
await Promise.race([
|
|
7565
|
-
work,
|
|
7566
|
-
new Promise((resolve) => {
|
|
7567
|
-
timer = setTimeout(resolve, timeoutMs);
|
|
7568
|
-
})
|
|
7569
|
-
]);
|
|
7570
|
-
} finally {
|
|
7571
|
-
if (timer !== void 0) {
|
|
7572
|
-
clearTimeout(timer);
|
|
7573
|
-
}
|
|
7574
|
-
}
|
|
7575
|
-
}
|
|
7576
|
-
function startGatewayTelemetry(input) {
|
|
7577
|
-
const otlpUrl = telemetryBaseUrl(input.config.serverUrl);
|
|
7578
|
-
const telemetry = initNodeTelemetry({
|
|
7579
|
-
environment: environmentName(input.config),
|
|
7580
|
-
logger: stderrLogger,
|
|
7581
|
-
logsEnabled: false,
|
|
7582
|
-
// Counters in metrics.ts are created at import time, before this SDK
|
|
7583
|
-
// starts, so they stay no-ops. Do not turn metrics on until those
|
|
7584
|
-
// instruments are created after init.
|
|
7585
|
-
metricsEnabled: false,
|
|
7586
|
-
otlpHeaders: { Authorization: `Bearer ${input.apiKey}` },
|
|
7587
|
-
...otlpUrl ? { otlpUrl } : {},
|
|
7588
|
-
serviceName: "gateway",
|
|
7589
|
-
serviceVersion: "0.0.1"
|
|
7590
|
-
}, getDefaultPolicy(deploymentTypeFor(input.config)));
|
|
7591
|
-
const mcpTelemetry = new McpClientTelemetry(telemetry.getTracer("gateway.mcp"));
|
|
7592
|
-
return {
|
|
7593
|
-
mcpTelemetry,
|
|
7594
|
-
shutdown: async () => {
|
|
7595
|
-
try {
|
|
7596
|
-
mcpTelemetry.endSession();
|
|
7597
|
-
} finally {
|
|
7598
|
-
await settleWithin(telemetry.shutdown(), TELEMETRY_SHUTDOWN_MS);
|
|
7599
|
-
}
|
|
7600
|
-
}
|
|
7601
|
-
};
|
|
7602
|
-
}
|
|
7603
|
-
|
|
7604
7309
|
// ../../../gateway/dist/transports/mcp/mount.js
|
|
7605
7310
|
init_cjs_shims();
|
|
7606
7311
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -7700,150 +7405,6 @@ function N3(Z, $, J, X, V) {
|
|
|
7700
7405
|
return Z.registerResource($, J, { mimeType: p, ...X }, V);
|
|
7701
7406
|
}
|
|
7702
7407
|
|
|
7703
|
-
// ../../../gateway/dist/capabilities/integration-metadata.js
|
|
7704
|
-
init_cjs_shims();
|
|
7705
|
-
var DEFAULT_LIMIT = 100;
|
|
7706
|
-
function labelPart(value) {
|
|
7707
|
-
return typeof value === "string" ? value.trim().replaceAll(/[.[\]]/g, "_") : "";
|
|
7708
|
-
}
|
|
7709
|
-
function arrayEntryLabel(value, index) {
|
|
7710
|
-
if (value && typeof value === "object") {
|
|
7711
|
-
const row = value;
|
|
7712
|
-
const name = labelPart(row.name);
|
|
7713
|
-
if (name) {
|
|
7714
|
-
const schema = labelPart(row.schema);
|
|
7715
|
-
return schema ? `${schema}.${name}` : name;
|
|
7716
|
-
}
|
|
7717
|
-
}
|
|
7718
|
-
return String(index);
|
|
7719
|
-
}
|
|
7720
|
-
function metadataEntries(value, path3 = "", entries = []) {
|
|
7721
|
-
if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") {
|
|
7722
|
-
entries.push({ path: path3, value });
|
|
7723
|
-
return entries;
|
|
7724
|
-
}
|
|
7725
|
-
if (Array.isArray(value)) {
|
|
7726
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7727
|
-
value.forEach((entry, index) => {
|
|
7728
|
-
const label = arrayEntryLabel(entry, index);
|
|
7729
|
-
const unique = seen.has(label) ? `${label}#${index}` : label;
|
|
7730
|
-
seen.add(unique);
|
|
7731
|
-
metadataEntries(entry, `${path3}[${unique}]`, entries);
|
|
7732
|
-
});
|
|
7733
|
-
return entries;
|
|
7734
|
-
}
|
|
7735
|
-
if (value && typeof value === "object") {
|
|
7736
|
-
for (const [key2, entry] of Object.entries(value)) {
|
|
7737
|
-
metadataEntries(entry, path3 ? `${path3}.${key2}` : key2, entries);
|
|
7738
|
-
}
|
|
7739
|
-
}
|
|
7740
|
-
return entries;
|
|
7741
|
-
}
|
|
7742
|
-
async function getIntegrationMetadata(context2, input) {
|
|
7743
|
-
const principal = await ensurePrincipal(context2);
|
|
7744
|
-
if (principal.kind !== "ok") {
|
|
7745
|
-
return principal;
|
|
7746
|
-
}
|
|
7747
|
-
let applicationId;
|
|
7748
|
-
let label = sanitizeAgentFacingText(input.integrationId);
|
|
7749
|
-
try {
|
|
7750
|
-
const resolved = await resolveApplicationId(context2, principal.value, input.applicationId);
|
|
7751
|
-
applicationId = resolved.kind === "ok" ? resolved.value : void 0;
|
|
7752
|
-
const rows = await context2.server.getSupersetIntegrations({
|
|
7753
|
-
apiKey: principal.value.apiKey,
|
|
7754
|
-
...applicationId && { applicationId },
|
|
7755
|
-
organizationId: principal.value.organizationId
|
|
7756
|
-
});
|
|
7757
|
-
const integration = rows.find((row) => row.id === input.integrationId);
|
|
7758
|
-
if (!integration) {
|
|
7759
|
-
return {
|
|
7760
|
-
...applicationId && { applicationId },
|
|
7761
|
-
kind: "error",
|
|
7762
|
-
code: "integration_not_accessible",
|
|
7763
|
-
message: `Integration ${label} was not found or is not accessible.`
|
|
7764
|
-
};
|
|
7765
|
-
}
|
|
7766
|
-
const integrationName = sanitizeAgentFacingText(integration.name);
|
|
7767
|
-
const pluginId = sanitizeAgentFacingText(integration.pluginId);
|
|
7768
|
-
label = integrationName;
|
|
7769
|
-
if (!hasBuildPermission(integration)) {
|
|
7770
|
-
return {
|
|
7771
|
-
...applicationId && { applicationId },
|
|
7772
|
-
kind: "error",
|
|
7773
|
-
code: "integration_not_permitted",
|
|
7774
|
-
message: `You do not have build permission on ${integrationName}.`
|
|
7775
|
-
};
|
|
7776
|
-
}
|
|
7777
|
-
if (!integrationIsToolSupported(integration.pluginId)) {
|
|
7778
|
-
return {
|
|
7779
|
-
...applicationId && { applicationId },
|
|
7780
|
-
kind: "error",
|
|
7781
|
-
code: "integration_not_supported",
|
|
7782
|
-
message: `${integrationName} is a ${pluginId} integration, which this tool cannot inspect.`
|
|
7783
|
-
};
|
|
7784
|
-
}
|
|
7785
|
-
const profiles = await context2.server.getOrganizationProfiles({
|
|
7786
|
-
apiKey: principal.value.apiKey,
|
|
7787
|
-
organizationId: principal.value.organizationId
|
|
7788
|
-
});
|
|
7789
|
-
const profileKey = pickEditorProfileKey(context2.config.profileKey, profiles);
|
|
7790
|
-
const inventory = await context2.server.getAgentInventory({
|
|
7791
|
-
apiKey: principal.value.apiKey,
|
|
7792
|
-
organizationId: principal.value.organizationId
|
|
7793
|
-
});
|
|
7794
|
-
const orchestratorUrl = pickOrchestratorBaseUrl({
|
|
7795
|
-
agentType: inventory.agentType,
|
|
7796
|
-
agents: inventory.agents,
|
|
7797
|
-
profileKey
|
|
7798
|
-
});
|
|
7799
|
-
const scopedToken = await context2.server.issueScopedToken(applicationId ? {
|
|
7800
|
-
apiKey: principal.value.apiKey,
|
|
7801
|
-
applicationId,
|
|
7802
|
-
scope: "apps:update"
|
|
7803
|
-
} : {
|
|
7804
|
-
apiKey: principal.value.apiKey,
|
|
7805
|
-
integrationId: input.integrationId,
|
|
7806
|
-
scope: "integrations:build"
|
|
7807
|
-
});
|
|
7808
|
-
const metadata = await new HttpOrchestratorClient(orchestratorUrl).getMetadata({
|
|
7809
|
-
apiKey: principal.value.apiKey,
|
|
7810
|
-
integrationId: input.integrationId,
|
|
7811
|
-
profileKey,
|
|
7812
|
-
scopedToken
|
|
7813
|
-
});
|
|
7814
|
-
const sanitized = sanitizeAgentFacingValue(metadata);
|
|
7815
|
-
const search = input.search?.trim().toLowerCase();
|
|
7816
|
-
const matched = metadataEntries(sanitized).filter((entry) => !search || entry.path.toLowerCase().includes(search) || String(entry.value).toLowerCase().includes(search));
|
|
7817
|
-
const limit = input.limit ?? DEFAULT_LIMIT;
|
|
7818
|
-
const offset = input.offset ?? 0;
|
|
7819
|
-
const entries = matched.slice(offset, offset + limit);
|
|
7820
|
-
const nextOffset = offset + entries.length < matched.length ? offset + entries.length : null;
|
|
7821
|
-
return {
|
|
7822
|
-
kind: "ok",
|
|
7823
|
-
value: {
|
|
7824
|
-
...applicationId && { applicationId },
|
|
7825
|
-
entries,
|
|
7826
|
-
hasMore: nextOffset !== null,
|
|
7827
|
-
integrationId: integration.id,
|
|
7828
|
-
integrationName,
|
|
7829
|
-
nextOffset,
|
|
7830
|
-
offset,
|
|
7831
|
-
pluginId,
|
|
7832
|
-
returnedCount: entries.length,
|
|
7833
|
-
totalCount: matched.length
|
|
7834
|
-
}
|
|
7835
|
-
};
|
|
7836
|
-
} catch (error) {
|
|
7837
|
-
const detail = sanitizeAgentFacingText(error instanceof Error ? error.message : "Unknown metadata error").replaceAll("\u2014", "-");
|
|
7838
|
-
return {
|
|
7839
|
-
...applicationId && { applicationId },
|
|
7840
|
-
kind: "error",
|
|
7841
|
-
code: "integration_metadata_unavailable",
|
|
7842
|
-
message: `Could not load metadata for ${label}: ${detail}`
|
|
7843
|
-
};
|
|
7844
|
-
}
|
|
7845
|
-
}
|
|
7846
|
-
|
|
7847
7408
|
// ../../../gateway/dist/capture/browser-instructions.js
|
|
7848
7409
|
init_cjs_shims();
|
|
7849
7410
|
var BROWSER_DRIVER_INSTRUCTIONS = `Browser capture (MUST):
|
|
@@ -8505,16 +8066,6 @@ function resolveToken(options, auth) {
|
|
|
8505
8066
|
function superblocksProductCopy(text) {
|
|
8506
8067
|
return text.replaceAll(/\bClark AI Apps\b/g, "Superblocks AI Apps").replaceAll(/\bClark\b/g, "Superblocks");
|
|
8507
8068
|
}
|
|
8508
|
-
function completeToolAnnotations(annotations) {
|
|
8509
|
-
const readOnlyHint = annotations?.readOnlyHint ?? false;
|
|
8510
|
-
return {
|
|
8511
|
-
...annotations,
|
|
8512
|
-
destructiveHint: annotations?.destructiveHint ?? (readOnlyHint ? false : true),
|
|
8513
|
-
idempotentHint: annotations?.idempotentHint ?? readOnlyHint,
|
|
8514
|
-
openWorldHint: annotations?.openWorldHint ?? true,
|
|
8515
|
-
readOnlyHint
|
|
8516
|
-
};
|
|
8517
|
-
}
|
|
8518
8069
|
function registerAdminTools(server, options) {
|
|
8519
8070
|
const registry = buildToolRegistry(toolDefinitions, "customer", {
|
|
8520
8071
|
requireEntitledPlan: options.localAgentMode !== true
|
|
@@ -8525,7 +8076,7 @@ function registerAdminTools(server, options) {
|
|
|
8525
8076
|
}
|
|
8526
8077
|
const definition = toolDefinitions.find((d2) => d2.name === tool.name);
|
|
8527
8078
|
server.registerTool(tool.name, {
|
|
8528
|
-
annotations:
|
|
8079
|
+
annotations: tool.annotations,
|
|
8529
8080
|
description: superblocksProductCopy(tool.description ?? ""),
|
|
8530
8081
|
inputSchema: gatewayAdminInputShape(tool.inputSchema),
|
|
8531
8082
|
title: tool.title ?? definition?.title
|
|
@@ -8566,7 +8117,7 @@ function registerAdminTools(server, options) {
|
|
|
8566
8117
|
|
|
8567
8118
|
// ../../../gateway/dist/transports/mcp/app-status-html.js
|
|
8568
8119
|
init_cjs_shims();
|
|
8569
|
-
var APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-
|
|
8120
|
+
var APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-v6.html";
|
|
8570
8121
|
var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
8571
8122
|
<html lang="en">
|
|
8572
8123
|
<head>
|
|
@@ -8680,29 +8231,11 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8680
8231
|
<script>
|
|
8681
8232
|
(() => {
|
|
8682
8233
|
const PROTOCOL_VERSION = "2026-01-26";
|
|
8683
|
-
// Statuses get_app reports when the app is still the empty starter
|
|
8684
|
-
// template. "building" is deliberately absent: the card only hears a
|
|
8685
|
-
// build finished if a new result arrives, so a stale badge would strand
|
|
8686
|
-
// the button.
|
|
8687
|
-
const UNBUILT_STATUSES = [
|
|
8688
|
-
"cancelled",
|
|
8689
|
-
"live_edit_terminated",
|
|
8690
|
-
"needs_decision",
|
|
8691
|
-
"no_changes",
|
|
8692
|
-
"timeout",
|
|
8693
|
-
];
|
|
8694
|
-
const BLOCKED_ACTIONS = [
|
|
8695
|
-
"answer_question",
|
|
8696
|
-
"approve_plan",
|
|
8697
|
-
"retry_build",
|
|
8698
|
-
"retry_import",
|
|
8699
|
-
];
|
|
8700
8234
|
let nextId = 1;
|
|
8701
8235
|
const pending = new Map();
|
|
8702
8236
|
let applicationId = "";
|
|
8703
8237
|
let appName = "";
|
|
8704
8238
|
let commitId = "";
|
|
8705
|
-
let pendingAction = "";
|
|
8706
8239
|
let editUrl = "";
|
|
8707
8240
|
let previewUrl = "";
|
|
8708
8241
|
let publishUrl = "";
|
|
@@ -8710,13 +8243,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8710
8243
|
let canCallTools = false;
|
|
8711
8244
|
let publishing = false;
|
|
8712
8245
|
let lastHeight = 0;
|
|
8713
|
-
let refreshInFlight = false;
|
|
8714
|
-
let refreshTimer = 0;
|
|
8715
|
-
let refreshGeneration = 0;
|
|
8716
|
-
let refreshAttempts = 0;
|
|
8717
|
-
let pollAfterMs = 2000;
|
|
8718
|
-
const MIN_POLL_MS = 2000;
|
|
8719
|
-
const MAX_REFRESH_ATTEMPTS = 40;
|
|
8720
8246
|
|
|
8721
8247
|
function post(message) {
|
|
8722
8248
|
window.parent.postMessage(message, "*");
|
|
@@ -8806,31 +8332,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8806
8332
|
}
|
|
8807
8333
|
}
|
|
8808
8334
|
|
|
8809
|
-
/**
|
|
8810
|
-
* True when publishing would deploy the empty starter template.
|
|
8811
|
-
* pendingAction is the server's own "nothing to preview" signal;
|
|
8812
|
-
* wait_for_build is the building exception. Status is only a fallback
|
|
8813
|
-
* when the payload omitted pendingAction. loading/waiting with no
|
|
8814
|
-
* preview fail closed so Publish is not clickable before get_app
|
|
8815
|
-
* returns.
|
|
8816
|
-
*/
|
|
8817
|
-
function nothingToPublish() {
|
|
8818
|
-
if (previewUrl || publishUrl) {
|
|
8819
|
-
return false;
|
|
8820
|
-
}
|
|
8821
|
-
if (pendingAction === "wait_for_build") {
|
|
8822
|
-
return false;
|
|
8823
|
-
}
|
|
8824
|
-
if (BLOCKED_ACTIONS.indexOf(pendingAction) !== -1) {
|
|
8825
|
-
return true;
|
|
8826
|
-
}
|
|
8827
|
-
const badge = element("status").textContent;
|
|
8828
|
-
if (!badge || badge === "loading" || badge === "waiting") {
|
|
8829
|
-
return true;
|
|
8830
|
-
}
|
|
8831
|
-
return UNBUILT_STATUSES.indexOf(badge) !== -1;
|
|
8832
|
-
}
|
|
8833
|
-
|
|
8834
8335
|
/**
|
|
8835
8336
|
* Keep URLs in memory for openLink \u2014 never print them (preview JWTs are
|
|
8836
8337
|
* huge and ugly in the card).
|
|
@@ -8845,10 +8346,7 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8845
8346
|
: "Publish app";
|
|
8846
8347
|
element("publishApp").disabled = publishUrl
|
|
8847
8348
|
? !canOpenLinks
|
|
8848
|
-
: !applicationId ||
|
|
8849
|
-
!canCallTools ||
|
|
8850
|
-
publishing ||
|
|
8851
|
-
nothingToPublish();
|
|
8349
|
+
: !applicationId || !canCallTools || publishing;
|
|
8852
8350
|
// Only warn about what is actually broken. Hosts that do open links
|
|
8853
8351
|
// handle local http fine; if one refuses, refused() says so then.
|
|
8854
8352
|
if (!canOpenLinks && (editUrl || previewUrl) && !publishUrl) {
|
|
@@ -8920,11 +8418,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8920
8418
|
if (typeof value.commitId === "string") {
|
|
8921
8419
|
commitId = value.commitId;
|
|
8922
8420
|
}
|
|
8923
|
-
if (typeof value.pendingAction === "string") {
|
|
8924
|
-
pendingAction = value.pendingAction;
|
|
8925
|
-
} else if (typeof value.status === "string") {
|
|
8926
|
-
pendingAction = "";
|
|
8927
|
-
}
|
|
8928
8421
|
if (typeof value.screenshotBase64 === "string") {
|
|
8929
8422
|
showScreenshot(value.screenshotBase64, "image/jpeg");
|
|
8930
8423
|
}
|
|
@@ -8937,9 +8430,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8937
8430
|
if (typeof value.publishUrl === "string") {
|
|
8938
8431
|
publishUrl = webUrl(value.publishUrl);
|
|
8939
8432
|
}
|
|
8940
|
-
if (typeof value.nextPollAfterMs === "number") {
|
|
8941
|
-
pollAfterMs = value.nextPollAfterMs;
|
|
8942
|
-
}
|
|
8943
8433
|
// Hosts that deliver URLs without a status left the badge on the HTML
|
|
8944
8434
|
// default ("loading") even after the app was built.
|
|
8945
8435
|
const badge = element("status").textContent;
|
|
@@ -8954,91 +8444,29 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
8954
8444
|
}
|
|
8955
8445
|
|
|
8956
8446
|
/**
|
|
8957
|
-
*
|
|
8958
|
-
*
|
|
8959
|
-
*
|
|
8447
|
+
* When the host opened the card with tool input (applicationId) but never
|
|
8448
|
+
* pushed a tool result, refresh ourselves so the badge is not stuck on
|
|
8449
|
+
* "loading" after the build finished.
|
|
8960
8450
|
*/
|
|
8961
|
-
function clearRefreshTimer() {
|
|
8962
|
-
if (refreshTimer) {
|
|
8963
|
-
clearTimeout(refreshTimer);
|
|
8964
|
-
refreshTimer = 0;
|
|
8965
|
-
}
|
|
8966
|
-
}
|
|
8967
|
-
|
|
8968
|
-
function retryDelay() {
|
|
8969
|
-
return Math.max(MIN_POLL_MS, pollAfterMs || MIN_POLL_MS);
|
|
8970
|
-
}
|
|
8971
|
-
|
|
8972
|
-
function scheduleRefresh(delayMs) {
|
|
8973
|
-
clearRefreshTimer();
|
|
8974
|
-
if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {
|
|
8975
|
-
note("Stopped checking whether the app is still building.");
|
|
8976
|
-
return;
|
|
8977
|
-
}
|
|
8978
|
-
refreshTimer = setTimeout(() => {
|
|
8979
|
-
refreshTimer = 0;
|
|
8980
|
-
refreshFromServer();
|
|
8981
|
-
}, delayMs);
|
|
8982
|
-
}
|
|
8983
|
-
|
|
8984
8451
|
function refreshFromServer() {
|
|
8985
|
-
|
|
8986
|
-
if (!canCallTools || !applicationId || refreshInFlight) {
|
|
8987
|
-
return;
|
|
8988
|
-
}
|
|
8989
|
-
if (typeof document.hidden === "boolean" && document.hidden) {
|
|
8990
|
-
scheduleRefresh(retryDelay());
|
|
8991
|
-
return;
|
|
8992
|
-
}
|
|
8993
|
-
const badge = element("status").textContent;
|
|
8994
|
-
if (editUrl && badge !== "building") {
|
|
8995
|
-
return;
|
|
8996
|
-
}
|
|
8997
|
-
if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {
|
|
8998
|
-
note("Stopped checking whether the app is still building.");
|
|
8452
|
+
if (!canCallTools || !applicationId || editUrl) {
|
|
8999
8453
|
return;
|
|
9000
8454
|
}
|
|
9001
|
-
refreshAttempts += 1;
|
|
9002
|
-
const generation = refreshGeneration;
|
|
9003
|
-
refreshInFlight = true;
|
|
9004
8455
|
request("tools/call", {
|
|
9005
8456
|
name: "get_app",
|
|
9006
|
-
arguments: {
|
|
9007
|
-
applicationId,
|
|
9008
|
-
ensurePreview: false,
|
|
9009
|
-
wait: false,
|
|
9010
|
-
},
|
|
8457
|
+
arguments: { applicationId },
|
|
9011
8458
|
})
|
|
9012
8459
|
.then((result) => {
|
|
9013
|
-
refreshInFlight = false;
|
|
9014
|
-
if (generation !== refreshGeneration) {
|
|
9015
|
-
if (element("status").textContent === "building") {
|
|
9016
|
-
scheduleRefresh(retryDelay());
|
|
9017
|
-
}
|
|
9018
|
-
return;
|
|
9019
|
-
}
|
|
9020
8460
|
if (!result || result.isError) {
|
|
9021
|
-
scheduleRefresh(retryDelay());
|
|
9022
8461
|
return;
|
|
9023
8462
|
}
|
|
9024
8463
|
applyPayload(result);
|
|
9025
8464
|
if (result.structuredContent) {
|
|
9026
8465
|
applyPayload(result.structuredContent);
|
|
9027
8466
|
}
|
|
9028
|
-
if (element("status").textContent !== "building") {
|
|
9029
|
-
return;
|
|
9030
|
-
}
|
|
9031
|
-
if (pollAfterMs === 0) {
|
|
9032
|
-
return;
|
|
9033
|
-
}
|
|
9034
|
-
scheduleRefresh(retryDelay());
|
|
9035
8467
|
})
|
|
9036
8468
|
.catch(() => {
|
|
9037
|
-
|
|
9038
|
-
if (generation !== refreshGeneration) {
|
|
9039
|
-
return;
|
|
9040
|
-
}
|
|
9041
|
-
scheduleRefresh(retryDelay());
|
|
8469
|
+
// Host declined; stay on whatever we have.
|
|
9042
8470
|
});
|
|
9043
8471
|
}
|
|
9044
8472
|
|
|
@@ -9091,10 +8519,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
9091
8519
|
if (!applicationId || !canCallTools || publishing) {
|
|
9092
8520
|
return;
|
|
9093
8521
|
}
|
|
9094
|
-
if (nothingToPublish()) {
|
|
9095
|
-
note("Nothing to publish yet: this turn did not build the app.");
|
|
9096
|
-
return;
|
|
9097
|
-
}
|
|
9098
8522
|
publishing = true;
|
|
9099
8523
|
renderActions();
|
|
9100
8524
|
note("Publishing\u2026");
|
|
@@ -9178,10 +8602,6 @@ var APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
9178
8602
|
if (params.structuredContent) {
|
|
9179
8603
|
applyPayload(params.structuredContent);
|
|
9180
8604
|
}
|
|
9181
|
-
refreshGeneration += 1;
|
|
9182
|
-
if (element("status").textContent === "building") {
|
|
9183
|
-
refreshFromServer();
|
|
9184
|
-
}
|
|
9185
8605
|
}
|
|
9186
8606
|
if (method === "ui/notifications/tool-input" && params.arguments) {
|
|
9187
8607
|
applyPayload(params.arguments);
|
|
@@ -9511,24 +8931,6 @@ function createProgressNotifier(extra) {
|
|
|
9511
8931
|
}
|
|
9512
8932
|
|
|
9513
8933
|
// ../../../gateway/dist/transports/mcp/mount.js
|
|
9514
|
-
var DESTRUCTIVE_TOOL_ANNOTATIONS = {
|
|
9515
|
-
destructiveHint: true,
|
|
9516
|
-
idempotentHint: false,
|
|
9517
|
-
openWorldHint: true,
|
|
9518
|
-
readOnlyHint: false
|
|
9519
|
-
};
|
|
9520
|
-
var NON_DESTRUCTIVE_WRITE_TOOL_ANNOTATIONS = {
|
|
9521
|
-
destructiveHint: false,
|
|
9522
|
-
idempotentHint: false,
|
|
9523
|
-
openWorldHint: true,
|
|
9524
|
-
readOnlyHint: false
|
|
9525
|
-
};
|
|
9526
|
-
var READ_ONLY_TOOL_ANNOTATIONS = {
|
|
9527
|
-
destructiveHint: false,
|
|
9528
|
-
idempotentHint: true,
|
|
9529
|
-
openWorldHint: true,
|
|
9530
|
-
readOnlyHint: true
|
|
9531
|
-
};
|
|
9532
8934
|
var eventCursorInputSchema = external_exports.object({
|
|
9533
8935
|
streams: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
9534
8936
|
version: external_exports.unknown().optional()
|
|
@@ -9549,11 +8951,10 @@ Name the builder "Superblocks" in every word you write. Users sometimes call it
|
|
|
9549
8951
|
Use these tools whenever the user asks to build, change, import, or ship an app, whichever of those names they reach for.
|
|
9550
8952
|
|
|
9551
8953
|
- start_app: create a new application and hand a prompt to Superblocks. Returns as soon as Superblocks accepts, with status "building". Superblocks names it unless a name is given.
|
|
9552
|
-
- import_app: import an existing app from a ZIP (or .tgz/.gz) into Superblocks and start a Superblocks migration. Pass the archive's file name as zipPath \u2014 the gateway opens the file on this machine itself. Archives larger than 1 MB are rejected \u2014 they almost certainly include node_modules; re-export without install artifacts. Optional prompt carries extra intent (e.g. "make it more secure"). Returns like start_app with status "building".
|
|
8954
|
+
- import_app: import an existing app from a ZIP (or .tgz/.gz) into Superblocks and start a Superblocks migration. Pass the archive's file name as zipPath \u2014 the gateway opens the file on this machine itself. Archives larger than 1 MB are rejected \u2014 they almost certainly include node_modules; re-export without install artifacts. Optional prompt carries extra intent (e.g. "make it more secure"). Returns like start_app with status "building".
|
|
9553
8955
|
- edit_app: send a follow-up prompt (including the answer when Superblocks asked a question) for an existing application. Also returns at status "building". Defaults to the most recent app, so an applicationId is only needed to target a different app.
|
|
9554
8956
|
- check_app_progress: wait for the next thing Superblocks does and return it. It returns the moment Superblocks says anything, and after ~10 seconds of silence at the latest. "activity" holds Superblocks' own words since the previous call, in order; a quiet poll still returns a short heartbeat with elapsedSeconds.
|
|
9555
|
-
- get_app: return editor and preview URLs for the recent or specified app (builds a private preview when needed). Prefer this after status "ready" so the user can open the live app. Hosts that support MCP Apps show the status card (Open editor / Open preview) on this call \u2014 not on check_app_progress or preview_app \u2014 so only one card opens. When Superblocks has written code the tool includes a screenshot: the live Vite canvas (library peer) if a held session exists, otherwise the signed-in preview. Never open canvas.doNotOpen (the edit URL) to take that screenshot. It refuses to build a preview of an app Superblocks has not written yet: while a plan or question is outstanding it returns status "needs_decision" with "pendingAction", while a turn is running it returns status "building", and when the last turn ended without writing anything it returns that turn's status ("timeout", "live_edit_terminated", "no_changes" or "cancelled") with pendingAction "retry_build"
|
|
9556
|
-
- get_integration_metadata: inspect the tables, columns, and types in a connected integration. It needs no application and never executes an integration action, so do not call start_app or hunt through list_applications to satisfy it. Pass applicationId only for an integration that belongs to one application, such as a Native DB. Use search, limit, and offset to page large results. get_integration_config_schema is the JSON form for create_integration; it does not inspect connected data.
|
|
8957
|
+
- get_app: return editor and preview URLs for the recent or specified app (builds a private preview when needed). Prefer this after status "ready" so the user can open the live app. Hosts that support MCP Apps show the status card (Open editor / Open preview) on this call \u2014 not on check_app_progress or preview_app \u2014 so only one card opens. When Superblocks has written code the tool includes a screenshot: the live Vite canvas (library peer) if a held session exists, otherwise the signed-in preview. Never open canvas.doNotOpen (the edit URL) to take that screenshot. It refuses to build a preview of an app Superblocks has not written yet: while a plan or question is outstanding it returns status "needs_decision" with "pendingAction", while a turn is running it returns status "building", and when the last turn ended without writing anything it returns that turn's status ("timeout", "live_edit_terminated", "no_changes" or "cancelled") with pendingAction "retry_build". In each case there are no preview URLs and no screenshot \u2014 do the pendingAction first rather than calling get_app again.
|
|
9557
8958
|
- preview_app: build the application's current work and return a URL that runs it, without deploying it \u2014 the editor's Preview button. Nobody else can reach a preview. Text/markdown only (no MCP Apps widget); use get_app instead when you want the status card.
|
|
9558
8959
|
- publish_app: deploy an application and wait until it is live. It commits the current work first, so a commitId is only needed to publish an earlier commit.
|
|
9559
8960
|
|
|
@@ -9561,25 +8962,21 @@ A build takes two to four minutes, and start_app/edit_app/import_app return with
|
|
|
9561
8962
|
|
|
9562
8963
|
The user sees nothing at all while a tool call is outstanding, so between two calls always write out the new "activity" lines as a short message in your own reply \u2014 quote or paraphrase them, oldest first, before calling check_app_progress again. Do not batch them up for a summary at the end, and do not go two calls in a row without writing something: the point of the loop is that the user watches the build happen. When a call comes back with only a heartbeat (no new Superblocks words), say Superblocks is still working and how long it has been going, then poll again.
|
|
9563
8964
|
|
|
9564
|
-
status "ready" means the turn finished: report the "reply" field, then call get_app (not preview_app as well \u2014 calling both used to open two widgets) so the user gets Open preview / an https link or a screenshot. status "needs_decision" means Superblocks is waiting \u2014 often with a plan \u2014 so stop polling and put the decision to the user. When "decision.kind" is "plan", show the plan markdown, then invite them to build it as written or say what to change \u2014 the same fork the editor's Build-it button offers. Ask that as an ordinary closing question in your own words; do not turn it into a numbered or bulleted menu, and do not wrap the choices in quotation marks. When they say "Build it", "approve", "looks good", or "go ahead", you MUST call edit_app with planAction "approve" and omit prompt (do not re-send the plan, and do not put "approve" or "Build it" in the prompt field \u2014 that is refine feedback to Superblocks, not the editor Build-it path). When they want changes, call edit_app with planAction "refine" and their feedback as prompt. When "decision.kind" is "multi_choice", relay the question and options and send their answer with edit_app. Do not claim the app is built while status is "needs_decision". status "no_changes" means the Superblocks job ended without building anything: relay reply, say no app was built, and do not present the edit URL as a finished app. status "live_edit_terminated" means the live-edit session that was to run the turn died before it built anything, or never opened at all \u2014 relay reply, tell the user the session did not survive, and
|
|
9565
|
-
|
|
9566
|
-
When get_app returns a screenshot, inspect it yourself before reporting that the app looks correct. If it shows skeletons, spinners, empty tables or charts, or "Loading...", call get_app again a few seconds later instead of treating that as a defect. If it shows a problem the user would plainly recognize as wrong, call edit_app once with a concrete correction, follow that turn to completion, and inspect the next get_app screenshot. Otherwise describe what you see and ask the user whether to fix it.
|
|
8965
|
+
status "ready" means the turn finished: report the "reply" field, then call get_app (not preview_app as well \u2014 calling both used to open two widgets) so the user gets Open preview / an https link or a screenshot. status "needs_decision" means Superblocks is waiting \u2014 often with a plan \u2014 so stop polling and put the decision to the user. When "decision.kind" is "plan", show the plan markdown, then invite them to build it as written or say what to change \u2014 the same fork the editor's Build-it button offers. Ask that as an ordinary closing question in your own words; do not turn it into a numbered or bulleted menu, and do not wrap the choices in quotation marks. When they say "Build it", "approve", "looks good", or "go ahead", you MUST call edit_app with planAction "approve" and omit prompt (do not re-send the plan, and do not put "approve" or "Build it" in the prompt field \u2014 that is refine feedback to Superblocks, not the editor Build-it path). When they want changes, call edit_app with planAction "refine" and their feedback as prompt. When "decision.kind" is "multi_choice", relay the question and options and send their answer with edit_app. Do not claim the app is built while status is "needs_decision". status "no_changes" means the Superblocks job ended without building anything: relay reply, say no app was built, and do not present the edit URL as a finished app. status "live_edit_terminated" means the live-edit session that was to run the turn died before it built anything, or never opened at all \u2014 the prompt was fine and nothing timed out, so relay reply, tell the user the session did not survive, and offer to send the same instruction again with edit_app. status "detached" means Superblocks is still working but the gateway can no longer see it \u2014 usually because the app is open in a browser editor, which takes over Superblocks updates. Stop polling, say so, and point the user at the edit URL. status "unknown" means nothing is in flight for that app. A checkpointCommitId means Superblocks work is saved and the edit URL opens the finished app; when viewStatus is unknown, say the app may still be finishing in the editor.
|
|
9567
8966
|
|
|
9568
8967
|
start_app, edit_app, and import_app default to Plan mode (Superblocks proposes a plan before writing). Pass mode "BUILD" only when the user asks to skip planning and build immediately. Approving a plan after start_app or import_app is always a follow-up edit_app with planAction "approve" \u2014 never a second start_app/import_app with prompt "approve". Once the app has run in Build mode, later edit_app calls stay in Build mode on their own: you do not need to re-send mode "BUILD", and a new instruction is not a fresh planning round. Send mode "PLAN" only when the user explicitly asks to plan again before building. Every start_app / edit_app / import_app result reports the "mode" the turn ran in, so you can tell the user whether Superblocks is planning or building rather than guessing \u2014 and if a result comes back "PLAN" after a long gap, the build session was recycled rather than the user asking to plan, so pass mode "BUILD" again to carry on building. editUrl / previewUrl / publishUrl may appear in structured JSON for openLink buttons \u2014 do not dump raw URLs (especially preview JWTs) into the chat. Prefer the MCP Apps Open editor / Open preview buttons from get_app. Claude Desktop can only openLink https URLs; when previewUrl is http, say so briefly and rely on any screenshot image the tool returned rather than pasting the URL.
|
|
9569
8968
|
|
|
9570
8969
|
Once a build reaches "ready", call get_app so the user can open the app, then offer publish_app to deploy for their organization when they ask. Prefer get_app over preview_app after a build \u2014 get_app already ensures a private preview and is the only tool that opens the MCP Apps status card. Only publish when the user asks. If preview_app or get_app comes back with status "building", the URL is already correct; tell the user it is still building and call again to check.
|
|
9571
8970
|
|
|
9572
|
-
There is nothing to preview until Superblocks has written code, so get_app is not the way out of a plan, a question, or a turn that failed. When it answers status "needs_decision" (pendingAction "approve_plan" or "answer_question"), the app is still the empty starter template: put the decision to the user, send their answer with edit_app, and only call get_app once a turn has finished. When it answers "timeout", "live_edit_terminated", "no_changes" or "cancelled" with pendingAction "retry_build", that turn built nothing: tell the user so plainly, and send the instruction again with edit_app if they want to retry.
|
|
8971
|
+
There is nothing to preview until Superblocks has written code, so get_app is not the way out of a plan, a question, or a turn that failed. When it answers status "needs_decision" (pendingAction "approve_plan" or "answer_question"), the app is still the empty starter template: put the decision to the user, send their answer with edit_app, and only call get_app once a turn has finished. When it answers "timeout", "live_edit_terminated", "no_changes" or "cancelled" with pendingAction "retry_build", that turn built nothing: tell the user so plainly, and send the instruction again with edit_app if they want to retry. Repeating get_app instead opens another status card and tells the user nothing new.
|
|
9573
8972
|
|
|
9574
8973
|
Superblocks tests what it builds: it opens the app in a browser and runs its APIs, and the test run arrives as ordinary "activity" lines ("Testing the orders page", "Test passed: \u2026", "Tests failed: \u2026"). Relay those lines like any other activity, and say which cases passed and which failed \u2014 a test run is the only evidence the user has that the app actually works. A failing test is a build signal, not an auth problem: it means the app has a bug Superblocks is about to work on, so keep polling and never tell the user to sign in again or re-enter credentials over one.
|
|
9575
8974
|
|
|
9576
|
-
A failed call still names the application it was working on. start_app and import_app create the application before the build can start, so an error from either one leaves an application that exists and belongs to this conversation, and the error says which: read the "applicationId" field, never a UUID out of the message text. Never take an error to mean nothing happened. Do not answer a failed start_app with a second start_app \u2014 that abandons the app you already have and creates a duplicate. When the error carries pendingAction "retry_build" \u2014 a "live_edit_unavailable" session that would not open, or a turn that ran out of budget \u2014 send the same prompt again with edit_app and that applicationId.
|
|
9577
|
-
|
|
9578
|
-
A cancelled call does not stop the build, and it is not permission to start over. Cancelling only ends the waiting \u2014 Superblocks carries on, and the "cancelled" error names the application it was driving in "applicationId". Read that id, call check_app_progress or get_app on it, and act on what comes back. When the user then asks to redo, retry, or resume an import, that is a request to finish the application you already have: never answer it with an import_app that omits applicationId, which builds a second app and strands the first. The same holds when no pendingAction is in front of you \u2014 after a cancel, or in a later session. If the app came from an import, the way back in is import_app with the same archive and that applicationId; if you cannot tell which application the user means, ask rather than create one.
|
|
8975
|
+
A failed call still names the application it was working on. start_app and import_app create the application before the build can start, so an error from either one leaves an application that exists and belongs to this conversation, and the error says which: read the "applicationId" field, never a UUID out of the message text. Never take an error to mean nothing happened. Do not answer a failed start_app with a second start_app \u2014 that abandons the app you already have and creates a duplicate. When the error carries pendingAction "retry_build" \u2014 a "live_edit_unavailable" session that would not open, or a turn that ran out of budget \u2014 send the same prompt again with edit_app and that applicationId. A failed import_app carries no such recovery, because edit_app cannot resupply the archive the migration prompt reads: that application is empty and nothing can continue it in place, so name it to the user and let them decide whether to import again. Every edit_app error names its applicationId too, which is the one place to see which app a call that omitted the id actually ran on.
|
|
9579
8976
|
|
|
9580
8977
|
Prompts are forwarded to Superblocks verbatim \u2014 pass the user's wording rather than a summary.
|
|
9581
8978
|
|
|
9582
|
-
This connector is the single Superblocks MCP: Builder tools (start_app, import_app, edit_app, check_app_progress, get_app,
|
|
8979
|
+
This connector is the single Superblocks MCP: Builder tools (start_app, import_app, edit_app, check_app_progress, get_app, preview_app, publish_app) and Admin tools (integrations, apps, users, folders, deploy_application, and the rest of the customer Admin surface) share this endpoint. Prefer create_integration / update_integration / list_integrations here when Superblocks needs a missing Postgres, REST, or other datasource \u2014 do not send the user to a second MCP. create_integration is Admin CRUD for org datasources; start_app creates a new application and hands a prompt to Superblocks. deploy_application is Admin deploy of an existing commit; publish_app is the Builder path that commits current work and waits until the app is live. Omit base_url on Admin tools unless targeting a different control plane \u2014 the gateway injects its configured Server URL. checkout_application is not exposed on this network surface (host filesystem writes); use the CLI/workspace checkout path instead.
|
|
9583
8980
|
|
|
9584
8981
|
This connection is already authenticated and already pointed at one Superblocks Server, so there is no setup, login, or auth-status call to make first. Call the tool that does the job \u2014 list_integrations to see the org's datasources, start_app to create an application \u2014 and read its error if something is genuinely wrong. Do not look for a tool that reports credentials or environments; there is none, and asking for one costs the user a turn.
|
|
9585
8982
|
|
|
@@ -9589,7 +8986,7 @@ For import_app, the archive never travels through you. A file the user attached
|
|
|
9589
8986
|
|
|
9590
8987
|
${BROWSER_DRIVER_INSTRUCTIONS}`;
|
|
9591
8988
|
function createMcpServer(deps) {
|
|
9592
|
-
const
|
|
8989
|
+
const context = async (progress, notify, signal) => ({
|
|
9593
8990
|
caller: callerFrom(),
|
|
9594
8991
|
captureLibraryScreenshot: captureLibraryScreenshotWithPlaywright,
|
|
9595
8992
|
capturePreviewScreenshot: capturePreviewScreenshotWithPlaywright,
|
|
@@ -9599,9 +8996,6 @@ function createMcpServer(deps) {
|
|
|
9599
8996
|
progress.push(event);
|
|
9600
8997
|
notify?.(event.message);
|
|
9601
8998
|
},
|
|
9602
|
-
onPrincipalResolved: (principal) => {
|
|
9603
|
-
deps.mcpTelemetry?.setOrganizationId(principal.organizationId);
|
|
9604
|
-
},
|
|
9605
8999
|
principal: principalFrom(deps),
|
|
9606
9000
|
progressCursors: deps.progressCursors,
|
|
9607
9001
|
recentApps: deps.recentApps,
|
|
@@ -9614,22 +9008,22 @@ function createMcpServer(deps) {
|
|
|
9614
9008
|
gatewayDebugStack("tool started", { "tool.name": toolName });
|
|
9615
9009
|
const progress = [];
|
|
9616
9010
|
const notify = createProgressNotifier(extra);
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9011
|
+
let result;
|
|
9012
|
+
if (!deps.cliApiKey) {
|
|
9013
|
+
gatewayDebug("tool short-circuited", {
|
|
9014
|
+
"tool.name": toolName,
|
|
9015
|
+
"tool.reason": "missing_cli_session"
|
|
9016
|
+
});
|
|
9017
|
+
result = {
|
|
9018
|
+
kind: "error",
|
|
9019
|
+
code: "unauthenticated",
|
|
9020
|
+
message: "This Gateway has no CLI session. Run: superblocks login"
|
|
9021
|
+
};
|
|
9022
|
+
} else {
|
|
9629
9023
|
try {
|
|
9630
9024
|
const signal = extra?.signal;
|
|
9631
|
-
const capabilityContext = await
|
|
9632
|
-
|
|
9025
|
+
const capabilityContext = await context(progress, notify, signal);
|
|
9026
|
+
result = await capability(capabilityContext, () => {
|
|
9633
9027
|
for (let index = progress.length - 1; index >= 0; index -= 1) {
|
|
9634
9028
|
if (progress[index]?.type === "completed") {
|
|
9635
9029
|
progress.splice(index, 1);
|
|
@@ -9638,23 +9032,13 @@ function createMcpServer(deps) {
|
|
|
9638
9032
|
});
|
|
9639
9033
|
} catch (error) {
|
|
9640
9034
|
console.error("gateway capability failed", error);
|
|
9641
|
-
|
|
9035
|
+
result = {
|
|
9642
9036
|
kind: "error",
|
|
9643
9037
|
code: "capability_failed",
|
|
9644
9038
|
message: error instanceof Error ? error.message : "The gateway failed for an unknown reason."
|
|
9645
9039
|
};
|
|
9646
9040
|
}
|
|
9647
|
-
}
|
|
9648
|
-
const client = server.server.getClientVersion();
|
|
9649
|
-
const result = deps.mcpTelemetry ? await deps.mcpTelemetry.runTool({
|
|
9650
|
-
...client ? {
|
|
9651
|
-
client: {
|
|
9652
|
-
name: client.name,
|
|
9653
|
-
version: client.version
|
|
9654
|
-
}
|
|
9655
|
-
} : {},
|
|
9656
|
-
toolName
|
|
9657
|
-
}, execute) : await execute();
|
|
9041
|
+
}
|
|
9658
9042
|
const resultStatus = result.kind === "ok" && result.value && typeof result.value === "object" && "status" in result.value && typeof result.value.status === "string" ? result.value.status : void 0;
|
|
9659
9043
|
gatewayDebug("tool finished", {
|
|
9660
9044
|
"progress.event_count": progress.length,
|
|
@@ -9680,12 +9064,12 @@ function createMcpServer(deps) {
|
|
|
9680
9064
|
title: "Superblocks",
|
|
9681
9065
|
version: "0.0.1"
|
|
9682
9066
|
}, { instructions: SERVER_INSTRUCTIONS });
|
|
9683
|
-
const progressWithDecisionForm = async (
|
|
9067
|
+
const progressWithDecisionForm = async (context2, input, extra, forgetFinishedTurn) => {
|
|
9684
9068
|
gatewayDebug("progress decision flow started", {
|
|
9685
9069
|
"application.id": input.applicationId,
|
|
9686
9070
|
"progress.cursor_provided": Boolean(input.cursor)
|
|
9687
9071
|
});
|
|
9688
|
-
const result = await checkAppProgress(
|
|
9072
|
+
const result = await checkAppProgress(context2, input);
|
|
9689
9073
|
const decision = pendingDecision(result);
|
|
9690
9074
|
if (!decision) {
|
|
9691
9075
|
gatewayDebug("progress decision flow finished", {
|
|
@@ -9705,7 +9089,7 @@ function createMcpServer(deps) {
|
|
|
9705
9089
|
const resolved = await resolveDecisionByElicitation({
|
|
9706
9090
|
apply: (answer) => {
|
|
9707
9091
|
forgetFinishedTurn();
|
|
9708
|
-
return editApp(
|
|
9092
|
+
return editApp(context2, {
|
|
9709
9093
|
applicationId: input.applicationId,
|
|
9710
9094
|
idempotencyKey: `mcp-decision:${randomUUID4()}`,
|
|
9711
9095
|
wait: "ack",
|
|
@@ -9737,20 +9121,7 @@ function createMcpServer(deps) {
|
|
|
9737
9121
|
});
|
|
9738
9122
|
}
|
|
9739
9123
|
function registerBuilderTools() {
|
|
9740
|
-
server.registerTool("get_integration_metadata", {
|
|
9741
|
-
annotations: READ_ONLY_TOOL_ANNOTATIONS,
|
|
9742
|
-
description: "Inspect the tables, columns, and types in a connected Superblocks integration. Needs no application and never executes an integration action. Pass integrationId, which list_integrations returns. A large result comes back paged: narrow it with search, take more or fewer entries with limit, and continue from nextOffset with offset. Requires build permission on the integration. Do not use this to learn how to create an integration; that is get_integration_config_schema.",
|
|
9743
|
-
inputSchema: {
|
|
9744
|
-
applicationId: external_exports.string().uuid().optional().describe("Only for an integration owned by a single application, such as a Native DB. Leave unset otherwise; do not go looking for an application to supply."),
|
|
9745
|
-
integrationId: external_exports.string().uuid(),
|
|
9746
|
-
limit: external_exports.number().int().min(1).max(200).optional(),
|
|
9747
|
-
offset: external_exports.number().int().min(0).optional(),
|
|
9748
|
-
search: external_exports.string().min(1).optional()
|
|
9749
|
-
},
|
|
9750
|
-
title: "Get Integration Metadata"
|
|
9751
|
-
}, async (input, extra) => run("get_integration_metadata", (context3) => getIntegrationMetadata(context3, input), extra));
|
|
9752
9124
|
server.registerTool("start_app", {
|
|
9753
|
-
annotations: NON_DESTRUCTIVE_WRITE_TOOL_ANNOTATIONS,
|
|
9754
9125
|
description: 'Create a Superblocks application and hand a prompt to Superblocks in Plan mode by default. Returns as soon as Superblocks accepts, with status "building" and an edit URL; follow with check_app_progress until status is no longer "building". When Superblocks returns needs_decision with a plan and the user says "Build it", call edit_app with planAction "approve" (omit prompt) \u2014 do not call start_app again with prompt "approve". Pass mode "BUILD" to skip planning. Superblocks names the application unless name is given. An error from this tool does not mean nothing happened: the application is created before the build starts, so the error names it in "applicationId". Retry that app with edit_app rather than calling start_app another time, which would leave the first one abandoned.',
|
|
9755
9126
|
inputSchema: {
|
|
9756
9127
|
branch: external_exports.string().optional(),
|
|
@@ -9763,7 +9134,7 @@ function createMcpServer(deps) {
|
|
|
9763
9134
|
// the tool name: a host that ranks tools by title has to be able to find
|
|
9764
9135
|
// this one from the request.
|
|
9765
9136
|
title: "Create Superblocks App"
|
|
9766
|
-
}, async ({ branch, idempotencyKey, mode, name, prompt }, extra) => run("start_app", (
|
|
9137
|
+
}, async ({ branch, idempotencyKey, mode, name, prompt }, extra) => run("start_app", (context2) => startApp(context2, {
|
|
9767
9138
|
branch,
|
|
9768
9139
|
idempotencyKey: idempotencyKey ?? `mcp-start:${randomUUID4()}`,
|
|
9769
9140
|
mode,
|
|
@@ -9775,10 +9146,8 @@ function createMcpServer(deps) {
|
|
|
9775
9146
|
wait: "ack"
|
|
9776
9147
|
}), extra));
|
|
9777
9148
|
server.registerTool("import_app", {
|
|
9778
|
-
|
|
9779
|
-
description: `Import an existing app from a ZIP/.tgz/.gz archive into Superblocks and start a Superblocks migration. Pass the archive's file name (or its full path on this machine) as zipPath: the gateway reads the file itself, so a path from your own sandbox is fine as long as the name matches the file the user has. Never encode the archive as base64 \u2014 zipBase64 only carries test fixtures. Archives larger than 1 MB are rejected \u2014 exclude node_modules. Optional prompt adds intent such as hardening security. Returns status "building"; follow with check_app_progress. Defaults to Plan mode \u2014 when Superblocks returns a plan and the user says "Build it", call edit_app with planAction "approve" (omit prompt); do not call import_app again with prompt "approve". An error from this tool does not mean nothing happened: the application is created before the migration starts, so the error names it in "applicationId". When it returns pendingAction "retry_import", call import_app again with the same archive and applicationId to resume that application instead of creating another one.`,
|
|
9149
|
+
description: `Import an existing app from a ZIP/.tgz/.gz archive into Superblocks and start a Superblocks migration. Pass the archive's file name (or its full path on this machine) as zipPath: the gateway reads the file itself, so a path from your own sandbox is fine as long as the name matches the file the user has. Never encode the archive as base64 \u2014 zipBase64 only carries test fixtures. Archives larger than 1 MB are rejected \u2014 exclude node_modules. Optional prompt adds intent such as hardening security. Returns status "building"; follow with check_app_progress. Defaults to Plan mode \u2014 when Superblocks returns a plan and the user says "Build it", call edit_app with planAction "approve" (omit prompt); do not call import_app again with prompt "approve". An error from this tool does not mean nothing happened: the application is created before the migration starts, so the error names it in "applicationId". That application is empty \u2014 the migration never ran \u2014 and nothing can continue it in place, so say it exists and let the user decide whether to import again rather than silently retrying.`,
|
|
9780
9150
|
inputSchema: {
|
|
9781
|
-
applicationId: external_exports.string().uuid().optional(),
|
|
9782
9151
|
branch: external_exports.string().optional(),
|
|
9783
9152
|
idempotencyKey: external_exports.string().optional(),
|
|
9784
9153
|
mode: external_exports.enum(["BUILD", "PLAN"]).optional(),
|
|
@@ -9798,8 +9167,7 @@ function createMcpServer(deps) {
|
|
|
9798
9167
|
zipPath: external_exports.string().min(1).optional()
|
|
9799
9168
|
},
|
|
9800
9169
|
title: "Import App"
|
|
9801
|
-
}, async ({
|
|
9802
|
-
applicationId,
|
|
9170
|
+
}, async ({ branch, idempotencyKey, mode, name, prompt, source, zipBase64, zipPath }, extra) => run("import_app", (context2) => importApp(context2, {
|
|
9803
9171
|
branch,
|
|
9804
9172
|
idempotencyKey: idempotencyKey ?? `mcp-import:${randomUUID4()}`,
|
|
9805
9173
|
mode,
|
|
@@ -9811,7 +9179,6 @@ function createMcpServer(deps) {
|
|
|
9811
9179
|
zipPath
|
|
9812
9180
|
}), extra));
|
|
9813
9181
|
server.registerTool("edit_app", {
|
|
9814
|
-
annotations: DESTRUCTIVE_TOOL_ANNOTATIONS,
|
|
9815
9182
|
description: 'Forward a prompt to Superblocks for the recent or specified application. Defaults to Plan mode until the app has run in Build mode; after that later edits keep building directly \u2014 you do not need to pass mode again. Pass mode "PLAN" only when the user explicitly asks to plan before building. The result reports the "mode" the turn ran in; a "PLAN" result after a long gap means the build session was recycled, so pass mode "BUILD" again rather than treating it as a new planning round. When status was needs_decision with a plan and the user says "Build it" / approve / go ahead, call edit_app with planAction "approve" and omit prompt \u2014 do not put "approve" or "Build it" in prompt (that is refine feedback, not the Build-it path). Use planAction "refine" with their feedback as prompt to change the plan. Also use edit_app to answer multi_choice questions. Returns status "building"; follow with check_app_progress.',
|
|
9816
9183
|
inputSchema: {
|
|
9817
9184
|
applicationId: external_exports.string().uuid().optional(),
|
|
@@ -9822,7 +9189,7 @@ function createMcpServer(deps) {
|
|
|
9822
9189
|
prompt: external_exports.string().min(1).optional()
|
|
9823
9190
|
},
|
|
9824
9191
|
title: "Edit App"
|
|
9825
|
-
}, async ({ applicationId, branch, idempotencyKey, mode, planAction, prompt }, extra) => run("edit_app", (
|
|
9192
|
+
}, async ({ applicationId, branch, idempotencyKey, mode, planAction, prompt }, extra) => run("edit_app", (context2) => editApp(context2, {
|
|
9826
9193
|
applicationId,
|
|
9827
9194
|
branch,
|
|
9828
9195
|
idempotencyKey: idempotencyKey ?? `mcp-edit:${randomUUID4()}`,
|
|
@@ -9832,26 +9199,24 @@ function createMcpServer(deps) {
|
|
|
9832
9199
|
wait: "ack"
|
|
9833
9200
|
}), extra));
|
|
9834
9201
|
server.registerTool("check_app_progress", {
|
|
9835
|
-
annotations: NON_DESTRUCTIVE_WRITE_TOOL_ANNOTATIONS,
|
|
9836
9202
|
description: `Wait for the next thing Superblocks does on the recent or specified application and return it: "activity" carries Superblocks' words since the previous call (or a short heartbeat when Superblocks is quiet), and status is "building" while the app is still being generated. Returns as soon as Superblocks says anything, and after ~10 seconds of silence at the latest. Call within about 10 seconds of start_app, import_app, or edit_app so a plan or question surfaces quickly. Once the plan is approved and Superblocks is building, space later polls about 30 seconds apart (honor "nextPollAfterMs" when present) until status is no longer "building" \u2014 a 10-second cadence on a multi-minute build burns through the host's tool-call budget. Relay each new activity line to the user between calls. When status becomes "needs_decision", stop polling and put the decision to the user \u2014 for a plan, show it and ask whether to build it or say what to change; for multi_choice, relay the question and options. Hosts that support form elicitation get a native picker instead, and this tool then returns the answered turn. When status becomes "ready", follow with get_app so the user can open the preview. Progress is text-only (no MCP Apps widget) so each poll does not reopen a blank card. Optional "cursor" from a prior result resumes from that composite position (per producer, no global sequence); omit it to use the gateway's stored place for this caller.`,
|
|
9837
9203
|
inputSchema: {
|
|
9838
9204
|
applicationId: external_exports.string().uuid().optional(),
|
|
9839
9205
|
cursor: eventCursorInputSchema.optional()
|
|
9840
9206
|
},
|
|
9841
9207
|
title: "Check App Progress"
|
|
9842
|
-
}, async ({ applicationId, cursor }, extra) => run("check_app_progress", (
|
|
9208
|
+
}, async ({ applicationId, cursor }, extra) => run("check_app_progress", (context2, forgetFinishedTurn) => {
|
|
9843
9209
|
const parsed = cursor === void 0 ? void 0 : parseEventCursor(cursor);
|
|
9844
9210
|
gatewayDebug("progress cursor parsed", {
|
|
9845
9211
|
"progress.cursor_provided": cursor !== void 0,
|
|
9846
9212
|
"progress.cursor_valid": Boolean(parsed)
|
|
9847
9213
|
});
|
|
9848
|
-
return progressWithDecisionForm(
|
|
9214
|
+
return progressWithDecisionForm(context2, {
|
|
9849
9215
|
applicationId,
|
|
9850
9216
|
...parsed ? { cursor: parsed } : {}
|
|
9851
9217
|
}, extra, forgetFinishedTurn);
|
|
9852
9218
|
}, extra));
|
|
9853
9219
|
K3(server, "get_app", {
|
|
9854
|
-
annotations: READ_ONLY_TOOL_ANNOTATIONS,
|
|
9855
9220
|
description: 'Return editor and preview URLs for the recent or specified Superblocks application. Ensures a private preview build by default (same as preview_app), but only once Superblocks has something to show: while a plan or question is outstanding it returns status "needs_decision" with the "decision" and a "pendingAction" of "approve_plan" or "answer_question", while a turn is running it returns status "building", and when the last turn ended without writing anything it returns "timeout", "live_edit_terminated", "no_changes" or "cancelled" with pendingAction "retry_build" \u2014 no preview URLs and no screenshot in any of those cases, because the app is still the empty starter template. Act on "pendingAction" through edit_app instead of calling this again. Prefer this after check_app_progress reaches status "ready". Also the right call when you do not know where a build stands \u2014 after a reconnect, when no turn of yours is running, or when the conversation moved to another channel: pass wait false and read "status" and "cursor" from the result rather than guessing. Hosts that support MCP Apps show Open editor / Open preview buttons. When Superblocks has written code the result includes a screenshot of the live Vite canvas if a held session exists, otherwise the signed-in preview \u2014 never the edit URL.',
|
|
9856
9221
|
inputSchema: {
|
|
9857
9222
|
applicationId: external_exports.string().uuid().optional(),
|
|
@@ -9863,16 +9228,15 @@ function createMcpServer(deps) {
|
|
|
9863
9228
|
_meta: {
|
|
9864
9229
|
ui: { resourceUri: APP_STATUS_RESOURCE_URI }
|
|
9865
9230
|
}
|
|
9866
|
-
}, async ({ applicationId, branch, ensurePreview, wait }, extra) => run("get_app", (
|
|
9231
|
+
}, async ({ applicationId, branch, ensurePreview, wait }, extra) => run("get_app", (context2) => getApp(context2, { applicationId, branch, ensurePreview, wait }), extra));
|
|
9867
9232
|
server.registerTool("preview_app", {
|
|
9868
|
-
annotations: READ_ONLY_TOOL_ANNOTATIONS,
|
|
9869
9233
|
description: `Build the recent or specified Superblocks application's current work and return a URL that runs it, without deploying it \u2014 the same thing the editor's Preview button does. Only the user can open it. Status "ready" means the URL works now; "building" means the build is still running and calling again resumes watching it. Prefer get_app when you want the MCP Apps status card (Open editor / Open preview); this tool returns the same URLs as text/markdown without opening a second widget.`,
|
|
9870
9234
|
inputSchema: {
|
|
9871
9235
|
applicationId: external_exports.string().uuid().optional(),
|
|
9872
9236
|
branch: external_exports.string().optional()
|
|
9873
9237
|
},
|
|
9874
9238
|
title: "Preview App"
|
|
9875
|
-
}, async ({ applicationId, branch }, extra) => run("preview_app", (
|
|
9239
|
+
}, async ({ applicationId, branch }, extra) => run("preview_app", (context2) => previewApp(context2, { applicationId, branch }), extra));
|
|
9876
9240
|
const uiCsp = { csp: { frameDomains: [] } };
|
|
9877
9241
|
N3(server, "Gateway app status", APP_STATUS_RESOURCE_URI, {
|
|
9878
9242
|
description: "Status card with Open editor / Open preview / Publish app",
|
|
@@ -9889,7 +9253,6 @@ function createMcpServer(deps) {
|
|
|
9889
9253
|
]
|
|
9890
9254
|
}));
|
|
9891
9255
|
server.registerTool("publish_app", {
|
|
9892
|
-
annotations: DESTRUCTIVE_TOOL_ANNOTATIONS,
|
|
9893
9256
|
description: "Publish/deploy the recent or specified Superblocks application and wait until it is live. Commits the application's current work first, so commitId is only needed to publish an earlier commit.",
|
|
9894
9257
|
inputSchema: {
|
|
9895
9258
|
applicationId: external_exports.string().uuid().optional(),
|
|
@@ -9899,7 +9262,7 @@ function createMcpServer(deps) {
|
|
|
9899
9262
|
prompt: external_exports.string().min(1)
|
|
9900
9263
|
},
|
|
9901
9264
|
title: "Publish App"
|
|
9902
|
-
}, async ({ applicationId, branch, commitId, idempotencyKey, prompt }, extra) => run("publish_app", (
|
|
9265
|
+
}, async ({ applicationId, branch, commitId, idempotencyKey, prompt }, extra) => run("publish_app", (context2) => publishApp(context2, {
|
|
9903
9266
|
applicationId,
|
|
9904
9267
|
branch,
|
|
9905
9268
|
commitId,
|
|
@@ -9919,7 +9282,6 @@ function createMcpServer(deps) {
|
|
|
9919
9282
|
async function createRuntime(apiKey) {
|
|
9920
9283
|
const config = loadConfig();
|
|
9921
9284
|
const stores = await createStores();
|
|
9922
|
-
const telemetry = startGatewayTelemetry({ apiKey, config });
|
|
9923
9285
|
const serverClient = new HttpSuperblocksServerClient(config.serverUrl);
|
|
9924
9286
|
const sessionPeer = new WebSocketSessionPeer({
|
|
9925
9287
|
beatLostGraceMs: config.beatLostGraceMs,
|
|
@@ -9937,7 +9299,6 @@ async function createRuntime(apiKey) {
|
|
|
9937
9299
|
cliApiKey: apiKey,
|
|
9938
9300
|
config,
|
|
9939
9301
|
events: stores.events,
|
|
9940
|
-
mcpTelemetry: telemetry.mcpTelemetry,
|
|
9941
9302
|
progressCursors: stores.progressCursors,
|
|
9942
9303
|
recentApps: stores.recentApps,
|
|
9943
9304
|
server: serverClient,
|
|
@@ -9949,7 +9310,7 @@ async function createRuntime(apiKey) {
|
|
|
9949
9310
|
deps,
|
|
9950
9311
|
close: async () => {
|
|
9951
9312
|
sessionPeer.closeAll();
|
|
9952
|
-
await
|
|
9313
|
+
await stores.close();
|
|
9953
9314
|
}
|
|
9954
9315
|
};
|
|
9955
9316
|
}
|
|
@@ -9995,4 +9356,4 @@ export {
|
|
|
9995
9356
|
startApp,
|
|
9996
9357
|
startStdioGateway
|
|
9997
9358
|
};
|
|
9998
|
-
//# sourceMappingURL=dist-
|
|
9359
|
+
//# sourceMappingURL=dist-P7G6RMCF.js.map
|