@fluidframework/tree-agent 2.72.0 → 2.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/tree-agent.alpha.api.md +88 -17
  3. package/dist/agent.d.ts +5 -31
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +19 -38
  6. package/dist/agent.js.map +1 -1
  7. package/dist/alpha.d.ts +12 -3
  8. package/dist/api.d.ts +38 -20
  9. package/dist/api.d.ts.map +1 -1
  10. package/dist/api.js.map +1 -1
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/prompt.d.ts +2 -2
  16. package/dist/prompt.d.ts.map +1 -1
  17. package/dist/prompt.js +4 -4
  18. package/dist/prompt.js.map +1 -1
  19. package/dist/propertyBinding.d.ts +106 -0
  20. package/dist/propertyBinding.d.ts.map +1 -0
  21. package/dist/propertyBinding.js +64 -0
  22. package/dist/propertyBinding.js.map +1 -0
  23. package/dist/subtree.d.ts +8 -9
  24. package/dist/subtree.d.ts.map +1 -1
  25. package/dist/subtree.js +21 -21
  26. package/dist/subtree.js.map +1 -1
  27. package/dist/typeGeneration.d.ts.map +1 -1
  28. package/dist/typeGeneration.js +78 -21
  29. package/dist/typeGeneration.js.map +1 -1
  30. package/dist/utils.d.ts +1 -7
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +17 -3
  33. package/dist/utils.js.map +1 -1
  34. package/lib/agent.d.ts +5 -31
  35. package/lib/agent.d.ts.map +1 -1
  36. package/lib/agent.js +17 -35
  37. package/lib/agent.js.map +1 -1
  38. package/lib/alpha.d.ts +12 -3
  39. package/lib/api.d.ts +38 -20
  40. package/lib/api.d.ts.map +1 -1
  41. package/lib/api.js.map +1 -1
  42. package/lib/index.d.ts +4 -3
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/index.js +1 -1
  45. package/lib/index.js.map +1 -1
  46. package/lib/prompt.d.ts +2 -2
  47. package/lib/prompt.d.ts.map +1 -1
  48. package/lib/prompt.js +4 -4
  49. package/lib/prompt.js.map +1 -1
  50. package/lib/propertyBinding.d.ts +106 -0
  51. package/lib/propertyBinding.d.ts.map +1 -0
  52. package/lib/propertyBinding.js +59 -0
  53. package/lib/propertyBinding.js.map +1 -0
  54. package/lib/subtree.d.ts +8 -9
  55. package/lib/subtree.d.ts.map +1 -1
  56. package/lib/subtree.js +21 -21
  57. package/lib/subtree.js.map +1 -1
  58. package/lib/typeGeneration.d.ts.map +1 -1
  59. package/lib/typeGeneration.js +78 -21
  60. package/lib/typeGeneration.js.map +1 -1
  61. package/lib/utils.d.ts +1 -7
  62. package/lib/utils.d.ts.map +1 -1
  63. package/lib/utils.js +17 -3
  64. package/lib/utils.js.map +1 -1
  65. package/package.json +10 -10
  66. package/src/agent.ts +27 -69
  67. package/src/api.ts +56 -29
  68. package/src/index.ts +16 -4
  69. package/src/prompt.ts +6 -6
  70. package/src/propertyBinding.ts +181 -0
  71. package/src/subtree.ts +26 -29
  72. package/src/typeGeneration.ts +90 -24
  73. package/src/utils.ts +21 -15
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,O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AAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;YACD,WAAW,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,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\tTreeBranchAlpha,\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\tTreeBranchAlpha;\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 (optionally filtered) schemas reachable from the given schema to the given set.\n * @returns The set of schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findSchemas(\n\tschema: ImplicitFieldSchema,\n\tfilter: (schema: TreeNodeSchema) => boolean = () => true,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!schemas.has(nodeSchema)) {\n\t\t\tif (filter(nodeSchema)) {\n\t\t\t\tschemas.add(nodeSchema);\n\t\t\t}\n\t\t\tfindSchemas([...nodeSchema.childTypes], filter, schemas);\n\t\t}\n\t}\n\treturn schemas;\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"]}
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;AAQtE,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;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAYnD;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1B,CAA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,OAAO,EAAkC,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,WAAW,CAC1B,MAA2B,EAC3B,SAA8C,GAAG,EAAE,CAAC,IAAI,EACxD,UAAU,IAAI,GAAG,EAAkB;IAEnC,KAAK,MAAM,UAAU,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,CAAC;QACtE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;YACD,WAAW,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,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\tTreeNode,\n\tTreeNodeSchema,\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\";\nimport { PropertyDef } from \"./propertyBinding.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 */\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 appendBoundProperties(type: z.ZodType): void {\n\t\tconst property = (type as unknown as { property?: PropertyDef }).property;\n\n\t\tif (!(property instanceof PropertyDef)) {\n\t\t\tif (type.description !== undefined && type.description !== \"\") {\n\t\t\t\tappend(` // ${type.description}`);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (property.readOnly === true) {\n\t\t\tappend(\" // readonly\");\n\t\t}\n\t\tif (property.description !== undefined && property.description !== \"\") {\n\t\t\tappend(` - ${property.description}`);\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\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\tappendBoundProperties(type);\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 (optionally filtered) schemas reachable from the given schema to the given set.\n * @returns The set of schemas added (same as the `schemas` parameter, if supplied).\n */\nexport function findSchemas(\n\tschema: ImplicitFieldSchema,\n\tfilter: (schema: TreeNodeSchema) => boolean = () => true,\n\tschemas = new Set<TreeNodeSchema>(),\n): Set<TreeNodeSchema> {\n\tfor (const nodeSchema of normalizeFieldSchema(schema).allowedTypeSet) {\n\t\tif (!schemas.has(nodeSchema)) {\n\t\t\tif (filter(nodeSchema)) {\n\t\t\t\tschemas.add(nodeSchema);\n\t\t\t}\n\t\t\tfindSchemas([...nodeSchema.childTypes], filter, schemas);\n\t\t}\n\t}\n\treturn schemas;\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.72.0",
3
+ "version": "2.73.0",
4
4
  "description": "Experimental package to simplify integrating AI into Fluid-based applications",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -70,24 +70,24 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@anthropic-ai/sdk": "^0.39.0",
