opencode-swarm-plugin 0.56.1 → 0.57.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/README.md +21 -0
- package/claude-plugin/agents/background-worker.md +1 -0
- package/claude-plugin/agents/coordinator.md +1 -0
- package/claude-plugin/agents/worker.md +1 -0
- package/claude-plugin/bin/swarm-mcp-server.ts +47 -8
- package/claude-plugin/dist/agent-mail.d.ts +480 -0
- package/claude-plugin/dist/agent-mail.d.ts.map +1 -0
- package/claude-plugin/dist/anti-patterns.d.ts +257 -0
- package/claude-plugin/dist/anti-patterns.d.ts.map +1 -0
- package/claude-plugin/dist/bin/swarm.js +373128 -0
- package/claude-plugin/dist/cass-tools.d.ts +74 -0
- package/claude-plugin/dist/cass-tools.d.ts.map +1 -0
- package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
- package/claude-plugin/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-hook.d.ts +178 -0
- package/claude-plugin/dist/compaction-hook.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-observability.d.ts +173 -0
- package/claude-plugin/dist/compaction-observability.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-prompt-scoring.d.ts +125 -0
- package/claude-plugin/dist/compaction-prompt-scoring.d.ts.map +1 -0
- package/claude-plugin/dist/compaction-prompt-scoring.js +139 -0
- package/claude-plugin/dist/contributor-tools.d.ts +42 -0
- package/claude-plugin/dist/contributor-tools.d.ts.map +1 -0
- package/claude-plugin/dist/coordinator-guard.d.ts +79 -0
- package/claude-plugin/dist/coordinator-guard.d.ts.map +1 -0
- package/claude-plugin/dist/dashboard.d.ts +82 -0
- package/claude-plugin/dist/dashboard.d.ts.map +1 -0
- package/claude-plugin/dist/decision-trace-integration.d.ts +204 -0
- package/claude-plugin/dist/decision-trace-integration.d.ts.map +1 -0
- package/claude-plugin/dist/error-enrichment.d.ts +49 -0
- package/claude-plugin/dist/error-enrichment.d.ts.map +1 -0
- package/claude-plugin/dist/eval-capture.d.ts +494 -0
- package/claude-plugin/dist/eval-capture.d.ts.map +1 -0
- package/claude-plugin/dist/eval-capture.js +12844 -0
- package/claude-plugin/dist/eval-gates.d.ts +84 -0
- package/claude-plugin/dist/eval-gates.d.ts.map +1 -0
- package/claude-plugin/dist/eval-history.d.ts +117 -0
- package/claude-plugin/dist/eval-history.d.ts.map +1 -0
- package/claude-plugin/dist/eval-learning.d.ts +216 -0
- package/claude-plugin/dist/eval-learning.d.ts.map +1 -0
- package/claude-plugin/dist/eval-runner.d.ts +134 -0
- package/claude-plugin/dist/eval-runner.d.ts.map +1 -0
- package/claude-plugin/dist/examples/plugin-wrapper-template.ts +3341 -0
- package/claude-plugin/dist/export-tools.d.ts +76 -0
- package/claude-plugin/dist/export-tools.d.ts.map +1 -0
- package/claude-plugin/dist/hive.d.ts +949 -0
- package/claude-plugin/dist/hive.d.ts.map +1 -0
- package/claude-plugin/dist/hive.js +15009 -0
- package/claude-plugin/dist/hivemind-tools.d.ts +479 -0
- package/claude-plugin/dist/hivemind-tools.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/atomic-write.d.ts +21 -0
- package/claude-plugin/dist/hooks/atomic-write.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/constants.d.ts +28 -0
- package/claude-plugin/dist/hooks/constants.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/index.d.ts +16 -0
- package/claude-plugin/dist/hooks/index.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/session-start.d.ts +30 -0
- package/claude-plugin/dist/hooks/session-start.d.ts.map +1 -0
- package/claude-plugin/dist/hooks/tool-complete.d.ts +54 -0
- package/claude-plugin/dist/hooks/tool-complete.d.ts.map +1 -0
- package/claude-plugin/dist/index.d.ts +2017 -0
- package/claude-plugin/dist/index.d.ts.map +1 -0
- package/claude-plugin/dist/index.js +73453 -0
- package/claude-plugin/dist/learning.d.ts +700 -0
- package/claude-plugin/dist/learning.d.ts.map +1 -0
- package/claude-plugin/dist/logger.d.ts +38 -0
- package/claude-plugin/dist/logger.d.ts.map +1 -0
- package/claude-plugin/dist/mandate-promotion.d.ts +93 -0
- package/claude-plugin/dist/mandate-promotion.d.ts.map +1 -0
- package/claude-plugin/dist/mandate-storage.d.ts +209 -0
- package/claude-plugin/dist/mandate-storage.d.ts.map +1 -0
- package/claude-plugin/dist/mandates.d.ts +230 -0
- package/claude-plugin/dist/mandates.d.ts.map +1 -0
- package/claude-plugin/dist/memory-tools.d.ts +281 -0
- package/claude-plugin/dist/memory-tools.d.ts.map +1 -0
- package/claude-plugin/dist/memory.d.ts +164 -0
- package/claude-plugin/dist/memory.d.ts.map +1 -0
- package/claude-plugin/dist/model-selection.d.ts +37 -0
- package/claude-plugin/dist/model-selection.d.ts.map +1 -0
- package/claude-plugin/dist/observability-health.d.ts +87 -0
- package/claude-plugin/dist/observability-health.d.ts.map +1 -0
- package/claude-plugin/dist/observability-tools.d.ts +184 -0
- package/claude-plugin/dist/observability-tools.d.ts.map +1 -0
- package/claude-plugin/dist/output-guardrails.d.ts +125 -0
- package/claude-plugin/dist/output-guardrails.d.ts.map +1 -0
- package/claude-plugin/dist/pattern-maturity.d.ts +246 -0
- package/claude-plugin/dist/pattern-maturity.d.ts.map +1 -0
- package/claude-plugin/dist/planning-guardrails.d.ts +183 -0
- package/claude-plugin/dist/planning-guardrails.d.ts.map +1 -0
- package/claude-plugin/dist/plugin.d.ts +22 -0
- package/claude-plugin/dist/plugin.d.ts.map +1 -0
- package/claude-plugin/dist/plugin.js +72295 -0
- package/claude-plugin/dist/post-compaction-tracker.d.ts +133 -0
- package/claude-plugin/dist/post-compaction-tracker.d.ts.map +1 -0
- package/claude-plugin/dist/query-tools.d.ts +90 -0
- package/claude-plugin/dist/query-tools.d.ts.map +1 -0
- package/claude-plugin/dist/rate-limiter.d.ts +218 -0
- package/claude-plugin/dist/rate-limiter.d.ts.map +1 -0
- package/claude-plugin/dist/regression-detection.d.ts +58 -0
- package/claude-plugin/dist/regression-detection.d.ts.map +1 -0
- package/claude-plugin/dist/replay-tools.d.ts +28 -0
- package/claude-plugin/dist/replay-tools.d.ts.map +1 -0
- package/claude-plugin/dist/repo-crawl.d.ts +146 -0
- package/claude-plugin/dist/repo-crawl.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/cell-events.d.ts +1352 -0
- package/claude-plugin/dist/schemas/cell-events.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/cell.d.ts +413 -0
- package/claude-plugin/dist/schemas/cell.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/evaluation.d.ts +161 -0
- package/claude-plugin/dist/schemas/evaluation.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/index.d.ts +46 -0
- package/claude-plugin/dist/schemas/index.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/mandate.d.ts +336 -0
- package/claude-plugin/dist/schemas/mandate.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/swarm-context.d.ts +131 -0
- package/claude-plugin/dist/schemas/swarm-context.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/task.d.ts +189 -0
- package/claude-plugin/dist/schemas/task.d.ts.map +1 -0
- package/claude-plugin/dist/schemas/worker-handoff.d.ts +78 -0
- package/claude-plugin/dist/schemas/worker-handoff.d.ts.map +1 -0
- package/claude-plugin/dist/sessions/agent-discovery.d.ts +59 -0
- package/claude-plugin/dist/sessions/agent-discovery.d.ts.map +1 -0
- package/claude-plugin/dist/sessions/index.d.ts +10 -0
- package/claude-plugin/dist/sessions/index.d.ts.map +1 -0
- package/claude-plugin/dist/skills.d.ts +490 -0
- package/claude-plugin/dist/skills.d.ts.map +1 -0
- package/claude-plugin/dist/storage.d.ts +260 -0
- package/claude-plugin/dist/storage.d.ts.map +1 -0
- package/claude-plugin/dist/structured.d.ts +206 -0
- package/claude-plugin/dist/structured.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-adversarial-review.d.ts +104 -0
- package/claude-plugin/dist/swarm-adversarial-review.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-decompose.d.ts +297 -0
- package/claude-plugin/dist/swarm-decompose.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-insights.d.ts +390 -0
- package/claude-plugin/dist/swarm-insights.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-mail.d.ts +274 -0
- package/claude-plugin/dist/swarm-mail.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-orchestrate.d.ts +924 -0
- package/claude-plugin/dist/swarm-orchestrate.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-prompts.d.ts +467 -0
- package/claude-plugin/dist/swarm-prompts.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-prompts.js +45283 -0
- package/claude-plugin/dist/swarm-research.d.ts +125 -0
- package/claude-plugin/dist/swarm-research.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-review.d.ts +214 -0
- package/claude-plugin/dist/swarm-review.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-signature.d.ts +106 -0
- package/claude-plugin/dist/swarm-signature.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-strategies.d.ts +113 -0
- package/claude-plugin/dist/swarm-strategies.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-validation.d.ts +127 -0
- package/claude-plugin/dist/swarm-validation.d.ts.map +1 -0
- package/claude-plugin/dist/swarm-worktree.d.ts +185 -0
- package/claude-plugin/dist/swarm-worktree.d.ts.map +1 -0
- package/claude-plugin/dist/swarm.d.ts +590 -0
- package/claude-plugin/dist/swarm.d.ts.map +1 -0
- package/claude-plugin/dist/tool-availability.d.ts +91 -0
- package/claude-plugin/dist/tool-availability.d.ts.map +1 -0
- package/claude-plugin/dist/utils/tree-renderer.d.ts +61 -0
- package/claude-plugin/dist/utils/tree-renderer.d.ts.map +1 -0
- package/claude-plugin/dist/validators/index.d.ts +7 -0
- package/claude-plugin/dist/validators/index.d.ts.map +1 -0
- package/claude-plugin/dist/validators/schema-validator.d.ts +58 -0
- package/claude-plugin/dist/validators/schema-validator.d.ts.map +1 -0
- package/claude-plugin/skills/always-on-guidance/SKILL.md +44 -0
- package/dist/agent-mail.d.ts +4 -4
- package/dist/agent-mail.d.ts.map +1 -1
- package/dist/bin/swarm.js +467 -12
- package/dist/claude-plugin/claude-plugin-assets.d.ts +10 -0
- package/dist/claude-plugin/claude-plugin-assets.d.ts.map +1 -0
- package/dist/compaction-hook.d.ts +1 -1
- package/dist/compaction-hook.d.ts.map +1 -1
- package/dist/index.js +370 -260
- package/dist/plugin.js +369 -259
- package/dist/skills.d.ts +15 -0
- package/dist/skills.d.ts.map +1 -1
- package/dist/swarm-mail.d.ts.map +1 -1
- package/dist/swarm-prompts.d.ts +3 -1
- package/dist/swarm-prompts.d.ts.map +1 -1
- package/dist/swarm-prompts.js +79 -2
- package/package.json +2 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability Tools - Agent-facing Analytics
|
|
3
|
+
*
|
|
4
|
+
* Exposes observability tools to agents via plugin tools.
|
|
5
|
+
* Agents get programmatic access to analytics, not just CLI.
|
|
6
|
+
*
|
|
7
|
+
* Tools:
|
|
8
|
+
* - swarm_analytics: Query pre-built analytics
|
|
9
|
+
* - swarm_query: Raw SQL for power users
|
|
10
|
+
* - swarm_diagnose: Auto-diagnosis for epic/task
|
|
11
|
+
* - swarm_insights: Generate learning insights
|
|
12
|
+
*/
|
|
13
|
+
export interface SwarmAnalyticsArgs {
|
|
14
|
+
query: "failed-decompositions" | "strategy-success-rates" | "lock-contention" | "agent-activity" | "message-latency" | "scope-violations" | "task-duration" | "checkpoint-frequency" | "recovery-success" | "human-feedback";
|
|
15
|
+
since?: string;
|
|
16
|
+
format?: "json" | "summary";
|
|
17
|
+
}
|
|
18
|
+
export interface SwarmQueryArgs {
|
|
19
|
+
sql: string;
|
|
20
|
+
format?: "json" | "table";
|
|
21
|
+
}
|
|
22
|
+
export interface SwarmDiagnoseArgs {
|
|
23
|
+
epic_id?: string;
|
|
24
|
+
bead_id?: string;
|
|
25
|
+
include?: Array<"blockers" | "conflicts" | "slow_tasks" | "errors" | "timeline">;
|
|
26
|
+
}
|
|
27
|
+
export interface SwarmInsightsArgs {
|
|
28
|
+
scope: "epic" | "project" | "recent";
|
|
29
|
+
epic_id?: string;
|
|
30
|
+
metrics: Array<"success_rate" | "avg_duration" | "conflict_rate" | "retry_rate">;
|
|
31
|
+
}
|
|
32
|
+
export interface SwarmStatsData {
|
|
33
|
+
overall: {
|
|
34
|
+
totalSwarms: number;
|
|
35
|
+
successRate: number;
|
|
36
|
+
avgDurationMin: number;
|
|
37
|
+
};
|
|
38
|
+
byStrategy: Array<{
|
|
39
|
+
strategy: string;
|
|
40
|
+
total: number;
|
|
41
|
+
successRate: number;
|
|
42
|
+
successes: number;
|
|
43
|
+
}>;
|
|
44
|
+
coordinator: {
|
|
45
|
+
violationRate: number;
|
|
46
|
+
spawnEfficiency: number;
|
|
47
|
+
reviewThoroughness: number;
|
|
48
|
+
};
|
|
49
|
+
recentDays: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Format swarm stats as beautiful CLI output with box drawing
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatSwarmStats(stats: SwarmStatsData): string;
|
|
55
|
+
/**
|
|
56
|
+
* Parse time period string like "7d", "24h", "30m" to timestamp
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseTimePeriod(period: string): number;
|
|
59
|
+
/**
|
|
60
|
+
* Aggregate swarm outcomes by strategy
|
|
61
|
+
*/
|
|
62
|
+
export declare function aggregateByStrategy(outcomes: Array<{
|
|
63
|
+
strategy: string | null;
|
|
64
|
+
success: boolean;
|
|
65
|
+
}>): Array<{
|
|
66
|
+
strategy: string;
|
|
67
|
+
total: number;
|
|
68
|
+
successRate: number;
|
|
69
|
+
successes: number;
|
|
70
|
+
}>;
|
|
71
|
+
export interface SwarmHistoryRecord {
|
|
72
|
+
epic_id: string;
|
|
73
|
+
epic_title: string;
|
|
74
|
+
strategy: string;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
overall_success: boolean;
|
|
77
|
+
task_count: number;
|
|
78
|
+
completed_count: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Query swarm history from swarm events
|
|
82
|
+
*
|
|
83
|
+
* Constructs epic-level view from decomposition_generated and subtask_outcome events:
|
|
84
|
+
* - decomposition_generated: epic_id, task (title), strategy, subtask_count
|
|
85
|
+
* - subtask_outcome: count successful completed tasks per epic
|
|
86
|
+
*/
|
|
87
|
+
export declare function querySwarmHistory(projectPath: string, options?: {
|
|
88
|
+
limit?: number;
|
|
89
|
+
status?: "success" | "failed" | "in_progress";
|
|
90
|
+
strategy?: "file-based" | "feature-based" | "risk-based";
|
|
91
|
+
}): Promise<SwarmHistoryRecord[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Format relative time (e.g., "2h ago", "1d ago")
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatRelativeTime(timestamp: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Format swarm history as beautiful CLI table
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatSwarmHistory(records: SwarmHistoryRecord[]): string;
|
|
100
|
+
export declare const observabilityTools: {
|
|
101
|
+
swarm_analytics: {
|
|
102
|
+
description: string;
|
|
103
|
+
args: {
|
|
104
|
+
query: import("zod").ZodEnum<{
|
|
105
|
+
"failed-decompositions": "failed-decompositions";
|
|
106
|
+
"strategy-success-rates": "strategy-success-rates";
|
|
107
|
+
"lock-contention": "lock-contention";
|
|
108
|
+
"agent-activity": "agent-activity";
|
|
109
|
+
"message-latency": "message-latency";
|
|
110
|
+
"scope-violations": "scope-violations";
|
|
111
|
+
"task-duration": "task-duration";
|
|
112
|
+
"checkpoint-frequency": "checkpoint-frequency";
|
|
113
|
+
"recovery-success": "recovery-success";
|
|
114
|
+
"human-feedback": "human-feedback";
|
|
115
|
+
}>;
|
|
116
|
+
since: import("zod").ZodOptional<import("zod").ZodString>;
|
|
117
|
+
format: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
118
|
+
summary: "summary";
|
|
119
|
+
json: "json";
|
|
120
|
+
}>>;
|
|
121
|
+
};
|
|
122
|
+
execute(args: {
|
|
123
|
+
query: "failed-decompositions" | "strategy-success-rates" | "lock-contention" | "agent-activity" | "message-latency" | "scope-violations" | "task-duration" | "checkpoint-frequency" | "recovery-success" | "human-feedback";
|
|
124
|
+
since?: string | undefined;
|
|
125
|
+
format?: "summary" | "json" | undefined;
|
|
126
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
127
|
+
};
|
|
128
|
+
swarm_query: {
|
|
129
|
+
description: string;
|
|
130
|
+
args: {
|
|
131
|
+
sql: import("zod").ZodString;
|
|
132
|
+
format: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
133
|
+
table: "table";
|
|
134
|
+
json: "json";
|
|
135
|
+
}>>;
|
|
136
|
+
};
|
|
137
|
+
execute(args: {
|
|
138
|
+
sql: string;
|
|
139
|
+
format?: "table" | "json" | undefined;
|
|
140
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
141
|
+
};
|
|
142
|
+
swarm_diagnose: {
|
|
143
|
+
description: string;
|
|
144
|
+
args: {
|
|
145
|
+
epic_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
146
|
+
bead_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
147
|
+
include: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
148
|
+
errors: "errors";
|
|
149
|
+
blockers: "blockers";
|
|
150
|
+
conflicts: "conflicts";
|
|
151
|
+
slow_tasks: "slow_tasks";
|
|
152
|
+
timeline: "timeline";
|
|
153
|
+
}>>>;
|
|
154
|
+
};
|
|
155
|
+
execute(args: {
|
|
156
|
+
epic_id?: string | undefined;
|
|
157
|
+
bead_id?: string | undefined;
|
|
158
|
+
include?: ("errors" | "blockers" | "conflicts" | "slow_tasks" | "timeline")[] | undefined;
|
|
159
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
160
|
+
};
|
|
161
|
+
swarm_insights: {
|
|
162
|
+
description: string;
|
|
163
|
+
args: {
|
|
164
|
+
scope: import("zod").ZodEnum<{
|
|
165
|
+
project: "project";
|
|
166
|
+
epic: "epic";
|
|
167
|
+
recent: "recent";
|
|
168
|
+
}>;
|
|
169
|
+
epic_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
170
|
+
metrics: import("zod").ZodArray<import("zod").ZodEnum<{
|
|
171
|
+
success_rate: "success_rate";
|
|
172
|
+
avg_duration: "avg_duration";
|
|
173
|
+
conflict_rate: "conflict_rate";
|
|
174
|
+
retry_rate: "retry_rate";
|
|
175
|
+
}>>;
|
|
176
|
+
};
|
|
177
|
+
execute(args: {
|
|
178
|
+
scope: "project" | "epic" | "recent";
|
|
179
|
+
metrics: ("success_rate" | "avg_duration" | "conflict_rate" | "retry_rate")[];
|
|
180
|
+
epic_id?: string | undefined;
|
|
181
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=observability-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability-tools.d.ts","sourceRoot":"","sources":["../src/observability-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,MAAM,WAAW,kBAAkB;IAClC,KAAK,EACF,uBAAuB,GACvB,wBAAwB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,gBAAgB,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,i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EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBpF;AAMD,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC9C,QAAQ,CAAC,EAAE,YAAY,GAAG,eAAe,GAAG,YAAY,CAAC;CACzD,GACC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA0F/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAiCxE;AAMD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAK9B,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Guardrails for MCP Tool Response Truncation
|
|
3
|
+
*
|
|
4
|
+
* Prevents MCP tools from blowing out context with massive responses.
|
|
5
|
+
* Provides smart truncation that preserves JSON, code blocks, and markdown structure.
|
|
6
|
+
*
|
|
7
|
+
* @module output-guardrails
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { guardrailOutput, DEFAULT_GUARDRAIL_CONFIG } from "./output-guardrails"
|
|
12
|
+
*
|
|
13
|
+
* const result = guardrailOutput("context7_get-library-docs", hugeOutput)
|
|
14
|
+
* if (result.truncated) {
|
|
15
|
+
* console.log(`Truncated ${result.originalLength - result.truncatedLength} chars`)
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Guardrail configuration for tool output limits
|
|
21
|
+
*
|
|
22
|
+
* Controls per-tool character limits and skip rules.
|
|
23
|
+
*/
|
|
24
|
+
export interface GuardrailConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Default max characters for tool output
|
|
27
|
+
* Default: 32000 chars (~8000 tokens at 4 chars/token)
|
|
28
|
+
*/
|
|
29
|
+
defaultMaxChars: number;
|
|
30
|
+
/**
|
|
31
|
+
* Per-tool character limit overrides
|
|
32
|
+
*
|
|
33
|
+
* Higher limits for code/doc tools that commonly return large outputs.
|
|
34
|
+
*/
|
|
35
|
+
toolLimits: Record<string, number>;
|
|
36
|
+
/**
|
|
37
|
+
* Tools that should never be truncated
|
|
38
|
+
*
|
|
39
|
+
* Internal coordination tools (beads_*, swarmmail_*, structured_*)
|
|
40
|
+
* should always return complete output.
|
|
41
|
+
*/
|
|
42
|
+
skipTools: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of guardrail output processing
|
|
46
|
+
*/
|
|
47
|
+
export interface GuardrailResult {
|
|
48
|
+
/** Processed output (truncated if needed) */
|
|
49
|
+
output: string;
|
|
50
|
+
/** Whether truncation occurred */
|
|
51
|
+
truncated: boolean;
|
|
52
|
+
/** Original output length in characters */
|
|
53
|
+
originalLength: number;
|
|
54
|
+
/** Final output length in characters */
|
|
55
|
+
truncatedLength: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Metrics for guardrail analytics
|
|
59
|
+
*
|
|
60
|
+
* Used to track truncation patterns and adjust limits.
|
|
61
|
+
*/
|
|
62
|
+
export interface GuardrailMetrics {
|
|
63
|
+
/** Tool that produced the output */
|
|
64
|
+
toolName: string;
|
|
65
|
+
/** Original output length */
|
|
66
|
+
originalLength: number;
|
|
67
|
+
/** Truncated output length */
|
|
68
|
+
truncatedLength: number;
|
|
69
|
+
/** Timestamp of truncation */
|
|
70
|
+
timestamp: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Default guardrail configuration
|
|
74
|
+
*
|
|
75
|
+
* - defaultMaxChars: 32000 (~8000 tokens)
|
|
76
|
+
* - Higher limits for code/doc tools (64000)
|
|
77
|
+
* - Skip internal coordination tools
|
|
78
|
+
*/
|
|
79
|
+
export declare const DEFAULT_GUARDRAIL_CONFIG: GuardrailConfig;
|
|
80
|
+
/**
|
|
81
|
+
* Smart truncation preserving structure boundaries
|
|
82
|
+
*
|
|
83
|
+
* Truncates text while preserving:
|
|
84
|
+
* - JSON structure (finds matching braces, doesn't cut mid-object)
|
|
85
|
+
* - Code blocks (preserves ``` boundaries)
|
|
86
|
+
* - Markdown headers (cuts at ## boundaries when possible)
|
|
87
|
+
*
|
|
88
|
+
* @param text - Text to truncate
|
|
89
|
+
* @param maxChars - Maximum character count
|
|
90
|
+
* @returns Truncated text with "[TRUNCATED - X chars removed]" suffix
|
|
91
|
+
*/
|
|
92
|
+
export declare function truncateWithBoundaries(text: string, maxChars: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Apply guardrails to tool output
|
|
95
|
+
*
|
|
96
|
+
* Main entry point for guardrail processing:
|
|
97
|
+
* 1. Check if tool is in skipTools → return unchanged
|
|
98
|
+
* 2. Check if output.length > getToolLimit(toolName) → truncate
|
|
99
|
+
* 3. Return { output, truncated, originalLength, truncatedLength }
|
|
100
|
+
*
|
|
101
|
+
* @param toolName - Name of the tool that produced the output
|
|
102
|
+
* @param output - Tool output to process
|
|
103
|
+
* @param config - Optional guardrail configuration (defaults to DEFAULT_GUARDRAIL_CONFIG)
|
|
104
|
+
* @returns Guardrail result with truncated output and metadata
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const result = guardrailOutput("context7_get-library-docs", hugeOutput)
|
|
109
|
+
* console.log(result.output) // Truncated or original
|
|
110
|
+
* console.log(result.truncated) // true if truncated
|
|
111
|
+
* console.log(`${result.originalLength} → ${result.truncatedLength} chars`)
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function guardrailOutput(toolName: string, output: string, config?: GuardrailConfig): GuardrailResult;
|
|
115
|
+
/**
|
|
116
|
+
* Create a guardrail metrics entry
|
|
117
|
+
*
|
|
118
|
+
* Used for analytics and learning about truncation patterns.
|
|
119
|
+
*
|
|
120
|
+
* @param result - Guardrail result from guardrailOutput
|
|
121
|
+
* @param toolName - Name of the tool
|
|
122
|
+
* @returns Metrics entry
|
|
123
|
+
*/
|
|
124
|
+
export declare function createMetrics(result: GuardrailResult, toolName: string): GuardrailMetrics;
|
|
125
|
+
//# sourceMappingURL=output-guardrails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-guardrails.d.ts","sourceRoot":"","sources":["../src/output-guardrails.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IAEnB,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAC;IAEvB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IAEjB,6BAA6B;IAC7B,cAAc,EAAE,MAAM,CAAC;IAEvB,8BAA8B;IAC9B,eAAe,EAAE,MAAM,CAAC;IAExB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,eA+EtC,CAAC;AA+BF;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwE7E;AAgBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,eAA0C,GACjD,eAAe,CAoCjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAOlB"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Maturity Module
|
|
3
|
+
*
|
|
4
|
+
* Tracks decomposition pattern maturity states through lifecycle:
|
|
5
|
+
* candidate → established → proven (or deprecated)
|
|
6
|
+
*
|
|
7
|
+
* Patterns start as candidates until they accumulate enough feedback.
|
|
8
|
+
* Strong positive feedback promotes to proven, strong negative deprecates.
|
|
9
|
+
*
|
|
10
|
+
* @see https://github.com/Dicklesworthstone/cass_memory_system/blob/main/src/scoring.ts#L73-L98
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
/**
|
|
14
|
+
* Maturity state for a decomposition pattern
|
|
15
|
+
*
|
|
16
|
+
* - candidate: Not enough feedback to judge (< minFeedback events)
|
|
17
|
+
* - established: Enough feedback, neither proven nor deprecated
|
|
18
|
+
* - proven: Strong positive signal (high helpful, low harmful ratio)
|
|
19
|
+
* - deprecated: Strong negative signal (high harmful ratio)
|
|
20
|
+
*/
|
|
21
|
+
export declare const MaturityStateSchema: z.ZodEnum<{
|
|
22
|
+
deprecated: "deprecated";
|
|
23
|
+
candidate: "candidate";
|
|
24
|
+
established: "established";
|
|
25
|
+
proven: "proven";
|
|
26
|
+
}>;
|
|
27
|
+
export type MaturityState = z.infer<typeof MaturityStateSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Pattern maturity tracking
|
|
30
|
+
*
|
|
31
|
+
* Tracks feedback counts and state transitions for a decomposition pattern.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PatternMaturitySchema: z.ZodObject<{
|
|
34
|
+
pattern_id: z.ZodString;
|
|
35
|
+
state: z.ZodEnum<{
|
|
36
|
+
deprecated: "deprecated";
|
|
37
|
+
candidate: "candidate";
|
|
38
|
+
established: "established";
|
|
39
|
+
proven: "proven";
|
|
40
|
+
}>;
|
|
41
|
+
helpful_count: z.ZodNumber;
|
|
42
|
+
harmful_count: z.ZodNumber;
|
|
43
|
+
last_validated: z.ZodString;
|
|
44
|
+
promoted_at: z.ZodOptional<z.ZodString>;
|
|
45
|
+
deprecated_at: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type PatternMaturity = z.infer<typeof PatternMaturitySchema>;
|
|
48
|
+
/**
|
|
49
|
+
* Feedback event for maturity tracking
|
|
50
|
+
*/
|
|
51
|
+
export declare const MaturityFeedbackSchema: z.ZodObject<{
|
|
52
|
+
pattern_id: z.ZodString;
|
|
53
|
+
type: z.ZodEnum<{
|
|
54
|
+
helpful: "helpful";
|
|
55
|
+
harmful: "harmful";
|
|
56
|
+
}>;
|
|
57
|
+
timestamp: z.ZodString;
|
|
58
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type MaturityFeedback = z.infer<typeof MaturityFeedbackSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for maturity calculations
|
|
63
|
+
*/
|
|
64
|
+
export interface MaturityConfig {
|
|
65
|
+
/** Minimum feedback events before leaving candidate state */
|
|
66
|
+
minFeedback: number;
|
|
67
|
+
/** Minimum decayed helpful score to reach proven state */
|
|
68
|
+
minHelpful: number;
|
|
69
|
+
/** Maximum harmful ratio to reach/maintain proven state */
|
|
70
|
+
maxHarmful: number;
|
|
71
|
+
/** Harmful ratio threshold for deprecation */
|
|
72
|
+
deprecationThreshold: number;
|
|
73
|
+
/** Half-life for decay in days */
|
|
74
|
+
halfLifeDays: number;
|
|
75
|
+
}
|
|
76
|
+
export declare const DEFAULT_MATURITY_CONFIG: MaturityConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate decayed feedback counts
|
|
79
|
+
*
|
|
80
|
+
* Applies half-life decay to each feedback event based on age.
|
|
81
|
+
*
|
|
82
|
+
* @param feedbackEvents - Raw feedback events
|
|
83
|
+
* @param config - Maturity configuration
|
|
84
|
+
* @param now - Current timestamp for decay calculation
|
|
85
|
+
* @returns Decayed helpful and harmful totals
|
|
86
|
+
*/
|
|
87
|
+
export declare function calculateDecayedCounts(feedbackEvents: MaturityFeedback[], config?: MaturityConfig, now?: Date): {
|
|
88
|
+
decayedHelpful: number;
|
|
89
|
+
decayedHarmful: number;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Calculate maturity state from feedback events
|
|
93
|
+
*
|
|
94
|
+
* State determination logic:
|
|
95
|
+
* 1. "deprecated" if harmful ratio > 0.3 AND total >= minFeedback
|
|
96
|
+
* 2. "candidate" if total < minFeedback (not enough data)
|
|
97
|
+
* 3. "proven" if decayedHelpful >= minHelpful AND harmfulRatio < maxHarmful
|
|
98
|
+
* 4. "established" otherwise (enough data but not yet proven)
|
|
99
|
+
*
|
|
100
|
+
* @param feedbackEvents - Feedback events for this pattern
|
|
101
|
+
* @param config - Maturity configuration
|
|
102
|
+
* @param now - Current timestamp for decay calculation
|
|
103
|
+
* @returns Calculated maturity state
|
|
104
|
+
*/
|
|
105
|
+
export declare function calculateMaturityState(feedbackEvents: MaturityFeedback[], config?: MaturityConfig, now?: Date): MaturityState;
|
|
106
|
+
/**
|
|
107
|
+
* Create initial pattern maturity record
|
|
108
|
+
*
|
|
109
|
+
* @param patternId - Unique pattern identifier
|
|
110
|
+
* @returns New PatternMaturity in candidate state
|
|
111
|
+
*/
|
|
112
|
+
export declare function createPatternMaturity(patternId: string): PatternMaturity;
|
|
113
|
+
/**
|
|
114
|
+
* Update pattern maturity with new feedback.
|
|
115
|
+
*
|
|
116
|
+
* Side Effects:
|
|
117
|
+
* - Sets `promoted_at` timestamp on first entry into 'proven' status
|
|
118
|
+
* - Sets `deprecated_at` timestamp on first entry into 'deprecated' status
|
|
119
|
+
* - Updates `helpful_count` and `harmful_count` based on feedback events
|
|
120
|
+
* - Recalculates `state` based on decayed feedback counts
|
|
121
|
+
*
|
|
122
|
+
* State Transitions:
|
|
123
|
+
* - candidate → established: After minFeedback observations (default 3)
|
|
124
|
+
* - established → proven: When decayedHelpful >= minHelpful (5) AND harmfulRatio < maxHarmful (15%)
|
|
125
|
+
* - any → deprecated: When harmfulRatio > deprecationThreshold (30%) AND total >= minFeedback
|
|
126
|
+
*
|
|
127
|
+
* @param maturity - Current maturity record
|
|
128
|
+
* @param feedbackEvents - All feedback events for this pattern
|
|
129
|
+
* @param config - Maturity configuration
|
|
130
|
+
* @returns Updated maturity record with new state
|
|
131
|
+
*/
|
|
132
|
+
export declare function updatePatternMaturity(maturity: PatternMaturity, feedbackEvents: MaturityFeedback[], config?: MaturityConfig): PatternMaturity;
|
|
133
|
+
/**
|
|
134
|
+
* Promote a pattern to proven state
|
|
135
|
+
*
|
|
136
|
+
* Manually promotes a pattern regardless of feedback counts.
|
|
137
|
+
* Use when external validation confirms pattern effectiveness.
|
|
138
|
+
*
|
|
139
|
+
* @param maturity - Current maturity record
|
|
140
|
+
* @returns Updated maturity record with proven state
|
|
141
|
+
*/
|
|
142
|
+
export declare function promotePattern(maturity: PatternMaturity): PatternMaturity;
|
|
143
|
+
/**
|
|
144
|
+
* Deprecate a pattern
|
|
145
|
+
*
|
|
146
|
+
* Manually deprecates a pattern regardless of feedback counts.
|
|
147
|
+
* Use when external validation shows pattern is harmful.
|
|
148
|
+
*
|
|
149
|
+
* @param maturity - Current maturity record
|
|
150
|
+
* @param reason - Optional reason for deprecation
|
|
151
|
+
* @returns Updated maturity record with deprecated state
|
|
152
|
+
*/
|
|
153
|
+
export declare function deprecatePattern(maturity: PatternMaturity, _reason?: string): PatternMaturity;
|
|
154
|
+
/**
|
|
155
|
+
* Get weight multiplier based on pattern maturity status.
|
|
156
|
+
*
|
|
157
|
+
* Multipliers chosen to:
|
|
158
|
+
* - Heavily penalize deprecated patterns (0x) - never recommend
|
|
159
|
+
* - Slightly boost proven patterns (1.5x) - reward validated success
|
|
160
|
+
* - Penalize unvalidated candidates (0.5x) - reduce impact until proven
|
|
161
|
+
* - Neutral for established (1.0x) - baseline weight
|
|
162
|
+
*
|
|
163
|
+
* @param state - Pattern maturity status
|
|
164
|
+
* @returns Multiplier to apply to pattern weight
|
|
165
|
+
*/
|
|
166
|
+
export declare function getMaturityMultiplier(state: MaturityState): number;
|
|
167
|
+
/**
|
|
168
|
+
* Format maturity state for inclusion in prompts
|
|
169
|
+
*
|
|
170
|
+
* Shows pattern reliability to help agents make informed decisions.
|
|
171
|
+
*
|
|
172
|
+
* @param maturity - Pattern maturity record
|
|
173
|
+
* @returns Formatted string describing pattern reliability
|
|
174
|
+
*/
|
|
175
|
+
export declare function formatMaturityForPrompt(maturity: PatternMaturity): string;
|
|
176
|
+
/**
|
|
177
|
+
* Format multiple patterns with maturity for prompt inclusion
|
|
178
|
+
*
|
|
179
|
+
* Groups patterns by maturity state for clear presentation.
|
|
180
|
+
*
|
|
181
|
+
* @param patterns - Map of pattern content to maturity record
|
|
182
|
+
* @returns Formatted string for prompt inclusion
|
|
183
|
+
*/
|
|
184
|
+
export declare function formatPatternsWithMaturityForPrompt(patterns: Map<string, PatternMaturity>): string;
|
|
185
|
+
/**
|
|
186
|
+
* Storage interface for pattern maturity records
|
|
187
|
+
*/
|
|
188
|
+
export interface MaturityStorage {
|
|
189
|
+
/** Store or update a maturity record */
|
|
190
|
+
store(maturity: PatternMaturity): Promise<void>;
|
|
191
|
+
/** Get maturity record by pattern ID */
|
|
192
|
+
get(patternId: string): Promise<PatternMaturity | null>;
|
|
193
|
+
/** Get all maturity records */
|
|
194
|
+
getAll(): Promise<PatternMaturity[]>;
|
|
195
|
+
/** Get patterns by state */
|
|
196
|
+
getByState(state: MaturityState): Promise<PatternMaturity[]>;
|
|
197
|
+
/** Store a feedback event */
|
|
198
|
+
storeFeedback(feedback: MaturityFeedback): Promise<void>;
|
|
199
|
+
/** Get all feedback for a pattern */
|
|
200
|
+
getFeedback(patternId: string): Promise<MaturityFeedback[]>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* In-memory maturity storage (for testing and short-lived sessions)
|
|
204
|
+
*/
|
|
205
|
+
export declare class InMemoryMaturityStorage implements MaturityStorage {
|
|
206
|
+
private maturities;
|
|
207
|
+
private feedback;
|
|
208
|
+
store(maturity: PatternMaturity): Promise<void>;
|
|
209
|
+
get(patternId: string): Promise<PatternMaturity | null>;
|
|
210
|
+
getAll(): Promise<PatternMaturity[]>;
|
|
211
|
+
getByState(state: MaturityState): Promise<PatternMaturity[]>;
|
|
212
|
+
storeFeedback(feedback: MaturityFeedback): Promise<void>;
|
|
213
|
+
getFeedback(patternId: string): Promise<MaturityFeedback[]>;
|
|
214
|
+
}
|
|
215
|
+
export declare const maturitySchemas: {
|
|
216
|
+
MaturityStateSchema: z.ZodEnum<{
|
|
217
|
+
deprecated: "deprecated";
|
|
218
|
+
candidate: "candidate";
|
|
219
|
+
established: "established";
|
|
220
|
+
proven: "proven";
|
|
221
|
+
}>;
|
|
222
|
+
PatternMaturitySchema: z.ZodObject<{
|
|
223
|
+
pattern_id: z.ZodString;
|
|
224
|
+
state: z.ZodEnum<{
|
|
225
|
+
deprecated: "deprecated";
|
|
226
|
+
candidate: "candidate";
|
|
227
|
+
established: "established";
|
|
228
|
+
proven: "proven";
|
|
229
|
+
}>;
|
|
230
|
+
helpful_count: z.ZodNumber;
|
|
231
|
+
harmful_count: z.ZodNumber;
|
|
232
|
+
last_validated: z.ZodString;
|
|
233
|
+
promoted_at: z.ZodOptional<z.ZodString>;
|
|
234
|
+
deprecated_at: z.ZodOptional<z.ZodString>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
MaturityFeedbackSchema: z.ZodObject<{
|
|
237
|
+
pattern_id: z.ZodString;
|
|
238
|
+
type: z.ZodEnum<{
|
|
239
|
+
helpful: "helpful";
|
|
240
|
+
harmful: "harmful";
|
|
241
|
+
}>;
|
|
242
|
+
timestamp: z.ZodString;
|
|
243
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
244
|
+
}, z.core.$strip>;
|
|
245
|
+
};
|
|
246
|
+
//# sourceMappingURL=pattern-maturity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-maturity.d.ts","sourceRoot":"","sources":["../src/pattern-maturity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;EAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAehC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;iBASjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAA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