🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(agent-share): default-grant marker and declined grants on share config (#23471)
YuTengjing4629e1cb3457
diff --git a/apps/server/src/routers/lambda/agentShare.ts b/apps/server/src/routers/lambda/agentShare.tsindex 00812c6a287..2145defa68d 100644--- a/apps/server/src/routers/lambda/agentShare.ts+++ b/apps/server/src/routers/lambda/agentShare.ts@@ -70,6 +70,12 @@ export const agentShareConfigSchema = z).max(20).optional(),+ /** Presentation-only review state; see `AgentShareConfig.declinedGrantIds`. */+ declinedGrantIds: z+ .array(z.string().trim().min(1))+ .max(500)+ .refine((ids) => new Set(ids).size === ids.length, 'Duplicate declined identifier')+ .optional(),deviceAccess: z.enum(['none', 'contacts', 'allowlist']).optional(),/** Each id must also be in the scope's address book; `updateShareConfig` checks that. */deviceAllowUserIds: z@@ -86,6 +92,8 @@ export const agentShareConfigSchema = zmaxFileStorage: z.number().int().nonnegative().optional(),maxMessagesPerVisitor: z.number().int().positive().optional(),monthlySpendLimit: z.number().nonnegative().optional(),+ /** Only clearable: the marker is set by `AgentShareModel.create` alone. */+ seedDefaultGrants: z.literal(false).optional(),/*** Skill identifiers the creator opened to visitors. An empty array is* accepted rather than rejected: unticking the last skill is a normaldiff --git a/locales/en-US/agent.json b/locales/en-US/agent.jsonindex 8ae661b7952..260a81544b6 100644--- a/locales/en-US/agent.json+++ b/locales/en-US/agent.json@@ -734,6 +734,10 @@"share.settings.notice.title": "You pay for visitor usage.","share.settings.notice.workspaceDesc": "Visitors don’t just read this Agent — they run it. Every reply is generated in the Workspace and charged to its shared budget, without consuming the creator’s or another member’s quota. The Agent only acts with the visitor access you grant below.","share.settings.notice.workspaceTitle": "Visitors run this Agent on the Workspace budget",+ "share.settings.pendingGrants.decline": "Don’t open",+ "share.settings.pendingGrants.desc": "Includes {{names}}. If you choose not to open them, you won’t be asked about them again.",+ "share.settings.pendingGrants.grantAll": "Open to visitors",+ "share.settings.pendingGrants.title": "{{count}} tools or skills turned on in this Agent aren’t open to visitors yet","share.settings.permissions.allowCreatorViewSessions": "Let me read visitor conversations","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",diff --git a/locales/zh-CN/agent.json b/locales/zh-CN/agent.jsonindex b11de5d3046..309105c3f67 100644--- a/locales/zh-CN/agent.json+++ b/locales/zh-CN/agent.json@@ -734,6 +734,10 @@"share.settings.notice.title": "访客使用产生的费用由你承担。","share.settings.notice.workspaceDesc": "访客不只是查看这个助手,而是真的在运行它。每一次回复都在工作区内生成并从工作区共享预算扣费,不占用创建者或其他成员的个人额度。助手只会使用你在下面授予访客的权限。","share.settings.notice.workspaceTitle": "访客将使用工作区预算运行此助手",+ "share.settings.pendingGrants.decline": "不开放",+ "share.settings.pendingGrants.desc": "包括:{{names}}。选择不开放后,不会再就这些提醒你。",+ "share.settings.pendingGrants.grantAll": "开放给访客",+ "share.settings.pendingGrants.title": "助手里已开启的 {{count}} 个工具或技能还没开放给访客","share.settings.permissions.allowCreatorViewSessions": "允许我查看访客对话","share.settings.permissions.allowCreatorViewSessionsHint": "默认关闭:访客的对话只有访客自己能看到。开启后,可在该助手「话题」页的「分享」来源中查看。","share.settings.permissions.allowReadMemory": "允许读取我的记忆",diff --git a/packages/database/src/models/__tests__/agentShare.test.ts b/packages/database/src/models/__tests__/agentShare.test.tsindex 5a5c3155d88..75108d25f20 100644--- a/packages/database/src/models/__tests__/agentShare.test.ts+++ b/packages/database/src/models/__tests__/agentShare.test.ts@@ -102,6 +102,21 @@ describe('AgentShareModel', () => {expect(rows[0].visibility).toBe('private');});+ it('marks only a newly inserted share for default grants', async () => {+ const created = await agentShareModel.create(agentId, 'link');+ expect(created.shareConfig.seedDefaultGrants).toBe(true);++ await agentShareModel.updateConfig(agentId, {+ seedDefaultGrants: false,+ toolGrants: [{ identifier: 'search' }],+ });+ // Re-enabling returns the existing row and must not re-arm the marker.+ const again = await agentShareModel.create(agentId, 'link');++ expect(again.shareConfig.seedDefaultGrants).toBe(false);+ expect(again.shareConfig.toolGrants).toEqual([{ identifier: 'search' }]);+ });+describe('profile slug seed', () => {it("seeds the share slug from the agent's own profile slug", async () => {await serverDB@@ -355,6 +370,20 @@ describe('AgentShareModel', () => {expect((await agentShareModel.getByAgentId(agentId))?.shareConfig.demoCases).toEqual([]);});+ it('persists declined grant ids through unrelated patches', async () => {+ await agentShareModel.create(agentId);+ expect(+ (await agentShareModel.getByAgentId(agentId))?.shareConfig.declinedGrantIds,+ ).toBeUndefined();++ await agentShareModel.updateConfig(agentId, { declinedGrantIds: ['calculator'] });+ await agentShareModel.updateConfig(agentId, { toolGrants: [{ identifier: 'search' }] });++ expect((await agentShareModel.getByAgentId(agentId))?.shareConfig.declinedGrantIds).toEqual([+ 'calculator',+ ]);+ });+it('does not let another owner replace profile content', async () => {await agentShareModel.create(agentId);expect(@@ -415,8 +444,15 @@ describe('AgentShareModel', () => {const readBack = await agentShareModel.getByAgentId(agentId);// The slug seeded from the agent's profile slug at `create` survives a- // full config overwrite — it is owner-facing url state, not config.- const expected = { demoCases: [], featuredWorkIds: [], ...config, slug: 'shareable-agent' };+ // full config overwrite — it is owner-facing url state, not config. So+ // does the default-grant marker `create` set, which this config omits.+ const expected = {+ demoCases: [],+ featuredWorkIds: [],+ seedDefaultGrants: true,+ ...config,+ slug: 'shareable-agent',+ };expect(updated?.shareConfig).toEqual(expected);expect(readBack?.shareConfig).toEqual(expected);});diff --git a/packages/database/src/models/agentShare.ts b/packages/database/src/models/agentShare.tsindex 08ed9db4f6b..4f503a1ee9c 100644--- a/packages/database/src/models/agentShare.ts+++ b/packages/database/src/models/agentShare.ts@@ -40,6 +40,8 @@ const normalizeAgentShareConfig = (allowCreatorViewSessions:config?.allowCreatorViewSessions ?? DEFAULT_AGENT_SHARE_CONFIG.allowCreatorViewSessions,allowReadMemory: config?.allowReadMemory ?? DEFAULT_AGENT_SHARE_CONFIG.allowReadMemory,+ /** Left absent like `skillGrants`: absent marks a share whose Agent tools were never reviewed. */+ declinedGrantIds: config?.declinedGrantIds,demoCases: config?.demoCases ?? [],deviceAccess: config?.deviceAccess ?? 'none',deviceAllowUserIds: config?.deviceAllowUserIds ?? [],@@ -53,6 +55,7 @@ const normalizeAgentShareConfig = (* granted", so a default would only write a value the creator never picked.*/skillGrants: config?.skillGrants,+ seedDefaultGrants: config?.seedDefaultGrants,slug: config?.slug,toolGrants: config?.toolGrants ?? DEFAULT_AGENT_SHARE_CONFIG.toolGrants,});@@ -260,7 +263,9 @@ export class AgentShareModel {.insert(agentShares).values({agentId,- shareConfig: DEFAULT_AGENT_SHARE_CONFIG,+ // Only an inserted row carries the marker; the conflict path below+ // returns an existing share untouched.+ shareConfig: { ...DEFAULT_AGENT_SHARE_CONFIG, seedDefaultGrants: true },visibility,}).onConflictDoNothing({ target: agentShares.agentId })diff --git a/packages/database/src/schemas/agentShare.ts b/packages/database/src/schemas/agentShare.tsindex b90d95828e4..43953ddfd12 100644--- a/packages/database/src/schemas/agentShare.ts+++ b/packages/database/src/schemas/agentShare.ts@@ -18,6 +18,15 @@ export interface AgentShareConfig {* a shared conversation. Defaults to `false`.*/allowReadMemory?: boolean;+ /**+ * Tool and skill identifiers the creator chose NOT to grant: dismissed from+ * the "new on this Agent" prompt, or unticked in a picker. Grants nothing and+ * revokes nothing — the server gate never reads it. It only stops the share+ * settings from offering these identifiers again as newly added to the Agent.+ * Absent on shares created before the prompt existed, so their ungranted+ * Agent tools surface once for review instead of being granted silently.+ */+ declinedGrantIds?: string[];/** Visitor trial scenarios, maintained independently of agents.openingQuestions. */demoCases?: AgentShareDemoCase[];/**@@ -75,6 +84,15 @@ export interface AgentShareConfig {* the OSS schema only carries the configured value.*/monthlySpendLimit?: number;+ /**+ * Set only by `AgentShareModel.create` when it inserts a brand-new share:+ * the creator share settings then grant the Agent's usable tools and skills+ * once and write `false`. Persisted on the row rather than kept in client+ * state, so the default lands on exactly the share that was created — never+ * on an existing share another tab or manager configured, nor on a different+ * Agent the page navigated to. The server gate never reads it.+ */+ seedDefaultGrants?: boolean;/*** Skills visitors may load, by skill identifier. Deliberately separate from* {@link toolGrants}: a skill grant governs BOTH the tool pathdiff --git a/packages/locales/src/default/agent.ts b/packages/locales/src/default/agent.tsindex 61abfedcd9c..bdf882ce6e6 100644--- a/packages/locales/src/default/agent.ts+++ b/packages/locales/src/default/agent.ts@@ -952,6 +952,12 @@ export default {'share.settings.notice.workspaceDesc':'Visitors don’t just read this Agent — they run it. Every reply is generated in the Workspace and charged to its shared budget, without consuming the creator’s or another member’s quota. The Agent only acts with the visitor access you grant below.','share.settings.notice.workspaceTitle': 'Visitors run this Agent on the Workspace budget',+ 'share.settings.pendingGrants.decline': 'Don’t open',+ 'share.settings.pendingGrants.desc':+ 'Includes {{names}}. If you choose not to open them, you won’t be asked about them again.',+ 'share.settings.pendingGrants.grantAll': 'Open to visitors',+ 'share.settings.pendingGrants.title':+ '{{count}} tools or skills turned on in this Agent aren’t open to visitors yet','share.settings.permissions.allowCreatorViewSessions': 'Let me read visitor conversations','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.",