73
- "@fluidframework/core-utils": "~2.72.0",
74
- "@fluidframework/runtime-utils": "~2.72.0",
75
- "@fluidframework/telemetry-utils": "~2.72.0",
76
- "@fluidframework/tree": "~2.72.0",
73
+ "@fluidframework/core-utils": "~2.73.0",
74
+ "@fluidframework/runtime-utils": "~2.73.0",
75
+ "@fluidframework/telemetry-utils": "~2.73.0",
76
+ "@fluidframework/tree": "~2.73.0",
77
77
  "uuid": "^11.1.0",
78
78
  "zod": "^3.25.32"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@arethetypeswrong/cli": "^0.17.1",
82
82
  "@biomejs/biome": "~1.9.3",
83
- "@fluid-internal/mocha-test-setup": "~2.72.0",
83
+ "@fluid-internal/mocha-test-setup": "~2.73.0",
84
84
  "@fluid-tools/build-cli": "^0.60.0",
85
85
  "@fluidframework/build-common": "^2.0.3",
86
86
  "@fluidframework/build-tools": "^0.60.0",
87
- "@fluidframework/eslint-config-fluid": "~2.72.0",
88
- "@fluidframework/id-compressor": "~2.72.0",
89
- "@fluidframework/runtime-utils": "~2.72.0",
90
- "@fluidframework/test-runtime-utils": "~2.72.0",
87
+ "@fluidframework/eslint-config-fluid": "~2.73.0",
88
+ "@fluidframework/id-compressor": "~2.73.0",
89
+ "@fluidframework/runtime-utils": "~2.73.0",
90
+ "@fluidframework/test-runtime-utils": "~2.73.0",
91
91
  "@langchain/anthropic": "^0.3.24",
