create-agentmark 0.2.0 → 0.3.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.
Files changed (64) hide show
  1. package/dist/index.cjs +803 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1 -0
  4. package/dist/index.d.ts +0 -2
  5. package/dist/index.js +770 -57
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -2
  8. package/dist/index.d.ts.map +0 -1
  9. package/dist/utils/examples/create-example-app.d.ts +0 -2
  10. package/dist/utils/examples/create-example-app.d.ts.map +0 -1
  11. package/dist/utils/examples/create-example-app.js +0 -214
  12. package/dist/utils/examples/create-example-app.js.map +0 -1
  13. package/dist/utils/examples/templates/animal-drawing-prompt.d.ts +0 -2
  14. package/dist/utils/examples/templates/animal-drawing-prompt.d.ts.map +0 -1
  15. package/dist/utils/examples/templates/animal-drawing-prompt.js +0 -19
  16. package/dist/utils/examples/templates/animal-drawing-prompt.js.map +0 -1
  17. package/dist/utils/examples/templates/app-index.d.ts +0 -2
  18. package/dist/utils/examples/templates/app-index.d.ts.map +0 -1
  19. package/dist/utils/examples/templates/app-index.js +0 -95
  20. package/dist/utils/examples/templates/app-index.js.map +0 -1
  21. package/dist/utils/examples/templates/customer-support-prompt.d.ts +0 -2
  22. package/dist/utils/examples/templates/customer-support-prompt.d.ts.map +0 -1
  23. package/dist/utils/examples/templates/customer-support-prompt.js +0 -40
  24. package/dist/utils/examples/templates/customer-support-prompt.js.map +0 -1
  25. package/dist/utils/examples/templates/datasets.d.ts +0 -5
  26. package/dist/utils/examples/templates/datasets.d.ts.map +0 -1
  27. package/dist/utils/examples/templates/datasets.js +0 -21
  28. package/dist/utils/examples/templates/datasets.js.map +0 -1
  29. package/dist/utils/examples/templates/env.d.ts +0 -2
  30. package/dist/utils/examples/templates/env.d.ts.map +0 -1
  31. package/dist/utils/examples/templates/env.js +0 -30
  32. package/dist/utils/examples/templates/env.js.map +0 -1
  33. package/dist/utils/examples/templates/example-prompts.d.ts +0 -2
  34. package/dist/utils/examples/templates/example-prompts.d.ts.map +0 -1
  35. package/dist/utils/examples/templates/example-prompts.js +0 -35
  36. package/dist/utils/examples/templates/example-prompts.js.map +0 -1
  37. package/dist/utils/examples/templates/index.d.ts +0 -12
  38. package/dist/utils/examples/templates/index.d.ts.map +0 -1
  39. package/dist/utils/examples/templates/index.js +0 -12
  40. package/dist/utils/examples/templates/index.js.map +0 -1
  41. package/dist/utils/examples/templates/package-setup.d.ts +0 -3
  42. package/dist/utils/examples/templates/package-setup.d.ts.map +0 -1
  43. package/dist/utils/examples/templates/package-setup.js +0 -63
  44. package/dist/utils/examples/templates/package-setup.js.map +0 -1
  45. package/dist/utils/examples/templates/party-planner-prompt.d.ts +0 -2
  46. package/dist/utils/examples/templates/party-planner-prompt.d.ts.map +0 -1
  47. package/dist/utils/examples/templates/party-planner-prompt.js +0 -40
  48. package/dist/utils/examples/templates/party-planner-prompt.js.map +0 -1
  49. package/dist/utils/examples/templates/story-teller-prompt.d.ts +0 -2
  50. package/dist/utils/examples/templates/story-teller-prompt.d.ts.map +0 -1
  51. package/dist/utils/examples/templates/story-teller-prompt.js +0 -23
  52. package/dist/utils/examples/templates/story-teller-prompt.js.map +0 -1
  53. package/dist/utils/examples/templates/tsconfig.d.ts +0 -2
  54. package/dist/utils/examples/templates/tsconfig.d.ts.map +0 -1
  55. package/dist/utils/examples/templates/tsconfig.js +0 -14
  56. package/dist/utils/examples/templates/tsconfig.js.map +0 -1
  57. package/dist/utils/examples/templates/user-client-config.d.ts +0 -6
  58. package/dist/utils/examples/templates/user-client-config.d.ts.map +0 -1
  59. package/dist/utils/examples/templates/user-client-config.js +0 -163
  60. package/dist/utils/examples/templates/user-client-config.js.map +0 -1
  61. package/dist/utils/providers.d.ts +0 -9
  62. package/dist/utils/providers.d.ts.map +0 -1
  63. package/dist/utils/providers.js +0 -16
  64. package/dist/utils/providers.js.map +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,803 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // src/index.ts
