@multiplayer-app/agent 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +29 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lambda-microvm-entrypoint.d.ts +3 -0
- package/dist/lambda-microvm-entrypoint.d.ts.map +1 -0
- package/dist/lambda-microvm-entrypoint.js +88 -0
- package/dist/lambda-microvm-entrypoint.js.map +1 -0
- package/dist/loop.d.ts +6 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +68 -0
- package/dist/loop.js.map +1 -0
- package/dist/mcp/mcp-client.d.ts +11 -0
- package/dist/mcp/mcp-client.d.ts.map +1 -0
- package/dist/mcp/mcp-client.js +192 -0
- package/dist/mcp/mcp-client.js.map +1 -0
- package/dist/mcp/mcp-connection.d.ts +40 -0
- package/dist/mcp/mcp-connection.d.ts.map +1 -0
- package/dist/mcp/mcp-connection.js +6 -0
- package/dist/mcp/mcp-connection.js.map +1 -0
- package/dist/mcp/mcp-tool-schema.d.ts +25 -0
- package/dist/mcp/mcp-tool-schema.d.ts.map +1 -0
- package/dist/mcp/mcp-tool-schema.js +96 -0
- package/dist/mcp/mcp-tool-schema.js.map +1 -0
- package/dist/mcp/mcp-tools.d.ts +54 -0
- package/dist/mcp/mcp-tools.d.ts.map +1 -0
- package/dist/mcp/mcp-tools.js +115 -0
- package/dist/mcp/mcp-tools.js.map +1 -0
- package/dist/mcp/search-mcp-tools.d.ts +33 -0
- package/dist/mcp/search-mcp-tools.d.ts.map +1 -0
- package/dist/mcp/search-mcp-tools.js +149 -0
- package/dist/mcp/search-mcp-tools.js.map +1 -0
- package/dist/report.d.ts +30 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +55 -0
- package/dist/report.js.map +1 -0
- package/dist/tools/exec-tools.d.ts +8 -0
- package/dist/tools/exec-tools.d.ts.map +1 -0
- package/dist/tools/exec-tools.js +53 -0
- package/dist/tools/exec-tools.js.map +1 -0
- package/dist/tools/fs-tools.d.ts +30 -0
- package/dist/tools/fs-tools.d.ts.map +1 -0
- package/dist/tools/fs-tools.js +80 -0
- package/dist/tools/fs-tools.js.map +1 -0
- package/package.json +44 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
// Generic entrypoint — reads its whole config from real process.env (already materialized by
|
|
5
|
+
// the time this runs: QEMU's init script exports ENV_B64 before launching the entrypoint, so
|
|
6
|
+
// this is the right entrypoint for that engine). Lambda MicroVM's own entrypoint
|
|
7
|
+
// (lambda-microvm-entrypoint.ts) has to materialize env from the /run lifecycle hook payload
|
|
8
|
+
// first, then calls the same runAgentLoop — this file's job is intentionally just "trust
|
|
9
|
+
// process.env and go".
|
|
10
|
+
const config_1 = require("./config");
|
|
11
|
+
const loop_1 = require("./loop");
|
|
12
|
+
const report_1 = require("./report");
|
|
13
|
+
async function main() {
|
|
14
|
+
const config = (0, config_1.loadConfigFromEnv)();
|
|
15
|
+
const reporter = (0, report_1.createReporter)(config.socketUrl, config.socketToken, config.sessionId);
|
|
16
|
+
try {
|
|
17
|
+
await (0, loop_1.runAgentLoop)(config, reporter);
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
await reporter.close();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
main()
|
|
24
|
+
.then(() => process.exit(0))
|
|
25
|
+
.catch((error) => {
|
|
26
|
+
console.error(error instanceof Error ? error.message : error);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,6FAA6F;AAC7F,6FAA6F;AAC7F,iFAAiF;AACjF,6FAA6F;AAC7F,yFAAyF;AACzF,uBAAuB;AACvB,qCAA4C;AAC5C,iCAAqC;AACrC,qCAAyC;AAEzC,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAA,0BAAiB,GAAE,CAAA;IAClC,MAAM,QAAQ,GAAG,IAAA,uBAAc,EAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;IACvF,IAAI,CAAC;QACH,MAAM,IAAA,mBAAY,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACtC,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;AACH,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { McpConnectionRecord } from './mcp/mcp-connection';
|
|
2
|
+
export interface AgentRuntimeConfig {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
task: string;
|
|
5
|
+
model: string;
|
|
6
|
+
workspaceDir: string;
|
|
7
|
+
mcpConnections: McpConnectionRecord[];
|
|
8
|
+
/** Gateway's agent-socket-server endpoint (ws(s)://.../agent-sessions/ws), not the api directly. */
|
|
9
|
+
socketUrl?: string;
|
|
10
|
+
socketToken?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Reads the full run config from process.env — the guest's own contract, documented on VmCreateRequest.env. */
|
|
13
|
+
export declare function loadConfigFromEnv(env?: NodeJS.ProcessEnv): AgentRuntimeConfig;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE/D,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,mBAAmB,EAAE,CAAA;IACrC,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAgBD,gHAAgH;AAChH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,kBAAkB,CAe1F"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadConfigFromEnv = loadConfigFromEnv;
|
|
4
|
+
const DEFAULT_MODEL = 'claude-sonnet-4-5';
|
|
5
|
+
const DEFAULT_WORKSPACE_DIR = '/workspace';
|
|
6
|
+
function decodeMcpConnections(raw) {
|
|
7
|
+
if (!raw)
|
|
8
|
+
return [];
|
|
9
|
+
try {
|
|
10
|
+
const json = Buffer.from(raw, 'base64').toString('utf8');
|
|
11
|
+
const parsed = JSON.parse(json);
|
|
12
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw new Error(`MCP_SERVERS_JSON is not valid base64-encoded JSON: ${error.message}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Reads the full run config from process.env — the guest's own contract, documented on VmCreateRequest.env. */
|
|
19
|
+
function loadConfigFromEnv(env = process.env) {
|
|
20
|
+
const sessionId = env.SESSION_ID;
|
|
21
|
+
const task = env.AGENT_TASK;
|
|
22
|
+
if (!sessionId)
|
|
23
|
+
throw new Error('SESSION_ID is required');
|
|
24
|
+
if (!task)
|
|
25
|
+
throw new Error('AGENT_TASK is required');
|
|
26
|
+
return {
|
|
27
|
+
sessionId,
|
|
28
|
+
task,
|
|
29
|
+
model: env.AGENT_MODEL || DEFAULT_MODEL,
|
|
30
|
+
workspaceDir: env.AGENT_WORKSPACE_DIR || DEFAULT_WORKSPACE_DIR,
|
|
31
|
+
mcpConnections: decodeMcpConnections(env.MCP_SERVERS_JSON),
|
|
32
|
+
socketUrl: env.AGENT_SOCKET_URL,
|
|
33
|
+
socketToken: env.AGENT_SOCKET_TOKEN,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AA4BA,8CAeC;AA9BD,MAAM,aAAa,GAAG,mBAAmB,CAAA;AACzC,MAAM,qBAAqB,GAAG,YAAY,CAAA;AAE1C,SAAS,oBAAoB,CAAC,GAAuB;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAgC,CAAC,CAAC,CAAC,EAAE,CAAA;IACvE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,sDAAuD,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;IACnG,CAAC;AACH,CAAC;AAED,gHAAgH;AAChH,SAAgB,iBAAiB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACpE,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAA;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAA;IAC3B,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IACzD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAEpD,OAAO;QACL,SAAS;QACT,IAAI;QACJ,KAAK,EAAE,GAAG,CAAC,WAAW,IAAI,aAAa;QACvC,YAAY,EAAE,GAAG,CAAC,mBAAmB,IAAI,qBAAqB;QAC9D,cAAc,EAAE,oBAAoB,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC1D,SAAS,EAAE,GAAG,CAAC,gBAAgB;QAC/B,WAAW,EAAE,GAAG,CAAC,kBAAkB;KACpC,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { loadConfigFromEnv, type AgentRuntimeConfig } from './config';
|
|
2
|
+
export { runAgentLoop } from './loop';
|
|
3
|
+
export { createReporter, type AgentEvent, type Reporter } from './report';
|
|
4
|
+
export type { McpConnectionRecord, McpConnectionSummary, McpOAuthTokens, McpToolSummary } from './mcp/mcp-connection';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AACzE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReporter = exports.runAgentLoop = exports.loadConfigFromEnv = void 0;
|
|
4
|
+
var config_1 = require("./config");
|
|
5
|
+
Object.defineProperty(exports, "loadConfigFromEnv", { enumerable: true, get: function () { return config_1.loadConfigFromEnv; } });
|
|
6
|
+
var loop_1 = require("./loop");
|
|
7
|
+
Object.defineProperty(exports, "runAgentLoop", { enumerable: true, get: function () { return loop_1.runAgentLoop; } });
|
|
8
|
+
var report_1 = require("./report");
|
|
9
|
+
Object.defineProperty(exports, "createReporter", { enumerable: true, get: function () { return report_1.createReporter; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAqE;AAA5D,2GAAA,iBAAiB,OAAA;AAC1B,+BAAqC;AAA5B,oGAAA,YAAY,OAAA;AACrB,mCAAyE;AAAhE,wGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda-microvm-entrypoint.d.ts","sourceRoot":"","sources":["../src/lambda-microvm-entrypoint.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
// Lambda MicroVM-specific bootstrap. AWS's platform calls the lifecycle hooks
|
|
8
|
+
// (/aws/lambda-microvms/runtime/v1/{run,resume,suspend,terminate}) on port 8080 and expects a
|
|
9
|
+
// response before it considers the instance up (createMicrovmImages registers every image with
|
|
10
|
+
// hooks: { run/resume/suspend/terminate: 'ENABLED' } — libs/sandbox/src/microvm-images.ts:58-62
|
|
11
|
+
// — this isn't optional). Per-run config (env vars) arrives as the /run hook's runHookPayload,
|
|
12
|
+
// not as real process env vars — mirrors the existing plain node/python guest agent
|
|
13
|
+
// (microvm-guest-agents.ts's NODE_APP) exactly for that part.
|
|
14
|
+
//
|
|
15
|
+
// Once /run is handled, this closes the hook server and runs the agent loop in-process — if
|
|
16
|
+
// the task starts a dev server, it binds the now-free $PORT (8080) itself. Matches the existing
|
|
17
|
+
// release-deployment guest agent's own tradeoff: once port 8080 is handed over, later
|
|
18
|
+
// suspend/resume/terminate hooks have nowhere to land until proper lifecycle support lands
|
|
19
|
+
// (tracked alongside EFS persistence — see the plan's deferred section).
|
|
20
|
+
const http_1 = __importDefault(require("http"));
|
|
21
|
+
const config_1 = require("./config");
|
|
22
|
+
const loop_1 = require("./loop");
|
|
23
|
+
const report_1 = require("./report");
|
|
24
|
+
const HOOK_PREFIX = '/aws/lambda-microvms/runtime/v1/';
|
|
25
|
+
const PORT = 8080;
|
|
26
|
+
function materializeEnv(runHookPayload) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!runHookPayload)
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
const session = JSON.parse(runHookPayload);
|
|
32
|
+
for (const [key, value] of Object.entries((_a = session.env) !== null && _a !== void 0 ? _a : {})) {
|
|
33
|
+
if (typeof value === 'string')
|
|
34
|
+
process.env[key] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (_b) {
|
|
38
|
+
// payload is optional / best-effort, matching the plain node/python guest agent
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function runTask() {
|
|
42
|
+
let reporter;
|
|
43
|
+
try {
|
|
44
|
+
const config = (0, config_1.loadConfigFromEnv)();
|
|
45
|
+
reporter = (0, report_1.createReporter)(config.socketUrl, config.socketToken, config.sessionId);
|
|
46
|
+
await (0, loop_1.runAgentLoop)(config, reporter);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('agent run failed:', error);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
await (reporter === null || reporter === void 0 ? void 0 : reporter.close());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const server = http_1.default.createServer((req, res) => {
|
|
56
|
+
var _a;
|
|
57
|
+
if (((_a = req.url) === null || _a === void 0 ? void 0 : _a.startsWith(HOOK_PREFIX)) && req.method === 'POST') {
|
|
58
|
+
const hook = req.url.slice(HOOK_PREFIX.length);
|
|
59
|
+
const chunks = [];
|
|
60
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
61
|
+
req.on('end', () => {
|
|
62
|
+
const body = Buffer.concat(chunks).toString();
|
|
63
|
+
// Runtime env may contain MCP tokens or a callback bearer token; never log the body.
|
|
64
|
+
console.log(`lifecycle hook: ${hook}`);
|
|
65
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
66
|
+
res.end('{}');
|
|
67
|
+
if (hook === 'run') {
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(body);
|
|
70
|
+
materializeEnv(parsed.runHookPayload);
|
|
71
|
+
}
|
|
72
|
+
catch (_a) {
|
|
73
|
+
/* payload is optional */
|
|
74
|
+
}
|
|
75
|
+
server.close(() => {
|
|
76
|
+
void runTask();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
83
|
+
res.end(JSON.stringify({ status: 'ok', path: req.url }));
|
|
84
|
+
});
|
|
85
|
+
server.listen(PORT, () => {
|
|
86
|
+
console.log(`agent lifecycle hook server listening on ${PORT}`);
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=lambda-microvm-entrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda-microvm-entrypoint.js","sourceRoot":"","sources":["../src/lambda-microvm-entrypoint.ts"],"names":[],"mappings":";;;;;;AACA,8EAA8E;AAC9E,8FAA8F;AAC9F,+FAA+F;AAC/F,gGAAgG;AAChG,+FAA+F;AAC/F,oFAAoF;AACpF,8DAA8D;AAC9D,EAAE;AACF,4FAA4F;AAC5F,gGAAgG;AAChG,sFAAsF;AACtF,2FAA2F;AAC3F,yEAAyE;AACzE,gDAAuB;AACvB,qCAA4C;AAC5C,iCAAqC;AACrC,qCAAwD;AAExD,MAAM,WAAW,GAAG,kCAAkC,CAAA;AACtD,MAAM,IAAI,GAAG,IAAI,CAAA;AAEjB,SAAS,cAAc,CAAC,cAAkC;;IACxD,IAAI,CAAC,cAAc;QAAE,OAAM;IAC3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAsC,CAAA;QAC/E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAA,OAAO,CAAC,GAAG,mCAAI,EAAE,CAAC,EAAE,CAAC;YAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACzD,CAAC;IACH,CAAC;I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AAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAwC/G"}
|
package/dist/loop.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runAgentLoop = runAgentLoop;
|
|
4
|
+
// The core agent loop — reimplemented directly on the Vercel AI SDK's generateText/
|
|
5
|
+
// stepCountIs (the same primitives ai-agent-node uses underneath its ChatProcessor), not a
|
|
6
|
+
// port of ChatProcessor itself: that class's only public entry point requires 4+ MongoDB
|
|
7
|
+
// repositories and Socket.IO broadcast, none of which exist inside a guest VM.
|
|
8
|
+
const anthropic_1 = require("@ai-sdk/anthropic");
|
|
9
|
+
const ai_1 = require("ai");
|
|
10
|
+
const mcp_tools_1 = require("./mcp/mcp-tools");
|
|
11
|
+
const exec_tools_1 = require("./tools/exec-tools");
|
|
12
|
+
const fs_tools_1 = require("./tools/fs-tools");
|
|
13
|
+
const MAX_STEPS = 40;
|
|
14
|
+
const SYSTEM_PROMPT = `You are a coding agent running inside an isolated session workspace VM. You have direct
|
|
15
|
+
tools to read/write files and run shell commands in the workspace, plus (if any MCP servers are
|
|
16
|
+
configured) search_tools/get_tool_details/call_mcp_tool to use them.
|
|
17
|
+
|
|
18
|
+
If the user's task involves a web app or API, start a dev server bound to $PORT (already set in
|
|
19
|
+
your environment) — the live preview link the user sees is a direct proxy to that port, so
|
|
20
|
+
starting it is what makes your changes visible. Background long-lived processes (dev servers)
|
|
21
|
+
so a single run_command call returns promptly.
|
|
22
|
+
|
|
23
|
+
Work efficiently: make the changes, verify with a command when it's cheap to do so (e.g. a
|
|
24
|
+
build or lint step), and finish with a concise summary of what you did.`;
|
|
25
|
+
function isoNow() {
|
|
26
|
+
return new Date().toISOString();
|
|
27
|
+
}
|
|
28
|
+
async function runAgentLoop(config, reporter) {
|
|
29
|
+
const tools = {
|
|
30
|
+
...(0, fs_tools_1.createFsTools)(config.workspaceDir),
|
|
31
|
+
...(0, exec_tools_1.createExecTools)(config.workspaceDir),
|
|
32
|
+
...(0, mcp_tools_1.createMcpTools)(config.mcpConnections),
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
const result = await (0, ai_1.generateText)({
|
|
36
|
+
model: (0, anthropic_1.anthropic)(config.model),
|
|
37
|
+
system: SYSTEM_PROMPT,
|
|
38
|
+
prompt: config.task,
|
|
39
|
+
tools,
|
|
40
|
+
stopWhen: (0, ai_1.stepCountIs)(MAX_STEPS),
|
|
41
|
+
onStepFinish: async (step) => {
|
|
42
|
+
for (let i = 0; i < step.toolCalls.length; i++) {
|
|
43
|
+
const call = step.toolCalls[i];
|
|
44
|
+
const result = step.toolResults[i];
|
|
45
|
+
await reporter.send({
|
|
46
|
+
type: 'tool_call',
|
|
47
|
+
sessionId: config.sessionId,
|
|
48
|
+
toolName: call.toolName,
|
|
49
|
+
input: call.input,
|
|
50
|
+
output: result === null || result === void 0 ? void 0 : result.output,
|
|
51
|
+
timestamp: isoNow(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (step.text) {
|
|
55
|
+
await reporter.send({ type: 'message', sessionId: config.sessionId, text: step.text, timestamp: isoNow() });
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
await reporter.send({ type: 'done', sessionId: config.sessionId, summary: result.text, timestamp: isoNow() });
|
|
60
|
+
return { summary: result.text };
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
64
|
+
await reporter.send({ type: 'error', sessionId: config.sessionId, message, timestamp: isoNow() });
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=loop.js.map
|
package/dist/loop.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"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,CAAC,SAAS;wBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;wBACvB,KAAK,EAAE,IAAI,CAAC,KAAK;wBACjB,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM;wBACtB,SAAS,EAAE,MAAM,EAAE;qBACpB,CAAC,CAAA;gBACJ,CAAC;gBACD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACd,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;gBAC7G,CAAC;YACH,CAAC;SACF,CAAC,CAAA;QAEF,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;QAC7G,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACtE,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { McpConnectionRecord, McpToolSummary } from './mcp-connection';
|
|
2
|
+
export declare function mcpTransportStatus(error: unknown): number | undefined;
|
|
3
|
+
/** Linear retired `/sse`; Streamable HTTP lives at `/mcp`. Other hosts keep the stored URL. */
|
|
4
|
+
export declare function normalizeRemoteMcpUrl(raw: string): URL;
|
|
5
|
+
export declare function shouldFallbackToSse(error: unknown): boolean;
|
|
6
|
+
export declare function listRemoteTools(connection: McpConnectionRecord): Promise<McpToolSummary[]>;
|
|
7
|
+
export declare function callRemoteTool(connection: McpConnectionRecord, name: string, args?: Record<string, unknown>): Promise<{
|
|
8
|
+
isError: boolean;
|
|
9
|
+
content: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=mcp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAkB,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAuF3F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQrE;AAED,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAMtD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG3D;AAoDD,wBAAsB,eAAe,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAWhG;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAWhD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.mcpTransportStatus = mcpTransportStatus;
|
|
37
|
+
exports.normalizeRemoteMcpUrl = normalizeRemoteMcpUrl;
|
|
38
|
+
exports.shouldFallbackToSse = shouldFallbackToSse;
|
|
39
|
+
exports.listRemoteTools = listRemoteTools;
|
|
40
|
+
exports.callRemoteTool = callRemoteTool;
|
|
41
|
+
const mcp_tool_schema_1 = require("./mcp-tool-schema");
|
|
42
|
+
const LIST_TIMEOUT_MS = 20000;
|
|
43
|
+
const CALL_TIMEOUT_MS = 30000;
|
|
44
|
+
function fromStoredTokens(stored) {
|
|
45
|
+
if (!(stored === null || stored === void 0 ? void 0 : stored.accessToken))
|
|
46
|
+
return undefined;
|
|
47
|
+
return {
|
|
48
|
+
access_token: stored.accessToken,
|
|
49
|
+
refresh_token: stored.refreshToken,
|
|
50
|
+
token_type: stored.tokenType || 'Bearer',
|
|
51
|
+
scope: stored.scope,
|
|
52
|
+
expires_in: stored.expiresAt
|
|
53
|
+
? Math.max(0, Math.floor((Date.parse(stored.expiresAt) - Date.now()) / 1000))
|
|
54
|
+
: undefined,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function toStoredTokens(tokens) {
|
|
58
|
+
return {
|
|
59
|
+
accessToken: tokens.access_token,
|
|
60
|
+
refreshToken: tokens.refresh_token,
|
|
61
|
+
tokenType: tokens.token_type,
|
|
62
|
+
scope: tokens.scope,
|
|
63
|
+
expiresAt: typeof tokens.expires_in === 'number'
|
|
64
|
+
? new Date(Date.now() + tokens.expires_in * 1000).toISOString()
|
|
65
|
+
: undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
class InMemoryMcpAuthProvider {
|
|
69
|
+
constructor(connection) {
|
|
70
|
+
this.connection = connection;
|
|
71
|
+
this.redirectUrl = 'urn:ietf:wg:oauth:2.0:oob';
|
|
72
|
+
}
|
|
73
|
+
get clientMetadata() {
|
|
74
|
+
return {
|
|
75
|
+
client_name: 'Multiplayer Agent Runtime',
|
|
76
|
+
redirect_uris: [this.redirectUrl],
|
|
77
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
78
|
+
response_types: ['code'],
|
|
79
|
+
token_endpoint_auth_method: this.connection.oauthClientSecret ? 'client_secret_post' : 'none',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async clientInformation() {
|
|
83
|
+
if (!this.connection.oauthClientId)
|
|
84
|
+
return undefined;
|
|
85
|
+
return { client_id: this.connection.oauthClientId, client_secret: this.connection.oauthClientSecret };
|
|
86
|
+
}
|
|
87
|
+
async tokens() {
|
|
88
|
+
return fromStoredTokens(this.connection.oauthTokens);
|
|
89
|
+
}
|
|
90
|
+
// In-memory only — a refreshed token just needs to survive this process's lifetime.
|
|
91
|
+
async saveTokens(tokens) {
|
|
92
|
+
this.connection.oauthTokens = toStoredTokens(tokens);
|
|
93
|
+
}
|
|
94
|
+
// The consent flow already happened server-side before this VM ever started — a headless
|
|
95
|
+
// agent has no browser to redirect through, so treat re-auth as a hard failure.
|
|
96
|
+
async redirectToAuthorization() {
|
|
97
|
+
throw new Error(mcp_tool_schema_1.MCP_AUTH_EXPIRED);
|
|
98
|
+
}
|
|
99
|
+
async saveCodeVerifier() { }
|
|
100
|
+
async codeVerifier() {
|
|
101
|
+
throw new Error(mcp_tool_schema_1.MCP_AUTH_EXPIRED);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function mcpTransportStatus(error) {
|
|
105
|
+
if (error && typeof error === 'object') {
|
|
106
|
+
const code = error.code;
|
|
107
|
+
if (typeof code === 'number' && code >= 400 && code < 600)
|
|
108
|
+
return code;
|
|
109
|
+
}
|
|
110
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
111
|
+
const match = message.match(/\b(40[456])\b/);
|
|
112
|
+
return match ? Number(match[1]) : undefined;
|
|
113
|
+
}
|
|
114
|
+
/** Linear retired `/sse`; Streamable HTTP lives at `/mcp`. Other hosts keep the stored URL. */
|
|
115
|
+
function normalizeRemoteMcpUrl(raw) {
|
|
116
|
+
const url = new URL(raw);
|
|
117
|
+
if (url.hostname === 'mcp.linear.app' && /^\/sse\/?$/i.test(url.pathname)) {
|
|
118
|
+
url.pathname = '/mcp';
|
|
119
|
+
}
|
|
120
|
+
return url;
|
|
121
|
+
}
|
|
122
|
+
function shouldFallbackToSse(error) {
|
|
123
|
+
const status = mcpTransportStatus(error);
|
|
124
|
+
return status === 404 || status === 405 || status === 406;
|
|
125
|
+
}
|
|
126
|
+
async function withRemoteMcpClient(connection, fn) {
|
|
127
|
+
var _a;
|
|
128
|
+
if (connection.transport !== 'remote' || !connection.url) {
|
|
129
|
+
throw new Error('Remote MCP connections require an http(s) URL');
|
|
130
|
+
}
|
|
131
|
+
const [{ Client }, { StreamableHTTPClientTransport }, { SSEClientTransport }] = await Promise.all([
|
|
132
|
+
Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/client/index.js'))),
|
|
133
|
+
Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/client/streamableHttp.js'))),
|
|
134
|
+
Promise.resolve().then(() => __importStar(require('@modelcontextprotocol/sdk/client/sse.js'))),
|
|
135
|
+
]);
|
|
136
|
+
const authProvider = ((_a = connection.oauthTokens) === null || _a === void 0 ? void 0 : _a.accessToken) ? new InMemoryMcpAuthProvider(connection) : undefined;
|
|
137
|
+
const requestInit = connection.headers ? { headers: connection.headers } : undefined;
|
|
138
|
+
const url = normalizeRemoteMcpUrl(connection.url);
|
|
139
|
+
const tryTransport = async (Transport) => {
|
|
140
|
+
const client = new Client({ name: 'Multiplayer Agent Runtime', version: '1.0.0' });
|
|
141
|
+
const transport = new Transport(url, { authProvider, requestInit });
|
|
142
|
+
try {
|
|
143
|
+
await client.connect(transport);
|
|
144
|
+
return await fn(client);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await client.close().catch(() => undefined);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
try {
|
|
151
|
+
return await tryTransport(StreamableHTTPClientTransport);
|
|
152
|
+
}
|
|
153
|
+
catch (streamableError) {
|
|
154
|
+
if (!shouldFallbackToSse(streamableError)) {
|
|
155
|
+
throw new Error((0, mcp_tool_schema_1.mcpErrorMessage)(streamableError));
|
|
156
|
+
}
|
|
157
|
+
console.warn(`MCP streamable HTTP failed for ${url.href}; trying SSE`, streamableError);
|
|
158
|
+
try {
|
|
159
|
+
return await tryTransport(SSEClientTransport);
|
|
160
|
+
}
|
|
161
|
+
catch (_b) {
|
|
162
|
+
// SSE against a Streamable-HTTP-only URL (Linear `/mcp`) 405s on GET.
|
|
163
|
+
// Surface the original POST error instead of the fallback 405.
|
|
164
|
+
throw new Error((0, mcp_tool_schema_1.mcpErrorMessage)(streamableError));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function listRemoteTools(connection) {
|
|
169
|
+
return withRemoteMcpClient(connection, async (client) => {
|
|
170
|
+
const discovered = [];
|
|
171
|
+
let cursor;
|
|
172
|
+
do {
|
|
173
|
+
const page = await client.listTools(cursor ? { cursor } : undefined, { timeout: LIST_TIMEOUT_MS });
|
|
174
|
+
discovered.push(...page.tools);
|
|
175
|
+
cursor = typeof page.nextCursor === 'string' && page.nextCursor ? page.nextCursor : undefined;
|
|
176
|
+
} while (cursor && discovered.length < mcp_tool_schema_1.MAX_TOOLS);
|
|
177
|
+
return (0, mcp_tool_schema_1.sanitizeDiscoveredTools)(discovered);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async function callRemoteTool(connection, name, args) {
|
|
181
|
+
try {
|
|
182
|
+
const result = await withRemoteMcpClient(connection, (client) =>
|
|
183
|
+
// SDK signature is (params, resultSchema, options). Passing timeout as the
|
|
184
|
+
// second arg treats it as a Zod schema and drops the request options.
|
|
185
|
+
client.callTool({ name, arguments: args !== null && args !== void 0 ? args : {} }, undefined, { timeout: CALL_TIMEOUT_MS }));
|
|
186
|
+
return (0, mcp_tool_schema_1.shapeCallToolResult)(result);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return { isError: true, content: (0, mcp_tool_schema_1.mcpErrorMessage)(error) };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=mcp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.js","sourceRoot":"","sources":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,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;QAC9D,2EAA2E;QAC3E,sEAAsE;QACtE,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAC1F,CAAA;QACD,OAAO,IAAA,qCAAmB,EAAC,MAAM,CAAC,CAAA;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC,EAAE,CAAA;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type McpTransport = 'remote' | 'command';
|
|
2
|
+
export interface McpOAuthTokens {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
refreshToken?: string;
|
|
5
|
+
expiresAt?: string;
|
|
6
|
+
tokenType?: string;
|
|
7
|
+
scope?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface McpToolSummary {
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
inputSchema?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface McpConnectionSummary {
|
|
16
|
+
mcpConnectionId: string;
|
|
17
|
+
accountId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
transport: McpTransport;
|
|
21
|
+
url?: string;
|
|
22
|
+
command?: string;
|
|
23
|
+
headerKeys: string[];
|
|
24
|
+
oauthClientId?: string;
|
|
25
|
+
hasClientSecret: boolean;
|
|
26
|
+
authenticated: boolean;
|
|
27
|
+
tools: McpToolSummary[];
|
|
28
|
+
toolsSyncedAt?: string;
|
|
29
|
+
toolsSyncError?: string;
|
|
30
|
+
createdBy: string;
|
|
31
|
+
updatedBy: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface McpConnectionRecord extends McpConnectionSummary {
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
oauthClientSecret?: string;
|
|
38
|
+
oauthTokens?: McpOAuthTokens;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=mcp-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-connection.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-connection.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE/C,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,cAAc,CAAA;CAC7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Vendored from libs/builder-api/src/lib/mcp-connections/mcp-connection.ts — kept in sync by
|
|
3
|
+
// hand. Only the fields this package actually reads are included; the source of truth for the
|
|
4
|
+
// full connection record (create/update, OAuth consent) stays server-side.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
//# sourceMappingURL=mcp-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-connection.js","sourceRoot":"","sources":["../../src/mcp/mcp-connection.ts"],"names":[],"mappings":";AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,2EAA2E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { McpToolSummary } from './mcp-connection';
|
|
2
|
+
export declare const MAX_TOOLS = 200;
|
|
3
|
+
export declare const TOOL_NAME_MAX = 200;
|
|
4
|
+
export declare const TOOL_DESCRIPTION_MAX = 500;
|
|
5
|
+
export declare const INPUT_SCHEMA_MAX_BYTES: number;
|
|
6
|
+
export declare const CALL_RESULT_MAX_BYTES: number;
|
|
7
|
+
export declare const MCP_AUTH_EXPIRED = "MCP server authentication expired. Re-authenticate this connection.";
|
|
8
|
+
export declare function sanitizeInputSchema(schema: unknown): Record<string, unknown> | undefined;
|
|
9
|
+
export declare function sanitizeDiscoveredTools(tools: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
inputSchema?: unknown;
|
|
14
|
+
}>): McpToolSummary[];
|
|
15
|
+
export declare function mergeTools(existing: McpToolSummary[] | undefined, discovered: McpToolSummary[]): McpToolSummary[];
|
|
16
|
+
export declare function mcpErrorMessage(error: unknown): string;
|
|
17
|
+
export declare function shapeCallToolResult(result: {
|
|
18
|
+
content?: unknown;
|
|
19
|
+
isError?: boolean;
|
|
20
|
+
structuredContent?: unknown;
|
|
21
|
+
}): {
|
|
22
|
+
isError: boolean;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=mcp-tool-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-schema.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-tool-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,eAAO,MAAM,SAAS,MAAM,CAAA;AAC5B,eAAO,MAAM,aAAa,MAAM,CAAA;AAChC,eAAO,MAAM,oBAAoB,MAAM,CAAA;AACvC,eAAO,MAAM,sBAAsB,QAAW,CAAA;AAC9C,eAAO,MAAM,qBAAqB,QAAY,CAAA;AAC9C,eAAO,MAAM,gBAAgB,wEAAwE,CAAA;AAErG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CASxF;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAC1F,cAAc,EAAE,CAiBlB;AAED,wBAAgB,UAAU,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