@constal/sdk 1.0.0 → 2.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 +25 -1
- package/publish/index.d.ts +275 -10
- package/publish/index.js +252 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constal/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Public TypeScript SDK for authoring Constal agents, integrations, policies, channels, and credential providers",
|
|
5
5
|
"keywords": ["constal", "agents", "integrations", "typescript", "sdk"],
|
|
6
6
|
"license": "UNLICENSED",
|
package/publish/api.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@constal/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"exports": [
|
|
5
5
|
"Action",
|
|
6
6
|
"ActionPattern",
|
|
@@ -139,6 +139,8 @@
|
|
|
139
139
|
"HandleOutcome",
|
|
140
140
|
"Hash",
|
|
141
141
|
"HistoryView",
|
|
142
|
+
"IngressRequest",
|
|
143
|
+
"IngressTarget",
|
|
142
144
|
"IntegrationContext",
|
|
143
145
|
"IntegrationEgressPolicy",
|
|
144
146
|
"IntegrationEgressRequest",
|
|
@@ -254,6 +256,8 @@
|
|
|
254
256
|
"SessionDeleted",
|
|
255
257
|
"SetEvalBaselineRequest",
|
|
256
258
|
"SortField",
|
|
259
|
+
"SpawnAttenuation",
|
|
260
|
+
"SpawnBudget",
|
|
257
261
|
"SpawnCardinality",
|
|
258
262
|
"SpawnOpts",
|
|
259
263
|
"SqlFold",
|
|
@@ -296,11 +300,27 @@
|
|
|
296
300
|
"TurnGate",
|
|
297
301
|
"TurnRecord",
|
|
298
302
|
"TurnSpec",
|
|
303
|
+
"UI_BUNDLE_BOUNDS",
|
|
304
|
+
"UiAccess",
|
|
305
|
+
"UiBundle",
|
|
306
|
+
"UiBundleManifest",
|
|
307
|
+
"UiCRN",
|
|
308
|
+
"UiCapability",
|
|
309
|
+
"UiExecution",
|
|
310
|
+
"UiGovernanceMeter",
|
|
311
|
+
"UiHandler",
|
|
312
|
+
"UiResource",
|
|
313
|
+
"UiRuntimeContext",
|
|
314
|
+
"UiSource",
|
|
315
|
+
"UiSqlResult",
|
|
316
|
+
"UiState",
|
|
299
317
|
"UnknownTool",
|
|
300
318
|
"UpstreamPayer",
|
|
301
319
|
"Verdict",
|
|
302
320
|
"VerdictSamplingMode",
|
|
303
321
|
"ViewDef",
|
|
322
|
+
"WEB_FETCH_ARGUMENT_SCHEMA",
|
|
323
|
+
"WEB_SEARCH_ARGUMENT_SCHEMA",
|
|
304
324
|
"WaitResolvedEvent",
|
|
305
325
|
"action",
|
|
306
326
|
"actionPattern",
|
|
@@ -387,6 +407,10 @@
|
|
|
387
407
|
"trainingProvider",
|
|
388
408
|
"trainingProviderMetadata",
|
|
389
409
|
"trainingRecipe",
|
|
410
|
+
"uiBundle",
|
|
411
|
+
"uiBundleManifest",
|
|
412
|
+
"uiLimit",
|
|
413
|
+
"uiName",
|
|
390
414
|
"validateBatchSpec",
|
|
391
415
|
"validateFoldFn",
|
|
392
416
|
"validateJsonSchema",
|
package/publish/index.d.ts
CHANGED
|
@@ -228,6 +228,8 @@ interface CaseRow {
|
|
|
228
228
|
fact: FactRef;
|
|
229
229
|
agent?: string;
|
|
230
230
|
customer?: CustomerTenantCRN | null;
|
|
231
|
+
/** Exact immutable execution identity captured with a production Run. */
|
|
232
|
+
subject?: EvalSubject;
|
|
231
233
|
} | null;
|
|
232
234
|
tags: Record<string, string>;
|
|
233
235
|
}
|
|
@@ -726,7 +728,7 @@ declare function labelSelector(value: unknown): LabelSelector;
|
|
|
726
728
|
declare function resourceSelector<K extends CRNKind>(value: unknown, allowedKinds: readonly K[]): ResourceSelector<K>;
|
|
727
729
|
declare function matchesLabelSelector(selector: LabelSelector, labels: Record<string, string>): boolean;
|
|
728
730
|
|
|
729
|
-
declare const RESOURCE_KINDS: readonly ["agent", "channel", "auth-provider", "policy", "credential-provider", "credential", "tool", "scorer", "dataset", "model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
|
|
731
|
+
declare const RESOURCE_KINDS: readonly ["agent", "channel", "ui", "auth-provider", "policy", "credential-provider", "credential", "tool", "scorer", "dataset", "model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
|
|
730
732
|
declare const PLATFORM_ADDRESS_KINDS: readonly ["analytics", "role", "principal", "customer", "binding", "session", "run", "ledger", "table", "artifact", "deployment"];
|
|
731
733
|
declare const INVOKABLE_KINDS: readonly ["model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
|
|
732
734
|
type ResourceKind = typeof RESOURCE_KINDS[number];
|
|
@@ -749,6 +751,9 @@ type CredentialProviderCRN = CRN & {
|
|
|
749
751
|
type AuthProviderCRN = CRN & {
|
|
750
752
|
readonly __authProviderCRN: "AuthProviderCRN";
|
|
751
753
|
};
|
|
754
|
+
type UiCRN = CRN & {
|
|
755
|
+
readonly __uiCRN: "UiCRN";
|
|
756
|
+
};
|
|
752
757
|
type PolicyCRN = CRN & {
|
|
753
758
|
readonly __policyCRN: "PolicyCRN";
|
|
754
759
|
};
|
|
@@ -872,6 +877,15 @@ type SandboxNetworkPolicy = {
|
|
|
872
877
|
} | {
|
|
873
878
|
mode: "unrestricted";
|
|
874
879
|
};
|
|
880
|
+
interface ResourceHeader {
|
|
881
|
+
crn: CRN;
|
|
882
|
+
kind: ResourceKind;
|
|
883
|
+
version: string;
|
|
884
|
+
hash: Hash;
|
|
885
|
+
policies: PolicyCRN[];
|
|
886
|
+
/** Immutable user labels. The Registry adds protected identity labels during selection. */
|
|
887
|
+
labels?: Record<string, string>;
|
|
888
|
+
}
|
|
875
889
|
type UpstreamPayer = "platform" | "tenant";
|
|
876
890
|
interface ModelTechnicalCapabilities {
|
|
877
891
|
contextTokens: number;
|
|
@@ -894,6 +908,68 @@ interface PolicyDelegationCeiling {
|
|
|
894
908
|
resources: ResourcePattern[];
|
|
895
909
|
maxTtlMs: number;
|
|
896
910
|
}
|
|
911
|
+
type UiSource = {
|
|
912
|
+
kind: "template";
|
|
913
|
+
template: "chat";
|
|
914
|
+
version: string;
|
|
915
|
+
} | {
|
|
916
|
+
kind: "bundle";
|
|
917
|
+
artifact: {
|
|
918
|
+
cas: {
|
|
919
|
+
crn: CRN;
|
|
920
|
+
hash: Hash;
|
|
921
|
+
};
|
|
922
|
+
ref: Hash;
|
|
923
|
+
manifestHash: Hash;
|
|
924
|
+
format: "constal.ui.v1";
|
|
925
|
+
};
|
|
926
|
+
};
|
|
927
|
+
type UiAccess = {
|
|
928
|
+
mode: "public";
|
|
929
|
+
} | {
|
|
930
|
+
mode: "authenticated";
|
|
931
|
+
authProvider: {
|
|
932
|
+
crn: AuthProviderCRN;
|
|
933
|
+
hash: Hash;
|
|
934
|
+
};
|
|
935
|
+
};
|
|
936
|
+
type UiExecution = {
|
|
937
|
+
mode: "stateless";
|
|
938
|
+
} | {
|
|
939
|
+
mode: "durable";
|
|
940
|
+
storage: {
|
|
941
|
+
kind: "sqlite";
|
|
942
|
+
maximumBytes: number;
|
|
943
|
+
maximumRowsReadPerRequest: number;
|
|
944
|
+
maximumRowsWrittenPerRequest: number;
|
|
945
|
+
maximumResultBytes: number;
|
|
946
|
+
};
|
|
947
|
+
};
|
|
948
|
+
interface UiResource extends ResourceHeader {
|
|
949
|
+
crn: UiCRN;
|
|
950
|
+
kind: "ui";
|
|
951
|
+
displayName: string;
|
|
952
|
+
description: string;
|
|
953
|
+
source: UiSource;
|
|
954
|
+
target: {
|
|
955
|
+
channel: {
|
|
956
|
+
crn: CRN;
|
|
957
|
+
hash: Hash;
|
|
958
|
+
};
|
|
959
|
+
agent: {
|
|
960
|
+
crn: CRN;
|
|
961
|
+
hash: Hash;
|
|
962
|
+
};
|
|
963
|
+
};
|
|
964
|
+
access: UiAccess;
|
|
965
|
+
execution: UiExecution;
|
|
966
|
+
limits: {
|
|
967
|
+
requestBodyBytes: number;
|
|
968
|
+
responseBodyBytes: number;
|
|
969
|
+
cpuMs: number;
|
|
970
|
+
subrequests: number;
|
|
971
|
+
};
|
|
972
|
+
}
|
|
897
973
|
interface CredentialRotationDefaults {
|
|
898
974
|
mode: "manual" | "scheduled" | "auto";
|
|
899
975
|
intervalMs: number | null;
|
|
@@ -927,6 +1003,7 @@ declare function parseResourceName(value: string): ResourceNameParts;
|
|
|
927
1003
|
declare function credentialName(value: string): CredentialCRN;
|
|
928
1004
|
declare function credentialProviderName(value: string): CredentialProviderCRN;
|
|
929
1005
|
declare function authProviderName(value: string): AuthProviderCRN;
|
|
1006
|
+
declare function uiName(value: string): UiCRN;
|
|
930
1007
|
declare function policyName(value: string): PolicyCRN;
|
|
931
1008
|
declare function scorerName(value: string): ScorerCRN;
|
|
932
1009
|
declare function datasetName(value: string): DatasetCRN;
|
|
@@ -997,10 +1074,12 @@ interface ModelGovernanceControls {
|
|
|
997
1074
|
temperature_max: number;
|
|
998
1075
|
}
|
|
999
1076
|
type ModelGovernanceMeter = "cached_input_tokens" | "input_tokens" | "output_tokens" | "requests";
|
|
1077
|
+
type UiGovernanceMeter = "requests";
|
|
1000
1078
|
declare function sandboxControls(values: Partial<SandboxGovernanceControls>): ResourceControlsConstraint;
|
|
1001
1079
|
declare function sandboxLimit(input: AdmissionLimitInput<SandboxGovernanceMeter>): AdmissionLimitConstraint;
|
|
1002
1080
|
declare function modelControls(values: Partial<ModelGovernanceControls>): ResourceControlsConstraint;
|
|
1003
1081
|
declare function modelLimit(input: AdmissionLimitInput<ModelGovernanceMeter>): AdmissionLimitConstraint;
|
|
1082
|
+
declare function uiLimit(input: AdmissionLimitInput<UiGovernanceMeter>): AdmissionLimitConstraint;
|
|
1004
1083
|
|
|
1005
1084
|
type PrincipalKind = "user" | "service" | "channel" | "agent" | "anonymous";
|
|
1006
1085
|
interface CustomerPrincipalContext {
|
|
@@ -1048,8 +1127,11 @@ type PolicyInvocationOrigin = {
|
|
|
1048
1127
|
tool: CRN | null;
|
|
1049
1128
|
} | {
|
|
1050
1129
|
kind: "ingress";
|
|
1051
|
-
|
|
1052
|
-
|
|
1130
|
+
target: {
|
|
1131
|
+
kind: "channel" | "ui";
|
|
1132
|
+
crn: CRN;
|
|
1133
|
+
};
|
|
1134
|
+
authProvider: CRN | null;
|
|
1053
1135
|
} | {
|
|
1054
1136
|
kind: "channel";
|
|
1055
1137
|
channel: CRN;
|
|
@@ -1415,10 +1497,23 @@ interface Task<T> {
|
|
|
1415
1497
|
version: string;
|
|
1416
1498
|
run(input: any, ctx: Ctx): Promise<T>;
|
|
1417
1499
|
}
|
|
1500
|
+
interface SpawnBudget {
|
|
1501
|
+
turns: number;
|
|
1502
|
+
microUsd: number;
|
|
1503
|
+
wallMs: number;
|
|
1504
|
+
}
|
|
1505
|
+
/** Exact local Resource and Tool names retained by a child Run. Omitted names
|
|
1506
|
+
* are unavailable to the child even when they are bound to the parent. */
|
|
1507
|
+
interface SpawnAttenuation {
|
|
1508
|
+
bindings: readonly string[];
|
|
1509
|
+
tools: readonly string[];
|
|
1510
|
+
}
|
|
1418
1511
|
interface SpawnOpts {
|
|
1419
1512
|
retries?: number;
|
|
1420
1513
|
dedupe?: "specHash";
|
|
1421
1514
|
from?: BranchRef;
|
|
1515
|
+
budget?: SpawnBudget;
|
|
1516
|
+
attenuation?: SpawnAttenuation;
|
|
1422
1517
|
}
|
|
1423
1518
|
interface AwaitOpts<T> {
|
|
1424
1519
|
timeout?: number;
|
|
@@ -1488,6 +1583,11 @@ interface Tool {
|
|
|
1488
1583
|
needs?: ResourceNeed[];
|
|
1489
1584
|
tier?: Tier;
|
|
1490
1585
|
guard?(args: any, ctx: Ctx): string | null;
|
|
1586
|
+
/**
|
|
1587
|
+
* Return a bounded, deterministic, secret-safe projection of a large result
|
|
1588
|
+
* for later model Turns. The runtime retains the complete result by Ref.
|
|
1589
|
+
*/
|
|
1590
|
+
preview?(result: any): unknown;
|
|
1491
1591
|
once?: "per-run-and-args" | "per-run";
|
|
1492
1592
|
run(args: any, ctx: Ctx): Promise<any>;
|
|
1493
1593
|
}
|
|
@@ -1525,6 +1625,8 @@ interface TurnSpec {
|
|
|
1525
1625
|
gate?: TurnGate;
|
|
1526
1626
|
model?: string;
|
|
1527
1627
|
stream?: boolean;
|
|
1628
|
+
/** Requested output ceiling for this turn. The bound Model and Policy may lower it. */
|
|
1629
|
+
maxOutputTokens?: number;
|
|
1528
1630
|
}
|
|
1529
1631
|
interface ToolCallRecord {
|
|
1530
1632
|
id: string;
|
|
@@ -1543,6 +1645,8 @@ interface ToolCallRecord {
|
|
|
1543
1645
|
actor: Actor;
|
|
1544
1646
|
valueRef?: Ref;
|
|
1545
1647
|
};
|
|
1648
|
+
policyDecisionHash?: Hash;
|
|
1649
|
+
refusal?: "policy" | "guard";
|
|
1546
1650
|
}
|
|
1547
1651
|
interface TurnRecord {
|
|
1548
1652
|
hash: Hash;
|
|
@@ -1820,12 +1924,14 @@ declare function validateFoldFn<I, O>(fn: FoldFn<I, O> | SqlFold): FoldFn<I, O>
|
|
|
1820
1924
|
declare function agent<S>(def: AgentDef<S>): AgentDef<S>;
|
|
1821
1925
|
declare function subtask<T>(def: Task<T>): Task<T>;
|
|
1822
1926
|
|
|
1823
|
-
interface
|
|
1927
|
+
interface IngressRequest {
|
|
1824
1928
|
method: string;
|
|
1825
1929
|
url: string;
|
|
1826
1930
|
headers: Record<string, string>;
|
|
1827
1931
|
bodyBase64: string | null;
|
|
1828
1932
|
}
|
|
1933
|
+
/** The Channel protocol consumes the shared bounded ingress envelope. */
|
|
1934
|
+
type ChannelRequest = IngressRequest;
|
|
1829
1935
|
interface ChannelResponse {
|
|
1830
1936
|
status: number;
|
|
1831
1937
|
headers?: Record<string, string>;
|
|
@@ -1920,9 +2026,13 @@ interface Channel<Input = unknown, Output = unknown, Delivery = Output> {
|
|
|
1920
2026
|
}
|
|
1921
2027
|
declare function channel<I, O, D = O>(definition: Channel<I, O, D>): Channel<I, O, D>;
|
|
1922
2028
|
|
|
2029
|
+
interface IngressTarget {
|
|
2030
|
+
kind: "channel" | "ui";
|
|
2031
|
+
crn: CRN;
|
|
2032
|
+
}
|
|
1923
2033
|
interface AuthProviderRequest {
|
|
1924
|
-
request:
|
|
1925
|
-
|
|
2034
|
+
request: IngressRequest;
|
|
2035
|
+
ingress: IngressTarget;
|
|
1926
2036
|
audience: CRN;
|
|
1927
2037
|
}
|
|
1928
2038
|
type AuthProviderResult = {
|
|
@@ -1940,7 +2050,7 @@ type AuthProviderResult = {
|
|
|
1940
2050
|
interface AuthProviderContext {
|
|
1941
2051
|
requestId: string;
|
|
1942
2052
|
provider: AuthProviderCRN;
|
|
1943
|
-
|
|
2053
|
+
ingress: IngressTarget;
|
|
1944
2054
|
resources: Record<string, CRN>;
|
|
1945
2055
|
invoke<T>(resource: CRN, op: string, args: unknown): Promise<T>;
|
|
1946
2056
|
}
|
|
@@ -1952,6 +2062,81 @@ interface AuthProvider {
|
|
|
1952
2062
|
}
|
|
1953
2063
|
declare function authProvider(definition: AuthProvider): AuthProvider;
|
|
1954
2064
|
|
|
2065
|
+
declare const UI_BUNDLE_BOUNDS: Readonly<{
|
|
2066
|
+
maximumManifestBytes: 16384;
|
|
2067
|
+
maximumModules: 128;
|
|
2068
|
+
maximumAssets: 512;
|
|
2069
|
+
maximumFileBytes: 4194304;
|
|
2070
|
+
maximumExpandedBytes: 16777216;
|
|
2071
|
+
}>;
|
|
2072
|
+
interface UiBundleManifest {
|
|
2073
|
+
schemaVersion: 1;
|
|
2074
|
+
kind: "constal.ui";
|
|
2075
|
+
runtime: {
|
|
2076
|
+
contract: "constal.ui-handler.v1";
|
|
2077
|
+
entry: string;
|
|
2078
|
+
};
|
|
2079
|
+
state?: {
|
|
2080
|
+
schemaVersion: number;
|
|
2081
|
+
compatibleSchemaVersions: {
|
|
2082
|
+
minimum: number;
|
|
2083
|
+
maximum: number;
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
assets: {
|
|
2087
|
+
root: string;
|
|
2088
|
+
fallback: string;
|
|
2089
|
+
};
|
|
2090
|
+
contentSecurityPolicy: "strict";
|
|
2091
|
+
}
|
|
2092
|
+
interface UiBundle {
|
|
2093
|
+
manifest: UiBundleManifest;
|
|
2094
|
+
modules: Record<string, {
|
|
2095
|
+
type: "esmodule";
|
|
2096
|
+
source: string;
|
|
2097
|
+
}>;
|
|
2098
|
+
assets: Record<string, {
|
|
2099
|
+
bodyBase64: string;
|
|
2100
|
+
contentType: string;
|
|
2101
|
+
}>;
|
|
2102
|
+
}
|
|
2103
|
+
interface UiCapability {
|
|
2104
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
2105
|
+
}
|
|
2106
|
+
interface UiSqlResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
2107
|
+
rows: Row[];
|
|
2108
|
+
rowsRead: number;
|
|
2109
|
+
rowsWritten: number;
|
|
2110
|
+
databaseSize: number;
|
|
2111
|
+
}
|
|
2112
|
+
interface UiState {
|
|
2113
|
+
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, bindings?: unknown[]): UiSqlResult<Row>;
|
|
2114
|
+
batch(statements: Array<{
|
|
2115
|
+
sql: string;
|
|
2116
|
+
bindings?: unknown[];
|
|
2117
|
+
}>): UiSqlResult[];
|
|
2118
|
+
}
|
|
2119
|
+
interface UiRuntimeContext {
|
|
2120
|
+
ui: CRN;
|
|
2121
|
+
revision: Hash;
|
|
2122
|
+
publicBaseUrl: string;
|
|
2123
|
+
assets: UiCapability;
|
|
2124
|
+
channel: UiCapability;
|
|
2125
|
+
state?: UiState;
|
|
2126
|
+
}
|
|
2127
|
+
interface UiHandler {
|
|
2128
|
+
fetch(request: Request, context: UiRuntimeContext): Response | Promise<Response>;
|
|
2129
|
+
/** Runs without network capabilities inside one synchronous SQLite transaction. */
|
|
2130
|
+
migrate?(migration: {
|
|
2131
|
+
from: number | null;
|
|
2132
|
+
to: number;
|
|
2133
|
+
}, context: Pick<UiRuntimeContext, "ui" | "revision" | "publicBaseUrl"> & {
|
|
2134
|
+
state: UiState;
|
|
2135
|
+
}): void;
|
|
2136
|
+
}
|
|
2137
|
+
declare function uiBundleManifest(value: unknown, execution: UiExecution["mode"]): UiBundleManifest;
|
|
2138
|
+
declare function uiBundle(value: unknown, execution: UiExecution["mode"]): UiBundle;
|
|
2139
|
+
|
|
1955
2140
|
interface PolicyDefinition {
|
|
1956
2141
|
id: string;
|
|
1957
2142
|
version: string;
|
|
@@ -1989,8 +2174,88 @@ interface CatalogTool extends Tool {
|
|
|
1989
2174
|
op: string;
|
|
1990
2175
|
};
|
|
1991
2176
|
}
|
|
1992
|
-
declare function opTool(binding: string, op: string, override?: Partial<Pick<Tool, "name" | "description" | "tier" | "once" | "guard">>): CatalogTool;
|
|
2177
|
+
declare function opTool(binding: string, op: string, override?: Partial<Pick<Tool, "name" | "description" | "schema" | "tier" | "once" | "guard" | "preview">>): CatalogTool;
|
|
1993
2178
|
declare function opTools(binding: string, ops?: string[]): CatalogTool[];
|
|
2179
|
+
declare const WEB_FETCH_ARGUMENT_SCHEMA: {
|
|
2180
|
+
readonly type: "object";
|
|
2181
|
+
readonly required: readonly ["url"];
|
|
2182
|
+
readonly additionalProperties: false;
|
|
2183
|
+
readonly properties: {
|
|
2184
|
+
readonly url: {
|
|
2185
|
+
readonly type: "string";
|
|
2186
|
+
readonly minLength: 1;
|
|
2187
|
+
readonly maxLength: 2048;
|
|
2188
|
+
};
|
|
2189
|
+
readonly accept: {
|
|
2190
|
+
readonly type: "string";
|
|
2191
|
+
readonly maxLength: 256;
|
|
2192
|
+
};
|
|
2193
|
+
};
|
|
2194
|
+
};
|
|
2195
|
+
declare const WEB_SEARCH_ARGUMENT_SCHEMA: {
|
|
2196
|
+
readonly type: "object";
|
|
2197
|
+
readonly required: readonly ["query"];
|
|
2198
|
+
readonly additionalProperties: false;
|
|
2199
|
+
readonly properties: {
|
|
2200
|
+
readonly query: {
|
|
2201
|
+
readonly type: "string";
|
|
2202
|
+
readonly minLength: 1;
|
|
2203
|
+
readonly maxLength: 4096;
|
|
2204
|
+
readonly description: "A self-contained description of the information to find.";
|
|
2205
|
+
};
|
|
2206
|
+
readonly searchQueries: {
|
|
2207
|
+
readonly type: "array";
|
|
2208
|
+
readonly minItems: 1;
|
|
2209
|
+
readonly maxItems: 3;
|
|
2210
|
+
readonly uniqueItems: true;
|
|
2211
|
+
readonly description: "Optional concise keyword queries that narrow the search.";
|
|
2212
|
+
readonly items: {
|
|
2213
|
+
readonly type: "string";
|
|
2214
|
+
readonly minLength: 1;
|
|
2215
|
+
readonly maxLength: 256;
|
|
2216
|
+
};
|
|
2217
|
+
};
|
|
2218
|
+
readonly maximumResults: {
|
|
2219
|
+
readonly type: "integer";
|
|
2220
|
+
readonly minimum: 1;
|
|
2221
|
+
readonly maximum: 20;
|
|
2222
|
+
readonly description: "Maximum number of sources to return.";
|
|
2223
|
+
};
|
|
2224
|
+
readonly maximumCharacters: {
|
|
2225
|
+
readonly type: "integer";
|
|
2226
|
+
readonly minimum: 1000;
|
|
2227
|
+
readonly maximum: 60000;
|
|
2228
|
+
readonly description: "Maximum total excerpt characters to return.";
|
|
2229
|
+
};
|
|
2230
|
+
readonly includeDomains: {
|
|
2231
|
+
readonly type: "array";
|
|
2232
|
+
readonly maxItems: 50;
|
|
2233
|
+
readonly uniqueItems: true;
|
|
2234
|
+
readonly description: "Optional domains to restrict results to.";
|
|
2235
|
+
readonly items: {
|
|
2236
|
+
readonly type: "string";
|
|
2237
|
+
readonly minLength: 1;
|
|
2238
|
+
readonly maxLength: 253;
|
|
2239
|
+
};
|
|
2240
|
+
};
|
|
2241
|
+
readonly excludeDomains: {
|
|
2242
|
+
readonly type: "array";
|
|
2243
|
+
readonly maxItems: 50;
|
|
2244
|
+
readonly uniqueItems: true;
|
|
2245
|
+
readonly description: "Optional domains to omit.";
|
|
2246
|
+
readonly items: {
|
|
2247
|
+
readonly type: "string";
|
|
2248
|
+
readonly minLength: 1;
|
|
2249
|
+
readonly maxLength: 253;
|
|
2250
|
+
};
|
|
2251
|
+
};
|
|
2252
|
+
readonly afterDate: {
|
|
2253
|
+
readonly type: "string";
|
|
2254
|
+
readonly pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
|
|
2255
|
+
readonly description: "Optional earliest publication date in YYYY-MM-DD form.";
|
|
2256
|
+
};
|
|
2257
|
+
};
|
|
2258
|
+
};
|
|
1994
2259
|
declare const webFetch: CatalogTool;
|
|
1995
2260
|
declare const webSearch: CatalogTool;
|
|
1996
2261
|
declare const casTool: Tool;
|
|
@@ -2519,5 +2784,5 @@ declare class SessionDeleted extends Error {
|
|
|
2519
2784
|
constructor(session: string);
|
|
2520
2785
|
}
|
|
2521
2786
|
|
|
2522
|
-
export { AfterYield, ApiError, CommitConflict, CommitGateRejected, CredentialRevoked, CredentialUnavailable, DirectNetworkDenied, EffectCeilingExceeded, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, NondeterministicReplay, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TerminalIntegrationFailure, ToolUnavailable, UnknownTool, action, actionPattern, agent, agentResourceBinding, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, customerTenantName, cutBatches, cutPartitions, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, integrationEgressPolicy, labelSelector, matchesAction, matchesLabelSelector, matchesResource, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelLimit, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeModelGatewayConfig, normalizeSandboxNetworkPolicy, opTool, opTools, parseResourceName, policy, policyName, renderTrainingCompletion, resolveGatewayEgress, resourceContractRef, resourceCredentialBinding, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, sandboxControls, sandboxLimit, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scorerName, sha256Hex, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingProvider, trainingProviderMetadata, trainingRecipe, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
|
|
2523
|
-
export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentDef, AgentDeployPolicy, AnalyticsClient, AnalyticsDimensionValue, AnalyticsEventDefinition, AnalyticsIntent, AnalyticsValues, AuthProvider, AuthProviderCRN, AuthProviderContext, AuthProviderRequest, AuthProviderResult, AwaitOpts, BatchSpec, BindingCRN, BindingOwnerScope, BranchRef, CRN, CRNKind, CanonicalEvent, CanonicalEventDraft, CapabilityContractRef, CapabilityGrant, CapabilityRef, CaptureCaseRequest, CaseRow, CatalogTool, Channel, ChannelAlarm, ChannelAlarmResult, ChannelContext, ChannelMessage, ChannelProtocol, ChannelRequest, ChannelResponse, CheckpointDeploymentRequest, CheckpointImportMetadata, CheckpointImportRequest, CodeScoreResult, CodeScorerIR, CodeScorerRule, CommitOpts, CompareSuitesRequest, Compensation, ConnectionCancelRequest, ConnectionIdentity, ConnectionOperation, ConnectionRecoveryRequest, ConnectionRecoveryResult, ConnectionRequest, ConnectionUsageReport, ControlEvent, Cost, CreateSandboxOptions, CredentialCRN, CredentialDestroyResult, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialProviderCRN, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EventBase, Fact, FactRef, FileEntry, FixedMemoryStoreRef, FixedModelGatewayRef, FoldFn, GateEvidence, GateResult, GateVerdict, GatewayCancelRequest, GatewayConfigEgressBinding, GatewayContext, GatewayCredentialSlotSetup, GatewayDefinition, GatewayDiscoverySetup, GatewayModelOffer, GatewayOperation, GatewayPackage, GatewayPackageMetadata, GatewayRecoveryRequest, GatewayRecoveryResult, GatewayRequest, GovernanceContractRef, Handle, HandleOutcome, Hash, HistoryView, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationSecret, IntegrationState, InvokableKind, InvokeOpts, JsonScalar, JsonValue, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerEvent, ManifestIndexPage, MapFact, MapOpts, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCredentialHeader, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGovernanceControls, ModelGovernanceMeter, ModelInvocationArgs, ModelInvocationResult, ModelTechnicalCapabilities, ModelTool, NormalizedModelGatewayConfig, Out, Over, PartitionFn, PartitionSpec, Partitioning, PolicyCRN, PolicyConstraint, PolicyContextValue, PolicyDefinition, PolicyInput, PolicyInvocationOrigin, PolicyOutcome, Principal, PrincipalKind, Provenance, Recovery, ReduceFact, ReduceOpts, Ref, RequestLabelRequest, ResourceContractRef, ResourceControlsConstraint, ResourceCredentialBinding, ResourceKind, ResourceName, ResourceNameParts, ResourceNeed, ResourcePattern, ResourceSelector, RollbackReport, RunIdentityView, RunInfo, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCommandResult, SandboxExecInput, SandboxFileResult, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxImage, SandboxMutationResult, SandboxNetworkMode, SandboxNetworkPolicy, SandboxPool, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SortField, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingUsageUnits, TurnDraft, TurnGate, TurnRecord, TurnSpec, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };
|
|
2787
|
+
export { AfterYield, ApiError, CommitConflict, CommitGateRejected, CredentialRevoked, CredentialUnavailable, DirectNetworkDenied, EffectCeilingExceeded, GateExhausted, IntegrationRequestNotSent, LeaseLost, MCP_CLIENT_CAPABILITY, MEMORY_OPERATION_DECLARATIONS, MODEL_CHECKPOINT_IMPORT_CAPABILITY, MODEL_COMPLETION_CAPABILITY, NondeterministicReplay, OutcomeUnknown, PolicyConstraintFailed, PolicyDecisionFailed, ResourceDisabled, ResourceInvalid, ResourceUnbound, RollbackTargetInvalid, SessionDeleted, SpawnCardinality, SwallowedYield, TRAINING_PROVIDER_CAPABILITY, TerminalIntegrationFailure, ToolUnavailable, UI_BUNDLE_BOUNDS, UnknownTool, WEB_FETCH_ARGUMENT_SCHEMA, WEB_SEARCH_ARGUMENT_SCHEMA, action, actionPattern, agent, agentResourceBinding, analyticsEvent, approximateTokens, authProvider, authProviderName, bindingName, bucketFor, canonicalJson, capabilityContractRef, casTool, channel, checkpointArtifactRef, checkpointDeploymentRequest, checkpointImportMetadata, checkpointImportRequest, codeScorerIR, credentialInteractionAction, credentialInteractionEvent, credentialInteractionResult, credentialName, credentialProvider, credentialProviderConfigSchema, credentialProviderName, credentialProviderSetupMetadata, credentialRotationDefaults, customerTenantName, cutBatches, cutPartitions, datasetName, evaluateCodeScorer, evaluatePolicyDefinition, gateway, gatewayModelOffer, gatewayPackageMetadata, hash, hashValue, integrationEgressPolicy, labelSelector, matchesAction, matchesLabelSelector, matchesResource, memoryStoreBinding, modelAdvertisedPricing, modelControls, modelGatewayBinding, modelGatewayEndpoint, modelLimit, modelPrompt, modelProtocolRequest, modelProtocolResult, murmur3_32, normalizeModelGatewayConfig, normalizeSandboxNetworkPolicy, opTool, opTools, parseResourceName, policy, policyName, renderTrainingCompletion, resolveGatewayEgress, resourceContractRef, resourceCredentialBinding, resourceLabelMap, resourceName, resourceNeed, resourcePattern, resourceSelector, sandboxControls, sandboxLimit, scopedBindingKey, scopedCredentialRef, scopedResourceRef, scorerName, sha256Hex, stageOutput, startTrainingRequest, subtask, tableDescribe, tableQuery, trainingProvider, trainingProviderMetadata, trainingRecipe, uiBundle, uiBundleManifest, uiLimit, uiName, validateBatchSpec, validateFoldFn, validateJsonSchema, validateJsonSchemaDefinition, validatePartitionFn, validatePartitionSpec, validateStageOutputSpec, validateTool, validateView, webFetch, webSearch };
|
|
2788
|
+
export type { Action, ActionPattern, Actor, AdmissionLimitConstraint, AdmissionLimitInput, AdmissionLimitScope, AdmissionLimitWindow, Agent, AgentDef, AgentDeployPolicy, AnalyticsClient, AnalyticsDimensionValue, AnalyticsEventDefinition, AnalyticsIntent, AnalyticsValues, AuthProvider, AuthProviderCRN, AuthProviderContext, AuthProviderRequest, AuthProviderResult, AwaitOpts, BatchSpec, BindingCRN, BindingOwnerScope, BranchRef, CRN, CRNKind, CanonicalEvent, CanonicalEventDraft, CapabilityContractRef, CapabilityGrant, CapabilityRef, CaptureCaseRequest, CaseRow, CatalogTool, Channel, ChannelAlarm, ChannelAlarmResult, ChannelContext, ChannelMessage, ChannelProtocol, ChannelRequest, ChannelResponse, CheckpointDeploymentRequest, CheckpointImportMetadata, CheckpointImportRequest, CodeScoreResult, CodeScorerIR, CodeScorerRule, CommitOpts, CompareSuitesRequest, Compensation, ConnectionCancelRequest, ConnectionIdentity, ConnectionOperation, ConnectionRecoveryRequest, ConnectionRecoveryResult, ConnectionRequest, ConnectionUsageReport, ControlEvent, Cost, CreateSandboxOptions, CredentialCRN, CredentialDestroyResult, CredentialInteractionAction, CredentialInteractionAdvanceRequest, CredentialInteractionEvent, CredentialInteractionPrimaryAction, CredentialInteractionProof, CredentialInteractionResult, CredentialInteractionStartRequest, CredentialMaterialRequest, CredentialMintRequest, CredentialMintResult, CredentialProviderCRN, CredentialProviderContext, CredentialProviderCredentialSlotSetup, CredentialProviderDefinition, CredentialProviderPackage, CredentialProviderPackageMetadata, CredentialProviderSecretInput, CredentialProviderSetupMetadata, CredentialVerifyResult, Ctx, CustomerTenantCRN, DataManifest, DatasetCRN, DatasetDraft, DatasetRef, DelegatedGrant, DelegationCeiling, DeliveryMode, DeliveryReceipt, DispatchResult, EffectClass, EvalComparison, EvalDivergence, EvalMode, EvalSubject, EvalSubjectSource, EventBase, Fact, FactRef, FileEntry, FixedMemoryStoreRef, FixedModelGatewayRef, FoldFn, GateEvidence, GateResult, GateVerdict, GatewayCancelRequest, GatewayConfigEgressBinding, GatewayContext, GatewayCredentialSlotSetup, GatewayDefinition, GatewayDiscoverySetup, GatewayModelOffer, GatewayOperation, GatewayPackage, GatewayPackageMetadata, GatewayRecoveryRequest, GatewayRecoveryResult, GatewayRequest, GovernanceContractRef, Handle, HandleOutcome, Hash, HistoryView, IngressRequest, IngressTarget, IntegrationContext, IntegrationEgressPolicy, IntegrationEgressRequest, IntegrationEgressResponse, IntegrationEgressRule, IntegrationSecret, IntegrationState, InvokableKind, InvokeOpts, JsonScalar, JsonValue, LabelRequest, LabelSelector, LabelSelectorOperator, LabelSelectorRequirement, LedgerAddress, LedgerEvent, ManifestIndexPage, MapFact, MapOpts, MemoryDeleteArgs, MemoryGetArgs, MemoryRecord, MemoryRememberArgs, MemorySearchArgs, MemorySearchHit, MemoryStoreBinding, Mode, ModelAdvertisedPricing, ModelCredentialHeader, ModelGatewayBinding, ModelGatewayConfig, ModelGatewayProtocol, ModelGovernanceControls, ModelGovernanceMeter, ModelInvocationArgs, ModelInvocationResult, ModelTechnicalCapabilities, ModelTool, NormalizedModelGatewayConfig, Out, Over, PartitionFn, PartitionSpec, Partitioning, PolicyCRN, PolicyConstraint, PolicyContextValue, PolicyDefinition, PolicyInput, PolicyInvocationOrigin, PolicyOutcome, Principal, PrincipalKind, Provenance, Recovery, ReduceFact, ReduceOpts, Ref, RequestLabelRequest, ResourceContractRef, ResourceControlsConstraint, ResourceCredentialBinding, ResourceKind, ResourceName, ResourceNameParts, ResourceNeed, ResourcePattern, ResourceSelector, RollbackReport, RunIdentityView, RunInfo, RunStatusDetail, RunSuiteRequest, Sandbox, SandboxCommandResult, SandboxExecInput, SandboxFileResult, SandboxGovernanceControls, SandboxGovernanceMeter, SandboxImage, SandboxMutationResult, SandboxNetworkMode, SandboxNetworkPolicy, SandboxPool, ScopedBindingKey, ScopedCredentialRef, ScopedMemoryStoreRef, ScopedModelGatewayRef, ScopedResourceRef, ScoreRequest, ScorerApplies, ScorerCRN, ScorerDef, ScorerEvaluation, ScorerKind, ScorerRef, ScorerVerdictIntent, SetEvalBaselineRequest, SortField, SpawnAttenuation, SpawnBudget, SpawnOpts, SqlFold, StageInfo, StageOutputSpec, StartTrainingRequest, SteerEvent, SuiteFact, TableAggregate, TableDescribeArgs, TableFilter, TableFilterOperation, TableOrder, TableQueryArgs, TableQueryPlan, TableQueryResult, TableScalar, TableSnapshotDescription, Task, Tier, Tool, ToolCallRecord, TrainingJobFact, TrainingJobReference, TrainingJobState, TrainingJobStatus, TrainingMethod, TrainingModelOffer, TrainingProviderDefinition, TrainingProviderMetadata, TrainingProviderPin, TrainingRecipe, TrainingResumePoint, TrainingUsageUnits, TurnDraft, TurnGate, TurnRecord, TurnSpec, UiAccess, UiBundle, UiBundleManifest, UiCRN, UiCapability, UiExecution, UiGovernanceMeter, UiHandler, UiResource, UiRuntimeContext, UiSource, UiSqlResult, UiState, UpstreamPayer, Verdict, VerdictSamplingMode, ViewDef, WaitResolvedEvent };
|
package/publish/index.js
CHANGED
|
@@ -392,6 +392,7 @@ function matchesLabelSelector(selector, labels) {
|
|
|
392
392
|
var RESOURCE_KINDS = [
|
|
393
393
|
"agent",
|
|
394
394
|
"channel",
|
|
395
|
+
"ui",
|
|
395
396
|
"auth-provider",
|
|
396
397
|
"policy",
|
|
397
398
|
"credential-provider",
|
|
@@ -425,6 +426,17 @@ var PLATFORM_ADDRESS_KINDS = [
|
|
|
425
426
|
];
|
|
426
427
|
var INVOKABLE_KINDS = ["model", "memory", "cas", "web", "service", "mcp", "db", "browser", "sandbox-pool", "vault"];
|
|
427
428
|
var POLICY_TARGET_KINDS = [...RESOURCE_KINDS, ...PLATFORM_ADDRESS_KINDS];
|
|
429
|
+
var UI_RESOURCE_BOUNDS = Object.freeze({
|
|
430
|
+
maximumRequestBodyBytes: 1048576,
|
|
431
|
+
maximumResponseBodyBytes: 16777216,
|
|
432
|
+
maximumCpuMs: 3e4,
|
|
433
|
+
maximumSubrequests: 100,
|
|
434
|
+
maximumDatabaseBytes: 1073741824,
|
|
435
|
+
maximumRowsReadPerRequest: 1e6,
|
|
436
|
+
maximumRowsWrittenPerRequest: 1e5,
|
|
437
|
+
maximumSqlResultBytes: 1048576
|
|
438
|
+
});
|
|
439
|
+
var ACTION_PATTERN = /^[a-z][a-z0-9-]{0,63}:[a-z][a-z0-9-]{0,63}$/u;
|
|
428
440
|
var SEGMENT = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
|
|
429
441
|
var PATH = /^[A-Za-z0-9._~/%-]{1,512}$/u;
|
|
430
442
|
var NAME2 = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
|
|
@@ -587,6 +599,10 @@ function authProviderName(value) {
|
|
|
587
599
|
if (parseResourceName(value).kind !== "auth-provider") throw new TypeError("AuthProvider CRN is invalid");
|
|
588
600
|
return value;
|
|
589
601
|
}
|
|
602
|
+
function uiName(value) {
|
|
603
|
+
if (parseResourceName(value).kind !== "ui") throw new TypeError("UI CRN is invalid");
|
|
604
|
+
return value;
|
|
605
|
+
}
|
|
590
606
|
function policyName(value) {
|
|
591
607
|
if (parseResourceName(value).kind !== "policy") throw new TypeError("Policy CRN is invalid");
|
|
592
608
|
return value;
|
|
@@ -624,7 +640,7 @@ function matchesResource(pattern, value) {
|
|
|
624
640
|
return wildcard(pattern, value);
|
|
625
641
|
}
|
|
626
642
|
function action(value) {
|
|
627
|
-
if (
|
|
643
|
+
if (!ACTION_PATTERN.test(value)) throw new TypeError("action is invalid");
|
|
628
644
|
return value;
|
|
629
645
|
}
|
|
630
646
|
function actionPattern(value) {
|
|
@@ -777,6 +793,7 @@ function validateTool(tool, path = "tool") {
|
|
|
777
793
|
requiredString(tool.version, `${path}.version`);
|
|
778
794
|
if (!["read-only", "idempotent", "reconcilable", "non-idempotent"].includes(tool.maxEffect)) throw new TypeError(`${path}.maxEffect is invalid`);
|
|
779
795
|
tool.needs?.forEach(resourceNeed);
|
|
796
|
+
if (tool.preview !== void 0 && typeof tool.preview !== "function") throw new TypeError(`${path}.preview must be a function`);
|
|
780
797
|
if (typeof tool.run !== "function") throw new TypeError(`${path}.run must be a function`);
|
|
781
798
|
return tool;
|
|
782
799
|
}
|
|
@@ -866,6 +883,124 @@ function channel(definition) {
|
|
|
866
883
|
return definition;
|
|
867
884
|
}
|
|
868
885
|
|
|
886
|
+
// src/ui.ts
|
|
887
|
+
var PATH2 = /^(?!\/)(?!.*(?:^|\/)\.\.?\/?)(?!.*\/\/)[A-Za-z0-9._~/-]{1,256}$/u;
|
|
888
|
+
var CONTENT_TYPE = /^[A-Za-z0-9!#$&^_.+-]+\/[A-Za-z0-9!#$&^_.+-]+(?:; charset=utf-8)?$/u;
|
|
889
|
+
var BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
890
|
+
var SECRET = /(?:sk_(?:live|test)_[A-Za-z0-9]{16,}|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|CONSTAL_API_KEY\s*=|\.env(?:\.|\/|$))/u;
|
|
891
|
+
var PLATFORM_MODULE_PREFIX = "__constal_";
|
|
892
|
+
var UI_BUNDLE_BOUNDS = Object.freeze({
|
|
893
|
+
maximumManifestBytes: 16384,
|
|
894
|
+
maximumModules: 128,
|
|
895
|
+
maximumAssets: 512,
|
|
896
|
+
maximumFileBytes: 4194304,
|
|
897
|
+
maximumExpandedBytes: 16777216
|
|
898
|
+
});
|
|
899
|
+
function object(value, message) {
|
|
900
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError(message);
|
|
901
|
+
return value;
|
|
902
|
+
}
|
|
903
|
+
function exactKeys(value, allowed, required2) {
|
|
904
|
+
if (Object.keys(value).some((key) => !allowed.includes(key)) || required2.some((key) => !Object.hasOwn(value, key))) {
|
|
905
|
+
throw new TypeError("UI bundle contains unsupported fields");
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function safePath(value, label) {
|
|
909
|
+
if (typeof value !== "string" || !PATH2.test(value) || value.split("/").some((part) => part === "." || part === "..")) {
|
|
910
|
+
throw new TypeError(`${label} is invalid`);
|
|
911
|
+
}
|
|
912
|
+
return value;
|
|
913
|
+
}
|
|
914
|
+
function byteLength(value) {
|
|
915
|
+
return new TextEncoder().encode(value).byteLength;
|
|
916
|
+
}
|
|
917
|
+
function uiBundleManifest(value, execution) {
|
|
918
|
+
const manifest = object(value, "UI bundle manifest is invalid");
|
|
919
|
+
exactKeys(
|
|
920
|
+
manifest,
|
|
921
|
+
["schemaVersion", "kind", "runtime", "state", "assets", "contentSecurityPolicy"],
|
|
922
|
+
["schemaVersion", "kind", "runtime", "assets", "contentSecurityPolicy"]
|
|
923
|
+
);
|
|
924
|
+
const runtime = object(manifest.runtime, "UI bundle runtime is invalid");
|
|
925
|
+
const assets = object(manifest.assets, "UI bundle assets manifest is invalid");
|
|
926
|
+
exactKeys(runtime, ["contract", "entry"], ["contract", "entry"]);
|
|
927
|
+
exactKeys(assets, ["root", "fallback"], ["root", "fallback"]);
|
|
928
|
+
if (manifest.schemaVersion !== 1 || manifest.kind !== "constal.ui" || runtime.contract !== "constal.ui-handler.v1" || manifest.contentSecurityPolicy !== "strict") throw new TypeError("UI bundle manifest contract is unsupported");
|
|
929
|
+
const entry = safePath(runtime.entry, "UI bundle entry");
|
|
930
|
+
const root = safePath(assets.root, "UI asset root");
|
|
931
|
+
const fallback = safePath(assets.fallback, "UI asset fallback");
|
|
932
|
+
if (!entry.endsWith(".mjs") || fallback.startsWith(`${root}/`)) throw new TypeError("UI bundle entry or asset fallback is invalid");
|
|
933
|
+
if (byteLength(JSON.stringify(manifest)) > UI_BUNDLE_BOUNDS.maximumManifestBytes) throw new TypeError("UI bundle manifest exceeds 16 KiB");
|
|
934
|
+
let state;
|
|
935
|
+
if (execution === "stateless") {
|
|
936
|
+
if (manifest.state !== void 0) throw new TypeError("stateless UI bundles cannot declare SQLite state");
|
|
937
|
+
} else {
|
|
938
|
+
const raw = object(manifest.state, "durable UI bundles require a state manifest");
|
|
939
|
+
const compatible = object(raw.compatibleSchemaVersions, "UI state compatibility is invalid");
|
|
940
|
+
exactKeys(raw, ["schemaVersion", "compatibleSchemaVersions"], ["schemaVersion", "compatibleSchemaVersions"]);
|
|
941
|
+
exactKeys(compatible, ["minimum", "maximum"], ["minimum", "maximum"]);
|
|
942
|
+
const version = Number(raw.schemaVersion);
|
|
943
|
+
const minimum = Number(compatible.minimum);
|
|
944
|
+
const maximum = Number(compatible.maximum);
|
|
945
|
+
if (!Number.isSafeInteger(version) || version < 1 || ![minimum, maximum].every((item) => Number.isSafeInteger(item) && item >= 0) || minimum > version || version > maximum) throw new TypeError("UI state schema compatibility is invalid");
|
|
946
|
+
state = { schemaVersion: version, compatibleSchemaVersions: { minimum, maximum } };
|
|
947
|
+
}
|
|
948
|
+
return {
|
|
949
|
+
schemaVersion: 1,
|
|
950
|
+
kind: "constal.ui",
|
|
951
|
+
runtime: { contract: "constal.ui-handler.v1", entry },
|
|
952
|
+
...state ? { state } : {},
|
|
953
|
+
assets: { root, fallback },
|
|
954
|
+
contentSecurityPolicy: "strict"
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function uiBundle(value, execution) {
|
|
958
|
+
const bundle = object(value, "UI bundle is invalid");
|
|
959
|
+
exactKeys(bundle, ["manifest", "modules", "assets"], ["manifest", "modules", "assets"]);
|
|
960
|
+
const manifest = uiBundleManifest(bundle.manifest, execution);
|
|
961
|
+
const modules = object(bundle.modules, "UI bundle modules are invalid");
|
|
962
|
+
const assets = object(bundle.assets, "UI bundle assets are invalid");
|
|
963
|
+
const moduleEntries = Object.entries(modules);
|
|
964
|
+
const assetEntries = Object.entries(assets);
|
|
965
|
+
if (moduleEntries.length < 1 || moduleEntries.length > UI_BUNDLE_BOUNDS.maximumModules || assetEntries.length > UI_BUNDLE_BOUNDS.maximumAssets || !Object.hasOwn(modules, manifest.runtime.entry)) {
|
|
966
|
+
throw new TypeError("UI bundle file inventory is invalid");
|
|
967
|
+
}
|
|
968
|
+
const paths = /* @__PURE__ */ new Set();
|
|
969
|
+
let expandedBytes = 0;
|
|
970
|
+
const normalizedModules = {};
|
|
971
|
+
for (const [rawPath, rawModule] of moduleEntries.sort(([left], [right]) => left.localeCompare(right))) {
|
|
972
|
+
const path = safePath(rawPath, "UI module path");
|
|
973
|
+
const module = object(rawModule, "UI module is invalid");
|
|
974
|
+
exactKeys(module, ["type", "source"], ["type", "source"]);
|
|
975
|
+
if (path.split("/").some((part) => part.startsWith(PLATFORM_MODULE_PREFIX))) {
|
|
976
|
+
throw new TypeError("UI module path uses the reserved platform namespace");
|
|
977
|
+
}
|
|
978
|
+
if (module.type !== "esmodule" || typeof module.source !== "string" || SECRET.test(module.source)) throw new TypeError("UI module is invalid or contains secret material");
|
|
979
|
+
const bytes = byteLength(module.source);
|
|
980
|
+
if (bytes > UI_BUNDLE_BOUNDS.maximumFileBytes || paths.has(path)) throw new TypeError("UI module path or size is invalid");
|
|
981
|
+
paths.add(path);
|
|
982
|
+
expandedBytes += bytes;
|
|
983
|
+
normalizedModules[path] = { type: "esmodule", source: module.source };
|
|
984
|
+
}
|
|
985
|
+
const normalizedAssets = {};
|
|
986
|
+
for (const [rawPath, rawAsset] of assetEntries.sort(([left], [right]) => left.localeCompare(right))) {
|
|
987
|
+
const path = safePath(rawPath, "UI asset path");
|
|
988
|
+
const asset = object(rawAsset, "UI asset is invalid");
|
|
989
|
+
exactKeys(asset, ["bodyBase64", "contentType"], ["bodyBase64", "contentType"]);
|
|
990
|
+
if (typeof asset.bodyBase64 !== "string" || !BASE64.test(asset.bodyBase64) || typeof asset.contentType !== "string" || !CONTENT_TYPE.test(asset.contentType) || paths.has(path)) throw new TypeError("UI asset is invalid");
|
|
991
|
+
const bytes = Math.floor(asset.bodyBase64.length * 3 / 4) - (asset.bodyBase64.endsWith("==") ? 2 : asset.bodyBase64.endsWith("=") ? 1 : 0);
|
|
992
|
+
if (bytes > UI_BUNDLE_BOUNDS.maximumFileBytes) throw new TypeError("UI asset exceeds the file limit");
|
|
993
|
+
paths.add(path);
|
|
994
|
+
expandedBytes += bytes;
|
|
995
|
+
normalizedAssets[path] = { bodyBase64: asset.bodyBase64, contentType: asset.contentType };
|
|
996
|
+
}
|
|
997
|
+
if (!Object.hasOwn(normalizedAssets, `${manifest.assets.root}/${manifest.assets.fallback}`)) {
|
|
998
|
+
throw new TypeError("UI bundle fallback asset is unavailable");
|
|
999
|
+
}
|
|
1000
|
+
if (expandedBytes > UI_BUNDLE_BOUNDS.maximumExpandedBytes) throw new TypeError("UI bundle exceeds the expanded-size limit");
|
|
1001
|
+
return { manifest, modules: normalizedModules, assets: normalizedAssets };
|
|
1002
|
+
}
|
|
1003
|
+
|
|
869
1004
|
// src/policy-governance.ts
|
|
870
1005
|
var SANDBOX_CONTRACT = {
|
|
871
1006
|
id: "constal.sandbox-pool",
|
|
@@ -877,6 +1012,11 @@ var MODEL_CONTRACT = {
|
|
|
877
1012
|
version: "1",
|
|
878
1013
|
hash: "76dd0da40da46adabb6837f911b25ed6f675c965e5d4d919077ee9c3945fbca7"
|
|
879
1014
|
};
|
|
1015
|
+
var UI_CONTRACT = {
|
|
1016
|
+
id: "constal.ui",
|
|
1017
|
+
version: "1",
|
|
1018
|
+
hash: "133f0ab76ca2f1435dfbaa151652cfc79926ea5237c0892d0c4d3b96d7bb6f48"
|
|
1019
|
+
};
|
|
880
1020
|
var sandboxSchema = {
|
|
881
1021
|
type: "object",
|
|
882
1022
|
additionalProperties: false,
|
|
@@ -922,6 +1062,9 @@ function modelControls(values) {
|
|
|
922
1062
|
function modelLimit(input) {
|
|
923
1063
|
return limit(MODEL_CONTRACT, ["cached_input_tokens", "input_tokens", "output_tokens", "requests"], input);
|
|
924
1064
|
}
|
|
1065
|
+
function uiLimit(input) {
|
|
1066
|
+
return limit(UI_CONTRACT, ["requests"], input);
|
|
1067
|
+
}
|
|
925
1068
|
function validatePolicyGovernanceConstraint(value) {
|
|
926
1069
|
if (value.kind === "resource-controls") {
|
|
927
1070
|
if (!value.contract || typeof value.contract.id !== "string" || typeof value.contract.version !== "string" || !/^[a-f0-9]{64}$/u.test(value.contract.hash) || !value.values || typeof value.values !== "object" || Array.isArray(value.values)) {
|
|
@@ -946,7 +1089,7 @@ function requiredString2(value, path, maximum = 1024) {
|
|
|
946
1089
|
throw new TypeError(`${path} must be a bounded non-empty string`);
|
|
947
1090
|
}
|
|
948
1091
|
}
|
|
949
|
-
function
|
|
1092
|
+
function exactKeys2(value, allowed, required2, path) {
|
|
950
1093
|
if (Object.keys(value).some((key) => !allowed.includes(key)) || required2.some((key) => !Object.hasOwn(value, key))) {
|
|
951
1094
|
throw new TypeError(`${path} has invalid keys`);
|
|
952
1095
|
}
|
|
@@ -958,7 +1101,7 @@ function validateGrant(grant, path) {
|
|
|
958
1101
|
if (!record3(grant) || !Array.isArray(grant.actions) || grant.actions.length === 0 || grant.actions.length > 256 || !Array.isArray(grant.resources) || grant.resources.length === 0 || grant.resources.length > 256 || !Number.isSafeInteger(grant.ttlMs) || grant.ttlMs < 1 || grant.ttlMs > 864e5) {
|
|
959
1102
|
throw new TypeError(`${path} is invalid`);
|
|
960
1103
|
}
|
|
961
|
-
|
|
1104
|
+
exactKeys2(grant, ["actions", "resources", "ttlMs"], ["actions", "resources", "ttlMs"], path);
|
|
962
1105
|
grant.actions.forEach(actionPattern);
|
|
963
1106
|
grant.resources.forEach(resourcePattern);
|
|
964
1107
|
}
|
|
@@ -976,19 +1119,19 @@ function validatePolicyConstraint(constraint, path = "constraint") {
|
|
|
976
1119
|
return;
|
|
977
1120
|
}
|
|
978
1121
|
if (constraint.kind === "arguments") {
|
|
979
|
-
|
|
1122
|
+
exactKeys2(source, ["kind", "schema"], ["kind", "schema"], path);
|
|
980
1123
|
if (!record3(constraint.schema) || validateJsonSchemaDefinition(constraint.schema)) throw new TypeError(`${path}.schema is invalid`);
|
|
981
1124
|
return;
|
|
982
1125
|
}
|
|
983
1126
|
if (constraint.kind === "context") {
|
|
984
|
-
|
|
1127
|
+
exactKeys2(source, ["kind", "equals"], ["kind", "equals"], path);
|
|
985
1128
|
if (!record3(constraint.equals) || Object.keys(constraint.equals).length === 0 || Object.keys(constraint.equals).length > 64 || Object.entries(constraint.equals).some(([key, value]) => !key || key.length > 256 || !scalar(value))) {
|
|
986
1129
|
throw new TypeError(`${path}.equals is invalid`);
|
|
987
1130
|
}
|
|
988
1131
|
return;
|
|
989
1132
|
}
|
|
990
1133
|
if (constraint.kind === "credential-binding") {
|
|
991
|
-
|
|
1134
|
+
exactKeys2(source, ["kind", "source", "consumer"], ["kind", "source", "consumer"], path);
|
|
992
1135
|
credentialName(constraint.source);
|
|
993
1136
|
parseResourceName(constraint.consumer);
|
|
994
1137
|
return;
|
|
@@ -1005,24 +1148,24 @@ function validateConstraints(value, path, required2) {
|
|
|
1005
1148
|
}
|
|
1006
1149
|
function policyOutcome(value) {
|
|
1007
1150
|
if (!record3(value) || typeof value.kind !== "string") throw new TypeError("Policy outcome is invalid");
|
|
1008
|
-
if (value.kind === "allow")
|
|
1151
|
+
if (value.kind === "allow") exactKeys2(value, ["kind"], ["kind"], "Policy allow outcome");
|
|
1009
1152
|
else if (value.kind === "deny") {
|
|
1010
|
-
|
|
1153
|
+
exactKeys2(value, ["kind", "code", "reason"], ["kind", "code"], "Policy deny outcome");
|
|
1011
1154
|
if (typeof value.code !== "string" || !DENIAL_CODE.test(value.code)) throw new TypeError("Policy denial code is invalid");
|
|
1012
1155
|
if (value.reason !== void 0) requiredString2(value.reason, "Policy denial reason", MAX_REASON_BYTES);
|
|
1013
1156
|
} else if (value.kind === "constrain") {
|
|
1014
|
-
|
|
1157
|
+
exactKeys2(value, ["kind", "constraints"], ["kind", "constraints"], "Policy constrain outcome");
|
|
1015
1158
|
validateConstraints(value.constraints, "Policy constraints", true);
|
|
1016
1159
|
} else if (value.kind === "substitute") {
|
|
1017
|
-
|
|
1160
|
+
exactKeys2(value, ["kind", "value", "constraints"], ["kind", "value"], "Policy substitute outcome");
|
|
1018
1161
|
canonicalJson(value.value);
|
|
1019
1162
|
validateConstraints(value.constraints, "Policy constraints", false);
|
|
1020
1163
|
} else if (value.kind === "require-approval") {
|
|
1021
|
-
|
|
1164
|
+
exactKeys2(value, ["kind", "reason", "constraints"], ["kind"], "Policy approval outcome");
|
|
1022
1165
|
if (value.reason !== void 0) requiredString2(value.reason, "Policy approval reason", MAX_REASON_BYTES);
|
|
1023
1166
|
validateConstraints(value.constraints, "Policy constraints", false);
|
|
1024
1167
|
} else if (value.kind === "grant") {
|
|
1025
|
-
|
|
1168
|
+
exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
|
|
1026
1169
|
validateGrant(value.grant, "Policy grant");
|
|
1027
1170
|
} else throw new TypeError("Policy outcome kind is invalid");
|
|
1028
1171
|
if (encoder3.encode(canonicalJson(value)).byteLength > MAX_OUTCOME_BYTES) throw new TypeError("Policy outcome is oversized");
|
|
@@ -1163,12 +1306,13 @@ function opTool(binding, op, override = {}) {
|
|
|
1163
1306
|
name,
|
|
1164
1307
|
version: "catalog",
|
|
1165
1308
|
description: override.description ?? `Invoke ${op} on the bound ${binding} resource.`,
|
|
1166
|
-
schema: { type: "object", additionalProperties: false },
|
|
1309
|
+
schema: override.schema ?? { type: "object", additionalProperties: false },
|
|
1167
1310
|
maxEffect: "read-only",
|
|
1168
1311
|
needs: [],
|
|
1169
1312
|
...override.tier ? { tier: override.tier } : {},
|
|
1170
1313
|
...override.once ? { once: override.once } : {},
|
|
1171
1314
|
...override.guard ? { guard: override.guard } : {},
|
|
1315
|
+
...override.preview ? { preview: override.preview } : {},
|
|
1172
1316
|
catalog: { binding, op },
|
|
1173
1317
|
async run() {
|
|
1174
1318
|
throw new TypeError(`catalog Tool ${binding}#${op} was not resolved by deployment`);
|
|
@@ -1179,13 +1323,76 @@ function opTools(binding, ops = []) {
|
|
|
1179
1323
|
if (ops.length === 0) throw new TypeError("opTools requires pinned operation names at bundle construction");
|
|
1180
1324
|
return ops.map((op) => opTool(binding, op));
|
|
1181
1325
|
}
|
|
1326
|
+
var WEB_FETCH_ARGUMENT_SCHEMA = {
|
|
1327
|
+
type: "object",
|
|
1328
|
+
required: ["url"],
|
|
1329
|
+
additionalProperties: false,
|
|
1330
|
+
properties: {
|
|
1331
|
+
url: { type: "string", minLength: 1, maxLength: 2048 },
|
|
1332
|
+
accept: { type: "string", maxLength: 256 }
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
var WEB_SEARCH_ARGUMENT_SCHEMA = {
|
|
1336
|
+
type: "object",
|
|
1337
|
+
required: ["query"],
|
|
1338
|
+
additionalProperties: false,
|
|
1339
|
+
properties: {
|
|
1340
|
+
query: {
|
|
1341
|
+
type: "string",
|
|
1342
|
+
minLength: 1,
|
|
1343
|
+
maxLength: 4096,
|
|
1344
|
+
description: "A self-contained description of the information to find."
|
|
1345
|
+
},
|
|
1346
|
+
searchQueries: {
|
|
1347
|
+
type: "array",
|
|
1348
|
+
minItems: 1,
|
|
1349
|
+
maxItems: 3,
|
|
1350
|
+
uniqueItems: true,
|
|
1351
|
+
description: "Optional concise keyword queries that narrow the search.",
|
|
1352
|
+
items: { type: "string", minLength: 1, maxLength: 256 }
|
|
1353
|
+
},
|
|
1354
|
+
maximumResults: {
|
|
1355
|
+
type: "integer",
|
|
1356
|
+
minimum: 1,
|
|
1357
|
+
maximum: 20,
|
|
1358
|
+
description: "Maximum number of sources to return."
|
|
1359
|
+
},
|
|
1360
|
+
maximumCharacters: {
|
|
1361
|
+
type: "integer",
|
|
1362
|
+
minimum: 1e3,
|
|
1363
|
+
maximum: 6e4,
|
|
1364
|
+
description: "Maximum total excerpt characters to return."
|
|
1365
|
+
},
|
|
1366
|
+
includeDomains: {
|
|
1367
|
+
type: "array",
|
|
1368
|
+
maxItems: 50,
|
|
1369
|
+
uniqueItems: true,
|
|
1370
|
+
description: "Optional domains to restrict results to.",
|
|
1371
|
+
items: { type: "string", minLength: 1, maxLength: 253 }
|
|
1372
|
+
},
|
|
1373
|
+
excludeDomains: {
|
|
1374
|
+
type: "array",
|
|
1375
|
+
maxItems: 50,
|
|
1376
|
+
uniqueItems: true,
|
|
1377
|
+
description: "Optional domains to omit.",
|
|
1378
|
+
items: { type: "string", minLength: 1, maxLength: 253 }
|
|
1379
|
+
},
|
|
1380
|
+
afterDate: {
|
|
1381
|
+
type: "string",
|
|
1382
|
+
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
|
|
1383
|
+
description: "Optional earliest publication date in YYYY-MM-DD form."
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1182
1387
|
var webFetch = opTool("web", "get", {
|
|
1183
1388
|
name: "web_fetch",
|
|
1184
|
-
description: "Fetch an HTTPS resource through the bound governed web Resource."
|
|
1389
|
+
description: "Fetch an HTTPS resource through the bound governed web Resource.",
|
|
1390
|
+
schema: WEB_FETCH_ARGUMENT_SCHEMA
|
|
1185
1391
|
});
|
|
1186
1392
|
var webSearch = opTool("search", "search", {
|
|
1187
1393
|
name: "web_search",
|
|
1188
|
-
description: "Search the public web through the bound governed search Resource."
|
|
1394
|
+
description: "Search the public web through the bound governed search Resource.",
|
|
1395
|
+
schema: WEB_SEARCH_ARGUMENT_SCHEMA
|
|
1189
1396
|
});
|
|
1190
1397
|
var casTool = {
|
|
1191
1398
|
name: "cas",
|
|
@@ -1821,7 +2028,7 @@ function credentialProviderConfigSchema(value) {
|
|
|
1821
2028
|
function interactionRecord(value) {
|
|
1822
2029
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
1823
2030
|
}
|
|
1824
|
-
function
|
|
2031
|
+
function exactKeys3(value, allowed) {
|
|
1825
2032
|
return Object.keys(value).every((key) => allowed.includes(key));
|
|
1826
2033
|
}
|
|
1827
2034
|
function boundedText(value, maximum) {
|
|
@@ -1839,26 +2046,26 @@ function credentialInteractionEvent(value) {
|
|
|
1839
2046
|
if (event.kind === "callback") {
|
|
1840
2047
|
const parameters = interactionRecord(event.parameters);
|
|
1841
2048
|
const headers = interactionRecord(event.headers);
|
|
1842
|
-
if (!
|
|
2049
|
+
if (!exactKeys3(event, ["kind", "method", "parameters", "headers", "bodyBase64"]) || !["GET", "POST"].includes(String(event.method ?? "")) || !parameters || Object.keys(parameters).length > 32 || Object.entries(parameters).some(([key, item]) => key.length > 128 || typeof item !== "string" || item.length > 4096) || !headers || Object.keys(headers).length > 64 || Object.entries(headers).some(([key, item]) => key.length > 128 || typeof item !== "string" || item.length > 8192) || event.bodyBase64 !== null && (typeof event.bodyBase64 !== "string" || event.bodyBase64.length > 35e4 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(event.bodyBase64))) {
|
|
1843
2050
|
throw new TypeError("credential interaction callback is invalid");
|
|
1844
2051
|
}
|
|
1845
2052
|
} else if (event.kind === "submit") {
|
|
1846
|
-
if (!
|
|
2053
|
+
if (!exactKeys3(event, ["kind", "value"]) || new TextEncoder().encode(canonicalJson(event.value)).byteLength > 65536) {
|
|
1847
2054
|
throw new TypeError("credential interaction submission is invalid");
|
|
1848
2055
|
}
|
|
1849
|
-
} else if (!
|
|
2056
|
+
} else if (!exactKeys3(event, ["kind"])) throw new TypeError("credential interaction event is invalid");
|
|
1850
2057
|
return event;
|
|
1851
2058
|
}
|
|
1852
2059
|
function credentialInteractionPrimaryAction(value, origins) {
|
|
1853
2060
|
const action2 = interactionRecord(value);
|
|
1854
2061
|
const event = interactionRecord(action2?.event);
|
|
1855
|
-
if (!action2 || !event || !boundedText(action2.label, 64) || !
|
|
2062
|
+
if (!action2 || !event || !boundedText(action2.label, 64) || !exactKeys3(event, ["kind"]) || event.kind !== "continue") {
|
|
1856
2063
|
throw new TypeError("credential interaction primary action is invalid");
|
|
1857
2064
|
}
|
|
1858
2065
|
if (action2.kind === "continue") {
|
|
1859
|
-
if (!
|
|
2066
|
+
if (!exactKeys3(action2, ["kind", "label", "event"])) throw new TypeError("credential interaction primary action is invalid");
|
|
1860
2067
|
} else if (action2.kind === "open-url") {
|
|
1861
|
-
if (!
|
|
2068
|
+
if (!exactKeys3(action2, ["kind", "label", "url", "event"]) || !boundedText(action2.url, 4096)) {
|
|
1862
2069
|
throw new TypeError("credential interaction primary action is invalid");
|
|
1863
2070
|
}
|
|
1864
2071
|
let url;
|
|
@@ -1881,7 +2088,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
|
|
|
1881
2088
|
const expiresAt = action2.kind === "complete" ? null : interactionExpiry(action2.expiresAt, sessionExpiresAt);
|
|
1882
2089
|
if (Number.isNaN(expiresAt)) throw new TypeError("credential interaction action expiry is invalid");
|
|
1883
2090
|
if (action2.kind === "redirect") {
|
|
1884
|
-
if (!
|
|
2091
|
+
if (!exactKeys3(action2, ["kind", "url", "expiresAt"]) || !boundedText(action2.url, 4096)) {
|
|
1885
2092
|
throw new TypeError("credential interaction redirect is invalid");
|
|
1886
2093
|
}
|
|
1887
2094
|
let url;
|
|
@@ -1894,7 +2101,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
|
|
|
1894
2101
|
throw new TypeError("credential interaction redirect is not authorized");
|
|
1895
2102
|
}
|
|
1896
2103
|
} else if (action2.kind === "form") {
|
|
1897
|
-
if (!
|
|
2104
|
+
if (!exactKeys3(action2, ["kind", "schema", "title", "description", "submitLabel", "expiresAt"]) || action2.title !== void 0 && !boundedText(action2.title, 128) || action2.description !== void 0 && !boundedText(action2.description, 1024) || action2.submitLabel !== void 0 && !boundedText(action2.submitLabel, 64)) {
|
|
1898
2105
|
throw new TypeError("credential interaction form is invalid");
|
|
1899
2106
|
}
|
|
1900
2107
|
const schemaError = validateJsonSchemaDefinition(action2.schema, "$interaction.form.schema");
|
|
@@ -1903,16 +2110,16 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
|
|
|
1903
2110
|
throw new TypeError(`credential interaction form schema is invalid${schemaError ? `: ${schemaError}` : ""}`);
|
|
1904
2111
|
}
|
|
1905
2112
|
} else if (action2.kind === "display") {
|
|
1906
|
-
if (!
|
|
2113
|
+
if (!exactKeys3(action2, ["kind", "instructions", "title", "userCode", "primaryAction", "expiresAt"]) || !boundedText(action2.instructions, 4096) || action2.title !== void 0 && !boundedText(action2.title, 128) || action2.userCode !== void 0 && !boundedText(action2.userCode, 512)) {
|
|
1907
2114
|
throw new TypeError("credential interaction display is invalid");
|
|
1908
2115
|
}
|
|
1909
2116
|
credentialInteractionPrimaryAction(action2.primaryAction, origins);
|
|
1910
2117
|
} else if (action2.kind === "wait") {
|
|
1911
|
-
if (!
|
|
2118
|
+
if (!exactKeys3(action2, ["kind", "resume", "expiresAt", "pollAfterMs"]) || !["callback", "poll"].includes(String(action2.resume ?? "")) || expiresAt === null || action2.pollAfterMs !== void 0 && (!Number.isSafeInteger(action2.pollAfterMs) || Number(action2.pollAfterMs) < 1e3 || Number(action2.pollAfterMs) > 3e5) || action2.resume === "poll" && action2.pollAfterMs === void 0 || action2.resume === "callback" && action2.pollAfterMs !== void 0) {
|
|
1912
2119
|
throw new TypeError("credential interaction wait action is invalid");
|
|
1913
2120
|
}
|
|
1914
2121
|
} else {
|
|
1915
|
-
if (!
|
|
2122
|
+
if (!exactKeys3(action2, ["kind", "material", "expiresAt"]) || !boundedText(action2.material, 1048576) || action2.expiresAt !== void 0 && action2.expiresAt !== null && (!Number.isSafeInteger(action2.expiresAt) || Number(action2.expiresAt) <= Date.now())) {
|
|
1916
2123
|
throw new TypeError("credential interaction completion is invalid");
|
|
1917
2124
|
}
|
|
1918
2125
|
}
|
|
@@ -1920,7 +2127,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
|
|
|
1920
2127
|
}
|
|
1921
2128
|
function credentialInteractionResult(value, origins, state, sessionExpiresAt) {
|
|
1922
2129
|
const result = interactionRecord(value);
|
|
1923
|
-
if (!result || !
|
|
2130
|
+
if (!result || !exactKeys3(result, ["action", "privateState"])) throw new TypeError("credential interaction result is invalid");
|
|
1924
2131
|
const privateState = result.privateState;
|
|
1925
2132
|
if (privateState !== void 0 && privateState !== null && (typeof privateState !== "string" || new TextEncoder().encode(privateState).byteLength > 1048576)) throw new TypeError("credential interaction private state is invalid");
|
|
1926
2133
|
return {
|
|
@@ -2182,28 +2389,28 @@ function validPointer(value) {
|
|
|
2182
2389
|
function record7(value) {
|
|
2183
2390
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
2184
2391
|
}
|
|
2185
|
-
function
|
|
2392
|
+
function exactKeys4(value, allowed) {
|
|
2186
2393
|
return Object.keys(value).every((key) => allowed.includes(key));
|
|
2187
2394
|
}
|
|
2188
2395
|
function scorerRule(value, depth, state) {
|
|
2189
2396
|
const rule = record7(value);
|
|
2190
2397
|
if (!rule || depth > 32 || ++state.rules > 1024 || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
|
|
2191
2398
|
if (rule.op === "all" || rule.op === "any") {
|
|
2192
|
-
if (!
|
|
2399
|
+
if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1 || rule.rules.length > 128) {
|
|
2193
2400
|
throw new TypeError("Code Scorer logical rule is invalid");
|
|
2194
2401
|
}
|
|
2195
2402
|
return { op: rule.op, rules: rule.rules.map((child) => scorerRule(child, depth + 1, state)) };
|
|
2196
2403
|
}
|
|
2197
2404
|
if (rule.op === "not") {
|
|
2198
|
-
if (!
|
|
2405
|
+
if (!exactKeys4(rule, ["op", "rule"])) throw new TypeError("Code Scorer not rule is invalid");
|
|
2199
2406
|
return { op: "not", rule: scorerRule(rule.rule, depth + 1, state) };
|
|
2200
2407
|
}
|
|
2201
2408
|
if (rule.op === "schema") {
|
|
2202
|
-
if (!
|
|
2409
|
+
if (!exactKeys4(rule, ["op", "path", "schema"]) || !validPointer(rule.path) || !record7(rule.schema) || validateJsonSchemaDefinition(rule.schema)) throw new TypeError("Code Scorer schema rule is invalid");
|
|
2203
2410
|
return rule;
|
|
2204
2411
|
}
|
|
2205
2412
|
if (rule.op === "regex") {
|
|
2206
|
-
if (!
|
|
2413
|
+
if (!exactKeys4(rule, ["op", "path", "pattern", "flags"]) || !validPointer(rule.path) || typeof rule.pattern !== "string" || rule.pattern.length > 4096 || ![void 0, "", "i", "m", "im"].includes(rule.flags)) {
|
|
2207
2414
|
throw new TypeError("Code Scorer regex rule is invalid");
|
|
2208
2415
|
}
|
|
2209
2416
|
try {
|
|
@@ -2214,28 +2421,28 @@ function scorerRule(value, depth, state) {
|
|
|
2214
2421
|
return rule;
|
|
2215
2422
|
}
|
|
2216
2423
|
if (rule.op === "range") {
|
|
2217
|
-
if (!
|
|
2424
|
+
if (!exactKeys4(rule, ["op", "path", "min", "max"]) || !validPointer(rule.path) || rule.min === void 0 && rule.max === void 0 || rule.min !== void 0 && (typeof rule.min !== "number" || !Number.isFinite(rule.min)) || rule.max !== void 0 && (typeof rule.max !== "number" || !Number.isFinite(rule.max)) || typeof rule.min === "number" && typeof rule.max === "number" && rule.min > rule.max) throw new TypeError("Code Scorer range rule is invalid");
|
|
2218
2425
|
return rule;
|
|
2219
2426
|
}
|
|
2220
2427
|
if (rule.op === "equals" || rule.op === "contains") {
|
|
2221
|
-
if (!
|
|
2428
|
+
if (!exactKeys4(rule, ["op", "path", "value"]) || !validPointer(rule.path) || !Object.hasOwn(rule, "value") || new TextEncoder().encode(canonicalJson(rule.value)).byteLength > 65536) {
|
|
2222
2429
|
throw new TypeError(`Code Scorer ${rule.op} rule is invalid`);
|
|
2223
2430
|
}
|
|
2224
2431
|
return rule;
|
|
2225
2432
|
}
|
|
2226
2433
|
if (rule.op === "tool-sequence") {
|
|
2227
|
-
if (!
|
|
2434
|
+
if (!exactKeys4(rule, ["op", "path", "expected", "mode"]) || !validPointer(rule.path) || !Array.isArray(rule.expected) || rule.expected.length > 256 || 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");
|
|
2228
2435
|
return rule;
|
|
2229
2436
|
}
|
|
2230
2437
|
if (rule.op === "citations-in-source") {
|
|
2231
|
-
if (!
|
|
2438
|
+
if (!exactKeys4(rule, ["op", "textPath", "sourcesPath"]) || !validPointer(rule.textPath) || !validPointer(rule.sourcesPath)) throw new TypeError("Code Scorer citation rule is invalid");
|
|
2232
2439
|
return rule;
|
|
2233
2440
|
}
|
|
2234
2441
|
throw new TypeError("Code Scorer operation is invalid");
|
|
2235
2442
|
}
|
|
2236
2443
|
function codeScorerIR(value) {
|
|
2237
2444
|
const ir = record7(value);
|
|
2238
|
-
if (!ir || ir.v !== 1 || !
|
|
2445
|
+
if (!ir || ir.v !== 1 || !exactKeys4(ir, ["v", "rule"])) throw new TypeError("Code Scorer IR is invalid");
|
|
2239
2446
|
return { v: 1, rule: scorerRule(ir.rule, 0, { rules: 0 }) };
|
|
2240
2447
|
}
|
|
2241
2448
|
function pointer(value, path) {
|
|
@@ -2525,7 +2732,10 @@ export {
|
|
|
2525
2732
|
TRAINING_PROVIDER_CAPABILITY,
|
|
2526
2733
|
TerminalIntegrationFailure,
|
|
2527
2734
|
ToolUnavailable,
|
|
2735
|
+
UI_BUNDLE_BOUNDS,
|
|
2528
2736
|
UnknownTool,
|
|
2737
|
+
WEB_FETCH_ARGUMENT_SCHEMA,
|
|
2738
|
+
WEB_SEARCH_ARGUMENT_SCHEMA,
|
|
2529
2739
|
action,
|
|
2530
2740
|
actionPattern,
|
|
2531
2741
|
agent,
|
|
@@ -2611,6 +2821,10 @@ export {
|
|
|
2611
2821
|
trainingProvider,
|
|
2612
2822
|
trainingProviderMetadata,
|
|
2613
2823
|
trainingRecipe,
|
|
2824
|
+
uiBundle,
|
|
2825
|
+
uiBundleManifest,
|
|
2826
|
+
uiLimit,
|
|
2827
|
+
uiName,
|
|
2614
2828
|
validateBatchSpec,
|
|
2615
2829
|
validateFoldFn,
|
|
2616
2830
|
validateJsonSchema,
|