@constal/sdk 3.11.0 → 4.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 +1 -1
- package/publish/api.json +1 -1
- package/publish/index.d.ts +22 -81
- package/publish/index.js +162 -180
package/publish/index.js
CHANGED
|
@@ -222,7 +222,7 @@ function validatePartitionSpec(spec) {
|
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
if ("key" in spec) {
|
|
225
|
-
if (typeof spec.key !== "string" || spec.key.length === 0 || !positiveSafeInteger(spec.buckets)
|
|
225
|
+
if (typeof spec.key !== "string" || spec.key.length === 0 || !positiveSafeInteger(spec.buckets)) {
|
|
226
226
|
throw new TypeError("partition.key requires a non-empty field and 1..1024 buckets");
|
|
227
227
|
}
|
|
228
228
|
return;
|
|
@@ -292,7 +292,7 @@ function analyticsEvent(definition) {
|
|
|
292
292
|
if (RESERVED.has(definition.id.split(/[.-]/u)[0])) throw new TypeError("analytics event id uses a reserved namespace");
|
|
293
293
|
if (typeof definition.version !== "string" || !VERSION.test(definition.version)) throw new TypeError("analytics event version is invalid");
|
|
294
294
|
for (const [kind, fields] of [["dimensions", definition.dimensions], ["metrics", definition.metrics]]) {
|
|
295
|
-
if (!Array.isArray(fields) || fields.
|
|
295
|
+
if (!Array.isArray(fields) || fields.some((field2) => typeof field2 !== "string" || !FIELD_ID.test(field2))) throw new TypeError(`analytics event ${kind} are invalid`);
|
|
296
296
|
if (new Set(fields).size !== fields.length) throw new TypeError(`analytics event ${kind} must be unique`);
|
|
297
297
|
}
|
|
298
298
|
const metricNames = new Set(definition.metrics);
|
|
@@ -450,9 +450,6 @@ var RESOURCE_IDENTITY_LABELS = {
|
|
|
450
450
|
kind: "constal.ai/kind",
|
|
451
451
|
version: "constal.ai/version"
|
|
452
452
|
};
|
|
453
|
-
var MAX_LABELS = 64;
|
|
454
|
-
var MAX_EXPRESSIONS = 64;
|
|
455
|
-
var MAX_VALUES = 64;
|
|
456
453
|
var NAME = /^[A-Za-z0-9](?:[-_.A-Za-z0-9]{0,61}[A-Za-z0-9])?$/u;
|
|
457
454
|
var DNS_LABEL = /^[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?$/u;
|
|
458
455
|
function record(value) {
|
|
@@ -475,7 +472,7 @@ function selectorValue(key, value) {
|
|
|
475
472
|
}
|
|
476
473
|
function resourceLabelMap(value, options = {}) {
|
|
477
474
|
const source = record(value);
|
|
478
|
-
if (!source
|
|
475
|
+
if (!source) throw new TypeError("Resource labels are invalid");
|
|
479
476
|
const entries = Object.entries(source);
|
|
480
477
|
for (const [key, candidate] of entries) {
|
|
481
478
|
if (!labelKey(key) || !(options.allowProtected ? selectorValue(key, candidate) : labelValue(candidate)) || !options.allowProtected && key.startsWith(PROTECTED_RESOURCE_LABEL_PREFIX)) throw new TypeError(`Resource label ${key || "<empty>"} is invalid`);
|
|
@@ -489,7 +486,7 @@ function labelSelector(value) {
|
|
|
489
486
|
}
|
|
490
487
|
const matchLabels = source.matchLabels === void 0 ? {} : resourceLabelMap(source.matchLabels, { allowProtected: true });
|
|
491
488
|
const rawExpressions = source.matchExpressions === void 0 ? [] : source.matchExpressions;
|
|
492
|
-
if (!Array.isArray(rawExpressions)
|
|
489
|
+
if (!Array.isArray(rawExpressions)) throw new TypeError("Label selector expressions are invalid");
|
|
493
490
|
const matchExpressions = rawExpressions.map((raw, index) => {
|
|
494
491
|
const expression = record(raw);
|
|
495
492
|
const operator = expression?.operator;
|
|
@@ -498,7 +495,7 @@ function labelSelector(value) {
|
|
|
498
495
|
throw new TypeError(`Label selector expression ${index} is invalid`);
|
|
499
496
|
}
|
|
500
497
|
if (operator === "In" || operator === "NotIn") {
|
|
501
|
-
if (!Array.isArray(values) || values.length === 0 || values.
|
|
498
|
+
if (!Array.isArray(values) || values.length === 0 || values.some((item) => !selectorValue(expression.key, item))) {
|
|
502
499
|
throw new TypeError(`Label selector expression ${index} values are invalid`);
|
|
503
500
|
}
|
|
504
501
|
return { key: expression.key, operator, values: [...new Set(values)].sort() };
|
|
@@ -741,14 +738,14 @@ function channelTarget(value) {
|
|
|
741
738
|
return { resourceKind: "channel", subscriptions: { provider: subscriptions.provider } };
|
|
742
739
|
}
|
|
743
740
|
var UI_RESOURCE_BOUNDS = Object.freeze({
|
|
744
|
-
maximumRequestBodyBytes:
|
|
745
|
-
maximumResponseBodyBytes:
|
|
746
|
-
maximumCpuMs:
|
|
747
|
-
maximumSubrequests:
|
|
748
|
-
maximumDatabaseBytes:
|
|
749
|
-
maximumRowsReadPerRequest:
|
|
750
|
-
maximumRowsWrittenPerRequest:
|
|
751
|
-
maximumSqlResultBytes:
|
|
741
|
+
maximumRequestBodyBytes: Number.MAX_SAFE_INTEGER,
|
|
742
|
+
maximumResponseBodyBytes: Number.MAX_SAFE_INTEGER,
|
|
743
|
+
maximumCpuMs: Number.MAX_SAFE_INTEGER,
|
|
744
|
+
maximumSubrequests: Number.MAX_SAFE_INTEGER,
|
|
745
|
+
maximumDatabaseBytes: Number.MAX_SAFE_INTEGER,
|
|
746
|
+
maximumRowsReadPerRequest: Number.MAX_SAFE_INTEGER,
|
|
747
|
+
maximumRowsWrittenPerRequest: Number.MAX_SAFE_INTEGER,
|
|
748
|
+
maximumSqlResultBytes: Number.MAX_SAFE_INTEGER
|
|
752
749
|
});
|
|
753
750
|
var ACTION_PATTERN = /^[a-z][a-z0-9-]{0,63}:[a-z][a-z0-9-]{0,63}$/u;
|
|
754
751
|
var SEGMENT = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
|
|
@@ -1255,7 +1252,7 @@ function channel(definition) {
|
|
|
1255
1252
|
definition.needs?.forEach(resourceNeed);
|
|
1256
1253
|
const analytics = definition.analytics ?? [];
|
|
1257
1254
|
analytics.forEach((event) => analyticsEvent(event));
|
|
1258
|
-
if (
|
|
1255
|
+
if (new Set(analytics.map((event) => `${event.id}@${event.version}`)).size !== analytics.length) throw new TypeError("channel analytics definitions must be unique");
|
|
1259
1256
|
return definition;
|
|
1260
1257
|
}
|
|
1261
1258
|
|
|
@@ -1442,7 +1439,7 @@ function channelSourceEvidence(value) {
|
|
|
1442
1439
|
}
|
|
1443
1440
|
function credentialEvidence(value) {
|
|
1444
1441
|
const input = object2(value), provider = object2(input?.provider), claims = object2(input?.claims);
|
|
1445
|
-
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.
|
|
1442
|
+
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.entries(claims).some(([key, value2]) => !/^[A-Za-z0-9._-]{1,128}$/u.test(key) || !(typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2) || Array.isArray(value2) && value2.every((item) => typeof item === "string")))) {
|
|
1446
1443
|
throw new TypeError("Credential evidence is invalid");
|
|
1447
1444
|
}
|
|
1448
1445
|
if (parseResourceName(input.credential).kind !== "credential" || parseResourceName(provider.crn).kind !== "credential-provider") {
|
|
@@ -1469,7 +1466,7 @@ function channelSubscriptionRequest(value) {
|
|
|
1469
1466
|
throw new TypeError("Channel subscription crosses the authenticated tenant");
|
|
1470
1467
|
}
|
|
1471
1468
|
const credentials = input.credentials ?? [];
|
|
1472
|
-
if (!Array.isArray(credentials)
|
|
1469
|
+
if (!Array.isArray(credentials)) throw new TypeError("Channel subscription Credentials are invalid");
|
|
1473
1470
|
const proofs = credentials.map(credentialEvidence);
|
|
1474
1471
|
for (const proof of proofs) {
|
|
1475
1472
|
const owner = parseResourceName(proof.credential), provider = parseResourceName(proof.provider.crn);
|
|
@@ -1481,7 +1478,7 @@ function channelSubscriptionRequest(value) {
|
|
|
1481
1478
|
}
|
|
1482
1479
|
function channelIngressRequest(value) {
|
|
1483
1480
|
const input = object2(value), headers = object2(input?.headers);
|
|
1484
|
-
if (!input || !["GET", "POST", "PUT", "PATCH", "DELETE"].includes(String(input.method)) || typeof input.url !== "string" || !input.url || input.url.length > 2048 || !headers || Object.
|
|
1481
|
+
if (!input || !["GET", "POST", "PUT", "PATCH", "DELETE"].includes(String(input.method)) || typeof input.url !== "string" || !input.url || input.url.length > 2048 || !headers || 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");
|
|
1485
1482
|
return { method: input.method, url: input.url, headers, bodyBase64: input.bodyBase64 };
|
|
1486
1483
|
}
|
|
1487
1484
|
|
|
@@ -1718,7 +1715,7 @@ function setupAwait(screen) {
|
|
|
1718
1715
|
type: "object",
|
|
1719
1716
|
additionalProperties: false,
|
|
1720
1717
|
required: ["crn", "hash"],
|
|
1721
|
-
properties: { crn: { type: "string"
|
|
1718
|
+
properties: { crn: { type: "string" }, hash: hash3 }
|
|
1722
1719
|
};
|
|
1723
1720
|
const receipt = current.kind === "credential-interaction" && current.receipt !== void 0 ? {
|
|
1724
1721
|
type: "object",
|
|
@@ -1733,21 +1730,21 @@ function setupAwait(screen) {
|
|
|
1733
1730
|
additionalProperties: false,
|
|
1734
1731
|
required: ["credential", "provider", "version", "expiresAt", "claims"],
|
|
1735
1732
|
properties: {
|
|
1736
|
-
credential: { type: "string"
|
|
1733
|
+
credential: { type: "string" },
|
|
1737
1734
|
provider: {
|
|
1738
1735
|
...reference,
|
|
1739
|
-
properties: { crn: setupPanelProviderIsCrn(current.provider) ? { const: current.provider } : { type: "string"
|
|
1736
|
+
properties: { crn: setupPanelProviderIsCrn(current.provider) ? { const: current.provider } : { type: "string" }, hash: hash3 }
|
|
1740
1737
|
},
|
|
1741
1738
|
version: { type: "integer", minimum: 1 },
|
|
1742
1739
|
expiresAt: { type: ["integer", "null"], minimum: 1 },
|
|
1743
|
-
claims: { type: "object"
|
|
1740
|
+
claims: { type: "object" }
|
|
1744
1741
|
}
|
|
1745
1742
|
},
|
|
1746
1743
|
binding: current.selection ? {
|
|
1747
1744
|
type: "object",
|
|
1748
1745
|
additionalProperties: false,
|
|
1749
1746
|
required: ["crn", "headSeq", "revisionHash"],
|
|
1750
|
-
properties: { crn: { type: "string"
|
|
1747
|
+
properties: { crn: { type: "string" }, headSeq: { type: "integer", minimum: 1 }, revisionHash: hash3 }
|
|
1751
1748
|
} : { type: "null" }
|
|
1752
1749
|
}
|
|
1753
1750
|
} : null;
|
|
@@ -1845,10 +1842,10 @@ var CONSTAL_API_OPERATIONS = [
|
|
|
1845
1842
|
];
|
|
1846
1843
|
var CONSTAL_API_BOUNDS = {
|
|
1847
1844
|
defaultPageSize: 50,
|
|
1848
|
-
maximumPageSize:
|
|
1849
|
-
maximumRelationDepth:
|
|
1850
|
-
maximumPlanOperations:
|
|
1851
|
-
maximumInputBytes:
|
|
1845
|
+
maximumPageSize: Number.MAX_SAFE_INTEGER,
|
|
1846
|
+
maximumRelationDepth: Number.MAX_SAFE_INTEGER,
|
|
1847
|
+
maximumPlanOperations: Number.MAX_SAFE_INTEGER,
|
|
1848
|
+
maximumInputBytes: Number.MAX_SAFE_INTEGER,
|
|
1852
1849
|
planTtlMs: 15 * 6e4
|
|
1853
1850
|
};
|
|
1854
1851
|
var CONSTAL_API_QUERY_KINDS = [
|
|
@@ -1904,17 +1901,16 @@ var CONSTAL_API_GET_CRN_KINDS = [
|
|
|
1904
1901
|
"deployment"
|
|
1905
1902
|
];
|
|
1906
1903
|
var CONSTAL_API_OBJECT_REF_CRN_KINDS = [...CONSTAL_API_GET_CRN_KINDS, "customer"];
|
|
1907
|
-
var boundedNameSchema = { type: "string", minLength: 1,
|
|
1904
|
+
var boundedNameSchema = { type: "string", minLength: 1, pattern: "^[A-Za-z][A-Za-z0-9._-]{0,127}$" };
|
|
1908
1905
|
var namespaceSchema = {
|
|
1909
1906
|
type: "string",
|
|
1910
1907
|
minLength: 1,
|
|
1911
|
-
maxLength: 128,
|
|
1912
1908
|
pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
|
|
1913
1909
|
};
|
|
1914
1910
|
var actionSchema = { type: "string", pattern: ACTION_PATTERN.source };
|
|
1915
|
-
var boundedIdSchema = { type: "string", minLength: 1,
|
|
1911
|
+
var boundedIdSchema = { type: "string", minLength: 1, pattern: "^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$" };
|
|
1916
1912
|
var hashSchema = { type: "string", pattern: "^[a-f0-9]{64}$" };
|
|
1917
|
-
var stringListSchema = { type: "array",
|
|
1913
|
+
var stringListSchema = { type: "array", items: { type: "string", minLength: 1 } };
|
|
1918
1914
|
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: [
|
|
1919
1915
|
{
|
|
1920
1916
|
type: "object",
|
|
@@ -1930,25 +1926,22 @@ var scopeSchema = { description: "Use namespace with an exact namespace allowed
|
|
|
1930
1926
|
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}$`;
|
|
1931
1927
|
var objectRefSchema = { type: "object", additionalProperties: false, properties: {
|
|
1932
1928
|
kind: { enum: [...CONSTAL_API_GET_KINDS], description: "Exact lower-case object kind returned by a governed platform result." },
|
|
1933
|
-
id: { type: "string", minLength: 1
|
|
1929
|
+
id: { type: "string", minLength: 1 },
|
|
1934
1930
|
crn: { anyOf: [{ type: "null" }, {
|
|
1935
1931
|
type: "string",
|
|
1936
1932
|
minLength: 1,
|
|
1937
|
-
maxLength: 2048,
|
|
1938
1933
|
pattern: crnPattern(CONSTAL_API_OBJECT_REF_CRN_KINDS)
|
|
1939
1934
|
}] },
|
|
1940
1935
|
hash: { anyOf: [{ type: "null" }, hashSchema] },
|
|
1941
1936
|
namespace: {
|
|
1942
1937
|
type: ["string", "null"],
|
|
1943
|
-
maxLength: 128,
|
|
1944
1938
|
pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
|
|
1945
1939
|
},
|
|
1946
|
-
version: { type: ["string", "null"]
|
|
1940
|
+
version: { type: ["string", "null"] }
|
|
1947
1941
|
}, required: ["kind", "id", "namespace"] };
|
|
1948
1942
|
var exactGetCrnSchema = {
|
|
1949
1943
|
type: "string",
|
|
1950
1944
|
minLength: 1,
|
|
1951
|
-
maxLength: 2048,
|
|
1952
1945
|
description: "Exact addressable CRN obtained from governed platform evidence.",
|
|
1953
1946
|
pattern: crnPattern(CONSTAL_API_GET_CRN_KINDS)
|
|
1954
1947
|
};
|
|
@@ -1959,11 +1952,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
1959
1952
|
operations: stringListSchema,
|
|
1960
1953
|
include: {
|
|
1961
1954
|
type: "array",
|
|
1962
|
-
maxItems: 5,
|
|
1963
1955
|
uniqueItems: true,
|
|
1964
1956
|
items: { enum: ["objects", "operations", "relations", "schemas", "docs"] }
|
|
1965
1957
|
},
|
|
1966
|
-
cursor: { type: "string"
|
|
1958
|
+
cursor: { type: "string" },
|
|
1967
1959
|
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize }
|
|
1968
1960
|
} },
|
|
1969
1961
|
query: {
|
|
@@ -1975,8 +1967,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
1975
1967
|
kind: { enum: [...CONSTAL_API_QUERY_KINDS], description: "Exact queryable kind. Never guess a kind or change its casing." },
|
|
1976
1968
|
scope: scopeSchema,
|
|
1977
1969
|
filter: { type: "object", description: "Optional catalog-advertised filter expression." },
|
|
1978
|
-
search: { type: "string"
|
|
1979
|
-
order: { type: "array",
|
|
1970
|
+
search: { type: "string" },
|
|
1971
|
+
order: { type: "array", items: {
|
|
1980
1972
|
type: "object",
|
|
1981
1973
|
required: ["field", "direction"],
|
|
1982
1974
|
additionalProperties: false,
|
|
@@ -1984,7 +1976,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
1984
1976
|
} },
|
|
1985
1977
|
fields: stringListSchema,
|
|
1986
1978
|
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
|
|
1987
|
-
cursor: { type: "string"
|
|
1979
|
+
cursor: { type: "string" },
|
|
1988
1980
|
asOf: { type: "integer", minimum: 0 },
|
|
1989
1981
|
range: { type: "object", required: ["start", "end"], additionalProperties: false, properties: {
|
|
1990
1982
|
start: { type: "integer", minimum: 0 },
|
|
@@ -2009,8 +2001,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2009
2001
|
},
|
|
2010
2002
|
fields: stringListSchema,
|
|
2011
2003
|
page: { type: "object", additionalProperties: false, properties: {
|
|
2012
|
-
cursor: { type: "string"
|
|
2013
|
-
limit: { type: "integer", minimum: 1
|
|
2004
|
+
cursor: { type: "string" },
|
|
2005
|
+
limit: { type: "integer", minimum: 1 }
|
|
2014
2006
|
} }
|
|
2015
2007
|
}
|
|
2016
2008
|
},
|
|
@@ -2019,35 +2011,33 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2019
2011
|
type: "object",
|
|
2020
2012
|
required: ["crn"],
|
|
2021
2013
|
additionalProperties: false,
|
|
2022
|
-
properties: { crn: { type: "string", minLength: 1
|
|
2014
|
+
properties: { crn: { type: "string", minLength: 1 }, hash: hashSchema }
|
|
2023
2015
|
}] },
|
|
2024
2016
|
direction: { enum: ["outgoing", "incoming", "both"] },
|
|
2025
2017
|
types: stringListSchema,
|
|
2026
2018
|
depth: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumRelationDepth },
|
|
2027
2019
|
limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
|
|
2028
|
-
cursor: { type: "string"
|
|
2020
|
+
cursor: { type: "string" }
|
|
2029
2021
|
} },
|
|
2030
2022
|
explainPolicy: { type: "object", required: ["action", "resource"], additionalProperties: false, properties: {
|
|
2031
2023
|
principal: { anyOf: [
|
|
2032
|
-
{ type: "string"
|
|
2024
|
+
{ type: "string" },
|
|
2033
2025
|
{ type: "object", required: ["roles", "scopes"], additionalProperties: false, properties: {
|
|
2034
|
-
name: { type: "string"
|
|
2026
|
+
name: { type: "string" },
|
|
2035
2027
|
roles: {
|
|
2036
2028
|
type: "array",
|
|
2037
|
-
maxItems: 64,
|
|
2038
2029
|
uniqueItems: true,
|
|
2039
|
-
items: { type: "string", minLength: 1
|
|
2030
|
+
items: { type: "string", minLength: 1 }
|
|
2040
2031
|
},
|
|
2041
2032
|
scopes: {
|
|
2042
2033
|
type: "array",
|
|
2043
|
-
maxItems: 256,
|
|
2044
2034
|
uniqueItems: true,
|
|
2045
2035
|
items: { type: "string", pattern: "^(?:\\*|[a-z][a-z0-9-]{0,63}:(?:[a-z][a-z0-9-]{0,63}|\\*))$" }
|
|
2046
2036
|
}
|
|
2047
2037
|
} }
|
|
2048
2038
|
] },
|
|
2049
2039
|
action: actionSchema,
|
|
2050
|
-
resource: { type: "string", minLength: 1
|
|
2040
|
+
resource: { type: "string", minLength: 1 },
|
|
2051
2041
|
context: { type: "object" },
|
|
2052
2042
|
arguments: {},
|
|
2053
2043
|
at: { type: "object", required: ["run"], additionalProperties: false, properties: {
|
|
@@ -2057,7 +2047,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2057
2047
|
additionalProperties: false,
|
|
2058
2048
|
properties: {
|
|
2059
2049
|
namespace: boundedNameSchema,
|
|
2060
|
-
agent: { type: "string", minLength: 1,
|
|
2050
|
+
agent: { type: "string", minLength: 1, pattern: "^[a-z0-9][a-z0-9-]{0,62}$" },
|
|
2061
2051
|
session: boundedIdSchema,
|
|
2062
2052
|
run: boundedIdSchema
|
|
2063
2053
|
}
|
|
@@ -2065,7 +2055,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2065
2055
|
} }
|
|
2066
2056
|
} },
|
|
2067
2057
|
plan: { type: "object", required: ["objective", "operations"], additionalProperties: false, properties: {
|
|
2068
|
-
objective: { type: "string", minLength: 1
|
|
2058
|
+
objective: { type: "string", minLength: 1 },
|
|
2069
2059
|
validateOnly: { type: "boolean" },
|
|
2070
2060
|
operations: {
|
|
2071
2061
|
type: "array",
|
|
@@ -2074,10 +2064,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2074
2064
|
items: { type: "object", required: ["operation", "input"], additionalProperties: false, properties: {
|
|
2075
2065
|
id: boundedIdSchema,
|
|
2076
2066
|
operation: boundedNameSchema,
|
|
2077
|
-
target: { type: "string"
|
|
2067
|
+
target: { type: "string" },
|
|
2078
2068
|
input: {},
|
|
2079
2069
|
expectedCurrentHash: { anyOf: [{ type: "null" }, hashSchema] },
|
|
2080
|
-
dependsOn: { type: "array",
|
|
2070
|
+
dependsOn: { type: "array", items: boundedIdSchema }
|
|
2081
2071
|
} }
|
|
2082
2072
|
}
|
|
2083
2073
|
} },
|
|
@@ -2093,53 +2083,58 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
|
|
|
2093
2083
|
observe: { type: "object", required: ["id"], additionalProperties: false, properties: { id: boundedIdSchema } }
|
|
2094
2084
|
};
|
|
2095
2085
|
|
|
2096
|
-
// packages/sdk/src/artifact-limits.ts
|
|
2097
|
-
var ARTIFACT_MAX_BYTES = 5 * 1024 ** 3;
|
|
2098
|
-
|
|
2099
2086
|
// packages/sdk/src/sandbox-policy-contract.ts
|
|
2100
2087
|
var SANDBOX_CONTRACT_REF = {
|
|
2101
2088
|
id: "constal.sandbox-pool",
|
|
2102
2089
|
version: "2",
|
|
2103
|
-
hash: "
|
|
2090
|
+
hash: "89c34a8870f861811e6548d8388eddfc2d9b74e642fabeaf37c89f6d21df1c8e"
|
|
2104
2091
|
};
|
|
2105
2092
|
var SANDBOX_CONTROLS_SCHEMA = {
|
|
2106
2093
|
type: "object",
|
|
2107
2094
|
additionalProperties: false,
|
|
2108
2095
|
properties: {
|
|
2109
|
-
command_timeout_ms: { type: "integer", minimum:
|
|
2110
|
-
cpu: { type: "number", exclusiveMinimum: 0
|
|
2111
|
-
disk_gib: { type: "number", minimum: 0
|
|
2112
|
-
idle_stop_ms: { type: "integer", minimum:
|
|
2113
|
-
max_concurrent_commands: { type: "integer", minimum: 1
|
|
2114
|
-
max_file_bytes: { type: "integer", minimum: 1
|
|
2115
|
-
memory_gib: { type: "number", exclusiveMinimum: 0
|
|
2116
|
-
network_cidrs: { type: "array", minItems: 1,
|
|
2117
|
-
network_domains: { type: "array", minItems: 1,
|
|
2096
|
+
command_timeout_ms: { type: "integer", minimum: 1 },
|
|
2097
|
+
cpu: { type: "number", exclusiveMinimum: 0 },
|
|
2098
|
+
disk_gib: { type: "number", minimum: 0 },
|
|
2099
|
+
idle_stop_ms: { type: "integer", minimum: 1 },
|
|
2100
|
+
max_concurrent_commands: { type: "integer", minimum: 1 },
|
|
2101
|
+
max_file_bytes: { type: "integer", minimum: 1 },
|
|
2102
|
+
memory_gib: { type: "number", exclusiveMinimum: 0 },
|
|
2103
|
+
network_cidrs: { type: "array", minItems: 1, items: { type: "string" } },
|
|
2104
|
+
network_domains: { type: "array", minItems: 1, items: { type: "string" } },
|
|
2118
2105
|
network_egress: { type: ["string", "null"] },
|
|
2119
2106
|
network_mode: { enum: ["block-all", "cidr-allow", "domain-allow", "managed-http", "unrestricted"] },
|
|
2120
2107
|
network_transport: { enum: [null, "bridge", "proxy"] },
|
|
2121
|
-
permitted_paths: { type: "array", minItems: 1,
|
|
2108
|
+
permitted_paths: { type: "array", minItems: 1, items: { type: "string" } }
|
|
2122
2109
|
}
|
|
2123
2110
|
};
|
|
2124
2111
|
|
|
2125
|
-
// packages/sdk/src/policy-
|
|
2126
|
-
var
|
|
2127
|
-
var MODEL_CONTRACT = {
|
|
2112
|
+
// packages/sdk/src/model-policy-contract.ts
|
|
2113
|
+
var MODEL_CONTRACT_REF = {
|
|
2128
2114
|
id: "constal.model",
|
|
2129
2115
|
version: "1",
|
|
2130
|
-
hash: "
|
|
2116
|
+
hash: "5f2d00a0ba630341c15725d26dec7ff31f48724328e21c1264d1f7f7cee048b8"
|
|
2117
|
+
};
|
|
2118
|
+
var MODEL_CONTROLS_SCHEMA = {
|
|
2119
|
+
type: "object",
|
|
2120
|
+
additionalProperties: false,
|
|
2121
|
+
properties: {
|
|
2122
|
+
max_input_tokens: { type: "integer", minimum: 1 },
|
|
2123
|
+
max_output_tokens: { type: "integer", minimum: 1 },
|
|
2124
|
+
temperature_max: { type: "number" }
|
|
2125
|
+
}
|
|
2131
2126
|
};
|
|
2127
|
+
|
|
2128
|
+
// packages/sdk/src/policy-governance.ts
|
|
2129
|
+
var SANDBOX_CONTRACT = SANDBOX_CONTRACT_REF;
|
|
2130
|
+
var MODEL_CONTRACT = MODEL_CONTRACT_REF;
|
|
2132
2131
|
var UI_CONTRACT = {
|
|
2133
2132
|
id: "constal.ui",
|
|
2134
2133
|
version: "1",
|
|
2135
2134
|
hash: "133f0ab76ca2f1435dfbaa151652cfc79926ea5237c0892d0c4d3b96d7bb6f48"
|
|
2136
2135
|
};
|
|
2137
2136
|
var sandboxSchema = SANDBOX_CONTROLS_SCHEMA;
|
|
2138
|
-
var modelSchema =
|
|
2139
|
-
max_input_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
|
|
2140
|
-
max_output_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
|
|
2141
|
-
temperature_max: { type: "number", minimum: 0, maximum: 2 }
|
|
2142
|
-
} };
|
|
2137
|
+
var modelSchema = MODEL_CONTROLS_SCHEMA;
|
|
2143
2138
|
function controls(contract, values, schema) {
|
|
2144
2139
|
const error = validateJsonSchema(values, schema);
|
|
2145
2140
|
if (error) throw new TypeError(`governance controls are invalid: ${error}`);
|
|
@@ -2175,17 +2170,14 @@ function validatePolicyGovernanceConstraint(value) {
|
|
|
2175
2170
|
}
|
|
2176
2171
|
|
|
2177
2172
|
// packages/sdk/src/authorization.ts
|
|
2178
|
-
var MAX_CONSTRAINTS = 64;
|
|
2179
|
-
var MAX_OUTCOME_BYTES = 65536;
|
|
2180
|
-
var MAX_REASON_BYTES = 1024;
|
|
2181
2173
|
var DENIAL_CODE = /^[a-z][a-z0-9._-]{0,127}$/u;
|
|
2182
2174
|
var encoder4 = new TextEncoder();
|
|
2183
2175
|
function record4(value) {
|
|
2184
2176
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2185
2177
|
}
|
|
2186
|
-
function requiredString2(value, path,
|
|
2187
|
-
if (typeof value !== "string" || value.length === 0
|
|
2188
|
-
throw new TypeError(`${path} must be a
|
|
2178
|
+
function requiredString2(value, path, _maximum) {
|
|
2179
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
2180
|
+
throw new TypeError(`${path} must be a non-empty string`);
|
|
2189
2181
|
}
|
|
2190
2182
|
}
|
|
2191
2183
|
function exactKeys2(value, allowed, required2, path) {
|
|
@@ -2197,7 +2189,7 @@ function scalar(value) {
|
|
|
2197
2189
|
return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
2198
2190
|
}
|
|
2199
2191
|
function validateGrant(grant, path) {
|
|
2200
|
-
if (!record4(grant) || !Array.isArray(grant.actions) || grant.actions.length === 0 ||
|
|
2192
|
+
if (!record4(grant) || !Array.isArray(grant.actions) || grant.actions.length === 0 || !Array.isArray(grant.resources) || grant.resources.length === 0 || !Number.isSafeInteger(grant.ttlMs) || grant.ttlMs < 1 || grant.ttlMs > 864e5) {
|
|
2201
2193
|
throw new TypeError(`${path} is invalid`);
|
|
2202
2194
|
}
|
|
2203
2195
|
exactKeys2(grant, ["actions", "resources", "ttlMs"], ["actions", "resources", "ttlMs"], path);
|
|
@@ -2224,7 +2216,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
|
|
|
2224
2216
|
}
|
|
2225
2217
|
if (constraint.kind === "context") {
|
|
2226
2218
|
exactKeys2(source, ["kind", "equals"], ["kind", "equals"], path);
|
|
2227
|
-
if (!record4(constraint.equals) || Object.keys(constraint.equals).length === 0 || Object.
|
|
2219
|
+
if (!record4(constraint.equals) || Object.keys(constraint.equals).length === 0 || Object.entries(constraint.equals).some(([key, value]) => !key || key.length > 256 || !scalar(value))) {
|
|
2228
2220
|
throw new TypeError(`${path}.equals is invalid`);
|
|
2229
2221
|
}
|
|
2230
2222
|
return;
|
|
@@ -2239,7 +2231,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
|
|
|
2239
2231
|
}
|
|
2240
2232
|
function validateConstraints(value, path, required2) {
|
|
2241
2233
|
if (value === void 0 && !required2) return [];
|
|
2242
|
-
if (!Array.isArray(value) || required2 && value.length === 0
|
|
2234
|
+
if (!Array.isArray(value) || required2 && value.length === 0) {
|
|
2243
2235
|
throw new TypeError(`${path} is invalid`);
|
|
2244
2236
|
}
|
|
2245
2237
|
value.forEach((constraint, index) => validatePolicyConstraint(constraint, `${path}[${index}]`));
|
|
@@ -2251,7 +2243,7 @@ function policyOutcome(value) {
|
|
|
2251
2243
|
else if (value.kind === "deny") {
|
|
2252
2244
|
exactKeys2(value, ["kind", "code", "reason"], ["kind", "code"], "Policy deny outcome");
|
|
2253
2245
|
if (typeof value.code !== "string" || !DENIAL_CODE.test(value.code)) throw new TypeError("Policy denial code is invalid");
|
|
2254
|
-
if (value.reason !== void 0) requiredString2(value.reason, "Policy denial reason"
|
|
2246
|
+
if (value.reason !== void 0) requiredString2(value.reason, "Policy denial reason");
|
|
2255
2247
|
} else if (value.kind === "constrain") {
|
|
2256
2248
|
exactKeys2(value, ["kind", "constraints"], ["kind", "constraints"], "Policy constrain outcome");
|
|
2257
2249
|
validateConstraints(value.constraints, "Policy constraints", true);
|
|
@@ -2261,13 +2253,13 @@ function policyOutcome(value) {
|
|
|
2261
2253
|
validateConstraints(value.constraints, "Policy constraints", false);
|
|
2262
2254
|
} else if (value.kind === "require-approval") {
|
|
2263
2255
|
exactKeys2(value, ["kind", "reason", "constraints"], ["kind"], "Policy approval outcome");
|
|
2264
|
-
if (value.reason !== void 0) requiredString2(value.reason, "Policy approval reason"
|
|
2256
|
+
if (value.reason !== void 0) requiredString2(value.reason, "Policy approval reason");
|
|
2265
2257
|
validateConstraints(value.constraints, "Policy constraints", false);
|
|
2266
2258
|
} else if (value.kind === "grant") {
|
|
2267
2259
|
exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
|
|
2268
2260
|
validateGrant(value.grant, "Policy grant");
|
|
2269
2261
|
} else throw new TypeError("Policy outcome kind is invalid");
|
|
2270
|
-
|
|
2262
|
+
canonicalJson(value);
|
|
2271
2263
|
return value;
|
|
2272
2264
|
}
|
|
2273
2265
|
|
|
@@ -2287,7 +2279,7 @@ var identifier = { type: "string", pattern: "^[a-zA-Z_][a-zA-Z0-9_.-]{0,127}$",
|
|
|
2287
2279
|
var tableName = { type: "string", pattern: "^[a-z0-9][a-z0-9._-]{0,127}$", maxLength: 128 };
|
|
2288
2280
|
var branchName = { type: "string", pattern: "^[a-z0-9][a-z0-9._/-]{0,127}$", maxLength: 128 };
|
|
2289
2281
|
var hash2 = { type: "string", pattern: "^[a-f0-9]{64}$" };
|
|
2290
|
-
var scalar2 = { type: ["string", "number", "integer", "boolean", "null"]
|
|
2282
|
+
var scalar2 = { type: ["string", "number", "integer", "boolean", "null"] };
|
|
2291
2283
|
var TABLE_DESCRIBE_SCHEMA = {
|
|
2292
2284
|
type: "object",
|
|
2293
2285
|
required: ["table"],
|
|
@@ -2297,7 +2289,7 @@ var TABLE_DESCRIBE_SCHEMA = {
|
|
|
2297
2289
|
branch: branchName,
|
|
2298
2290
|
snapshot: hash2,
|
|
2299
2291
|
stageId: hash2,
|
|
2300
|
-
waitMs: { type: "integer", minimum: 0
|
|
2292
|
+
waitMs: { type: "integer", minimum: 0 }
|
|
2301
2293
|
}
|
|
2302
2294
|
};
|
|
2303
2295
|
var filterSchema = {
|
|
@@ -2307,7 +2299,7 @@ var filterSchema = {
|
|
|
2307
2299
|
properties: {
|
|
2308
2300
|
field: identifier,
|
|
2309
2301
|
op: { type: "string", enum: ["eq", "ne", "gt", "gte", "lt", "lte", "in", "between"] },
|
|
2310
|
-
value: { anyOf: [scalar2, { type: "array", minItems: 1,
|
|
2302
|
+
value: { anyOf: [scalar2, { type: "array", minItems: 1, items: scalar2 }] }
|
|
2311
2303
|
}
|
|
2312
2304
|
};
|
|
2313
2305
|
var TABLE_QUERY_SCHEMA = {
|
|
@@ -2322,10 +2314,10 @@ var TABLE_QUERY_SCHEMA = {
|
|
|
2322
2314
|
type: "object",
|
|
2323
2315
|
additionalProperties: false,
|
|
2324
2316
|
properties: {
|
|
2325
|
-
select: { type: "array",
|
|
2326
|
-
where: { type: "array",
|
|
2327
|
-
groupBy: { type: "array",
|
|
2328
|
-
aggregates: { type: "array",
|
|
2317
|
+
select: { type: "array", uniqueItems: true, items: identifier },
|
|
2318
|
+
where: { type: "array", items: filterSchema },
|
|
2319
|
+
groupBy: { type: "array", uniqueItems: true, items: identifier },
|
|
2320
|
+
aggregates: { type: "array", items: {
|
|
2329
2321
|
type: "object",
|
|
2330
2322
|
required: ["fn", "as"],
|
|
2331
2323
|
additionalProperties: false,
|
|
@@ -2335,13 +2327,13 @@ var TABLE_QUERY_SCHEMA = {
|
|
|
2335
2327
|
as: identifier
|
|
2336
2328
|
}
|
|
2337
2329
|
} },
|
|
2338
|
-
orderBy: { type: "array",
|
|
2330
|
+
orderBy: { type: "array", items: {
|
|
2339
2331
|
type: "object",
|
|
2340
2332
|
required: ["field", "direction"],
|
|
2341
2333
|
additionalProperties: false,
|
|
2342
2334
|
properties: { field: identifier, direction: { type: "string", enum: ["asc", "desc"] } }
|
|
2343
2335
|
} },
|
|
2344
|
-
limit: { type: "integer", minimum: 1
|
|
2336
|
+
limit: { type: "integer", minimum: 1 }
|
|
2345
2337
|
}
|
|
2346
2338
|
}
|
|
2347
2339
|
}
|
|
@@ -2355,7 +2347,7 @@ function validateStageOutputSpec(value, path = "$.output") {
|
|
|
2355
2347
|
const schemaError = validateJsonSchemaDefinition(output.schema, `${path}.schema`);
|
|
2356
2348
|
if (schemaError) return schemaError;
|
|
2357
2349
|
const sortOrder = output.sortOrder ?? [];
|
|
2358
|
-
if (!Array.isArray(sortOrder)
|
|
2350
|
+
if (!Array.isArray(sortOrder)) return `${path}.sortOrder is invalid`;
|
|
2359
2351
|
const keys = /* @__PURE__ */ new Set();
|
|
2360
2352
|
for (const [index, raw] of sortOrder.entries()) {
|
|
2361
2353
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return `${path}.sortOrder[${index}] is invalid`;
|
|
@@ -2476,8 +2468,8 @@ var WEB_FETCH_ARGUMENT_SCHEMA = {
|
|
|
2476
2468
|
required: ["url"],
|
|
2477
2469
|
additionalProperties: false,
|
|
2478
2470
|
properties: {
|
|
2479
|
-
url: { type: "string", minLength: 1
|
|
2480
|
-
accept: { type: "string"
|
|
2471
|
+
url: { type: "string", minLength: 1 },
|
|
2472
|
+
accept: { type: "string" }
|
|
2481
2473
|
}
|
|
2482
2474
|
};
|
|
2483
2475
|
var WEB_SEARCH_ARGUMENT_SCHEMA = {
|
|
@@ -2488,42 +2480,36 @@ var WEB_SEARCH_ARGUMENT_SCHEMA = {
|
|
|
2488
2480
|
query: {
|
|
2489
2481
|
type: "string",
|
|
2490
2482
|
minLength: 1,
|
|
2491
|
-
maxLength: 4096,
|
|
2492
2483
|
description: "A self-contained description of the information to find."
|
|
2493
2484
|
},
|
|
2494
2485
|
searchQueries: {
|
|
2495
2486
|
type: "array",
|
|
2496
2487
|
minItems: 1,
|
|
2497
|
-
maxItems: 3,
|
|
2498
2488
|
uniqueItems: true,
|
|
2499
2489
|
description: "Optional concise keyword queries that narrow the search.",
|
|
2500
|
-
items: { type: "string", minLength: 1
|
|
2490
|
+
items: { type: "string", minLength: 1 }
|
|
2501
2491
|
},
|
|
2502
2492
|
maximumResults: {
|
|
2503
2493
|
type: "integer",
|
|
2504
2494
|
minimum: 1,
|
|
2505
|
-
maximum: 20,
|
|
2506
2495
|
description: "Maximum number of sources to return."
|
|
2507
2496
|
},
|
|
2508
2497
|
maximumCharacters: {
|
|
2509
2498
|
type: "integer",
|
|
2510
|
-
minimum:
|
|
2511
|
-
maximum: 6e4,
|
|
2499
|
+
minimum: 1,
|
|
2512
2500
|
description: "Maximum total excerpt characters to return."
|
|
2513
2501
|
},
|
|
2514
2502
|
includeDomains: {
|
|
2515
2503
|
type: "array",
|
|
2516
|
-
maxItems: 50,
|
|
2517
2504
|
uniqueItems: true,
|
|
2518
2505
|
description: "Optional domains to restrict results to.",
|
|
2519
|
-
items: { type: "string", minLength: 1
|
|
2506
|
+
items: { type: "string", minLength: 1 }
|
|
2520
2507
|
},
|
|
2521
2508
|
excludeDomains: {
|
|
2522
2509
|
type: "array",
|
|
2523
|
-
maxItems: 50,
|
|
2524
2510
|
uniqueItems: true,
|
|
2525
2511
|
description: "Optional domains to omit.",
|
|
2526
|
-
items: { type: "string", minLength: 1
|
|
2512
|
+
items: { type: "string", minLength: 1 }
|
|
2527
2513
|
},
|
|
2528
2514
|
afterDate: {
|
|
2529
2515
|
type: "string",
|
|
@@ -2574,8 +2560,8 @@ var casTool = {
|
|
|
2574
2560
|
|
|
2575
2561
|
// packages/sdk/src/memory.ts
|
|
2576
2562
|
var id = { type: "string", pattern: "^[A-Za-z0-9._~-]{1,256}$", maxLength: 256 };
|
|
2577
|
-
var content = { type: "string", minLength: 1
|
|
2578
|
-
var metadata2 = { type: "object"
|
|
2563
|
+
var content = { type: "string", minLength: 1 };
|
|
2564
|
+
var metadata2 = { type: "object" };
|
|
2579
2565
|
var scope = { type: "string", pattern: "^[a-f0-9]{64}$", maxLength: 64 };
|
|
2580
2566
|
var record5 = {
|
|
2581
2567
|
type: "object",
|
|
@@ -2608,13 +2594,13 @@ var MEMORY_OPERATION_DECLARATIONS = [
|
|
|
2608
2594
|
type: "object",
|
|
2609
2595
|
required: ["query"],
|
|
2610
2596
|
additionalProperties: false,
|
|
2611
|
-
properties: { query: { type: "string", minLength: 1
|
|
2597
|
+
properties: { query: { type: "string", minLength: 1 }, limit: { type: "integer", minimum: 1 }, scope }
|
|
2612
2598
|
},
|
|
2613
2599
|
resultSchema: {
|
|
2614
2600
|
type: "object",
|
|
2615
2601
|
required: ["hits"],
|
|
2616
2602
|
additionalProperties: false,
|
|
2617
|
-
properties: { hits: { type: "array",
|
|
2603
|
+
properties: { hits: { type: "array", items: {
|
|
2618
2604
|
...record5,
|
|
2619
2605
|
required: [...record5.required, "score"],
|
|
2620
2606
|
properties: { ...record5.properties, score: { type: "number", minimum: 0, maximum: 1 } }
|
|
@@ -2690,13 +2676,13 @@ var TerminalIntegrationFailure = class extends Error {
|
|
|
2690
2676
|
var OPERATION3 = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/u;
|
|
2691
2677
|
function integrationEgressPolicy(value) {
|
|
2692
2678
|
const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
2693
|
-
if (!source || !Array.isArray(source.rules) ||
|
|
2679
|
+
if (!source || !Array.isArray(source.rules) || Object.keys(source).some((key) => key !== "rules")) {
|
|
2694
2680
|
throw new TypeError("integration egress policy is invalid");
|
|
2695
2681
|
}
|
|
2696
2682
|
const rules = source.rules.map((raw) => {
|
|
2697
2683
|
const rule = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
2698
2684
|
const paths = Number(rule?.pathPrefix !== void 0) + Number(rule?.pathExact !== void 0);
|
|
2699
|
-
if (!rule || !Array.isArray(rule.operations) || rule.operations.length === 0 || rule.operations.
|
|
2685
|
+
if (!rule || !Array.isArray(rule.operations) || rule.operations.length === 0 || rule.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !OPERATION3.test(operation)) || typeof rule.origin !== "string" || paths !== 1 || !Array.isArray(rule.methods) || rule.methods.length === 0 || rule.methods.length > 8 || rule.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(rule).some((key) => !["operations", "origin", "pathPrefix", "pathExact", "methods"].includes(key))) {
|
|
2700
2686
|
throw new TypeError("integration egress rule is invalid");
|
|
2701
2687
|
}
|
|
2702
2688
|
let origin;
|
|
@@ -2857,7 +2843,7 @@ function absoluteSandboxPath(value) {
|
|
|
2857
2843
|
return `/${segments.join("/")}`;
|
|
2858
2844
|
}
|
|
2859
2845
|
function normalizeSandboxWorkspacePath(path, cwd = WORKSPACE_ROOT) {
|
|
2860
|
-
if (typeof path !== "string" || !path || typeof cwd !== "string" || !cwd ||
|
|
2846
|
+
if (typeof path !== "string" || !path || typeof cwd !== "string" || !cwd || /[\u0000-\u001f\u007f]/u.test(path) || /[\u0000-\u001f\u007f]/u.test(cwd)) {
|
|
2861
2847
|
throw new TypeError("sandbox workspace path is invalid");
|
|
2862
2848
|
}
|
|
2863
2849
|
const base = absoluteSandboxPath(cwd.startsWith("/") ? cwd : `${WORKSPACE_ROOT}/${cwd}`);
|
|
@@ -2887,14 +2873,14 @@ var TRAINING_PROVIDER_CAPABILITY = {
|
|
|
2887
2873
|
function record6(value) {
|
|
2888
2874
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
2889
2875
|
}
|
|
2890
|
-
function integer(value, field2, minimum
|
|
2891
|
-
if (!Number.isSafeInteger(value) || Number(value) < minimum
|
|
2876
|
+
function integer(value, field2, minimum) {
|
|
2877
|
+
if (!Number.isSafeInteger(value) || Number(value) < minimum) {
|
|
2892
2878
|
throw new TypeError(`${field2} is invalid`);
|
|
2893
2879
|
}
|
|
2894
2880
|
return Number(value);
|
|
2895
2881
|
}
|
|
2896
|
-
function finite(value, field2, minimum
|
|
2897
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < minimum
|
|
2882
|
+
function finite(value, field2, minimum) {
|
|
2883
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < minimum) {
|
|
2898
2884
|
throw new TypeError(`${field2} is invalid`);
|
|
2899
2885
|
}
|
|
2900
2886
|
return value;
|
|
@@ -2917,7 +2903,7 @@ function resumePoint(value) {
|
|
|
2917
2903
|
function trainingProviderMetadata(value) {
|
|
2918
2904
|
const candidate = record6(value);
|
|
2919
2905
|
const checkpoints = record6(candidate?.checkpoints);
|
|
2920
|
-
if (!candidate || candidate.lifecycleVersion !== 1 || !Array.isArray(candidate.methods) || candidate.methods.length === 0 || candidate.methods.length > 2 || candidate.methods.some((method) => method !== "sft" && method !== "rl") || new Set(candidate.methods).size !== candidate.methods.length || !Array.isArray(candidate.models) ||
|
|
2906
|
+
if (!candidate || candidate.lifecycleVersion !== 1 || !Array.isArray(candidate.methods) || candidate.methods.length === 0 || candidate.methods.length > 2 || candidate.methods.some((method) => method !== "sft" && method !== "rl") || new Set(candidate.methods).size !== candidate.methods.length || !Array.isArray(candidate.models) || !checkpoints || !Array.isArray(checkpoints.formats) || checkpoints.formats.length === 0 || checkpoints.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(checkpoints.formats).size !== checkpoints.formats.length || typeof checkpoints.resume !== "boolean" || typeof checkpoints.fork !== "boolean" || Object.keys(checkpoints).some((key) => !["formats", "resume", "fork"].includes(key)) || Object.keys(candidate).some((key) => !["lifecycleVersion", "methods", "models", "checkpoints"].includes(key))) {
|
|
2921
2907
|
throw new TypeError("Training Provider metadata is invalid");
|
|
2922
2908
|
}
|
|
2923
2909
|
const models = candidate.models.map((raw) => {
|
|
@@ -2973,25 +2959,25 @@ function trainingRecipe(value) {
|
|
|
2973
2959
|
"maxSampleTokens",
|
|
2974
2960
|
"budgetMicroUsd"
|
|
2975
2961
|
];
|
|
2976
|
-
if (!candidate || candidate.method !== "sft" && candidate.method !== "rl" || typeof candidate.baseModel !== "string" || !PROVIDER_MODEL_ID.test(candidate.baseModel) || !Array.isArray(candidate.scorers) || candidate.
|
|
2962
|
+
if (!candidate || candidate.method !== "sft" && candidate.method !== "rl" || typeof candidate.baseModel !== "string" || !PROVIDER_MODEL_ID.test(candidate.baseModel) || !Array.isArray(candidate.scorers) || candidate.method === "rl" && candidate.scorers.length === 0 || Object.keys(candidate).some((key) => !allowed.includes(key))) throw new TypeError("training recipe is invalid");
|
|
2977
2963
|
const recipe = {
|
|
2978
2964
|
method: candidate.method,
|
|
2979
2965
|
baseModel: candidate.baseModel,
|
|
2980
2966
|
dataset: datasetRef(candidate.dataset, "training dataset"),
|
|
2981
2967
|
validationDataset: candidate.validationDataset === null ? null : datasetRef(candidate.validationDataset, "validation dataset"),
|
|
2982
2968
|
scorers: candidate.scorers.map((scorer, index) => scorerRef(scorer, `training scorer ${index}`)),
|
|
2983
|
-
loraRank: integer(candidate.loraRank, "LoRA rank", 1
|
|
2984
|
-
learningRate: finite(candidate.learningRate, "learning rate", Number.MIN_VALUE
|
|
2985
|
-
epochs: integer(candidate.epochs, "epochs", 1
|
|
2986
|
-
batchSize: integer(candidate.batchSize, "batch size", 1
|
|
2987
|
-
groupSize: integer(candidate.groupSize, "group size", 1
|
|
2988
|
-
temperature: finite(candidate.temperature, "temperature", 0
|
|
2989
|
-
seed: integer(candidate.seed, "seed", 0
|
|
2990
|
-
checkpointEvery: integer(candidate.checkpointEvery, "checkpoint interval", 1
|
|
2991
|
-
evalEvery: integer(candidate.evalEvery, "evaluation interval", 1
|
|
2992
|
-
maxTrainTokens: integer(candidate.maxTrainTokens, "training token limit", 1
|
|
2993
|
-
maxSampleTokens: integer(candidate.maxSampleTokens, "sample token limit", 1
|
|
2994
|
-
budgetMicroUsd: integer(candidate.budgetMicroUsd, "training budget", 1
|
|
2969
|
+
loraRank: integer(candidate.loraRank, "LoRA rank", 1),
|
|
2970
|
+
learningRate: finite(candidate.learningRate, "learning rate", Number.MIN_VALUE),
|
|
2971
|
+
epochs: integer(candidate.epochs, "epochs", 1),
|
|
2972
|
+
batchSize: integer(candidate.batchSize, "batch size", 1),
|
|
2973
|
+
groupSize: integer(candidate.groupSize, "group size", 1),
|
|
2974
|
+
temperature: finite(candidate.temperature, "temperature", 0),
|
|
2975
|
+
seed: integer(candidate.seed, "seed", 0),
|
|
2976
|
+
checkpointEvery: integer(candidate.checkpointEvery, "checkpoint interval", 1),
|
|
2977
|
+
evalEvery: integer(candidate.evalEvery, "evaluation interval", 1),
|
|
2978
|
+
maxTrainTokens: integer(candidate.maxTrainTokens, "training token limit", 1),
|
|
2979
|
+
maxSampleTokens: integer(candidate.maxSampleTokens, "sample token limit", 1),
|
|
2980
|
+
budgetMicroUsd: integer(candidate.budgetMicroUsd, "training budget", 1)
|
|
2995
2981
|
};
|
|
2996
2982
|
if (recipe.method === "sft" && recipe.groupSize !== 1) throw new TypeError("SFT group size must be 1");
|
|
2997
2983
|
return recipe;
|
|
@@ -3268,7 +3254,6 @@ function httpsUrl(value, field2) {
|
|
|
3268
3254
|
function slotMetadata(value) {
|
|
3269
3255
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Gateway Credential slots are invalid");
|
|
3270
3256
|
const entries = Object.entries(value);
|
|
3271
|
-
if (entries.length > 32) throw new TypeError("Gateway Credential slots are invalid");
|
|
3272
3257
|
const output = {};
|
|
3273
3258
|
for (const [slot, raw] of entries) {
|
|
3274
3259
|
const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
@@ -3282,10 +3267,10 @@ function slotMetadata(value) {
|
|
|
3282
3267
|
}
|
|
3283
3268
|
function configEgressBindings(value) {
|
|
3284
3269
|
if (value === void 0) return [];
|
|
3285
|
-
if (!Array.isArray(value)
|
|
3270
|
+
if (!Array.isArray(value)) throw new TypeError("Gateway config egress bindings are invalid");
|
|
3286
3271
|
return value.map((raw) => {
|
|
3287
3272
|
const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
3288
|
-
if (!item || !SLOT.test(String(item.urlProperty ?? "")) || !Array.isArray(item.operations) || item.operations.length === 0 || item.operations.
|
|
3273
|
+
if (!item || !SLOT.test(String(item.urlProperty ?? "")) || !Array.isArray(item.operations) || item.operations.length === 0 || item.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/u.test(operation)) || !Array.isArray(item.methods) || item.methods.length === 0 || item.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(item).some((key) => !["urlProperty", "operations", "methods"].includes(key))) {
|
|
3289
3274
|
throw new TypeError("Gateway config egress bindings are invalid");
|
|
3290
3275
|
}
|
|
3291
3276
|
return {
|
|
@@ -3305,7 +3290,7 @@ function discoverySetup(value) {
|
|
|
3305
3290
|
}
|
|
3306
3291
|
function checkpointImportMetadata(value) {
|
|
3307
3292
|
const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3308
|
-
if (!source || source.lifecycleVersion !== 1 || !Array.isArray(source.formats) || source.formats.length === 0 || source.formats.
|
|
3293
|
+
if (!source || source.lifecycleVersion !== 1 || !Array.isArray(source.formats) || source.formats.length === 0 || source.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(source.formats).size !== source.formats.length || Object.keys(source).some((key) => !["lifecycleVersion", "formats"].includes(key))) {
|
|
3309
3294
|
throw new TypeError("Gateway checkpoint import metadata is invalid");
|
|
3310
3295
|
}
|
|
3311
3296
|
return { lifecycleVersion: 1, formats: [...source.formats] };
|
|
@@ -3322,7 +3307,7 @@ function checkpointImportRequest(value) {
|
|
|
3322
3307
|
throw new TypeError("checkpoint import request is invalid");
|
|
3323
3308
|
}
|
|
3324
3309
|
try {
|
|
3325
|
-
|
|
3310
|
+
canonicalJson(artifactValue);
|
|
3326
3311
|
} catch {
|
|
3327
3312
|
throw new TypeError("checkpoint import request is invalid");
|
|
3328
3313
|
}
|
|
@@ -3363,7 +3348,7 @@ function gatewayModelOffer(value) {
|
|
|
3363
3348
|
const modalities = (field2) => {
|
|
3364
3349
|
const values = source[field2];
|
|
3365
3350
|
if (values === void 0) return void 0;
|
|
3366
|
-
if (!Array.isArray(values) || values.length === 0 || values.
|
|
3351
|
+
if (!Array.isArray(values) || values.length === 0 || values.some((item) => typeof item !== "string" || !SLOT.test(item)) || new Set(values).size !== values.length) {
|
|
3367
3352
|
throw new TypeError("Gateway Model offer is invalid");
|
|
3368
3353
|
}
|
|
3369
3354
|
return values;
|
|
@@ -3396,7 +3381,7 @@ function assertNonSecretGatewayConfig(value, field2 = "config") {
|
|
|
3396
3381
|
}
|
|
3397
3382
|
function gatewayPackageMetadata(value) {
|
|
3398
3383
|
const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3399
|
-
if (!source || source.lifecycleVersion !== 1 || typeof source.displayName !== "string" || !source.displayName || typeof source.description !== "string" || !source.description || source.service !== void 0 && (typeof source.service !== "string" || !source.service || source.service.length > 128) || !Array.isArray(source.capabilities) || source.capabilities.length === 0 ||
|
|
3384
|
+
if (!source || source.lifecycleVersion !== 1 || typeof source.displayName !== "string" || !source.displayName || typeof source.description !== "string" || !source.description || source.service !== void 0 && (typeof source.service !== "string" || !source.service || source.service.length > 128) || !Array.isArray(source.capabilities) || source.capabilities.length === 0 || !source.billing || typeof source.billing !== "object" || Array.isArray(source.billing) || !["platform", "tenant"].includes(String(source.billing.upstreamPayer ?? ""))) {
|
|
3400
3385
|
throw new TypeError("Gateway package metadata is invalid");
|
|
3401
3386
|
}
|
|
3402
3387
|
httpsUrl(source.documentationUrl, "Gateway documentation URL");
|
|
@@ -3404,7 +3389,7 @@ function gatewayPackageMetadata(value) {
|
|
|
3404
3389
|
const modelOffers = source.modelOffers === void 0 ? [] : Array.isArray(source.modelOffers) ? source.modelOffers.map(gatewayModelOffer) : (() => {
|
|
3405
3390
|
throw new TypeError("Gateway Model offers are invalid");
|
|
3406
3391
|
})();
|
|
3407
|
-
if (
|
|
3392
|
+
if (new Set(modelOffers.map((offer) => offer.id)).size !== modelOffers.length) {
|
|
3408
3393
|
throw new TypeError("Gateway Model offers are invalid");
|
|
3409
3394
|
}
|
|
3410
3395
|
const capabilities = source.capabilities.map(capabilityContractRef);
|
|
@@ -3577,13 +3562,14 @@ function credentialInteractionEvent(value) {
|
|
|
3577
3562
|
if (event.kind === "callback") {
|
|
3578
3563
|
const parameters = interactionRecord(event.parameters);
|
|
3579
3564
|
const headers = interactionRecord(event.headers);
|
|
3580
|
-
if (!exactKeys3(event, ["kind", "method", "parameters", "headers", "bodyBase64"]) || !["GET", "POST"].includes(String(event.method ?? "")) || !parameters || Object.
|
|
3565
|
+
if (!exactKeys3(event, ["kind", "method", "parameters", "headers", "bodyBase64"]) || !["GET", "POST"].includes(String(event.method ?? "")) || !parameters || Object.entries(parameters).some(([key, item]) => typeof item !== "string") || !headers || Object.entries(headers).some(([key, item]) => typeof item !== "string") || event.bodyBase64 !== null && (typeof event.bodyBase64 !== "string" || !/^[A-Za-z0-9+/]*={0,2}$/u.test(event.bodyBase64))) {
|
|
3581
3566
|
throw new TypeError("credential interaction callback is invalid");
|
|
3582
3567
|
}
|
|
3583
3568
|
} else if (event.kind === "submit") {
|
|
3584
|
-
if (!exactKeys3(event, ["kind", "value"])
|
|
3569
|
+
if (!exactKeys3(event, ["kind", "value"])) {
|
|
3585
3570
|
throw new TypeError("credential interaction submission is invalid");
|
|
3586
3571
|
}
|
|
3572
|
+
canonicalJson(event.value);
|
|
3587
3573
|
} else if (!exactKeys3(event, ["kind"])) throw new TypeError("credential interaction event is invalid");
|
|
3588
3574
|
return event;
|
|
3589
3575
|
}
|
|
@@ -3637,7 +3623,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
|
|
|
3637
3623
|
}
|
|
3638
3624
|
const schemaError = validateJsonSchemaDefinition(action3.schema, "$interaction.form.schema");
|
|
3639
3625
|
const formSchema = interactionRecord(action3.schema);
|
|
3640
|
-
if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false
|
|
3626
|
+
if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false) {
|
|
3641
3627
|
throw new TypeError(`credential interaction form schema is invalid${schemaError ? `: ${schemaError}` : ""}`);
|
|
3642
3628
|
}
|
|
3643
3629
|
} else if (action3.kind === "display") {
|
|
@@ -3660,7 +3646,7 @@ function credentialInteractionResult(value, origins, state, sessionExpiresAt) {
|
|
|
3660
3646
|
const result = interactionRecord(value);
|
|
3661
3647
|
if (!result || !exactKeys3(result, ["action", "privateState"])) throw new TypeError("credential interaction result is invalid");
|
|
3662
3648
|
const privateState = result.privateState;
|
|
3663
|
-
if (privateState !== void 0 && privateState !== null &&
|
|
3649
|
+
if (privateState !== void 0 && privateState !== null && typeof privateState !== "string") throw new TypeError("credential interaction private state is invalid");
|
|
3664
3650
|
return {
|
|
3665
3651
|
action: credentialInteractionAction(result.action, origins, state, sessionExpiresAt),
|
|
3666
3652
|
...privateState === void 0 ? {} : { privateState }
|
|
@@ -3699,7 +3685,7 @@ function credentialProviderSetupMetadata(value, slots) {
|
|
|
3699
3685
|
throw new TypeError("credential provider setup Credential slot documentation URL is invalid");
|
|
3700
3686
|
}
|
|
3701
3687
|
}
|
|
3702
|
-
if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.
|
|
3688
|
+
if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.some((item) => typeof item !== "string" || !item || item.length > 64))) {
|
|
3703
3689
|
throw new TypeError("credential provider setup Credential slot file types are invalid");
|
|
3704
3690
|
}
|
|
3705
3691
|
}
|
|
@@ -3725,12 +3711,12 @@ function credentialProvider(definition) {
|
|
|
3725
3711
|
credentialRotationDefaults(definition.rotation);
|
|
3726
3712
|
credentialProviderConfigSchema(definition.configSchema);
|
|
3727
3713
|
credentialProviderConfigSchema(definition.credentialConfigSchema);
|
|
3728
|
-
if (!Array.isArray(definition.credentialSlots) ||
|
|
3714
|
+
if (!Array.isArray(definition.credentialSlots) || new Set(definition.credentialSlots).size !== definition.credentialSlots.length || definition.credentialSlots.some((slot) => typeof slot !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(slot))) {
|
|
3729
3715
|
throw new TypeError("credential provider bootstrap slots are invalid");
|
|
3730
3716
|
}
|
|
3731
3717
|
const setup = credentialProviderSetupMetadata(definition.setup, definition.credentialSlots);
|
|
3732
3718
|
const interaction = definition.interaction ?? null;
|
|
3733
|
-
if (interaction && (!Array.isArray(interaction.origins) || interaction.origins.length === 0 ||
|
|
3719
|
+
if (interaction && (!Array.isArray(interaction.origins) || interaction.origins.length === 0 || new Set(interaction.origins).size !== interaction.origins.length || interaction.origins.some((origin) => {
|
|
3734
3720
|
try {
|
|
3735
3721
|
const url = new URL(origin);
|
|
3736
3722
|
return url.protocol !== "https:" || url.origin !== origin;
|
|
@@ -3764,35 +3750,36 @@ function credentialProvider(definition) {
|
|
|
3764
3750
|
|
|
3765
3751
|
// packages/sdk/src/evaluation.ts
|
|
3766
3752
|
var EVALUATION_LIMITS = {
|
|
3767
|
-
maxQuestions:
|
|
3768
|
-
maxChoiceOptions:
|
|
3769
|
-
maxScoreLevels:
|
|
3770
|
-
maxDepth:
|
|
3771
|
-
/**
|
|
3772
|
-
maxRequestBytes:
|
|
3753
|
+
maxQuestions: Number.MAX_SAFE_INTEGER,
|
|
3754
|
+
maxChoiceOptions: Number.MAX_SAFE_INTEGER,
|
|
3755
|
+
maxScoreLevels: Number.MAX_SAFE_INTEGER,
|
|
3756
|
+
maxDepth: Number.MAX_SAFE_INTEGER,
|
|
3757
|
+
/** Compatibility numeric domains, not request quotas; provider limits are reported by the provider. */
|
|
3758
|
+
maxRequestBytes: Number.MAX_SAFE_INTEGER
|
|
3773
3759
|
};
|
|
3774
3760
|
var QUESTION_ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/u;
|
|
3775
3761
|
var MODEL = /^[a-z0-9][a-z0-9._\/-]{0,255}$/u;
|
|
3776
3762
|
function record8(value) {
|
|
3777
3763
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3778
3764
|
}
|
|
3779
|
-
function entry(value, field2,
|
|
3780
|
-
if (depth > EVALUATION_LIMITS.maxDepth) throw new TypeError(`${field2} nests too deeply`);
|
|
3765
|
+
function entry(value, field2, ancestors = /* @__PURE__ */ new WeakSet()) {
|
|
3781
3766
|
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
3782
3767
|
if (typeof value === "number") {
|
|
3783
3768
|
if (!Number.isFinite(value)) throw new TypeError(`${field2} must be a finite number`);
|
|
3784
3769
|
return value;
|
|
3785
3770
|
}
|
|
3786
|
-
|
|
3787
|
-
const source = record8(value);
|
|
3771
|
+
const array = Array.isArray(value);
|
|
3772
|
+
const source = array ? value : record8(value);
|
|
3788
3773
|
const prototype = source ? Object.getPrototypeOf(source) : void 0;
|
|
3789
|
-
if (!source || prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3774
|
+
if (!source || !array && prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
|
|
3775
|
+
if (ancestors.has(source)) throw new TypeError(`${field2} contains a JSON cycle`);
|
|
3776
|
+
ancestors.add(source);
|
|
3777
|
+
try {
|
|
3778
|
+
if (array) return value.map((item, index) => entry(item, `${field2}[${index}]`, ancestors));
|
|
3779
|
+
return Object.fromEntries(Object.entries(source).filter(([, item]) => item !== void 0).map(([key, item]) => [key, entry(item, `${field2}.${key}`, ancestors)]));
|
|
3780
|
+
} finally {
|
|
3781
|
+
ancestors.delete(source);
|
|
3794
3782
|
}
|
|
3795
|
-
return output;
|
|
3796
3783
|
}
|
|
3797
3784
|
function question(id2, value) {
|
|
3798
3785
|
const source = record8(value);
|
|
@@ -3807,14 +3794,12 @@ function question(id2, value) {
|
|
|
3807
3794
|
const criteria2 = record8(source.criteria);
|
|
3808
3795
|
const options = criteria2 ? Object.keys(criteria2) : [];
|
|
3809
3796
|
if (!criteria2 || options.length < 2) throw new TypeError(`choice question ${id2} needs at least two options`);
|
|
3810
|
-
if (options.
|
|
3811
|
-
if (options.some((option) => !option.trim() || option.length > 256)) throw new TypeError(`choice question ${id2} has an invalid option key`);
|
|
3797
|
+
if (options.some((option) => !option.trim())) throw new TypeError(`choice question ${id2} has an invalid option key`);
|
|
3812
3798
|
return { type, instructions, criteria: Object.fromEntries(options.map((option) => [option, entry(criteria2[option], `choice question ${id2} option ${option}`)])) };
|
|
3813
3799
|
}
|
|
3814
3800
|
if (type === "score") {
|
|
3815
3801
|
const criteria2 = source.criteria;
|
|
3816
3802
|
if (!Array.isArray(criteria2) || criteria2.length < 2) throw new TypeError(`score question ${id2} needs at least two ordered levels`);
|
|
3817
|
-
if (criteria2.length > EVALUATION_LIMITS.maxScoreLevels) throw new TypeError(`score question ${id2} has too many levels`);
|
|
3818
3803
|
return { type, instructions, criteria: criteria2.map((level, index) => entry(level, `score question ${id2} level ${index}`)) };
|
|
3819
3804
|
}
|
|
3820
3805
|
if (source.criteria === void 0) return { type, instructions };
|
|
@@ -3835,8 +3820,7 @@ function evaluationArguments(value) {
|
|
|
3835
3820
|
const questionSource = record8(source.questions);
|
|
3836
3821
|
const ids = questionSource ? Object.keys(questionSource) : [];
|
|
3837
3822
|
if (!questionSource || ids.length === 0) throw new TypeError("evaluation requires at least one question");
|
|
3838
|
-
|
|
3839
|
-
const questions = {};
|
|
3823
|
+
const questions = /* @__PURE__ */ Object.create(null);
|
|
3840
3824
|
for (const id2 of ids) {
|
|
3841
3825
|
if (!QUESTION_ID.test(id2)) throw new TypeError(`question id is invalid: ${id2}`);
|
|
3842
3826
|
questions[id2] = question(id2, questionSource[id2]);
|
|
@@ -3849,8 +3833,6 @@ function evaluationArguments(value) {
|
|
|
3849
3833
|
model = source.model;
|
|
3850
3834
|
}
|
|
3851
3835
|
const output = { ...model === void 0 ? {} : { model }, state, questions };
|
|
3852
|
-
const bytes = new TextEncoder().encode(JSON.stringify({ state, questions })).byteLength;
|
|
3853
|
-
if (bytes > EVALUATION_LIMITS.maxRequestBytes) throw new TypeError("evaluation state and questions exceed the request size limit");
|
|
3854
3836
|
return output;
|
|
3855
3837
|
}
|
|
3856
3838
|
function evaluationProtocolRequest(protocol, model, args) {
|
|
@@ -4079,9 +4061,9 @@ function exactKeys4(value, allowed) {
|
|
|
4079
4061
|
}
|
|
4080
4062
|
function scorerRule(value, depth, state) {
|
|
4081
4063
|
const rule = record10(value);
|
|
4082
|
-
if (!rule ||
|
|
4064
|
+
if (!rule || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
|
|
4083
4065
|
if (rule.op === "all" || rule.op === "any") {
|
|
4084
|
-
if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1
|
|
4066
|
+
if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1) {
|
|
4085
4067
|
throw new TypeError("Code Scorer logical rule is invalid");
|
|
4086
4068
|
}
|
|
4087
4069
|
return { op: rule.op, rules: rule.rules.map((child) => scorerRule(child, depth + 1, state)) };
|
|
@@ -4116,7 +4098,7 @@ function scorerRule(value, depth, state) {
|
|
|
4116
4098
|
return rule;
|
|
4117
4099
|
}
|
|
4118
4100
|
if (rule.op === "tool-sequence") {
|
|
4119
|
-
if (!exactKeys4(rule, ["op", "path", "expected", "mode"]) || !validPointer(rule.path) || !Array.isArray(rule.expected) || rule.expected.
|
|
4101
|
+
if (!exactKeys4(rule, ["op", "path", "expected", "mode"]) || !validPointer(rule.path) || !Array.isArray(rule.expected) || rule.expected.some((item) => typeof item !== "string" || !/^[A-Za-z0-9._-]{1,128}$/u.test(item)) || rule.mode !== "exact" && rule.mode !== "ordered-subsequence") throw new TypeError("Code Scorer tool sequence rule is invalid");
|
|
4120
4102
|
return rule;
|
|
4121
4103
|
}
|
|
4122
4104
|
if (rule.op === "citations-in-source") {
|