@harnesys/sdk 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/addon-context-factory.d.ts +6 -0
- package/dist/addon-context-factory.js +160 -0
- package/dist/addon-context.d.ts +346 -0
- package/dist/addon-context.js +0 -0
- package/dist/define-addon.d.ts +57 -0
- package/dist/define-addon.js +53 -0
- package/dist/families/config.d.ts +14 -0
- package/dist/families/config.js +16 -0
- package/dist/families/content.d.ts +28 -0
- package/dist/families/content.js +19 -0
- package/dist/families/field-spec.d.ts +100 -0
- package/dist/families/field-spec.js +85 -0
- package/dist/families/hook.d.ts +37 -0
- package/dist/families/hook.js +25 -0
- package/dist/families/job.d.ts +45 -0
- package/dist/families/job.js +26 -0
- package/dist/families/json-schema-value.d.ts +12 -0
- package/dist/families/json-schema-value.js +243 -0
- package/dist/families/json-schema.d.ts +36 -0
- package/dist/families/json-schema.js +101 -0
- package/dist/families/lsp.d.ts +18 -0
- package/dist/families/lsp.js +18 -0
- package/dist/families/mcp.d.ts +18 -0
- package/dist/families/mcp.js +18 -0
- package/dist/families/registry.d.ts +9 -0
- package/dist/families/registry.js +34 -0
- package/dist/families/route.d.ts +38 -0
- package/dist/families/route.js +37 -0
- package/dist/families/source-kind.d.ts +24 -0
- package/dist/families/source-kind.js +21 -0
- package/dist/families/tool-pack.d.ts +68 -0
- package/dist/families/tool-pack.js +57 -0
- package/dist/families/transport.d.ts +52 -0
- package/dist/families/transport.js +29 -0
- package/dist/families/trigger.d.ts +97 -0
- package/dist/families/trigger.js +46 -0
- package/dist/families/view.d.ts +255 -0
- package/dist/families/view.js +87 -0
- package/dist/families/viewer.d.ts +31 -0
- package/dist/families/viewer.js +26 -0
- package/dist/families/worker.d.ts +23 -0
- package/dist/families/worker.js +19 -0
- package/dist/host-client.d.ts +11 -0
- package/dist/host-client.js +30 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/manifest/branding.d.ts +14 -0
- package/dist/manifest/branding.js +18 -0
- package/dist/manifest/connections.d.ts +21 -0
- package/dist/manifest/connections.js +10 -0
- package/dist/manifest/json-schema.d.ts +2 -0
- package/dist/manifest/json-schema.js +13 -0
- package/dist/manifest/l10n.d.ts +9 -0
- package/dist/manifest/l10n.js +28 -0
- package/dist/manifest/manifest.d.ts +112 -0
- package/dist/manifest/manifest.js +45 -0
- package/dist/manifest/validate.d.ts +14 -0
- package/dist/manifest/validate.js +144 -0
- package/dist/permissions/permissions.d.ts +31 -0
- package/dist/permissions/permissions.js +53 -0
- package/dist/process-entry.d.ts +26 -0
- package/dist/process-entry.js +146 -0
- package/dist/protocol/envelope.d.ts +115 -0
- package/dist/protocol/envelope.js +72 -0
- package/dist/protocol/error.d.ts +67 -0
- package/dist/protocol/error.js +61 -0
- package/dist/protocol/handshake.d.ts +55 -0
- package/dist/protocol/handshake.js +26 -0
- package/dist/protocol/map.d.ts +1090 -0
- package/dist/protocol/map.js +127 -0
- package/dist/protocol/meta.d.ts +31 -0
- package/dist/protocol/meta.js +14 -0
- package/dist/protocol/method-spec.d.ts +13 -0
- package/dist/protocol/method-spec.js +9 -0
- package/dist/protocol/org-service-methods.d.ts +135 -0
- package/dist/protocol/org-service-methods.js +106 -0
- package/dist/protocol/shared.d.ts +389 -0
- package/dist/protocol/shared.js +231 -0
- package/dist/protocol/source-methods.d.ts +218 -0
- package/dist/protocol/source-methods.js +18 -0
- package/dist/protocol/thread-service-methods.d.ts +50 -0
- package/dist/protocol/thread-service-methods.js +32 -0
- package/dist/runtime.d.ts +25 -0
- package/dist/runtime.js +229 -0
- package/dist/testing/fake-db.d.ts +15 -0
- package/dist/testing/fake-db.js +120 -0
- package/dist/testing/fake-files.d.ts +9 -0
- package/dist/testing/fake-files.js +87 -0
- package/dist/testing/fake-host.d.ts +115 -0
- package/dist/testing/fake-host.js +217 -0
- package/dist/testing/fake-services.d.ts +63 -0
- package/dist/testing/fake-services.js +277 -0
- package/dist/testing/fixtures.d.ts +5 -0
- package/dist/testing/fixtures.js +101 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +2 -0
- package/package.json +66 -4
- package/src/addon-context-factory.ts +236 -0
- package/src/addon-context.ts +313 -0
- package/src/define-addon.ts +178 -0
- package/src/families/config.ts +24 -0
- package/src/families/content.ts +35 -0
- package/src/families/field-spec.ts +175 -0
- package/src/families/hook.ts +34 -0
- package/src/families/job.ts +41 -0
- package/src/families/json-schema-value.ts +322 -0
- package/src/families/json-schema.ts +167 -0
- package/src/families/lsp.ts +28 -0
- package/src/families/mcp.ts +28 -0
- package/src/families/registry.ts +44 -0
- package/src/families/route.ts +52 -0
- package/src/families/source-kind.ts +34 -0
- package/src/families/tool-pack.ts +92 -0
- package/src/families/transport.ts +52 -0
- package/src/families/trigger.ts +92 -0
- package/src/families/view.ts +144 -0
- package/src/families/viewer.ts +43 -0
- package/src/families/worker.ts +30 -0
- package/src/host-client.ts +52 -0
- package/src/index.ts +345 -0
- package/src/manifest/branding.ts +24 -0
- package/src/manifest/connections.ts +21 -0
- package/src/manifest/json-schema.ts +24 -0
- package/src/manifest/l10n.ts +39 -0
- package/src/manifest/manifest.ts +94 -0
- package/src/manifest/validate.ts +200 -0
- package/src/permissions/permissions.ts +79 -0
- package/src/process-entry.ts +205 -0
- package/src/protocol/envelope.ts +126 -0
- package/src/protocol/error.ts +81 -0
- package/src/protocol/handshake.ts +43 -0
- package/src/protocol/map.ts +339 -0
- package/src/protocol/meta.ts +26 -0
- package/src/protocol/method-spec.ts +40 -0
- package/src/protocol/org-service-methods.ts +148 -0
- package/src/protocol/shared.ts +345 -0
- package/src/protocol/source-methods.ts +61 -0
- package/src/protocol/thread-service-methods.ts +50 -0
- package/src/runtime.ts +332 -0
- package/src/testing/fake-db.ts +140 -0
- package/src/testing/fake-files.ts +114 -0
- package/src/testing/fake-host.ts +350 -0
- package/src/testing/fake-services.ts +345 -0
- package/src/testing/fixtures.ts +106 -0
- package/src/testing/index.ts +12 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function deriveHandlers(definition) {
|
|
2
|
+
const handlers = ['ping', 'shutdown'];
|
|
3
|
+
const hasKeys = (value) => value !== undefined && Object.keys(value).length > 0;
|
|
4
|
+
if (hasKeys(definition.tools)) {
|
|
5
|
+
handlers.push('tools.call');
|
|
6
|
+
}
|
|
7
|
+
if (hasKeys(definition.routes)) {
|
|
8
|
+
handlers.push('route.handle');
|
|
9
|
+
}
|
|
10
|
+
if (hasKeys(definition.triggers)) {
|
|
11
|
+
handlers.push('trigger.start', 'trigger.stop');
|
|
12
|
+
}
|
|
13
|
+
if (hasKeys(definition.jobs)) {
|
|
14
|
+
handlers.push('job.run');
|
|
15
|
+
}
|
|
16
|
+
if (hasKeys(definition.workers)) {
|
|
17
|
+
handlers.push('worker.start', 'worker.stop');
|
|
18
|
+
}
|
|
19
|
+
if (definition.transport?.send !== undefined) {
|
|
20
|
+
handlers.push('transport.send');
|
|
21
|
+
}
|
|
22
|
+
if (definition.transport?.edit !== undefined) {
|
|
23
|
+
handlers.push('transport.edit');
|
|
24
|
+
}
|
|
25
|
+
if (definition.transport?.typing !== undefined) {
|
|
26
|
+
handlers.push('transport.typing');
|
|
27
|
+
}
|
|
28
|
+
if (hasKeys(definition.hooks)) {
|
|
29
|
+
handlers.push('hook.deliver');
|
|
30
|
+
}
|
|
31
|
+
handlers.push(...sourceHandlerNames(definition.sources));
|
|
32
|
+
if (definition.lifecycle?.upgrade !== undefined) {
|
|
33
|
+
handlers.push('lifecycle.upgrade');
|
|
34
|
+
}
|
|
35
|
+
return handlers;
|
|
36
|
+
}
|
|
37
|
+
function sourceHandlerNames(sources) {
|
|
38
|
+
if (sources === undefined || Object.keys(sources).length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const names = ['source.list', 'source.stat', 'source.download'];
|
|
42
|
+
const implementations = Object.values(sources);
|
|
43
|
+
const anyOp = (op) => implementations.some((backend) => backend[op] !== undefined);
|
|
44
|
+
for (const op of ['upload', 'mkdir', 'remove', 'export']) {
|
|
45
|
+
if (anyOp(op)) {
|
|
46
|
+
names.push(`source.${op}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return names;
|
|
50
|
+
}
|
|
51
|
+
export function defineAddon(definition) {
|
|
52
|
+
return { ...definition, handlers: deriveHandlers(definition) };
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { FieldSpec } from './field-spec.ts';
|
|
3
|
+
export declare const CONFIG_SCHEMA_VERSION = 1;
|
|
4
|
+
export interface ConfigDescriptor {
|
|
5
|
+
fields: FieldSpec[];
|
|
6
|
+
}
|
|
7
|
+
export declare const ConfigDescriptorSchema: z.ZodObject<{
|
|
8
|
+
fields: z.ZodArray<z.ZodType<FieldSpec, unknown, z.core.$ZodTypeInternals<FieldSpec, unknown>>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const configFamily: {
|
|
11
|
+
family: string;
|
|
12
|
+
versions: number[];
|
|
13
|
+
schema: (v: number) => z.ZodType;
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FieldSpecSchema } from "./field-spec.js";
|
|
3
|
+
export const CONFIG_SCHEMA_VERSION = 1;
|
|
4
|
+
export const ConfigDescriptorSchema = z.object({
|
|
5
|
+
fields: z.array(FieldSpecSchema),
|
|
6
|
+
});
|
|
7
|
+
export const configFamily = {
|
|
8
|
+
family: 'config',
|
|
9
|
+
versions: [CONFIG_SCHEMA_VERSION],
|
|
10
|
+
schema: (v) => {
|
|
11
|
+
if (v !== CONFIG_SCHEMA_VERSION) {
|
|
12
|
+
throw new Error(`config descriptor schema version ${v} is not supported`);
|
|
13
|
+
}
|
|
14
|
+
return ConfigDescriptorSchema;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { L10n } from '../manifest/l10n.ts';
|
|
3
|
+
export declare const CONTENT_SCHEMA_VERSION = 1;
|
|
4
|
+
export interface ContentDescriptor {
|
|
5
|
+
id: string;
|
|
6
|
+
title: L10n;
|
|
7
|
+
kind: 'skill' | 'prompt';
|
|
8
|
+
/**
|
|
9
|
+
* Path from the package root. For `kind: 'skill'` it is the skill directory
|
|
10
|
+
* (containing `SKILL.md` and its `references/`); a path to a single markdown
|
|
11
|
+
* file is still accepted for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const ContentDescriptorSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
skill: "skill";
|
|
20
|
+
prompt: "prompt";
|
|
21
|
+
}>;
|
|
22
|
+
path: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const contentFamily: {
|
|
25
|
+
family: string;
|
|
26
|
+
versions: number[];
|
|
27
|
+
schema: (v: number) => z.ZodType;
|
|
28
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { L10nSchema } from "../manifest/l10n.js";
|
|
3
|
+
export const CONTENT_SCHEMA_VERSION = 1;
|
|
4
|
+
export const ContentDescriptorSchema = z.object({
|
|
5
|
+
id: z.string().min(1),
|
|
6
|
+
title: L10nSchema,
|
|
7
|
+
kind: z.enum(['skill', 'prompt']),
|
|
8
|
+
path: z.string().min(1),
|
|
9
|
+
});
|
|
10
|
+
export const contentFamily = {
|
|
11
|
+
family: 'content',
|
|
12
|
+
versions: [CONTENT_SCHEMA_VERSION],
|
|
13
|
+
schema: (v) => {
|
|
14
|
+
if (v !== CONTENT_SCHEMA_VERSION) {
|
|
15
|
+
throw new Error(`content descriptor schema version ${v} is not supported`);
|
|
16
|
+
}
|
|
17
|
+
return ContentDescriptorSchema;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type FieldType = 'text' | 'secret' | 'textarea' | 'url' | 'select' | 'number' | 'boolean' | 'group';
|
|
3
|
+
export type FieldValue = string | number | boolean | null;
|
|
4
|
+
export interface FieldOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** Hint shown for the currently selected option. */
|
|
8
|
+
help?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Conditional visibility: show the field only when `values[key]` matches. */
|
|
11
|
+
export interface FieldVisibleWhen {
|
|
12
|
+
key: string;
|
|
13
|
+
equals?: string;
|
|
14
|
+
oneOf?: string[];
|
|
15
|
+
}
|
|
16
|
+
/** Rich editor registered on the client; unknown kinds fall back to the base type. */
|
|
17
|
+
export interface FieldWidget {
|
|
18
|
+
kind: string;
|
|
19
|
+
params?: Record<string, string | number | boolean>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Declarative option source resolved by the host: an add-on-owned GET route
|
|
23
|
+
* or the add-on's connected accounts. No per-provider client code.
|
|
24
|
+
*/
|
|
25
|
+
export type FieldOptionsFrom = {
|
|
26
|
+
/** Route id served under `/orgs/:orgId/addons/:addonId/r/<route>`. */
|
|
27
|
+
kind: 'addonRoute';
|
|
28
|
+
route: string;
|
|
29
|
+
/** Field keys passed to the route as query params. */
|
|
30
|
+
dependsOn?: string[];
|
|
31
|
+
/** Response body key holding the rows. Defaults to `rows`. */
|
|
32
|
+
listKey?: string;
|
|
33
|
+
/** Row field used as the option value. */
|
|
34
|
+
valueKey: string;
|
|
35
|
+
/** Row field used as the option label. Defaults to `valueKey`. */
|
|
36
|
+
labelKey?: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'connections';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'agents';
|
|
41
|
+
};
|
|
42
|
+
export interface FieldSpec {
|
|
43
|
+
key: string;
|
|
44
|
+
label: string;
|
|
45
|
+
type: FieldType;
|
|
46
|
+
required: boolean;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
help?: string;
|
|
49
|
+
default?: FieldValue;
|
|
50
|
+
options?: FieldOption[];
|
|
51
|
+
/** Option-valued field accepting several values, stored as one comma-separated string. */
|
|
52
|
+
multi?: boolean;
|
|
53
|
+
/** Options resolved by the host at render time; static `options` stay the fallback. */
|
|
54
|
+
optionsFrom?: FieldOptionsFrom;
|
|
55
|
+
pattern?: {
|
|
56
|
+
regex: string;
|
|
57
|
+
hint: string;
|
|
58
|
+
};
|
|
59
|
+
editable?: boolean;
|
|
60
|
+
generated?: boolean;
|
|
61
|
+
/** Children of a `group` field. */
|
|
62
|
+
fields?: FieldSpec[];
|
|
63
|
+
visibleWhen?: FieldVisibleWhen;
|
|
64
|
+
widget?: FieldWidget;
|
|
65
|
+
/** `group` only: render collapsed by default. */
|
|
66
|
+
collapsible?: boolean;
|
|
67
|
+
/** `group` only: an expert section, rendered after the main fields. */
|
|
68
|
+
advanced?: boolean;
|
|
69
|
+
/** `group` only: grid columns for children. */
|
|
70
|
+
columns?: number;
|
|
71
|
+
}
|
|
72
|
+
export declare const FieldTypeSchema: z.ZodEnum<{
|
|
73
|
+
number: "number";
|
|
74
|
+
boolean: "boolean";
|
|
75
|
+
text: "text";
|
|
76
|
+
url: "url";
|
|
77
|
+
group: "group";
|
|
78
|
+
secret: "secret";
|
|
79
|
+
textarea: "textarea";
|
|
80
|
+
select: "select";
|
|
81
|
+
}>;
|
|
82
|
+
export declare const FieldValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
83
|
+
export declare const FieldOptionSchema: z.ZodObject<{
|
|
84
|
+
value: z.ZodString;
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
help: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export declare const FieldVisibleWhenSchema: z.ZodObject<{
|
|
89
|
+
key: z.ZodString;
|
|
90
|
+
equals: z.ZodOptional<z.ZodString>;
|
|
91
|
+
oneOf: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export declare const FieldWidgetSchema: z.ZodObject<{
|
|
94
|
+
kind: z.ZodString;
|
|
95
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export declare const FieldOptionsFromSchema: z.ZodType<FieldOptionsFrom>;
|
|
98
|
+
export declare const FieldSpecSchema: z.ZodType<FieldSpec>;
|
|
99
|
+
export declare function fieldVisible(field: FieldSpec, values: Record<string, unknown>): boolean;
|
|
100
|
+
export declare function defaultConfigValues(fields: FieldSpec[]): Record<string, FieldValue>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const FieldTypeSchema = z.enum([
|
|
3
|
+
'text',
|
|
4
|
+
'secret',
|
|
5
|
+
'textarea',
|
|
6
|
+
'url',
|
|
7
|
+
'select',
|
|
8
|
+
'number',
|
|
9
|
+
'boolean',
|
|
10
|
+
'group',
|
|
11
|
+
]);
|
|
12
|
+
export const FieldValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
13
|
+
export const FieldOptionSchema = z.object({
|
|
14
|
+
value: z.string(),
|
|
15
|
+
label: z.string(),
|
|
16
|
+
help: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const FieldVisibleWhenSchema = z.object({
|
|
19
|
+
key: z.string().min(1),
|
|
20
|
+
equals: z.string().optional(),
|
|
21
|
+
oneOf: z.array(z.string()).optional(),
|
|
22
|
+
});
|
|
23
|
+
export const FieldWidgetSchema = z.object({
|
|
24
|
+
kind: z.string().min(1),
|
|
25
|
+
params: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
|
26
|
+
});
|
|
27
|
+
export const FieldOptionsFromSchema = z.union([
|
|
28
|
+
z.object({
|
|
29
|
+
kind: z.literal('addonRoute'),
|
|
30
|
+
route: z.string().min(1),
|
|
31
|
+
dependsOn: z.array(z.string().min(1)).optional(),
|
|
32
|
+
listKey: z.string().min(1).optional(),
|
|
33
|
+
valueKey: z.string().min(1),
|
|
34
|
+
labelKey: z.string().min(1).optional(),
|
|
35
|
+
}),
|
|
36
|
+
z.object({ kind: z.literal('connections') }),
|
|
37
|
+
z.object({ kind: z.literal('agents') }),
|
|
38
|
+
]);
|
|
39
|
+
export const FieldSpecSchema = z.object({
|
|
40
|
+
key: z.string().min(1),
|
|
41
|
+
label: z.string().min(1),
|
|
42
|
+
type: FieldTypeSchema,
|
|
43
|
+
required: z.boolean(),
|
|
44
|
+
placeholder: z.string().optional(),
|
|
45
|
+
help: z.string().optional(),
|
|
46
|
+
default: FieldValueSchema.optional(),
|
|
47
|
+
options: z.array(FieldOptionSchema).optional(),
|
|
48
|
+
multi: z.boolean().optional(),
|
|
49
|
+
optionsFrom: FieldOptionsFromSchema.optional(),
|
|
50
|
+
pattern: z.object({ regex: z.string(), hint: z.string() }).optional(),
|
|
51
|
+
editable: z.boolean().optional(),
|
|
52
|
+
generated: z.boolean().optional(),
|
|
53
|
+
fields: z.lazy(() => z.array(FieldSpecSchema)).optional(),
|
|
54
|
+
visibleWhen: FieldVisibleWhenSchema.optional(),
|
|
55
|
+
widget: FieldWidgetSchema.optional(),
|
|
56
|
+
collapsible: z.boolean().optional(),
|
|
57
|
+
advanced: z.boolean().optional(),
|
|
58
|
+
columns: z.number().int().min(1).max(4).optional(),
|
|
59
|
+
});
|
|
60
|
+
export function fieldVisible(field, values) {
|
|
61
|
+
const condition = field.visibleWhen;
|
|
62
|
+
if (!condition) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const actual = values[condition.key];
|
|
66
|
+
if (actual === undefined || actual === null) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (condition.equals !== undefined) {
|
|
70
|
+
return String(actual) === condition.equals;
|
|
71
|
+
}
|
|
72
|
+
if (condition.oneOf) {
|
|
73
|
+
return condition.oneOf.includes(String(actual));
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
export function defaultConfigValues(fields) {
|
|
78
|
+
const values = {};
|
|
79
|
+
for (const field of fields) {
|
|
80
|
+
if (field.default !== undefined) {
|
|
81
|
+
values[field.key] = field.default;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return values;
|
|
85
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const HOOK_SCHEMA_VERSION = 1;
|
|
3
|
+
export interface HookDescriptor {
|
|
4
|
+
id: string;
|
|
5
|
+
on: {
|
|
6
|
+
event: string;
|
|
7
|
+
} | {
|
|
8
|
+
providerEvent: {
|
|
9
|
+
connection: string;
|
|
10
|
+
types?: string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const HookOnSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
15
|
+
event: z.ZodString;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
providerEvent: z.ZodObject<{
|
|
18
|
+
connection: z.ZodString;
|
|
19
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
}, z.core.$strip>]>;
|
|
22
|
+
export declare const HookDescriptorSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
on: z.ZodUnion<readonly [z.ZodObject<{
|
|
25
|
+
event: z.ZodString;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
providerEvent: z.ZodObject<{
|
|
28
|
+
connection: z.ZodString;
|
|
29
|
+
types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
}, z.core.$strip>]>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const hookFamily: {
|
|
34
|
+
family: string;
|
|
35
|
+
versions: number[];
|
|
36
|
+
schema: (v: number) => z.ZodType;
|
|
37
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const HOOK_SCHEMA_VERSION = 1;
|
|
3
|
+
export const HookOnSchema = z.union([
|
|
4
|
+
z.object({ event: z.string().min(1) }),
|
|
5
|
+
z.object({
|
|
6
|
+
providerEvent: z.object({
|
|
7
|
+
connection: z.string().min(1),
|
|
8
|
+
types: z.array(z.string().min(1)).optional(),
|
|
9
|
+
}),
|
|
10
|
+
}),
|
|
11
|
+
]);
|
|
12
|
+
export const HookDescriptorSchema = z.object({
|
|
13
|
+
id: z.string().min(1),
|
|
14
|
+
on: HookOnSchema,
|
|
15
|
+
});
|
|
16
|
+
export const hookFamily = {
|
|
17
|
+
family: 'hook',
|
|
18
|
+
versions: [HOOK_SCHEMA_VERSION],
|
|
19
|
+
schema: (v) => {
|
|
20
|
+
if (v !== HOOK_SCHEMA_VERSION) {
|
|
21
|
+
throw new Error(`hook descriptor schema version ${v} is not supported`);
|
|
22
|
+
}
|
|
23
|
+
return HookDescriptorSchema;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { L10n } from '../manifest/l10n.ts';
|
|
3
|
+
export declare const JOB_SCHEMA_VERSION = 1;
|
|
4
|
+
export interface JobDescriptor {
|
|
5
|
+
id: string;
|
|
6
|
+
title: L10n;
|
|
7
|
+
schedule: {
|
|
8
|
+
cron: string;
|
|
9
|
+
} | {
|
|
10
|
+
everySec: number;
|
|
11
|
+
};
|
|
12
|
+
timezone?: 'org' | 'utc';
|
|
13
|
+
timeoutSec?: number;
|
|
14
|
+
catchUp: 'none' | 'once';
|
|
15
|
+
defaultEnabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const JobScheduleSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
18
|
+
cron: z.ZodString;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
everySec: z.ZodNumber;
|
|
21
|
+
}, z.core.$strip>]>;
|
|
22
|
+
export declare const JobDescriptorSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
|
|
25
|
+
schedule: z.ZodUnion<readonly [z.ZodObject<{
|
|
26
|
+
cron: z.ZodString;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
everySec: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>]>;
|
|
30
|
+
timezone: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
org: "org";
|
|
32
|
+
utc: "utc";
|
|
33
|
+
}>>;
|
|
34
|
+
timeoutSec: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
catchUp: z.ZodEnum<{
|
|
36
|
+
none: "none";
|
|
37
|
+
once: "once";
|
|
38
|
+
}>;
|
|
39
|
+
defaultEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export declare const jobFamily: {
|
|
42
|
+
family: string;
|
|
43
|
+
versions: number[];
|
|
44
|
+
schema: (v: number) => z.ZodType;
|
|
45
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { L10nSchema } from "../manifest/l10n.js";
|
|
3
|
+
export const JOB_SCHEMA_VERSION = 1;
|
|
4
|
+
export const JobScheduleSchema = z.union([
|
|
5
|
+
z.object({ cron: z.string().min(1) }),
|
|
6
|
+
z.object({ everySec: z.number().int().positive() }),
|
|
7
|
+
]);
|
|
8
|
+
export const JobDescriptorSchema = z.object({
|
|
9
|
+
id: z.string().min(1),
|
|
10
|
+
title: L10nSchema,
|
|
11
|
+
schedule: JobScheduleSchema,
|
|
12
|
+
timezone: z.enum(['org', 'utc']).optional(),
|
|
13
|
+
timeoutSec: z.number().int().positive().optional(),
|
|
14
|
+
catchUp: z.enum(['none', 'once']),
|
|
15
|
+
defaultEnabled: z.boolean().optional(),
|
|
16
|
+
});
|
|
17
|
+
export const jobFamily = {
|
|
18
|
+
family: 'job',
|
|
19
|
+
versions: [JOB_SCHEMA_VERSION],
|
|
20
|
+
schema: (v) => {
|
|
21
|
+
if (v !== JOB_SCHEMA_VERSION) {
|
|
22
|
+
throw new Error(`job descriptor schema version ${v} is not supported`);
|
|
23
|
+
}
|
|
24
|
+
return JobDescriptorSchema;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SchemaValueIssue {
|
|
2
|
+
path: string;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validates a value against the §6.5 JSON Schema subset (`type`, `properties`,
|
|
7
|
+
* `required`, `items`, `enum`, `const`, numeric and string bounds,
|
|
8
|
+
* `additionalProperties`, limited `oneOf`/`anyOf`, local `$defs`/`$ref`).
|
|
9
|
+
* Same contract the host applies to route request bodies; the fake host uses it
|
|
10
|
+
* to validate tool `inputSchema`/`outputSchema`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function schemaValueIssues(value: unknown, schema: Record<string, unknown>): SchemaValueIssue[];
|