@multiplayer-app/sandbox 0.0.6 → 0.0.8
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/agents/shared/get-latest-session-artifact.tool.d.ts +7 -0
- package/dist/agents/shared/get-latest-session-artifact.tool.d.ts.map +1 -0
- package/dist/agents/shared/get-latest-session-artifact.tool.js +43 -0
- package/dist/agents/shared/get-latest-session-artifact.tool.js.map +1 -0
- package/dist/lib/session-pages/read-session-artifact.d.ts +7 -0
- package/dist/lib/session-pages/read-session-artifact.d.ts.map +1 -0
- package/dist/lib/session-pages/read-session-artifact.js +60 -0
- package/dist/lib/session-pages/read-session-artifact.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AgentTool } from '@multiplayer-app/ai-agent-types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const getLatestSessionArtifactInputSchema: z.ZodObject<{
|
|
4
|
+
path: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare function createGetLatestSessionArtifactTool(): AgentTool;
|
|
7
|
+
//# sourceMappingURL=get-latest-session-artifact.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-latest-session-artifact.tool.d.ts","sourceRoot":"","sources":["../../../src/agents/shared/get-latest-session-artifact.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAGnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,mCAAmC;;iBAO9C,CAAA;AAEF,wBAAgB,kCAAkC,IAAI,SAAS,CAgC9D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLatestSessionArtifactInputSchema = void 0;
|
|
4
|
+
exports.createGetLatestSessionArtifactTool = createGetLatestSessionArtifactTool;
|
|
5
|
+
const ai_agent_types_1 = require("@multiplayer-app/ai-agent-types");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const read_session_artifact_1 = require("../../lib/session-pages/read-session-artifact");
|
|
8
|
+
const resolve_chat_id_1 = require("../../lib/session-pages/resolve-chat-id");
|
|
9
|
+
exports.getLatestSessionArtifactInputSchema = zod_1.z.object({
|
|
10
|
+
path: zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.describe('Session-relative artifact path (attachment), e.g. index.html, README.md, styles.css, docs/architecture.md'),
|
|
14
|
+
});
|
|
15
|
+
function createGetLatestSessionArtifactTool() {
|
|
16
|
+
return {
|
|
17
|
+
type: ai_agent_types_1.AgentToolType.LOCAL_FUNCTION,
|
|
18
|
+
userConfigurable: true,
|
|
19
|
+
data: {
|
|
20
|
+
title: 'getLatestSessionArtifact',
|
|
21
|
+
needsApproval: false,
|
|
22
|
+
description: 'Load the current on-disk or live-collaboration contents of a session artifact by path. Use before editing existing files — never rely on stale content from earlier messages or tool results.',
|
|
23
|
+
inputSchema: exports.getLatestSessionArtifactInputSchema,
|
|
24
|
+
outputSchema: zod_1.z.object({
|
|
25
|
+
sessionId: zod_1.z.string(),
|
|
26
|
+
path: zod_1.z.string(),
|
|
27
|
+
content: zod_1.z.string(),
|
|
28
|
+
bytes: zod_1.z.number(),
|
|
29
|
+
}),
|
|
30
|
+
execute: async (input, context, secondArg) => {
|
|
31
|
+
const sessionId = await (0, resolve_chat_id_1.resolveChatId)(context, secondArg);
|
|
32
|
+
const result = await (0, read_session_artifact_1.readLatestSessionArtifactText)(sessionId, input.path);
|
|
33
|
+
return {
|
|
34
|
+
sessionId,
|
|
35
|
+
path: result.path,
|
|
36
|
+
content: result.content,
|
|
37
|
+
bytes: result.bytes,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=get-latest-session-artifact.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-latest-session-artifact.tool.js","sourceRoot":"","sources":["../../../src/agents/shared/get-latest-session-artifact.tool.ts"],"names":[],"mappings":";;;AAgBA,gFAgCC;AA/CD,oEAA+D;AAE/D,6BAAuB;AACvB,yFAA6F;AAC7F,6EAAuE;AAE1D,QAAA,mCAAmC,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1D,IAAI,EAAE,OAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,2GAA2G,CAC5G;CACJ,CAAC,CAAA;AAEF,SAAgB,kCAAkC;IAChD,OAAO;QACL,IAAI,EAAE,8BAAa,CAAC,cAAc;QAClC,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE;YACJ,KAAK,EAAE,0BAA0B;YACjC,aAAa,EAAE,KAAK;YACpB,WAAW,EACT,+LAA+L;YACjM,WAAW,EAAE,2CAAmC;YAChD,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;gBACrB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;gBACrB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;gBAChB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;gBACnB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;aAClB,CAAC;YACF,OAAO,EAAE,KAAK,EACZ,KAA0D,EAC1D,OAA2B,EAC3B,SAAgC,EAChC,EAAE;gBACF,MAAM,SAAS,GAAG,MAAM,IAAA,+BAAa,EAAC,OAAO,EAAE,SAAS,CAAC,CAAA;gBACzD,MAAM,MAAM,GAAG,MAAM,IAAA,qDAA6B,EAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;gBACzE,OAAO;oBACL,SAAS;oBACT,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAA;YACH,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ReadLatestSessionArtifactResult {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
bytes: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function readLatestSessionArtifactText(sessionId: string, artifactPath: string): Promise<ReadLatestSessionArtifactResult>;
|
|
7
|
+
//# sourceMappingURL=read-session-artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-session-artifact.d.ts","sourceRoot":"","sources":["../../../src/lib/session-pages/read-session-artifact.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,+BAA+B,CAAC,CAoB1C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readLatestSessionArtifactText = readLatestSessionArtifactText;
|
|
7
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
+
const session_artifact_yjs_store_1 = require("../../realtime/session-artifact-yjs-store");
|
|
9
|
+
const paths_1 = require("./paths");
|
|
10
|
+
const BINARY_EXTENSIONS = new Set([
|
|
11
|
+
'png',
|
|
12
|
+
'jpg',
|
|
13
|
+
'jpeg',
|
|
14
|
+
'gif',
|
|
15
|
+
'svg',
|
|
16
|
+
'webp',
|
|
17
|
+
'ico',
|
|
18
|
+
'bmp',
|
|
19
|
+
'avif',
|
|
20
|
+
'woff',
|
|
21
|
+
'woff2',
|
|
22
|
+
'ttf',
|
|
23
|
+
'otf',
|
|
24
|
+
'eot',
|
|
25
|
+
'pdf',
|
|
26
|
+
'zip',
|
|
27
|
+
'tar',
|
|
28
|
+
'gz',
|
|
29
|
+
'br',
|
|
30
|
+
'mp3',
|
|
31
|
+
'mp4',
|
|
32
|
+
'wav',
|
|
33
|
+
'ogg',
|
|
34
|
+
'webm',
|
|
35
|
+
]);
|
|
36
|
+
function isLikelyBinaryArtifactPath(artifactPath) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const ext = (_b = (_a = artifactPath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
39
|
+
return BINARY_EXTENSIONS.has(ext);
|
|
40
|
+
}
|
|
41
|
+
async function readLatestSessionArtifactText(sessionId, artifactPath) {
|
|
42
|
+
const path = (0, paths_1.normalizeArtifactPath)(artifactPath);
|
|
43
|
+
if (isLikelyBinaryArtifactPath(path)) {
|
|
44
|
+
throw new Error(`Cannot read binary artifact as text: ${path}`);
|
|
45
|
+
}
|
|
46
|
+
const absolutePath = (0, paths_1.resolveArtifactPath)(sessionId, path);
|
|
47
|
+
try {
|
|
48
|
+
await promises_1.default.access(absolutePath);
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
throw new Error(`Artifact not found: ${path}`);
|
|
52
|
+
}
|
|
53
|
+
const content = await (0, session_artifact_yjs_store_1.getSessionArtifactYjsStore)().getLatestArtifactText(sessionId, path);
|
|
54
|
+
return {
|
|
55
|
+
path,
|
|
56
|
+
content,
|
|
57
|
+
bytes: Buffer.byteLength(content, 'utf8'),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=read-session-artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-session-artifact.js","sourceRoot":"","sources":["../../../src/lib/session-pages/read-session-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,CAAA;IACzF,OAAO;QACL,IAAI;QACJ,OAAO;QACP,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1C,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/sandbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Embeddable Builder HTTP API and agent runtime",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@multiplayer-app/ai-agent-node": "0.1.0-beta.
|
|
12
|
-
"@multiplayer-app/ai-agent-types": "0.1.0-beta.
|
|
11
|
+
"@multiplayer-app/ai-agent-node": "0.1.0-beta.84",
|
|
12
|
+
"@multiplayer-app/ai-agent-types": "0.1.0-beta.84",
|
|
13
13
|
"@multiplayer-app/realtime-server": "0.1.1",
|
|
14
14
|
"ai": "6.0.3",
|
|
15
15
|
"express": "^5.2.1",
|