@fluidframework/tree-agent 2.81.0 → 2.82.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.
- package/CHANGELOG.md +4 -0
- package/dist/methodBinding.d.ts.map +1 -1
- package/dist/methodBinding.js.map +1 -1
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +20 -2
- package/dist/prompt.js.map +1 -1
- package/dist/renderSchemaTypeScript.d.ts.map +1 -1
- package/dist/renderSchemaTypeScript.js +5 -1
- package/dist/renderSchemaTypeScript.js.map +1 -1
- package/eslint.config.mts +0 -6
- package/lib/methodBinding.d.ts.map +1 -1
- package/lib/methodBinding.js.map +1 -1
- package/lib/prompt.d.ts +4 -0
- package/lib/prompt.d.ts.map +1 -1
- package/lib/prompt.js +20 -2
- package/lib/prompt.js.map +1 -1
- package/lib/renderSchemaTypeScript.d.ts.map +1 -1
- package/lib/renderSchemaTypeScript.js +5 -1
- package/lib/renderSchemaTypeScript.js.map +1 -1
- package/package.json +11 -11
- package/src/methodBinding.ts +16 -15
- package/src/prompt.ts +21 -2
- package/src/renderSchemaTypeScript.ts +5 -1
- package/biome.jsonc +0 -4
package/src/prompt.ts
CHANGED
|
@@ -8,12 +8,17 @@ import { NodeKind, Tree, TreeNode } from "@fluidframework/tree";
|
|
|
8
8
|
import type { ImplicitFieldSchema, TreeMapNode } from "@fluidframework/tree";
|
|
9
9
|
import type { ReadableField } from "@fluidframework/tree/alpha";
|
|
10
10
|
import { getSimpleSchema } from "@fluidframework/tree/alpha";
|
|
11
|
-
import { normalizeFieldSchema } from "@fluidframework/tree/internal";
|
|
11
|
+
import { normalizeFieldSchema, ValueSchema } from "@fluidframework/tree/internal";
|
|
12
12
|
|
|
13
13
|
import type { Subtree } from "./subtree.js";
|
|
14
14
|
import { generateEditTypesForPrompt } from "./typeGeneration.js";
|
|
15
15
|
import { getFriendlyName, communize, findSchemas } from "./utils.js";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The type name used for handles in generated TypeScript.
|
|
19
|
+
*/
|
|
20
|
+
export const fluidHandleTypeName = "_OpaqueHandle";
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* Produces a "system" prompt for the tree agent, based on the provided subtree.
|
|
19
24
|
*/
|
|
@@ -32,6 +37,7 @@ export function getPrompt(args: {
|
|
|
32
37
|
let nodeTypeUnion: string | undefined;
|
|
33
38
|
let hasArrays = false;
|
|
34
39
|
let hasMaps = false;
|
|
40
|
+
let hasFluidHandles = false;
|
|
35
41
|
let exampleObjectName: string | undefined;
|
|
36
42
|
for (const s of findSchemas(schema)) {
|
|
37
43
|
if (s.kind !== NodeKind.Leaf) {
|
|
@@ -54,6 +60,10 @@ export function getPrompt(args: {
|
|
|
54
60
|
exampleObjectName ??= getFriendlyName(s);
|
|
55
61
|
break;
|
|
56
62
|
}
|
|
63
|
+
case NodeKind.Leaf: {
|
|
64
|
+
hasFluidHandles ||= s.info === ValueSchema.FluidHandle;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
57
67
|
// No default
|
|
58
68
|
}
|
|
59
69
|
}
|
|
@@ -63,6 +73,15 @@ export function getPrompt(args: {
|
|
|
63
73
|
schema,
|
|
64
74
|
getSimpleSchema(schema),
|
|
65
75
|
);
|
|
76
|
+
const fluidHandleType = hasFluidHandles
|
|
77
|
+
? `/**
|
|
78
|
+
* Opaque handle type representing a reference to a Fluid object.
|
|
79
|
+
* This type should not be constructed by generated code.
|
|
80
|
+
*/
|
|
81
|
+
type ${fluidHandleTypeName} = unknown;
|
|
82
|
+
|
|
83
|
+
`
|
|
84
|
+
: "";
|
|
66
85
|
const exampleTypeName =
|
|
67
86
|
nodeTypeUnion === undefined
|
|
68
87
|
? undefined
|
|
@@ -274,7 +293,7 @@ Finally, double check that the edits would accomplish the user's request (if it
|
|
|
274
293
|
The JSON tree adheres to the following Typescript schema:
|
|
275
294
|
|
|
276
295
|
\`\`\`typescript
|
|
277
|
-
${typescriptSchemaTypes}
|
|
296
|
+
${fluidHandleType}${typescriptSchemaTypes}
|
|
278
297
|
\`\`\`
|
|
279
298
|
|
|
280
299
|
If the user asks you a question about the tree, you should inspect the state of the tree and answer the question.
|
|
@@ -17,6 +17,7 @@ import { z } from "zod";
|
|
|
17
17
|
|
|
18
18
|
import type { BindableSchema, FunctionWrapper } from "./methodBinding.js";
|
|
19
19
|
import { getExposedMethods } from "./methodBinding.js";
|
|
20
|
+
import { fluidHandleTypeName } from "./prompt.js";
|
|
20
21
|
import { getExposedProperties, type PropertyDef } from "./propertyBinding.js";
|
|
21
22
|
import {
|
|
22
23
|
instanceOfsTypeFactory,
|
|
@@ -478,8 +479,11 @@ function renderLeaf(leafKind: ValueSchema): string {
|
|
|
478
479
|
case ValueSchema.Null: {
|
|
479
480
|
return "null";
|
|
480
481
|
}
|
|
482
|
+
case ValueSchema.FluidHandle: {
|
|
483
|
+
return fluidHandleTypeName;
|
|
484
|
+
}
|
|
481
485
|
default: {
|
|
482
|
-
throw new Error(`Unsupported leaf kind
|
|
486
|
+
throw new Error(`Unsupported leaf kind.`);
|
|
483
487
|
}
|
|
484
488
|
}
|
|
485
489
|
}
|
package/biome.jsonc
DELETED