@agentproto/operator 0.1.0-alpha.1
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 +23 -0
- package/dist/chunk-HILBXS2I.mjs +158 -0
- package/dist/chunk-HILBXS2I.mjs.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manifest/index.d.ts +114 -0
- package/dist/manifest/index.mjs +113 -0
- package/dist/manifest/index.mjs.map +1 -0
- package/dist/types-BxJvLb8Z.d.ts +139 -0
- package/package.json +68 -0
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/operator
|
|
2
|
+
|
|
3
|
+
AIP-9 `OPERATOR.md` reference implementation. A single canonical operator shell — pluggable profile, skills, tools, memory, governance — that any agent runtime can implement and any conforming workflow can dispatch to.
|
|
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-9>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineOperator } from "@agentproto/operator"
|
|
13
|
+
|
|
14
|
+
const x = defineOperator({
|
|
15
|
+
id: "my-operator",
|
|
16
|
+
description: "Short purpose.",
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { createDoctype } from '@agentproto/define-doctype';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/operator v0.1.0-alpha
|
|
5
|
+
* AIP-9 OPERATOR.md `defineOperator` reference implementation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var OPERATOR_ID_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$/;
|
|
9
|
+
var VERSION_PATTERN = /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/;
|
|
10
|
+
var POLICY_REF_PATTERN = /^policy:[A-Za-z0-9_./-]+$/;
|
|
11
|
+
var AUDIT_REF_PATTERN = /^audit:[A-Za-z0-9_./-]+$/;
|
|
12
|
+
var SHARE_WITH_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$/;
|
|
13
|
+
var CAPABILITY_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
14
|
+
var TAG_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
15
|
+
var defineOperator = createDoctype(
|
|
16
|
+
{
|
|
17
|
+
aip: 9,
|
|
18
|
+
name: "operator",
|
|
19
|
+
idPattern: OPERATOR_ID_PATTERN,
|
|
20
|
+
// OPERATOR.md uses `persona_summary` for LLM-facing prose; no
|
|
21
|
+
// `description` field. Use it as the description-equivalent for
|
|
22
|
+
// length validation, capped at 280 per the schema.
|
|
23
|
+
readDescription: (def) => def.persona_summary,
|
|
24
|
+
maxDescriptionLen: 280,
|
|
25
|
+
validate(def) {
|
|
26
|
+
if (typeof def.name !== "string" || def.name.length === 0 || def.name.length > 80) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`defineOperator (AIP-9): id='${def.id}' name must be 1\u201380 chars`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (!VERSION_PATTERN.test(def.version ?? "")) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`defineOperator (AIP-9): id='${def.id}' version must match ${VERSION_PATTERN}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!def.profile) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`defineOperator (AIP-9): id='${def.id}' profile is required`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (typeof def.profile.role !== "string" || def.profile.role.length === 0 || def.profile.role.length > 1e3) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`defineOperator (AIP-9): id='${def.id}' profile.role must be 1\u20131000 chars`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (typeof def.profile.voice !== "string" || def.profile.voice.length === 0 || def.profile.voice.length > 1e3) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`defineOperator (AIP-9): id='${def.id}' profile.voice must be 1\u20131000 chars`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(def.profile.boundaries)) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`defineOperator (AIP-9): id='${def.id}' profile.boundaries must be an array`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (def.memory?.kind === "external" && !def.memory.external?.uri) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`defineOperator (AIP-9): id='${def.id}' memory.kind='external' requires memory.external.uri`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (def.governance) {
|
|
62
|
+
if (!AUDIT_REF_PATTERN.test(def.governance.audit_log ?? "")) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`defineOperator (AIP-9): id='${def.id}' governance.audit_log must match ${AUDIT_REF_PATTERN}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
for (const p of def.governance.policies ?? []) {
|
|
68
|
+
if (!POLICY_REF_PATTERN.test(p)) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`defineOperator (AIP-9): id='${def.id}' governance.policies entry '${p}' must match ${POLICY_REF_PATTERN}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const peer of def.memory?.share_with ?? []) {
|
|
76
|
+
if (!SHARE_WITH_PATTERN.test(peer)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`defineOperator (AIP-9): id='${def.id}' memory.share_with entry '${peer}' must match ${SHARE_WITH_PATTERN}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const c of def.capabilities ?? []) {
|
|
83
|
+
if (!CAPABILITY_PATTERN.test(c)) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`defineOperator (AIP-9): id='${def.id}' capabilities entry '${c}' must match ${CAPABILITY_PATTERN}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const t of def.tags ?? []) {
|
|
90
|
+
if (!TAG_PATTERN.test(t)) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`defineOperator (AIP-9): id='${def.id}' tags entry '${t}' must match ${TAG_PATTERN}`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (def.governance?.autonomy === "gated") {
|
|
97
|
+
const mode = def.participation?.mode ?? "mention-only";
|
|
98
|
+
if (mode !== "mention-only" && mode !== "silent") {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`defineOperator (AIP-9): id='${def.id}' governance.autonomy='gated' forbids participation.mode='${mode}' \u2014 must be 'mention-only' or 'silent'`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (def.runtime?.kind === "agent-cli" && !def.runtime.ref) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`defineOperator (AIP-9): id='${def.id}' runtime.kind='agent-cli' requires runtime.ref (e.g. '@agentproto/adapter-hermes#hermes')`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
build(def) {
|
|
111
|
+
return {
|
|
112
|
+
id: def.id,
|
|
113
|
+
name: def.name,
|
|
114
|
+
persona_summary: def.persona_summary,
|
|
115
|
+
version: def.version,
|
|
116
|
+
entry: def.entry,
|
|
117
|
+
profile: Object.freeze({
|
|
118
|
+
role: def.profile.role,
|
|
119
|
+
voice: def.profile.voice,
|
|
120
|
+
boundaries: Object.freeze([...def.profile.boundaries])
|
|
121
|
+
}),
|
|
122
|
+
skills: Object.freeze([...def.skills ?? []]),
|
|
123
|
+
tools: Object.freeze([...def.tools ?? []]),
|
|
124
|
+
memory: def.memory ? Object.freeze({
|
|
125
|
+
kind: def.memory.kind,
|
|
126
|
+
policy: def.memory.policy ?? "summarising",
|
|
127
|
+
share_with: Object.freeze([...def.memory.share_with ?? []]),
|
|
128
|
+
external: def.memory.external ? Object.freeze({ ...def.memory.external }) : void 0
|
|
129
|
+
}) : void 0,
|
|
130
|
+
governance: def.governance ? Object.freeze({
|
|
131
|
+
policies: Object.freeze([...def.governance.policies ?? []]),
|
|
132
|
+
audit_log: def.governance.audit_log,
|
|
133
|
+
autonomy: def.governance.autonomy
|
|
134
|
+
}) : void 0,
|
|
135
|
+
capabilities: Object.freeze([...def.capabilities ?? []]),
|
|
136
|
+
participation: def.participation ? Object.freeze({
|
|
137
|
+
mode: def.participation.mode ?? "mention-only",
|
|
138
|
+
pass_when: def.participation.pass_when,
|
|
139
|
+
reactions: def.participation.reactions ?? false
|
|
140
|
+
}) : Object.freeze({ mode: "mention-only", reactions: false }),
|
|
141
|
+
runtime: def.runtime ? Object.freeze({
|
|
142
|
+
kind: def.runtime.kind,
|
|
143
|
+
ref: def.runtime.ref,
|
|
144
|
+
session: def.runtime.session ? Object.freeze({
|
|
145
|
+
mode: def.runtime.session.mode,
|
|
146
|
+
idle_timeout_ms: def.runtime.session.idle_timeout_ms
|
|
147
|
+
}) : void 0
|
|
148
|
+
}) : void 0,
|
|
149
|
+
tags: Object.freeze([...def.tags ?? []]),
|
|
150
|
+
metadata: Object.freeze({ ...def.metadata ?? {} })
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
export { defineOperator };
|
|
157
|
+
//# sourceMappingURL=chunk-HILBXS2I.mjs.map
|
|
158
|
+
//# sourceMappingURL=chunk-HILBXS2I.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/define-operator.ts"],"names":[],"mappings":";;;;;;;AAUA,IAAM,mBAAA,GAAsB,2BAAA;AAE5B,IAAM,eAAA,GAAkB,wCAAA;AACxB,IAAM,kBAAA,GAAqB,2BAAA;AAC3B,IAAM,iBAAA,GAAoB,0BAAA;AAC1B,IAAM,kBAAA,GAAqB,2BAAA;AAC3B,IAAM,kBAAA,GAAqB,mBAAA;AAC3B,IAAM,WAAA,GAAc,mBAAA;AAoBb,IAAM,cAAA,GAAiB,aAAA;AAAA,EAC5B;AAAA,IACE,GAAA,EAAK,CAAA;AAAA,IACL,IAAA,E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,CAAQ;AAAA,WACtC,CAAA,GACD;AAAA,SACL,CAAA,GACD,MAAA;AAAA,QACJ,IAAA,EAAM,OAAO,MAAA,CAAO,CAAC,GAAI,GAAA,CAAI,IAAA,IAAQ,EAAG,CAAC,CAAA;AAAA,QACzC,QAAA,EAAU,OAAO,MAAA,CAAO,EAAE,GAAI,GAAA,CAAI,QAAA,IAAY,EAAC,EAAI;AAAA,OACrD;AAAA,IACF;AAAA;AAEJ","file":"chunk-HILBXS2I.mjs","sourcesContent":["import { createDoctype } from \"@agentproto/define-doctype\"\nimport type { OperatorDefinition, OperatorHandle } from \"./types.js\"\n\n/**\n * AIP-9 id pattern — `^[a-z][a-z0-9-]*[a-z0-9]$` (slug-style, no dots,\n * no underscores, 2+ chars). Stricter than the createDoctype default\n * because operator ids double as dispatch slugs in conversation\n * mentions (`@<slug>`) where dot/underscore would collide with\n * shell/file conventions.\n */\nconst OPERATOR_ID_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$/\n\nconst VERSION_PATTERN = /^\\d+\\.\\d+\\.\\d+(?:[-+][a-zA-Z0-9.-]+)?$/\nconst POLICY_REF_PATTERN = /^policy:[A-Za-z0-9_./-]+$/\nconst AUDIT_REF_PATTERN = /^audit:[A-Za-z0-9_./-]+$/\nconst SHARE_WITH_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$/\nconst CAPABILITY_PATTERN = /^[a-z][a-z0-9-]*$/\nconst TAG_PATTERN = /^[a-z][a-z0-9-]*$/\n\n/**\n * AIP-9 reference implementation of `defineOperator`.\n *\n * Built on `createDoctype` so the cross-AIP invariants (id pattern,\n * top-level freeze, \"defineOperator (AIP-9): …\" error prefix) run\n * uniformly with every other AIP defineX. Spec-9-specific checks live\n * in `validate(def)`; defaulting + nested freezing in `build(def)`.\n *\n * Cross-field invariants enforced:\n * - persona_summary 1–280 chars (the LLM-facing one-liner)\n * - profile.role / profile.voice 1–1000 chars\n * - version matches semver (with optional prerelease/build)\n * - governance.audit_log shape `audit:<slug>`\n * - governance.policies entries shape `policy:<slug>`\n * - memory.kind === \"external\" requires memory.external.uri\n * - governance.autonomy === \"gated\" forces participation.mode in\n * {mention-only, silent} (matches the schema's allOf/if/then)\n */\nexport const defineOperator = createDoctype<OperatorDefinition, OperatorHandle>(\n {\n aip: 9,\n name: \"operator\",\n idPattern: OPERATOR_ID_PATTERN,\n // OPERATOR.md uses `persona_summary` for LLM-facing prose; no\n // `description` field. Use it as the description-equivalent for\n // length validation, capped at 280 per the schema.\n readDescription: (def) => def.persona_summary,\n maxDescriptionLen: 280,\n validate(def) {\n // Required-field shape checks beyond what createDoctype does.\n if (typeof def.name !== \"string\" || def.name.length === 0 || def.name.length > 80) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' name must be 1–80 chars`,\n )\n }\n if (!VERSION_PATTERN.test(def.version ?? \"\")) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' version must match ${VERSION_PATTERN}`,\n )\n }\n if (!def.profile) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' profile is required`,\n )\n }\n if (\n typeof def.profile.role !== \"string\" ||\n def.profile.role.length === 0 ||\n def.profile.role.length > 1000\n ) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' profile.role must be 1–1000 chars`,\n )\n }\n if (\n typeof def.profile.voice !== \"string\" ||\n def.profile.voice.length === 0 ||\n def.profile.voice.length > 1000\n ) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' profile.voice must be 1–1000 chars`,\n )\n }\n if (!Array.isArray(def.profile.boundaries)) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' profile.boundaries must be an array`,\n )\n }\n\n // Memory: external kind needs an `external.uri`.\n if (def.memory?.kind === \"external\" && !def.memory.external?.uri) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' memory.kind='external' requires memory.external.uri`,\n )\n }\n\n // Governance ref shapes.\n if (def.governance) {\n if (!AUDIT_REF_PATTERN.test(def.governance.audit_log ?? \"\")) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' governance.audit_log must match ${AUDIT_REF_PATTERN}`,\n )\n }\n for (const p of def.governance.policies ?? []) {\n if (!POLICY_REF_PATTERN.test(p)) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' governance.policies entry '${p}' must match ${POLICY_REF_PATTERN}`,\n )\n }\n }\n }\n\n // share_with entries follow the operator-id pattern.\n for (const peer of def.memory?.share_with ?? []) {\n if (!SHARE_WITH_PATTERN.test(peer)) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' memory.share_with entry '${peer}' must match ${SHARE_WITH_PATTERN}`,\n )\n }\n }\n\n // Capabilities + tags: lowercase-slug pattern.\n for (const c of def.capabilities ?? []) {\n if (!CAPABILITY_PATTERN.test(c)) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' capabilities entry '${c}' must match ${CAPABILITY_PATTERN}`,\n )\n }\n }\n for (const t of def.tags ?? []) {\n if (!TAG_PATTERN.test(t)) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' tags entry '${t}' must match ${TAG_PATTERN}`,\n )\n }\n }\n\n // Cross-field: autonomy=gated → participation.mode in {mention-only, silent}.\n // Mirrors the schema's allOf/if/then. The default participation mode\n // is mention-only (which satisfies the constraint) — only catch\n // explicit \"proactive\" with \"gated\".\n if (def.governance?.autonomy === \"gated\") {\n const mode = def.participation?.mode ?? \"mention-only\"\n if (mode !== \"mention-only\" && mode !== \"silent\") {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' governance.autonomy='gated' forbids participation.mode='${mode}' — must be 'mention-only' or 'silent'`,\n )\n }\n }\n\n // Cross-field: runtime.kind=agent-cli requires runtime.ref.\n if (def.runtime?.kind === \"agent-cli\" && !def.runtime.ref) {\n throw new Error(\n `defineOperator (AIP-9): id='${def.id}' runtime.kind='agent-cli' requires runtime.ref (e.g. '@agentproto/adapter-hermes#hermes')`,\n )\n }\n },\n build(def) {\n return {\n id: def.id,\n name: def.name,\n persona_summary: def.persona_summary,\n version: def.version,\n entry: def.entry,\n profile: Object.freeze({\n role: def.profile.role,\n voice: def.profile.voice,\n boundaries: Object.freeze([...def.profile.boundaries]),\n }),\n skills: Object.freeze([...(def.skills ?? [])]),\n tools: Object.freeze([...(def.tools ?? [])]),\n memory: def.memory\n ? Object.freeze({\n kind: def.memory.kind,\n policy: def.memory.policy ?? \"summarising\",\n share_with: Object.freeze([...(def.memory.share_with ?? [])]),\n external: def.memory.external\n ? Object.freeze({ ...def.memory.external })\n : undefined,\n })\n : undefined,\n governance: def.governance\n ? Object.freeze({\n policies: Object.freeze([...(def.governance.policies ?? [])]),\n audit_log: def.governance.audit_log,\n autonomy: def.governance.autonomy,\n })\n : undefined,\n capabilities: Object.freeze([...(def.capabilities ?? [])]),\n participation: def.participation\n ? Object.freeze({\n mode: def.participation.mode ?? \"mention-only\",\n pass_when: def.participation.pass_when,\n reactions: def.participation.reactions ?? false,\n })\n : Object.freeze({ mode: \"mention-only\", reactions: false }),\n runtime: def.runtime\n ? Object.freeze({\n kind: def.runtime.kind,\n ref: def.runtime.ref,\n session: def.runtime.session\n ? Object.freeze({\n mode: def.runtime.session.mode,\n idle_timeout_ms: def.runtime.session.idle_timeout_ms,\n })\n : undefined,\n })\n : undefined,\n tags: Object.freeze([...(def.tags ?? [])]),\n metadata: Object.freeze({ ...(def.metadata ?? {}) }),\n }\n },\n },\n)\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { O as OperatorDefinition, a as OperatorHandle } from './types-BxJvLb8Z.js';
|
|
2
|
+
export { A as Autonomy, M as MemoryKind, b as MemoryPolicy, c as OperatorGovernance, d as OperatorMemory, e as OperatorParticipation, f as OperatorProfile, P as ParticipationMode, S as SkillRef, T as ToolRef } from './types-BxJvLb8Z.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AIP-9 reference implementation of `defineOperator`.
|
|
6
|
+
*
|
|
7
|
+
* Built on `createDoctype` so the cross-AIP invariants (id pattern,
|
|
8
|
+
* top-level freeze, "defineOperator (AIP-9): …" error prefix) run
|
|
9
|
+
* uniformly with every other AIP defineX. Spec-9-specific checks live
|
|
10
|
+
* in `validate(def)`; defaulting + nested freezing in `build(def)`.
|
|
11
|
+
*
|
|
12
|
+
* Cross-field invariants enforced:
|
|
13
|
+
* - persona_summary 1–280 chars (the LLM-facing one-liner)
|
|
14
|
+
* - profile.role / profile.voice 1–1000 chars
|
|
15
|
+
* - version matches semver (with optional prerelease/build)
|
|
16
|
+
* - governance.audit_log shape `audit:<slug>`
|
|
17
|
+
* - governance.policies entries shape `policy:<slug>`
|
|
18
|
+
* - memory.kind === "external" requires memory.external.uri
|
|
19
|
+
* - governance.autonomy === "gated" forces participation.mode in
|
|
20
|
+
* {mention-only, silent} (matches the schema's allOf/if/then)
|
|
21
|
+
*/
|
|
22
|
+
declare const defineOperator: (def: OperatorDefinition) => OperatorHandle;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @agentproto/operator — AIP-9 OPERATOR.md `defineOperator` reference impl.
|
|
26
|
+
*
|
|
27
|
+
* A single canonical operator shell — pluggable profile, skills, tools,
|
|
28
|
+
* memory, governance — that any agent runtime can implement and any
|
|
29
|
+
* conforming workflow can dispatch to.
|
|
30
|
+
*
|
|
31
|
+
* Spec: https://agentproto.sh/docs/aip-9
|
|
32
|
+
*
|
|
33
|
+
* Authoring paths:
|
|
34
|
+
* - TS: `defineOperator({...})` → `OperatorHandle`
|
|
35
|
+
* - MD: `parseOperatorManifest(src) → operatorFromManifest({...})` → `OperatorHandle`
|
|
36
|
+
*/
|
|
37
|
+
declare const SPEC_NAME: "agentoperator/v1";
|
|
38
|
+
declare const SPEC_VERSION: "1.0.0-alpha";
|
|
39
|
+
|
|
40
|
+
export { OperatorDefinition, OperatorHandle, SPEC_NAME, SPEC_VERSION, defineOperator };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { defineOperator } from './chunk-HILBXS2I.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/operator v0.1.0-alpha
|
|
5
|
+
* AIP-9 OPERATOR.md `defineOperator` reference implementation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
var SPEC_NAME = "agentoperator/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":";;;;;;;;AAcO,IAAM,SAAA,GAAY;AAClB,IAAM,YAAA,GAAe","file":"index.mjs","sourcesContent":["/**\n * @agentproto/operator — AIP-9 OPERATOR.md `defineOperator` reference impl.\n *\n * A single canonical operator shell — pluggable profile, skills, tools,\n * memory, governance — that any agent runtime can implement and any\n * conforming workflow can dispatch to.\n *\n * Spec: https://agentproto.sh/docs/aip-9\n *\n * Authoring paths:\n * - TS: `defineOperator({...})` → `OperatorHandle`\n * - MD: `parseOperatorManifest(src) → operatorFromManifest({...})` → `OperatorHandle`\n */\n\nexport const SPEC_NAME = \"agentoperator/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\nexport { defineOperator } from \"./define-operator.js\"\nexport type {\n Autonomy,\n MemoryKind,\n MemoryPolicy,\n OperatorDefinition,\n OperatorGovernance,\n OperatorHandle,\n OperatorMemory,\n OperatorParticipation,\n OperatorProfile,\n ParticipationMode,\n SkillRef,\n ToolRef,\n} from \"./types.js\"\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { a as OperatorHandle } from '../types-BxJvLb8Z.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AIP-9 OPERATOR.md sidecar parser + manifest-to-handle constructor.
|
|
6
|
+
*
|
|
7
|
+
* Mirror of `@agentproto/tool/manifest`, `@agentproto/driver/manifest`,
|
|
8
|
+
* and `@agentproto/governance/policy`: the .md provides metadata; the
|
|
9
|
+
* TS module routes it through `defineOperator` so AIP-9 invariants
|
|
10
|
+
* (cross-field rules, ref shapes, length caps) run uniformly with the
|
|
11
|
+
* TS authoring path.
|
|
12
|
+
*
|
|
13
|
+
* The frontmatter schema mirrors `OPERATOR.schema.json`
|
|
14
|
+
* (resources/aip-9/draft/) field-for-field. AIP-9 forbids
|
|
15
|
+
* `additionalProperties` at every nested level, so we use plain
|
|
16
|
+
* `.object({...})` (strict) — extra keys raise a helpful error
|
|
17
|
+
* instead of silently surviving.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const operatorManifestFrontmatterSchema: z.ZodObject<{
|
|
21
|
+
schema: z.ZodOptional<z.ZodLiteral<"agentoperator/v1">>;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
persona_summary: z.ZodString;
|
|
25
|
+
version: z.ZodString;
|
|
26
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
27
|
+
profile: z.ZodObject<{
|
|
28
|
+
role: z.ZodString;
|
|
29
|
+
voice: z.ZodString;
|
|
30
|
+
boundaries: z.ZodArray<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
source: z.ZodOptional<z.ZodString>;
|
|
35
|
+
version: z.ZodOptional<z.ZodString>;
|
|
36
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
}, z.core.$strip>]>>>;
|
|
38
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
source: z.ZodOptional<z.ZodString>;
|
|
41
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
43
|
+
network: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
47
|
+
kind: z.ZodLiteral<"mcp">;
|
|
48
|
+
server: z.ZodString;
|
|
49
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>]>>>;
|
|
51
|
+
memory: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
kind: z.ZodEnum<{
|
|
53
|
+
none: "none";
|
|
54
|
+
thread: "thread";
|
|
55
|
+
"operator-context": "operator-context";
|
|
56
|
+
external: "external";
|
|
57
|
+
}>;
|
|
58
|
+
policy: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
"append-only": "append-only";
|
|
60
|
+
redactable: "redactable";
|
|
61
|
+
summarising: "summarising";
|
|
62
|
+
}>>;
|
|
63
|
+
share_with: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
external: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
uri: z.ZodString;
|
|
66
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
governance: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
policies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
audit_log: z.ZodString;
|
|
72
|
+
autonomy: z.ZodEnum<{
|
|
73
|
+
autonomous: "autonomous";
|
|
74
|
+
supervised: "supervised";
|
|
75
|
+
gated: "gated";
|
|
76
|
+
}>;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
|
+
participation: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
"mention-only": "mention-only";
|
|
82
|
+
proactive: "proactive";
|
|
83
|
+
silent: "silent";
|
|
84
|
+
}>>;
|
|
85
|
+
pass_when: z.ZodOptional<z.ZodString>;
|
|
86
|
+
reactions: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
runtime: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
kind: z.ZodEnum<{
|
|
90
|
+
"in-process": "in-process";
|
|
91
|
+
"agent-cli": "agent-cli";
|
|
92
|
+
}>;
|
|
93
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
94
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
96
|
+
ephemeral: "ephemeral";
|
|
97
|
+
persistent: "persistent";
|
|
98
|
+
resumable: "resumable";
|
|
99
|
+
}>>;
|
|
100
|
+
idle_timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
104
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
type OperatorManifestFrontmatter = z.infer<typeof operatorManifestFrontmatterSchema>;
|
|
107
|
+
interface OperatorManifest {
|
|
108
|
+
frontmatter: OperatorManifestFrontmatter;
|
|
109
|
+
body: string;
|
|
110
|
+
}
|
|
111
|
+
declare function parseOperatorManifest(source: string): OperatorManifest;
|
|
112
|
+
declare function operatorFromManifest(manifest: OperatorManifest): OperatorHandle;
|
|
113
|
+
|
|
114
|
+
export { type OperatorManifest, type OperatorManifestFrontmatter, operatorFromManifest, operatorManifestFrontmatterSchema, parseOperatorManifest };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineOperator } from '../chunk-HILBXS2I.mjs';
|
|
2
|
+
import matter from 'gray-matter';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @agentproto/operator v0.1.0-alpha
|
|
7
|
+
* AIP-9 OPERATOR.md `defineOperator` reference implementation.
|
|
8
|
+
*/
|
|
9
|
+
var skillRefSchema = z.union([
|
|
10
|
+
z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),
|
|
11
|
+
z.object({
|
|
12
|
+
id: z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),
|
|
13
|
+
source: z.string().optional(),
|
|
14
|
+
version: z.string().optional(),
|
|
15
|
+
allow: z.array(z.string()).optional()
|
|
16
|
+
})
|
|
17
|
+
]);
|
|
18
|
+
var toolRefSchema = z.union([
|
|
19
|
+
z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),
|
|
20
|
+
z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
source: z.string().optional(),
|
|
23
|
+
scope: z.object({
|
|
24
|
+
workspace: z.string().optional(),
|
|
25
|
+
network: z.array(z.string()).optional(),
|
|
26
|
+
secrets: z.array(z.string()).optional()
|
|
27
|
+
}).optional()
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
kind: z.literal("mcp"),
|
|
31
|
+
server: z.string(),
|
|
32
|
+
allow: z.array(z.string()).optional()
|
|
33
|
+
})
|
|
34
|
+
]);
|
|
35
|
+
var operatorManifestFrontmatterSchema = z.object({
|
|
36
|
+
schema: z.literal("agentoperator/v1").optional(),
|
|
37
|
+
name: z.string().min(1).max(80),
|
|
38
|
+
id: z.string().min(2).max(64).regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),
|
|
39
|
+
persona_summary: z.string().min(1).max(280),
|
|
40
|
+
version: z.string().regex(/^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/),
|
|
41
|
+
entry: z.string().optional(),
|
|
42
|
+
profile: z.object({
|
|
43
|
+
role: z.string().min(1).max(1e3),
|
|
44
|
+
voice: z.string().min(1).max(1e3),
|
|
45
|
+
boundaries: z.array(z.string().max(500))
|
|
46
|
+
}),
|
|
47
|
+
skills: z.array(skillRefSchema).optional(),
|
|
48
|
+
tools: z.array(toolRefSchema).optional(),
|
|
49
|
+
memory: z.object({
|
|
50
|
+
kind: z.enum(["none", "thread", "operator-context", "external"]),
|
|
51
|
+
policy: z.enum(["append-only", "redactable", "summarising"]).optional(),
|
|
52
|
+
share_with: z.array(z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/)).optional(),
|
|
53
|
+
external: z.object({ uri: z.string(), namespace: z.string().optional() }).optional()
|
|
54
|
+
}).optional(),
|
|
55
|
+
governance: z.object({
|
|
56
|
+
policies: z.array(z.string().regex(/^policy:[A-Za-z0-9_./-]+$/)).optional(),
|
|
57
|
+
audit_log: z.string().regex(/^audit:[A-Za-z0-9_./-]+$/),
|
|
58
|
+
autonomy: z.enum(["autonomous", "supervised", "gated"])
|
|
59
|
+
}).optional(),
|
|
60
|
+
capabilities: z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).optional(),
|
|
61
|
+
participation: z.object({
|
|
62
|
+
mode: z.enum(["mention-only", "proactive", "silent"]).optional(),
|
|
63
|
+
pass_when: z.string().optional(),
|
|
64
|
+
reactions: z.boolean().optional()
|
|
65
|
+
}).optional(),
|
|
66
|
+
runtime: z.object({
|
|
67
|
+
kind: z.enum(["in-process", "agent-cli"]),
|
|
68
|
+
ref: z.string().optional(),
|
|
69
|
+
session: z.object({
|
|
70
|
+
mode: z.enum(["ephemeral", "persistent", "resumable"]).optional(),
|
|
71
|
+
idle_timeout_ms: z.number().int().min(1e3).optional()
|
|
72
|
+
}).optional()
|
|
73
|
+
}).optional(),
|
|
74
|
+
tags: z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).optional(),
|
|
75
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
76
|
+
});
|
|
77
|
+
function parseOperatorManifest(source) {
|
|
78
|
+
const parsed = matter(source);
|
|
79
|
+
if (Object.keys(parsed.data).length === 0) {
|
|
80
|
+
throw new Error("parseOperatorManifest: missing or empty frontmatter");
|
|
81
|
+
}
|
|
82
|
+
const result = operatorManifestFrontmatterSchema.safeParse(parsed.data);
|
|
83
|
+
if (!result.success) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`parseOperatorManifest: invalid frontmatter \u2014 ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return { frontmatter: result.data, body: parsed.content };
|
|
89
|
+
}
|
|
90
|
+
function operatorFromManifest(manifest) {
|
|
91
|
+
const fm = manifest.frontmatter;
|
|
92
|
+
return defineOperator({
|
|
93
|
+
id: fm.id,
|
|
94
|
+
name: fm.name,
|
|
95
|
+
persona_summary: fm.persona_summary,
|
|
96
|
+
version: fm.version,
|
|
97
|
+
entry: fm.entry,
|
|
98
|
+
profile: fm.profile,
|
|
99
|
+
skills: fm.skills,
|
|
100
|
+
tools: fm.tools,
|
|
101
|
+
memory: fm.memory,
|
|
102
|
+
governance: fm.governance,
|
|
103
|
+
capabilities: fm.capabilities,
|
|
104
|
+
participation: fm.participation,
|
|
105
|
+
runtime: fm.runtime,
|
|
106
|
+
tags: fm.tags,
|
|
107
|
+
metadata: fm.metadata
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { operatorFromManifest, operatorManifestFrontmatterSchema, parseOperatorManifest };
|
|
112
|
+
//# sourceMappingURL=index.mjs.map
|
|
113
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/manifest/index.ts"],"names":[],"mappings":";;;;;;;;AAqBA,IAAM,cAAA,GAAiB,EAAE,KAAA,CAAM;AAAA,EAC7B,CAAA,CAAE,MAAA,EAAO,CAAE,KAAA,CAAM,2BAA2B,CAAA;AAAA,EA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AC1D;AAEO,SAAS,qBAAqB,QAAA,EAA4C;AAC/E,EAAA,MAAM,KAAK,QAAA,CAAS,WAAA;AACpB,EAAA,OAAO,cAAA,CAAe;AAAA,IACpB,IAAI,EAAA,CAAG,EAAA;AAAA,IACP,MAAM,EAAA,CAAG,IAAA;AAAA,IACT,iBAAiB,EAAA,CAAG,eAAA;AAAA,IACpB,SAAS,EAAA,CAAG,OAAA;AAAA,IACZ,OAAO,EAAA,CAAG,KAAA;AAAA,IACV,SAAS,EAAA,CAAG,OAAA;AAAA,IACZ,QAAQ,EAAA,CAAG,MAAA;AAAA,IACX,OAAO,EAAA,CAAG,KAAA;AAAA,IACV,QAAQ,EAAA,CAAG,MAAA;AAAA,IACX,YAAY,EAAA,CAAG,UAAA;AAAA,IACf,cAAc,EAAA,CAAG,YAAA;AAAA,IACjB,eAAe,EAAA,CAAG,aAAA;AAAA,IAClB,SAAS,EAAA,CAAG,OAAA;AAAA,IACZ,MAAM,EAAA,CAAG,IAAA;AAAA,IACT,UAAU,EAAA,CAAG;AAAA,GACd,CAAA;AACH","file":"index.mjs","sourcesContent":["/**\n * AIP-9 OPERATOR.md sidecar parser + manifest-to-handle constructor.\n *\n * Mirror of `@agentproto/tool/manifest`, `@agentproto/driver/manifest`,\n * and `@agentproto/governance/policy`: the .md provides metadata; the\n * TS module routes it through `defineOperator` so AIP-9 invariants\n * (cross-field rules, ref shapes, length caps) run uniformly with the\n * TS authoring path.\n *\n * The frontmatter schema mirrors `OPERATOR.schema.json`\n * (resources/aip-9/draft/) field-for-field. AIP-9 forbids\n * `additionalProperties` at every nested level, so we use plain\n * `.object({...})` (strict) — extra keys raise a helpful error\n * instead of silently surviving.\n */\n\nimport matter from \"gray-matter\"\nimport { z } from \"zod\"\nimport { defineOperator } from \"../define-operator.js\"\nimport type { OperatorHandle } from \"../types.js\"\n\nconst skillRefSchema = z.union([\n z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),\n z.object({\n id: z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),\n source: z.string().optional(),\n version: z.string().optional(),\n allow: z.array(z.string()).optional(),\n }),\n])\n\nconst toolRefSchema = z.union([\n z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),\n z.object({\n id: z.string(),\n source: z.string().optional(),\n scope: z\n .object({\n workspace: z.string().optional(),\n network: z.array(z.string()).optional(),\n secrets: z.array(z.string()).optional(),\n })\n .optional(),\n }),\n z.object({\n kind: z.literal(\"mcp\"),\n server: z.string(),\n allow: z.array(z.string()).optional(),\n }),\n])\n\nexport const operatorManifestFrontmatterSchema = z.object({\n schema: z.literal(\"agentoperator/v1\").optional(),\n name: z.string().min(1).max(80),\n id: z\n .string()\n .min(2)\n .max(64)\n .regex(/^[a-z][a-z0-9-]*[a-z0-9]$/),\n persona_summary: z.string().min(1).max(280),\n version: z.string().regex(/^\\d+\\.\\d+\\.\\d+(?:[-+][a-zA-Z0-9.-]+)?$/),\n entry: z.string().optional(),\n profile: z.object({\n role: z.string().min(1).max(1000),\n voice: z.string().min(1).max(1000),\n boundaries: z.array(z.string().max(500)),\n }),\n skills: z.array(skillRefSchema).optional(),\n tools: z.array(toolRefSchema).optional(),\n memory: z\n .object({\n kind: z.enum([\"none\", \"thread\", \"operator-context\", \"external\"]),\n policy: z.enum([\"append-only\", \"redactable\", \"summarising\"]).optional(),\n share_with: z\n .array(z.string().regex(/^[a-z][a-z0-9-]*[a-z0-9]$/))\n .optional(),\n external: z\n .object({ uri: z.string(), namespace: z.string().optional() })\n .optional(),\n })\n .optional(),\n governance: z\n .object({\n policies: z.array(z.string().regex(/^policy:[A-Za-z0-9_./-]+$/)).optional(),\n audit_log: z.string().regex(/^audit:[A-Za-z0-9_./-]+$/),\n autonomy: z.enum([\"autonomous\", \"supervised\", \"gated\"]),\n })\n .optional(),\n capabilities: z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).optional(),\n participation: z\n .object({\n mode: z.enum([\"mention-only\", \"proactive\", \"silent\"]).optional(),\n pass_when: z.string().optional(),\n reactions: z.boolean().optional(),\n })\n .optional(),\n runtime: z\n .object({\n kind: z.enum([\"in-process\", \"agent-cli\"]),\n ref: z.string().optional(),\n session: z\n .object({\n mode: z.enum([\"ephemeral\", \"persistent\", \"resumable\"]).optional(),\n idle_timeout_ms: z.number().int().min(1000).optional(),\n })\n .optional(),\n })\n .optional(),\n tags: z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport type OperatorManifestFrontmatter = z.infer<\n typeof operatorManifestFrontmatterSchema\n>\n\nexport interface OperatorManifest {\n frontmatter: OperatorManifestFrontmatter\n body: string\n}\n\nexport function parseOperatorManifest(source: string): OperatorManifest {\n const parsed = matter(source)\n if (Object.keys(parsed.data).length === 0) {\n throw new Error(\"parseOperatorManifest: missing or empty frontmatter\")\n }\n const result = operatorManifestFrontmatterSchema.safeParse(parsed.data)\n if (!result.success) {\n throw new Error(\n `parseOperatorManifest: 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 operatorFromManifest(manifest: OperatorManifest): OperatorHandle {\n const fm = manifest.frontmatter\n return defineOperator({\n id: fm.id,\n name: fm.name,\n persona_summary: fm.persona_summary,\n version: fm.version,\n entry: fm.entry,\n profile: fm.profile,\n skills: fm.skills,\n tools: fm.tools,\n memory: fm.memory,\n governance: fm.governance,\n capabilities: fm.capabilities,\n participation: fm.participation,\n runtime: fm.runtime,\n tags: fm.tags,\n metadata: fm.metadata,\n })\n}\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIP-9 OperatorDefinition + OperatorHandle.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `OPERATOR.schema.json` (resources/aip-9/draft/) one-to-one.
|
|
5
|
+
* The .md frontmatter and the TS literal are interchangeable inputs
|
|
6
|
+
* to `defineOperator` — same fields, same constraints, same handle
|
|
7
|
+
* shape on the way out.
|
|
8
|
+
*/
|
|
9
|
+
/** AIP-3 skill reference. Plain id, or an object with optional source/version/allow. */
|
|
10
|
+
type SkillRef = string | {
|
|
11
|
+
id: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
allow?: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* AIP-14 tool reference. Plain id, an explicit `{ id, source?, scope? }`,
|
|
18
|
+
* or an MCP-server binding `{ kind: "mcp", server, allow? }`.
|
|
19
|
+
*/
|
|
20
|
+
type ToolRef = string | {
|
|
21
|
+
id: string;
|
|
22
|
+
source?: string;
|
|
23
|
+
scope?: {
|
|
24
|
+
workspace?: string;
|
|
25
|
+
network?: readonly string[];
|
|
26
|
+
secrets?: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
kind: "mcp";
|
|
30
|
+
server: string;
|
|
31
|
+
allow?: readonly string[];
|
|
32
|
+
};
|
|
33
|
+
type MemoryKind = "none" | "thread" | "operator-context" | "external";
|
|
34
|
+
type MemoryPolicy = "append-only" | "redactable" | "summarising";
|
|
35
|
+
type Autonomy = "autonomous" | "supervised" | "gated";
|
|
36
|
+
type ParticipationMode = "mention-only" | "proactive" | "silent";
|
|
37
|
+
type OperatorRuntimeKind = "in-process" | "agent-cli";
|
|
38
|
+
type OperatorRuntimeSessionMode = "ephemeral" | "persistent" | "resumable";
|
|
39
|
+
interface OperatorRuntime {
|
|
40
|
+
/** Default `in-process`. */
|
|
41
|
+
kind: OperatorRuntimeKind;
|
|
42
|
+
/** AIP-45 AGENT-CLI ref. Required when kind=agent-cli. */
|
|
43
|
+
ref?: string;
|
|
44
|
+
/** Session policy when delegating to an agent CLI. */
|
|
45
|
+
session?: {
|
|
46
|
+
mode?: OperatorRuntimeSessionMode;
|
|
47
|
+
idle_timeout_ms?: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
interface OperatorProfile {
|
|
51
|
+
/** Job title and primary responsibility. 1–1000 chars. */
|
|
52
|
+
role: string;
|
|
53
|
+
/** Tone, register, pronoun stance. 1–1000 chars. */
|
|
54
|
+
voice: string;
|
|
55
|
+
/** Imperative MUST-NOT rules. Surface in every system-prompt synthesis. */
|
|
56
|
+
boundaries: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
interface OperatorMemory {
|
|
59
|
+
kind: MemoryKind;
|
|
60
|
+
/** Default `summarising` when memory section is present. */
|
|
61
|
+
policy?: MemoryPolicy;
|
|
62
|
+
/** Operator ids granted READ access to this operator's memory. */
|
|
63
|
+
share_with?: readonly string[];
|
|
64
|
+
/** Required when `kind === "external"`. */
|
|
65
|
+
external?: {
|
|
66
|
+
uri: string;
|
|
67
|
+
namespace?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
interface OperatorGovernance {
|
|
71
|
+
/** AIP-7 policy refs (`policy:<slug>`) consulted before privileged actions. */
|
|
72
|
+
policies?: readonly string[];
|
|
73
|
+
/** Audit channel (`audit:<slug>`) for state transitions, tool calls, memory writes. */
|
|
74
|
+
audit_log: string;
|
|
75
|
+
/** Per-turn autonomy class. */
|
|
76
|
+
autonomy: Autonomy;
|
|
77
|
+
}
|
|
78
|
+
interface OperatorParticipation {
|
|
79
|
+
/** Default `mention-only`. AIP-9 cross-field rule: autonomy=gated forces mention-only or silent. */
|
|
80
|
+
mode?: ParticipationMode;
|
|
81
|
+
/** Host-evaluated predicate; when true the operator emits a `pass` instead of a full turn. */
|
|
82
|
+
pass_when?: string;
|
|
83
|
+
/** Default `false`. */
|
|
84
|
+
reactions?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface OperatorDefinition {
|
|
87
|
+
/** Machine identifier and dispatch slug. Lowercase, digits, dashes. 2–64 chars. */
|
|
88
|
+
id: string;
|
|
89
|
+
/** Human-readable display name. 1–80 chars. */
|
|
90
|
+
name: string;
|
|
91
|
+
/** One-sentence role description, written for a teammate to read at a glance. 1–280 chars. */
|
|
92
|
+
persona_summary: string;
|
|
93
|
+
/** Spec version of THIS file. Bump on breaking change. */
|
|
94
|
+
version: string;
|
|
95
|
+
/** Relative path to the implementation file (e.g. `operator.ts`). */
|
|
96
|
+
entry?: string;
|
|
97
|
+
profile: OperatorProfile;
|
|
98
|
+
/** AIP-3 skill references. */
|
|
99
|
+
skills?: readonly SkillRef[];
|
|
100
|
+
/** AIP-14 tool refs and MCP server bindings the operator may invoke. */
|
|
101
|
+
tools?: readonly ToolRef[];
|
|
102
|
+
memory?: OperatorMemory;
|
|
103
|
+
governance?: OperatorGovernance;
|
|
104
|
+
/** Capability surface declared. Negotiated against runtime offer at registration. */
|
|
105
|
+
capabilities?: readonly string[];
|
|
106
|
+
participation?: OperatorParticipation;
|
|
107
|
+
/**
|
|
108
|
+
* Optional runtime binding. When omitted or `kind=in-process`, the
|
|
109
|
+
* host runs the operator's turn loop in-process. When `kind=agent-cli`,
|
|
110
|
+
* turns are dispatched to the spawned AIP-45 agent CLI (Hermes,
|
|
111
|
+
* Claude Code, …) referenced by `ref`.
|
|
112
|
+
*/
|
|
113
|
+
runtime?: OperatorRuntime;
|
|
114
|
+
tags?: readonly string[];
|
|
115
|
+
metadata?: Record<string, unknown>;
|
|
116
|
+
}
|
|
117
|
+
interface OperatorHandle {
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly persona_summary: string;
|
|
121
|
+
readonly version: string;
|
|
122
|
+
readonly entry?: string;
|
|
123
|
+
readonly profile: Readonly<{
|
|
124
|
+
role: string;
|
|
125
|
+
voice: string;
|
|
126
|
+
boundaries: readonly string[];
|
|
127
|
+
}>;
|
|
128
|
+
readonly skills: readonly SkillRef[];
|
|
129
|
+
readonly tools: readonly ToolRef[];
|
|
130
|
+
readonly memory?: Readonly<OperatorMemory>;
|
|
131
|
+
readonly governance?: Readonly<OperatorGovernance>;
|
|
132
|
+
readonly capabilities: readonly string[];
|
|
133
|
+
readonly participation?: Readonly<OperatorParticipation>;
|
|
134
|
+
readonly runtime?: Readonly<OperatorRuntime>;
|
|
135
|
+
readonly tags: readonly string[];
|
|
136
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type { Autonomy as A, MemoryKind as M, OperatorDefinition as O, ParticipationMode as P, SkillRef as S, ToolRef as T, OperatorHandle as a, MemoryPolicy as b, OperatorGovernance as c, OperatorMemory as d, OperatorParticipation as e, OperatorProfile as f };
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentproto/operator",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "@agentproto/operator — AIP-9 OPERATOR.md reference implementation. A single canonical operator shell — pluggable profile, skills, tools, memory, governance — that any agent runtime can implement and any conforming workflow can dispatch to.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-9",
|
|
8
|
+
"operator",
|
|
9
|
+
"defineOperator",
|
|
10
|
+
"open-standard",
|
|
11
|
+
"agentic"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://agentproto.sh/docs/aip-9",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/agentproto/ts",
|
|
17
|
+
"directory": "packages/operator"
|
|
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
|
+
}
|