@patchbay-nebius/agent 0.0.0-stage → 0.1.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 +66 -2
- package/dist/chunk-JVXVCXNZ.js +2356 -0
- package/dist/chunk-JVXVCXNZ.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +391 -0
- package/dist/cli.js.map +1 -0
- package/dist/fixtures/typeform-pipedrive/attempt-1/README.md +41 -0
- package/dist/fixtures/typeform-pipedrive/attempt-1/src/connector.test.ts +111 -0
- package/dist/fixtures/typeform-pipedrive/attempt-1/src/connector.ts +93 -0
- package/dist/fixtures/typeform-pipedrive/attempt-1/src/fixtures.ts +173 -0
- package/dist/fixtures/typeform-pipedrive/final/README.md +41 -0
- package/dist/fixtures/typeform-pipedrive/final/src/connector.test.ts +111 -0
- package/dist/fixtures/typeform-pipedrive/final/src/connector.ts +94 -0
- package/dist/fixtures/typeform-pipedrive/final/src/fixtures.ts +173 -0
- package/dist/fixtures/typeform-pipedrive/meta.json +192 -0
- package/dist/fixtures/typeform-pipedrive/run.json +444 -0
- package/dist/index.d.ts +302 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner-IPBNTPNM.js +247 -0
- package/dist/scanner-IPBNTPNM.js.map +1 -0
- package/package.json +61 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
interface ModelTier {
|
|
2
|
+
id: string;
|
|
3
|
+
/** USD per million tokens, used for the cost readout. */
|
|
4
|
+
inputPrice: number;
|
|
5
|
+
outputPrice: number;
|
|
6
|
+
}
|
|
7
|
+
interface AgentConfig {
|
|
8
|
+
mock: boolean;
|
|
9
|
+
/** `nebius` (isolated sandbox, default) or `local` (dev fallback, not isolated). */
|
|
10
|
+
runner: 'nebius' | 'local';
|
|
11
|
+
nebiusApiKey: string;
|
|
12
|
+
nebiusProject: string;
|
|
13
|
+
nebiusBaseUrl: string;
|
|
14
|
+
sandboxUrl: string;
|
|
15
|
+
tavilyApiKey: string;
|
|
16
|
+
baseImage: string | undefined;
|
|
17
|
+
maxAttempts: number;
|
|
18
|
+
/** How many repair variants to try in parallel per attempt. 1 = classic sequential repair. */
|
|
19
|
+
parallelRepairs: number;
|
|
20
|
+
/**
|
|
21
|
+
* LLM provider identity, chosen by setting PATCHBAY_LLM_PROVIDER. Default `nebius` keeps
|
|
22
|
+
* the Nemotron-specific `chat_template_kwargs: { enable_thinking: false }` field in requests;
|
|
23
|
+
* `openai` / `generic` strip it so any other OpenAI-compatible endpoint (OpenAI, Groq,
|
|
24
|
+
* Together, Fireworks, OpenRouter, self-hosted vLLM) stops rejecting it.
|
|
25
|
+
*/
|
|
26
|
+
llmProvider: 'nebius' | 'openai' | 'generic';
|
|
27
|
+
models: {
|
|
28
|
+
fast: ModelTier;
|
|
29
|
+
mid: ModelTier;
|
|
30
|
+
strong: ModelTier;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
type Env = Record<string, string | undefined>;
|
|
34
|
+
declare function loadConfig(env?: Env): AgentConfig;
|
|
35
|
+
declare function missingLiveKeys(config: AgentConfig): string[];
|
|
36
|
+
|
|
37
|
+
type StepId = 'plan' | 'research' | 'generate' | 'verify' | 'package';
|
|
38
|
+
interface Plan {
|
|
39
|
+
summary: string;
|
|
40
|
+
source: {
|
|
41
|
+
app: string;
|
|
42
|
+
trigger: string;
|
|
43
|
+
docsQuery: string;
|
|
44
|
+
};
|
|
45
|
+
target: {
|
|
46
|
+
app: string;
|
|
47
|
+
action: string;
|
|
48
|
+
docsQuery: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Extra target apps the connector must also call, in the order it will call them.
|
|
52
|
+
* Lets a single run cover chained flows like "Zendesk → GitHub → Zendesk comment"
|
|
53
|
+
* or "HubSpot → Google OAuth refresh → Google Sheets" where more than one external
|
|
54
|
+
* service is reached. Each entry is researched and gets its own endpoints in the spec.
|
|
55
|
+
*/
|
|
56
|
+
additionalTargets?: {
|
|
57
|
+
app: string;
|
|
58
|
+
action: string;
|
|
59
|
+
docsQuery: string;
|
|
60
|
+
}[];
|
|
61
|
+
fieldMapping: {
|
|
62
|
+
from: string;
|
|
63
|
+
to: string;
|
|
64
|
+
note?: string;
|
|
65
|
+
}[];
|
|
66
|
+
assumptions: string[];
|
|
67
|
+
}
|
|
68
|
+
interface AuthSpec {
|
|
69
|
+
type: 'header' | 'bearer' | 'query' | 'basic' | 'none';
|
|
70
|
+
/** Header or query parameter name, e.g. `x-api-token` or `api_token`. */
|
|
71
|
+
name?: string;
|
|
72
|
+
/** Environment variable the generated connector reads the secret from. */
|
|
73
|
+
envVar: string;
|
|
74
|
+
}
|
|
75
|
+
interface EndpointSpec {
|
|
76
|
+
app: string;
|
|
77
|
+
role: 'source' | 'target';
|
|
78
|
+
method: string;
|
|
79
|
+
url: string;
|
|
80
|
+
auth: AuthSpec;
|
|
81
|
+
/** Minimal but realistic example of the request body (target) or event payload (source). */
|
|
82
|
+
example: unknown;
|
|
83
|
+
/** Example of what the endpoint returns, when the connector needs the response. */
|
|
84
|
+
responseExample?: unknown;
|
|
85
|
+
docsUrl: string;
|
|
86
|
+
notes: string[];
|
|
87
|
+
}
|
|
88
|
+
interface ApiSpec {
|
|
89
|
+
source: EndpointSpec;
|
|
90
|
+
target: EndpointSpec[];
|
|
91
|
+
}
|
|
92
|
+
interface Source {
|
|
93
|
+
title: string;
|
|
94
|
+
url: string;
|
|
95
|
+
/** The page is on the vendor's own domain. */
|
|
96
|
+
official?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface GeneratedFile {
|
|
99
|
+
path: string;
|
|
100
|
+
content: string;
|
|
101
|
+
}
|
|
102
|
+
interface TestFailure {
|
|
103
|
+
name: string;
|
|
104
|
+
message: string;
|
|
105
|
+
}
|
|
106
|
+
interface TestReport {
|
|
107
|
+
typecheckOk: boolean;
|
|
108
|
+
typecheckOutput: string;
|
|
109
|
+
passed: number;
|
|
110
|
+
failed: number;
|
|
111
|
+
total: number;
|
|
112
|
+
failures: TestFailure[];
|
|
113
|
+
durationMs: number;
|
|
114
|
+
/** Where the tests ran: a Nebius sandbox operation id, `local`, or `replay`. */
|
|
115
|
+
ranOn: string;
|
|
116
|
+
/** Did the suite run the connector against the documented example payload, and did that pass? */
|
|
117
|
+
contract?: 'passed' | 'failed' | 'missing';
|
|
118
|
+
/** Full names of the tests that passed. */
|
|
119
|
+
passedNames?: string[];
|
|
120
|
+
}
|
|
121
|
+
interface Usage {
|
|
122
|
+
model: string;
|
|
123
|
+
promptTokens: number;
|
|
124
|
+
completionTokens: number;
|
|
125
|
+
costUsd: number;
|
|
126
|
+
}
|
|
127
|
+
type RunEvent = {
|
|
128
|
+
type: 'mode';
|
|
129
|
+
mode: 'live' | 'replay';
|
|
130
|
+
} | {
|
|
131
|
+
type: 'step';
|
|
132
|
+
step: StepId;
|
|
133
|
+
status: 'start' | 'done' | 'error';
|
|
134
|
+
detail?: string;
|
|
135
|
+
} | {
|
|
136
|
+
type: 'log';
|
|
137
|
+
step: StepId;
|
|
138
|
+
message: string;
|
|
139
|
+
} | {
|
|
140
|
+
type: 'plan';
|
|
141
|
+
plan: Plan;
|
|
142
|
+
} | {
|
|
143
|
+
type: 'sources';
|
|
144
|
+
sources: Source[];
|
|
145
|
+
} | {
|
|
146
|
+
type: 'spec';
|
|
147
|
+
spec: ApiSpec;
|
|
148
|
+
} | {
|
|
149
|
+
type: 'files';
|
|
150
|
+
attempt: number;
|
|
151
|
+
files: GeneratedFile[];
|
|
152
|
+
} | {
|
|
153
|
+
type: 'tests';
|
|
154
|
+
attempt: number;
|
|
155
|
+
report: TestReport;
|
|
156
|
+
branches?: Array<{
|
|
157
|
+
branch: number;
|
|
158
|
+
passed: number;
|
|
159
|
+
total: number;
|
|
160
|
+
typecheckOk: boolean;
|
|
161
|
+
green: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'usage';
|
|
165
|
+
usage: Usage[];
|
|
166
|
+
} | {
|
|
167
|
+
type: 'result';
|
|
168
|
+
ok: boolean;
|
|
169
|
+
attempts: number;
|
|
170
|
+
files: GeneratedFile[];
|
|
171
|
+
report: TestReport | null;
|
|
172
|
+
} | {
|
|
173
|
+
type: 'error';
|
|
174
|
+
message: string;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
interface RecordedRun {
|
|
178
|
+
prompt: string;
|
|
179
|
+
/** `fixture` for the bundled example, `live` for runs captured with `npm run agent -- --record`. */
|
|
180
|
+
origin: 'fixture' | 'live';
|
|
181
|
+
events: RunEvent[];
|
|
182
|
+
}
|
|
183
|
+
declare const REPLAY_RUN: RecordedRun;
|
|
184
|
+
/** Streams a recorded run with short pauses so the UI shows the same progression as a live run. */
|
|
185
|
+
declare function replayRun(run?: RecordedRun, pace?: number): AsyncGenerator<RunEvent>;
|
|
186
|
+
|
|
187
|
+
interface ChatMessage {
|
|
188
|
+
role: 'system' | 'user' | 'assistant';
|
|
189
|
+
content: string;
|
|
190
|
+
}
|
|
191
|
+
interface ChatOptions {
|
|
192
|
+
temperature?: number;
|
|
193
|
+
/** Includes reasoning tokens when thinking is on, so leave generous headroom. */
|
|
194
|
+
maxTokens?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Nemotron reasons before answering by default. Structured steps (plan, spec) turn it off:
|
|
197
|
+
* the answer is immediate and the token budget goes to the JSON, not to deliberation.
|
|
198
|
+
*/
|
|
199
|
+
thinking?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface LlmClient {
|
|
202
|
+
chat(model: ModelTier, messages: ChatMessage[], options?: ChatOptions): Promise<string>;
|
|
203
|
+
usage(): Usage[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
interface RepairContext {
|
|
207
|
+
/** 1-based: the attempt we are producing the fix FOR (so the repair output will be verified as this attempt). */
|
|
208
|
+
attempt: number;
|
|
209
|
+
/** The absolute cap; the agent gives up after this many attempts. */
|
|
210
|
+
maxAttempts: number;
|
|
211
|
+
/** Short lines describing what previous attempts tried and still failed on. Chronological. */
|
|
212
|
+
previousAttempts?: Array<{
|
|
213
|
+
attempt: number;
|
|
214
|
+
summary: string;
|
|
215
|
+
}>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
interface SandboxRunner {
|
|
219
|
+
/** Returns an image id that has node, typescript and vitest installed under /work. */
|
|
220
|
+
prepare(log: (message: string) => void): Promise<string>;
|
|
221
|
+
/** Runs typecheck + tests for the given files on a fresh branch of the prepared image. */
|
|
222
|
+
runTests(baseImage: string, files: GeneratedFile[], log: (message: string) => void): Promise<TestReport>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface SearchHit {
|
|
226
|
+
title: string;
|
|
227
|
+
url: string;
|
|
228
|
+
content: string;
|
|
229
|
+
score: number;
|
|
230
|
+
}
|
|
231
|
+
interface ExtractedPage {
|
|
232
|
+
url: string;
|
|
233
|
+
content: string;
|
|
234
|
+
}
|
|
235
|
+
interface SearchClient {
|
|
236
|
+
search(query: string, options?: {
|
|
237
|
+
maxResults?: number;
|
|
238
|
+
includeDomains?: string[];
|
|
239
|
+
}): Promise<SearchHit[]>;
|
|
240
|
+
extract(urls: string[]): Promise<ExtractedPage[]>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface AgentDeps {
|
|
244
|
+
config: AgentConfig;
|
|
245
|
+
llm: LlmClient;
|
|
246
|
+
search: SearchClient;
|
|
247
|
+
sandbox: SandboxRunner;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* plan (fast model) → research (Tavily + mid model) → generate (strong model)
|
|
251
|
+
* → verify in a Nebius sandbox → repair with the failures, up to maxAttempts.
|
|
252
|
+
*/
|
|
253
|
+
declare function runAgent(prompt: string, deps: AgentDeps): AsyncGenerator<RunEvent>;
|
|
254
|
+
/** plan → research only, ends with the spec. No code generation, no sandbox. */
|
|
255
|
+
declare function researchAgent(prompt: string, deps: Omit<AgentDeps, 'sandbox'>): AsyncGenerator<RunEvent>;
|
|
256
|
+
/** verify + repair loop for already-generated files. Uses sandbox + strong model. */
|
|
257
|
+
declare function verifyAgent(files: GeneratedFile[], deps: Omit<AgentDeps, 'search'>): AsyncGenerator<RunEvent>;
|
|
258
|
+
declare function makePlan(prompt: string, llm: LlmClient, config: AgentConfig): Promise<Plan>;
|
|
259
|
+
declare function research(plan: Plan, search: SearchClient, llm: LlmClient, config: AgentConfig, log: (m: string) => void): Promise<{
|
|
260
|
+
spec: ApiSpec;
|
|
261
|
+
sources: Source[];
|
|
262
|
+
}>;
|
|
263
|
+
declare function generate(plan: Plan, spec: ApiSpec, fixtures: string, llm: LlmClient, config: AgentConfig): Promise<GeneratedFile[]>;
|
|
264
|
+
declare function repair(files: GeneratedFile[], report: TestReport, llm: LlmClient, config: AgentConfig, options?: {
|
|
265
|
+
temperature?: number;
|
|
266
|
+
context?: RepairContext;
|
|
267
|
+
}): Promise<GeneratedFile[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Generates up to N repair variants in parallel (different temperatures), verifies all of them
|
|
270
|
+
* in parallel sandbox forks of the same checkpoint, and picks the first green one (or the one
|
|
271
|
+
* with the most passed tests when none is green).
|
|
272
|
+
*/
|
|
273
|
+
declare function repairParallel(files: GeneratedFile[], report: TestReport, deps: {
|
|
274
|
+
llm: LlmClient;
|
|
275
|
+
sandbox: SandboxRunner;
|
|
276
|
+
config: AgentConfig;
|
|
277
|
+
baseImage: string;
|
|
278
|
+
withFixtures: (files: GeneratedFile[]) => GeneratedFile[];
|
|
279
|
+
context?: RepairContext;
|
|
280
|
+
}, log: (m: string) => void): Promise<{
|
|
281
|
+
files: GeneratedFile[];
|
|
282
|
+
report: TestReport;
|
|
283
|
+
branches: Array<{
|
|
284
|
+
branch: number;
|
|
285
|
+
passed: number;
|
|
286
|
+
total: number;
|
|
287
|
+
typecheckOk: boolean;
|
|
288
|
+
green: boolean;
|
|
289
|
+
}>;
|
|
290
|
+
}>;
|
|
291
|
+
|
|
292
|
+
declare function parseTestOutput(stdout: string, ranOn: string): TestReport;
|
|
293
|
+
declare function isGreen(report: TestReport): boolean;
|
|
294
|
+
|
|
295
|
+
/** Live run when keys are configured and mock mode is off, otherwise the recorded replay. */
|
|
296
|
+
declare function startRun(prompt: string, config?: AgentConfig): AsyncGenerator<RunEvent>;
|
|
297
|
+
/** Plan + research only. Live if keys are set; the replay stream truncated after `spec` otherwise. */
|
|
298
|
+
declare function startResearch(prompt: string, config?: AgentConfig): AsyncGenerator<RunEvent>;
|
|
299
|
+
/** Verify + repair for given files. Requires live keys; throws in mock mode. */
|
|
300
|
+
declare function startVerify(files: GeneratedFile[], config?: AgentConfig): AsyncGenerator<RunEvent>;
|
|
301
|
+
|
|
302
|
+
export { type AgentDeps, type ApiSpec, type AuthSpec, type EndpointSpec, type GeneratedFile, type Plan, REPLAY_RUN, type RecordedRun, type RunEvent, type Source, type StepId, type TestFailure, type TestReport, type Usage, generate, isGreen, loadConfig, makePlan, missingLiveKeys, parseTestOutput, repair, repairParallel, replayRun, research, researchAgent, runAgent, startResearch, startRun, startVerify, verifyAgent };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REPLAY_RUN,
|
|
3
|
+
generate,
|
|
4
|
+
isGreen,
|
|
5
|
+
loadConfig,
|
|
6
|
+
makePlan,
|
|
7
|
+
missingLiveKeys,
|
|
8
|
+
parseTestOutput,
|
|
9
|
+
repair,
|
|
10
|
+
repairParallel,
|
|
11
|
+
replayRun,
|
|
12
|
+
research,
|
|
13
|
+
researchAgent,
|
|
14
|
+
runAgent,
|
|
15
|
+
startResearch,
|
|
16
|
+
startRun,
|
|
17
|
+
startVerify,
|
|
18
|
+
verifyAgent
|
|
19
|
+
} from "./chunk-JVXVCXNZ.js";
|
|
20
|
+
export {
|
|
21
|
+
REPLAY_RUN,
|
|
22
|
+
generate,
|
|
23
|
+
isGreen,
|
|
24
|
+
loadConfig,
|
|
25
|
+
makePlan,
|
|
26
|
+
missingLiveKeys,
|
|
27
|
+
parseTestOutput,
|
|
28
|
+
repair,
|
|
29
|
+
repairParallel,
|
|
30
|
+
replayRun,
|
|
31
|
+
research,
|
|
32
|
+
researchAgent,
|
|
33
|
+
runAgent,
|
|
34
|
+
startResearch,
|
|
35
|
+
startRun,
|
|
36
|
+
startVerify,
|
|
37
|
+
verifyAgent
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// src/scanner.ts
|
|
2
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
3
|
+
import { join, relative, extname, basename } from "path";
|
|
4
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", ".next", "out", "build", ".turbo", ".vercel", "coverage"]);
|
|
5
|
+
var SCAN_EXTS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".go", ".rb", ".env", ".example"]);
|
|
6
|
+
var SCAN_MAX_BYTES = 5e5;
|
|
7
|
+
var INTEGRATION_KEYWORDS = /\b(webhook|sync|notify|integrate|forward|post\s+to|send\s+to|push\s+to|pull\s+from|fetch\s+from|subscribe|publish|route\s+to|hook\s+into)\b/i;
|
|
8
|
+
var VENDOR_HINTS = {
|
|
9
|
+
stripe: "Stripe",
|
|
10
|
+
shopify: "Shopify",
|
|
11
|
+
mailchimp: "Mailchimp",
|
|
12
|
+
typeform: "Typeform",
|
|
13
|
+
pipedrive: "Pipedrive",
|
|
14
|
+
hubspot: "HubSpot",
|
|
15
|
+
salesforce: "Salesforce",
|
|
16
|
+
slack: "Slack",
|
|
17
|
+
discord: "Discord",
|
|
18
|
+
notion: "Notion",
|
|
19
|
+
airtable: "Airtable",
|
|
20
|
+
asana: "Asana",
|
|
21
|
+
jira: "Jira",
|
|
22
|
+
linear: "Linear",
|
|
23
|
+
github: "GitHub",
|
|
24
|
+
gitlab: "GitLab",
|
|
25
|
+
zendesk: "Zendesk",
|
|
26
|
+
intercom: "Intercom",
|
|
27
|
+
twilio: "Twilio",
|
|
28
|
+
sendgrid: "SendGrid",
|
|
29
|
+
brevo: "Brevo",
|
|
30
|
+
resend: "Resend",
|
|
31
|
+
postmark: "Postmark",
|
|
32
|
+
mailgun: "Mailgun",
|
|
33
|
+
calendly: "Calendly",
|
|
34
|
+
jotform: "Jotform",
|
|
35
|
+
pusher: "Pusher",
|
|
36
|
+
zoom: "Zoom",
|
|
37
|
+
trello: "Trello",
|
|
38
|
+
freshdesk: "Freshdesk",
|
|
39
|
+
monday: "Monday",
|
|
40
|
+
pipeline: "Pipedrive",
|
|
41
|
+
quickbooks: "QuickBooks",
|
|
42
|
+
xero: "Xero",
|
|
43
|
+
paypal: "PayPal",
|
|
44
|
+
square: "Square"
|
|
45
|
+
};
|
|
46
|
+
var VENDOR_PATTERN = new RegExp(`\\b(${Object.keys(VENDOR_HINTS).join("|")})\\b`, "gi");
|
|
47
|
+
function scanRepo(root) {
|
|
48
|
+
const files = walk(root);
|
|
49
|
+
const opportunities = [];
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
let content;
|
|
52
|
+
try {
|
|
53
|
+
const size = statSync(file).size;
|
|
54
|
+
if (size > SCAN_MAX_BYTES) continue;
|
|
55
|
+
content = readFileSync(file, "utf8");
|
|
56
|
+
} catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const rel = relative(root, file).replace(/\\/g, "/");
|
|
60
|
+
const name = basename(file).toLowerCase();
|
|
61
|
+
const lines = content.split("\n");
|
|
62
|
+
if (name.endsWith(".env") || name.endsWith(".env.example") || name === ".env.example" || name === ".env.sample") {
|
|
63
|
+
opportunities.push(...scanEnvFile(rel, lines));
|
|
64
|
+
}
|
|
65
|
+
opportunities.push(...scanTodos(rel, lines));
|
|
66
|
+
opportunities.push(...scanWebhookHandlers(rel, lines, content));
|
|
67
|
+
opportunities.push(...scanVendorImports(rel, lines));
|
|
68
|
+
}
|
|
69
|
+
return rankAndDedupe(opportunities);
|
|
70
|
+
}
|
|
71
|
+
function walk(dir, out = []) {
|
|
72
|
+
let entries;
|
|
73
|
+
try {
|
|
74
|
+
entries = readdirSync(dir);
|
|
75
|
+
} catch {
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
if (entry.startsWith(".") && !entry.startsWith(".env")) continue;
|
|
80
|
+
if (SKIP_DIRS.has(entry)) continue;
|
|
81
|
+
const full = join(dir, entry);
|
|
82
|
+
let st;
|
|
83
|
+
try {
|
|
84
|
+
st = statSync(full);
|
|
85
|
+
} catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (st.isDirectory()) walk(full, out);
|
|
89
|
+
else if (SCAN_EXTS.has(extname(entry).toLowerCase()) || entry.startsWith(".env")) out.push(full);
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function scanEnvFile(file, lines) {
|
|
94
|
+
const found = [];
|
|
95
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
96
|
+
for (let i = 0; i < lines.length; i++) {
|
|
97
|
+
const line = lines[i];
|
|
98
|
+
const match = line.match(/^([A-Z][A-Z0-9_]+)=/);
|
|
99
|
+
if (!match) continue;
|
|
100
|
+
const key = match[1];
|
|
101
|
+
const vendor = detectVendor(key.toLowerCase());
|
|
102
|
+
if (!vendor) continue;
|
|
103
|
+
const bucket = grouped.get(vendor) ?? { line: i + 1, vars: [] };
|
|
104
|
+
bucket.vars.push(key);
|
|
105
|
+
grouped.set(vendor, bucket);
|
|
106
|
+
}
|
|
107
|
+
for (const [vendor, info] of grouped) {
|
|
108
|
+
const title = VENDOR_HINTS[vendor];
|
|
109
|
+
found.push({
|
|
110
|
+
score: 60 + info.vars.length * 5,
|
|
111
|
+
kind: "env-var",
|
|
112
|
+
file,
|
|
113
|
+
line: info.line,
|
|
114
|
+
evidence: info.vars.join(", "),
|
|
115
|
+
vendors: [title],
|
|
116
|
+
prompt: `When something happens that needs ${title}, call ${title}'s API with the fields configured via ${info.vars.join(" / ")}.`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return found;
|
|
120
|
+
}
|
|
121
|
+
function scanTodos(file, lines) {
|
|
122
|
+
const found = [];
|
|
123
|
+
for (let i = 0; i < lines.length; i++) {
|
|
124
|
+
const line = lines[i];
|
|
125
|
+
const match = line.match(/(?:\/\/|\/\*|#|<!--|\*)\s*(?:TODO|FIXME|XXX|HACK)\b[: ]*(.*)/i);
|
|
126
|
+
if (!match) continue;
|
|
127
|
+
const text = match[1].replace(/\*\/\s*$/, "").trim();
|
|
128
|
+
if (text.length < 15) continue;
|
|
129
|
+
if (!INTEGRATION_KEYWORDS.test(text) && !VENDOR_PATTERN.test(text)) continue;
|
|
130
|
+
const vendors = detectVendors(text);
|
|
131
|
+
found.push({
|
|
132
|
+
score: 50 + vendors.length * 10 + (INTEGRATION_KEYWORDS.test(text) ? 10 : 0),
|
|
133
|
+
kind: "todo",
|
|
134
|
+
file,
|
|
135
|
+
line: i + 1,
|
|
136
|
+
evidence: text.slice(0, 160),
|
|
137
|
+
vendors,
|
|
138
|
+
prompt: text.length < 180 && /^when|^on\b/i.test(text) ? text : promptFromTodo(text, vendors)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return found;
|
|
142
|
+
}
|
|
143
|
+
function scanWebhookHandlers(file, lines, content) {
|
|
144
|
+
const found = [];
|
|
145
|
+
const routeRe = /(?:router|app)\.(?:post|put|patch)\s*\(\s*['"`]([^'"`]*(?:webhook|hook|callback|notify|event)[^'"`]*)['"`]/gi;
|
|
146
|
+
let m;
|
|
147
|
+
while (m = routeRe.exec(content)) {
|
|
148
|
+
const path = m[1];
|
|
149
|
+
const upto = content.slice(0, m.index);
|
|
150
|
+
const lineNo = upto.split("\n").length;
|
|
151
|
+
const windowStart = Math.max(0, lineNo - 1);
|
|
152
|
+
const window = lines.slice(windowStart, Math.min(lines.length, windowStart + 20)).join("\n");
|
|
153
|
+
const stubby = /(TODO|FIXME|not\s+implemented|throw\s+new\s+Error)/i.test(window) || window.replace(/[^{}]/g, "").length < 4;
|
|
154
|
+
if (!stubby) continue;
|
|
155
|
+
const vendors = detectVendors(path + " " + window);
|
|
156
|
+
found.push({
|
|
157
|
+
score: 70 + vendors.length * 10,
|
|
158
|
+
kind: "webhook-handler",
|
|
159
|
+
file,
|
|
160
|
+
line: lineNo,
|
|
161
|
+
evidence: `${path} \u2014 route body is empty / TODO / not-implemented`,
|
|
162
|
+
vendors,
|
|
163
|
+
prompt: vendors.length ? `When a ${vendors[0]} webhook hits ${path}, handle the payload and ${inferAction(vendors)}.` : `When an incoming webhook hits ${path}, verify the signature, parse the payload and forward the result to the configured target.`
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return found;
|
|
167
|
+
}
|
|
168
|
+
function scanVendorImports(file, lines) {
|
|
169
|
+
const found = [];
|
|
170
|
+
for (let i = 0; i < lines.length; i++) {
|
|
171
|
+
const line = lines[i];
|
|
172
|
+
const match = line.match(/(?:from\s+|require\(\s*)['"]([^'"\n]+)['"]/);
|
|
173
|
+
if (!match) continue;
|
|
174
|
+
const spec = match[1];
|
|
175
|
+
if (spec.startsWith(".") || spec.startsWith("/") || spec.startsWith("node:")) continue;
|
|
176
|
+
const vendor = detectVendor(spec.replace(/^@/, "").toLowerCase());
|
|
177
|
+
if (!vendor) continue;
|
|
178
|
+
const vendorUses = (readSafe(file).match(new RegExp(`\\b${vendor}`, "gi")) || []).length;
|
|
179
|
+
if (vendorUses > 6) continue;
|
|
180
|
+
const title = VENDOR_HINTS[vendor];
|
|
181
|
+
found.push({
|
|
182
|
+
score: 40 + (vendorUses < 3 ? 15 : 0),
|
|
183
|
+
kind: "vendor-sdk-import",
|
|
184
|
+
file,
|
|
185
|
+
line: i + 1,
|
|
186
|
+
evidence: `imports '${spec}' but only uses "${vendor}" ${vendorUses}\xD7 in this file`,
|
|
187
|
+
vendors: [title],
|
|
188
|
+
prompt: `Write a ${title} integration \u2014 the ${title} SDK is already a dependency but there's no handler wired up.`
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return found;
|
|
192
|
+
}
|
|
193
|
+
function readSafe(file) {
|
|
194
|
+
try {
|
|
195
|
+
return readFileSync(file, "utf8");
|
|
196
|
+
} catch {
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function detectVendor(text) {
|
|
201
|
+
for (const key of Object.keys(VENDOR_HINTS)) if (text.includes(key)) return key;
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
function detectVendors(text) {
|
|
205
|
+
const set = /* @__PURE__ */ new Set();
|
|
206
|
+
const lower = text.toLowerCase();
|
|
207
|
+
for (const key of Object.keys(VENDOR_HINTS)) if (lower.includes(key)) set.add(VENDOR_HINTS[key]);
|
|
208
|
+
return [...set];
|
|
209
|
+
}
|
|
210
|
+
function promptFromTodo(text, vendors) {
|
|
211
|
+
if (vendors.length >= 2) return `When something happens in ${vendors[0]}, do the matching thing in ${vendors[1]}. (From TODO: "${text.slice(0, 100)}")`;
|
|
212
|
+
if (vendors.length === 1) return `Build the ${vendors[0]} integration this TODO describes: "${text.slice(0, 160)}"`;
|
|
213
|
+
return `Build the integration this TODO describes: "${text.slice(0, 180)}"`;
|
|
214
|
+
}
|
|
215
|
+
function inferAction(vendors) {
|
|
216
|
+
if (vendors.length >= 2) return `forward the result to ${vendors[1]}`;
|
|
217
|
+
return "persist the result and reply 200";
|
|
218
|
+
}
|
|
219
|
+
function rankAndDedupe(opportunities) {
|
|
220
|
+
const map = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const op of opportunities) {
|
|
222
|
+
const key = `${op.file}::${op.kind}::${op.vendors.join(",")}`;
|
|
223
|
+
const existing = map.get(key);
|
|
224
|
+
if (!existing || op.score > existing.score) map.set(key, op);
|
|
225
|
+
}
|
|
226
|
+
return [...map.values()].sort((a, b) => b.score - a.score);
|
|
227
|
+
}
|
|
228
|
+
function formatReport(opportunities, root) {
|
|
229
|
+
if (!opportunities.length) return `No integration opportunities found under ${root}.`;
|
|
230
|
+
const header = `patchbay scan found ${opportunities.length} integration opportunit${opportunities.length === 1 ? "y" : "ies"} under ${root}
|
|
231
|
+
`;
|
|
232
|
+
const body = opportunities.map((op, i) => `#${i + 1} score ${op.score} ${op.kind} ${op.file}:${op.line}
|
|
233
|
+
${op.evidence}
|
|
234
|
+
build: patchbay build "${op.prompt}"`).join("\n\n");
|
|
235
|
+
const footer = `
|
|
236
|
+
|
|
237
|
+
Run one directly:
|
|
238
|
+
patchbay build "${opportunities[0].prompt}"
|
|
239
|
+
Or let patchbay build the top N for you:
|
|
240
|
+
patchbay scan ${root} --build-top=1`;
|
|
241
|
+
return header + "\n" + body + footer;
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
formatReport,
|
|
245
|
+
scanRepo
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=scanner-IPBNTPNM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scanner.ts"],"sourcesContent":["import { readFileSync, readdirSync, statSync } from 'node:fs'\nimport { join, relative, extname, basename } from 'node:path'\n\n/**\n * `patchbay scan <dir>` walks a repository looking for integration opportunities\n * patchbay could build. It reports a prioritised list with a concrete one-sentence\n * prompt per opportunity so the user can go straight to `patchbay build \"...\"`\n * (or `patchbay scan <dir> --build-top=N` for the hands-off path).\n *\n * The scanner is deliberately heuristic — regex + file-structure only, no LLM —\n * so it's instant, free, and the user can audit every signal we flagged.\n */\n\nexport interface Opportunity {\n score: number\n kind: 'todo' | 'env-var' | 'webhook-handler' | 'vendor-sdk-import'\n file: string\n line: number\n evidence: string\n prompt: string\n vendors: string[]\n}\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.next', 'out', 'build', '.turbo', '.vercel', 'coverage'])\nconst SCAN_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.py', '.go', '.rb', '.env', '.example'])\nconst SCAN_MAX_BYTES = 500_000\n\nconst INTEGRATION_KEYWORDS = /\\b(webhook|sync|notify|integrate|forward|post\\s+to|send\\s+to|push\\s+to|pull\\s+from|fetch\\s+from|subscribe|publish|route\\s+to|hook\\s+into)\\b/i\n\n/** Vendor name → canonical title case for the prompt. */\nconst VENDOR_HINTS: Record<string, string> = {\n stripe: 'Stripe', shopify: 'Shopify', mailchimp: 'Mailchimp', typeform: 'Typeform', pipedrive: 'Pipedrive',\n hubspot: 'HubSpot', salesforce: 'Salesforce', slack: 'Slack', discord: 'Discord', notion: 'Notion',\n airtable: 'Airtable', asana: 'Asana', jira: 'Jira', linear: 'Linear', github: 'GitHub', gitlab: 'GitLab',\n zendesk: 'Zendesk', intercom: 'Intercom', twilio: 'Twilio', sendgrid: 'SendGrid', brevo: 'Brevo',\n resend: 'Resend', postmark: 'Postmark', mailgun: 'Mailgun', calendly: 'Calendly', jotform: 'Jotform',\n pusher: 'Pusher', zoom: 'Zoom', trello: 'Trello', freshdesk: 'Freshdesk', monday: 'Monday',\n pipeline: 'Pipedrive', quickbooks: 'QuickBooks', xero: 'Xero', paypal: 'PayPal', square: 'Square',\n}\n\nconst VENDOR_PATTERN = new RegExp(`\\\\b(${Object.keys(VENDOR_HINTS).join('|')})\\\\b`, 'gi')\n\nexport function scanRepo(root: string): Opportunity[] {\n const files = walk(root)\n const opportunities: Opportunity[] = []\n for (const file of files) {\n let content: string\n try {\n const size = statSync(file).size\n if (size > SCAN_MAX_BYTES) continue\n content = readFileSync(file, 'utf8')\n } catch { continue }\n\n const rel = relative(root, file).replace(/\\\\/g, '/')\n const name = basename(file).toLowerCase()\n const lines = content.split('\\n')\n\n if (name.endsWith('.env') || name.endsWith('.env.example') || name === '.env.example' || name === '.env.sample') {\n opportunities.push(...scanEnvFile(rel, lines))\n }\n opportunities.push(...scanTodos(rel, lines))\n opportunities.push(...scanWebhookHandlers(rel, lines, content))\n opportunities.push(...scanVendorImports(rel, lines))\n }\n return rankAndDedupe(opportunities)\n}\n\nfunction walk(dir: string, out: string[] = []): string[] {\n let entries: string[]\n try { entries = readdirSync(dir) } catch { return out }\n for (const entry of entries) {\n if (entry.startsWith('.') && !entry.startsWith('.env')) continue\n if (SKIP_DIRS.has(entry)) continue\n const full = join(dir, entry)\n let st\n try { st = statSync(full) } catch { continue }\n if (st.isDirectory()) walk(full, out)\n else if (SCAN_EXTS.has(extname(entry).toLowerCase()) || entry.startsWith('.env')) out.push(full)\n }\n return out\n}\n\nfunction scanEnvFile(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n const grouped = new Map<string, { line: number; vars: string[] }>()\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/^([A-Z][A-Z0-9_]+)=/)\n if (!match) continue\n const key = match[1]!\n const vendor = detectVendor(key.toLowerCase())\n if (!vendor) continue\n const bucket = grouped.get(vendor) ?? { line: i + 1, vars: [] }\n bucket.vars.push(key)\n grouped.set(vendor, bucket)\n }\n for (const [vendor, info] of grouped) {\n const title = VENDOR_HINTS[vendor]!\n found.push({\n score: 60 + info.vars.length * 5,\n kind: 'env-var',\n file,\n line: info.line,\n evidence: info.vars.join(', '),\n vendors: [title],\n prompt: `When something happens that needs ${title}, call ${title}'s API with the fields configured via ${info.vars.join(' / ')}.`,\n })\n }\n return found\n}\n\nfunction scanTodos(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n // Only inline / block comments, not strings or type literals.\n const match = line.match(/(?:\\/\\/|\\/\\*|#|<!--|\\*)\\s*(?:TODO|FIXME|XXX|HACK)\\b[: ]*(.*)/i)\n if (!match) continue\n const text = match[1]!.replace(/\\*\\/\\s*$/, '').trim()\n if (text.length < 15) continue\n if (!INTEGRATION_KEYWORDS.test(text) && !VENDOR_PATTERN.test(text)) continue\n const vendors = detectVendors(text)\n found.push({\n score: 50 + vendors.length * 10 + (INTEGRATION_KEYWORDS.test(text) ? 10 : 0),\n kind: 'todo',\n file,\n line: i + 1,\n evidence: text.slice(0, 160),\n vendors,\n prompt: text.length < 180 && /^when|^on\\b/i.test(text) ? text : promptFromTodo(text, vendors),\n })\n }\n return found\n}\n\nfunction scanWebhookHandlers(file: string, lines: string[], content: string): Opportunity[] {\n const found: Opportunity[] = []\n // Node/TS: look for Express/Next route handlers that are near-empty or throw.\n const routeRe = /(?:router|app)\\.(?:post|put|patch)\\s*\\(\\s*['\"`]([^'\"`]*(?:webhook|hook|callback|notify|event)[^'\"`]*)['\"`]/gi\n let m: RegExpExecArray | null\n while ((m = routeRe.exec(content))) {\n const path = m[1]!\n const upto = content.slice(0, m.index)\n const lineNo = upto.split('\\n').length\n const windowStart = Math.max(0, lineNo - 1)\n const window = lines.slice(windowStart, Math.min(lines.length, windowStart + 20)).join('\\n')\n const stubby = /(TODO|FIXME|not\\s+implemented|throw\\s+new\\s+Error)/i.test(window) || window.replace(/[^{}]/g, '').length < 4\n if (!stubby) continue\n const vendors = detectVendors(path + ' ' + window)\n found.push({\n score: 70 + vendors.length * 10,\n kind: 'webhook-handler',\n file,\n line: lineNo,\n evidence: `${path} — route body is empty / TODO / not-implemented`,\n vendors,\n prompt: vendors.length\n ? `When a ${vendors[0]} webhook hits ${path}, handle the payload and ${inferAction(vendors)}.`\n : `When an incoming webhook hits ${path}, verify the signature, parse the payload and forward the result to the configured target.`,\n })\n }\n return found\n}\n\nfunction scanVendorImports(file: string, lines: string[]): Opportunity[] {\n const found: Opportunity[] = []\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/(?:from\\s+|require\\(\\s*)['\"]([^'\"\\n]+)['\"]/)\n if (!match) continue\n const spec = match[1]!\n // Only real npm packages: skip relative imports (./x, ../x) and node builtins (node:x).\n if (spec.startsWith('.') || spec.startsWith('/') || spec.startsWith('node:')) continue\n const vendor = detectVendor(spec.replace(/^@/, '').toLowerCase())\n if (!vendor) continue\n // Count how many times the vendor name shows up in the file to tell \"imported-and-used\" from \"imported-but-stubbed\".\n const vendorUses = (readSafe(file).match(new RegExp(`\\\\b${vendor}`, 'gi')) || []).length\n if (vendorUses > 6) continue // actively used; probably not an opportunity\n const title = VENDOR_HINTS[vendor]!\n found.push({\n score: 40 + (vendorUses < 3 ? 15 : 0),\n kind: 'vendor-sdk-import',\n file,\n line: i + 1,\n evidence: `imports '${spec}' but only uses \"${vendor}\" ${vendorUses}× in this file`,\n vendors: [title],\n prompt: `Write a ${title} integration — the ${title} SDK is already a dependency but there's no handler wired up.`,\n })\n }\n return found\n}\n\nfunction readSafe(file: string): string {\n try { return readFileSync(file, 'utf8') } catch { return '' }\n}\n\nfunction detectVendor(text: string): string | null {\n for (const key of Object.keys(VENDOR_HINTS)) if (text.includes(key)) return key\n return null\n}\n\nfunction detectVendors(text: string): string[] {\n const set = new Set<string>()\n const lower = text.toLowerCase()\n for (const key of Object.keys(VENDOR_HINTS)) if (lower.includes(key)) set.add(VENDOR_HINTS[key]!)\n return [...set]\n}\n\nfunction promptFromTodo(text: string, vendors: string[]): string {\n if (vendors.length >= 2) return `When something happens in ${vendors[0]}, do the matching thing in ${vendors[1]}. (From TODO: \"${text.slice(0, 100)}\")`\n if (vendors.length === 1) return `Build the ${vendors[0]} integration this TODO describes: \"${text.slice(0, 160)}\"`\n return `Build the integration this TODO describes: \"${text.slice(0, 180)}\"`\n}\n\nfunction inferAction(vendors: string[]): string {\n if (vendors.length >= 2) return `forward the result to ${vendors[1]}`\n return 'persist the result and reply 200'\n}\n\nfunction rankAndDedupe(opportunities: Opportunity[]): Opportunity[] {\n // Collapse duplicates (same file + same first vendor + same kind) to the highest-scoring.\n const map = new Map<string, Opportunity>()\n for (const op of opportunities) {\n const key = `${op.file}::${op.kind}::${op.vendors.join(',')}`\n const existing = map.get(key)\n if (!existing || op.score > existing.score) map.set(key, op)\n }\n return [...map.values()].sort((a, b) => b.score - a.score)\n}\n\nexport function formatReport(opportunities: Opportunity[], root: string): string {\n if (!opportunities.length) return `No integration opportunities found under ${root}.`\n const header = `patchbay scan found ${opportunities.length} integration opportunit${opportunities.length === 1 ? 'y' : 'ies'} under ${root}\\n`\n const body = opportunities\n .map((op, i) => `#${i + 1} score ${op.score} ${op.kind} ${op.file}:${op.line}\\n ${op.evidence}\\n build: patchbay build \"${op.prompt}\"`)\n .join('\\n\\n')\n const footer = `\\n\\nRun one directly:\\n patchbay build \"${opportunities[0]!.prompt}\"\\nOr let patchbay build the top N for you:\\n patchbay scan ${root} --build-top=1`\n return header + '\\n' + body + footer\n}\n"],"mappings":";AAAA,SAAS,cAAc,aAAa,gBAAgB;AACpD,SAAS,MAAM,UAAU,SAAS,gBAAgB;AAsBlD,IAAM,YAAY,oBAAI,IAAI,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,OAAO,SAAS,UAAU,WAAW,UAAU,CAAC;AACpH,IAAM,YAAY,oBAAI,IAAI,CAAC,OAAO,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO,OAAO,QAAQ,UAAU,CAAC;AACjH,IAAM,iBAAiB;AAEvB,IAAM,uBAAuB;AAG7B,IAAM,eAAuC;AAAA,EAC3C,QAAQ;AAAA,EAAU,SAAS;AAAA,EAAW,WAAW;AAAA,EAAa,UAAU;AAAA,EAAY,WAAW;AAAA,EAC/F,SAAS;AAAA,EAAW,YAAY;AAAA,EAAc,OAAO;AAAA,EAAS,SAAS;AAAA,EAAW,QAAQ;AAAA,EAC1F,UAAU;AAAA,EAAY,OAAO;AAAA,EAAS,MAAM;AAAA,EAAQ,QAAQ;AAAA,EAAU,QAAQ;AAAA,EAAU,QAAQ;AAAA,EAChG,SAAS;AAAA,EAAW,UAAU;AAAA,EAAY,QAAQ;AAAA,EAAU,UAAU;AAAA,EAAY,OAAO;AAAA,EACzF,QAAQ;AAAA,EAAU,UAAU;AAAA,EAAY,SAAS;AAAA,EAAW,UAAU;AAAA,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