@fluidframework/tree-agent 2.70.0-360374 → 2.70.0-360753
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/api-report/tree-agent.alpha.api.md +20 -3
- package/dist/agent.d.ts +30 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +52 -33
- package/dist/agent.js.map +1 -1
- package/dist/alpha.d.ts +5 -0
- package/dist/api.d.ts +24 -17
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/lib/agent.d.ts +30 -1
- package/lib/agent.d.ts.map +1 -1
- package/lib/agent.js +49 -32
- package/lib/agent.js.map +1 -1
- package/lib/alpha.d.ts +5 -0
- package/lib/api.d.ts +24 -17
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +10 -12
- package/src/agent.ts +88 -41
- package/src/api.ts +33 -24
- package/src/index.ts +8 -1
package/src/api.ts
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { ImplicitFieldSchema, TreeNode } from "@fluidframework/tree";
|
|
7
|
-
//
|
|
7
|
+
// These are used for doc links
|
|
8
8
|
import type { FactoryContentObject, ReadableField } from "@fluidframework/tree/alpha";
|
|
9
9
|
|
|
10
|
+
// This is used for doc links
|
|
11
|
+
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
12
|
+
import type { bindEditor, defaultEditor } from "./agent.js";
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Logger interface for logging events from a {@link SharedTreeSemanticAgent}.
|
|
12
16
|
* @alpha
|
|
@@ -18,6 +22,26 @@ export interface Logger {
|
|
|
18
22
|
log(message: string): void;
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A synchronous function that executes a string of JavaScript code to perform an edit within a {@link SharedTreeSemanticAgent}.
|
|
27
|
+
* @param context - An object that must be provided to the generated code as a variable named "context" in its top-level scope.
|
|
28
|
+
* @param code - The JavaScript code that should be executed.
|
|
29
|
+
* @remarks To simulate the execution of an editor outside of an {@link SharedTreeSemanticAgent | agent}, you can use {@link bindEditor | bindEditor} to bind an editor to a specific subtree.
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export type SynchronousEditor = (context: Record<string, unknown>, code: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* An asynchronous function that executes a string of JavaScript code to perform an edit within a {@link SharedTreeSemanticAgent}.
|
|
35
|
+
* @param context - An object that must be provided to the generated code as a variable named "context" in its top-level scope.
|
|
36
|
+
* @param code - The JavaScript code that should be executed.
|
|
37
|
+
* @remarks To simulate the execution of an editor outside of an {@link SharedTreeSemanticAgent | agent}, you can use {@link bindEditor | bindEditor} to bind an editor to a specific subtree.
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
export type AsynchronousEditor = (
|
|
41
|
+
context: Record<string, unknown>,
|
|
42
|
+
code: string,
|
|
43
|
+
) => Promise<void>;
|
|
44
|
+
|
|
21
45
|
/**
|
|
22
46
|
* Options used to parameterize the creation of a {@link SharedTreeSemanticAgent}.
|
|
23
47
|
* @alpha
|
|
@@ -28,22 +52,14 @@ export interface SemanticAgentOptions {
|
|
|
28
52
|
*/
|
|
29
53
|
domainHints?: string;
|
|
30
54
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* @
|
|
34
|
-
* @throws If the code is invalid, this function should throw an error with a human-readable message describing why it is invalid.
|
|
35
|
-
*/
|
|
36
|
-
validateEdit?: (code: string) => void | Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Evaluates/runs any generated JavaScript created by the {@link SharedTreeChatModel.editToolName | model's editing tool}.
|
|
39
|
-
* @remarks This happens only after the code has been successfully validated by the optional {@link SemanticAgentOptions.validateEdit | validateEdit} function.
|
|
40
|
-
* @param context - An object that must be provided to the generated code as a variable named "context" in its top-level scope.
|
|
41
|
-
* @param code - The generated JavaScript code as a string.
|
|
42
|
-
* @throws If an error is thrown while executing the code, it will be caught and the message will be forwarded to the model for debugging.
|
|
43
|
-
* @remarks If this function is not provided, the generated code will be executed using a simple `eval` call, which may not provide sufficient security guarantees for some environments.
|
|
55
|
+
* Executes any generated JavaScript created by the {@link SharedTreeChatModel.editToolName | model's editing tool}.
|
|
56
|
+
* @remarks If an error is thrown while executing the code, it will be caught and the message will be forwarded to the {@link SharedTreeChatModel | model} for debugging.
|
|
57
|
+
* @remarks If this function is not provided, the generated code will be executed using a {@link defaultEditor | simple default} which may not provide sufficient security guarantees for some environments.
|
|
44
58
|
* Use a library such as SES to provide a more secure implementation - see `@fluidframework/tree-agent-ses` for a drop-in implementation.
|
|
59
|
+
*
|
|
60
|
+
* To simulate the execution of an editor outside of an {@link SharedTreeSemanticAgent | agent}, you can use {@link bindEditor | bindEditor} to bind an editor to a specific subtree.
|
|
45
61
|
*/
|
|
46
|
-
|
|
62
|
+
editor?: SynchronousEditor | AsynchronousEditor;
|
|
47
63
|
/**
|
|
48
64
|
* The maximum number of sequential edits the LLM can make before we assume it's stuck in a loop.
|
|
49
65
|
*/
|
|
@@ -64,18 +80,11 @@ export interface EditResult {
|
|
|
64
80
|
* @remarks
|
|
65
81
|
* - `success`: The edit was successfully applied.
|
|
66
82
|
* - `disabledError`: The model is not allowed to edit the tree (i.e. {@link SharedTreeChatModel.editToolName} was not provided).
|
|
67
|
-
* - `
|
|
68
|
-
* - `executionError`: An error was thrown while parsing or executing the provided JavaScript.
|
|
83
|
+
* - `editingError`: An error was thrown while parsing or executing the provided JavaScript.
|
|
69
84
|
* - `tooManyEditsError`: The {@link SharedTreeChatQuery.edit} function has been called more than the number of times specified by {@link SemanticAgentOptions.maximumSequentialEdits} for the same message.
|
|
70
85
|
* - `expiredError`: The {@link SharedTreeChatQuery.edit} function was called after the issuing query has already completed.
|
|
71
86
|
*/
|
|
72
|
-
type:
|
|
73
|
-
| "success"
|
|
74
|
-
| "disabledError"
|
|
75
|
-
| "validationError"
|
|
76
|
-
| "executionError"
|
|
77
|
-
| "tooManyEditsError"
|
|
78
|
-
| "expiredError";
|
|
87
|
+
type: "success" | "disabledError" | "editingError" | "tooManyEditsError" | "expiredError";
|
|
79
88
|
|
|
80
89
|
/**
|
|
81
90
|
* A human-readable message describing the result of the edit attempt.
|
package/src/index.ts
CHANGED
|
@@ -9,13 +9,20 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
SharedTreeSemanticAgent,
|
|
14
|
+
bindEditor,
|
|
15
|
+
bindEditorImpl,
|
|
16
|
+
defaultEditor,
|
|
17
|
+
} from "./agent.js";
|
|
13
18
|
export type {
|
|
14
19
|
EditResult,
|
|
15
20
|
SharedTreeChatModel,
|
|
16
21
|
SharedTreeChatQuery,
|
|
17
22
|
Logger,
|
|
18
23
|
SemanticAgentOptions,
|
|
24
|
+
SynchronousEditor,
|
|
25
|
+
AsynchronousEditor,
|
|
19
26
|
} from "./api.js";
|
|
20
27
|
export { type TreeView, llmDefault } from "./utils.js";
|
|
21
28
|
export {
|