Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Refresh YC welcome and launch personalized ideas chats (#1315)

Regan Bell7a23b4547b7a
diff --git a/docs/screenshots/yc-welcome/welcome.png b/docs/screenshots/yc-welcome/welcome.png
new file mode 100644
index 000000000..160cef74f
Binary files /dev/null and b/docs/screenshots/yc-welcome/welcome.png differ
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.ts
index 0d56eae4e..b86062971 100644
--- a/plugins/web-ui/src/chat.ts
+++ b/plugins/web-ui/src/chat.ts
@@ -1,6 +1,7 @@
import { appEditSlug } from "./app-edit";
import { isConnectionReturn } from "./connection-return";
import "./onboarding-welcome";
+import { welcomeIdeasPrompt } from "./welcome-ideas";
import { setupContent } from "./setup-widget";
import { isWelcomeConversation } from "./welcome-session";
import { ADMIN_BASE } from "./shell";
@@ -1130,6 +1131,38 @@ export function createChatSurface(
consumeBackgroundPanelRequest();
}
+ let startingIdeas = false;
+
+ function ideasUnavailable(): boolean {
+ return (
+ startingIdeas ||
+ !chatState.agent ||
+ chatState.agent.state.isStreaming ||
+ Boolean(chatState.pendingSend) ||
+ Boolean(ctx.composer.state.draft) ||
+ Boolean(ctx.composer.state.attachments.length) ||
+ ctx.composer.state.processingFiles ||
+ hasUnresolvedApproval()
+ );
+ }
+
+ async function showWelcomeIdeas(): Promise<void> {
+ if (ideasUnavailable()) return;
+ startingIdeas = true;
+ const threadRef = `web:${appState.me!.user}:ideas:${crypto.randomUUID()}`;
+ mountContinuable(threadRef, null, null, []);
+ const agent = chatState.agent;
+ try {
+ if (agent) {
+ await ctx.composer.refreshRuntimeSelection(null, agent);
+ await ctx.composer.sendSuggestedPrompt(welcomeIdeasPrompt, agent);
+ }
+ } finally {
+ startingIdeas = false;
+ if (agent && agent === chatState.agent) drawActiveChat(agent);
+ }
+ }
+
function welcomeGreeting(animate = true): TemplateResult {
return html`
<article class="message-row assistant-row welcome-greeting">
@@ -1137,6 +1170,8 @@ export function createChatSurface(
<qm-onboarding-welcome
.me=${appState.me}
.animateWelcome=${animate}
+ .onMoreIdeas=${showWelcomeIdeas}
+ .ideasDisabled=${ideasUnavailable()}
.base=${withBase("")}
.adminBase=${ADMIN_BASE}
></qm-onboarding-welcome>
diff --git a/plugins/web-ui/src/composer.ts b/plugins/web-ui/src/composer.ts
index 1235073aa..d33d6370c 100644
--- a/plugins/web-ui/src/composer.ts
+++ b/plugins/web-ui/src/composer.ts
@@ -2492,6 +2492,18 @@ export function createComposerSurface(ctx: ConvCtx): ComposerSurface {
resetComposer,
focusComposerEnd,
fillSuggestedPrompt,
+ sendSuggestedPrompt: async (prompt: string, agent: Agent): Promise<void> => {
+ if (
+ agent !== ctx.chat.state.agent ||
+ agent.state.isStreaming ||
+ composerState.draft ||
+ composerState.attachments.length ||
+ composerState.processingFiles
+ )
+ return;
+ fillSuggestedPrompt(prompt, agent);
+ await sendPrompt(agent);
+ },
resizeComposer,
currentModelOption,
carryModelPick,
diff --git a/plugins/web-ui/src/conv-types.ts b/plugins/web-ui/src/conv-types.ts
index 1ab67f787..dc45f5c10 100644
--- a/plugins/web-ui/src/conv-types.ts
+++ b/plugins/web-ui/src/conv-types.ts
@@ -129,6 +129,7 @@ export interface ComposerSurface {
resetComposer(): void;
focusComposerEnd(): void;
fillSuggestedPrompt(prompt: string, agent: Agent): void;
+ sendSuggestedPrompt(prompt: string, agent: Agent): Promise<void>;
resizeComposer(): void;
currentModelOption(): ModelOption | undefined;
carryModelPick(fromThreadRef: string | null, toThreadRef: string): void;
diff --git a/plugins/web-ui/src/onboarding-welcome.css b/plugins/web-ui/src/onboarding-welcome.css
index a8e03d99b..c762125e4 100644
--- a/plugins/web-ui/src/onboarding-welcome.css
+++ b/plugins/web-ui/src/onboarding-welcome.css
@@ -299,3 +299,26 @@ qm-onboarding-welcome {
font-size: 13px;
color: var(--foreground);
}
+
+.welcome-more-ideas {
+ padding: 0;
+ border: 0;
+ background: none;
+ font: inherit;
+ color: color-mix(in srgb, var(--foreground) 40%, var(--muted-foreground));
+ text-decoration: underline;
+ text-decoration-color: color-mix(in srgb, currentColor 38%, transparent);
+ text-decoration-thickness: 1px;
+ text-underline-offset: 3px;
+ white-space: nowrap;
+ cursor: pointer;
+}
+.welcome-more-ideas:hover,
+.welcome-more-ideas:focus-visible {
+ color: var(--foreground);
+ text-decoration-color: currentColor;
+}
+.welcome-more-ideas:disabled {
+ opacity: 0.5;
+ cursor: default;
+}
diff --git a/plugins/web-ui/src/onboarding-welcome.ts b/plugins/web-ui/src/onboarding-welcome.ts
index 4c71daca8..45aa0c412 100644
--- a/plugins/web-ui/src/onboarding-welcome.ts
+++ b/plugins/web-ui/src/onboarding-welcome.ts
@@ -31,6 +31,8 @@ import {
export class OnboardingWelcome extends LitElement {
static properties = {
me: { attribute: false },
+ onMoreIdeas: { attribute: false },
+ ideasDisabled: { type: Boolean },
animateWelcome: { type: Boolean },
setupOnly: { type: Boolean },
widget: {},
@@ -46,6 +48,8 @@ export class OnboardingWelcome extends LitElement {
connectionError: { state: true },
};
declare me: Me | null;
+ declare onMoreIdeas: (() => void) | undefined;
+ declare ideasDisabled: boolean;
declare animateWelcome: boolean;
declare setupOnly: boolean;
declare widget: "all" | "apps" | "slack";
@@ -78,6 +82,7 @@ export class OnboardingWelcome extends LitElement {
constructor() {
super();
this.me = null;
+ this.ideasDisabled = false;
this.animateWelcome = true;
this.setupOnly = false;
this.widget = "all";
@@ -399,14 +404,26 @@ export class OnboardingWelcome extends LitElement {
</div>`
: nothing
}
- <p class="welcome-beat" style=${`--welcome-delay:${cohort ? 2400 : 400}ms`}>
- ${cohort ? "And welcome" : "Welcome"} to QM, ${cohort ? "YC’s" : "your"} agent harness. Use it to
- research customers, build tools, and automate the everyday work of running
- ${this.me?.companyName?.trim() || "your company"}.
- </p>
- <p class="welcome-beat" style=${`--welcome-delay:${cohort ? 2800 : 700}ms`}>
- The easiest way to get up and running:
- </p>`
+ ${
+ cohort
+ ? html`<p class="welcome-beat" style="--welcome-delay:2400ms">
+ And welcome to QM, the agent harness we use to run YC.
+ </p>
+ <p class="welcome-beat" style="--welcome-delay:2600ms">
+ Use it to research customers and investors, fundraise, and automate the everyday work of running
+ ${this.me?.companyName?.trim() || "your company"}.
+ ${this.onMoreIdeas ? html`<button type="button" class="welcome-more-ideas" ?disabled=${this.ideasDisabled} @click=${this.onMoreIdeas}>More ideas</button>` : nothing}
+ </p>
+ <p class="welcome-beat" style="--welcome-delay:2800ms">
+ Think of it as your YC partner in a box. The more you use QM, the more context we have, the more
+ we can help.
+ </p>`
+ : html`<p class="welcome-beat" style="--welcome-delay:400ms">
+ Welcome to QM, your agent harness. Use it to research customers, build tools, and automate the
+ everyday work of running ${this.me?.companyName?.trim() || "your company"}.
+ </p>
+ <p class="welcome-beat" style="--welcome-delay:700ms">The easiest way to get up and running:</p>`
+ }`
}
${
this.widget !== "apps" && this.me?.permissions?.includes("admin")
diff --git a/plugins/web-ui/src/welcome-ideas.ts b/plugins/web-ui/src/welcome-ideas.ts
new file mode 100644
index 000000000..73fcf78ef
--- /dev/null
+++ b/plugins/web-ui/src/welcome-ideas.ts
@@ -0,0 +1,7 @@
+export const welcomeIdeasPrompt = `Help me explore what I can do with QM. Skip onboarding and setup in this conversation; go straight to ideas. Keep your first response around 200 words: three concrete example bullets, followed by an offer to tailor more ideas and at most two focused questions. Avoid repeating permission disclaimers. Show these workflows as possibilities, not tasks to execute now:
+
+1. Recruiting: Check Work at a Startup every morning for new engineering candidates with Rust experience, notify me in Slack, and prepare Gmail outreach drafts in the tone of my previous emails.
+2. Building: Help implement a Stripe integration, check for an applicable YC Deal first, and prepare a pull request for my cofounder to review.
+3. Fundraising: Build a fundraising dashboard with investor prospects from the YC investor database and the web, matches based on what our company does, outreach drafts for my review, fundraising progress, and investor inbound from my inbox.
+
+Then offer to help come up with more ideas tailored to my goals, our company's current needs, and our progress through the YC batch. Check whether the yc tool is available. If it is, use its authorized context and tool discovery to learn about me, my company, and the current batch. Combine that with available company context and memory; if the tool is unavailable, continue with what you know. Do not assume today's goals or batch stage from old information. If context is missing, ask one or two focused questions. Suggest a few concrete next steps and help me choose one. Only discuss the examples for now; do not set up automations, send outreach, redeem deals, or modify external systems until I choose what to do.`;
diff --git a/plugins/web-ui/src/welcome-session.ts b/plugins/web-ui/src/welcome-session.ts
index 1bf213786..04ef53aea 100644
--- a/plugins/web-ui/src/welcome-session.ts
+++ b/plugins/web-ui/src/welcome-session.ts
@@ -6,9 +6,13 @@ export function isWelcomeConversation(
threadRef: string | null,
scopeId: string | null,
): boolean {
+ if (threadRef?.startsWith(`web:${user}:ideas:`)) return false;
if (!threadRef?.startsWith(`web:${user}:`) || (scopeId && scopeId !== `personal:${user}`)) return false;
const personal = sessions.filter(
- (session) => session.scopeId === `personal:${user}` && session.threadRef.startsWith(`web:${user}:`),
+ (session) =>
+ session.scopeId === `personal:${user}` &&
+ session.threadRef.startsWith(`web:${user}:`) &&
+ !session.threadRef.startsWith(`web:${user}:ideas:`),
);
const first = personal.reduce<CoreSession | undefined>(
(oldest, session) =>
diff --git a/plugins/web-ui/test/welcome-ideas.test.ts b/plugins/web-ui/test/welcome-ideas.test.ts
new file mode 100644
index 000000000..df576d54b
--- /dev/null
+++ b/plugins/web-ui/test/welcome-ideas.test.ts
@@ -0,0 +1,101 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { harness } from "./deep-link-boot-fixture.ts";
+
+test("More ideas opens a fresh personal web chat and sends the examples once", async () => {
+ const h = await harness({ path: "/", welcome: true, listSessions: [] });
+ Object.defineProperty(window.Element.prototype, "getAnimations", { configurable: true, value: () => [] });
+ Object.defineProperty(window.Element.prototype, "animate", {
+ configurable: true,
+ value: () => ({ cancel() {}, currentTime: 0 }),
+ });
+ const matrixDescriptor = Object.getOwnPropertyDescriptor(globalThis, "DOMMatrix");
+ Object.defineProperty(globalThis, "DOMMatrix", { configurable: true, value: class {} });
+ const previousFetch = globalThis.fetch;
+ const turns: Record<string, unknown>[] = [];
+ const realNow = Date.now;
+ let holdRuntime = false;
+ let releaseRuntime: () => void = () => {};
+ const runtimeHeld = new Promise<void>((resolve) => {
+ releaseRuntime = resolve;
+ });
+ globalThis.fetch = async (input, init) => {
+ if (String(input).startsWith("/api/runtime-config")) {
+ if (holdRuntime) await runtimeHeld;
+ await new Promise((resolve) => setTimeout(resolve, 25));
+ return Response.json({
+ scopeId: "personal:tester",
+ approvedHarnesses: ["pi"],
+ modelsByHarness: { pi: ["test-model"] },
+ modelCatalog: {
+ "test-model": {
+ id: "test-model",
+ name: "Test",
+ label: "Test",
+ buttonLabel: "Test",
+ provider: "anthropic",
+ api: "anthropic-messages",
+ reasoning: false,
+ input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 10000,
+ maxTokens: 1000,
+ },
+ },
+ effective: { harnessId: "pi", modelId: "test-model" },
+ orgDefault: { harnessId: "pi", modelId: "test-model", revision: 1 },
+ scopeOverride: null,
+ upgradeAvailable: false,
+ });
+ }
+ if (String(input) === "/api/turn") {
+ turns.push(JSON.parse(String(init?.body)));
+ return Response.json({ reply: "Let's explore ideas." });
+ }
+ return previousFetch(input, init);
+ };
+ try {
+ h.releaseSessions();
+ await h.boot();
+ await new Promise((resolve) => setTimeout(resolve, 60));
+ const originalThread = h.visibleConversation().state.threadRef;
+ const draft = document.querySelector<HTMLTextAreaElement>(".composer-input")!;
+ draft.value = "Keep this draft";
+ draft.dispatchEvent(new window.Event("input", { bubbles: true }));
+ await new Promise((resolve) => setTimeout(resolve, 30));
+ document.querySelector<HTMLButtonElement>(".welcome-more-ideas")!.click();
+ assert.equal(h.visibleConversation().state.threadRef, originalThread);
+ assert.equal(turns.length, 0);
+ draft.value = "";
+ draft.dispatchEvent(new window.Event("input", { bubbles: true }));
+ await new Promise((resolve) => setTimeout(resolve, 30));
+ const more = document.querySelector<HTMLButtonElement>(".welcome-more-ideas")!;
+ assert.ok(more);
+ holdRuntime = true;
+ Date.now = () => realNow() + 31_000;
+ more.click();
+ more.click();
+ await new Promise((resolve) => setTimeout(resolve, 30));
+ assert.equal(turns.length, 0);
+ assert.notEqual(h.visibleConversation().state.threadRef, originalThread);
+ releaseRuntime();
+ for (let i = 0; i < 100 && !turns.length; i++) await new Promise((resolve) => setTimeout(resolve, 10));
+ assert.equal(turns.length, 1, h.mainText());
+ assert.notEqual(turns[0]!.threadRef, originalThread);
+ assert.match(String(turns[0]!.threadRef), /^web:tester:ideas:/);
+ assert.equal(turns[0]!.scopeId, undefined);
+ assert.equal(turns[0]!.proactiveOpener, undefined);
+ assert.match(String(turns[0]!.text), /Work at a Startup/);
+ assert.match(String(turns[0]!.text), /Stripe/);
+ assert.match(String(turns[0]!.text), /fundraising dashboard/);
+ assert.match(String(turns[0]!.text), /Skip onboarding/);
+ assert.match(String(turns[0]!.text), /yc tool/);
+ assert.doesNotMatch(String(turns[0]!.text), /YC application|historical context/);
+ } finally {
+ releaseRuntime();
+ Date.now = realNow;
+ await h.close();
+ if (matrixDescriptor) Object.defineProperty(globalThis, "DOMMatrix", matrixDescriptor);
+ else Reflect.deleteProperty(globalThis, "DOMMatrix");
+ }
+});
diff --git a/plugins/web-ui/test/welcome-session.test.ts b/plugins/web-ui/test/welcome-session.test.ts
index 148cc4085..f30fb3699 100644
--- a/plugins/web-ui/test/welcome-session.test.ts
+++ b/plugins/web-ui/test/welcome-session.test.ts
@@ -30,3 +30,10 @@ test("shared, Slack, and other people's conversations do not get the welcome", (
const shared = { ...first, scopeId: "group:team", threadRef: "web:sam:first", createdAt: 0 };
assert.equal(isWelcomeConversation([shared, first], "alex", first.threadRef, first.scopeId), true);
});
+
+test("ideas chats never show the welcome or take the first welcome slot", () => {
+ const ideas = { ...first, threadRef: "web:alex:ideas:12345678-1234-4123-8123-123456789abc", createdAt: 0 };
+ assert.equal(isWelcomeConversation([], "alex", ideas.threadRef, null), false);
+ assert.equal(isWelcomeConversation([ideas], "alex", first.threadRef, null), true);
+ assert.equal(isWelcomeConversation([ideas, first], "alex", first.threadRef, null), true);
+});
diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.ts
index 030a42cd1..5c4d392cd 100644
--- a/src/core/orchestrator.ts
+++ b/src/core/orchestrator.ts
@@ -107,6 +107,7 @@ import { createSkillMaterializer, skillsIndex, SKILLS_DIR } from "../skills/mate
import {
detectOnboardingStatus,
onboardingSkillVisible,
+ isIdeasConversation,
PROACTIVE_OPENER_PROMPT,
renderPendingOnboardingPrompt,
} from "../onboarding/onboarding.ts";
@@ -1213,8 +1214,10 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {
? `\n\n## What you remember\nYou're in ${memoryContext}. Scope headings and \`(said in …)\` tags identify provenance. You may use facts from these included, authorized memories to answer this request; do not ask for them to be shared again merely because they came from another scope. Context-specific instructions and preferences still apply only to their source context unless the user says otherwise.\n\n${recalled}`
: "";
- let onboardingBlock = "";
- if (useMemory && conversation.kind === "dm" && onboardingSkillVisible(visibleSkills)) {
+ let onboardingBlock = isIdeasConversation(input)
+ ? "## Ideas conversation\nThe user chose to explore ideas in this conversation. Skip the onboarding skill and setup flow for this entire conversation, including follow-ups. Do not mark onboarding completed or dismissed in memory. Use available authorized company context and answer their request directly."
+ : "";
+ if (!onboardingBlock && useMemory && conversation.kind === "dm" && onboardingSkillVisible(visibleSkills)) {
const fullMemory = await deps.memory.read(memoryScopeId).catch(swallowAs("orchestrator: memory read", ""));
onboardingBlock = renderPendingOnboardingPrompt(detectOnboardingStatus(fullMemory));
}
diff --git a/src/onboarding/onboarding.ts b/src/onboarding/onboarding.ts
index 000419ce6..787fff892 100644
--- a/src/onboarding/onboarding.ts
+++ b/src/onboarding/onboarding.ts
@@ -1,3 +1,4 @@
+import type { TurnRequest } from "../types.ts";
import type { SkillResolution } from "../skills/skill-store.ts";
const ONBOARDING_SKILL_NAME = "onboarding";
@@ -73,3 +74,16 @@ export function renderPendingOnboardingPrompt(status: OnboardingStatus, version
`Use the \`memory\` tool as the source of truth. On completion or an explicit stop, preserve the notebook and add \`- Onboarding: completed ${version} on YYYY-MM-DD.\` so onboarding does not recur.`,
].join("\n");
}
+
+export function isIdeasConversation(input: {
+ surface?: string;
+ conversation: Pick<TurnRequest["conversation"], "kind" | "threadRef">;
+}): boolean {
+ return (
+ input.surface === "web" &&
+ input.conversation.kind === "dm" &&
+ /^web:.+:ideas:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
+ input.conversation.threadRef,
+ )
+ );
+}
diff --git a/test/onboarding.test.ts b/test/onboarding.test.ts
index 62575821b..1f728292a 100644
--- a/test/onboarding.test.ts
+++ b/test/onboarding.test.ts
@@ -121,3 +121,34 @@ test("the opener defers Slack setup until status can be checked without requirin
assert.match(PROACTIVE_OPENER_PROMPT, /skip connections and continue onboarding/);
assert.match(PROACTIVE_OPENER_PROMPT, /do not ask them to create OAuth apps or supply project keys/);
});
+
+test("ideas web conversations bypass onboarding on every turn without completing it", async () => {
+ const { app, skills, memory } = freshApp();
+ await waitForOnboardingSkill(skills);
+ const threadRef = "web:U1:ideas:12345678-1234-4123-8123-123456789abc";
+ for (let i = 0; i < 2; i++) {
+ const sys = await app.turn({
+ surface: "web",
+ actor,
+ conversation: { kind: "dm", threadRef },
+ text: "!sysprompt",
+ } as TurnRequest);
+ assert.doesNotMatch(sys.reply ?? "", /## Pending Onboarding/);
+ assert.match(sys.reply ?? "", /Skip the onboarding skill and setup flow for this entire conversation/);
+ }
+ assert.equal(detectOnboardingStatus(await memory.read(scopeId("personal", "U1"))), "not_started");
+ const ordinary = await app.turn({
+ surface: "web",
+ actor,
+ conversation: { kind: "dm", threadRef: "web:U1:ordinary" },
+ text: "!sysprompt",
+ } as TurnRequest);
+ assert.match(ordinary.reply ?? "", /## Pending Onboarding/);
+ const slack = await app.turn({
+ surface: "slack",
+ actor,
+ conversation: { kind: "dm", threadRef },
+ text: "!sysprompt",
+ } as TurnRequest);
+ assert.match(slack.reply ?? "", /## Pending Onboarding/);
+});