@capybara-hq/plugin-sdk 0.1.0-rc.63 → 0.1.0-rc.65
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/agent-docs/connector-templates.md +5 -2
- package/agent-docs/extensions.md +47 -0
- package/dist/config-ui.d.ts +6 -6
- package/dist/config-ui.js +24 -21
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/define-extension.d.ts +3 -2
- package/dist/define-extension.js +30 -2
- package/dist/device-provider.d.ts +64 -5
- package/dist/device-provider.js +21 -0
- package/dist/directory.d.ts +15 -12
- package/dist/field-meta.d.ts +18 -0
- package/dist/field-meta.js +48 -0
- package/dist/file-preview.d.ts +3 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/legacy-org-access.d.ts +17 -0
- package/dist/legacy-org-access.js +12 -0
- package/dist/model.d.ts +4 -4
- package/dist/platform-only.d.ts +26 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +5 -2
- package/dist/plugin-manifest.js +46 -15
- package/dist/plugin-package.d.ts +1 -2
- package/dist/plugin-package.js +9 -14
- package/dist/secret.d.ts +6 -3
- package/dist/secret.js +9 -5
- package/dist/tool.d.ts +4 -6
- package/dist/ui.d.ts +3 -4
- package/dist/web.d.ts +26 -20
- package/package.json +1 -1
- package/schemas/connector-template.v1.schema.json +30 -4
- package/schemas/plugin.v1.schema.json +5 -2
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export const SDK_VERSION = "0.1.0-rc.65";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
3
|
export * from "./avatar-presets.js";
|
|
4
4
|
export * from "./bootstrap.js";
|
|
@@ -7,6 +7,7 @@ export * from "./channel.js";
|
|
|
7
7
|
export * from "./client-css.js";
|
|
8
8
|
export * from "./client-section.js";
|
|
9
9
|
export * from "./config-ui.js";
|
|
10
|
+
export * from "./config-url-fetch.js";
|
|
10
11
|
export * from "./connector.js";
|
|
11
12
|
export * from "./connector-auth.js";
|
|
12
13
|
export * from "./context.js";
|
|
@@ -23,13 +24,14 @@ export * from "./git-hosts.js";
|
|
|
23
24
|
export * from "./hooks.js";
|
|
24
25
|
export * from "./http-access.js";
|
|
25
26
|
export * from "./identity.js";
|
|
27
|
+
export * from "./legacy-org-access.js";
|
|
26
28
|
export * from "./marketplace.js";
|
|
27
29
|
export * from "./model.js";
|
|
28
30
|
export * from "./model-params.js";
|
|
29
31
|
export * from "./net.js";
|
|
30
32
|
export * from "./network-classes.js";
|
|
31
|
-
export * from "./org-access.js";
|
|
32
33
|
export * from "./permissions.js";
|
|
34
|
+
export * from "./platform-only.js";
|
|
33
35
|
export * from "./plugin-manifest.js";
|
|
34
36
|
export * from "./plugin-package.js";
|
|
35
37
|
export * from "./push.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Removed by core#720; kept only so plugin modules packed before core#720 still load.
|
|
4
|
+
* Fields are org-overridable by default (`platformOnly` marks platform-only). Removed in core#720
|
|
5
|
+
* plan Task 17.
|
|
6
|
+
*/
|
|
7
|
+
export type OrgAccess = "readonly" | "override";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Removed by core#720; kept only so plugin modules packed before core#720 still load;
|
|
10
|
+
* fields are org-overridable by default (`platformOnly` marks platform-only). Removed in core#720
|
|
11
|
+
* plan Task 17.
|
|
12
|
+
*
|
|
13
|
+
* A no-op: it returns `schema` unchanged and adds no meta. Both levels are ignored: the field stays
|
|
14
|
+
* an ordinary deployment field, overridable by orgs unless it is marked {@link platformOnly};
|
|
15
|
+
* `"readonly"` in particular makes nothing visible to orgs or read-only. New code never calls it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function orgAccess<T extends z.ZodTypeAny>(schema: T, _access: OrgAccess): T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Removed by core#720; kept only so plugin modules packed before core#720 still load;
|
|
3
|
+
* fields are org-overridable by default (`platformOnly` marks platform-only). Removed in core#720
|
|
4
|
+
* plan Task 17.
|
|
5
|
+
*
|
|
6
|
+
* A no-op: it returns `schema` unchanged and adds no meta. Both levels are ignored: the field stays
|
|
7
|
+
* an ordinary deployment field, overridable by orgs unless it is marked {@link platformOnly};
|
|
8
|
+
* `"readonly"` in particular makes nothing visible to orgs or read-only. New code never calls it.
|
|
9
|
+
*/
|
|
10
|
+
export function orgAccess(schema, _access) {
|
|
11
|
+
return schema;
|
|
12
|
+
}
|
package/dist/model.d.ts
CHANGED
|
@@ -317,10 +317,10 @@ export declare class ModelError extends Error {
|
|
|
317
317
|
/**
|
|
318
318
|
* Options of a model call made for an organization.
|
|
319
319
|
* `config` is the extension's effective deployment config for this org: the platform's deployment
|
|
320
|
-
* config with the org's copy applied to the overridable fields (
|
|
321
|
-
* platform's config (equal to `ctx.config`) while the org follows it. Use
|
|
322
|
-
* work done for this org.
|
|
323
|
-
*
|
|
320
|
+
* config with the org's copy applied to the overridable fields (every field not marked
|
|
321
|
+
* `platformOnly`), or the platform's config (equal to `ctx.config`) while the org follows it. Use
|
|
322
|
+
* it, not `ctx.config`, for work done for this org. Both are absent on a call not made for an org,
|
|
323
|
+
* such as a conformance run.
|
|
324
324
|
*/
|
|
325
325
|
export interface ModelCallOptions {
|
|
326
326
|
orgId?: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Marks a deployment config field, or the whole deployment schema, as platform-only (Zod 4 meta
|
|
4
|
+
* `{ platformOnly: true }`), merging with existing meta (`secret`, `hot`, `ui`), also the meta of
|
|
5
|
+
* the nodes under `.optional()` / `.default()` and the other wrappers, so
|
|
6
|
+
* `platformOnly(secret(x))` and `secret(platformOnly(x))` are the same. `configJsonSchema`
|
|
7
|
+
* publishes it as `"x-platform-only": true`; it is allowed on the root and on its top-level
|
|
8
|
+
* properties (a nested field has the level of its top-level key).
|
|
9
|
+
*
|
|
10
|
+
* Every deployment field without the mark is overridable: an org follows the platform's value until
|
|
11
|
+
* it saves its own copy, and the extension reads it from the per-call `config` (the effective config
|
|
12
|
+
* for the org), not from `ctx.config`. A platform-only field is set only by the platform and is never
|
|
13
|
+
* shown to an org.
|
|
14
|
+
*
|
|
15
|
+
* The effective config of an org that has its own copy still contains the platform-only secrets,
|
|
16
|
+
* which an org cannot set; it never contains an overridable platform secret. Never send a
|
|
17
|
+
* platform-only secret to an endpoint taken from an overridable field: an org could point that
|
|
18
|
+
* endpoint at a server it controls.
|
|
19
|
+
*/
|
|
20
|
+
export declare function platformOnly<T extends z.ZodTypeAny>(schema: T): T;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a schema carries the {@link platformOnly} mark. It sees through `.optional()`,
|
|
23
|
+
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the outermost meta
|
|
24
|
+
* wins), so it agrees with the `"x-platform-only"` that `configJsonSchema` publishes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPlatformOnly(schema: z.ZodTypeAny): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { withMeta, wrapperChain } from "./field-meta.js";
|
|
2
|
+
/**
|
|
3
|
+
* Marks a deployment config field, or the whole deployment schema, as platform-only (Zod 4 meta
|
|
4
|
+
* `{ platformOnly: true }`), merging with existing meta (`secret`, `hot`, `ui`), also the meta of
|
|
5
|
+
* the nodes under `.optional()` / `.default()` and the other wrappers, so
|
|
6
|
+
* `platformOnly(secret(x))` and `secret(platformOnly(x))` are the same. `configJsonSchema`
|
|
7
|
+
* publishes it as `"x-platform-only": true`; it is allowed on the root and on its top-level
|
|
8
|
+
* properties (a nested field has the level of its top-level key).
|
|
9
|
+
*
|
|
10
|
+
* Every deployment field without the mark is overridable: an org follows the platform's value until
|
|
11
|
+
* it saves its own copy, and the extension reads it from the per-call `config` (the effective config
|
|
12
|
+
* for the org), not from `ctx.config`. A platform-only field is set only by the platform and is never
|
|
13
|
+
* shown to an org.
|
|
14
|
+
*
|
|
15
|
+
* The effective config of an org that has its own copy still contains the platform-only secrets,
|
|
16
|
+
* which an org cannot set; it never contains an overridable platform secret. Never send a
|
|
17
|
+
* platform-only secret to an endpoint taken from an overridable field: an org could point that
|
|
18
|
+
* endpoint at a server it controls.
|
|
19
|
+
*/
|
|
20
|
+
export function platformOnly(schema) {
|
|
21
|
+
return withMeta(schema, "platformOnly", true);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether a schema carries the {@link platformOnly} mark. It sees through `.optional()`,
|
|
25
|
+
* `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the outermost meta
|
|
26
|
+
* wins), so it agrees with the `"x-platform-only"` that `configJsonSchema` publishes.
|
|
27
|
+
*/
|
|
28
|
+
export function isPlatformOnly(schema) {
|
|
29
|
+
for (const node of wrapperChain(schema)) {
|
|
30
|
+
const v = node.meta()?.platformOnly;
|
|
31
|
+
if (v !== undefined)
|
|
32
|
+
return v === true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
@@ -89,7 +89,6 @@ export interface PluginExtensionSection {
|
|
|
89
89
|
*/
|
|
90
90
|
configSchemas?: {
|
|
91
91
|
deployment?: JsonSchema;
|
|
92
|
-
org?: JsonSchema;
|
|
93
92
|
};
|
|
94
93
|
/** Browser code, styles and assets (needs `permissions.client: true`); see {@link PluginClientSection}. */
|
|
95
94
|
client?: PluginClientSection;
|
|
@@ -157,7 +156,11 @@ export interface PluginManifest {
|
|
|
157
156
|
/** A connector template file `connectors/<id>.json`; the template id is the file's base name. */
|
|
158
157
|
export interface ConnectorTemplateFile {
|
|
159
158
|
displayName: LocalizedName;
|
|
160
|
-
|
|
159
|
+
/**
|
|
160
|
+
* A string (shown in both languages) or `{ zh, en }`; each text ≤
|
|
161
|
+
* {@link CONNECTOR_TEMPLATE_LIMITS}`.descriptionChars` characters.
|
|
162
|
+
*/
|
|
163
|
+
description?: string | LocalizedName;
|
|
161
164
|
/** Safe path relative to the plugin root (an optional leading `./`), .svg / .png. */
|
|
162
165
|
icon?: string;
|
|
163
166
|
/**
|
package/dist/plugin-manifest.js
CHANGED
|
@@ -93,6 +93,30 @@ const baseId = (p) => (p.split("/").pop() ?? "").replace(/\.json$/, "");
|
|
|
93
93
|
const configFields = z
|
|
94
94
|
.array(z.strictObject({ path: z.string().max(1000), secret: z.boolean(), hot: z.boolean() }))
|
|
95
95
|
.max(1000);
|
|
96
|
+
const configSchemaJson = z
|
|
97
|
+
.record(z.string(), z.unknown())
|
|
98
|
+
.refine((v) => new TextEncoder().encode(JSON.stringify(v)).length <= CONFIG_UI_LIMITS.configSchemaBytes, {
|
|
99
|
+
message: `must be at most ${CONFIG_UI_LIMITS.configSchemaBytes} bytes of JSON (${CONFIG_UI_LIMITS.configSchemaBytes / 1024} KiB)`,
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Transition only: packages packed before core#720 carry the old org-only config in plugin.json:
|
|
103
|
+
* `extension.manifest.config.org` (the org config field list, often `[]`) and
|
|
104
|
+
* `extension.configSchemas.org` (its form schema). Published tarballs are immutable, so the reader
|
|
105
|
+
* accepts both and drops them: they never reach the parsed manifest, the permission set, the
|
|
106
|
+
* config levels or the views. Nothing else reads them, `defineExtension` drops a module's
|
|
107
|
+
* `config.org` the same way, and the packer refuses it and never writes either. Removed once the official plugins are
|
|
108
|
+
* republished and re-pinned (core#720 plan Task 17).
|
|
109
|
+
*/
|
|
110
|
+
const legacyPackedBeforeCore720 = {
|
|
111
|
+
configOrg: configFields.optional().meta({
|
|
112
|
+
deprecated: true,
|
|
113
|
+
description: "Ignored: written only by packers before core#720.",
|
|
114
|
+
}),
|
|
115
|
+
configSchemasOrg: configSchemaJson.optional().meta({
|
|
116
|
+
deprecated: true,
|
|
117
|
+
description: "Ignored: written only by packers before core#720.",
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
96
120
|
const staticExtensionManifest = z.strictObject({
|
|
97
121
|
name: z.string(),
|
|
98
122
|
version: z.string(),
|
|
@@ -102,12 +126,9 @@ const staticExtensionManifest = z.strictObject({
|
|
|
102
126
|
optional: z.array(z.string()),
|
|
103
127
|
permissions: z.record(z.string(), z.unknown()),
|
|
104
128
|
ui: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
105
|
-
config: z
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
.record(z.string(), z.unknown())
|
|
109
|
-
.refine((v) => new TextEncoder().encode(JSON.stringify(v)).length <= CONFIG_UI_LIMITS.configSchemaBytes, {
|
|
110
|
-
message: `must be at most ${CONFIG_UI_LIMITS.configSchemaBytes} bytes of JSON (${CONFIG_UI_LIMITS.configSchemaBytes / 1024} KiB)`,
|
|
129
|
+
config: z
|
|
130
|
+
.strictObject({ deployment: configFields, org: legacyPackedBeforeCore720.configOrg })
|
|
131
|
+
.transform(({ org: _legacyOrg, ...config }) => config),
|
|
111
132
|
});
|
|
112
133
|
const setupGuide = z.strictObject({
|
|
113
134
|
id: z.string().regex(CATALOG_ITEM_NAME_RE, {
|
|
@@ -149,7 +170,11 @@ const extensionSection = z.strictObject({
|
|
|
149
170
|
migrations: dotPath("migrations").optional(),
|
|
150
171
|
ui: dotPath("ui").optional(),
|
|
151
172
|
configSchemas: z
|
|
152
|
-
.strictObject({
|
|
173
|
+
.strictObject({
|
|
174
|
+
deployment: configSchemaJson.optional(),
|
|
175
|
+
org: legacyPackedBeforeCore720.configSchemasOrg,
|
|
176
|
+
})
|
|
177
|
+
.transform(({ org: _legacyOrg, ...schemas }) => schemas)
|
|
153
178
|
.optional(),
|
|
154
179
|
client: clientSection.optional(),
|
|
155
180
|
});
|
|
@@ -384,14 +409,12 @@ const schema = z
|
|
|
384
409
|
if (semver.validRange(em.sdk) !== null && !hasUpperBound(em.sdk)) {
|
|
385
410
|
issue(["extension", "manifest", "sdk"], `"${em.sdk}" has no upper bound: use a range such as ^0.1.0 so a future major SDK is not assumed compatible`);
|
|
386
411
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
issue(["extension", "manifest", "config", k], `duplicate config path "${f.path}"`);
|
|
392
|
-
}
|
|
393
|
-
seen.add(f.path);
|
|
412
|
+
const seen = new Set();
|
|
413
|
+
for (const f of em.config.deployment) {
|
|
414
|
+
if (seen.has(f.path)) {
|
|
415
|
+
issue(["extension", "manifest", "config", "deployment"], `duplicate config path "${f.path}"`);
|
|
394
416
|
}
|
|
417
|
+
seen.add(f.path);
|
|
395
418
|
}
|
|
396
419
|
// Name, version, sdk range, extension point refs, permissions, UI contributions: the same
|
|
397
420
|
// rules as defineExtension (with a placeholder setup).
|
|
@@ -430,7 +453,15 @@ const template = z.strictObject({
|
|
|
430
453
|
const templateFile = z
|
|
431
454
|
.strictObject({
|
|
432
455
|
displayName: localized,
|
|
433
|
-
description:
|
|
456
|
+
description: z
|
|
457
|
+
.union([
|
|
458
|
+
text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description"),
|
|
459
|
+
z.strictObject({
|
|
460
|
+
zh: text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description.zh"),
|
|
461
|
+
en: text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description.en"),
|
|
462
|
+
}),
|
|
463
|
+
])
|
|
464
|
+
.optional(),
|
|
434
465
|
icon: z
|
|
435
466
|
.string()
|
|
436
467
|
.max(L.pathChars)
|
package/dist/plugin-package.d.ts
CHANGED
|
@@ -45,7 +45,6 @@ export interface StaticExtensionManifest {
|
|
|
45
45
|
ui?: ExtensionManifest["ui"];
|
|
46
46
|
config: {
|
|
47
47
|
deployment: StaticConfigField[];
|
|
48
|
-
org: StaticConfigField[];
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
@@ -154,7 +153,7 @@ export declare const CONNECTOR_TEMPLATE_LIMITS: {
|
|
|
154
153
|
readonly toolPolicies: 1000;
|
|
155
154
|
/** Upper bound on the characters of publisher. */
|
|
156
155
|
readonly publisherChars: 100;
|
|
157
|
-
/** Upper bound on the characters of description. */
|
|
156
|
+
/** Upper bound on the characters of description (per language when it is `{ zh, en }`). */
|
|
158
157
|
readonly descriptionChars: 1024;
|
|
159
158
|
/** Upper bound on the characters of displayName per language. */
|
|
160
159
|
readonly displayNameChars: 100;
|
package/dist/plugin-package.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
import { ConnectorAuthSchema } from "./connector-auth.js";
|
|
3
3
|
import { EXTENSION_NAME_RE } from "./define-extension.js";
|
|
4
|
+
import { chainMeta, wrapperChain } from "./field-meta.js";
|
|
4
5
|
import { validateGitSource } from "./git-hosts.js";
|
|
5
6
|
/**
|
|
6
7
|
* Plugin package (npm-pack tgz) rules shared by the SDK, the packer and the kernel (spec §4.1). Pure
|
|
@@ -83,28 +84,23 @@ export function checkEntryImports(specifiers) {
|
|
|
83
84
|
}
|
|
84
85
|
return out;
|
|
85
86
|
}
|
|
86
|
-
const WRAPPERS = new Set(["default", "prefault", "optional", "nullable", "readonly", "catch"]);
|
|
87
87
|
const defOf = (s) => s._zod.def;
|
|
88
|
-
const metaOf = (s) => s.meta();
|
|
89
88
|
/**
|
|
90
89
|
* The same traversal as the kernel's `configFields`: objects are expanded recursively, wrappers
|
|
91
|
-
* such as default / optional are stripped
|
|
90
|
+
* such as default / optional are stripped (their meta merged, `secret` from any of them), and a
|
|
91
|
+
* secret on an object is inherited downward.
|
|
92
92
|
*/
|
|
93
93
|
function configFieldsOf(schema, prefix = "", inheritedSecret = false) {
|
|
94
94
|
if (!schema)
|
|
95
95
|
return [];
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
meta ??= metaOf(node);
|
|
101
|
-
}
|
|
102
|
-
const secret = inheritedSecret || meta?.secret === true;
|
|
103
|
-
const def = defOf(node);
|
|
96
|
+
const chain = wrapperChain(schema);
|
|
97
|
+
const meta = chainMeta(schema);
|
|
98
|
+
const secret = inheritedSecret || meta.secret === true;
|
|
99
|
+
const def = defOf(chain[chain.length - 1]);
|
|
104
100
|
if (def.type === "object" && def.shape) {
|
|
105
101
|
return Object.entries(def.shape).flatMap(([k, v]) => configFieldsOf(v, prefix ? `${prefix}.${k}` : k, secret));
|
|
106
102
|
}
|
|
107
|
-
return [{ path: prefix, secret, hot: meta
|
|
103
|
+
return [{ path: prefix, secret, hot: meta.hot === true }];
|
|
108
104
|
}
|
|
109
105
|
const byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
110
106
|
const jsonClone = (v) => JSON.parse(JSON.stringify(v));
|
|
@@ -125,7 +121,6 @@ export function staticManifestOf(m) {
|
|
|
125
121
|
permissions: jsonClone(m.permissions ?? {}),
|
|
126
122
|
config: {
|
|
127
123
|
deployment: configFieldsOf(m.config?.deployment).sort(byPath),
|
|
128
|
-
org: configFieldsOf(m.config?.org).sort(byPath),
|
|
129
124
|
},
|
|
130
125
|
};
|
|
131
126
|
if (m.ui !== undefined)
|
|
@@ -285,7 +280,7 @@ export const CONNECTOR_TEMPLATE_LIMITS = {
|
|
|
285
280
|
toolPolicies: 1000,
|
|
286
281
|
/** Upper bound on the characters of publisher. */
|
|
287
282
|
publisherChars: 100,
|
|
288
|
-
/** Upper bound on the characters of description. */
|
|
283
|
+
/** Upper bound on the characters of description (per language when it is `{ zh, en }`). */
|
|
289
284
|
descriptionChars: 1024,
|
|
290
285
|
/** Upper bound on the characters of displayName per language. */
|
|
291
286
|
displayNameChars: 100,
|
package/dist/secret.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Marks a schema as a secret field (Zod 4 meta `{ secret: true }`), merging with existing meta
|
|
4
|
-
* (`ui` hints, `hot`),
|
|
4
|
+
* (`ui` hints, `hot`, `platformOnly`), also the meta of the nodes under `.optional()` /
|
|
5
|
+
* `.default()` and the other wrappers, so `secret(ui(x, …))` and `ui(secret(x), …)` are the same.
|
|
5
6
|
*/
|
|
6
7
|
export declare function secret<T extends z.ZodTypeAny>(schema: T): T;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Whether a schema is sensitive: `secret: true` in its meta or in the meta of any node it wraps
|
|
10
|
+
* through `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()`
|
|
11
|
+
* (fail-safe: an outer meta never hides the mark). The kernel's `meta({secret:true})` is recognized
|
|
12
|
+
* the same way.
|
|
10
13
|
*/
|
|
11
14
|
export declare function isSecret(schema: z.ZodTypeAny): boolean;
|
package/dist/secret.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { chainMeta, withMeta } from "./field-meta.js";
|
|
1
2
|
/**
|
|
2
3
|
* Marks a schema as a secret field (Zod 4 meta `{ secret: true }`), merging with existing meta
|
|
3
|
-
* (`ui` hints, `hot`),
|
|
4
|
+
* (`ui` hints, `hot`, `platformOnly`), also the meta of the nodes under `.optional()` /
|
|
5
|
+
* `.default()` and the other wrappers, so `secret(ui(x, …))` and `ui(secret(x), …)` are the same.
|
|
4
6
|
*/
|
|
5
7
|
export function secret(schema) {
|
|
6
|
-
return
|
|
8
|
+
return withMeta(schema, "secret", true);
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* Whether a schema is sensitive: `secret: true` in its meta or in the meta of any node it wraps
|
|
12
|
+
* through `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()`
|
|
13
|
+
* (fail-safe: an outer meta never hides the mark). The kernel's `meta({secret:true})` is recognized
|
|
14
|
+
* the same way.
|
|
11
15
|
*/
|
|
12
16
|
export function isSecret(schema) {
|
|
13
|
-
return schema.
|
|
17
|
+
return chainMeta(schema).secret === true;
|
|
14
18
|
}
|
package/dist/tool.d.ts
CHANGED
|
@@ -178,8 +178,7 @@ export interface ToolCallContext {
|
|
|
178
178
|
* The key of this logical call for idempotent side effects: 64 lowercase hex characters derived
|
|
179
179
|
* from the conversation, the run and `callId`. The same for every invocation of the call
|
|
180
180
|
* (each `InputRequired` round), different for every other call, including a later call the
|
|
181
|
-
* model makes to retry it.
|
|
182
|
-
* passes it.
|
|
181
|
+
* model makes to retry it.
|
|
183
182
|
*/
|
|
184
183
|
idempotencyKey?: string;
|
|
185
184
|
signal: AbortSignal;
|
|
@@ -190,10 +189,9 @@ export interface ToolCallContext {
|
|
|
190
189
|
};
|
|
191
190
|
/**
|
|
192
191
|
* The extension's effective deployment config for this org: the platform's deployment config
|
|
193
|
-
* with the org's copy applied to the overridable fields (
|
|
194
|
-
* platform's config (equal to `ctx.config`) while the org follows it. Use it, not
|
|
195
|
-
* for work done for this org.
|
|
196
|
-
* always passes it.
|
|
192
|
+
* with the org's copy applied to the overridable fields (every field not marked `platformOnly`),
|
|
193
|
+
* or the platform's config (equal to `ctx.config`) while the org follows it. Use it, not
|
|
194
|
+
* `ctx.config`, for work done for this org.
|
|
197
195
|
*/
|
|
198
196
|
config?: unknown;
|
|
199
197
|
/** Where the conversation comes from. The kernel always passes it. */
|
package/dist/ui.d.ts
CHANGED
|
@@ -195,10 +195,9 @@ export interface UiRenderArgsBase {
|
|
|
195
195
|
signal: AbortSignal;
|
|
196
196
|
/**
|
|
197
197
|
* The extension's effective deployment config: for an org, the platform's deployment config
|
|
198
|
-
* with the org's copy applied to the overridable fields (
|
|
199
|
-
* platform's config (equal to `ctx.config`) while the org follows it; for the platform
|
|
200
|
-
* the platform's config. Use it, not `ctx.config`, for work done for this org.
|
|
201
|
-
* type so older extensions compile; the kernel always passes it.
|
|
198
|
+
* with the org's copy applied to the overridable fields (every field not marked `platformOnly`),
|
|
199
|
+
* or the platform's config (equal to `ctx.config`) while the org follows it; for the platform
|
|
200
|
+
* scope, the platform's config. Use it, not `ctx.config`, for work done for this org.
|
|
202
201
|
*/
|
|
203
202
|
config?: unknown;
|
|
204
203
|
}
|
package/dist/web.d.ts
CHANGED
|
@@ -13,30 +13,33 @@ export interface WebSearchResult {
|
|
|
13
13
|
publishedAt?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A web search provider (`web-search@1`). The kernel passes the
|
|
17
|
-
*
|
|
16
|
+
* A web search provider (`web-search@1`). The kernel passes the extension's effective config for
|
|
17
|
+
* the org (`config`).
|
|
18
18
|
*/
|
|
19
19
|
export interface WebSearchProvider {
|
|
20
20
|
/**
|
|
21
|
-
* False when this org's config lacks what the provider needs
|
|
22
|
-
*
|
|
21
|
+
* False when this org's effective config lacks what the provider needs (see `search`'s
|
|
22
|
+
* `config`).
|
|
23
23
|
*/
|
|
24
|
-
configured?(
|
|
24
|
+
configured?(config: unknown): boolean;
|
|
25
25
|
search(args: {
|
|
26
26
|
query: string;
|
|
27
27
|
/** Hints only: the kernel filters the results again. */
|
|
28
28
|
allowedDomains?: string[];
|
|
29
29
|
blockedDomains?: string[];
|
|
30
30
|
maxResults: number;
|
|
31
|
-
orgConfig: unknown;
|
|
32
31
|
/**
|
|
33
|
-
* The extension's effective
|
|
34
|
-
*
|
|
32
|
+
* The extension's effective config for this org: the platform's deployment config with the
|
|
33
|
+
* org's copy applied to the overridable fields (every field not marked `platformOnly`), or the
|
|
35
34
|
* platform's config (equal to `ctx.config`) while the org follows it. Use it, not `ctx.config`,
|
|
36
|
-
* for work done for this org.
|
|
37
|
-
* always passes it.
|
|
35
|
+
* for work done for this org.
|
|
38
36
|
*/
|
|
39
|
-
config
|
|
37
|
+
config: unknown;
|
|
38
|
+
/**
|
|
39
|
+
* The org the call is made for. Pass it to `configUrlFetch` (`orgId`) or `ctx.net.fetch`, so a
|
|
40
|
+
* URL an org set is checked against that org's network rules. The kernel always sets it.
|
|
41
|
+
*/
|
|
42
|
+
orgId?: string;
|
|
40
43
|
signal: AbortSignal;
|
|
41
44
|
}): Promise<{
|
|
42
45
|
results: WebSearchResult[];
|
|
@@ -63,22 +66,25 @@ export interface WebFetchPage {
|
|
|
63
66
|
*/
|
|
64
67
|
export interface WebFetchProvider {
|
|
65
68
|
/**
|
|
66
|
-
* False when this org's config lacks what the provider needs
|
|
67
|
-
*
|
|
69
|
+
* False when this org's effective config lacks what the provider needs (see `fetch`'s
|
|
70
|
+
* `config`).
|
|
68
71
|
*/
|
|
69
|
-
configured?(
|
|
72
|
+
configured?(config: unknown): boolean;
|
|
70
73
|
fetch(args: {
|
|
71
74
|
/** Already validated and upgraded by the kernel. */
|
|
72
75
|
url: string;
|
|
73
|
-
orgConfig: unknown;
|
|
74
76
|
/**
|
|
75
|
-
* The extension's effective
|
|
76
|
-
*
|
|
77
|
+
* The extension's effective config for this org: the platform's deployment config with the
|
|
78
|
+
* org's copy applied to the overridable fields (every field not marked `platformOnly`), or the
|
|
77
79
|
* platform's config (equal to `ctx.config`) while the org follows it. Use it, not `ctx.config`,
|
|
78
|
-
* for work done for this org.
|
|
79
|
-
|
|
80
|
+
* for work done for this org.
|
|
81
|
+
*/
|
|
82
|
+
config: unknown;
|
|
83
|
+
/**
|
|
84
|
+
* The org the call is made for. Pass it to `configUrlFetch` (`orgId`) or `ctx.net.fetch`, so a
|
|
85
|
+
* URL an org set is checked against that org's network rules. The kernel always sets it.
|
|
80
86
|
*/
|
|
81
|
-
|
|
87
|
+
orgId?: string;
|
|
82
88
|
signal: AbortSignal;
|
|
83
89
|
}): Promise<WebFetchPage>;
|
|
84
90
|
}
|
package/package.json
CHANGED
|
@@ -27,10 +27,36 @@
|
|
|
27
27
|
"additionalProperties": false
|
|
28
28
|
},
|
|
29
29
|
"description": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
"anyOf": [
|
|
31
|
+
{
|
|
32
|
+
"type": "string",
|
|
33
|
+
"minLength": 1,
|
|
34
|
+
"maxLength": 1024,
|
|
35
|
+
"pattern": "\\S"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"zh": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 1,
|
|
43
|
+
"maxLength": 1024,
|
|
44
|
+
"pattern": "\\S"
|
|
45
|
+
},
|
|
46
|
+
"en": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"minLength": 1,
|
|
49
|
+
"maxLength": 1024,
|
|
50
|
+
"pattern": "\\S"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"zh",
|
|
55
|
+
"en"
|
|
56
|
+
],
|
|
57
|
+
"additionalProperties": false
|
|
58
|
+
}
|
|
59
|
+
]
|
|
34
60
|
},
|
|
35
61
|
"icon": {
|
|
36
62
|
"type": "string",
|
|
@@ -353,6 +353,8 @@
|
|
|
353
353
|
}
|
|
354
354
|
},
|
|
355
355
|
"org": {
|
|
356
|
+
"deprecated": true,
|
|
357
|
+
"description": "Ignored: written only by packers before core#720.",
|
|
356
358
|
"maxItems": 1000,
|
|
357
359
|
"type": "array",
|
|
358
360
|
"items": {
|
|
@@ -379,8 +381,7 @@
|
|
|
379
381
|
}
|
|
380
382
|
},
|
|
381
383
|
"required": [
|
|
382
|
-
"deployment"
|
|
383
|
-
"org"
|
|
384
|
+
"deployment"
|
|
384
385
|
],
|
|
385
386
|
"additionalProperties": false
|
|
386
387
|
}
|
|
@@ -420,6 +421,8 @@
|
|
|
420
421
|
"additionalProperties": {}
|
|
421
422
|
},
|
|
422
423
|
"org": {
|
|
424
|
+
"deprecated": true,
|
|
425
|
+
"description": "Ignored: written only by packers before core#720.",
|
|
423
426
|
"type": "object",
|
|
424
427
|
"propertyNames": {
|
|
425
428
|
"type": "string"
|
package/dist/org-access.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* How an org may treat a deployment config field: `readonly` (the org sees it, never sets it) or
|
|
4
|
-
* `override` (an org may set its own value). A field without a level is deployment-only.
|
|
5
|
-
*/
|
|
6
|
-
export type OrgAccess = "readonly" | "override";
|
|
7
|
-
/**
|
|
8
|
-
* Marks a deployment config field with an org access level (Zod 4 meta `{ org: access }`), merging
|
|
9
|
-
* with existing meta (`secret`, `hot`, `ui`), so `orgAccess(secret(x), …)` and
|
|
10
|
-
* `secret(orgAccess(x, …))` are the same. `configJsonSchema` publishes it as `"x-org"`.
|
|
11
|
-
*
|
|
12
|
-
* The author's promise for `override`: the extension reads the field from the per-call `config`
|
|
13
|
-
* the kernel passes with each request, not from `ctx.config`, and the field may be absent from
|
|
14
|
-
* `ctx.config` (the deployment value is the default, which an org may replace per call).
|
|
15
|
-
*
|
|
16
|
-
* The per-call config of an org that has its own copy still contains the platform's hidden
|
|
17
|
-
* (platform-only) secrets, which an org cannot set; it never contains an overridable platform
|
|
18
|
-
* secret. Never send a hidden secret to an endpoint taken from an overridable field: an org could
|
|
19
|
-
* point that endpoint at a server it controls.
|
|
20
|
-
*/
|
|
21
|
-
export declare function orgAccess<T extends z.ZodTypeAny>(schema: T, access: OrgAccess): T;
|
|
22
|
-
/**
|
|
23
|
-
* The org access level of a schema's meta, or undefined when it has none. It sees through
|
|
24
|
-
* `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the
|
|
25
|
-
* outermost level wins), so it agrees with the `"x-org"` that `configJsonSchema` publishes.
|
|
26
|
-
*/
|
|
27
|
-
export declare function orgAccessOf(schema: z.ZodTypeAny): OrgAccess | undefined;
|
package/dist/org-access.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Marks a deployment config field with an org access level (Zod 4 meta `{ org: access }`), merging
|
|
3
|
-
* with existing meta (`secret`, `hot`, `ui`), so `orgAccess(secret(x), …)` and
|
|
4
|
-
* `secret(orgAccess(x, …))` are the same. `configJsonSchema` publishes it as `"x-org"`.
|
|
5
|
-
*
|
|
6
|
-
* The author's promise for `override`: the extension reads the field from the per-call `config`
|
|
7
|
-
* the kernel passes with each request, not from `ctx.config`, and the field may be absent from
|
|
8
|
-
* `ctx.config` (the deployment value is the default, which an org may replace per call).
|
|
9
|
-
*
|
|
10
|
-
* The per-call config of an org that has its own copy still contains the platform's hidden
|
|
11
|
-
* (platform-only) secrets, which an org cannot set; it never contains an overridable platform
|
|
12
|
-
* secret. Never send a hidden secret to an endpoint taken from an overridable field: an org could
|
|
13
|
-
* point that endpoint at a server it controls.
|
|
14
|
-
*/
|
|
15
|
-
export function orgAccess(schema, access) {
|
|
16
|
-
return schema.meta({ ...(schema.meta() ?? {}), org: access });
|
|
17
|
-
}
|
|
18
|
-
/** The wrappers a field's org level is read through, as `configJsonSchema` inherits meta. */
|
|
19
|
-
const WRAPPERS = new Set(["default", "prefault", "optional", "nullable", "readonly", "catch"]);
|
|
20
|
-
/**
|
|
21
|
-
* The org access level of a schema's meta, or undefined when it has none. It sees through
|
|
22
|
-
* `.optional()`, `.default()`, `.nullable()`, `.prefault()`, `.catch()` and `.readonly()` (the
|
|
23
|
-
* outermost level wins), so it agrees with the `"x-org"` that `configJsonSchema` publishes.
|
|
24
|
-
*/
|
|
25
|
-
export function orgAccessOf(schema) {
|
|
26
|
-
let node = schema;
|
|
27
|
-
while (node) {
|
|
28
|
-
const v = node.meta()?.org;
|
|
29
|
-
if (v === "readonly" || v === "override")
|
|
30
|
-
return v;
|
|
31
|
-
const def = node._zod.def;
|
|
32
|
-
node = WRAPPERS.has(def.type) ? def.innerType : undefined;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|