@agentproto/intent 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agentproto contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @agentproto/intent
2
+
3
+ AIP-28 `INTENT.md` reference implementation. A markdown + frontmatter format for declaring a user-facing agent intent — the verb a user surfaces ("create image", "list PRs"). Sits between SKILL (multi-step expertise) and TOOL (atomic technical call), carrying the catalog/UX layer (label, intent, surfaces, examples) and routing one or more underlying tools, with the standard `defineIntent` entry-point signature.
4
+
5
+ > **Status: 0.1.0-alpha.** Generated by `scripts/scaffold-aip.mjs` — `build()` and `validate()` bodies are TODOs.
6
+
7
+ Spec: <https://agentproto.sh/docs/aip-28>
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { defineIntent } from "@agentproto/intent"
13
+
14
+ const x = defineIntent({
15
+ id: "my-intent",
16
+ description: "Short purpose.",
17
+ // ...
18
+ })
19
+ ```
20
+
21
+ ## License
22
+
23
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ import { createDoctype } from '@agentproto/define-doctype';
3
+
4
+ /**
5
+ * @agentproto/intent v0.1.0-alpha
6
+ * AIP-28 INTENT.md `defineIntent` reference implementation.
7
+ */
8
+
9
+ var intentFrontmatterSchema = z.object({ "name": z.any().describe("Internal display name."), "id": z.string().regex(new RegExp("^[a-z0-9][a-z0-9.\\-]{1,79}$")), "label": z.any().describe("User-facing button/menu label."), "description": z.any().describe("User-facing copy (\u2264500 chars per locale)."), "version": z.string().regex(new RegExp("^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.\\-]+)?$")), "intent": z.any().superRefine((x, ctx) => {
10
+ const schemas = [z.array(z.string()).min(1), z.record(z.string(), z.array(z.string()).min(1))];
11
+ const { errors, failed } = schemas.reduce(
12
+ ({ errors: errors2, failed: failed2 }, schema) => ((result) => result.error ? {
13
+ errors: [...errors2, ...result.error.issues],
14
+ failed: failed2 + 1
15
+ } : { errors: errors2, failed: failed2 })(
16
+ schema.safeParse(x)
17
+ ),
18
+ { errors: [], failed: 0 }
19
+ );
20
+ const passed = schemas.length - failed;
21
+ if (passed !== 1) {
22
+ ctx.addIssue(errors.length ? {
23
+ path: [],
24
+ code: "invalid_union",
25
+ errors: [errors],
26
+ message: "Invalid input: Should pass single schema. Passed " + passed
27
+ } : {
28
+ path: [],
29
+ code: "custom",
30
+ errors: [errors],
31
+ message: "Invalid input: Should pass single schema. Passed " + passed
32
+ });
33
+ }
34
+ }).describe("Natural-language seeds an LLM matches against."), "surfaces": z.array(z.enum(["chat", "menu", "voice", "shortcut", "api"])).min(0).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: "All items must be unique!" }), "inputs": z.array(z.any()).optional(), "outputs": z.any().optional(), "entry": z.string().describe("Workspace-relative path to a routing implementation.").optional(), "implements": z.array(z.any()).min(1), "cost_class": z.enum(["trivial", "metered", "expensive"]).optional(), "quota_key": z.string().regex(new RegExp("^[a-z0-9][a-z0-9.\\-]{1,127}$")).optional(), "requires": z.any().optional(), "auth": z.string().describe("Workspace-relative path to a SECRETS.md (AIP-19).").optional(), "experiments": z.array(z.any()).optional(), "scope": z.enum(["app", "tier", "user", "guild", "workspace", "operator"]).optional().describe("Publication tier. Aligns with Model Access Rules v2 scope chain. Default `app`. `platform` is reserved for host-runtime defaults and MUST NOT appear in authored manifests."), "disable": z.string().regex(new RegExp("^[a-z0-9][a-z0-9.\\-]{1,79}$")).optional().describe("Intent id of a less-specific-tier intent that this manifest hides."), "preview": z.string().optional(), "tags": z.array(z.string().regex(new RegExp("^[a-z0-9][a-z0-9\\-]{0,63}$"))).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: "All items must be unique!" }).optional(), "examples": z.array(z.object({ "user": z.any(), "note": z.any().optional() }).strict()).optional(), "metadata": z.record(z.string(), z.any()).optional() }).strict().describe("JSON Schema for the YAML frontmatter of an AIP-28 INTENT.md manifest.");
35
+ var defineIntent = createDoctype({
36
+ aip: 28,
37
+ name: "intent",
38
+ validate(def) {
39
+ const result = intentFrontmatterSchema.safeParse(def);
40
+ if (!result.success) {
41
+ throw new Error(
42
+ `defineIntent (AIP-28): ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
43
+ );
44
+ }
45
+ },
46
+ build(def) {
47
+ return { ...def };
48
+ }
49
+ });
50
+
51
+ export { defineIntent, intentFrontmatterSchema };
52
+ //# sourceMappingURL=chunk-YXCUWIWF.mjs.map
53
+ //# sourceMappingURL=chunk-YXCUWIWF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/define-intent.ts"],"names":["errors","failed"],"mappings":";;;;;;;;AAeO,IAAM,uBAAA,GA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,MAAA,EAAQ,CAAA,CAAE,GAAA,EAAI,EAAG,MAAA,EAAQ,CAAA,CAAE,KAAI,CAAE,QAAA,EAAS,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAA,CAAE,QAAA,EAAS,EAAG,UAAA,EAAY,CAAA,CAAE,MAAA,CAAO,CAAA,CAAE,QAAO,EAAG,CAAA,CAAE,GAAA,EAAK,CAAA,CAAE,QAAA,EAAS,EAAG,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,CAAS,uEAAuE;AC9B3oD,IAAM,eAAe,aAAA,CAA8C;AAAA,EACxE,GAAA,EAAK,EAAA;AAAA,EACL,IAAA,EAAM,QAAA;AAAA,EACN,SAAS,GAAA,EAAK;AACZ,IAAA,MAAM,MAAA,GAAS,uBAAA,CAAwB,SAAA,CAAU,GAAG,CAAA;AACpD,IAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,uBAAA,EAA0B,OAAO,KAAA,CAAM,MAAA,CACpC,IAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAA,CAAK,KAAK,GAAG,CAAC,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA,CAC9C,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,OACf;AAAA,IACF;AAAA,EAIF,CAAA;AAAA,EACA,MAAM,GAAA,EAAK;AAKT,IAAA,OAAO,EAAE,GAAG,GAAA,EAAI;AAAA,EAClB;AACF,CAAC","file":"chunk-YXCUWIWF.mjs","sourcesContent":["/**\n * AIP-28 INTENT.md frontmatter zod schema.\n *\n * Generated from `resources/aip-28/draft/INTENT.schema.json` via\n * json-schema-to-zod. Imported by both `define-intent.ts` (TS path\n * validation) and `manifest/index.ts` (.md path validation) so every\n * field-level constraint runs in both authoring paths from a single\n * source of truth — re-run scaffold-aip to refresh after spec changes.\n *\n * Cross-field rules (if/then/allOf in JSON Schema) don't translate\n * cleanly and live in `define-intent.ts`'s `validate(def)` instead.\n */\n\nimport { z } from \"zod\"\n\nexport const intentFrontmatterSchema = z.object({ \"name\": z.any().describe(\"Internal display name.\"), \"id\": z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9.\\\\-]{1,79}$\")), \"label\": z.any().describe(\"User-facing button/menu label.\"), \"description\": z.any().describe(\"User-facing copy (≤500 chars per locale).\"), \"version\": z.string().regex(new RegExp(\"^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:[-+][\\\\w.\\\\-]+)?$\")), \"intent\": z.any().superRefine((x, ctx) => {\n const schemas = [z.array(z.string()).min(1), z.record(z.string(), z.array(z.string()).min(1))];\n const { errors, failed } = schemas.reduce<{\n errors: z.core.$ZodIssue[];\n failed: number;\n }>(\n ({ errors, failed }, schema) =>\n ((result) =>\n result.error\n ? {\n errors: [...errors, ...result.error.issues],\n failed: failed + 1,\n }\n : { errors, failed })(\n schema.safeParse(x),\n ),\n { errors: [], failed: 0 },\n );\n const passed = schemas.length - failed;\n if (passed !== 1) {\n ctx.addIssue(errors.length ? {\n path: [],\n code: \"invalid_union\",\n errors: [errors],\n message: \"Invalid input: Should pass single schema. Passed \" + passed,\n } : {\n path: [],\n code: \"custom\",\n errors: [errors],\n message: \"Invalid input: Should pass single schema. Passed \" + passed,\n });\n }\n }).describe(\"Natural-language seeds an LLM matches against.\"), \"surfaces\": z.array(z.enum([\"chat\",\"menu\",\"voice\",\"shortcut\",\"api\"])).min(0).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: \"All items must be unique!\" }), \"inputs\": z.array(z.any()).optional(), \"outputs\": z.any().optional(), \"entry\": z.string().describe(\"Workspace-relative path to a routing implementation.\").optional(), \"implements\": z.array(z.any()).min(1), \"cost_class\": z.enum([\"trivial\",\"metered\",\"expensive\"]).optional(), \"quota_key\": z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9.\\\\-]{1,127}$\")).optional(), \"requires\": z.any().optional(), \"auth\": z.string().describe(\"Workspace-relative path to a SECRETS.md (AIP-19).\").optional(), \"experiments\": z.array(z.any()).optional(), \"scope\": z.enum([\"app\",\"tier\",\"user\",\"guild\",\"workspace\",\"operator\"]).optional().describe(\"Publication tier. Aligns with Model Access Rules v2 scope chain. Default `app`. `platform` is reserved for host-runtime defaults and MUST NOT appear in authored manifests.\"), \"disable\": z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9.\\\\-]{1,79}$\")).optional().describe(\"Intent id of a less-specific-tier intent that this manifest hides.\"), \"preview\": z.string().optional(), \"tags\": z.array(z.string().regex(new RegExp(\"^[a-z0-9][a-z0-9\\\\-]{0,63}$\"))).refine((arr) => arr.every((item, i) => arr.indexOf(item) == i), { message: \"All items must be unique!\" }).optional(), \"examples\": z.array(z.object({ \"user\": z.any(), \"note\": z.any().optional() }).strict()).optional(), \"metadata\": z.record(z.string(), z.any()).optional() }).strict().describe(\"JSON Schema for the YAML frontmatter of an AIP-28 INTENT.md manifest.\")\n\nexport type IntentFrontmatter = z.infer<typeof intentFrontmatterSchema>\n","import { createDoctype } from \"@agentproto/define-doctype\"\nimport { intentFrontmatterSchema } from \"./schema.js\"\nimport type { IntentDefinition, IntentHandle } from \"./types.js\"\n\n/**\n * AIP-28 reference implementation of `defineIntent`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * description length, top-level freeze, \"defineIntent (AIP-28): …\"\n * error prefix) run uniformly with every other AIP defineX.\n *\n * Field-level validation runs the schema-derived zod from\n * `./schema.ts` against the input. Same source of truth as the .md\n * path uses (`parseIntentManifest`), so a malformed TS-authored\n * definition fails with the same diagnostic as a malformed manifest.\n * Cross-field rules go in `validate(def)` after the zod check.\n */\nexport const defineIntent = createDoctype<IntentDefinition, IntentHandle>({\n aip: 28,\n name: \"intent\",\n validate(def) {\n const result = intentFrontmatterSchema.safeParse(def)\n if (!result.success) {\n throw new Error(\n `defineIntent (AIP-28): ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n // TODO: spec-28-specific cross-field rules (if/then/allOf in\n // the JSON Schema) — those don't translate to zod cleanly and\n // belong here. See @agentproto/operator's autonomy=gated rule.\n },\n build(def) {\n // Default build: spread the validated definition into a fresh object.\n // Hand-tune for nested freezing (Object.freeze on arrays/objects) and\n // for fields that need defaults applied — see @agentproto/operator\n // for a reference shape.\n return { ...def } as IntentHandle\n },\n})\n"]}
@@ -0,0 +1,33 @@
1
+ import { I as IntentDefinition } from './types-BkoMZLbu.js';
2
+ export { a as IntentHandle } from './types-BkoMZLbu.js';
3
+
4
+ /**
5
+ * AIP-28 reference implementation of `defineIntent`.
6
+ *
7
+ * Built on `createDoctype` so the cross-AIP invariants (id pattern,
8
+ * description length, top-level freeze, "defineIntent (AIP-28): …"
9
+ * error prefix) run uniformly with every other AIP defineX.
10
+ *
11
+ * Field-level validation runs the schema-derived zod from
12
+ * `./schema.ts` against the input. Same source of truth as the .md
13
+ * path uses (`parseIntentManifest`), so a malformed TS-authored
14
+ * definition fails with the same diagnostic as a malformed manifest.
15
+ * Cross-field rules go in `validate(def)` after the zod check.
16
+ */
17
+ declare const defineIntent: (def: IntentDefinition) => Readonly<IntentDefinition>;
18
+
19
+ /**
20
+ * @agentproto/intent — AIP-28 INTENT.md `defineIntent` reference impl.
21
+ *
22
+ * A markdown + frontmatter format for declaring a user-facing agent intent — the verb a user surfaces ("create image", "list PRs"). Sits between SKILL (multi-step expertise) and TOOL (atomic technical call), carrying the catalog/UX layer (label, intent, surfaces, examples) and routing one or more underlying tools, with the standard `defineIntent` entry-point signature.
23
+ *
24
+ * Spec: https://agentproto.sh/docs/aip-28
25
+ *
26
+ * Authoring paths:
27
+ * - TS: `defineIntent({...})` → `IntentHandle`
28
+ * - MD: `parseIntentManifest(src) → intentFromManifest({...})` → `IntentHandle`
29
+ */
30
+ declare const SPEC_NAME: "agentintent/v1";
31
+ declare const SPEC_VERSION: "1.0.0-alpha";
32
+
33
+ export { IntentDefinition, SPEC_NAME, SPEC_VERSION, defineIntent };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ export { defineIntent } from './chunk-YXCUWIWF.mjs';
2
+
3
+ /**
4
+ * @agentproto/intent v0.1.0-alpha
5
+ * AIP-28 INTENT.md `defineIntent` reference implementation.
6
+ */
7
+
8
+ // src/index.ts
9
+ var SPEC_NAME = "agentintent/v1";
10
+ var SPEC_VERSION = "1.0.0-alpha";
11
+
12
+ export { SPEC_NAME, SPEC_VERSION };
13
+ //# sourceMappingURL=index.mjs.map
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;AAYO,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * @agentproto/intent — AIP-28 INTENT.md `defineIntent` reference impl.\n *\n * A markdown + frontmatter format for declaring a user-facing agent intent — the verb a user surfaces (\"create image\", \"list PRs\"). Sits between SKILL (multi-step expertise) and TOOL (atomic technical call), carrying the catalog/UX layer (label, intent, surfaces, examples) and routing one or more underlying tools, with the standard `defineIntent` entry-point signature.\n *\n * Spec: https://agentproto.sh/docs/aip-28\n *\n * Authoring paths:\n * - TS: `defineIntent({...})` → `IntentHandle`\n * - MD: `parseIntentManifest(src) → intentFromManifest({...})` → `IntentHandle`\n */\n\nexport const SPEC_NAME = \"agentintent/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineIntent } from \"./define-intent.js\"\nexport type { IntentDefinition, IntentHandle } from \"./types.js\"\n"]}
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ import { a as IntentHandle } from '../types-BkoMZLbu.js';
3
+
4
+ /**
5
+ * AIP-28 INTENT.md frontmatter zod schema.
6
+ *
7
+ * Generated from `resources/aip-28/draft/INTENT.schema.json` via
8
+ * json-schema-to-zod. Imported by both `define-intent.ts` (TS path
9
+ * validation) and `manifest/index.ts` (.md path validation) so every
10
+ * field-level constraint runs in both authoring paths from a single
11
+ * source of truth — re-run scaffold-aip to refresh after spec changes.
12
+ *
13
+ * Cross-field rules (if/then/allOf in JSON Schema) don't translate
14
+ * cleanly and live in `define-intent.ts`'s `validate(def)` instead.
15
+ */
16
+
17
+ declare const intentFrontmatterSchema: z.ZodObject<{
18
+ name: z.ZodAny;
19
+ id: z.ZodString;
20
+ label: z.ZodAny;
21
+ description: z.ZodAny;
22
+ version: z.ZodString;
23
+ intent: z.ZodAny;
24
+ surfaces: z.ZodArray<z.ZodEnum<{
25
+ chat: "chat";
26
+ menu: "menu";
27
+ voice: "voice";
28
+ shortcut: "shortcut";
29
+ api: "api";
30
+ }>>;
31
+ inputs: z.ZodOptional<z.ZodArray<z.ZodAny>>;
32
+ outputs: z.ZodOptional<z.ZodAny>;
33
+ entry: z.ZodOptional<z.ZodString>;
34
+ implements: z.ZodArray<z.ZodAny>;
35
+ cost_class: z.ZodOptional<z.ZodEnum<{
36
+ trivial: "trivial";
37
+ metered: "metered";
38
+ expensive: "expensive";
39
+ }>>;
40
+ quota_key: z.ZodOptional<z.ZodString>;
41
+ requires: z.ZodOptional<z.ZodAny>;
42
+ auth: z.ZodOptional<z.ZodString>;
43
+ experiments: z.ZodOptional<z.ZodArray<z.ZodAny>>;
44
+ scope: z.ZodOptional<z.ZodEnum<{
45
+ app: "app";
46
+ tier: "tier";
47
+ user: "user";
48
+ guild: "guild";
49
+ workspace: "workspace";
50
+ operator: "operator";
51
+ }>>;
52
+ disable: z.ZodOptional<z.ZodString>;
53
+ preview: z.ZodOptional<z.ZodString>;
54
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
55
+ examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ user: z.ZodAny;
57
+ note: z.ZodOptional<z.ZodAny>;
58
+ }, z.core.$strict>>>;
59
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
60
+ }, z.core.$strict>;
61
+ type IntentFrontmatter = z.infer<typeof intentFrontmatterSchema>;
62
+
63
+ /**
64
+ * AIP-28 INTENT.md sidecar parser + manifest-to-handle constructor.
65
+ *
66
+ * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:
67
+ * the .md provides metadata; the TS module supplies any spec-specific
68
+ * runtime bits (schemas, execute bodies, …) that can't live in
69
+ * frontmatter. Both inputs end up in `defineIntent` so the cross-AIP
70
+ * invariants run uniformly.
71
+ *
72
+ *
73
+ * The frontmatter zod schema below was generated from
74
+ * `resources/aip-28/draft/INTENT.schema.json` via json-schema-to-zod.
75
+ * Re-run scaffold-aip to refresh after spec changes (or hand-tune
76
+ * any constraint the converter doesn't capture cleanly).
77
+ */
78
+
79
+ interface IntentManifest {
80
+ frontmatter: IntentFrontmatter;
81
+ body: string;
82
+ }
83
+ declare function parseIntentManifest(source: string): IntentManifest;
84
+ declare function intentFromManifest(manifest: IntentManifest): IntentHandle;
85
+
86
+ export { type IntentFrontmatter, type IntentManifest, intentFromManifest, intentFrontmatterSchema, parseIntentManifest };
@@ -0,0 +1,28 @@
1
+ import { intentFrontmatterSchema, defineIntent } from '../chunk-YXCUWIWF.mjs';
2
+ export { intentFrontmatterSchema } from '../chunk-YXCUWIWF.mjs';
3
+ import matter from 'gray-matter';
4
+
5
+ /**
6
+ * @agentproto/intent v0.1.0-alpha
7
+ * AIP-28 INTENT.md `defineIntent` reference implementation.
8
+ */
9
+ function parseIntentManifest(source) {
10
+ const parsed = matter(source);
11
+ if (Object.keys(parsed.data).length === 0) {
12
+ throw new Error("parseIntentManifest: missing or empty frontmatter");
13
+ }
14
+ const result = intentFrontmatterSchema.safeParse(parsed.data);
15
+ if (!result.success) {
16
+ throw new Error(
17
+ `parseIntentManifest: invalid frontmatter \u2014 ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
18
+ );
19
+ }
20
+ return { frontmatter: result.data, body: parsed.content };
21
+ }
22
+ function intentFromManifest(manifest) {
23
+ return defineIntent(manifest.frontmatter);
24
+ }
25
+
26
+ export { intentFromManifest, parseIntentManifest };
27
+ //# sourceMappingURL=index.mjs.map
28
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/manifest/index.ts"],"names":[],"mappings":";;;;;;;;AA8BO,SAAS,oBAAoB,MAAA,EAAgC;AAClE,EAAA,MAAM,MAAA,GAAS,OAAO,MAAM,CAAA;AAC5B,EAAA,IAAI,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,CAAA,CAAE,WAAW,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,MAAM,mDAAmD,CAAA;AAAA,EACrE;AACA,EAAA,MAAM,MAAA,GAAS,uBAAA,CAAwB,SAAA,CAAU,MAAA,CAAO,IAAI,CAAA;AAC5D,EAAA,IAAI,CAAC,OAAO,OAAA,EAAS;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,gDAAA,EAA8C,OAAO,KAAA,CAAM,MAAA,CACxD,IAAI,CAAC,CAAA,KAAM,GAAG,CAAA,CAAE,IAAA,CAAK,KAAK,GAAG,CAAC,KAAK,CAAA,CAAE,OAAO,EAAE,CAAA,CAC9C,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,OAAO,EAAE,WAAA,EAAa,MAAA,CAAO,IAAA,EAAM,IAAA,EAAM,OAAO,OAAA,EAAQ;AAC1D;AAEO,SAAS,mBAAmB,QAAA,EAAwC;AAKzE,EAAA,OAAO,YAAA,CAAa,SAAS,WAA0C,CAAA;AACzE","file":"index.mjs","sourcesContent":["/**\n * AIP-28 INTENT.md sidecar parser + manifest-to-handle constructor.\n *\n * Mirror of `@agentproto/tool/manifest` and `@agentproto/driver/manifest`:\n * the .md provides metadata; the TS module supplies any spec-specific\n * runtime bits (schemas, execute bodies, …) that can't live in\n * frontmatter. Both inputs end up in `defineIntent` so the cross-AIP\n * invariants run uniformly.\n *\n *\n * The frontmatter zod schema below was generated from\n * `resources/aip-28/draft/INTENT.schema.json` via json-schema-to-zod.\n * Re-run scaffold-aip to refresh after spec changes (or hand-tune\n * any constraint the converter doesn't capture cleanly).\n */\n\nimport matter from \"gray-matter\"\nimport { intentFrontmatterSchema, type IntentFrontmatter } from \"../schema.js\"\nimport { defineIntent } from \"../define-intent.js\"\nimport type { IntentDefinition, IntentHandle } from \"../types.js\"\n\n// Re-export so consumers can import the schema + inferred type either\n// from \"@@agentproto/intent/manifest\" or directly from \"@@agentproto/intent/schema\".\nexport { intentFrontmatterSchema, type IntentFrontmatter }\n\nexport interface IntentManifest {\n frontmatter: IntentFrontmatter\n body: string\n}\n\nexport function parseIntentManifest(source: string): IntentManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseIntentManifest: missing or empty frontmatter\")\n }\n const result = intentFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseIntentManifest: invalid frontmatter — ${result.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\"; \")}`,\n )\n }\n return { frontmatter: result.data, body: parsed.content }\n}\n\nexport function intentFromManifest(manifest: IntentManifest): IntentHandle {\n // The zod-validated frontmatter is structurally compatible with\n // IntentDefinition; the cast pins the typing once the manifest\n // schema and the TS interface diverge (e.g. handle has frozen fields\n // a literal config doesn't carry yet).\n return defineIntent(manifest.frontmatter as unknown as IntentDefinition)\n}\n"]}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * AIP-28 IntentDefinition + IntentHandle.
3
+ *
4
+ * `IntentDefinition` was generated from
5
+ * `resources/aip-28/draft/INTENT.schema.json` via json-schema-to-typescript.
6
+ * `IntentHandle` is the readonly view of the same shape; tighten it
7
+ * by hand for fields that get defaults applied in build().
8
+ */
9
+ /**
10
+ * Either a plain string (treated as locale `en`) or a per-locale map keyed by BCP-47.
11
+ */
12
+ type I18NString = string | {
13
+ [k: string]: string;
14
+ };
15
+ type ImplementsEntry = {
16
+ tool?: string;
17
+ workflow?: string;
18
+ entry?: string;
19
+ default?: boolean;
20
+ when?: {
21
+ [k: string]: PredicateValue;
22
+ };
23
+ mapping?: {
24
+ [k: string]: MappingValue;
25
+ };
26
+ } & ImplementsEntry1 & {
27
+ tool?: string;
28
+ workflow?: string;
29
+ entry?: string;
30
+ default?: boolean;
31
+ when?: {
32
+ [k: string]: PredicateValue;
33
+ };
34
+ mapping?: {
35
+ [k: string]: MappingValue;
36
+ };
37
+ } & ImplementsEntry1 & {
38
+ tool?: string;
39
+ workflow?: string;
40
+ entry?: string;
41
+ default?: boolean;
42
+ when?: {
43
+ [k: string]: PredicateValue;
44
+ };
45
+ mapping?: {
46
+ [k: string]: MappingValue;
47
+ };
48
+ } & ImplementsEntry1 & {
49
+ tool?: string;
50
+ workflow?: string;
51
+ entry?: string;
52
+ default?: boolean;
53
+ when?: {
54
+ [k: string]: PredicateValue;
55
+ };
56
+ mapping?: {
57
+ [k: string]: MappingValue;
58
+ };
59
+ } & ImplementsEntry1;
60
+ /**
61
+ * Value shape for `when` and `depends_on`. Literal value, or comparison object.
62
+ */
63
+ type PredicateValue = unknown | {
64
+ not?: unknown;
65
+ in?: unknown[];
66
+ not_in?: unknown[];
67
+ not_empty?: boolean;
68
+ gt?: number;
69
+ lt?: number;
70
+ gte?: number;
71
+ lte?: number;
72
+ };
73
+ type MappingValue = string | {
74
+ from: string;
75
+ /**
76
+ * Named transformer exported by the entry.
77
+ */
78
+ transform?: string;
79
+ };
80
+ type ImplementsEntry1 = {
81
+ [k: string]: unknown;
82
+ } | {
83
+ [k: string]: unknown;
84
+ } | {
85
+ [k: string]: unknown;
86
+ };
87
+ /**
88
+ * JSON Schema for the YAML frontmatter of an AIP-28 INTENT.md manifest.
89
+ */
90
+ interface IntentDefinition {
91
+ /**
92
+ * Internal display name.
93
+ */
94
+ name: string | {
95
+ [k: string]: string;
96
+ };
97
+ id: string;
98
+ /**
99
+ * User-facing button/menu label.
100
+ */
101
+ label: string | {
102
+ [k: string]: string;
103
+ };
104
+ /**
105
+ * User-facing copy (≤500 chars per locale).
106
+ */
107
+ description: string | {
108
+ [k: string]: string;
109
+ };
110
+ version: string;
111
+ /**
112
+ * Natural-language seeds an LLM matches against.
113
+ */
114
+ intent: [string, ...string[]] | {
115
+ /**
116
+ * @minItems 1
117
+ */
118
+ [k: string]: [string, ...string[]];
119
+ };
120
+ /**
121
+ * @minItems 0
122
+ */
123
+ surfaces: ("chat" | "menu" | "voice" | "shortcut" | "api")[];
124
+ inputs?: InputField[];
125
+ outputs?: Outputs;
126
+ /**
127
+ * Workspace-relative path to a routing implementation.
128
+ */
129
+ entry?: string;
130
+ /**
131
+ * @minItems 1
132
+ */
133
+ implements: [ImplementsEntry, ...ImplementsEntry[]];
134
+ cost_class?: "trivial" | "metered" | "expensive";
135
+ quota_key?: string;
136
+ requires?: Capabilities;
137
+ /**
138
+ * Workspace-relative path to a SECRETS.md (AIP-19).
139
+ */
140
+ auth?: string;
141
+ experiments?: ExperimentArm[];
142
+ /**
143
+ * Publication tier. Aligns with Model Access Rules v2 scope chain.
144
+ * Default `app`. `platform` is reserved for host-runtime defaults
145
+ * and MUST NOT appear in authored manifests.
146
+ *
147
+ * See AIP-28 § Scope and publication for the seven tiers, the
148
+ * specificity ranks, and the authoring-permission gates per tier.
149
+ */
150
+ scope?: "app" | "tier" | "user" | "guild" | "workspace" | "operator";
151
+ /**
152
+ * Intent id of a less-specific-tier intent that this manifest hides.
153
+ * Used when a higher-tier scope wants to remove a lower-tier intent
154
+ * without re-implementing it.
155
+ */
156
+ disable?: string;
157
+ preview?: string;
158
+ tags?: string[];
159
+ examples?: {
160
+ user: I18NString;
161
+ note?: I18NString;
162
+ }[];
163
+ metadata?: {};
164
+ }
165
+ interface InputField {
166
+ name: string;
167
+ label: I18NString;
168
+ type: "text" | "textarea" | "number" | "toggle" | "choice" | "multi-choice" | "file" | "image" | "date" | "markdown" | "code" | "ref";
169
+ placeholder?: I18NString;
170
+ hint?: I18NString;
171
+ required?: boolean;
172
+ default?: unknown;
173
+ min?: number;
174
+ max?: number;
175
+ min_length?: number;
176
+ max_length?: number;
177
+ pattern?: string;
178
+ /**
179
+ * For choice / multi-choice. Either a list of strings or a list of {value,label} objects.
180
+ */
181
+ values?: string[] | {
182
+ value: unknown;
183
+ label: I18NString;
184
+ }[];
185
+ accept?: string[];
186
+ language?: string;
187
+ depends_on?: {
188
+ [k: string]: unknown;
189
+ };
190
+ }
191
+ interface Outputs {
192
+ type: "text" | "image" | "markdown" | "file" | "custom";
193
+ template?: string;
194
+ }
195
+ interface Capabilities {
196
+ network?: string[];
197
+ secrets?: string[];
198
+ tools?: string[];
199
+ }
200
+ interface ExperimentArm {
201
+ id: string;
202
+ weight: number;
203
+ when?: {
204
+ [k: string]: PredicateValue;
205
+ };
206
+ /**
207
+ * @minItems 1
208
+ */
209
+ implements: [ImplementsEntry, ...ImplementsEntry[]];
210
+ }
211
+ type IntentHandle = Readonly<IntentDefinition>;
212
+
213
+ export type { IntentDefinition as I, IntentHandle as a };
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@agentproto/intent",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "@agentproto/intent — AIP-28 INTENT.md reference implementation. A markdown + frontmatter format for declaring a user-facing agent intent — the verb a user surfaces (\"create image\", \"list PRs\"). Sits between SKILL (multi-step expertise) and TOOL (atomic technical call), carrying the catalog/UX layer (label, intent, surfaces, examples) and routing one or more underlying tools, with the standard `defineIntent` entry-point signature.",
5
+ "keywords": [
6
+ "agentproto",
7
+ "aip-28",
8
+ "intent",
9
+ "defineIntent",
10
+ "open-standard",
11
+ "agentic"
12
+ ],
13
+ "homepage": "https://agentproto.sh/docs/aip-28",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/agentproto/ts",
17
+ "directory": "packages/intent"
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
+ "./manifest": {
34
+ "types": "./dist/manifest/index.d.ts",
35
+ "import": "./dist/manifest/index.mjs",
36
+ "default": "./dist/manifest/index.mjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "dependencies": {
49
+ "gray-matter": "^4.0.3",
50
+ "zod": "^4.4.3",
51
+ "@agentproto/define-doctype": "0.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^25.6.2",
55
+ "tsup": "^8.5.1",
56
+ "typescript": "^5.9.3",
57
+ "vitest": "^3.2.4",
58
+ "@agentproto/tooling": "0.1.0-alpha.0"
59
+ },
60
+ "scripts": {
61
+ "dev": "tsup --watch",
62
+ "build": "tsup",
63
+ "clean": "rm -rf dist",
64
+ "check-types": "tsc --noEmit",
65
+ "test": "vitest run --passWithNoTests",
66
+ "test:watch": "vitest"
67
+ }
68
+ }