27
+ var import_fs_extra4 = __toESM(require("fs-extra"), 1);
28
+ var import_prompts = __toESM(require("prompts"), 1);
29
+
30
+ // src/utils/examples/create-example-app.ts
31
+ var import_fs_extra3 = __toESM(require("fs-extra"), 1);
32
+ var import_fs = require("fs");
33
+ var path = __toESM(require("path"), 1);
34
+
35
+ // src/utils/providers.ts
36
+ var Providers = {
37
+ openai: {
38
+ label: "OpenAI",
39
+ languageModels: [
40
+ "gpt-4o",
41
+ "gpt-4o-mini",
42
+ "gpt-4",
43
+ "gpt-5",
44
+ "gpt-4-turbo",
45
+ "gpt-3.5-turbo"
46
+ ],
47
+ imageModels: ["dall-e-3", "dall-e-2"],
48
+ speechModels: ["tts-1", "tts-1-hd"]
49
+ }
50
+ };
51
+
52
+ // src/utils/examples/templates/adapters.ts
53
+ var createAdapterConfig = (provider) => {
54
+ return {
55
+ "ai-sdk": {
56
+ package: "@agentmark/ai-sdk-v5-adapter",
57
+ dependencies: ["ai@^5", `@ai-sdk/${provider}@^2`],
58
+ classes: {
59
+ modelRegistry: "VercelAIModelRegistry",
60
+ toolRegistry: "VercelAIToolRegistry",
61
+ webhookHandler: "VercelAdapterWebhookHandler"
62
+ }
63
+ },
64
+ mastra: {
65
+ package: "@agentmark/mastra-v0-adapter",
66
+ dependencies: [
67
+ "@mastra/core@<0.20.0",
68
+ "@mastra/mcp@<0.13.4",
69
+ `@ai-sdk/${provider}@<2`
70
+ ],
71
+ classes: {
72
+ modelRegistry: "MastraModelRegistry",
73
+ toolRegistry: "MastraToolRegistry",
74
+ webhookHandler: "MastraAdapterWebhookHandler"
75
+ }
76
+ }
77
+ };
78
+ };
79
+ function getAdapterConfig(adapter, provider) {
80
+ const config = createAdapterConfig(provider)[adapter];
81
+ if (!config) {
82
+ throw new Error(
83
+ `Unknown adapter: ${adapter}. Available adapters: ${Object.keys(
84
+ createAdapterConfig(provider)
85
+ ).join(", ")}`
86
+ );
87
+ }
88
+ return config;
89
+ }
90
+
91
+ // src/utils/examples/templates/app-index.ts
92
+ var getIndexFileContent = (adapter = "ai-sdk") => {
93
+ if (adapter === "mastra") {
94
+ return `import "dotenv/config";
95
+ import { Agent } from "@mastra/core/agent";
96
+ import { client } from "./agentmark.client";
97
+
98
+ const telemetry = {
99
+ isEnabled: true,
100
+ metadata: {
101
+ traceId: "trace-123",
102
+ traceName: "customer-support",
103
+ userId: "user-123",
104
+ sessionId: "session-123",
105
+ sessionName: "my-first-session",
106
+ },
107
+ };
108
+
109
+ const runCustomerSupport = async (customer_message: string) => {
110
+ const prompt = await client.loadTextPrompt("customer-support-agent.prompt.mdx");
111
+ const agentConfig = await prompt.formatAgent({
112
+ options: {
113
+ telemetry,
114
+ },
115
+ });
116
+
117
+ const [messages, generateOptions] = await agentConfig.formatMessages({
118
+ props: {
119
+ customer_question: customer_message,
120
+ },
121
+ });
122
+
123
+ const agent = new Agent(agentConfig);
124
+ const response = await agent.generate(messages, generateOptions);
125
+
126
+ return (response as any).text || (response as any).content || String(response);
127
+ };
128
+
129
+ const main = async () => {
130
+ try {
131
+ const user_message = "How long does shipping take?";
132
+ const assistant = await runCustomerSupport(user_message);
133
+ console.log("Customer support response:", assistant);
134
+ } catch (error) {
135
+ console.error(error);
136
+ }
137
+ };
138
+
139
+ main();
140
+ `;
141
+ } else {
142
+ return `import "dotenv/config";
143
+ import { generateText } from "ai";
144
+ import { client } from "./agentmark.client";
145
+
146
+ const telemetry = {
147
+ isEnabled: true,
148
+ metadata: {
149
+ traceId: "trace-123",
150
+ traceName: "customer-support",
151
+ userId: "user-123",
152
+ sessionId: "session-123",
153
+ sessionName: "my-first-session",
154
+ },
155
+ };
156
+
157
+ const runCustomerSupport = async (customer_message: string) => {
158
+ const prompt = await client.loadTextPrompt("customer-support-agent.prompt.mdx");
159
+ const vercelInput = await prompt.format({
160
+ props: {
161
+ customer_question: customer_message,
162
+ },
163
+ telemetry,
164
+ });
165
+
166
+ const resp = await generateText(vercelInput);
167
+
168
+ return resp.text;
169
+ };
170
+
171
+ const main = async () => {
172
+ try {
173
+ const user_message = "How long does shipping take?";
174
+ const assistant = await runCustomerSupport(user_message);
175
+ console.log("Customer support response:", assistant);
176
+ } catch (error) {
177
+ console.error(error);
178
+ }
179
+ };
180
+
181
+ main();
182
+ `;
183
+ }
184
+ };
185
+
186
+ // src/utils/examples/templates/env.ts
187
+ var getEnvFileContent = (_modelProvider, apiKey = "") => {
188
+ const apiKeyValue = apiKey || "your_api_key_here";
189
+ return `# Cloud deployment: Set these environment variables
190
+ # AGENTMARK_BASE_URL=https://api.agentmark.co
191
+ # AGENTMARK_API_KEY=your_agentmark_api_key
192
+ # AGENTMARK_APP_ID=your_agentmark_app_id
193
+ # Learn more: https://docs.agentmark.co/platform/getting_started/quickstart
194
+
195
+ OPENAI_API_KEY=${apiKeyValue}
196
+ `;
197
+ };
198
+
199
+ // src/utils/examples/templates/package-setup.ts
200
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
201
+ var import_child_process = require("child_process");
202
+ var setupPackageJson = (targetPath = ".") => {
203
+ const packageJsonPath = `${targetPath}/package.json`;
204
+ if (!import_fs_extra.default.existsSync(packageJsonPath)) {
205
+ console.log("Creating package.json...");
206
+ (0, import_child_process.execSync)("npm init -y", { cwd: targetPath });
207
+ }
208
+ const pkgJson = import_fs_extra.default.readJsonSync(packageJsonPath);
209
+ pkgJson.name = pkgJson.name === "test" || !pkgJson.name ? "agentmark-example-app" : pkgJson.name;
210
+ pkgJson.description = pkgJson.description || "A simple Node.js app using the Agentmark SDK";
211
+ const devScript = "agentmark dev";
212
+ pkgJson.scripts = {
213
+ ...pkgJson.scripts,
214
+ "demo": "npx tsx index.ts",
215
+ "dev": devScript,
216
+ "prompt": "agentmark run-prompt",
217
+ "experiment": "agentmark run-experiment"
218
+ };
219
+ import_fs_extra.default.writeJsonSync(packageJsonPath, pkgJson, { spaces: 2 });
220
+ };
221
+ var installDependencies = (modelProvider, targetPath = ".", adapter = "ai-sdk") => {
222
+ console.log("Installing required packages...");
223
+ console.log("This might take a moment...");
224
+ const adapterConfig = getAdapterConfig(adapter, modelProvider);
225
+ try {
226
+ const devDepsCmd = "npm install --save-dev typescript ts-node @types/node @agentmark/cli --legacy-peer-deps";
227
+ (0, import_child_process.execSync)(devDepsCmd, {
228
+ stdio: "inherit",
229
+ cwd: targetPath
230
+ });
231
+ const installArgs = [
232
+ "install",
233
+ "dotenv",
234
+ "@agentmark/prompt-core",
235
+ "@agentmark/sdk",
236
+ adapterConfig.package,
237
+ ...adapterConfig.dependencies,
238
+ "--legacy-peer-deps"
239
+ ];
240
+ (0, import_child_process.execFileSync)("npm", installArgs, { stdio: "inherit", cwd: targetPath });
241
+ console.log("Packages installed successfully!");
242
+ } catch (error) {
243
+ console.error("Error installing packages:", error);
244
+ throw new Error(
245
+ "Failed to install required packages. Please check your network connection and try again."
246
+ );
247
+ }
248
+ };
249
+
250
+ // src/utils/examples/templates/tsconfig.ts
251
+ var getTsConfigContent = () => {
252
+ return {
253
+ "compilerOptions": {
254
+ "target": "ES2020",
255
+ "module": "NodeNext",
256
+ "moduleResolution": "NodeNext",
257
+ "esModuleInterop": true,
258
+ "forceConsistentCasingInFileNames": true,
259
+ "strict": true,
260
+ "skipLibCheck": true
261
+ }
262
+ };
263
+ };
264
+
265
+ // src/utils/examples/templates/animal-drawing-prompt.ts
266
+ var getAnimalDrawingPrompt = () => {
267
+ return `---
268
+ name: animal-drawing
269
+ image_config:
270
+ model_name: dall-e-3
271
+ num_images: 1
272
+ size: 1024x1024
273
+ aspect_ratio: 1:1
274
+ test_settings:
275
+ dataset: animal.jsonl
276
+ props:
277
+ animal: "cat"
278
+ ---
279
+
280
+ <ImagePrompt>
281
+ Draw a hyper-realistic picture of a {props.animal}
282
+ </ImagePrompt>`;
283
+ };
284
+
285
+ // src/utils/examples/templates/customer-support-prompt.ts
286
+ var getCustomerSupportPrompt = (model) => {
287
+ return `---
288
+ name: customer-support-agent
289
+ text_config:
290
+ model_name: ${model}
291
+ max_calls: 2
292
+ tools:
293
+ search_knowledgebase:
294
+ description: Search the company knowledgebase for information about shipping, warranty, and returns policies.
295
+ parameters:
296
+ type: object
297
+ properties:
298
+ query:
299
+ type: string
300
+ description: The search query to find relevant information
301
+ required: [query]
302
+ test_settings:
303
+ dataset: customer-query.jsonl
304
+ props:
305
+ customer_question: "I'm having trouble with my order. How long does shipping take?"
306
+ input_schema:
307
+ type: object
308
+ properties:
309
+ customer_question:
310
+ type: string
311
+ description: "The customer's question"
312
+ required:
313
+ - customer_question
314
+ ---
315
+
316
+ <System>
317
+ You are a customer service agent for a company that sells products online. You are given a customer's question and you need to respond to the customer. You need to be friendly, professional, and helpful.
318
+
319
+ You have access to the following tool:
320
+ - search_knowledgebase: Search the company knowledgebase for information about shipping, warranty, and returns. Use this when customers ask about these topics.
321
+ </System>
322
+
323
+ <User>{props.customer_question}</User>`;
324
+ };
325
+
326
+ // src/utils/examples/templates/party-planner-prompt.ts
327
+ var getPartyPlannerPrompt = (model) => {
328
+ return `---
329
+ name: party-planner
330
+ object_config:
331
+ model_name: ${model}
332
+ schema:
333
+ type: object
334
+ properties:
335
+ names:
336
+ type: array
337
+ description: "List of names of people attending the party."
338
+ items:
339
+ type: string
340
+ required:
341
+ - names
342
+ test_settings:
343
+ dataset: party.jsonl
344
+ evals:
345
+ - exact_match_json
346
+ props:
347
+ party_text: "We're having a party with Alice, Bob, and Carol."
348
+ input_schema:
349
+ type: object
350
+ properties:
351
+ party_text:
352
+ type: string
353
+ description: "A block of text describing the upcoming party and attendees."
354
+ required:
355
+ - party_text
356
+ ---
357
+
358
+ <System>
359
+ Extract the names of all people attending the party from the following text. Respond with a list of names only.
360
+ </System>
361
+
362
+ <User>
363
+ Text: {props.party_text}
364
+ </User>`;
365
+ };
366
+
367
+ // src/utils/examples/templates/story-teller-prompt.ts
368
+ var getStoryTellerPrompt = () => {
369
+ return `---
370
+ name: story-teller
371
+ speech_config:
372
+ model_name: tts-1-hd
373
+ voice: "nova"
374
+ speed: 1.0
375
+ output_format: "mp3"
376
+ test_settings:
377
+ dataset: story.jsonl
378
+ props:
379
+ story: "Once upon a time, there was a cat who loved to play with a ball."
380
+ ---
381
+
382
+ <System>
383
+ You are a storyteller for children. Make sure your story is engaging and interesting.
384
+ </System>
385
+
386
+ <SpeechPrompt>
387
+ - {props.story}
388
+ </SpeechPrompt>`;
389
+ };
390
+
391
+ // src/utils/examples/templates/datasets.ts
392
+ var getAnimalDataset = () => {
393
+ return `{"input": {"animal": "cat"}, "expected_output": "A realistic picture of a cat"}
394
+ {"input": {"animal": "dog"}, "expected_output": "A realistic picture of a dog"}
395
+ {"input": {"animal": "bird"}, "expected_output": "A realistic picture of a bird"}`;
396
+ };
397
+ var getCustomerQueryDataset = () => {
398
+ return `{"input": {"customer_question": "My package hasn't arrived yet. Can you help me track it?"}}
399
+ {"input": {"customer_question": "I received the wrong item in my order. What should I do?"}}
400
+ {"input": {"customer_question": "How do I return a product that I purchased last week?"}}`;
401
+ };
402
+ var getPartyDataset = () => {
403
+ return `{"input": {"party_text": "We're having a party with Alice, Bob, and Carol."}, "expected_output": "{\\"names\\": [\\"Alice\\", \\"Bob\\", \\"Carol\\"]}"}
404
+ {"input": {"party_text": "The guest list includes Dave, Emma, and Frank."}, "expected_output": "{\\"names\\": [\\"Dave\\", \\"Emma\\", \\"Frank\\"]}"}
405
+ {"input": {"party_text": "Join us for a celebration with Grace, Henry, and Isla."}, "expected_output": "{\\"names\\": [\\"Grace\\", \\"Henry\\", \\"Isla\\"]}"}`;
406
+ };
407
+ var getStoryDataset = () => {
408
+ return `{"input": {"story": "Once upon a time, the Moon woke up and found her glow missing! She floated around the sky asking stars, clouds, and even comets if they'd seen her light. It wasn't until she peeked into a mountain lake that she saw her glow shining back\u2014hidden in her own reflection! Laughing, she realized she had never lost it\u2014it was with her all along, just hiding beneath a cloudy sky."}}
409
+ {"input": {"story": "Benny was no ordinary banana\u2014he dreamed of becoming a superhero. One day, when a monkey slipped in the jungle and cried for help, Benny rolled into action, dodging vines and swinging from branches using his peel like a lasso. The monkey was saved, and from that day on, Benny was known as \\"The Peel of Justice,\\" the bravest fruit in the whole rainforest."}}
410
+ {"input": {"story": "In the town of Maplebrook, there was a library that whispered stories when no one was looking. Curious little Nia tiptoed in one rainy day and heard the books giggling softly. She opened one called The Secret Tunnel, and to her surprise, it sucked her in! She found herself riding a dragon through glittering caves. When she returned, the book winked shut\u2014waiting for its next reader to listen."}}`;
411
+ };
412
+
413
+ // src/utils/examples/templates/example-prompts.ts
414
+ var import_fs_extra2 = __toESM(require("fs-extra"), 1);
415
+ var createExamplePrompts = (model, targetPath = ".", adapter = "ai-sdk") => {
416
+ import_fs_extra2.default.ensureDirSync(`${targetPath}/agentmark`);
417
+ if (adapter !== "mastra") {
418
+ const animalDrawingPrompt = getAnimalDrawingPrompt();
419
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/animal-drawing.prompt.mdx`, animalDrawingPrompt);
420
+ const animalDataset = getAnimalDataset();
421
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/animal.jsonl`, animalDataset);
422
+ }
423
+ const customerSupportPrompt = getCustomerSupportPrompt(model);
424
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/customer-support-agent.prompt.mdx`, customerSupportPrompt);
425
+ const customerQueryDataset = getCustomerQueryDataset();
426
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/customer-query.jsonl`, customerQueryDataset);
427
+ const partyPlannerPrompt = getPartyPlannerPrompt(model);
428
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/party-planner.prompt.mdx`, partyPlannerPrompt);
429
+ const partyDataset = getPartyDataset();
430
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/party.jsonl`, partyDataset);
431
+ if (adapter !== "mastra") {
432
+ const storyTellerPrompt = getStoryTellerPrompt();
433
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/story-teller.prompt.mdx`, storyTellerPrompt);
434
+ const storyDataset = getStoryDataset();
435
+ import_fs_extra2.default.writeFileSync(`${targetPath}/agentmark/story.jsonl`, storyDataset);
436
+ }
437
+ };
438
+
439
+ // src/utils/examples/templates/user-client-config.ts
440
+ var getClientConfigContent = (options) => {
441
+ const { provider, languageModels, adapter } = options;
442
+ const adapterConfig = getAdapterConfig(adapter);
443
+ const { modelRegistry, toolRegistry } = adapterConfig.classes;
444
+ const providerImport = `import { ${provider} } from '@ai-sdk/${provider}';`;
445
+ const extraModelRegs = provider === "openai" ? `.registerModels(["dall-e-3"], (name: string) => ${provider}.image(name))
446
+ .registerModels(["tts-1-hd"], (name: string) => ${provider}.speech(name))` : "";
447
+ return `// agentmark.client.ts
448
+ import path from 'node:path';
449
+ import dotenv from 'dotenv';
450
+ dotenv.config({ path: path.resolve(__dirname, '.env') });
451
+ import { createAgentMarkClient, ${modelRegistry}, ${toolRegistry}, EvalRegistry } from "${adapterConfig.package}";
452
+ import { AgentMarkSDK } from "@agentmark/sdk";
453
+ import AgentMarkTypes, { Tools } from './agentmark.types';
454
+ ${providerImport}
455
+
456
+ function createModelRegistry() {
457
+ const modelRegistry = new ${modelRegistry}()
458
+ .registerModels(${JSON.stringify(languageModels)}, (name: string) => ${provider}(name))
459
+ ${extraModelRegs};
460
+ return modelRegistry;
461
+ }
462
+
463
+ function createToolRegistry() {
464
+ const toolRegistry = new ${toolRegistry}<Tools>()
465
+ .register('search_knowledgebase', async ({ query }) => {
466
+ // Simulate search delay
467
+ await new Promise(resolve => setTimeout(resolve, 500));
468
+
469
+ // Return all three knowledge base articles
470
+ // The LLM will select the relevant one based on the query
471
+ return {
472
+ articles: [
473
+ { topic: 'shipping', content: 'Standard shipping takes 3\u20135 business days.' },
474
+ { topic: 'warranty', content: 'All products include a 1-year limited warranty.' },
475
+ { topic: 'returns', content: 'You can return items within 30 days of delivery.' }
476
+ ]
477
+ };
478
+ });
479
+ return toolRegistry;
480
+ }
481
+
482
+ function createEvalRegistry() {
483
+ const evalRegistry = new EvalRegistry()
484
+ .register('exact_match_json', ({ output, expectedOutput }) => {
485
+ if (!expectedOutput) {
486
+ return { score: 0, label: 'error', reason: 'No expected output provided', passed: false };
487
+ }
488
+ try {
489
+ const ok = JSON.stringify(output) === JSON.stringify(JSON.parse(expectedOutput));
490
+ return {
491
+ score: ok ? 1 : 0,
492
+ label: ok ? 'correct' : 'incorrect',
493
+ reason: ok ? 'Exact match' : 'Mismatch',
494
+ passed: ok
495
+ };
496
+ } catch (e) {
497
+ return { score: 0, label: 'error', reason: 'Failed to parse expected output as JSON', passed: false };
498
+ }
499
+ });
500
+ return evalRegistry;
501
+ }
502
+
503
+ function createClient(ctx?: { env?: Record<string,string|undefined> }) {
504
+ const env = (ctx?.env ?? process.env) as Record<string, string | undefined>;
505
+ // For local development, connect to the local agentmark serve instance (default: http://localhost:9418)
506
+ // For cloud deployment, set AGENTMARK_BASE_URL, AGENTMARK_API_KEY, and AGENTMARK_APP_ID
507
+ const baseUrl = env.AGENTMARK_BASE_URL || 'http://localhost:9418';
508
+ const apiKey = env.AGENTMARK_API_KEY || '';
509
+ const appId = env.AGENTMARK_APP_ID || '';
510
+ const sdk = new AgentMarkSDK({ apiKey, appId, baseUrl });
511
+ const fileLoader = sdk.getFileLoader();
512
+ const modelRegistry = createModelRegistry();
513
+ const toolRegistry = createToolRegistry();
514
+ const evalRegistry = createEvalRegistry();
515
+ return createAgentMarkClient<AgentMarkTypes, typeof toolRegistry>({ loader: fileLoader, modelRegistry, toolRegistry, evalRegistry });
516
+ }
517
+
518
+ export const client = createClient();
519
+ `;
520
+ };
521
+
522
+ // src/utils/examples/create-example-app.ts
523
+ var import_shared_utils = require("@agentmark/shared-utils");
524
+ var setupMCPServer = (client, targetPath) => {
525
+ if (client === "skip") {
526
+ console.log("Skipping MCP server setup.");
527
+ return;
528
+ }
529
+ const folderName = targetPath;
530
+ if (client === "vscode") {
531
+ try {
532
+ console.log(`Setting up MCP server for VS Code in ${folderName}...`);
533
+ const vscodeDir = path.join(targetPath, ".vscode");
534
+ import_fs_extra3.default.ensureDirSync(vscodeDir);
535
+ const mcpConfig = {
536
+ servers: {
537
+ "agentmark-docs": {
538
+ url: "https://docs.agentmark.co/mcp"
539
+ }
540
+ }
541
+ };
542
+ import_fs_extra3.default.writeJsonSync(path.join(vscodeDir, "mcp.json"), mcpConfig, { spaces: 2 });
543
+ console.log(`\u2705 MCP server configured for VS Code in ${folderName}/.vscode/mcp.json`);
544
+ } catch (error) {
545
+ console.warn(`Warning: Could not set up MCP server for VS Code:`, error);
546
+ console.log("See https://docs.agentmark.co/agentmark/further_reference/agentmark-mcp for setup instructions.");
547
+ }
548
+ return;
549
+ }
550
+ if (client === "zed") {
551
+ try {
552
+ console.log(`Setting up MCP server for Zed in ${folderName}...`);
553
+ const zedDir = path.join(targetPath, ".zed");
554
+ import_fs_extra3.default.ensureDirSync(zedDir);
555
+ const zedConfig = {
556
+ context_servers: {
557
+ "agentmark-docs": {
558
+ url: "https://docs.agentmark.co/mcp"
559
+ }
560
+ }
561
+ };
562
+ import_fs_extra3.default.writeJsonSync(path.join(zedDir, "settings.json"), zedConfig, { spaces: 2 });
563
+ console.log(`\u2705 MCP server configured for Zed in ${folderName}/.zed/settings.json`);
564
+ } catch (error) {
565
+ console.warn(`Warning: Could not set up MCP server for Zed:`, error);
566
+ console.log("See https://docs.agentmark.co/agentmark/further_reference/agentmark-mcp for setup instructions.");
567
+ }
568
+ return;
569
+ }
570
+ if (client === "cursor") {
571
+ try {
572
+ console.log(`Setting up MCP server for Cursor in ${folderName}...`);
573
+ const cursorDir = path.join(targetPath, ".cursor");
574
+ import_fs_extra3.default.ensureDirSync(cursorDir);
575
+ const cursorConfig = {
576
+ mcpServers: {
577
+ "agentmark-docs": {
578
+ url: "https://docs.agentmark.co/mcp"
579
+ }
580
+ }
581
+ };
582
+ import_fs_extra3.default.writeJsonSync(path.join(cursorDir, "mcp.json"), cursorConfig, { spaces: 2 });
583
+ console.log(`\u2705 MCP server configured for Cursor in ${folderName}/.cursor/mcp.json`);
584
+ } catch (error) {
585
+ console.warn(`Warning: Could not set up MCP server for Cursor:`, error);
586
+ console.log("See https://docs.agentmark.co/agentmark/further_reference/agentmark-mcp for setup instructions.");
587
+ }
588
+ return;
589
+ }
590
+ if (client === "claude-code") {
591
+ try {
592
+ console.log(`Setting up MCP server for Claude Code in ${folderName}...`);
593
+ const mcpConfig = {
594
+ mcpServers: {
595
+ "agentmark-docs": {
596
+ type: "http",
597
+ url: "https://docs.agentmark.co/mcp"
598
+ }
599
+ }
600
+ };
601
+ import_fs_extra3.default.writeJsonSync(path.join(targetPath, ".mcp.json"), mcpConfig, { spaces: 2 });
602
+ console.log(`\u2705 MCP server configured for Claude Code in ${folderName}/.mcp.json`);
603
+ } catch (error) {
604
+ console.warn(`Warning: Could not set up MCP server for Claude Code:`, error);
605
+ console.log("See https://docs.agentmark.co/agentmark/further_reference/agentmark-mcp for setup instructions.");
606
+ }
607
+ return;
608
+ }
609
+ };
610
+ var createExampleApp = async (client, targetPath = ".", apiKey = "", adapter = "ai-sdk") => {
611
+ try {
612
+ const modelProvider = "openai";
613
+ const model = "gpt-4o";
614
+ console.log("Creating Agent Mark example app...");
615
+ const folderName = targetPath;
616
+ import_fs_extra3.default.ensureDirSync(`${targetPath}/agentmark`);
617
+ setupMCPServer(client, targetPath);
618
+ createExamplePrompts(model, targetPath, adapter);
619
+ console.log(`\u2705 Example prompts and datasets created in ${folderName}/agentmark/`);
620
+ const langModels = Providers[modelProvider].languageModels.slice(0, 1);
621
+ import_fs_extra3.default.writeFileSync(
622
+ `${targetPath}/agentmark.client.ts`,
623
+ getClientConfigContent({ provider: modelProvider, languageModels: langModels, adapter })
624
+ );
625
+ import_fs_extra3.default.writeFileSync(`${targetPath}/.env`, getEnvFileContent(modelProvider, apiKey));
626
+ const gitignore = ["node_modules", ".env", "*.agentmark-outputs/", ".agentmark"].join("\n");
627
+ import_fs_extra3.default.writeFileSync(`${targetPath}/.gitignore`, gitignore);
628
+ import_fs_extra3.default.writeFileSync(
629
+ `${targetPath}/index.ts`,
630
+ getIndexFileContent(adapter)
631
+ );
632
+ import_fs_extra3.default.writeJsonSync(`${targetPath}/tsconfig.json`, getTsConfigContent(), { spaces: 2 });
633
+ setupPackageJson(targetPath);
634
+ installDependencies(modelProvider, targetPath, adapter);
635
+ console.log("Generating types from prompts...");
636
+ try {
637
+ const agentmarkDir = path.join(targetPath, "agentmark");
638
+ const prompts2 = await (0, import_shared_utils.fetchPromptsFrontmatter)({ rootDir: agentmarkDir });
639
+ const typeDefinitions = await (0, import_shared_utils.generateTypeDefinitions)(prompts2);
640
+ import_fs_extra3.default.writeFileSync(`${targetPath}/agentmark.types.ts`, typeDefinitions);
641
+ } catch (error) {
642
+ console.warn("Warning: Could not generate types automatically:", error);
643
+ console.log("You can generate types later by running: npx agentmark generate-types --root-dir agentmark");
644
+ import_fs_extra3.default.writeFileSync(`${targetPath}/agentmark.types.ts`, `// Auto-generated types from AgentMark
645
+ // Run 'npx agentmark generate-types --root-dir agentmark' to generate types
646
+ export default interface AgentmarkTypes {}
647
+ `);
648
+ }
649
+ console.log("Creating development server entry point...");
650
+ const agentmarkInternalDir = path.join(targetPath, ".agentmark");
651
+ import_fs_extra3.default.ensureDirSync(agentmarkInternalDir);
652
+ const adapterConfig = getAdapterConfig(adapter);
653
+ const { webhookHandler } = adapterConfig.classes;
654
+ const devEntryContent = `// Auto-generated webhook server entry point
655
+ // To customize, create a dev-server.ts file in your project root
656
+
657
+ import { createWebhookServer } from '@agentmark/cli/runner-server';
658
+ import { ${webhookHandler} } from '${adapterConfig.package}/runner';
659
+ import { AgentMarkSDK } from '@agentmark/sdk';
660
+ import path from 'path';
661
+
662
+ async function main() {
663
+ const { client } = await import('../agentmark.client.js');
664
+
665
+ const args = process.argv.slice(2);
666
+ const webhookPortArg = args.find(arg => arg.startsWith('--webhook-port='));
667
+ const fileServerPortArg = args.find(arg => arg.startsWith('--file-server-port='));
668
+
669
+ const webhookPort = webhookPortArg ? parseInt(webhookPortArg.split('=')[1]) : 9417;
670
+ const fileServerPort = fileServerPortArg ? parseInt(fileServerPortArg.split('=')[1]) : 9418;
671
+
672
+ // Initialize OpenTelemetry tracing to export traces to the API server
673
+ const fileServerUrl = \`http://localhost:\${fileServerPort}\`;
674
+ const sdk = new AgentMarkSDK({
675
+ apiKey: '',
676
+ appId: '',
677
+ baseUrl: fileServerUrl,
678
+ });
679
+ sdk.initTracing({ disableBatch: true });
680
+
681
+ const handler = new ${webhookHandler}(client as any);
682
+ const templatesDirectory = path.join(process.cwd(), 'agentmark');
683
+
684
+ await createWebhookServer({
685
+ port: webhookPort,
686
+ handler,
687
+ fileServerUrl,
688
+ templatesDirectory
689
+ });
690
+ }
691
+
692
+ main().catch((err) => {
693
+ console.error(err);
694
+ process.exit(1);
695
+ });
696
+ `;
697
+ import_fs_extra3.default.writeFileSync(path.join(agentmarkInternalDir, "dev-entry.ts"), devEntryContent);
698
+ const webhookUrl = "http://localhost:9417";
699
+ const envPath = path.join(targetPath, ".env");
700
+ let envContent = "";
701
+ if ((0, import_fs.existsSync)(envPath)) {
702
+ envContent = (0, import_fs.readFileSync)(envPath, "utf8");
703
+ if (!envContent.includes("AGENTMARK_WEBHOOK_URL")) {
704
+ envContent += `
705
+ # AgentMark runner server URL
706
+ AGENTMARK_WEBHOOK_URL=${webhookUrl}
707
+ `;
708
+ }
709
+ } else {
710
+ envContent = `# AgentMark runner server URL
711
+ AGENTMARK_WEBHOOK_URL=${webhookUrl}
712
+
713
+ # Add your API keys here
714
+ # OPENAI_API_KEY=your-key-here
715
+ `;
716
+ }
717
+ (0, import_fs.writeFileSync)(envPath, envContent, "utf8");
718
+ console.log("\n\u2705 Agentmark initialization completed successfully!");
719
+ console.log(
720
+ `
721
+ \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557
722
+ \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u255D
723
+ \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2554\u255D
724
+ \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2557
725
+ \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557
726
+ \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
727
+
728
+ `
729
+ );
730
+ console.log("\n" + "\u2550".repeat(70));
731
+ console.log("Next Steps");
732
+ console.log("\u2550".repeat(70));
733
+ console.log("\n Get Started:");
734
+ if (folderName !== "." && folderName !== "./") {
735
+ console.log(` $ cd ${folderName}`);
736
+ }
737
+ console.log(" $ npm run dev\n");
738
+ console.log("\u2500".repeat(70));
739
+ console.log("Resources");
740
+ console.log("\u2500".repeat(70));
741
+ console.log(" Documentation: https://docs.agentmark.co");
742
+ console.log("\u2550".repeat(70) + "\n");
743
+ } catch (error) {
744
+ console.error("Error creating example app:", error);
745
+ throw error;
746
+ }
747
+ };
748
+
749
+ // src/index.ts
750
+ var main = async () => {
751
+ const config = {
752
+ $schema: "https://raw.githubusercontent.com/agentmark-ai/agentmark/refs/heads/main/packages/cli/agentmark.schema.json",
753
+ version: "2.0.0",
754
+ mdxVersion: "1.0",
755
+ agentmarkPath: "."
756
+ };
757
+ console.log("Initializing project.");
758
+ const { folderName } = await (0, import_prompts.default)({
759
+ name: "folderName",
760
+ type: "text",
761
+ message: "Where would you like to create your AgentMark app?",
762
+ initial: "my-agentmark-app"
763
+ });
764
+ const targetPath = `./${folderName}`;
765
+ import_fs_extra4.default.ensureDirSync(targetPath);
766
+ config.builtInModels = ["gpt-4o"];
767
+ let apiKey = "";
768
+ const { providedApiKey } = await (0, import_prompts.default)({
769
+ name: "providedApiKey",
770
+ type: "password",
771
+ message: `Enter your OpenAI API key (or press Enter to skip):`,
772
+ initial: ""
773
+ });
774
+ apiKey = providedApiKey || "";
775
+ const { adapter } = await (0, import_prompts.default)({
776
+ name: "adapter",
777
+ type: "select",
778
+ message: "Which adapter would you like to use?",
779
+ choices: [
780
+ { title: "AI SDK (Vercel)", value: "ai-sdk" },
781
+ { title: "Mastra", value: "mastra" }
782
+ ]
783
+ });
784
+ const { client } = await (0, import_prompts.default)({
785
+ name: "client",
786
+ type: "select",
787
+ message: "Make your IDE an AgentMark expert",
788
+ choices: [
789
+ { title: "Claude Code", value: "claude-code" },
790
+ { title: "Cursor", value: "cursor" },
791
+ { title: "VS Code", value: "vscode" },
792
+ { title: "Zed", value: "zed" },
793
+ { title: "Skip", value: "skip" }
794
+ ]
795
+ });
796
+ await createExampleApp(client, targetPath, apiKey, adapter);
797
+ import_fs_extra4.default.writeJsonSync(`${targetPath}/agentmark.json`, config, { spaces: 2 });
798
+ };
799
+ main().catch((error) => {
800
+ console.error("Error:", error);
801
+ process.exit(1);
802
+ });
803
+ //# sourceMappingURL=index.cjs.map