Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(agent-share): contacts-wide device access, always-redacted visitor errors (#23495)

YuTengjingd46a77aa0da6
diff --git a/apps/server/src/modules/AgentRuntime/AgentRuntimeCoordinator.ts b/apps/server/src/modules/AgentRuntime/AgentRuntimeCoordinator.ts
index d94def2ca7b..7e358df60c2 100644
--- a/apps/server/src/modules/AgentRuntime/AgentRuntimeCoordinator.ts
+++ b/apps/server/src/modules/AgentRuntime/AgentRuntimeCoordinator.ts
@@ -98,7 +98,6 @@ export class AgentRuntimeCoordinator {
data: {
acceptsMemberRuntimeEnd?: boolean;
agentConfig?: any;
- visitorRedaction?: { showErrorDetails?: boolean };
mirrorToOperationId?: string;
modelRuntimeConfig?: any;
streamOwnerUserId?: string;
diff --git a/apps/server/src/modules/AgentRuntime/AgentStateManager.ts b/apps/server/src/modules/AgentRuntime/AgentStateManager.ts
index ac7f06e3668..c1295d216b8 100644
--- a/apps/server/src/modules/AgentRuntime/AgentStateManager.ts
+++ b/apps/server/src/modules/AgentRuntime/AgentStateManager.ts
@@ -203,14 +203,6 @@ export interface AgentOperationMetadata {
totalCost: number;
totalSteps: number;
userId?: string;
- /**
- * Visitor-facing redaction policy for a shared-agent visitor run, mirrored
- * from the share's `AgentShareConfig`. Persisted alongside
- * {@link streamOwnerUserId} so a queue worker that never ran this op's init
- * can still apply the OWNER-configured policy instead of falling back to the
- * fail-closed full strip.
- */
- visitorRedaction?: { showErrorDetails?: boolean };
/**
* Workspace the operation runs in (null/undefined = personal). Persisted so
* queue workers (e.g. QStash `runStep`) can reconstruct a workspace-scoped
@@ -534,9 +526,6 @@ export class AgentStateManager {
return {
acceptsMemberRuntimeEnd: metadata.acceptsMemberRuntimeEnd === 'true' || undefined,
agentConfig: metadata.agentConfig ? JSON.parse(metadata.agentConfig) : undefined,
- visitorRedaction: metadata.visitorRedaction
- ? JSON.parse(metadata.visitorRedaction)
- : undefined,
createdAt: metadata.createdAt,
lastActiveAt: metadata.lastActiveAt,
modelRuntimeConfig: metadata.modelRuntimeConfig
@@ -564,7 +553,6 @@ export class AgentStateManager {
data: {
acceptsMemberRuntimeEnd?: boolean;
agentConfig?: any;
- visitorRedaction?: { showErrorDetails?: boolean };
mirrorToOperationId?: string;
modelRuntimeConfig?: any;
streamOwnerUserId?: string;
@@ -578,7 +566,6 @@ export class AgentStateManager {
const metadata: AgentOperationMetadata = {
acceptsMemberRuntimeEnd: data.acceptsMemberRuntimeEnd,
agentConfig: data.agentConfig,
- visitorRedaction: data.visitorRedaction,
createdAt: new Date().toISOString(),
lastActiveAt: new Date().toISOString(),
mirrorToOperationId: data.mirrorToOperationId,
@@ -609,8 +596,6 @@ export class AgentStateManager {
if (metadata.modelRuntimeConfig)
redisData.modelRuntimeConfig = JSON.stringify(metadata.modelRuntimeConfig);
if (metadata.agentConfig) redisData.agentConfig = JSON.stringify(metadata.agentConfig);
- if (metadata.visitorRedaction)
- redisData.visitorRedaction = JSON.stringify(metadata.visitorRedaction);
await this.redis.hmset(metaKey, redisData);
await this.redis.expire(metaKey, this.DEFAULT_TTL);
diff --git a/apps/server/src/modules/AgentRuntime/GatewayStreamNotifier.ts b/apps/server/src/modules/AgentRuntime/GatewayStreamNotifier.ts
index f6ee0468df8..cf8bdcfa941 100644
--- a/apps/server/src/modules/AgentRuntime/GatewayStreamNotifier.ts
+++ b/apps/server/src/modules/AgentRuntime/GatewayStreamNotifier.ts
@@ -14,9 +14,7 @@ import { projectGatewayEventData, toMirroredEvent } from './gatewayEventProjecti
import {
buildPublicEndEventData,
buildPublicInitEventData,
- FULL_STRIP_REDACTION,
type GatewayVisitorRedaction,
- isShareVisitorInit,
resolveRedactionFromState,
sanitizeGatewayEventData,
} from './gatewayVisitorRedaction';
@@ -170,18 +168,16 @@ export class GatewayStreamNotifier implements IStreamEventManager {
private memberEndTargets = new Map<string, Promise<boolean>>();
/**
- * `operationId → visitor redaction policy` for confirmed shared-agent visitor
+ * `operationId → true` for confirmed shared-agent visitor
* runs. `step_start` events carry neither `streamOwnerUserId` (only on
* `agent_runtime_init`'s `initialState`) nor `finalState` (only on
* `agent_runtime_end` / `step_complete`), so this per-operation entry is the
* only signal `pushEvent` has for scrubbing `uiMessages` on those events.
* Mirrors `mirrorTargets`'s two population paths:
* - fast path: set at `publishAgentRuntimeInit` / `publishAgentRuntimeEnd`
- * from the state's `metadata.agentShareVisitor`, so the share's real
- * `showErrorDetails` config is honored.
+ * from the state.
* - queue path: lazily resolved from persisted op metadata via
- * `resolvePersistedShareVisitor`, which can only tell share-or-not — it
- * therefore falls back to {@link FULL_STRIP_REDACTION}.
+ * `resolvePersistedShareVisitor`.
* Cleared at `publishAgentRuntimeEnd`.
*/
private shareVisitorOps = new Map<string, GatewayVisitorRedaction>();
@@ -201,8 +197,8 @@ export class GatewayStreamNotifier implements IStreamEventManager {
*/
private resolveMirrorTarget?: (operationId: string) => Promise<string | undefined>,
/**
- * Resolves an op's persisted share-visitor redaction policy (from
- * `streamOwnerUserId` + `visitorRedaction` on op metadata); `null` for a
+ * Resolves whether an op is a share-visitor run (from `streamOwnerUserId`
+ * on op metadata); `false` for a
* normal run. Lets a queue worker — which never ran the op's init — still
* scrub events for that op. Omitted ⇒ in-process map only (safe: init
* always precedes events for the op it created).
@@ -285,13 +281,9 @@ export class GatewayStreamNotifier implements IStreamEventManager {
// `initialState` here) so every later event for this op — including
// `step_start`, which carries neither `streamOwnerUserId` nor `finalState`
// — is sanitized without re-resolving.
- const initRedaction = resolveRedactionFromState(initialState);
- const isShareInit = isShareVisitorInit(initialState);
- if (initRedaction || isShareInit) {
- // Fail closed: `streamOwnerUserId` alone (without a readable
- // `metadata.agentShareVisitor`) still means a visitor is on the other end.
- this.shareVisitorOps.set(operationId, initRedaction ?? FULL_STRIP_REDACTION);
- }
+ // `streamOwnerUserId` alone (without a readable `principal.actor.shareVisitor`)
+ // still means a visitor is on the other end.
+ if (resolveRedactionFromState(initialState)) this.shareVisitorOps.set(operationId, true);
this.shareVisitorResolved.add(operationId);
try {
@@ -359,7 +351,6 @@ export class GatewayStreamNotifier implements IStreamEventManager {
rawErrorType === undefined
? undefined
: ({ message: finalState?.error?.message, type: rawErrorType } as ChatMessageError),
- endRedaction,
)
: undefined;
const effectiveReasonDetail = endRedaction
@@ -371,7 +362,7 @@ export class GatewayStreamNotifier implements IStreamEventManager {
// so record it before pushing — covers the case where this runs in a
// process that never saw the op's `publishAgentRuntimeInit` (queue mode)
// without waiting on the async metadata resolver.
- if (endRedaction) this.shareVisitorOps.set(operationId, endRedaction);
+ if (endRedaction) this.shareVisitorOps.set(operationId, true);
this.shareVisitorResolved.add(operationId);
// Forward `uiMessages` to the gateway push channel so terminal-state
@@ -802,8 +793,8 @@ export class GatewayStreamNotifier implements IStreamEventManager {
private isShareVisitorKnown(operationId: string): GatewayVisitorRedaction | undefined {
const cached = this.shareVisitorOps.get(operationId);
if (cached) return cached;
- if (this.shareVisitorResolved.has(operationId)) return null;
- if (!this.resolvePersistedShareVisitor) return null;
+ if (this.shareVisitorResolved.has(operationId)) return false;
+ if (!this.resolvePersistedShareVisitor) return false;
return undefined;
}
@@ -814,13 +805,13 @@ export class GatewayStreamNotifier implements IStreamEventManager {
* Deduped so concurrent events for the same unresolved op share one metadata
* read.
*
- * Fails closed: a resolution error returns the full strip rather than risk
+ * Fails closed: a resolution error treats the op as a share run rather than risk
* leaking the creator's identity, and deliberately does NOT cache that
* outcome as resolved, so the next event retries once the transient failure
* clears.
*/
private resolveShareVisitor(operationId: string): Promise<GatewayVisitorRedaction> {
- if (!this.resolvePersistedShareVisitor) return Promise.resolve(null);
+ if (!this.resolvePersistedShareVisitor) return Promise.resolve(false);
let pending = this.shareVisitorResolving.get(operationId);
if (!pending) {
@@ -828,14 +819,14 @@ export class GatewayStreamNotifier implements IStreamEventManager {
.then((resolved) => {
this.shareVisitorResolved.add(operationId);
this.shareVisitorResolving.delete(operationId);
- if (!resolved) return null;
- this.shareVisitorOps.set(operationId, resolved);
- return resolved;
+ if (!resolved) return false;
+ this.shareVisitorOps.set(operationId, true);
+ return true;
})
.catch((error) => {
this.shareVisitorResolving.delete(operationId);
log('[%s] Share visitor resolution failed, failing closed: %O', operationId, error);
- return FULL_STRIP_REDACTION;
+ return true;
});
this.shareVisitorResolving.set(operationId, pending);
}
diff --git a/apps/server/src/modules/AgentRuntime/InMemoryAgentStateManager.ts b/apps/server/src/modules/AgentRuntime/InMemoryAgentStateManager.ts
index 21fccdcb41c..6ac3500ed0f 100644
--- a/apps/server/src/modules/AgentRuntime/InMemoryAgentStateManager.ts
+++ b/apps/server/src/modules/AgentRuntime/InMemoryAgentStateManager.ts
@@ -114,7 +114,6 @@ export class InMemoryAgentStateManager implements IAgentStateManager {
data: {
acceptsMemberRuntimeEnd?: boolean;
agentConfig?: any;
- visitorRedaction?: { showErrorDetails?: boolean };
mirrorToOperationId?: string;
modelRuntimeConfig?: any;
streamOwnerUserId?: string;
@@ -125,7 +124,6 @@ export class InMemoryAgentStateManager implements IAgentStateManager {
const metadata: AgentOperationMetadata = {
acceptsMemberRuntimeEnd: data.acceptsMemberRuntimeEnd,
agentConfig: data.agentConfig,
- visitorRedaction: data.visitorRedaction,
createdAt: new Date().toISOString(),
lastActiveAt: new Date().toISOString(),
mirrorToOperationId: data.mirrorToOperationId,
diff --git a/apps/server/src/modules/AgentRuntime/__tests__/GatewayStreamNotifier.test.ts b/apps/server/src/modules/AgentRuntime/__tests__/GatewayStreamNotifier.test.ts
index 68bcc2df530..91df7002017 100644
--- a/apps/server/src/modules/AgentRuntime/__tests__/GatewayStreamNotifier.test.ts
+++ b/apps/server/src/modules/AgentRuntime/__tests__/GatewayStreamNotifier.test.ts
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { GatewayStreamNotifier } from '../GatewayStreamNotifier';
-import { FULL_STRIP_REDACTION, sanitizeGatewayEventData } from '../gatewayVisitorRedaction';
+import { sanitizeGatewayEventData } from '../gatewayVisitorRedaction';
import type { StreamChunkData } from '../StreamEventManager';
import { createMockInner } from '../testUtils';
@@ -187,7 +187,7 @@ describe('GatewayStreamNotifier', () => {
initialContext: { prompt: 'context' },
status: 'done',
});
- expect(sanitizeGatewayEventData(data, FULL_STRIP_REDACTION, 'step_complete')).toEqual({
+ expect(sanitizeGatewayEventData(data, true, 'step_complete')).toEqual({
phase: 'execution_complete',
reason: 'done',
});
diff --git a/apps/server/src/modules/AgentRuntime/factory.ts b/apps/server/src/modules/AgentRuntime/factory.ts
index 08d720ffd7c..f74db409084 100644
--- a/apps/server/src/modules/AgentRuntime/factory.ts
+++ b/apps/server/src/modules/AgentRuntime/factory.ts
@@ -4,7 +4,6 @@ import { appEnv } from '@/envs/app';
import { AgentStateManager } from './AgentStateManager';
import { GatewayStreamNotifier, type GatewayStreamNotifierOptions } from './GatewayStreamNotifier';
-import { FULL_STRIP_REDACTION } from './gatewayVisitorRedaction';
import { inMemoryAgentStateManager } from './InMemoryAgentStateManager';
import { inMemoryStreamEventManager } from './InMemoryStreamEventManager';
import { getAgentRuntimeRedisClient } from './redis';
@@ -113,11 +112,10 @@ export const createStreamEventManager = (
// Same reasoning as the mirror resolver above, but for share-visitor
// detection: a queue worker that never ran `publishAgentRuntimeInit` for
// this op still needs to know whether its events must be scrubbed of the
- // creator's identity, and under which owner-configured policy.
+ // creator's identity.
async (operationId) => {
const meta = await stateManager.getOperationMetadata(operationId);
- if (!meta?.streamOwnerUserId) return null;
- return meta.visitorRedaction ?? FULL_STRIP_REDACTION;
+ return !!meta?.streamOwnerUserId;
},
{
...notifierOptions,
diff --git a/apps/server/src/modules/AgentRuntime/gatewayVisitorRedaction.ts b/apps/server/src/modules/AgentRuntime/gatewayVisitorRedaction.ts
index a5ce0b22e4d..09ed2432c3e 100644
--- a/apps/server/src/modules/AgentRuntime/gatewayVisitorRedaction.ts
+++ b/apps/server/src/modules/AgentRuntime/gatewayVisitorRedaction.ts
@@ -4,29 +4,19 @@ import {
redactCreatorPrivateBlob,
sanitizeVisitorError,
toVisitorMessage,
- type VisitorRedactionOptions,
} from '@/database/models/message';
import { stripFinalStateInEventData } from './StreamEventManager';
/**
- * Per-operation redaction policy for a shared-agent visitor run, derived from
- * the share's `AgentShareConfig` (`showErrorDetails`) and
- * carried on `state.principal.actor.shareVisitor`.
+ * Whether an operation's Gateway pushes go to a shared-agent visitor. A visitor
+ * run is always fully redacted: creator model/provider/usage are stripped and
+ * errors are projected to a classified type, with no per-share opt-out.
*
- * `null` is the explicit "not a share run — push verbatim" marker, so a
+ * `false` is the explicit "not a share run — push verbatim" marker, so a
* missing/undefined value can stay reserved for "not resolved yet".
*/
-export type GatewayVisitorRedaction = VisitorRedactionOptions | null;
-
-/**
- * The most restrictive policy: strip model/provider/usage AND project errors
- * down to a classified type. Used as the fail-closed fallback whenever the
- * share's real config is unavailable (a queue worker that never ran the op's
- * init can only read `streamOwnerUserId` back from persisted op metadata, not
- * the share config).
- */
-export const FULL_STRIP_REDACTION: GatewayVisitorRedaction = {};
+export type GatewayVisitorRedaction = boolean;
/**
* Whether `publishAgentRuntimeInit` is initializing a shared-agent visitor run.
@@ -39,33 +29,22 @@ export const isShareVisitorInit = (initialState: any): boolean =>
typeof initialState?.streamOwnerUserId === 'string' && initialState.streamOwnerUserId.length > 0;
/**
- * Read the redaction policy off whatever the notifier was handed.
+ * Read whether a run is a shared-agent visitor run off whatever the notifier
+ * was handed.
*
* Two shapes reach here, deliberately handled by one function so the fast path
* never disagrees with itself:
- * - a runtime `AgentState`, whose `metadata.agentShareVisitor` is stamped once at
- * operation creation (`AgentRuntimeService.createOperation`) and rides the
+ * - a runtime `AgentState`, whose `principal.actor.shareVisitor` is stamped once
+ * at operation creation (`AgentRuntimeService.createOperation`) and rides the
* state through to the terminal event (`publishAgentRuntimeEnd`);
* - an `AgentOperationMetadata` record, which is what
* `AgentRuntimeCoordinator.createAgentOperation` passes to
- * `publishAgentRuntimeInit` — it carries the flattened
- * `streamOwnerUserId` + `visitorRedaction` pair instead.
- *
- * Returns `null` for a normal (non-share) run. Fails closed to
- * {@link FULL_STRIP_REDACTION} when a run is identifiable as a share run but
- * its policy is unreadable.
+ * `publishAgentRuntimeInit` — it carries the flattened `streamOwnerUserId`
+ * instead.
*/
export const resolveRedactionFromState = (state: any): GatewayVisitorRedaction => {
- const share = state?.principal?.actor?.shareVisitor as
- { showErrorDetails?: boolean; visitorUserId?: string } | undefined;
-
- if (share?.visitorUserId) {
- return { showErrorDetails: share.showErrorDetails };
- }
-
- if (!isShareVisitorInit(state)) return null;
-
- return (state.visitorRedaction as GatewayVisitorRedaction) ?? FULL_STRIP_REDACTION;
+ const share = state?.principal?.actor?.shareVisitor as { visitorUserId?: string } | undefined;
+ return !!share?.visitorUserId || isShareVisitorInit(state);
};
/**
@@ -110,12 +89,9 @@ export const buildPublicEndEventData = <T extends { finalState?: unknown }>(
* `toVisitorMessage` — the same projection `shareChat.getMessages` applies — so
* the two paths cannot drift apart.
*/
-const sanitizeUiMessagesForVisitor = (
- uiMessages: unknown,
- redaction: VisitorRedactionOptions,
-): unknown => {
+const sanitizeUiMessagesForVisitor = (uiMessages: unknown): unknown => {
if (!Array.isArray(uiMessages)) return uiMessages;
- return (uiMessages as UIChatMessage[]).map((message) => toVisitorMessage(message, redaction));
+ return (uiMessages as UIChatMessage[]).map((message) => toVisitorMessage(message));
};
/**
@@ -131,10 +107,7 @@ const sanitizeUiMessagesForVisitor = (
* `formatErrorEventData`'s flatter `{ error, errorType, phase }` wire shape
* instead of `ChatMessageError`'s `{ body, message, type }`.
*/
-const sanitizeErrorEventDataForVisitor = (
- data: unknown,
- redaction: VisitorRedactionOptions,
-): unknown => {
+const sanitizeErrorEventDataForVisitor = (data: unknown): unknown => {
if (!data || typeof data !== 'object') return data;
const record = data as { error?: unknown; errorType?: unknown; phase?: unknown };
@@ -145,7 +118,6 @@ const sanitizeErrorEventDataForVisitor = (
type: record.errorType,
} as ChatMessageError)
: undefined,
- redaction,
);
return {
@@ -168,8 +140,7 @@ const sanitizeErrorEventDataForVisitor = (
* {@link sanitizeErrorEventDataForVisitor} — a SEPARATE leak from
* `uiMessages`/`finalState`, since it carries `formatErrorEventData`'s raw
* `{ body, error, errorType }` shape with no `finalState`/`uiMessages` key
- * for the other checks to even look at. Skipped when the share opted into
- * `showErrorDetails`.
+ * for the other checks to even look at.
* 3. {@link redactCreatorPrivateBlob} runs over the WHOLE remaining payload.
* Every other event type for a share run — `stream_start` (`{ model,
* provider }`), `tool_end` (a tool's own free-form `result.state` blob, e.g.
@@ -208,7 +179,7 @@ export const sanitizeGatewayEventData = (
})()
: record;
- if (eventType === 'error') return sanitizeErrorEventDataForVisitor(withoutFinalState, redaction);
+ if (eventType === 'error') return sanitizeErrorEventDataForVisitor(withoutFinalState);
const redacted = redactCreatorPrivateBlob(withoutFinalState);
@@ -216,6 +187,6 @@ export const sanitizeGatewayEventData = (
return {
...redacted,
- uiMessages: sanitizeUiMessagesForVisitor(withoutFinalState.uiMessages, redaction),
+ uiMessages: sanitizeUiMessagesForVisitor(withoutFinalState.uiMessages),
};
};
diff --git a/apps/server/src/modules/AgentRuntime/types.ts b/apps/server/src/modules/AgentRuntime/types.ts
index eaf87016b0f..edc532c570f 100644
--- a/apps/server/src/modules/AgentRuntime/types.ts
+++ b/apps/server/src/modules/AgentRuntime/types.ts
@@ -53,7 +53,6 @@ export interface IAgentStateManager {
/** See {@link AgentOperationMetadata.acceptsMemberRuntimeEnd}. */
acceptsMemberRuntimeEnd?: boolean;
agentConfig?: any;
- visitorRedaction?: { showErrorDetails?: boolean };
mirrorToOperationId?: string;
modelRuntimeConfig?: any;
/**
diff --git a/apps/server/src/routers/lambda/__tests__/agentShare.test.ts b/apps/server/src/routers/lambda/__tests__/agentShare.test.ts
index a9b340b2818..91e3654faa9 100644
--- a/apps/server/src/routers/lambda/__tests__/agentShare.test.ts
+++ b/apps/server/src/routers/lambda/__tests__/agentShare.test.ts
@@ -383,6 +383,13 @@ describe('agentShareRouter', () => {
expect(mockUpdateConfig).toHaveBeenCalledWith('agent-1', config);
});
+ it('stores an address-book-wide grant without a list', async () => {
+ const caller = agentShareRouter.createCaller(await createContextInner({ userId: 'user-1' }));
+
+ await caller.updateShareConfig({ agentId: 'agent-1', config: { deviceAccess: 'contacts' } });
+ expect(mockUpdateConfig).toHaveBeenCalledWith('agent-1', { deviceAccess: 'contacts' });
+ });
+
// The runtime grants nothing while contacts are off, so a grant must not be
// stored then either (it would also come alive when they turn on).
it('refuses a grant while contacts are off for the Agent owner', async () => {
@@ -399,6 +406,9 @@ describe('agentShareRouter', () => {
await expect(
caller.updateShareConfig({ agentId: 'agent-1', config: { deviceAccess: 'allowlist' } }),
).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ await expect(
+ caller.updateShareConfig({ agentId: 'agent-1', config: { deviceAccess: 'contacts' } }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
expect(mockUpdateConfig).not.toHaveBeenCalled();
await expect(caller.listDeviceGrantablePeople({ agentId: 'agent-1' })).resolves.toMatchObject(
diff --git a/apps/server/src/routers/lambda/__tests__/share.test.ts b/apps/server/src/routers/lambda/__tests__/share.test.ts
index 3645afb39aa..368ce076aba 100644
--- a/apps/server/src/routers/lambda/__tests__/share.test.ts
+++ b/apps/server/src/routers/lambda/__tests__/share.test.ts
@@ -254,6 +254,18 @@ describe('shareRouter', () => {
resolveModelSelectionMock.mockResolvedValue({ model: 'gpt-4o', provider: 'openai' });
});
+ it('advertises no LobeHub tool grants for a Claude Code / Codex Agent', async () => {
+ vi.mocked(AgentShareModel.findBySlugOrId).mockResolvedValue({
+ ...agentShare,
+ agentAgencyConfig: { heterogeneousProvider: { type: 'claude-code' } },
+ } as any);
+ const caller = shareRouter.createCaller(await createContextInner({ userId: 'visitor-user' }));
+
+ const result = await caller.getSharedAgent({ slugOrId: 'shared-agent' });
+
+ expect(result.toolGrants).toEqual([]);
+ });
+
it('returns independent demos and selected deliveries in the owner scope', async () => {
const demoCases = [{ prompt: 'Review this migration', description: 'Find deployment risks' }];
const work = { id: 'work-selected', title: 'Migration review', totalCost: 0.2 };
diff --git a/apps/server/src/routers/lambda/__tests__/shareChat.test.ts b/apps/server/src/routers/lambda/__tests__/shareChat.test.ts
index dbe065f194d..b783f9f9ccc 100644
--- a/apps/server/src/routers/lambda/__tests__/shareChat.test.ts
+++ b/apps/server/src/routers/lambda/__tests__/shareChat.test.ts
@@ -1377,9 +1377,6 @@ describe('shareChatRouter', () => {
expect(mockMessageQueryForVisitor).toHaveBeenCalledWith(
{ includeFileWorks: true, topicId: 'tpc_visitor' },
expect.objectContaining({
- redaction: {
- showErrorDetails: undefined,
- },
// Pinned to share + topic + VISITOR: the ordinary scope would join
// the creator's Works, which must never reach a visitor surface.
workAccessScope: {
diff --git a/apps/server/src/routers/lambda/agentShare.ts b/apps/server/src/routers/lambda/agentShare.ts
index 7970a4c2e2f..00812c6a287 100644
--- a/apps/server/src/routers/lambda/agentShare.ts
+++ b/apps/server/src/routers/lambda/agentShare.ts
@@ -70,7 +70,7 @@ export const agentShareConfigSchema = z
)
.max(20)
.optional(),
- deviceAccess: z.enum(['none', 'allowlist']).optional(),
+ deviceAccess: z.enum(['none', 'contacts', 'allowlist']).optional(),
/** Each id must also be in the scope's address book; `updateShareConfig` checks that. */
deviceAllowUserIds: z
.array(z.string().trim().min(1).max(64))
@@ -86,7 +86,6 @@ export const agentShareConfigSchema = z
maxFileStorage: z.number().int().nonnegative().optional(),
maxMessagesPerVisitor: z.number().int().positive().optional(),
monthlySpendLimit: z.number().nonnegative().optional(),
- showErrorDetails: z.boolean().optional(),
/**
* Skill identifiers the creator opened to visitors. An empty array is
* accepted rather than rejected: unticking the last skill is a normal
@@ -491,7 +490,11 @@ export const agentShareRouter = router({
await assertCanManageAgentShare(ctx, input.agentId);
const { deviceAccess, deviceAllowUserIds } = input.config;
- if (deviceAccess === 'allowlist' || deviceAllowUserIds?.length) {
+ if (
+ deviceAccess === 'allowlist' ||
+ deviceAccess === 'contacts' ||
+ deviceAllowUserIds?.length
+ ) {
const { book, enabled } = await shareAddressBook(ctx, input.agentId);
// The runtime grants nothing while contacts are off, so refuse to store
// a grant that would silently do nothing (or wake up when they turn on).
diff --git a/apps/server/src/routers/lambda/share.ts b/apps/server/src/routers/lambda/share.ts
index f330fb10783..dadc8798d2e 100644
--- a/apps/server/src/routers/lambda/share.ts
+++ b/apps/server/src/routers/lambda/share.ts
@@ -250,8 +250,12 @@ export const shareRouter = router({
share.shareConfig.maxMessagesPerVisitor ?? AGENT_SHARE_DEFAULT_MAX_MESSAGES_PER_VISITOR,
},
// Identifiers only. The granted API list is owner-facing configuration
- // and must not reach a visitor.
- toolGrants: (share.shareConfig.toolGrants ?? []).map((grant) => grant.identifier),
+ // and must not reach a visitor. A Claude Code / Codex Agent runs none of
+ // LobeHub's tools, so grants stored before it switched harness are not
+ // advertised (the settings page hides them too).
+ toolGrants: share.agentAgencyConfig?.heterogeneousProvider
+ ? []
+ : (share.shareConfig.toolGrants ?? []).map((grant) => grant.identifier),
uploadAbility,
// TODO(cloud budget gate): the spend gate itself is already enforced —
// `shareChat.execAgent` checks `checkAgentShareSpendAllowance` before
diff --git a/apps/server/src/routers/lambda/shareChat/conversation.ts b/apps/server/src/routers/lambda/shareChat/conversation.ts
index 58948c6ebca..1323acbd065 100644
--- a/apps/server/src/routers/lambda/shareChat/conversation.ts
+++ b/apps/server/src/routers/lambda/shareChat/conversation.ts
@@ -65,17 +65,13 @@ export const conversationRouter = router({
);
// queryForVisitor strips the creator's `sender` identity and the
- // spend/model snapshot, and — unless the share opts in via
- // `showErrorDetails` — the raw error payload too. Share messages persist under the
+ // spend/model snapshot, and projects errors to a classified type. Share messages persist under the
// CREATOR's account (see the `shareChatProcedure` doc in `procedures.ts`), so the raw `query()` result
// would otherwise leak the creator's account identity to the visitor.
return messageModel.queryForVisitor(
{ includeFileWorks: input.includeFileWorks, topicId: input.topicId },
{
postProcessUrl: (path, file) => fileService.getFileAccessUrl({ id: file.id, url: path }),
- redaction: {
- showErrorDetails: share.shareConfig.showErrorDetails,
- },
// Work summaries are assembled under the visitor's OWN share scope:
// only Works registered from this share topic resolve, never the
// creator's ordinary Works (see `workMatchesAccessScope`).
diff --git a/apps/server/src/routers/lambda/shareChat/exec.ts b/apps/server/src/routers/lambda/shareChat/exec.ts
index 91ce00e9cb2..9f51babda91 100644
--- a/apps/server/src/routers/lambda/shareChat/exec.ts
+++ b/apps/server/src/routers/lambda/shareChat/exec.ts
@@ -303,11 +303,7 @@ export const execRouter = router({
// still be consumed as if the run started, opening a WebSocket for an
// operation that never began.
if (!result.success) {
- throw toVisitorSafeStartupError(
- 'execAgent',
- { message: result.error },
- { showErrorDetails: share.shareConfig.showErrorDetails },
- );
+ throw toVisitorSafeStartupError('execAgent', { message: result.error });
}
return result;
@@ -321,9 +317,7 @@ export const execRouter = router({
});
}
- throw toVisitorSafeStartupError('execAgent', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('execAgent', error);
}
}),
});
diff --git a/apps/server/src/routers/lambda/shareChat/guards.ts b/apps/server/src/routers/lambda/shareChat/guards.ts
index 323b2e82636..461d596003a 100644
--- a/apps/server/src/routers/lambda/shareChat/guards.ts
+++ b/apps/server/src/routers/lambda/shareChat/guards.ts
@@ -68,20 +68,13 @@ export const findVisitorTopicOrThrow = async (
* `{ type }` (or `{ message }` for the narrow allowlisted codes) that
* `sanitizeVisitorError` already deems visitor-safe.
*
- * `showErrorDetails` (the owner's opt-in on the share config) bypasses the
- * projection, exactly as it does for persisted rows and live stream events.
- *
* Also the sink for a RESOLVED (not thrown) `{ success: false, error }` from
* `AiAgentService.execAgent` — a `createOperation` startup failure resolves
* rather than rejects there, so the visitor-facing `execAgent` handler (`exec.ts`)
* re-throws that case through this same function instead of letting the raw
* message escape via a normal `return`.
*/
-export const toVisitorSafeStartupError = (
- context: string,
- error: unknown,
- options: { showErrorDetails?: boolean } = {},
-): TRPCError => {
+export const toVisitorSafeStartupError = (context: string, error: unknown): TRPCError => {
log('%s failed: %O', context, error);
const raw = error as { message?: unknown; type?: unknown } | null | undefined;
@@ -92,7 +85,6 @@ export const toVisitorSafeStartupError = (
type: raw.type,
} as ChatMessageError)
: undefined,
- options,
);
// `type` widens to `string | number` (the numeric HTTP-status error codes),
diff --git a/apps/server/src/routers/lambda/shareChat/runControl.ts b/apps/server/src/routers/lambda/shareChat/runControl.ts
index bc045f68b5c..c993f148777 100644
--- a/apps/server/src/routers/lambda/shareChat/runControl.ts
+++ b/apps/server/src/routers/lambda/shareChat/runControl.ts
@@ -162,9 +162,7 @@ export const runControlRouter = router({
} catch (error: any) {
if (error instanceof TRPCError) throw error;
- throw toVisitorSafeStartupError('resolveInterventionBySource', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('resolveInterventionBySource', error);
}
}),
/**
@@ -235,9 +233,7 @@ export const runControlRouter = router({
} catch (error: any) {
if (error instanceof TRPCError) throw error;
- throw toVisitorSafeStartupError('stopPendingApproval', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('stopPendingApproval', error);
}
return {
operationId: input.operationId,
@@ -257,9 +253,7 @@ export const runControlRouter = router({
} catch (error: any) {
if (error instanceof TRPCError) throw error;
- throw toVisitorSafeStartupError('stopPendingApproval', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('stopPendingApproval', error);
}
}),
/**
@@ -276,7 +270,7 @@ export const runControlRouter = router({
interruptTask: shareChatProcedure
.input(ShareTopicScopeSchema.extend({ operationId: z.string() }))
.mutation(async ({ input, ctx }) => {
- const { aiAgentService, share } = await authorizeVisitorRunningOperation(
+ const { aiAgentService } = await authorizeVisitorRunningOperation(
ctx.serverDB,
ctx.userId,
input,
@@ -298,9 +292,7 @@ export const runControlRouter = router({
} catch (error: any) {
if (error instanceof TRPCError) throw error;
- throw toVisitorSafeStartupError('interruptTask', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('interruptTask', error);
}
}),
/**
@@ -311,7 +303,7 @@ export const runControlRouter = router({
setQueuedMessages: shareChatProcedure
.input(ShareTopicScopeSchema.extend({ operationId: z.string(), pending: z.boolean() }))
.mutation(async ({ input, ctx }) => {
- const { aiAgentService, share } = await authorizeVisitorRunningOperation(
+ const { aiAgentService } = await authorizeVisitorRunningOperation(
ctx.serverDB,
ctx.userId,
input,
@@ -334,9 +326,7 @@ export const runControlRouter = router({
} catch (error: any) {
if (error instanceof TRPCError) throw error;
- throw toVisitorSafeStartupError('setQueuedMessages', error, {
- showErrorDetails: share.shareConfig.showErrorDetails,
- });
+ throw toVisitorSafeStartupError('setQueuedMessages', error);
}
}),
/**
diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService/createOperation.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService/createOperation.ts
index b8d0a1bc413..0adf72af480 100644
--- a/apps/server/src/services/agentRuntime/AgentRuntimeService/createOperation.ts
+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService/createOperation.ts
@@ -212,12 +212,6 @@ export async function createOperation(
{
acceptsMemberRuntimeEnd,
agentConfig,
- // Persisted so a queue worker that never ran this op's init still
- // applies the owner-configured visitor redaction policy instead of the
- // fail-closed full strip. See `gatewayVisitorRedaction.ts`.
- visitorRedaction: agentShareVisitor
- ? { showErrorDetails: agentShareVisitor.showErrorDetails }
- : undefined,
mirrorToOperationId,
modelRuntimeConfig: withoutFrozenModelFacts(modelRuntimeConfig),
// Share-visitor runs execute as the creator (`userId`) but stream only
diff --git a/apps/server/src/services/aiAgent/deviceAccessPolicy.ts b/apps/server/src/services/aiAgent/deviceAccessPolicy.ts
index 44a665ac322..bce7f5021e2 100644
--- a/apps/server/src/services/aiAgent/deviceAccessPolicy.ts
+++ b/apps/server/src/services/aiAgent/deviceAccessPolicy.ts
@@ -39,8 +39,8 @@ export type DeviceAccessReason =
| 'share-visitor'
/**
* Shared-agent visitor the creator explicitly granted the Agent's execution
- * environment (`shareConfig.deviceAccess` = `all`, or `allowlist` with the
- * visitor listed). The device is still the Agent's configured one; the
+ * environment (`shareConfig.deviceAccess` = `contacts` with the visitor in the
+ * address book, or `allowlist` with the visitor also listed). The device is still the Agent's configured one; the
* visitor never picks it.
*/
| 'share-visitor-granted';
diff --git a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.shareVisitor.test.ts b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.shareVisitor.test.ts
index d4431ee27a7..1fbdcd56c69 100644
--- a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.shareVisitor.test.ts
+++ b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.shareVisitor.test.ts
@@ -91,7 +91,7 @@ vi.mock('../codexDeviceRuntime', () => ({
const shareGate = {
agentId: 'agent-1',
canUseDevice: true,
- shareConfig: { showErrorDetails: true },
+ shareConfig: {},
shareId: 'share-1',
visitorUserId: 'visitor-1',
} as any;
@@ -167,18 +167,13 @@ describe('dispatchHeteroAgent — share visitor run', () => {
expect(mocks.signUserJWT).toHaveBeenCalledWith('visitor-1');
expect(mocks.signUserJWT).not.toHaveBeenCalledWith('creator-1');
- const redaction = { showErrorDetails: true };
expect(mocks.createOperationMetadata).toHaveBeenCalledWith(
expect.any(String),
- expect.objectContaining({
- streamOwnerUserId: 'visitor-1',
- userId: 'creator-1',
- visitorRedaction: redaction,
- }),
+ expect.objectContaining({ streamOwnerUserId: 'visitor-1', userId: 'creator-1' }),
);
expect(mocks.publishAgentRuntimeInit).toHaveBeenCalledWith(
expect.any(String),
- expect.objectContaining({ streamOwnerUserId: 'visitor-1', visitorRedaction: redaction }),
+ expect.objectContaining({ streamOwnerUserId: 'visitor-1' }),
);
});
diff --git a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.ts b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.ts
index 109d72af010..051e32393a8 100644
--- a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.ts
+++ b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/index.ts
@@ -78,12 +78,7 @@ const dispatchHeteroAgentImpl = async (
// visitor: the gateway registers the op under this id, the token it returns
// is the visitor's, and `streamOwnerUserId` on the op metadata is what tells
// the ingest/finish requests (other processes) to redact for a visitor.
- const shareStream = shareGate
- ? {
- streamOwnerUserId: shareGate.visitorUserId,
- visitorRedaction: { showErrorDetails: shareGate.shareConfig.showErrorDetails },
- }
- : undefined;
+ const shareStream = shareGate ? { streamOwnerUserId: shareGate.visitorUserId } : undefined;
// Same structured shape as the built-in path (`op_{ts}_{agentId}_{topicId}_{rand}`)
// so hetero ops aren't visually distinct bare nanoids in the trace/op tables.
const operationId =
diff --git a/apps/server/src/services/aiAgent/pipeline/startOperation.ts b/apps/server/src/services/aiAgent/pipeline/startOperation.ts
index 827501212a8..f171adc69ee 100644
--- a/apps/server/src/services/aiAgent/pipeline/startOperation.ts
+++ b/apps/server/src/services/aiAgent/pipeline/startOperation.ts
@@ -281,7 +281,6 @@ export const startOperation = async (
// resolves a model-supplied skill NAME, so a name the pool never
// offered still reaches the runtime.
skillGrants: shareGate.shareConfig.skillGrants,
- showErrorDetails: shareGate.shareConfig.showErrorDetails,
visitorUserId: shareGate.visitorUserId,
}
: undefined,
diff --git a/apps/server/src/services/aiAgent/shareGate/README.md b/apps/server/src/services/aiAgent/shareGate/README.md
index 536e6b742cc..db203638c40 100644
--- a/apps/server/src/services/aiAgent/shareGate/README.md
+++ b/apps/server/src/services/aiAgent/shareGate/README.md
@@ -72,11 +72,12 @@ tool does not ship):
device(s). A visitor executing arbitrary commands or driving a live
browser session on the CREATOR's own machine is a far larger blast radius
than any single data store, so they are never offered through the tool
- picker. They are granted only by `shareConfig.deviceAccess: 'allowlist'`
- naming the visitor in `deviceAllowUserIds`, and only while the visitor is
- still in the address book of the Agent's scope (personal contacts, or the
- workspace's members and external contacts). There is no "every visitor"
- value. The explicit creator choice is resolved once per gate by `resolveShareVisitorDeviceAccess` into
+ picker. They are granted only by `shareConfig.deviceAccess`: `contacts`
+ admits everyone currently in the address book of the Agent's scope
+ (personal contacts, or the workspace's members and external contacts),
+ including people added later; `allowlist` admits only visitors named in
+ `deviceAllowUserIds`, and only while they are still in that address book.
+ There is no "every visitor" value. The explicit creator choice is resolved once per gate by `resolveShareVisitorDeviceAccess` into
`canUseDevice` and re-applied at dispatch. The same grant admits
device-only MCP servers (which still need their own tool grant). The device
is always the Agent's configured execution environment; a visitor never
diff --git a/apps/server/src/services/aiAgent/shareGate/deviceAccess.test.ts b/apps/server/src/services/aiAgent/shareGate/deviceAccess.test.ts
index f8a5ab5675e..31335a05b1f 100644
--- a/apps/server/src/services/aiAgent/shareGate/deviceAccess.test.ts
+++ b/apps/server/src/services/aiAgent/shareGate/deviceAccess.test.ts
@@ -66,6 +66,26 @@ describe('resolveShareVisitorDeviceAccess', () => {
expect(await resolveShareVisitorDeviceAccess(db, share(config), 'visitor-1')).toBe(false);
});
+ it('grants every address-book person under `contacts`, without a list', async () => {
+ const config = { deviceAccess: 'contacts' } as const;
+
+ filterAddressBookPeople.mockResolvedValue(['visitor-1']);
+ expect(await resolveShareVisitorDeviceAccess(db, share(config, 'ws-1'), 'visitor-1')).toBe(
+ true,
+ );
+ expect(ContactModel).toHaveBeenCalledWith(db, 'owner', 'ws-1');
+ expect(filterAddressBookPeople).toHaveBeenCalledWith(['visitor-1']);
+
+ // A stranger, or someone removed from contacts, gets nothing.
+ filterAddressBookPeople.mockResolvedValue([]);
+ expect(await resolveShareVisitorDeviceAccess(db, share(config), 'visitor-1')).toBe(false);
+
+ // Contacts off for the owner grants nothing either.
+ filterAddressBookPeople.mockResolvedValue(['visitor-1']);
+ isChannelEnabled.mockResolvedValue(false);
+ expect(await resolveShareVisitorDeviceAccess(db, share(config), 'visitor-1')).toBe(false);
+ });
+
it('denies a listed contact while contacts are off for the owner', async () => {
const config = { deviceAccess: 'allowlist', deviceAllowUserIds: ['visitor-1'] } as const;
filterAddressBookPeople.mockResolvedValue(['visitor-1']);
diff --git a/apps/server/src/services/aiAgent/shareGate/deviceAccess.ts b/apps/server/src/services/aiAgent/shareGate/deviceAccess.ts
index ad37f3f111e..e9547a3efd4 100644
--- a/apps/server/src/services/aiAgent/shareGate/deviceAccess.ts
+++ b/apps/server/src/services/aiAgent/shareGate/deviceAccess.ts
@@ -41,8 +41,9 @@ export interface ShareDeviceAccessSubject {
* The only place `shareConfig.deviceAccess` is interpreted; every share-gate
* builder calls it so a fresh turn and a deferred init decide alike.
*
- * `allowlist` grants a listed visitor only while they are still in the
- * address book of the Agent's scope (`ContactModel.filterAddressBookPeople`):
+ * `contacts` grants every visitor currently in the address book of the
+ * Agent's scope. `allowlist` grants a listed visitor only while they are still
+ * in that address book (`ContactModel.filterAddressBookPeople`):
* the owner's personal contacts, or the workspace's members and external
* contacts. The list was checked against the same book when written; checking
* again here makes removing a contact, or leaving the workspace, revoke the
@@ -55,9 +56,10 @@ export const resolveShareVisitorDeviceAccess = async (
visitorUserId: string,
): Promise<boolean> => {
const { deviceAccess, deviceAllowUserIds } = share.shareConfig;
- if (deviceAccess !== 'allowlist') return false;
+ if (deviceAccess !== 'allowlist' && deviceAccess !== 'contacts') return false;
- if (!deviceAllowUserIds?.includes(visitorUserId)) {
+ // `contacts` skips the list: being in the address book is the whole grant.
+ if (deviceAccess === 'allowlist' && !deviceAllowUserIds?.includes(visitorUserId)) {
log('allowlist denied visitor %s: not listed', visitorUserId);
return false;
}
diff --git a/locales/en-US/agent.json b/locales/en-US/agent.json
index 3a79c8da906..8ae661b7952 100644
--- a/locales/en-US/agent.json
+++ b/locales/en-US/agent.json
@@ -704,6 +704,7 @@
"share.settings.limits.monthlySpendLimit": "Monthly spend cap",
"share.settings.limits.monthlySpendLimitHint": "Visitor runs stop once this month’s spend on this Agent reaches the cap. Resets on the 1st of each month (UTC).",
"share.settings.limits.monthlySpendLimitUnit": "USD",
+ "share.settings.limits.saved": "Limits saved",
"share.settings.limits.title": "Limits",
"share.settings.limits.workspaceDesc": "Every visitor run is billed to the Workspace budget, not to the visitor or any member quota. These per-Agent caps always apply — you can change the numbers, but not turn them off.",
"share.settings.link.changeModel": "Change model",
@@ -737,24 +738,28 @@
"share.settings.permissions.allowCreatorViewSessionsHint": "Off by default: visitor conversations stay private to the visitor. When on, they appear under Share on this agent's Topics page.",
"share.settings.permissions.allowReadMemory": "Allow reading my memory",
"share.settings.permissions.allowReadMemoryHint": "The Agent may draw on your long-term memory while answering a visitor.",
- "share.settings.permissions.desc": "What a visitor’s run may read, and what the visitor gets to see back.",
+ "share.settings.permissions.desc": "What a visitor’s run may read, and whether you can read visitor conversations.",
"share.settings.permissions.deviceAccessConfirm.commands": "They can run any command and read or write any file on the machine this Agent runs on, including through Claude Code or Codex.",
- "share.settings.permissions.deviceAccessConfirm.intro": "People you add will run this Agent on your execution environment:",
+ "share.settings.permissions.deviceAccessConfirm.contactsScope": "Anyone added to this Agent’s contacts later gets this access too, not only the people there now.",
+ "share.settings.permissions.deviceAccessConfirm.intro": "People you grant access will run this Agent on your execution environment:",
"share.settings.permissions.deviceAccessConfirm.messageLimit": "The monthly spend cap does not limit that usage. Only the message limit per visitor does.",
"share.settings.permissions.deviceAccessConfirm.ok": "Allow listed people",
+ "share.settings.permissions.deviceAccessConfirm.okContacts": "Allow everyone in contacts",
"share.settings.permissions.deviceAccessConfirm.subscription": "Claude Code and Codex runs use the model subscription signed in on that machine.",
"share.settings.permissions.deviceAccessConfirm.title": "Let people use your execution environment?",
- "share.settings.permissions.deviceAccessOption.allowlist": "People from contacts",
+ "share.settings.permissions.deviceAccessOption.allowlist": "Specific people from contacts",
+ "share.settings.permissions.deviceAccessOption.allowlistDesc": "Only the people you pick below from this Agent’s contacts can use it.",
+ "share.settings.permissions.deviceAccessOption.contacts": "Everyone in contacts",
+ "share.settings.permissions.deviceAccessOption.contactsDesc": "Everyone in this Agent’s contacts can use it, including people added later. Removing someone from contacts also removes their access.",
"share.settings.permissions.deviceAccessOption.none": "No visitors",
- "share.settings.permissions.deviceAllowContactsUnavailable": "Only people in your contacts can be added, and contacts aren’t available for your account yet.",
+ "share.settings.permissions.deviceAccessOption.noneDesc": "Visitors can chat with this Agent but never run it on your execution environment.",
+ "share.settings.permissions.deviceAllowContactsUnavailable": "Device access works through contacts, and contacts aren’t available for your account yet.",
"share.settings.permissions.deviceAllowHint": "Only people in this Agent’s contacts can be added. Removing someone from contacts also removes their access.",
"share.settings.permissions.deviceAllowLimitReached": "You can add up to {{limit}} people.",
"share.settings.permissions.deviceAllowLoadFailed": "Couldn’t load your contacts. Refresh to try again.",
"share.settings.permissions.deviceAllowNoContacts": "Your contacts are empty. Add people to your contacts first.",
"share.settings.permissions.deviceAllowPlaceholder": "Choose people from your contacts",
"share.settings.permissions.deviceAllowUnlisted": "No longer in contacts, so they can’t use it: {{names}}. They’re removed the next time you edit this list.",
- "share.settings.permissions.showErrorDetails": "Show error details to visitors",
- "share.settings.permissions.showErrorDetailsHint": "Off by default: visitors see a generic failure notice instead of raw error text.",
"share.settings.permissions.title": "Permissions",
"share.settings.profile.demoCases.add": "Add example",
"share.settings.profile.demoCases.desc": "Write examples for visitors to try. These are separate from the agent’s opening questions.",
@@ -864,7 +869,7 @@
"share.visitor.privacyNoticeWorkspaceCreatorVisible": "This topic runs in the owner Workspace. The Agent creator has turned on topic access and may read its messages, so avoid sharing sensitive information.",
"share.visitor.profile.about": "About",
"share.visitor.profile.createdBy": "Created by {{creator}}",
- "share.visitor.profile.cta": "Start a topic",
+ "share.visitor.profile.cta": "Start a conversation",
"share.visitor.profile.ctaSignIn": "Sign in to start",
"share.visitor.profile.freeNote": "Free · paid for by the creator",
"share.visitor.profile.freeNoteWorkspace": "Free · paid for by the Workspace",
diff --git a/locales/zh-CN/agent.json b/locales/zh-CN/agent.json
index 93c615ad2b6..b11de5d3046 100644
--- a/locales/zh-CN/agent.json
+++ b/locales/zh-CN/agent.json
@@ -704,6 +704,7 @@
"share.settings.limits.monthlySpendLimit": "每月消耗上限",
"share.settings.limits.monthlySpendLimitHint": "本月该助手的消耗达到上限后,访客将无法继续运行。按自然月统计,每月 1 日(UTC)重置。",
"share.settings.limits.monthlySpendLimitUnit": "美元",
+ "share.settings.limits.saved": "限制已保存",
"share.settings.limits.title": "使用限制",
"share.settings.limits.workspaceDesc": "访客的每次运行都会从工作区预算扣费,不会扣访客余额,也不占用创建者或其他成员的个人额度。每个智能体的这些上限始终生效,你可以调整数值,但不能关闭。",
"share.settings.link.changeModel": "更换模型",
@@ -737,24 +738,28 @@
"share.settings.permissions.allowCreatorViewSessionsHint": "默认关闭:访客的对话只有访客自己能看到。开启后,可在该助手「话题」页的「分享」来源中查看。",
"share.settings.permissions.allowReadMemory": "允许读取我的记忆",
"share.settings.permissions.allowReadMemoryHint": "助手在回答访客时可以参考你的长期记忆。",
- "share.settings.permissions.desc": "访客的运行可以读取什么,以及访客能看到什么。",
+ "share.settings.permissions.desc": "访客的运行可以读取什么,以及你能否查看访客的对话。",
"share.settings.permissions.deviceAccessConfirm.commands": "他们可以在这个助手运行的机器上执行任意命令、读写任意文件,包括通过 Claude Code 或 Codex。",
- "share.settings.permissions.deviceAccessConfirm.intro": "你添加的人会在你的执行环境上运行这个助手:",
+ "share.settings.permissions.deviceAccessConfirm.contactsScope": "之后加入这个助手所在通讯录的人也会自动获得这项权限,而不只是现在的联系人。",
+ "share.settings.permissions.deviceAccessConfirm.intro": "获得权限的人会在你的执行环境上运行这个助手:",
"share.settings.permissions.deviceAccessConfirm.messageLimit": "这部分用量不受每月消耗上限限制,只受每位访客的消息数上限约束。",
"share.settings.permissions.deviceAccessConfirm.ok": "允许指定的人",
+ "share.settings.permissions.deviceAccessConfirm.okContacts": "允许通讯录中的所有人",
"share.settings.permissions.deviceAccessConfirm.subscription": "Claude Code 和 Codex 会使用那台机器上登录的模型订阅。",
"share.settings.permissions.deviceAccessConfirm.title": "允许他人使用你的执行环境?",
- "share.settings.permissions.deviceAccessOption.allowlist": "通讯录中的人",
+ "share.settings.permissions.deviceAccessOption.allowlist": "通讯录中指定的人",
+ "share.settings.permissions.deviceAccessOption.allowlistDesc": "只有你在下方从通讯录中选出的人可以使用。",
+ "share.settings.permissions.deviceAccessOption.contacts": "通讯录中的所有人",
+ "share.settings.permissions.deviceAccessOption.contactsDesc": "这个助手所在通讯录中的所有人都能使用,包括之后新加入的人。把某人移出通讯录,也会同时收回其权限。",
"share.settings.permissions.deviceAccessOption.none": "不允许",
- "share.settings.permissions.deviceAllowContactsUnavailable": "只能添加通讯录中的人,你的账号暂未开通通讯录。",
+ "share.settings.permissions.deviceAccessOption.noneDesc": "访客可以和助手对话,但不能在你的执行环境上运行它。",
+ "share.settings.permissions.deviceAllowContactsUnavailable": "设备权限依赖通讯录,你的账号暂未开通通讯录。",
"share.settings.permissions.deviceAllowHint": "只能添加这个助手所在通讯录中的人。把某人移出通讯录,也会同时收回其权限。",
"share.settings.permissions.deviceAllowLimitReached": "最多可添加 {{limit}} 人。",
"share.settings.permissions.deviceAllowLoadFailed": "通讯录加载失败,请刷新重试。",
"share.settings.permissions.deviceAllowNoContacts": "通讯录里还没有人,请先添加联系人。",
"share.settings.permissions.deviceAllowPlaceholder": "从通讯录选择",
"share.settings.permissions.deviceAllowUnlisted": "已不在通讯录,无法使用:{{names}}。下次修改名单时会被移除。",
- "share.settings.permissions.showErrorDetails": "向访客展示错误详情",
- "share.settings.permissions.showErrorDetailsHint": "默认关闭:访客只会看到一句通用的失败提示,而不是原始报错。",
"share.settings.permissions.title": "权限",
"share.settings.profile.demoCases.add": "添加案例",
"share.settings.profile.demoCases.desc": "为访客编写可直接试用的案例,独立于助手的开场问题。",
@@ -864,7 +869,7 @@
"share.visitor.privacyNoticeWorkspaceCreatorVisible": "此话题运行在所属工作区内。智能体创建者开启了话题查看权限,可能会读取其中的消息,请勿发送敏感信息。",
"share.visitor.profile.about": "简介",
"share.visitor.profile.createdBy": "由 {{creator}} 创建",
- "share.visitor.profile.cta": "新建话题",
+ "share.visitor.profile.cta": "开始对话",
"share.visitor.profile.ctaSignIn": "登录后开始",
"share.visitor.profile.freeNote": "免费 · 由创建者付费",
"share.visitor.profile.freeNoteWorkspace": "免费 · 由工作区付费",
diff --git a/packages/database/src/models/__tests__/agentShare.coverage.test.ts b/packages/database/src/models/__tests__/agentShare.coverage.test.ts
index 197e403cf4d..5f5ce83bc54 100644
--- a/packages/database/src/models/__tests__/agentShare.coverage.test.ts
+++ b/packages/database/src/models/__tests__/agentShare.coverage.test.ts
@@ -33,7 +33,12 @@ describe('AgentShareModel coverage edges', () => {
});
await serverDB.insert(agents).values([
{ id: agentId, slug: 'ascov-agent-slug', title: 'ascov agent', userId },
- { id: unsharedAgentId, slug: 'ascov-unshared-slug', userId },
+ {
+ agencyConfig: { heterogeneousProvider: { type: 'claude-code' } },
+ id: unsharedAgentId,
+ slug: 'ascov-unshared-slug',
+ userId,
+ },
{ id: workspaceAgentId, slug: 'ascov-workspace-slug', userId, workspaceId },
{
id: nullListsAgentId,
@@ -133,23 +138,26 @@ describe('AgentShareModel coverage edges', () => {
it('keeps the stored config when the patch carries no defined field', async () => {
const model = new AgentShareModel(serverDB, userId);
await model.create(agentId);
- await model.updateConfig(agentId, { maxMessagesPerVisitor: 7, showErrorDetails: true });
+ await model.updateConfig(agentId, {
+ allowCreatorViewSessions: true,
+ maxMessagesPerVisitor: 7,
+ });
const updated = await model.updateConfig(agentId, {
+ allowCreatorViewSessions: undefined,
maxMessagesPerVisitor: undefined,
- showErrorDetails: undefined,
});
expect(updated?.shareConfig).toMatchObject({
+ allowCreatorViewSessions: true,
maxMessagesPerVisitor: 7,
- showErrorDetails: true,
slug: 'ascov-agent-slug',
});
const empty = await model.updateConfig(agentId, {});
expect(empty?.shareConfig).toMatchObject({
+ allowCreatorViewSessions: true,
maxMessagesPerVisitor: 7,
- showErrorDetails: true,
});
});
});
@@ -180,6 +188,24 @@ describe('AgentShareModel coverage edges', () => {
});
describe('findByShareId', () => {
+ it('returns the Agent harness so visitor grants can follow it', async () => {
+ const share = await new AgentShareModel(serverDB, userId).create(unsharedAgentId, 'link');
+
+ const found = await AgentShareModel.findByShareId(serverDB, share.id);
+
+ expect(found?.agentAgencyConfig).toEqual({
+ heterogeneousProvider: { type: 'claude-code' },
+ });
+ expect(
+ (
+ await AgentShareModel.findByShareId(
+ serverDB,
+ (await new AgentShareModel(serverDB, userId).create(agentId, 'link')).id,
+ )
+ )?.agentAgencyConfig ?? null,
+ ).toBeNull();
+ });
+
it('falls back to empty lists when the agent stores null tags and opening questions', async () => {
const share = await new AgentShareModel(serverDB, userId).create(nullListsAgentId, 'link');
diff --git a/packages/database/src/models/__tests__/agentShare.test.ts b/packages/database/src/models/__tests__/agentShare.test.ts
index 55be690f74f..5a5c3155d88 100644
--- a/packages/database/src/models/__tests__/agentShare.test.ts
+++ b/packages/database/src/models/__tests__/agentShare.test.ts
@@ -76,7 +76,6 @@ describe('AgentShareModel', () => {
allowCreatorViewSessions: false,
allowReadMemory: false,
maxMessagesPerVisitor: 100,
- showErrorDetails: false,
toolGrants: [],
},
userViewCount: 0,
@@ -393,7 +392,6 @@ describe('AgentShareModel', () => {
maxFileStorage: 512 * 1024 * 1024,
maxMessagesPerVisitor: 100,
monthlySpendLimit: 10,
- showErrorDetails: false,
slug: undefined,
toolGrants: [],
});
@@ -410,7 +408,6 @@ describe('AgentShareModel', () => {
maxFileStorage: 256 * 1024 * 1024,
maxMessagesPerVisitor: 40,
monthlySpendLimit: 25,
- showErrorDetails: true,
toolGrants: [{ identifier: 'search' }],
};
@@ -432,14 +429,14 @@ describe('AgentShareModel', () => {
toolGrants: [{ identifier: 'search' }],
});
const updated = await agentShareModel.updateConfig(agentId, {
+ allowCreatorViewSessions: true,
maxFileStorage: 1024,
- showErrorDetails: true,
});
expect(updated?.shareConfig).toMatchObject({
+ allowCreatorViewSessions: true,
maxFileStorage: 1024,
maxMessagesPerVisitor: 10,
- showErrorDetails: true,
toolGrants: [{ identifier: 'search' }],
});
});
@@ -449,15 +446,15 @@ describe('AgentShareModel', () => {
await agentShareModel.updateConfig(agentId, { monthlySpendLimit: 25 });
const updated = await agentShareModel.updateConfig(agentId, {
+ allowCreatorViewSessions: true,
monthlySpendLimit: 0,
- showErrorDetails: true,
// smuggled past the type on purpose — must be stripped, not persisted
...({ slug: 'sneaky-slug' } as object),
});
// `0` is a real cap ("stop all visitor runs"), never a cleared one.
expect(updated?.shareConfig.monthlySpendLimit).toBe(0);
- expect(updated?.shareConfig.showErrorDetails).toBe(true);
+ expect(updated?.shareConfig.allowCreatorViewSessions).toBe(true);
// The seeded profile slug is untouched; the smuggled one never lands.
expect(updated?.shareConfig.slug).toBe('shareable-agent');
expect(await AgentShareModel.findBySlugOrId(serverDB, 'sneaky-slug')).toBeNull();
diff --git a/packages/database/src/models/__tests__/messages/visitor.projection.test.ts b/packages/database/src/models/__tests__/messages/visitor.projection.test.ts
index df77eedb736..207900a1c38 100644
--- a/packages/database/src/models/__tests__/messages/visitor.projection.test.ts
+++ b/packages/database/src/models/__tests__/messages/visitor.projection.test.ts
@@ -80,12 +80,6 @@ describe('sanitizeVisitorError', () => {
expect(sanitized).toEqual({ type: AgentRuntimeErrorType.AgentRuntimeError });
});
- it('passes the raw failure through when the share opted into details', () => {
- const error = { message: 'raw upstream body', type: 'UpstreamError' as ChatErrorType };
-
- expect(sanitizeVisitorError(error, { showErrorDetails: true })).toBe(error);
- });
-
it('returns an absent error as-is', () => {
expect(sanitizeVisitorError(undefined)).toBeUndefined();
expect(sanitizeVisitorError(null)).toBeNull();
@@ -222,7 +216,7 @@ describe('toVisitorMessage', () => {
]);
});
- it('projects the error through the share error policy', () => {
+ it('projects the error to a classified type', () => {
const raw = {
message: 'OpenAI rejected the creator key',
type: 'InvalidProviderAPIKey' as ChatErrorType,
@@ -231,6 +225,5 @@ describe('toVisitorMessage', () => {
expect(toVisitorMessage(message({ error: raw })).error).toEqual({
type: AgentRuntimeErrorType.AgentRuntimeError,
});
- expect(toVisitorMessage(message({ error: raw }), { showErrorDetails: true }).error).toBe(raw);
});
});
diff --git a/packages/database/src/models/agentShare.ts b/packages/database/src/models/agentShare.ts
index 14aeb07b20e..08ed9db4f6b 100644
--- a/packages/database/src/models/agentShare.ts
+++ b/packages/database/src/models/agentShare.ts
@@ -30,7 +30,6 @@ const DEFAULT_AGENT_SHARE_CONFIG = {
maxFileStorage: AGENT_SHARE_DEFAULT_MAX_FILE_STORAGE,
maxMessagesPerVisitor: AGENT_SHARE_DEFAULT_MAX_MESSAGES_PER_VISITOR,
monthlySpendLimit: AGENT_SHARE_DEFAULT_MONTHLY_SPEND_LIMIT,
- showErrorDetails: false,
toolGrants: [],
} satisfies AgentShareConfig;
@@ -49,7 +48,6 @@ const normalizeAgentShareConfig = (
maxMessagesPerVisitor:
config?.maxMessagesPerVisitor ?? DEFAULT_AGENT_SHARE_CONFIG.maxMessagesPerVisitor,
monthlySpendLimit: config?.monthlySpendLimit ?? DEFAULT_AGENT_SHARE_CONFIG.monthlySpendLimit,
- showErrorDetails: config?.showErrorDetails ?? DEFAULT_AGENT_SHARE_CONFIG.showErrorDetails,
/**
* Left absent rather than defaulted to `[]`: both read as "no skill
* granted", so a default would only write a value the creator never picked.
@@ -623,6 +621,9 @@ export class AgentShareModel {
const [share] = await db
.select({
+ // Server-side only: which harness runs the Agent decides which grants
+ // apply (a Claude Code / Codex Agent has no LobeHub tools).
+ agentAgencyConfig: agents.agencyConfig,
agentAvatar: agents.avatar,
agentBackgroundColor: agents.backgroundColor,
agentDescription: agents.description,
diff --git a/packages/database/src/models/message/query.ts b/packages/database/src/models/message/query.ts
index df5223a8971..7d2164be187 100644
--- a/packages/database/src/models/message/query.ts
+++ b/packages/database/src/models/message/query.ts
@@ -27,7 +27,6 @@ import type {
QueryTopicByCursorParams,
TopicMessagesByCursorResult,
TopicTranscriptResult,
- VisitorRedactionOptions,
} from './types';
import { toVisitorMessage } from './visitor';
@@ -292,9 +291,8 @@ export class MessageConversationQueries extends MessageScope {
*
* Share messages persist under the CREATOR's account (see `shareChat.ts`),
* so `query()`'s joined `sender` and the billing/model-snapshot fields
- * describe the creator, not the visitor reading them. `redaction` carries the
- * share's own `showErrorDetails` switch; omitting it strips everything
- * (fail closed). Model, provider and spend never reach a visitor.
+ * describe the creator, not the visitor reading them. Errors are projected to
+ * a classified type; model, provider and spend never reach a visitor.
*/
queryForVisitor = async (
params: QueryMessageParams = {},
@@ -303,7 +301,6 @@ export class MessageConversationQueries extends MessageScope {
path: string | null,
file: { fileType: string; id?: string | null },
) => Promise<string>;
- redaction?: VisitorRedactionOptions;
timing?: ModelTimingContext;
/**
* The visitor's share scope for Work summaries. Omitting it skips Work
@@ -319,7 +316,7 @@ export class MessageConversationQueries extends MessageScope {
{ ...params, skipWorks: params.skipWorks || !options.workAccessScope },
{ ...options, allowShareVisitor: true },
);
- return messageItems.map((message) => toVisitorMessage(message, options.redaction));
+ return messageItems.map((message) => toVisitorMessage(message));
};
/**
diff --git a/packages/database/src/models/message/types.ts b/packages/database/src/models/message/types.ts
index 1956956a910..b692c7acebb 100644
--- a/packages/database/src/models/message/types.ts
+++ b/packages/database/src/models/message/types.ts
@@ -243,22 +243,6 @@ export interface MessageModelOptions {
includeShareVisitor?: boolean;
}
-/**
- * Per-share switches that relax {@link toVisitorMessage}'s default redaction.
- * Both default to `false` (strip everything), so a caller that forgets to pass
- * options gets the fail-closed projection.
- */
-export interface VisitorRedactionOptions {
- /**
- * `AgentShareConfig.showErrorDetails`. When false, a run failure is
- * projected down to a generic classified `type` (see
- * {@link sanitizeVisitorError}) instead of the raw
- * message/provider/budget/upstream-body payload `formatErrorForState`
- * builds.
- */
- showErrorDetails?: boolean;
-}
-
export interface SoftDeletedMessage {
/** Live children that were re-parented away from this message at trash time. */
childIds: string[];
diff --git a/packages/database/src/models/message/visitor.ts b/packages/database/src/models/message/visitor.ts
index c3de2d02c98..167385ace03 100644
--- a/packages/database/src/models/message/visitor.ts
+++ b/packages/database/src/models/message/visitor.ts
@@ -10,8 +10,6 @@ import type {
import { AgentRuntimeErrorType, ChatErrorType } from '@lobechat/types';
import { isPlainRecord } from '@lobechat/utils/object';
-import type { VisitorRedactionOptions } from './types';
-
/**
* Fields on {@link UIChatMessage} that are safe to forward to an agent-share
* visitor verbatim: the message's OWN presentational content (text,
@@ -228,15 +226,14 @@ const VISITOR_PUBLIC_ERROR_TYPE = AgentRuntimeErrorType.AgentRuntimeError;
* re-derives its localized copy, alert styling, and error-card variant from
* `type` alone.
*
- * Bypassed entirely when the share sets `showErrorDetails` — the creator has
- * then explicitly opted into showing visitors the raw failure.
+ * Applied to every visitor-facing error without a share-level opt-out: the raw
+ * payload describes the creator's provider and billing, which a visitor cannot
+ * act on.
*/
export const sanitizeVisitorError = (
error: ChatMessageError | null | undefined,
- options: VisitorRedactionOptions = {},
): ChatMessageError | null | undefined => {
if (!error) return error;
- if (options.showErrorDetails) return error;
const type = error.type as unknown;
if (typeof type === 'string' && VISITOR_SAFE_ERROR_TYPES.has(type)) {
@@ -305,17 +302,13 @@ const sanitizeVisitorWorks = (
/**
* Strip creator-only fields from a message row before it reaches an
* agent-share visitor. Creator account identity and the creator's
- * model/provider/spend choices never cross the share boundary; raw error
- * payloads cross it only when the share sets `showErrorDetails`
- * ({@link VisitorRedactionOptions}).
+ * model/provider/spend choices never cross the share boundary, and errors are
+ * projected to a classified type ({@link sanitizeVisitorError}).
*
* Built from {@link VISITOR_MESSAGE_ALLOWED_KEYS} plus explicit handling for
* the fields that need transformation rather than a plain allow/deny.
*/
-export const toVisitorMessage = (
- message: UIChatMessage,
- options: VisitorRedactionOptions = {},
-): UIChatMessage => {
+export const toVisitorMessage = (message: UIChatMessage): UIChatMessage => {
return {
...pickAllowedKeys(message),
// `sender` is the CREATOR's account identity — never gated by any config
@@ -330,7 +323,7 @@ export const toVisitorMessage = (
pluginError: redactCreatorPrivateBlob(message.pluginError),
pluginState: redactCreatorPrivateBlob(message.pluginState),
// Projected, not redacted — see `sanitizeVisitorError`.
- error: sanitizeVisitorError(message.error, options),
+ error: sanitizeVisitorError(message.error),
model: undefined,
provider: undefined,
signalCallbacks: sanitizeVisitorSignalCallbacks(message.signalCallbacks),
@@ -344,12 +337,10 @@ export const toVisitorMessage = (
// nests member messages, so anything less than a full recursive sanitize
// would leave the creator's identity on everything inside it.
...(message.compressedMessages && {
- compressedMessages: message.compressedMessages.map((nested) =>
- toVisitorMessage(nested, options),
- ),
+ compressedMessages: message.compressedMessages.map((nested) => toVisitorMessage(nested)),
}),
...(message.members && {
- members: message.members.map((nested) => toVisitorMessage(nested, options)),
+ members: message.members.map((nested) => toVisitorMessage(nested)),
}),
// `pinnedMessages` is only ever the narrow group-node projection (see
// `queryMessageGroupNodes` in the Compression branch).
@@ -376,7 +367,7 @@ export const toVisitorMessage = (
message.children as unknown as VisitorGroupSnapshotProjection[],
) as unknown as UIChatMessage['children'])
: ((message.children as unknown as UIChatMessage[]).map((child) =>
- toVisitorMessage(child, options),
+ toVisitorMessage(child),
) as unknown as UIChatMessage['children']),
}),
// `AssistantContentBlock.council` on a nested assistantGroup child is a
@@ -387,7 +378,7 @@ export const toVisitorMessage = (
...((message as unknown as { council?: unknown }).council !== undefined &&
({
council: ((message as unknown as { council?: UIChatMessage[] }).council ?? []).map(
- (member) => toVisitorMessage(member, options),
+ (member) => toVisitorMessage(member),
),
} as unknown as Partial<UIChatMessage>)),
} as UIChatMessage;
diff --git a/packages/database/src/repositories/channel/__tests__/sharedAgent.test.ts b/packages/database/src/repositories/channel/__tests__/sharedAgent.test.ts
index 250a66f9e99..68dfac7bcbc 100644
--- a/packages/database/src/repositories/channel/__tests__/sharedAgent.test.ts
+++ b/packages/database/src/repositories/channel/__tests__/sharedAgent.test.ts
@@ -313,10 +313,12 @@ describe('a contact’s shared Agent in a direct conversation', () => {
expect(job.errorType).toBe('AgentRuntimeError');
});
- it('shows the raw failure when the owner’s share opts into error details', async () => {
+ // The share option to show visitors raw errors was removed; a row written before then
+ // must not bring it back.
+ it('still redacts the failure when a stored share config predates the removed error-details option', async () => {
await db
.update(agentShares)
- .set({ shareConfig: { showErrorDetails: true } })
+ .set({ shareConfig: { showErrorDetails: true } as Record<string, unknown> })
.where(eq(agentShares.id, shareId));
const { channel } = await visitor.create({
agentId,
@@ -325,7 +327,8 @@ describe('a contact’s shared Agent in a direct conversation', () => {
});
const job = await failedView(channel.id, visitor);
- expect(job.errorMessage).toBe('Upstream provider key sk-owner-secret rejected');
+ expect(job.errorMessage).toBeNull();
+ expect(job.errorType).toBe('AgentRuntimeError');
});
// The visitor saw "no reason recorded" when the owner's monthly cap refused the reply.
diff --git a/packages/database/src/repositories/channel/view.ts b/packages/database/src/repositories/channel/view.ts
index d35b1b09dad..2766a50c7d3 100644
--- a/packages/database/src/repositories/channel/view.ts
+++ b/packages/database/src/repositories/channel/view.ts
@@ -31,7 +31,6 @@ import { sanitizeVisitorError } from '../../models/message/visitor';
import {
agentOperations,
agents,
- agentShares,
channelJobs,
channelMembers,
channelMessages,
@@ -293,7 +292,6 @@ const publicJobColumns = {
publicationRevoked: channelJobs.publicationRevoked,
// Read only to redact the error of a shared Agent's run, then dropped by `readJobs`.
sharedRun: sql<boolean>`COALESCE(jsonb_exists(${channelJobs.executionConfig}, 'share'), false)`,
- shareShowsErrorDetails: sql<boolean>`COALESCE(${agentShares.shareConfig}->>'showErrorDetails' = 'true', false)`,
};
/** At most this many of a main view's threads' jobs still at work ride along with its own. */
@@ -303,25 +301,23 @@ const THREAD_ACTIVE_JOB_LIMIT = 50;
* A shared Agent runs under its owner's credentials, so its failure text can carry the owner's
* provider or infrastructure diagnostics. The viewer of such a run is the visitor, who gets the
* share page's projection (`sanitizeVisitorError`): a classified type, and the message only for
- * the few visitor-safe codes, unless the owner's share opts into `showErrorDetails`.
+ * the few visitor-safe codes.
*/
const redactSharedRunError = <
Job extends {
errorMessage: string | null;
errorType: string | null;
sharedRun: boolean;
- shareShowsErrorDetails: boolean;
},
>({
sharedRun,
- shareShowsErrorDetails,
...job
}: Job) => {
if (!sharedRun || job.errorMessage === null) return job;
- const safe = sanitizeVisitorError(
- { message: job.errorMessage, type: job.errorType ?? undefined } as ChatMessageError,
- { showErrorDetails: shareShowsErrorDetails },
- );
+ const safe = sanitizeVisitorError({
+ message: job.errorMessage,
+ type: job.errorType ?? undefined,
+ } as ChatMessageError);
return { ...job, errorMessage: safe?.message ?? null, errorType: safe?.type?.toString() ?? null };
};
@@ -331,10 +327,6 @@ const readJobs = async (tx: Transaction, where: SQL | undefined, limit: number)
.from(channelJobs)
.leftJoin(agentOperations, eq(agentOperations.id, channelJobs.operationId))
.leftJoin(topics, eq(topics.id, channelJobs.topicId))
- .leftJoin(
- agentShares,
- sql`${agentShares.id}::text = ${channelJobs.executionConfig}->'share'->>'shareId'`,
- )
.where(where)
.orderBy(desc(channelJobs.createdAt))
.limit(limit);
diff --git a/packages/database/src/schemas/agentShare.ts b/packages/database/src/schemas/agentShare.ts
index 2771f3f5eff..b90d95828e4 100644
--- a/packages/database/src/schemas/agentShare.ts
+++ b/packages/database/src/schemas/agentShare.ts
@@ -4,7 +4,7 @@ import { index, integer, jsonb, pgTable, text, uniqueIndex, uuid } from 'drizzle
import { timestamps } from './_helpers';
import { agents } from './agent';
-export type AgentShareDeviceAccess = 'allowlist' | 'none';
+export type AgentShareDeviceAccess = 'allowlist' | 'contacts' | 'none';
export interface AgentShareConfig {
/**
@@ -29,6 +29,9 @@ export interface AgentShareConfig {
* - `allowlist`: only the people in {@link deviceAllowUserIds} who are
* still in the Agent's address book. They get the device tools and, for a
* heterogeneous Agent, run it on the device.
+ * - `contacts`: everyone currently in the Agent's address book, so a creator
+ * can prepare the share before someone joins: they can use it as soon as
+ * they are added, and lose it when removed.
*
* There is no "every visitor" value: a stranger never reaches the creator's
* machine. The visitor never picks the device — it always follows the
@@ -72,11 +75,6 @@ export interface AgentShareConfig {
* the OSS schema only carries the configured value.
*/
monthlySpendLimit?: number;
- /**
- * Whether visitors may see raw run error details (message/stack) instead of
- * a generic failure notice. Defaults to `false`.
- */
- showErrorDetails?: boolean;
/**
* Skills visitors may load, by skill identifier. Deliberately separate from
* {@link toolGrants}: a skill grant governs BOTH the tool path
diff --git a/packages/locales/src/default/agent.ts b/packages/locales/src/default/agent.ts
index 904f657c914..61abfedcd9c 100644
--- a/packages/locales/src/default/agent.ts
+++ b/packages/locales/src/default/agent.ts
@@ -960,19 +960,30 @@ export default {
'The Agent may draw on your long-term memory while answering a visitor.',
'share.settings.permissions.deviceAccessConfirm.messageLimit':
'The monthly spend cap does not limit that usage. Only the message limit per visitor does.',
- 'share.settings.permissions.deviceAccessOption.allowlist': 'People from contacts',
+ 'share.settings.permissions.deviceAccessOption.allowlist': 'Specific people from contacts',
+ 'share.settings.permissions.deviceAccessConfirm.okContacts': 'Allow everyone in contacts',
+ 'share.settings.permissions.deviceAccessOption.contacts': 'Everyone in contacts',
'share.settings.permissions.deviceAccessOption.none': 'No visitors',
+ 'share.settings.permissions.deviceAccessOption.noneDesc':
+ 'Visitors can chat with this Agent but never run it on your execution environment.',
+ 'share.settings.permissions.deviceAccessOption.contactsDesc':
+ 'Everyone in this Agent’s contacts can use it, including people added later. Removing someone from contacts also removes their access.',
+ 'share.settings.permissions.deviceAccessOption.allowlistDesc':
+ 'Only the people you pick below from this Agent’s contacts can use it.',
+ 'share.settings.limits.saved': 'Limits saved',
'share.settings.permissions.deviceAccessConfirm.commands':
'They can run any command and read or write any file on the machine this Agent runs on, including through Claude Code or Codex.',
+ 'share.settings.permissions.deviceAccessConfirm.contactsScope':
+ 'Anyone added to this Agent’s contacts later gets this access too, not only the people there now.',
'share.settings.permissions.deviceAccessConfirm.intro':
- 'People you add will run this Agent on your execution environment:',
+ 'People you grant access will run this Agent on your execution environment:',
'share.settings.permissions.deviceAccessConfirm.ok': 'Allow listed people',
'share.settings.permissions.deviceAccessConfirm.subscription':
'Claude Code and Codex runs use the model subscription signed in on that machine.',
'share.settings.permissions.deviceAccessConfirm.title':
'Let people use your execution environment?',
'share.settings.permissions.deviceAllowContactsUnavailable':
- 'Only people in your contacts can be added, and contacts aren’t available for your account yet.',
+ 'Device access works through contacts, and contacts aren’t available for your account yet.',
'share.settings.permissions.deviceAllowHint':
'Only people in this Agent’s contacts can be added. Removing someone from contacts also removes their access.',
'share.settings.permissions.deviceAllowLimitReached': 'You can add up to {{limit}} people.',
@@ -984,10 +995,7 @@ export default {
'share.settings.permissions.deviceAllowUnlisted':
'No longer in contacts, so they can’t use it: {{names}}. They’re removed the next time you edit this list.',
'share.settings.permissions.desc':
- 'What a visitor’s run may read, and what the visitor gets to see back.',
- 'share.settings.permissions.showErrorDetails': 'Show error details to visitors',
- 'share.settings.permissions.showErrorDetailsHint':
- 'Off by default: visitors see a generic failure notice instead of raw error text.',
+ 'What a visitor’s run may read, and whether you can read visitor conversations.',
'share.settings.permissions.title': 'Permissions',
'share.settings.tabs.access': 'Access',
'share.settings.tabs.profile': 'Public profile',
@@ -1095,7 +1103,7 @@ export default {
'This topic runs in the owner Workspace. The Agent creator has turned on topic access and may read its messages, so avoid sharing sensitive information.',
'share.visitor.profile.about': 'About',
'share.visitor.profile.createdBy': 'Created by {{creator}}',
- 'share.visitor.profile.cta': 'Start a topic',
+ 'share.visitor.profile.cta': 'Start a conversation',
'share.visitor.profile.ctaSignIn': 'Sign in to start',
'share.visitor.profile.freeNote': 'Free · paid for by the creator',
'share.visitor.profile.freeNoteWorkspace': 'Free · paid for by the Workspace',
diff --git a/packages/types/src/agentRuntime.ts b/packages/types/src/agentRuntime.ts
index 5662d3f3c44..6e9534a43ad 100644
--- a/packages/types/src/agentRuntime.ts
+++ b/packages/types/src/agentRuntime.ts
@@ -103,8 +103,7 @@ export enum RequestTrigger {
/**
* Everything one shared-agent visitor run carries: WHO the run belongs to
* (`agentId` / `shareId` / `visitorUserId`), WHAT the visitor is allowed to
- * reach (`allowReadMemory` / `toolGrants` / `knowledgeBaseIds`), and HOW
- * much of the run is shown back to them (`showErrorDetails`).
+ * reach (`allowReadMemory` / `toolGrants` / `knowledgeBaseIds`).
*
* Single source of truth for the runtime-side share marker: it is stamped once
* at operation creation onto `state.metadata.agentShareVisitor` and read back
@@ -148,8 +147,6 @@ export interface AgentShareVisitorContext {
* `AgentShareModel.isRunStillAuthorized`).
*/
shareId: string;
- /** `AgentShareConfig.showErrorDetails` — gates visitor-facing error redaction. */
- showErrorDetails?: boolean;
/**
* Mirrors `shareConfig.skillGrants` so the skill runtime can enforce the same
* per-skill allowlist the operation's skill pool was built from. Absent or
diff --git a/src/features/AgentChannel/PlatformDetail/ModuleSaveBar.tsx b/src/features/AgentChannel/PlatformDetail/ModuleSaveBar.tsx
index 5ff48ee745f..51c8a7641af 100644
--- a/src/features/AgentChannel/PlatformDetail/ModuleSaveBar.tsx
+++ b/src/features/AgentChannel/PlatformDetail/ModuleSaveBar.tsx
@@ -9,6 +9,8 @@ interface ModuleSaveBarProps {
disabled?: boolean;
onDiscard: () => void;
onSave: () => void;
+ /** Blocks only Save, e.g. while a field is invalid; Discard stays available. */
+ saveDisabled?: boolean;
saving?: boolean;
}
@@ -20,7 +22,7 @@ interface ModuleSaveBarProps {
* With a change pending it says so and offers to put the block back.
*/
export const ModuleSaveBar = memo<ModuleSaveBarProps>(
- ({ dirty, disabled, onDiscard, onSave, saving }) => {
+ ({ dirty, disabled, onDiscard, onSave, saveDisabled, saving }) => {
const { t: _t } = useTranslation('agent');
const t = _t as (key: string) => string;
@@ -37,7 +39,7 @@ export const ModuleSaveBar = memo<ModuleSaveBarProps>(
</Button>
)}
<Button
- disabled={disabled || !dirty}
+ disabled={disabled || saveDisabled || !dirty}
loading={saving}
size={'small'}
type={dirty ? 'primary' : 'default'}