create-agentmark 0.8.4 → 0.10.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/dist/index.js
CHANGED
|
@@ -17,7 +17,6 @@ var createAdapterConfig = (provider) => {
|
|
|
17
17
|
dependencies: ["ai@^5", `@ai-sdk/${provider}@^2`],
|
|
18
18
|
classes: {
|
|
19
19
|
modelRegistry: "VercelAIModelRegistry",
|
|
20
|
-
toolRegistry: "VercelAIToolRegistry",
|
|
21
20
|
webhookHandler: "VercelAdapterWebhookHandler"
|
|
22
21
|
}
|
|
23
22
|
},
|
|
@@ -26,11 +25,11 @@ var createAdapterConfig = (provider) => {
|
|
|
26
25
|
dependencies: [
|
|
27
26
|
"@mastra/core@<0.20.0",
|
|
28
27
|
"@mastra/mcp@<0.13.4",
|
|
29
|
-
`@ai-sdk/${provider}@<2
|
|
28
|
+
`@ai-sdk/${provider}@<2`,
|
|
29
|
+
"ai@^4"
|
|
30
30
|
],
|
|
31
31
|
classes: {
|
|
32
32
|
modelRegistry: "MastraModelRegistry",
|
|
33
|
-
toolRegistry: "MastraToolRegistry",
|
|
34
33
|
webhookHandler: "MastraAdapterWebhookHandler"
|
|
35
34
|
}
|
|
36
35
|
},
|
|
@@ -39,7 +38,6 @@ var createAdapterConfig = (provider) => {
|
|
|
39
38
|
dependencies: ["@anthropic-ai/claude-agent-sdk@^0.1.0"],
|
|
40
39
|
classes: {
|
|
41
40
|
modelRegistry: "ClaudeAgentModelRegistry",
|
|
42
|
-
toolRegistry: "ClaudeAgentToolRegistry",
|
|
43
41
|
webhookHandler: "ClaudeAgentWebhookHandler"
|
|
44
42
|
}
|
|
45
43
|
}
|
|
@@ -229,16 +227,22 @@ main();
|
|
|
229
227
|
};
|
|
230
228
|
|
|
231
229
|
// src/utils/examples/templates/env.ts
|
|
232
|
-
var getEnvFileContent = (_modelProvider, apiKey = "", adapter = "ai-sdk") => {
|
|
230
|
+
var getEnvFileContent = (_modelProvider, apiKey = "", adapter = "ai-sdk", deploymentMode = "cloud") => {
|
|
233
231
|
const apiKeyValue = apiKey || "your_api_key_here";
|
|
234
232
|
const apiKeyName = adapter === "claude-agent-sdk" ? "ANTHROPIC_API_KEY" : "OPENAI_API_KEY";
|
|
235
|
-
|
|
233
|
+
const cloudEnvVars = deploymentMode === "cloud" ? `
|
|
234
|
+
# AgentMark Cloud \u2014 required for managed deployments
|
|
235
|
+
AGENTMARK_API_KEY=your_agentmark_api_key
|
|
236
|
+
AGENTMARK_APP_ID=your_agentmark_app_id
|
|
237
|
+
` : `
|
|
238
|
+
# Cloud deployment: Set these environment variables
|
|
236
239
|
# AGENTMARK_BASE_URL=https://api.agentmark.co
|
|
237
240
|
# AGENTMARK_API_KEY=your_agentmark_api_key
|
|
238
241
|
# AGENTMARK_APP_ID=your_agentmark_app_id
|
|
242
|
+
`;
|
|
243
|
+
return `${apiKeyName}=${apiKeyValue}
|
|
244
|
+
${cloudEnvVars}
|
|
239
245
|
# Learn more: https://docs.agentmark.co/platform/getting_started/quickstart
|
|
240
|
-
|
|
241
|
-
${apiKeyName}=${apiKeyValue}
|
|
242
246
|
`;
|
|
243
247
|
};
|
|
244
248
|
|
|
@@ -718,20 +722,23 @@ var getStoryDataset = () => {
|
|
|
718
722
|
import fs3 from "fs-extra";
|
|
719
723
|
var createExamplePrompts = (model, targetPath = ".", adapter = "ai-sdk") => {
|
|
720
724
|
fs3.ensureDirSync(`${targetPath}/agentmark`);
|
|
721
|
-
const noImageSupport = ["mastra", "claude-agent-sdk"];
|
|
722
|
-
const noSpeechSupport = ["mastra", "claude-agent-sdk"];
|
|
725
|
+
const noImageSupport = ["mastra", "claude-agent-sdk", "pydantic-ai"];
|
|
726
|
+
const noSpeechSupport = ["mastra", "claude-agent-sdk", "pydantic-ai"];
|
|
723
727
|
const skipImagePrompts = noImageSupport.includes(adapter);
|
|
724
728
|
const skipSpeechPrompts = noSpeechSupport.includes(adapter);
|
|
729
|
+
const usedModels = [];
|
|
725
730
|
if (!skipImagePrompts) {
|
|
726
731
|
const animalDrawingPrompt = getAnimalDrawingPrompt();
|
|
727
732
|
fs3.writeFileSync(`${targetPath}/agentmark/animal-drawing.prompt.mdx`, animalDrawingPrompt);
|
|
728
733
|
const animalDataset = getAnimalDataset();
|
|
729
734
|
fs3.writeFileSync(`${targetPath}/agentmark/animal.jsonl`, animalDataset);
|
|
735
|
+
usedModels.push("openai/dall-e-3");
|
|
730
736
|
}
|
|
731
737
|
const customerSupportPrompt = getCustomerSupportPrompt(model);
|
|
732
738
|
fs3.writeFileSync(`${targetPath}/agentmark/customer-support-agent.prompt.mdx`, customerSupportPrompt);
|
|
733
739
|
const customerQueryDataset = getCustomerQueryDataset();
|
|
734
740
|
fs3.writeFileSync(`${targetPath}/agentmark/customer-query.jsonl`, customerQueryDataset);
|
|
741
|
+
usedModels.push(model);
|
|
735
742
|
const partyPlannerPrompt = getPartyPlannerPrompt(model);
|
|
736
743
|
fs3.writeFileSync(`${targetPath}/agentmark/party-planner.prompt.mdx`, partyPlannerPrompt);
|
|
737
744
|
const partyDataset = getPartyDataset();
|
|
@@ -741,14 +748,17 @@ var createExamplePrompts = (model, targetPath = ".", adapter = "ai-sdk") => {
|
|
|
741
748
|
fs3.writeFileSync(`${targetPath}/agentmark/story-teller.prompt.mdx`, storyTellerPrompt);
|
|
742
749
|
const storyDataset = getStoryDataset();
|
|
743
750
|
fs3.writeFileSync(`${targetPath}/agentmark/story.jsonl`, storyDataset);
|
|
751
|
+
usedModels.push("openai/tts-1-hd");
|
|
744
752
|
}
|
|
753
|
+
return [...new Set(usedModels)];
|
|
745
754
|
};
|
|
746
755
|
|
|
747
756
|
// src/utils/examples/templates/user-client-config.ts
|
|
748
757
|
var getClientConfigContent = (options) => {
|
|
749
758
|
const { provider, adapter, deploymentMode = "cloud" } = options;
|
|
759
|
+
const isMastra = adapter === "mastra";
|
|
750
760
|
const adapterConfig = getAdapterConfig(adapter, provider);
|
|
751
|
-
const { modelRegistry
|
|
761
|
+
const { modelRegistry } = adapterConfig.classes;
|
|
752
762
|
const isClaudeAgentSdk = adapter === "claude-agent-sdk";
|
|
753
763
|
const providerImport = isClaudeAgentSdk ? "" : `import { ${provider} } from '@ai-sdk/${provider}';`;
|
|
754
764
|
const loaderImport = deploymentMode === "cloud" ? `import { ApiLoader } from "@agentmark-ai/loader-api";` : `import { ApiLoader } from "@agentmark-ai/loader-api";
|
|
@@ -807,64 +817,98 @@ const adapterOptions = {
|
|
|
807
817
|
// allowedTools: ['Read', 'Write', 'Glob'],
|
|
808
818
|
// disallowedTools: ['Bash'],
|
|
809
819
|
};` : "";
|
|
810
|
-
const
|
|
820
|
+
const toolImport = isClaudeAgentSdk ? `import { tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
|
|
821
|
+
import { z } from 'zod';` : isMastra ? `import { tool } from 'ai';
|
|
822
|
+
import type { ToolsInput } from '@mastra/core/agent';
|
|
823
|
+
import { z } from 'zod';` : `import { tool } from 'ai';
|
|
824
|
+
import type { Tool } from 'ai';
|
|
825
|
+
import { z } from 'zod';`;
|
|
826
|
+
const createClientCall = isClaudeAgentSdk ? `return createAgentMarkClient<AgentMarkTypes>({ loader, modelRegistry, evalRegistry, adapterOptions, mcpServers: { 'customer-support': customerSupportTools } });` : `return createAgentMarkClient<AgentMarkTypes>({ loader, modelRegistry, tools, evalRegistry });`;
|
|
827
|
+
const toolSchemaField = isMastra ? `parameters: z.object({ query: z.string().describe('The search query') })` : `inputSchema: z.object({ query: z.string().describe('The search query') })`;
|
|
828
|
+
const toolsReturnType = isMastra ? "ToolsInput" : "Record<string, Tool>";
|
|
829
|
+
const toolsSetup = isClaudeAgentSdk ? `
|
|
830
|
+
// Custom tools exposed as an MCP server \u2014 the SDK's native tool mechanism.
|
|
831
|
+
// The server name is used in mcpServers config; tool names are used in prompt files.
|
|
832
|
+
const knowledgeBase = tool(
|
|
833
|
+
'search_knowledgebase',
|
|
834
|
+
'Search the knowledge base for relevant articles',
|
|
835
|
+
{ query: z.string().describe('The search query') },
|
|
836
|
+
async ({ query }) => ({
|
|
837
|
+
content: [{ type: 'text' as const, text: JSON.stringify({
|
|
838
|
+
articles: [
|
|
839
|
+
{ topic: 'shipping', content: 'Standard shipping takes 3\u20135 business days.' },
|
|
840
|
+
{ topic: 'warranty', content: 'All products include a 1-year limited warranty.' },
|
|
841
|
+
{ topic: 'returns', content: 'You can return items within 30 days of delivery.' },
|
|
842
|
+
],
|
|
843
|
+
}) }],
|
|
844
|
+
})
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
const customerSupportTools = createSdkMcpServer({
|
|
848
|
+
name: 'customer-support',
|
|
849
|
+
tools: [knowledgeBase],
|
|
850
|
+
});` : `
|
|
851
|
+
function createTools(): ${toolsReturnType} {
|
|
852
|
+
return {
|
|
853
|
+
search_knowledgebase: tool({
|
|
854
|
+
description: 'Search the knowledge base for relevant articles',
|
|
855
|
+
${toolSchemaField},
|
|
856
|
+
execute: async ({ query }) => {
|
|
857
|
+
// Simulate search delay
|
|
858
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
859
|
+
|
|
860
|
+
// Return all three knowledge base articles
|
|
861
|
+
// The LLM will select the relevant one based on the query
|
|
862
|
+
return {
|
|
863
|
+
articles: [
|
|
864
|
+
{ topic: 'shipping', content: 'Standard shipping takes 3\u20135 business days.' },
|
|
865
|
+
{ topic: 'warranty', content: 'All products include a 1-year limited warranty.' },
|
|
866
|
+
{ topic: 'returns', content: 'You can return items within 30 days of delivery.' }
|
|
867
|
+
]
|
|
868
|
+
};
|
|
869
|
+
},
|
|
870
|
+
}),
|
|
871
|
+
};
|
|
872
|
+
}`;
|
|
873
|
+
const toolsVariable = isClaudeAgentSdk ? "" : ` const tools = createTools();`;
|
|
811
874
|
return `// agentmark.client.ts
|
|
812
875
|
import path from 'node:path';
|
|
813
876
|
import dotenv from 'dotenv';
|
|
814
877
|
dotenv.config({ path: path.resolve(__dirname, '.env') });
|
|
815
|
-
import { createAgentMarkClient, ${modelRegistry}
|
|
878
|
+
import { createAgentMarkClient, ${modelRegistry} } from "${adapterConfig.package}";
|
|
879
|
+
import type { EvalRegistry } from "${adapterConfig.package}";
|
|
816
880
|
${loaderImport}
|
|
817
|
-
import AgentMarkTypes
|
|
881
|
+
import AgentMarkTypes from './agentmark.types';
|
|
818
882
|
${providerImport}
|
|
883
|
+
${toolImport}
|
|
819
884
|
${adapterOptionsImport}
|
|
820
885
|
|
|
821
886
|
${modelRegistrySetup}
|
|
887
|
+
${toolsSetup}
|
|
822
888
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
// The LLM will select the relevant one based on the query
|
|
889
|
+
const evalRegistry: EvalRegistry = {
|
|
890
|
+
exact_match_json: ({ output, expectedOutput }) => {
|
|
891
|
+
if (!expectedOutput) {
|
|
892
|
+
return { score: 0, label: 'error', reason: 'No expected output provided', passed: false };
|
|
893
|
+
}
|
|
894
|
+
try {
|
|
895
|
+
const ok = JSON.stringify(output) === JSON.stringify(JSON.parse(expectedOutput));
|
|
831
896
|
return {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
]
|
|
897
|
+
score: ok ? 1 : 0,
|
|
898
|
+
label: ok ? 'correct' : 'incorrect',
|
|
899
|
+
reason: ok ? 'Exact match' : 'Mismatch',
|
|
900
|
+
passed: ok
|
|
837
901
|
};
|
|
838
|
-
})
|
|
839
|
-
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
const evalRegistry = new EvalRegistry()
|
|
844
|
-
.register('exact_match_json', ({ output, expectedOutput }) => {
|
|
845
|
-
if (!expectedOutput) {
|
|
846
|
-
return { score: 0, label: 'error', reason: 'No expected output provided', passed: false };
|
|
847
|
-
}
|
|
848
|
-
try {
|
|
849
|
-
const ok = JSON.stringify(output) === JSON.stringify(JSON.parse(expectedOutput));
|
|
850
|
-
return {
|
|
851
|
-
score: ok ? 1 : 0,
|
|
852
|
-
label: ok ? 'correct' : 'incorrect',
|
|
853
|
-
reason: ok ? 'Exact match' : 'Mismatch',
|
|
854
|
-
passed: ok
|
|
855
|
-
};
|
|
856
|
-
} catch (e) {
|
|
857
|
-
return { score: 0, label: 'error', reason: 'Failed to parse expected output as JSON', passed: false };
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
return evalRegistry;
|
|
861
|
-
}
|
|
902
|
+
} catch (e) {
|
|
903
|
+
return { score: 0, label: 'error', reason: 'Failed to parse expected output as JSON', passed: false };
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
};
|
|
862
907
|
|
|
863
908
|
function createClient() {
|
|
864
909
|
${loaderSetup}
|
|
865
910
|
const modelRegistry = createModelRegistry();
|
|
866
|
-
|
|
867
|
-
const evalRegistry = createEvalRegistry();
|
|
911
|
+
${toolsVariable}
|
|
868
912
|
${createClientCall}
|
|
869
913
|
}
|
|
870
914
|
|
|
@@ -966,38 +1010,6 @@ function displayProjectDetectionSummary(projectInfo) {
|
|
|
966
1010
|
console.log("");
|
|
967
1011
|
}
|
|
968
1012
|
|
|
969
|
-
// src/utils/git-init.ts
|
|
970
|
-
import { execSync as execSync2 } from "child_process";
|
|
971
|
-
function initGitRepo(targetPath) {
|
|
972
|
-
try {
|
|
973
|
-
try {
|
|
974
|
-
execSync2("git --version", { stdio: "ignore" });
|
|
975
|
-
} catch {
|
|
976
|
-
console.log("\u26A0\uFE0F git not found \u2014 skipping repository initialization");
|
|
977
|
-
return false;
|
|
978
|
-
}
|
|
979
|
-
try {
|
|
980
|
-
execSync2("git rev-parse --is-inside-work-tree", {
|
|
981
|
-
cwd: targetPath,
|
|
982
|
-
stdio: "ignore"
|
|
983
|
-
});
|
|
984
|
-
return false;
|
|
985
|
-
} catch {
|
|
986
|
-
}
|
|
987
|
-
execSync2("git init", { cwd: targetPath, stdio: "ignore" });
|
|
988
|
-
execSync2("git add -A", { cwd: targetPath, stdio: "ignore" });
|
|
989
|
-
execSync2(
|
|
990
|
-
'git -c user.name="create-agentmark" -c user.email="noreply" commit -m "Initial commit from create-agentmark"',
|
|
991
|
-
{ cwd: targetPath, stdio: "ignore" }
|
|
992
|
-
);
|
|
993
|
-
console.log("\u2705 Initialized git repository with initial commit");
|
|
994
|
-
return true;
|
|
995
|
-
} catch {
|
|
996
|
-
console.log("\u26A0\uFE0F Could not initialize git repository");
|
|
997
|
-
return false;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
1013
|
// src/utils/examples/create-example-app.ts
|
|
1002
1014
|
var setupMCPServer = (client, targetPath) => {
|
|
1003
1015
|
if (client === "skip") {
|
|
@@ -1126,7 +1138,7 @@ var createExampleApp = async (client, targetPath = ".", apiKey = "", adapter = "
|
|
|
1126
1138
|
const folderName = targetPath;
|
|
1127
1139
|
fs4.ensureDirSync(`${targetPath}/agentmark`);
|
|
1128
1140
|
setupMCPServer(client, targetPath);
|
|
1129
|
-
createExamplePrompts(model, targetPath, adapter);
|
|
1141
|
+
const usedModels = createExamplePrompts(model, targetPath, adapter);
|
|
1130
1142
|
console.log(`\u2705 Example prompts and datasets created in ${folderName}/agentmark/`);
|
|
1131
1143
|
fs4.writeFileSync(
|
|
1132
1144
|
`${targetPath}/agentmark.client.ts`,
|
|
@@ -1140,6 +1152,10 @@ var createExampleApp = async (client, targetPath = ".", apiKey = "", adapter = "
|
|
|
1140
1152
|
} else {
|
|
1141
1153
|
envVars[apiKeyEnvVar] = adapter === "claude-agent-sdk" ? "your-anthropic-api-key" : "your-openai-api-key";
|
|
1142
1154
|
}
|
|
1155
|
+
if (deploymentMode === "cloud") {
|
|
1156
|
+
envVars["AGENTMARK_API_KEY"] = "your_agentmark_api_key";
|
|
1157
|
+
envVars["AGENTMARK_APP_ID"] = "your_agentmark_app_id";
|
|
1158
|
+
}
|
|
1143
1159
|
const result = appendEnv(targetPath, envVars);
|
|
1144
1160
|
if (result.added.length > 0) {
|
|
1145
1161
|
console.log(`\u2705 Added to .env: ${result.added.join(", ")}`);
|
|
@@ -1148,7 +1164,7 @@ var createExampleApp = async (client, targetPath = ".", apiKey = "", adapter = "
|
|
|
1148
1164
|
console.log(`\u23ED\uFE0F Skipped existing .env vars: ${result.skipped.join(", ")}`);
|
|
1149
1165
|
}
|
|
1150
1166
|
} else {
|
|
1151
|
-
fs4.writeFileSync(`${targetPath}/.env`, getEnvFileContent(modelProvider, apiKey, adapter));
|
|
1167
|
+
fs4.writeFileSync(`${targetPath}/.env`, getEnvFileContent(modelProvider, apiKey, adapter, deploymentMode));
|
|
1152
1168
|
}
|
|
1153
1169
|
const gitignoreEntries = ["node_modules/", ".env", "*.agentmark-outputs/", "dist/"];
|
|
1154
1170
|
if (shouldMergeFile(".gitignore", projectInfo, resolutions)) {
|
|
@@ -1193,6 +1209,59 @@ var createExampleApp = async (client, targetPath = ".", apiKey = "", adapter = "
|
|
|
1193
1209
|
export default interface AgentmarkTypes {}
|
|
1194
1210
|
`);
|
|
1195
1211
|
}
|
|
1212
|
+
if (deploymentMode === "cloud") {
|
|
1213
|
+
const handlerAdapterConfig = getAdapterConfig(adapter, modelProvider);
|
|
1214
|
+
const { webhookHandler: handlerClass } = handlerAdapterConfig.classes;
|
|
1215
|
+
const handlerContent = `import { ${handlerClass} } from '${handlerAdapterConfig.package}/runner';
|
|
1216
|
+
import { AgentMarkSDK } from '@agentmark-ai/sdk';
|
|
1217
|
+
import { client } from './agentmark.client';
|
|
1218
|
+
|
|
1219
|
+
// Initialize tracing \u2014 sends traces to AgentMark Cloud
|
|
1220
|
+
const sdk = new AgentMarkSDK({
|
|
1221
|
+
apiKey: process.env.AGENTMARK_API_KEY ?? '',
|
|
1222
|
+
appId: process.env.AGENTMARK_APP_ID ?? '',
|
|
1223
|
+
baseUrl: process.env.AGENTMARK_BASE_URL,
|
|
1224
|
+
});
|
|
1225
|
+
sdk.initTracing({ disableBatch: true });
|
|
1226
|
+
|
|
1227
|
+
const adapter = new ${handlerClass}(client as any);
|
|
1228
|
+
|
|
1229
|
+
export default async function handler(request: {
|
|
1230
|
+
type: 'prompt-run' | 'dataset-run';
|
|
1231
|
+
data: {
|
|
1232
|
+
ast: unknown;
|
|
1233
|
+
customProps?: Record<string, unknown>;
|
|
1234
|
+
options?: { shouldStream?: boolean };
|
|
1235
|
+
experimentId?: string;
|
|
1236
|
+
datasetPath?: string;
|
|
1237
|
+
};
|
|
1238
|
+
}) {
|
|
1239
|
+
if (request.type === 'prompt-run') {
|
|
1240
|
+
return adapter.runPrompt(request.data.ast, {
|
|
1241
|
+
shouldStream: request.data.options?.shouldStream,
|
|
1242
|
+
customProps: request.data.customProps,
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (request.type === 'dataset-run') {
|
|
1247
|
+
return adapter.runExperiment(
|
|
1248
|
+
request.data.ast,
|
|
1249
|
+
request.data.experimentId ?? '',
|
|
1250
|
+
request.data.datasetPath,
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
throw new Error(\`Unknown request type: \${request.type}\`);
|
|
1255
|
+
}
|
|
1256
|
+
`;
|
|
1257
|
+
const handlerPath = path2.join(targetPath, "handler.ts");
|
|
1258
|
+
if (fs4.existsSync(handlerPath)) {
|
|
1259
|
+
console.log("\u23ED\uFE0F Skipped handler.ts (already exists - preserving customizations)");
|
|
1260
|
+
} else {
|
|
1261
|
+
fs4.writeFileSync(handlerPath, handlerContent);
|
|
1262
|
+
console.log(`\u2705 Created handler.ts for cloud deployment`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1196
1265
|
console.log("Creating development server entry point...");
|
|
1197
1266
|
const adapterConfig = getAdapterConfig(adapter, modelProvider);
|
|
1198
1267
|
const { webhookHandler } = adapterConfig.classes;
|
|
@@ -1251,9 +1320,6 @@ main().catch((err) => {
|
|
|
1251
1320
|
fs4.writeFileSync(devEntryPath, devEntryContent);
|
|
1252
1321
|
console.log(`\u2705 Created dev-entry.ts at project root`);
|
|
1253
1322
|
}
|
|
1254
|
-
if (!isExistingProject) {
|
|
1255
|
-
initGitRepo(targetPath);
|
|
1256
|
-
}
|
|
1257
1323
|
console.log("\n\u2705 Agentmark initialization completed successfully!");
|
|
1258
1324
|
console.log(
|
|
1259
1325
|
`
|
|
@@ -1289,6 +1355,7 @@ main().catch((err) => {
|
|
|
1289
1355
|
console.log("\u2500".repeat(70));
|
|
1290
1356
|
console.log(" Documentation: https://docs.agentmark.co");
|
|
1291
1357
|
console.log("\u2550".repeat(70) + "\n");
|
|
1358
|
+
return usedModels;
|
|
1292
1359
|
} catch (error) {
|
|
1293
1360
|
console.error("Error creating example app:", error);
|
|
1294
1361
|
throw error;
|
|
@@ -1479,7 +1546,7 @@ var getAgentmarkClientContent = (_deploymentMode, adapter) => {
|
|
|
1479
1546
|
return `"""AgentMark client configuration.
|
|
1480
1547
|
|
|
1481
1548
|
This file configures the AgentMark client with Claude Agent SDK adapter.
|
|
1482
|
-
Customize the model registry
|
|
1549
|
+
Customize the model registry as needed.
|
|
1483
1550
|
"""
|
|
1484
1551
|
|
|
1485
1552
|
import os
|
|
@@ -1490,7 +1557,6 @@ from agentmark.prompt_core import FileLoader
|
|
|
1490
1557
|
from agentmark_claude_agent_sdk import (
|
|
1491
1558
|
create_claude_agent_client,
|
|
1492
1559
|
create_default_model_registry,
|
|
1493
|
-
ClaudeAgentToolRegistry,
|
|
1494
1560
|
)
|
|
1495
1561
|
|
|
1496
1562
|
# Load environment variables
|
|
@@ -1500,26 +1566,15 @@ load_dotenv()
|
|
|
1500
1566
|
# Supports: claude-* models
|
|
1501
1567
|
model_registry = create_default_model_registry()
|
|
1502
1568
|
|
|
1503
|
-
# Configure tool registry for custom tools
|
|
1504
|
-
tool_registry = ClaudeAgentToolRegistry()
|
|
1505
|
-
|
|
1506
|
-
# Example tool registration:
|
|
1507
|
-
# tool_registry.register(
|
|
1508
|
-
# "search",
|
|
1509
|
-
# lambda args, ctx: f"Search results for: {args['query']}",
|
|
1510
|
-
# description="Search the web",
|
|
1511
|
-
# parameters={"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
|
|
1512
|
-
# )
|
|
1513
|
-
|
|
1514
1569
|
# Create file loader for local development
|
|
1515
1570
|
# Uses the project root as base directory for resolving relative paths
|
|
1516
1571
|
project_root = Path(__file__).parent.resolve()
|
|
1517
1572
|
loader = FileLoader(base_dir=str(project_root))
|
|
1518
1573
|
|
|
1519
1574
|
# Create the client
|
|
1575
|
+
# Claude Agent SDK handles tools natively through the SDK
|
|
1520
1576
|
client = create_claude_agent_client(
|
|
1521
1577
|
model_registry=model_registry,
|
|
1522
|
-
tool_registry=tool_registry,
|
|
1523
1578
|
loader=loader,
|
|
1524
1579
|
)
|
|
1525
1580
|
|
|
@@ -1529,7 +1584,7 @@ __all__ = ["client"]
|
|
|
1529
1584
|
return `"""AgentMark client configuration.
|
|
1530
1585
|
|
|
1531
1586
|
This file configures the AgentMark client with Pydantic AI adapter.
|
|
1532
|
-
Customize the model registry and
|
|
1587
|
+
Customize the model registry and tools as needed.
|
|
1533
1588
|
"""
|
|
1534
1589
|
|
|
1535
1590
|
import os
|
|
@@ -1540,7 +1595,6 @@ from agentmark.prompt_core import FileLoader
|
|
|
1540
1595
|
from agentmark_pydantic_ai_v0 import (
|
|
1541
1596
|
create_pydantic_ai_client,
|
|
1542
1597
|
create_default_model_registry,
|
|
1543
|
-
PydanticAIToolRegistry,
|
|
1544
1598
|
)
|
|
1545
1599
|
|
|
1546
1600
|
# Load environment variables
|
|
@@ -1550,14 +1604,12 @@ load_dotenv()
|
|
|
1550
1604
|
# Supports: gpt-*, claude-*, gemini-*, etc.
|
|
1551
1605
|
model_registry = create_default_model_registry()
|
|
1552
1606
|
|
|
1553
|
-
#
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
# Example tool registration:
|
|
1557
|
-
# @tool_registry.register("search")
|
|
1558
|
-
# async def search_web(args: dict, ctx: dict | None) -> str:
|
|
1559
|
-
# query = args["query"]
|
|
1607
|
+
# Define tools as native pydantic-ai Tool objects or callables
|
|
1608
|
+
# Example:
|
|
1609
|
+
# def search(query: str) -> str:
|
|
1560
1610
|
# return f"Search results for: {query}"
|
|
1611
|
+
# tools = [search]
|
|
1612
|
+
tools = []
|
|
1561
1613
|
|
|
1562
1614
|
# Create file loader for local development
|
|
1563
1615
|
# Uses the project root as base directory for resolving relative paths
|
|
@@ -1567,7 +1619,7 @@ loader = FileLoader(base_dir=str(project_root))
|
|
|
1567
1619
|
# Create the client
|
|
1568
1620
|
client = create_pydantic_ai_client(
|
|
1569
1621
|
model_registry=model_registry,
|
|
1570
|
-
|
|
1622
|
+
tools=tools,
|
|
1571
1623
|
loader=loader,
|
|
1572
1624
|
)
|
|
1573
1625
|
|
|
@@ -1786,7 +1838,7 @@ var createPythonApp = async (client, targetPath = ".", apiKey = "", deploymentMo
|
|
|
1786
1838
|
const folderName = targetPath;
|
|
1787
1839
|
fs5.ensureDirSync(`${targetPath}/agentmark`);
|
|
1788
1840
|
setupMCPServer2(client, targetPath);
|
|
1789
|
-
createExamplePrompts(model, targetPath, adapter);
|
|
1841
|
+
const usedModels = createExamplePrompts(model, targetPath, adapter);
|
|
1790
1842
|
console.log(`Example prompts and datasets created in ${folderName}/agentmark/`);
|
|
1791
1843
|
if (!isExistingProject) {
|
|
1792
1844
|
const projectName = path3.basename(targetPath).replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
@@ -1861,9 +1913,6 @@ var createPythonApp = async (client, targetPath = ".", apiKey = "", deploymentMo
|
|
|
1861
1913
|
console.log("Note: You'll need to set up a virtual environment and install dependencies.");
|
|
1862
1914
|
console.log("");
|
|
1863
1915
|
}
|
|
1864
|
-
if (!isExistingProject) {
|
|
1865
|
-
initGitRepo(targetPath);
|
|
1866
|
-
}
|
|
1867
1916
|
console.log("\n\u2705 AgentMark Python initialization completed successfully!");
|
|
1868
1917
|
console.log(
|
|
1869
1918
|
`
|
|
@@ -1898,6 +1947,7 @@ var createPythonApp = async (client, targetPath = ".", apiKey = "", deploymentMo
|
|
|
1898
1947
|
console.log("\u2500".repeat(70));
|
|
1899
1948
|
console.log(" Documentation: https://docs.agentmark.co");
|
|
1900
1949
|
console.log("\u2550".repeat(70) + "\n");
|
|
1950
|
+
return usedModels;
|
|
1901
1951
|
} catch (error) {
|
|
1902
1952
|
console.error("Error creating Python app:", error);
|
|
1903
1953
|
throw error;
|
|
@@ -2014,6 +2064,38 @@ function isCurrentDirectory(folderName) {
|
|
|
2014
2064
|
return folderName === "." || folderName === "./" || folderName === ".\\";
|
|
2015
2065
|
}
|
|
2016
2066
|
|
|
2067
|
+
// src/utils/git-init.ts
|
|
2068
|
+
import { execSync as execSync2 } from "child_process";
|
|
2069
|
+
function initGitRepo(targetPath) {
|
|
2070
|
+
try {
|
|
2071
|
+
try {
|
|
2072
|
+
execSync2("git --version", { stdio: "ignore" });
|
|
2073
|
+
} catch {
|
|
2074
|
+
console.log("\u26A0\uFE0F git not found \u2014 skipping repository initialization");
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
try {
|
|
2078
|
+
execSync2("git rev-parse --is-inside-work-tree", {
|
|
2079
|
+
cwd: targetPath,
|
|
2080
|
+
stdio: "ignore"
|
|
2081
|
+
});
|
|
2082
|
+
return false;
|
|
2083
|
+
} catch {
|
|
2084
|
+
}
|
|
2085
|
+
execSync2("git init", { cwd: targetPath, stdio: "ignore" });
|
|
2086
|
+
execSync2("git add -A", { cwd: targetPath, stdio: "ignore" });
|
|
2087
|
+
execSync2(
|
|
2088
|
+
'git -c user.name="create-agentmark" -c user.email="noreply" commit -m "Initial commit from create-agentmark"',
|
|
2089
|
+
{ cwd: targetPath, stdio: "ignore" }
|
|
2090
|
+
);
|
|
2091
|
+
console.log("\u2705 Initialized git repository with initial commit");
|
|
2092
|
+
return true;
|
|
2093
|
+
} catch {
|
|
2094
|
+
console.log("\u26A0\uFE0F Could not initialize git repository");
|
|
2095
|
+
return false;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2017
2099
|
// src/index.ts
|
|
2018
2100
|
var parseArgs = () => {
|
|
2019
2101
|
const args = process.argv.slice(2);
|
|
@@ -2095,7 +2177,6 @@ var main = async () => {
|
|
|
2095
2177
|
});
|
|
2096
2178
|
adapter = response.adapter;
|
|
2097
2179
|
}
|
|
2098
|
-
config.builtInModels = adapter === "claude-agent-sdk" ? ["anthropic/claude-sonnet-4-20250514"] : ["openai/gpt-4o"];
|
|
2099
2180
|
const apiKeyName = adapter === "claude-agent-sdk" ? "Anthropic" : "OpenAI";
|
|
2100
2181
|
let apiKey = "";
|
|
2101
2182
|
const { providedApiKey } = await prompts2({
|
|
@@ -2138,10 +2219,15 @@ var main = async () => {
|
|
|
2138
2219
|
{ title: "Skip", value: "skip" }
|
|
2139
2220
|
]
|
|
2140
2221
|
});
|
|
2222
|
+
let usedModels;
|
|
2141
2223
|
if (language === "python") {
|
|
2142
|
-
await createPythonApp(client, targetPath, apiKey, deploymentMode, adapter, projectInfo, resolutions);
|
|
2224
|
+
usedModels = await createPythonApp(client, targetPath, apiKey, deploymentMode, adapter, projectInfo, resolutions);
|
|
2143
2225
|
} else {
|
|
2144
|
-
await createExampleApp(client, targetPath, apiKey, adapter, deploymentMode, projectInfo, resolutions);
|
|
2226
|
+
usedModels = await createExampleApp(client, targetPath, apiKey, adapter, deploymentMode, projectInfo, resolutions);
|
|
2227
|
+
}
|
|
2228
|
+
config.builtInModels = usedModels;
|
|
2229
|
+
if (deploymentMode === "cloud") {
|
|
2230
|
+
config.handler = "handler.ts";
|
|
2145
2231
|
}
|
|
2146
2232
|
const agentmarkJsonPath = path6.join(targetPath, "agentmark.json");
|
|
2147
2233
|
const agentmarkJsonResolution = resolutions.find((r) => r.path === "agentmark.json");
|
|
@@ -2150,6 +2236,9 @@ var main = async () => {
|
|
|
2150
2236
|
} else if (agentmarkJsonResolution?.action === "skip") {
|
|
2151
2237
|
console.log("\u23ED\uFE0F Skipped agentmark.json (keeping existing file)");
|
|
2152
2238
|
}
|
|
2239
|
+
if (!projectInfo.isExistingProject) {
|
|
2240
|
+
initGitRepo(targetPath);
|
|
2241
|
+
}
|
|
2153
2242
|
};
|
|
2154
2243
|
main().catch((error) => {
|
|
2155
2244
|
console.error("Error:", error);
|