Skip to content

An open-source, faster Devin alternative

TypeScript

fix: address UI/docs PR review (credential field, SDK casing, pagination, rotation)

Igor Zalutski8f61a07206fd
diff --git a/docs/agent-sessions/credentials.mdx b/docs/agent-sessions/credentials.mdx
index 4267922e..8ad575e0 100644
--- a/docs/agent-sessions/credentials.mdx
+++ b/docs/agent-sessions/credentials.mdx
@@ -84,16 +84,16 @@ If neither resolves, the session fails to start with `422 no_credential`.
## Rotation
-Rotating the **key value** behind a credential flows to **running** sessions too — the one exception to a session's otherwise [pinned config](/agent-sessions/agents#session-pinned-config), so a compromised key can be swapped without restarting work. Rotate by updating the agent's `key`:
+Rotating the **key value** behind a credential flows to **running** sessions too — the one exception to a session's otherwise [pinned config](/agent-sessions/agents#session-pinned-config), so a compromised key can be swapped without restarting work. Rotate the credential:
<CodeGroup>
```ts TypeScript SDK
-await oc.agents.update("agt_...", { key: "sk-ant-NEW..." });
+await oc.credentials.rotate("cred_...", "sk-ant-NEW...");
```
```http REST API
-PATCH https://api.opencomputer.dev/v3/agents/agt_...
+PATCH https://api.opencomputer.dev/v3/credentials/cred_...
Authorization: Bearer $OPENCOMPUTER_API_KEY
Content-Type: application/json
@@ -102,6 +102,8 @@ Content-Type: application/json
</CodeGroup>
+Passing a new `key` to [`oc.agents.update`](/agent-sessions/agents) still works as a shortcut — it rotates the agent's attached credential.
+
Changing **which** credential an agent uses (a different `credential` id) affects only **future** sessions — existing sessions keep the one they pinned.
## Shortcut: add a key inline
diff --git a/docs/agent-sessions/slack.mdx b/docs/agent-sessions/slack.mdx
index 44b794c5..53b0999e 100644
--- a/docs/agent-sessions/slack.mdx
+++ b/docs/agent-sessions/slack.mdx
@@ -12,13 +12,13 @@ Connect from the agent's page in the [dashboard](https://app.opencomputer.dev) (
```ts TypeScript SDK
// 1. Manifest to create the Slack app from (Create app → From a manifest).
-const { manifest, create_url } = await oc.agents.slackManifest(agentId);
+const { manifest, createUrl } = await oc.agents.slackManifest(agentId);
// 2. Finalize with the App ID, Signing Secret, and Bot User OAuth Token.
const slack = await oc.agents.connectSlack(agentId, {
- app_id: "A0…",
- signing_secret: "…",
- bot_token: "xoxb-…",
+ appId: "A0…",
+ signingSecret: "…",
+ botToken: "xoxb-…",
});
await oc.agents.getSlack(agentId); // { status: "active", … } — no secrets
diff --git a/sdks/typescript/src/agents/agents.ts b/sdks/typescript/src/agents/agents.ts
index dc9cd124..2f7338d2 100644
--- a/sdks/typescript/src/agents/agents.ts
+++ b/sdks/typescript/src/agents/agents.ts
@@ -25,7 +25,7 @@ export interface Page<T> { data: T[]; nextCursor?: string | null; }
/** The Slack app manifest to create in Slack (from `slackManifest`). */
export interface SlackManifest {
manifest: Record<string, unknown>;
- create_url: string;
+ createUrl: string;
steps?: unknown;
status: string;
}
@@ -33,18 +33,18 @@ export interface SlackManifest {
/** A Slack connection's public state — never carries the bot token / signing secret. */
export interface SlackConnection {
id: string;
- agent_id: string;
+ agentId: string;
status: string; // pending | active | revoked | error
- slack_app_id?: string | null;
- team_id?: string | null;
- account_login?: string | null;
+ slackAppId?: string | null;
+ teamId?: string | null;
+ accountLogin?: string | null;
}
/** The three values pasted back from Slack to finalize a connection. */
export interface ConnectSlackParams {
- app_id: string;
- bot_token: string;
- signing_secret: string;
+ appId: string;
+ botToken: string;
+ signingSecret: string;
}
/** Reusable agents — the "what" a session runs. */
@@ -72,7 +72,8 @@ export class Agents {
slackManifest(id: string, opts: { reconnect?: boolean } = {}): Promise<SlackManifest> {
return this.http.request("POST", `/agents/${id}/slack/manifest`, { body: opts });
}
- /** Finalize the connection with the three values Slack shows after install. */
+ /** Finalize the connection with the three values Slack shows after install.
+ * (The HTTP layer converts appId → app_id, etc. on the wire.) */
connectSlack(id: string, params: ConnectSlackParams): Promise<SlackConnection> {
return this.http.request("POST", `/agents/${id}/slack`, { body: params });
}
diff --git a/sdks/typescript/src/agents/credentials.ts b/sdks/typescript/src/agents/credentials.ts
index cb04a7e4..be98d738 100644
--- a/sdks/typescript/src/agents/credentials.ts
+++ b/sdks/typescript/src/agents/credentials.ts
@@ -25,6 +25,10 @@ export class Credentials {
delete(id: string): Promise<void> {
return this.http.request("DELETE", `/credentials/${id}`);
}
+ /** Rotate the key VALUE behind a credential (versioned) — flows to running sessions. */
+ rotate(id: string, key: string): Promise<Credential> {
+ return this.http.request("PATCH", `/credentials/${id}`, { body: { key } });
+ }
setDefault(params: { credential: string; provider?: string }): Promise<void> {
return this.http.request("PUT", "/credentials/default", { body: params });
}
diff --git a/sdks/typescript/src/agents/index.ts b/sdks/typescript/src/agents/index.ts
index 394c97a0..bc989197 100644
--- a/sdks/typescript/src/agents/index.ts
+++ b/sdks/typescript/src/agents/index.ts
@@ -8,7 +8,10 @@ export type {
SourceErrorCode, SourceSummary,
} from "./sessions.js";
export { Agents } from "./agents.js";
-export type { CreateAgentParams, UpdateAgentParams, Page } from "./agents.js";
+export type {
+ CreateAgentParams, UpdateAgentParams, Page,
+ SlackManifest, SlackConnection, ConnectSlackParams,
+} from "./agents.js";
export { Repos, GitHub, GitHubApps, GitHubInstallations } from "./repos.js";
export type {
CreateRepoParams, UpdateRepoParams, Repo,
diff --git a/web/src/api/client.ts b/web/src/api/client.ts
index 0edac00f..be6ec11b 100644
--- a/web/src/api/client.ts
+++ b/web/src/api/client.ts
@@ -370,7 +370,8 @@ export const createAgent = (body: {
prompt: string
model: string
runtime: string
- credential_id?: string
+ // The request field is `credential` (the response carries `credential_id`).
+ credential?: string
// `key` sugar: mints a model credential of the runtime's provider for this
// agent (write-only). Without it (and no org default) sessions 422 no_credential.
key?: string
@@ -479,12 +480,21 @@ export const rotateCredential = (id: string, key: string) =>
)
// Sessions — the durable runs.
-export const getSessions = (status?: string) =>
- apiFetch(
- `/v3/sessions${status ? `?status=${status}` : ''}`,
+export const getSessions = (
+ params: { agent?: string; status?: string; limit?: number; cursor?: string } = {},
+) => {
+ const q = new URLSearchParams()
+ if (params.agent) q.set('agent', params.agent)
+ if (params.status) q.set('status', params.status)
+ if (params.limit) q.set('limit', String(params.limit))
+ if (params.cursor) q.set('cursor', params.cursor)
+ const qs = q.toString()
+ return apiFetch(
+ `/v3/sessions${qs ? `?${qs}` : ''}`,
{},
S.SessionListSchema,
).then((r) => r.data)
+}
export const getSession = (id: string) =>
apiFetch(`/v3/sessions/${id}`, {}, S.SessionSchema)
diff --git a/web/src/components/slack-connect.tsx b/web/src/components/slack-connect.tsx
index 6c3552a7..9ca7da5f 100644
--- a/web/src/components/slack-connect.tsx
+++ b/web/src/components/slack-connect.tsx
@@ -25,7 +25,6 @@ import {
DialogTitle,
} from '@/components/ui/dialog'
import { Field, Input } from '@/components/form'
-import { CopyRow } from '@/components/copy-row'
import { StatusBadge } from '@/components/status-badge'
import { ConfirmDialog } from '@/components/confirm-dialog'
import { useTransientFlag } from '@/lib/use-transient-flag'
@@ -139,6 +138,9 @@ export function SlackConnect({
onSuccess: () => {
void invalidate()
setStep('done')
+ setAppId('')
+ setBotToken('')
+ setSigningSecret('') // don't keep secrets in state past a successful connect
},
onError: (e) =>
notifyError('Slack rejected those values. Double-check them.', e),
@@ -199,9 +201,8 @@ export function SlackConnect({
is connected{workspace ? ` to ${workspace}` : ''}.
</p>
<p className="text-muted-foreground text-sm">
- Invite it to a channel with{' '}
- <code className="text-foreground">/invite @{conn?.handle}</code>,
- then <strong>@-mention</strong> it to start or steer a session.
+ Invite the bot to a channel, then <strong>@-mention</strong> it to
+ start or steer a session.
</p>
<div className="flex gap-2">
<Button
@@ -445,9 +446,9 @@ export function SlackConnect({
is connected{workspace ? ` to ${workspace}` : ''}.
</p>
<p className="text-muted-foreground">
- Invite it to a channel, then @-mention it:
+ Invite the bot to a channel, then @-mention it to start a
+ session.
</p>
- <CopyRow value={`/invite @${conn?.handle ?? agentName}`} />
</div>
<DialogFooter>
<Button
diff --git a/web/src/pages/AgentDetail.tsx b/web/src/pages/AgentDetail.tsx
index 65cc0f74..62196c59 100644
--- a/web/src/pages/AgentDetail.tsx
+++ b/web/src/pages/AgentDetail.tsx
@@ -57,12 +57,12 @@ export default function AgentDetail() {
enabled: !!agentId,
})
- // This agent's sessions. The API has no per-agent filter, so scope client-side.
- const { data: allSessions, isLoading: loadingSessions } = useQuery({
- queryKey: ['sessions'],
- queryFn: () => getSessions(),
+ // This agent's sessions — filtered server-side (not a client slice of an unfiltered
+ // first page, which would drop older sessions once the org is busy).
+ const { data: sessions = [], isLoading: loadingSessions } = useQuery({
+ queryKey: ['sessions', { agent: agentId }],
+ queryFn: () => getSessions({ agent: agentId }),
})
- const sessions = (allSessions ?? []).filter((s) => s.agent_id === agentId)
// Credentials for the switch picker + to label the current one.
const { data: credentials } = useQuery({
diff --git a/web/src/pages/Agents.tsx b/web/src/pages/Agents.tsx
index 0a741792..9f4dbe07 100644
--- a/web/src/pages/Agents.tsx
+++ b/web/src/pages/Agents.tsx
@@ -120,7 +120,7 @@ export default function Agents() {
prompt: prompt.trim(),
model,
runtime: 'claude',
- credential_id: credentialId,
+ credential: credentialId,
})
},
onSuccess: (agent) => {