@simplr-ai/ai 1.0.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 +21 -0
- package/README.md +120 -0
- package/dist/index.cjs +253 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +195 -0
- package/dist/index.d.ts +195 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/langchain.cjs +237 -0
- package/dist/langchain.cjs.map +1 -0
- package/dist/langchain.d.cts +21 -0
- package/dist/langchain.d.ts +21 -0
- package/dist/langchain.js +210 -0
- package/dist/langchain.js.map +1 -0
- package/dist/openai.cjs +319 -0
- package/dist/openai.cjs.map +1 -0
- package/dist/openai.d.cts +67 -0
- package/dist/openai.d.ts +67 -0
- package/dist/openai.js +290 -0
- package/dist/openai.js.map +1 -0
- package/dist/types-Y9ma4qBT.d.cts +73 -0
- package/dist/types-Y9ma4qBT.d.ts +73 -0
- package/package.json +90 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { S as SimplrAIConfig, C as CheckResult, O as OrderResult, P as PhoneIntelligenceResult, a as PhoneReportResult, b as CheckInput, c as OrderInput, d as PhoneReportInput } from './types-Y9ma4qBT.js';
|
|
3
|
+
export { e as PhoneOutcome, R as RiskLevel } from './types-Y9ma4qBT.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Zod input schemas for each Simplr tool, with rich `.describe()` text so that
|
|
7
|
+
* LLMs call the tools with the right arguments. Each schema corresponds 1:1 to
|
|
8
|
+
* the API request body documented in the Simplr contract.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Input for `simplr_check_identity` → POST /v1/check. */
|
|
12
|
+
declare const checkIdentitySchema: z.ZodObject<{
|
|
13
|
+
email: z.ZodOptional<z.ZodString>;
|
|
14
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
15
|
+
event_type: z.ZodOptional<z.ZodString>;
|
|
16
|
+
event_id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
email?: string | undefined;
|
|
20
|
+
phone?: string | undefined;
|
|
21
|
+
event_type?: string | undefined;
|
|
22
|
+
event_id?: string | undefined;
|
|
23
|
+
metadata?: Record<string, unknown> | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
email?: string | undefined;
|
|
26
|
+
phone?: string | undefined;
|
|
27
|
+
event_type?: string | undefined;
|
|
28
|
+
event_id?: string | undefined;
|
|
29
|
+
metadata?: Record<string, unknown> | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
/** Input for `simplr_score_order` → POST /v1/orders. */
|
|
32
|
+
declare const scoreOrderSchema: z.ZodObject<{
|
|
33
|
+
order_id: z.ZodString;
|
|
34
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
35
|
+
amount: z.ZodNumber;
|
|
36
|
+
currency: z.ZodString;
|
|
37
|
+
fingerprint_hash: z.ZodOptional<z.ZodString>;
|
|
38
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
order_id: string;
|
|
41
|
+
amount: number;
|
|
42
|
+
currency: string;
|
|
43
|
+
metadata?: Record<string, unknown> | undefined;
|
|
44
|
+
external_id?: string | undefined;
|
|
45
|
+
fingerprint_hash?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
order_id: string;
|
|
48
|
+
amount: number;
|
|
49
|
+
currency: string;
|
|
50
|
+
metadata?: Record<string, unknown> | undefined;
|
|
51
|
+
external_id?: string | undefined;
|
|
52
|
+
fingerprint_hash?: string | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
/** Input for `simplr_phone_intelligence` → GET /v1/check/phone/intelligence/{phone}. */
|
|
55
|
+
declare const phoneIntelligenceSchema: z.ZodObject<{
|
|
56
|
+
phone: z.ZodString;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
phone: string;
|
|
59
|
+
}, {
|
|
60
|
+
phone: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** Input for `simplr_report_phone_outcome` → POST /v1/check/phone/report. */
|
|
63
|
+
declare const reportPhoneOutcomeSchema: z.ZodObject<{
|
|
64
|
+
phone: z.ZodString;
|
|
65
|
+
outcome: z.ZodEnum<["fraud", "sim_swap_fraud", "account_takeover", "spam", "bot", "legitimate"]>;
|
|
66
|
+
check_id: z.ZodOptional<z.ZodString>;
|
|
67
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
phone: string;
|
|
71
|
+
outcome: "fraud" | "sim_swap_fraud" | "account_takeover" | "spam" | "bot" | "legitimate";
|
|
72
|
+
metadata?: Record<string, unknown> | undefined;
|
|
73
|
+
check_id?: string | undefined;
|
|
74
|
+
confidence?: number | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
phone: string;
|
|
77
|
+
outcome: "fraud" | "sim_swap_fraud" | "account_takeover" | "spam" | "bot" | "legitimate";
|
|
78
|
+
metadata?: Record<string, unknown> | undefined;
|
|
79
|
+
check_id?: string | undefined;
|
|
80
|
+
confidence?: number | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
type CheckIdentityArgs = z.infer<typeof checkIdentitySchema>;
|
|
83
|
+
type ScoreOrderArgs = z.infer<typeof scoreOrderSchema>;
|
|
84
|
+
type PhoneIntelligenceArgs = z.infer<typeof phoneIntelligenceSchema>;
|
|
85
|
+
type ReportPhoneOutcomeArgs = z.infer<typeof reportPhoneOutcomeSchema>;
|
|
86
|
+
|
|
87
|
+
type schemas_CheckIdentityArgs = CheckIdentityArgs;
|
|
88
|
+
type schemas_PhoneIntelligenceArgs = PhoneIntelligenceArgs;
|
|
89
|
+
type schemas_ReportPhoneOutcomeArgs = ReportPhoneOutcomeArgs;
|
|
90
|
+
type schemas_ScoreOrderArgs = ScoreOrderArgs;
|
|
91
|
+
declare const schemas_checkIdentitySchema: typeof checkIdentitySchema;
|
|
92
|
+
declare const schemas_phoneIntelligenceSchema: typeof phoneIntelligenceSchema;
|
|
93
|
+
declare const schemas_reportPhoneOutcomeSchema: typeof reportPhoneOutcomeSchema;
|
|
94
|
+
declare const schemas_scoreOrderSchema: typeof scoreOrderSchema;
|
|
95
|
+
declare namespace schemas {
|
|
96
|
+
export { type schemas_CheckIdentityArgs as CheckIdentityArgs, type schemas_PhoneIntelligenceArgs as PhoneIntelligenceArgs, type schemas_ReportPhoneOutcomeArgs as ReportPhoneOutcomeArgs, type schemas_ScoreOrderArgs as ScoreOrderArgs, schemas_checkIdentitySchema as checkIdentitySchema, schemas_phoneIntelligenceSchema as phoneIntelligenceSchema, schemas_reportPhoneOutcomeSchema as reportPhoneOutcomeSchema, schemas_scoreOrderSchema as scoreOrderSchema };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Framework-agnostic tool descriptors.
|
|
101
|
+
*
|
|
102
|
+
* Each descriptor is a plain object `{ name, description, inputSchema, execute }`.
|
|
103
|
+
* The same descriptors are wrapped for Vercel AI SDK (`./index`), raw OpenAI
|
|
104
|
+
* function-calling (`./openai`), and LangChain (`./langchain`).
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/** A single framework-agnostic Simplr tool descriptor. */
|
|
108
|
+
interface SimplrToolDescriptor<Args = any, Result = any> {
|
|
109
|
+
/** Stable tool name, e.g. `simplr_check_identity`. */
|
|
110
|
+
name: string;
|
|
111
|
+
/** Agent-facing description (when to use it, what it returns). */
|
|
112
|
+
description: string;
|
|
113
|
+
/** Zod schema for the tool's input arguments. */
|
|
114
|
+
inputSchema: z.ZodType<Args>;
|
|
115
|
+
/** Run the tool against the Simplr API and return the unwrapped result. */
|
|
116
|
+
execute: (args: Args) => Promise<Result>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Build the four Simplr tool descriptors bound to a client. These are pure data
|
|
120
|
+
* + closures — no AI framework is required to use them.
|
|
121
|
+
*/
|
|
122
|
+
declare function createSimplrToolDescriptors(config: SimplrAIConfig): {
|
|
123
|
+
simplr_check_identity: SimplrToolDescriptor<CheckIdentityArgs, CheckResult>;
|
|
124
|
+
simplr_score_order: SimplrToolDescriptor<ScoreOrderArgs, OrderResult>;
|
|
125
|
+
simplr_phone_intelligence: SimplrToolDescriptor<PhoneIntelligenceArgs, PhoneIntelligenceResult>;
|
|
126
|
+
simplr_report_phone_outcome: SimplrToolDescriptor<ReportPhoneOutcomeArgs, PhoneReportResult>;
|
|
127
|
+
};
|
|
128
|
+
/** The set of tool names exposed by this package. */
|
|
129
|
+
type SimplrToolName = "simplr_check_identity" | "simplr_score_order" | "simplr_phone_intelligence" | "simplr_report_phone_outcome";
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Thrown when the Simplr API returns a non-2xx response, or a request fails
|
|
133
|
+
* (network error / timeout — in which case `status` is 0 and `body` is null).
|
|
134
|
+
*
|
|
135
|
+
* Mirrors `SimplrError` from `@simplr-ai/node`.
|
|
136
|
+
*/
|
|
137
|
+
declare class SimplrError extends Error {
|
|
138
|
+
readonly status: number;
|
|
139
|
+
readonly body: unknown;
|
|
140
|
+
constructor(message: string, status: number, body: unknown);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** A minimal Simplr API client exposing only the endpoints these tools need. */
|
|
144
|
+
declare class SimplrClient {
|
|
145
|
+
private readonly cfg;
|
|
146
|
+
constructor(config: SimplrAIConfig);
|
|
147
|
+
/** POST /v1/check — identity/fraud check. */
|
|
148
|
+
check(input: CheckInput): Promise<CheckResult>;
|
|
149
|
+
/** POST /v1/orders — order fraud scoring. */
|
|
150
|
+
scoreOrder(input: OrderInput): Promise<OrderResult>;
|
|
151
|
+
/** GET /v1/check/phone/intelligence/{phone} — stored phone intelligence. */
|
|
152
|
+
phoneIntelligence(phone: string): Promise<PhoneIntelligenceResult>;
|
|
153
|
+
/** POST /v1/check/phone/report — report a real-world phone outcome. */
|
|
154
|
+
reportPhone(input: PhoneReportInput): Promise<PhoneReportResult>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* `@simplr-ai/ai` — main entry.
|
|
159
|
+
*
|
|
160
|
+
* Exposes Simplr's fraud/identity/phone checks as ready-to-use tools for AI
|
|
161
|
+
* agents. The primary integration is the Vercel AI SDK (`ai` package): call
|
|
162
|
+
* `createSimplrTools(config)` to get an object of `tool()` instances you can pass
|
|
163
|
+
* straight into `generateText`/`streamText`.
|
|
164
|
+
*
|
|
165
|
+
* `ai` is an OPTIONAL peer dependency and is imported lazily, so this package
|
|
166
|
+
* builds and tests without it installed. If you call `createSimplrTools` without
|
|
167
|
+
* `ai` present, a clear error tells you to install it (or use
|
|
168
|
+
* `createSimplrToolDescriptors`, which needs no framework).
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
/** The shape of a Vercel AI SDK `tool()` instance (kept loose to avoid a hard dep). */
|
|
172
|
+
type VercelTool = unknown;
|
|
173
|
+
/**
|
|
174
|
+
* Create Vercel AI SDK tools for every Simplr capability, keyed by tool name.
|
|
175
|
+
*
|
|
176
|
+
* ```ts
|
|
177
|
+
* import { generateText } from "ai";
|
|
178
|
+
* import { openai } from "@ai-sdk/openai";
|
|
179
|
+
* import { createSimplrTools } from "@simplr-ai/ai";
|
|
180
|
+
*
|
|
181
|
+
* const tools = createSimplrTools({ apiKey: process.env.SIMPLR_API_KEY! });
|
|
182
|
+
* const { text } = await generateText({
|
|
183
|
+
* model: openai("gpt-4o"),
|
|
184
|
+
* tools,
|
|
185
|
+
* prompt: "Is user@example.com risky to sign up?",
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* Requires the optional peer dependency `ai`. If it isn't installed, this throws
|
|
190
|
+
* with installation guidance — use `createSimplrToolDescriptors` for a
|
|
191
|
+
* framework-free alternative.
|
|
192
|
+
*/
|
|
193
|
+
declare function createSimplrTools(config: SimplrAIConfig): Record<SimplrToolName, VercelTool>;
|
|
194
|
+
|
|
195
|
+
export { CheckInput, CheckResult, OrderInput, OrderResult, PhoneIntelligenceResult, PhoneReportInput, PhoneReportResult, SimplrAIConfig, SimplrClient, SimplrError, type SimplrToolDescriptor, type SimplrToolName, type VercelTool, createSimplrToolDescriptors, createSimplrTools, schemas };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/errors.ts
|
|
14
|
+
var SimplrError = class extends Error {
|
|
15
|
+
status;
|
|
16
|
+
body;
|
|
17
|
+
constructor(message, status, body) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "SimplrError";
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.body = body;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/client.ts
|
|
26
|
+
var DEFAULT_BASE_URL = "https://api.simplr.sh";
|
|
27
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
28
|
+
function resolve(config) {
|
|
29
|
+
if (!config?.apiKey) throw new Error("@simplr-ai/ai: `apiKey` is required");
|
|
30
|
+
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
31
|
+
if (typeof fetchImpl !== "function") {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"@simplr-ai/ai: no global fetch available \u2014 use Node 18+ or pass `fetch` in config"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
apiKey: config.apiKey,
|
|
38
|
+
baseUrl: (config.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, ""),
|
|
39
|
+
timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
40
|
+
fetchImpl
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function apiRequest(cfg, method, path, body) {
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const timer = setTimeout(() => controller.abort(), cfg.timeoutMs);
|
|
46
|
+
try {
|
|
47
|
+
const res = await cfg.fetchImpl(`${cfg.baseUrl}${path}`, {
|
|
48
|
+
method,
|
|
49
|
+
headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
|
|
50
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
51
|
+
signal: controller.signal
|
|
52
|
+
});
|
|
53
|
+
const text = await res.text();
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = text ? JSON.parse(text) : void 0;
|
|
57
|
+
} catch {
|
|
58
|
+
parsed = text;
|
|
59
|
+
}
|
|
60
|
+
if (!res.ok) {
|
|
61
|
+
const message = parsed && (parsed.message || parsed.error) || `Simplr API error ${res.status}`;
|
|
62
|
+
throw new SimplrError(message, res.status, parsed);
|
|
63
|
+
}
|
|
64
|
+
return parsed && typeof parsed === "object" && "content" in parsed ? parsed.content : parsed;
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (err instanceof SimplrError) throw err;
|
|
67
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
68
|
+
throw new SimplrError(`Request to ${path} timed out after ${cfg.timeoutMs}ms`, 0, null);
|
|
69
|
+
}
|
|
70
|
+
throw new SimplrError(err instanceof Error ? err.message : "Network error", 0, null);
|
|
71
|
+
} finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var SimplrClient = class {
|
|
76
|
+
cfg;
|
|
77
|
+
constructor(config) {
|
|
78
|
+
this.cfg = resolve(config);
|
|
79
|
+
}
|
|
80
|
+
/** POST /v1/check — identity/fraud check. */
|
|
81
|
+
check(input) {
|
|
82
|
+
return apiRequest(this.cfg, "POST", "/v1/check", input);
|
|
83
|
+
}
|
|
84
|
+
/** POST /v1/orders — order fraud scoring. */
|
|
85
|
+
scoreOrder(input) {
|
|
86
|
+
return apiRequest(this.cfg, "POST", "/v1/orders", input);
|
|
87
|
+
}
|
|
88
|
+
/** GET /v1/check/phone/intelligence/{phone} — stored phone intelligence. */
|
|
89
|
+
phoneIntelligence(phone) {
|
|
90
|
+
return apiRequest(
|
|
91
|
+
this.cfg,
|
|
92
|
+
"GET",
|
|
93
|
+
`/v1/check/phone/intelligence/${encodeURIComponent(phone)}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
/** POST /v1/check/phone/report — report a real-world phone outcome. */
|
|
97
|
+
reportPhone(input) {
|
|
98
|
+
return apiRequest(this.cfg, "POST", "/v1/check/phone/report", input);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/schemas.ts
|
|
103
|
+
var schemas_exports = {};
|
|
104
|
+
__export(schemas_exports, {
|
|
105
|
+
checkIdentitySchema: () => checkIdentitySchema,
|
|
106
|
+
phoneIntelligenceSchema: () => phoneIntelligenceSchema,
|
|
107
|
+
reportPhoneOutcomeSchema: () => reportPhoneOutcomeSchema,
|
|
108
|
+
scoreOrderSchema: () => scoreOrderSchema
|
|
109
|
+
});
|
|
110
|
+
import { z } from "zod";
|
|
111
|
+
var checkIdentitySchema = z.object({
|
|
112
|
+
email: z.string().email().optional().describe("The user's email address to evaluate (e.g. for signup/login risk)."),
|
|
113
|
+
phone: z.string().optional().describe("The user's phone number in E.164 format (e.g. +14155552671)."),
|
|
114
|
+
event_type: z.string().optional().describe(
|
|
115
|
+
"The lifecycle event being scored, e.g. 'signup', 'login', 'checkout', 'password_reset'. Helps tune the risk model."
|
|
116
|
+
),
|
|
117
|
+
event_id: z.string().optional().describe("Your own idempotency / correlation id for this event, if any."),
|
|
118
|
+
metadata: z.record(z.unknown()).optional().describe(
|
|
119
|
+
"Arbitrary extra context about the event (e.g. { ip: '1.2.3.4', user_id: 'u_123' }). Free-form key/value object."
|
|
120
|
+
)
|
|
121
|
+
}).describe(
|
|
122
|
+
"Provide at least one of `email` or `phone`. Returns a fraud/identity risk assessment for the given user or event."
|
|
123
|
+
);
|
|
124
|
+
var scoreOrderSchema = z.object({
|
|
125
|
+
order_id: z.string().describe("Your unique identifier for this order."),
|
|
126
|
+
external_id: z.string().optional().describe("An optional secondary id (e.g. your payment-processor reference)."),
|
|
127
|
+
amount: z.number().describe("The order total as a number in the order's currency (e.g. 129.99)."),
|
|
128
|
+
currency: z.string().describe("ISO 4217 currency code, e.g. 'USD', 'EUR', 'GBP'."),
|
|
129
|
+
fingerprint_hash: z.string().optional().describe(
|
|
130
|
+
"Device fingerprint hash from a prior identity check, if available, to link the order to a device."
|
|
131
|
+
),
|
|
132
|
+
metadata: z.record(z.unknown()).optional().describe("Arbitrary extra order context (items, shipping, customer id, etc.).")
|
|
133
|
+
}).describe(
|
|
134
|
+
"Score a placed order for payment/transaction fraud risk. Returns a risk_score and risk_level for the order."
|
|
135
|
+
);
|
|
136
|
+
var phoneIntelligenceSchema = z.object({
|
|
137
|
+
phone: z.string().describe(
|
|
138
|
+
"The phone number to look up, in E.164 format (e.g. +14155552671). It will be URL-encoded."
|
|
139
|
+
)
|
|
140
|
+
}).describe(
|
|
141
|
+
"Fetch stored risk intelligence for a phone number (carrier, line type, SIM-swap signals, prior outcomes). Read-only, no side effects."
|
|
142
|
+
);
|
|
143
|
+
var reportPhoneOutcomeSchema = z.object({
|
|
144
|
+
phone: z.string().describe("The phone number the outcome applies to, in E.164 format."),
|
|
145
|
+
outcome: z.enum([
|
|
146
|
+
"fraud",
|
|
147
|
+
"sim_swap_fraud",
|
|
148
|
+
"account_takeover",
|
|
149
|
+
"spam",
|
|
150
|
+
"bot",
|
|
151
|
+
"legitimate"
|
|
152
|
+
]).describe(
|
|
153
|
+
"The confirmed real-world outcome for this phone: 'legitimate' (good actor), 'fraud', 'sim_swap_fraud', 'account_takeover', 'spam', or 'bot'."
|
|
154
|
+
),
|
|
155
|
+
check_id: z.string().optional().describe("The id of the original check this outcome relates to, if known."),
|
|
156
|
+
confidence: z.number().min(0).max(1).optional().describe("Your confidence in the reported outcome, 0.0\u20131.0."),
|
|
157
|
+
metadata: z.record(z.unknown()).optional().describe("Arbitrary extra context about how the outcome was determined.")
|
|
158
|
+
}).describe(
|
|
159
|
+
"Report a confirmed real-world outcome for a phone number back to Simplr. This is a feedback/training signal that improves future scoring \u2014 only call it once you actually know the outcome."
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
// src/tools.ts
|
|
163
|
+
var RISK_LEVEL_DOC = "The result includes `risk_score` (0\u2013100, higher = riskier) and `risk_level` (one of 'low', 'medium', 'high', 'critical').";
|
|
164
|
+
function createSimplrToolDescriptors(config) {
|
|
165
|
+
const client = new SimplrClient(config);
|
|
166
|
+
return {
|
|
167
|
+
simplr_check_identity: {
|
|
168
|
+
name: "simplr_check_identity",
|
|
169
|
+
description: "Assess the fraud/identity risk of a user or event using their email and/or phone. Use this for signups, logins, password resets, or any moment you need to decide whether to trust, challenge (e.g. step-up auth), or block a user. " + RISK_LEVEL_DOC,
|
|
170
|
+
inputSchema: checkIdentitySchema,
|
|
171
|
+
execute: (args) => client.check(args)
|
|
172
|
+
},
|
|
173
|
+
simplr_score_order: {
|
|
174
|
+
name: "simplr_score_order",
|
|
175
|
+
description: "Score a placed order/transaction for payment fraud risk given its amount, currency, and ids. Use this at checkout or post-purchase review to decide whether to approve, hold for manual review, or reject an order. " + RISK_LEVEL_DOC,
|
|
176
|
+
inputSchema: scoreOrderSchema,
|
|
177
|
+
execute: (args) => client.scoreOrder(args)
|
|
178
|
+
},
|
|
179
|
+
simplr_phone_intelligence: {
|
|
180
|
+
name: "simplr_phone_intelligence",
|
|
181
|
+
description: "Look up stored risk intelligence for a phone number (carrier, line type, SIM-swap and prior-outcome signals). Read-only with no side effects \u2014 safe to call whenever you need context about a phone number before deciding.",
|
|
182
|
+
inputSchema: phoneIntelligenceSchema,
|
|
183
|
+
execute: (args) => client.phoneIntelligence(args.phone)
|
|
184
|
+
},
|
|
185
|
+
simplr_report_phone_outcome: {
|
|
186
|
+
name: "simplr_report_phone_outcome",
|
|
187
|
+
description: "Report a confirmed real-world outcome for a phone number (e.g. 'fraud', 'sim_swap_fraud', 'legitimate') back to Simplr. This is a feedback/training signal that improves future scoring. Only call it once you actually KNOW the outcome \u2014 do not guess.",
|
|
188
|
+
inputSchema: reportPhoneOutcomeSchema,
|
|
189
|
+
execute: (args) => client.reportPhone(args)
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/index.ts
|
|
195
|
+
function createSimplrTools(config) {
|
|
196
|
+
let tool;
|
|
197
|
+
try {
|
|
198
|
+
const mod = loadAi();
|
|
199
|
+
tool = mod.tool;
|
|
200
|
+
if (typeof tool !== "function") {
|
|
201
|
+
throw new Error("`ai` is installed but does not export `tool`.");
|
|
202
|
+
}
|
|
203
|
+
} catch (err) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
"@simplr-ai/ai: createSimplrTools() requires the Vercel AI SDK. Install it with `npm install ai`, or use createSimplrToolDescriptors() for a framework-agnostic alternative. (Original error: " + (err instanceof Error ? err.message : String(err)) + ")"
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const descriptors = createSimplrToolDescriptors(config);
|
|
209
|
+
const out = {};
|
|
210
|
+
for (const key of Object.keys(descriptors)) {
|
|
211
|
+
const d = descriptors[key];
|
|
212
|
+
out[key] = tool({
|
|
213
|
+
description: d.description,
|
|
214
|
+
// The AI SDK reads either `inputSchema` (v4+) or `parameters` (v3); we set
|
|
215
|
+
// both to the zod schema so it works across versions.
|
|
216
|
+
inputSchema: d.inputSchema,
|
|
217
|
+
parameters: d.inputSchema,
|
|
218
|
+
execute: (args) => d.execute(args)
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
function loadAi() {
|
|
224
|
+
const specifier = "ai";
|
|
225
|
+
return __require(specifier);
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
SimplrClient,
|
|
229
|
+
SimplrError,
|
|
230
|
+
createSimplrToolDescriptors,
|
|
231
|
+
createSimplrTools,
|
|
232
|
+
schemas_exports as schemas
|
|
233
|
+
};
|
|
234
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/schemas.ts","../src/tools.ts","../src/index.ts"],"sourcesContent":["/**\n * Thrown when the Simplr API returns a non-2xx response, or a request fails\n * (network error / timeout — in which case `status` is 0 and `body` is null).\n *\n * Mirrors `SimplrError` from `@simplr-ai/node`.\n */\nexport class SimplrError extends Error {\n readonly status: number;\n readonly body: unknown;\n\n constructor(message: string, status: number, body: unknown) {\n super(message);\n this.name = \"SimplrError\";\n this.status = status;\n this.body = body;\n }\n}\n","/**\n * Thin internal HTTP client.\n *\n * This mirrors the minimal request layer of `@simplr-ai/node` (`apiRequest` +\n * the check / orders / phone endpoints) so this package has **no unbuilt\n * workspace dependency** and tests can run fully offline. If you need the full\n * SDK (bulk, edge, flags, webhooks) use `@simplr-ai/node` directly.\n */\nimport { SimplrError } from \"./errors.js\";\nimport type {\n CheckInput,\n CheckResult,\n OrderInput,\n OrderResult,\n PhoneIntelligenceResult,\n PhoneReportInput,\n PhoneReportResult,\n SimplrAIConfig,\n} from \"./types.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.simplr.sh\";\nconst DEFAULT_TIMEOUT_MS = 15000;\n\ninterface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n timeoutMs: number;\n fetchImpl: typeof fetch;\n}\n\nfunction resolve(config: SimplrAIConfig): ResolvedConfig {\n if (!config?.apiKey) throw new Error(\"@simplr-ai/ai: `apiKey` is required\");\n const fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new Error(\n \"@simplr-ai/ai: no global fetch available — use Node 18+ or pass `fetch` in config\",\n );\n }\n return {\n apiKey: config.apiKey,\n baseUrl: (config.baseUrl || DEFAULT_BASE_URL).replace(/\\/+$/, \"\"),\n timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n fetchImpl,\n };\n}\n\n/**\n * Internal request helper. Sends `X-API-Key`, applies a timeout, and unwraps the\n * API's `{ success, message, content }` envelope (returning `content`).\n */\nasync function apiRequest<T>(\n cfg: ResolvedConfig,\n method: \"GET\" | \"POST\",\n path: string,\n body?: unknown,\n): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), cfg.timeoutMs);\n try {\n const res = await cfg.fetchImpl(`${cfg.baseUrl}${path}`, {\n method,\n headers: { \"Content-Type\": \"application/json\", \"X-API-Key\": cfg.apiKey },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n const text = await res.text();\n let parsed: any;\n try {\n parsed = text ? JSON.parse(text) : undefined;\n } catch {\n parsed = text;\n }\n\n if (!res.ok) {\n const message =\n (parsed && (parsed.message || parsed.error)) || `Simplr API error ${res.status}`;\n throw new SimplrError(message, res.status, parsed);\n }\n\n return (parsed && typeof parsed === \"object\" && \"content\" in parsed\n ? parsed.content\n : parsed) as T;\n } catch (err) {\n if (err instanceof SimplrError) throw err;\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new SimplrError(`Request to ${path} timed out after ${cfg.timeoutMs}ms`, 0, null);\n }\n throw new SimplrError(err instanceof Error ? err.message : \"Network error\", 0, null);\n } finally {\n clearTimeout(timer);\n }\n}\n\n/** A minimal Simplr API client exposing only the endpoints these tools need. */\nexport class SimplrClient {\n private readonly cfg: ResolvedConfig;\n\n constructor(config: SimplrAIConfig) {\n this.cfg = resolve(config);\n }\n\n /** POST /v1/check — identity/fraud check. */\n check(input: CheckInput): Promise<CheckResult> {\n return apiRequest(this.cfg, \"POST\", \"/v1/check\", input);\n }\n\n /** POST /v1/orders — order fraud scoring. */\n scoreOrder(input: OrderInput): Promise<OrderResult> {\n return apiRequest(this.cfg, \"POST\", \"/v1/orders\", input);\n }\n\n /** GET /v1/check/phone/intelligence/{phone} — stored phone intelligence. */\n phoneIntelligence(phone: string): Promise<PhoneIntelligenceResult> {\n return apiRequest(\n this.cfg,\n \"GET\",\n `/v1/check/phone/intelligence/${encodeURIComponent(phone)}`,\n );\n }\n\n /** POST /v1/check/phone/report — report a real-world phone outcome. */\n reportPhone(input: PhoneReportInput): Promise<PhoneReportResult> {\n return apiRequest(this.cfg, \"POST\", \"/v1/check/phone/report\", input);\n }\n}\n","/**\n * Zod input schemas for each Simplr tool, with rich `.describe()` text so that\n * LLMs call the tools with the right arguments. Each schema corresponds 1:1 to\n * the API request body documented in the Simplr contract.\n */\nimport { z } from \"zod\";\n\n/** Input for `simplr_check_identity` → POST /v1/check. */\nexport const checkIdentitySchema = z\n .object({\n email: z\n .string()\n .email()\n .optional()\n .describe(\"The user's email address to evaluate (e.g. for signup/login risk).\"),\n phone: z\n .string()\n .optional()\n .describe(\"The user's phone number in E.164 format (e.g. +14155552671).\"),\n event_type: z\n .string()\n .optional()\n .describe(\n \"The lifecycle event being scored, e.g. 'signup', 'login', 'checkout', 'password_reset'. Helps tune the risk model.\",\n ),\n event_id: z\n .string()\n .optional()\n .describe(\"Your own idempotency / correlation id for this event, if any.\"),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe(\n \"Arbitrary extra context about the event (e.g. { ip: '1.2.3.4', user_id: 'u_123' }). Free-form key/value object.\",\n ),\n })\n .describe(\n \"Provide at least one of `email` or `phone`. Returns a fraud/identity risk assessment for the given user or event.\",\n );\n\n/** Input for `simplr_score_order` → POST /v1/orders. */\nexport const scoreOrderSchema = z\n .object({\n order_id: z\n .string()\n .describe(\"Your unique identifier for this order.\"),\n external_id: z\n .string()\n .optional()\n .describe(\"An optional secondary id (e.g. your payment-processor reference).\"),\n amount: z\n .number()\n .describe(\"The order total as a number in the order's currency (e.g. 129.99).\"),\n currency: z\n .string()\n .describe(\"ISO 4217 currency code, e.g. 'USD', 'EUR', 'GBP'.\"),\n fingerprint_hash: z\n .string()\n .optional()\n .describe(\n \"Device fingerprint hash from a prior identity check, if available, to link the order to a device.\",\n ),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe(\"Arbitrary extra order context (items, shipping, customer id, etc.).\"),\n })\n .describe(\n \"Score a placed order for payment/transaction fraud risk. Returns a risk_score and risk_level for the order.\",\n );\n\n/** Input for `simplr_phone_intelligence` → GET /v1/check/phone/intelligence/{phone}. */\nexport const phoneIntelligenceSchema = z\n .object({\n phone: z\n .string()\n .describe(\n \"The phone number to look up, in E.164 format (e.g. +14155552671). It will be URL-encoded.\",\n ),\n })\n .describe(\n \"Fetch stored risk intelligence for a phone number (carrier, line type, SIM-swap signals, prior outcomes). Read-only, no side effects.\",\n );\n\n/** Input for `simplr_report_phone_outcome` → POST /v1/check/phone/report. */\nexport const reportPhoneOutcomeSchema = z\n .object({\n phone: z\n .string()\n .describe(\"The phone number the outcome applies to, in E.164 format.\"),\n outcome: z\n .enum([\n \"fraud\",\n \"sim_swap_fraud\",\n \"account_takeover\",\n \"spam\",\n \"bot\",\n \"legitimate\",\n ])\n .describe(\n \"The confirmed real-world outcome for this phone: 'legitimate' (good actor), 'fraud', 'sim_swap_fraud', 'account_takeover', 'spam', or 'bot'.\",\n ),\n check_id: z\n .string()\n .optional()\n .describe(\"The id of the original check this outcome relates to, if known.\"),\n confidence: z\n .number()\n .min(0)\n .max(1)\n .optional()\n .describe(\"Your confidence in the reported outcome, 0.0–1.0.\"),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe(\"Arbitrary extra context about how the outcome was determined.\"),\n })\n .describe(\n \"Report a confirmed real-world outcome for a phone number back to Simplr. This is a feedback/training signal that improves future scoring — only call it once you actually know the outcome.\",\n );\n\nexport type CheckIdentityArgs = z.infer<typeof checkIdentitySchema>;\nexport type ScoreOrderArgs = z.infer<typeof scoreOrderSchema>;\nexport type PhoneIntelligenceArgs = z.infer<typeof phoneIntelligenceSchema>;\nexport type ReportPhoneOutcomeArgs = z.infer<typeof reportPhoneOutcomeSchema>;\n","/**\n * Framework-agnostic tool descriptors.\n *\n * Each descriptor is a plain object `{ name, description, inputSchema, execute }`.\n * The same descriptors are wrapped for Vercel AI SDK (`./index`), raw OpenAI\n * function-calling (`./openai`), and LangChain (`./langchain`).\n */\nimport type { z } from \"zod\";\nimport { SimplrClient } from \"./client.js\";\nimport {\n checkIdentitySchema,\n phoneIntelligenceSchema,\n reportPhoneOutcomeSchema,\n scoreOrderSchema,\n type CheckIdentityArgs,\n type PhoneIntelligenceArgs,\n type ReportPhoneOutcomeArgs,\n type ScoreOrderArgs,\n} from \"./schemas.js\";\nimport type {\n CheckResult,\n OrderResult,\n PhoneIntelligenceResult,\n PhoneReportResult,\n SimplrAIConfig,\n} from \"./types.js\";\n\n/** A single framework-agnostic Simplr tool descriptor. */\nexport interface SimplrToolDescriptor<Args = any, Result = any> {\n /** Stable tool name, e.g. `simplr_check_identity`. */\n name: string;\n /** Agent-facing description (when to use it, what it returns). */\n description: string;\n /** Zod schema for the tool's input arguments. */\n inputSchema: z.ZodType<Args>;\n /** Run the tool against the Simplr API and return the unwrapped result. */\n execute: (args: Args) => Promise<Result>;\n}\n\nconst RISK_LEVEL_DOC =\n \"The result includes `risk_score` (0–100, higher = riskier) and `risk_level` (one of 'low', 'medium', 'high', 'critical').\";\n\n/**\n * Build the four Simplr tool descriptors bound to a client. These are pure data\n * + closures — no AI framework is required to use them.\n */\nexport function createSimplrToolDescriptors(\n config: SimplrAIConfig,\n): {\n simplr_check_identity: SimplrToolDescriptor<CheckIdentityArgs, CheckResult>;\n simplr_score_order: SimplrToolDescriptor<ScoreOrderArgs, OrderResult>;\n simplr_phone_intelligence: SimplrToolDescriptor<\n PhoneIntelligenceArgs,\n PhoneIntelligenceResult\n >;\n simplr_report_phone_outcome: SimplrToolDescriptor<\n ReportPhoneOutcomeArgs,\n PhoneReportResult\n >;\n} {\n const client = new SimplrClient(config);\n\n return {\n simplr_check_identity: {\n name: \"simplr_check_identity\",\n description:\n \"Assess the fraud/identity risk of a user or event using their email and/or phone. \" +\n \"Use this for signups, logins, password resets, or any moment you need to decide whether to \" +\n \"trust, challenge (e.g. step-up auth), or block a user. \" +\n RISK_LEVEL_DOC,\n inputSchema: checkIdentitySchema,\n execute: (args) => client.check(args),\n },\n\n simplr_score_order: {\n name: \"simplr_score_order\",\n description:\n \"Score a placed order/transaction for payment fraud risk given its amount, currency, and ids. \" +\n \"Use this at checkout or post-purchase review to decide whether to approve, hold for manual review, or reject an order. \" +\n RISK_LEVEL_DOC,\n inputSchema: scoreOrderSchema,\n execute: (args) => client.scoreOrder(args),\n },\n\n simplr_phone_intelligence: {\n name: \"simplr_phone_intelligence\",\n description:\n \"Look up stored risk intelligence for a phone number (carrier, line type, SIM-swap and prior-outcome signals). \" +\n \"Read-only with no side effects — safe to call whenever you need context about a phone number before deciding.\",\n inputSchema: phoneIntelligenceSchema,\n execute: (args) => client.phoneIntelligence(args.phone),\n },\n\n simplr_report_phone_outcome: {\n name: \"simplr_report_phone_outcome\",\n description:\n \"Report a confirmed real-world outcome for a phone number (e.g. 'fraud', 'sim_swap_fraud', 'legitimate') back to Simplr. \" +\n \"This is a feedback/training signal that improves future scoring. Only call it once you actually KNOW the outcome — \" +\n \"do not guess.\",\n inputSchema: reportPhoneOutcomeSchema,\n execute: (args) => client.reportPhone(args),\n },\n };\n}\n\n/** The set of tool names exposed by this package. */\nexport type SimplrToolName =\n | \"simplr_check_identity\"\n | \"simplr_score_order\"\n | \"simplr_phone_intelligence\"\n | \"simplr_report_phone_outcome\";\n","/**\n * `@simplr-ai/ai` — main entry.\n *\n * Exposes Simplr's fraud/identity/phone checks as ready-to-use tools for AI\n * agents. The primary integration is the Vercel AI SDK (`ai` package): call\n * `createSimplrTools(config)` to get an object of `tool()` instances you can pass\n * straight into `generateText`/`streamText`.\n *\n * `ai` is an OPTIONAL peer dependency and is imported lazily, so this package\n * builds and tests without it installed. If you call `createSimplrTools` without\n * `ai` present, a clear error tells you to install it (or use\n * `createSimplrToolDescriptors`, which needs no framework).\n */\nimport {\n createSimplrToolDescriptors,\n type SimplrToolDescriptor,\n type SimplrToolName,\n} from \"./tools.js\";\nimport type { SimplrAIConfig } from \"./types.js\";\n\nexport { SimplrError } from \"./errors.js\";\nexport * from \"./types.js\";\nexport {\n createSimplrToolDescriptors,\n type SimplrToolDescriptor,\n type SimplrToolName,\n} from \"./tools.js\";\nexport * as schemas from \"./schemas.js\";\nexport { SimplrClient } from \"./client.js\";\n\n/** The shape of a Vercel AI SDK `tool()` instance (kept loose to avoid a hard dep). */\nexport type VercelTool = unknown;\n\n/**\n * Create Vercel AI SDK tools for every Simplr capability, keyed by tool name.\n *\n * ```ts\n * import { generateText } from \"ai\";\n * import { openai } from \"@ai-sdk/openai\";\n * import { createSimplrTools } from \"@simplr-ai/ai\";\n *\n * const tools = createSimplrTools({ apiKey: process.env.SIMPLR_API_KEY! });\n * const { text } = await generateText({\n * model: openai(\"gpt-4o\"),\n * tools,\n * prompt: \"Is user@example.com risky to sign up?\",\n * });\n * ```\n *\n * Requires the optional peer dependency `ai`. If it isn't installed, this throws\n * with installation guidance — use `createSimplrToolDescriptors` for a\n * framework-free alternative.\n */\nexport function createSimplrTools(\n config: SimplrAIConfig,\n): Record<SimplrToolName, VercelTool> {\n let tool: (spec: any) => unknown;\n try {\n // Lazy, synchronous resolution so absence of `ai` is a clear error and the\n // return type stays simple (no Promise). `require` works under both CJS and\n // tsup's interop; in pure ESM environments where `ai` is installed this is\n // resolvable too.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = loadAi();\n tool = mod.tool;\n if (typeof tool !== \"function\") {\n throw new Error(\"`ai` is installed but does not export `tool`.\");\n }\n } catch (err) {\n throw new Error(\n \"@simplr-ai/ai: createSimplrTools() requires the Vercel AI SDK. \" +\n \"Install it with `npm install ai`, or use createSimplrToolDescriptors() \" +\n \"for a framework-agnostic alternative. (Original error: \" +\n (err instanceof Error ? err.message : String(err)) +\n \")\",\n );\n }\n\n const descriptors = createSimplrToolDescriptors(config);\n const out = {} as Record<SimplrToolName, VercelTool>;\n for (const key of Object.keys(descriptors) as SimplrToolName[]) {\n const d = descriptors[key] as SimplrToolDescriptor;\n out[key] = tool({\n description: d.description,\n // The AI SDK reads either `inputSchema` (v4+) or `parameters` (v3); we set\n // both to the zod schema so it works across versions.\n inputSchema: d.inputSchema,\n parameters: d.inputSchema,\n execute: (args: unknown) => d.execute(args as any),\n });\n }\n return out;\n}\n\n/** Resolve the optional `ai` peer dependency synchronously via `require`. */\nfunction loadAi(): { tool: (spec: any) => unknown } {\n // In CJS output `require` exists directly. In ESM output tsup injects a\n // `require` shim (via createRequire) when `require` is referenced, so this\n // works under both module systems without bundling `ai` itself.\n const specifier = \"ai\";\n return (require as NodeRequire)(specifier);\n}\n"],"mappings":";;;;;;;;;;;;;AAMO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAC5B;AAAA,EACA;AAAA,EAET,YAAY,SAAiB,QAAgB,MAAe;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;;;ACIA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAS3B,SAAS,QAAQ,QAAwC;AACvD,MAAI,CAAC,QAAQ,OAAQ,OAAM,IAAI,MAAM,qCAAqC;AAC1E,QAAM,YAAY,OAAO,SAAS,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