UNPKG

@supernovaio/cli

Version:

Supernova.io Command Line Interface

69 lines (67 loc) 3.02 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ca7f9427-d164-5753-962b-413c048b2f41")}catch(e){}}(); import crypto from "node:crypto"; import { getApiClient as getDefaultApiClient } from "../../api-client.js"; export function createPrototypeService(input) { let apiClientPromise; const getApiClient = input.getApiClient ?? getDefaultApiClient; const getAuthenticatedApiClient = () => { apiClientPromise ??= getApiClient(input.env); return apiClientPromise; }; return { async ensureSharedContext(serviceInput) { const client = await getAuthenticatedApiClient(); const createInput = { designSystemId: serviceInput.designSystemId, name: serviceInput.contextName, sandboxTemplate: serviceInput.sandboxTemplate, workspaceId: serviceInput.workspaceId, }; try { return await createProjectContext(client, createInput); } catch (caughtError) { input.error(`Failed to create shared context. ${caughtError instanceof Error ? caughtError.message : "Unknown error"}`); } }, async createPrototypeProject(serviceInput) { const client = await getAuthenticatedApiClient(); const featureId = crypto.randomUUID(); const messageId = crypto.randomUUID(); const { project } = await client.forge.projects.create(serviceInput.workspaceId, { description: serviceInput.promptText, initialFeature: { description: serviceInput.promptText, id: featureId, initialMessage: { attachments: {}, body: serviceInput.promptText, id: messageId, isPrompt: true, startsNewThread: false, }, name: serviceInput.projectName, }, instruction: null, name: serviceInput.projectName, projectContextId: serviceInput.contextId, tags: [], }); const projectId = project.id; if (!projectId) { input.error("Project creation failed: missing project ID in response."); } return { featureId, projectId, }; }, openBrowser: input.openBrowser, }; } async function createProjectContext(client, createInput) { const { context } = await client.forge.projectContexts.create(createInput); return context.id; } //# sourceMappingURL=prototype-service.js.map //# debugId=ca7f9427-d164-5753-962b-413c048b2f41