@m6d/cortex 0.1.0 → 0.2.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/README.md +4 -3
- package/dist/drizzle.js +1 -1
- package/dist/{index-ncc61ew6.js → index-z0594rs3.js} +4 -1
- package/dist/index.d.ts +53 -32
- package/dist/index.js +87 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,9 @@ export const cortexServer = defineServer({
|
|
|
38
38
|
description: "Cancel one of the user's open orders.",
|
|
39
39
|
input: z.object({ orderId: z.string() }),
|
|
40
40
|
readOnly: false,
|
|
41
|
-
// Every call parks until the end user approves
|
|
42
|
-
|
|
41
|
+
// Every call parks until the end user approves it, on a card titled with
|
|
42
|
+
// what the model says that call will do.
|
|
43
|
+
requiresApproval: true,
|
|
43
44
|
run: async ({ orderId }, { user }) => {
|
|
44
45
|
if (!user)
|
|
45
46
|
throw new CortexError("forbidden", "Only a signed-in user can cancel an order");
|
|
@@ -62,7 +63,7 @@ app.route("/cortex", cortexServer);
|
|
|
62
63
|
|
|
63
64
|
Cortex reads `GET /` (the manifest, versioned by its own content) on every sync, and calls `POST /variables`, `POST /tools/:name`, `POST /verify` and `POST /events/approval_requested` behind it. A run-scoped call carries the run's token, which `resolve` and `run` receive as `token`: the end user's bearer in a chat, the trigger's credential in a trigger run. A tool's input is an object schema (any other fails at startup, since every call's `input` is an object), parsed before `run` sees it. A refusal answers as described in [Errors](#errors).
|
|
64
65
|
|
|
65
|
-
A name Cortex would refuse fails `defineServer` at startup: a tool or variable name that is no identifier, and Cortex's built-in names (`utcTime`, `locale`, `timezone`, and the built-in tools such as `executeCode` and `requestLocation`). The protocol is described in full in `apps/cortex/docs/cortex-integration.md`.
|
|
66
|
+
A name Cortex would refuse fails `defineServer` at startup: a tool or variable name that is no identifier, and Cortex's built-in names (`utcTime`, `locale`, `timezone`, and the built-in tools such as `executeCode` and `requestLocation`), and so does an input of a tool that needs approval that names `approvalTitle` or closes a sub-schema to it (`additionalProperties: false` inside `allOf`, `anyOf` or `oneOf`), since Cortex adds the card's title to it. The protocol is described in full in `apps/cortex/docs/cortex-integration.md`.
|
|
66
67
|
|
|
67
68
|
## Dataset hosts
|
|
68
69
|
|
package/dist/drizzle.js
CHANGED
|
@@ -52,6 +52,9 @@ import { z as z2 } from "zod";
|
|
|
52
52
|
function isRecord(value) {
|
|
53
53
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
54
54
|
}
|
|
55
|
+
function unescapePointerToken(token) {
|
|
56
|
+
return token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
57
|
+
}
|
|
55
58
|
|
|
56
59
|
// ../../internal/contracts/src/datasets/datasets.ts
|
|
57
60
|
var DATASET_IDENTIFIER_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
@@ -1143,4 +1146,4 @@ class Sources {
|
|
|
1143
1146
|
}
|
|
1144
1147
|
// ../../internal/contracts/src/datasets/dataset-sql-guide.ts
|
|
1145
1148
|
var DATASET_SQL_GRAMMAR = "One SELECT over one dataset. LEFT JOIN related datasets exactly as the dataset's description lists them (LEFT JOIN keeps rows without a match; JOIN or INNER JOIN drops them); reference dataset.column. " + "SELECT: columns, DATE_TRUNC('unit', column), EXTRACT(part FROM column), CASE WHEN ... END, LOWER/UPPER/TRIM/LENGTH/ABS/ROUND/COALESCE, COUNT/SUM/AVG/MIN/MAX over a column or arithmetic each with an optional FILTER (WHERE ...), and named arithmetic between aggregates (SUM(a) / COUNT(*) AS avg). " + "WHERE and HAVING: AND, OR, NOT, parentheses, comparisons with literals or other columns, IN, BETWEEN, LIKE, IS NULL; CURRENT_DATE and INTERVAL arithmetic on it. " + "GROUP BY columns or select aliases. An aggregate with OVER () or OVER (PARTITION BY ...) is a window: that aggregate over the rows sharing the partition, on every row (SUM(COUNT(*)) OVER () is the grand total); name it AS, use it in arithmetic, and QUALIFY filters the finished rows. " + "QUALIFY RANK() OVER (PARTITION BY ... ORDER BY ...) <= n for the top n per group (rows tied on every ORDER BY key share a rank and all stay); ORDER BY; LIMIT; OFFSET. " + "Rows nest qualified columns under the qualifier as written (pets.name comes back as row.pets.name); aliases and aggregates are top-level.";
|
|
1146
|
-
export { BACKEND_ERROR_STATUS, backendErrorSchema, CortexError, errorEnvelope, envelopeOf, datasetIdentifierSchema, datasetDefinitionSchema, datasetRequestSchema, datasetCatalogOf, groupKeyName, filterRefs, isColumnValue, checkDatasetQuery, boundDatasetResult, FUNCTION_SIGNATURES };
|
|
1149
|
+
export { BACKEND_ERROR_STATUS, backendErrorSchema, isRecord, unescapePointerToken, CortexError, errorEnvelope, envelopeOf, datasetIdentifierSchema, datasetDefinitionSchema, datasetRequestSchema, datasetCatalogOf, groupKeyName, filterRefs, isColumnValue, checkDatasetQuery, boundDatasetResult, FUNCTION_SIGNATURES };
|
package/dist/index.d.ts
CHANGED
|
@@ -86,11 +86,8 @@ export type ToolDefinition<TInput extends z.ZodType> = {
|
|
|
86
86
|
input: TInput;
|
|
87
87
|
output?: z.ZodType;
|
|
88
88
|
readOnly: boolean;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
en: string;
|
|
92
|
-
ar: string;
|
|
93
|
-
};
|
|
89
|
+
/** Every call parks until the end user approves it, on a card whose title the model writes for that call. */
|
|
90
|
+
requiresApproval?: boolean;
|
|
94
91
|
run(input: z.output<TInput>, context: WithToken<ToolRequest["context"]>): Awaitable<unknown>;
|
|
95
92
|
};
|
|
96
93
|
export type ServerOptions<TInputs extends Record<string, z.ZodType>> = {
|
|
@@ -1167,10 +1164,7 @@ declare const manifestToolSchema: z.ZodDiscriminatedUnion<[
|
|
|
1167
1164
|
prefix: z.ZodDefault<z.ZodString>;
|
|
1168
1165
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
1169
1166
|
}, z.core.$strict>>>;
|
|
1170
|
-
|
|
1171
|
-
en: "en";
|
|
1172
|
-
ar: "ar";
|
|
1173
|
-
}>, z.ZodString>>;
|
|
1167
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
1174
1168
|
responseWrap: z.ZodOptional<z.ZodEnum<{
|
|
1175
1169
|
value: "value";
|
|
1176
1170
|
items: "items";
|
|
@@ -1384,10 +1378,7 @@ declare const manifestToolSchema: z.ZodDiscriminatedUnion<[
|
|
|
1384
1378
|
prefix: z.ZodDefault<z.ZodString>;
|
|
1385
1379
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
1386
1380
|
}, z.core.$strict>>>;
|
|
1387
|
-
|
|
1388
|
-
en: "en";
|
|
1389
|
-
ar: "ar";
|
|
1390
|
-
}>, z.ZodString>>;
|
|
1381
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
1391
1382
|
embedOrigin: z.ZodPipe<z.ZodURL, z.ZodTransform<string, string>>;
|
|
1392
1383
|
surface: z.ZodEnum<{
|
|
1393
1384
|
inline: "inline";
|
|
@@ -1601,10 +1592,7 @@ declare const manifestToolSchema: z.ZodDiscriminatedUnion<[
|
|
|
1601
1592
|
prefix: z.ZodDefault<z.ZodString>;
|
|
1602
1593
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
1603
1594
|
}, z.core.$strict>>>;
|
|
1604
|
-
|
|
1605
|
-
en: "en";
|
|
1606
|
-
ar: "ar";
|
|
1607
|
-
}>, z.ZodString>>;
|
|
1595
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
1608
1596
|
soapVersion: z.ZodEnum<{
|
|
1609
1597
|
1.1: "1.1";
|
|
1610
1598
|
1.2: "1.2";
|
|
@@ -2531,10 +2519,7 @@ declare const manifestSchema: z.ZodObject<{
|
|
|
2531
2519
|
prefix: z.ZodDefault<z.ZodString>;
|
|
2532
2520
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
2533
2521
|
}, z.core.$strict>>>;
|
|
2534
|
-
|
|
2535
|
-
en: "en";
|
|
2536
|
-
ar: "ar";
|
|
2537
|
-
}>, z.ZodString>>;
|
|
2522
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
2538
2523
|
responseWrap: z.ZodOptional<z.ZodEnum<{
|
|
2539
2524
|
value: "value";
|
|
2540
2525
|
items: "items";
|
|
@@ -2748,10 +2733,7 @@ declare const manifestSchema: z.ZodObject<{
|
|
|
2748
2733
|
prefix: z.ZodDefault<z.ZodString>;
|
|
2749
2734
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
2750
2735
|
}, z.core.$strict>>>;
|
|
2751
|
-
|
|
2752
|
-
en: "en";
|
|
2753
|
-
ar: "ar";
|
|
2754
|
-
}>, z.ZodString>>;
|
|
2736
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
2755
2737
|
embedOrigin: z.ZodPipe<z.ZodURL, z.ZodTransform<string, string>>;
|
|
2756
2738
|
surface: z.ZodEnum<{
|
|
2757
2739
|
inline: "inline";
|
|
@@ -2965,10 +2947,7 @@ declare const manifestSchema: z.ZodObject<{
|
|
|
2965
2947
|
prefix: z.ZodDefault<z.ZodString>;
|
|
2966
2948
|
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
2967
2949
|
}, z.core.$strict>>>;
|
|
2968
|
-
|
|
2969
|
-
en: "en";
|
|
2970
|
-
ar: "ar";
|
|
2971
|
-
}>, z.ZodString>>;
|
|
2950
|
+
requiresApproval: z.ZodDefault<z.ZodBoolean>;
|
|
2972
2951
|
soapVersion: z.ZodEnum<{
|
|
2973
2952
|
1.1: "1.1";
|
|
2974
2953
|
1.2: "1.2";
|
|
@@ -3179,6 +3158,29 @@ declare const manifestSchema: z.ZodObject<{
|
|
|
3179
3158
|
type: z.ZodLiteral<"client">;
|
|
3180
3159
|
}, z.core.$strict>
|
|
3181
3160
|
], "type">>>;
|
|
3161
|
+
openapi: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
3162
|
+
name: z.ZodString;
|
|
3163
|
+
url: z.ZodURL;
|
|
3164
|
+
credentials: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
3165
|
+
header: z.ZodString;
|
|
3166
|
+
prefix: z.ZodDefault<z.ZodString>;
|
|
3167
|
+
credential: z.ZodType<string | null, string | null, z.core.$ZodTypeInternals<string | null, string | null>>;
|
|
3168
|
+
}, z.core.$strict>>>;
|
|
3169
|
+
pinned: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
3170
|
+
approval: z.ZodPrefault<z.ZodObject<{
|
|
3171
|
+
never: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
3172
|
+
always: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
3173
|
+
}, z.core.$strict>>;
|
|
3174
|
+
audience: z.ZodUnion<readonly [
|
|
3175
|
+
z.ZodLiteral<"all">,
|
|
3176
|
+
z.ZodObject<{
|
|
3177
|
+
server: z.ZodString;
|
|
3178
|
+
}, z.core.$strict>,
|
|
3179
|
+
z.ZodObject<{
|
|
3180
|
+
agents: z.ZodArray<z.ZodString>;
|
|
3181
|
+
}, z.core.$strict>
|
|
3182
|
+
]>;
|
|
3183
|
+
}, z.core.$strict>>>;
|
|
3182
3184
|
services: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
3183
3185
|
key: z.ZodString;
|
|
3184
3186
|
name: z.ZodRecord<z.ZodEnum<{
|
|
@@ -3693,7 +3695,7 @@ export declare function defineManifest(manifest: Manifest): {
|
|
|
3693
3695
|
credential: string | null;
|
|
3694
3696
|
prefix?: string | undefined;
|
|
3695
3697
|
}[] | undefined;
|
|
3696
|
-
|
|
3698
|
+
requiresApproval?: boolean | undefined;
|
|
3697
3699
|
responseWrap?: "value" | "items" | undefined;
|
|
3698
3700
|
} | {
|
|
3699
3701
|
audience: "all" | {
|
|
@@ -3812,7 +3814,7 @@ export declare function defineManifest(manifest: Manifest): {
|
|
|
3812
3814
|
credential: string | null;
|
|
3813
3815
|
prefix?: string | undefined;
|
|
3814
3816
|
}[] | undefined;
|
|
3815
|
-
|
|
3817
|
+
requiresApproval?: boolean | undefined;
|
|
3816
3818
|
} | {
|
|
3817
3819
|
audience: "all" | {
|
|
3818
3820
|
server: string;
|
|
@@ -3931,7 +3933,7 @@ export declare function defineManifest(manifest: Manifest): {
|
|
|
3931
3933
|
credential: string | null;
|
|
3932
3934
|
prefix?: string | undefined;
|
|
3933
3935
|
}[] | undefined;
|
|
3934
|
-
|
|
3936
|
+
requiresApproval?: boolean | undefined;
|
|
3935
3937
|
tokenCall?: {
|
|
3936
3938
|
envelopeTemplate: string;
|
|
3937
3939
|
soapAction: string;
|
|
@@ -4046,6 +4048,25 @@ export declare function defineManifest(manifest: Manifest): {
|
|
|
4046
4048
|
pinned?: boolean | undefined;
|
|
4047
4049
|
tags?: string[] | undefined;
|
|
4048
4050
|
})[] | undefined;
|
|
4051
|
+
openapi?: {
|
|
4052
|
+
name: string;
|
|
4053
|
+
url: string;
|
|
4054
|
+
audience: "all" | {
|
|
4055
|
+
server: string;
|
|
4056
|
+
} | {
|
|
4057
|
+
agents: string[];
|
|
4058
|
+
};
|
|
4059
|
+
credentials?: {
|
|
4060
|
+
header: string;
|
|
4061
|
+
credential: string | null;
|
|
4062
|
+
prefix?: string | undefined;
|
|
4063
|
+
}[] | undefined;
|
|
4064
|
+
pinned?: string[] | undefined;
|
|
4065
|
+
approval?: {
|
|
4066
|
+
never?: string[] | undefined;
|
|
4067
|
+
always?: string[] | undefined;
|
|
4068
|
+
} | undefined;
|
|
4069
|
+
}[] | undefined;
|
|
4049
4070
|
services?: {
|
|
4050
4071
|
key: string;
|
|
4051
4072
|
name: Record<"en" | "ar", string>;
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
datasetIdentifierSchema,
|
|
10
10
|
datasetRequestSchema,
|
|
11
11
|
envelopeOf,
|
|
12
|
-
errorEnvelope
|
|
13
|
-
|
|
12
|
+
errorEnvelope,
|
|
13
|
+
isRecord,
|
|
14
|
+
unescapePointerToken
|
|
15
|
+
} from "./index-z0594rs3.js";
|
|
14
16
|
|
|
15
17
|
// src/server.ts
|
|
16
18
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
@@ -7034,6 +7036,7 @@ var DEFAULT_MEDIA_FORMS = [
|
|
|
7034
7036
|
"map"
|
|
7035
7037
|
];
|
|
7036
7038
|
var ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024;
|
|
7039
|
+
var APPROVAL_TITLE_FIELD = "approvalTitle";
|
|
7037
7040
|
|
|
7038
7041
|
// ../../internal/contracts/src/server/index.ts
|
|
7039
7042
|
var END_USER_TOKEN_HEADER = "X-End-User-Token";
|
|
@@ -7092,7 +7095,8 @@ var BUILT_IN_TOOL_NAMES = [
|
|
|
7092
7095
|
function isBuiltInToolName(name) {
|
|
7093
7096
|
return BUILT_IN_TOOL_NAMES.some((builtIn) => builtIn === name);
|
|
7094
7097
|
}
|
|
7095
|
-
var
|
|
7098
|
+
var TOOL_NAME_MAX_LENGTH = 64;
|
|
7099
|
+
var declaredToolNameSchema = z2.string().regex(IDENTIFIER_PATTERN).max(TOOL_NAME_MAX_LENGTH).refine((name) => !isBuiltInToolName(name), "the name of a built-in tool");
|
|
7096
7100
|
var jsonSchemaSchema = z2.record(z2.string(), z2.unknown());
|
|
7097
7101
|
var serverVariableSchema = z2.object({
|
|
7098
7102
|
name: z2.string().regex(IDENTIFIER_PATTERN).max(64).refine((name) => !BUILT_IN_VARIABLES.some((builtIn) => builtIn.name === name), "the name of a built-in variable"),
|
|
@@ -7106,7 +7110,7 @@ var serverToolSchema = z2.object({
|
|
|
7106
7110
|
inputSchema: jsonSchemaSchema.refine((schema) => schema.type === "object", "a tool's input is an object"),
|
|
7107
7111
|
outputSchema: jsonSchemaSchema.optional(),
|
|
7108
7112
|
readOnly: z2.boolean(),
|
|
7109
|
-
|
|
7113
|
+
requiresApproval: z2.boolean().optional()
|
|
7110
7114
|
});
|
|
7111
7115
|
var SERVER_EVENTS = ["approval_requested"];
|
|
7112
7116
|
var EVENT_HEADER = "X-Cortex-Event";
|
|
@@ -7122,13 +7126,74 @@ var approvalRequestedEventSchema = z2.object({
|
|
|
7122
7126
|
approvals: z2.array(pendingApprovalSchema.partial({ input: true })),
|
|
7123
7127
|
occurredAt: z2.iso.datetime()
|
|
7124
7128
|
});
|
|
7129
|
+
function pointerKey(token) {
|
|
7130
|
+
try {
|
|
7131
|
+
return unescapePointerToken(decodeURIComponent(token));
|
|
7132
|
+
} catch {
|
|
7133
|
+
return;
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
function pointedAt(root, ref) {
|
|
7137
|
+
if (!ref.startsWith("#"))
|
|
7138
|
+
return;
|
|
7139
|
+
let node = root;
|
|
7140
|
+
for (const token of ref.slice(1).split("/").slice(1)) {
|
|
7141
|
+
const key = pointerKey(token);
|
|
7142
|
+
node = key !== undefined && (isRecord(node) || Array.isArray(node)) ? new Map(Object.entries(node)).get(key) : undefined;
|
|
7143
|
+
}
|
|
7144
|
+
return node;
|
|
7145
|
+
}
|
|
7146
|
+
function namesApprovalTitle(node) {
|
|
7147
|
+
const required = node.required;
|
|
7148
|
+
return isRecord(node.properties) && Object.hasOwn(node.properties, APPROVAL_TITLE_FIELD) || Array.isArray(required) && required.includes(APPROVAL_TITLE_FIELD);
|
|
7149
|
+
}
|
|
7150
|
+
function sameObjectSchemas(node, root) {
|
|
7151
|
+
const schemas = typeof node.$ref === "string" ? [pointedAt(root, node.$ref)] : [];
|
|
7152
|
+
for (const keyword of ["allOf", "anyOf", "oneOf"]) {
|
|
7153
|
+
const members = node[keyword];
|
|
7154
|
+
if (!Array.isArray(members))
|
|
7155
|
+
continue;
|
|
7156
|
+
const listed = members;
|
|
7157
|
+
schemas.push(...listed);
|
|
7158
|
+
}
|
|
7159
|
+
return schemas;
|
|
7160
|
+
}
|
|
7161
|
+
function sameObjectNodes(inputSchema) {
|
|
7162
|
+
const nodes = new Array;
|
|
7163
|
+
const pending = [inputSchema];
|
|
7164
|
+
while (pending.length > 0) {
|
|
7165
|
+
const node = pending.pop();
|
|
7166
|
+
if (!isRecord(node) || nodes.includes(node))
|
|
7167
|
+
continue;
|
|
7168
|
+
nodes.push(node);
|
|
7169
|
+
pending.push(...sameObjectSchemas(node, inputSchema));
|
|
7170
|
+
}
|
|
7171
|
+
return nodes;
|
|
7172
|
+
}
|
|
7173
|
+
function closed(node) {
|
|
7174
|
+
return node.additionalProperties === false || node.unevaluatedProperties === false;
|
|
7175
|
+
}
|
|
7176
|
+
function blocksApprovalTitle(inputSchema) {
|
|
7177
|
+
return sameObjectNodes(inputSchema).some((node) => namesApprovalTitle(node) || node !== inputSchema && closed(node));
|
|
7178
|
+
}
|
|
7179
|
+
function refuseBlockedApprovalTitle(tool, context, path) {
|
|
7180
|
+
if (!tool.requiresApproval || !blocksApprovalTitle(tool.inputSchema))
|
|
7181
|
+
return;
|
|
7182
|
+
context.addIssue({
|
|
7183
|
+
code: "custom",
|
|
7184
|
+
path: [...path, "inputSchema"],
|
|
7185
|
+
message: `a tool that needs approval cannot take an input named ${APPROVAL_TITLE_FIELD}, nor one a closed sub-schema describes: Cortex adds the approval card's title to it`
|
|
7186
|
+
});
|
|
7187
|
+
}
|
|
7125
7188
|
function uniqueNames(entries) {
|
|
7126
7189
|
return new Set(entries.map((entry) => entry.name)).size === entries.length;
|
|
7127
7190
|
}
|
|
7128
7191
|
var serverManifestSchema = z2.object({
|
|
7129
7192
|
version: z2.string().min(1).max(128),
|
|
7130
7193
|
variables: z2.array(serverVariableSchema).max(100).refine(uniqueNames, "variable names repeat"),
|
|
7131
|
-
tools: z2.array(serverToolSchema).max(500).refine(uniqueNames, "tool names repeat"),
|
|
7194
|
+
tools: z2.array(serverToolSchema).max(500).refine(uniqueNames, "tool names repeat").superRefine((tools, context) => {
|
|
7195
|
+
tools.forEach((tool, index) => refuseBlockedApprovalTitle(tool, context, [index]));
|
|
7196
|
+
}),
|
|
7132
7197
|
verify: z2.boolean(),
|
|
7133
7198
|
events: z2.array(z2.enum(SERVER_EVENTS))
|
|
7134
7199
|
});
|
|
@@ -7202,7 +7267,7 @@ function manifestOf(options) {
|
|
|
7202
7267
|
}),
|
|
7203
7268
|
...tool.output ? { outputSchema: z3.toJSONSchema(tool.output, { io: "output" }) } : {},
|
|
7204
7269
|
readOnly: tool.readOnly,
|
|
7205
|
-
...tool.
|
|
7270
|
+
...tool.requiresApproval ? { requiresApproval: true } : {}
|
|
7206
7271
|
})),
|
|
7207
7272
|
verify: options.verify !== undefined,
|
|
7208
7273
|
events: SERVER_EVENTS.filter((event) => options.events?.[event])
|
|
@@ -7759,7 +7824,7 @@ var calledToolSchema = toolBaseSchema.extend({
|
|
|
7759
7824
|
inputSchema: objectSchemaOf(true).default(EMPTY_OBJECT),
|
|
7760
7825
|
url: upstreamUrlSchema.refine(confinesEndpointParams, "a {parameter} outside the path or query"),
|
|
7761
7826
|
credentials: credentialsSchema,
|
|
7762
|
-
|
|
7827
|
+
requiresApproval: z4.boolean().default(false)
|
|
7763
7828
|
});
|
|
7764
7829
|
var manifestToolSchema = z4.discriminatedUnion("type", [
|
|
7765
7830
|
calledToolSchema.extend({
|
|
@@ -7779,7 +7844,19 @@ var manifestToolSchema = z4.discriminatedUnion("type", [
|
|
|
7779
7844
|
...toolConfigByType.soap.shape
|
|
7780
7845
|
}),
|
|
7781
7846
|
toolBaseSchema.extend({ type: z4.literal("client") })
|
|
7782
|
-
])
|
|
7847
|
+
]).superRefine((tool, context) => {
|
|
7848
|
+
if (tool.type !== "client")
|
|
7849
|
+
refuseBlockedApprovalTitle(tool, context, []);
|
|
7850
|
+
});
|
|
7851
|
+
var toolNamesSchema = z4.array(serverToolSchema.shape.name).max(500).default([]);
|
|
7852
|
+
var manifestOpenApiSchema = z4.strictObject({
|
|
7853
|
+
name: nameSchema,
|
|
7854
|
+
url: upstreamUrlSchema,
|
|
7855
|
+
credentials: credentialsSchema,
|
|
7856
|
+
pinned: toolNamesSchema,
|
|
7857
|
+
approval: z4.strictObject({ never: toolNamesSchema, always: toolNamesSchema }).prefault({}).refine(({ never, always }) => !never.some((name) => always.includes(name)), "a tool both never and always needs approval"),
|
|
7858
|
+
audience: audienceSchema
|
|
7859
|
+
});
|
|
7783
7860
|
var manifestServiceSchema = z4.strictObject({
|
|
7784
7861
|
key: slugSchema,
|
|
7785
7862
|
name: localizedLineSchema,
|
|
@@ -7931,6 +8008,7 @@ var manifestSchema = z4.strictObject({
|
|
|
7931
8008
|
id: slugSchema,
|
|
7932
8009
|
agents: listOf(manifestAgentSchema, (agent) => agent.slug),
|
|
7933
8010
|
tools: listOf(manifestToolSchema, byName),
|
|
8011
|
+
openapi: listOf(manifestOpenApiSchema, byName),
|
|
7934
8012
|
services: listOf(manifestServiceSchema, (service) => service.key),
|
|
7935
8013
|
skills: listOf(manifestSkillSchema, byName),
|
|
7936
8014
|
triggers: listOf(manifestTriggerSchema, byName),
|
|
@@ -7939,7 +8017,7 @@ var manifestSchema = z4.strictObject({
|
|
|
7939
8017
|
webhooks: listOf(manifestWebhookSchema, byName),
|
|
7940
8018
|
collections: listOf(manifestCollectionSchema, byName)
|
|
7941
8019
|
});
|
|
7942
|
-
var namesByKindSchema = z4.record(manifestSchema.keyof().exclude(["id"]), z4.array(z4.string()));
|
|
8020
|
+
var namesByKindSchema = z4.record(manifestSchema.keyof().exclude(["id", "openapi"]), z4.array(z4.string()));
|
|
7943
8021
|
var manifestChangesSchema = z4.object({
|
|
7944
8022
|
create: namesByKindSchema,
|
|
7945
8023
|
update: namesByKindSchema,
|