@constal/sdk 2.4.0 → 3.0.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/package.json +14 -4
- package/publish/api.json +36 -1
- package/publish/index.d.ts +268 -43
- package/publish/index.js +373 -52
package/publish/index.js
CHANGED
|
@@ -311,6 +311,13 @@ function validateJsonSchema(value, schema, path = "$") {
|
|
|
311
311
|
|
|
312
312
|
// src/selector.ts
|
|
313
313
|
var PROTECTED_RESOURCE_LABEL_PREFIX = "constal.ai/";
|
|
314
|
+
var RESOURCE_IDENTITY_LABELS = {
|
|
315
|
+
crn: "constal.ai/crn",
|
|
316
|
+
name: "constal.ai/name",
|
|
317
|
+
namespace: "constal.ai/namespace",
|
|
318
|
+
kind: "constal.ai/kind",
|
|
319
|
+
version: "constal.ai/version"
|
|
320
|
+
};
|
|
314
321
|
var MAX_LABELS = 64;
|
|
315
322
|
var MAX_EXPRESSIONS = 64;
|
|
316
323
|
var MAX_VALUES = 64;
|
|
@@ -387,6 +394,17 @@ function matchesLabelSelector(selector, labels) {
|
|
|
387
394
|
}
|
|
388
395
|
return true;
|
|
389
396
|
}
|
|
397
|
+
function selectableResourceLabels(input) {
|
|
398
|
+
const labels = {
|
|
399
|
+
...resourceLabelMap(input.labels ?? {}, { allowProtected: true }),
|
|
400
|
+
[RESOURCE_IDENTITY_LABELS.crn]: input.crn,
|
|
401
|
+
[RESOURCE_IDENTITY_LABELS.name]: input.name,
|
|
402
|
+
[RESOURCE_IDENTITY_LABELS.namespace]: input.namespace,
|
|
403
|
+
[RESOURCE_IDENTITY_LABELS.kind]: input.kind,
|
|
404
|
+
...input.version === void 0 ? {} : { [RESOURCE_IDENTITY_LABELS.version]: input.version }
|
|
405
|
+
};
|
|
406
|
+
return resourceLabelMap(labels, { allowProtected: true });
|
|
407
|
+
}
|
|
390
408
|
|
|
391
409
|
// src/resources.ts
|
|
392
410
|
var RESOURCE_KINDS = [
|
|
@@ -426,6 +444,71 @@ var PLATFORM_ADDRESS_KINDS = [
|
|
|
426
444
|
];
|
|
427
445
|
var INVOKABLE_KINDS = ["model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
|
|
428
446
|
var POLICY_TARGET_KINDS = [...RESOURCE_KINDS, ...PLATFORM_ADDRESS_KINDS];
|
|
447
|
+
function resolveBindingOwner(scope2, context, required2 = true) {
|
|
448
|
+
bindingOwnerScope(scope2);
|
|
449
|
+
if (!SEGMENT.test(context.environment) || !SEGMENT.test(context.tenant)) throw new TypeError("Binding owner context is invalid");
|
|
450
|
+
for (const kind of ["principal", "customer"]) {
|
|
451
|
+
if (context[kind] === void 0) continue;
|
|
452
|
+
const parts2 = parseResourceName(context[kind]);
|
|
453
|
+
if (parts2.environment !== context.environment || parts2.tenant !== context.tenant || parts2.kind !== kind) {
|
|
454
|
+
throw new TypeError("Binding owner is outside the authenticated context");
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (scope2 === "tenant") return { kind: "tenant", tenant: context.tenant };
|
|
458
|
+
const name = scope2 === "principal" ? context.principal : context.customer;
|
|
459
|
+
if (!name) {
|
|
460
|
+
if (!required2) return null;
|
|
461
|
+
throw new TypeError(`A ${scope2} is required for this binding`);
|
|
462
|
+
}
|
|
463
|
+
const parts = parseResourceName(name);
|
|
464
|
+
if (parts.environment !== context.environment || parts.tenant !== context.tenant || parts.kind !== scope2) {
|
|
465
|
+
throw new TypeError("Binding owner is outside the authenticated context");
|
|
466
|
+
}
|
|
467
|
+
return scope2 === "principal" ? { kind: "principal", principal: name } : { kind: "customer", customer: name };
|
|
468
|
+
}
|
|
469
|
+
function agentSetupRequirements(value, options = {}) {
|
|
470
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > 64) throw new TypeError("Agent setup requirements are invalid");
|
|
471
|
+
const requirements = value.map((raw) => {
|
|
472
|
+
const item = record2(raw);
|
|
473
|
+
if (!item || typeof item.id !== "string" || !NAME2.test(item.id) || typeof item.title !== "string" || !item.title.trim() || item.title.length > 128 || item.description !== void 0 && (typeof item.description !== "string" || item.description.length > 4096) || item.optional !== void 0 && typeof item.optional !== "boolean" || Object.keys(item).some((key) => !["id", "title", "description", "optional", "resourceKind", "selector", "binding"].includes(key))) {
|
|
474
|
+
throw new TypeError("Agent setup requirement is invalid");
|
|
475
|
+
}
|
|
476
|
+
const selection = resourceSelector({ resourceKind: item.resourceKind, selector: item.selector === void 0 ? {} : item.selector }, RESOURCE_KINDS);
|
|
477
|
+
if (item.resourceKind === "credential") {
|
|
478
|
+
const binding = record2(item.binding);
|
|
479
|
+
if (!binding || typeof binding.key !== "string" || !NAME2.test(binding.key) || Object.keys(binding).some((key) => key !== "key" && key !== "owner")) {
|
|
480
|
+
throw new TypeError("Credential setup requires one binding key and an explicit owner scope");
|
|
481
|
+
}
|
|
482
|
+
const owner = binding.owner === void 0 && options.allowLegacyTenantOwner ? "tenant" : binding.owner;
|
|
483
|
+
bindingOwnerScope(owner);
|
|
484
|
+
return { ...item, ...selection, binding: { key: binding.key, owner } };
|
|
485
|
+
} else if (item.binding !== void 0) {
|
|
486
|
+
throw new TypeError("Resource setup requirements use selectors; only Credentials declare binding keys");
|
|
487
|
+
}
|
|
488
|
+
return { ...item, ...selection };
|
|
489
|
+
});
|
|
490
|
+
if (new Set(requirements.map(({ id: id2 }) => id2)).size !== requirements.length) throw new TypeError("Agent setup requirement ids must be unique");
|
|
491
|
+
const credentialKeys = requirements.flatMap((item) => item.resourceKind === "credential" ? [`${item.binding.owner}:${item.binding.key}`] : []);
|
|
492
|
+
if (new Set(credentialKeys).size !== credentialKeys.length) throw new TypeError("Credential setup binding keys must be unique");
|
|
493
|
+
return requirements;
|
|
494
|
+
}
|
|
495
|
+
function agentSetupMetadata(value, options = {}) {
|
|
496
|
+
const source = record2(value);
|
|
497
|
+
if (source && Object.keys(source).length === 1 && source.requirements !== void 0) {
|
|
498
|
+
return { requirements: agentSetupRequirements(source.requirements, options) };
|
|
499
|
+
}
|
|
500
|
+
if (!source || source.protocol !== "constal.setup.v1" || typeof source.agent !== "string" || !NAME2.test(source.agent) || typeof source.session !== "string" || !source.session || source.session.length > 256 || !record2(source.input) || Object.keys(source).some((key) => !["protocol", "agent", "session", "input"].includes(key))) {
|
|
501
|
+
throw new TypeError("Agent setup metadata is invalid");
|
|
502
|
+
}
|
|
503
|
+
return source;
|
|
504
|
+
}
|
|
505
|
+
function channelTarget(value) {
|
|
506
|
+
const target = record2(value);
|
|
507
|
+
if (target?.resourceKind !== "channel") return resourceSelector(value, ["agent"]);
|
|
508
|
+
const subscriptions = record2(target.subscriptions);
|
|
509
|
+
if (!subscriptions || typeof subscriptions.provider !== "string" || !/^[a-z0-9][a-z0-9-]{0,62}$/u.test(subscriptions.provider) || Object.keys(target).some((key) => !["resourceKind", "subscriptions"].includes(key)) || Object.keys(subscriptions).some((key) => key !== "provider")) throw new TypeError("Channel subscription target is invalid");
|
|
510
|
+
return { resourceKind: "channel", subscriptions: { provider: subscriptions.provider } };
|
|
511
|
+
}
|
|
429
512
|
var UI_RESOURCE_BOUNDS = Object.freeze({
|
|
430
513
|
maximumRequestBodyBytes: 1048576,
|
|
431
514
|
maximumResponseBodyBytes: 16777216,
|
|
@@ -579,6 +662,35 @@ function resourceName(parts) {
|
|
|
579
662
|
validateParts(parts);
|
|
580
663
|
return `crn:constal:${parts.environment}:${parts.tenant}:${parts.namespace}:${parts.kind}/${parts.path}`;
|
|
581
664
|
}
|
|
665
|
+
function resourceDependencyRef(value, expectedKinds) {
|
|
666
|
+
if (typeof value === "string") {
|
|
667
|
+
const parts = parseResourceName(value);
|
|
668
|
+
if (!expectedKinds.includes(parts.kind)) throw new TypeError("resource dependency kind is invalid");
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
const candidate = record2(value);
|
|
672
|
+
if (!candidate || candidate.kind !== "local" || typeof candidate.resourceKind !== "string" || !expectedKinds.includes(candidate.resourceKind) || typeof candidate.id !== "string" || candidate.namespace !== void 0 && typeof candidate.namespace !== "string" || Object.keys(candidate).some((key) => !["kind", "resourceKind", "id", "namespace"].includes(key))) {
|
|
673
|
+
throw new TypeError("resource dependency reference is invalid");
|
|
674
|
+
}
|
|
675
|
+
resourceName({
|
|
676
|
+
environment: "local",
|
|
677
|
+
tenant: "local",
|
|
678
|
+
namespace: candidate.namespace ?? "default",
|
|
679
|
+
kind: candidate.resourceKind,
|
|
680
|
+
path: candidate.id
|
|
681
|
+
});
|
|
682
|
+
return candidate;
|
|
683
|
+
}
|
|
684
|
+
function resolveResourceDependencyRef(value, scope2, expectedKinds) {
|
|
685
|
+
const reference = resourceDependencyRef(value, expectedKinds);
|
|
686
|
+
if (typeof reference === "string") return reference;
|
|
687
|
+
return resourceName({
|
|
688
|
+
...scope2,
|
|
689
|
+
namespace: reference.namespace ?? scope2.namespace,
|
|
690
|
+
kind: reference.resourceKind,
|
|
691
|
+
path: reference.id
|
|
692
|
+
});
|
|
693
|
+
}
|
|
582
694
|
function parseResourceName(value) {
|
|
583
695
|
const match = value.match(/^crn:constal:([^:]+):([^:]+):([^:]+):([^/]+)\/(.+)$/u);
|
|
584
696
|
if (!match) throw new TypeError("resource name is invalid");
|
|
@@ -818,7 +930,8 @@ function validateFoldFn(fn) {
|
|
|
818
930
|
if (fn.associative !== true && fn.associative.orderBy !== "partition") throw new TypeError("fold.associative is required");
|
|
819
931
|
return fn;
|
|
820
932
|
}
|
|
821
|
-
function agent(
|
|
933
|
+
function agent(input) {
|
|
934
|
+
const def = { ...input, version: input.version === void 0 ? "current" : input.version };
|
|
822
935
|
validateExecutable(def, "agent");
|
|
823
936
|
requiredString(def.model, "agent.model");
|
|
824
937
|
const mode = def.mode ?? "script";
|
|
@@ -872,10 +985,10 @@ function executable(value, path) {
|
|
|
872
985
|
function channel(definition) {
|
|
873
986
|
executable(definition, "channel");
|
|
874
987
|
executable(definition.protocol, "channel.protocol");
|
|
875
|
-
if (typeof definition.protocol.receive !== "function" || typeof definition.protocol.respond !== "function" || definition.protocol.send !== void 0 && typeof definition.protocol.send !== "function" || definition.protocol.alarm !== void 0 && typeof definition.protocol.alarm !== "function") {
|
|
876
|
-
throw new TypeError("channel.protocol must define receive and respond
|
|
988
|
+
if (typeof definition.protocol.receive !== "function" || typeof definition.protocol.respond !== "function" || definition.protocol.send !== void 0 && typeof definition.protocol.send !== "function" || definition.protocol.alarm !== void 0 && typeof definition.protocol.alarm !== "function" || definition.protocol.authorizeSubscription !== void 0 && typeof definition.protocol.authorizeSubscription !== "function") {
|
|
989
|
+
throw new TypeError("channel.protocol must define receive and respond; optional handlers must be functions");
|
|
877
990
|
}
|
|
878
|
-
|
|
991
|
+
resourceDependencyRef(definition.authProvider, ["auth-provider"]);
|
|
879
992
|
definition.needs?.forEach(resourceNeed);
|
|
880
993
|
const analytics = definition.analytics ?? [];
|
|
881
994
|
analytics.forEach((event) => analyticsEvent(event));
|
|
@@ -1189,6 +1302,108 @@ function setupScreenView(id2 = "setup-screen") {
|
|
|
1189
1302
|
};
|
|
1190
1303
|
}
|
|
1191
1304
|
|
|
1305
|
+
// src/agent-setup.ts
|
|
1306
|
+
function credentialSetupState(requirement, scope2, inventory, binding) {
|
|
1307
|
+
const parsed = agentSetupRequirements([requirement])[0];
|
|
1308
|
+
if (parsed.resourceKind !== "credential") throw new TypeError("Credential setup requires a Credential requirement");
|
|
1309
|
+
const required2 = parsed.optional !== true;
|
|
1310
|
+
const owner = resolveBindingOwner(parsed.binding.owner, scope2, required2);
|
|
1311
|
+
if (!owner) return { status: "missing", required: required2, credential: null, candidates: [] };
|
|
1312
|
+
const candidates = [...new Set(inventory.flatMap((candidate) => {
|
|
1313
|
+
if (candidate.available !== true) return [];
|
|
1314
|
+
try {
|
|
1315
|
+
const parts = parseResourceName(candidate.crn);
|
|
1316
|
+
if (parts.kind !== "credential" || parts.environment !== scope2.environment || parts.tenant !== scope2.tenant) return [];
|
|
1317
|
+
const labels = selectableResourceLabels({
|
|
1318
|
+
crn: candidate.crn,
|
|
1319
|
+
name: parts.path,
|
|
1320
|
+
namespace: parts.namespace,
|
|
1321
|
+
kind: parts.kind,
|
|
1322
|
+
...candidate.labels === void 0 ? {} : { labels: candidate.labels },
|
|
1323
|
+
...candidate.version === void 0 ? {} : { version: candidate.version }
|
|
1324
|
+
});
|
|
1325
|
+
return matchesLabelSelector(parsed.selector, labels) ? [candidate.crn] : [];
|
|
1326
|
+
} catch {
|
|
1327
|
+
return [];
|
|
1328
|
+
}
|
|
1329
|
+
}))].sort();
|
|
1330
|
+
if (!binding) return { status: candidates.length ? "choose" : "missing", required: required2, credential: null, candidates };
|
|
1331
|
+
const revision = binding.revision;
|
|
1332
|
+
if (revision.environment !== scope2.environment || revision.tenant !== scope2.tenant || revision.namespace !== scope2.namespace || revision.targetClass !== "credential" || revision.key !== parsed.binding.key || canonicalJson(revision.owner) !== canonicalJson(owner)) {
|
|
1333
|
+
throw new TypeError("Saved Credential binding does not belong to this setup slot");
|
|
1334
|
+
}
|
|
1335
|
+
const target = parseResourceName(revision.target.crn);
|
|
1336
|
+
if (target.kind !== "credential" || target.environment !== scope2.environment || target.tenant !== scope2.tenant) {
|
|
1337
|
+
throw new TypeError("Saved Credential target is outside this setup slot");
|
|
1338
|
+
}
|
|
1339
|
+
const credential = revision.target.crn;
|
|
1340
|
+
return {
|
|
1341
|
+
status: binding.state === "enabled" && candidates.includes(credential) ? "ready" : "blocked",
|
|
1342
|
+
required: required2,
|
|
1343
|
+
credential,
|
|
1344
|
+
candidates
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// src/ingress.ts
|
|
1349
|
+
var encoder3 = new TextEncoder();
|
|
1350
|
+
function object2(value) {
|
|
1351
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
1352
|
+
}
|
|
1353
|
+
function channelSourceEvidence(value) {
|
|
1354
|
+
const input = object2(value), channel2 = object2(input?.channel), authProvider2 = object2(input?.authProvider);
|
|
1355
|
+
if (!input || !channel2 || !authProvider2 || typeof authProvider2.crn !== "string" || typeof authProvider2.hash !== "string" || !/^[a-f0-9]{64}$/u.test(authProvider2.hash) || typeof channel2.crn !== "string" || typeof channel2.hash !== "string" || !/^[a-f0-9]{64}$/u.test(channel2.hash) || typeof input.id !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/u.test(input.id) || typeof input.requestHash !== "string" || !/^[a-f0-9]{64}$/u.test(input.requestHash)) throw new TypeError("Channel source evidence is invalid");
|
|
1356
|
+
const source = channelIngressSource(input.source), name = parseResourceName(channel2.crn), authentication = parseResourceName(authProvider2.crn);
|
|
1357
|
+
if (name.kind !== "channel" || name.tenant !== "platform" || name.namespace !== "ingress" || name.path !== source.provider || authentication.kind !== "auth-provider" || authentication.environment !== name.environment || authentication.tenant !== name.tenant || authentication.namespace !== name.namespace) {
|
|
1358
|
+
throw new TypeError("Channel source evidence is outside its source");
|
|
1359
|
+
}
|
|
1360
|
+
return { channel: { crn: channel2.crn, hash: channel2.hash }, authProvider: { crn: authProvider2.crn, hash: authProvider2.hash }, source, id: input.id, requestHash: input.requestHash };
|
|
1361
|
+
}
|
|
1362
|
+
function credentialEvidence(value) {
|
|
1363
|
+
const input = object2(value), provider = object2(input?.provider), claims = object2(input?.claims);
|
|
1364
|
+
if (!input || typeof input.credential !== "string" || !provider || typeof provider.crn !== "string" || typeof provider.hash !== "string" || !/^[a-f0-9]{64}$/u.test(provider.hash) || !Number.isSafeInteger(input.version) || Number(input.version) < 1 || input.expiresAt !== null && (!Number.isSafeInteger(input.expiresAt) || Number(input.expiresAt) < 1) || !claims || Object.keys(claims).length > 32 || encoder3.encode(JSON.stringify(claims)).byteLength > 65536 || Object.entries(claims).some(([key, value2]) => !/^[A-Za-z0-9._-]{1,128}$/u.test(key) || !(typeof value2 === "string" && value2.length <= 2048 || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2) || Array.isArray(value2) && value2.length <= 500 && value2.every((item) => typeof item === "string" && item.length <= 256)))) {
|
|
1365
|
+
throw new TypeError("Credential evidence is invalid");
|
|
1366
|
+
}
|
|
1367
|
+
if (parseResourceName(input.credential).kind !== "credential" || parseResourceName(provider.crn).kind !== "credential-provider") {
|
|
1368
|
+
throw new TypeError("Credential evidence identity is invalid");
|
|
1369
|
+
}
|
|
1370
|
+
return {
|
|
1371
|
+
credential: input.credential,
|
|
1372
|
+
provider: { crn: provider.crn, hash: provider.hash },
|
|
1373
|
+
version: Number(input.version),
|
|
1374
|
+
expiresAt: input.expiresAt,
|
|
1375
|
+
claims
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function channelIngressSource(value) {
|
|
1379
|
+
const source = object2(value);
|
|
1380
|
+
if (!source || typeof source.provider !== "string" || !/^[a-z0-9][a-z0-9._-]{0,63}$/u.test(source.provider) || typeof source.key !== "string" || !/^[A-Za-z0-9._:-]{1,256}$/u.test(source.key)) throw new TypeError("Channel ingress source is invalid");
|
|
1381
|
+
return { provider: source.provider, key: source.key };
|
|
1382
|
+
}
|
|
1383
|
+
function channelSubscriptionRequest(value) {
|
|
1384
|
+
const input = object2(value), configuration = object2(input?.configuration);
|
|
1385
|
+
if (!input || !configuration || typeof input.channel !== "string" || typeof input.principal !== "string") throw new TypeError("Channel subscription is invalid");
|
|
1386
|
+
const channel2 = parseResourceName(input.channel), principal = parseResourceName(input.principal);
|
|
1387
|
+
if (channel2.kind !== "channel" || principal.kind !== "principal" || channel2.environment !== principal.environment || channel2.tenant !== principal.tenant) {
|
|
1388
|
+
throw new TypeError("Channel subscription crosses the authenticated tenant");
|
|
1389
|
+
}
|
|
1390
|
+
const credentials = input.credentials ?? [];
|
|
1391
|
+
if (!Array.isArray(credentials) || credentials.length > 32) throw new TypeError("Channel subscription Credentials are invalid");
|
|
1392
|
+
const proofs = credentials.map(credentialEvidence);
|
|
1393
|
+
for (const proof of proofs) {
|
|
1394
|
+
const owner = parseResourceName(proof.credential), provider = parseResourceName(proof.provider.crn);
|
|
1395
|
+
if (owner.tenant !== channel2.tenant || owner.environment !== channel2.environment || provider.environment !== channel2.environment) {
|
|
1396
|
+
throw new TypeError("Channel subscription Credential crosses the authenticated tenant");
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return { source: channelIngressSource(input.source), channel: input.channel, principal: input.principal, configuration, credentials: proofs };
|
|
1400
|
+
}
|
|
1401
|
+
function channelIngressRequest(value) {
|
|
1402
|
+
const input = object2(value), headers = object2(input?.headers);
|
|
1403
|
+
if (!input || !["GET", "POST", "PUT", "PATCH", "DELETE"].includes(String(input.method)) || typeof input.url !== "string" || !input.url || input.url.length > 2048 || !headers || Object.keys(headers).length > 128 || Object.entries(headers).some(([key, value2]) => !/^[a-z0-9-]{1,128}$/u.test(key) || typeof value2 !== "string" || value2.length > 8192) || input.bodyBase64 !== null && (typeof input.bodyBase64 !== "string" || input.bodyBase64.length > 5592408) || encoder3.encode(JSON.stringify(input)).byteLength > 6 * 1024 * 1024) throw new TypeError("Channel ingress request is invalid");
|
|
1404
|
+
return { method: input.method, url: input.url, headers, bodyBase64: input.bodyBase64 };
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1192
1407
|
// src/constal-api.ts
|
|
1193
1408
|
var CONSTAL_API_CAPABILITY = "constal.api";
|
|
1194
1409
|
var CONSTAL_API_VERSION = "1";
|
|
@@ -1210,28 +1425,107 @@ var CONSTAL_API_BOUNDS = {
|
|
|
1210
1425
|
maximumInputBytes: 1048576,
|
|
1211
1426
|
planTtlMs: 15 * 6e4
|
|
1212
1427
|
};
|
|
1428
|
+
var CONSTAL_API_QUERY_KINDS = [
|
|
1429
|
+
...RESOURCE_KINDS,
|
|
1430
|
+
"analytics",
|
|
1431
|
+
"customer",
|
|
1432
|
+
"binding",
|
|
1433
|
+
"session",
|
|
1434
|
+
"run",
|
|
1435
|
+
"deployment",
|
|
1436
|
+
"documentation",
|
|
1437
|
+
"analytics-event",
|
|
1438
|
+
"namespace",
|
|
1439
|
+
"team-member",
|
|
1440
|
+
"team-invite",
|
|
1441
|
+
"api-key",
|
|
1442
|
+
"billing-account",
|
|
1443
|
+
"invoice",
|
|
1444
|
+
"subscription",
|
|
1445
|
+
"resource-contract",
|
|
1446
|
+
"dataset-draft",
|
|
1447
|
+
"dataset-case",
|
|
1448
|
+
"eval-score",
|
|
1449
|
+
"eval-sample",
|
|
1450
|
+
"eval-policy",
|
|
1451
|
+
"eval-suite",
|
|
1452
|
+
"eval-baseline",
|
|
1453
|
+
"eval-schedule",
|
|
1454
|
+
"training-job",
|
|
1455
|
+
"checkpoint",
|
|
1456
|
+
"training-provider",
|
|
1457
|
+
"training-model",
|
|
1458
|
+
"checkpoint-gateway",
|
|
1459
|
+
"credential-provider-package",
|
|
1460
|
+
"credential-consumer",
|
|
1461
|
+
"credential-use",
|
|
1462
|
+
"credential-event",
|
|
1463
|
+
"gateway-package",
|
|
1464
|
+
"rollout",
|
|
1465
|
+
"wait"
|
|
1466
|
+
];
|
|
1467
|
+
var CONSTAL_API_GET_KINDS = CONSTAL_API_QUERY_KINDS;
|
|
1468
|
+
var CONSTAL_API_MODEL_TOOL_DESCRIPTIONS = {
|
|
1469
|
+
query: "Query authorized Constal objects with bounded pagination and evidence. Select the exact lower-case singular kind from the schema enum; never pluralize, recase, or substitute an abstract kind. If context supplies platformToolContract.queryScope, copy it unchanged. Otherwise use only an exact namespace allowed by the delegated Run authority, and tenant scope only for an explicitly tenant-wide request. Use catalog-advertised fields and filters; constrained kinds require their advertised filter. Preserve next and evidence completeness.",
|
|
1470
|
+
get: "Retrieve one exact authorized Constal object or immutable revision. Pass a complete ref unchanged from query, relations, runtime inspection, or a governed receipt; never construct a kind, id, namespace, CRN, hash, or cursor from display text. The schema enum contains every supported addressable kind. For a Run, omit fields for complete diagnosis or request only documented top-level fields, and follow only the returned page cursor."
|
|
1471
|
+
};
|
|
1472
|
+
var CONSTAL_API_GET_CRN_KINDS = [
|
|
1473
|
+
...RESOURCE_KINDS,
|
|
1474
|
+
"analytics",
|
|
1475
|
+
"binding",
|
|
1476
|
+
"session",
|
|
1477
|
+
"run",
|
|
1478
|
+
"deployment"
|
|
1479
|
+
];
|
|
1480
|
+
var CONSTAL_API_OBJECT_REF_CRN_KINDS = [...CONSTAL_API_GET_CRN_KINDS, "customer"];
|
|
1213
1481
|
var boundedNameSchema = { type: "string", minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9._-]{0,127}$" };
|
|
1482
|
+
var namespaceSchema = {
|
|
1483
|
+
type: "string",
|
|
1484
|
+
minLength: 1,
|
|
1485
|
+
maxLength: 128,
|
|
1486
|
+
pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
|
|
1487
|
+
};
|
|
1214
1488
|
var actionSchema = { type: "string", pattern: ACTION_PATTERN.source };
|
|
1215
1489
|
var boundedIdSchema = { type: "string", minLength: 1, maxLength: 256, pattern: "^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$" };
|
|
1216
1490
|
var hashSchema = { type: "string", pattern: "^[a-f0-9]{64}$" };
|
|
1217
1491
|
var stringListSchema = { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } };
|
|
1218
|
-
var scopeSchema = { anyOf: [
|
|
1492
|
+
var scopeSchema = { description: "Use namespace with an exact namespace allowed by the delegated Run authority. Use tenant only for an explicitly tenant-wide request.", anyOf: [
|
|
1219
1493
|
{
|
|
1220
1494
|
type: "object",
|
|
1221
1495
|
required: ["kind", "namespace"],
|
|
1222
1496
|
additionalProperties: false,
|
|
1223
|
-
properties: { kind: { const: "namespace" }, namespace:
|
|
1497
|
+
properties: { kind: { const: "namespace" }, namespace: {
|
|
1498
|
+
...namespaceSchema,
|
|
1499
|
+
description: "Exact authorized namespace. Do not infer it from an object name or repository."
|
|
1500
|
+
} }
|
|
1224
1501
|
},
|
|
1225
1502
|
{ type: "object", required: ["kind"], additionalProperties: false, properties: { kind: { const: "tenant" } } }
|
|
1226
1503
|
] };
|
|
1504
|
+
var crnPattern = (kinds) => `^crn:constal:[a-z0-9][a-z0-9._-]{0,127}:[a-z0-9][a-z0-9._-]{0,127}:[a-z0-9][a-z0-9._-]{0,127}:(?:${kinds.join("|")})/[A-Za-z0-9._~/%-]{1,512}$`;
|
|
1227
1505
|
var objectRefSchema = { type: "object", additionalProperties: false, properties: {
|
|
1228
|
-
kind: {
|
|
1229
|
-
id: { type: "string", maxLength: 512 },
|
|
1230
|
-
crn: {
|
|
1506
|
+
kind: { enum: [...CONSTAL_API_GET_KINDS], description: "Exact lower-case object kind returned by a governed platform result." },
|
|
1507
|
+
id: { type: "string", minLength: 1, maxLength: 512 },
|
|
1508
|
+
crn: { anyOf: [{ type: "null" }, {
|
|
1509
|
+
type: "string",
|
|
1510
|
+
minLength: 1,
|
|
1511
|
+
maxLength: 2048,
|
|
1512
|
+
pattern: crnPattern(CONSTAL_API_OBJECT_REF_CRN_KINDS)
|
|
1513
|
+
}] },
|
|
1231
1514
|
hash: { anyOf: [{ type: "null" }, hashSchema] },
|
|
1232
|
-
namespace: {
|
|
1515
|
+
namespace: {
|
|
1516
|
+
type: ["string", "null"],
|
|
1517
|
+
maxLength: 128,
|
|
1518
|
+
pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
|
|
1519
|
+
},
|
|
1233
1520
|
version: { type: ["string", "null"], maxLength: 128 }
|
|
1234
|
-
} };
|
|
1521
|
+
}, required: ["kind", "id", "namespace"] };
|
|
1522
|
+
var exactGetCrnSchema = {
|
|
1523
|
+
type: "string",
|
|
1524
|
+
minLength: 1,
|
|
1525
|
+
maxLength: 2048,
|
|
1526
|
+
description: "Exact addressable CRN obtained from governed platform evidence.",
|
|
1527
|
+
pattern: crnPattern(CONSTAL_API_GET_CRN_KINDS)
|
|
1528
|
+
};
|
|
1235
1529
|
var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
1236
1530
|
describe: { type: "object", additionalProperties: false, properties: {
|
|
1237
1531
|
domains: stringListSchema,
|
|
@@ -1246,39 +1540,54 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
1246
1540
|
cursor: { type: "string", maxLength: 4096 },
|
|
1247
1541
|
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize }
|
|
1248
1542
|
} },
|
|
1249
|
-
query: {
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
} }
|
|
1268
|
-
} },
|
|
1269
|
-
get: { type: "object", required: ["ref"], additionalProperties: false, properties: {
|
|
1270
|
-
ref: { anyOf: [objectRefSchema, {
|
|
1271
|
-
type: "object",
|
|
1272
|
-
required: ["crn"],
|
|
1273
|
-
additionalProperties: false,
|
|
1274
|
-
properties: { crn: { type: "string", minLength: 1, maxLength: 2048 }, hash: hashSchema }
|
|
1275
|
-
}] },
|
|
1276
|
-
fields: stringListSchema,
|
|
1277
|
-
page: { type: "object", additionalProperties: false, properties: {
|
|
1543
|
+
query: {
|
|
1544
|
+
type: "object",
|
|
1545
|
+
required: ["kind", "scope"],
|
|
1546
|
+
additionalProperties: false,
|
|
1547
|
+
description: "Query one exact catalog kind. Kind ids are lower-case, singular, and must be selected from the enum; abstract names and pluralizations are invalid.",
|
|
1548
|
+
properties: {
|
|
1549
|
+
kind: { enum: [...CONSTAL_API_QUERY_KINDS], description: "Exact queryable kind. Never guess a kind or change its casing." },
|
|
1550
|
+
scope: scopeSchema,
|
|
1551
|
+
filter: { type: "object", description: "Optional catalog-advertised filter expression." },
|
|
1552
|
+
search: { type: "string", maxLength: 512 },
|
|
1553
|
+
order: { type: "array", maxItems: 8, items: {
|
|
1554
|
+
type: "object",
|
|
1555
|
+
required: ["field", "direction"],
|
|
1556
|
+
additionalProperties: false,
|
|
1557
|
+
properties: { field: boundedNameSchema, direction: { enum: ["ascending", "descending"] } }
|
|
1558
|
+
} },
|
|
1559
|
+
fields: stringListSchema,
|
|
1560
|
+
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
|
|
1278
1561
|
cursor: { type: "string", maxLength: 4096 },
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1562
|
+
asOf: { type: "integer", minimum: 0 },
|
|
1563
|
+
range: { type: "object", required: ["start", "end"], additionalProperties: false, properties: {
|
|
1564
|
+
start: { type: "integer", minimum: 0 },
|
|
1565
|
+
end: { type: "integer", minimum: 0 }
|
|
1566
|
+
} }
|
|
1567
|
+
}
|
|
1568
|
+
},
|
|
1569
|
+
get: {
|
|
1570
|
+
type: "object",
|
|
1571
|
+
required: ["ref"],
|
|
1572
|
+
additionalProperties: false,
|
|
1573
|
+
description: "Read one addressable object using a complete ref returned by query, relations, runtime inspection, or a governed receipt. Do not synthesize refs.",
|
|
1574
|
+
properties: {
|
|
1575
|
+
ref: {
|
|
1576
|
+
description: "Copy a complete object ref from governed output, or supply an exact supported CRN.",
|
|
1577
|
+
anyOf: [objectRefSchema, {
|
|
1578
|
+
type: "object",
|
|
1579
|
+
required: ["crn"],
|
|
1580
|
+
additionalProperties: false,
|
|
1581
|
+
properties: { crn: exactGetCrnSchema, hash: hashSchema }
|
|
1582
|
+
}]
|
|
1583
|
+
},
|
|
1584
|
+
fields: stringListSchema,
|
|
1585
|
+
page: { type: "object", additionalProperties: false, properties: {
|
|
1586
|
+
cursor: { type: "string", maxLength: 4096 },
|
|
1587
|
+
limit: { type: "integer", minimum: 1, maximum: 500 }
|
|
1588
|
+
} }
|
|
1589
|
+
}
|
|
1590
|
+
},
|
|
1282
1591
|
relations: { type: "object", required: ["start"], additionalProperties: false, properties: {
|
|
1283
1592
|
start: { anyOf: [objectRefSchema, {
|
|
1284
1593
|
type: "object",
|
|
@@ -1437,12 +1746,12 @@ var MAX_CONSTRAINTS = 64;
|
|
|
1437
1746
|
var MAX_OUTCOME_BYTES = 65536;
|
|
1438
1747
|
var MAX_REASON_BYTES = 1024;
|
|
1439
1748
|
var DENIAL_CODE = /^[a-z][a-z0-9._-]{0,127}$/u;
|
|
1440
|
-
var
|
|
1749
|
+
var encoder4 = new TextEncoder();
|
|
1441
1750
|
function record4(value) {
|
|
1442
1751
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1443
1752
|
}
|
|
1444
1753
|
function requiredString2(value, path, maximum = 1024) {
|
|
1445
|
-
if (typeof value !== "string" || value.length === 0 ||
|
|
1754
|
+
if (typeof value !== "string" || value.length === 0 || encoder4.encode(value).byteLength > maximum) {
|
|
1446
1755
|
throw new TypeError(`${path} must be a bounded non-empty string`);
|
|
1447
1756
|
}
|
|
1448
1757
|
}
|
|
@@ -1525,7 +1834,7 @@ function policyOutcome(value) {
|
|
|
1525
1834
|
exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
|
|
1526
1835
|
validateGrant(value.grant, "Policy grant");
|
|
1527
1836
|
} else throw new TypeError("Policy outcome kind is invalid");
|
|
1528
|
-
if (
|
|
1837
|
+
if (encoder4.encode(canonicalJson(value)).byteLength > MAX_OUTCOME_BYTES) throw new TypeError("Policy outcome is oversized");
|
|
1529
1838
|
return value;
|
|
1530
1839
|
}
|
|
1531
1840
|
|
|
@@ -1738,12 +2047,7 @@ var WEB_SEARCH_ARGUMENT_SCHEMA = {
|
|
|
1738
2047
|
type: "string",
|
|
1739
2048
|
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
|
|
1740
2049
|
description: "Optional earliest publication date in YYYY-MM-DD form."
|
|
1741
|
-
}
|
|
1742
|
-
searchDepth: { type: "string", enum: ["basic", "advanced"], description: "Provider search depth when supported." },
|
|
1743
|
-
includeAnswer: { type: "boolean", description: "Request a provider-synthesized answer when supported." },
|
|
1744
|
-
includeRawContent: { type: "boolean", description: "Include bounded raw source content when supported." },
|
|
1745
|
-
includeImages: { type: "boolean", description: "Include relevant image results when supported." },
|
|
1746
|
-
includeImageDescriptions: { type: "boolean", description: "Include image descriptions when supported." }
|
|
2050
|
+
}
|
|
1747
2051
|
}
|
|
1748
2052
|
};
|
|
1749
2053
|
var webFetch = opTool("web", "get", {
|
|
@@ -3077,8 +3381,11 @@ export {
|
|
|
3077
3381
|
AfterYield,
|
|
3078
3382
|
ApiError,
|
|
3079
3383
|
CONSTAL_API_CAPABILITY,
|
|
3384
|
+
CONSTAL_API_GET_KINDS,
|
|
3385
|
+
CONSTAL_API_MODEL_TOOL_DESCRIPTIONS,
|
|
3080
3386
|
CONSTAL_API_OPERATIONS,
|
|
3081
3387
|
CONSTAL_API_OPERATION_SCHEMAS,
|
|
3388
|
+
CONSTAL_API_QUERY_KINDS,
|
|
3082
3389
|
CONSTAL_API_VERSION,
|
|
3083
3390
|
CommitConflict,
|
|
3084
3391
|
CommitGateRejected,
|
|
@@ -3097,6 +3404,7 @@ export {
|
|
|
3097
3404
|
OutcomeUnknown,
|
|
3098
3405
|
PolicyConstraintFailed,
|
|
3099
3406
|
PolicyDecisionFailed,
|
|
3407
|
+
RESOURCE_KINDS,
|
|
3100
3408
|
ResourceDisabled,
|
|
3101
3409
|
ResourceInvalid,
|
|
3102
3410
|
ResourceUnbound,
|
|
@@ -3115,6 +3423,8 @@ export {
|
|
|
3115
3423
|
actionPattern,
|
|
3116
3424
|
agent,
|
|
3117
3425
|
agentResourceBinding,
|
|
3426
|
+
agentSetupMetadata,
|
|
3427
|
+
agentSetupRequirements,
|
|
3118
3428
|
analyticsEvent,
|
|
3119
3429
|
approximateTokens,
|
|
3120
3430
|
authProvider,
|
|
@@ -3125,11 +3435,17 @@ export {
|
|
|
3125
3435
|
capabilityContractRef,
|
|
3126
3436
|
casTool,
|
|
3127
3437
|
channel,
|
|
3438
|
+
channelIngressRequest,
|
|
3439
|
+
channelIngressSource,
|
|
3440
|
+
channelSourceEvidence,
|
|
3441
|
+
channelSubscriptionRequest,
|
|
3442
|
+
channelTarget,
|
|
3128
3443
|
checkpointArtifactRef,
|
|
3129
3444
|
checkpointDeploymentRequest,
|
|
3130
3445
|
checkpointImportMetadata,
|
|
3131
3446
|
checkpointImportRequest,
|
|
3132
3447
|
codeScorerIR,
|
|
3448
|
+
credentialEvidence,
|
|
3133
3449
|
credentialInteractionAction,
|
|
3134
3450
|
credentialInteractionEvent,
|
|
3135
3451
|
credentialInteractionResult,
|
|
@@ -3139,6 +3455,7 @@ export {
|
|
|
3139
3455
|
credentialProviderName,
|
|
3140
3456
|
credentialProviderSetupMetadata,
|
|
3141
3457
|
credentialRotationDefaults,
|
|
3458
|
+
credentialSetupState,
|
|
3142
3459
|
customerTenantName,
|
|
3143
3460
|
cutBatches,
|
|
3144
3461
|
cutPartitions,
|
|
@@ -3173,9 +3490,12 @@ export {
|
|
|
3173
3490
|
policy,
|
|
3174
3491
|
policyName,
|
|
3175
3492
|
renderTrainingCompletion,
|
|
3493
|
+
resolveBindingOwner,
|
|
3176
3494
|
resolveGatewayEgress,
|
|
3495
|
+
resolveResourceDependencyRef,
|
|
3177
3496
|
resourceContractRef,
|
|
3178
3497
|
resourceCredentialBinding,
|
|
3498
|
+
resourceDependencyRef,
|
|
3179
3499
|
resourceLabelMap,
|
|
3180
3500
|
resourceName,
|
|
3181
3501
|
resourceNeed,
|
|
@@ -3187,6 +3507,7 @@ export {
|
|
|
3187
3507
|
scopedCredentialRef,
|
|
3188
3508
|
scopedResourceRef,
|
|
3189
3509
|
scorerName,
|
|
3510
|
+
selectableResourceLabels,
|
|
3190
3511
|
setupAwait,
|
|
3191
3512
|
setupScreen,
|
|
3192
3513
|
setupScreenView,
|