源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { app } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den } from "../evals/packages/env/src/den.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export interface AcmeDemoWorld {
|
||||
den: Den;
|
||||
alex: App;
|
||||
jordan: App;
|
||||
}
|
||||
|
||||
/** The seeded Acme demo with Alex signed in and Jordan on a fresh profile. */
|
||||
export async function bootAcmeDemo(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
): Promise<AcmeDemoWorld> {
|
||||
const den = stack.use(await server({
|
||||
place,
|
||||
ports: { api: 8790, web: 3005 },
|
||||
seedProfile: "demo-org",
|
||||
web: true,
|
||||
}));
|
||||
const alex = stack.use(await app({ den, place, as: "admin" }));
|
||||
const jordan = stack.use(await app({ den, place, signIn: false }));
|
||||
return { den, alex, jordan };
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const { den, alex, jordan } = await bootAcmeDemo(stack, resolvePlace());
|
||||
await hold({
|
||||
name: "acme-demo",
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
alexCdp: alex.handle.cdpUrl,
|
||||
jordanCdp: jordan.handle.cdpUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,210 @@
|
||||
import { createOrgConnection, createPluginWithSkill, denFetch } from "../evals/packages/behaviors/src/index.ts";
|
||||
import type { DenSession } from "../evals/packages/behaviors/src/index.ts";
|
||||
import { app } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { createAdmin, createOrg, inviteMember, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { mcpMock } from "../evals/packages/env/src/mock.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export const ACME_DOCS_ORGANIZATION_NAME = "Acme Robotics";
|
||||
export const ACME_DOCS_MEMBER = "jordan";
|
||||
export const ACME_DOCS_APP = "docs";
|
||||
export const ACME_DOCS_WORKSPACE = "/tmp/acme/acme-robotics";
|
||||
export const ACME_DOCS_PROMPT_CARDS = [
|
||||
{
|
||||
title: "Prepare a customer briefing",
|
||||
prompt: "Review this workspace and prepare a briefing with customer goals, recent decisions, risks, and next steps.",
|
||||
},
|
||||
{
|
||||
title: "Turn meeting notes into action",
|
||||
prompt: "Turn the latest meeting notes into an action plan with owners, deadlines, dependencies, and open questions.",
|
||||
},
|
||||
{
|
||||
title: "Draft the weekly project update",
|
||||
prompt: "Summarize project progress, risks, decisions, and next week's priorities for the leadership team.",
|
||||
},
|
||||
];
|
||||
|
||||
const plugins = [
|
||||
{
|
||||
name: "Customer Research",
|
||||
description: "Prepare for sales calls with a structured company brief.",
|
||||
skillName: "customer-research",
|
||||
skillDescription: "Research a company and summarize key facts before a sales call.",
|
||||
skillBody: "# Instructions\n\n1. Gather the company's product, size, and recent news.\n2. Summarize the three facts that matter for this call.\n3. Suggest one opening question.",
|
||||
},
|
||||
{
|
||||
name: "Weekly Status Report",
|
||||
description: "Draft the weekly status update from recent activity.",
|
||||
skillName: "weekly-status-report",
|
||||
skillDescription: "Draft the weekly status update from this week's activity.",
|
||||
skillBody: "# Instructions\n\n1. Collect what shipped, what slipped, and what is blocked.\n2. Write a five-line update in the team's usual format.",
|
||||
},
|
||||
{
|
||||
name: "Meeting Notes",
|
||||
description: "Turn a transcript into structured meeting notes.",
|
||||
skillName: "meeting-notes",
|
||||
skillDescription: "Turn a meeting transcript into decisions, owners, and follow-ups.",
|
||||
skillBody: "# Instructions\n\n1. Extract decisions, owners, and deadlines from the transcript.\n2. List open questions at the end.",
|
||||
},
|
||||
];
|
||||
|
||||
export interface AcmeDocsWorld {
|
||||
den: Den;
|
||||
org: DenOrgHandle;
|
||||
docs: App;
|
||||
pluginIds: string[];
|
||||
app(name: string): App;
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function auth(session: DenSession): Record<string, string> {
|
||||
return { authorization: `Bearer ${session.token}` };
|
||||
}
|
||||
|
||||
async function memberId(session: DenSession, organizationId: string): Promise<string> {
|
||||
const route = "/v1/me/orgs";
|
||||
const result = await denFetch(session, route, { headers: auth(session) });
|
||||
const organizations = isRecord(result.body) && Array.isArray(result.body.orgs)
|
||||
? result.body.orgs.filter(isRecord)
|
||||
: [];
|
||||
const organization = organizations.find((candidate) => candidate.id === organizationId);
|
||||
const id = organization && typeof organization.membershipId === "string"
|
||||
? organization.membershipId
|
||||
: organization && typeof organization.orgMemberId === "string"
|
||||
? organization.orgMemberId
|
||||
: "";
|
||||
if (!result.response.ok || !id) {
|
||||
throw new Error(`GET ${route} could not resolve Jordan's organization member id: HTTP ${result.response.status} ${result.text.slice(0, 500)}`);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
async function enableDocsCapabilities(admin: DenSession, organizationId: string): Promise<void> {
|
||||
const route = `/v1/admin/organizations/${organizationId}/capabilities`;
|
||||
const result = await denFetch(admin, route, {
|
||||
method: "PUT",
|
||||
headers: auth(admin),
|
||||
body: JSON.stringify({ capabilities: { mcpConnections: true, cloud: true } }),
|
||||
});
|
||||
if (!result.response.ok) {
|
||||
throw new Error(`PUT ${route} failed: HTTP ${result.response.status} ${result.text.slice(0, 500)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function createProductOperationsPolicy(
|
||||
den: Den,
|
||||
organizationId: string,
|
||||
jordan: DenSession,
|
||||
): Promise<void> {
|
||||
const jordanId = await memberId(jordan, organizationId);
|
||||
const teamRoute = "/v1/teams";
|
||||
const team = await denFetch(den.admin, teamRoute, {
|
||||
method: "POST",
|
||||
headers: { ...auth(den.admin), "x-openwork-org-id": organizationId },
|
||||
body: JSON.stringify({ name: "Product Operations", memberIds: [jordanId] }),
|
||||
});
|
||||
const teamRecord = isRecord(team.body) && isRecord(team.body.team) ? team.body.team : null;
|
||||
const teamId = teamRecord && typeof teamRecord.id === "string" ? teamRecord.id : "";
|
||||
if (team.response.status !== 201 || !teamId) {
|
||||
throw new Error(`POST ${teamRoute} failed: HTTP ${team.response.status} ${team.text.slice(0, 500)}`);
|
||||
}
|
||||
|
||||
const policyRoute = "/v1/desktop-policies";
|
||||
const policy = await denFetch(den.admin, policyRoute, {
|
||||
method: "POST",
|
||||
headers: { ...auth(den.admin), "x-openwork-org-id": organizationId },
|
||||
body: JSON.stringify({
|
||||
policyName: "Product operations prompts",
|
||||
priority: 100,
|
||||
isEnabled: true,
|
||||
policy: {
|
||||
onboardingPrompts: ACME_DOCS_PROMPT_CARDS.map((card) => card.prompt),
|
||||
onboardingPromptDescriptions: ACME_DOCS_PROMPT_CARDS.map((card) => card.title),
|
||||
},
|
||||
memberIds: [jordanId],
|
||||
teamIds: [teamId],
|
||||
}),
|
||||
});
|
||||
if (policy.response.status !== 201) {
|
||||
throw new Error(`POST ${policyRoute} failed: HTTP ${policy.response.status} ${policy.text.slice(0, 500)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/** The organization, content, witness connection, policy, and member desktop used by docs shots. */
|
||||
export async function bootAcmeDocs(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
): Promise<AcmeDocsWorld> {
|
||||
const den = stack.use(await server({
|
||||
place,
|
||||
provision: false,
|
||||
web: true,
|
||||
mocks: { slack: mcpMock() },
|
||||
env: { DEN_BOOTSTRAP_ADMIN_EMAILS: "alex@acme.dev" },
|
||||
}));
|
||||
const admin = await createAdmin(den, { name: "Alex Rivera", email: "alex@acme.dev" });
|
||||
const org = stack.use(await createOrg(den, ACME_DOCS_ORGANIZATION_NAME));
|
||||
const jordan = await inviteMember(den, ACME_DOCS_MEMBER, {
|
||||
name: "Jordan Lee",
|
||||
email: "jordan@acme.dev",
|
||||
});
|
||||
|
||||
await enableDocsCapabilities(admin, org.id);
|
||||
const pluginIds: string[] = [];
|
||||
for (const plugin of plugins) {
|
||||
const created = await createPluginWithSkill(admin, plugin);
|
||||
pluginIds.push(created.id);
|
||||
}
|
||||
const slack = den.mocks.slack;
|
||||
if (!slack) throw new Error("The Slack MCP witness did not boot.");
|
||||
await createOrgConnection(admin, {
|
||||
name: "Slack",
|
||||
url: slack.mcpUrl,
|
||||
authType: "oauth",
|
||||
credentialMode: "per_member",
|
||||
access: { orgWide: true },
|
||||
});
|
||||
await createProductOperationsPolicy(den, org.id, jordan);
|
||||
|
||||
const docs = stack.use(await app({
|
||||
den,
|
||||
place,
|
||||
as: ACME_DOCS_MEMBER,
|
||||
workspacePath: ACME_DOCS_WORKSPACE,
|
||||
}));
|
||||
return {
|
||||
den,
|
||||
org,
|
||||
docs,
|
||||
pluginIds,
|
||||
app(name) {
|
||||
if (name !== ACME_DOCS_APP) throw new Error(`Unknown Acme docs app ${JSON.stringify(name)}.`);
|
||||
return docs;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const world = await bootAcmeDocs(stack, resolvePlace());
|
||||
const slack = world.den.mocks.slack;
|
||||
if (!slack) throw new Error("The Slack MCP witness did not boot.");
|
||||
await hold({
|
||||
name: "acme-docs",
|
||||
outputs: {
|
||||
denWeb: world.den.ref.webUrl,
|
||||
denApi: world.den.ref.apiUrl,
|
||||
docsCdp: world.docs.handle.cdpUrl,
|
||||
slackMcp: slack.mcpUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,41 @@
|
||||
import { createAdmin, createOrg, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export const AZURE_BYOK_ORGANIZATION = "Azure BYOK Repro";
|
||||
export const AZURE_BYOK_ADMIN_EMAIL = "provider-admin@azure-repro.test";
|
||||
|
||||
export interface AzureByokWorld {
|
||||
den: Den;
|
||||
admin: Awaited<ReturnType<typeof createAdmin>>;
|
||||
org: DenOrgHandle;
|
||||
}
|
||||
|
||||
/** Fresh isolated self-hosted Den for verifying Azure BYOK delivery. */
|
||||
export async function bootAzureByok(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
): Promise<AzureByokWorld> {
|
||||
const den = stack.use(await server({ place, provision: false, web: true }));
|
||||
const admin = await createAdmin(den, {
|
||||
name: "Provider Admin",
|
||||
email: AZURE_BYOK_ADMIN_EMAIL,
|
||||
});
|
||||
const org = stack.use(await createOrg(den, AZURE_BYOK_ORGANIZATION));
|
||||
return { den, admin, org };
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const { den } = await bootAzureByok(stack, resolvePlace());
|
||||
await hold({
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,63 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
import { launchHeadlessWeb } from "../packages/world/src/headless-web.ts";
|
||||
import type { HeadlessWebHandle } from "../packages/world/src/headless-web.ts";
|
||||
|
||||
const REPO_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
||||
const CLOUD_MODEL_INFRA_WORKER_NAME = "cloud-model-infra-worker";
|
||||
const CLOUD_MODEL_INFRA_WORKER_WORKSPACE = "/tmp/openwork-cloud-model-infra-worker";
|
||||
|
||||
export interface CloudModelInfraWorkerOptions {
|
||||
name: string;
|
||||
workspace: string;
|
||||
replace: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Worker runtime for the cloud model-infrastructure world: the same
|
||||
* source-first openwork-server plus managed OpenCode engine an OpenWork
|
||||
* Cloud worker runs, in an isolated workspace.
|
||||
*
|
||||
* `cloud-model-infra.ts` seeds a Den `worker` whose Daytona signed preview
|
||||
* points at this server's `openworkUrl`, so Den's readiness probe, provider
|
||||
* materialization, and remote-session capabilities exercise a real worker
|
||||
* runtime end to end without a Daytona sandbox.
|
||||
*
|
||||
* Launch: `pnpm world up ./worlds/cloud-model-infra-worker.ts`
|
||||
* Proof: `evals/specs/cloud-model-infra.e2e.test.ts`
|
||||
*/
|
||||
export async function bootCloudModelInfraWorker(
|
||||
stack: AsyncDisposableStack,
|
||||
options: CloudModelInfraWorkerOptions,
|
||||
): Promise<HeadlessWebHandle> {
|
||||
await mkdir(options.workspace, { recursive: true });
|
||||
const handle = await launchHeadlessWeb({
|
||||
repoRoot: REPO_ROOT,
|
||||
name: options.name,
|
||||
state: "isolated",
|
||||
workspace: options.workspace,
|
||||
replace: options.replace,
|
||||
});
|
||||
return stack.adopt(handle, (headless) => headless.stop());
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const handle = await bootCloudModelInfraWorker(stack, {
|
||||
name: CLOUD_MODEL_INFRA_WORKER_NAME,
|
||||
workspace: CLOUD_MODEL_INFRA_WORKER_WORKSPACE,
|
||||
replace: false,
|
||||
});
|
||||
await hold({
|
||||
name: CLOUD_MODEL_INFRA_WORKER_NAME,
|
||||
outputs: {
|
||||
webUrl: handle.manifest.webUrl,
|
||||
openworkUrl: handle.manifest.openworkUrl,
|
||||
workspace: handle.manifest.workspace,
|
||||
runtimeManifest: handle.manifest.runtimeManifestPath,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,96 @@
|
||||
import { denFetch } from "../evals/packages/behaviors/src/den.ts";
|
||||
import type { DenSession } from "../evals/packages/behaviors/src/den.ts";
|
||||
import { createAdmin, createOrg, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export const CLOUD_MODEL_INFRA_ORG = "Cloud Model Infra";
|
||||
export const CLOUD_MODEL_INFRA_ADMIN_EMAIL = "infra-admin@cloud-model-infra.test";
|
||||
export const CLOUD_MODEL_INFRA_GATEWAY_KEY = "cloud-model-infra-gateway-key";
|
||||
export const CLOUD_MODEL_INFRA_DAYTONA_KEY = "cloud-model-infra-daytona-guard-key";
|
||||
|
||||
export interface CloudModelInfraOptions {
|
||||
daytonaApiUrl: string;
|
||||
}
|
||||
|
||||
export interface CloudModelInfraWorld {
|
||||
den: Den;
|
||||
admin: DenSession;
|
||||
org: DenOrgHandle;
|
||||
}
|
||||
|
||||
async function enableCloudCapability(admin: DenSession, organizationId: string): Promise<void> {
|
||||
const route = `/v1/admin/organizations/${organizationId}/capabilities`;
|
||||
const result = await denFetch(admin, route, {
|
||||
method: "PUT",
|
||||
headers: { authorization: `Bearer ${admin.token}` },
|
||||
body: JSON.stringify({ capabilities: { cloud: true } }),
|
||||
});
|
||||
if (!result.response.ok) {
|
||||
throw new Error(`PUT ${route} failed: HTTP ${result.response.status} ${result.text.slice(0, 500)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloud model-infrastructure world: a fresh self-hosted Den whose only
|
||||
* organization is Cloud-enabled (`capabilities.cloud`) and whose Daytona
|
||||
* provisioner gate is satisfied without any real Daytona account.
|
||||
*
|
||||
* `DAYTONA_API_URL` deliberately points at an unroutable local address: the
|
||||
* healthy-worker runtime path (signed-preview probe, gateway resolve,
|
||||
* provider materialization, remote-session capabilities) must never call the
|
||||
* Daytona SDK. Any unexpected SDK call fails fast instead of reaching the
|
||||
* real Daytona API. The proof spec replaces this URL with a live request
|
||||
* ledger and asserts it stays empty.
|
||||
*
|
||||
* The member-owned cloud worker itself is seeded at the database seam
|
||||
* (`worker`, `worker_token`, `daytona_sandbox`) pointing at a real
|
||||
* source-first openwork-server launched from `cloud-model-infra-worker.ts`,
|
||||
* so Den talks to a genuine worker runtime over plain HTTP.
|
||||
*
|
||||
* Launch: `pnpm world up ./worlds/cloud-model-infra.ts`
|
||||
* Proof: `evals/specs/cloud-model-infra.e2e.test.ts`
|
||||
*/
|
||||
export async function bootCloudModelInfra(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
options: CloudModelInfraOptions,
|
||||
): Promise<CloudModelInfraWorld> {
|
||||
const den = stack.use(await server({
|
||||
place,
|
||||
provision: false,
|
||||
web: true,
|
||||
env: {
|
||||
PROVISIONER_MODE: "daytona",
|
||||
DAYTONA_API_KEY: CLOUD_MODEL_INFRA_DAYTONA_KEY,
|
||||
DAYTONA_API_URL: options.daytonaApiUrl,
|
||||
DEN_GATEWAY_KEY: CLOUD_MODEL_INFRA_GATEWAY_KEY,
|
||||
DEN_BOOTSTRAP_ADMIN_EMAILS: CLOUD_MODEL_INFRA_ADMIN_EMAIL,
|
||||
},
|
||||
}));
|
||||
const admin = await createAdmin(den, {
|
||||
name: "Infra Admin",
|
||||
email: CLOUD_MODEL_INFRA_ADMIN_EMAIL,
|
||||
});
|
||||
const org = stack.use(await createOrg(den, CLOUD_MODEL_INFRA_ORG));
|
||||
await enableCloudCapability(admin, org.id);
|
||||
return { den, admin, org };
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const place = resolvePlace();
|
||||
const { den } = await bootCloudModelInfra(stack, place, {
|
||||
daytonaApiUrl: "http://127.0.0.1:9/daytona-guard",
|
||||
});
|
||||
await hold({
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,69 @@
|
||||
import { seedSessions } from "../evals/packages/behaviors/src/sessions.ts";
|
||||
import { app } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { createAdmin, createOrg, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export const CROSS_WORKSPACE_SPLIT_VIEW_ORG = "Cross Workspace Split View";
|
||||
|
||||
export interface CrossWorkspaceSplitViewOptions {
|
||||
adminEmail: string;
|
||||
workspacePath: string;
|
||||
sessionTitles: readonly string[];
|
||||
}
|
||||
|
||||
export interface CrossWorkspaceSplitViewWorld {
|
||||
den: Den;
|
||||
admin: Awaited<ReturnType<typeof createAdmin>>;
|
||||
org: DenOrgHandle;
|
||||
desktop: App;
|
||||
sessions: { sessionId: string; title: string }[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Repro world for validating split view across two sessions that belong to
|
||||
* different local workspaces. The builder seeds the signed-in desktop and the
|
||||
* first workspace; the scenario creates a second workspace at runtime so each
|
||||
* run gets isolated temporary workspace paths.
|
||||
*/
|
||||
export async function bootCrossWorkspaceSplitView(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
options: CrossWorkspaceSplitViewOptions,
|
||||
): Promise<CrossWorkspaceSplitViewWorld> {
|
||||
const den = stack.use(await server({ place, provision: false, web: true }));
|
||||
const admin = await createAdmin(den, {
|
||||
name: "Split View Admin",
|
||||
email: options.adminEmail,
|
||||
});
|
||||
const org = stack.use(await createOrg(den, CROSS_WORKSPACE_SPLIT_VIEW_ORG));
|
||||
const desktop = stack.use(await app({
|
||||
den,
|
||||
place,
|
||||
as: "admin",
|
||||
workspacePath: options.workspacePath,
|
||||
}));
|
||||
const sessions = await seedSessions(desktop, options.sessionTitles);
|
||||
return { den, admin, org, desktop, sessions };
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const { den, desktop } = await bootCrossWorkspaceSplitView(stack, resolvePlace(), {
|
||||
adminEmail: "split-view-admin@openwork.test",
|
||||
workspacePath: "/tmp/openwork-cross-workspace-split-primary",
|
||||
sessionTitles: ["Primary split anchor", "Primary same-workspace peer"],
|
||||
});
|
||||
await hold({
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
cdp: desktop.handle.cdpUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,21 @@
|
||||
import { kindServer } from "../evals/packages/env/src/kind-server.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
/**
|
||||
* The Kind Helm fixture has separate browser-facing web/API origins while
|
||||
* DEN_API_BASE remains the in-cluster service.
|
||||
*/
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const den = stack.use(await kindServer());
|
||||
await hold({
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
await main();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { localHost, resolveInstalledProductionDesktopState } from "../evals/packages/hosts/src/index.ts";
|
||||
import type { InstalledProductionDesktopState } from "../evals/packages/hosts/src/index.ts";
|
||||
import { liveSharedProductionApp } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export interface DesktopProductionLiveOptions {
|
||||
allowSharedState: true;
|
||||
resolveInstalledProductionState?: () => Promise<InstalledProductionDesktopState>;
|
||||
}
|
||||
|
||||
/** Launch source Electron against installed production state after explicit consent. */
|
||||
export async function desktopProductionLive(options: DesktopProductionLiveOptions): Promise<App> {
|
||||
if (options?.allowSharedState !== true) {
|
||||
throw new Error("Refusing LIVE SHARED PRODUCTION STATE launch without explicit allowSharedState: true consent.");
|
||||
}
|
||||
const state = await (
|
||||
options.resolveInstalledProductionState ?? resolveInstalledProductionDesktopState
|
||||
)();
|
||||
return liveSharedProductionApp({
|
||||
host: localHost(),
|
||||
name: "world-desktop-production-live",
|
||||
state,
|
||||
});
|
||||
}
|
||||
|
||||
function parseArgs(argv: readonly string[]): DesktopProductionLiveOptions {
|
||||
if (argv.length !== 1 || argv[0] !== "--allow-shared-state") {
|
||||
throw new Error("Launch desktop-prod-live with exactly --allow-shared-state.");
|
||||
}
|
||||
return { allowSharedState: true };
|
||||
}
|
||||
|
||||
export async function main(argv: readonly string[] = process.argv.slice(2)): Promise<void> {
|
||||
await using desktop = await desktopProductionLive(parseArgs(argv));
|
||||
await hold({ outputs: { cdp: desktop.handle.cdpUrl } });
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
await main();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
import { launchHeadlessWeb } from "../packages/world/src/headless-web.ts";
|
||||
import type { HeadlessWebHandle } from "../packages/world/src/headless-web.ts";
|
||||
|
||||
const REPO_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
||||
const DEV_HEADLESS_NAME = "dev-headless";
|
||||
|
||||
export interface DevHeadlessOptions {
|
||||
name?: string;
|
||||
replace?: boolean;
|
||||
keepTokens?: boolean;
|
||||
rotateTokens?: boolean;
|
||||
}
|
||||
|
||||
function parseArgs(argv: readonly string[]): DevHeadlessOptions {
|
||||
const supported = new Set(["--replace", "--keep-tokens", "--rotate-tokens"]);
|
||||
const unsupported = argv.find((argument) => !supported.has(argument));
|
||||
if (unsupported) throw new Error(`Unsupported dev-headless flag: ${unsupported}`);
|
||||
return {
|
||||
replace: argv.includes("--replace")
|
||||
|| ["1", "true", "yes", "on"].includes((process.env.OPENWORK_DEV_HEADLESS_WEB_REPLACE ?? "").trim().toLowerCase()),
|
||||
keepTokens: argv.includes("--keep-tokens"),
|
||||
rotateTokens: argv.includes("--rotate-tokens"),
|
||||
};
|
||||
}
|
||||
|
||||
function outputs(handle: HeadlessWebHandle): Record<string, string> {
|
||||
return {
|
||||
webUrl: handle.manifest.webUrl,
|
||||
openworkUrl: handle.manifest.openworkUrl,
|
||||
workspace: handle.manifest.workspace,
|
||||
runtimeManifest: handle.manifest.runtimeManifestPath,
|
||||
};
|
||||
}
|
||||
|
||||
/** Isolated source UI + local backend. This is the world behind pnpm dev:headless-web. */
|
||||
export async function bootDevHeadless(
|
||||
stack: AsyncDisposableStack,
|
||||
options: DevHeadlessOptions = {},
|
||||
): Promise<HeadlessWebHandle> {
|
||||
const handle = await launchHeadlessWeb({
|
||||
repoRoot: REPO_ROOT,
|
||||
name: options.name ?? DEV_HEADLESS_NAME,
|
||||
state: "isolated",
|
||||
replace: options.replace,
|
||||
keepTokens: options.keepTokens,
|
||||
rotateTokens: options.rotateTokens,
|
||||
});
|
||||
return stack.adopt(handle, (headless) => headless.stop());
|
||||
}
|
||||
|
||||
export async function main(argv: readonly string[] = process.argv.slice(2)): Promise<void> {
|
||||
const options = parseArgs(argv);
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const handle = await bootDevHeadless(stack, options);
|
||||
await hold({ name: DEV_HEADLESS_NAME, outputs: outputs(handle) });
|
||||
}
|
||||
|
||||
export async function detachDevHeadless(argv: readonly string[]): Promise<void> {
|
||||
const options = parseArgs(argv);
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const handle = await bootDevHeadless(stack, options);
|
||||
await handle.detach();
|
||||
stack.move();
|
||||
for (const [key, value] of Object.entries(outputs(handle))) console.log(`${key} ${value}`);
|
||||
console.log(`World ${JSON.stringify(DEV_HEADLESS_NAME)} is up. Detached; relaunch with --replace to tear it down.`);
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,52 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
import { launchHeadlessWeb } from "../packages/world/src/headless-web.ts";
|
||||
import type { HeadlessWebHandle } from "../packages/world/src/headless-web.ts";
|
||||
|
||||
const REPO_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
||||
const HEADLESS_PROD_LIVE_NAME = "headless-prod-live";
|
||||
|
||||
export interface HeadlessProdLiveOptions {
|
||||
allowSharedState: true;
|
||||
}
|
||||
|
||||
/** Source web/backend processes using the installed production desktop stores. */
|
||||
export async function bootHeadlessProdLive(
|
||||
stack: AsyncDisposableStack,
|
||||
options: HeadlessProdLiveOptions,
|
||||
): Promise<HeadlessWebHandle> {
|
||||
if (options?.allowSharedState !== true) {
|
||||
throw new Error("Refusing LIVE SHARED PRODUCTION STATE launch without explicit --allow-shared-state opt-in.");
|
||||
}
|
||||
const handle = await launchHeadlessWeb({
|
||||
repoRoot: REPO_ROOT,
|
||||
name: HEADLESS_PROD_LIVE_NAME,
|
||||
state: "installed-production",
|
||||
allowSharedState: true,
|
||||
});
|
||||
return stack.adopt(handle, (headless) => headless.stop());
|
||||
}
|
||||
|
||||
function parseArgs(argv: readonly string[]): HeadlessProdLiveOptions {
|
||||
if (argv.length !== 1 || argv[0] !== "--allow-shared-state") {
|
||||
throw new Error("Launch headless-prod-live with exactly --allow-shared-state.");
|
||||
}
|
||||
return { allowSharedState: true };
|
||||
}
|
||||
|
||||
export async function main(argv: readonly string[] = process.argv.slice(2)): Promise<void> {
|
||||
const options = parseArgs(argv);
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const handle = await bootHeadlessProdLive(stack, options);
|
||||
await hold({
|
||||
name: HEADLESS_PROD_LIVE_NAME,
|
||||
outputs: {
|
||||
webUrl: handle.manifest.webUrl,
|
||||
openworkUrl: handle.manifest.openworkUrl,
|
||||
workspace: handle.manifest.workspace,
|
||||
runtimeManifest: handle.manifest.runtimeManifestPath,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,95 @@
|
||||
import { app } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { createAdmin, createOrg, inviteMember, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { liteLlmPerMemberProvider } from "../evals/packages/env/src/litellm-provider.ts";
|
||||
import { liteLlm } from "../evals/packages/env/src/litellm.ts";
|
||||
import type { LiteLlmHandle } from "../evals/packages/env/src/litellm.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export const LITELLM_WORLD_ORG = "LiteLLM Per-Member World";
|
||||
export const LITELLM_WORLD_PROVIDER = "openwork-litellm-per-member";
|
||||
export const LITELLM_WORLD_MODEL = "openwork-litellm-per-member-model";
|
||||
export const LITELLM_WORLD_PASSWORD = "OpenWorkEval123!";
|
||||
|
||||
const REPLY = "The database-backed per-member LiteLLM world is working.";
|
||||
|
||||
export interface LiteLlmPerMemberWorld {
|
||||
gateway: LiteLlmHandle;
|
||||
den: Den;
|
||||
org: DenOrgHandle;
|
||||
admin: Awaited<ReturnType<typeof createAdmin>>;
|
||||
alice: Awaited<ReturnType<typeof inviteMember>>;
|
||||
provider: Awaited<ReturnType<typeof liteLlmPerMemberProvider>>;
|
||||
desktop: App;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Desktop + Den + database-backed LiteLLM world for manually exercising
|
||||
* the complete per-member example. The LiteLLM gateway talks to a deterministic
|
||||
* local OpenAI-compatible witness; it never reads or requires OPENAI_API_KEY.
|
||||
*
|
||||
* Launch: `pnpm world up ./worlds/litellm-per-member.ts`
|
||||
*/
|
||||
export async function bootLiteLlmPerMember(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
): Promise<LiteLlmPerMemberWorld> {
|
||||
const gateway = stack.use(await liteLlm({
|
||||
place,
|
||||
modelId: LITELLM_WORLD_MODEL,
|
||||
reply: REPLY,
|
||||
database: true,
|
||||
maxInputTokens: 128_000,
|
||||
maxOutputTokens: 16_384,
|
||||
}));
|
||||
const den = stack.use(await server({ place, provision: false, web: true }));
|
||||
const admin = await createAdmin(den, {
|
||||
name: "LiteLLM Admin",
|
||||
email: "litellm-admin@openwork.test",
|
||||
password: LITELLM_WORLD_PASSWORD,
|
||||
});
|
||||
const org = stack.use(await createOrg(den, LITELLM_WORLD_ORG));
|
||||
const alice = await inviteMember(den, "alice", {
|
||||
name: "Alice LiteLLM",
|
||||
email: "alice-litellm@openwork.test",
|
||||
password: LITELLM_WORLD_PASSWORD,
|
||||
});
|
||||
const provider = await liteLlmPerMemberProvider(admin, {
|
||||
gateway,
|
||||
orgId: org.id,
|
||||
providerId: LITELLM_WORLD_PROVIDER,
|
||||
name: "Per-Member LiteLLM Gateway",
|
||||
envVar: "LITELLM_PER_MEMBER_API_KEY",
|
||||
modelId: LITELLM_WORLD_MODEL,
|
||||
modelName: "Per-Member LiteLLM Witness",
|
||||
});
|
||||
const desktop = stack.use(await app({
|
||||
den,
|
||||
place,
|
||||
as: "admin",
|
||||
workspacePath: "/tmp/openwork-litellm-per-member-world",
|
||||
model: `${LITELLM_WORLD_PROVIDER}/${LITELLM_WORLD_MODEL}`,
|
||||
}));
|
||||
return { gateway, den, org, admin, alice, provider, desktop };
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const place = resolvePlace();
|
||||
const { gateway, den, desktop } = await bootLiteLlmPerMember(stack, place);
|
||||
await hold({
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
litellm: gateway.baseUrl,
|
||||
cdp: desktop.handle.cdpUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
await main();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
import { launchHeadlessWeb } from "../packages/world/src/headless-web.ts";
|
||||
import type { HeadlessWebHandle } from "../packages/world/src/headless-web.ts";
|
||||
|
||||
const REPO_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
||||
const REMOTE_SESSION_NAME = "remote-session";
|
||||
const REMOTE_SESSION_WORKSPACE = "/tmp/openwork-remote-session-world";
|
||||
|
||||
export interface RemoteSessionOptions {
|
||||
name?: string;
|
||||
workspace?: string;
|
||||
replace?: boolean;
|
||||
keepTokens?: boolean;
|
||||
rotateTokens?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Real source-first openwork-server and browser UI used by remote-session
|
||||
* gateway capabilities and their real-server spec.
|
||||
*/
|
||||
export async function bootRemoteSession(
|
||||
stack: AsyncDisposableStack,
|
||||
options: RemoteSessionOptions = {},
|
||||
): Promise<HeadlessWebHandle> {
|
||||
const handle = await launchHeadlessWeb({
|
||||
repoRoot: REPO_ROOT,
|
||||
name: options.name ?? REMOTE_SESSION_NAME,
|
||||
state: "isolated",
|
||||
workspace: options.workspace ?? REMOTE_SESSION_WORKSPACE,
|
||||
replace: options.replace,
|
||||
keepTokens: options.keepTokens,
|
||||
rotateTokens: options.rotateTokens,
|
||||
});
|
||||
return stack.adopt(handle, (headless) => headless.stop());
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const handle = await bootRemoteSession(stack);
|
||||
await hold({
|
||||
name: REMOTE_SESSION_NAME,
|
||||
outputs: {
|
||||
webUrl: handle.manifest.webUrl,
|
||||
openworkUrl: handle.manifest.openworkUrl,
|
||||
workspace: handle.manifest.workspace,
|
||||
runtimeManifest: handle.manifest.runtimeManifestPath,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
@@ -0,0 +1,56 @@
|
||||
import { seedSessions } from "../evals/packages/behaviors/src/sessions.ts";
|
||||
import { app } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import type { App } from "../evals/packages/env/src/desktop-app.ts";
|
||||
import { createAdmin, createOrg, server } from "../evals/packages/env/src/den.ts";
|
||||
import type { Den, DenOrgHandle } from "../evals/packages/env/src/den.ts";
|
||||
import { resolvePlace } from "../evals/packages/env/src/place.ts";
|
||||
import type { Place } from "../evals/packages/env/src/place.ts";
|
||||
import { hold } from "../packages/world/src/hold.ts";
|
||||
|
||||
export interface SoloOptions {
|
||||
sessions?: readonly string[];
|
||||
workspacePath?: string;
|
||||
profileDir?: string;
|
||||
}
|
||||
|
||||
export interface SoloWorld {
|
||||
den: Den;
|
||||
org: DenOrgHandle;
|
||||
desktop: App;
|
||||
sessions: { sessionId: string; title: string }[];
|
||||
}
|
||||
|
||||
/** One fresh organization and one signed-in desktop workspace. */
|
||||
export async function bootSolo(
|
||||
stack: AsyncDisposableStack,
|
||||
place: Place,
|
||||
options: SoloOptions = {},
|
||||
): Promise<SoloWorld> {
|
||||
const den = stack.use(await server({ place, provision: false, web: true }));
|
||||
await createAdmin(den, {});
|
||||
const org = stack.use(await createOrg(den, "acme"));
|
||||
const desktop = stack.use(await app({
|
||||
den,
|
||||
place,
|
||||
as: "admin",
|
||||
...(options.workspacePath === undefined ? {} : { workspacePath: options.workspacePath }),
|
||||
...(options.profileDir === undefined ? {} : { profileDir: options.profileDir }),
|
||||
}));
|
||||
const sessions = options.sessions ? await seedSessions(desktop, options.sessions) : [];
|
||||
return { den, org, desktop, sessions };
|
||||
}
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
await using stack = new AsyncDisposableStack();
|
||||
const { den, desktop } = await bootSolo(stack, resolvePlace());
|
||||
await hold({
|
||||
name: "solo",
|
||||
outputs: {
|
||||
denWeb: den.ref.webUrl,
|
||||
denApi: den.ref.apiUrl,
|
||||
cdp: desktop.handle.cdpUrl,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
Reference in New Issue
Block a user