@keel_flow/pack-agent-topology 0.2.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 jglasskatz
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,15 @@
1
+ # @keel_flow/pack-agent-topology
2
+
3
+ Agent and tool architecture principles for Keel multi-agent systems: seven opinionated principles covering single-source-of-truth per tool, bounded-context ownership, agent isolation, and tool call determinism — each with a machine-checkable `check` function that plugs into `keel verify`.
4
+
5
+ Part of the [Keel](https://github.com/jglasskatz/keel) framework.
6
+
7
+ ## Install
8
+
9
+ ```
10
+ npm install @keel_flow/pack-agent-topology
11
+ ```
12
+
13
+ ## License
14
+
15
+ MIT
@@ -0,0 +1,4 @@
1
+ import type { PrincipleWithCheck, PrinciplePack } from "@keel_flow/schema";
2
+ export declare const agentTopologyPrinciples: PrincipleWithCheck[];
3
+ export declare const agentTopologyPack: PrinciplePack;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAC;AAGtF,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,EA8GvD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,aAK/B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,124 @@
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { join } from "path";
3
+ import { isTemplateFile } from "@keel_flow/pack-general-se/scope-filters";
4
+ export const agentTopologyPrinciples = [
5
+ {
6
+ id: "single-source-of-truth-per-tool",
7
+ description: "Each tool reads/writes through exactly one data path",
8
+ rationale: "Multiple paths create state drift; tool answers diverge from reality when a second path exists",
9
+ severity: "critical",
10
+ },
11
+ {
12
+ id: "no-cross-agent-state-mutation",
13
+ description: "Agents must not mutate state owned by another agent",
14
+ rationale: "Cross-agent mutation couples agents implicitly; the coupling manifests as unreproducible bugs",
15
+ severity: "critical",
16
+ },
17
+ {
18
+ id: "explicit-handoff-contracts",
19
+ description: "Agent-to-agent handoffs are typed; the receiving agent validates the payload at its boundary",
20
+ rationale: "Untyped handoffs are the primary source of cascading failures in multi-agent systems",
21
+ severity: "critical",
22
+ },
23
+ {
24
+ id: "tool-schemas-are-load-bearing",
25
+ description: "Tool input and output schemas are the source of truth for what a tool does",
26
+ rationale: "Prose descriptions drift; schemas are machine-checked and therefore always accurate",
27
+ severity: "critical",
28
+ check({ diff, cwd }) {
29
+ // Honor the verify cwd so file reads resolve against the target project
30
+ // rather than the runner's working directory.
31
+ const root = cwd ?? process.cwd();
32
+ const violations = [];
33
+ for (const file of diff.files) {
34
+ if (!file.path.includes("/tools/") && !file.path.includes("tool.ts"))
35
+ continue;
36
+ if (file.status === "removed")
37
+ continue;
38
+ if (file.path.endsWith(".test.ts"))
39
+ continue;
40
+ if (isTemplateFile(file.path))
41
+ continue;
42
+ const absPath = join(root, file.path);
43
+ if (!existsSync(absPath))
44
+ continue;
45
+ try {
46
+ const content = readFileSync(absPath, "utf-8");
47
+ const hasZod = content.includes("inputSchema") || content.includes("z.object");
48
+ const hasTypeBox = content.includes("Type.Object") || /parameters\s*:/.test(content);
49
+ if (!hasZod && !hasTypeBox) {
50
+ violations.push({
51
+ principleId: "tool-schemas-are-load-bearing",
52
+ file: file.path,
53
+ severity: "critical",
54
+ message: `Tool file "${file.path}" appears to define a tool without a typed parameter schema (Zod inputSchema or TypeBox Type.Object). Every tool must have a typed schema.`,
55
+ });
56
+ }
57
+ }
58
+ catch {
59
+ // File unreadable; skip
60
+ }
61
+ }
62
+ return violations;
63
+ },
64
+ },
65
+ {
66
+ id: "one-agent-one-bounded-context",
67
+ description: "Each agent is assigned to exactly one bounded context in the architecture map",
68
+ rationale: "An agent crossing contexts is an agent without a clear owner, and an architecture without clear seams",
69
+ severity: "warning",
70
+ },
71
+ {
72
+ id: "tool-failures-are-typed",
73
+ description: "Every tool must return a typed error variant on failure; tools must not throw unstructured exceptions",
74
+ rationale: "Unstructured exceptions escape the type system and force callers to catch and inspect unknown shapes; typed errors allow exhaustive handling",
75
+ severity: "critical",
76
+ check({ diff, cwd }) {
77
+ // Honor the verify cwd so file reads resolve against the target project
78
+ // rather than the runner's working directory.
79
+ const root = cwd ?? process.cwd();
80
+ const violations = [];
81
+ for (const file of diff.files) {
82
+ if (!file.path.includes("/tools/") && !file.path.includes("tool.ts"))
83
+ continue;
84
+ if (file.status === "removed")
85
+ continue;
86
+ if (file.path.endsWith(".test.ts"))
87
+ continue;
88
+ if (isTemplateFile(file.path))
89
+ continue;
90
+ const absPath = join(root, file.path);
91
+ if (!existsSync(absPath))
92
+ continue;
93
+ try {
94
+ const content = readFileSync(absPath, "utf-8");
95
+ if (content.includes("throw new Error") && !content.match(/error[Tt]ype|ErrorType|ToolError|ResultError|errorKind/)) {
96
+ violations.push({
97
+ principleId: "tool-failures-are-typed",
98
+ file: file.path,
99
+ severity: "critical",
100
+ message: `Tool file "${file.path}" throws unstructured errors. Return a typed error variant instead.`,
101
+ });
102
+ }
103
+ }
104
+ catch {
105
+ // File unreadable; skip
106
+ }
107
+ }
108
+ return violations;
109
+ },
110
+ },
111
+ {
112
+ id: "kb-retrieval-before-creativity",
113
+ description: "An agent with KB access must retrieve relevant context before generating a response; it must not speculate first",
114
+ rationale: "Generating before retrieving produces responses anchored to training priors rather than workspace reality; retrieval-first grounds the agent",
115
+ severity: "critical",
116
+ },
117
+ ];
118
+ export const agentTopologyPack = {
119
+ id: "@keel_flow/pack-agent-topology",
120
+ version: "0.1.0",
121
+ description: "Agent and tool architecture principles for Keel multi-agent systems.",
122
+ principles: agentTopologyPrinciples,
123
+ };
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D;QACE,EAAE,EAAE,iCAAiC;QACrC,WAAW,EAAE,sDAAsD;QACnE,SAAS,EACP,gGAAgG;QAClG,QAAQ,EAAE,UAAU;KACrB;IACD;QACE,EAAE,EAAE,+BAA+B;QACnC,WAAW,EAAE,qDAAqD;QAClE,SAAS,EACP,+FAA+F;QACjG,QAAQ,EAAE,UAAU;KACrB;IACD;QACE,EAAE,EAAE,4BAA4B;QAChC,WAAW,EACT,8FAA8F;QAChG,SAAS,EAAE,sFAAsF;QACjG,QAAQ,EAAE,UAAU;KACrB;IACD;QACE,EAAE,EA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AM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,wDAAwD,CAAC,EAAE,CAAC;wBACpH,UAAU,CAAC,IAAI,CAAC;4BACd,WAAW,EAAE,yBAAyB;4BACtC,IAAI,EAAE,IAAI,CAAC,IAAI;4BACf,QAAQ,EAAE,UAAU;4BACpB,OAAO,EAAE,cAAc,IAAI,CAAC,IAAI,qEAAqE;yBACtG,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,wBAAwB;gBAC1B,CAAC;YACH,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;KACF;IACD;QACE,EAAE,EAAE,gCAAgC;QACpC,WAAW,EACT,kHAAkH;QACpH,SAAS,EACP,8IAA8I;QAChJ,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,EAAE,EAAE,gCAAgC;IACpC,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,sEAAsE;IACnF,UAAU,EAAE,uBAAuB;CACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@keel_flow/pack-agent-topology",
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Agent and tool architecture principles for Keel multi-agent systems",
7
+ "keywords": [
8
+ "keel",
9
+ "principles",
10
+ "agents",
11
+ "tools"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "types": "./dist/index.d.ts"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "@keel_flow/schema": "0.2.0",
30
+ "@keel_flow/pack-general-se": "0.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^25.9.1",
34
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
35
+ "@typescript-eslint/parser": "^8.0.0",
36
+ "eslint": "^9.0.0",
37
+ "typescript": "^5.5.0",
38
+ "vitest": "^2.0.0"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "lint": "eslint src"
45
+ }
46
+ }