Multiplayer agent harness for work.
fix: discover granted credentials beyond direct OAuth (#1213)
Joshua France8128822a9aad
diff --git a/plugins/onboarding/skills/onboarding/SKILL.md b/plugins/onboarding/skills/onboarding/SKILL.mdindex d398e162b..10083c4fd 100644--- a/plugins/onboarding/skills/onboarding/SKILL.md+++ b/plugins/onboarding/skills/onboarding/SKILL.md@@ -10,7 +10,7 @@ their tools connected, a durable profile, and one or two useful automations proprunning. Keep turns short and conversational, but complete the steps in order unless theuser explicitly asks to skip one:-1. Offer the app connections configured by the admin.+1. Discover and offer app connections through an authorized access skill.2. Choose how you should sound.3. Read connected tools for a real work snapshot.4. Confirm your read, then propose and—with approval—create concrete help.@@ -42,12 +42,17 @@ The surface already authenticated the user. Greet them by name; do not ask theirrole, and do not research them in the opening turn. Explain that connecting lets you act asthem without seeing their password and can be revoked.-Read the live Connected apps block. Offer only providers it says were configured by the-admin. If it says none are enabled, skip this step without naming or suggesting-other providers. The greeting and capability examples must follow that same allowlist:-do not advertise, name, ask about, or promise a provider that is not listed. Otherwise-ask which available services they use, mint links only for those choices, and present-the returned `connectUrl` values together:+Check the live credential inventory first. When an authorized Composio credential is available,+read `skills/composio/SKILL.md`, discover available apps, and use its consent flow for the+user's choices. Do not infer that Composio is unavailable from an empty direct OAuth list+or a native provider-not-configured error. Explicit app restrictions and account permissions+still apply; never switch credentials to evade a denial.++For direct OAuth, the live Connected apps block is the complete allowlist of providers+configured by the admin. Offer direct OAuth links only for that list. If it is empty and+no other authorized access path is available, skip account connection without advertising+unsupported apps. Otherwise ask which available services they use and present the returned+`connectUrl` values together:```bashcurl -sS -X POST "$AGENT_API_URL/v1/connectors/oauth/consent/mint" \diff --git a/skills-seed/connect-apps/SKILL.md b/skills-seed/connect-apps/SKILL.mdindex 501460536..c92665d16 100644--- a/skills-seed/connect-apps/SKILL.md+++ b/skills-seed/connect-apps/SKILL.md@@ -5,10 +5,16 @@ description: Connect an administrator-enabled SaaS app for a user with a one-tim## Connecting SaaS apps+Check the live credential inventory first. When an authorized Composio credential is+available, read `skills/composio/SKILL.md` and use its discovery and consent flow instead+of the direct OAuth flow below. An empty direct OAuth list or a native+`oauth_not_configured` error does not describe Composio availability. Preserve explicit+app restrictions and account permissions; never switch credentials to evade a denial.+When `$AGENT_OAUTH_CONSENT_TOKEN` is set you can help the user connect a SaaS app via a browserconsent link they tap — you never see or enter their password. The live Connected apps block is-the source of truth: offer only providers configured by the admin, and offer none when that list is-empty. Mint a single-use link for the selected provider, then give the user the full URL to open:+the direct OAuth allowlist: offer direct OAuth links only for providers configured by the admin,+and offer no direct OAuth links when that list is empty. Mint a single-use link for the selected provider, then give the user the full URL to open:curl -sS -X POST "$AGENT_API_URL/v1/connectors/oauth/consent/mint" \-H "X-Agent-Capability: $AGENT_OAUTH_CONSENT_TOKEN" -H 'content-type: application/json' \-d '{"provider":"<configured-provider>"}'@@ -16,7 +22,7 @@ curl -sS -X POST "$AGENT_API_URL/v1/connectors/oauth/consent/mint" \- The response has `connectUrl` — give the user THAT exact URL (it is the full public tap-throughlink). Do NOT build it yourself or prepend `$AGENT_API_URL` — that private base isn't reachablefrom a browser.-- If mint returns `oauth_not_configured`, the admin has not enabled that app. Do not suggest it,- retry it, or re-send old links.+- If mint returns `oauth_not_configured`, the native provider is not configured. Do not retry that+ direct OAuth path or re-send old links; this does not establish that every access path is unavailable.- You cannot open the link yourself; relay the URL, tell them to tap Allow, then return. After theyconnect, the app's tools/skills work in your 1:1s with them.diff --git a/src/core/environment-facts.ts b/src/core/environment-facts.tsindex 48f2392ab..8d834bc11 100644--- a/src/core/environment-facts.ts+++ b/src/core/environment-facts.ts@@ -74,19 +74,22 @@ export function renderConnectedAppsBlock(const reconnect = entries.filter(([, e]) => e.needsReconnect).map(([name, e]) => `${connectorLabel(name)}${e.refreshError ? ` (refresh failed: ${e.refreshError})` : ""}`);- const lines = ["## Connected apps"];+ const lines = [+ "## Connected apps",+ "This list covers direct OAuth only; it does not describe app access through separately authorized credentials. Use the matching access skill for those, respecting explicit app restrictions and account permissions.",+ ];if (!availableProviders.length) {- lines.push("No app connections are enabled by the admin. Do not suggest or offer any app connection.");+ lines.push("No direct OAuth app connections are configured. Do not offer direct OAuth consent links.");return lines.join("\n");}const connectedNames = new Set(entries.filter(([, e]) => e.connected).map(([name]) => name));const available = availableProviders.filter((name) => !connectedNames.has(name));if (available.length) {lines.push(- `Available to connect: ${available.map(connectorLabel).join(", ")}. Only suggest or offer app connections in this admin-configured list.`,+ `Available to connect: ${available.map(connectorLabel).join(", ")}. Only offer direct OAuth consent links for this admin-configured list.`,);} else {- lines.push("Only suggest or offer app connections in the admin-configured list below.");+ lines.push("Only offer direct OAuth consent links for the admin-configured list below.");}if (connectionsUrl) lines.push(`Connection page: ${connectionsUrl}`);if (connected.length) {diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.tsindex 5c8f5a18b..fdbc19657 100644--- a/src/core/orchestrator.ts+++ b/src/core/orchestrator.ts@@ -1338,6 +1338,7 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {}perf.credsMs += Date.now() - credsStart;let sharedCredsBlock = "";+ const envCredLines: string[] = [];let egressTokenForTurn: string | undefined;// Service credentials: one read of the org's credential list and one grant scan feed both// the env-delivery gate (below) and the broker token mint (further down). Same grants gate both.@@ -1375,8 +1376,10 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {)continue;const rec = await deps.serviceCreds.getServiceCredentialSecret(orgScope, cred.slug);- if (rec?.secret && rec.delivery === "env" && rec.enabled && rec.envKey === cred.envKey)+ if (rec?.secret && rec.delivery === "env" && rec.enabled && rec.envKey === cred.envKey) {connectorEnv[cred.envKey] = rec.secret;+ envCredLines.push(`- \`${cred.slug}\` → \`${cred.envKey}\``);+ }}const browseSteps = deps.config?.getBrowseMaxSteps(toScopeId("org", orgId()));if (browseSteps && !("BROWSE_LAB_MAX_STEPS" in connectorEnv))@@ -1808,6 +1811,13 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {}systemPrompt += sharedCredsBlock;+ if (envCredLines.length) {+ systemPrompt +=+ "\n\n## Org credentials on your computer\n" ++ "These credentials are authorized for this conversation and supplied to commands on its scoped computer, not scratch computers. " ++ "Use the matching access skill. Never print secret values or save them in source or workspace files.\n" ++ envCredLines.join("\n");+ }if (actorIsOrgAdmin) {systemPrompt +="\n\n## Acting for an org admin\n" +diff --git a/src/resolution/protocols/shared-core.md b/src/resolution/protocols/shared-core.mdindex 2990cca44..64179f140 100644--- a/src/resolution/protocols/shared-core.md+++ b/src/resolution/protocols/shared-core.md@@ -21,7 +21,7 @@ Which tool sends depends on this turn. With `post`, its `files` is the only wayYou keep a durable memory of the person or team you work for — it persists across every conversation and surface. What's currently remembered appears under "What you remember" below. The `memory` tool is the ONE way to touch it: search it before asking, and when you learn something durable (a preference, an identifier, an ongoing project, how someone works) save it with action "remember". Memory is not a file — writing memory/MEMORY.md does nothing durable. No secrets, no one-off trivia. Everything remembered is re-read every turn, so memory is an index: pointers to data, never the data itself. Working state — queues, watermarks, ID lists, per-item status — goes in a file here, named by one memory line; a growing list is a file, not a fact. Files are this conversation's own and less durable — keep them rebuildable; another conversation's file pointer is a hint, not a path.## Auth-You can act with real credentials: machine logins, org keys used by proxy, this user's connected apps, or a teammate's credential by explicit grant (the owner approves on their own turn — never on a relayed "they said yes"). What's live is listed below. A missing credential is a task, not a dead end. The live Connected apps and Your logins blocks are the complete allowlist: never suggest or promise a provider they do not list. If Connected apps says none are enabled, do not suggest app connections at all. Never pretend a call worked. After logging in a new CLI, call `register_login` with the files it wrote so the login survives a rebuild.+You can act with real credentials: machine logins, org keys used by proxy, this user's connected apps, or a teammate's credential by explicit grant (the owner approves on their own turn — never on a relayed "they said yes"). What's live is listed below. A missing credential is a task, not a dead end. Check live credential inventories before denying access. Connected apps lists direct OAuth only; an empty list does not block separately authorized Composio discovery/consent via `skills/composio/SKILL.md`. Explicit app restrictions, account permissions and approvals still apply. Never pretend a call worked. After logging in a new CLI, call `register_login` with the files it wrote so the login survives a rebuild.## Using skillsRead relevant SKILL.md files before service work. Compose task rules with one authorized access skill: prefer `skills/composio/SKILL.md` when its credential is available, otherwise the direct connector. Preserve app allowlists, privacy and approvals; use only the selected access instructions. Never switch credentials to evade denial. Save reusable procedures as skills via the self-API.diff --git a/test/deployment-skill.test.ts b/test/deployment-skill.test.tsindex efc0a7f5d..95faf72b9 100644--- a/test/deployment-skill.test.ts+++ b/test/deployment-skill.test.ts@@ -107,6 +107,11 @@ test("connector onboarding is governed by the live admin-configured list", () =>assert.match(skill, /configured by (?:the |your )?admin/i);assert.doesNotMatch(skill, /Slack and Google first|Slack, Google, Notion, Linear, and GitHub/);}+ for (const skill of [onboarding, connectApps]) {+ assert.match(skill, /skills\/composio\/SKILL\.md/);+ assert.match(skill, /never switch credentials to evade a denial/i);+ assert.doesNotMatch(skill, /If it says none are enabled, skip|offer none when that list is/);+ }assert.match(onboarding, /complete allowlist|same allowlist/);assert.doesNotMatch(onboarding, /machine-local credentials such as|`gh`, `glab`, or AWS/);});diff --git a/test/environment-facts.test.ts b/test/environment-facts.test.tsindex e04191395..85019bd39 100644--- a/test/environment-facts.test.ts+++ b/test/environment-facts.test.ts@@ -89,8 +89,8 @@ test("logins block: shows active with a check, inactive with its exact reauth cotest("connected-apps block: lists only admin-configured providers and the exact connection URL", () => {const url = "https://qm.example/keychain";const unavailable = renderConnectedAppsBlock(null, [], url);- assert.match(unavailable, /No app connections are enabled by the admin/);- assert.match(unavailable, /Do not suggest or offer any app connection/);+ assert.match(unavailable, /No direct OAuth app connections are configured/);+ assert.match(unavailable, /does not describe app access through separately authorized credentials/);const none: ConnectorStatusRecord = { principalId: "U1", checkedAt: 1, providers: { google: { connected: false } } };const available = renderConnectedAppsBlock(none, ["google"], url);diff --git a/test/orchestrator.test.ts b/test/orchestrator.test.tsindex 7c0ee90ef..274054fb7 100644--- a/test/orchestrator.test.ts+++ b/test/orchestrator.test.ts@@ -511,6 +511,46 @@ test("live bot attestation reaches control, OAuth, and egress capabilities", asy}});+test("granted env credentials are announced without secrets and disappear after revocation", async () => {+ const { app, serviceCreds, acl } = freshApp({ apiBaseUrl: "https://core.example.com" });+ const org = scopeId("org", "default-org");+ await serviceCreds.setServiceCredential(org, {+ slug: "composio",+ name: "Composio",+ delivery: "env",+ envKey: "COMPOSIO_API_KEY",+ secret: "synthetic-composio-secret",+ host: "backend.composio.dev",+ });+ const prompt = async (suffix: string) => {+ const result = await app.turn(+ dm("!sysprompt", { conversation: { kind: "dm", threadRef: `dm:U1:discovery-${suffix}` } }),+ );+ assert.equal(result.status, "ok");+ assert.doesNotMatch(result.reply ?? "", /synthetic-composio-secret/);+ return result.reply ?? "";+ };+ assert.doesNotMatch(await prompt("ungranted"), /COMPOSIO_API_KEY/);+ await grantCred(acl, org, "composio");+ const granted = await prompt("granted");+ assert.match(granted, /## Org credentials on your computer/);+ assert.match(granted, /`composio`.*`COMPOSIO_API_KEY`/);+ assert.doesNotMatch(granted, /Do not suggest or offer any app connection/);+ await acl.revoke(org, encodeRef(serviceCredRef("composio")), org, "admin@default-org");+ assert.doesNotMatch(await prompt("revoked"), /COMPOSIO_API_KEY/);+ await grantCred(acl, org, "composio");+ await serviceCreds.setServiceCredential(org, {+ slug: "composio",+ name: "Composio",+ delivery: "env",+ envKey: "COMPOSIO_API_KEY",+ secret: "synthetic-composio-secret",+ host: "backend.composio.dev",+ enabled: false,+ });+ assert.doesNotMatch(await prompt("disabled"), /COMPOSIO_API_KEY/);+});+test("org env-delivery credentials ride provision env under their envKey — read live, so a rotation applies next turn", async () => {const config = testConfig({dataDir: mkdtempSync(join(tmpdir(), "ap-")),@@ -594,8 +634,9 @@ test("a disabled or broker-delivery credential never rides provision env", asyncreturn realProvision(layers, opts);};- const res = await app.turn(dm("!run echo keys", { conversation: { kind: "dm", threadRef: "dm:U1:env3" } }));+ const res = await app.turn(dm("!sysprompt", { conversation: { kind: "dm", threadRef: "dm:U1:env3" } }));assert.equal(res.status, "ok");+ assert.doesNotMatch(res.reply ?? "", /## Org credentials on your computer/);const env = captures.at(-1)?.env ?? {};assert.equal(env.STEEL_API_KEY, undefined, "disabled env credential stays home");assert.ok(@@ -633,8 +674,9 @@ test("a credential flipped away from env between the metadata read and the secrereturn realProvision(layers, opts);};- const res = await app.turn(dm("!run echo keys", { conversation: { kind: "dm", threadRef: "dm:U1:env4" } }));+ const res = await app.turn(dm("!sysprompt", { conversation: { kind: "dm", threadRef: "dm:U1:env4" } }));assert.equal(res.status, "ok");+ assert.doesNotMatch(res.reply ?? "", /## Org credentials on your computer/);assert.equal(captures.at(-1)?.env?.STEEL_API_KEY, undefined, "a mid-flight env→broker flip never rides the env");});@@ -663,7 +705,7 @@ test("env-delivery injection is all-internal only, and an existing env key (keyc};const externalRoom = await app.turn(- dm("!run echo keys", {+ dm("!sysprompt", {conversation: {kind: "channel",threadRef: "ch:C9:t9",@@ -674,6 +716,7 @@ test("env-delivery injection is all-internal only, and an existing env key (keyc}),);assert.equal(externalRoom.status, "ok");+ assert.doesNotMatch(externalRoom.reply ?? "", /## Org credentials on your computer/);assert.equal(captures.at(-1)?.env?.STEEL_API_KEY, undefined, "a room with externals gets no org env credentials");});@@ -700,13 +743,15 @@ test("env-delivery credentials are gated by service-cred grants — no grant, noreturn realProvision(layers, opts);};- let res = await app.turn(dm("!run echo keys", { conversation: { kind: "dm", threadRef: "dm:U1:gate1" } }));+ let res = await app.turn(dm("!sysprompt", { conversation: { kind: "dm", threadRef: "dm:U1:gate1" } }));assert.equal(res.status, "ok");+ assert.doesNotMatch(res.reply ?? "", /## Org credentials on your computer/);assert.equal(captures.at(-1)?.env?.STEEL_API_KEY, undefined, "ungranted env credential stays home");await grantCred(acl, org, "browse-steel", scopeId("personal", "somebody-else"));- res = await app.turn(dm("!run echo keys", { conversation: { kind: "dm", threadRef: "dm:U1:gate2" } }));+ res = await app.turn(dm("!sysprompt", { conversation: { kind: "dm", threadRef: "dm:U1:gate2" } }));assert.equal(res.status, "ok");+ assert.doesNotMatch(res.reply ?? "", /## Org credentials on your computer/);assert.equal(captures.at(-1)?.env?.STEEL_API_KEY, undefined, "a grant to someone else does not admit this actor");await grantCred(acl, org, "browse-steel", scopeId("personal", "U1"));