@finalai/final-agent-provider 0.10.0 → 0.11.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 +126 -40
- package/WORKSPACE-EGRESS.md +11 -11
- package/dist/modules/catalog.d.mts +9 -0
- package/dist/modules/catalog.mjs +21 -0
- package/dist/modules/catalog.mjs.map +7 -0
- package/dist/modules/channels/projection.mjs +15 -8
- package/dist/modules/channels/projection.mjs.map +2 -2
- package/dist/modules/harnesses/acp-agent.d.mts +4 -0
- package/dist/modules/harnesses/acp-agent.mjs +35 -0
- package/dist/modules/harnesses/acp-agent.mjs.map +7 -0
- package/dist/modules/harnesses/adapters.d.mts +7 -0
- package/dist/modules/harnesses/adapters.mjs +74 -0
- package/dist/modules/harnesses/adapters.mjs.map +7 -0
- package/dist/modules/harnesses/claude-code.d.mts +14 -0
- package/dist/modules/harnesses/claude-code.mjs +79 -0
- package/dist/modules/harnesses/claude-code.mjs.map +7 -0
- package/dist/modules/harnesses/codex.d.mts +12 -0
- package/dist/modules/harnesses/codex.mjs +90 -0
- package/dist/modules/harnesses/codex.mjs.map +7 -0
- package/dist/modules/harnesses/config-fields.d.mts +98 -57
- package/dist/modules/harnesses/config-fields.mjs +58 -35
- package/dist/modules/harnesses/config-fields.mjs.map +3 -3
- package/dist/modules/harnesses/definitions.d.mts +3 -0
- package/dist/modules/harnesses/definitions.mjs +21 -0
- package/dist/modules/harnesses/definitions.mjs.map +7 -0
- package/dist/modules/harnesses/fidelity.d.mts +1 -1
- package/dist/modules/harnesses/fidelity.mjs +19 -16
- package/dist/modules/harnesses/fidelity.mjs.map +2 -2
- package/dist/modules/harnesses/final.d.mts +12 -0
- package/dist/modules/harnesses/final.mjs +70 -0
- package/dist/modules/harnesses/final.mjs.map +7 -0
- package/dist/modules/harnesses/index.d.mts +13 -12
- package/dist/modules/harnesses/index.mjs +86 -45
- package/dist/modules/harnesses/index.mjs.map +3 -3
- package/dist/modules/harnesses/names.d.mts +43 -0
- package/dist/modules/harnesses/names.mjs +59 -0
- package/dist/modules/harnesses/names.mjs.map +7 -0
- package/dist/modules/harnesses/nanocode-claude.d.mts +18 -0
- package/dist/modules/harnesses/nanocode-claude.mjs +101 -0
- package/dist/modules/harnesses/nanocode-claude.mjs.map +7 -0
- package/dist/modules/harnesses/nanocode-codex.d.mts +13 -0
- package/dist/modules/harnesses/nanocode-codex.mjs +64 -0
- package/dist/modules/harnesses/nanocode-codex.mjs.map +7 -0
- package/dist/modules/harnesses/pi.d.mts +12 -0
- package/dist/modules/harnesses/pi.mjs +71 -0
- package/dist/modules/harnesses/pi.mjs.map +7 -0
- package/dist/modules/integrations.d.mts +9 -0
- package/dist/modules/integrations.mjs +29 -0
- package/dist/modules/integrations.mjs.map +7 -0
- package/dist/modules/provider/general.bundle.d.mts +1 -0
- package/dist/modules/provider/general.bundle.mjs +5 -0
- package/dist/modules/provider/general.bundle.mjs.map +7 -0
- package/dist/modules/provider/general.d.mts +11 -0
- package/dist/modules/provider/general.mjs +130 -0
- package/dist/modules/provider/general.mjs.map +7 -0
- package/dist/modules/provider/index.d.mts +3 -0
- package/dist/modules/provider/index.mjs +13 -0
- package/dist/modules/provider/index.mjs.map +7 -0
- package/dist/modules/sandboxes/access.d.mts +34 -0
- package/dist/modules/sandboxes/access.mjs +15 -0
- package/dist/modules/sandboxes/access.mjs.map +7 -0
- package/dist/modules/sandboxes/computer.d.mts +24 -51
- package/dist/modules/sandboxes/computer.mjs +523 -888
- package/dist/modules/sandboxes/computer.mjs.map +3 -3
- package/dist/modules/sandboxes/computers-api.d.mts +3 -2
- package/dist/modules/sandboxes/computers-api.mjs +2 -4
- package/dist/modules/sandboxes/computers-api.mjs.map +2 -2
- package/dist/modules/sandboxes/device-api.d.mts +4 -3
- package/dist/modules/sandboxes/device-api.mjs +2 -4
- package/dist/modules/sandboxes/device-api.mjs.map +2 -2
- package/dist/modules/sandboxes/device.d.mts +6 -6
- package/dist/modules/sandboxes/device.mjs +126 -121
- package/dist/modules/sandboxes/device.mjs.map +3 -3
- package/dist/modules/sandboxes/egress.d.mts +10 -9
- package/dist/modules/sandboxes/egress.mjs +73 -56
- package/dist/modules/sandboxes/egress.mjs.map +2 -2
- package/dist/modules/sandboxes/environment.d.mts +35 -269
- package/dist/modules/sandboxes/environment.mjs +27 -104
- package/dist/modules/sandboxes/environment.mjs.map +3 -3
- package/dist/modules/sandboxes/index.d.mts +9 -69
- package/dist/modules/sandboxes/index.mjs +35 -95
- package/dist/modules/sandboxes/index.mjs.map +3 -3
- package/dist/modules/sandboxes/local.d.mts +28 -0
- package/dist/modules/sandboxes/local.mjs +499 -0
- package/dist/modules/sandboxes/local.mjs.map +7 -0
- package/dist/modules/sandboxes/session.d.mts +0 -3
- package/dist/modules/sandboxes/session.mjs +2 -22
- package/dist/modules/sandboxes/session.mjs.map +2 -2
- package/dist/modules/sandboxes/testing/fake-machine.mjs +0 -28
- package/dist/modules/sandboxes/testing/fake-machine.mjs.map +2 -2
- package/package.json +76 -104
- package/dist/modules/connections.d.mts +0 -11
- package/dist/modules/connections.mjs +0 -16
- package/dist/modules/connections.mjs.map +0 -7
- package/dist/modules/harnesses/acp-describe.d.mts +0 -20
- package/dist/modules/harnesses/acp-describe.mjs +0 -110
- package/dist/modules/harnesses/acp-describe.mjs.map +0 -7
- package/dist/modules/harnesses/local-stdio.d.mts +0 -47
- package/dist/modules/harnesses/local-stdio.mjs +0 -41
- package/dist/modules/harnesses/local-stdio.mjs.map +0 -7
- package/dist/modules/harnesses/remote-acp.d.mts +0 -76
- package/dist/modules/harnesses/remote-acp.mjs +0 -83
- package/dist/modules/harnesses/remote-acp.mjs.map +0 -7
- package/dist/modules/harnesses/remote-claude-code.d.mts +0 -88
- package/dist/modules/harnesses/remote-claude-code.mjs +0 -113
- package/dist/modules/harnesses/remote-claude-code.mjs.map +0 -7
- package/dist/modules/harnesses/remote-client-tls.d.mts +0 -35
- package/dist/modules/harnesses/remote-client-tls.mjs +0 -37
- package/dist/modules/harnesses/remote-client-tls.mjs.map +0 -7
- package/dist/modules/harnesses/remote-codex.d.mts +0 -98
- package/dist/modules/harnesses/remote-codex.mjs +0 -128
- package/dist/modules/harnesses/remote-codex.mjs.map +0 -7
- package/dist/modules/harnesses/remote-pi.d.mts +0 -78
- package/dist/modules/harnesses/remote-pi.mjs +0 -104
- package/dist/modules/harnesses/remote-pi.mjs.map +0 -7
- package/dist/modules/harnesses/remote-url.d.mts +0 -5
- package/dist/modules/harnesses/remote-url.mjs +0 -19
- package/dist/modules/harnesses/remote-url.mjs.map +0 -7
- package/dist/modules/harnesses/serverless-final.d.mts +0 -63
- package/dist/modules/harnesses/serverless-final.mjs +0 -88
- package/dist/modules/harnesses/serverless-final.mjs.map +0 -7
- package/dist/modules/harnesses/serverless-nanocode-claude.d.mts +0 -64
- package/dist/modules/harnesses/serverless-nanocode-claude.mjs +0 -105
- package/dist/modules/harnesses/serverless-nanocode-claude.mjs.map +0 -7
- package/dist/modules/harnesses/serverless-nanocode-codex.d.mts +0 -66
- package/dist/modules/harnesses/serverless-nanocode-codex.mjs +0 -113
- package/dist/modules/harnesses/serverless-nanocode-codex.mjs.map +0 -7
- package/dist/modules/harnesses/serverless-pi.d.mts +0 -64
- package/dist/modules/harnesses/serverless-pi.mjs +0 -98
- package/dist/modules/harnesses/serverless-pi.mjs.map +0 -7
- package/dist/modules/runtime/index.d.mts +0 -7
- package/dist/modules/runtime/index.mjs +0 -18
- package/dist/modules/runtime/index.mjs.map +0 -7
- package/dist/modules/runtime/local-stdio.d.mts +0 -10
- package/dist/modules/runtime/local-stdio.mjs +0 -106
- package/dist/modules/runtime/local-stdio.mjs.map +0 -7
- package/dist/modules/runtime/remote-acp.d.mts +0 -16
- package/dist/modules/runtime/remote-acp.mjs +0 -152
- package/dist/modules/runtime/remote-acp.mjs.map +0 -7
- package/dist/modules/runtime/remote-claude-code.d.mts +0 -5
- package/dist/modules/runtime/remote-claude-code.mjs +0 -47
- package/dist/modules/runtime/remote-claude-code.mjs.map +0 -7
- package/dist/modules/runtime/remote-codex.d.mts +0 -5
- package/dist/modules/runtime/remote-codex.mjs +0 -47
- package/dist/modules/runtime/remote-codex.mjs.map +0 -7
- package/dist/modules/runtime/remote-host.d.mts +0 -127
- package/dist/modules/runtime/remote-host.mjs +0 -387
- package/dist/modules/runtime/remote-host.mjs.map +0 -7
- package/dist/modules/runtime/remote-pi.d.mts +0 -5
- package/dist/modules/runtime/remote-pi.mjs +0 -44
- package/dist/modules/runtime/remote-pi.mjs.map +0 -7
- package/dist/modules/sandboxes/guide.d.mts +0 -35
- package/dist/modules/sandboxes/guide.mjs +0 -119
- package/dist/modules/sandboxes/guide.mjs.map +0 -7
- package/dist/modules/sandboxes/workspace-setup.d.mts +0 -42
- package/dist/modules/sandboxes/workspace-setup.mjs +0 -242
- package/dist/modules/sandboxes/workspace-setup.mjs.map +0 -7
- package/dist/modules/testing/harness.d.mts +0 -9
- package/dist/modules/testing/harness.mjs +0 -123
- package/dist/modules/testing/harness.mjs.map +0 -7
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACP_V2_INTERFACE,
|
|
3
|
+
FinalExtension,
|
|
4
|
+
harnessStartFor,
|
|
5
|
+
HarnessEnvironmentKind,
|
|
6
|
+
runtimesOf
|
|
7
|
+
} from "@finalai/agent-provider/harness-start";
|
|
8
|
+
const REQUIRED_FINAL_EXTENSIONS = [
|
|
9
|
+
FinalExtension.Observe,
|
|
10
|
+
FinalExtension.AuthorMeta,
|
|
11
|
+
FinalExtension.ResumeReplay,
|
|
12
|
+
FinalExtension.AfterSeqReplay
|
|
13
|
+
];
|
|
14
|
+
const refused = (problems) => ({ unsuitable: problems });
|
|
15
|
+
const listOf = (items) => items.length === 0 ? "nothing" : items.join(", ");
|
|
16
|
+
const urlEndpoint = async (args) => {
|
|
17
|
+
if (args.adapter != null)
|
|
18
|
+
return refused([
|
|
19
|
+
`An ACP endpoint at a URL already speaks ACP and takes no adapter (${args.adapter})`
|
|
20
|
+
]);
|
|
21
|
+
let protocol;
|
|
22
|
+
try {
|
|
23
|
+
protocol = new URL(args.url).protocol;
|
|
24
|
+
} catch {
|
|
25
|
+
return refused([`${args.url} is not a URL`]);
|
|
26
|
+
}
|
|
27
|
+
const transport = protocol === "wss:" || protocol === "ws:" ? "ws" : protocol === "https:" || protocol === "http:" ? "http" : null;
|
|
28
|
+
if (transport == null)
|
|
29
|
+
return refused([`${args.url}: an ACP endpoint answers over ws(s) or http(s)`]);
|
|
30
|
+
const headers = {};
|
|
31
|
+
if (args.hop != null) {
|
|
32
|
+
const token = await args.ctx.secrets.get(args.hop);
|
|
33
|
+
if (token == null || token.length === 0)
|
|
34
|
+
return refused([`The project has no secret ${args.hop} for ${args.url}`]);
|
|
35
|
+
headers["authorization"] = `Bearer ${token}`;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
ref: args.ref,
|
|
39
|
+
transport,
|
|
40
|
+
url: args.url,
|
|
41
|
+
headers,
|
|
42
|
+
extensions: [...REQUIRED_FINAL_EXTENSIONS]
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const sandboxEndpoint = (args, ref, sandboxId) => {
|
|
46
|
+
const harness = args.harness;
|
|
47
|
+
const adapter = args.adapter;
|
|
48
|
+
const name = harness.name;
|
|
49
|
+
if (harness.definition.provider != null)
|
|
50
|
+
return refused([`${name} is reached by its own harness provider`]);
|
|
51
|
+
const problems = [];
|
|
52
|
+
if (adapter == null && harness.definition.interface !== ACP_V2_INTERFACE)
|
|
53
|
+
problems.push(`${name} speaks ${harness.definition.interface}, not ACP v2, and has no adapter`);
|
|
54
|
+
if (adapter != null) {
|
|
55
|
+
if (!adapter.definition.adapts.includes(harness.definition.interface))
|
|
56
|
+
problems.push(
|
|
57
|
+
`ACP adapter ${adapter.name} adapts ${listOf(adapter.definition.adapts)}, not ${harness.definition.interface}`
|
|
58
|
+
);
|
|
59
|
+
const missing = REQUIRED_FINAL_EXTENSIONS.filter(
|
|
60
|
+
(extension) => !adapter.definition.extensions.includes(extension)
|
|
61
|
+
);
|
|
62
|
+
if (missing.length > 0)
|
|
63
|
+
problems.push(
|
|
64
|
+
`ACP adapter ${adapter.name} does not implement Final's ACP extensions ${listOf(missing)}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const runtime = args.runtime;
|
|
68
|
+
const harnessRuntimes = runtimesOf(harness.definition.run);
|
|
69
|
+
const adapterRuntimes = adapter == null ? null : runtimesOf(adapter.definition.run);
|
|
70
|
+
if (runtime == null) problems.push(`Sandbox ${sandboxId} runs nothing ${name} has an entry for`);
|
|
71
|
+
else {
|
|
72
|
+
if (!harnessRuntimes.includes(runtime))
|
|
73
|
+
problems.push(`${name} has no ${runtime} entry (it runs as ${listOf(harnessRuntimes)})`);
|
|
74
|
+
if (adapter != null && adapterRuntimes != null && !adapterRuntimes.includes(runtime))
|
|
75
|
+
problems.push(
|
|
76
|
+
`ACP adapter ${adapter.name} has no ${runtime} entry (it runs as ${listOf(adapterRuntimes)})`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (problems.length > 0 || runtime == null) return refused(problems);
|
|
80
|
+
const started = harnessStartFor({
|
|
81
|
+
harness: harness.definition,
|
|
82
|
+
adapter: adapter?.definition ?? null,
|
|
83
|
+
runtime,
|
|
84
|
+
configuration: args.settings.configuration
|
|
85
|
+
});
|
|
86
|
+
if (!started.ok) return refused(started.problems);
|
|
87
|
+
const endpoint = {
|
|
88
|
+
ref,
|
|
89
|
+
transport: "sandbox",
|
|
90
|
+
sandboxId,
|
|
91
|
+
start: started.start,
|
|
92
|
+
extensions: [...REQUIRED_FINAL_EXTENSIONS]
|
|
93
|
+
};
|
|
94
|
+
return endpoint;
|
|
95
|
+
};
|
|
96
|
+
const endpointFor = (args, ref, ctx) => {
|
|
97
|
+
const environment = args.environment;
|
|
98
|
+
if (environment.kind === HarnessEnvironmentKind.Url)
|
|
99
|
+
return urlEndpoint({
|
|
100
|
+
ref,
|
|
101
|
+
url: environment.url,
|
|
102
|
+
hop: environment.hop,
|
|
103
|
+
adapter: args.adapter?.name ?? null,
|
|
104
|
+
ctx
|
|
105
|
+
});
|
|
106
|
+
return Promise.resolve(sandboxEndpoint(args, ref, environment.sandboxId));
|
|
107
|
+
};
|
|
108
|
+
const open = (args, ctx) => endpointFor(
|
|
109
|
+
args,
|
|
110
|
+
{ harness: args.harness.name, harnessSessionRef: args.harnessSessionId, generation: 0 },
|
|
111
|
+
ctx
|
|
112
|
+
);
|
|
113
|
+
const resume = (args, ctx) => endpointFor(args, args.ref, ctx);
|
|
114
|
+
const park = async (_args, _ctx) => {
|
|
115
|
+
};
|
|
116
|
+
const close = async (_args, _ctx) => {
|
|
117
|
+
};
|
|
118
|
+
const health = async (_args, _ctx) => ({
|
|
119
|
+
ok: true,
|
|
120
|
+
detail: "The session service watches the program it started"
|
|
121
|
+
});
|
|
122
|
+
export {
|
|
123
|
+
REQUIRED_FINAL_EXTENSIONS,
|
|
124
|
+
close,
|
|
125
|
+
health,
|
|
126
|
+
open,
|
|
127
|
+
park,
|
|
128
|
+
resume
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=general.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/provider/general.ts"],
|
|
4
|
+
"sourcesContent": ["import type { HarnessSessionRefIface } from '@finalai/agent-provider/harness';\nimport type { ComposedEnvironmentIface } from '@finalai/agent-provider/harness-definition';\nimport {\n ACP_V2_INTERFACE,\n FinalExtension,\n harnessStartFor,\n HarnessEnvironmentKind,\n runtimesOf,\n} from '@finalai/agent-provider/harness-start';\nimport type {\n HarnessProviderCloseArgsIface,\n HarnessProviderContextIface,\n HarnessProviderEndpointResultIface,\n HarnessProviderOpenArgsIface,\n HarnessProviderOpenResultIface,\n HarnessProviderRefArgsIface,\n HarnessProviderResumeArgsIface,\n} from '@finalai/agent-provider/harness-provider';\n\n// The general harness provider: it starts adapter(harness) in the harness's\n// environment from the two definitions' run entries and hands the session\n// service the ACP stream; for an environment at a URL it hands over the URL.\n// Built only on the public harness provider contract and bundled into one\n// self-contained module (./general.bundle.ts), like any third party's\n// provider. It imports values only from dependency-free modules, and writes\n// the contract's transports as the strings they are, to keep that small.\n//\n// The session service starts what a `sandbox` endpoint names over the\n// sandbox's process streams (startSandboxEndpoint) and keeps the program for\n// the session's life, so park, close and health have nothing of their own to\n// stop or watch.\n\n// What every ACP endpoint it hands over must implement and advertise in\n// `initialize`, beyond ACP v2.\nexport const REQUIRED_FINAL_EXTENSIONS: readonly FinalExtension[] = [\n FinalExtension.Observe,\n FinalExtension.AuthorMeta,\n FinalExtension.ResumeReplay,\n FinalExtension.AfterSeqReplay,\n];\n\nconst refused = (problems: string[]): HarnessProviderOpenResultIface => ({ unsuitable: problems });\n\nconst listOf = (items: readonly string[]): string =>\n items.length === 0 ? 'nothing' : items.join(', ');\n\nconst urlEndpoint = async (args: {\n ref: HarnessSessionRefIface;\n url: string;\n hop: string | null;\n adapter: string | null;\n ctx: HarnessProviderContextIface;\n}): Promise<HarnessProviderOpenResultIface> => {\n if (args.adapter != null)\n return refused([\n `An ACP endpoint at a URL already speaks ACP and takes no adapter (${args.adapter})`,\n ]);\n let protocol: string;\n try {\n protocol = new URL(args.url).protocol;\n } catch {\n return refused([`${args.url} is not a URL`]);\n }\n const transport =\n protocol === 'wss:' || protocol === 'ws:'\n ? 'ws'\n : protocol === 'https:' || protocol === 'http:'\n ? 'http'\n : null;\n if (transport == null)\n return refused([`${args.url}: an ACP endpoint answers over ws(s) or http(s)`]);\n const headers: Record<string, string> = {};\n if (args.hop != null) {\n const token = await args.ctx.secrets.get(args.hop);\n if (token == null || token.length === 0)\n return refused([`The project has no secret ${args.hop} for ${args.url}`]);\n headers['authorization'] = `Bearer ${token}`;\n }\n return {\n ref: args.ref,\n transport,\n url: args.url,\n headers,\n extensions: [...REQUIRED_FINAL_EXTENSIONS],\n };\n};\n\nconst sandboxEndpoint = (\n args: HarnessProviderOpenArgsIface,\n ref: HarnessSessionRefIface,\n sandboxId: string,\n): HarnessProviderOpenResultIface => {\n const harness = args.harness;\n const adapter = args.adapter;\n const name = harness.name;\n if (harness.definition.provider != null)\n return refused([`${name} is reached by its own harness provider`]);\n const problems: string[] = [];\n if (adapter == null && harness.definition.interface !== ACP_V2_INTERFACE)\n problems.push(`${name} speaks ${harness.definition.interface}, not ACP v2, and has no adapter`);\n if (adapter != null) {\n if (!adapter.definition.adapts.includes(harness.definition.interface))\n problems.push(\n `ACP adapter ${adapter.name} adapts ${listOf(adapter.definition.adapts)}, not ${harness.definition.interface}`,\n );\n const missing = REQUIRED_FINAL_EXTENSIONS.filter(\n (extension) => !adapter.definition.extensions.includes(extension),\n );\n if (missing.length > 0)\n problems.push(\n `ACP adapter ${adapter.name} does not implement Final's ACP extensions ${listOf(missing)}`,\n );\n }\n const runtime = args.runtime;\n const harnessRuntimes = runtimesOf(harness.definition.run);\n const adapterRuntimes = adapter == null ? null : runtimesOf(adapter.definition.run);\n if (runtime == null) problems.push(`Sandbox ${sandboxId} runs nothing ${name} has an entry for`);\n else {\n if (!harnessRuntimes.includes(runtime))\n problems.push(`${name} has no ${runtime} entry (it runs as ${listOf(harnessRuntimes)})`);\n if (adapter != null && adapterRuntimes != null && !adapterRuntimes.includes(runtime))\n problems.push(\n `ACP adapter ${adapter.name} has no ${runtime} entry (it runs as ${listOf(adapterRuntimes)})`,\n );\n }\n if (problems.length > 0 || runtime == null) return refused(problems);\n\n const started = harnessStartFor({\n harness: harness.definition,\n adapter: adapter?.definition ?? null,\n runtime,\n configuration: args.settings.configuration,\n });\n if (!started.ok) return refused(started.problems);\n const endpoint: HarnessProviderEndpointResultIface = {\n ref,\n transport: 'sandbox',\n sandboxId,\n start: started.start,\n extensions: [...REQUIRED_FINAL_EXTENSIONS],\n };\n return endpoint;\n};\n\nconst endpointFor = (\n args: HarnessProviderOpenArgsIface,\n ref: HarnessSessionRefIface,\n ctx: HarnessProviderContextIface,\n): Promise<HarnessProviderOpenResultIface> => {\n const environment: ComposedEnvironmentIface = args.environment;\n if (environment.kind === HarnessEnvironmentKind.Url)\n return urlEndpoint({\n ref,\n url: environment.url,\n hop: environment.hop,\n adapter: args.adapter?.name ?? null,\n ctx,\n });\n return Promise.resolve(sandboxEndpoint(args, ref, environment.sandboxId));\n};\n\nexport const open = (\n args: HarnessProviderOpenArgsIface,\n ctx: HarnessProviderContextIface,\n): Promise<HarnessProviderOpenResultIface> =>\n endpointFor(\n args,\n { harness: args.harness.name, harnessSessionRef: args.harnessSessionId, generation: 0 },\n ctx,\n );\n\n// The worker runtime finds a harness session's state again by its id; a\n// process starts afresh and the session service resumes it over ACP.\nexport const resume = (\n args: HarnessProviderResumeArgsIface,\n ctx: HarnessProviderContextIface,\n): Promise<HarnessProviderOpenResultIface> => endpointFor(args, args.ref, ctx);\n\nexport const park = async (\n _args: HarnessProviderRefArgsIface,\n _ctx: HarnessProviderContextIface,\n): Promise<void> => {};\n\nexport const close = async (\n _args: HarnessProviderCloseArgsIface,\n _ctx: HarnessProviderContextIface,\n): Promise<void> => {};\n\nexport const health = async (\n _args: HarnessProviderRefArgsIface,\n _ctx: HarnessProviderContextIface,\n): Promise<{ ok: boolean; detail?: string }> => ({\n ok: true,\n detail: 'The session service watches the program it started',\n});\n"],
|
|
5
|
+
"mappings": "AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BA,MAAM,4BAAuD;AAAA,EAClE,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AACjB;AAEA,MAAM,UAAU,CAAC,cAAwD,EAAE,YAAY,SAAS;AAEhG,MAAM,SAAS,CAAC,UACd,MAAM,WAAW,IAAI,YAAY,MAAM,KAAK,IAAI;AAElD,MAAM,cAAc,OAAO,SAMoB;AAC7C,MAAI,KAAK,WAAW;AAClB,WAAO,QAAQ;AAAA,MACb,qEA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AC5C,QAAM,cAAwC,KAAK;AACnD,MAAI,YAAY,SAAS,uBAAuB;AAC9C,WAAO,YAAY;AAAA,MACjB;AAAA,MACA,KAAK,YAAY;AAAA,MACjB,KAAK,YAAY;AAAA,MACjB,SAAS,KAAK,SAAS,QAAQ;AAAA,MAC/B;AAAA,IACF,CAAC;AACH,SAAO,QAAQ,QAAQ,gBAAgB,MAAM,KAAK,YAAY,SAAS,CAAC;AAC1E;AAEO,MAAM,OAAO,CAClB,MACA,QAEA;AAAA,EACE;AAAA,EACA,EAAE,SAAS,KAAK,QAAQ,MAAM,mBAAmB,KAAK,kBAAkB,YAAY,EAAE;AAAA,EACtF;AACF;AAIK,MAAM,SAAS,CACpB,MACA,QAC4C,YAAY,MAAM,KAAK,KAAK,GAAG;AAEtE,MAAM,OAAO,OAClB,OACA,SACkB;AAAC;AAEd,MAAM,QAAQ,OACnB,OACA,SACkB;AAAC;AAEd,MAAM,SAAS,OACpB,OACA,UAC+C;AAAA,EAC/C,IAAI;AAAA,EACJ,QAAQ;AACV;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineHarnessProvider
|
|
3
|
+
} from "@finalai/agent-definition/authoring";
|
|
4
|
+
import { GENERAL_HARNESS_PROVIDER_SOURCE } from "./general.bundle.mjs";
|
|
5
|
+
import { REQUIRED_FINAL_EXTENSIONS } from "./general.mjs";
|
|
6
|
+
const GENERAL_HARNESS_PROVIDER = defineHarnessProvider({
|
|
7
|
+
source: GENERAL_HARNESS_PROVIDER_SOURCE
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
GENERAL_HARNESS_PROVIDER,
|
|
11
|
+
REQUIRED_FINAL_EXTENSIONS
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/provider/index.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n defineHarnessProvider,\n type DefinedHarnessProviderIface,\n} from '@finalai/agent-definition/authoring';\nimport { GENERAL_HARNESS_PROVIDER_SOURCE } from \"./general.bundle.mjs\";\n\nexport { REQUIRED_FINAL_EXTENSIONS } from \"./general.mjs\";\n\n// The general harness provider as one self-contained module, ready to run on\n// a serverless runtime like any other harness provider's code.\nexport const GENERAL_HARNESS_PROVIDER: DefinedHarnessProviderIface = defineHarnessProvider({\n source: GENERAL_HARNESS_PROVIDER_SOURCE,\n});\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,uCAAuC;AAEhD,SAAS,iCAAiC;AAInC,MAAM,2BAAwD,sBAAsB;AAAA,EACzF,QAAQ;AACV,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface FinalPlatformAccessIface {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
token: string;
|
|
4
|
+
}
|
|
5
|
+
export type ComputersAccessIface = (args: {
|
|
6
|
+
organizationId: string;
|
|
7
|
+
projectId: string;
|
|
8
|
+
refresh: boolean;
|
|
9
|
+
}) => Promise<FinalPlatformAccessIface | null>;
|
|
10
|
+
export type DeviceAccessIface = (args: {
|
|
11
|
+
organizationId: string;
|
|
12
|
+
projectId: string | null;
|
|
13
|
+
actingUserId: string | null;
|
|
14
|
+
refresh: boolean;
|
|
15
|
+
}) => Promise<FinalPlatformAccessIface | null>;
|
|
16
|
+
export interface ComputersApiCredentialsIface {
|
|
17
|
+
computersAccess(args?: {
|
|
18
|
+
refresh?: boolean;
|
|
19
|
+
}): Promise<FinalPlatformAccessIface | null>;
|
|
20
|
+
}
|
|
21
|
+
export interface DeviceApiCredentialsIface {
|
|
22
|
+
deviceAccess(args?: {
|
|
23
|
+
actingUserId?: string | null;
|
|
24
|
+
refresh?: boolean;
|
|
25
|
+
}): Promise<FinalPlatformAccessIface | null>;
|
|
26
|
+
}
|
|
27
|
+
export declare const computersCredentialsFor: (access: ComputersAccessIface | undefined, scope: {
|
|
28
|
+
organizationId: string;
|
|
29
|
+
projectId: string;
|
|
30
|
+
}) => ComputersApiCredentialsIface;
|
|
31
|
+
export declare const deviceCredentialsFor: (access: DeviceAccessIface | undefined, scope: {
|
|
32
|
+
organizationId: string;
|
|
33
|
+
projectId: string | null;
|
|
34
|
+
}) => DeviceApiCredentialsIface;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const computersCredentialsFor = (access, scope) => ({
|
|
2
|
+
computersAccess: async (args) => access == null ? null : access({ ...scope, refresh: args?.refresh === true })
|
|
3
|
+
});
|
|
4
|
+
const deviceCredentialsFor = (access, scope) => ({
|
|
5
|
+
deviceAccess: async (args) => access == null ? null : access({
|
|
6
|
+
...scope,
|
|
7
|
+
actingUserId: args?.actingUserId ?? null,
|
|
8
|
+
refresh: args?.refresh === true
|
|
9
|
+
})
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
computersCredentialsFor,
|
|
13
|
+
deviceCredentialsFor
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=access.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/sandboxes/access.ts"],
|
|
4
|
+
"sourcesContent": ["// Access to Final's Computers and Device APIs. It is configuration of the\n// `computer` and `device` providers (and of workspace Device egress), supplied\n// by whoever runs them, never part of the generic provider context.\n\nexport interface FinalPlatformAccessIface {\n // The API origin; requests go to `<baseUrl>/v1/...`.\n baseUrl: string;\n token: string;\n}\n\n// Computers API access for one project's sandboxes. `refresh` asks for a new\n// token after the API rejected the last one. Null: none granted.\nexport type ComputersAccessIface = (args: {\n organizationId: string;\n projectId: string;\n refresh: boolean;\n}) => Promise<FinalPlatformAccessIface | null>;\n\n// Device API access acting for `actingUserId` (null: service access for\n// workspace networking). Null: none granted.\nexport type DeviceAccessIface = (args: {\n organizationId: string;\n projectId: string | null;\n actingUserId: string | null;\n refresh: boolean;\n}) => Promise<FinalPlatformAccessIface | null>;\n\n// The per-call form the API clients ask before each request.\nexport interface ComputersApiCredentialsIface {\n computersAccess(args?: { refresh?: boolean }): Promise<FinalPlatformAccessIface | null>;\n}\n\nexport interface DeviceApiCredentialsIface {\n deviceAccess(args?: {\n actingUserId?: string | null;\n refresh?: boolean;\n }): Promise<FinalPlatformAccessIface | null>;\n}\n\nexport const computersCredentialsFor = (\n access: ComputersAccessIface | undefined,\n scope: { organizationId: string; projectId: string },\n): ComputersApiCredentialsIface => ({\n computersAccess: async (args) =>\n access == null ? null : access({ ...scope, refresh: args?.refresh === true }),\n});\n\nexport const deviceCredentialsFor = (\n access: DeviceAccessIface | undefined,\n scope: { organizationId: string; projectId: string | null },\n): DeviceApiCredentialsIface => ({\n deviceAccess: async (args) =>\n access == null\n ? null\n : access({\n ...scope,\n actingUserId: args?.actingUserId ?? null,\n refresh: args?.refresh === true,\n }),\n});\n"],
|
|
5
|
+
"mappings": "AAuCO,MAAM,0BAA0B,CACrC,QACA,WACkC;AAAA,EAClC,iBAAiB,OAAO,SACtB,UAAU,OAAO,OAAO,OAAO,EAAE,GAAG,OAAO,SAAS,MAAM,YAAY,KAAK,CAAC;AAChF;AAEO,MAAM,uBAAuB,CAClC,QACA,WAC+B;AAAA,EAC/B,cAAc,OAAO,SACnB,UAAU,OACN,OACA,OAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,MAAM,gBAAgB;AAAA,IACpC,SAAS,MAAM,YAAY;AAAA,EAC7B,CAAC;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
1
|
+
import { NetworkPolicy, type JsonValue } from '@finalai/agent-provider';
|
|
2
|
+
import { SandboxCapability, type NetworkPolicyIface, type NetworkSandboxSessionIface, type SandboxNetworkingExtensionIface, type SandboxProviderIface, type SandboxSetupIface } from '@finalai/agent-provider/sandbox';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import { type ComputersApiConfigIface } from "./computers-api.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { type GuideCommandIface } from "./workspace-setup.mjs";
|
|
7
|
-
export declare const computerWorkspaceName: (options: {
|
|
8
|
-
bindingId: string;
|
|
9
|
-
conversationId: string | null;
|
|
10
|
-
target: string;
|
|
11
|
-
conversationWorkspace: boolean;
|
|
12
|
-
}) => Promise<string>;
|
|
5
|
+
import { type ComputerBuildIface } from "./environment.mjs";
|
|
13
6
|
export type { ComputersApiConfigIface } from "./computers-api.mjs";
|
|
14
|
-
export type { FinalPlatformAccessIface } from
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
17
|
-
export type { ComputerGuideVersionIface } from "./guide.mjs";
|
|
18
|
-
export type { RepositoryCloneSourceIface } from "./workspace-setup.mjs";
|
|
7
|
+
export type { FinalPlatformAccessIface } from "./access.mjs";
|
|
8
|
+
export { COMPUTER_PROVIDER } from "./environment.mjs";
|
|
9
|
+
export declare const WORKSPACE_ROOT = "/workspaces";
|
|
19
10
|
export interface ComputerSandboxLogIface {
|
|
20
11
|
(message: string, fields?: Record<string, string | number | boolean | null>): void;
|
|
21
12
|
}
|
|
22
13
|
export interface ComputerSandboxProviderConfigIface {
|
|
14
|
+
computersApiUrl: string;
|
|
23
15
|
computersApi?: ComputersApiConfigIface;
|
|
24
16
|
networking?: SandboxNetworkingExtensionIface;
|
|
25
17
|
registryCredentialId?: string;
|
|
@@ -30,13 +22,10 @@ export interface ComputerSandboxProviderConfigIface {
|
|
|
30
22
|
memoryMb?: number;
|
|
31
23
|
diskGb?: number;
|
|
32
24
|
};
|
|
33
|
-
idleTimeoutSeconds?: number;
|
|
34
25
|
imageWaitMs?: number;
|
|
35
26
|
imagePollMs?: number;
|
|
36
27
|
buildWaitMs?: number;
|
|
37
28
|
buildPollMs?: number;
|
|
38
|
-
shelveWaitMs?: number;
|
|
39
|
-
shelvePollMs?: number;
|
|
40
29
|
runningWaitMs?: number;
|
|
41
30
|
runningPollMs?: number;
|
|
42
31
|
log?: ComputerSandboxLogIface;
|
|
@@ -64,47 +53,31 @@ declare const computerArtifactSchema: z.ZodObject<{
|
|
|
64
53
|
}, z.core.$strip>], "kind">;
|
|
65
54
|
}, z.core.$strip>;
|
|
66
55
|
declare const computerStateSchema: z.ZodObject<{
|
|
67
|
-
version: z.ZodLiteral<
|
|
68
|
-
computerId: z.ZodString;
|
|
56
|
+
version: z.ZodLiteral<2>;
|
|
69
57
|
computerName: z.ZodString;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
networkPolicySaved: z.
|
|
58
|
+
computerId: z.ZodNullable<z.ZodString>;
|
|
59
|
+
network: z.ZodObject<{
|
|
60
|
+
mode: z.ZodEnum<typeof NetworkPolicy>;
|
|
61
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
ports: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
|
|
64
|
+
networkPolicySaved: z.ZodDefault<z.ZodBoolean>;
|
|
77
65
|
}, z.core.$strip>;
|
|
78
66
|
export type ComputerSandboxArtifact = z.infer<typeof computerArtifactSchema>;
|
|
79
67
|
export type ComputerSandboxState = z.infer<typeof computerStateSchema>;
|
|
80
|
-
export interface ComputerSandboxDescriptionIface {
|
|
81
|
-
provider: 'computer';
|
|
82
|
-
computerId: string;
|
|
83
|
-
computerName: string;
|
|
84
|
-
workspaceRoot: string;
|
|
85
|
-
transport: string;
|
|
86
|
-
guide: {
|
|
87
|
-
slug: string;
|
|
88
|
-
number: number;
|
|
89
|
-
} | null;
|
|
90
|
-
repositories: {
|
|
91
|
-
alias: string;
|
|
92
|
-
path: string;
|
|
93
|
-
repository: string;
|
|
94
|
-
}[];
|
|
95
|
-
services: {
|
|
96
|
-
name: string;
|
|
97
|
-
readyUrl: string | null;
|
|
98
|
-
}[];
|
|
99
|
-
commands: GuideCommandIface[];
|
|
100
|
-
capabilities: SandboxCapability[];
|
|
101
|
-
}
|
|
102
68
|
export interface ComputerSandboxSessionIface extends NetworkSandboxSessionIface {
|
|
103
|
-
describe(): ComputerSandboxDescriptionIface;
|
|
104
69
|
readonly capabilities: readonly SandboxCapability[];
|
|
105
70
|
}
|
|
106
|
-
export type ComputerSandboxProviderIface = SandboxProviderIface<JsonValue,
|
|
71
|
+
export type ComputerSandboxProviderIface = SandboxProviderIface<JsonValue, ComputerSandboxArtifact, ComputerSandboxState, ComputerSandboxSessionIface>;
|
|
107
72
|
export interface ComputerSandboxErrorIface extends Error {
|
|
108
73
|
code: 'artifact_unavailable' | 'computer_gone' | 'computer_not_running' | 'invalid_environment' | 'build_failed';
|
|
109
74
|
}
|
|
75
|
+
export declare const computerNetworkPolicyOf: (setup: SandboxSetupIface | null) => NetworkPolicyIface;
|
|
76
|
+
export declare const computerNameFor: (sandboxId: string) => Promise<string>;
|
|
77
|
+
export declare const computerNeedsBuild: (build: ComputerBuildIface | undefined) => boolean;
|
|
78
|
+
export declare const computeComputerArtifactKey: (inputs: {
|
|
79
|
+
image: string;
|
|
80
|
+
build: ComputerBuildIface | undefined;
|
|
81
|
+
diskGb: number | null;
|
|
82
|
+
}) => Promise<string>;
|
|
110
83
|
export declare const createComputerSandboxProvider: (config: ComputerSandboxProviderConfigIface) => ComputerSandboxProviderIface;
|