92
92
  "@langchain/core": "^0.3.78",
93
93
  "@langchain/google-genai": "^0.2.16",
package/src/agent.ts CHANGED
@@ -22,15 +22,15 @@ import type {
22
22
  EditResult,
23
23
  SemanticAgentOptions,
24
24
  Logger,
25
- SynchronousEditor,
26
25
  AsynchronousEditor,
27
26
  Context,
27
+ SynchronousEditor,
28
+ ViewOrTree,
28
29
  } from "./api.js";
29
30
  import { getPrompt, stringifyTree } from "./prompt.js";
30
31
  import { Subtree } from "./subtree.js";
31
32
  import {
32
33
  llmDefault,
33
- type TreeView,
34
34
  findSchemas,
35
35
  toErrorString,
36
36
  unqualifySchema,
@@ -51,6 +51,7 @@ const defaultMaxSequentialEdits = 20;
51
51
  export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
52
52
  // Converted from ECMAScript private fields (#name) to TypeScript private members for easier debugger inspection.
53
53
  private readonly outerTree: Subtree<TSchema>;
54
+ private readonly editor: SynchronousEditor<TSchema> | AsynchronousEditor<TSchema>;
54
55
  /**
55
56
  * Whether or not the outer tree has changed since the last query finished.
56
57
  */
@@ -58,8 +59,8 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
58
59
 
59
60
  public constructor(
60
61
  private readonly client: SharedTreeChatModel,
61
- tree: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
62
- private readonly options?: Readonly<SemanticAgentOptions>,
62
+ tree: ViewOrTree<TSchema>,
63
+ private readonly options?: Readonly<SemanticAgentOptions<TSchema>>,
63
64
  ) {
64
65
  if (tree instanceof TreeNode) {
65
66
  Tree.on(tree, "treeChanged", () => (this.outerTreeIsDirty = true));
@@ -68,6 +69,7 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
68
69
  }
69
70
 
70
71
  this.outerTree = new Subtree(tree);
72
+ this.editor = this.options?.editor ?? createDefaultEditor();
71
73
  const prompt = getPrompt({
72
74
  subtree: this.outerTree,
73
75
  editToolName: this.client.editToolName,
@@ -145,7 +147,7 @@ export class SharedTreeSemanticAgent<TSchema extends ImplicitFieldSchema> {
145
147
  const editResult = await applyTreeFunction(
146
148
  queryTree,
147
149
  editCode,
148
- this.options?.editor ?? defaultEditor,
150
+ this.editor,
149
151
  this.options?.logger,
150
152
  );
151
153
 
@@ -209,7 +211,7 @@ function constructTreeNode(schema: TreeNodeSchema, content: FactoryContentObject
209
211
  async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
210
212
  tree: Subtree<TSchema>,
211
213
  editCode: string,
212
- editor: Required<SemanticAgentOptions>["editor"],
214
+ editor: SynchronousEditor<TSchema> | AsynchronousEditor<TSchema>,
213
215
  logger: Logger | undefined,
214
216
  ): Promise<EditResult> {
215
217
  logger?.log(`### Editing Tool Invoked\n\n`);
@@ -217,9 +219,8 @@ async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
217
219
 
218
220
  // Fork a branch to edit. If the edit fails or produces an error, we discard this branch, otherwise we merge it.
219
221
  const editTree = tree.fork();
220
- const boundEditor = bindEditorToSubtree(editTree, editor);
221
222
  try {
222
- await boundEditor(editCode);
223
+ await editor(editTree.viewOrTree, editCode);
223
224
  } catch (error: unknown) {
224
225
  logger?.log(`#### Error\n\n`);
225
226
  logger?.log(`\`\`\`JSON\n${toErrorString(error)}\n\`\`\`\n\n`);
@@ -239,80 +240,40 @@ async function applyTreeFunction<TSchema extends ImplicitFieldSchema>(
239
240
  };
240
241
  }
241
242
 
242
- /**
243
- * The default {@link AsynchronousEditor | editor} implementation that simply uses `new Function` to run the provided code.
244
- * @remarks This editor allows both synchronous and asynchronous code (i.e. the provided code may return a Promise).
245
- * @example `await new Function("context", code)(context);`
246
- * @alpha
247
- */
248
- export const defaultEditor: AsynchronousEditor = async (context, code) => {
249
- // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
250
- const fn = new Function("context", code);
251
- await fn(context);
252
- };
253
-
254
- /**
255
- * Binds the given {@link AsynchronousEditor | editor} to the given view or tree.
256
- * @returns A function that takes a string of JavaScript code and executes it on the given view or tree using the given editor function.
257
- * @remarks This is useful for testing/debugging code execution without needing to set up a full {@link SharedTreeSemanticAgent | agent}.
258
- * @alpha
259
- */
260
- export function bindEditorImpl<TSchema extends ImplicitFieldSchema>(
261
- tree: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
262
- editor: AsynchronousEditor,
263
- ): (code: string) => Promise<void>;
264
- /**
265
- * Binds the given {@link SynchronousEditor | editor} to the given view or tree.
266
- * @returns A function that takes a string of JavaScript code and executes it on the given view or tree using the given editor function.
267
- * @remarks This is useful for testing/debugging code execution without needing to set up a full {@link SharedTreeSemanticAgent | agent}.
268
- * @alpha
269
- */
270
- export function bindEditorImpl<TSchema extends ImplicitFieldSchema>(
271
- tree: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
272
- editor: SynchronousEditor,
273
- ): (code: string) => void;
274
- /**
275
- * Binds the given {@link SynchronousEditor | editor} or {@link AsynchronousEditor | editor} to the given view or tree.
276
- * @returns A function that takes a string of JavaScript code and executes it on the given view or tree using the given editor function.
277
- * @remarks This is useful for testing/debugging code execution without needing to set up a full {@link SharedTreeSemanticAgent | agent}.
278
- * @alpha
279
- */
280
- export function bindEditorImpl<TSchema extends ImplicitFieldSchema>(
281
- tree: TreeView<TSchema> | (ReadableField<TSchema> & TreeNode),
282
- editor: SynchronousEditor | AsynchronousEditor,
283
- ): ((code: string) => void) | ((code: string) => Promise<void>) {
284
- const subtree = new Subtree(tree);
285
- return bindEditorToSubtree(subtree, editor);
243
+ function createDefaultEditor<
244
+ TSchema extends ImplicitFieldSchema = ImplicitFieldSchema,
245
+ >(): AsynchronousEditor<TSchema> {
246
+ return async (tree, code) => {
247
+ const context = createContext(tree);
248
+ // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
249
+ const fn = new Function("context", code);
250
+ await fn(context);
251
+ };
286
252
  }
287
253
 
288
254
  /**
289
- * Binds the given {@link SynchronousEditor | synchronous} or {@link AsynchronousEditor | asynchronous} editor to the given view or tree.
290
- * @returns A function that takes a string of JavaScript code and executes it on the given view or tree using the given editor.
291
- * @remarks This is useful for testing/debugging code execution without needing to set up a full {@link SharedTreeSemanticAgent | agent}.
255
+ * Creates a {@link Context} for the given subtree.
292
256
  * @alpha
293
- * @privateRemarks This exists (as opposed to just exporting bindEditorImpl directly) so that API documentation links work correctly.
294
257
  */
295
- export const bindEditor = bindEditorImpl;
296
-
297
- function bindEditorToSubtree<TSchema extends ImplicitFieldSchema>(
298
- tree: Subtree<TSchema>,
299
- executeEdit: SynchronousEditor | AsynchronousEditor,
300
- ): (code: string) => void | Promise<void> {
258
+ export function createContext<TSchema extends ImplicitFieldSchema>(
259
+ tree: ViewOrTree<TSchema>,
260
+ ): Context<TSchema> {
261
+ const subTree = new Subtree(tree);
301
262
  // Stick the tree schema constructors on an object passed to the function so that the LLM can create new nodes.
302
263
  const create: Record<string, (input: FactoryContentObject) => TreeNode> = {};
303
264
  const is: Record<string, <T extends TreeNode>(input: unknown) => input is T> = {};
304
- for (const schema of findSchemas(tree.schema, (s) => isNamedSchema(s.identifier))) {
265
+ for (const schema of findSchemas(subTree.schema, (s) => isNamedSchema(s.identifier))) {
305
266
  const name = unqualifySchema(schema.identifier);
306
267
  create[name] = (input: FactoryContentObject) => constructTreeNode(schema, input);
307
268
  is[name] = <T extends TreeNode>(input: unknown): input is T => Tree.is(input, schema);
308
269
  }
309
270
 
310
- const context = {
271
+ return {
311
272
  get root(): ReadableField<TSchema> {
312
- return tree.field;
273
+ return subTree.field;
313
274
  },
314
275
  set root(value: TreeFieldFromImplicitField<ReadSchema<TSchema>>) {
315
- tree.field = value;
276
+ subTree.field = value;
316
277
  },
317
278
  create,
318
279
  is,
@@ -339,7 +300,4 @@ function bindEditorToSubtree<TSchema extends ImplicitFieldSchema>(
339
300
  parent: (child: TreeNode): TreeNode | undefined => Tree.parent(child),
340
301
  key: (child: TreeNode): string | number => Tree.key(child),
341
302
  } satisfies Context<TSchema>;
342
-
343
- // eslint-disable-next-line @typescript-eslint/promise-function-async
344
- return (code: string) => executeEdit(context, code);
345
303
  }
package/src/api.ts CHANGED
@@ -5,11 +5,12 @@
5
5
 
6
6
  import type { ImplicitFieldSchema, TreeNode } from "@fluidframework/tree";
7
7
  // These are used for doc links
8
- import type { FactoryContentObject, ReadableField } from "@fluidframework/tree/alpha";
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";
8
+ import type {
9
+ FactoryContentObject,
10
+ ReadableField,
11
+ TreeBranchAlpha,
12
+ TreeViewAlpha,
13
+ } from "@fluidframework/tree/alpha";
13
14
 
14
15
  /**
15
16
  * Logger interface for logging events from a {@link SharedTreeSemanticAgent}.
@@ -22,10 +23,31 @@ export interface Logger {
22
23
  log(message: string): void;
23
24
  }
24
25
 
26
+ /**
27
+ * A SharedTree view for use by a {@link SharedTreeSemanticAgent}.
28
+ * @alpha
29
+ * @privateRemarks This is a subset of the TreeViewAlpha functionality because if take it wholesale, it causes problems with invariance of the generic parameters.
30
+ */
31
+ export type TreeView<TRoot extends ImplicitFieldSchema> = Pick<
32
+ TreeViewAlpha<TRoot>,
33
+ "root" | "fork" | "merge" | "rebaseOnto" | "schema" | "events"
34
+ > &
35
+ TreeBranchAlpha;
36
+
37
+ /**
38
+ * A value that is either a {@link TreeView} or a subtree within a {@link TreeView}.
39
+ * @alpha
40
+ */
41
+ export type ViewOrTree<TSchema extends ImplicitFieldSchema> =
42
+ | TreeView<TSchema>
43
+ | (ReadableField<TSchema> & TreeNode);
44
+
25
45
  /**
26
46
  * The context object available to generated code when editing a tree.
27
47
  * @remarks This object is provided to JavaScript code executed by the {@link SynchronousEditor | editor} as a variable named `context`.
28
48
  * It contains the current state of the tree and utilities for creating and inspecting tree nodes.
49
+ *
50
+ * Use {@link createContext} to create a context.
29
51
  * @alpha
30
52
  */
31
53
  export interface Context<TSchema extends ImplicitFieldSchema> {
@@ -97,21 +119,39 @@ export interface Context<TSchema extends ImplicitFieldSchema> {
97
119
 
98
120
  /**
99
121
  * A synchronous function that executes a string of JavaScript code to perform an edit within a {@link SharedTreeSemanticAgent}.
100
- * @param context - An object that must be provided to the generated code as a variable named "context" in its top-level scope.
122
+ * @param tree - The tree to edit.
101
123
  * @param code - The JavaScript code that should be executed.
102
- * @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.
124
+ * @throws Any error thrown by the executed code.
125
+ * @remarks The code expects a variable named `context` to be in scope, which provides access to the tree and utilities for creating and inspecting nodes.
126
+ * A context can be created for a given tree via the {@link createContext} function.
127
+ * @example
128
+ * ```ts
129
+ * // A simple editor implementation that runs the provided code via a JavaScript Function.
130
+ * new Function("context", code)(createContext(tree));
131
+ * ```
103
132
  * @alpha
104
133
  */
105
- export type SynchronousEditor = (context: Record<string, unknown>, code: string) => void;
134
+ export type SynchronousEditor<TSchema extends ImplicitFieldSchema> = (
135
+ tree: ViewOrTree<TSchema>,
136
+ code: string,
137
+ ) => void;
138
+
106
139
  /**
107
140
  * An asynchronous function that executes a string of JavaScript code to perform an edit within a {@link SharedTreeSemanticAgent}.
108
- * @param context - An object that must be provided to the generated code as a variable named "context" in its top-level scope.
141
+ * @param tree - The tree to edit.
109
142
  * @param code - The JavaScript code that should be executed.
110
- * @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.
143
+ * @throws Any error thrown by the executed code.
144
+ * @remarks The code expects a variable named `context` to be in scope, which provides access to the tree and utilities for creating and inspecting nodes.
145
+ * A context can be created for a given tree via the {@link createContext} function.
146
+ * @example
147
+ * ```ts
148
+ * // A simple editor implementation that runs the provided code via a JavaScript Function.
149
+ * await new Function("context", code)(createContext(tree));
150
+ * ```
111
151
  * @alpha
112
152
  */
113
- export type AsynchronousEditor = (
114
- context: Record<string, unknown>,
153
+ export type AsynchronousEditor<TSchema extends ImplicitFieldSchema> = (
154
+ tree: ViewOrTree<TSchema>,
115
155
  code: string,
116
156
  ) => Promise<void>;
117
157
 
@@ -119,7 +159,7 @@ export type AsynchronousEditor = (
119
159
  * Options used to parameterize the creation of a {@link SharedTreeSemanticAgent}.
120
160
  * @alpha
121
161
  */
122
- export interface SemanticAgentOptions {
162
+ export interface SemanticAgentOptions<TSchema extends ImplicitFieldSchema> {
123
163
  /**
124
164
  * Additional information about the application domain that will be included in the context provided to the {@link SharedTreeChatModel | model}.
125
165
  */
@@ -127,12 +167,10 @@ export interface SemanticAgentOptions {
127
167
  /**
128
168
  * Executes any generated JavaScript created by the {@link SharedTreeChatModel.editToolName | model's editing tool}.
129
169
  * @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.
130
- * @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.
131
- * Use a library such as SES to provide a more secure implementation - see `@fluidframework/tree-agent-ses` for a drop-in implementation.
132
- *
133
- * 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.
170
+ * @remarks If this function is not provided, the generated code will be executed using a simple JavaScript eval which may not provide sufficient security guarantees for some environments.
171
+ * Run the code in a sandboxed environment or use a library such as SES to provide a more secure implementation - see `@fluidframework/tree-agent-ses` for a drop-in implementation.
134
172
  */
135
- editor?: SynchronousEditor | AsynchronousEditor;
173
+ editor?: SynchronousEditor<TSchema> | AsynchronousEditor<TSchema>;
136
174
  /**
137
175
  * The maximum number of sequential edits the LLM can make before we assume it's stuck in a loop.
138
176
  */
@@ -234,14 +272,3 @@ export interface SharedTreeChatModel {
234
272
  */
235
273
  query(message: SharedTreeChatQuery): Promise<string>;
236
274
  }
237
-
238
- /**
239
- * A function that edits a SharedTree.
240
- */
241
- export type EditFunction<TSchema extends ImplicitFieldSchema> = ({
242
- root,
243
- create,
244
- }: {
245
- root: ReadableField<TSchema>;
246
- create: Record<string, (input: FactoryContentObject) => TreeNode>;
247
- }) => void | Promise<void>;
package/src/index.ts CHANGED
@@ -11,9 +11,7 @@
11
11
 
12
12
  export {
13
13
  SharedTreeSemanticAgent,
14
- bindEditor,
15
- bindEditorImpl,
16
- defaultEditor,
14
+ createContext,
17
15
  } from "./agent.js";
18
16
  export type {
19
17
  EditResult,
@@ -23,8 +21,11 @@ export type {
23
21
  SemanticAgentOptions,
24
22
  SynchronousEditor,
25
23
  AsynchronousEditor,
24
+ TreeView,
25
+ ViewOrTree,
26
+ Context,
26
27
  } from "./api.js";
27
- export { type TreeView, llmDefault } from "./utils.js";
28
+ export { llmDefault } from "./utils.js";
28
29
  export {
29
30
  buildFunc,
30
31
  exposeMethodsSymbol,
@@ -38,3 +39,14 @@ export {
38
39
  type Infer,
39
40
  type IExposedMethods,
40
41
  } from "./methodBinding.js";
42
+ export type {
43
+ exposePropertiesSymbol,
44
+ PropertyDef,
45
+ ExposedProperties,
46
+ IExposedProperties,
47
+ ExposableKeys,
48
+ ReadOnlyRequirement,
49
+ ReadonlyKeys,
50
+ TypeMatchOrError,
51
+ IfEquals,
52
+ } from "./propertyBinding.js";
package/src/prompt.ts CHANGED
@@ -25,8 +25,8 @@ import {
25
25
  /**
26
26
  * Produces a "system" prompt for the tree agent, based on the provided subtree.
27
27
  */
28
- export function getPrompt<TRoot extends ImplicitFieldSchema>(args: {
29
- subtree: Subtree<TRoot>;
28
+ export function getPrompt(args: {
29
+ subtree: Pick<Subtree<ImplicitFieldSchema>, "schema" | "field">;
30
30
  editToolName: string | undefined;
31
31
  domainHints?: string;
32
32
  }): string {
@@ -121,23 +121,23 @@ export function getPrompt<TRoot extends ImplicitFieldSchema>(args: {
121
121
  * ${`Example: Check if a node is a ${exampleTypeName} with \`if (context.is.${exampleTypeName}(node)) {}\``}
122
122
  */
123
123
  is: Record<string, <T extends TreeData>(data: unknown) => data is T>;
124
-
124
+
125
125
  /**
126
126
  * Checks if the provided data is an array.
127
127
  * @remarks
128
128
  * DO NOT use \`Array.isArray\` to check if tree data is an array - use this function instead.
129
- *
129
+ *
130
130
  * This function will also work for native JavaScript arrays.
131
131
  *
132
132
  * ${`Example: \`if (context.isArray(node)) {}\``}
133
133
  */
134
134
  isArray(data: any): boolean;
135
-
135
+
136
136
  /**
137
137
  * Checks if the provided data is a map.
138
138
  * @remarks
139
139
  * DO NOT use \`instanceof Map\` to check if tree data is a map - use this function instead.
140
- *
140
+ *
141
141
  * This function will also work for native JavaScript Map instances.
142
142
  *
143
143
  * ${`Example: \`if (context.isMap(node)) {}\``}