@salesforce/sfdx-agent-sdk 0.1.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.
Files changed (67) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +508 -0
  3. package/dist/agent-connectivity-resolver.d.ts +62 -0
  4. package/dist/agent-connectivity-resolver.js +47 -0
  5. package/dist/agent-connectivity-resolver.js.map +1 -0
  6. package/dist/agent-manager.d.ts +134 -0
  7. package/dist/agent-manager.js +266 -0
  8. package/dist/agent-manager.js.map +1 -0
  9. package/dist/agent.d.ts +218 -0
  10. package/dist/agent.js +313 -0
  11. package/dist/agent.js.map +1 -0
  12. package/dist/chat-session.d.ts +298 -0
  13. package/dist/chat-session.js +407 -0
  14. package/dist/chat-session.js.map +1 -0
  15. package/dist/errors.d.ts +12 -0
  16. package/dist/errors.js +20 -0
  17. package/dist/errors.js.map +1 -0
  18. package/dist/harness/agent-harness.d.ts +200 -0
  19. package/dist/harness/agent-harness.js +6 -0
  20. package/dist/harness/agent-harness.js.map +1 -0
  21. package/dist/harness/harness-bus-owner.d.ts +34 -0
  22. package/dist/harness/harness-bus-owner.js +78 -0
  23. package/dist/harness/harness-bus-owner.js.map +1 -0
  24. package/dist/harness/harness-config.d.ts +89 -0
  25. package/dist/harness/harness-config.js +26 -0
  26. package/dist/harness/harness-config.js.map +1 -0
  27. package/dist/harness/harness-factory.d.ts +21 -0
  28. package/dist/harness/harness-factory.js +6 -0
  29. package/dist/harness/harness-factory.js.map +1 -0
  30. package/dist/harness/index.d.ts +4 -0
  31. package/dist/harness/index.js +6 -0
  32. package/dist/harness/index.js.map +1 -0
  33. package/dist/index.d.ts +23 -0
  34. package/dist/index.js +20 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/internal/telemetry-router.d.ts +41 -0
  37. package/dist/internal/telemetry-router.js +128 -0
  38. package/dist/internal/telemetry-router.js.map +1 -0
  39. package/dist/mcp-auth.d.ts +20 -0
  40. package/dist/mcp-auth.js +40 -0
  41. package/dist/mcp-auth.js.map +1 -0
  42. package/dist/mcp-config.d.ts +52 -0
  43. package/dist/mcp-config.js +13 -0
  44. package/dist/mcp-config.js.map +1 -0
  45. package/dist/test/tsconfig.tsbuildinfo +1 -0
  46. package/dist/types/events.d.ts +151 -0
  47. package/dist/types/events.js +6 -0
  48. package/dist/types/events.js.map +1 -0
  49. package/dist/types/index.d.ts +4 -0
  50. package/dist/types/index.js +6 -0
  51. package/dist/types/index.js.map +1 -0
  52. package/dist/types/messages.d.ts +60 -0
  53. package/dist/types/messages.js +6 -0
  54. package/dist/types/messages.js.map +1 -0
  55. package/dist/types/telemetry-events.d.ts +93 -0
  56. package/dist/types/telemetry-events.js +6 -0
  57. package/dist/types/telemetry-events.js.map +1 -0
  58. package/dist/types/tools.d.ts +57 -0
  59. package/dist/types/tools.js +6 -0
  60. package/dist/types/tools.js.map +1 -0
  61. package/dist/types/usage.d.ts +31 -0
  62. package/dist/types/usage.js +6 -0
  63. package/dist/types/usage.js.map +1 -0
  64. package/dist/workspace.d.ts +15 -0
  65. package/dist/workspace.js +48 -0
  66. package/dist/workspace.js.map +1 -0
  67. package/package.json +64 -0
