@vertesia/tools-sdk 1.6.0-dev.20261008.064737Z → 1.6.0-dev.20261014.015055Z
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/lib/auth.d.ts +5 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +9 -1
- package/lib/auth.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/sandbox.d.ts +1 -0
- package/lib/sandbox.d.ts.map +1 -1
- package/lib/sandbox.js +3 -1
- package/lib/sandbox.js.map +1 -1
- package/lib/scratch.d.ts +44 -0
- package/lib/scratch.d.ts.map +1 -0
- package/lib/scratch.js +168 -0
- package/lib/scratch.js.map +1 -0
- package/lib/server/hooks.d.ts.map +1 -1
- package/lib/server/hooks.js +2 -0
- package/lib/server/hooks.js.map +1 -1
- package/lib/types.d.ts +6 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/auth.ts +10 -0
- package/src/index.ts +1 -0
- package/src/sandbox.ts +13 -5
- package/src/scratch.ts +196 -0
- package/src/server/hooks.ts +2 -0
- package/src/types.ts +6 -0
package/lib/auth.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { VertesiaClient } from '@vertesia/client';
|
|
|
2
2
|
import type { AuthTokenPayload } from '@vertesia/common';
|
|
3
3
|
import type { Context } from 'hono';
|
|
4
4
|
import { type JWTVerifyGetKey } from 'jose';
|
|
5
|
+
import { type ToolScratch } from './scratch.js';
|
|
5
6
|
import type { ToolExecutionContext } from './types.js';
|
|
6
7
|
export declare function getJwks(url: string): Promise<JWTVerifyGetKey<CryptoKey | Uint8Array<ArrayBufferLike>>>;
|
|
7
8
|
export declare function verifyToken(token: string): Promise<import("jose").JWTVerifyResult<AuthTokenPayload> & import("jose").ResolvedKey<CryptoKey | Uint8Array<ArrayBufferLike>>>;
|
|
@@ -28,7 +29,10 @@ export declare class AuthSession implements ToolExecutionContext {
|
|
|
28
29
|
token: string;
|
|
29
30
|
};
|
|
30
31
|
toolContext?: ToolContext;
|
|
31
|
-
|
|
32
|
+
private _scratch;
|
|
33
|
+
constructor(token: string, payload: AuthTokenPayload, endpointOverrides?: EndpointOverrides, toolContext?: ToolContext, scratch?: ToolScratch);
|
|
34
|
+
/** One store per session, which is one per request; created on first use. */
|
|
35
|
+
get scratch(): ToolScratch;
|
|
32
36
|
getClient(): Promise<VertesiaClient>;
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=auth.d.ts.map
|
package/lib/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAoD,KAAK,eAAe,EAAa,MAAM,MAAM,CAAC;AACzG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIvD,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,qEAgBxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,mIAU9C;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sFAAsF;AACtF,wBAAsB,gBAAgB,CAClC,GAAG,EAAE,OAAO,EACZ,kBAAkB,CAAC,E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WAAW,wBAoC7G;AAED,qBAAa,WAAY,YAAW,oBAAoB;IAWzC,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,gBAAgB;IAXpC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAA0B;IAE1C,YACW,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gBAAgB,EAChC,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,WAAW,CAAC,EAAE,WAAW,EACzB,OAAO,CAAC,EAAE,WAAW,EAWxB;IAED,6EAA6E;IAC7E,IAAI,OAAO,IAAI,WAAW,CAGzB;IAEK,SAAS,4BAYd;CACJ"}
|
package/lib/auth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeEndpoints, VertesiaClient } from '@vertesia/client';
|
|
2
2
|
import { HTTPException } from 'hono/http-exception';
|
|
3
3
|
import { createLocalJWKSet, decodeJwt, jwtVerify } from 'jose';
|
|
4
|
+
import { createMemoryScratch } from './scratch.js';
|
|
4
5
|
const cache = {};
|
|
5
6
|
export async function getJwks(url) {
|
|
6
7
|
if (!cache[url]) {
|
|
@@ -84,9 +85,11 @@ export class AuthSession {
|
|
|
84
85
|
_client;
|
|
85
86
|
endpoints;
|
|
86
87
|
toolContext;
|
|
87
|
-
|
|
88
|
+
_scratch;
|
|
89
|
+
constructor(token, payload, endpointOverrides, toolContext, scratch) {
|
|
88
90
|
this.token = token;
|
|
89
91
|
this.payload = payload;
|
|
92
|
+
this._scratch = scratch;
|
|
90
93
|
const decoded = decodeEndpoints(payload.endpoints);
|
|
91
94
|
// Use overrides from workflow config if provided, falling back to JWT endpoints
|
|
92
95
|
this.endpoints = {
|
|
@@ -96,6 +99,11 @@ export class AuthSession {
|
|
|
96
99
|
};
|
|
97
100
|
this.toolContext = toolContext;
|
|
98
101
|
}
|
|
102
|
+
/** One store per session, which is one per request; created on first use. */
|
|
103
|
+
get scratch() {
|
|
104
|
+
this._scratch ??= createMemoryScratch();
|
|
105
|
+
return this._scratch;
|
|
106
|
+
}
|
|
99
107
|
async getClient() {
|
|
100
108
|
if (!this._client) {
|
|
101
109
|
const toolInfo = this.toolContext?.toolName ? ` for ${this.toolContext.toolName}` : '';
|
package/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAA4C,SAAS,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAA4C,SAAS,EAAE,MAAM,MAAM,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AAGrE,MAAM,KAAK,GAAoC,EAAE,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC;aACxB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACR,IAAI,CAAC,CAAC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BAAgB,CAAC,OAAyB;IAC/C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE;YACzB,OAAO,EAAE,gBAAgB,OAAO,CAAC,OAAO,CAAC,IAAI,0CAA0C;SAC1F,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './InteractionCollection.js';
|
|
|
6
6
|
export { loadSkillsFromDirectory, loadToolsFromDirectory } from './node-loaders.js';
|
|
7
7
|
export * from './RenderingTemplateCollection.js';
|
|
8
8
|
export * from './SkillCollection.js';
|
|
9
|
+
export * from './scratch.js';
|
|
9
10
|
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
10
11
|
export { buildAppPackage } from './server/app-package.js';
|
|
11
12
|
export * from './server/types.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './InteractionCollection.js';
|
|
|
6
6
|
export { loadSkillsFromDirectory, loadToolsFromDirectory } from './node-loaders.js';
|
|
7
7
|
export * from './RenderingTemplateCollection.js';
|
|
8
8
|
export * from './SkillCollection.js';
|
|
9
|
+
export * from './scratch.js';
|
|
9
10
|
export { buildAppPackage } from './server/app-package.js';
|
|
10
11
|
export * from './server/types.js';
|
|
11
12
|
export * from './server.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/sandbox.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './ContentTypesCollection.js';
|
|
|
9
9
|
export * from './InteractionCollection.js';
|
|
10
10
|
export * from './RenderingTemplateCollection.js';
|
|
11
11
|
export * from './SkillCollection.js';
|
|
12
|
+
export * from './scratch.js';
|
|
12
13
|
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
13
14
|
export { buildAppPackage } from './server/app-package.js';
|
|
14
15
|
export * from './server/types.js';
|
package/lib/sandbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,iGAAiG;AACjG,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,gBAAgB,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AACvE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB;cAEvC;QAAE,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAAE;eACpC;QAAE,eAAe,EAAE,WAAW,CAAC;QAAC,YAAY,EAAE,SAAS,CAAA;KAAE;0CAyB3E;AACD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/sandbox.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { AuthSession } from './auth.js';
|
|
3
|
+
import { createSandboxScratch } from './scratch.js';
|
|
3
4
|
import { createToolServer as createBaseToolServer } from './server.js';
|
|
4
5
|
/** Browser-bundle entrypoint. Collections take bundled data; directory loaders are Node-only. */
|
|
5
6
|
export * from './ActivityCollection.js';
|
|
@@ -8,6 +9,7 @@ export * from './ContentTypesCollection.js';
|
|
|
8
9
|
export * from './InteractionCollection.js';
|
|
9
10
|
export * from './RenderingTemplateCollection.js';
|
|
10
11
|
export * from './SkillCollection.js';
|
|
12
|
+
export * from './scratch.js';
|
|
11
13
|
export { buildAppPackage } from './server/app-package.js';
|
|
12
14
|
export * from './server/types.js';
|
|
13
15
|
/** The host supplies non-secret claims; SDK HTTP goes through the sandbox's host-mediated fetch. */
|
|
@@ -21,7 +23,7 @@ export function createToolServer(config) {
|
|
|
21
23
|
studio: 'https://platform.invalid/studio',
|
|
22
24
|
store: 'https://platform.invalid/store',
|
|
23
25
|
token: 'https://platform.invalid/token',
|
|
24
|
-
}));
|
|
26
|
+
}, undefined, createSandboxScratch()));
|
|
25
27
|
}
|
|
26
28
|
await next();
|
|
27
29
|
});
|
package/lib/sandbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,C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AAC"}
|
package/lib/scratch.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-invocation scratch storage with one API in every host. Under the Vertesia workerd sandbox it is served
|
|
3
|
+
* by the runtime; on Node (localhost, Vercel) it lives in memory for the request. Either way it is private to
|
|
4
|
+
* one tool request and gone when the request ends: keep durable results in agent artifacts or files.
|
|
5
|
+
*
|
|
6
|
+
* Browser-safe: no Node built-ins, so the sandbox bundle can include it.
|
|
7
|
+
*/
|
|
8
|
+
export type ScratchData = string | Uint8Array | ArrayBuffer | Blob;
|
|
9
|
+
export interface ScratchEntry {
|
|
10
|
+
key: string;
|
|
11
|
+
size: number;
|
|
12
|
+
contentType: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ToolScratch {
|
|
15
|
+
/** Create or replace `key`. Keys are `/`-separated relative paths, e.g. `work/page-1.json`. */
|
|
16
|
+
put(key: string, data: ScratchData, options?: {
|
|
17
|
+
contentType?: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
putJson(key: string, value: unknown): Promise<void>;
|
|
20
|
+
/** `undefined` when the key does not exist. */
|
|
21
|
+
get(key: string): Promise<Uint8Array | undefined>;
|
|
22
|
+
getText(key: string): Promise<string | undefined>;
|
|
23
|
+
getJson<T = unknown>(key: string): Promise<T | undefined>;
|
|
24
|
+
/** `false` when the key did not exist. */
|
|
25
|
+
delete(key: string): Promise<boolean>;
|
|
26
|
+
list(): Promise<ScratchEntry[]>;
|
|
27
|
+
}
|
|
28
|
+
export type ScratchErrorCode = 'invalid_key' | 'quota_exceeded' | 'unavailable';
|
|
29
|
+
export declare class ScratchError extends Error {
|
|
30
|
+
readonly code: ScratchErrorCode;
|
|
31
|
+
constructor(code: ScratchErrorCode, message: string, options?: {
|
|
32
|
+
cause?: unknown;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** Matches the sandbox runtime's per-invocation default (`APP_RUNTIME_MAX_SCRATCH_BYTES`). */
|
|
36
|
+
export declare const DEFAULT_SCRATCH_QUOTA_BYTES: number;
|
|
37
|
+
/** Guest-visible origin of the sandbox runtime's scratch storage. */
|
|
38
|
+
export declare const SANDBOX_SCRATCH_ORIGIN = "http://scratch.invalid";
|
|
39
|
+
export declare function validateScratchKey(key: string): void;
|
|
40
|
+
/** In-process scratch for Node hosts. One instance per request; it is garbage collected with the request. */
|
|
41
|
+
export declare function createMemoryScratch(quota?: number): ToolScratch;
|
|
42
|
+
/** Scratch served by the Vertesia sandbox runtime; the runtime enforces the quota. */
|
|
43
|
+
export declare function createSandboxScratch(fetchImpl?: typeof fetch): ToolScratch;
|
|
44
|
+
//# sourceMappingURL=scratch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["../src/scratch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC;AAEnE,MAAM,WAAW,YAAY;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IACxB,+FAA+F;IAC/F,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,+CAA+C;IAC/C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1D,0CAA0C;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAEhF,qBAAa,YAAa,SAAQ,KAAK;aAEf,IAAI,EAAE,gBAAgB;IAD1C,YACoB,IAAI,EAAE,gBAAgB,EACtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIhC;CACJ;AAED,8FAA8F;AAC9F,eAAO,MAAM,2BAA2B,QAAoB,CAAC;AAE7D,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CASpD;AAmDD,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,KAAK,SAAuB,GAAG,WAAW,CAyB7E;AAUD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,SAAS,GAAE,OAAO,KAAmC,GAAG,WAAW,CAkDvG"}
|
package/lib/scratch.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-invocation scratch storage with one API in every host. Under the Vertesia workerd sandbox it is served
|
|
3
|
+
* by the runtime; on Node (localhost, Vercel) it lives in memory for the request. Either way it is private to
|
|
4
|
+
* one tool request and gone when the request ends: keep durable results in agent artifacts or files.
|
|
5
|
+
*
|
|
6
|
+
* Browser-safe: no Node built-ins, so the sandbox bundle can include it.
|
|
7
|
+
*/
|
|
8
|
+
export class ScratchError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
constructor(code, message, options) {
|
|
11
|
+
super(message, options);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.name = 'ScratchError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Matches the sandbox runtime's per-invocation default (`APP_RUNTIME_MAX_SCRATCH_BYTES`). */
|
|
17
|
+
export const DEFAULT_SCRATCH_QUOTA_BYTES = 128 * 1024 * 1024;
|
|
18
|
+
/** Guest-visible origin of the sandbox runtime's scratch storage. */
|
|
19
|
+
export const SANDBOX_SCRATCH_ORIGIN = 'http://scratch.invalid';
|
|
20
|
+
export function validateScratchKey(key) {
|
|
21
|
+
if (typeof key !== 'string' ||
|
|
22
|
+
!key ||
|
|
23
|
+
key.length > 1024 ||
|
|
24
|
+
/[\\\0]/.test(key) ||
|
|
25
|
+
key.split('/').some((part) => part === '.' || part === '..' || !part))
|
|
26
|
+
throw new ScratchError('invalid_key', `Invalid scratch key: ${JSON.stringify(key)}`);
|
|
27
|
+
}
|
|
28
|
+
/** Always a private copy: later caller mutations cannot change stored content in either backend. */
|
|
29
|
+
async function toBytes(data) {
|
|
30
|
+
if (typeof data === 'string')
|
|
31
|
+
return new TextEncoder().encode(data);
|
|
32
|
+
if (data instanceof Uint8Array)
|
|
33
|
+
return data.slice();
|
|
34
|
+
if (data instanceof ArrayBuffer)
|
|
35
|
+
return new Uint8Array(data.slice(0));
|
|
36
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
37
|
+
}
|
|
38
|
+
function contentTypeOf(data, contentType) {
|
|
39
|
+
if (contentType)
|
|
40
|
+
return contentType;
|
|
41
|
+
if (typeof data === 'string')
|
|
42
|
+
return 'text/plain;charset=UTF-8';
|
|
43
|
+
if (typeof Blob !== 'undefined' && data instanceof Blob && data.type)
|
|
44
|
+
return data.type;
|
|
45
|
+
return 'application/octet-stream';
|
|
46
|
+
}
|
|
47
|
+
/** Shared convenience methods over the three primitives each backend implements. */
|
|
48
|
+
function withHelpers(base) {
|
|
49
|
+
const scratch = {
|
|
50
|
+
async put(key, data, options) {
|
|
51
|
+
validateScratchKey(key);
|
|
52
|
+
await base.put(key, await toBytes(data), contentTypeOf(data, options?.contentType));
|
|
53
|
+
},
|
|
54
|
+
putJson: (key, value) => scratch.put(key, JSON.stringify(value), { contentType: 'application/json' }),
|
|
55
|
+
async get(key) {
|
|
56
|
+
validateScratchKey(key);
|
|
57
|
+
return base.get(key);
|
|
58
|
+
},
|
|
59
|
+
async getText(key) {
|
|
60
|
+
const bytes = await scratch.get(key);
|
|
61
|
+
return bytes === undefined ? undefined : new TextDecoder().decode(bytes);
|
|
62
|
+
},
|
|
63
|
+
async getJson(key) {
|
|
64
|
+
const text = await scratch.getText(key);
|
|
65
|
+
return text === undefined ? undefined : JSON.parse(text);
|
|
66
|
+
},
|
|
67
|
+
async delete(key) {
|
|
68
|
+
validateScratchKey(key);
|
|
69
|
+
return base.delete(key);
|
|
70
|
+
},
|
|
71
|
+
list: () => base.list(),
|
|
72
|
+
};
|
|
73
|
+
return scratch;
|
|
74
|
+
}
|
|
75
|
+
/** In-process scratch for Node hosts. One instance per request; it is garbage collected with the request. */
|
|
76
|
+
export function createMemoryScratch(quota = defaultMemoryQuota()) {
|
|
77
|
+
const entries = new Map();
|
|
78
|
+
let used = 0;
|
|
79
|
+
return withHelpers({
|
|
80
|
+
async put(key, bytes, contentType) {
|
|
81
|
+
const previous = entries.get(key)?.bytes.byteLength ?? 0;
|
|
82
|
+
if (bytes.byteLength > quota - used + previous)
|
|
83
|
+
throw new ScratchError('quota_exceeded', `Scratch storage quota of ${quota} bytes exceeded`);
|
|
84
|
+
entries.set(key, { bytes, contentType });
|
|
85
|
+
used += bytes.byteLength - previous;
|
|
86
|
+
},
|
|
87
|
+
async get(key) {
|
|
88
|
+
return entries.get(key)?.bytes.slice();
|
|
89
|
+
},
|
|
90
|
+
async delete(key) {
|
|
91
|
+
const entry = entries.get(key);
|
|
92
|
+
if (!entry)
|
|
93
|
+
return false;
|
|
94
|
+
entries.delete(key);
|
|
95
|
+
used -= entry.bytes.byteLength;
|
|
96
|
+
return true;
|
|
97
|
+
},
|
|
98
|
+
async list() {
|
|
99
|
+
return [...entries].map(([key, { bytes, contentType }]) => ({ key, size: bytes.byteLength, contentType }));
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function defaultMemoryQuota() {
|
|
104
|
+
const configured = globalThis.process?.env
|
|
105
|
+
?.VERTESIA_SCRATCH_MAX_BYTES;
|
|
106
|
+
const value = configured === undefined ? DEFAULT_SCRATCH_QUOTA_BYTES : Number(configured);
|
|
107
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
108
|
+
throw new Error('Invalid VERTESIA_SCRATCH_MAX_BYTES');
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
/** Scratch served by the Vertesia sandbox runtime; the runtime enforces the quota. */
|
|
112
|
+
export function createSandboxScratch(fetchImpl = (...args) => fetch(...args)) {
|
|
113
|
+
const url = (key = '') => `${SANDBOX_SCRATCH_ORIGIN}/${key.split('/').map(encodeURIComponent).join('/')}`;
|
|
114
|
+
const failure = async (response, operation) => {
|
|
115
|
+
const detail = (await response.text().catch(() => '')).slice(0, 200);
|
|
116
|
+
if (response.status === 507)
|
|
117
|
+
return new ScratchError('quota_exceeded', detail || 'Scratch storage quota exceeded');
|
|
118
|
+
if (response.status === 400)
|
|
119
|
+
return new ScratchError('invalid_key', detail || 'Invalid scratch key');
|
|
120
|
+
return new ScratchError('unavailable', `Scratch ${operation} failed with status ${response.status}: ${detail}`);
|
|
121
|
+
};
|
|
122
|
+
// An unreachable runtime, or a response cut off mid-body, is the same `unavailable` as an error status.
|
|
123
|
+
const run = async (operation, exchange) => {
|
|
124
|
+
try {
|
|
125
|
+
return await exchange();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
if (error instanceof ScratchError)
|
|
129
|
+
throw error;
|
|
130
|
+
throw new ScratchError('unavailable', `Scratch ${operation} failed: ${String(error)}`, { cause: error });
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return withHelpers({
|
|
134
|
+
put: (key, bytes, contentType) => run('write', async () => {
|
|
135
|
+
const response = await fetchImpl(url(key), {
|
|
136
|
+
method: 'PUT',
|
|
137
|
+
headers: { 'content-type': contentType },
|
|
138
|
+
body: bytes,
|
|
139
|
+
});
|
|
140
|
+
if (!response.ok)
|
|
141
|
+
throw await failure(response, 'write');
|
|
142
|
+
}),
|
|
143
|
+
get: (key) => run('read', async () => {
|
|
144
|
+
const response = await fetchImpl(url(key));
|
|
145
|
+
if (response.status === 404)
|
|
146
|
+
return undefined;
|
|
147
|
+
if (!response.ok)
|
|
148
|
+
throw await failure(response, 'read');
|
|
149
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
150
|
+
}),
|
|
151
|
+
delete: (key) => run('delete', async () => {
|
|
152
|
+
const response = await fetchImpl(url(key), { method: 'DELETE' });
|
|
153
|
+
if (response.status === 404)
|
|
154
|
+
return false;
|
|
155
|
+
if (!response.ok)
|
|
156
|
+
throw await failure(response, 'delete');
|
|
157
|
+
return true;
|
|
158
|
+
}),
|
|
159
|
+
list: () => run('list', async () => {
|
|
160
|
+
const response = await fetchImpl(url());
|
|
161
|
+
if (!response.ok)
|
|
162
|
+
throw await failure(response, 'list');
|
|
163
|
+
const body = (await response.json());
|
|
164
|
+
return body.entries.map(({ key, size, type }) => ({ key, size, contentType: type }));
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=scratch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratch.js","sourceRoot":"","sources":["../src/scratch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEf,IAAI;IADxB,YACoB,IAAsB,EACtC,OAAe,EACf,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAJR,IAAI;QAKpB,IAAI,CAAC,IAAI,GAAG,c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I,EAAE,CAA+D,CAAC;YACnG,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC;KACT,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/server/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAY1C,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKhE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/server/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAY1C,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKhE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,QA4CrF"}
|
package/lib/server/hooks.js
CHANGED
|
@@ -37,6 +37,7 @@ export function createHooksRoute(app, basePath, config) {
|
|
|
37
37
|
token: session.token,
|
|
38
38
|
payload: session.payload,
|
|
39
39
|
getClient: () => session.getClient(),
|
|
40
|
+
scratch: session.scratch,
|
|
40
41
|
metadata,
|
|
41
42
|
};
|
|
42
43
|
const result = await hook.handler(context);
|
|
@@ -50,6 +51,7 @@ async function executeEventHook(c, requestContext, hook) {
|
|
|
50
51
|
token: session.token,
|
|
51
52
|
payload: session.payload,
|
|
52
53
|
getClient: () => session.getClient(),
|
|
54
|
+
scratch: session.scratch,
|
|
53
55
|
};
|
|
54
56
|
const result = await hook.handler(eventPayload, context);
|
|
55
57
|
return c.json({ ok: true, ...(result ?? {}) });
|
package/lib/server/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/server/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAC3E,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AAElE,MAAM,UAAU,gBAAgB,CAAC,GAAS,EAAE,QAAgB,EAAE,MAAwB;IAClF,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+D,CAAC;IACrF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACpC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAA4B,CAAC,EAAE,CAAC;YAC7E,MAAM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EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACvB,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ToolDefinition, ToolUse } from '@llumiverse/common';
|
|
2
2
|
import type { VertesiaClient } from '@vertesia/client';
|
|
3
3
|
import type { AgentToolDefinition, AuthTokenPayload, AppEventHookDelivery as CommonAppEventHookDelivery, AppEventHookPayload as CommonAppEventHookPayload, AppEventSubscriptionDefinition as CommonAppEventSubscriptionDefinition, MCPToolAnnotations, ProjectConfiguration, RenderingTemplateDefinition, ToolExecutionMetadata, ToolResult, ToolResultContent, ToolResultMeta } from '@vertesia/common';
|
|
4
|
+
import type { ToolScratch } from './scratch.js';
|
|
4
5
|
export type { ToolExecutionMetadata };
|
|
5
6
|
export type AppEventSubscriptionDefinition = CommonAppEventSubscriptionDefinition;
|
|
6
7
|
export type AppEventHookDelivery = CommonAppEventHookDelivery;
|
|
@@ -41,6 +42,11 @@ export interface ToolExecutionContext {
|
|
|
41
42
|
* @returns a vertesia client instance
|
|
42
43
|
*/
|
|
43
44
|
getClient: () => Promise<VertesiaClient>;
|
|
45
|
+
/**
|
|
46
|
+
* Temporary storage private to this request, with the same behavior in the Vertesia sandbox and on
|
|
47
|
+
* Node hosts (localhost, Vercel). Discarded when the request ends.
|
|
48
|
+
*/
|
|
49
|
+
scratch: ToolScratch;
|
|
44
50
|
}
|
|
45
51
|
export type AppLifecycleHookName = 'install' | 'uninstall';
|
|
46
52
|
export interface AppLifecycleHookContext extends ToolExecutionContext {
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EA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;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;KACrB,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/tools-sdk",
|
|
3
|
-
"version": "1.6.0-dev.
|
|
3
|
+
"version": "1.6.0-dev.20261014.015055Z",
|
|
4
4
|
"description": "Tools SDK - utilities for building remote tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^24.19.
|
|
25
|
+
"@types/node": "^24.19.1",
|
|
26
26
|
"@vertesia/tsconfig": "0.1.0",
|
|
27
27
|
"typescript": "7.0.2",
|
|
28
|
-
"vitest": "5.0.
|
|
28
|
+
"vitest": "5.0.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"hono": "^4.13.13"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@llumiverse/common": "1.6.0-dev.
|
|
35
|
-
"@vertesia/client": "1.6.0-dev.
|
|
36
|
-
"@vertesia/common": "1.6.0-dev.
|
|
34
|
+
"@llumiverse/common": "1.6.0-dev.20261014.012028Z",
|
|
35
|
+
"@vertesia/client": "1.6.0-dev.20261014.015055Z",
|
|
36
|
+
"@vertesia/common": "1.6.0-dev.20261014.015055Z",
|
|
37
37
|
"jose": "^6.2.12",
|
|
38
38
|
"zod": "4.6.5"
|
|
39
39
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"agents",
|
|
52
52
|
"typescript"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "468240ecf939f968e1324116be26386cdf5ada49",
|
|
55
55
|
"scripts": {
|
|
56
56
|
"lint": "biome lint src",
|
|
57
57
|
"test": "vitest run",
|
package/src/auth.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { AuthTokenPayload } from '@vertesia/common';
|
|
|
3
3
|
import type { Context } from 'hono';
|
|
4
4
|
import { HTTPException } from 'hono/http-exception';
|
|
5
5
|
import { createLocalJWKSet, decodeJwt, type JSONWebKeySet, type JWTVerifyGetKey, jwtVerify } from 'jose';
|
|
6
|
+
import { createMemoryScratch, type ToolScratch } from './scratch.js';
|
|
6
7
|
import type { ToolExecutionContext } from './types.js';
|
|
7
8
|
|
|
8
9
|
const cache: Record<string, JWTVerifyGetKey> = {};
|
|
@@ -106,13 +107,16 @@ export class AuthSession implements ToolExecutionContext {
|
|
|
106
107
|
token: string;
|
|
107
108
|
};
|
|
108
109
|
toolContext?: ToolContext;
|
|
110
|
+
private _scratch: ToolScratch | undefined;
|
|
109
111
|
|
|
110
112
|
constructor(
|
|
111
113
|
public token: string,
|
|
112
114
|
public payload: AuthTokenPayload,
|
|
113
115
|
endpointOverrides?: EndpointOverrides,
|
|
114
116
|
toolContext?: ToolContext,
|
|
117
|
+
scratch?: ToolScratch,
|
|
115
118
|
) {
|
|
119
|
+
this._scratch = scratch;
|
|
116
120
|
const decoded = decodeEndpoints(payload.endpoints);
|
|
117
121
|
// Use overrides from workflow config if provided, falling back to JWT endpoints
|
|
118
122
|
this.endpoints = {
|
|
@@ -123,6 +127,12 @@ export class AuthSession implements ToolExecutionContext {
|
|
|
123
127
|
this.toolContext = toolContext;
|
|
124
128
|
}
|
|
125
129
|
|
|
130
|
+
/** One store per session, which is one per request; created on first use. */
|
|
131
|
+
get scratch(): ToolScratch {
|
|
132
|
+
this._scratch ??= createMemoryScratch();
|
|
133
|
+
return this._scratch;
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
async getClient() {
|
|
127
137
|
if (!this._client) {
|
|
128
138
|
const toolInfo = this.toolContext?.toolName ? ` for ${this.toolContext.toolName}` : '';
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './InteractionCollection.js';
|
|
|
6
6
|
export { loadSkillsFromDirectory, loadToolsFromDirectory } from './node-loaders.js';
|
|
7
7
|
export * from './RenderingTemplateCollection.js';
|
|
8
8
|
export * from './SkillCollection.js';
|
|
9
|
+
export * from './scratch.js';
|
|
9
10
|
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
10
11
|
export { buildAppPackage } from './server/app-package.js';
|
|
11
12
|
export * from './server/types.js';
|
package/src/sandbox.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AuthTokenPayload } from '@vertesia/common';
|
|
2
2
|
import { Hono } from 'hono';
|
|
3
3
|
import { AuthSession } from './auth.js';
|
|
4
|
+
import { createSandboxScratch } from './scratch.js';
|
|
4
5
|
import type { ToolServerConfig } from './server/types.js';
|
|
5
6
|
import { createToolServer as createBaseToolServer } from './server.js';
|
|
6
7
|
|
|
@@ -11,6 +12,7 @@ export * from './ContentTypesCollection.js';
|
|
|
11
12
|
export * from './InteractionCollection.js';
|
|
12
13
|
export * from './RenderingTemplateCollection.js';
|
|
13
14
|
export * from './SkillCollection.js';
|
|
15
|
+
export * from './scratch.js';
|
|
14
16
|
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
15
17
|
export { buildAppPackage } from './server/app-package.js';
|
|
16
18
|
export * from './server/types.js';
|
|
@@ -26,11 +28,17 @@ export function createToolServer(config: ToolServerConfig) {
|
|
|
26
28
|
if (payload) {
|
|
27
29
|
ctx.set(
|
|
28
30
|
'toolAuthSession',
|
|
29
|
-
new AuthSession(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
new AuthSession(
|
|
32
|
+
'sandbox',
|
|
33
|
+
payload,
|
|
34
|
+
{
|
|
35
|
+
studio: 'https://platform.invalid/studio',
|
|
36
|
+
store: 'https://platform.invalid/store',
|
|
37
|
+
token: 'https://platform.invalid/token',
|
|
38
|
+
},
|
|
39
|
+
undefined,
|
|
40
|
+
createSandboxScratch(),
|
|
41
|
+
),
|
|
34
42
|
);
|
|
35
43
|
}
|
|
36
44
|
await next();
|
package/src/scratch.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-invocation scratch storage with one API in every host. Under the Vertesia workerd sandbox it is served
|
|
3
|
+
* by the runtime; on Node (localhost, Vercel) it lives in memory for the request. Either way it is private to
|
|
4
|
+
* one tool request and gone when the request ends: keep durable results in agent artifacts or files.
|
|
5
|
+
*
|
|
6
|
+
* Browser-safe: no Node built-ins, so the sandbox bundle can include it.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ScratchData = string | Uint8Array | ArrayBuffer | Blob;
|
|
10
|
+
|
|
11
|
+
export interface ScratchEntry {
|
|
12
|
+
key: string;
|
|
13
|
+
size: number;
|
|
14
|
+
contentType: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToolScratch {
|
|
18
|
+
/** Create or replace `key`. Keys are `/`-separated relative paths, e.g. `work/page-1.json`. */
|
|
19
|
+
put(key: string, data: ScratchData, options?: { contentType?: string }): Promise<void>;
|
|
20
|
+
putJson(key: string, value: unknown): Promise<void>;
|
|
21
|
+
/** `undefined` when the key does not exist. */
|
|
22
|
+
get(key: string): Promise<Uint8Array | undefined>;
|
|
23
|
+
getText(key: string): Promise<string | undefined>;
|
|
24
|
+
getJson<T = unknown>(key: string): Promise<T | undefined>;
|
|
25
|
+
/** `false` when the key did not exist. */
|
|
26
|
+
delete(key: string): Promise<boolean>;
|
|
27
|
+
list(): Promise<ScratchEntry[]>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ScratchErrorCode = 'invalid_key' | 'quota_exceeded' | 'unavailable';
|
|
31
|
+
|
|
32
|
+
export class ScratchError extends Error {
|
|
33
|
+
constructor(
|
|
34
|
+
public readonly code: ScratchErrorCode,
|
|
35
|
+
message: string,
|
|
36
|
+
options?: { cause?: unknown },
|
|
37
|
+
) {
|
|
38
|
+
super(message, options);
|
|
39
|
+
this.name = 'ScratchError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Matches the sandbox runtime's per-invocation default (`APP_RUNTIME_MAX_SCRATCH_BYTES`). */
|
|
44
|
+
export const DEFAULT_SCRATCH_QUOTA_BYTES = 128 * 1024 * 1024;
|
|
45
|
+
|
|
46
|
+
/** Guest-visible origin of the sandbox runtime's scratch storage. */
|
|
47
|
+
export const SANDBOX_SCRATCH_ORIGIN = 'http://scratch.invalid';
|
|
48
|
+
|
|
49
|
+
export function validateScratchKey(key: string): void {
|
|
50
|
+
if (
|
|
51
|
+
typeof key !== 'string' ||
|
|
52
|
+
!key ||
|
|
53
|
+
key.length > 1024 ||
|
|
54
|
+
/[\\\0]/.test(key) ||
|
|
55
|
+
key.split('/').some((part) => part === '.' || part === '..' || !part)
|
|
56
|
+
)
|
|
57
|
+
throw new ScratchError('invalid_key', `Invalid scratch key: ${JSON.stringify(key)}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Always a private copy: later caller mutations cannot change stored content in either backend. */
|
|
61
|
+
async function toBytes(data: ScratchData): Promise<Uint8Array<ArrayBuffer>> {
|
|
62
|
+
if (typeof data === 'string') return new TextEncoder().encode(data);
|
|
63
|
+
if (data instanceof Uint8Array) return data.slice();
|
|
64
|
+
if (data instanceof ArrayBuffer) return new Uint8Array(data.slice(0));
|
|
65
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function contentTypeOf(data: ScratchData, contentType: string | undefined): string {
|
|
69
|
+
if (contentType) return contentType;
|
|
70
|
+
if (typeof data === 'string') return 'text/plain;charset=UTF-8';
|
|
71
|
+
if (typeof Blob !== 'undefined' && data instanceof Blob && data.type) return data.type;
|
|
72
|
+
return 'application/octet-stream';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Shared convenience methods over the three primitives each backend implements. */
|
|
76
|
+
function withHelpers(base: {
|
|
77
|
+
put(key: string, bytes: Uint8Array<ArrayBuffer>, contentType: string): Promise<void>;
|
|
78
|
+
get(key: string): Promise<Uint8Array | undefined>;
|
|
79
|
+
delete(key: string): Promise<boolean>;
|
|
80
|
+
list(): Promise<ScratchEntry[]>;
|
|
81
|
+
}): ToolScratch {
|
|
82
|
+
const scratch: ToolScratch = {
|
|
83
|
+
async put(key, data, options) {
|
|
84
|
+
validateScratchKey(key);
|
|
85
|
+
await base.put(key, await toBytes(data), contentTypeOf(data, options?.contentType));
|
|
86
|
+
},
|
|
87
|
+
putJson: (key, value) => scratch.put(key, JSON.stringify(value), { contentType: 'application/json' }),
|
|
88
|
+
async get(key) {
|
|
89
|
+
validateScratchKey(key);
|
|
90
|
+
return base.get(key);
|
|
91
|
+
},
|
|
92
|
+
async getText(key) {
|
|
93
|
+
const bytes = await scratch.get(key);
|
|
94
|
+
return bytes === undefined ? undefined : new TextDecoder().decode(bytes);
|
|
95
|
+
},
|
|
96
|
+
async getJson<T>(key: string) {
|
|
97
|
+
const text = await scratch.getText(key);
|
|
98
|
+
return text === undefined ? undefined : (JSON.parse(text) as T);
|
|
99
|
+
},
|
|
100
|
+
async delete(key) {
|
|
101
|
+
validateScratchKey(key);
|
|
102
|
+
return base.delete(key);
|
|
103
|
+
},
|
|
104
|
+
list: () => base.list(),
|
|
105
|
+
};
|
|
106
|
+
return scratch;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** In-process scratch for Node hosts. One instance per request; it is garbage collected with the request. */
|
|
110
|
+
export function createMemoryScratch(quota = defaultMemoryQuota()): ToolScratch {
|
|
111
|
+
const entries = new Map<string, { bytes: Uint8Array; contentType: string }>();
|
|
112
|
+
let used = 0;
|
|
113
|
+
return withHelpers({
|
|
114
|
+
async put(key, bytes, contentType) {
|
|
115
|
+
const previous = entries.get(key)?.bytes.byteLength ?? 0;
|
|
116
|
+
if (bytes.byteLength > quota - used + previous)
|
|
117
|
+
throw new ScratchError('quota_exceeded', `Scratch storage quota of ${quota} bytes exceeded`);
|
|
118
|
+
entries.set(key, { bytes, contentType });
|
|
119
|
+
used += bytes.byteLength - previous;
|
|
120
|
+
},
|
|
121
|
+
async get(key) {
|
|
122
|
+
return entries.get(key)?.bytes.slice();
|
|
123
|
+
},
|
|
124
|
+
async delete(key) {
|
|
125
|
+
const entry = entries.get(key);
|
|
126
|
+
if (!entry) return false;
|
|
127
|
+
entries.delete(key);
|
|
128
|
+
used -= entry.bytes.byteLength;
|
|
129
|
+
return true;
|
|
130
|
+
},
|
|
131
|
+
async list() {
|
|
132
|
+
return [...entries].map(([key, { bytes, contentType }]) => ({ key, size: bytes.byteLength, contentType }));
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function defaultMemoryQuota(): number {
|
|
138
|
+
const configured = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env
|
|
139
|
+
?.VERTESIA_SCRATCH_MAX_BYTES;
|
|
140
|
+
const value = configured === undefined ? DEFAULT_SCRATCH_QUOTA_BYTES : Number(configured);
|
|
141
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error('Invalid VERTESIA_SCRATCH_MAX_BYTES');
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Scratch served by the Vertesia sandbox runtime; the runtime enforces the quota. */
|
|
146
|
+
export function createSandboxScratch(fetchImpl: typeof fetch = (...args) => fetch(...args)): ToolScratch {
|
|
147
|
+
const url = (key = '') => `${SANDBOX_SCRATCH_ORIGIN}/${key.split('/').map(encodeURIComponent).join('/')}`;
|
|
148
|
+
const failure = async (response: Response, operation: string) => {
|
|
149
|
+
const detail = (await response.text().catch(() => '')).slice(0, 200);
|
|
150
|
+
if (response.status === 507)
|
|
151
|
+
return new ScratchError('quota_exceeded', detail || 'Scratch storage quota exceeded');
|
|
152
|
+
if (response.status === 400) return new ScratchError('invalid_key', detail || 'Invalid scratch key');
|
|
153
|
+
return new ScratchError('unavailable', `Scratch ${operation} failed with status ${response.status}: ${detail}`);
|
|
154
|
+
};
|
|
155
|
+
// An unreachable runtime, or a response cut off mid-body, is the same `unavailable` as an error status.
|
|
156
|
+
const run = async <T>(operation: string, exchange: () => Promise<T>): Promise<T> => {
|
|
157
|
+
try {
|
|
158
|
+
return await exchange();
|
|
159
|
+
} catch (error: unknown) {
|
|
160
|
+
if (error instanceof ScratchError) throw error;
|
|
161
|
+
throw new ScratchError('unavailable', `Scratch ${operation} failed: ${String(error)}`, { cause: error });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
return withHelpers({
|
|
165
|
+
put: (key, bytes, contentType) =>
|
|
166
|
+
run('write', async () => {
|
|
167
|
+
const response = await fetchImpl(url(key), {
|
|
168
|
+
method: 'PUT',
|
|
169
|
+
headers: { 'content-type': contentType },
|
|
170
|
+
body: bytes,
|
|
171
|
+
});
|
|
172
|
+
if (!response.ok) throw await failure(response, 'write');
|
|
173
|
+
}),
|
|
174
|
+
get: (key) =>
|
|
175
|
+
run('read', async () => {
|
|
176
|
+
const response = await fetchImpl(url(key));
|
|
177
|
+
if (response.status === 404) return undefined;
|
|
178
|
+
if (!response.ok) throw await failure(response, 'read');
|
|
179
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
180
|
+
}),
|
|
181
|
+
delete: (key) =>
|
|
182
|
+
run('delete', async () => {
|
|
183
|
+
const response = await fetchImpl(url(key), { method: 'DELETE' });
|
|
184
|
+
if (response.status === 404) return false;
|
|
185
|
+
if (!response.ok) throw await failure(response, 'delete');
|
|
186
|
+
return true;
|
|
187
|
+
}),
|
|
188
|
+
list: () =>
|
|
189
|
+
run('list', async () => {
|
|
190
|
+
const response = await fetchImpl(url());
|
|
191
|
+
if (!response.ok) throw await failure(response, 'list');
|
|
192
|
+
const body = (await response.json()) as { entries: { key: string; size: number; type: string }[] };
|
|
193
|
+
return body.entries.map(({ key, size, type }) => ({ key, size, contentType: type }));
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
}
|
package/src/server/hooks.ts
CHANGED
|
@@ -53,6 +53,7 @@ export function createHooksRoute(app: Hono, basePath: string, config: ToolServer
|
|
|
53
53
|
token: session.token,
|
|
54
54
|
payload: session.payload,
|
|
55
55
|
getClient: () => session.getClient(),
|
|
56
|
+
scratch: session.scratch,
|
|
56
57
|
metadata,
|
|
57
58
|
};
|
|
58
59
|
const result = await hook.handler(context);
|
|
@@ -68,6 +69,7 @@ async function executeEventHook(c: Context, requestContext: ToolContext, hook: A
|
|
|
68
69
|
token: session.token,
|
|
69
70
|
payload: session.payload,
|
|
70
71
|
getClient: () => session.getClient(),
|
|
72
|
+
scratch: session.scratch,
|
|
71
73
|
};
|
|
72
74
|
const result = await hook.handler(eventPayload, context);
|
|
73
75
|
|
package/src/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
ToolResultContent,
|
|
15
15
|
ToolResultMeta,
|
|
16
16
|
} from '@vertesia/common';
|
|
17
|
+
import type { ToolScratch } from './scratch.js';
|
|
17
18
|
|
|
18
19
|
export type { ToolExecutionMetadata };
|
|
19
20
|
export type AppEventSubscriptionDefinition = CommonAppEventSubscriptionDefinition;
|
|
@@ -58,6 +59,11 @@ export interface ToolExecutionContext {
|
|
|
58
59
|
* @returns a vertesia client instance
|
|
59
60
|
*/
|
|
60
61
|
getClient: () => Promise<VertesiaClient>;
|
|
62
|
+
/**
|
|
63
|
+
* Temporary storage private to this request, with the same behavior in the Vertesia sandbox and on
|
|
64
|
+
* Node hosts (localhost, Vercel). Discarded when the request ends.
|
|
65
|
+
*/
|
|
66
|
+
scratch: ToolScratch;
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
export type AppLifecycleHookName = 'install' | 'uninstall';
|