@finalai/agent-provider 0.9.0 → 0.10.0
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/HOSTING.md +334 -245
- package/README.md +93 -14
- package/dist/modules/canonical-json.d.mts +4 -0
- package/dist/modules/canonical-json.mjs +33 -0
- package/dist/modules/canonical-json.mjs.map +7 -0
- package/dist/modules/channel.d.mts +0 -3
- package/dist/modules/channel.mjs.map +1 -1
- package/dist/modules/code-host/host.d.mts +10 -0
- package/dist/modules/code-host/host.mjs +88 -0
- package/dist/modules/code-host/host.mjs.map +7 -0
- package/dist/modules/code-host/in-process.d.mts +24 -0
- package/dist/modules/code-host/in-process.mjs +89 -0
- package/dist/modules/code-host/in-process.mjs.map +7 -0
- package/dist/modules/code-host/index.d.mts +4 -0
- package/dist/modules/code-host/index.mjs +5 -0
- package/dist/modules/code-host/index.mjs.map +7 -0
- package/dist/modules/code-host/serverless.d.mts +63 -0
- package/dist/modules/code-host/serverless.mjs +27 -0
- package/dist/modules/code-host/serverless.mjs.map +7 -0
- package/dist/modules/code-host/types.d.mts +152 -0
- package/dist/modules/code-host/types.mjs +85 -0
- package/dist/modules/code-host/types.mjs.map +7 -0
- package/dist/modules/conformance/agent.mjs +72 -6
- package/dist/modules/conformance/agent.mjs.map +2 -2
- package/dist/modules/conformance/harness-kit.d.mts +9 -2
- package/dist/modules/conformance/harness-kit.mjs +224 -63
- package/dist/modules/conformance/harness-kit.mjs.map +3 -3
- package/dist/modules/conformance/local-harness.d.mts +1 -4
- package/dist/modules/conformance/local-harness.mjs +21 -22
- package/dist/modules/conformance/local-harness.mjs.map +2 -2
- package/dist/modules/conformance/protocol.d.mts +1 -0
- package/dist/modules/conformance/protocol.mjs +2 -0
- package/dist/modules/conformance/protocol.mjs.map +2 -2
- package/dist/modules/conformance/sandbox-kit.d.mts +12 -4
- package/dist/modules/conformance/sandbox-kit.mjs +189 -103
- package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/chat-completions.mjs +1 -0
- package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/directives.d.mts +3 -0
- package/dist/modules/conformance/scripted-model/directives.mjs +26 -10
- package/dist/modules/conformance/scripted-model/directives.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/messages.mjs +1 -0
- package/dist/modules/conformance/scripted-model/messages.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/responses.mjs +2 -0
- package/dist/modules/conformance/scripted-model/responses.mjs.map +2 -2
- package/dist/modules/conformance/stdio.d.mts +21 -0
- package/dist/modules/conformance/stdio.mjs +158 -0
- package/dist/modules/conformance/stdio.mjs.map +7 -0
- package/dist/modules/credential-routes.d.mts +2 -0
- package/dist/modules/credential-routes.mjs +2 -0
- package/dist/modules/credential-routes.mjs.map +2 -2
- package/dist/modules/document.d.mts +376 -0
- package/dist/modules/document.mjs +208 -0
- package/dist/modules/document.mjs.map +7 -0
- package/dist/modules/harness-configuration.d.mts +16 -0
- package/dist/modules/harness-configuration.mjs +83 -0
- package/dist/modules/harness-configuration.mjs.map +7 -0
- package/dist/modules/harness-definition.d.mts +280 -0
- package/dist/modules/harness-definition.mjs +430 -0
- package/dist/modules/harness-definition.mjs.map +7 -0
- package/dist/modules/harness-provider.d.mts +197 -0
- package/dist/modules/harness-provider.mjs +108 -0
- package/dist/modules/harness-provider.mjs.map +7 -0
- package/dist/modules/harness-requirements.d.mts +19 -0
- package/dist/modules/harness-requirements.mjs +40 -0
- package/dist/modules/harness-requirements.mjs.map +7 -0
- package/dist/modules/harness-start.d.mts +33 -0
- package/dist/modules/harness-start.mjs +107 -0
- package/dist/modules/harness-start.mjs.map +7 -0
- package/dist/modules/harness.d.mts +84 -109
- package/dist/modules/harness.mjs +56 -111
- package/dist/modules/harness.mjs.map +3 -3
- package/dist/modules/identity.d.mts +1 -0
- package/dist/modules/identity.mjs +2 -0
- package/dist/modules/identity.mjs.map +7 -0
- package/dist/modules/index.d.mts +12 -6
- package/dist/modules/index.mjs +12 -6
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/inference.d.mts +35 -0
- package/dist/modules/inference.mjs +74 -0
- package/dist/modules/inference.mjs.map +7 -0
- package/dist/modules/local-channel-context.mjs +1 -1
- package/dist/modules/local-channel-context.mjs.map +2 -2
- package/dist/modules/requirements-check.d.mts +30 -0
- package/dist/modules/requirements-check.mjs +164 -0
- package/dist/modules/requirements-check.mjs.map +7 -0
- package/dist/modules/room-surface.d.mts +0 -5
- package/dist/modules/room-surface.mjs.map +2 -2
- package/dist/modules/sandbox/client.d.mts +3 -0
- package/dist/modules/sandbox/client.mjs +101 -18
- package/dist/modules/sandbox/client.mjs.map +2 -2
- package/dist/modules/sandbox/grant.d.mts +78 -0
- package/dist/modules/sandbox/grant.mjs +134 -0
- package/dist/modules/sandbox/grant.mjs.map +7 -0
- package/dist/modules/sandbox/index.d.mts +3 -3
- package/dist/modules/sandbox/index.mjs +4 -5
- package/dist/modules/sandbox/index.mjs.map +2 -2
- package/dist/modules/sandbox/mcp-hosted.d.mts +1 -1
- package/dist/modules/sandbox/mcp-hosted.mjs +4 -7
- package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
- package/dist/modules/sandbox/mcp.d.mts +4 -2
- package/dist/modules/sandbox/mcp.mjs +14 -7
- package/dist/modules/sandbox/mcp.mjs.map +2 -2
- package/dist/modules/sandbox/memory-sandbox.d.mts +2 -1
- package/dist/modules/sandbox/memory-sandbox.mjs +71 -41
- package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
- package/dist/modules/sandbox/networking.d.mts +7 -7
- package/dist/modules/sandbox/networking.mjs +16 -9
- package/dist/modules/sandbox/networking.mjs.map +2 -2
- package/dist/modules/sandbox/remote/adapter.d.mts +30 -0
- package/dist/modules/sandbox/remote/adapter.mjs +381 -0
- package/dist/modules/sandbox/remote/adapter.mjs.map +7 -0
- package/dist/modules/sandbox/remote/errors.d.mts +10 -0
- package/dist/modules/sandbox/remote/errors.mjs +62 -0
- package/dist/modules/sandbox/remote/errors.mjs.map +7 -0
- package/dist/modules/sandbox/remote/index.d.mts +5 -0
- package/dist/modules/sandbox/remote/index.mjs +6 -0
- package/dist/modules/sandbox/remote/index.mjs.map +7 -0
- package/dist/modules/sandbox/remote/ndjson.d.mts +6 -0
- package/dist/modules/sandbox/remote/ndjson.mjs +80 -0
- package/dist/modules/sandbox/remote/ndjson.mjs.map +7 -0
- package/dist/modules/sandbox/remote/platform-api.d.mts +8 -0
- package/dist/modules/sandbox/remote/platform-api.mjs +15 -0
- package/dist/modules/sandbox/remote/platform-api.mjs.map +7 -0
- package/dist/modules/sandbox/remote/preamble.d.mts +7 -0
- package/dist/modules/sandbox/remote/preamble.mjs +51 -0
- package/dist/modules/sandbox/remote/preamble.mjs.map +7 -0
- package/dist/modules/sandbox/remote/serve.d.mts +34 -0
- package/dist/modules/sandbox/remote/serve.mjs +519 -0
- package/dist/modules/sandbox/remote/serve.mjs.map +7 -0
- package/dist/modules/sandbox/remote/testing.d.mts +34 -0
- package/dist/modules/sandbox/remote/testing.mjs +275 -0
- package/dist/modules/sandbox/remote/testing.mjs.map +7 -0
- package/dist/modules/sandbox/seeds.d.mts +2 -2
- package/dist/modules/sandbox/seeds.mjs +2 -2
- package/dist/modules/sandbox/seeds.mjs.map +2 -2
- package/dist/modules/sandbox/server.d.mts +4 -6
- package/dist/modules/sandbox/server.mjs +93 -49
- package/dist/modules/sandbox/server.mjs.map +2 -2
- package/dist/modules/sandbox/setup/apply.d.mts +41 -0
- package/dist/modules/sandbox/setup/apply.mjs +204 -0
- package/dist/modules/sandbox/setup/apply.mjs.map +7 -0
- package/dist/modules/sandbox/setup/describe.d.mts +10 -0
- package/dist/modules/sandbox/setup/describe.mjs +62 -0
- package/dist/modules/sandbox/setup/describe.mjs.map +7 -0
- package/dist/modules/sandbox/setup/index.d.mts +6 -0
- package/dist/modules/sandbox/setup/index.mjs +17 -0
- package/dist/modules/sandbox/setup/index.mjs.map +7 -0
- package/dist/modules/sandbox/setup/paths.d.mts +8 -0
- package/dist/modules/sandbox/setup/paths.mjs +18 -0
- package/dist/modules/sandbox/setup/paths.mjs.map +7 -0
- package/dist/modules/sandbox/setup/schema.d.mts +42 -0
- package/dist/modules/sandbox/setup/schema.mjs +58 -0
- package/dist/modules/sandbox/setup/schema.mjs.map +7 -0
- package/dist/modules/sandbox/tool-policy.d.mts +1 -1
- package/dist/modules/sandbox/tool-policy.mjs +1 -1
- package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +117 -130
- package/dist/modules/sandbox/types.mjs +46 -50
- package/dist/modules/sandbox/types.mjs.map +3 -3
- package/dist/modules/sandbox/wire.d.mts +93 -6
- package/dist/modules/sandbox/wire.mjs +61 -38
- package/dist/modules/sandbox/wire.mjs.map +2 -2
- package/dist/modules/schemas.d.mts +5 -76
- package/dist/modules/schemas.mjs +18 -85
- package/dist/modules/schemas.mjs.map +2 -2
- package/dist/modules/tool-annotations.d.mts +15 -6
- package/dist/modules/tool-annotations.mjs +9 -3
- package/dist/modules/tool-annotations.mjs.map +2 -2
- package/dist/modules/tool-descriptor.d.mts +16 -0
- package/dist/modules/tool-descriptor.mjs +19 -0
- package/dist/modules/tool-descriptor.mjs.map +7 -0
- package/dist/modules/tool-patterns.d.mts +7 -7
- package/dist/modules/tool-patterns.mjs +10 -9
- package/dist/modules/tool-patterns.mjs.map +2 -2
- package/package.json +86 -36
- package/dist/modules/credentials.d.mts +0 -206
- package/dist/modules/credentials.mjs +0 -207
- package/dist/modules/credentials.mjs.map +0 -7
- package/dist/modules/dynamic.d.mts +0 -40
- package/dist/modules/dynamic.mjs +0 -79
- package/dist/modules/dynamic.mjs.map +0 -7
- package/dist/modules/hosted-bindings.d.mts +0 -15
- package/dist/modules/hosted-bindings.mjs +0 -21
- package/dist/modules/hosted-bindings.mjs.map +0 -7
- package/dist/modules/manifest.d.mts +0 -791
- package/dist/modules/manifest.mjs +0 -322
- package/dist/modules/manifest.mjs.map +0 -7
- package/dist/modules/provider-ref.d.mts +0 -29
- package/dist/modules/provider-ref.mjs +0 -55
- package/dist/modules/provider-ref.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope-node.d.mts +0 -4
- package/dist/modules/sandbox/open-scope-node.mjs +0 -19
- package/dist/modules/sandbox/open-scope-node.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope.d.mts +0 -16
- package/dist/modules/sandbox/open-scope.mjs +0 -66
- package/dist/modules/sandbox/open-scope.mjs.map +0 -7
- package/dist/modules/sandbox/workspace-identity.d.mts +0 -5
- package/dist/modules/sandbox/workspace-identity.mjs +0 -14
- package/dist/modules/sandbox/workspace-identity.mjs.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/sandbox/remote/ndjson.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n SANDBOX_PROVIDER_NDJSON_CONTENT_TYPE,\n SandboxProviderErrorCode,\n sandboxProviderErrorSchema,\n} from '@finalai/agent-protocol/sandbox-provider-wire';\nimport * as z from 'zod';\nimport type { JsonValue } from \"../../json.mjs\";\nimport { sandboxProviderWireError, wireErrorFromBody, wireErrorOf } from \"./errors.mjs\";\n\n// Long provider calls answer NDJSON: a heartbeat line while the work runs,\n// then exactly one result or error line. Load balancers and proxies then\n// never see an idle request, however long the backend takes.\n\nconst HEARTBEAT_LINE = `${JSON.stringify({ heartbeat: true })}\\n`;\n\nexport const ndjsonResponse = (args: {\n work: () => Promise<JsonValue>;\n heartbeatMs: number;\n}): Response => {\n const encoder = new TextEncoder();\n let timer: ReturnType<typeof setInterval> | null = null;\n // A caller that went away cancels the body; the work's answer then goes nowhere.\n let cancelled = false;\n const body = new ReadableStream<Uint8Array>({\n start: (controller) => {\n timer = setInterval(\n () => controller.enqueue(encoder.encode(HEARTBEAT_LINE)),\n args.heartbeatMs,\n );\n void args\n .work()\n .then(\n (result) => ({ result }),\n (cause: unknown) => ({ error: wireErrorOf(cause) }),\n )\n .then((line) => {\n if (timer != null) clearInterval(timer);\n if (cancelled) return;\n controller.enqueue(encoder.encode(`${JSON.stringify(line)}\\n`));\n controller.close();\n });\n },\n cancel: () => {\n cancelled = true;\n if (timer != null) clearInterval(timer);\n },\n });\n return new Response(body, {\n status: 200,\n headers: { 'content-type': SANDBOX_PROVIDER_NDJSON_CONTENT_TYPE },\n });\n};\n\nconst lineSchema = z.union([\n z.object({ heartbeat: z.literal(true) }),\n z.object({ result: z.unknown() }),\n z.object({ error: sandboxProviderErrorSchema }),\n]);\n\n// The result an answer carries, plain JSON or NDJSON; throws its wire error.\nexport const readWireAnswer = async (response: Response): Promise<unknown> => {\n // Read as text so proxy and load balancer error pages survive.\n const text = await response.text();\n if (!response.ok) throw wireErrorFromBody(response.status, text);\n const contentType = response.headers.get('content-type') ?? '';\n if (!contentType.startsWith(SANDBOX_PROVIDER_NDJSON_CONTENT_TYPE)) {\n try {\n return JSON.parse(text);\n } catch {\n throw wireErrorFromBody(502, text);\n }\n }\n for (const raw of text.split('\\n')) {\n if (raw.trim() === '') continue;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw wireErrorFromBody(502, raw);\n }\n const line = lineSchema.safeParse(parsed);\n if (!line.success) throw wireErrorFromBody(502, raw);\n if ('error' in line.data) throw sandboxProviderWireError(line.data.error);\n if ('result' in line.data) return line.data.result;\n }\n throw sandboxProviderWireError({\n code: SandboxProviderErrorCode.Unavailable,\n message: 'the sandbox provider ended its answer without a result',\n retryable: true,\n });\n};\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,OAAO;AAEnB,SAAS,0BAA0B,mBAAmB,mBAAmB;AAMzE,MAAM,iBAAiB,GAAG,KAAK,UAAU,EAAE,WAAW,KAAK,CAAC,CAAC;AAAA;AAEtD,MAAM,iBAAiB,CAAC,SAGf;AACd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AAI;AACF,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB,QAAQ;AACN,YAAM,kBAAkB,KAAK,IAAI;AAAA,IACnC;AAAA,EACF;AACA,aAAW,OAAO,KAAK,MAAM,IAAI,GAAG;AAClC,QAAI,IAAI,KAAK,MAAM,GAAI;AACvB,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,GAAG;AAAA,IACzB,QAAQ;AACN,YAAM,kBAAkB,KAAK,GAAG;AAAA,IAClC;AACA,UAAM,OAAO,WAAW,UAAU,MAAM;AACxC,QAAI,CAAC,KAAK,QAAS,OAAM,kBAAkB,KAAK,GAAG;AACnD,QAAI,WAAW,KAAK,KAAM,OAAM,yBAAyB,KAAK,KAAK,KAAK;AACxE,QAAI,YAAY,KAAK,KAAM,QAAO,KAAK,KAAK;AAAA,EAC9C;AACA,QAAM,yBAAyB;AAAA,IAC7B,MAAM,yBAAyB;AAAA,IAC/B,SAAS;AAAA,IACT,WAAW;AAAA,EACb,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const PLATFORM_IDENTITY_EXCHANGE_PATH = "/api/v1/platform-identity/exchange";
|
|
3
|
+
export declare const SANDBOX_PROVIDER_ARTIFACTS_PATH = "/api/v1/sandbox-provider-artifacts";
|
|
4
|
+
export declare const sandboxProviderArtifactBodySchema: z.ZodObject<{
|
|
5
|
+
artifact: z.ZodType<import("../../index.mjs").JsonValue, unknown, z.core.$ZodTypeInternals<import("../../index.mjs").JsonValue, unknown>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const sandboxProviderArtifactUrl: (issuer: string, key: string) => string;
|
|
8
|
+
export declare const platformIdentityExchangeUrl: (issuer: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { jsonValueSchema } from "../../json.mjs";
|
|
3
|
+
const PLATFORM_IDENTITY_EXCHANGE_PATH = "/api/v1/platform-identity/exchange";
|
|
4
|
+
const SANDBOX_PROVIDER_ARTIFACTS_PATH = "/api/v1/sandbox-provider-artifacts";
|
|
5
|
+
const sandboxProviderArtifactBodySchema = z.object({ artifact: jsonValueSchema });
|
|
6
|
+
const sandboxProviderArtifactUrl = (issuer, key) => new URL(`${SANDBOX_PROVIDER_ARTIFACTS_PATH}/${encodeURIComponent(key)}`, issuer).toString();
|
|
7
|
+
const platformIdentityExchangeUrl = (issuer) => new URL(PLATFORM_IDENTITY_EXCHANGE_PATH, issuer).toString();
|
|
8
|
+
export {
|
|
9
|
+
PLATFORM_IDENTITY_EXCHANGE_PATH,
|
|
10
|
+
SANDBOX_PROVIDER_ARTIFACTS_PATH,
|
|
11
|
+
platformIdentityExchangeUrl,
|
|
12
|
+
sandboxProviderArtifactBodySchema,
|
|
13
|
+
sandboxProviderArtifactUrl
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=platform-api.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/sandbox/remote/platform-api.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport { jsonValueSchema } from \"../../json.mjs\";\n\n// The two platform routes a provider host calls back, both authenticated by\n// the provider's current sandbox-provider assertion:\n//\n// - `POST {issuer}/api/v1/platform-identity/exchange { subjectToken, audience }`\n// \u2192 `{ token, expiresAt }`: an assertion for a backend the registration was\n// granted (`ctx.identity`).\n// - `GET|PUT {issuer}/api/v1/sandbox-provider-artifacts/:key`: the provider's\n// reusable artifacts (`ctx.artifacts`), scoped to its organization and\n// registration. GET answers `{ artifact }` or 404; PUT takes `{ artifact }`.\n\nexport const PLATFORM_IDENTITY_EXCHANGE_PATH = '/api/v1/platform-identity/exchange';\nexport const SANDBOX_PROVIDER_ARTIFACTS_PATH = '/api/v1/sandbox-provider-artifacts';\n\nexport const sandboxProviderArtifactBodySchema = z.object({ artifact: jsonValueSchema });\n\nexport const sandboxProviderArtifactUrl = (issuer: string, key: string): string =>\n new URL(`${SANDBOX_PROVIDER_ARTIFACTS_PATH}/${encodeURIComponent(key)}`, issuer).toString();\n\nexport const platformIdentityExchangeUrl = (issuer: string): string =>\n new URL(PLATFORM_IDENTITY_EXCHANGE_PATH, issuer).toString();\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,uBAAuB;AAYzB,MAAM,kCAAkC;AACxC,MAAM,kCAAkC;AAExC,MAAM,oCAAoC,EAAE,OAAO,EAAE,UAAU,gBAAgB,CAAC;AAEhF,MAAM,6BAA6B,CAAC,QAAgB,QACzD,IAAI,IAAI,GAAG,+BAA+B,IAAI,mBAAmB,GAAG,CAAC,IAAI,MAAM,EAAE,SAAS;AAErF,MAAM,8BAA8B,CAAC,WAC1C,IAAI,IAAI,iCAAiC,MAAM,EAAE,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FrameChannelCloseIface, FrameChannelIface, WireFrame } from "../wire.mjs";
|
|
2
|
+
export interface PreambleChannelIface {
|
|
3
|
+
next(): Promise<WireFrame>;
|
|
4
|
+
readonly closed: Promise<FrameChannelCloseIface>;
|
|
5
|
+
rest(): FrameChannelIface;
|
|
6
|
+
}
|
|
7
|
+
export declare const preambleChannel: (channel: FrameChannelIface) => PreambleChannelIface;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const preambleChannel = (channel) => {
|
|
2
|
+
const queue = [];
|
|
3
|
+
const waiters = [];
|
|
4
|
+
let handlers = null;
|
|
5
|
+
let resting = false;
|
|
6
|
+
let closedWith = null;
|
|
7
|
+
let resolveClosed = () => void 0;
|
|
8
|
+
const closed = new Promise((resolve) => {
|
|
9
|
+
resolveClosed = resolve;
|
|
10
|
+
});
|
|
11
|
+
const closedError = (info) => new Error(`the socket closed (${info.code}${info.reason === "" ? "" : `: ${info.reason}`})`);
|
|
12
|
+
channel.listen({
|
|
13
|
+
frame: (frame) => {
|
|
14
|
+
if (handlers != null) handlers.frame(frame);
|
|
15
|
+
else if (!resting && waiters.length > 0) waiters.shift()?.resolve(frame);
|
|
16
|
+
else queue.push(frame);
|
|
17
|
+
},
|
|
18
|
+
close: (info) => {
|
|
19
|
+
if (closedWith != null) return;
|
|
20
|
+
closedWith = info;
|
|
21
|
+
for (const waiter of waiters.splice(0)) waiter.reject(closedError(info));
|
|
22
|
+
handlers?.close(info);
|
|
23
|
+
resolveClosed(info);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
next: () => {
|
|
28
|
+
const queued = queue.shift();
|
|
29
|
+
if (queued != null) return Promise.resolve(queued);
|
|
30
|
+
if (closedWith != null) return Promise.reject(closedError(closedWith));
|
|
31
|
+
return new Promise((resolve, reject) => waiters.push({ resolve, reject }));
|
|
32
|
+
},
|
|
33
|
+
closed,
|
|
34
|
+
rest: () => {
|
|
35
|
+
resting = true;
|
|
36
|
+
return {
|
|
37
|
+
send: (frame) => channel.send(frame),
|
|
38
|
+
close: (code, reason) => channel.close(code, reason),
|
|
39
|
+
listen: (next) => {
|
|
40
|
+
handlers = next;
|
|
41
|
+
for (const frame of queue.splice(0)) next.frame(frame);
|
|
42
|
+
if (closedWith != null) next.close(closedWith);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
preambleChannel
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=preamble.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/sandbox/remote/preamble.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n FrameChannelCloseIface,\n FrameChannelHandlersIface,\n FrameChannelIface,\n WireFrame,\n} from \"../wire.mjs\";\n\n// The attach socket starts with a few frames of its own (the attach request,\n// heartbeats, the attached reply) and then carries the handle RPC. This reads\n// those first frames one at a time, then hands the rest of the socket, with\n// anything already received, to the handle RPC as an ordinary frame channel.\n\nexport interface PreambleChannelIface {\n // The next frame; rejects once the channel closed.\n next(): Promise<WireFrame>;\n // Resolves when the channel closes, whoever closed it.\n readonly closed: Promise<FrameChannelCloseIface>;\n // The rest of the channel; call once, after the last `next`.\n rest(): FrameChannelIface;\n}\n\nexport const preambleChannel = (channel: FrameChannelIface): PreambleChannelIface => {\n const queue: WireFrame[] = [];\n const waiters: { resolve: (frame: WireFrame) => void; reject: (error: Error) => void }[] = [];\n let handlers: FrameChannelHandlersIface | null = null;\n let resting = false;\n let closedWith: FrameChannelCloseIface | null = null;\n let resolveClosed: (info: FrameChannelCloseIface) => void = () => undefined;\n const closed = new Promise<FrameChannelCloseIface>((resolve) => {\n resolveClosed = resolve;\n });\n const closedError = (info: FrameChannelCloseIface) =>\n new Error(`the socket closed (${info.code}${info.reason === '' ? '' : `: ${info.reason}`})`);\n channel.listen({\n frame: (frame) => {\n if (handlers != null) handlers.frame(frame);\n else if (!resting && waiters.length > 0) waiters.shift()?.resolve(frame);\n else queue.push(frame);\n },\n close: (info) => {\n if (closedWith != null) return;\n closedWith = info;\n for (const waiter of waiters.splice(0)) waiter.reject(closedError(info));\n handlers?.close(info);\n resolveClosed(info);\n },\n });\n return {\n next: () => {\n const queued = queue.shift();\n if (queued != null) return Promise.resolve(queued);\n if (closedWith != null) return Promise.reject(closedError(closedWith));\n return new Promise<WireFrame>((resolve, reject) => waiters.push({ resolve, reject }));\n },\n closed,\n rest: () => {\n resting = true;\n return {\n send: (frame) => channel.send(frame),\n close: (code, reason) => channel.close(code, reason),\n listen: (next) => {\n handlers = next;\n for (const frame of queue.splice(0)) next.frame(frame);\n if (closedWith != null) next.close(closedWith);\n },\n };\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "AAqBO,MAAM,kBAAkB,CAAC,YAAqD;AACnF,QAAM,QAAqB,C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AAS,MAAM,OAAO,CAAC,EAAG,MAAK,MAAM,KAAK;AACrD,cAAI,cAAc,KAAM,MAAK,MAAM,UAAU;AAAA,QAC/C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RuntimeKind } from '@finalai/agent-protocol';
|
|
2
|
+
import { type JwksIface, type JwksKeySourceIface } from '@finalai/agent-protocol/identity';
|
|
3
|
+
import { type SandboxFormFactor, type SandboxProviderFeaturesIface } from '@finalai/agent-protocol/sandbox-provider-wire';
|
|
4
|
+
import { type JsonObject } from "../../json.mjs";
|
|
5
|
+
import { type AnySandboxProviderIface, type SandboxCapabilityOffer } from "../types.mjs";
|
|
6
|
+
import { type WebSocketLikeIface } from "../wire.mjs";
|
|
7
|
+
export interface SandboxProviderDiscoveryInputIface {
|
|
8
|
+
title?: string | null;
|
|
9
|
+
formFactor: SandboxFormFactor;
|
|
10
|
+
environmentSchema?: JsonObject | null;
|
|
11
|
+
capabilities: SandboxCapabilityOffer;
|
|
12
|
+
runtimes?: RuntimeKind[];
|
|
13
|
+
features?: SandboxProviderFeaturesIface;
|
|
14
|
+
}
|
|
15
|
+
export interface ServedSandboxProviderIface {
|
|
16
|
+
provider: AnySandboxProviderIface;
|
|
17
|
+
discovery: SandboxProviderDiscoveryInputIface;
|
|
18
|
+
}
|
|
19
|
+
export interface ServeSandboxProviderArgsIface {
|
|
20
|
+
providers: Record<string, ServedSandboxProviderIface>;
|
|
21
|
+
issuer: string;
|
|
22
|
+
jwksUrl?: string;
|
|
23
|
+
jwks?: JwksIface | JwksKeySourceIface;
|
|
24
|
+
publicUrl: (name: string) => string;
|
|
25
|
+
fetch?: typeof fetch;
|
|
26
|
+
heartbeatMs?: number;
|
|
27
|
+
now?: () => number;
|
|
28
|
+
log?: (message: string, fields?: Record<string, string | number | boolean | null>) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface SandboxProviderServerIface {
|
|
31
|
+
fetch(request: Request): Promise<Response>;
|
|
32
|
+
upgrade(request: Request, socket: WebSocketLikeIface): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const serveSandboxProvider: (args: ServeSandboxProviderArgsIface) => SandboxProviderServerIface;
|