@fluidframework/tree-agent 2.63.0-359286 → 2.63.0-359734

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 (65) hide show
  1. package/api-report/tree-agent.alpha.api.md +16 -18
  2. package/dist/agent.d.ts +1 -2
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +24 -51
  5. package/dist/agent.js.map +1 -1
  6. package/dist/alpha.d.ts +1 -0
  7. package/dist/api.d.ts +38 -20
  8. package/dist/api.d.ts.map +1 -1
  9. package/dist/api.js.map +1 -1
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +10 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/langchain.d.ts +3 -4
  15. package/dist/langchain.d.ts.map +1 -1
  16. package/dist/langchain.js +2 -4
  17. package/dist/langchain.js.map +1 -1
  18. package/dist/prompt.d.ts +1 -2
  19. package/dist/prompt.d.ts.map +1 -1
  20. package/dist/prompt.js +18 -21
  21. package/dist/prompt.js.map +1 -1
  22. package/dist/ses.d.ts +21 -0
  23. package/dist/ses.d.ts.map +1 -0
  24. package/dist/ses.js +64 -0
  25. package/dist/ses.js.map +1 -0
  26. package/dist/utils.d.ts +4 -0
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +16 -1
  29. package/dist/utils.js.map +1 -1
  30. package/lib/agent.d.ts +1 -2
  31. package/lib/agent.d.ts.map +1 -1
  32. package/lib/agent.js +25 -52
  33. package/lib/agent.js.map +1 -1
  34. package/lib/alpha.d.ts +1 -0
  35. package/lib/api.d.ts +38 -20
  36. package/lib/api.d.ts.map +1 -1
  37. package/lib/api.js.map +1 -1
  38. package/lib/index.d.ts +2 -1
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/index.js +7 -0
  41. package/lib/index.js.map +1 -1
  42. package/lib/langchain.d.ts +3 -4
  43. package/lib/langchain.d.ts.map +1 -1
  44. package/lib/langchain.js +2 -4
  45. package/lib/langchain.js.map +1 -1
  46. package/lib/prompt.d.ts +1 -2
  47. package/lib/prompt.d.ts.map +1 -1
  48. package/lib/prompt.js +18 -21
  49. package/lib/prompt.js.map +1 -1
  50. package/lib/ses.d.ts +21 -0
  51. package/lib/ses.d.ts.map +1 -0
  52. package/lib/ses.js +60 -0
  53. package/lib/ses.js.map +1 -0
  54. package/lib/utils.d.ts +4 -0
  55. package/lib/utils.d.ts.map +1 -1
  56. package/lib/utils.js +14 -0
  57. package/lib/utils.js.map +1 -1
  58. package/package.json +10 -9
  59. package/src/agent.ts +34 -74
  60. package/src/api.ts +39 -23
  61. package/src/index.ts +2 -1
  62. package/src/langchain.ts +6 -8
  63. package/src/prompt.ts +19 -23
  64. package/src/ses.ts +73 -0
  65. package/src/utils.ts +14 -0
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,qEAAqE;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAUtE,OAAO,EACN,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAYrD;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,SAAS,CAAC,CAAC,WAAW,CAC3B,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CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ImplicitFieldSchema, TreeNodeSchemaClass } from \"@fluidframework/tree\";\nimport type {\n\tInsertableContent,\n\tTreeBranch,\n\tTreeNode,\n\tTreeNodeSchema,\n\tTreeViewAlpha,\n\tUnsafeUnknownSchema,\n} from \"@fluidframework/tree/alpha\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tObjectNodeSchema,\n\tRecordNodeSchema,\n\tTreeAlpha,\n} from \"@fluidframework/tree/alpha\";\nimport { NodeKind, normalizeFieldSchema } from \"@fluidframework/tree/internal\";\nimport { z } from \"zod\";\n\nimport { FunctionWrapper } from \"./methodBinding.js\";\n\n/**\n * Subset of Map interface.\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * TBD\n */\nexport function fail(message: string): never {\n\tthrow new Error(message);\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * TODO\n * @alpha\n * @privateRemarks This is a subset of the TreeViewAlpha functionality because if take it wholesale, it causes problems with invariance of the generic parameters.\n */\nexport type TreeView<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema> = Pick<\n\tTreeViewAlpha<TRoot>,\n\t\"root\" | \"fork\" | \"merge\" | \"rebaseOnto\" | \"schema\" | \"events\"\n> &\n\tTreeBranch;\n\n/**\n * TODO\n */\nexport function tryGetSingleton<T>(set: ReadonlySet<T>): T | undefined {\n\tif (set.size === 1) {\n\t\tfor (const item of set) {\n\t\t\treturn item;\n\t\t}\n\t}\n}\n\n/**\n * Does it have at least two elements?\n */\nexport function hasAtLeastTwo<T>(array: T[]): array is [T, T, ...T[]] {\n\treturn array.length >= 2;\n}\n\n/**\n * 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.\n * @example\n * ```ts\n * class Object extends schemaFactory.object(\"Object\", {\n * created: sf.required(sf.number, {\n * custom: {\n * // The LLM will ignore this field, and instead it will be populated with the result of the function\n * [llmDefault]: () => Date.now(),\n * },\n * }),\n * }) {};\n * ```\n * @alpha\n */\nexport const llmDefault = Symbol(\"tree-agent/llmDefault\");\n// TODO: make this a wrapper function instead, and hide the symbol.\n// function llmDefault<T extends FieldSchemaMetadata>(metadata: T): T { ... }\n\n/**\n * Usage fail\n */\nexport function failUsage(message: string): never {\n\tthrow new UsageError(message);\n}\n\n/**\n * Construct an object node from a schema and value.\n */\nexport function constructNode(schema: TreeNodeSchema, value: InsertableContent): TreeNode {\n\tconst node = TreeAlpha.create<UnsafeUnknownSchema>(schema, value);\n\tassert(\n\t\tnode !== undefined && node !== null && typeof node === \"object\" && !isFluidHandle(node),\n\t\t0xc1e /* Expected a constructed node to be an object */,\n\t);\n\treturn node;\n}\n\n/**\n * Returns the unqualified name of a tree value's schema (e.g. a node with schema identifier `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks If the schema is an inlined array, map, or record type, then it has no name and this function will return a string representation of the type (e.g., `\"MyNode[]\"` or `\"Map<string, MyNode>\"`).\n */\nexport function getFriendlyName(schema: TreeNodeSchema): string {\n\tif (schema.kind === NodeKind.Leaf || isNamedSchema(schema.identifier)) {\n\t\treturn unqualifySchema(schema.identifier);\n\t}\n\n\tconst childNames = Array.from(schema.childTypes, (t) => getFriendlyName(t));\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn childNames.length > 1 ? `(${childNames.join(\" | \")})[]` : `${childNames[0]}[]`;\n\t}\n\tif (schema instanceof MapNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Map<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Map<string, ${childNames[0]}>`;\n\t}\n\tif (schema instanceof RecordNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Record<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Record<string, ${childNames[0]}>`;\n\t}\n\tfail(\"Unexpected node schema\");\n}\n\n/**\n * Returns true if the schema identifier represents a named schema (object, named array, named map, or named record).\n * @remarks This does not include primitive schemas or inlined array/map/record schemas.\n */\nexport function isNamedSchema(schemaIdentifier: string): boolean {\n\tif (\n\t\t[\"string\", \"number\", \"boolean\", \"null\", \"handle\"].includes(\n\t\t\tunqualifySchema(schemaIdentifier),\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn schemaIdentifier.match(/(?:Array|Map|Record)<\\[\"(.*)\"]>/) === null;\n}\n\n/**\n * Returns the unqualified name of a schema (e.g. `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks This works by removing all characters before the last dot in the schema name.\n * If there is a dot in a user's schema name, this might produce unexpected results.\n */\nexport function unqualifySchema(schemaIdentifier: string): string {\n\t// Get the unqualified name by removing the scope (everything before the last dot).\n\tconst matches = schemaIdentifier.match(/[^.]+$/);\n\tif (matches === null) {\n\t\treturn schemaIdentifier; // Return the original name if it is unscoped.\n\t}\n\treturn matches[0];\n}\n\n/**\n * Details about the properties of a TypeScript schema represented as Zod.\n */\nexport interface SchemaDetails {\n\thasHelperMethods: boolean;\n}\n\n// TODO: yuck, this entire file has too many statics. we should rewrite it as a generic zod schema walk.\nlet detailsI: SchemaDetails = {\n\thasHelperMethods: false,\n};\n\n/**\n * Returns the TypeScript source code corresponding to a Zod schema. The schema is supplied as an object where each\n * property provides a name for an associated Zod type. The return value is a string containing the TypeScript source\n * code corresponding to the schema. Each property of the schema object is emitted as a named `interface` or `type`\n * declaration for the associated type and is referenced by that name in the emitted type declarations. Other types\n * referenced in the schema are emitted in their structural form.\n * @param schema - A schema object where each property provides a name for an associated Zod type.\n * @param details - Optional details about the schema. The fields will be set according to the details in the given schema.\n * @returns The TypeScript source code corresponding to the schema.\n */\nexport function getZodSchemaAsTypeScript(\n\tschema: Record<string, z.ZodType>,\n\tdetails?: SchemaDetails,\n): string {\n\tdetailsI = details ?? { hasHelperMethods: false };\n\tlet result = \"\";\n\tlet startOfLine = true;\n\tlet indent = 0;\n\tconst entries = [...Object.entries(schema)];\n\tconst namedTypes = new Map<object, string>(\n\t\tentries.map(([name, type]) => [getTypeIdentity(type), name]),\n\t);\n\tfor (const [name, type] of entries) {\n\t\tif (result) {\n\t\t\tappendNewLine();\n\t\t}\n\t\tconst description = type._def.description;\n\t\tif (description !== undefined && description !== \"\") {\n\t\t\tfor (const comment of description.split(\"\\n\")) {\n\t\t\t\tappend(`// ${comment}`);\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodObject) {\n\t\t\tappend(`interface ${name} `);\n\t\t\tappendObjectType(type as z.ZodObject<z.ZodRawShape>);\n\t\t} else {\n\t\t\tappend(`type ${name} = `);\n\t\t\tappendTypeDefinition(type);\n\t\t\tappend(\";\");\n\t\t}\n\t\tappendNewLine();\n\t}\n\treturn result;\n\n\tfunction append(s: string) {\n\t\tif (startOfLine) {\n\t\t\tresult += \" \".repeat(indent);\n\t\t\tstartOfLine = false;\n\t\t}\n\t\tresult += s;\n\t}\n\n\tfunction appendNewLine() {\n\t\tappend(\"\\n\");\n\t\tstartOfLine = true;\n\t}\n\n\tfunction appendType(type: z.ZodType, minPrecedence = TypePrecedence.Object) {\n\t\tconst name = namedTypes.get(getTypeIdentity(type));\n\t\tif (name === undefined) {\n\t\t\tconst parenthesize = getTypePrecendece(type) < minPrecedence;\n\t\t\tif (parenthesize) append(\"(\");\n\t\t\tappendTypeDefinition(type);\n\t\t\tif (parenthesize) append(\")\");\n\t\t} else {\n\t\t\tappend(name);\n\t\t}\n\t}\n\n\tfunction appendTypeDefinition(type: z.ZodType) {\n\t\tswitch (getTypeKind(type)) {\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodString: {\n\t\t\t\treturn append(\"string\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodNumber: {\n\t\t\t\treturn append(\"number\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodBoolean: {\n\t\t\t\treturn append(\"boolean\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodDate: {\n\t\t\t\treturn append(\"Date\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUndefined: {\n\t\t\t\treturn append(\"undefined\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodNull: {\n\t\t\t\treturn append(\"null\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUnknown: {\n\t\t\t\treturn append(\"unknown\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodArray: {\n\t\t\t\treturn appendArrayType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodObject: {\n\t\t\t\treturn appendObjectType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUnion: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t(type._def as z.ZodUnionDef).options,\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[...(type._def as z.ZodDiscriminatedUnionDef<string>).options.values()],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodIntersection: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[\n\t\t\t\t\t\t(type._def as z.ZodIntersectionDef).left,\n\t\t\t\t\t\t(type._def as z.ZodIntersectionDef).right,\n\t\t\t\t\t],\n\t\t\t\t\tTypePrecedence.Intersection,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodTuple: {\n\t\t\t\treturn appendTupleType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodRecord: {\n\t\t\t\treturn appendRecordType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodMap: {\n\t\t\t\treturn appendMapType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodLiteral: {\n\t\t\t\treturn appendLiteral((type._def as z.ZodLiteralDef).value);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodEnum: {\n\t\t\t\treturn append(\n\t\t\t\t\t(type._def as z.ZodEnumDef).values.map((value) => JSON.stringify(value)).join(\" | \"),\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodOptional: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[(type._def as z.ZodOptionalDef).innerType, z.undefined()],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodReadonly: {\n\t\t\t\treturn appendReadonlyType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodEffects: {\n\t\t\t\t// Currently, this only handles schema class instances, but there are other cases in which a ZodEffects could theoretically be used.\n\t\t\t\tif (instanceOfs.has(type)) {\n\t\t\t\t\tconst objectNodeSchema = instanceOfs.get(type);\n\t\t\t\t\tif (objectNodeSchema === undefined) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t`Unsupported zod effects type when transforming class method: ${getTypeKind(type)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn append(getFriendlyName(objectNodeSchema));\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Unsupported zod effects type. Did you use z.instanceOf? Use ExposedMethods.instanceOf function to reference schema classes in methods.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodVoid: {\n\t\t\t\treturn append(\"void\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodLazy: {\n\t\t\t\treturn appendType((type._def as z.ZodLazyDef).getter());\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported type when transforming class method: ${getTypeKind(type)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendBoundMethods(boundType: z.ZodType): void {\n\t\t// eslint-disable-next-line prefer-const\n\t\tfor (let [name, type] of Object.entries((boundType._def as z.ZodObjectDef).shape())) {\n\t\t\t// Special handling of methods on objects\n\t\t\tconst method = (type as unknown as { method: object | undefined }).method;\n\t\t\tif (method !== undefined && method instanceof FunctionWrapper) {\n\t\t\t\tdetailsI.hasHelperMethods = true;\n\t\t\t\tappend(name);\n\t\t\t\tappend(\"(\");\n\t\t\t\tlet first = true;\n\t\t\t\tfor (const [argName, argType] of method.args) {\n\t\t\t\t\tif (!first) append(\", \");\n\t\t\t\t\tif (getTypeKind(argType) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\t\t\tappend(`${argName}?: `);\n\t\t\t\t\t\tappendType((argType._def as z.ZodOptionalDef).innerType, TypePrecedence.Object);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tappend(`${argName}: `);\n\t\t\t\t\t\tappendType(argType);\n\t\t\t\t\t}\n\t\t\t\t\tfirst = false;\n\t\t\t\t}\n\t\t\t\tif (method.rest !== null) {\n\t\t\t\t\tif (!first) append(\", \");\n\t\t\t\t\tappend(\"...rest: \");\n\t\t\t\t\tappendType(method.rest, TypePrecedence.Object);\n\t\t\t\t\tappend(\"[]\");\n\t\t\t\t}\n\t\t\t\tappend(`): `);\n\t\t\t\tappendType(method.returns, TypePrecedence.Object);\n\t\t\t\tappend(\";\");\n\t\t\t\tif (method.description !== undefined) {\n\t\t\t\t\tappend(` // ${method.description}`);\n\t\t\t\t}\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendArrayType(arrayType: z.ZodType) {\n\t\tappendType((arrayType._def as z.ZodArrayDef).type, TypePrecedence.Object);\n\t\tappend(\"[]\");\n\t}\n\n\tfunction appendObjectType(objectType: z.ZodType) {\n\t\tappend(\"{\");\n\t\tappendNewLine();\n\t\tindent++;\n\t\t// eslint-disable-next-line prefer-const\n\t\tfor (let [name, type] of Object.entries((objectType._def as z.ZodObjectDef).shape())) {\n\t\t\tconst method = (type as unknown as { method: object | undefined }).method;\n\t\t\tif (method === undefined || !(method instanceof FunctionWrapper)) {\n\t\t\t\tappend(name);\n\t\t\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\t\tappend(\"?\");\n\t\t\t\t\ttype = (type._def as z.ZodOptionalDef).innerType;\n\t\t\t\t}\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType(type);\n\t\t\t\tappend(\";\");\n\t\t\t\tconst comment = type.description;\n\t\t\t\tif (comment !== undefined && comment !== \"\") append(` // ${comment}`);\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t\tappendBoundMethods(objectType);\n\t\tindent--;\n\t\tappend(\"}\");\n\t}\n\n\tfunction appendUnionOrIntersectionTypes(\n\t\ttypes: readonly z.ZodType[],\n\t\tminPrecedence: TypePrecedence,\n\t) {\n\t\tlet first = true;\n\t\tfor (const type of types) {\n\t\t\tif (!first) append(minPrecedence === TypePrecedence.Intersection ? \" & \" : \" | \");\n\t\t\tappendType(type, minPrecedence);\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfunction appendTupleType(tupleType: z.ZodType) {\n\t\tappend(\"[\");\n\t\tlet first = true;\n\t\tfor (const type of (tupleType._def as z.ZodTupleDef<z.ZodTupleItems, z.ZodType>).items) {\n\t\t\tif (!first) append(\", \");\n\t\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\tappendType((type._def as z.ZodOptionalDef).innerType, TypePrecedence.Object);\n\t\t\t\tappend(\"?\");\n\t\t\t} else {\n\t\t\t\tappendType(type);\n\t\t\t}\n\t\t\tfirst = false;\n\t\t}\n\t\tconst rest = (tupleType._def as z.ZodTupleDef<z.ZodTupleItems, z.ZodType | null>).rest;\n\t\tif (rest !== null) {\n\t\t\tif (!first) append(\", \");\n\t\t\tappend(\"...\");\n\t\t\tappendType(rest, TypePrecedence.Object);\n\t\t\tappend(\"[]\");\n\t\t}\n\t\tappend(\"]\");\n\t}\n\n\tfunction appendRecordType(recordType: z.ZodType) {\n\t\tappend(\"Record<\");\n\t\tappendType((recordType._def as z.ZodRecordDef).keyType);\n\t\tappend(\", \");\n\t\tappendType((recordType._def as z.ZodRecordDef).valueType);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendMapType(mapType: z.ZodType) {\n\t\tappend(\"Map<\");\n\t\tappendType((mapType._def as z.ZodMapDef).keyType);\n\t\tappend(\", \");\n\t\tappendType((mapType._def as z.ZodMapDef).valueType);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendLiteral(value: unknown) {\n\t\tappend(\n\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\"\n\t\t\t\t? JSON.stringify(value)\n\t\t\t\t: \"any\",\n\t\t);\n\t}\n\n\tfunction appendReadonlyType(readonlyType: z.ZodType) {\n\t\tappend(\"Readonly<\");\n\t\tappendType((readonlyType._def as z.ZodReadonlyDef).innerType);\n\t\tappend(\">\");\n\t}\n}\n\nfunction getTypeKind(type: z.ZodType): z.ZodFirstPartyTypeKind {\n\treturn (type._def as z.ZodTypeDef & { typeName: z.ZodFirstPartyTypeKind }).typeName;\n}\n\nfunction getTypeIdentity(type: z.ZodType): object {\n\tswitch (getTypeKind(type)) {\n\t\tcase z.ZodFirstPartyTypeKind.ZodObject: {\n\t\t\treturn (type._def as z.ZodObjectDef).shape();\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodEnum: {\n\t\t\treturn (type._def as z.ZodEnumDef).values;\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodUnion: {\n\t\t\treturn (type._def as z.ZodUnionDef).options;\n\t\t}\n\t\tdefault: {\n\t\t\treturn type;\n\t\t}\n\t}\n}\n\nconst enum TypePrecedence {\n\tUnion = 0,\n\tIntersection = 1,\n\tObject = 2,\n}\n\nfunction getTypePrecendece(type: z.ZodType): TypePrecedence {\n\tswitch (getTypeKind(type)) {\n\t\tcase z.ZodFirstPartyTypeKind.ZodEnum:\n\t\tcase z.ZodFirstPartyTypeKind.ZodUnion:\n\t\tcase z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {\n\t\t\treturn TypePrecedence.Union;\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodIntersection: {\n\t\t\treturn TypePrecedence.Intersection;\n\t\t}\n\t\tdefault: {\n\t\t\treturn TypePrecedence.Object;\n\t\t}\n\t}\n}\n\n/**\n * Create a Zod schema for a SharedTree schema class.\n * @alpha\n */\nexport function instanceOf<T extends TreeNodeSchemaClass>(\n\tschema: T,\n): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>> {\n\tif (!(schema instanceof ObjectNodeSchema)) {\n\t\tthrow new UsageError(`${schema.identifier} must be an instance of ObjectNodeSchema.`);\n\t}\n\tconst effect = z.instanceof(schema);\n\tinstanceOfs.set(effect, schema);\n\treturn effect;\n}\n\nconst instanceOfs = new WeakMap<z.ZodTypeAny, ObjectNodeSchema>();\n\n/**\n * Adds all named object, map, array, and record schemas reachable from the given schema to the given set.\n * @remarks This includes transitive child/descendant schemas.\n * It does not include primitive schemas or inlined array/map/record schemas.\n * @returns The set of named schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findNamedSchemas(\n\tschema: ImplicitFieldSchema,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tconst set = schemas ?? new Set();\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!set.has(nodeSchema)) {\n\t\t\tif (isNamedSchema(nodeSchema.identifier)) {\n\t\t\t\tset.add(nodeSchema);\n\t\t\t}\n\t\t\tfindNamedSchemas([...nodeSchema.childTypes], set);\n\t\t}\n\t}\n\treturn set;\n}\n\n/**\n * De-capitalize (the first letter of) a string.\n */\nexport function communize(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,qEAA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CAAC;AAED,MAAM,WAAW,GAAG,IAAI,OAAO,EAAkC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC/B,MAA2B,EAC3B,UAAU,IAAI,GAAG,EAAkB;IAEnC,MAAM,GAAG,GAAG,OAAO,IAAI,IAAI,GAAG,EAAE,CAAC;IACjC,KAAK,MAAM,UAAU,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,CAAC;QACtE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1B,IAAI,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC1C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACrB,CAAC;YACD,gBAAgB,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport type { ImplicitFieldSchema, TreeNodeSchemaClass } from \"@fluidframework/tree\";\nimport type {\n\tInsertableContent,\n\tTreeBranch,\n\tTreeNode,\n\tTreeNodeSchema,\n\tTreeViewAlpha,\n\tUnsafeUnknownSchema,\n} from \"@fluidframework/tree/alpha\";\nimport {\n\tArrayNodeSchema,\n\tMapNodeSchema,\n\tObjectNodeSchema,\n\tRecordNodeSchema,\n\tTreeAlpha,\n} from \"@fluidframework/tree/alpha\";\nimport { NodeKind, normalizeFieldSchema } from \"@fluidframework/tree/internal\";\nimport { z } from \"zod\";\n\nimport { FunctionWrapper } from \"./methodBinding.js\";\n\n/**\n * Subset of Map interface.\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport interface MapGetSet<K, V> {\n\tget(key: K): V | undefined;\n\tset(key: K, value: V): void;\n}\n\n/**\n * TBD\n */\nexport function fail(message: string): never {\n\tthrow new Error(message);\n}\n\n/**\n * Map one iterable to another by transforming each element one at a time\n * @param iterable - the iterable to transform\n * @param map - the transformation function to run on each element of the iterable\n * @returns a new iterable of elements which have been transformed by the `map` function\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function* mapIterable<T, U>(\n\titerable: Iterable<T>,\n\tmap: (t: T) => U,\n): IterableIterator<U> {\n\tfor (const t of iterable) {\n\t\tyield map(t);\n\t}\n}\n\n/**\n * Retrieve a value from a map with the given key, or create a new entry if the key is not in the map.\n * @param map - The map to query/update\n * @param key - The key to lookup in the map\n * @param defaultValue - a function which returns a default value. This is called and used to set an initial value for the given key in the map if none exists\n * @returns either the existing value for the given key, or the newly-created value (the result of `defaultValue`)\n *\n * @remarks originally from tree/src/util/utils.ts\n */\nexport function getOrCreate<K, V>(\n\tmap: MapGetSet<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tlet value = map.get(key);\n\tif (value === undefined) {\n\t\tvalue = defaultValue(key);\n\t\tmap.set(key, value);\n\t}\n\treturn value;\n}\n\n/**\n * TODO\n * @alpha\n * @privateRemarks This is a subset of the TreeViewAlpha functionality because if take it wholesale, it causes problems with invariance of the generic parameters.\n */\nexport type TreeView<TRoot extends ImplicitFieldSchema | UnsafeUnknownSchema> = Pick<\n\tTreeViewAlpha<TRoot>,\n\t\"root\" | \"fork\" | \"merge\" | \"rebaseOnto\" | \"schema\" | \"events\"\n> &\n\tTreeBranch;\n\n/**\n * TODO\n */\nexport function tryGetSingleton<T>(set: ReadonlySet<T>): T | undefined {\n\tif (set.size === 1) {\n\t\tfor (const item of set) {\n\t\t\treturn item;\n\t\t}\n\t}\n}\n\n/**\n * Does it have at least two elements?\n */\nexport function hasAtLeastTwo<T>(array: T[]): array is [T, T, ...T[]] {\n\treturn array.length >= 2;\n}\n\n/**\n * 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.\n * @example\n * ```ts\n * class Object extends schemaFactory.object(\"Object\", {\n * created: sf.required(sf.number, {\n * custom: {\n * // The LLM will ignore this field, and instead it will be populated with the result of the function\n * [llmDefault]: () => Date.now(),\n * },\n * }),\n * }) {};\n * ```\n * @alpha\n */\nexport const llmDefault = Symbol(\"tree-agent/llmDefault\");\n// TODO: make this a wrapper function instead, and hide the symbol.\n// function llmDefault<T extends FieldSchemaMetadata>(metadata: T): T { ... }\n\n/**\n * Usage fail\n */\nexport function failUsage(message: string): never {\n\tthrow new UsageError(message);\n}\n\n/**\n * Construct an object node from a schema and value.\n */\nexport function constructNode(schema: TreeNodeSchema, value: InsertableContent): TreeNode {\n\tconst node = TreeAlpha.create<UnsafeUnknownSchema>(schema, value);\n\tassert(\n\t\tnode !== undefined && node !== null && typeof node === \"object\" && !isFluidHandle(node),\n\t\t0xc1e /* Expected a constructed node to be an object */,\n\t);\n\treturn node;\n}\n\n/**\n * Returns the unqualified name of a tree value's schema (e.g. a node with schema identifier `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks If the schema is an inlined array, map, or record type, then it has no name and this function will return a string representation of the type (e.g., `\"MyNode[]\"` or `\"Map<string, MyNode>\"`).\n */\nexport function getFriendlyName(schema: TreeNodeSchema): string {\n\tif (schema.kind === NodeKind.Leaf || isNamedSchema(schema.identifier)) {\n\t\treturn unqualifySchema(schema.identifier);\n\t}\n\n\tconst childNames = Array.from(schema.childTypes, (t) => getFriendlyName(t));\n\tif (schema instanceof ArrayNodeSchema) {\n\t\treturn childNames.length > 1 ? `(${childNames.join(\" | \")})[]` : `${childNames[0]}[]`;\n\t}\n\tif (schema instanceof MapNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Map<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Map<string, ${childNames[0]}>`;\n\t}\n\tif (schema instanceof RecordNodeSchema) {\n\t\treturn childNames.length > 1\n\t\t\t? `Record<string, (${childNames.join(\" | \")})>`\n\t\t\t: `Record<string, ${childNames[0]}>`;\n\t}\n\tfail(\"Unexpected node schema\");\n}\n\n/**\n * Returns true if the schema identifier represents a named schema (object, named array, named map, or named record).\n * @remarks This does not include primitive schemas or inlined array/map/record schemas.\n */\nexport function isNamedSchema(schemaIdentifier: string): boolean {\n\tif (\n\t\t[\"string\", \"number\", \"boolean\", \"null\", \"handle\"].includes(\n\t\t\tunqualifySchema(schemaIdentifier),\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn schemaIdentifier.match(/(?:Array|Map|Record)<\\[\"(.*)\"]>/) === null;\n}\n\n/**\n * Returns the unqualified name of a schema (e.g. `\"my.scope.MyNode\"` returns `\"MyNode\"`).\n * @remarks This works by removing all characters before the last dot in the schema name.\n * If there is a dot in a user's schema name, this might produce unexpected results.\n */\nexport function unqualifySchema(schemaIdentifier: string): string {\n\t// Get the unqualified name by removing the scope (everything before the last dot).\n\tconst matches = schemaIdentifier.match(/[^.]+$/);\n\tif (matches === null) {\n\t\treturn schemaIdentifier; // Return the original name if it is unscoped.\n\t}\n\treturn matches[0];\n}\n\n/**\n * Details about the properties of a TypeScript schema represented as Zod.\n */\nexport interface SchemaDetails {\n\thasHelperMethods: boolean;\n}\n\n// TODO: yuck, this entire file has too many statics. we should rewrite it as a generic zod schema walk.\nlet detailsI: SchemaDetails = {\n\thasHelperMethods: false,\n};\n\n/**\n * Returns the TypeScript source code corresponding to a Zod schema. The schema is supplied as an object where each\n * property provides a name for an associated Zod type. The return value is a string containing the TypeScript source\n * code corresponding to the schema. Each property of the schema object is emitted as a named `interface` or `type`\n * declaration for the associated type and is referenced by that name in the emitted type declarations. Other types\n * referenced in the schema are emitted in their structural form.\n * @param schema - A schema object where each property provides a name for an associated Zod type.\n * @param details - Optional details about the schema. The fields will be set according to the details in the given schema.\n * @returns The TypeScript source code corresponding to the schema.\n */\nexport function getZodSchemaAsTypeScript(\n\tschema: Record<string, z.ZodType>,\n\tdetails?: SchemaDetails,\n): string {\n\tdetailsI = details ?? { hasHelperMethods: false };\n\tlet result = \"\";\n\tlet startOfLine = true;\n\tlet indent = 0;\n\tconst entries = [...Object.entries(schema)];\n\tconst namedTypes = new Map<object, string>(\n\t\tentries.map(([name, type]) => [getTypeIdentity(type), name]),\n\t);\n\tfor (const [name, type] of entries) {\n\t\tif (result) {\n\t\t\tappendNewLine();\n\t\t}\n\t\tconst description = type._def.description;\n\t\tif (description !== undefined && description !== \"\") {\n\t\t\tfor (const comment of description.split(\"\\n\")) {\n\t\t\t\tappend(`// ${comment}`);\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodObject) {\n\t\t\tappend(`interface ${name} `);\n\t\t\tappendObjectType(type as z.ZodObject<z.ZodRawShape>);\n\t\t} else {\n\t\t\tappend(`type ${name} = `);\n\t\t\tappendTypeDefinition(type);\n\t\t\tappend(\";\");\n\t\t}\n\t\tappendNewLine();\n\t}\n\treturn result;\n\n\tfunction append(s: string) {\n\t\tif (startOfLine) {\n\t\t\tresult += \" \".repeat(indent);\n\t\t\tstartOfLine = false;\n\t\t}\n\t\tresult += s;\n\t}\n\n\tfunction appendNewLine() {\n\t\tappend(\"\\n\");\n\t\tstartOfLine = true;\n\t}\n\n\tfunction appendType(type: z.ZodType, minPrecedence = TypePrecedence.Object) {\n\t\tconst name = namedTypes.get(getTypeIdentity(type));\n\t\tif (name === undefined) {\n\t\t\tconst parenthesize = getTypePrecendece(type) < minPrecedence;\n\t\t\tif (parenthesize) append(\"(\");\n\t\t\tappendTypeDefinition(type);\n\t\t\tif (parenthesize) append(\")\");\n\t\t} else {\n\t\t\tappend(name);\n\t\t}\n\t}\n\n\tfunction appendTypeDefinition(type: z.ZodType) {\n\t\tswitch (getTypeKind(type)) {\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodString: {\n\t\t\t\treturn append(\"string\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodNumber: {\n\t\t\t\treturn append(\"number\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodBoolean: {\n\t\t\t\treturn append(\"boolean\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodDate: {\n\t\t\t\treturn append(\"Date\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUndefined: {\n\t\t\t\treturn append(\"undefined\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodNull: {\n\t\t\t\treturn append(\"null\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUnknown: {\n\t\t\t\treturn append(\"unknown\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodArray: {\n\t\t\t\treturn appendArrayType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodObject: {\n\t\t\t\treturn appendObjectType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodUnion: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t(type._def as z.ZodUnionDef).options,\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[...(type._def as z.ZodDiscriminatedUnionDef<string>).options.values()],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodIntersection: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[\n\t\t\t\t\t\t(type._def as z.ZodIntersectionDef).left,\n\t\t\t\t\t\t(type._def as z.ZodIntersectionDef).right,\n\t\t\t\t\t],\n\t\t\t\t\tTypePrecedence.Intersection,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodTuple: {\n\t\t\t\treturn appendTupleType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodRecord: {\n\t\t\t\treturn appendRecordType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodMap: {\n\t\t\t\treturn appendMapType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodLiteral: {\n\t\t\t\treturn appendLiteral((type._def as z.ZodLiteralDef).value);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodEnum: {\n\t\t\t\treturn append(\n\t\t\t\t\t(type._def as z.ZodEnumDef).values.map((value) => JSON.stringify(value)).join(\" | \"),\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodOptional: {\n\t\t\t\treturn appendUnionOrIntersectionTypes(\n\t\t\t\t\t[(type._def as z.ZodOptionalDef).innerType, z.undefined()],\n\t\t\t\t\tTypePrecedence.Union,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodReadonly: {\n\t\t\t\treturn appendReadonlyType(type);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodEffects: {\n\t\t\t\t// Currently, this only handles schema class instances, but there are other cases in which a ZodEffects could theoretically be used.\n\t\t\t\tif (instanceOfs.has(type)) {\n\t\t\t\t\tconst objectNodeSchema = instanceOfs.get(type);\n\t\t\t\t\tif (objectNodeSchema === undefined) {\n\t\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\t`Unsupported zod effects type when transforming class method: ${getTypeKind(type)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn append(getFriendlyName(objectNodeSchema));\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Unsupported zod effects type. Did you use z.instanceOf? Use ExposedMethods.instanceOf function to reference schema classes in methods.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodVoid: {\n\t\t\t\treturn append(\"void\");\n\t\t\t}\n\t\t\tcase z.ZodFirstPartyTypeKind.ZodLazy: {\n\t\t\t\treturn appendType((type._def as z.ZodLazyDef).getter());\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t`Unsupported type when transforming class method: ${getTypeKind(type)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendBoundMethods(boundType: z.ZodType): void {\n\t\t// eslint-disable-next-line prefer-const\n\t\tfor (let [name, type] of Object.entries((boundType._def as z.ZodObjectDef).shape())) {\n\t\t\t// Special handling of methods on objects\n\t\t\tconst method = (type as unknown as { method: object | undefined }).method;\n\t\t\tif (method !== undefined && method instanceof FunctionWrapper) {\n\t\t\t\tdetailsI.hasHelperMethods = true;\n\t\t\t\tappend(name);\n\t\t\t\tappend(\"(\");\n\t\t\t\tlet first = true;\n\t\t\t\tfor (const [argName, argType] of method.args) {\n\t\t\t\t\tif (!first) append(\", \");\n\t\t\t\t\tif (getTypeKind(argType) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\t\t\tappend(`${argName}?: `);\n\t\t\t\t\t\tappendType((argType._def as z.ZodOptionalDef).innerType, TypePrecedence.Object);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tappend(`${argName}: `);\n\t\t\t\t\t\tappendType(argType);\n\t\t\t\t\t}\n\t\t\t\t\tfirst = false;\n\t\t\t\t}\n\t\t\t\tif (method.rest !== null) {\n\t\t\t\t\tif (!first) append(\", \");\n\t\t\t\t\tappend(\"...rest: \");\n\t\t\t\t\tappendType(method.rest, TypePrecedence.Object);\n\t\t\t\t\tappend(\"[]\");\n\t\t\t\t}\n\t\t\t\tappend(`): `);\n\t\t\t\tappendType(method.returns, TypePrecedence.Object);\n\t\t\t\tappend(\";\");\n\t\t\t\tif (method.description !== undefined) {\n\t\t\t\t\tappend(` // ${method.description}`);\n\t\t\t\t}\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction appendArrayType(arrayType: z.ZodType) {\n\t\tappendType((arrayType._def as z.ZodArrayDef).type, TypePrecedence.Object);\n\t\tappend(\"[]\");\n\t}\n\n\tfunction appendObjectType(objectType: z.ZodType) {\n\t\tappend(\"{\");\n\t\tappendNewLine();\n\t\tindent++;\n\t\t// eslint-disable-next-line prefer-const\n\t\tfor (let [name, type] of Object.entries((objectType._def as z.ZodObjectDef).shape())) {\n\t\t\tconst method = (type as unknown as { method: object | undefined }).method;\n\t\t\tif (method === undefined || !(method instanceof FunctionWrapper)) {\n\t\t\t\tappend(name);\n\t\t\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\t\tappend(\"?\");\n\t\t\t\t\ttype = (type._def as z.ZodOptionalDef).innerType;\n\t\t\t\t}\n\t\t\t\tappend(\": \");\n\t\t\t\tappendType(type);\n\t\t\t\tappend(\";\");\n\t\t\t\tconst comment = type.description;\n\t\t\t\tif (comment !== undefined && comment !== \"\") append(` // ${comment}`);\n\t\t\t\tappendNewLine();\n\t\t\t}\n\t\t}\n\t\tappendBoundMethods(objectType);\n\t\tindent--;\n\t\tappend(\"}\");\n\t}\n\n\tfunction appendUnionOrIntersectionTypes(\n\t\ttypes: readonly z.ZodType[],\n\t\tminPrecedence: TypePrecedence,\n\t) {\n\t\tlet first = true;\n\t\tfor (const type of types) {\n\t\t\tif (!first) append(minPrecedence === TypePrecedence.Intersection ? \" & \" : \" | \");\n\t\t\tappendType(type, minPrecedence);\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfunction appendTupleType(tupleType: z.ZodType) {\n\t\tappend(\"[\");\n\t\tlet first = true;\n\t\tfor (const type of (tupleType._def as z.ZodTupleDef<z.ZodTupleItems, z.ZodType>).items) {\n\t\t\tif (!first) append(\", \");\n\t\t\tif (getTypeKind(type) === z.ZodFirstPartyTypeKind.ZodOptional) {\n\t\t\t\tappendType((type._def as z.ZodOptionalDef).innerType, TypePrecedence.Object);\n\t\t\t\tappend(\"?\");\n\t\t\t} else {\n\t\t\t\tappendType(type);\n\t\t\t}\n\t\t\tfirst = false;\n\t\t}\n\t\tconst rest = (tupleType._def as z.ZodTupleDef<z.ZodTupleItems, z.ZodType | null>).rest;\n\t\tif (rest !== null) {\n\t\t\tif (!first) append(\", \");\n\t\t\tappend(\"...\");\n\t\t\tappendType(rest, TypePrecedence.Object);\n\t\t\tappend(\"[]\");\n\t\t}\n\t\tappend(\"]\");\n\t}\n\n\tfunction appendRecordType(recordType: z.ZodType) {\n\t\tappend(\"Record<\");\n\t\tappendType((recordType._def as z.ZodRecordDef).keyType);\n\t\tappend(\", \");\n\t\tappendType((recordType._def as z.ZodRecordDef).valueType);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendMapType(mapType: z.ZodType) {\n\t\tappend(\"Map<\");\n\t\tappendType((mapType._def as z.ZodMapDef).keyType);\n\t\tappend(\", \");\n\t\tappendType((mapType._def as z.ZodMapDef).valueType);\n\t\tappend(\">\");\n\t}\n\n\tfunction appendLiteral(value: unknown) {\n\t\tappend(\n\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\"\n\t\t\t\t? JSON.stringify(value)\n\t\t\t\t: \"any\",\n\t\t);\n\t}\n\n\tfunction appendReadonlyType(readonlyType: z.ZodType) {\n\t\tappend(\"Readonly<\");\n\t\tappendType((readonlyType._def as z.ZodReadonlyDef).innerType);\n\t\tappend(\">\");\n\t}\n}\n\nfunction getTypeKind(type: z.ZodType): z.ZodFirstPartyTypeKind {\n\treturn (type._def as z.ZodTypeDef & { typeName: z.ZodFirstPartyTypeKind }).typeName;\n}\n\nfunction getTypeIdentity(type: z.ZodType): object {\n\tswitch (getTypeKind(type)) {\n\t\tcase z.ZodFirstPartyTypeKind.ZodObject: {\n\t\t\treturn (type._def as z.ZodObjectDef).shape();\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodEnum: {\n\t\t\treturn (type._def as z.ZodEnumDef).values;\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodUnion: {\n\t\t\treturn (type._def as z.ZodUnionDef).options;\n\t\t}\n\t\tdefault: {\n\t\t\treturn type;\n\t\t}\n\t}\n}\n\nconst enum TypePrecedence {\n\tUnion = 0,\n\tIntersection = 1,\n\tObject = 2,\n}\n\nfunction getTypePrecendece(type: z.ZodType): TypePrecedence {\n\tswitch (getTypeKind(type)) {\n\t\tcase z.ZodFirstPartyTypeKind.ZodEnum:\n\t\tcase z.ZodFirstPartyTypeKind.ZodUnion:\n\t\tcase z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {\n\t\t\treturn TypePrecedence.Union;\n\t\t}\n\t\tcase z.ZodFirstPartyTypeKind.ZodIntersection: {\n\t\t\treturn TypePrecedence.Intersection;\n\t\t}\n\t\tdefault: {\n\t\t\treturn TypePrecedence.Object;\n\t\t}\n\t}\n}\n\n/**\n * Create a Zod schema for a SharedTree schema class.\n * @alpha\n */\nexport function instanceOf<T extends TreeNodeSchemaClass>(\n\tschema: T,\n): z.ZodType<InstanceType<T>, z.ZodTypeDef, InstanceType<T>> {\n\tif (!(schema instanceof ObjectNodeSchema)) {\n\t\tthrow new UsageError(`${schema.identifier} must be an instance of ObjectNodeSchema.`);\n\t}\n\tconst effect = z.instanceof(schema);\n\tinstanceOfs.set(effect, schema);\n\treturn effect;\n}\n\nconst instanceOfs = new WeakMap<z.ZodTypeAny, ObjectNodeSchema>();\n\n/**\n * Adds all named object, map, array, and record schemas reachable from the given schema to the given set.\n * @remarks This includes transitive child/descendant schemas.\n * It does not include primitive schemas or inlined array/map/record schemas.\n * @returns The set of named schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findNamedSchemas(\n\tschema: ImplicitFieldSchema,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tconst set = schemas ?? new Set();\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!set.has(nodeSchema)) {\n\t\t\tif (isNamedSchema(nodeSchema.identifier)) {\n\t\t\t\tset.add(nodeSchema);\n\t\t\t}\n\t\t\tfindNamedSchemas([...nodeSchema.childTypes], set);\n\t\t}\n\t}\n\treturn set;\n}\n\n/**\n * De-capitalize (the first letter of) a string.\n */\nexport function communize(str: string): string {\n\treturn str.charAt(0).toLowerCase() + str.slice(1);\n}\n\n/**\n * Stringify an unknown error value\n */\nexport function toErrorString(error: unknown): string {\n\tif (error instanceof Error) {\n\t\treturn error.message;\n\t}\n\ttry {\n\t\treturn JSON.stringify(error);\n\t} catch {\n\t\treturn String(error);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/tree-agent",
3
- "version": "2.63.0-359286",
3
+ "version": "2.63.0-359734",
4
4
  "description": "Experimental package to simplify integrating AI into Fluid-based applications",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -70,26 +70,27 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@anthropic-ai/sdk": "^0.39.0",
