@finalai/agent-definition 0.1.2 → 0.1.3
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 +165 -0
- package/README.md +7 -0
- package/dist/compiler-assets/{chunk-TATN3PYK.ts → chunk-2ZRYQO4Q.ts} +4 -4
- package/dist/compiler-assets/{chunk-HGW4YHAY.ts → chunk-3K4C4SVG.ts} +9 -0
- package/dist/compiler-assets/{chunk-JPY4L2UJ.ts → chunk-3YAKMWV4.ts} +7 -7
- package/dist/compiler-assets/{chunk-CWWRTRWW.ts → chunk-4E5HECVD.ts} +1 -1
- package/dist/compiler-assets/{chunk-7QP2CKPI.ts → chunk-4X2DS5BR.ts} +1 -1
- package/dist/compiler-assets/{chunk-ZDLVA6XF.ts → chunk-5IZTHCGZ.ts} +8 -8
- package/dist/compiler-assets/{chunk-2CZRHOLL.ts → chunk-7XUPKRZU.ts} +1 -1
- package/dist/compiler-assets/{chunk-7VSSVZM4.ts → chunk-BEFBCBUL.ts} +4 -4
- package/dist/compiler-assets/{chunk-HFS4KLEL.ts → chunk-D3SB4CCB.ts} +1 -1
- package/dist/compiler-assets/{chunk-EVQIK62B.ts → chunk-FHKYXT3F.ts} +11 -7
- package/dist/compiler-assets/{chunk-HNPUTP35.ts → chunk-GCFSHHH2.ts} +2 -2
- package/dist/compiler-assets/{chunk-MZMSKIKU.ts → chunk-I6U47R5U.ts} +14 -5
- package/dist/compiler-assets/{chunk-5BK6FVRE.ts → chunk-IF6MR7JF.ts} +2 -2
- package/dist/compiler-assets/{chunk-LUSAAV4L.ts → chunk-IZGOMT7K.ts} +2 -2
- package/dist/compiler-assets/{chunk-GTUZOATD.ts → chunk-JGQ2KAN7.ts} +1 -1
- package/dist/compiler-assets/chunk-JXJPBM5W.ts +61 -0
- package/dist/compiler-assets/{chunk-NYTOYKKF.ts → chunk-K6D7ZK74.ts} +3 -3
- package/dist/compiler-assets/{chunk-WMXMVFHM.ts → chunk-K7V4IMOB.ts} +3 -3
- package/dist/compiler-assets/{chunk-VHXHUU7L.ts → chunk-LHMUAIYJ.ts} +1 -1
- package/dist/compiler-assets/{chunk-SKTNMUO7.ts → chunk-MSE7X5YG.ts} +25 -2
- package/dist/compiler-assets/{chunk-OWC6SFFF.ts → chunk-OO67EO5E.ts} +10 -9
- package/dist/compiler-assets/chunk-PFLSBTJA.ts +39 -0
- package/dist/compiler-assets/{chunk-XHKPWT3G.ts → chunk-QJ26GEUM.ts} +1 -1
- package/dist/compiler-assets/chunk-RMIQJHSL.ts +0 -0
- package/dist/compiler-assets/{chunk-BLB6JGLO.ts → chunk-TCKYMNPM.ts} +27 -24
- package/dist/compiler-assets/{chunk-QMWTDPNT.ts → chunk-TJZS457N.ts} +3 -3
- package/dist/compiler-assets/{chunk-JIPNTA56.ts → chunk-TM36NO3C.ts} +1 -1
- package/dist/compiler-assets/{chunk-QMKWAFVZ.ts → chunk-TS7XNNHN.ts} +3 -3
- package/dist/compiler-assets/chunk-ULI5WWRR.ts +40 -0
- package/dist/compiler-assets/chunk-W6DOJA4W.ts +3763 -0
- package/dist/compiler-assets/src/authoring/agent.ts +4 -4
- package/dist/compiler-assets/src/authoring/approval.ts +7 -7
- package/dist/compiler-assets/src/authoring/brand.ts +3 -3
- package/dist/compiler-assets/src/authoring/channels.ts +6 -6
- package/dist/compiler-assets/src/authoring/connections.ts +14 -4
- package/dist/compiler-assets/src/authoring/credentials.ts +7 -6
- package/dist/compiler-assets/src/authoring/dynamic.ts +9 -4
- package/dist/compiler-assets/src/authoring/harness.ts +9 -9
- package/dist/compiler-assets/src/authoring/hooks.ts +10 -8
- package/dist/compiler-assets/src/authoring/index.ts +33 -26
- package/dist/compiler-assets/src/authoring/instructions.ts +10 -5
- package/dist/compiler-assets/src/authoring/sandbox.ts +10 -10
- package/dist/compiler-assets/src/authoring/schedules.ts +4 -4
- package/dist/compiler-assets/src/authoring/skills.ts +4 -4
- package/dist/compiler-assets/src/authoring/tools.ts +10 -8
- package/dist/compiler-assets/src/compatibility.ts +11 -11
- package/dist/compiler-assets/src/hosted-bindings.ts +15 -0
- package/dist/compiler-assets/src/index.ts +50 -41
- package/dist/compiler-assets/src/manifest.ts +4 -4
- package/dist/compiler-assets/src/resolve.ts +5 -5
- package/dist/compiler-assets/src/runtime/bundle.ts +22 -20
- package/dist/compiler-assets/src/runtime/describe.ts +14 -12
- package/dist/compiler-assets/src/runtime/described.ts +16 -11
- package/dist/compiler-assets/src/runtime/isolate.ts +18 -16
- package/dist/compiler-assets/src/runtime/lower.ts +13 -11
- package/dist/compiler-assets/src/runtime/schema-validation.ts +4 -4
- package/dist/compiler-assets/src/runtime/values.ts +2 -2
- package/dist/modules/authoring/connections.d.mts +5 -0
- package/dist/modules/authoring/connections.mjs +36 -0
- package/dist/modules/authoring/connections.mjs.map +2 -2
- package/dist/modules/authoring/context.d.mts +3 -1
- package/dist/modules/authoring/context.mjs.map +2 -2
- package/dist/modules/authoring/dynamic.d.mts +3 -1
- package/dist/modules/authoring/dynamic.mjs +19 -1
- package/dist/modules/authoring/dynamic.mjs.map +2 -2
- package/dist/modules/authoring/hooks.d.mts +2 -1
- package/dist/modules/authoring/hooks.mjs.map +2 -2
- package/dist/modules/authoring/index.d.mts +4 -2
- package/dist/modules/authoring/index.mjs +4 -1
- package/dist/modules/authoring/index.mjs.map +2 -2
- package/dist/modules/authoring/sandbox.d.mts +2 -1
- package/dist/modules/authoring/sandbox.mjs.map +2 -2
- package/dist/modules/compiler/assemble.mjs +5 -0
- package/dist/modules/compiler/assemble.mjs.map +2 -2
- package/dist/modules/compiler/index.d.mts +2 -1
- package/dist/modules/compiler/index.mjs +18 -0
- package/dist/modules/compiler/index.mjs.map +2 -2
- package/dist/modules/compiler/local-isolate.d.mts +2 -1
- package/dist/modules/compiler/local-isolate.mjs +6 -1
- package/dist/modules/compiler/local-isolate.mjs.map +2 -2
- package/dist/modules/hosted-bindings.d.mts +10 -0
- package/dist/modules/hosted-bindings.mjs +36 -0
- package/dist/modules/hosted-bindings.mjs.map +7 -0
- package/dist/modules/index.d.mts +2 -0
- package/dist/modules/index.mjs +2 -0
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/resolve.mjs +4 -0
- package/dist/modules/resolve.mjs.map +2 -2
- package/dist/modules/runtime/describe.mjs +8 -1
- package/dist/modules/runtime/describe.mjs.map +2 -2
- package/dist/modules/runtime/described.d.mts +36 -0
- package/dist/modules/runtime/described.mjs +2 -1
- package/dist/modules/runtime/described.mjs.map +2 -2
- package/dist/modules/runtime/isolate.d.mts +2 -0
- package/dist/modules/runtime/isolate.mjs +7 -4
- package/dist/modules/runtime/isolate.mjs.map +2 -2
- package/dist/modules/runtime/schema-validation.mjs +19 -2
- package/dist/modules/runtime/schema-validation.mjs.map +2 -2
- package/package.json +4 -3
- package/dist/compiler-assets/chunk-GNR7XBPN.ts +0 -3364
- package/dist/compiler-assets/chunk-JNJE72EH.ts +0 -10
- package/dist/compiler-assets/chunk-T6WG4L4M.ts +0 -19
- /package/dist/compiler-assets/{chunk-6WR3PGNF.ts → chunk-CIWWFQHL.ts} +0 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsonSchemaSchema,
|
|
3
|
+
jsonValueSchema
|
|
4
|
+
} from "./chunk-4X2DS5BR.ts";
|
|
1
5
|
import {
|
|
2
6
|
array,
|
|
3
7
|
json,
|
|
@@ -7,7 +11,23 @@ import {
|
|
|
7
11
|
string,
|
|
8
12
|
union,
|
|
9
13
|
unknown
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3K4C4SVG.ts";
|
|
15
|
+
|
|
16
|
+
// ../agent-provider/src/hosted-bindings.ts
|
|
17
|
+
var requireHostedBinding = async (options) => {
|
|
18
|
+
if (options.name.trim().length === 0) throw new Error("Hosted binding name must not be empty");
|
|
19
|
+
if (options.bindings == null)
|
|
20
|
+
throw new Error(`Hosting does not supply bindings required by ${options.name}`);
|
|
21
|
+
const value = await options.bindings.get(options.name);
|
|
22
|
+
if (value == null) throw new Error(`Hosted binding ${options.name} is not configured`);
|
|
23
|
+
const parsed = jsonValueSchema.safeParse(value);
|
|
24
|
+
if (!parsed.success) throw new Error(`Hosted binding ${options.name} is not JSON configuration`);
|
|
25
|
+
return parsed.data;
|
|
26
|
+
};
|
|
27
|
+
var hostedBindingRequirementSchema = object({
|
|
28
|
+
name: string().trim().min(1),
|
|
29
|
+
schema: jsonSchemaSchema
|
|
30
|
+
});
|
|
11
31
|
|
|
12
32
|
// ../agent-provider/src/dynamic.ts
|
|
13
33
|
var DynamicEvent = /* @__PURE__ */ ((DynamicEvent2) => {
|
|
@@ -22,7 +42,8 @@ var dynamicSlotSchema = object({
|
|
|
22
42
|
events: array(nativeEnum(DynamicEvent)).min(1),
|
|
23
43
|
// Final additions so Build can render a slot without resolving it.
|
|
24
44
|
description: string().optional(),
|
|
25
|
-
preview: string().optional()
|
|
45
|
+
preview: string().optional(),
|
|
46
|
+
requiredBindings: array(hostedBindingRequirementSchema).optional()
|
|
26
47
|
})
|
|
27
48
|
});
|
|
28
49
|
var isDynamicSlot = (value) => dynamicSlotSchema.safeParse(value).success;
|
|
@@ -55,6 +76,8 @@ var findDynamicSlots = (value, path = "") => {
|
|
|
55
76
|
var containsDynamicSlot = (value) => findDynamicSlots(value).length > 0;
|
|
56
77
|
|
|
57
78
|
export {
|
|
79
|
+
requireHostedBinding,
|
|
80
|
+
hostedBindingRequirementSchema,
|
|
58
81
|
DynamicEvent,
|
|
59
82
|
dynamicSlotSchema,
|
|
60
83
|
isDynamicSlot,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
jsonObjectSchema,
|
|
3
|
-
jsonSchemaSchema,
|
|
4
|
-
jsonValueSchema
|
|
5
|
-
} from "./chunk-7QP2CKPI.ts";
|
|
6
1
|
import {
|
|
7
2
|
DynamicEvent,
|
|
8
3
|
containsDynamicSlot,
|
|
9
4
|
maybeDynamic
|
|
10
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MSE7X5YG.ts";
|
|
6
|
+
import {
|
|
7
|
+
jsonObjectSchema,
|
|
8
|
+
jsonSchemaSchema,
|
|
9
|
+
jsonValueSchema
|
|
10
|
+
} from "./chunk-4X2DS5BR.ts";
|
|
11
11
|
import {
|
|
12
12
|
array,
|
|
13
13
|
boolean,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
record,
|
|
20
20
|
string,
|
|
21
21
|
union
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-3K4C4SVG.ts";
|
|
23
23
|
|
|
24
24
|
// ../agent-provider/src/provider-ref.ts
|
|
25
25
|
var packageProviderRefSchema = object({
|
|
@@ -45,7 +45,7 @@ var bundleRef = (exportName) => ({
|
|
|
45
45
|
var formatProviderRef = (ref) => ref.kind === "package" /* Package */ ? `package:${ref.specifier}` : `bundle:${ref.export}`;
|
|
46
46
|
|
|
47
47
|
// ../agent-provider/src/manifest.ts
|
|
48
|
-
var MANIFEST_VERSION =
|
|
48
|
+
var MANIFEST_VERSION = 3;
|
|
49
49
|
var BaseCapability = /* @__PURE__ */ ((BaseCapability2) => {
|
|
50
50
|
BaseCapability2["Shell"] = "shell";
|
|
51
51
|
BaseCapability2["Files"] = "files";
|
|
@@ -197,7 +197,8 @@ var harnessBindingSchema = object({
|
|
|
197
197
|
config: maybeDynamic(jsonValueSchema)
|
|
198
198
|
});
|
|
199
199
|
var agentManifestSchema = object({
|
|
200
|
-
|
|
200
|
+
// Read persisted v2 revisions; v3 writers require hosts enforcing hosted bindings.
|
|
201
|
+
version: union([literal(2), literal(MANIFEST_VERSION)]),
|
|
201
202
|
identity: identitySchema,
|
|
202
203
|
harness: harnessBindingSchema,
|
|
203
204
|
mcpServers: maybeDynamic(array(mcpServerBindingSchema)),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateHostedBindingRequirements
|
|
3
|
+
} from "./chunk-ULI5WWRR.ts";
|
|
4
|
+
import {
|
|
5
|
+
stamp
|
|
6
|
+
} from "./chunk-QJ26GEUM.ts";
|
|
7
|
+
|
|
8
|
+
// src/authoring/dynamic.ts
|
|
9
|
+
var defineDynamic = (definition) => {
|
|
10
|
+
const checked = (handler) => {
|
|
11
|
+
if (handler == null || (definition.requiredBindings?.length ?? 0) === 0) return handler;
|
|
12
|
+
return async (event, ctx) => {
|
|
13
|
+
await validateHostedBindingRequirements({
|
|
14
|
+
requirements: definition.requiredBindings ?? [],
|
|
15
|
+
bindings: ctx.bindings
|
|
16
|
+
});
|
|
17
|
+
const result = await handler(event, ctx);
|
|
18
|
+
if (result == null) throw new Error("Required hosted binding resolver returned no value");
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const sentinel = {
|
|
23
|
+
kind: "final:dynamic",
|
|
24
|
+
events: {
|
|
25
|
+
...definition.events,
|
|
26
|
+
"session.started": checked(definition.events["session.started"]),
|
|
27
|
+
"turn.started": checked(definition.events["turn.started"])
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (definition.description != null) sentinel.description = definition.description;
|
|
31
|
+
if (definition.preview != null) sentinel.preview = definition.preview;
|
|
32
|
+
if (definition.provider != null) sentinel.provider = definition.provider;
|
|
33
|
+
if (definition.requiredBindings != null) sentinel.requiredBindings = definition.requiredBindings;
|
|
34
|
+
return stamp(sentinel, "dynamic" /* Dynamic */);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
defineDynamic
|
|
39
|
+
};
|
|
File without changes
|
|
@@ -8,48 +8,48 @@ import {
|
|
|
8
8
|
lowerSkill,
|
|
9
9
|
lowerTool,
|
|
10
10
|
toJson
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5IZTHCGZ.ts";
|
|
12
12
|
import {
|
|
13
13
|
AUTHORED_SERVER_KEY
|
|
14
14
|
} from "./chunk-NMYHO2QN.ts";
|
|
15
15
|
import {
|
|
16
16
|
hookHandlersFor
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TJZS457N.ts";
|
|
18
18
|
import {
|
|
19
19
|
unopenedRequestOf
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4E5HECVD.ts";
|
|
21
21
|
import {
|
|
22
22
|
registerToolName,
|
|
23
23
|
toolLabelSchema
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import {
|
|
26
|
-
validateSchemaValue
|
|
27
|
-
} from "./chunk-GNR7XBPN.ts";
|
|
24
|
+
} from "./chunk-2ZRYQO4Q.ts";
|
|
28
25
|
import {
|
|
29
26
|
lowerApproval
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
mcpServerBindingSchema,
|
|
33
|
-
providerRefSchema
|
|
34
|
-
} from "./chunk-OWC6SFFF.ts";
|
|
27
|
+
} from "./chunk-BEFBCBUL.ts";
|
|
35
28
|
import {
|
|
36
29
|
ConversationKind,
|
|
37
30
|
ParticipantKind
|
|
38
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-IF6MR7JF.ts";
|
|
39
32
|
import {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} from "./chunk-
|
|
33
|
+
mcpServerBindingSchema,
|
|
34
|
+
providerRefSchema
|
|
35
|
+
} from "./chunk-OO67EO5E.ts";
|
|
43
36
|
import {
|
|
44
37
|
TranscriptRole
|
|
45
38
|
} from "./chunk-RWUIMTBI.ts";
|
|
39
|
+
import {
|
|
40
|
+
validateSchemaValue
|
|
41
|
+
} from "./chunk-W6DOJA4W.ts";
|
|
46
42
|
import {
|
|
47
43
|
DynamicEvent
|
|
48
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-MSE7X5YG.ts";
|
|
45
|
+
import {
|
|
46
|
+
jsonObjectSchema,
|
|
47
|
+
jsonValueSchema
|
|
48
|
+
} from "./chunk-4X2DS5BR.ts";
|
|
49
49
|
import {
|
|
50
50
|
authoredKindOf,
|
|
51
51
|
stamp
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-QJ26GEUM.ts";
|
|
53
53
|
import {
|
|
54
54
|
authoredRecordSchema,
|
|
55
55
|
callableSchema,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
isPlainObject,
|
|
62
62
|
messageOf,
|
|
63
63
|
optionalValueSchema
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-TM36NO3C.ts";
|
|
65
65
|
import {
|
|
66
66
|
array,
|
|
67
67
|
boolean,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
number,
|
|
71
71
|
object,
|
|
72
72
|
string
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-3K4C4SVG.ts";
|
|
74
74
|
|
|
75
75
|
// src/runtime/isolate.ts
|
|
76
76
|
var jsonOf = (value, path) => {
|
|
@@ -316,18 +316,20 @@ var createIsolateRuntime = (modules) => {
|
|
|
316
316
|
session: boundary.session,
|
|
317
317
|
messages: boundary.messages,
|
|
318
318
|
channel: boundary.channel,
|
|
319
|
-
secrets: args.secrets
|
|
319
|
+
secrets: args.secrets,
|
|
320
|
+
bindings: args.bindings
|
|
320
321
|
});
|
|
321
322
|
const expected = args.kind === "tool" /* Tool */ ? "tool" /* Tool */ : "connection" /* Connection */;
|
|
322
323
|
return authoredKindOf(result) === expected ? result : fieldOf(result, boundary.name);
|
|
323
324
|
};
|
|
324
325
|
return {
|
|
325
|
-
evaluateApproval: async ({ reference, input, secrets }) => {
|
|
326
|
+
evaluateApproval: async ({ reference, input, secrets, bindings }) => {
|
|
326
327
|
const value = await resolveAuthored({
|
|
327
328
|
exportName: reference.export,
|
|
328
329
|
dynamic: reference.dynamic,
|
|
329
330
|
kind: reference.kind,
|
|
330
|
-
secrets
|
|
331
|
+
secrets,
|
|
332
|
+
bindings
|
|
331
333
|
});
|
|
332
334
|
let policy;
|
|
333
335
|
let validated = input;
|
|
@@ -355,7 +357,8 @@ var createIsolateRuntime = (modules) => {
|
|
|
355
357
|
exportName: args.export,
|
|
356
358
|
dynamic: args.dynamic,
|
|
357
359
|
kind: "tool" /* Tool */,
|
|
358
|
-
secrets: args.ctx.secrets
|
|
360
|
+
secrets: args.ctx.secrets,
|
|
361
|
+
bindings: args.ctx.bindings
|
|
359
362
|
});
|
|
360
363
|
if (args.dynamic != null)
|
|
361
364
|
registerToolName(value, dynamicToolBoundarySchema.parse(args.dynamic).name);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
stamp
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QJ26GEUM.ts";
|
|
4
4
|
import {
|
|
5
5
|
authoredRecordSchema,
|
|
6
6
|
isCallable
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TM36NO3C.ts";
|
|
8
8
|
import {
|
|
9
9
|
looseObject
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3K4C4SVG.ts";
|
|
11
11
|
|
|
12
12
|
// src/authoring/hooks.ts
|
|
13
13
|
var HookEvent = /* @__PURE__ */ ((HookEvent2) => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
harnessDescriptionSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3YAKMWV4.ts";
|
|
4
4
|
import {
|
|
5
5
|
bundleRef
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OO67EO5E.ts";
|
|
7
7
|
import {
|
|
8
8
|
registerPending
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QJ26GEUM.ts";
|
|
10
10
|
|
|
11
11
|
// src/authoring/harness.ts
|
|
12
12
|
var completeHarnessDescription = (authored) => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsonSchemaError
|
|
3
|
+
} from "./chunk-W6DOJA4W.ts";
|
|
4
|
+
import {
|
|
5
|
+
findDynamicSlots,
|
|
6
|
+
requireHostedBinding
|
|
7
|
+
} from "./chunk-MSE7X5YG.ts";
|
|
8
|
+
|
|
9
|
+
// src/hosted-bindings.ts
|
|
10
|
+
var validateHostedBindings = async (options) => {
|
|
11
|
+
await validateHostedBindingRequirements({
|
|
12
|
+
requirements: findDynamicSlots(options.manifest).flatMap(
|
|
13
|
+
({ slot }) => slot.$dynamic.requiredBindings ?? []
|
|
14
|
+
),
|
|
15
|
+
bindings: options.bindings
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var validateHostedBindingRequirements = async (options) => {
|
|
19
|
+
const values = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const requirement of options.requirements) {
|
|
21
|
+
let value = values.get(requirement.name);
|
|
22
|
+
if (value == null) {
|
|
23
|
+
value = await requireHostedBinding({ bindings: options.bindings, name: requirement.name });
|
|
24
|
+
values.set(requirement.name, value);
|
|
25
|
+
}
|
|
26
|
+
let validationError;
|
|
27
|
+
try {
|
|
28
|
+
validationError = jsonSchemaError(requirement.schema, value);
|
|
29
|
+
} catch {
|
|
30
|
+
throw new Error(`Hosted binding ${requirement.name} has an invalid schema`);
|
|
31
|
+
}
|
|
32
|
+
if (validationError != null)
|
|
33
|
+
throw new Error(`Hosted binding ${requirement.name} has invalid configuration`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
validateHostedBindings,
|
|
39
|
+
validateHostedBindingRequirements
|
|
40
|
+
};
|