@fluidframework/tree-agent Package
A library for creating AI agents to interact with a https://fluidframework.com/docs/data-structures/tree/.
Interfaces
| Interface | Alerts | Description |
|---|---|---|
| Context | Alpha | The context object available to generated code when editing a tree. |
| EditResult | Alpha | A result from an edit attempt via the edit(js) function. |
| ExposedMethods | Alpha | An interface for exposing methods of schema classes to an agent. |
| ExposedProperties | Alpha | An interface for exposing properties of schema classes to an agent. |
| FunctionDef | Alpha | A function definition interface that describes the structure of a function. |
| IExposedMethods | Alpha | An interface that SharedTree schema classes should implement to expose their methods to the LLM. |
| IExposedProperties | Alpha | An interface that SharedTree schema classes should implement to expose their properties to the LLM. |
| Logger | Alpha | Logger interface for logging events from a SharedTreeSemanticAgent. |
| SemanticAgentOptions | Alpha | Options used to parameterize the creation of a SharedTreeSemanticAgent. |
| SharedTreeChatModel | Alpha | A plugin interface that handles queries from a SharedTreeSemanticAgent. |
| SharedTreeChatQuery | Alpha | A query from a user to a SharedTreeSemanticAgent. |
| TypeFactoryArray | Alpha | Represents an array type in the type factory system. |
| TypeFactoryBoolean | Alpha | Represents a boolean type in the type factory system. |
| TypeFactoryDate | Alpha | Represents a Date type in the type factory system. |
| TypeFactoryFunction | Alpha | Represents a function type in the type factory system. |
| TypeFactoryInstanceOf | Alpha | Represents an instanceof type that references a SharedTree schema class in the type factory system. |
| TypeFactoryIntersection | Alpha | Represents an intersection type in the type factory system. |
| TypeFactoryLiteral | Alpha | Represents a literal type (specific string, number, or boolean value) in the type factory system. |
| TypeFactoryMap | Alpha | Represents a Map type in the type factory system. |
| TypeFactoryNull | Alpha | Represents a null type in the type factory system. |
| TypeFactoryNumber | Alpha | Represents a number type in the type factory system. |
| TypeFactoryObject | Alpha | Represents an object type with a fixed shape in the type factory system. |
| TypeFactoryOptional | Alpha | Represents an optional type modifier in the type factory system. |
| TypeFactoryPromise | Alpha | Represents a Promise type in the type factory system. |
| TypeFactoryReadonly | Alpha | Represents a readonly type modifier in the type factory system. |
| TypeFactoryRecord | Alpha | Represents a record type (index signature) in the type factory system. |
| TypeFactoryString | Alpha | Represents a string type in the type factory system. |
| TypeFactoryTuple | Alpha | Represents a tuple type with fixed-length items and optional rest elements in the type factory system. |
| TypeFactoryType | Alpha | Base interface for type factory types. |
| TypeFactoryUndefined | Alpha | Represents an undefined type in the type factory system. |
| TypeFactoryUnion | Alpha | Represents a union type in the type factory system. |
| TypeFactoryUnknown | Alpha | Represents an unknown type in the type factory system. |
| TypeFactoryVoid | Alpha | Represents a void type in the type factory system. |
Classes
| Class | Alerts | Modifiers | Description |
|---|---|---|---|
| PropertyDef | Alpha | A property definition class that describes the structure of the property | |
| SharedTreeSemanticAgent | Alpha | sealed | An agent that uses a SharedTreeChatModel to interact with a SharedTree. |
Types
| TypeAlias | Alerts | Description |
|---|---|---|
| Arg | Alpha | A type that represents a function argument. |
| ArgsTuple | Alpha | A utility type that extracts the argument types from a function definition. |
| AsynchronousEditor | Alpha | An asynchronous function that executes a string of JavaScript code to perform an edit within a SharedTreeSemanticAgent. |
| BindableSchema | Alpha | A type that represents an object schema class. |
| Ctor | Alpha | A type that represents a constructor function. |
| MethodKeys | Alpha | A utility type that extracts the method keys from a given type. |
| SynchronousEditor | Alpha | A synchronous function that executes a string of JavaScript code to perform an edit within a SharedTreeSemanticAgent. |
| TreeView | Alpha | A SharedTree view for use by a SharedTreeSemanticAgent. |
| TypeFactoryFunctionParameter | Alpha | Represents a function parameter as a tuple of [name, type]. |
| TypeFactoryTypeKind | Alpha | Type kinds for the type factory type system. |
| ViewOrTree | Alpha | A value that is either a TreeView or a subtree within a TreeView. |
Functions
| Function | Alerts | Return Type | Description |
|---|---|---|---|
| buildFunc(def, args) | Alpha | FunctionDef<Args, Return, Rest> | A utility function to build a function definition. |
| createContext(tree) | Alpha | Context<TSchema> | Creates a Context for the given subtree. |
| isTypeFactoryType(value) | Alpha | value is TypeFactoryType | Type guard to check if a value is a type factory type. |
Variables
| Variable | Alerts | Modifiers | Type | Description |
|---|---|---|---|---|
| exposeMethodsSymbol | Alpha | readonly | unique symbol | A symbol used to expose methods to the LLM. |
| exposePropertiesSymbol | Alpha | readonly | unique symbol | A symbol used to expose properties to the LLM. |
| llmDefault | Alpha | readonly | unique symbol | Include this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM. |
| typeFactory | Alpha | readonly | { string(): TypeFactoryString; number(): TypeFactoryNumber; boolean(): TypeFactoryBoolean; date(): TypeFactoryDate; void(): TypeFactoryVoid; undefined(): TypeFactoryUndefined; null(): TypeFactoryNull; unknown(): TypeFactoryUnknown; array(element: TypeFactoryType): TypeFactoryArray; promise(innerType: TypeFactoryType): TypeFactoryPromise; object(shape: Record<string, TypeFactoryType>): TypeFactoryObject; record(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord; map(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap; tuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple; union(options: readonly TypeFactoryType[]): TypeFactoryUnion; intersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection; literal(value: string | number | boolean): TypeFactoryLiteral; optional(innerType: TypeFactoryType): TypeFactoryOptional; readonly(innerType: TypeFactoryType): TypeFactoryReadonly; function(parameters: readonly TypeFactoryFunctionParameter[], returnType: TypeFactoryType, restParameter?: TypeFactoryFunctionParameter): TypeFactoryFunction; instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf; } | Namespace containing type factory functions. |
Function Details
buildFunc
A utility function to build a function definition.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
export declare function buildFunc<const Return extends TypeFactoryType, const Args extends readonly Arg[], const Rest extends TypeFactoryType | null = null>(def: {
description?: string;
returns: Return;
rest?: Rest;
}, ...args: Args): FunctionDef<Args, Return, Rest>;
Type Parameters
| Parameter | Constraint | Default | Description |
|---|---|---|---|
| Return | TypeFactoryType | ||
| Args | readonly Arg[] | ||
| Rest | TypeFactoryType | null | null |
Parameters
| Parameter | Type | Description |
|---|---|---|
| def | { description?: string; returns: Return; rest?: Rest; } | |
| args | Args |
Returns
Return type: FunctionDef<Args, Return, Rest>
createContext
Creates a Context for the given subtree.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
export declare function createContext<TSchema extends ImplicitFieldSchema>(tree: ViewOrTree<TSchema>): Context<TSchema>;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| TSchema | ImplicitFieldSchema |
Parameters
| Parameter | Type | Description |
|---|---|---|
| tree | ViewOrTree<TSchema> |
Returns
Return type: Context<TSchema>
isTypeFactoryType
Type guard to check if a value is a type factory type.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
export declare function isTypeFactoryType(value: unknown): value is TypeFactoryType;
Parameters
| Parameter | Type | Description |
|---|---|---|
| value | unknown |
Returns
Return type: value is TypeFactoryType
Variable Details
exposeMethodsSymbol
A symbol used to expose methods to the LLM.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
exposeMethodsSymbol: unique symbol
Type: unique symbol
exposePropertiesSymbol
A symbol used to expose properties to the LLM.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
exposePropertiesSymbol: unique symbol
Type: unique symbol
llmDefault
Include this property in a field's schema metadata to indicate that the field's value should be generated via a provided function rather than by the LLM.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
llmDefault: unique symbol
Type: unique symbol
Example
class Object extends schemaFactory.object("Object", {
created: sf.required(sf.number, {
custom: {
// The LLM will ignore this field, and instead it will be populated with the result of the function
[llmDefault]: () => Date.now(),
},
}),
}) {};
typeFactory
Namespace containing type factory functions.
To use, import via @fluidframework/tree-agent/alpha.
For more information about our API support guarantees, see here.
Signature
typeFactory: {
string(): TypeFactoryString;
number(): TypeFactoryNumber;
boolean(): TypeFactoryBoolean;
date(): TypeFactoryDate;
void(): TypeFactoryVoid;
undefined(): TypeFactoryUndefined;
null(): TypeFactoryNull;
unknown(): TypeFactoryUnknown;
array(element: TypeFactoryType): TypeFactoryArray;
promise(innerType: TypeFactoryType): TypeFactoryPromise;
object(shape: Record<string, TypeFactoryType>): TypeFactoryObject;
record(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord;
map(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap;
tuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple;
union(options: readonly TypeFactoryType[]): TypeFactoryUnion;
intersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection;
literal(value: string | number | boolean): TypeFactoryLiteral;
optional(innerType: TypeFactoryType): TypeFactoryOptional;
readonly(innerType: TypeFactoryType): TypeFactoryReadonly;
function(parameters: readonly TypeFactoryFunctionParameter[], returnType: TypeFactoryType, restParameter?: TypeFactoryFunctionParameter): TypeFactoryFunction;
instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf;
}
Type: { string(): TypeFactoryString; number(): TypeFactoryNumber; boolean(): TypeFactoryBoolean; date(): TypeFactoryDate; void(): TypeFactoryVoid; undefined(): TypeFactoryUndefined; null(): TypeFactoryNull; unknown(): TypeFactoryUnknown; array(element: TypeFactoryType): TypeFactoryArray; promise(innerType: TypeFactoryType): TypeFactoryPromise; object(shape: Record<string, TypeFactoryType>): TypeFactoryObject; record(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord; map(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap; tuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple; union(options: readonly TypeFactoryType[]): TypeFactoryUnion; intersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection; literal(value: string | number | boolean): TypeFactoryLiteral; optional(innerType: TypeFactoryType): TypeFactoryOptional; readonly(innerType: TypeFactoryType): TypeFactoryReadonly; function(parameters: readonly TypeFactoryFunctionParameter[], returnType: TypeFactoryType, restParameter?: TypeFactoryFunctionParameter): TypeFactoryFunction; instanceOf<T extends TreeNodeSchemaClass>(schema: T): TypeFactoryInstanceOf; }