@inf-monkeys-tech/monkeys 1.1.16 → 1.1.18
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/README.md +20 -0
- package/lib/contracts/action-program-http.d.ts +1021 -0
- package/lib/contracts/action-program-http.d.ts.map +1 -0
- package/lib/contracts/action-program-http.js +42 -0
- package/lib/contracts/action-program-http.js.map +1 -0
- package/lib/contracts/declarative-control-http.d.ts +11365 -18
- package/lib/contracts/declarative-control-http.d.ts.map +1 -1
- package/lib/contracts/declarative-control.d.ts +3263 -1022
- package/lib/contracts/declarative-control.d.ts.map +1 -1
- package/lib/contracts/declarative-control.js +278 -5
- package/lib/contracts/declarative-control.js.map +1 -1
- package/lib/contracts/declarative-publication-job.d.ts +3356 -8
- package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
- package/lib/contracts/index.d.ts +1 -0
- package/lib/contracts/index.d.ts.map +1 -1
- package/lib/contracts/index.js +1 -0
- package/lib/contracts/index.js.map +1 -1
- package/lib/esm/contracts/index.mjs +342 -3
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +689 -29
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +639 -29
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +4088 -3797
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/json-schema/action-program-artifact.schema.json +1226 -0
- package/lib/json-schema/action-program-definition.schema.json +1205 -0
- package/lib/json-schema/index.json +2 -0
- package/lib/json-schema/navigation-release.schema.json +1 -0
- package/lib/json-schema/navigation-runtime-bundle.schema.json +1 -0
- package/lib/json-schema/page-release.schema.json +1 -0
- package/lib/json-schema/page-runtime-bundle.schema.json +2436 -0
- package/lib/json-schema/page.schema.json +941 -0
- package/lib/json-schema/workbench-release.schema.json +1 -0
- package/lib/json-schema/workbench-runtime-bundle.schema.json +1 -0
- package/lib/runtime/action-program-author.d.ts +40 -0
- package/lib/runtime/action-program-author.d.ts.map +1 -0
- package/lib/runtime/action-program-author.js +178 -0
- package/lib/runtime/action-program-author.js.map +1 -0
- package/lib/runtime/declarative-control-compiler.d.ts +9 -1
- package/lib/runtime/declarative-control-compiler.d.ts.map +1 -1
- package/lib/runtime/declarative-control-compiler.js +123 -7
- package/lib/runtime/declarative-control-compiler.js.map +1 -1
- package/lib/runtime/declarative-runtime-contract.d.ts.map +1 -1
- package/lib/runtime/declarative-runtime-contract.js +40 -2
- package/lib/runtime/declarative-runtime-contract.js.map +1 -1
- package/lib/runtime/index.d.ts +1 -0
- package/lib/runtime/index.d.ts.map +1 -1
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/index.js.map +1 -1
- package/lib/schemas/index.d.ts +2216 -1232
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +116 -111
- package/lib/schemas/index.js.map +1 -1
- package/package.json +4 -2
package/lib/esm/index.mjs
CHANGED
|
@@ -7321,7 +7321,7 @@ var require__ = __commonJS({
|
|
|
7321
7321
|
var discriminator_1 = require_discriminator();
|
|
7322
7322
|
var json_schema_2020_12_1 = require_json_schema_2020_12();
|
|
7323
7323
|
var META_SCHEMA_ID = "https://json-schema.org/draft/2020-12/schema";
|
|
7324
|
-
var
|
|
7324
|
+
var Ajv20203 = class extends core_1.default {
|
|
7325
7325
|
constructor(opts = {}) {
|
|
7326
7326
|
super({
|
|
7327
7327
|
...opts,
|
|
@@ -7348,11 +7348,11 @@ var require__ = __commonJS({
|
|
|
7348
7348
|
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
|
|
7349
7349
|
}
|
|
7350
7350
|
};
|
|
7351
|
-
exports.Ajv2020 =
|
|
7352
|
-
module.exports = exports =
|
|
7353
|
-
module.exports.Ajv2020 =
|
|
7351
|
+
exports.Ajv2020 = Ajv20203;
|
|
7352
|
+
module.exports = exports = Ajv20203;
|
|
7353
|
+
module.exports.Ajv2020 = Ajv20203;
|
|
7354
7354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7355
|
-
exports.default =
|
|
7355
|
+
exports.default = Ajv20203;
|
|
7356
7356
|
var validate_1 = require_validate();
|
|
7357
7357
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
7358
7358
|
return validate_1.KeywordCxt;
|
|
@@ -10437,6 +10437,7 @@ var ReleaseDependencyRoleSchema = z15.enum([
|
|
|
10437
10437
|
"view",
|
|
10438
10438
|
"projection",
|
|
10439
10439
|
"action",
|
|
10440
|
+
"action-program",
|
|
10440
10441
|
"token",
|
|
10441
10442
|
"schema",
|
|
10442
10443
|
"compiler",
|
|
@@ -10467,6 +10468,7 @@ var DependencyKindByRole = {
|
|
|
10467
10468
|
view: "view",
|
|
10468
10469
|
projection: "projection",
|
|
10469
10470
|
action: "domain-command",
|
|
10471
|
+
"action-program": "action-program",
|
|
10470
10472
|
token: "design-token",
|
|
10471
10473
|
schema: "schema",
|
|
10472
10474
|
compiler: "compiler",
|
|
@@ -11419,8 +11421,14 @@ var QueryBindingSchema = z15.object({
|
|
|
11419
11421
|
}).strict().superRefine((value, context) => {
|
|
11420
11422
|
if (value.draftRetention) {
|
|
11421
11423
|
const names = value.draftRetention.identityParameters;
|
|
11422
|
-
if (value.execution !== "server" || new Set(names).size !== names.length || names.some(
|
|
11423
|
-
|
|
11424
|
+
if (value.execution !== "server" || new Set(names).size !== names.length || names.some(
|
|
11425
|
+
(name) => !Object.prototype.hasOwnProperty.call(value.parameters, name)
|
|
11426
|
+
)) {
|
|
11427
|
+
context.addIssue({
|
|
11428
|
+
code: "custom",
|
|
11429
|
+
path: ["draftRetention"],
|
|
11430
|
+
message: "Draft retention requires distinct declared Server query identity parameters."
|
|
11431
|
+
});
|
|
11424
11432
|
}
|
|
11425
11433
|
}
|
|
11426
11434
|
if (value.targetProjection) {
|
|
@@ -12114,6 +12122,237 @@ var PageDataSchema = QueryBindingSchema.omit({
|
|
|
12114
12122
|
cursorWindow: PageCursorWindowSchema.optional(),
|
|
12115
12123
|
resultStateBindings: z15.array(PageResultStateBindingSchema).max(32).optional()
|
|
12116
12124
|
}).strict();
|
|
12125
|
+
var ACTION_PROGRAM_ABI = "monkeys.action-program/2";
|
|
12126
|
+
var ActionProgramBudgetsSchema = z15.object({
|
|
12127
|
+
rpcMs: z15.number().int().positive().max(3e4),
|
|
12128
|
+
concurrentCalls: z15.number().int().positive().max(4),
|
|
12129
|
+
calls: z15.number().int().positive().max(128),
|
|
12130
|
+
messageBytes: z15.number().int().positive().max(1048576),
|
|
12131
|
+
activeMs: z15.number().int().positive().max(12e4),
|
|
12132
|
+
formMs: z15.number().int().positive().max(3e5),
|
|
12133
|
+
wallMs: z15.number().int().positive().max(6e5)
|
|
12134
|
+
}).strict();
|
|
12135
|
+
var DEFAULT_ACTION_PROGRAM_BUDGETS = Object.freeze({
|
|
12136
|
+
rpcMs: 3e4,
|
|
12137
|
+
concurrentCalls: 4,
|
|
12138
|
+
calls: 128,
|
|
12139
|
+
messageBytes: 1048576,
|
|
12140
|
+
activeMs: 12e4,
|
|
12141
|
+
formMs: 3e5,
|
|
12142
|
+
wallMs: 6e5
|
|
12143
|
+
});
|
|
12144
|
+
var ProgramSchemaRefSchema = RevisionRefSchema.refine(
|
|
12145
|
+
(ref2) => ref2.kind === "schema",
|
|
12146
|
+
"Expected an exact Schema reference."
|
|
12147
|
+
);
|
|
12148
|
+
var ActionProgramDependencySchema = z15.object({
|
|
12149
|
+
kind: z15.enum(["query", "command"]),
|
|
12150
|
+
revisionRef: RevisionRefSchema,
|
|
12151
|
+
inputSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12152
|
+
resultSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12153
|
+
download: ActionBindingSchema.shape.success.shape.download,
|
|
12154
|
+
// Fixed/identity arguments are injected by the trusted caller, never by guest code.
|
|
12155
|
+
dynamicInputKeys: z15.array(ContractIdentifierSchema).max(128)
|
|
12156
|
+
}).strict().superRefine((value, context) => {
|
|
12157
|
+
const expected = value.kind === "query" ? "domain-query-definition" : "domain-command";
|
|
12158
|
+
if (value.revisionRef.kind !== expected)
|
|
12159
|
+
context.addIssue({
|
|
12160
|
+
code: "custom",
|
|
12161
|
+
path: ["revisionRef", "kind"],
|
|
12162
|
+
message: `Expected ${expected}.`
|
|
12163
|
+
});
|
|
12164
|
+
if (new Set(value.dynamicInputKeys).size !== value.dynamicInputKeys.length)
|
|
12165
|
+
context.addIssue({
|
|
12166
|
+
code: "custom",
|
|
12167
|
+
path: ["dynamicInputKeys"],
|
|
12168
|
+
message: "Dynamic input keys must be unique."
|
|
12169
|
+
});
|
|
12170
|
+
});
|
|
12171
|
+
var ActionProgramDefinitionSchema = z15.object({
|
|
12172
|
+
contract: z15.literal("ActionProgramDefinition"),
|
|
12173
|
+
schemaVersion: z15.literal(1),
|
|
12174
|
+
programId: ContractIdentifierSchema,
|
|
12175
|
+
ownerRepo: ContractIdentifierSchema,
|
|
12176
|
+
tenantScope: TenantScopeSchema,
|
|
12177
|
+
supportedSurface: z15.literal("studio"),
|
|
12178
|
+
inputSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12179
|
+
resultSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12180
|
+
entry: z15.literal("main"),
|
|
12181
|
+
abi: z15.literal(ACTION_PROGRAM_ABI),
|
|
12182
|
+
compiler: z15.string().trim().min(1).max(128),
|
|
12183
|
+
target: z15.literal("browser-worker-es2020"),
|
|
12184
|
+
sourceHash: Sha256Schema,
|
|
12185
|
+
compiledHash: Sha256Schema,
|
|
12186
|
+
sourceMapHash: Sha256Schema,
|
|
12187
|
+
dependencies: z15.array(ActionProgramDependencySchema).max(128),
|
|
12188
|
+
effects: z15.array(
|
|
12189
|
+
z15.enum([
|
|
12190
|
+
"form",
|
|
12191
|
+
"toast",
|
|
12192
|
+
"refresh",
|
|
12193
|
+
"download",
|
|
12194
|
+
"state.get",
|
|
12195
|
+
"state.set"
|
|
12196
|
+
])
|
|
12197
|
+
).max(6),
|
|
12198
|
+
refreshAliases: z15.array(ContractIdentifierSchema).max(128),
|
|
12199
|
+
stateAliases: z15.array(
|
|
12200
|
+
z15.object({
|
|
12201
|
+
alias: ContractIdentifierSchema,
|
|
12202
|
+
schemaRevisionRef: ProgramSchemaRefSchema
|
|
12203
|
+
}).strict()
|
|
12204
|
+
).max(128),
|
|
12205
|
+
budgets: ActionProgramBudgetsSchema
|
|
12206
|
+
}).strict().superRefine((value, context) => {
|
|
12207
|
+
for (const [name, keys] of [
|
|
12208
|
+
[
|
|
12209
|
+
"dependencies",
|
|
12210
|
+
value.dependencies.map((dep) => `${dep.kind}:${dep.revisionRef.id}`)
|
|
12211
|
+
],
|
|
12212
|
+
["effects", value.effects],
|
|
12213
|
+
["refreshAliases", value.refreshAliases],
|
|
12214
|
+
["stateAliases", value.stateAliases.map((entry) => entry.alias)]
|
|
12215
|
+
])
|
|
12216
|
+
if (new Set(keys).size !== keys.length)
|
|
12217
|
+
context.addIssue({
|
|
12218
|
+
code: "custom",
|
|
12219
|
+
path: [name],
|
|
12220
|
+
message: "Program declarations must be unique."
|
|
12221
|
+
});
|
|
12222
|
+
const refs = [
|
|
12223
|
+
value.inputSchemaRevisionRef,
|
|
12224
|
+
value.resultSchemaRevisionRef,
|
|
12225
|
+
...value.dependencies.flatMap((dep) => [
|
|
12226
|
+
dep.revisionRef,
|
|
12227
|
+
dep.inputSchemaRevisionRef,
|
|
12228
|
+
dep.resultSchemaRevisionRef
|
|
12229
|
+
]),
|
|
12230
|
+
...value.stateAliases.map((entry) => entry.schemaRevisionRef)
|
|
12231
|
+
];
|
|
12232
|
+
refs.forEach((ref2, index) => {
|
|
12233
|
+
if (ref2.visibility === "tenant" && ref2.tenantScope && tenantScopeKey(ref2.tenantScope) !== tenantScopeKey(value.tenantScope))
|
|
12234
|
+
context.addIssue({
|
|
12235
|
+
code: "custom",
|
|
12236
|
+
path: ["dependencies"],
|
|
12237
|
+
message: `Cross-tenant program reference ${index}.`
|
|
12238
|
+
});
|
|
12239
|
+
});
|
|
12240
|
+
});
|
|
12241
|
+
var ActionProgramArtifactSchema = z15.object({
|
|
12242
|
+
definition: ActionProgramDefinitionSchema,
|
|
12243
|
+
// Hashes use canonicalContentHash of the exact UTF-8 string, not engine bytecode.
|
|
12244
|
+
javascript: z15.string().min(1).max(262144).refine(
|
|
12245
|
+
(value) => new TextEncoder().encode(value).length <= 262144,
|
|
12246
|
+
"Program exceeds 256 KiB."
|
|
12247
|
+
),
|
|
12248
|
+
sourceMap: z15.string().min(1).max(524288).refine(
|
|
12249
|
+
(value) => new TextEncoder().encode(value).length <= 524288,
|
|
12250
|
+
"Source map exceeds 512 KiB."
|
|
12251
|
+
)
|
|
12252
|
+
}).strict();
|
|
12253
|
+
var ProgramInputSourceSchema = z15.discriminatedUnion("kind", [
|
|
12254
|
+
...BindingSourceSchema.options,
|
|
12255
|
+
ExpressionBindingSourceSchema
|
|
12256
|
+
]);
|
|
12257
|
+
var ProgramBindingShape = {
|
|
12258
|
+
bindingId: ContractIdentifierSchema,
|
|
12259
|
+
inputMapping: z15.record(ContractIdentifierSchema, ProgramInputSourceSchema),
|
|
12260
|
+
dependencyInputs: z15.record(
|
|
12261
|
+
ContractIdentifierSchema,
|
|
12262
|
+
z15.record(ContractIdentifierSchema, ProgramInputSourceSchema)
|
|
12263
|
+
),
|
|
12264
|
+
accessPolicy: AccessPolicySchema,
|
|
12265
|
+
confirmation: I18nTextSchema.optional(),
|
|
12266
|
+
when: PageExpressionSchema.optional(),
|
|
12267
|
+
concurrencyKeyPath: PageValuePathSchema.min(1),
|
|
12268
|
+
refreshAliases: z15.record(
|
|
12269
|
+
ContractIdentifierSchema,
|
|
12270
|
+
z15.array(ContractIdentifierSchema).min(1).max(128)
|
|
12271
|
+
),
|
|
12272
|
+
stateAliases: z15.record(ContractIdentifierSchema, ContractIdentifierSchema)
|
|
12273
|
+
};
|
|
12274
|
+
var PageProgramActionSchema = z15.object({
|
|
12275
|
+
...ProgramBindingShape,
|
|
12276
|
+
program: ContractIdentifierSchema,
|
|
12277
|
+
port: ContractIdentifierSchema
|
|
12278
|
+
}).strict();
|
|
12279
|
+
var ProgramBindingSchema = z15.object({
|
|
12280
|
+
...ProgramBindingShape,
|
|
12281
|
+
source: z15.object({
|
|
12282
|
+
capabilityInstanceId: ContractIdentifierSchema,
|
|
12283
|
+
port: ContractIdentifierSchema
|
|
12284
|
+
}).strict(),
|
|
12285
|
+
sourceIntentSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12286
|
+
programRevisionRef: RevisionRefSchema.refine(
|
|
12287
|
+
(ref2) => ref2.kind === "action-program",
|
|
12288
|
+
"Expected action-program reference."
|
|
12289
|
+
),
|
|
12290
|
+
definition: ActionProgramDefinitionSchema
|
|
12291
|
+
}).strict();
|
|
12292
|
+
function validateProgramBindingTargets(page, context) {
|
|
12293
|
+
const ids = new Set(page.actionBindings.map((binding) => binding.bindingId));
|
|
12294
|
+
const ports = new Set(
|
|
12295
|
+
page.actionBindings.map(
|
|
12296
|
+
(binding) => `${binding.source.capabilityInstanceId}:${binding.source.port}`
|
|
12297
|
+
)
|
|
12298
|
+
);
|
|
12299
|
+
const dataIds = new Set(
|
|
12300
|
+
[...page.ontologyBindings, ...page.queryBindings ?? []].map(
|
|
12301
|
+
(binding) => binding.bindingId
|
|
12302
|
+
)
|
|
12303
|
+
);
|
|
12304
|
+
for (const [index, binding] of (page.programBindings ?? []).entries()) {
|
|
12305
|
+
const issue = (message) => context.addIssue({
|
|
12306
|
+
code: "custom",
|
|
12307
|
+
path: ["programBindings", index],
|
|
12308
|
+
message
|
|
12309
|
+
});
|
|
12310
|
+
const port = `${binding.source.capabilityInstanceId}:${binding.source.port}`;
|
|
12311
|
+
if (ids.has(binding.bindingId) || ports.has(port))
|
|
12312
|
+
issue("Program binding id and event must be exclusive.");
|
|
12313
|
+
ids.add(binding.bindingId);
|
|
12314
|
+
ports.add(port);
|
|
12315
|
+
if (!page.capabilityInstances.some(
|
|
12316
|
+
(instance) => instance.instanceId === binding.source.capabilityInstanceId
|
|
12317
|
+
))
|
|
12318
|
+
issue("Program source instance is missing.");
|
|
12319
|
+
const exactKeys = (keys, expected) => keys.length === expected.length && keys.every((key) => expected.includes(key));
|
|
12320
|
+
if (!exactKeys(
|
|
12321
|
+
Object.keys(binding.refreshAliases),
|
|
12322
|
+
binding.definition.refreshAliases
|
|
12323
|
+
) || Object.values(binding.refreshAliases).some(
|
|
12324
|
+
(targets) => targets.some((target) => !dataIds.has(target))
|
|
12325
|
+
))
|
|
12326
|
+
issue(
|
|
12327
|
+
"Program refresh aliases must resolve exactly to declared data bindings."
|
|
12328
|
+
);
|
|
12329
|
+
if (!exactKeys(
|
|
12330
|
+
Object.keys(binding.stateAliases),
|
|
12331
|
+
binding.definition.stateAliases.map((entry) => entry.alias)
|
|
12332
|
+
))
|
|
12333
|
+
issue("Program state aliases must match its manifest.");
|
|
12334
|
+
for (const entry of binding.definition.stateAliases) {
|
|
12335
|
+
const state = page.stateDefinitions?.find(
|
|
12336
|
+
(state2) => state2.stateId === binding.stateAliases[entry.alias]
|
|
12337
|
+
);
|
|
12338
|
+
if (!state || !exactRevisionRef(state.schemaRevisionRef, entry.schemaRevisionRef))
|
|
12339
|
+
issue("Program state alias has an incompatible Schema.");
|
|
12340
|
+
}
|
|
12341
|
+
const dependencyIds = binding.definition.dependencies.map(
|
|
12342
|
+
(dep) => dep.revisionRef.id
|
|
12343
|
+
);
|
|
12344
|
+
if (!Object.keys(binding.dependencyInputs).every(
|
|
12345
|
+
(key) => dependencyIds.includes(key)
|
|
12346
|
+
))
|
|
12347
|
+
issue("Unknown program dependency input mapping.");
|
|
12348
|
+
for (const dep of binding.definition.dependencies) {
|
|
12349
|
+
if (Object.keys(binding.dependencyInputs[dep.revisionRef.id] ?? {}).some(
|
|
12350
|
+
(key) => dep.dynamicInputKeys.includes(key)
|
|
12351
|
+
))
|
|
12352
|
+
issue("Fixed dependency arguments cannot also be guest-writable.");
|
|
12353
|
+
}
|
|
12354
|
+
}
|
|
12355
|
+
}
|
|
12117
12356
|
var PageActionSchema = ActionBindingSchema.omit({
|
|
12118
12357
|
commandRevisionRef: true,
|
|
12119
12358
|
source: true,
|
|
@@ -12156,6 +12395,7 @@ var PageNodeSchema = z15.lazy(
|
|
|
12156
12395
|
}).strict().optional(),
|
|
12157
12396
|
data: z15.array(PageDataSchema).optional(),
|
|
12158
12397
|
actions: z15.array(PageActionSchema).optional(),
|
|
12398
|
+
programActions: z15.array(PageProgramActionSchema).max(128).optional(),
|
|
12159
12399
|
on: z15.array(PageInteractionSchema).optional(),
|
|
12160
12400
|
effects: z15.array(PageEventEffectSchema).optional(),
|
|
12161
12401
|
eventPayloads: z15.array(
|
|
@@ -12234,6 +12474,7 @@ var PageSchema = z15.object({
|
|
|
12234
12474
|
for (const [field, values, target] of [
|
|
12235
12475
|
["data", node.data ?? [], dataIds],
|
|
12236
12476
|
["actions", node.actions ?? [], actionIds],
|
|
12477
|
+
["programActions", node.programActions ?? [], actionIds],
|
|
12237
12478
|
["on", node.on ?? [], interactionIds]
|
|
12238
12479
|
])
|
|
12239
12480
|
for (const [index, value] of values.entries()) {
|
|
@@ -12287,6 +12528,7 @@ var ResolvedPageSchema = z15.object({
|
|
|
12287
12528
|
ontologyBindings: z15.array(PersistedOntologyBindingSchema),
|
|
12288
12529
|
queryBindings: z15.array(QueryBindingSchema).optional(),
|
|
12289
12530
|
actionBindings: z15.array(ActionBindingSchema),
|
|
12531
|
+
programBindings: z15.array(ProgramBindingSchema).max(128).optional(),
|
|
12290
12532
|
pageAccessPolicy: AccessPolicySchema,
|
|
12291
12533
|
managementAccess: ManagementAccessSchema,
|
|
12292
12534
|
tokenRevisionRefs: z15.array(RevisionRefSchema).min(1),
|
|
@@ -12299,6 +12541,7 @@ var ResolvedPageSchema = z15.object({
|
|
|
12299
12541
|
"restricted"
|
|
12300
12542
|
])
|
|
12301
12543
|
}).strict().superRefine((value, context) => {
|
|
12544
|
+
validateProgramBindingTargets(value, context);
|
|
12302
12545
|
validateDeclaredRouteSurfaces(
|
|
12303
12546
|
value.supportedSurfaces,
|
|
12304
12547
|
value.routeClaims,
|
|
@@ -12656,6 +12899,35 @@ var ResolvedPageSchema = z15.object({
|
|
|
12656
12899
|
)
|
|
12657
12900
|
);
|
|
12658
12901
|
}
|
|
12902
|
+
(value.programBindings ?? []).forEach((binding, index) => {
|
|
12903
|
+
const scopes = scopesForNode(
|
|
12904
|
+
instanceNodes.get(binding.source.capabilityInstanceId)
|
|
12905
|
+
);
|
|
12906
|
+
checkScopedSources(binding.inputMapping, scopes, [
|
|
12907
|
+
"programBindings",
|
|
12908
|
+
index,
|
|
12909
|
+
"inputMapping"
|
|
12910
|
+
]);
|
|
12911
|
+
for (const [id, mapping] of Object.entries(binding.dependencyInputs))
|
|
12912
|
+
checkScopedSources(mapping, scopes, [
|
|
12913
|
+
"programBindings",
|
|
12914
|
+
index,
|
|
12915
|
+
"dependencyInputs",
|
|
12916
|
+
id
|
|
12917
|
+
]);
|
|
12918
|
+
if (binding.when) {
|
|
12919
|
+
const reads = collectPageExpressionReads(binding.when);
|
|
12920
|
+
checkScopedReads(reads, scopes, ["programBindings", index, "when"]);
|
|
12921
|
+
if (reads.some(
|
|
12922
|
+
(read) => read.root === "state" && !stateIds.has(read.path[0])
|
|
12923
|
+
))
|
|
12924
|
+
context.addIssue({
|
|
12925
|
+
code: "custom",
|
|
12926
|
+
path: ["programBindings", index, "when"],
|
|
12927
|
+
message: "Program condition references an unknown Page state."
|
|
12928
|
+
});
|
|
12929
|
+
}
|
|
12930
|
+
});
|
|
12659
12931
|
value.actionBindings.forEach((binding, index) => {
|
|
12660
12932
|
const scopes = scopesForNode(
|
|
12661
12933
|
instanceNodes.get(binding.source.capabilityInstanceId)
|
|
@@ -13236,7 +13508,10 @@ var ResolvedPageSchema = z15.object({
|
|
|
13236
13508
|
const conflictingInteraction = interactionBindings.some(
|
|
13237
13509
|
(candidate) => candidate.source.capabilityInstanceId === sourceId && candidate.source.port === binding.cursorWindow.pageChangePort
|
|
13238
13510
|
);
|
|
13239
|
-
const conflictingAction =
|
|
13511
|
+
const conflictingAction = [
|
|
13512
|
+
...value.actionBindings,
|
|
13513
|
+
...value.programBindings ?? []
|
|
13514
|
+
].some(
|
|
13240
13515
|
(candidate) => candidate.source.capabilityInstanceId === sourceId && candidate.source.port === binding.cursorWindow.pageChangePort
|
|
13241
13516
|
);
|
|
13242
13517
|
if (conflictingInteraction || conflictingAction) {
|
|
@@ -13247,6 +13522,20 @@ var ResolvedPageSchema = z15.object({
|
|
|
13247
13522
|
});
|
|
13248
13523
|
}
|
|
13249
13524
|
});
|
|
13525
|
+
(value.programBindings ?? []).forEach((binding, index) => {
|
|
13526
|
+
validatePageStateSources(binding.inputMapping, [
|
|
13527
|
+
"programBindings",
|
|
13528
|
+
index,
|
|
13529
|
+
"inputMapping"
|
|
13530
|
+
]);
|
|
13531
|
+
for (const [id, mapping] of Object.entries(binding.dependencyInputs))
|
|
13532
|
+
validatePageStateSources(mapping, [
|
|
13533
|
+
"programBindings",
|
|
13534
|
+
index,
|
|
13535
|
+
"dependencyInputs",
|
|
13536
|
+
id
|
|
13537
|
+
]);
|
|
13538
|
+
});
|
|
13250
13539
|
value.actionBindings.forEach((binding, index) => {
|
|
13251
13540
|
if (!instanceIds.has(binding.source.capabilityInstanceId)) {
|
|
13252
13541
|
context.addIssue({
|
|
@@ -14087,6 +14376,7 @@ var CompatiblePageRuntimeBundleSchema = z15.object({
|
|
|
14087
14376
|
ontologyBindings: z15.array(PersistedOntologyBindingSchema),
|
|
14088
14377
|
queryBindings: z15.array(QueryBindingSchema).default([]),
|
|
14089
14378
|
actionBindings: z15.array(ActionBindingSchema),
|
|
14379
|
+
programBindings: z15.array(ProgramBindingSchema).max(128).optional(),
|
|
14090
14380
|
pageAccessPolicy: AccessPolicySchema,
|
|
14091
14381
|
tokenRevisionRefs: z15.array(RevisionRefSchema),
|
|
14092
14382
|
performanceBudgetRef: RevisionRefSchema,
|
|
@@ -14109,6 +14399,7 @@ var CompatiblePageRuntimeBundleSchema = z15.object({
|
|
|
14109
14399
|
message: "Denied capability identities must be unique declared instances."
|
|
14110
14400
|
});
|
|
14111
14401
|
}
|
|
14402
|
+
validateProgramBindingTargets(value, context);
|
|
14112
14403
|
validateRuntimeBundleBase(value, "page-release", context);
|
|
14113
14404
|
value.routeClaims.forEach((claim, index) => {
|
|
14114
14405
|
if (claim.surface !== value.surface) {
|
|
@@ -21390,6 +21681,38 @@ var pageStreamRoutes = {
|
|
|
21390
21681
|
};
|
|
21391
21682
|
var PageStreamControlResultSchema = z30.object({ requestId: z30.string().uuid(), accepted: z30.literal(true) }).strict();
|
|
21392
21683
|
|
|
21684
|
+
// src/contracts/action-program-http.ts
|
|
21685
|
+
import { z as z31 } from "zod";
|
|
21686
|
+
var PrepareActionProgramRequestSchema = z31.object({
|
|
21687
|
+
artifact: ActionProgramArtifactSchema,
|
|
21688
|
+
expectedVersion: z31.number().int().min(0)
|
|
21689
|
+
}).strict();
|
|
21690
|
+
var RegisterActionProgramRequestSchema = PrepareActionProgramRequestSchema.extend({
|
|
21691
|
+
planHash: Sha256Schema,
|
|
21692
|
+
idempotencyKey: ContractIdentifierSchema
|
|
21693
|
+
}).strict();
|
|
21694
|
+
var ReadActionProgramRequestSchema = z31.object({ revisionRef: RevisionRefSchema }).strict();
|
|
21695
|
+
var RuntimeProgramLoadRequestSchema = z31.object({
|
|
21696
|
+
context: DeclarativeRuntimeActionExecuteIntentSchema
|
|
21697
|
+
}).strict();
|
|
21698
|
+
var RuntimeProgramCallRequestSchema = RuntimeProgramLoadRequestSchema.extend({
|
|
21699
|
+
kind: z31.enum(["query", "command"]),
|
|
21700
|
+
dependencyId: ContractIdentifierSchema,
|
|
21701
|
+
args: JsonObjectSchema,
|
|
21702
|
+
stepKey: z31.string().min(1).max(128),
|
|
21703
|
+
recoveryOnly: z31.literal(true).optional()
|
|
21704
|
+
}).strict();
|
|
21705
|
+
var RuntimeProgramLoadResultSchema = z31.object({
|
|
21706
|
+
artifact: ActionProgramArtifactSchema,
|
|
21707
|
+
input: JsonObjectSchema,
|
|
21708
|
+
schemas: z31.array(z31.object({ revisionRef: RevisionRefSchema, document: JsonObjectSchema }).strict()).max(512)
|
|
21709
|
+
}).strict();
|
|
21710
|
+
var RuntimeProgramCallResultSchema = z31.object({ value: JsonObjectSchema }).strict();
|
|
21711
|
+
var RuntimeProgramDownloadResultSchema = z31.discriminatedUnion("kind", [
|
|
21712
|
+
z31.object({ kind: z31.literal("native"), download: DeclarativeNativeDownloadSchema }).strict(),
|
|
21713
|
+
z31.object({ kind: z31.literal("text-artifact"), fileName: z31.string().min(1).max(255), mimeType: z31.enum(["application/json", "text/plain", "text/csv"]), content: z31.string().max(1048576) }).strict()
|
|
21714
|
+
]);
|
|
21715
|
+
|
|
21393
21716
|
// src/schemas/index.ts
|
|
21394
21717
|
var canonicalContractSchemas = {
|
|
21395
21718
|
"aggregate-commit-request": AggregateCommitRequestSchema,
|
|
@@ -21423,6 +21746,8 @@ var canonicalContractSchemas = {
|
|
|
21423
21746
|
"domain-event": DomainEventSchema,
|
|
21424
21747
|
"domain-command": DomainCommandSchema,
|
|
21425
21748
|
"domain-command-definition": DomainCommandDefinitionSchema,
|
|
21749
|
+
"action-program-definition": ActionProgramDefinitionSchema,
|
|
21750
|
+
"action-program-artifact": ActionProgramArtifactSchema,
|
|
21426
21751
|
"data-continuity-envelope": DataContinuityEnvelopeSchema,
|
|
21427
21752
|
"domain-query-definition": DomainQueryDefinitionSchema,
|
|
21428
21753
|
"declarative-control-ontology-definition": DeclarativeControlOntologyDefinitionSchema,
|
|
@@ -23024,6 +23349,17 @@ var pageDependencies = (page, compilerRevisionRef) => [
|
|
|
23024
23349
|
}
|
|
23025
23350
|
] : []
|
|
23026
23351
|
]),
|
|
23352
|
+
...(page.programBindings ?? []).flatMap((binding) => [
|
|
23353
|
+
{
|
|
23354
|
+
role: "action-program",
|
|
23355
|
+
revisionRef: binding.programRevisionRef
|
|
23356
|
+
},
|
|
23357
|
+
{
|
|
23358
|
+
role: "schema",
|
|
23359
|
+
revisionRef: binding.sourceIntentSchemaRevisionRef
|
|
23360
|
+
},
|
|
23361
|
+
...programDependencies(binding.definition)
|
|
23362
|
+
]),
|
|
23027
23363
|
...page.actionBindings.flatMap((binding) => [
|
|
23028
23364
|
{ role: "action", revisionRef: binding.commandRevisionRef },
|
|
23029
23365
|
{
|
|
@@ -23255,6 +23591,7 @@ var resolvePage = (input) => {
|
|
|
23255
23591
|
const capabilityInstances = [];
|
|
23256
23592
|
const queryBindings = [];
|
|
23257
23593
|
const actionBindings = [];
|
|
23594
|
+
const programBindings = [];
|
|
23258
23595
|
const interactionBindings = [];
|
|
23259
23596
|
const nodesById = /* @__PURE__ */ new Map();
|
|
23260
23597
|
const indexNode = (node) => {
|
|
@@ -23467,6 +23804,76 @@ var resolvePage = (input) => {
|
|
|
23467
23804
|
resultSchemaRevisionRef
|
|
23468
23805
|
});
|
|
23469
23806
|
}
|
|
23807
|
+
for (const [index, binding] of (node.programActions ?? []).entries()) {
|
|
23808
|
+
const path = `page.body.${node.id}.programActions[${index}]`;
|
|
23809
|
+
const matches = (input.programRegistry ?? []).filter(
|
|
23810
|
+
(entry) => entry.definition.programId === binding.program
|
|
23811
|
+
);
|
|
23812
|
+
if (matches.length !== 1)
|
|
23813
|
+
throw new DeclarativeControlCompilationError(
|
|
23814
|
+
"DEPENDENCY_MISSING",
|
|
23815
|
+
path,
|
|
23816
|
+
"Expected one exact program registration."
|
|
23817
|
+
);
|
|
23818
|
+
const program = matches[0];
|
|
23819
|
+
const definition = ActionProgramDefinitionSchema.parse(
|
|
23820
|
+
program.definition
|
|
23821
|
+
);
|
|
23822
|
+
assertProgramRegistration(program, page.tenantScope, page.surface, path);
|
|
23823
|
+
const port = registration.outputPorts.find(
|
|
23824
|
+
(candidate) => candidate.name === binding.port
|
|
23825
|
+
);
|
|
23826
|
+
if (!port)
|
|
23827
|
+
throw new DeclarativeControlCompilationError(
|
|
23828
|
+
"PORT_TYPE_MISMATCH",
|
|
23829
|
+
path,
|
|
23830
|
+
"Program source port is not registered."
|
|
23831
|
+
);
|
|
23832
|
+
if ((node.actions ?? []).some((action) => action.port === binding.port) || programBindings.some(
|
|
23833
|
+
(action) => action.source.capabilityInstanceId === node.id && action.source.port === binding.port
|
|
23834
|
+
))
|
|
23835
|
+
throw new DeclarativeControlCompilationError(
|
|
23836
|
+
"CAPABILITY_BINDING_MISMATCH",
|
|
23837
|
+
path,
|
|
23838
|
+
"A program output port must have one exclusive action binding."
|
|
23839
|
+
);
|
|
23840
|
+
for (const dep of definition.dependencies) {
|
|
23841
|
+
const registrations = dep.kind === "query" ? queryRegistrations : commandRegistrations;
|
|
23842
|
+
const actual = registrations.find(
|
|
23843
|
+
(entry) => sameRevisionRef(entry.revisionRef, dep.revisionRef)
|
|
23844
|
+
);
|
|
23845
|
+
if (!actual || canonicalContentHash(actual.definition) !== dep.revisionRef.contentHash || "sensitiveInputPaths" in actual.definition && !!actual.definition.sensitiveInputPaths?.length || "sensitiveResultPaths" in actual.definition && !!actual.definition.sensitiveResultPaths?.length || ("queryId" in actual.definition ? !sameRevisionRef(
|
|
23846
|
+
actual.definition.inputSchemaRevisionRef,
|
|
23847
|
+
dep.inputSchemaRevisionRef
|
|
23848
|
+
) || !sameRevisionRef(
|
|
23849
|
+
actual.definition.resultSchemaRevisionRef,
|
|
23850
|
+
dep.resultSchemaRevisionRef
|
|
23851
|
+
) : actual.definition.inputSchemaRef !== dep.inputSchemaRevisionRef.id || actual.definition.outputSchemaRef !== dep.resultSchemaRevisionRef.id))
|
|
23852
|
+
throw new DeclarativeControlCompilationError(
|
|
23853
|
+
"DEPENDENCY_MISSING",
|
|
23854
|
+
path,
|
|
23855
|
+
"Program capability/schema revision is not registered."
|
|
23856
|
+
);
|
|
23857
|
+
}
|
|
23858
|
+
for (const ref2 of programDependencies(definition).filter((dep) => dep.role === "schema").map((dep) => dep.revisionRef)) {
|
|
23859
|
+
if (!schemaRegistrations.some(
|
|
23860
|
+
(entry) => sameRevisionRef(entry.revisionRef, ref2)
|
|
23861
|
+
))
|
|
23862
|
+
throw new DeclarativeControlCompilationError(
|
|
23863
|
+
"SCHEMA_DEFINITION_MISMATCH",
|
|
23864
|
+
path,
|
|
23865
|
+
"Program requires an exact registered Schema."
|
|
23866
|
+
);
|
|
23867
|
+
}
|
|
23868
|
+
const { program: _program, port: _port, ...rest } = binding;
|
|
23869
|
+
programBindings.push({
|
|
23870
|
+
...rest,
|
|
23871
|
+
source: { capabilityInstanceId: node.id, port: binding.port },
|
|
23872
|
+
sourceIntentSchemaRevisionRef: port.schemaRevisionRef,
|
|
23873
|
+
programRevisionRef: program.definitionRevisionRef,
|
|
23874
|
+
definition
|
|
23875
|
+
});
|
|
23876
|
+
}
|
|
23470
23877
|
for (const [index, binding] of (node.on ?? []).entries()) {
|
|
23471
23878
|
const port = registration.outputPorts.find(
|
|
23472
23879
|
(candidate) => candidate.name === binding.port
|
|
@@ -23552,6 +23959,7 @@ var resolvePage = (input) => {
|
|
|
23552
23959
|
ontologyBindings: [],
|
|
23553
23960
|
...queryBindings.length ? { queryBindings } : {},
|
|
23554
23961
|
actionBindings,
|
|
23962
|
+
...programBindings.length ? { programBindings } : {},
|
|
23555
23963
|
pageAccessPolicy: page.access,
|
|
23556
23964
|
managementAccess: page.managementAccess,
|
|
23557
23965
|
tokenRevisionRefs,
|
|
@@ -24050,27 +24458,47 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
|
|
|
24050
24458
|
);
|
|
24051
24459
|
}
|
|
24052
24460
|
});
|
|
24053
|
-
page.
|
|
24054
|
-
const
|
|
24055
|
-
|
|
24461
|
+
(page.programBindings ?? []).forEach((binding, index) => {
|
|
24462
|
+
const path = `programBindings[${index}]`;
|
|
24463
|
+
const registration = (input.programRegistry ?? []).find(
|
|
24464
|
+
(entry) => sameRevisionRef(entry.definitionRevisionRef, binding.programRevisionRef)
|
|
24056
24465
|
);
|
|
24057
|
-
|
|
24058
|
-
`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`
|
|
24059
|
-
);
|
|
24060
|
-
const port = registration?.outputPorts.find(
|
|
24061
|
-
(candidate) => candidate.name === binding.source.port
|
|
24062
|
-
);
|
|
24063
|
-
if (!port || !sameSchemaContract(
|
|
24064
|
-
port.schemaRevisionRef,
|
|
24065
|
-
binding.sourceIntentSchemaRevisionRef
|
|
24066
|
-
)) {
|
|
24466
|
+
if (!registration || canonicalContentHash(registration.definition) !== canonicalContentHash(binding.definition))
|
|
24067
24467
|
throw new DeclarativeControlCompilationError(
|
|
24068
|
-
"
|
|
24069
|
-
|
|
24070
|
-
"
|
|
24468
|
+
"DEPENDENCY_MISSING",
|
|
24469
|
+
path,
|
|
24470
|
+
"Exact program registration does not match binding."
|
|
24071
24471
|
);
|
|
24072
|
-
|
|
24472
|
+
assertProgramRegistration(
|
|
24473
|
+
registration,
|
|
24474
|
+
page.tenantScope,
|
|
24475
|
+
release.target.surface,
|
|
24476
|
+
path
|
|
24477
|
+
);
|
|
24073
24478
|
});
|
|
24479
|
+
[...page.actionBindings, ...page.programBindings ?? []].forEach(
|
|
24480
|
+
(binding, index) => {
|
|
24481
|
+
const instance = page.capabilityInstances.find(
|
|
24482
|
+
(candidate) => candidate.instanceId === binding.source.capabilityInstanceId
|
|
24483
|
+
);
|
|
24484
|
+
const registration = instance && registrationsByPair.get(
|
|
24485
|
+
`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`
|
|
24486
|
+
);
|
|
24487
|
+
const port = registration?.outputPorts.find(
|
|
24488
|
+
(candidate) => candidate.name === binding.source.port
|
|
24489
|
+
);
|
|
24490
|
+
if (!port || !sameSchemaContract(
|
|
24491
|
+
port.schemaRevisionRef,
|
|
24492
|
+
binding.sourceIntentSchemaRevisionRef
|
|
24493
|
+
)) {
|
|
24494
|
+
throw new DeclarativeControlCompilationError(
|
|
24495
|
+
"PORT_TYPE_MISMATCH",
|
|
24496
|
+
`actionBindings[${index}].sourceIntentSchemaRevisionRef`,
|
|
24497
|
+
"Action source intent does not match the registered capability output port."
|
|
24498
|
+
);
|
|
24499
|
+
}
|
|
24500
|
+
}
|
|
24501
|
+
);
|
|
24074
24502
|
const routeClaims = compileRouteClaims({
|
|
24075
24503
|
claims: page.routeClaims,
|
|
24076
24504
|
routeSpaces: input.routeSpaces,
|
|
@@ -24224,6 +24652,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
|
|
|
24224
24652
|
ontologyBindings: page.ontologyBindings,
|
|
24225
24653
|
queryBindings: page.queryBindings,
|
|
24226
24654
|
actionBindings: page.actionBindings,
|
|
24655
|
+
...page.programBindings?.length ? { programBindings: page.programBindings } : {},
|
|
24227
24656
|
pageAccessPolicy: page.pageAccessPolicy,
|
|
24228
24657
|
tokenRevisionRefs: page.tokenRevisionRefs,
|
|
24229
24658
|
performanceBudgetRef: page.performanceBudgetRef,
|
|
@@ -24538,7 +24967,9 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
24538
24967
|
input.compilerRevisionRef
|
|
24539
24968
|
);
|
|
24540
24969
|
const scope = TenantScopeSchema.parse(navigation.tenantScope);
|
|
24541
|
-
const verifiedKernelPageReferences = [
|
|
24970
|
+
const verifiedKernelPageReferences = [
|
|
24971
|
+
...input.verifiedKernelPageReferences ?? []
|
|
24972
|
+
].map((reference, index) => {
|
|
24542
24973
|
const parsed = RevisionRefSchema.parse(reference);
|
|
24543
24974
|
if (release.target.surface !== "kernel" || parsed.visibility !== "tenant" || !parsed.tenantScope?.teamRef?.id.startsWith("kernel-page.") || parsed.ownerRepo !== "monkeys-server" || !["page", "page-release"].includes(parsed.kind)) {
|
|
24544
24975
|
throw new DeclarativeControlCompilationError(
|
|
@@ -24752,8 +25183,14 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
24752
25183
|
const released = releasedByNodeId.get(node.nodeId);
|
|
24753
25184
|
const unavailable = unavailableByNodeId.get(node.nodeId);
|
|
24754
25185
|
if (!registration && node.targetRef.kind === "page" && (unavailable && sameStableRef(unavailable.stableTargetRef, node.targetRef) || released && sameStableRef(released.stableTargetRef, node.targetRef))) {
|
|
24755
|
-
if (!released || !verifiedKernelPageReferenceKeys.has(
|
|
24756
|
-
|
|
25186
|
+
if (!released || !verifiedKernelPageReferenceKeys.has(
|
|
25187
|
+
revisionRefKey(released.targetRevisionRef)
|
|
25188
|
+
)) {
|
|
25189
|
+
assertTenantCompatible(
|
|
25190
|
+
node.targetRef,
|
|
25191
|
+
scope,
|
|
25192
|
+
`nodes[${index}].targetRef`
|
|
25193
|
+
);
|
|
24757
25194
|
}
|
|
24758
25195
|
if (unavailable?.accessPolicy && !accessPolicyChainImplies(
|
|
24759
25196
|
[...ancestors, node.audience],
|
|
@@ -24782,7 +25219,10 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
24782
25219
|
if (!registration || !released && !(currentPage && unavailable && sameStableRef(unavailable.stableTargetRef, node.targetRef)) || !sameStableRef(
|
|
24783
25220
|
registration.stableTargetRef,
|
|
24784
25221
|
stableFromRevision(registration.targetRevisionRef)
|
|
24785
|
-
) || released && !sameStableRef(
|
|
25222
|
+
) || released && !sameStableRef(
|
|
25223
|
+
registration.stableTargetRef,
|
|
25224
|
+
released.stableTargetRef
|
|
25225
|
+
) || !currentPage && released && !sameRevisionRef(
|
|
24786
25226
|
registration.targetRevisionRef,
|
|
24787
25227
|
released.targetRevisionRef
|
|
24788
25228
|
) || !currentPage && released && registration.kind === "route" && (Boolean(registration.releaseRevisionRef) !== Boolean(released.releaseRevisionRef) || registration.releaseRevisionRef && released.releaseRevisionRef && !sameRevisionRef(
|
|
@@ -25044,6 +25484,33 @@ var resolveWorkbenchEntry = (input) => {
|
|
|
25044
25484
|
};
|
|
25045
25485
|
return { status: "forbidden", workbenchId: "" };
|
|
25046
25486
|
};
|
|
25487
|
+
var programDependencies = (definition) => [
|
|
25488
|
+
...[
|
|
25489
|
+
definition.inputSchemaRevisionRef,
|
|
25490
|
+
definition.resultSchemaRevisionRef,
|
|
25491
|
+
...definition.stateAliases.map((entry) => entry.schemaRevisionRef)
|
|
25492
|
+
].map((revisionRef) => ({ role: "schema", revisionRef })),
|
|
25493
|
+
...definition.dependencies.flatMap((dep) => [
|
|
25494
|
+
{
|
|
25495
|
+
role: dep.kind === "query" ? "query-definition" : "action",
|
|
25496
|
+
revisionRef: dep.revisionRef
|
|
25497
|
+
},
|
|
25498
|
+
{ role: "schema", revisionRef: dep.inputSchemaRevisionRef },
|
|
25499
|
+
{ role: "schema", revisionRef: dep.resultSchemaRevisionRef }
|
|
25500
|
+
])
|
|
25501
|
+
];
|
|
25502
|
+
function assertProgramRegistration(registration, scope, surface, path = "program") {
|
|
25503
|
+
const definition = ActionProgramDefinitionSchema.parse(
|
|
25504
|
+
registration.definition
|
|
25505
|
+
);
|
|
25506
|
+
const ref2 = RevisionRefSchema.parse(registration.definitionRevisionRef);
|
|
25507
|
+
if (ref2.kind !== "action-program" || ref2.id !== definition.programId || ref2.ownerRepo !== definition.ownerRepo || ref2.visibility !== "tenant" || canonicalContentHash(ref2.tenantScope) !== canonicalContentHash(scope) || canonicalContentHash(definition.tenantScope) !== canonicalContentHash(scope) || ref2.schemaVersion !== definition.schemaVersion || ref2.contentHash !== canonicalContentHash(definition) || definition.supportedSurface !== surface)
|
|
25508
|
+
throw new DeclarativeControlCompilationError(
|
|
25509
|
+
"CROSS_TENANT_REFERENCE",
|
|
25510
|
+
path,
|
|
25511
|
+
"Program identity, scope, surface or content hash does not match its exact reference."
|
|
25512
|
+
);
|
|
25513
|
+
}
|
|
25047
25514
|
|
|
25048
25515
|
// src/runtime/navigation-availability.ts
|
|
25049
25516
|
var NAVIGATION_UNAVAILABLE_CAPABILITY_HEADER = "x-monkeys-navigation-capabilities";
|
|
@@ -26163,6 +26630,19 @@ var assertDeclarativeCapabilityContract = (entry, request) => {
|
|
|
26163
26630
|
throw new TypeError("The historical capability snapshot is not supported by the current runtime contract.");
|
|
26164
26631
|
}
|
|
26165
26632
|
};
|
|
26633
|
+
var schemasCannotOverlap = (left, right) => {
|
|
26634
|
+
if (left === false || right === false) return true;
|
|
26635
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object" || Array.isArray(left) || Array.isArray(right)) return false;
|
|
26636
|
+
const a = left;
|
|
26637
|
+
const b = right;
|
|
26638
|
+
if (a.$ref || b.$ref) return false;
|
|
26639
|
+
const values = (schema2) => Object.prototype.hasOwnProperty.call(schema2, "const") ? [schema2.const] : Array.isArray(schema2.enum) ? schema2.enum : void 0;
|
|
26640
|
+
const av = values(a), bv = values(b);
|
|
26641
|
+
if (av && bv && av.every((value) => !bv.some((other) => canonicalContentHash(value) === canonicalContentHash(other)))) return true;
|
|
26642
|
+
if (a.type !== "object" || b.type !== "object") return false;
|
|
26643
|
+
const property = (schema2, key) => schema2.properties?.[key] ?? (schema2.patternProperties ? true : schema2.additionalProperties ?? true);
|
|
26644
|
+
return [...a.required ?? [], ...b.required ?? []].some((key) => schemasCannotOverlap(property(a, key), property(b, key)));
|
|
26645
|
+
};
|
|
26166
26646
|
var acceptsPreviousSchema = (previous, next) => {
|
|
26167
26647
|
if (canonicalContentHash(previous) === canonicalContentHash(next) || next === true) return true;
|
|
26168
26648
|
if (previous === false) return true;
|
|
@@ -26170,11 +26650,17 @@ var acceptsPreviousSchema = (previous, next) => {
|
|
|
26170
26650
|
const withoutAnnotations = (schema2) => Object.fromEntries(Object.entries(schema2).filter(([key]) => !["title", "description", "examples", "$comment"].includes(key)));
|
|
26171
26651
|
const before = withoutAnnotations(previous);
|
|
26172
26652
|
const after = withoutAnnotations(next);
|
|
26653
|
+
const branches = (schema2) => Object.keys(schema2).length === 1 ? Array.isArray(schema2.anyOf) ? schema2.anyOf : Array.isArray(schema2.oneOf) ? schema2.oneOf : void 0 : void 0;
|
|
26654
|
+
const oldBranches = branches(before);
|
|
26655
|
+
if (oldBranches) return oldBranches.every((branch) => acceptsPreviousSchema(branch, next));
|
|
26656
|
+
const newBranches = branches(after);
|
|
26657
|
+
if (newBranches) return newBranches.some((branch, index) => acceptsPreviousSchema(previous, branch) && (!after.oneOf || newBranches.every((other, otherIndex) => index === otherIndex || schemasCannotOverlap(previous, other))));
|
|
26173
26658
|
const {
|
|
26174
26659
|
properties: oldProperties,
|
|
26175
26660
|
required: oldRequired,
|
|
26176
26661
|
additionalProperties: oldAdditional,
|
|
26177
26662
|
enum: oldEnum,
|
|
26663
|
+
items: oldItems,
|
|
26178
26664
|
...oldFixed
|
|
26179
26665
|
} = before;
|
|
26180
26666
|
const {
|
|
@@ -26182,9 +26668,11 @@ var acceptsPreviousSchema = (previous, next) => {
|
|
|
26182
26668
|
required: newRequired,
|
|
26183
26669
|
additionalProperties: newAdditional,
|
|
26184
26670
|
enum: newEnum,
|
|
26671
|
+
items: newItems,
|
|
26185
26672
|
...newFixed
|
|
26186
26673
|
} = after;
|
|
26187
26674
|
if (canonicalContentHash(oldFixed) !== canonicalContentHash(newFixed)) return false;
|
|
26675
|
+
if (!acceptsPreviousSchema(oldItems ?? true, newItems ?? true)) return false;
|
|
26188
26676
|
if (newEnum && (!oldEnum || oldEnum.some((value) => !newEnum.some((candidate) => canonicalContentHash(candidate) === canonicalContentHash(value))))) return false;
|
|
26189
26677
|
if ((newRequired ?? []).some((key) => !(oldRequired ?? []).includes(key))) return false;
|
|
26190
26678
|
const oldExtra = oldAdditional ?? true;
|
|
@@ -27140,7 +27628,159 @@ function applyPageStreamEvent(state, input) {
|
|
|
27140
27628
|
error: frame.type === "error" ? frame.payload : void 0
|
|
27141
27629
|
};
|
|
27142
27630
|
}
|
|
27631
|
+
|
|
27632
|
+
// src/runtime/action-program-author.ts
|
|
27633
|
+
var import__2 = __toESM(require__());
|
|
27634
|
+
function programSchemaType(schema2, path = "$", depth = 0) {
|
|
27635
|
+
if (depth > 32 || !schema2 || typeof schema2 !== "object" || Array.isArray(schema2))
|
|
27636
|
+
throw new Error(`Unsupported schema at ${path}`);
|
|
27637
|
+
const value = schema2;
|
|
27638
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
27639
|
+
"$schema",
|
|
27640
|
+
"$id",
|
|
27641
|
+
"title",
|
|
27642
|
+
"description",
|
|
27643
|
+
"type",
|
|
27644
|
+
"properties",
|
|
27645
|
+
"required",
|
|
27646
|
+
"additionalProperties",
|
|
27647
|
+
"items",
|
|
27648
|
+
"enum",
|
|
27649
|
+
"const",
|
|
27650
|
+
"anyOf",
|
|
27651
|
+
"oneOf",
|
|
27652
|
+
"minLength",
|
|
27653
|
+
"maxLength",
|
|
27654
|
+
"pattern",
|
|
27655
|
+
"format",
|
|
27656
|
+
"minimum",
|
|
27657
|
+
"maximum",
|
|
27658
|
+
"exclusiveMinimum",
|
|
27659
|
+
"exclusiveMaximum",
|
|
27660
|
+
"multipleOf",
|
|
27661
|
+
"minItems",
|
|
27662
|
+
"maxItems",
|
|
27663
|
+
"uniqueItems",
|
|
27664
|
+
"minProperties",
|
|
27665
|
+
"maxProperties",
|
|
27666
|
+
"default",
|
|
27667
|
+
"examples",
|
|
27668
|
+
"readOnly",
|
|
27669
|
+
"writeOnly"
|
|
27670
|
+
]);
|
|
27671
|
+
for (const key of Object.keys(value))
|
|
27672
|
+
if (!allowed.has(key))
|
|
27673
|
+
throw new Error(`Unsupported schema keyword ${path}.${key}`);
|
|
27674
|
+
const child = (schema3, key) => programSchemaType(schema3, `${path}.${key}`, depth + 1);
|
|
27675
|
+
const literal = (input) => {
|
|
27676
|
+
if (input !== null && !["string", "number", "boolean"].includes(typeof input))
|
|
27677
|
+
throw new Error(`Unsupported literal at ${path}`);
|
|
27678
|
+
return JSON.stringify(input);
|
|
27679
|
+
};
|
|
27680
|
+
if ("const" in value) return literal(value.const);
|
|
27681
|
+
if (Array.isArray(value.enum) && value.enum.length)
|
|
27682
|
+
return value.enum.map(literal).join(" | ");
|
|
27683
|
+
if (Array.isArray(value.anyOf) || Array.isArray(value.oneOf))
|
|
27684
|
+
return (value.anyOf ?? value.oneOf).map((schema3, i) => `(${child(schema3, String(i))})`).join(" | ") || "never";
|
|
27685
|
+
if (Array.isArray(value.type))
|
|
27686
|
+
return value.type.map((type) => child({ ...value, type }, String(type))).join(" | ");
|
|
27687
|
+
switch (value.type) {
|
|
27688
|
+
case "null":
|
|
27689
|
+
return "null";
|
|
27690
|
+
case "boolean":
|
|
27691
|
+
return "boolean";
|
|
27692
|
+
case "string":
|
|
27693
|
+
return "string";
|
|
27694
|
+
case "number":
|
|
27695
|
+
case "integer":
|
|
27696
|
+
return "number";
|
|
27697
|
+
case "array":
|
|
27698
|
+
return `Array<${child(value.items, "items")}>`;
|
|
27699
|
+
case "object": {
|
|
27700
|
+
const properties = value.properties ?? {};
|
|
27701
|
+
if (typeof properties !== "object" || !properties || Array.isArray(properties))
|
|
27702
|
+
throw new Error(`Invalid properties at ${path}`);
|
|
27703
|
+
const required = value.required ?? [];
|
|
27704
|
+
if (!Array.isArray(required) || required.some(
|
|
27705
|
+
(key) => typeof key !== "string" || !Object.prototype.hasOwnProperty.call(properties, key)
|
|
27706
|
+
))
|
|
27707
|
+
throw new Error(`Unsupported required keys at ${path}`);
|
|
27708
|
+
const fields = Object.entries(properties).map(
|
|
27709
|
+
([key, schema3]) => `${JSON.stringify(key)}${required.includes(key) ? "" : "?"}: ${child(schema3, key)};`
|
|
27710
|
+
);
|
|
27711
|
+
if (value.additionalProperties !== false) {
|
|
27712
|
+
if (value.additionalProperties !== void 0 && value.additionalProperties !== true)
|
|
27713
|
+
throw new Error(`Unsupported additionalProperties at ${path}`);
|
|
27714
|
+
fields.push("[key: string]: unknown;");
|
|
27715
|
+
}
|
|
27716
|
+
return `{ ${fields.join(" ")} }`;
|
|
27717
|
+
}
|
|
27718
|
+
default:
|
|
27719
|
+
throw new Error(`Schema needs a supported explicit type at ${path}`);
|
|
27720
|
+
}
|
|
27721
|
+
}
|
|
27722
|
+
function generateActionProgramTypes(definition, schemas) {
|
|
27723
|
+
const resolve = (ref2) => {
|
|
27724
|
+
const matches = schemas.filter(
|
|
27725
|
+
(entry) => sameRevisionRef(entry.definitionRevisionRef, ref2)
|
|
27726
|
+
);
|
|
27727
|
+
if (matches.length !== 1 || canonicalContentHash(matches[0].definition) !== ref2.contentHash)
|
|
27728
|
+
throw new Error(`Missing exact Schema ${ref2.id}`);
|
|
27729
|
+
return programSchemaType(matches[0].definition.document);
|
|
27730
|
+
};
|
|
27731
|
+
const formRefs = new Map(
|
|
27732
|
+
[
|
|
27733
|
+
definition.inputSchemaRevisionRef,
|
|
27734
|
+
definition.resultSchemaRevisionRef,
|
|
27735
|
+
...definition.dependencies.flatMap((dep) => [
|
|
27736
|
+
dep.inputSchemaRevisionRef,
|
|
27737
|
+
dep.resultSchemaRevisionRef
|
|
27738
|
+
])
|
|
27739
|
+
].map((ref2) => [ref2.id, ref2])
|
|
27740
|
+
);
|
|
27741
|
+
for (const ref2 of [
|
|
27742
|
+
definition.inputSchemaRevisionRef,
|
|
27743
|
+
definition.resultSchemaRevisionRef,
|
|
27744
|
+
...definition.dependencies.flatMap((dep) => [
|
|
27745
|
+
dep.inputSchemaRevisionRef,
|
|
27746
|
+
dep.resultSchemaRevisionRef
|
|
27747
|
+
])
|
|
27748
|
+
]) {
|
|
27749
|
+
if (!sameRevisionRef(formRefs.get(ref2.id), ref2))
|
|
27750
|
+
throw new Error("Ambiguous form Schema revision " + ref2.id);
|
|
27751
|
+
}
|
|
27752
|
+
const forms = "{" + [...formRefs].map(([id, ref2]) => JSON.stringify(id) + ": " + resolve(ref2) + ";").join(" ") + "}";
|
|
27753
|
+
const states = "{" + definition.stateAliases.map(
|
|
27754
|
+
(entry) => JSON.stringify(entry.alias) + ": " + resolve(entry.schemaRevisionRef) + ";"
|
|
27755
|
+
).join(" ") + "}";
|
|
27756
|
+
const refresh = definition.refreshAliases.map((alias) => JSON.stringify(alias)).join(" | ") || "never";
|
|
27757
|
+
const capabilityMap = (kind) => `{
|
|
27758
|
+
${definition.dependencies.filter((dep) => dep.kind === kind).map(
|
|
27759
|
+
(dep) => `${JSON.stringify(dep.revisionRef.id)}: {input: ${"Pick<" + resolve(dep.inputSchemaRevisionRef) + ", " + (dep.dynamicInputKeys.map((key) => JSON.stringify(key)).join(" | ") || "never") + ">"}; result: ${resolve(dep.resultSchemaRevisionRef)}};`
|
|
27760
|
+
).join("\n")}
|
|
27761
|
+
}`;
|
|
27762
|
+
return `// Generated from exact program/schema revisions. Do not edit.
|
|
27763
|
+
import type { ActionProgramContext } from "@inf-monkeys-tech/monkeys";
|
|
27764
|
+
export type Input = ${resolve(definition.inputSchemaRevisionRef)};
|
|
27765
|
+
export type Result = ${resolve(definition.resultSchemaRevisionRef)};
|
|
27766
|
+
export type Queries = ${capabilityMap("query")};
|
|
27767
|
+
export type Commands = ${capabilityMap("command")};
|
|
27768
|
+
export type BaseContext = ActionProgramContext<Queries, Commands, ${forms}, ${states}, ${refresh}>;
|
|
27769
|
+
export type Context = Omit<BaseContext, "ui" | "state"> & {ui: Pick<BaseContext["ui"], ${definition.effects.filter((effect) => !effect.startsWith("state.")).map((effect) => JSON.stringify(effect)).join(" | ") || "never"}>; state: Pick<BaseContext["state"], ${definition.effects.filter((effect) => effect.startsWith("state.")).map((effect) => JSON.stringify(effect.slice(6))).join(" | ") || "never"}>};
|
|
27770
|
+
export type Program = (context: Context, input: Input) => Promise<Result>;
|
|
27771
|
+
`;
|
|
27772
|
+
}
|
|
27773
|
+
function compileProgramValueValidator(schema2, documents = []) {
|
|
27774
|
+
const ajv2 = new import__2.default({ strict: false, allErrors: false, coerceTypes: false, removeAdditional: false, useDefaults: false });
|
|
27775
|
+
const ids = /* @__PURE__ */ new Set();
|
|
27776
|
+
for (const document of documents) if (typeof document.$id === "string" && document.$id !== schema2.$id && !ids.has(document.$id)) {
|
|
27777
|
+
ajv2.addSchema(document);
|
|
27778
|
+
ids.add(document.$id);
|
|
27779
|
+
}
|
|
27780
|
+
return ajv2.compile(schema2);
|
|
27781
|
+
}
|
|
27143
27782
|
export {
|
|
27783
|
+
ACTION_PROGRAM_ABI,
|
|
27144
27784
|
AGENT_MODE_CAPABILITIES,
|
|
27145
27785
|
AGENT_SESSION_CAPABILITY_EVIDENCE,
|
|
27146
27786
|
AGENT_SESSION_COMMAND_POLICIES,
|
|
@@ -27148,6 +27788,10 @@ export {
|
|
|
27148
27788
|
APPLICATION_HANDOFF_QUERY_PARAMETER,
|
|
27149
27789
|
AccessPolicySchema,
|
|
27150
27790
|
ActionBindingSchema,
|
|
27791
|
+
ActionProgramArtifactSchema,
|
|
27792
|
+
ActionProgramBudgetsSchema,
|
|
27793
|
+
ActionProgramDefinitionSchema,
|
|
27794
|
+
ActionProgramDependencySchema,
|
|
27151
27795
|
ActionResultBindingEffectSchema,
|
|
27152
27796
|
ActionResultBindingEffectSourceSchema,
|
|
27153
27797
|
ActionResultClipboardEffectSchema,
|
|
@@ -27287,6 +27931,7 @@ export {
|
|
|
27287
27931
|
DECLARATIVE_CONTROL_ONTOLOGY_DEFINITIONS,
|
|
27288
27932
|
DECLARATIVE_CONTROL_SCHEMA_VERSION,
|
|
27289
27933
|
DECLARATIVE_MIGRATION_ERROR_CODES,
|
|
27934
|
+
DEFAULT_ACTION_PROGRAM_BUDGETS,
|
|
27290
27935
|
DEFAULT_AGENT_WORKBENCH_SIDEBAR_SECTIONS,
|
|
27291
27936
|
DEFAULT_CONDUCTOR_OWNER_EMAIL,
|
|
27292
27937
|
DataContinuityEnvelopeSchema,
|
|
@@ -27513,6 +28158,7 @@ export {
|
|
|
27513
28158
|
PageNavigationProjectionSchema,
|
|
27514
28159
|
PageNodeSchema,
|
|
27515
28160
|
PageOperatorSchema,
|
|
28161
|
+
PageProgramActionSchema,
|
|
27516
28162
|
PagePropertyBindingSchema,
|
|
27517
28163
|
PageReleaseSchema,
|
|
27518
28164
|
PageRendererProjectionSchema,
|
|
@@ -27541,6 +28187,7 @@ export {
|
|
|
27541
28187
|
PermissionBundleSchema,
|
|
27542
28188
|
PermissionDefinitionSchema,
|
|
27543
28189
|
PersistedOntologyBindingSchema,
|
|
28190
|
+
PrepareActionProgramRequestSchema,
|
|
27544
28191
|
ProductAccessDeclarationSchema,
|
|
27545
28192
|
ProductBodySchema,
|
|
27546
28193
|
ProductContextSchema,
|
|
@@ -27548,6 +28195,7 @@ export {
|
|
|
27548
28195
|
ProductDeclarativeAuthoringCatalogSchema,
|
|
27549
28196
|
ProductDeclarativeCapabilityRegistrationSchema,
|
|
27550
28197
|
ProductSurfaceSchema,
|
|
28198
|
+
ProgramBindingSchema,
|
|
27551
28199
|
ProjectionSpecSchema,
|
|
27552
28200
|
PublicationPlanOperationSchema,
|
|
27553
28201
|
PublicationPlanSchema,
|
|
@@ -27568,6 +28216,7 @@ export {
|
|
|
27568
28216
|
RadarScoreProjectionSchema,
|
|
27569
28217
|
RadarSelectionSchema,
|
|
27570
28218
|
RadarWritebackRecordSchema,
|
|
28219
|
+
ReadActionProgramRequestSchema,
|
|
27571
28220
|
ReadablePageRuntimeBundleSchema,
|
|
27572
28221
|
RecordEditorDraftOperationSchema,
|
|
27573
28222
|
RecordEditorDraftSchema,
|
|
@@ -27576,6 +28225,7 @@ export {
|
|
|
27576
28225
|
RecordEditorSubmissionSnapshotSchema,
|
|
27577
28226
|
RecordEditorValidationDetailsSchema,
|
|
27578
28227
|
ReferenceVisibilitySchema,
|
|
28228
|
+
RegisterActionProgramRequestSchema,
|
|
27579
28229
|
RegisteredServiceDomainQueryDataSourceSchema,
|
|
27580
28230
|
ReleaseDependencyRoleSchema,
|
|
27581
28231
|
ReleaseDependencySchema,
|
|
@@ -27606,6 +28256,11 @@ export {
|
|
|
27606
28256
|
RoutePathTemplateSchema,
|
|
27607
28257
|
RouteSpaceParameterSchema,
|
|
27608
28258
|
RouteSpaceSchema,
|
|
28259
|
+
RuntimeProgramCallRequestSchema,
|
|
28260
|
+
RuntimeProgramCallResultSchema,
|
|
28261
|
+
RuntimeProgramDownloadResultSchema,
|
|
28262
|
+
RuntimeProgramLoadRequestSchema,
|
|
28263
|
+
RuntimeProgramLoadResultSchema,
|
|
27609
28264
|
SavedRadarQuerySchema,
|
|
27610
28265
|
SchemaDefinitionSchema,
|
|
27611
28266
|
ScopedIdentityRefSchema,
|
|
@@ -27705,6 +28360,7 @@ export {
|
|
|
27705
28360
|
assertDeclarativeCapabilityContract,
|
|
27706
28361
|
assertMonkeysThemeTokensComplete,
|
|
27707
28362
|
assertPageValueBudget,
|
|
28363
|
+
assertProgramRegistration,
|
|
27708
28364
|
assertThemeTokensDocumentStructure,
|
|
27709
28365
|
assertViewProviderContract,
|
|
27710
28366
|
buildApplicationHandoffUrl,
|
|
@@ -27732,6 +28388,7 @@ export {
|
|
|
27732
28388
|
compileProductAccessDeclaration,
|
|
27733
28389
|
compileProductDeclaration,
|
|
27734
28390
|
compileProductRuntimeCatalog,
|
|
28391
|
+
compileProgramValueValidator,
|
|
27735
28392
|
compileRenderTree,
|
|
27736
28393
|
compileRouteClaims,
|
|
27737
28394
|
compileTargetRenderModelValidator,
|
|
@@ -27765,6 +28422,7 @@ export {
|
|
|
27765
28422
|
evaluatePageExpression,
|
|
27766
28423
|
extractOpenApiCapabilityManifests,
|
|
27767
28424
|
findUnsupportedAgentSessionCapabilities,
|
|
28425
|
+
generateActionProgramTypes,
|
|
27768
28426
|
getAgentModeCapabilities,
|
|
27769
28427
|
getAgentSessionCommandPolicy,
|
|
27770
28428
|
getAgentSessionRuntimeCapabilities,
|
|
@@ -27786,6 +28444,8 @@ export {
|
|
|
27786
28444
|
parseExactProductDeclarativeCapabilityRegistration,
|
|
27787
28445
|
parseWorkflowColumnBinding,
|
|
27788
28446
|
permissionAlternativePolicyAllows,
|
|
28447
|
+
programDependencies,
|
|
28448
|
+
programSchemaType,
|
|
27789
28449
|
projectAgentSessionEvents,
|
|
27790
28450
|
projectCurrentNavigationPages,
|
|
27791
28451
|
projectNavigationCompatibility,
|