@agentproto/define-doctype 0.1.0-alpha.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 +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.mjs +64 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT License — Copyright (c) 2026 agentproto contributors
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentproto/define-doctype — meta-factory for AIP `defineX` constructors.
|
|
3
|
+
*
|
|
4
|
+
* Every AIP that defines a markdown-with-frontmatter doctype ships a
|
|
5
|
+
* `defineX(definition)` constructor (`defineTool` for AIP-14, `defineDriver`
|
|
6
|
+
* for AIP-30, future `defineSkill` / `defineKnowledge` / …). Those
|
|
7
|
+
* constructors share a small invariant prologue: validate the `id`
|
|
8
|
+
* against a regex, validate `description` length, throw with a canonical
|
|
9
|
+
* error prefix, freeze the returned handle.
|
|
10
|
+
*
|
|
11
|
+
* `createDoctype` lifts that prologue to one place. Each per-AIP
|
|
12
|
+
* package supplies the spec-specific bits via `validate(def)` and
|
|
13
|
+
* `build(def)`; the factory wires them together with the shared rules.
|
|
14
|
+
*
|
|
15
|
+
* Recommended scaffold for new AIPs (referenced from AIP-1).
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Default shape every AIP definition is assumed to satisfy when no
|
|
19
|
+
* custom `readIdentity` / `readDescription` extractors are passed.
|
|
20
|
+
*
|
|
21
|
+
* Most AIPs (AIP-14 TOOL, AIP-30 DRIVER, AIP-3 SKILL, …) carry
|
|
22
|
+
* `id` + `description`. AIPs that depart from this convention (e.g.
|
|
23
|
+
* AIP-7 POLICY uses `slug` + `name`, with `description` optional)
|
|
24
|
+
* supply their own extractors via `DoctypeOptions`.
|
|
25
|
+
*/
|
|
26
|
+
interface DoctypeDefinitionBase {
|
|
27
|
+
id: string;
|
|
28
|
+
description: string;
|
|
29
|
+
}
|
|
30
|
+
interface DoctypeOptions<TDef, THandle> {
|
|
31
|
+
/**
|
|
32
|
+
* AIP number — surfaces in error messages so a thrown stack frame
|
|
33
|
+
* inside a framework adapter still tells you which spec rejected
|
|
34
|
+
* the definition.
|
|
35
|
+
*/
|
|
36
|
+
aip: number;
|
|
37
|
+
/**
|
|
38
|
+
* Doctype name (lower-case singular). Used to build the error
|
|
39
|
+
* prefix: `name = "tool"` → "defineTool: …".
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* Extract the identity string (kebab-id, slug, …) to validate against
|
|
44
|
+
* `idPattern`. Default: `(def) => (def as { id: string }).id` —
|
|
45
|
+
* works for any AIP whose definition has an `id` field. AIPs whose
|
|
46
|
+
* identity field has a different name (e.g. AIP-7 POLICY's `slug`)
|
|
47
|
+
* supply their own reader.
|
|
48
|
+
*/
|
|
49
|
+
readIdentity?: (def: TDef) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Override the default identity pattern. Default:
|
|
52
|
+
* `/^[a-z0-9][a-z0-9._-]{1,79}$/` — kebab/snake/dot separated,
|
|
53
|
+
* 2-80 chars, leading alphanumeric. AIPs with stricter rules
|
|
54
|
+
* (AIP-7 POLICY uses `^[a-z0-9][a-z0-9-]*$`, no dots) override.
|
|
55
|
+
*/
|
|
56
|
+
idPattern?: RegExp;
|
|
57
|
+
/**
|
|
58
|
+
* Extract the LLM-facing prose used by the length check. Default:
|
|
59
|
+
* `(def) => (def as { description: string }).description`. Pass
|
|
60
|
+
* `false` to skip the length validation (e.g. AIPs where
|
|
61
|
+
* description is optional, or where the human-readable string lives
|
|
62
|
+
* in a different field).
|
|
63
|
+
*/
|
|
64
|
+
readDescription?: ((def: TDef) => string | undefined) | false;
|
|
65
|
+
/**
|
|
66
|
+
* Override the maximum prose length. Default 2000. AIPs whose
|
|
67
|
+
* doctypes carry longer normative text on the doctype itself can
|
|
68
|
+
* raise this; most should keep the default for prompt-injection
|
|
69
|
+
* resistance.
|
|
70
|
+
*/
|
|
71
|
+
maxDescriptionLen?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Spec-specific validations that run AFTER the default id and
|
|
74
|
+
* description checks. Throw on failure. Stays out of `build()` so
|
|
75
|
+
* the build path can assume a validated definition.
|
|
76
|
+
*/
|
|
77
|
+
validate?: (def: TDef) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Build the immutable handle from a validated definition. Apply
|
|
80
|
+
* defaults, freeze nested arrays/objects per the spec's freezing
|
|
81
|
+
* rules, return the handle. The factory takes care of the
|
|
82
|
+
* top-level `Object.freeze`.
|
|
83
|
+
*/
|
|
84
|
+
build: (def: TDef) => THandle;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Build a `defineX(definition)` constructor that enforces the
|
|
88
|
+
* cross-AIP invariants and delegates spec-specific behaviour to
|
|
89
|
+
* `validate` / `build`.
|
|
90
|
+
*
|
|
91
|
+
* Usage (from `@agentproto/tool/src/define-tool.ts`):
|
|
92
|
+
*
|
|
93
|
+
* export const defineTool = createDoctype<ToolDefinition, ToolHandle>({
|
|
94
|
+
* aip: 14,
|
|
95
|
+
* name: "tool",
|
|
96
|
+
* validate(def) { ...spec-14 checks... },
|
|
97
|
+
* build(def) { ...defaulting + nested freezing... },
|
|
98
|
+
* })
|
|
99
|
+
*/
|
|
100
|
+
declare function createDoctype<TDef, THandle>(opts: DoctypeOptions<TDef, THandle>): (def: TDef) => THandle;
|
|
101
|
+
declare const DOCTYPE_DEFAULT_ID_PATTERN: RegExp;
|
|
102
|
+
declare const DOCTYPE_MAX_DESCRIPTION_LEN = 2000;
|
|
103
|
+
/**
|
|
104
|
+
* Filter a value to its YAML-serialisable subset:
|
|
105
|
+
* - functions removed (e.g. driver `execute[id]: ExecuteFn`)
|
|
106
|
+
* - zod schemas removed (e.g. tool `inputSchema`, `outputSchema`,
|
|
107
|
+
* `contextSchema` — they live in TS, not in frontmatter)
|
|
108
|
+
* - `undefined` values dropped from objects (so the YAML output
|
|
109
|
+
* doesn't carry empty keys; `null` is preserved as a real value)
|
|
110
|
+
*
|
|
111
|
+
* Used by per-AIP `createX(params, opts)` to project a validated
|
|
112
|
+
* definition into a manifest-shaped object before writing to disk.
|
|
113
|
+
* Pure function; no I/O.
|
|
114
|
+
*/
|
|
115
|
+
declare function filterSerializable(value: unknown): unknown;
|
|
116
|
+
|
|
117
|
+
export { DOCTYPE_DEFAULT_ID_PATTERN, DOCTYPE_MAX_DESCRIPTION_LEN, type DoctypeDefinitionBase, type DoctypeOptions, createDoctype, filterSerializable };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentproto/define-doctype v0.1.0-alpha
|
|
3
|
+
* Meta-factory for AIP defineX(definition) constructors.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
var DEFAULT_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{1,79}$/;
|
|
8
|
+
var MAX_DESCRIPTION_LEN = 2e3;
|
|
9
|
+
function createDoctype(opts) {
|
|
10
|
+
const idPattern = opts.idPattern ?? DEFAULT_ID_PATTERN;
|
|
11
|
+
const readIdentity = opts.readIdentity ?? ((def) => def.id);
|
|
12
|
+
const readDescription = opts.readDescription === false ? null : opts.readDescription ?? ((def) => def.description);
|
|
13
|
+
const maxLen = opts.maxDescriptionLen ?? MAX_DESCRIPTION_LEN;
|
|
14
|
+
const prefix = `define${capitalize(opts.name)}`;
|
|
15
|
+
const aipTag = `(AIP-${opts.aip})`;
|
|
16
|
+
return function constructDoctype(def) {
|
|
17
|
+
const identity = readIdentity(def);
|
|
18
|
+
if (typeof identity !== "string" || !idPattern.test(identity)) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`${prefix} ${aipTag}: invalid id '${String(
|
|
21
|
+
identity
|
|
22
|
+
)}' \u2014 must match ${idPattern}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (readDescription) {
|
|
26
|
+
const description = readDescription(def);
|
|
27
|
+
if (typeof description !== "string" || description.length === 0 || description.length > maxLen) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`${prefix} ${aipTag}: id='${identity}' description must be 1\u2013${maxLen} chars`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
opts.validate?.(def);
|
|
34
|
+
return Object.freeze(opts.build(def));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function capitalize(s) {
|
|
38
|
+
return s.length === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1);
|
|
39
|
+
}
|
|
40
|
+
var DOCTYPE_DEFAULT_ID_PATTERN = DEFAULT_ID_PATTERN;
|
|
41
|
+
var DOCTYPE_MAX_DESCRIPTION_LEN = MAX_DESCRIPTION_LEN;
|
|
42
|
+
function filterSerializable(value) {
|
|
43
|
+
if (value === null || value === void 0) return value;
|
|
44
|
+
if (typeof value === "function") return void 0;
|
|
45
|
+
if (typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "_def") && "parse" in value && typeof value.parse === "function") {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map(filterSerializable).filter((v) => v !== void 0);
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === "object") {
|
|
52
|
+
const out = {};
|
|
53
|
+
for (const [k, v] of Object.entries(value)) {
|
|
54
|
+
const filtered = filterSerializable(v);
|
|
55
|
+
if (filtered !== void 0) out[k] = filtered;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { DOCTYPE_DEFAULT_ID_PATTERN, DOCTYPE_MAX_DESCRIPTION_LEN, createDoctype, filterSerializable };
|
|
63
|
+
//# sourceMappingURL=index.mjs.map
|
|
64
|
+
//# sourceMappingUR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M,MAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAgC,CAAA,EAAG;AACrE,MAAA,MAAM,QAAA,GAAW,mBAAmB,CAAC,CAAA;AACrC,MAAA,IAAI,QAAA,KAAa,MAAA,EAAW,GAAA,CAAI,CAAC,CAAA,GAAI,QAAA;AAAA,IACvC;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * @agentproto/define-doctype — meta-factory for AIP `defineX` constructors.\n *\n * Every AIP that defines a markdown-with-frontmatter doctype ships a\n * `defineX(definition)` constructor (`defineTool` for AIP-14, `defineDriver`\n * for AIP-30, future `defineSkill` / `defineKnowledge` / …). Those\n * constructors share a small invariant prologue: validate the `id`\n * against a regex, validate `description` length, throw with a canonical\n * error prefix, freeze the returned handle.\n *\n * `createDoctype` lifts that prologue to one place. Each per-AIP\n * package supplies the spec-specific bits via `validate(def)` and\n * `build(def)`; the factory wires them together with the shared rules.\n *\n * Recommended scaffold for new AIPs (referenced from AIP-1).\n */\n\n/**\n * Default shape every AIP definition is assumed to satisfy when no\n * custom `readIdentity` / `readDescription` extractors are passed.\n *\n * Most AIPs (AIP-14 TOOL, AIP-30 DRIVER, AIP-3 SKILL, …) carry\n * `id` + `description`. AIPs that depart from this convention (e.g.\n * AIP-7 POLICY uses `slug` + `name`, with `description` optional)\n * supply their own extractors via `DoctypeOptions`.\n */\nexport interface DoctypeDefinitionBase {\n id: string\n description: string\n}\n\nexport interface DoctypeOptions<TDef, THandle> {\n /**\n * AIP number — surfaces in error messages so a thrown stack frame\n * inside a framework adapter still tells you which spec rejected\n * the definition.\n */\n aip: number\n /**\n * Doctype name (lower-case singular). Used to build the error\n * prefix: `name = \"tool\"` → \"defineTool: …\".\n */\n name: string\n /**\n * Extract the identity string (kebab-id, slug, …) to validate against\n * `idPattern`. Default: `(def) => (def as { id: string }).id` —\n * works for any AIP whose definition has an `id` field. AIPs whose\n * identity field has a different name (e.g. AIP-7 POLICY's `slug`)\n * supply their own reader.\n */\n readIdentity?: (def: TDef) => string\n /**\n * Override the default identity pattern. Default:\n * `/^[a-z0-9][a-z0-9._-]{1,79}$/` — kebab/snake/dot separated,\n * 2-80 chars, leading alphanumeric. AIPs with stricter rules\n * (AIP-7 POLICY uses `^[a-z0-9][a-z0-9-]*$`, no dots) override.\n */\n idPattern?: RegExp\n /**\n * Extract the LLM-facing prose used by the length check. Default:\n * `(def) => (def as { description: string }).description`. Pass\n * `false` to skip the length validation (e.g. AIPs where\n * description is optional, or where the human-readable string lives\n * in a different field).\n */\n readDescription?: ((def: TDef) => string | undefined) | false\n /**\n * Override the maximum prose length. Default 2000. AIPs whose\n * doctypes carry longer normative text on the doctype itself can\n * raise this; most should keep the default for prompt-injection\n * resistance.\n */\n maxDescriptionLen?: number\n /**\n * Spec-specific validations that run AFTER the default id and\n * description checks. Throw on failure. Stays out of `build()` so\n * the build path can assume a validated definition.\n */\n validate?: (def: TDef) => void\n /**\n * Build the immutable handle from a validated definition. Apply\n * defaults, freeze nested arrays/objects per the spec's freezing\n * rules, return the handle. The factory takes care of the\n * top-level `Object.freeze`.\n */\n build: (def: TDef) => THandle\n}\n\nconst DEFAULT_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{1,79}$/\nconst MAX_DESCRIPTION_LEN = 2000\n\n/**\n * Build a `defineX(definition)` constructor that enforces the\n * cross-AIP invariants and delegates spec-specific behaviour to\n * `validate` / `build`.\n *\n * Usage (from `@agentproto/tool/src/define-tool.ts`):\n *\n * export const defineTool = createDoctype<ToolDefinition, ToolHandle>({\n * aip: 14,\n * name: \"tool\",\n * validate(def) { ...spec-14 checks... },\n * build(def) { ...defaulting + nested freezing... },\n * })\n */\nexport function createDoctype<TDef, THandle>(\n opts: DoctypeOptions<TDef, THandle>,\n): (def: TDef) => THandle {\n const idPattern = opts.idPattern ?? DEFAULT_ID_PATTERN\n const readIdentity =\n opts.readIdentity ?? ((def: TDef) => (def as { id: string }).id)\n const readDescription =\n opts.readDescription === false\n ? null\n : (opts.readDescription ??\n ((def: TDef) => (def as { description: string }).description))\n const maxLen = opts.maxDescriptionLen ?? MAX_DESCRIPTION_LEN\n const prefix = `define${capitalize(opts.name)}`\n const aipTag = `(AIP-${opts.aip})`\n\n return function constructDoctype(def: TDef): THandle {\n const identity = readIdentity(def)\n if (typeof identity !== \"string\" || !idPattern.test(identity)) {\n throw new Error(\n `${prefix} ${aipTag}: invalid id '${String(\n identity,\n )}' — must match ${idPattern}`,\n )\n }\n if (readDescription) {\n const description = readDescription(def)\n if (\n typeof description !== \"string\" ||\n description.length === 0 ||\n description.length > maxLen\n ) {\n throw new Error(\n `${prefix} ${aipTag}: id='${identity}' description must be 1–${maxLen} chars`,\n )\n }\n }\n opts.validate?.(def)\n return Object.freeze(opts.build(def)) as THandle\n }\n}\n\nfunction capitalize(s: string): string {\n return s.length === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nexport const DOCTYPE_DEFAULT_ID_PATTERN = DEFAULT_ID_PATTERN\nexport const DOCTYPE_MAX_DESCRIPTION_LEN = MAX_DESCRIPTION_LEN\n\n/**\n * Filter a value to its YAML-serialisable subset:\n * - functions removed (e.g. driver `execute[id]: ExecuteFn`)\n * - zod schemas removed (e.g. tool `inputSchema`, `outputSchema`,\n * `contextSchema` — they live in TS, not in frontmatter)\n * - `undefined` values dropped from objects (so the YAML output\n * doesn't carry empty keys; `null` is preserved as a real value)\n *\n * Used by per-AIP `createX(params, opts)` to project a validated\n * definition into a manifest-shaped object before writing to disk.\n * Pure function; no I/O.\n */\nexport function filterSerializable(value: unknown): unknown {\n if (value === null || value === undefined) return value\n if (typeof value === \"function\") return undefined\n if (\n typeof value === \"object\" &&\n value !== null &&\n Object.prototype.hasOwnProperty.call(value, \"_def\") &&\n \"parse\" in value &&\n typeof (value as { parse?: unknown }).parse === \"function\"\n ) {\n return undefined\n }\n if (Array.isArray(value)) {\n return value.map(filterSerializable).filter((v) => v !== undefined)\n }\n if (typeof value === \"object\") {\n const out: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const filtered = filterSerializable(v)\n if (filtered !== undefined) out[k] = filtered\n }\n return out\n }\n return value\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentproto/define-doctype",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "agentproto/define-doctype — meta-factory for AIP `defineX(definition)` constructors. Centralises the cross-spec invariants every define-* shares (id shape, description length, top-level freeze, error-message prefix); leaves spec-specific defaulting + nested freezing to per-AIP `build()`. Used by @agentproto/tool, @agentproto/driver, and any future AIP doctype implementation.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-1",
|
|
8
|
+
"doctype",
|
|
9
|
+
"defineX",
|
|
10
|
+
"scaffold",
|
|
11
|
+
"open-standard",
|
|
12
|
+
"agentic"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://agentproto.sh/docs/aip-1",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/agentproto/ts"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/agentproto/ts/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/index.mjs",
|
|
25
|
+
"module": "dist/index.mjs",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.1.0",
|
|
45
|
+
"tsup": "^8.5.1",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "^3.2.4",
|
|
48
|
+
"@agentproto/tooling": "0.1.0-alpha.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"dev": "tsup --watch",
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"clean": "rm -rf dist",
|
|
54
|
+
"check-types": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest"
|
|
57
|
+
}
|
|
58
|
+
}
|