@agentforge-io/core 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,18 @@ export interface AgentRecord {
29
29
  mcpServers?: McpServerConfig[];
30
30
  metadata?: Record<string, unknown>;
31
31
  isActive?: boolean;
32
+ /**
33
+ * When set, connector tools (Gmail, Drive, ...) are resolved against
34
+ * this user's OAuth authorizations instead of the caller's. Used by
35
+ * public-chat agents — a visitor's browser session can leverage the
36
+ * agent owner's authorized connectors without exposing the owner's
37
+ * identity in the conversation record.
38
+ *
39
+ * Leave undefined for personal agents where the caller owns the
40
+ * connectors themselves; in that case the SDK falls back to the
41
+ * caller's userId, preserving the original behavior.
42
+ */
43
+ connectorOwnerUserId?: string;
32
44
  }
33
45
  /**
34
46
  * Host-supplied resolver for per-tenant agent configurations. The SDK never
@@ -157,7 +157,11 @@ class AgentService {
157
157
  role: 'user',
158
158
  content: params.content,
159
159
  });
160
- const extraTools = await this.resolveExtraTools(params.userId);
160
+ // Connector tools follow `agent.connectorOwnerUserId` when the
161
+ // resolved agent declares one (e.g. a public-chat agent reusing the
162
+ // owner's Gmail authorization); otherwise they fall back to the
163
+ // caller's userId, which is the historical personal-agent path.
164
+ const extraTools = await this.resolveExtraTools(agent.connectorOwnerUserId ?? params.userId);
161
165
  const response = await this.runner.run(agent, messages, {
162
166
  userId: params.userId,
163
167
  conversationId: params.conversationId,
@@ -217,7 +221,10 @@ class AgentService {
217
221
  });
218
222
  let fullContent = '';
219
223
  let finalUsage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
220
- const extraTools = await this.resolveExtraTools(params.userId);
224
+ // Same precedence as sendMessage — agent.connectorOwnerUserId takes
225
+ // priority so a public-chat agent always uses the owner's connector
226
+ // toolbelt regardless of which visitor session is streaming.
227
+ const extraTools = await this.resolveExtraTools(agent.connectorOwnerUserId ?? params.userId);
221
228
  for await (const chunk of this.runner.stream(agent, messages, {
222
229
  userId: params.userId,
223
230
  conversationId: params.conversationId,
@@ -325,5 +332,6 @@ function toAgentDefinition(record) {
325
332
  tools: record.tools,
326
333
  mcpServers: record.mcpServers,
327
334
  metadata: record.metadata,
335
+ connectorOwnerUserId: record.connectorOwnerUserId,
328
336
  };
329
337
  }
@@ -94,6 +94,15 @@ export interface AgentDefinition {
94
94
  requiredPlan?: string[];
95
95
  /** Custom metadata */
96
96
  metadata?: Record<string, unknown>;
97
+ /**
98
+ * When set, connector tools (Gmail, Drive, ...) are resolved against
99
+ * this user's OAuth authorizations instead of the caller's. Lets a
100
+ * public-chat agent reuse the agent owner's authorized connectors
101
+ * while keeping the conversation scoped to the visitor. Leave
102
+ * undefined for personal agents — the SDK falls back to the caller's
103
+ * userId, preserving the original behavior.
104
+ */
105
+ connectorOwnerUserId?: string;
97
106
  }
98
107
  /**
99
108
  * Configuration for an MCP server the runtime should connect to.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/core",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "Framework-free AI runtime SDK. Owns: agent loop (Anthropic), conversations, tools, streaming, agent-job queue, SdkHooks. Identity, billing, infra (email/uploads/secrets) live in the host's modules — not here.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",