@agentwonderland/mcp 0.1.57 → 0.1.58

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.
@@ -1,199 +0,0 @@
1
- type StepLike = {
2
- id: string;
3
- agent_slug: string | null;
4
- default_input?: Record<string, unknown>;
5
- quantity?: number;
6
- iteration?: number;
7
- };
8
-
9
- export type PlaybookStepInputResult =
10
- | {
11
- status: "ready";
12
- input: Record<string, unknown>;
13
- certification: "explicit";
14
- }
15
- | {
16
- status: "blocked";
17
- code: string;
18
- message: string;
19
- };
20
-
21
- const BLOCKED_PLAYBOOKS: Record<string, string> = {
22
- "icp-hunter": "Blocked until the friendly ICP input is mapped to the live prospect-search schema and the prospect agent is verified to honor those filters.",
23
- "no-web-leads": "Blocked until zip/category inputs are mapped to the live no-web/place/phone schemas and the no-web agent is verified to honor the requested local filters.",
24
- };
25
-
26
- function asString(value: unknown): string | undefined {
27
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
28
- }
29
-
30
- function outputRecord(value: unknown): Record<string, unknown> | undefined {
31
- return value && typeof value === "object" && !Array.isArray(value)
32
- ? value as Record<string, unknown>
33
- : undefined;
34
- }
35
-
36
- function previousOutputs(input: Record<string, unknown>): Array<Record<string, unknown>> {
37
- return Array.isArray(input.previous_outputs)
38
- ? input.previous_outputs.map(outputRecord).filter((item): item is Record<string, unknown> => Boolean(item))
39
- : [];
40
- }
41
-
42
- function stepOutput(entry: Record<string, unknown> | undefined): unknown {
43
- return outputRecord(entry)?.output ?? entry;
44
- }
45
-
46
- function extractHtml(value: unknown): string | undefined {
47
- if (typeof value === "string" && /<html|<!doctype|<body|<section|<main/i.test(value)) return value;
48
- const record = outputRecord(value);
49
- if (!record) return undefined;
50
- const direct = record.html;
51
- if (typeof direct === "string" && direct.trim()) return direct;
52
- const output = record.output;
53
- if (typeof output === "string" && /<html|<!doctype|<body|<section|<main/i.test(output)) return output;
54
- const nested = outputRecord(output);
55
- return typeof nested?.html === "string" && nested.html.trim() ? nested.html : undefined;
56
- }
57
-
58
- function launchLandingInput(baseInput: Record<string, unknown>, step: StepLike): PlaybookStepInputResult {
59
- const brief = asString(baseInput.brief) ?? asString(baseInput.context) ?? asString(baseInput.product);
60
- if (!brief) {
61
- return {
62
- status: "blocked",
63
- code: "PLAYBOOK_INPUT_MISSING_BRIEF",
64
- message: "launch-landing requires a brief before any child agent is called.",
65
- };
66
- }
67
-
68
- if (step.agent_slug === "marketing-copy-council") {
69
- return {
70
- status: "ready",
71
- certification: "explicit",
72
- input: {
73
- brief,
74
- context: {
75
- product_slug: asString(baseInput.product_slug),
76
- },
77
- num_outputs: 1,
78
- },
79
- };
80
- }
81
-
82
- const outputs = previousOutputs(baseInput);
83
- if (step.agent_slug === "write-landing-page-copy") {
84
- const council = outputs.find((item) => item.step === "council" || item.step === "marketing-copy-council") ?? outputs.at(-1);
85
- const product = asString(baseInput.product)
86
- ?? asString(baseInput.product_name)
87
- ?? asString(baseInput.product_slug)
88
- ?? "Landing page";
89
-
90
- return {
91
- status: "ready",
92
- certification: "explicit",
93
- input: {
94
- product,
95
- audience: asString(baseInput.audience) ?? "builders and operators",
96
- tone: asString(baseInput.tone) ?? "confident and practical",
97
- context: JSON.stringify({
98
- brief,
99
- product_slug: asString(baseInput.product_slug),
100
- council_output: stepOutput(council),
101
- }),
102
- },
103
- };
104
- }
105
-
106
- if (step.agent_slug === "publish-html-to-a-public-url") {
107
- const writer = outputs.find((item) => item.step === "structure" || item.step === "write-landing-page-copy") ?? outputs.at(-1);
108
- const html = extractHtml(stepOutput(writer)) ?? extractHtml(writer);
109
- if (!html) {
110
- return {
111
- status: "blocked",
112
- code: "PLAYBOOK_INPUT_MISSING_HTML",
113
- message: "launch-landing publish step requires generated HTML from the writer step.",
114
- };
115
- }
116
- return {
117
- status: "ready",
118
- certification: "explicit",
119
- input: {
120
- html,
121
- slug: asString(baseInput.product_slug) ?? asString(baseInput.slug),
122
- title: asString(baseInput.title) ?? asString(baseInput.product) ?? asString(baseInput.product_slug),
123
- },
124
- };
125
- }
126
-
127
- return {
128
- status: "blocked",
129
- code: "PLAYBOOK_STEP_NOT_CERTIFIED",
130
- message: `launch-landing step ${step.id} (${step.agent_slug ?? "unknown"}) has no explicit adapter.`,
131
- };
132
- }
133
-
134
- function ipoBriefInput(baseInput: Record<string, unknown>, step: StepLike): PlaybookStepInputResult {
135
- const ticker = asString(baseInput.ticker) ?? asString(baseInput.symbol);
136
- if (!ticker) {
137
- return {
138
- status: "blocked",
139
- code: "PLAYBOOK_INPUT_MISSING_TICKER",
140
- message: "ipo-brief requires ticker before any child agent is called.",
141
- };
142
- }
143
-
144
- if (step.agent_slug === "ipo-s-1-analysis") {
145
- return {
146
- status: "ready",
147
- certification: "explicit",
148
- input: { ticker },
149
- };
150
- }
151
- if (step.agent_slug === "insider-trading-tracker") {
152
- return {
153
- status: "ready",
154
- certification: "explicit",
155
- input: {
156
- ticker,
157
- days_back: Number(baseInput.days_back ?? 365),
158
- },
159
- };
160
- }
161
- if (step.agent_slug === "stock-comparison") {
162
- const peers = Array.isArray(baseInput.peer_tickers) ? baseInput.peer_tickers : [];
163
- const tickers = [ticker, ...peers].filter((item): item is string => typeof item === "string" && Boolean(item.trim())).slice(0, 5);
164
- return {
165
- status: "ready",
166
- certification: "explicit",
167
- input: { tickers },
168
- };
169
- }
170
-
171
- return {
172
- status: "blocked",
173
- code: "PLAYBOOK_STEP_NOT_CERTIFIED",
174
- message: `ipo-brief step ${step.id} (${step.agent_slug ?? "unknown"}) has no explicit adapter.`,
175
- };
176
- }
177
-
178
- export function playbookRunBlocker(slug: string): string | null {
179
- return BLOCKED_PLAYBOOKS[slug] ?? null;
180
- }
181
-
182
- export function buildExplicitPlaybookStepInput(
183
- playbookSlug: string,
184
- baseInput: Record<string, unknown>,
185
- step: StepLike,
186
- ): PlaybookStepInputResult | null {
187
- const blocker = playbookRunBlocker(playbookSlug);
188
- if (blocker) {
189
- return {
190
- status: "blocked",
191
- code: "PLAYBOOK_NOT_CERTIFIED",
192
- message: blocker,
193
- };
194
- }
195
-
196
- if (playbookSlug === "launch-landing") return launchLandingInput(baseInput, step);
197
- if (playbookSlug === "ipo-brief") return ipoBriefInput(baseInput, step);
198
- return null;
199
- }