@burtson-labs/host-kit 0.4.32 → 0.4.34
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/artifacts.d.ts +45 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +73 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +103 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +178 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/tools/publishArtifactTool.d.ts +6 -0
- package/dist/tools/publishArtifactTool.d.ts.map +1 -0
- package/dist/tools/publishArtifactTool.js +90 -0
- package/dist/tools/publishArtifactTool.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bandit Artifacts (cloud) — publish a shareable artifact to S3Api and get back
|
|
3
|
+
* a URL anyone with the link can open.
|
|
4
|
+
*
|
|
5
|
+
* Cloud users' Burtson JWT authenticates to every Burtson API (confirmed), so
|
|
6
|
+
* this talks to S3Api directly — no gateway proxy, no service credential. The
|
|
7
|
+
* upload is per-user scoped and quota-bounded server-side (see S3Api's
|
|
8
|
+
* ArtifactController); this client just posts the bytes with the caller's token
|
|
9
|
+
* and returns the shareable URL S3Api mints.
|
|
10
|
+
*
|
|
11
|
+
* Host-agnostic (fetch + FormData/Blob, standard in the Node the CLI and
|
|
12
|
+
* extension run on), so both hosts share one implementation. Local-only users
|
|
13
|
+
* never call this — it requires a cloud token, keeping the offline path offline.
|
|
14
|
+
*/
|
|
15
|
+
export interface PublishArtifactOptions {
|
|
16
|
+
/** S3Api base URL, e.g. https://s3.burtson.ai (no trailing slash needed). */
|
|
17
|
+
s3ApiBaseUrl: string;
|
|
18
|
+
/** The user's Bandit cloud token (same JWT used for every Burtson API). */
|
|
19
|
+
token: string;
|
|
20
|
+
/** Artifact bytes (a report, a file) or text. */
|
|
21
|
+
content: Uint8Array | string;
|
|
22
|
+
/** File name — its extension drives how the artifact renders when shared. */
|
|
23
|
+
filename: string;
|
|
24
|
+
/** MIME type; defaults by extension, else application/octet-stream. */
|
|
25
|
+
contentType?: string;
|
|
26
|
+
/** Injectable for tests / non-global-fetch runtimes. */
|
|
27
|
+
fetchImpl?: typeof fetch;
|
|
28
|
+
}
|
|
29
|
+
export interface PublishedArtifact {
|
|
30
|
+
/** Absolute shareable URL (open in any browser). */
|
|
31
|
+
url: string;
|
|
32
|
+
/** Server object key (owner-prefixed). */
|
|
33
|
+
key: string;
|
|
34
|
+
size: number;
|
|
35
|
+
}
|
|
36
|
+
/** Best-effort MIME guess from a filename extension. */
|
|
37
|
+
export declare function guessContentType(filename: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Upload an artifact and return its shareable URL. Throws on a non-2xx (with
|
|
40
|
+
* the status + server message) so callers can surface a clear failure — this
|
|
41
|
+
* is user-initiated ("share this"), so silent failure would be worse than an
|
|
42
|
+
* error.
|
|
43
|
+
*/
|
|
44
|
+
export declare function publishArtifact(opts: PublishArtifactOptions): Promise<PublishedArtifact>;
|
|
45
|
+
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAczD;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0B9F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bandit Artifacts (cloud) — publish a shareable artifact to S3Api and get back
|
|
4
|
+
* a URL anyone with the link can open.
|
|
5
|
+
*
|
|
6
|
+
* Cloud users' Burtson JWT authenticates to every Burtson API (confirmed), so
|
|
7
|
+
* this talks to S3Api directly — no gateway proxy, no service credential. The
|
|
8
|
+
* upload is per-user scoped and quota-bounded server-side (see S3Api's
|
|
9
|
+
* ArtifactController); this client just posts the bytes with the caller's token
|
|
10
|
+
* and returns the shareable URL S3Api mints.
|
|
11
|
+
*
|
|
12
|
+
* Host-agnostic (fetch + FormData/Blob, standard in the Node the CLI and
|
|
13
|
+
* extension run on), so both hosts share one implementation. Local-only users
|
|
14
|
+
* never call this — it requires a cloud token, keeping the offline path offline.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.guessContentType = guessContentType;
|
|
18
|
+
exports.publishArtifact = publishArtifact;
|
|
19
|
+
/** Best-effort MIME guess from a filename extension. */
|
|
20
|
+
function guessContentType(filename) {
|
|
21
|
+
const ext = filename.slice(filename.lastIndexOf('.')).toLowerCase();
|
|
22
|
+
switch (ext) {
|
|
23
|
+
case '.html':
|
|
24
|
+
case '.htm': return 'text/html';
|
|
25
|
+
case '.md': return 'text/markdown';
|
|
26
|
+
case '.txt':
|
|
27
|
+
case '.log': return 'text/plain';
|
|
28
|
+
case '.json': return 'application/json';
|
|
29
|
+
case '.csv': return 'text/csv';
|
|
30
|
+
case '.pdf': return 'application/pdf';
|
|
31
|
+
case '.png': return 'image/png';
|
|
32
|
+
case '.jpg':
|
|
33
|
+
case '.jpeg': return 'image/jpeg';
|
|
34
|
+
case '.svg': return 'image/svg+xml';
|
|
35
|
+
default: return 'application/octet-stream';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Upload an artifact and return its shareable URL. Throws on a non-2xx (with
|
|
40
|
+
* the status + server message) so callers can surface a clear failure — this
|
|
41
|
+
* is user-initiated ("share this"), so silent failure would be worse than an
|
|
42
|
+
* error.
|
|
43
|
+
*/
|
|
44
|
+
async function publishArtifact(opts) {
|
|
45
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
46
|
+
const base = opts.s3ApiBaseUrl.replace(/\/$/, '');
|
|
47
|
+
const contentType = opts.contentType ?? guessContentType(opts.filename);
|
|
48
|
+
const bytes = typeof opts.content === 'string' ? new TextEncoder().encode(opts.content) : opts.content;
|
|
49
|
+
const form = new FormData();
|
|
50
|
+
// Field name must match S3Api's UploadRequest.File. Don't set a
|
|
51
|
+
// Content-Type header ourselves — fetch derives the multipart boundary.
|
|
52
|
+
// Cast: Uint8Array is a valid BlobPart at runtime; the cast only sidesteps
|
|
53
|
+
// TS 5.7's ArrayBufferLike/SharedArrayBuffer generic strictness.
|
|
54
|
+
form.append('File', new Blob([bytes], { type: contentType }), opts.filename);
|
|
55
|
+
const res = await fetchImpl(`${base}/api/artifact`, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: { authorization: `Bearer ${opts.token}` },
|
|
58
|
+
body: form,
|
|
59
|
+
});
|
|
60
|
+
if (!res.ok) {
|
|
61
|
+
let detail = '';
|
|
62
|
+
try {
|
|
63
|
+
detail = (await res.json())?.message ?? '';
|
|
64
|
+
}
|
|
65
|
+
catch { /* non-JSON */ }
|
|
66
|
+
throw new Error(`artifact upload failed: HTTP ${res.status}${detail ? ` — ${detail}` : ''}`);
|
|
67
|
+
}
|
|
68
|
+
const body = (await res.json());
|
|
69
|
+
if (!body.url)
|
|
70
|
+
throw new Error('artifact upload succeeded but no URL was returned');
|
|
71
|
+
return { url: body.url, key: body.key ?? '', size: body.size ?? bytes.byteLength };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AA0BH,4CAcC;AAQD,0CA0BC;AAjDD,wDAAwD;AACxD,SAAgB,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO,CAAC;QAAC,KAAK,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC;QAC9C,KAAK,KAAK,CAAC,CAAC,OAAO,eAAe,CAAC;QACnC,KAAK,MAAM,CAAC;QAAC,KAAK,MAAM,CAAC,CAAC,OAAO,YAAY,CAAC;QAC9C,KAAK,OAAO,CAAC,CAAC,OAAO,kBAAkB,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,OAAO,UAAU,CAAC;QAC/B,KAAK,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC;QACtC,KAAK,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC;QAChC,KAAK,MAAM,CAAC;QAAC,KAAK,OAAO,CAAC,CAAC,OAAO,YAAY,CAAC;QAC/C,KAAK,MAAM,CAAC,CAAC,OAAO,eAAe,CAAC;QACpC,OAAO,CAAC,CAAC,OAAO,0BAA0B,CAAC;IAC7C,CAAC;AACH,CAAC;AAED;;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AAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA+B,CAAC;IAC9D,IAAI,CAAC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACpF,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;AACrF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export { loadMemory, loadCombinedMemory, appendMemory, consolidateMemory, type M
|
|
|
2
2
|
export { loadMemoryIndex, renderMemoryIndexBlock, writeMemoryTopic, migrateMemoryToBanditDir, MAX_INDEX_BYTES, MAX_MEMORY_FILE_BYTES, MEMORY_DIR, MEMORY_INDEX_FILE, BANDIT_DIR, BANDIT_MEMORY_DIR, BANDIT_MEMORY_INDEX_FILE, type MemoryIndex, type MemoryIndexEntry, type MemoryWarnFn } from './memoryIndex';
|
|
3
3
|
export { buildReadMemoryTool } from './tools/readMemoryTool';
|
|
4
4
|
export { lessonsPath, loadLessons, addLesson, clearLessons, type AddLessonResult } from './lessons';
|
|
5
|
+
export { publishArtifact, guessContentType, type PublishArtifactOptions, type PublishedArtifact } from './artifacts';
|
|
6
|
+
export { buildPublishArtifactTool } from './tools/publishArtifactTool';
|
|
7
|
+
export { LocalSandboxExecutor, AntonSandboxExecutor, createSandboxExecutor, ANTON_EXEC_CONTRACT, type SandboxExecutor, type SandboxExecOptions, type SandboxExecResult, type SandboxConfig, } from './sandbox';
|
|
5
8
|
export { RUNNER_PROTOCOL_VERSION, type RemoteRunMode, type RemoteTask, type RunnerEvent, type RunnerGateway } from './runner/contract';
|
|
6
9
|
export { HttpRunnerGateway, type HttpGatewayOptions } from './runner/httpGateway';
|
|
7
10
|
export { RemoteSession, type RemoteSessionOptions } from './runner/remoteSession';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,eAAe,C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AAC7B,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.loadMcpToolCache = exports.mcpTrustPath = exports.revokeMcpFingerprint = exports.approveMcpFingerprint = exports.loadApprovedMcpFingerprints = exports.buildCustomServerConfig = exports.looksLikeGmailCredentialsPath = exports.buildGmailServerConfig = exports.looksLikeGitLabToken = exports.buildGitLabServerConfig = exports.looksLikeSlackTeamId = exports.looksLikeSlackToken = exports.buildSlackServerConfig = exports.looksLikeGitHubToken = exports.buildGitHubServerConfig = exports.addMcpServerToConfig = exports.persistMcpActivation = exports.globalMcpServersPath = exports.registerMcpServersFromDisk = exports.loadMcpServersConfig = exports.RemoteSession = exports.HttpRunnerGateway = exports.RUNNER_PROTOCOL_VERSION = exports.ANTON_EXEC_CONTRACT = exports.createSandboxExecutor = exports.AntonSandboxExecutor = exports.LocalSandboxExecutor = exports.buildPublishArtifactTool = exports.guessContentType = exports.publishArtifact = exports.clearLessons = exports.addLesson = exports.loadLessons = exports.lessonsPath = exports.buildReadMemoryTool = exports.BANDIT_MEMORY_INDEX_FILE = exports.BANDIT_MEMORY_DIR = exports.BANDIT_DIR = exports.MEMORY_INDEX_FILE = exports.MEMORY_DIR = exports.MAX_MEMORY_FILE_BYTES = exports.MAX_INDEX_BYTES = exports.migrateMemoryToBanditDir = exports.writeMemoryTopic = exports.renderMemoryIndexBlock = exports.loadMemoryIndex = exports.consolidateMemory = exports.appendMemory = exports.loadCombinedMemory = exports.loadMemory = void 0;
|
|
4
|
+
exports.summarizeTurnTrace = exports.parseTurnLog = exports.readTurnTraceById = exports.readTurnTrace = exports.listTurnTraces = exports.listTurnTraceFiles = exports.previewText = exports.openTurnLog = exports.SessionPermissionStore = exports.mergePolicies = exports.emptyPolicy = exports.evaluatePermission = exports.InMemoryBackgroundTaskStore = exports.buildInsightsAiCallback = exports.buildAiInput = exports.writeInsightsReport = exports.renderInsightsHtml = exports.computeInsights = exports.parseTestOutput = exports.buildTestCommand = exports.detectTestFramework = exports.buildTestRunTool = exports.buildListTasksTool = exports.buildCheckTaskTool = exports.buildTaskTool = exports.buildRememberTool = exports.buildWebSearchTool = exports.buildWebFetchTool = exports.buildTodoWriteTool = exports.TodoStore = exports.expandMentions = exports.CYCLE_MODES = exports.PERMISSION_MODES = exports.AutoApprovalLedger = exports.nextCycleMode = exports.isPermissionMode = exports.decidePermission = exports.shouldAutoApprove = exports.resolvePermissionMode = exports.policyIncludes = exports.commandSignature = exports.grantRuleFor = exports.classifyRisk = exports.evaluateSecurityGuard = exports.runHooks = exports.persistAllowEntry = exports.loadHookSettings = exports.mcpToolCachePath = exports.pruneMcpToolCache = exports.saveMcpToolEntry = void 0;
|
|
5
|
+
exports.CheckpointStore = exports.isChatCapable = exports.suggestOllamaMatch = exports.listInstalledOllamaModels = exports.formatTurnTraceMarkdown = void 0;
|
|
5
6
|
var memory_1 = require("./memory");
|
|
6
7
|
Object.defineProperty(exports, "loadMemory", { enumerable: true, get: function () { return memory_1.loadMemory; } });
|
|
7
8
|
Object.defineProperty(exports, "loadCombinedMemory", { enumerable: true, get: function () { return memory_1.loadCombinedMemory; } });
|
|
@@ -27,6 +28,19 @@ Object.defineProperty(exports, "lessonsPath", { enumerable: true, get: function
|
|
|
27
28
|
Object.defineProperty(exports, "loadLessons", { enumerable: true, get: function () { return lessons_1.loadLessons; } });
|
|
28
29
|
Object.defineProperty(exports, "addLesson", { enumerable: true, get: function () { return lessons_1.addLesson; } });
|
|
29
30
|
Object.defineProperty(exports, "clearLessons", { enumerable: true, get: function () { return lessons_1.clearLessons; } });
|
|
31
|
+
// Bandit Artifacts (cloud) — publish a shareable artifact to S3Api, get a URL.
|
|
32
|
+
var artifacts_1 = require("./artifacts");
|
|
33
|
+
Object.defineProperty(exports, "publishArtifact", { enumerable: true, get: function () { return artifacts_1.publishArtifact; } });
|
|
34
|
+
Object.defineProperty(exports, "guessContentType", { enumerable: true, get: function () { return artifacts_1.guessContentType; } });
|
|
35
|
+
var publishArtifactTool_1 = require("./tools/publishArtifactTool");
|
|
36
|
+
Object.defineProperty(exports, "buildPublishArtifactTool", { enumerable: true, get: function () { return publishArtifactTool_1.buildPublishArtifactTool; } });
|
|
37
|
+
// Sandbox execution seam — swappable boundary for running commands (local host
|
|
38
|
+
// today; Firecracker microVM via anton once its exec endpoint lands).
|
|
39
|
+
var sandbox_1 = require("./sandbox");
|
|
40
|
+
Object.defineProperty(exports, "LocalSandboxExecutor", { enumerable: true, get: function () { return sandbox_1.LocalSandboxExecutor; } });
|
|
41
|
+
Object.defineProperty(exports, "AntonSandboxExecutor", { enumerable: true, get: function () { return sandbox_1.AntonSandboxExecutor; } });
|
|
42
|
+
Object.defineProperty(exports, "createSandboxExecutor", { enumerable: true, get: function () { return sandbox_1.createSandboxExecutor; } });
|
|
43
|
+
Object.defineProperty(exports, "ANTON_EXEC_CONTRACT", { enumerable: true, get: function () { return sandbox_1.ANTON_EXEC_CONTRACT; } });
|
|
30
44
|
// Remote control: the local-runner ↔ gateway transport + live-session driver.
|
|
31
45
|
// Host-agnostic (only fetch + ReadableStream), so BOTH the CLI and the VS Code
|
|
32
46
|
// extension import the SAME RemoteSession — one proven mechanism, not two copies.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,mCAQkB;AAPhB,oGAAA,UAAU,OAAA;AACV,4GAAA,kBAAkB,OAAA;AAClB,sGAAA,YAAY,OAAA;AACZ,2GAAA,iBAAiB,OAAA;AAKnB,6CAeuB;AAdrB,8GAAA,eAAe,OAAA;AACf,qHAAA,sBAAsB,OAAA;AACtB,+GAAA,gBAAgB,OAAA;AAChB,uHAAA,wBAAwB,OAAA;AACxB,8GAAA,eAAe,OAAA;AACf,oHAAA,qBAAqB,OAAA;AACrB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,yGAAA,UAAU,OAAA;AACV,gHAAA,iBAAiB,OAAA;AACjB,uHAAA,wBAAwB,OAAA;AAK1B,yDAA6D;AAApD,qHAAA,mBAAmB,OAAA;AAC5B,+EAA+E;AAC/E,qCAAoG;AAA3F,sGAAA,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AAsB,OAAA;AAIxB,qCAgBmB;AAfjB,sGAAA,WAAW,OAAA;AACX,sGAAA,WAAW,OAAA;AACX,6GAAA,kBAAkB,OAAA;AAClB,yGAAA,cAAc,OAAA;AACd,wGAAA,aAAa,OAAA;AACb,4GAAA,iBAAiB,OAAA;AACjB,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAClB,kHAAA,uBAAuB,OAAA;AAQzB,+CAKwB;AAJtB,yHAAA,yBAAyB,OAAA;AACzB,kHAAA,kBAAkB,OAAA;AAClB,6GAAA,aAAa,OAAA;AAGf,6CAKuB;AAJrB,8GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox execution seam — the boundary that lets Bandit run a command inside
|
|
3
|
+
* a hard isolation boundary (a Firecracker microVM) instead of directly on the
|
|
4
|
+
* host filesystem.
|
|
5
|
+
*
|
|
6
|
+
* WHY: Bandit's safety today is BEHAVIORAL — host-kit's decidePermission gates
|
|
7
|
+
* whether a command runs, but if it runs, it runs on your real machine. That's
|
|
8
|
+
* fine with a human at the keyboard; it is NOT fine for the autonomy we now
|
|
9
|
+
* ship (remote control, graph auto-routing) where nobody is watching. A microVM
|
|
10
|
+
* is a HARD boundary: a compromised model output, a prompt-injection, or a bad
|
|
11
|
+
* tool call physically cannot reach the host. This seam is what a caller routes
|
|
12
|
+
* `runCommand` through so that boundary is swappable.
|
|
13
|
+
*
|
|
14
|
+
* The interface is deliberately tiny and backend-agnostic. Today only the local
|
|
15
|
+
* backend exists (no isolation — current behavior). The microVM backend targets
|
|
16
|
+
* the `anton` control plane (Firecracker microVMs on son-of-anton), but anton's
|
|
17
|
+
* current API deploys web apps (Caddy rootfs + bundle→serve) and does NOT yet
|
|
18
|
+
* expose command-exec-with-output — see ANTON_EXEC_CONTRACT below for exactly
|
|
19
|
+
* what it must add. Until then, selecting the anton backend fails loudly rather
|
|
20
|
+
* than silently running on the host.
|
|
21
|
+
*/
|
|
22
|
+
export interface SandboxExecOptions {
|
|
23
|
+
/** Working directory for the command (inside the sandbox's mounted workspace). */
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/** Hard timeout in ms. A sandbox MUST kill the command at this bound. */
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
/** Extra environment for the command. Secrets should NOT be passed here for
|
|
28
|
+
* untrusted work — that's part of the point of the boundary. */
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export interface SandboxExecResult {
|
|
32
|
+
stdout: string;
|
|
33
|
+
stderr: string;
|
|
34
|
+
exitCode: number;
|
|
35
|
+
/** True when the command was killed at timeoutMs. */
|
|
36
|
+
timedOut?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Runs a command somewhere. `local` = the host (no isolation). `microvm` = a
|
|
40
|
+
* one-command-scoped Firecracker VM via anton (hard boundary). Callers depend
|
|
41
|
+
* on this interface, never on a concrete backend, so the boundary is a config
|
|
42
|
+
* switch, not a rewrite.
|
|
43
|
+
*/
|
|
44
|
+
export interface SandboxExecutor {
|
|
45
|
+
readonly kind: 'local' | 'microvm';
|
|
46
|
+
exec(command: string, opts?: SandboxExecOptions): Promise<SandboxExecResult>;
|
|
47
|
+
/** Release any per-executor resources (VM teardown, etc.). */
|
|
48
|
+
dispose?(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The HTTP contract anton must implement for microVM exec (it doesn't yet).
|
|
52
|
+
* Documented here as the single source of truth for the two-repo work:
|
|
53
|
+
*
|
|
54
|
+
* POST {antonBaseUrl}/sessions → { id } (create VM)
|
|
55
|
+
* POST {antonBaseUrl}/sessions/{id}/exec { command, cwd?, env?, timeoutMs? }
|
|
56
|
+
* → { stdout, stderr, exitCode, timedOut? }
|
|
57
|
+
* DELETE {antonBaseUrl}/sessions/{id} (teardown)
|
|
58
|
+
*
|
|
59
|
+
* Auth: Burtson JWT (same bearer the CLI/extension already hold). The VM mounts
|
|
60
|
+
* ONLY the workspace, has NO host mount, and NO network egress by default.
|
|
61
|
+
*/
|
|
62
|
+
export declare const ANTON_EXEC_CONTRACT = "POST /sessions/{id}/exec {command,cwd?,env?,timeoutMs?} -> {stdout,stderr,exitCode}";
|
|
63
|
+
/** The host backend — no isolation, current behavior. A microVM backend
|
|
64
|
+
* implements the same interface against anton once its exec endpoint lands. */
|
|
65
|
+
export declare class LocalSandboxExecutor implements SandboxExecutor {
|
|
66
|
+
readonly kind: "local";
|
|
67
|
+
exec(command: string, opts?: SandboxExecOptions): Promise<SandboxExecResult>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The microVM backend — a client for anton's exec API (ANTON_EXEC_CONTRACT).
|
|
71
|
+
* Each exec creates a fresh VM, runs the command, tears it down: one-command
|
|
72
|
+
* isolation, so nothing persists or leaks between calls. Built + tested here
|
|
73
|
+
* against the contract; it goes live the moment anton ships the endpoint (the
|
|
74
|
+
* anton side stages the command as the VM's run.sh, boots, returns output).
|
|
75
|
+
*/
|
|
76
|
+
export declare class AntonSandboxExecutor implements SandboxExecutor {
|
|
77
|
+
private readonly opts;
|
|
78
|
+
readonly kind: "microvm";
|
|
79
|
+
constructor(opts: {
|
|
80
|
+
baseUrl: string;
|
|
81
|
+
token: string;
|
|
82
|
+
fetchImpl?: typeof fetch;
|
|
83
|
+
});
|
|
84
|
+
private get fetchImpl();
|
|
85
|
+
private headers;
|
|
86
|
+
exec(command: string, opts?: SandboxExecOptions): Promise<SandboxExecResult>;
|
|
87
|
+
}
|
|
88
|
+
export interface SandboxConfig {
|
|
89
|
+
/** 'local' (default) or 'microvm'. */
|
|
90
|
+
mode?: 'local' | 'microvm';
|
|
91
|
+
/** anton node-agent base URL, required for 'microvm'. */
|
|
92
|
+
antonBaseUrl?: string;
|
|
93
|
+
/** Bearer token for anton (Burtson JWT). */
|
|
94
|
+
token?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Pick a backend from config. Defaults to local. `microvm` is accepted but the
|
|
98
|
+
* anton backend is not implemented yet, so this throws with a precise reason
|
|
99
|
+
* rather than degrading to local (silent degrade would defeat the safety goal —
|
|
100
|
+
* you'd think you were sandboxed and not be).
|
|
101
|
+
*/
|
|
102
|
+
export declare function createSandboxExecutor(config?: SandboxConfig, localFactory?: () => SandboxExecutor): SandboxExecutor;
|
|
103
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;qEACiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7E,8DAA8D;IAC9D,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,wFAAwF,CAAC;AAEzH;gFACgF;AAChF,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IAE3B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA0BvF;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAGxD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFvB,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;gBAEhB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;KAAE;IAGrF,OAAO,KAAK,SAAS,GAAyD;IAC9E,OAAO,CAAC,OAAO;IAIT,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA2BvF;AAED,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,aAAkB,EAC1B,YAAY,GAAE,MAAM,eAAkD,GACrE,eAAe,CAcjB"}
|
package/dist/sandbox.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sandbox execution seam — the boundary that lets Bandit run a command inside
|
|
4
|
+
* a hard isolation boundary (a Firecracker microVM) instead of directly on the
|
|
5
|
+
* host filesystem.
|
|
6
|
+
*
|
|
7
|
+
* WHY: Bandit's safety today is BEHAVIORAL — host-kit's decidePermission gates
|
|
8
|
+
* whether a command runs, but if it runs, it runs on your real machine. That's
|
|
9
|
+
* fine with a human at the keyboard; it is NOT fine for the autonomy we now
|
|
10
|
+
* ship (remote control, graph auto-routing) where nobody is watching. A microVM
|
|
11
|
+
* is a HARD boundary: a compromised model output, a prompt-injection, or a bad
|
|
12
|
+
* tool call physically cannot reach the host. This seam is what a caller routes
|
|
13
|
+
* `runCommand` through so that boundary is swappable.
|
|
14
|
+
*
|
|
15
|
+
* The interface is deliberately tiny and backend-agnostic. Today only the local
|
|
16
|
+
* backend exists (no isolation — current behavior). The microVM backend targets
|
|
17
|
+
* the `anton` control plane (Firecracker microVMs on son-of-anton), but anton's
|
|
18
|
+
* current API deploys web apps (Caddy rootfs + bundle→serve) and does NOT yet
|
|
19
|
+
* expose command-exec-with-output — see ANTON_EXEC_CONTRACT below for exactly
|
|
20
|
+
* what it must add. Until then, selecting the anton backend fails loudly rather
|
|
21
|
+
* than silently running on the host.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.AntonSandboxExecutor = exports.LocalSandboxExecutor = exports.ANTON_EXEC_CONTRACT = void 0;
|
|
58
|
+
exports.createSandboxExecutor = createSandboxExecutor;
|
|
59
|
+
/**
|
|
60
|
+
* The HTTP contract anton must implement for microVM exec (it doesn't yet).
|
|
61
|
+
* Documented here as the single source of truth for the two-repo work:
|
|
62
|
+
*
|
|
63
|
+
* POST {antonBaseUrl}/sessions → { id } (create VM)
|
|
64
|
+
* POST {antonBaseUrl}/sessions/{id}/exec { command, cwd?, env?, timeoutMs? }
|
|
65
|
+
* → { stdout, stderr, exitCode, timedOut? }
|
|
66
|
+
* DELETE {antonBaseUrl}/sessions/{id} (teardown)
|
|
67
|
+
*
|
|
68
|
+
* Auth: Burtson JWT (same bearer the CLI/extension already hold). The VM mounts
|
|
69
|
+
* ONLY the workspace, has NO host mount, and NO network egress by default.
|
|
70
|
+
*/
|
|
71
|
+
exports.ANTON_EXEC_CONTRACT = 'POST /sessions/{id}/exec {command,cwd?,env?,timeoutMs?} -> {stdout,stderr,exitCode}';
|
|
72
|
+
/** The host backend — no isolation, current behavior. A microVM backend
|
|
73
|
+
* implements the same interface against anton once its exec endpoint lands. */
|
|
74
|
+
class LocalSandboxExecutor {
|
|
75
|
+
constructor() {
|
|
76
|
+
this.kind = 'local';
|
|
77
|
+
}
|
|
78
|
+
async exec(command, opts = {}) {
|
|
79
|
+
const { spawn } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
const child = spawn(command, {
|
|
82
|
+
shell: true,
|
|
83
|
+
cwd: opts.cwd,
|
|
84
|
+
env: { ...process.env, ...(opts.env ?? {}) },
|
|
85
|
+
});
|
|
86
|
+
let stdout = '';
|
|
87
|
+
let stderr = '';
|
|
88
|
+
let timedOut = false;
|
|
89
|
+
const timer = opts.timeoutMs
|
|
90
|
+
? setTimeout(() => { timedOut = true; child.kill('SIGKILL'); }, opts.timeoutMs)
|
|
91
|
+
: null;
|
|
92
|
+
child.stdout?.on('data', (d) => { stdout += d.toString(); });
|
|
93
|
+
child.stderr?.on('data', (d) => { stderr += d.toString(); });
|
|
94
|
+
child.on('close', (code) => {
|
|
95
|
+
if (timer)
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
resolve({ stdout, stderr, exitCode: code ?? (timedOut ? 124 : 1), timedOut });
|
|
98
|
+
});
|
|
99
|
+
child.on('error', (err) => {
|
|
100
|
+
if (timer)
|
|
101
|
+
clearTimeout(timer);
|
|
102
|
+
resolve({ stdout, stderr: stderr + String(err), exitCode: 127 });
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.LocalSandboxExecutor = LocalSandboxExecutor;
|
|
108
|
+
/**
|
|
109
|
+
* The microVM backend — a client for anton's exec API (ANTON_EXEC_CONTRACT).
|
|
110
|
+
* Each exec creates a fresh VM, runs the command, tears it down: one-command
|
|
111
|
+
* isolation, so nothing persists or leaks between calls. Built + tested here
|
|
112
|
+
* against the contract; it goes live the moment anton ships the endpoint (the
|
|
113
|
+
* anton side stages the command as the VM's run.sh, boots, returns output).
|
|
114
|
+
*/
|
|
115
|
+
class AntonSandboxExecutor {
|
|
116
|
+
constructor(opts) {
|
|
117
|
+
this.opts = opts;
|
|
118
|
+
this.kind = 'microvm';
|
|
119
|
+
}
|
|
120
|
+
get fetchImpl() { return this.opts.fetchImpl ?? fetch; }
|
|
121
|
+
headers() {
|
|
122
|
+
return { authorization: `Bearer ${this.opts.token}`, 'content-type': 'application/json' };
|
|
123
|
+
}
|
|
124
|
+
async exec(command, opts = {}) {
|
|
125
|
+
const base = this.opts.baseUrl.replace(/\/$/, '');
|
|
126
|
+
// 1) create a fresh VM
|
|
127
|
+
const created = await this.fetchImpl(`${base}/sessions`, { method: 'POST', headers: this.headers() });
|
|
128
|
+
if (!created.ok)
|
|
129
|
+
throw new Error(`sandbox create failed: HTTP ${created.status}`);
|
|
130
|
+
const { id } = (await created.json());
|
|
131
|
+
try {
|
|
132
|
+
// 2) run the command in it
|
|
133
|
+
const res = await this.fetchImpl(`${base}/sessions/${encodeURIComponent(id)}/exec`, {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
headers: this.headers(),
|
|
136
|
+
body: JSON.stringify({ command, cwd: opts.cwd, env: opts.env, timeoutMs: opts.timeoutMs }),
|
|
137
|
+
});
|
|
138
|
+
if (!res.ok)
|
|
139
|
+
throw new Error(`sandbox exec failed: HTTP ${res.status}`);
|
|
140
|
+
const body = (await res.json());
|
|
141
|
+
return {
|
|
142
|
+
stdout: body.stdout ?? '',
|
|
143
|
+
stderr: body.stderr ?? '',
|
|
144
|
+
exitCode: typeof body.exitCode === 'number' ? body.exitCode : 1,
|
|
145
|
+
timedOut: body.timedOut,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
// 3) always tear the VM down (best-effort)
|
|
150
|
+
try {
|
|
151
|
+
await this.fetchImpl(`${base}/sessions/${encodeURIComponent(id)}`, { method: 'DELETE', headers: this.headers() });
|
|
152
|
+
}
|
|
153
|
+
catch { /* reaper will collect it */ }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.AntonSandboxExecutor = AntonSandboxExecutor;
|
|
158
|
+
/**
|
|
159
|
+
* Pick a backend from config. Defaults to local. `microvm` is accepted but the
|
|
160
|
+
* anton backend is not implemented yet, so this throws with a precise reason
|
|
161
|
+
* rather than degrading to local (silent degrade would defeat the safety goal —
|
|
162
|
+
* you'd think you were sandboxed and not be).
|
|
163
|
+
*/
|
|
164
|
+
function createSandboxExecutor(config = {}, localFactory = () => new LocalSandboxExecutor()) {
|
|
165
|
+
const mode = config.mode ?? 'local';
|
|
166
|
+
if (mode === 'local')
|
|
167
|
+
return localFactory();
|
|
168
|
+
// microvm: point at anton. Missing config throws rather than degrading to
|
|
169
|
+
// host execution — if you asked for isolation you get isolation or an error,
|
|
170
|
+
// never a silent host run. (When anton lacks the exec endpoint the client
|
|
171
|
+
// errors at exec time with a clear HTTP failure — also never a host run.)
|
|
172
|
+
if (!config.antonBaseUrl || !config.token) {
|
|
173
|
+
throw new Error(`sandbox mode "microvm" requires antonBaseUrl + token (the anton node-agent exec API: ${exports.ANTON_EXEC_CONTRACT}). ` +
|
|
174
|
+
`Refusing to fall back to host execution.`);
|
|
175
|
+
}
|
|
176
|
+
return new AntonSandboxExecutor({ baseUrl: config.antonBaseUrl, token: config.token });
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IH,sDAiBC;AA9HD;;;;;;;;;;;GAWG;AACU,QAAA,mBAAmB,GAAG,qFAAqF,CAAC;AAEzH;gFACgF;AAChF,MAAa,oBAAoB;IAAjC;QACW,SAAI,GAAG,OAAgB,CAAC;IA4BnC,CAAC;IA1BC,KAAK,CAAC,IAAI,CAAC,OAAe,EAAE,OAA2B,EAAE;QACvD,MAAM,EAAE,KAAK,EAAE,GAAG,wDAAa,eAAe,GAAC,CAAC;QAChD,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,KA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,EAAE,CAAC,IAAI,oBAAoB,EAAE;IAEtE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC;IACpC,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,YAAY,EAAE,CAAC;IAC5C,0EAA0E;IAC1E,6EAA6E;IAC7E,0EAA0E;IAC1E,0EAA0E;IAC1E,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,wFAAwF,2BAAmB,KAAK;YAChH,0CAA0C,CAC3C,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,oBAAoB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishArtifactTool.d.ts","sourceRoot":"","sources":["../../src/tools/publishArtifactTool.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAoC,MAAM,0BAA0B,CAAC;AAG5F,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAwCjG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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.buildPublishArtifactTool = buildPublishArtifactTool;
|
|
37
|
+
/**
|
|
38
|
+
* `publish_artifact` — let the AGENT publish a workspace file as a shareable
|
|
39
|
+
* Bandit Artifact during a turn (so "make a README and publish it" works in one
|
|
40
|
+
* go, instead of the user having to run the /artifact slash command by hand).
|
|
41
|
+
*
|
|
42
|
+
* Thin wrapper over publishArtifact (posts straight to S3Api). Cloud-only: the
|
|
43
|
+
* host only registers this tool when a cloud token is present, so local-only
|
|
44
|
+
* runs never see it and stay fully offline.
|
|
45
|
+
*/
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const artifacts_1 = require("../artifacts");
|
|
49
|
+
function buildPublishArtifactTool(opts) {
|
|
50
|
+
return {
|
|
51
|
+
name: 'publish_artifact',
|
|
52
|
+
description: 'Publish a file from the workspace as a shareable Bandit Artifact and return a public URL anyone can open. ' +
|
|
53
|
+
'Use this when the user asks to "publish", "share", or "make an artifact" of a file — write the file first, then call this with its path. Cloud feature.',
|
|
54
|
+
parameters: [
|
|
55
|
+
{
|
|
56
|
+
name: 'path',
|
|
57
|
+
description: 'Workspace-relative (or absolute) path to the file to publish, e.g. "README.md".',
|
|
58
|
+
required: true
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
async execute(params, ctx) {
|
|
62
|
+
const rel = (params.path ?? '').trim();
|
|
63
|
+
if (!rel)
|
|
64
|
+
return { output: 'Error: the `path` parameter is required.', isError: true };
|
|
65
|
+
const root = ctx.workspaceRoot ?? process.cwd();
|
|
66
|
+
const abs = path.isAbsolute(rel) ? rel : path.join(root, rel);
|
|
67
|
+
let bytes;
|
|
68
|
+
try {
|
|
69
|
+
bytes = await fs.promises.readFile(abs);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return { output: `Error: can't read "${rel}". Write the file first, then publish it.`, isError: true };
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const artifact = await (0, artifacts_1.publishArtifact)({
|
|
76
|
+
s3ApiBaseUrl: opts.s3ApiBaseUrl,
|
|
77
|
+
token: opts.token,
|
|
78
|
+
content: new Uint8Array(bytes),
|
|
79
|
+
filename: path.basename(abs),
|
|
80
|
+
contentType: (0, artifacts_1.guessContentType)(path.basename(abs))
|
|
81
|
+
});
|
|
82
|
+
return { output: `Published "${path.basename(abs)}" — shareable link: ${artifact.url}` };
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
return { output: `Error publishing artifact: ${err instanceof Error ? err.message : String(err)}`, isError: true };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=publishArtifactTool.js.map
|
|
@@ -0,0 +1 @@
|
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,EAAC;oBACrC,YAAY,EAAE,IAAI,CAAC,YAAY;oBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,OAAO,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC;oBAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;oBAC5B,WAAW,EAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;iBAClD,CAAC,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,cAAc,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,uBAAuB,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;YAC3F,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,EAAE,MAAM,EAAE,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACrH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burtson-labs/host-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.34",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Burtson Labs",
|
|
6
6
|
"email": "team@burtson.ai",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@burtson-labs/agent-core": "1.6.
|
|
25
|
+
"@burtson-labs/agent-core": "1.6.51"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.11.0",
|