@salesforce/agents 0.17.1 → 0.17.2
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.
- package/lib/agentTrace.d.ts +23 -0
- package/lib/agentTrace.js +38 -0
- package/lib/agentTrace.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +69 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { type AgentTraceResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A service for retrieving agent execution traces. Provides detailed information
|
|
5
|
+
* about agent plan execution including steps, timing, and safety scores.
|
|
6
|
+
*
|
|
7
|
+
* **Examples**
|
|
8
|
+
*
|
|
9
|
+
* Get trace data for a specific trace ID:
|
|
10
|
+
*
|
|
11
|
+
* `const traceData = await AgentTrace.getTrace(connection, '12-23-34');`
|
|
12
|
+
*/
|
|
13
|
+
export declare class AgentTrace {
|
|
14
|
+
/**
|
|
15
|
+
* Get the trace data for a given trace ID.
|
|
16
|
+
*
|
|
17
|
+
* @param connection The connection to use for making the API request
|
|
18
|
+
* @param traceId The trace ID to retrieve trace data for
|
|
19
|
+
* @returns Promise that resolves with the trace data response containing actions and their execution details
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
static getTrace(connection: Connection, traceId: string): Promise<AgentTraceResponse>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AgentTrace = void 0;
|
|
10
|
+
const maybe_mock_1 = require("./maybe-mock");
|
|
11
|
+
/**
|
|
12
|
+
* A service for retrieving agent execution traces. Provides detailed information
|
|
13
|
+
* about agent plan execution including steps, timing, and safety scores.
|
|
14
|
+
*
|
|
15
|
+
* **Examples**
|
|
16
|
+
*
|
|
17
|
+
* Get trace data for a specific trace ID:
|
|
18
|
+
*
|
|
19
|
+
* `const traceData = await AgentTrace.getTrace(connection, '12-23-34');`
|
|
20
|
+
*/
|
|
21
|
+
class AgentTrace {
|
|
22
|
+
/**
|
|
23
|
+
* Get the trace data for a given trace ID.
|
|
24
|
+
*
|
|
25
|
+
* @param connection The connection to use for making the API request
|
|
26
|
+
* @param traceId The trace ID to retrieve trace data for
|
|
27
|
+
* @returns Promise that resolves with the trace data response containing actions and their execution details
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
static async getTrace(connection, traceId) {
|
|
31
|
+
const maybeMock = new maybe_mock_1.MaybeMock(connection);
|
|
32
|
+
// TODO: who knows what the real endpoint will be, or if the return type is 100% accurate
|
|
33
|
+
const url = `/api/trace/${traceId}`;
|
|
34
|
+
return maybeMock.request('GET', url);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AgentTrace = AgentTrace;
|
|
38
|
+
//# sourceMappingURL=agentTrace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTrace.js","sourceRoot":"","sources":["../src/agentTrace.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAyC;AAGzC;;;;;;;;;GASG;AACH,MAAa,UAAU;IACrB;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAsB,EAAE,OAAe;QAClE,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,UAAU,CAAC,CAAC;QAC5C,yFAAyF;QACzF,MAAM,GAAG,GAAG,cAAc,OAAO,EAAE,CAAC;QAEpC,OAAO,SAAS,CAAC,OAAO,CAAqB,KAAK,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF;AAhBD,gCAgBC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type BotMetadata, type BotVersionMetadata, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, } from './types';
|
|
1
|
+
export { type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig, type AgentOptions, type AgentTone, type AgentType, type AgentPreviewMessageLinks, type AgentPreviewMessage, type AgentPreviewStartResponse, type AgentPreviewSendResponse, type AgentPreviewEndResponse, type AgentTraceResponse, type AgentTraceStep, type BotMetadata, type BotVersionMetadata, type DraftAgentTopics, type DraftAgentTopicsBody, type DraftAgentTopicsResponse, type AvailableDefinition, type AgentTestResultsResponse, type AgentTestStartResponse, type AgentTestStatusResponse, type TestCaseResult, type TestStatus, } from './types';
|
|
2
2
|
export { metric } from './utils';
|
|
3
3
|
export { Agent, AgentCreateLifecycleStages } from './agent';
|
|
4
4
|
export { AgentTester } from './agentTester';
|
|
5
5
|
export { AgentTest, AgentTestCreateLifecycleStages } from './agentTest';
|
|
6
|
+
export { AgentTrace } from './agentTrace';
|
|
6
7
|
export { convertTestResultsToFormat, humanFriendlyName } from './agentTestResults';
|
|
7
8
|
export { AgentPreview } from './agentPreview';
|
|
8
9
|
export { writeDebugLog } from './apexUtils';
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.writeDebugLog = exports.AgentPreview = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.metric = void 0;
|
|
9
|
+
exports.writeDebugLog = exports.AgentPreview = exports.humanFriendlyName = exports.convertTestResultsToFormat = exports.AgentTrace = exports.AgentTestCreateLifecycleStages = exports.AgentTest = exports.AgentTester = exports.AgentCreateLifecycleStages = exports.Agent = exports.metric = void 0;
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
Object.defineProperty(exports, "metric", { enumerable: true, get: function () { return utils_1.metric; } });
|
|
12
12
|
var agent_1 = require("./agent");
|
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "AgentTester", { enumerable: true, get: function
|
|
|
17
17
|
var agentTest_1 = require("./agentTest");
|
|
18
18
|
Object.defineProperty(exports, "AgentTest", { enumerable: true, get: function () { return agentTest_1.AgentTest; } });
|
|
19
19
|
Object.defineProperty(exports, "AgentTestCreateLifecycleStages", { enumerable: true, get: function () { return agentTest_1.AgentTestCreateLifecycleStages; } });
|
|
20
|
+
var agentTrace_1 = require("./agentTrace");
|
|
21
|
+
Object.defineProperty(exports, "AgentTrace", { enumerable: true, get: function () { return agentTrace_1.AgentTrace; } });
|
|
20
22
|
var agentTestResults_1 = require("./agentTestResults");
|
|
21
23
|
Object.defineProperty(exports, "convertTestResultsToFormat", { enumerable: true, get: function () { return agentTestResults_1.convertTestResultsToFormat; } });
|
|
22
24
|
Object.defineProperty(exports, "humanFriendlyName", { enumerable: true, get: function () { return agentTestResults_1.humanFriendlyName; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA6BH,iCAAiC;AAAxB,+FAAA,MAAM,OAAA;AACf,iCAA4D;AAAnD,8FAAA,KAAK,OAAA;AAAE,mHAAA,0BAA0B,OAAA;AAC1C,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwE;AAA/D,sGAAA,SAAS,OAAA;AAAE,2HAAA,8BAA8B,OAAA;AAClD,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uDAAmF;AAA1E,8HAAA,0BAA0B,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AACtD,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA"}
|
package/lib/types.d.ts
CHANGED
|
@@ -458,4 +458,73 @@ export type AgentPreviewEndResponse = {
|
|
|
458
458
|
_links: AgentPreviewMessageLinks;
|
|
459
459
|
};
|
|
460
460
|
export type EndReason = 'UserRequest' | 'Transfer' | 'Expiration' | 'Error' | 'Other';
|
|
461
|
+
export type AgentTraceStep = UserInputStep | LLMExecutionStep | UpdateTopicStep | EventStep | ReasoningStep | PlannerResponseStep;
|
|
462
|
+
export type UserInputStep = {
|
|
463
|
+
type: 'UserInputStep';
|
|
464
|
+
message: string;
|
|
465
|
+
};
|
|
466
|
+
export type LLMExecutionStep = {
|
|
467
|
+
type: 'LLMExecutionStep';
|
|
468
|
+
promptName: string;
|
|
469
|
+
promptContent: string;
|
|
470
|
+
promptResponse: string;
|
|
471
|
+
executionLatency: number;
|
|
472
|
+
startExecutionTime: number;
|
|
473
|
+
endExecutionTime: number;
|
|
474
|
+
};
|
|
475
|
+
export type UpdateTopicStep = {
|
|
476
|
+
type: 'UpdateTopicStep';
|
|
477
|
+
topic: string;
|
|
478
|
+
description: string;
|
|
479
|
+
job: string;
|
|
480
|
+
instructions: string[];
|
|
481
|
+
availableFunctions: unknown[];
|
|
482
|
+
};
|
|
483
|
+
export type EventStep = {
|
|
484
|
+
type: 'EventStep';
|
|
485
|
+
eventName: string;
|
|
486
|
+
isError: boolean;
|
|
487
|
+
payload: {
|
|
488
|
+
oldTopic: string;
|
|
489
|
+
newTopic: string;
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
export type ReasoningStep = {
|
|
493
|
+
type: 'ReasoningStep';
|
|
494
|
+
reason: string;
|
|
495
|
+
};
|
|
496
|
+
export type PlannerResponseStep = {
|
|
497
|
+
type: 'PlannerResponseStep';
|
|
498
|
+
message: string;
|
|
499
|
+
responseType: string;
|
|
500
|
+
isContentSafe: boolean;
|
|
501
|
+
safetyScore: {
|
|
502
|
+
safety_score: number;
|
|
503
|
+
category_scores: {
|
|
504
|
+
toxicity: number;
|
|
505
|
+
hate: number;
|
|
506
|
+
identity: number;
|
|
507
|
+
violence: number;
|
|
508
|
+
physical: number;
|
|
509
|
+
sexual: number;
|
|
510
|
+
profanity: number;
|
|
511
|
+
biased: number;
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
export type AgentTraceResponse = {
|
|
516
|
+
actions: Array<{
|
|
517
|
+
id: string;
|
|
518
|
+
state: string;
|
|
519
|
+
returnValue: {
|
|
520
|
+
type: string;
|
|
521
|
+
planId: string;
|
|
522
|
+
sessionId: string;
|
|
523
|
+
intent: string;
|
|
524
|
+
topic: string;
|
|
525
|
+
plan: AgentTraceStep[];
|
|
526
|
+
};
|
|
527
|
+
error: unknown[];
|
|
528
|
+
}>;
|
|
529
|
+
};
|
|
461
530
|
export {};
|