@@ -0,0 +1,34 @@
1
+ import { LogBus, type LogRecord, type Unsubscribe } from '@salesforce/agentic-common';
2
+ import type { TelemetryEvent, TelemetryEventCallback } from '../types/telemetry-events.js';
3
+ /**
4
+ * Composition helper used by `AgentHarness` implementations to own telemetry and log buses.
5
+ *
6
+ * Harnesses instantiate one of these as a private field and delegate `onTelemetry()` / `onLog()` to it; they
7
+ * then emit events by calling the owner's `emitTelemetry()` / `logDebug()` / etc. Dispose clears both buses;
8
+ * further calls throw `AgentSDKError('DISPOSED')`.
9
+ *
10
+ * Exported from the public `index.ts` so third-party `AgentHarness` implementations in sibling packages
11
+ * can reuse it.
12
+ */
13
+ export declare class HarnessBusOwner {
14
+ private readonly telemetryBus;
15
+ private readonly logBus;
16
+ private disposed;
17
+ /**
18
+ * Returns the log bus so harness implementations can hand it to pure helpers (e.g. message
19
+ * mappers / event adapters) that need to emit structured logs. Returns `undefined` after
20
+ * `dispose()` so callers in late-shutdown paths (e.g. teardown races) can fall through to a
21
+ * no-op rather than catching `DISPOSED`.
22
+ */
23
+ getLogBus(): LogBus | undefined;
24
+ onTelemetry(callback: TelemetryEventCallback): Unsubscribe;
25
+ onLog(callback: (record: LogRecord) => void): Unsubscribe;
26
+ emitTelemetry(event: TelemetryEvent): void;
27
+ emitLog(record: LogRecord): void;
28
+ logDebug(message: string, context?: Record<string, unknown>): void;
29
+ logInfo(message: string, context?: Record<string, unknown>): void;
30
+ logWarn(message: string, context?: Record<string, unknown>, error?: Error): void;
31
+ logError(message: string, error?: Error, context?: Record<string, unknown>): void;
32
+ dispose(): void;
33
+ private assertNotDisposed;
34
+ }
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ import { EventBus, LogBus } from '@salesforce/agentic-common';
6
+ import { AgentSDKError, AgentSDKErrorType } from '../errors.js';
7
+ /**
8
+ * Composition helper used by `AgentHarness` implementations to own telemetry and log buses.
9
+ *
10
+ * Harnesses instantiate one of these as a private field and delegate `onTelemetry()` / `onLog()` to it; they
11
+ * then emit events by calling the owner's `emitTelemetry()` / `logDebug()` / etc. Dispose clears both buses;
12
+ * further calls throw `AgentSDKError('DISPOSED')`.
13
+ *
14
+ * Exported from the public `index.ts` so third-party `AgentHarness` implementations in sibling packages
15
+ * can reuse it.
16
+ */
17
+ export class HarnessBusOwner {
18
+ telemetryBus = new EventBus();
19
+ logBus = new LogBus();
20
+ disposed = false;
21
+ /**
22
+ * Returns the log bus so harness implementations can hand it to pure helpers (e.g. message
23
+ * mappers / event adapters) that need to emit structured logs. Returns `undefined` after
24
+ * `dispose()` so callers in late-shutdown paths (e.g. teardown races) can fall through to a
25
+ * no-op rather than catching `DISPOSED`.
26
+ */
27
+ getLogBus() {
28
+ if (this.disposed)
29
+ return undefined;
30
+ return this.logBus;
31
+ }
32
+ onTelemetry(callback) {
33
+ this.assertNotDisposed();
34
+ return this.telemetryBus.on(callback);
35
+ }
36
+ onLog(callback) {
37
+ this.assertNotDisposed();
38
+ return this.logBus.on(callback);
39
+ }
40
+ emitTelemetry(event) {
41
+ this.assertNotDisposed();
42
+ this.telemetryBus.emit(event);
43
+ }
44
+ emitLog(record) {
45
+ this.assertNotDisposed();
46
+ this.logBus.emit(record);
47
+ }
48
+ logDebug(message, context) {
49
+ this.assertNotDisposed();
50
+ this.logBus.debug(message, context);
51
+ }
52
+ logInfo(message, context) {
53
+ this.assertNotDisposed();
54
+ this.logBus.info(message, context);
55
+ }
56
+ logWarn(message, context, error) {
57
+ this.assertNotDisposed();
58
+ this.logBus.warn(message, context, error);
59
+ }
60
+ logError(message, error, context) {
61
+ this.assertNotDisposed();
62
+ this.logBus.error(message, error, context);
63
+ }
64
+ dispose() {
65
+ if (this.disposed) {
66
+ return;
67
+ }
68
+ this.telemetryBus.dispose();
69
+ this.logBus.dispose();
70
+ this.disposed = true;
71
+ }
72
+ assertNotDisposed() {
73
+ if (this.disposed) {
74
+ throw new AgentSDKError('Harness buses have been disposed.', AgentSDKErrorType.DISPOSED);
75
+ }
76
+ }
77
+ }
78
+ //# sourceMappingURL=harness-bus-owner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-bus-owner.js","sourceRoot":"","sources":["../../src/harness/harness-bus-owner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAoC,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGhE;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IACP,YAAY,GAAiB,IAAI,QAAQ,EAAkB,CAAC;IAC5D,MAAM,GAAW,IAAI,MAAM,EAAE,CAAC;IACvC,QAAQ,GAAY,KAAK,CAAC;IAElC;;;;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tE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAEO,iBAAiB;QACrB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,aAAa,CAAC,mCAAmC,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAC7F,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,89 @@
1
+ import type { ToolDefinition } from '../types/tools.js';
2
+ import type { MCPConfiguration } from '../mcp-config.js';
3
+ import type { JSONWebToken, ModelName } from '@salesforce/llm-gateway-sdk';
4
+ /**
5
+ * Configuration for an agent's behavior and capabilities.
6
+ * This excludes identity; `agentId` is handled separately.
7
+ */
8
+ export type AgentConfig = {
9
+ /**
10
+ * Optional org alias (or username) to run this agent under.
11
+ *
12
+ * If omitted, the agent resolves auth in this order:
13
+ * - If `projectRoot` is an SFDX project and has a local `target-org` set, use that org.
14
+ * - Otherwise, use the default org configured on the machine.
15
+ */
16
+ orgAlias?: string;
17
+ /** The model to use for this agent. */
18
+ modelId?: ModelName;
19
+ /** Human-readable name for the agent. */
20
+ name?: string;
21
+ /** Description of the agent's purpose. ACP/OASF-ready metadata. */
22
+ description?: string;
23
+ /** System instructions defining the agent's behavior. */
24
+ instructions?: string;
25
+ /** Custom tools available to this agent. */
26
+ tools?: ToolDefinition[];
27
+ /** MCP server connections providing additional tools. */
28
+ mcpServers?: MCPConfiguration;
29
+ /** Filesystem paths to skill directories. Supports paths relative to the project root and absolute paths. */
30
+ skills?: string[];
31
+ };
32
+ /**
33
+ * Harness-facing configuration for creating/updating an agent.
34
+ *
35
+ * This is derived from {@link AgentConfig} but intentionally excludes org resolution concerns
36
+ * (e.g. `orgAlias`) and includes resolved runtime artifacts (`orgJwt`) that the harness needs.
37
+ */
38
+ export type HarnessAgentConfig = Omit<AgentConfig, 'orgAlias'> & {
39
+ /**
40
+ * Self-refreshing JWT for the resolved org. Harness implementations SHOULD pass this
41
+ * to {@link resolveMcpServerHeaders} when mapping remote MCP server configs to their native
42
+ * transport format, so that Salesforce Hosted MCP Servers receive automatic auth injection.
43
+ */
44
+ orgJwt?: JSONWebToken;
45
+ };
46
+ /**
47
+ * Converts a consumer-facing {@link AgentConfig} into a {@link HarnessAgentConfig}
48
+ * ready for the harness layer.
49
+ *
50
+ * Strips `orgAlias` since org resolution is handled above the harness and attaches
51
+ * the resolved `orgJwt` so harness implementations can use {@link resolveMcpServerHeaders}
52
+ * to inject auth for Salesforce Hosted MCP Servers.
53
+ */
54
+ export declare function toHarnessConfig(config: AgentConfig, orgJwt?: JSONWebToken): HarnessAgentConfig;
55
+ /**
56
+ * Per-call options controlling streaming behavior.
57
+ */
58
+ export type StreamOptions = {
59
+ /** Signal to abort the streaming operation. */
60
+ abortSignal?: AbortSignal;
61
+ /**
62
+ * When `true`, the harness requires human approval before executing any
63
+ * native tool (e.g., MCP tools). The stream emits a `tool-approval-request`
64
+ * event and suspends until the consumer calls `approveToolCall()` or
65
+ * `declineToolCall()`.
66
+ *
67
+ * Does not affect consumer-executed tools (those defined via `AgentConfig.tools`
68
+ * without an execute handler) — the consumer already controls execution for
69
+ * those via `submitToolResult()`.
70
+ */
71
+ requireToolApproval?: boolean;
72
+ /**
73
+ * Maximum number of LLM call steps the agent may take per `stream()` invocation.
74
+ * Each step is one LLM call (which may produce text, tool calls, or both).
75
+ *
76
+ * Defaults to {@link DEFAULT_MAX_STEPS} when omitted.
77
+ * Must be at least 1.
78
+ */
79
+ maxSteps?: number;
80
+ };
81
+ /**
82
+ * Default maximum steps for a single agent stream invocation.
83
+ *
84
+ * Set high enough to be effectively unlimited for real tasks — the practical
85
+ * ceiling is the context window and cost, not this counter. This exists only
86
+ * as a safety net against infinite tool-retry loops. Mastra requires a finite
87
+ * value (its internal default is only 5, far too low for agentic workflows).
88
+ */
89
+ export declare const DEFAULT_MAX_STEPS = 1024;
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /**
6
+ * Converts a consumer-facing {@link AgentConfig} into a {@link HarnessAgentConfig}
7
+ * ready for the harness layer.
8
+ *
9
+ * Strips `orgAlias` since org resolution is handled above the harness and attaches
10
+ * the resolved `orgJwt` so harness implementations can use {@link resolveMcpServerHeaders}
11
+ * to inject auth for Salesforce Hosted MCP Servers.
12
+ */
13
+ export function toHarnessConfig(config, orgJwt) {
14
+ const { orgAlias: _, ...rest } = config;
15
+ return { ...rest, orgJwt };
16
+ }
17
+ /**
18
+ * Default maximum steps for a single agent stream invocation.
19
+ *
20
+ * Set high enough to be effectively unlimited for real tasks — the practical
21
+ * ceiling is the context window and cost, not this counter. This exists only
22
+ * as a safety net against infinite tool-retry loops. Mastra requires a finite
23
+ * value (its internal default is only 5, far too low for agentic workflows).
24
+ */
25
+ export const DEFAULT_MAX_STEPS = 1024;
26
+ //# sourceMappingURL=harness-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-config.js","sourceRoot":"","sources":["../../src/harness/harness-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyDH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,MAAmB,EAAE,MAAqB;IACtE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACxC,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC;AA+BD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentHarness } from './agent-harness.js';
2
+ /**
3
+ * Constructs an {@link AgentHarness} on demand.
4
+ *
5
+ * The factory advertises its identity and the SDK-to-harness protocol version
6
+ * it implements so the SDK can reject incompatible harness packages **before**
7
+ * paying the cost of {@link HarnessFactory.create} (which typically opens
8
+ * persistent storage and connects to MCP servers).
9
+ *
10
+ * After the harness is constructed, the SDK additionally verifies that the
11
+ * returned harness reports the same `protocolVersion` as the factory. This
12
+ * guards against a factory that lies about its version or a harness package
13
+ * whose runtime drifts from its packaging metadata.
14
+ */
15
+ export interface HarnessFactory {
16
+ /** Unique identifier for the harness type this factory builds (e.g., `'mastra'`). */
17
+ readonly harnessId: string;
18
+ /** SDK-to-harness protocol version implemented by the harness this factory builds. */
19
+ readonly protocolVersion: number;
20
+ create(storageRootFolder: string): Promise<AgentHarness>;
21
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=harness-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-factory.js","sourceRoot":"","sources":["../../src/harness/harness-factory.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,4 @@
1
+ export type { AgentHarness } from './agent-harness.js';
2
+ export type { HarnessFactory } from './harness-factory.js';
3
+ export type { AgentConfig, StreamOptions } from './harness-config.js';
4
+ export { toHarnessConfig, DEFAULT_MAX_STEPS } from './harness-config.js';
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ export { toHarnessConfig, DEFAULT_MAX_STEPS } from './harness-config.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/harness/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,23 @@
1
+ export type { Message, MessagePart } from './types/messages.js';
2
+ export type { ChatEvent, StartEvent, TextDeltaEvent, ReasoningDeltaEvent, ToolCallEvent, ToolApprovalRequestEvent, ToolResultEvent, StepStartEvent, StepFinishEvent, ErrorEvent, FinishEvent, ChatStreamResult, } from './types/events.js';
3
+ export type { ToolDefinition, ToolCallInfo, ToolResultInfo } from './types/tools.js';
4
+ export type { FinishReason, UsageMetadata } from './types/usage.js';
5
+ export type { AgentConfig, HarnessAgentConfig, StreamOptions } from './harness/harness-config.js';
6
+ export { DEFAULT_MAX_STEPS } from './harness/harness-config.js';
7
+ export type { MCPConfiguration, MCPServerConfig, MCPStdioServerConfig, MCPRemoteServerConfig, McpServerInfo, } from './mcp-config.js';
8
+ export { McpServerStatus } from './mcp-config.js';
9
+ export { ModelName } from '@salesforce/llm-gateway-sdk';
10
+ export { SfApiEnv } from '@salesforce/agentic-common';
11
+ export { AgentManager, createAgentManager } from './agent-manager.js';
12
+ export { type Agent } from './agent.js';
13
+ export { type ChatSession, type ChatOptions } from './chat-session.js';
14
+ export type { AgentConnectivityResolver, ResolvedConnectivity } from './agent-connectivity-resolver.js';
15
+ export type { AgentHarness, HarnessFactory } from './harness/index.js';
16
+ export { SUPPORTED_PROTOCOL_VERSIONS } from './harness/agent-harness.js';
17
+ export { HarnessBusOwner } from './harness/harness-bus-owner.js';
18
+ export { AgentSDKError, AgentSDKErrorType } from './errors.js';
19
+ export type { AgentCreatedEvent, AgentDestroyedEvent, ChatStreamCompletedEvent, ChatStreamErrorEvent, ChatStreamStartedEvent, ChatStreamTrigger, McpServerDiscoveryCompletedEvent, McpServerDiscoveryFailedEvent, McpServerDiscoveryStartedEvent, SessionCreatedEvent, SessionDestroyedEvent, TelemetryEvent, TelemetryEventCallback, ToolApprovalRequestedEvent, ToolApprovalResolvedEvent, ToolExecutionCompletedEvent, ToolExecutionStartedEvent, } from './types/telemetry-events.js';
20
+ export type { LogLevel, LogRecord, Unsubscribe } from '@salesforce/agentic-common';
21
+ export { resolveMcpServerHeaders } from './mcp-auth.js';
22
+ export type { OrgConnection, OrgConnectionFactory } from '@salesforce/agentic-common';
23
+ export { Workspace } from './workspace.js';
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ export { DEFAULT_MAX_STEPS } from './harness/harness-config.js';
6
+ export { McpServerStatus } from './mcp-config.js';
7
+ export { ModelName } from '@salesforce/llm-gateway-sdk';
8
+ export { SfApiEnv } from '@salesforce/agentic-common';
9
+ // ── Agent Layer ─────────────────────────────────────────────────────
10
+ export { AgentManager, createAgentManager } from './agent-manager.js';
11
+ export {} from './agent.js';
12
+ export {} from './chat-session.js';
13
+ export { SUPPORTED_PROTOCOL_VERSIONS } from './harness/agent-harness.js';
14
+ export { HarnessBusOwner } from './harness/harness-bus-owner.js';
15
+ // ── Errors ───────────────────────────────────────────────────────────
16
+ export { AgentSDKError, AgentSDKErrorType } from './errors.js';
17
+ // ── MCP Auth ────────────────────────────────────────────────────────
18
+ export { resolveMcpServerHeaders } from './mcp-auth.js';
19
+ export { Workspace } from './workspace.js';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAQhE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,uEAAuE;AACvE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAc,MAAM,YAAY,CAAC;AACxC,OAAO,EAAsC,MAAM,mBAAmB,CAAC;AAKvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA4B/D,uEAAuE;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAIxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { LogBus } from '@salesforce/agentic-common';
2
+ import type { AgentHarness } from '../harness/agent-harness.js';
3
+ import type { TelemetryBus } from '../types/telemetry-events.js';
4
+ /**
5
+ * A pair of buses (telemetry + log) scoped to a single agent, session, or the unrouted catch-all.
6
+ *
7
+ * `DefaultAgent` and `DefaultChatSession` receive their slice at construction time and wire `forwardTo()`
8
+ * from the slice bus into their own bus so events bubble upward through the hierarchy.
9
+ */
10
+ export type TelemetrySlice = {
11
+ readonly telemetry: TelemetryBus;
12
+ readonly log: LogBus;
13
+ };
14
+ /**
15
+ * Splits a single harness's telemetry and log streams into per-agent, per-session, and unrouted sub-streams.
16
+ *
17
+ * The router is the only component that subscribes directly to the harness's buses. It examines each event's
18
+ * routing fields (`agentId` / `threadId` for telemetry; `context.agentId` / `context.threadId` for logs) and
19
+ * emits onto the corresponding slice bus. `DefaultAgent` / `DefaultChatSession` subscribe to their slice via
20
+ * `forwardTo()` — there is no downward dispatch from the Manager back into children.
21
+ *
22
+ * The router and its slices are internal to this package; consumers subscribe via the public
23
+ * `onTelemetry()` / `onLog()` methods on `AgentManager` / `Agent` / `ChatSession`.
24
+ */
25
+ export declare class TelemetryRouter {
26
+ private readonly agentSlices;
27
+ private readonly sessionSlices;
28
+ private readonly unroutedSlice;
29
+ private readonly harnessUnsubs;
30
+ private disposed;
31
+ constructor(harness: Pick<AgentHarness, 'onTelemetry' | 'onLog'>);
32
+ get unrouted(): TelemetrySlice;
33
+ registerAgent(agentId: string): TelemetrySlice;
34
+ unregisterAgent(agentId: string): void;
35
+ registerSession(threadId: string): TelemetrySlice;
36
+ unregisterSession(threadId: string): void;
37
+ dispose(): void;
38
+ private routeTelemetry;
39
+ private routeLog;
40
+ private static createSlice;
41
+ }
@@ -0,0 +1,128 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ import { EventBus, LogBus } from '@salesforce/agentic-common';
6
+ /**
7
+ * Splits a single harness's telemetry and log streams into per-agent, per-session, and unrouted sub-streams.
8
+ *
9
+ * The router is the only component that subscribes directly to the harness's buses. It examines each event's
10
+ * routing fields (`agentId` / `threadId` for telemetry; `context.agentId` / `context.threadId` for logs) and
11
+ * emits onto the corresponding slice bus. `DefaultAgent` / `DefaultChatSession` subscribe to their slice via
12
+ * `forwardTo()` — there is no downward dispatch from the Manager back into children.
13
+ *
14
+ * The router and its slices are internal to this package; consumers subscribe via the public
15
+ * `onTelemetry()` / `onLog()` methods on `AgentManager` / `Agent` / `ChatSession`.
16
+ */
17
+ export class TelemetryRouter {
18
+ agentSlices = new Map();
19
+ sessionSlices = new Map();
20
+ unroutedSlice;
21
+ harnessUnsubs = [];
22
+ disposed = false;
23
+ constructor(harness) {
24
+ this.unroutedSlice = TelemetryRouter.createSlice();
25
+ this.harnessUnsubs.push(harness.onTelemetry((event) => this.routeTelemetry(event)));
26
+ this.harnessUnsubs.push(harness.onLog((record) => this.routeLog(record)));
27
+ }
28
+ get unrouted() {
29
+ return this.unroutedSlice;
30
+ }
31
+ registerAgent(agentId) {
32
+ let slice = this.agentSlices.get(agentId);
33
+ if (!slice) {
34
+ slice = TelemetryRouter.createSlice();
35
+ this.agentSlices.set(agentId, slice);
36
+ }
37
+ return slice;
38
+ }
39
+ unregisterAgent(agentId) {
40
+ const slice = this.agentSlices.get(agentId);
41
+ if (slice) {
42
+ slice.telemetry.dispose();
43
+ slice.log.dispose();
44
+ this.agentSlices.delete(agentId);
45
+ }
46
+ }
47
+ registerSession(threadId) {
48
+ let slice = this.sessionSlices.get(threadId);
49
+ if (!slice) {
50
+ slice = TelemetryRouter.createSlice();
51
+ this.sessionSlices.set(threadId, slice);
52
+ }
53
+ return slice;
54
+ }
55
+ unregisterSession(threadId) {
56
+ const slice = this.sessionSlices.get(threadId);
57
+ if (slice) {
58
+ slice.telemetry.dispose();
59
+ slice.log.dispose();
60
+ this.sessionSlices.delete(threadId);
61
+ }
62
+ }
63
+ dispose() {
64
+ if (this.disposed) {
65
+ return;
66
+ }
67
+ for (const unsub of this.harnessUnsubs) {
68
+ unsub();
69
+ }
70
+ this.harnessUnsubs.length = 0;
71
+ for (const slice of this.agentSlices.values()) {
72
+ slice.telemetry.dispose();
73
+ slice.log.dispose();
74
+ }
75
+ this.agentSlices.clear();
76
+ for (const slice of this.sessionSlices.values()) {
77
+ slice.telemetry.dispose();
78
+ slice.log.dispose();
79
+ }
80
+ this.sessionSlices.clear();
81
+ this.unroutedSlice.telemetry.dispose();
82
+ this.unroutedSlice.log.dispose();
83
+ this.disposed = true;
84
+ }
85
+ routeTelemetry(event) {
86
+ const threadId = 'threadId' in event ? event.threadId : undefined;
87
+ if (threadId !== undefined) {
88
+ const sessionSlice = this.sessionSlices.get(threadId);
89
+ if (sessionSlice) {
90
+ sessionSlice.telemetry.emit(event);
91
+ return;
92
+ }
93
+ }
94
+ const agentSlice = this.agentSlices.get(event.agentId);
95
+ if (agentSlice) {
96
+ agentSlice.telemetry.emit(event);
97
+ return;
98
+ }
99
+ this.unroutedSlice.telemetry.emit(event);
100
+ }
101
+ routeLog(record) {
102
+ const context = record.context;
103
+ const threadId = typeof context?.['threadId'] === 'string' ? context['threadId'] : undefined;
104
+ if (threadId !== undefined) {
105
+ const sessionSlice = this.sessionSlices.get(threadId);
106
+ if (sessionSlice) {
107
+ sessionSlice.log.emit(record);
108
+ return;
109
+ }
110
+ }
111
+ const agentId = typeof context?.['agentId'] === 'string' ? context['agentId'] : undefined;
112
+ if (agentId !== undefined) {
113
+ const agentSlice = this.agentSlices.get(agentId);
114
+ if (agentSlice) {
115
+ agentSlice.log.emit(record);
116
+ return;
117
+ }
118
+ }
119
+ this.unroutedSlice.log.emit(record);
120
+ }
121
+ static createSlice() {
122
+ return {
123
+ telemetry: new EventBus(),
124
+ log: new LogBus(),
125
+ };
126
+ }
127
+ }
128
+ //# sourceMappingURL=telemetry-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-router.js","sourceRoot":"","sources":["../../src/internal/telemetry-router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAoC,MAAM,4BAA4B,CAAC;AAehG;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IACP,WAAW,GAAgC,IAAI,GAAG,EAAE,CAAC;IACrD,aAAa,GAAgC,IAAI,GAAG,EAAE,CAAC;IACvD,aAAa,CAAiB;IAC9B,aAAa,GAAkB,EAAE,CAAC;IAC3C,QAAQ,GAAY,KAAK,CAAC;IAElC,YAAY,OAAoD;QAC5D,IAAI,CAAC,aAAa,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,OAAe;QACzB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IACxC,CAAC;IAEO,MAAM,CAAC,WAAW;QACtB,OAAO;YACH,SAAS,EAAE,IAAI,QAAQ,EAAkB;YACzC,GAAG,EAAE,IAAI,MAAM,EAAE;SACpB,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,20 @@
1
+ import type { JSONWebToken } from '@salesforce/llm-gateway-sdk';
2
+ /**
3
+ * Returns true if the URL matches a Salesforce Hosted MCP Server endpoint.
4
+ * Covers all environments (prod, dev, test, perf, stage) and all API versions
5
+ * (beta: v1-beta.2, GA: v1, future versions).
6
+ */
7
+ export declare function isSalesforcePlatformMcpUrl(url: string | URL): boolean;
8
+ /**
9
+ * Resolves the final headers for an MCP server request.
10
+ *
11
+ * For Salesforce Hosted MCP Server URLs, injects an `Authorization: Bearer <token>`
12
+ * header (via `orgJwt.getValue()`) when no explicit Authorization header already exists.
13
+ * For all other URLs the headers are returned unmodified.
14
+ *
15
+ * @param url - The MCP server URL.
16
+ * @param orgJwt - The org's self-refreshing JWT (from HarnessAgentConfig.orgJwt).
17
+ * @param headers - Existing headers configured on the server.
18
+ * @returns The resolved headers — original headers plus any injected auth.
19
+ */
20
+ export declare function resolveMcpServerHeaders(url: string | URL, orgJwt: JSONWebToken | undefined, headers?: Record<string, string>): Promise<Record<string, string>>;
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ const SALESFORCE_PLATFORM_MCP_URL_REGEX = /^https:\/\/((dev|test|perf|stage)\.)?api\.salesforce\.com\/platform\/mcp\//;
6
+ /**
7
+ * Returns true if the URL matches a Salesforce Hosted MCP Server endpoint.
8
+ * Covers all environments (prod, dev, test, perf, stage) and all API versions
9
+ * (beta: v1-beta.2, GA: v1, future versions).
10
+ */
11
+ export function isSalesforcePlatformMcpUrl(url) {
12
+ const urlString = url instanceof URL ? url.toString() : url;
13
+ return SALESFORCE_PLATFORM_MCP_URL_REGEX.test(urlString);
14
+ }
15
+ /**
16
+ * Resolves the final headers for an MCP server request.
17
+ *
18
+ * For Salesforce Hosted MCP Server URLs, injects an `Authorization: Bearer <token>`
19
+ * header (via `orgJwt.getValue()`) when no explicit Authorization header already exists.
20
+ * For all other URLs the headers are returned unmodified.
21
+ *
22
+ * @param url - The MCP server URL.
23
+ * @param orgJwt - The org's self-refreshing JWT (from HarnessAgentConfig.orgJwt).
24
+ * @param headers - Existing headers configured on the server.
25
+ * @returns The resolved headers — original headers plus any injected auth.
26
+ */
27
+ export async function resolveMcpServerHeaders(url, orgJwt, headers = {}) {
28
+ if (!orgJwt)
29
+ return headers;
30
+ if (!isSalesforcePlatformMcpUrl(url))
31
+ return headers;
32
+ if (hasAuthorizationHeader(headers))
33
+ return headers;
34
+ const token = await orgJwt.getValue();
35
+ return { ...headers, Authorization: `Bearer ${token}` };
36
+ }
37
+ function hasAuthorizationHeader(headers) {
38
+ return Object.keys(headers).some((key) => key.toLowerCase() === 'authorization');
39
+ }
40
+ //# sourceMappingURL=mcp-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-auth.js","sourceRoot":"","sources":["../src/mcp-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,iCAAiC,GAAG,4EAA4E,CAAC;AAEvH;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAiB;IACxD,MAAM,SAAS,GAAG,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5D,OAAO,iCAAiC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CACzC,GAAiB,EACjB,MAAgC,EAChC,UAAkC,EAAE;IAEpC,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACrD,IAAI,sBAAsB,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAEpD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACtC,OAAO,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,sBAAsB,CAAC,OAA+B;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Configuration for MCP (Model Context Protocol) servers attached to an agent.
3
+ * Each server is identified by a unique name key.
4
+ */
5
+ export type MCPConfiguration = Record<string, MCPServerConfig>;
6
+ /**
7
+ * Configuration for a single MCP server.
8
+ * Discriminated union by `type`: either a local stdio process or a remote HTTP/SSE endpoint.
9
+ *
10
+ * Borrowed from the OpenCode SDK's `McpLocalConfig` / `McpRemoteConfig` pattern.
11
+ */
12
+ export type MCPServerConfig = MCPStdioServerConfig | MCPRemoteServerConfig;
13
+ /** MCP server launched as a local subprocess communicating over stdio. */
14
+ export type MCPStdioServerConfig = {
15
+ type: 'stdio';
16
+ /** Command to launch the MCP server process. */
17
+ command: string;
18
+ /** Arguments passed to the command. */
19
+ args?: string[];
20
+ /** Environment variables set when running the server process. */
21
+ env?: Record<string, string>;
22
+ /** Whether this server is enabled. Defaults to `true`. */
23
+ enabled?: boolean;
24
+ /** Timeout in milliseconds for connecting to the server. */
25
+ timeout?: number;
26
+ };
27
+ /** MCP server accessible over HTTP/SSE at a remote URL. */
28
+ export type MCPRemoteServerConfig = {
29
+ type: 'remote';
30
+ /** URL of the remote MCP server endpoint. */
31
+ url: string | URL;
32
+ /** HTTP headers sent with requests to the server. */
33
+ headers?: Record<string, string>;
34
+ /** Whether this server is enabled. Defaults to `true`. */
35
+ enabled?: boolean;
36
+ /** Timeout in milliseconds for connecting to the server. */
37
+ timeout?: number;
38
+ };
39
+ /** Connection status of a single MCP server. */
40
+ export declare enum McpServerStatus {
41
+ Connected = "connected",
42
+ Connecting = "connecting",
43
+ Disabled = "disabled",
44
+ Error = "error"
45
+ }
46
+ /** Runtime status of a configured MCP server, including its discovered tools. */
47
+ export type McpServerInfo = {
48
+ name: string;
49
+ status: McpServerStatus;
50
+ tools: string[];
51
+ error?: string;
52
+ };
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ /** Connection status of a single MCP server. */
6
+ export var McpServerStatus;
7
+ (function (McpServerStatus) {
8
+ McpServerStatus["Connected"] = "connected";
9
+ McpServerStatus["Connecting"] = "connecting";
10
+ McpServerStatus["Disabled"] = "disabled";
11
+ McpServerStatus["Error"] = "error";
12
+ })(McpServerStatus || (McpServerStatus = {}));
13
+ //# sourceMappingURL=mcp-config.js.map