patchwork-os 0.2.0-beta.10.canary.99 → 0.2.0-beta.11
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 +20 -1
- package/dist/adapters/grok.js +6 -1
- package/dist/adapters/grok.js.map +1 -1
- package/dist/approvalHttp.js +61 -66
- package/dist/approvalHttp.js.map +1 -1
- package/dist/bridge.js +3 -2
- package/dist/bridge.js.map +1 -1
- package/dist/claudeOrchestrator.js +15 -0
- package/dist/claudeOrchestrator.js.map +1 -1
- package/dist/commands/patchworkInit.d.ts +7 -0
- package/dist/commands/patchworkInit.js +26 -0
- package/dist/commands/patchworkInit.js.map +1 -1
- package/dist/commands/recipe.d.ts +14 -0
- package/dist/commands/recipe.js +51 -0
- package/dist/commands/recipe.js.map +1 -1
- package/dist/commands/recipeInstall.js +15 -0
- package/dist/commands/recipeInstall.js.map +1 -1
- package/dist/connectors/postgres.d.ts +7 -0
- package/dist/connectors/postgres.js +16 -2
- package/dist/connectors/postgres.js.map +1 -1
- package/dist/connectors/snowflake.js +6 -0
- package/dist/connectors/snowflake.js.map +1 -1
- package/dist/connectors/tokenStorage.d.ts +8 -0
- package/dist/connectors/tokenStorage.js +42 -3
- package/dist/connectors/tokenStorage.js.map +1 -1
- package/dist/drivers/claude/api.js +15 -2
- package/dist/drivers/claude/api.js.map +1 -1
- package/dist/drivers/claude/subprocess.js +1 -29
- package/dist/drivers/claude/subprocess.js.map +1 -1
- package/dist/drivers/gemini/index.js +9 -5
- package/dist/drivers/gemini/index.js.map +1 -1
- package/dist/drivers/openai/index.js +29 -4
- package/dist/drivers/openai/index.js.map +1 -1
- package/dist/drivers/outputCap.d.ts +27 -0
- package/dist/drivers/outputCap.js +50 -0
- package/dist/drivers/outputCap.js.map +1 -0
- package/dist/featureFlags.d.ts +9 -0
- package/dist/featureFlags.js +16 -0
- package/dist/featureFlags.js.map +1 -1
- package/dist/fp/commandDescription.d.ts +6 -0
- package/dist/fp/commandDescription.js +4 -4
- package/dist/fp/commandDescription.js.map +1 -1
- package/dist/fp/policyParser.js +13 -7
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/haltPushDispatch.js +7 -22
- package/dist/haltPushDispatch.js.map +1 -1
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -1
- package/dist/mcpRoutes.js +1 -1
- package/dist/mcpRoutes.js.map +1 -1
- package/dist/oauth.d.ts +13 -0
- package/dist/oauth.js +34 -1
- package/dist/oauth.js.map +1 -1
- package/dist/recipeOrchestration.js +10 -0
- package/dist/recipeOrchestration.js.map +1 -1
- package/dist/recipeRoutes.d.ts +39 -0
- package/dist/recipeRoutes.js +214 -12
- package/dist/recipeRoutes.js.map +1 -1
- package/dist/recipes/agentExecutor.d.ts +20 -0
- package/dist/recipes/agentExecutor.js +32 -10
- package/dist/recipes/agentExecutor.js.map +1 -1
- package/dist/recipes/chainedRunner.d.ts +41 -2
- package/dist/recipes/chainedRunner.js +134 -6
- package/dist/recipes/chainedRunner.js.map +1 -1
- package/dist/recipes/connectorPreflight.js +30 -0
- package/dist/recipes/connectorPreflight.js.map +1 -1
- package/dist/recipes/haltCategory.d.ts +5 -0
- package/dist/recipes/haltCategory.js +7 -1
- package/dist/recipes/haltCategory.js.map +1 -1
- package/dist/recipes/judgeVerdict.d.ts +10 -0
- package/dist/recipes/judgeVerdict.js +10 -0
- package/dist/recipes/judgeVerdict.js.map +1 -1
- package/dist/recipes/names.d.ts +5 -0
- package/dist/recipes/names.js +10 -5
- package/dist/recipes/names.js.map +1 -1
- package/dist/recipes/parser.js +32 -9
- package/dist/recipes/parser.js.map +1 -1
- package/dist/recipes/pricing/costRouter.d.ts +43 -0
- package/dist/recipes/pricing/costRouter.js +44 -0
- package/dist/recipes/pricing/costRouter.js.map +1 -0
- package/dist/recipes/pricing/priceTable.d.ts +76 -0
- package/dist/recipes/pricing/priceTable.js +144 -0
- package/dist/recipes/pricing/priceTable.js.map +1 -0
- package/dist/recipes/runBudget.d.ts +82 -32
- package/dist/recipes/runBudget.js +182 -49
- package/dist/recipes/runBudget.js.map +1 -1
- package/dist/recipes/schema.d.ts +25 -4
- package/dist/recipes/schemaGenerator.d.ts +9 -0
- package/dist/recipes/schemaGenerator.js +386 -75
- package/dist/recipes/schemaGenerator.js.map +1 -1
- package/dist/recipes/simulation/aggregateRunRisk.d.ts +43 -0
- package/dist/recipes/simulation/aggregateRunRisk.js +117 -0
- package/dist/recipes/simulation/aggregateRunRisk.js.map +1 -0
- package/dist/recipes/simulation/costProjector.d.ts +32 -0
- package/dist/recipes/simulation/costProjector.js +194 -0
- package/dist/recipes/simulation/costProjector.js.map +1 -0
- package/dist/recipes/simulation/sideEffects.d.ts +32 -0
- package/dist/recipes/simulation/sideEffects.js +62 -0
- package/dist/recipes/simulation/sideEffects.js.map +1 -0
- package/dist/recipes/simulation/simulate.d.ts +36 -0
- package/dist/recipes/simulation/simulate.js +264 -0
- package/dist/recipes/simulation/simulate.js.map +1 -0
- package/dist/recipes/simulation/simulateMockedRun.d.ts +52 -0
- package/dist/recipes/simulation/simulateMockedRun.js +72 -0
- package/dist/recipes/simulation/simulateMockedRun.js.map +1 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.d.ts +31 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.js +50 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.js.map +1 -0
- package/dist/recipes/simulation/types.d.ts +198 -0
- package/dist/recipes/simulation/types.js +30 -0
- package/dist/recipes/simulation/types.js.map +1 -0
- package/dist/recipes/stepObservation.d.ts +12 -0
- package/dist/recipes/stepObservation.js +21 -1
- package/dist/recipes/stepObservation.js.map +1 -1
- package/dist/recipes/tools/airtable.d.ts +15 -0
- package/dist/recipes/tools/airtable.js +240 -0
- package/dist/recipes/tools/airtable.js.map +1 -0
- package/dist/recipes/tools/caldiy.d.ts +13 -0
- package/dist/recipes/tools/caldiy.js +214 -0
- package/dist/recipes/tools/caldiy.js.map +1 -0
- package/dist/recipes/tools/circleci.d.ts +10 -0
- package/dist/recipes/tools/circleci.js +204 -0
- package/dist/recipes/tools/circleci.js.map +1 -0
- package/dist/recipes/tools/cloudflare.d.ts +13 -0
- package/dist/recipes/tools/cloudflare.js +211 -0
- package/dist/recipes/tools/cloudflare.js.map +1 -0
- package/dist/recipes/tools/docs.d.ts +18 -0
- package/dist/recipes/tools/docs.js +94 -0
- package/dist/recipes/tools/docs.js.map +1 -0
- package/dist/recipes/tools/elasticsearch.d.ts +11 -0
- package/dist/recipes/tools/elasticsearch.js +156 -0
- package/dist/recipes/tools/elasticsearch.js.map +1 -0
- package/dist/recipes/tools/figma.d.ts +12 -0
- package/dist/recipes/tools/figma.js +194 -0
- package/dist/recipes/tools/figma.js.map +1 -0
- package/dist/recipes/tools/grafana.d.ts +11 -0
- package/dist/recipes/tools/grafana.js +216 -0
- package/dist/recipes/tools/grafana.js.map +1 -0
- package/dist/recipes/tools/http.d.ts +1 -1
- package/dist/recipes/tools/http.js +10 -28
- package/dist/recipes/tools/http.js.map +1 -1
- package/dist/recipes/tools/index.d.ts +26 -0
- package/dist/recipes/tools/index.js +26 -0
- package/dist/recipes/tools/index.js.map +1 -1
- package/dist/recipes/tools/monday.d.ts +22 -0
- package/dist/recipes/tools/monday.js +242 -0
- package/dist/recipes/tools/monday.js.map +1 -0
- package/dist/recipes/tools/obsidian.d.ts +15 -0
- package/dist/recipes/tools/obsidian.js +172 -0
- package/dist/recipes/tools/obsidian.js.map +1 -0
- package/dist/recipes/tools/paystack.d.ts +11 -0
- package/dist/recipes/tools/paystack.js +211 -0
- package/dist/recipes/tools/paystack.js.map +1 -0
- package/dist/recipes/tools/pipedrive.d.ts +16 -0
- package/dist/recipes/tools/pipedrive.js +233 -0
- package/dist/recipes/tools/pipedrive.js.map +1 -0
- package/dist/recipes/tools/postgres.d.ts +15 -0
- package/dist/recipes/tools/postgres.js +185 -0
- package/dist/recipes/tools/postgres.js.map +1 -0
- package/dist/recipes/tools/posthog.d.ts +16 -0
- package/dist/recipes/tools/posthog.js +219 -0
- package/dist/recipes/tools/posthog.js.map +1 -0
- package/dist/recipes/tools/redis.d.ts +9 -0
- package/dist/recipes/tools/redis.js +140 -0
- package/dist/recipes/tools/redis.js.map +1 -0
- package/dist/recipes/tools/resend.d.ts +8 -0
- package/dist/recipes/tools/resend.js +153 -0
- package/dist/recipes/tools/resend.js.map +1 -0
- package/dist/recipes/tools/salesforce.d.ts +16 -0
- package/dist/recipes/tools/salesforce.js +184 -0
- package/dist/recipes/tools/salesforce.js.map +1 -0
- package/dist/recipes/tools/sendgrid.d.ts +9 -0
- package/dist/recipes/tools/sendgrid.js +174 -0
- package/dist/recipes/tools/sendgrid.js.map +1 -0
- package/dist/recipes/tools/shopify.d.ts +16 -0
- package/dist/recipes/tools/shopify.js +265 -0
- package/dist/recipes/tools/shopify.js.map +1 -0
- package/dist/recipes/tools/snowflake.d.ts +16 -0
- package/dist/recipes/tools/snowflake.js +173 -0
- package/dist/recipes/tools/snowflake.js.map +1 -0
- package/dist/recipes/tools/stripe.js +13 -12
- package/dist/recipes/tools/stripe.js.map +1 -1
- package/dist/recipes/tools/supabase.d.ts +9 -0
- package/dist/recipes/tools/supabase.js +132 -0
- package/dist/recipes/tools/supabase.js.map +1 -0
- package/dist/recipes/tools/todoist.d.ts +15 -0
- package/dist/recipes/tools/todoist.js +227 -0
- package/dist/recipes/tools/todoist.js.map +1 -0
- package/dist/recipes/tools/twilio.d.ts +11 -0
- package/dist/recipes/tools/twilio.js +180 -0
- package/dist/recipes/tools/twilio.js.map +1 -0
- package/dist/recipes/tools/vercel.d.ts +9 -0
- package/dist/recipes/tools/vercel.js +145 -0
- package/dist/recipes/tools/vercel.js.map +1 -0
- package/dist/recipes/tools/webflow.d.ts +11 -0
- package/dist/recipes/tools/webflow.js +243 -0
- package/dist/recipes/tools/webflow.js.map +1 -0
- package/dist/recipes/tools/woocommerce.d.ts +18 -0
- package/dist/recipes/tools/woocommerce.js +259 -0
- package/dist/recipes/tools/woocommerce.js.map +1 -0
- package/dist/recipes/tools/wrapConnectorExecute.d.ts +25 -0
- package/dist/recipes/tools/wrapConnectorExecute.js +37 -0
- package/dist/recipes/tools/wrapConnectorExecute.js.map +1 -0
- package/dist/recipes/validation.js +264 -0
- package/dist/recipes/validation.js.map +1 -1
- package/dist/recipes/yamlRunner.d.ts +112 -3
- package/dist/recipes/yamlRunner.js +482 -19
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/runLog.d.ts +46 -0
- package/dist/runLog.js +4 -0
- package/dist/runLog.js.map +1 -1
- package/dist/schemas/recipe.v1.json +217 -11
- package/dist/server.d.ts +3 -0
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/streamableHttp.js +3 -2
- package/dist/streamableHttp.js.map +1 -1
- package/dist/tools/gitWrite.js +5 -1
- package/dist/tools/gitWrite.js.map +1 -1
- package/dist/tools/terminal.js +15 -49
- package/dist/tools/terminal.js.map +1 -1
- package/dist/transport.d.ts +1 -0
- package/dist/transport.js +7 -0
- package/dist/transport.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mcp-stdio-shim.cjs +218 -84
- package/templates/recipes/incident-to-pr.yaml +187 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Salesforce recipe-step tools — read wrappers (query, search, get_object)
|
|
3
|
+
* plus a write-gated create_record.
|
|
4
|
+
*
|
|
5
|
+
* Self-registering tool module for the recipe tool registry. Unlike the
|
|
6
|
+
* class-plus-accessor connectors, src/connectors/salesforce.ts exports a set
|
|
7
|
+
* of standalone async functions (module-function pattern) — there is no
|
|
8
|
+
* getSalesforceConnector(). Each tool dynamically imports the function it wraps
|
|
9
|
+
* and JSON-stringifies the raw connector return value back out.
|
|
10
|
+
*
|
|
11
|
+
* Read tools (`query`, `searchSosl`, `getObject`) declare `isWrite: false`;
|
|
12
|
+
* `create_record` declares `isWrite: true` so the approval queue gates the
|
|
13
|
+
* mutation. The connector itself enforces SELECT-only SOQL and FIND-only SOSL,
|
|
14
|
+
* and validates sObject / record-id shapes before issuing the call.
|
|
15
|
+
*/
|
|
16
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
17
|
+
import { wrapConnectorExecute } from "./wrapConnectorExecute.js";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// salesforce.query (SOQL — read)
|
|
20
|
+
// ============================================================================
|
|
21
|
+
registerTool({
|
|
22
|
+
id: "salesforce.query",
|
|
23
|
+
namespace: "salesforce",
|
|
24
|
+
description: "Execute a SOQL SELECT query against Salesforce. The statement must start " +
|
|
25
|
+
"with SELECT (enforced by the connector). An optional limit caps the page " +
|
|
26
|
+
"size (default 200, hard cap 200).",
|
|
27
|
+
paramsSchema: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
soql: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "SOQL SELECT query (must start with SELECT)",
|
|
33
|
+
},
|
|
34
|
+
limit: {
|
|
35
|
+
type: "number",
|
|
36
|
+
description: "Optional page-size cap (default 200, hard cap 200)",
|
|
37
|
+
},
|
|
38
|
+
into: CommonSchemas.into,
|
|
39
|
+
},
|
|
40
|
+
required: ["soql"],
|
|
41
|
+
},
|
|
42
|
+
// SoqlQueryResult — see src/connectors/salesforce.ts.
|
|
43
|
+
outputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
totalSize: { type: "number" },
|
|
47
|
+
done: { type: "boolean" },
|
|
48
|
+
records: {
|
|
49
|
+
type: "array",
|
|
50
|
+
items: { type: "object" },
|
|
51
|
+
},
|
|
52
|
+
nextRecordsUrl: { type: "string" },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
riskDefault: "low",
|
|
56
|
+
isWrite: false,
|
|
57
|
+
isConnector: true,
|
|
58
|
+
execute: wrapConnectorExecute(async ({ params }) => {
|
|
59
|
+
const { query } = await import("../../connectors/salesforce.js");
|
|
60
|
+
const result = await query(params.soql, typeof params.limit === "number" ? { limit: params.limit } : undefined);
|
|
61
|
+
return JSON.stringify(result);
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// salesforce.search (SOSL — read)
|
|
66
|
+
// ============================================================================
|
|
67
|
+
registerTool({
|
|
68
|
+
id: "salesforce.search",
|
|
69
|
+
namespace: "salesforce",
|
|
70
|
+
description: "Execute a SOSL search against Salesforce. The statement must start with " +
|
|
71
|
+
"FIND (enforced by the connector).",
|
|
72
|
+
paramsSchema: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
sosl: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "SOSL search expression (must start with FIND)",
|
|
78
|
+
},
|
|
79
|
+
into: CommonSchemas.into,
|
|
80
|
+
},
|
|
81
|
+
required: ["sosl"],
|
|
82
|
+
},
|
|
83
|
+
// SoslSearchResult — see src/connectors/salesforce.ts.
|
|
84
|
+
outputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
searchRecords: {
|
|
88
|
+
type: "array",
|
|
89
|
+
items: { type: "object" },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
riskDefault: "low",
|
|
94
|
+
isWrite: false,
|
|
95
|
+
isConnector: true,
|
|
96
|
+
execute: wrapConnectorExecute(async ({ params }) => {
|
|
97
|
+
const { searchSosl } = await import("../../connectors/salesforce.js");
|
|
98
|
+
const result = await searchSosl(params.sosl);
|
|
99
|
+
return JSON.stringify(result);
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// salesforce.get_object (read)
|
|
104
|
+
// ============================================================================
|
|
105
|
+
registerTool({
|
|
106
|
+
id: "salesforce.get_object",
|
|
107
|
+
namespace: "salesforce",
|
|
108
|
+
description: "Fetch a single Salesforce sObject record by its API name and record id " +
|
|
109
|
+
"(e.g. object_name: 'Account', record_id: '001...').",
|
|
110
|
+
paramsSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
object_name: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "sObject API name (e.g. 'Account', 'Contact')",
|
|
116
|
+
},
|
|
117
|
+
record_id: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Salesforce record id (15 or 18 chars)",
|
|
120
|
+
},
|
|
121
|
+
into: CommonSchemas.into,
|
|
122
|
+
},
|
|
123
|
+
required: ["object_name", "record_id"],
|
|
124
|
+
},
|
|
125
|
+
// getObject resolves to the raw sObject record (Record<string, unknown>).
|
|
126
|
+
outputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
additionalProperties: true,
|
|
129
|
+
},
|
|
130
|
+
riskDefault: "low",
|
|
131
|
+
isWrite: false,
|
|
132
|
+
isConnector: true,
|
|
133
|
+
execute: wrapConnectorExecute(async ({ params }) => {
|
|
134
|
+
const { getObject } = await import("../../connectors/salesforce.js");
|
|
135
|
+
const result = await getObject(params.object_name, params.record_id);
|
|
136
|
+
return JSON.stringify(result);
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// salesforce.create_record (write-gated)
|
|
141
|
+
// ============================================================================
|
|
142
|
+
registerTool({
|
|
143
|
+
id: "salesforce.create_record",
|
|
144
|
+
namespace: "salesforce",
|
|
145
|
+
description: "Create a new Salesforce sObject record. Supply the sObject API name and a " +
|
|
146
|
+
"fields object mapping field API names to values.",
|
|
147
|
+
paramsSchema: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
object_name: {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "sObject API name (e.g. 'Account', 'Contact', 'Lead')",
|
|
153
|
+
},
|
|
154
|
+
fields: {
|
|
155
|
+
type: "object",
|
|
156
|
+
description: "Field API names mapped to values (e.g. { Name: 'Acme', Industry: 'Tech' })",
|
|
157
|
+
additionalProperties: true,
|
|
158
|
+
},
|
|
159
|
+
into: CommonSchemas.into,
|
|
160
|
+
},
|
|
161
|
+
required: ["object_name", "fields"],
|
|
162
|
+
},
|
|
163
|
+
// CreateRecordResult — see src/connectors/salesforce.ts.
|
|
164
|
+
outputSchema: {
|
|
165
|
+
type: "object",
|
|
166
|
+
properties: {
|
|
167
|
+
id: { type: "string" },
|
|
168
|
+
success: { type: "boolean" },
|
|
169
|
+
errors: { type: "array", items: {} },
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
riskDefault: "medium",
|
|
173
|
+
isWrite: true,
|
|
174
|
+
isConnector: true,
|
|
175
|
+
execute: wrapConnectorExecute(async ({ params }) => {
|
|
176
|
+
const { createRecord } = await import("../../connectors/salesforce.js");
|
|
177
|
+
const fields = params.fields && typeof params.fields === "object"
|
|
178
|
+
? params.fields
|
|
179
|
+
: {};
|
|
180
|
+
const result = await createRecord(params.object_name, fields);
|
|
181
|
+
return JSON.stringify(result);
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=salesforce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesforce.js","sourceRoot":"","sources":["../../../src/recipes/tools/salesforce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E,YAAY,CAAC;IACX,EAAE,EAAE,kBAAkB;IACtB,SAAS,EAAE,YAAY;IACvB,WAAW,EACT,2EAA2E;QAC3E,2EAA2E;QAC3E,mCAAmC;IACrC,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oDA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AAE,EAAE,EAAE;QACjD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;QACxE,MAAM,MAAM,GACV,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;YAChD,CAAC,CAAE,MAAM,CAAC,MAAkC;YAC5C,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,WAAqB,EAAE,MAAM,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SendGrid tools — transactional email send (write) plus read wrappers for
|
|
3
|
+
* dynamic/legacy templates and email stats.
|
|
4
|
+
*
|
|
5
|
+
* Self-registering tool module for the recipe tool registry. Wraps the
|
|
6
|
+
* SendGridConnector (src/connectors/sendgrid.ts) methods `send`,
|
|
7
|
+
* `listTemplates`, and `getStats`.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SendGrid tools — transactional email send (write) plus read wrappers for
|
|
3
|
+
* dynamic/legacy templates and email stats.
|
|
4
|
+
*
|
|
5
|
+
* Self-registering tool module for the recipe tool registry. Wraps the
|
|
6
|
+
* SendGridConnector (src/connectors/sendgrid.ts) methods `send`,
|
|
7
|
+
* `listTemplates`, and `getStats`.
|
|
8
|
+
*/
|
|
9
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// sendgrid.send_email (write-gated)
|
|
12
|
+
// ============================================================================
|
|
13
|
+
registerTool({
|
|
14
|
+
id: "sendgrid.send_email",
|
|
15
|
+
namespace: "sendgrid",
|
|
16
|
+
description: "Send a transactional email via SendGrid. Requires `to`, `subject`, and at " +
|
|
17
|
+
"least one of `text`/`html`. `from` defaults to the connected verified sender.",
|
|
18
|
+
paramsSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
to: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Recipient email address (required)",
|
|
24
|
+
},
|
|
25
|
+
subject: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Email subject line (required, non-empty)",
|
|
28
|
+
},
|
|
29
|
+
text: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Plain-text body (one of text/html is required)",
|
|
32
|
+
},
|
|
33
|
+
html: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "HTML body (one of text/html is required)",
|
|
36
|
+
},
|
|
37
|
+
from: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "Sender email address. Defaults to the connected verified sender (fromEmail).",
|
|
40
|
+
},
|
|
41
|
+
into: CommonSchemas.into,
|
|
42
|
+
},
|
|
43
|
+
required: ["to", "subject"],
|
|
44
|
+
},
|
|
45
|
+
outputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
ok: { type: "boolean" },
|
|
49
|
+
messageId: { type: "string" },
|
|
50
|
+
error: { type: "string" },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
riskDefault: "medium",
|
|
54
|
+
isWrite: true,
|
|
55
|
+
isConnector: true,
|
|
56
|
+
execute: async ({ params }) => {
|
|
57
|
+
const { getSendGridConnector } = await import("../../connectors/sendgrid.js");
|
|
58
|
+
try {
|
|
59
|
+
const connector = getSendGridConnector();
|
|
60
|
+
const result = await connector.send({
|
|
61
|
+
to: params.to,
|
|
62
|
+
subject: params.subject,
|
|
63
|
+
text: typeof params.text === "string" ? params.text : undefined,
|
|
64
|
+
html: typeof params.html === "string" ? params.html : undefined,
|
|
65
|
+
from: typeof params.from === "string" ? params.from : undefined,
|
|
66
|
+
});
|
|
67
|
+
return JSON.stringify({ ok: true, messageId: result.messageId });
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return JSON.stringify({
|
|
71
|
+
ok: false,
|
|
72
|
+
error: err instanceof Error ? err.message : String(err),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// sendgrid.list_templates
|
|
79
|
+
// ============================================================================
|
|
80
|
+
registerTool({
|
|
81
|
+
id: "sendgrid.list_templates",
|
|
82
|
+
namespace: "sendgrid",
|
|
83
|
+
description: "List SendGrid email templates, optionally filtered by generation " +
|
|
84
|
+
"(legacy or dynamic).",
|
|
85
|
+
paramsSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
limit: {
|
|
89
|
+
type: "number",
|
|
90
|
+
description: "Max number of templates to return (page_size)",
|
|
91
|
+
},
|
|
92
|
+
generations: {
|
|
93
|
+
type: "string",
|
|
94
|
+
enum: ["legacy", "dynamic"],
|
|
95
|
+
description: "Filter by template generation",
|
|
96
|
+
},
|
|
97
|
+
into: CommonSchemas.into,
|
|
98
|
+
},
|
|
99
|
+
required: [],
|
|
100
|
+
},
|
|
101
|
+
outputSchema: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
result: { type: "array", items: { type: "object" } },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
riskDefault: "low",
|
|
108
|
+
isWrite: false,
|
|
109
|
+
isConnector: true,
|
|
110
|
+
execute: async ({ params }) => {
|
|
111
|
+
const { getSendGridConnector } = await import("../../connectors/sendgrid.js");
|
|
112
|
+
const connector = getSendGridConnector();
|
|
113
|
+
const result = await connector.listTemplates({
|
|
114
|
+
limit: typeof params.limit === "number" ? params.limit : undefined,
|
|
115
|
+
generations: params.generations === "legacy" || params.generations === "dynamic"
|
|
116
|
+
? params.generations
|
|
117
|
+
: undefined,
|
|
118
|
+
});
|
|
119
|
+
return JSON.stringify(result);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
// ============================================================================
|
|
123
|
+
// sendgrid.get_stats
|
|
124
|
+
// ============================================================================
|
|
125
|
+
registerTool({
|
|
126
|
+
id: "sendgrid.get_stats",
|
|
127
|
+
namespace: "sendgrid",
|
|
128
|
+
description: "Fetch SendGrid email statistics for a date range, optionally aggregated " +
|
|
129
|
+
"by day/week/month.",
|
|
130
|
+
paramsSchema: {
|
|
131
|
+
type: "object",
|
|
132
|
+
properties: {
|
|
133
|
+
startDate: {
|
|
134
|
+
type: "string",
|
|
135
|
+
description: "Start date YYYY-MM-DD (required)",
|
|
136
|
+
},
|
|
137
|
+
endDate: {
|
|
138
|
+
type: "string",
|
|
139
|
+
description: "End date YYYY-MM-DD (optional, defaults to today)",
|
|
140
|
+
},
|
|
141
|
+
aggregatedBy: {
|
|
142
|
+
type: "string",
|
|
143
|
+
enum: ["day", "week", "month"],
|
|
144
|
+
description: "Aggregation bucket size",
|
|
145
|
+
},
|
|
146
|
+
into: CommonSchemas.into,
|
|
147
|
+
},
|
|
148
|
+
required: ["startDate"],
|
|
149
|
+
},
|
|
150
|
+
outputSchema: {
|
|
151
|
+
type: "object",
|
|
152
|
+
properties: {
|
|
153
|
+
data: { type: "array", items: { type: "object" } },
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
riskDefault: "low",
|
|
157
|
+
isWrite: false,
|
|
158
|
+
isConnector: true,
|
|
159
|
+
execute: async ({ params }) => {
|
|
160
|
+
const { getSendGridConnector } = await import("../../connectors/sendgrid.js");
|
|
161
|
+
const connector = getSendGridConnector();
|
|
162
|
+
const data = await connector.getStats({
|
|
163
|
+
startDate: params.startDate,
|
|
164
|
+
endDate: typeof params.endDate === "string" ? params.endDate : undefined,
|
|
165
|
+
aggregatedBy: params.aggregatedBy === "day" ||
|
|
166
|
+
params.aggregatedBy === "week" ||
|
|
167
|
+
params.aggregatedBy === "month"
|
|
168
|
+
? params.aggregatedBy
|
|
169
|
+
: undefined,
|
|
170
|
+
});
|
|
171
|
+
return JSON.stringify({ data });
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=sendgrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendgrid.js","sourceRoot":"","sources":["../../../src/recipes/tools/sendgrid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,qCAAqC;AACrC,+EAA+E;AAE/E,YAAY,CAAC;IACX,EAAE,EAAE,qBAAqB;IACzB,SAAS,EAAE,UAAU;IACrB,WAAW,EACT,4EAA4E;QAC5E,+EAA+E;IACjF,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;aAClD;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0CAA0C;aACxD;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gDAAgD;aAC9D;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0CAA0C;aACxD;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,8EAA8E;aACjF;YACD,IAAI,EAAE,aAAa,CAAC,IAAI;SACzB;QACD,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC;KAC5B;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YACvB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC7B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF;IACD,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,IAAI;IACb,WAAW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AAM,CAAC,YAAY,KAAK,MAAM;gBAC9B,MAAM,CAAC,YAAY,KAAK,OAAO;gBAC7B,CAAC,CAAC,MAAM,CAAC,YAAY;gBACrB,CAAC,CAAC,SAAS;SAChB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shopify tools — read-only access to products, orders, and customers.
|
|
3
|
+
*
|
|
4
|
+
* Self-registering tool module for the recipe tool registry. Each tool lazily
|
|
5
|
+
* imports the Shopify connector and wraps a single read method, returning the
|
|
6
|
+
* connector result verbatim via JSON.stringify.
|
|
7
|
+
*
|
|
8
|
+
* Connector methods mirrored (see src/connectors/shopify.ts):
|
|
9
|
+
* - listProducts({ limit?, status?, vendor?, productType? }) -> { data: ShopifyProduct[] }
|
|
10
|
+
* - listOrders({ limit?, status?, financialStatus?, fulfillmentStatus? }) -> { data: ShopifyOrder[] }
|
|
11
|
+
* - getOrder(orderId: string | number) -> ShopifyOrder
|
|
12
|
+
* - listCustomers({ limit?, query? }) -> { data: ShopifyCustomer[] }
|
|
13
|
+
*
|
|
14
|
+
* All v1 tools are read-only (`isWrite: false`, `riskDefault: "low"`).
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shopify tools — read-only access to products, orders, and customers.
|
|
3
|
+
*
|
|
4
|
+
* Self-registering tool module for the recipe tool registry. Each tool lazily
|
|
5
|
+
* imports the Shopify connector and wraps a single read method, returning the
|
|
6
|
+
* connector result verbatim via JSON.stringify.
|
|
7
|
+
*
|
|
8
|
+
* Connector methods mirrored (see src/connectors/shopify.ts):
|
|
9
|
+
* - listProducts({ limit?, status?, vendor?, productType? }) -> { data: ShopifyProduct[] }
|
|
10
|
+
* - listOrders({ limit?, status?, financialStatus?, fulfillmentStatus? }) -> { data: ShopifyOrder[] }
|
|
11
|
+
* - getOrder(orderId: string | number) -> ShopifyOrder
|
|
12
|
+
* - listCustomers({ limit?, query? }) -> { data: ShopifyCustomer[] }
|
|
13
|
+
*
|
|
14
|
+
* All v1 tools are read-only (`isWrite: false`, `riskDefault: "low"`).
|
|
15
|
+
*/
|
|
16
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// shopify.list_products
|
|
19
|
+
// ============================================================================
|
|
20
|
+
registerTool({
|
|
21
|
+
id: "shopify.list_products",
|
|
22
|
+
namespace: "shopify",
|
|
23
|
+
description: "List Shopify products, optionally filtered by status, vendor, or product type.",
|
|
24
|
+
paramsSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
limit: {
|
|
28
|
+
type: "number",
|
|
29
|
+
description: "Max number of products to return (default 50, max 250)",
|
|
30
|
+
default: 50,
|
|
31
|
+
},
|
|
32
|
+
status: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Filter by product status (active, archived, draft)",
|
|
35
|
+
},
|
|
36
|
+
vendor: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Filter by vendor name",
|
|
39
|
+
},
|
|
40
|
+
productType: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Filter by product type",
|
|
43
|
+
},
|
|
44
|
+
into: CommonSchemas.into,
|
|
45
|
+
},
|
|
46
|
+
required: [],
|
|
47
|
+
},
|
|
48
|
+
outputSchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
data: {
|
|
52
|
+
type: "array",
|
|
53
|
+
items: {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
id: { type: "number" },
|
|
57
|
+
title: { type: "string" },
|
|
58
|
+
body_html: { type: ["string", "null"] },
|
|
59
|
+
vendor: { type: "string" },
|
|
60
|
+
product_type: { type: "string" },
|
|
61
|
+
status: { type: "string" },
|
|
62
|
+
created_at: { type: "string" },
|
|
63
|
+
updated_at: { type: "string" },
|
|
64
|
+
tags: { type: "string" },
|
|
65
|
+
variants: { type: "array", items: { type: "object" } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
riskDefault: "low",
|
|
72
|
+
isWrite: false,
|
|
73
|
+
isConnector: true,
|
|
74
|
+
execute: async ({ params }) => {
|
|
75
|
+
const { getShopifyConnector } = await import("../../connectors/shopify.js");
|
|
76
|
+
const connector = getShopifyConnector();
|
|
77
|
+
const result = await connector.listProducts({
|
|
78
|
+
limit: typeof params.limit === "number" ? params.limit : undefined,
|
|
79
|
+
status: typeof params.status === "string" ? params.status : undefined,
|
|
80
|
+
vendor: typeof params.vendor === "string" ? params.vendor : undefined,
|
|
81
|
+
productType: typeof params.productType === "string" ? params.productType : undefined,
|
|
82
|
+
});
|
|
83
|
+
return JSON.stringify(result);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// shopify.list_orders
|
|
88
|
+
// ============================================================================
|
|
89
|
+
registerTool({
|
|
90
|
+
id: "shopify.list_orders",
|
|
91
|
+
namespace: "shopify",
|
|
92
|
+
description: "List Shopify orders, optionally filtered by status, financial status, or fulfillment status.",
|
|
93
|
+
paramsSchema: {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: {
|
|
96
|
+
limit: {
|
|
97
|
+
type: "number",
|
|
98
|
+
description: "Max number of orders to return (default 50, max 250)",
|
|
99
|
+
default: 50,
|
|
100
|
+
},
|
|
101
|
+
status: {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "Filter by order status (open, closed, cancelled, any; default any)",
|
|
104
|
+
},
|
|
105
|
+
financialStatus: {
|
|
106
|
+
type: "string",
|
|
107
|
+
description: "Filter by financial status (e.g. paid, pending, refunded, voided)",
|
|
108
|
+
},
|
|
109
|
+
fulfillmentStatus: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Filter by fulfillment status (e.g. shipped, partial, unshipped, any)",
|
|
112
|
+
},
|
|
113
|
+
into: CommonSchemas.into,
|
|
114
|
+
},
|
|
115
|
+
required: [],
|
|
116
|
+
},
|
|
117
|
+
outputSchema: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
data: {
|
|
121
|
+
type: "array",
|
|
122
|
+
items: {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: {
|
|
125
|
+
id: { type: "number" },
|
|
126
|
+
order_number: { type: "number" },
|
|
127
|
+
name: { type: "string" },
|
|
128
|
+
email: { type: ["string", "null"] },
|
|
129
|
+
financial_status: { type: ["string", "null"] },
|
|
130
|
+
fulfillment_status: { type: ["string", "null"] },
|
|
131
|
+
total_price: { type: "string" },
|
|
132
|
+
subtotal_price: { type: "string" },
|
|
133
|
+
currency: { type: "string" },
|
|
134
|
+
created_at: { type: "string" },
|
|
135
|
+
updated_at: { type: "string" },
|
|
136
|
+
customer: { type: ["object", "null"] },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
riskDefault: "low",
|
|
143
|
+
isWrite: false,
|
|
144
|
+
isConnector: true,
|
|
145
|
+
execute: async ({ params }) => {
|
|
146
|
+
const { getShopifyConnector } = await import("../../connectors/shopify.js");
|
|
147
|
+
const connector = getShopifyConnector();
|
|
148
|
+
const result = await connector.listOrders({
|
|
149
|
+
limit: typeof params.limit === "number" ? params.limit : undefined,
|
|
150
|
+
status: typeof params.status === "string" ? params.status : undefined,
|
|
151
|
+
financialStatus: typeof params.financialStatus === "string"
|
|
152
|
+
? params.financialStatus
|
|
153
|
+
: undefined,
|
|
154
|
+
fulfillmentStatus: typeof params.fulfillmentStatus === "string"
|
|
155
|
+
? params.fulfillmentStatus
|
|
156
|
+
: undefined,
|
|
157
|
+
});
|
|
158
|
+
return JSON.stringify(result);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// shopify.get_order
|
|
163
|
+
// ============================================================================
|
|
164
|
+
registerTool({
|
|
165
|
+
id: "shopify.get_order",
|
|
166
|
+
namespace: "shopify",
|
|
167
|
+
description: "Fetch a single Shopify order by ID.",
|
|
168
|
+
paramsSchema: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
orderId: {
|
|
172
|
+
type: ["string", "number"],
|
|
173
|
+
description: "Shopify order ID",
|
|
174
|
+
},
|
|
175
|
+
into: CommonSchemas.into,
|
|
176
|
+
},
|
|
177
|
+
required: ["orderId"],
|
|
178
|
+
},
|
|
179
|
+
outputSchema: {
|
|
180
|
+
type: "object",
|
|
181
|
+
properties: {
|
|
182
|
+
id: { type: "number" },
|
|
183
|
+
order_number: { type: "number" },
|
|
184
|
+
name: { type: "string" },
|
|
185
|
+
email: { type: ["string", "null"] },
|
|
186
|
+
financial_status: { type: ["string", "null"] },
|
|
187
|
+
fulfillment_status: { type: ["string", "null"] },
|
|
188
|
+
total_price: { type: "string" },
|
|
189
|
+
subtotal_price: { type: "string" },
|
|
190
|
+
currency: { type: "string" },
|
|
191
|
+
created_at: { type: "string" },
|
|
192
|
+
updated_at: { type: "string" },
|
|
193
|
+
customer: { type: ["object", "null"] },
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
riskDefault: "low",
|
|
197
|
+
isWrite: false,
|
|
198
|
+
isConnector: true,
|
|
199
|
+
execute: async ({ params }) => {
|
|
200
|
+
const { getShopifyConnector } = await import("../../connectors/shopify.js");
|
|
201
|
+
const connector = getShopifyConnector();
|
|
202
|
+
const result = await connector.getOrder(params.orderId);
|
|
203
|
+
return JSON.stringify(result);
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
// ============================================================================
|
|
207
|
+
// shopify.list_customers
|
|
208
|
+
// ============================================================================
|
|
209
|
+
registerTool({
|
|
210
|
+
id: "shopify.list_customers",
|
|
211
|
+
namespace: "shopify",
|
|
212
|
+
description: "List Shopify customers, optionally filtered by a search query string.",
|
|
213
|
+
paramsSchema: {
|
|
214
|
+
type: "object",
|
|
215
|
+
properties: {
|
|
216
|
+
limit: {
|
|
217
|
+
type: "number",
|
|
218
|
+
description: "Max number of customers to return (default 50, max 250)",
|
|
219
|
+
default: 50,
|
|
220
|
+
},
|
|
221
|
+
query: {
|
|
222
|
+
type: "string",
|
|
223
|
+
description: "Search query (uses the Shopify customer search endpoint, e.g. email or name)",
|
|
224
|
+
},
|
|
225
|
+
into: CommonSchemas.into,
|
|
226
|
+
},
|
|
227
|
+
required: [],
|
|
228
|
+
},
|
|
229
|
+
outputSchema: {
|
|
230
|
+
type: "object",
|
|
231
|
+
properties: {
|
|
232
|
+
data: {
|
|
233
|
+
type: "array",
|
|
234
|
+
items: {
|
|
235
|
+
type: "object",
|
|
236
|
+
properties: {
|
|
237
|
+
id: { type: "number" },
|
|
238
|
+
email: { type: ["string", "null"] },
|
|
239
|
+
first_name: { type: ["string", "null"] },
|
|
240
|
+
last_name: { type: ["string", "null"] },
|
|
241
|
+
phone: { type: ["string", "null"] },
|
|
242
|
+
orders_count: { type: "number" },
|
|
243
|
+
total_spent: { type: "string" },
|
|
244
|
+
state: { type: "string" },
|
|
245
|
+
created_at: { type: "string" },
|
|
246
|
+
updated_at: { type: "string" },
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
riskDefault: "low",
|
|
253
|
+
isWrite: false,
|
|
254
|
+
isConnector: true,
|
|
255
|
+
execute: async ({ params }) => {
|
|
256
|
+
const { getShopifyConnector } = await import("../../connectors/shopify.js");
|
|
257
|
+
const connector = getShopifyConnector();
|
|
258
|
+
const result = await connector.listCustomers({
|
|
259
|
+
limit: typeof params.limit === "number" ? params.limit : undefined,
|
|
260
|
+
query: typeof params.query === "string" ? params.query : undefined,
|
|
261
|
+
});
|
|
262
|
+
return JSON.stringify(result);
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
//# sourceMappingURL=shopify.js.map
|