@constal/sdk 2.5.0 → 3.0.1
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/package.json +19 -6
- package/publish/api.json +31 -1
- package/publish/index.d.ts +257 -42
- package/publish/index.js +340 -51
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,
|
|
@@ -847,7 +930,8 @@ function validateFoldFn(fn) {
|
|
|
847
930
|
if (fn.associative !== true && fn.associative.orderBy !== "partition") throw new TypeError("fold.associative is required");
|
|
848
931
|
return fn;
|
|
849
932
|
}
|
|
850
|
-
function agent(
|
|
933
|
+
function agent(input) {
|
|
934
|
+
const def = { ...input, version: input.version === void 0 ? "current" : input.version };
|
|
851
935
|
validateExecutable(def, "agent");
|
|
852
936
|
requiredString(def.model, "agent.model");
|
|
853
937
|
const mode = def.mode ?? "script";
|
|
@@ -901,8 +985,8 @@ function executable(value, path) {
|
|
|
901
985
|
function channel(definition) {
|
|
902
986
|
executable(definition, "channel");
|
|
903
987
|
executable(definition.protocol, "channel.protocol");
|
|
904
|
-
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") {
|
|
905
|
-
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");
|
|
906
990
|
}
|
|
907
991
|
resourceDependencyRef(definition.authProvider, ["auth-provider"]);
|
|
908
992
|
definition.needs?.forEach(resourceNeed);
|
|
@@ -1218,6 +1302,108 @@ function setupScreenView(id2 = "setup-screen") {
|
|
|
1218
1302
|
};
|
|
1219
1303
|
}
|
|
1220
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
|
+
|
|
1221
1407
|
// src/constal-api.ts
|
|
1222
1408
|
var CONSTAL_API_CAPABILITY = "constal.api";
|
|
1223
1409
|
var CONSTAL_API_VERSION = "1";
|
|
@@ -1239,28 +1425,107 @@ var CONSTAL_API_BOUNDS = {
|
|
|
1239
1425
|
maximumInputBytes: 1048576,
|
|
1240
1426
|
planTtlMs: 15 * 6e4
|
|
1241
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"];
|
|
1242
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
|
+
};
|
|
1243
1488
|
var actionSchema = { type: "string", pattern: ACTION_PATTERN.source };
|
|
1244
1489
|
var boundedIdSchema = { type: "string", minLength: 1, maxLength: 256, pattern: "^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$" };
|
|
1245
1490
|
var hashSchema = { type: "string", pattern: "^[a-f0-9]{64}$" };
|
|
1246
1491
|
var stringListSchema = { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } };
|
|
1247
|
-
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: [
|
|
1248
1493
|
{
|
|
1249
1494
|
type: "object",
|
|
1250
1495
|
required: ["kind", "namespace"],
|
|
1251
1496
|
additionalProperties: false,
|
|
1252
|
-
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
|
+
} }
|
|
1253
1501
|
},
|
|
1254
1502
|
{ type: "object", required: ["kind"], additionalProperties: false, properties: { kind: { const: "tenant" } } }
|
|
1255
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}$`;
|
|
1256
1505
|
var objectRefSchema = { type: "object", additionalProperties: false, properties: {
|
|
1257
|
-
kind: {
|
|
1258
|
-
id: { type: "string", maxLength: 512 },
|
|
1259
|
-
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
|
+
}] },
|
|
1260
1514
|
hash: { anyOf: [{ type: "null" }, hashSchema] },
|
|
1261
|
-
namespace: {
|
|
1515
|
+
namespace: {
|
|
1516
|
+
type: ["string", "null"],
|
|
1517
|
+
maxLength: 128,
|
|
1518
|
+
pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
|
|
1519
|
+
},
|
|
1262
1520
|
version: { type: ["string", "null"], maxLength: 128 }
|
|
1263
|
-
} };
|
|
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
|
+
};
|
|
1264
1529
|
var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
1265
1530
|
describe: { type: "object", additionalProperties: false, properties: {
|
|
1266
1531
|
domains: stringListSchema,
|
|
@@ -1275,39 +1540,54 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
1275
1540
|
cursor: { type: "string", maxLength: 4096 },
|
|
1276
1541
|
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize }
|
|
1277
1542
|
} },
|
|
1278
|
-
query: {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
} }
|
|
1297
|
-
} },
|
|
1298
|
-
get: { type: "object", required: ["ref"], additionalProperties: false, properties: {
|
|
1299
|
-
ref: { anyOf: [objectRefSchema, {
|
|
1300
|
-
type: "object",
|
|
1301
|
-
required: ["crn"],
|
|
1302
|
-
additionalProperties: false,
|
|
1303
|
-
properties: { crn: { type: "string", minLength: 1, maxLength: 2048 }, hash: hashSchema }
|
|
1304
|
-
}] },
|
|
1305
|
-
fields: stringListSchema,
|
|
1306
|
-
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 },
|
|
1307
1561
|
cursor: { type: "string", maxLength: 4096 },
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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
|
+
},
|
|
1311
1591
|
relations: { type: "object", required: ["start"], additionalProperties: false, properties: {
|
|
1312
1592
|
start: { anyOf: [objectRefSchema, {
|
|
1313
1593
|
type: "object",
|
|
@@ -1466,12 +1746,12 @@ var MAX_CONSTRAINTS = 64;
|
|
|
1466
1746
|
var MAX_OUTCOME_BYTES = 65536;
|
|
1467
1747
|
var MAX_REASON_BYTES = 1024;
|
|
1468
1748
|
var DENIAL_CODE = /^[a-z][a-z0-9._-]{0,127}$/u;
|
|
1469
|
-
var
|
|
1749
|
+
var encoder4 = new TextEncoder();
|
|
1470
1750
|
function record4(value) {
|
|
1471
1751
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1472
1752
|
}
|
|
1473
1753
|
function requiredString2(value, path, maximum = 1024) {
|
|
1474
|
-
if (typeof value !== "string" || value.length === 0 ||
|
|
1754
|
+
if (typeof value !== "string" || value.length === 0 || encoder4.encode(value).byteLength > maximum) {
|
|
1475
1755
|
throw new TypeError(`${path} must be a bounded non-empty string`);
|
|
1476
1756
|
}
|
|
1477
1757
|
}
|
|
@@ -1554,7 +1834,7 @@ function policyOutcome(value) {
|
|
|
1554
1834
|
exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
|
|
1555
1835
|
validateGrant(value.grant, "Policy grant");
|
|
1556
1836
|
} else throw new TypeError("Policy outcome kind is invalid");
|
|
1557
|
-
if (
|
|
1837
|
+
if (encoder4.encode(canonicalJson(value)).byteLength > MAX_OUTCOME_BYTES) throw new TypeError("Policy outcome is oversized");
|
|
1558
1838
|
return value;
|
|
1559
1839
|
}
|
|
1560
1840
|
|
|
@@ -1767,12 +2047,7 @@ var WEB_SEARCH_ARGUMENT_SCHEMA = {
|
|
|
1767
2047
|
type: "string",
|
|
1768
2048
|
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
|
|
1769
2049
|
description: "Optional earliest publication date in YYYY-MM-DD form."
|
|
1770
|
-
}
|
|
1771
|
-
searchDepth: { type: "string", enum: ["basic", "advanced"], description: "Provider search depth when supported." },
|
|
1772
|
-
includeAnswer: { type: "boolean", description: "Request a provider-synthesized answer when supported." },
|
|
1773
|
-
includeRawContent: { type: "boolean", description: "Include bounded raw source content when supported." },
|
|
1774
|
-
includeImages: { type: "boolean", description: "Include relevant image results when supported." },
|
|
1775
|
-
includeImageDescriptions: { type: "boolean", description: "Include image descriptions when supported." }
|
|
2050
|
+
}
|
|
1776
2051
|
}
|
|
1777
2052
|
};
|
|
1778
2053
|
var webFetch = opTool("web", "get", {
|
|
@@ -3106,8 +3381,11 @@ export {
|
|
|
3106
3381
|
AfterYield,
|
|
3107
3382
|
ApiError,
|
|
3108
3383
|
CONSTAL_API_CAPABILITY,
|
|
3384
|
+
CONSTAL_API_GET_KINDS,
|
|
3385
|
+
CONSTAL_API_MODEL_TOOL_DESCRIPTIONS,
|
|
3109
3386
|
CONSTAL_API_OPERATIONS,
|
|
3110
3387
|
CONSTAL_API_OPERATION_SCHEMAS,
|
|
3388
|
+
CONSTAL_API_QUERY_KINDS,
|
|
3111
3389
|
CONSTAL_API_VERSION,
|
|
3112
3390
|
CommitConflict,
|
|
3113
3391
|
CommitGateRejected,
|
|
@@ -3145,6 +3423,8 @@ export {
|
|
|
3145
3423
|
actionPattern,
|
|
3146
3424
|
agent,
|
|
3147
3425
|
agentResourceBinding,
|
|
3426
|
+
agentSetupMetadata,
|
|
3427
|
+
agentSetupRequirements,
|
|
3148
3428
|
analyticsEvent,
|
|
3149
3429
|
approximateTokens,
|
|
3150
3430
|
authProvider,
|
|
@@ -3155,11 +3435,17 @@ export {
|
|
|
3155
3435
|
capabilityContractRef,
|
|
3156
3436
|
casTool,
|
|
3157
3437
|
channel,
|
|
3438
|
+
channelIngressRequest,
|
|
3439
|
+
channelIngressSource,
|
|
3440
|
+
channelSourceEvidence,
|
|
3441
|
+
channelSubscriptionRequest,
|
|
3442
|
+
channelTarget,
|
|
3158
3443
|
checkpointArtifactRef,
|
|
3159
3444
|
checkpointDeploymentRequest,
|
|
3160
3445
|
checkpointImportMetadata,
|
|
3161
3446
|
checkpointImportRequest,
|
|
3162
3447
|
codeScorerIR,
|
|
3448
|
+
credentialEvidence,
|
|
3163
3449
|
credentialInteractionAction,
|
|
3164
3450
|
credentialInteractionEvent,
|
|
3165
3451
|
credentialInteractionResult,
|
|
@@ -3169,6 +3455,7 @@ export {
|
|
|
3169
3455
|
credentialProviderName,
|
|
3170
3456
|
credentialProviderSetupMetadata,
|
|
3171
3457
|
credentialRotationDefaults,
|
|
3458
|
+
credentialSetupState,
|
|
3172
3459
|
customerTenantName,
|
|
3173
3460
|
cutBatches,
|
|
3174
3461
|
cutPartitions,
|
|
@@ -3203,6 +3490,7 @@ export {
|
|
|
3203
3490
|
policy,
|
|
3204
3491
|
policyName,
|
|
3205
3492
|
renderTrainingCompletion,
|
|
3493
|
+
resolveBindingOwner,
|
|
3206
3494
|
resolveGatewayEgress,
|
|
3207
3495
|
resolveResourceDependencyRef,
|
|
3208
3496
|
resourceContractRef,
|
|
@@ -3219,6 +3507,7 @@ export {
|
|
|
3219
3507
|
scopedCredentialRef,
|
|
3220
3508
|
scopedResourceRef,
|
|
3221
3509
|
scorerName,
|
|
3510
|
+
selectableResourceLabels,
|
|
3222
3511
|
setupAwait,
|
|
3223
3512
|
setupScreen,
|
|
3224
3513
|
setupScreenView,
|