73
- "@fluidframework/core-utils": "2.63.0-359286",
74
- "@fluidframework/runtime-utils": "2.63.0-359286",
75
- "@fluidframework/telemetry-utils": "2.63.0-359286",
76
- "@fluidframework/tree": "2.63.0-359286",
73
+ "@fluidframework/core-utils": "2.63.0-359734",
74
+ "@fluidframework/runtime-utils": "2.63.0-359734",
75
+ "@fluidframework/telemetry-utils": "2.63.0-359734",
76
+ "@fluidframework/tree": "2.63.0-359734",
77
77
  "@langchain/core": "^0.3.66",
78
78
  "langchain": "^0.3.30",
79
+ "ses": "^1.14.0",
79
80
  "uuid": "^11.1.0",
80
81
  "zod": "^3.25.32"
81
82
  },
82
83
  "devDependencies": {
83
84
  "@arethetypeswrong/cli": "^0.17.1",
84
85
  "@biomejs/biome": "~1.9.3",
85
- "@fluid-internal/mocha-test-setup": "2.63.0-359286",
86
+ "@fluid-internal/mocha-test-setup": "2.63.0-359734",
86
87
  "@fluid-tools/build-cli": "^0.58.3",
87
88
  "@fluidframework/build-common": "^2.0.3",
88
89
  "@fluidframework/build-tools": "^0.58.3",
89
90
  "@fluidframework/eslint-config-fluid": "^6.0.0",
90
- "@fluidframework/id-compressor": "2.63.0-359286",
91
- "@fluidframework/runtime-utils": "2.63.0-359286",
92
- "@fluidframework/test-runtime-utils": "2.63.0-359286",
91
+ "@fluidframework/id-compressor": "2.63.0-359734",
92
+ "@fluidframework/runtime-utils": "2.63.0-359734",
93
+ "@fluidframework/test-runtime-utils": "2.63.0-359734",
93
94
  "@langchain/anthropic": "^0.3.24",
94
95
  "@langchain/google-genai": "^0.2.16",
95
96
  "@langchain/openai": "^0.6.12",
package/src/agent.ts CHANGED
@@ -17,13 +17,7 @@ import type {
17
17
  } from "@fluidframework/tree/alpha";
18
18
  import { ObjectNodeSchema, Tree } from "@fluidframework/tree/alpha";
19
19
 
20
- import type {
21
- SharedTreeChatModel,
22
- EditFunction,
23
- EditResult,
24
- SemanticAgentOptions,
25
- Logger,
26
- } from "./api.js";
20
+ import type { SharedTreeChatModel, EditResult, SemanticAgentOptions, Logger } from "./api.js";
27
21
  import { getPrompt, stringifyTree } from "./prompt.js";
28
22
  import { Subtree } from "./subtree.js";
29
23
  import {
@@ -32,7 +26,7 @@ import {
32
26
  llmDefault,
33
27
  type TreeView,
34
28
  findNamedSchemas,
35
- fail,
29
+ toErrorString,
36
30
  } from "./utils.js";
37
31
 
38
32
  /**
@@ -41,18 +35,12 @@ import {
41
35
  */
42
36
  const defaultMaxSequentialEdits = 20;
43
37
 
44
- /**
45
- * The name of the parameter passed to the edit function.
46
- */
47
- const paramsName = "params";
48
-
49
38
  /**
50
39
  * An agent that uses a {@link SharedTreeChatModel} to interact with a SharedTree.
51
40
  * @remarks This class forwards user queries to the chat model, and handles the application of any edits to the tree that the model requests.
52
41
  * @alpha @sealed
53
42
  */
54
43
  export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
55
- public static editFunctionName = "editTree";
56
44
  // Converted from ECMAScript private fields (#name) to TypeScript private members for easier debugger inspection.
57
45
  private readonly outerTree: Subtree<TSchema>;
58
46
  /**
@@ -63,7 +51,7 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
63
51
  public constructor(
64
52
  private readonly client: SharedTreeChatModel,
65
53
  tree: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
66
- private readonly options?: Readonly<SemanticAgentOptions<TSchema>>,
54
+ private readonly options?: Readonly<SemanticAgentOptions>,
67
55
  ) {
68
56
  if (tree instanceof TreeNode) {
69
57
  Tree.on(tree, "treeChanged", () => (this.outerTreeIsDirty = true));
@@ -75,7 +63,6 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
75
63
  const prompt = getPrompt({
76
64
  subtree: this.outerTree,
77
65
  editToolName: this.client.editToolName,
78
- editFunctionName: this.client.editFunctionName,
79
66
  domainHints: this.options?.domainHints,
80
67
  });
81
68
  this.options?.logger?.log(`# Fluid Framework SharedTree AI Agent Log\n\n`);
@@ -124,9 +111,9 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
124
111
  let active = true;
125
112
  let editCount = 0;
126
113
  let editFailed = false;
127
- const { editFunctionName } = this.client;
128
- const edit = async (js: string): Promise<EditResult> => {
129
- if (editFunctionName === undefined) {
114
+ const { editToolName } = this.client;
115
+ const edit = async (editCode: string): Promise<EditResult> => {
116
+ if (editToolName === undefined) {
130
117
  return {
131
118
  type: "disabledError",
132
119
  message: "Editing is not enabled for this model.",
@@ -149,9 +136,9 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
149
136
 
150
137
  const editResult = await applyTreeFunction(
151
138
  queryTree,
152
- js,
153
- editFunctionName ?? fail("Expected edit function name to be defined"),
154
- this.options?.validator,
139
+ editCode,
140
+ this.options?.validateEdit ?? defaultValidateEdit,
141
+ this.options?.executeEdit ?? defaultExecuteEdit,
155
142
  this.options?.logger,
156
143
  );
157
144
 
@@ -211,19 +198,22 @@ function constructTreeNode(schema: TreeNodeSchema, value: FactoryContentObject):
211
198
  */
212
199
  async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
213
200
  tree: Subtree<TSchema>,
214
- fn: string | EditFunction<TSchema>,
215
- editFunctionName: string,
216
- validator: ((js: string) => boolean) | undefined,
217
- logger: Logger<ReadableField<TSchema>> | undefined,
201
+ editCode: string,
202
+ validateEdit: Required<SemanticAgentOptions>["validateEdit"],
203
+ executeEdit: Required<SemanticAgentOptions>["executeEdit"],
204
+ logger: Logger | undefined,
218
205
  ): Promise<EditResult> {
219
206
  logger?.log(`### Editing Tool Invoked\n\n`);
220
- logger?.log(`#### Generated Code\n\n\`\`\`javascript\n${fn}\n\`\`\`\n\n`);
207
+ logger?.log(`#### Generated Code\n\n\`\`\`javascript\n${editCode}\n\`\`\`\n\n`);
221
208
 
222
- if (validator?.(fn.toString()) === false) {
209
+ try {
210
+ await validateEdit(editCode);
211
+ } catch (error: unknown) {
223
212
  logger?.log(`#### Code Validation Failed\n\n`);
213
+ logger?.log(`\`\`\`JSON\n${toErrorString(error)}\n\`\`\`\n\n`);
224
214
  return {
225
215
  type: "validationError",
226
- message: "The generated code did not pass validation. Please try again.",
216
+ message: `The generated code did not pass validation: ${toErrorString(error)}`,
227
217
  };
228
218
  }
229
219
 
@@ -236,7 +226,7 @@ async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
236
226
 
237
227
  // Fork a branch to edit. If the edit fails or produces an error, we discard this branch, otherwise we merge it.
238
228
  const editTree = tree.fork();
239
- const params = {
229
+ const context = {
240
230
  get root(): ReadableField<TSchema> {
241
231
  return editTree.field;
242
232
  },
@@ -246,64 +236,34 @@ async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
246
236
  create,
247
237
  };
248
238
 
249
- let editFunction: EditFunction<TSchema>;
250
- if (typeof fn === "string") {
251
- try {
252
- editFunction = processLlmCode(fn, editFunctionName);
253
- } catch (error) {
254
- logger?.log(`#### Error\n\n`);
255
- const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
256
- logger?.log(`\`\`\`JSON\n${errorMessage}\n\`\`\`\n\n`);
257
- editTree.branch.dispose();
258
- return {
259
- type: "compileError",
260
- message: `The supplied JavaScript function is not valid: ${errorMessage}`,
261
- };
262
- }
263
- } else {
264
- editFunction = fn;
265
- }
266
-
267
239
  try {
268
- await editFunction(params);
240
+ await executeEdit(context, editCode);
269
241
  } catch (error: unknown) {
270
242
  logger?.log(`#### Error\n\n`);
271
- const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
272
- logger?.log(`\`\`\`JSON\n${errorMessage}\n\`\`\`\n\n`);
243
+ logger?.log(`\`\`\`JSON\n${toErrorString(error)}\n\`\`\`\n\n`);
273
244
  editTree.branch.dispose();
274
245
  return {
275
- type: "runtimeError",
276
- message: `Running the function produced an error. The state of the tree will be reset to its previous state as it was before the function ran. Please try again. Here is the error: ${errorMessage}`,
246
+ type: "executionError",
247
+ message: `Running the generated code produced an error. The state of the tree will be reset to its previous state as it was before the code ran. Please try again. Here is the error: ${toErrorString(error)}`,
277
248
  };
278
249
  }
279
250
 
280
251
  tree.branch.merge(editTree.branch);
281
252
  logger?.log(`#### New Tree State\n\n`);
282
- logger?.log(
283
- `${
284
- logger?.treeToString?.(tree.field) ?? `\`\`\`JSON\n${stringifyTree(tree.field)}\n\`\`\``
285
- }\n\n`,
286
- );
253
+ logger?.log(`${`\`\`\`JSON\n${stringifyTree(tree.field)}\n\`\`\``}\n\n`);
287
254
  return {
288
255
  type: "success",
289
- message: `After running the function, the new state of the tree is:\n\n\`\`\`JSON\n${stringifyTree(tree.field)}\n\`\`\``,
256
+ message: `After running the code, the new state of the tree is:\n\n\`\`\`JSON\n${stringifyTree(tree.field)}\n\`\`\``,
290
257
  };
291
258
  }
292
259
 
293
- function processLlmCode<TSchema extends ImplicitFieldSchema>(
294
- code: string,
295
- editFunctionName: string,
296
- ): EditFunction<TSchema> {
297
- // TODO: use a library like Acorn to analyze the code more robustly
298
- const regex = new RegExp(`function\\s+${editFunctionName}\\s*\\(`);
299
- if (!regex.test(code)) {
300
- throw new Error(
301
- `Generated code does not contain a function named \`${editFunctionName}\``,
302
- );
303
- }
260
+ const defaultValidateEdit: Required<SemanticAgentOptions>["validateEdit"] = () => {};
304
261
 
305
- const executionCode = `${code}\n\n${editFunctionName}(${paramsName});`;
262
+ const defaultExecuteEdit: Required<SemanticAgentOptions>["executeEdit"] = async (
263
+ context,
264
+ code,
265
+ ) => {
306
266
  // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
307
- const fn = new Function(paramsName, executionCode);
308
- return fn as EditFunction<TSchema>;
309
- }
267
+ const fn = new Function("context", code);
268
+ await fn(context);
269
+ };
package/src/api.ts CHANGED
@@ -4,47 +4,63 @@
4
4
  */
5
5
 
6
6
  import type { ImplicitFieldSchema, TreeNode } from "@fluidframework/tree";
7
+ // This is used for doc links
7
8
  import type { FactoryContentObject, ReadableField } from "@fluidframework/tree/alpha";
8
9
 
9
10
  /**
10
11
  * Logger interface for logging events from a {@link SharedTreeSemanticAgent}.
11
12
  * @alpha
12
13
  */
13
- export interface Logger<
14
- TTree extends ReadableField<ImplicitFieldSchema> = ReadableField<ImplicitFieldSchema>,
15
- > {
14
+ export interface Logger {
16
15
  /**
17
16
  * Log a message.
18
17
  */
19
18
  log(message: string): void;
20
- /**
21
- * Optional function to override the default tree stringification (JSON) when logging tree state.
22
- */
23
- treeToString?(tree: TTree): string;
24
19
  }
25
20
 
26
21
  /**
27
22
  * Options used to parameterize the creation of a {@link SharedTreeSemanticAgent}.
28
23
  * @alpha
29
24
  */
30
- export interface SemanticAgentOptions<TSchema extends ImplicitFieldSchema> {
25
+ export interface SemanticAgentOptions {
26
+ /**
27
+ * Additional information about the application domain that will be included in the context provided to the {@link SharedTreeChatModel | model}.
28
+ */
31
29
  domainHints?: string;
32
- validator?: (js: string) => boolean;
30
+ /**
31
+ * Validates any generated JavaScript created by the {@link SharedTreeChatModel.editToolName | model's editing tool}.
32
+ * @remarks This happens before the code is executed - execution can be intercepted by using the {@link SemanticAgentOptions.executeEdit | executeEdit} callback.
33
+ * @param code - The generated JavaScript code as a string.
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 (executes) 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 evaluating 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.
44
+ * Use a library such as SES to provide a more secure implementation - see {@link createSesEditEvaluator} for a drop-in option.
45
+ */
46
+ executeEdit?: (context: Record<string, unknown>, code: string) => void | Promise<void>;
33
47
  /**
34
48
  * The maximum number of sequential edits the LLM can make before we assume it's stuck in a loop.
35
49
  */
36
50
  maximumSequentialEdits?: number;
37
- logger?: Logger<ReadableField<TSchema>>;
51
+ /**
52
+ * If supplied, generates human-readable markdown text describing the actions taken by the {@link SharedTreeSemanticAgent | agent} as it performs queries.
53
+ */
54
+ logger?: Logger;
38
55
  }
39
56
 
40
57
  /**
41
58
  * A result from an edit attempt via the {@link SharedTreeChatQuery.edit} function.
42
59
  * @remarks
43
60
  * - `success`: The edit was successfully applied.
44
- * - `disabledError`: The model is not allowed to edit the tree (i.e. {@link SharedTreeChatModel.editFunctionName} was not provided).
45
- * - `validationError`: The provided JavaScript did not pass the optional {@link SemanticAgentOptions.validator} function.
46
- * - `compileError`: The provided JavaScript could not be parsed or compiled.
47
- * - `runtimeError`: An error was thrown while executing the provided JavaScript.
61
+ * - `disabledError`: The model is not allowed to edit the tree (i.e. {@link SharedTreeChatModel.editToolName} was not provided).
62
+ * - `validationError`: The provided JavaScript did not pass the optional {@link SemanticAgentOptions.validateEdit} function.
63
+ * - `executionError`: An error was thrown while parsing or executing the provided JavaScript.
48
64
  * - `tooManyEditsError`: The {@link SharedTreeChatQuery.edit} function has been called more than the number of times specified by {@link SemanticAgentOptions.maximumSequentialEdits} for the same message.
49
65
  * - `expiredError`: The {@link SharedTreeChatQuery.edit} function was called after the issuing query has already completed.
50
66
  * @alpha
@@ -54,8 +70,7 @@ export interface EditResult {
54
70
  | "success"
55
71
  | "disabledError"
56
72
  | "validationError"
57
- | "compileError"
58
- | "runtimeError"
73
+ | "executionError"
59
74
  | "tooManyEditsError"
60
75
  | "expiredError";
61
76
 
@@ -98,6 +113,7 @@ export interface SharedTreeChatQuery {
98
113
 
99
114
  /**
100
115
  * A plugin interface that handles queries from a {@link SharedTreeSemanticAgent}.
116
+ * @remarks This wraps an underlying communication with an LLM and receives all necessary {@link SharedTreeChatModel.appendContext | context} from the {@link SharedTreeSemanticAgent | agent} for the LLM to properly analyze and edit the tree.
101
117
  * @alpha
102
118
  */
103
119
  export interface SharedTreeChatModel {
@@ -108,18 +124,18 @@ export interface SharedTreeChatModel {
108
124
  */
109
125
  name?: string;
110
126
  /**
111
- * The name of the tool that the model should use to edit the tree, if any.
112
- * @remarks If supplied, this will be mentioned in the context provided to the model and the model will be encouraged to use it when a user query requires an edit.
127
+ * The name of the tool that the model should use to edit the tree.
128
+ * @remarks If supplied, this will be mentioned in the context provided to the model so that the underlying LLM will be encouraged to use it when a user query requires an edit.
129
+ * The model should "implement" the tool by registering it with the underlying LLM API.
130
+ * The tool should take an LLM-generated JavaScript function as input and supply it to the {@link SharedTreeChatQuery.edit | edit} function.
131
+ * Instructions for generating the proper function signature and implementation will be provided by the {@link SharedTreeSemanticAgent | agent} via {@link SharedTreeChatModel.appendContext | context}.
132
+ * If not supplied, the model will not be able to edit the tree (running the {@link SharedTreeChatQuery.edit | edit} function will fail).
113
133
  */
114
134
  editToolName?: string;
115
- /**
116
- * The name of the function that the model should generate to edit the tree.
117
- * @remarks If not supplied, the model will not be allowed to edit the tree.
118
- */
119
- editFunctionName?: string;
120
135
  /**
121
136
  * Add contextual information to the model that may be relevant to future queries.
122
137
  * @remarks In practice, this may be implemented by e.g. appending a "system" message to an LLM's chat/message history.
138
+ * This context must be present in the context window of every {@link SharedTreeChatModel.query | query} for e.g. {@link SharedTreeChatModel.editToolName | editing} to work.
123
139
  * @param text - The message or context to append.
124
140
  */
125
141
  appendContext?(text: string): void;
package/src/index.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
 
12
- export type { SharedTreeSemanticAgent } from "./agent.js";
12
+ export { SharedTreeSemanticAgent } from "./agent.js";
13
13
  export type {
14
14
  EditResult,
15
15
  SharedTreeChatModel,
@@ -32,3 +32,4 @@ export {
32
32
  type IExposedMethods,
33
33
  } from "./methodBinding.js";
34
34
  export { LangchainChatModel, createSemanticAgent } from "./langchain.js";
35
+ export { createSesEditEvaluator } from "./ses.js";
package/src/langchain.ts CHANGED
@@ -37,7 +37,6 @@ export class LangchainChatModel implements SharedTreeChatModel {
37
37
  public constructor(private readonly model: BaseChatModel) {}
38
38
 
39
39
  public readonly editToolName = "GenerateTreeEditingCode";
40
- public readonly editFunctionName = "editTree";
41
40
 
42
41
  public get name(): string | undefined {
43
42
  const name = this.model.metadata?.modelName;
@@ -60,10 +59,9 @@ export class LangchainChatModel implements SharedTreeChatModel {
60
59
  },
61
60
  {
62
61
  name: this.editToolName,
63
- description: `Invokes a JavaScript function to edit a user's tree`,
62
+ description: `Invokes a JavaScript code snippet to edit a tree of application data.`,
64
63
  schema: z.object({
65
- functionCode: z.string().describe(`The code of the JavaScript function.
66
- For example: "function ${this.editFunctionName}({ root, create }) { /* your code here */ }"`),
64
+ functionCode: z.string().describe(`The JavaScript snippet code.`),
67
65
  }),
68
66
  },
69
67
  );
@@ -109,7 +107,7 @@ For example: "function ${this.editFunctionName}({ root, create }) { /* your code
109
107
  export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
110
108
  client: BaseChatModel,
111
109
  treeView: TreeView<TSchema>,
112
- options?: Readonly<SemanticAgentOptions<TSchema>>,
110
+ options?: Readonly<SemanticAgentOptions>,
113
111
  ): SharedTreeSemanticAgent<TSchema>;
114
112
  /**
115
113
  * Create a {@link SharedTreeSemanticAgent} using a Langchain chat model.
@@ -119,7 +117,7 @@ export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
119
117
  export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
120
118
  client: BaseChatModel,
121
119
  node: ReadableField<TSchema> & TreeNode,
122
- options?: Readonly<SemanticAgentOptions<TSchema>>,
120
+ options?: Readonly<SemanticAgentOptions>,
123
121
  ): SharedTreeSemanticAgent<TSchema>;
124
122
  /**
125
123
  * Create a {@link SharedTreeSemanticAgent} using a Langchain chat model.
@@ -129,7 +127,7 @@ export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
129
127
  export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
130
128
  client: BaseChatModel,
131
129
  treeView: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
132
- options?: Readonly<SemanticAgentOptions<TSchema>>,
130
+ options?: Readonly<SemanticAgentOptions>,
133
131
  ): SharedTreeSemanticAgent<TSchema>;
134
132
  /**
135
133
  * Create a {@link SharedTreeSemanticAgent} using a Langchain chat model.
@@ -139,7 +137,7 @@ export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
139
137
  export function createSemanticAgent<TSchema extends ImplicitFieldSchema>(
140
138
  client: BaseChatModel,
141
139
  treeView: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
142
- options?: Readonly<SemanticAgentOptions<TSchema>>,
140
+ options?: Readonly<SemanticAgentOptions>,
143
141
  ): SharedTreeSemanticAgent<TSchema> {
144
142
  return new SharedTreeSemanticAgent(new LangchainChatModel(client), treeView, options);
145
143
  }