Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2eTest/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export const TAGS = {
CANARY: "canary",
HARNESS: "harness",
RUNTIME: "runtime",
// The model choices of the interactive create wizard (TUI), made through the wizard's code.
TUI: "tui",
} as const;
52 changes: 52 additions & 0 deletions e2eTest/helpers/create-with-model-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Creates a project the way the interactive create wizard does when the user picks a model
* provider, through the same code: the template shortcut with the wizard's model answers, then the
* project manager's create. `agentcore create` takes no model flags, so the e2e tests that need a
* project on another provider run this script in the folder to create it in (create writes into the
* current directory). Run it with bun: `bun create-with-model-provider.ts '<json>'`, where the JSON
* holds name, template, region, modelProvider and, optional, modelId, apiKeyFile, apiBase and
* skipInstall.
*/
import { readFileSync } from "node:fs";
import { FsProjectManager } from "../../src/core/project/manager";
import { resolveRuntimeTemplateShortcut } from "../../src/handlers/project/shortcuts";
import type { RuntimeTemplateShortcutName } from "../../src/handlers/project/shortcuts";
import type { ModelProvider } from "../../src/handlers/project/types";
import { createSilentLogger } from "../../src/testing/logging";

interface Request {
name: string;
template: RuntimeTemplateShortcutName;
region: string;
modelProvider: ModelProvider;
modelId?: string;
apiKeyFile?: string;
apiBase?: string;
skipInstall?: boolean;
}

const request = JSON.parse(process.argv[2] ?? "{}") as Request;
const apiKey = request.apiKeyFile ? readFileSync(request.apiKeyFile, "utf8").trim() : undefined;

const manager = new FsProjectManager({
logger: createSilentLogger(),
// Create reaches neither AgentCore Identity nor Transaction Search: deploy does.
identity: undefined as never,
enableTransactionSearch: async () => {},
});
const events = manager.create({
name: request.name,
region: request.region,
skipGit: true,
skipInstall: request.skipInstall ?? false,
scaffoldRuntimeInput: resolveRuntimeTemplateShortcut(request.template, {
runtimeName: "agent",
modelProvider: request.modelProvider,
...(request.modelId !== undefined && { modelId: request.modelId }),
...(apiKey !== undefined && { apiKey }),
...(request.apiBase !== undefined && { apiBase: request.apiBase }),
}),
});
let next = await events.next();
while (!next.done) next = await events.next();
process.stdout.write(`${JSON.stringify({ project: { path: next.value.rootPath } })}\n`);
Loading
Loading