@tangle-network/agent-provider-tangle 4.4.3 → 4.4.4
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.
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AgentEnvironmentProvider } from "@tangle-network/agent-interface/environment-provider";
|
|
2
|
+
type ProfileValidator = NonNullable<AgentEnvironmentProvider["validateProfile"]>;
|
|
3
|
+
/** The provider's validateProfile: the Sandbox mount check, then any caller-supplied validator. */
|
|
4
|
+
export declare function tangleProfileValidator(supplied?: ProfileValidator): ProfileValidator;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { splitInlineProfileFileMounts, validateDeferredProfileFileMounts } from "@tangle-network/sandbox";
|
|
2
|
+
/**
|
|
3
|
+
* The Sandbox SDK's own create-time check of a profile's inline file mounts, run before any box
|
|
4
|
+
* exists. create() refuses the same input, but only once a caller has already committed to the
|
|
5
|
+
* spawn; a coordinator that checks first can return the refusal to whoever asked for the worker.
|
|
6
|
+
*/
|
|
7
|
+
function profileFileMountIssues(profile) {
|
|
8
|
+
if (typeof profile === "string")
|
|
9
|
+
return [];
|
|
10
|
+
const { deferredFiles } = splitInlineProfileFileMounts(profile);
|
|
11
|
+
if (!deferredFiles.length)
|
|
12
|
+
return [];
|
|
13
|
+
try {
|
|
14
|
+
validateDeferredProfileFileMounts(deferredFiles);
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const detail = error;
|
|
19
|
+
return [{
|
|
20
|
+
level: "error",
|
|
21
|
+
code: typeof detail.code === "string" ? detail.code : "PROFILE_FILE_MOUNT_INVALID",
|
|
22
|
+
message: typeof detail.message === "string" ? detail.message : String(error),
|
|
23
|
+
...(typeof detail.path === "string" ? { path: detail.path } : {}),
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The provider's validateProfile: the Sandbox mount check, then any caller-supplied validator. */
|
|
28
|
+
export function tangleProfileValidator(supplied) {
|
|
29
|
+
return async (profile) => {
|
|
30
|
+
const issues = profileFileMountIssues(profile);
|
|
31
|
+
const result = supplied ? await supplied(profile) : undefined;
|
|
32
|
+
return {
|
|
33
|
+
ok: !issues.some((issue) => issue.level === "error") && (result?.ok ?? true),
|
|
34
|
+
issues: [...issues, ...(result?.issues ?? [])],
|
|
35
|
+
...(result?.normalizedProfile ? { normalizedProfile: result.normalizedProfile } : {}),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
package/dist/tangle-provider.js
CHANGED
|
@@ -3,6 +3,7 @@ import { canonicalCandidateDigest, deepFreeze, harnessTypeSchema } from "@tangle
|
|
|
3
3
|
import { createTangleExactProcessProvider, } from "./exact-process.js";
|
|
4
4
|
import { capabilitiesForClient, defaultTangleSandboxCapabilities, narrowTangleCapabilitiesToBackend, } from "./tangle-capabilities.js";
|
|
5
5
|
import { sandboxInstanceAsEnvironment } from "./tangle-environment.js";
|
|
6
|
+
import { tangleProfileValidator } from "./tangle-profile-validation.js";
|
|
6
7
|
import { confidentialVerifierOption, createTangleWorkspaceBranching, } from "./tangle-workspace-branching.js";
|
|
7
8
|
import { assertCreateInputShape, assertMappedCreateOptions, assertMappedSecretNames, assertNoInlineSecretValues, captureModelCredentials, createRoutingFromProviderOptions, NATIVE_RESUME_CHECKPOINT_METADATA_KEY, sandboxOptionsFromCreateInput, sandboxRestoreFromCheckpoint } from "./tangle-create-options.js";
|
|
8
9
|
import { assertProxySecretAliases, captureProxySecrets, mergeProxySecrets, proxySecretsFromInput, proxySecretCapabilityFromDocument, PROXY_SECRETS_METADATA_KEY, rebindProxySecrets, requireProxySecretCapability } from "./tangle-proxy-secrets.js";
|
|
@@ -322,7 +323,7 @@ export function createTangleProvider(options) {
|
|
|
322
323
|
...(exactProcess ? { exactProcess } : {}),
|
|
323
324
|
...(workspaceBranching === undefined ? {} : { workspaceBranching }),
|
|
324
325
|
capabilities: resolveCapabilities,
|
|
325
|
-
|
|
326
|
+
validateProfile: tangleProfileValidator(options.validateProfile),
|
|
326
327
|
async create(input) {
|
|
327
328
|
const { signal, ...material } = input;
|
|
328
329
|
signal?.throwIfAborted();
|