@fluidframework/type-factory 2.93.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 (64) hide show
  1. package/.mocharc.cjs +11 -0
  2. package/CHANGELOG.md +3 -0
  3. package/LICENSE +21 -0
  4. package/README.md +133 -0
  5. package/alpha.d.ts +11 -0
  6. package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
  7. package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
  8. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  9. package/api-extractor/api-extractor-lint-index.cjs.json +5 -0
  10. package/api-extractor/api-extractor-lint-index.esm.json +5 -0
  11. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  12. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  13. package/api-extractor.json +14 -0
  14. package/api-report/type-factory.alpha.api.md +208 -0
  15. package/api-report/type-factory.beta.api.md +7 -0
  16. package/api-report/type-factory.public.api.md +7 -0
  17. package/dist/alpha.d.ts +57 -0
  18. package/dist/index.d.ts +14 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +21 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/methodBinding.d.ts +101 -0
  23. package/dist/methodBinding.d.ts.map +1 -0
  24. package/dist/methodBinding.js +26 -0
  25. package/dist/methodBinding.js.map +1 -0
  26. package/dist/package.json +4 -0
  27. package/dist/propertyBinding.d.ts +50 -0
  28. package/dist/propertyBinding.d.ts.map +1 -0
  29. package/dist/propertyBinding.js +13 -0
  30. package/dist/propertyBinding.js.map +1 -0
  31. package/dist/public.d.ts +16 -0
  32. package/dist/treeAgentTypes.d.ts +428 -0
  33. package/dist/treeAgentTypes.d.ts.map +1 -0
  34. package/dist/treeAgentTypes.js +218 -0
  35. package/dist/treeAgentTypes.js.map +1 -0
  36. package/eslint.config.mts +43 -0
  37. package/internal.d.ts +11 -0
  38. package/lib/alpha.d.ts +57 -0
  39. package/lib/index.d.ts +14 -0
  40. package/lib/index.d.ts.map +1 -0
  41. package/lib/index.js +13 -0
  42. package/lib/index.js.map +1 -0
  43. package/lib/methodBinding.d.ts +101 -0
  44. package/lib/methodBinding.d.ts.map +1 -0
  45. package/lib/methodBinding.js +22 -0
  46. package/lib/methodBinding.js.map +1 -0
  47. package/lib/propertyBinding.d.ts +50 -0
  48. package/lib/propertyBinding.d.ts.map +1 -0
  49. package/lib/propertyBinding.js +10 -0
  50. package/lib/propertyBinding.js.map +1 -0
  51. package/lib/public.d.ts +16 -0
  52. package/lib/treeAgentTypes.d.ts +428 -0
  53. package/lib/treeAgentTypes.d.ts.map +1 -0
  54. package/lib/treeAgentTypes.js +214 -0
  55. package/lib/treeAgentTypes.js.map +1 -0
  56. package/lib/tsdoc-metadata.json +11 -0
  57. package/package.json +142 -0
  58. package/src/index.ts +57 -0
  59. package/src/methodBinding.ts +139 -0
  60. package/src/propertyBinding.ts +62 -0
  61. package/src/treeAgentTypes.ts +601 -0
  62. package/tsconfig.cjs.json +7 -0
  63. package/tsconfig.json +14 -0
  64. package/tsdoc.json +4 -0
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.typeFactory = exports.isTypeFactoryType = void 0;
8
+ const internal_1 = require("@fluidframework/telemetry-utils/internal");
9
+ /**
10
+ * Set of valid type factory type kinds for efficient validation.
11
+ * @internal
12
+ */
13
+ const validTypeKinds = new Set([
14
+ "string",
15
+ "number",
16
+ "boolean",
17
+ "void",
18
+ "undefined",
19
+ "null",
20
+ "unknown",
21
+ "date",
22
+ "promise",
23
+ "array",
24
+ "object",
25
+ "record",
26
+ "map",
27
+ "tuple",
28
+ "union",
29
+ "intersection",
30
+ "literal",
31
+ "optional",
32
+ "readonly",
33
+ "function",
34
+ "instanceof",
35
+ ]);
36
+ /**
37
+ * Type guard to check if a value is a type factory type.
38
+ * @alpha
39
+ */
40
+ function isTypeFactoryType(value) {
41
+ if (typeof value !== "object" || value === null || !("_kind" in value)) {
42
+ return false;
43
+ }
44
+ const kind = value._kind;
45
+ return typeof kind === "string" && validTypeKinds.has(kind);
46
+ }
47
+ exports.isTypeFactoryType = isTypeFactoryType;
48
+ /**
49
+ * Namespace containing type factory functions for building type definitions
50
+ * that describe method signatures and property types to an LLM agent.
51
+ *
52
+ * @internal
53
+ */
54
+ exports.typeFactory = {
55
+ /**
56
+ * Create a string type.
57
+ * @alpha
58
+ */
59
+ string() {
60
+ return { _kind: "string" };
61
+ },
62
+ /**
63
+ * Create a number type.
64
+ * @alpha
65
+ */
66
+ number() {
67
+ return { _kind: "number" };
68
+ },
69
+ /**
70
+ * Create a boolean type.
71
+ * @alpha
72
+ */
73
+ boolean() {
74
+ return { _kind: "boolean" };
75
+ },
76
+ /**
77
+ * Create a Date type.
78
+ * @alpha
79
+ */
80
+ date() {
81
+ return { _kind: "date" };
82
+ },
83
+ /**
84
+ * Create a void type.
85
+ * @alpha
86
+ */
87
+ void() {
88
+ return { _kind: "void" };
89
+ },
90
+ /**
91
+ * Create an undefined type.
92
+ * @alpha
93
+ */
94
+ undefined() {
95
+ return { _kind: "undefined" };
96
+ },
97
+ /**
98
+ * Create a null type.
99
+ * @alpha
100
+ */
101
+ null() {
102
+ return { _kind: "null" };
103
+ },
104
+ /**
105
+ * Create an unknown type.
106
+ * @alpha
107
+ */
108
+ unknown() {
109
+ return { _kind: "unknown" };
110
+ },
111
+ /**
112
+ * Create an array type.
113
+ * @alpha
114
+ */
115
+ array(element) {
116
+ return { _kind: "array", element };
117
+ },
118
+ /**
119
+ * Create a Promise type.
120
+ * @alpha
121
+ */
122
+ promise(innerType) {
123
+ return { _kind: "promise", innerType };
124
+ },
125
+ /**
126
+ * Create an object type.
127
+ * @alpha
128
+ */
129
+ object(shape) {
130
+ return { _kind: "object", shape };
131
+ },
132
+ /**
133
+ * Create a record type.
134
+ * @alpha
135
+ */
136
+ record(keyType, valueType) {
137
+ return { _kind: "record", keyType, valueType };
138
+ },
139
+ /**
140
+ * Create a map type.
141
+ * @alpha
142
+ */
143
+ map(keyType, valueType) {
144
+ return { _kind: "map", keyType, valueType };
145
+ },
146
+ /**
147
+ * Create a tuple type.
148
+ * @alpha
149
+ */
150
+ tuple(items, rest) {
151
+ if (items.length === 0 && rest === undefined) {
152
+ throw new internal_1.UsageError("typeFactory.tuple requires at least one item or a rest type. Empty tuples are not supported.");
153
+ }
154
+ return rest === undefined ? { _kind: "tuple", items } : { _kind: "tuple", items, rest };
155
+ },
156
+ /**
157
+ * Create a union type.
158
+ * @alpha
159
+ */
160
+ union(options) {
161
+ if (options.length === 0) {
162
+ throw new internal_1.UsageError("typeFactory.union requires at least one option. Empty unions are not valid TypeScript types.");
163
+ }
164
+ return { _kind: "union", options };
165
+ },
166
+ /**
167
+ * Create an intersection type.
168
+ * @alpha
169
+ */
170
+ intersection(types) {
171
+ if (types.length === 0) {
172
+ throw new internal_1.UsageError("typeFactory.intersection requires at least one type. Empty intersections are not valid TypeScript types.");
173
+ }
174
+ return { _kind: "intersection", types };
175
+ },
176
+ /**
177
+ * Create a literal type.
178
+ * @alpha
179
+ */
180
+ literal(value) {
181
+ return { _kind: "literal", value };
182
+ },
183
+ /**
184
+ * Create an optional type.
185
+ * @alpha
186
+ */
187
+ optional(innerType) {
188
+ return { _kind: "optional", innerType };
189
+ },
190
+ /**
191
+ * Create a readonly type.
192
+ * @alpha
193
+ */
194
+ readonly(innerType) {
195
+ return { _kind: "readonly", innerType };
196
+ },
197
+ /**
198
+ * Create a function type.
199
+ * @alpha
200
+ */
201
+ function(parameters, returnType, restParameter) {
202
+ return restParameter === undefined
203
+ ? { _kind: "function", parameters, returnType }
204
+ : { _kind: "function", parameters, returnType, restParameter };
205
+ },
206
+ /**
207
+ * Create an instanceOf type for a class.
208
+ * @remarks
209
+ * This is an untyped version. `@fluidframework/tree-agent` re-exports a
210
+ * narrower override that constrains the constructor to `ObjectNodeSchema`.
211
+ * @internal
212
+ */
213
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
+ instanceOf(constructor) {
215
+ return { _kind: "instanceof", constructor };
216
+ },
217
+ };
218
+ //# sourceMappingURL=treeAgentTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeAgentTypes.js","sourceRoot":"","sources":["../src/treeAgentTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uEAAsE;AAwCtE;;;GAGG;AACH,MAAM,cAAc,GAAqC,IAAI,GAAG,CAAsB;IACrF,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,WAAW;IACX,MAAM;IACN,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,OAAO;IACP,OAAO;IACP,cAAc;IACd,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;CACZ,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAI,KAA4B,CAAC,KAAK,CAAC;IACjD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,IAA2B,CAAC,CAAC;AACpF,CAAC;AAND,8CAMC;AA8TD;;;;;GAKG;AACU,QAAA,WAAW,GAAG;IAC1B;;;OAGG;IACH,MAAM;QACL,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM;QACL,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,OAAO;QACN,OAAO,EAAE,KAAK,EAAE,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,EAAE,CAAC;IACjE,CAAC;IAED;;;;;;OAMG;IACH,8DAA8D;IAC9D,UAAU,CAAC,WAA4C;QACtD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;IAC7C,CAAC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Type kinds for the type factory type system.\n * @alpha\n */\nexport type TypeFactoryTypeKind =\n\t| \"string\"\n\t| \"number\"\n\t| \"boolean\"\n\t| \"void\"\n\t| \"undefined\"\n\t| \"null\"\n\t| \"unknown\"\n\t| \"date\"\n\t| \"promise\"\n\t| \"array\"\n\t| \"object\"\n\t| \"record\"\n\t| \"map\"\n\t| \"tuple\"\n\t| \"union\"\n\t| \"intersection\"\n\t| \"literal\"\n\t| \"optional\"\n\t| \"readonly\"\n\t| \"function\"\n\t| \"instanceof\";\n\n/**\n * Base interface for type factory types.\n * @alpha\n */\nexport interface TypeFactoryType {\n\t/**\n\t * The kind of type this represents.\n\t */\n\treadonly _kind: TypeFactoryTypeKind;\n}\n\n/**\n * Set of valid type factory type kinds for efficient validation.\n * @internal\n */\nconst validTypeKinds: ReadonlySet<TypeFactoryTypeKind> = new Set<TypeFactoryTypeKind>([\n\t\"string\",\n\t\"number\",\n\t\"boolean\",\n\t\"void\",\n\t\"undefined\",\n\t\"null\",\n\t\"unknown\",\n\t\"date\",\n\t\"promise\",\n\t\"array\",\n\t\"object\",\n\t\"record\",\n\t\"map\",\n\t\"tuple\",\n\t\"union\",\n\t\"intersection\",\n\t\"literal\",\n\t\"optional\",\n\t\"readonly\",\n\t\"function\",\n\t\"instanceof\",\n]);\n\n/**\n * Type guard to check if a value is a type factory type.\n * @alpha\n */\nexport function isTypeFactoryType(value: unknown): value is TypeFactoryType {\n\tif (typeof value !== \"object\" || value === null || !(\"_kind\" in value)) {\n\t\treturn false;\n\t}\n\tconst kind = (value as { _kind: unknown })._kind;\n\treturn typeof kind === \"string\" && validTypeKinds.has(kind as TypeFactoryTypeKind);\n}\n\n// Primitive type factories\n\n/**\n * Represents a string type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryString extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"string\";\n}\n\n/**\n * Represents a number type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryNumber extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"number\";\n}\n\n/**\n * Represents a boolean type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryBoolean extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"boolean\";\n}\n\n/**\n * Represents a Date type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryDate extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"date\";\n}\n\n/**\n * Represents a void type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryVoid extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"void\";\n}\n\n/**\n * Represents an undefined type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUndefined extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"undefined\";\n}\n\n/**\n * Represents a null type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryNull extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"null\";\n}\n\n/**\n * Represents an unknown type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUnknown extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"unknown\";\n}\n\n// Complex type interfaces\n\n/**\n * Represents an array type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryArray extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"array\";\n\t/**\n\t * The type of elements in the array.\n\t */\n\treadonly element: TypeFactoryType;\n}\n\n/**\n * Represents a Promise type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryPromise extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"promise\";\n\t/**\n\t * The type that the Promise resolves to.\n\t */\n\treadonly innerType: TypeFactoryType;\n}\n\n/**\n * Represents an object type with a fixed shape in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryObject extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"object\";\n\t/**\n\t * The shape of the object, mapping property names to their types.\n\t */\n\treadonly shape: Record<string, TypeFactoryType>;\n}\n\n/**\n * Represents a record type (index signature) in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryRecord extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"record\";\n\t/**\n\t * The type of the record's keys.\n\t */\n\treadonly keyType: TypeFactoryType;\n\t/**\n\t * The type of the record's values.\n\t */\n\treadonly valueType: TypeFactoryType;\n}\n\n/**\n * Represents a Map type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryMap extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"map\";\n\t/**\n\t * The type of the map's keys.\n\t */\n\treadonly keyType: TypeFactoryType;\n\t/**\n\t * The type of the map's values.\n\t */\n\treadonly valueType: TypeFactoryType;\n}\n\n/**\n * Represents a tuple type with fixed-length items and optional rest elements in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryTuple extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"tuple\";\n\t/**\n\t * The fixed-length items in the tuple.\n\t */\n\treadonly items: readonly TypeFactoryType[];\n\t/**\n\t * Optional rest element type for variable-length tuples.\n\t */\n\treadonly rest?: TypeFactoryType;\n}\n\n/**\n * Represents a union type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryUnion extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"union\";\n\t/**\n\t * The possible types in the union.\n\t */\n\treadonly options: readonly TypeFactoryType[];\n}\n\n/**\n * Represents an intersection type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryIntersection extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"intersection\";\n\t/**\n\t * The types to intersect.\n\t */\n\treadonly types: readonly TypeFactoryType[];\n}\n\n/**\n * Represents a literal type (specific string, number, or boolean value) in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryLiteral extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"literal\";\n\t/**\n\t * The specific literal value.\n\t */\n\treadonly value: string | number | boolean;\n}\n\n/**\n * Represents an optional type modifier in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryOptional extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"optional\";\n\t/**\n\t * The inner type that is optional.\n\t */\n\treadonly innerType: TypeFactoryType;\n}\n\n/**\n * Represents a readonly type modifier in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryReadonly extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"readonly\";\n\t/**\n\t * The inner type that is readonly.\n\t */\n\treadonly innerType: TypeFactoryType;\n}\n\n/**\n * Represents a function parameter as a tuple of [name, type].\n * @alpha\n */\nexport type TypeFactoryFunctionParameter = readonly [name: string, type: TypeFactoryType];\n\n/**\n * Represents a function type in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryFunction extends TypeFactoryType {\n\t/**\n\t * {@inheritDoc TypeFactoryType._kind}\n\t */\n\treadonly _kind: \"function\";\n\t/**\n\t * The function parameters.\n\t */\n\treadonly parameters: readonly TypeFactoryFunctionParameter[];\n\t/**\n\t * The function return type.\n\t */\n\treadonly returnType: TypeFactoryType;\n\t/**\n\t * Optional rest parameter for variable-length argument lists.\n\t */\n\treadonly restParameter?: TypeFactoryFunctionParameter;\n}\n\n/**\n * Represents an instanceof type that references a class in the type factory system.\n * @alpha\n */\nexport interface TypeFactoryInstanceOf extends TypeFactoryType {\n\t/**\n\t * The kind of type this represents.\n\t */\n\treadonly _kind: \"instanceof\";\n\t/**\n\t * The constructor to reference.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\treadonly constructor: new (\n\t\t...args: any[]\n\t) => unknown;\n}\n\n/**\n * Namespace containing type factory functions for building type definitions\n * that describe method signatures and property types to an LLM agent.\n *\n * @internal\n */\nexport const typeFactory = {\n\t/**\n\t * Create a string type.\n\t * @alpha\n\t */\n\tstring(): TypeFactoryString {\n\t\treturn { _kind: \"string\" };\n\t},\n\n\t/**\n\t * Create a number type.\n\t * @alpha\n\t */\n\tnumber(): TypeFactoryNumber {\n\t\treturn { _kind: \"number\" };\n\t},\n\n\t/**\n\t * Create a boolean type.\n\t * @alpha\n\t */\n\tboolean(): TypeFactoryBoolean {\n\t\treturn { _kind: \"boolean\" };\n\t},\n\n\t/**\n\t * Create a Date type.\n\t * @alpha\n\t */\n\tdate(): TypeFactoryDate {\n\t\treturn { _kind: \"date\" };\n\t},\n\n\t/**\n\t * Create a void type.\n\t * @alpha\n\t */\n\tvoid(): TypeFactoryVoid {\n\t\treturn { _kind: \"void\" };\n\t},\n\n\t/**\n\t * Create an undefined type.\n\t * @alpha\n\t */\n\tundefined(): TypeFactoryUndefined {\n\t\treturn { _kind: \"undefined\" };\n\t},\n\n\t/**\n\t * Create a null type.\n\t * @alpha\n\t */\n\tnull(): TypeFactoryNull {\n\t\treturn { _kind: \"null\" };\n\t},\n\n\t/**\n\t * Create an unknown type.\n\t * @alpha\n\t */\n\tunknown(): TypeFactoryUnknown {\n\t\treturn { _kind: \"unknown\" };\n\t},\n\n\t/**\n\t * Create an array type.\n\t * @alpha\n\t */\n\tarray(element: TypeFactoryType): TypeFactoryArray {\n\t\treturn { _kind: \"array\", element };\n\t},\n\n\t/**\n\t * Create a Promise type.\n\t * @alpha\n\t */\n\tpromise(innerType: TypeFactoryType): TypeFactoryPromise {\n\t\treturn { _kind: \"promise\", innerType };\n\t},\n\n\t/**\n\t * Create an object type.\n\t * @alpha\n\t */\n\tobject(shape: Record<string, TypeFactoryType>): TypeFactoryObject {\n\t\treturn { _kind: \"object\", shape };\n\t},\n\n\t/**\n\t * Create a record type.\n\t * @alpha\n\t */\n\trecord(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryRecord {\n\t\treturn { _kind: \"record\", keyType, valueType };\n\t},\n\n\t/**\n\t * Create a map type.\n\t * @alpha\n\t */\n\tmap(keyType: TypeFactoryType, valueType: TypeFactoryType): TypeFactoryMap {\n\t\treturn { _kind: \"map\", keyType, valueType };\n\t},\n\n\t/**\n\t * Create a tuple type.\n\t * @alpha\n\t */\n\ttuple(items: readonly TypeFactoryType[], rest?: TypeFactoryType): TypeFactoryTuple {\n\t\tif (items.length === 0 && rest === undefined) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.tuple requires at least one item or a rest type. Empty tuples are not supported.\",\n\t\t\t);\n\t\t}\n\t\treturn rest === undefined ? { _kind: \"tuple\", items } : { _kind: \"tuple\", items, rest };\n\t},\n\n\t/**\n\t * Create a union type.\n\t * @alpha\n\t */\n\tunion(options: readonly TypeFactoryType[]): TypeFactoryUnion {\n\t\tif (options.length === 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.union requires at least one option. Empty unions are not valid TypeScript types.\",\n\t\t\t);\n\t\t}\n\t\treturn { _kind: \"union\", options };\n\t},\n\n\t/**\n\t * Create an intersection type.\n\t * @alpha\n\t */\n\tintersection(types: readonly TypeFactoryType[]): TypeFactoryIntersection {\n\t\tif (types.length === 0) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"typeFactory.intersection requires at least one type. Empty intersections are not valid TypeScript types.\",\n\t\t\t);\n\t\t}\n\t\treturn { _kind: \"intersection\", types };\n\t},\n\n\t/**\n\t * Create a literal type.\n\t * @alpha\n\t */\n\tliteral(value: string | number | boolean): TypeFactoryLiteral {\n\t\treturn { _kind: \"literal\", value };\n\t},\n\n\t/**\n\t * Create an optional type.\n\t * @alpha\n\t */\n\toptional(innerType: TypeFactoryType): TypeFactoryOptional {\n\t\treturn { _kind: \"optional\", innerType };\n\t},\n\n\t/**\n\t * Create a readonly type.\n\t * @alpha\n\t */\n\treadonly(innerType: TypeFactoryType): TypeFactoryReadonly {\n\t\treturn { _kind: \"readonly\", innerType };\n\t},\n\n\t/**\n\t * Create a function type.\n\t * @alpha\n\t */\n\tfunction(\n\t\tparameters: readonly TypeFactoryFunctionParameter[],\n\t\treturnType: TypeFactoryType,\n\t\trestParameter?: TypeFactoryFunctionParameter,\n\t): TypeFactoryFunction {\n\t\treturn restParameter === undefined\n\t\t\t? { _kind: \"function\", parameters, returnType }\n\t\t\t: { _kind: \"function\", parameters, returnType, restParameter };\n\t},\n\n\t/**\n\t * Create an instanceOf type for a class.\n\t * @remarks\n\t * This is an untyped version. `@fluidframework/tree-agent` re-exports a\n\t * narrower override that constrains the constructor to `ObjectNodeSchema`.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinstanceOf(constructor: new (...args: any[]) => unknown): TypeFactoryInstanceOf {\n\t\treturn { _kind: \"instanceof\", constructor };\n\t},\n};\n"]}
@@ -0,0 +1,43 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { Linter } from "eslint";
7
+ import { strict } from "@fluidframework/eslint-config-fluid/flat.mts";
8
+
9
+ const config: Linter.Config[] = [
10
+ ...strict,
11
+ {
12
+ rules: {
13
+ "import-x/no-internal-modules": [
14
+ "error",
15
+ {
16
+ "allow": [
17
+ "@fluidframework/*/alpha",
18
+ "@fluidframework/*/beta",
19
+ "@fluidframework/*/internal",
20
+ ],
21
+ },
22
+ ],
23
+ },
24
+ },
25
+ {
26
+ files: ["src/test/**/*"],
27
+ rules: {
28
+ "import-x/no-internal-modules": [
29
+ "error",
30
+ {
31
+ "allow": [
32
+ "*/index.js",
33
+ "@fluidframework/*/alpha",
34
+ "@fluidframework/*/beta",
35
+ "@fluidframework/*/internal",
36
+ ],
37
+ },
38
+ ],
39
+ },
40
+ },
41
+ ];
42
+
43
+ export default config;
package/internal.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /*
7
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
+ */
10
+
11
+ export * from "./lib/index.js";
package/lib/alpha.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /*
7
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
+ */
10
+
11
+ /**
12
+ * Shared types for exposing schema methods and properties to an LLM agent.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+
17
+ export {
18
+ // #region @alpha APIs
19
+ Arg,
20
+ ArgsTuple,
21
+ Ctor,
22
+ ExposedMethods,
23
+ ExposedProperties,
24
+ FunctionDef,
25
+ IExposedMethods,
26
+ IExposedProperties,
27
+ MethodKeys,
28
+ TypeFactoryArray,
29
+ TypeFactoryBoolean,
30
+ TypeFactoryDate,
31
+ TypeFactoryFunction,
32
+ TypeFactoryFunctionParameter,
33
+ TypeFactoryInstanceOf,
34
+ TypeFactoryIntersection,
35
+ TypeFactoryLiteral,
36
+ TypeFactoryMap,
37
+ TypeFactoryNull,
38
+ TypeFactoryNumber,
39
+ TypeFactoryObject,
40
+ TypeFactoryOptional,
41
+ TypeFactoryPromise,
42
+ TypeFactoryReadonly,
43
+ TypeFactoryRecord,
44
+ TypeFactoryString,
45
+ TypeFactoryTuple,
46
+ TypeFactoryType,
47
+ TypeFactoryTypeKind,
48
+ TypeFactoryUndefined,
49
+ TypeFactoryUnion,
50
+ TypeFactoryUnknown,
51
+ TypeFactoryVoid,
52
+ buildFunc,
53
+ exposeMethodsSymbol,
54
+ exposePropertiesSymbol,
55
+ isTypeFactoryType
56
+ // #endregion
57
+ } from "./index.js";
package/lib/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Shared types for exposing schema methods and properties to an LLM agent.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { buildFunc, exposeMethodsSymbol, type ExposedMethods, type Arg, type ArgsTuple, type FunctionDef, type MethodKeys, type Ctor, type IExposedMethods, } from "./methodBinding.js";
11
+ export { exposePropertiesSymbol, type ExposedProperties, type IExposedProperties, } from "./propertyBinding.js";
12
+ export { typeFactory, isTypeFactoryType } from "./treeAgentTypes.js";
13
+ export type { TypeFactoryType, TypeFactoryTypeKind, TypeFactoryString, TypeFactoryNumber, TypeFactoryBoolean, TypeFactoryDate, TypeFactoryVoid, TypeFactoryUndefined, TypeFactoryNull, TypeFactoryUnknown, TypeFactoryArray, TypeFactoryPromise, TypeFactoryObject, TypeFactoryRecord, TypeFactoryMap, TypeFactoryTuple, TypeFactoryUnion, TypeFactoryIntersection, TypeFactoryLiteral, TypeFactoryOptional, TypeFactoryReadonly, TypeFactoryFunction, TypeFactoryFunctionParameter, TypeFactoryInstanceOf, } from "./treeAgentTypes.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,SAAS,EACT,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,eAAe,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAErE,YAAY,EACX,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,GACrB,MAAM,qBAAqB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Shared types for exposing schema methods and properties to an LLM agent.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { buildFunc, exposeMethodsSymbol, } from "./methodBinding.js";
11
+ export { exposePropertiesSymbol, } from "./propertyBinding.js";
12
+ export { typeFactory, isTypeFactoryType } from "./treeAgentTypes.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,SAAS,EACT,mBAAmB,GAQnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,sBAAsB,GAGtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Shared types for exposing schema methods and properties to an LLM agent.\n *\n * @packageDocumentation\n */\n\nexport {\n\tbuildFunc,\n\texposeMethodsSymbol,\n\ttype ExposedMethods,\n\ttype Arg,\n\ttype ArgsTuple,\n\ttype FunctionDef,\n\ttype MethodKeys,\n\ttype Ctor,\n\ttype IExposedMethods,\n} from \"./methodBinding.js\";\n\nexport {\n\texposePropertiesSymbol,\n\ttype ExposedProperties,\n\ttype IExposedProperties,\n} from \"./propertyBinding.js\";\n\nexport { typeFactory, isTypeFactoryType } from \"./treeAgentTypes.js\";\n\nexport type {\n\tTypeFactoryType,\n\tTypeFactoryTypeKind,\n\tTypeFactoryString,\n\tTypeFactoryNumber,\n\tTypeFactoryBoolean,\n\tTypeFactoryDate,\n\tTypeFactoryVoid,\n\tTypeFactoryUndefined,\n\tTypeFactoryNull,\n\tTypeFactoryUnknown,\n\tTypeFactoryArray,\n\tTypeFactoryPromise,\n\tTypeFactoryObject,\n\tTypeFactoryRecord,\n\tTypeFactoryMap,\n\tTypeFactoryTuple,\n\tTypeFactoryUnion,\n\tTypeFactoryIntersection,\n\tTypeFactoryLiteral,\n\tTypeFactoryOptional,\n\tTypeFactoryReadonly,\n\tTypeFactoryFunction,\n\tTypeFactoryFunctionParameter,\n\tTypeFactoryInstanceOf,\n} from \"./treeAgentTypes.js\";\n"]}
@@ -0,0 +1,101 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { TypeFactoryType } from "./treeAgentTypes.js";
6
+ /**
7
+ * A utility type that extracts the method keys from a given type.
8
+ * @alpha
9
+ */
10
+ export type MethodKeys<T> = {
11
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
12
+ };
13
+ /**
14
+ * A type that represents a constructor function.
15
+ * @alpha
16
+ */
17
+ export type Ctor<T = any> = new (...args: any[]) => T;
18
+ /**
19
+ * A type that represents a function argument.
20
+ * @alpha
21
+ */
22
+ export type Arg<T extends TypeFactoryType = TypeFactoryType> = readonly [
23
+ name: string,
24
+ type: T
25
+ ];
26
+ /**
27
+ * A utility type that extracts the argument types from a function definition.
28
+ * @alpha
29
+ */
30
+ export type ArgsTuple<T extends readonly Arg[]> = T extends readonly [infer Single extends Arg] ? [Single[1]] : T extends readonly [infer Head extends Arg, ...infer Tail extends readonly Arg[]] ? [Head[1], ...ArgsTuple<Tail>] : never;
31
+ /**
32
+ * A function definition interface that describes the structure of a function.
33
+ * @alpha
34
+ */
35
+ export interface FunctionDef<Args extends readonly Arg[], Return extends TypeFactoryType, Rest extends TypeFactoryType | null = null> {
36
+ /**
37
+ * Optional description of the function.
38
+ */
39
+ description?: string;
40
+ /**
41
+ * The function's parameters.
42
+ */
43
+ args: Args;
44
+ /**
45
+ * Optional rest parameter type.
46
+ */
47
+ rest?: Rest;
48
+ /**
49
+ * The function's return type.
50
+ */
51
+ returns: Return;
52
+ }
53
+ /**
54
+ * A utility function to build a function definition.
55
+ * @alpha
56
+ */
57
+ export declare function buildFunc<const Return extends TypeFactoryType, const Args extends readonly Arg[], const Rest extends TypeFactoryType | null = null>(def: {
58
+ description?: string;
59
+ returns: Return;
60
+ rest?: Rest;
61
+ }, ...args: Args): FunctionDef<Args, Return, Rest>;
62
+ /**
63
+ * An interface for exposing methods of classes to an agent.
64
+ * @alpha
65
+ */
66
+ export interface ExposedMethods {
67
+ /**
68
+ * Expose a method with type factory types.
69
+ */
70
+ exposeMethod<const K extends string & keyof MethodKeys<InstanceType<S>>, S extends Ctor & IExposedMethods, Z extends FunctionDef<readonly Arg[], TypeFactoryType, TypeFactoryType | null>>(constructor: S, methodName: K, tfFunction: Z): void;
71
+ /**
72
+ * Expose a method with type factory types.
73
+ */
74
+ expose<const K extends string & keyof MethodKeys<InstanceType<S>>, S extends Ctor & IExposedMethods, Z extends FunctionDef<readonly Arg[], TypeFactoryType, TypeFactoryType | null>>(constructor: S, methodName: K, tfFunction: Z): void;
75
+ }
76
+ /**
77
+ * A symbol used to expose methods to the LLM.
78
+ * @alpha
79
+ */
80
+ export declare const exposeMethodsSymbol: unique symbol;
81
+ /**
82
+ * An interface that classes should implement to expose their methods to the LLM.
83
+ *
84
+ * @remarks
85
+ * The `getExposedMethods` free function will cause the method here to be called on the class passed to it.
86
+ *
87
+ * @privateremarks
88
+ * Implementing this interface correctly seems tricky?
89
+ * To actually implement it in a way that satisfies TypeScript,
90
+ * classes need to declare both a static version and an instance version of the method
91
+ * (the instance one can just delegate to the static one).
92
+ *
93
+ * @alpha
94
+ */
95
+ export interface IExposedMethods {
96
+ /**
97
+ * Static method that exposes methods of this class to an agent.
98
+ */
99
+ [exposeMethodsSymbol](methods: ExposedMethods): void;
100
+ }
101
+ //# sourceMappingURL=methodBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methodBinding.d.ts","sourceRoot":"","sources":["../src/methodBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM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Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * A utility function to build a function definition.
7
+ * @alpha
8
+ */
9
+ export function buildFunc(def, ...args) {
10
+ return {
11
+ description: def.description,
12
+ returns: def.returns,
13
+ args,
14
+ rest: def.rest,
15
+ };
16
+ }
17
+ /**
18
+ * A symbol used to expose methods to the LLM.
19
+ * @alpha
20
+ */
21
+ export const exposeMethodsSymbol = Symbol("Type factory expose method/symbol");
22
+ //# sourceMappingURL=methodBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methodBinding.js","sourceRoot":"","sources":["../src/methodBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkEH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAKxB,GAA2D,EAC3D,GAAG,IAAU;IAEb,OAAO;QACN,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,IAAI;KACd,CAAC;AACH,CAAC;AA0BD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkB,MAAM,CAAC,mCAAmC,CAAC,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-explicit-any */\n\nimport type { TypeFactoryType } from \"./treeAgentTypes.js\";\n\n/**\n * A utility type that extracts the method keys from a given type.\n * @alpha\n */\nexport type MethodKeys<T> = {\n\t[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;\n};\n\n/**\n * A type that represents a constructor function.\n * @alpha\n */\nexport type Ctor<T = any> = new (...args: any[]) => T;\n\n/**\n * A type that represents a function argument.\n * @alpha\n */\nexport type Arg<T extends TypeFactoryType = TypeFactoryType> = readonly [\n\tname: string,\n\ttype: T,\n];\n\n/**\n * A utility type that extracts the argument types from a function definition.\n * @alpha\n */\nexport type ArgsTuple<T extends readonly Arg[]> = T extends readonly [infer Single extends Arg]\n\t? [Single[1]]\n\t: T extends readonly [infer Head extends Arg, ...infer Tail extends readonly Arg[]]\n\t\t? [Head[1], ...ArgsTuple<Tail>]\n\t\t: never;\n\n/**\n * A function definition interface that describes the structure of a function.\n * @alpha\n */\nexport interface FunctionDef<\n\tArgs extends readonly Arg[],\n\tReturn extends TypeFactoryType,\n\tRest extends TypeFactoryType | null = null,\n> {\n\t/**\n\t * Optional description of the function.\n\t */\n\tdescription?: string;\n\t/**\n\t * The function's parameters.\n\t */\n\targs: Args;\n\t/**\n\t * Optional rest parameter type.\n\t */\n\trest?: Rest;\n\t/**\n\t * The function's return type.\n\t */\n\treturns: Return;\n}\n\n/**\n * A utility function to build a function definition.\n * @alpha\n */\nexport function buildFunc<\n\tconst Return extends TypeFactoryType,\n\tconst Args extends readonly Arg[],\n\tconst Rest extends TypeFactoryType | null = null,\n>(\n\tdef: { description?: string; returns: Return; rest?: Rest },\n\t...args: Args\n): FunctionDef<Args, Return, Rest> {\n\treturn {\n\t\tdescription: def.description,\n\t\treturns: def.returns,\n\t\targs,\n\t\trest: def.rest,\n\t};\n}\n\n/**\n * An interface for exposing methods of classes to an agent.\n * @alpha\n */\nexport interface ExposedMethods {\n\t/**\n\t * Expose a method with type factory types.\n\t */\n\texposeMethod<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends Ctor & IExposedMethods,\n\t\tZ extends FunctionDef<readonly Arg[], TypeFactoryType, TypeFactoryType | null>,\n\t>(constructor: S, methodName: K, tfFunction: Z): void;\n\n\t/**\n\t * Expose a method with type factory types.\n\t */\n\texpose<\n\t\tconst K extends string & keyof MethodKeys<InstanceType<S>>,\n\t\tS extends Ctor & IExposedMethods,\n\t\tZ extends FunctionDef<readonly Arg[], TypeFactoryType, TypeFactoryType | null>,\n\t>(constructor: S, methodName: K, tfFunction: Z): void;\n}\n\n/**\n * A symbol used to expose methods to the LLM.\n * @alpha\n */\nexport const exposeMethodsSymbol: unique symbol = Symbol(\"Type factory expose method/symbol\");\n\n/**\n * An interface that classes should implement to expose their methods to the LLM.\n *\n * @remarks\n * The `getExposedMethods` free function will cause the method here to be called on the class passed to it.\n *\n * @privateremarks\n * Implementing this interface correctly seems tricky?\n * To actually implement it in a way that satisfies TypeScript,\n * classes need to declare both a static version and an instance version of the method\n * (the instance one can just delegate to the static one).\n *\n * @alpha\n */\nexport interface IExposedMethods {\n\t/**\n\t * Static method that exposes methods of this class to an agent.\n\t */\n\t[exposeMethodsSymbol](methods: ExposedMethods): void;\n}\n"]}
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { Ctor } from "./methodBinding.js";
6
+ import type { TypeFactoryType } from "./treeAgentTypes.js";
7
+ /**
8
+ * A symbol used to expose properties to the LLM.
9
+ * @alpha
10
+ */
11
+ export declare const exposePropertiesSymbol: unique symbol;
12
+ /**
13
+ * An interface for exposing properties of classes to an agent.
14
+ * @alpha
15
+ */
16
+ export interface ExposedProperties {
17
+ /**
18
+ * Expose a property with type factory type and metadata.
19
+ */
20
+ exposeProperty<S extends Ctor, K extends string>(constructor: S, name: K, def: {
21
+ schema: TypeFactoryType;
22
+ description?: string;
23
+ readOnly?: boolean;
24
+ }): void;
25
+ /**
26
+ * Expose a property with type factory type (simple form).
27
+ */
28
+ exposeProperty<S extends Ctor, K extends string>(constructor: S, name: K, tfType: TypeFactoryType): void;
29
+ }
30
+ /**
31
+ * An interface that classes should implement to expose their properties to the LLM.
32
+ *
33
+ * @remarks
34
+ * The `getExposedProperties` free function will cause the method here to be called on the class passed to it.
35
+ *
36
+ * @privateremarks
37
+ * Implementing this interface correctly seems tricky?
38
+ * To actually implement it in a way that satisfies TypeScript,
39
+ * classes need to declare both a static version and an instance version of the method
40
+ * (the instance one can just delegate to the static one).
41
+ *
42
+ * @alpha
43
+ */
44
+ export interface IExposedProperties {
45
+ /**
46
+ * Static method that exposes properties of this class to an agent.
47
+ */
48
+ [exposePropertiesSymbol]?(properties: ExposedProperties): void;
49
+ }
50
+ //# sourceMappingURL=propertyBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyBinding.d.ts","sourceRoot":"","sources":["../src/propertyBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,MAE3C,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,cAAc,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,EAC9C,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,CAAC,EACP,GAAG,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACxE,IAAI,CAAC;IAER;;OAEG;IACH,cAAc,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,EAC9C,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,eAAe,GACrB,IAAI,CAAC;CACR;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,CAAC,sBAAsB,CAAC,CAAC,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC/D"}
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * A symbol used to expose properties to the LLM.
7
+ * @alpha
8
+ */
9
+ export const exposePropertiesSymbol = Symbol("Type factory expose property/symbol");
10
+ //# sourceMappingURL=propertyBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyBinding.js","sourceRoot":"","sources":["../src/propertyBinding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB,MAAM,CAC1D,qCAAqC,CACrC,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-explicit-any */\n\nimport type { Ctor } from \"./methodBinding.js\";\nimport type { TypeFactoryType } from \"./treeAgentTypes.js\";\n\n/**\n * A symbol used to expose properties to the LLM.\n * @alpha\n */\nexport const exposePropertiesSymbol: unique symbol = Symbol(\n\t\"Type factory expose property/symbol\",\n);\n\n/**\n * An interface for exposing properties of classes to an agent.\n * @alpha\n */\nexport interface ExposedProperties {\n\t/**\n\t * Expose a property with type factory type and metadata.\n\t */\n\texposeProperty<S extends Ctor, K extends string>(\n\t\tconstructor: S,\n\t\tname: K,\n\t\tdef: { schema: TypeFactoryType; description?: string; readOnly?: boolean },\n\t): void;\n\n\t/**\n\t * Expose a property with type factory type (simple form).\n\t */\n\texposeProperty<S extends Ctor, K extends string>(\n\t\tconstructor: S,\n\t\tname: K,\n\t\ttfType: TypeFactoryType,\n\t): void;\n}\n\n/**\n * An interface that classes should implement to expose their properties to the LLM.\n *\n * @remarks\n * The `getExposedProperties` free function will cause the method here to be called on the class passed to it.\n *\n * @privateremarks\n * Implementing this interface correctly seems tricky?\n * To actually implement it in a way that satisfies TypeScript,\n * classes need to declare both a static version and an instance version of the method\n * (the instance one can just delegate to the static one).\n *\n * @alpha\n */\nexport interface IExposedProperties {\n\t/**\n\t * Static method that exposes properties of this class to an agent.\n\t */\n\t[exposePropertiesSymbol]?(properties: ExposedProperties): void;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /*
7
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
+ */
10
+
11
+ /**
12
+ * Shared types for exposing schema methods and properties to an LLM agent.
13
+ *
14
+ * @packageDocumentation
15
+ */export {}
16
+