@fluidframework/ai-collab 2.10.0-306579
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/.eslintrc.cjs +26 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +280 -0
- package/alpha.d.ts +11 -0
- package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-index.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-index.esm.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +4 -0
- package/api-report/ai-collab.alpha.api.md +164 -0
- package/api-report/ai-collab.beta.api.md +7 -0
- package/api-report/ai-collab.public.api.md +7 -0
- package/biome.jsonc +4 -0
- package/dist/aiCollab.d.ts +65 -0
- package/dist/aiCollab.d.ts.map +1 -0
- package/dist/aiCollab.js +81 -0
- package/dist/aiCollab.js.map +1 -0
- package/dist/aiCollabApi.d.ts +173 -0
- package/dist/aiCollabApi.d.ts.map +1 -0
- package/dist/aiCollabApi.js +7 -0
- package/dist/aiCollabApi.js.map +1 -0
- package/dist/alpha.d.ts +41 -0
- package/dist/explicit-strategy/agentEditReducer.d.ts +12 -0
- package/dist/explicit-strategy/agentEditReducer.d.ts.map +1 -0
- package/dist/explicit-strategy/agentEditReducer.js +394 -0
- package/dist/explicit-strategy/agentEditReducer.js.map +1 -0
- package/dist/explicit-strategy/agentEditTypes.d.ts +158 -0
- package/dist/explicit-strategy/agentEditTypes.d.ts.map +1 -0
- package/dist/explicit-strategy/agentEditTypes.js +50 -0
- package/dist/explicit-strategy/agentEditTypes.js.map +1 -0
- package/dist/explicit-strategy/idGenerator.d.ts +22 -0
- package/dist/explicit-strategy/idGenerator.d.ts.map +1 -0
- package/dist/explicit-strategy/idGenerator.js +74 -0
- package/dist/explicit-strategy/idGenerator.js.map +1 -0
- package/dist/explicit-strategy/index.d.ts +51 -0
- package/dist/explicit-strategy/index.d.ts.map +1 -0
- package/dist/explicit-strategy/index.js +223 -0
- package/dist/explicit-strategy/index.js.map +1 -0
- package/dist/explicit-strategy/jsonTypes.d.ts +23 -0
- package/dist/explicit-strategy/jsonTypes.d.ts.map +1 -0
- package/dist/explicit-strategy/jsonTypes.js +7 -0
- package/dist/explicit-strategy/jsonTypes.js.map +1 -0
- package/dist/explicit-strategy/promptGeneration.d.ts +51 -0
- package/dist/explicit-strategy/promptGeneration.d.ts.map +1 -0
- package/dist/explicit-strategy/promptGeneration.js +218 -0
- package/dist/explicit-strategy/promptGeneration.js.map +1 -0
- package/dist/explicit-strategy/typeGeneration.d.ts +15 -0
- package/dist/explicit-strategy/typeGeneration.d.ts.map +1 -0
- package/dist/explicit-strategy/typeGeneration.js +264 -0
- package/dist/explicit-strategy/typeGeneration.js.map +1 -0
- package/dist/explicit-strategy/utils.d.ts +37 -0
- package/dist/explicit-strategy/utils.d.ts.map +1 -0
- package/dist/explicit-strategy/utils.js +47 -0
- package/dist/explicit-strategy/utils.js.map +1 -0
- package/dist/implicit-strategy/index.d.ts +8 -0
- package/dist/implicit-strategy/index.d.ts.map +1 -0
- package/dist/implicit-strategy/index.js +18 -0
- package/dist/implicit-strategy/index.js.map +1 -0
- package/dist/implicit-strategy/sharedTreeBranchManager.d.ts +63 -0
- package/dist/implicit-strategy/sharedTreeBranchManager.d.ts.map +1 -0
- package/dist/implicit-strategy/sharedTreeBranchManager.js +212 -0
- package/dist/implicit-strategy/sharedTreeBranchManager.js.map +1 -0
- package/dist/implicit-strategy/sharedTreeDiff.d.ts +102 -0
- package/dist/implicit-strategy/sharedTreeDiff.d.ts.map +1 -0
- package/dist/implicit-strategy/sharedTreeDiff.js +522 -0
- package/dist/implicit-strategy/sharedTreeDiff.js.map +1 -0
- package/dist/implicit-strategy/utils.d.ts +21 -0
- package/dist/implicit-strategy/utils.d.ts.map +1 -0
- package/dist/implicit-strategy/utils.js +49 -0
- package/dist/implicit-strategy/utils.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +3 -0
- package/dist/public.d.ts +19 -0
- package/eslintrc.cjs +11 -0
- package/internal.d.ts +11 -0
- package/lib/aiCollab.d.ts +65 -0
- package/lib/aiCollab.d.ts.map +1 -0
- package/lib/aiCollab.js +77 -0
- package/lib/aiCollab.js.map +1 -0
- package/lib/aiCollabApi.d.ts +173 -0
- package/lib/aiCollabApi.d.ts.map +1 -0
- package/lib/aiCollabApi.js +6 -0
- package/lib/aiCollabApi.js.map +1 -0
- package/lib/alpha.d.ts +41 -0
- package/lib/explicit-strategy/agentEditReducer.d.ts +12 -0
- package/lib/explicit-strategy/agentEditReducer.d.ts.map +1 -0
- package/lib/explicit-strategy/agentEditReducer.js +390 -0
- package/lib/explicit-strategy/agentEditReducer.js.map +1 -0
- package/lib/explicit-strategy/agentEditTypes.d.ts +158 -0
- package/lib/explicit-strategy/agentEditTypes.d.ts.map +1 -0
- package/lib/explicit-strategy/agentEditTypes.js +47 -0
- package/lib/explicit-strategy/agentEditTypes.js.map +1 -0
- package/lib/explicit-strategy/idGenerator.d.ts +22 -0
- package/lib/explicit-strategy/idGenerator.d.ts.map +1 -0
- package/lib/explicit-strategy/idGenerator.js +70 -0
- package/lib/explicit-strategy/idGenerator.js.map +1 -0
- package/lib/explicit-strategy/index.d.ts +51 -0
- package/lib/explicit-strategy/index.d.ts.map +1 -0
- package/lib/explicit-strategy/index.js +219 -0
- package/lib/explicit-strategy/index.js.map +1 -0
- package/lib/explicit-strategy/jsonTypes.d.ts +23 -0
- package/lib/explicit-strategy/jsonTypes.d.ts.map +1 -0
- package/lib/explicit-strategy/jsonTypes.js +6 -0
- package/lib/explicit-strategy/jsonTypes.js.map +1 -0
- package/lib/explicit-strategy/promptGeneration.d.ts +51 -0
- package/lib/explicit-strategy/promptGeneration.d.ts.map +1 -0
- package/lib/explicit-strategy/promptGeneration.js +208 -0
- package/lib/explicit-strategy/promptGeneration.js.map +1 -0
- package/lib/explicit-strategy/typeGeneration.d.ts +15 -0
- package/lib/explicit-strategy/typeGeneration.d.ts.map +1 -0
- package/lib/explicit-strategy/typeGeneration.js +260 -0
- package/lib/explicit-strategy/typeGeneration.js.map +1 -0
- package/lib/explicit-strategy/utils.d.ts +37 -0
- package/lib/explicit-strategy/utils.d.ts.map +1 -0
- package/lib/explicit-strategy/utils.js +41 -0
- package/lib/explicit-strategy/utils.js.map +1 -0
- package/lib/implicit-strategy/index.d.ts +8 -0
- package/lib/implicit-strategy/index.d.ts.map +1 -0
- package/lib/implicit-strategy/index.js +8 -0
- package/lib/implicit-strategy/index.js.map +1 -0
- package/lib/implicit-strategy/sharedTreeBranchManager.d.ts +63 -0
- package/lib/implicit-strategy/sharedTreeBranchManager.d.ts.map +1 -0
- package/lib/implicit-strategy/sharedTreeBranchManager.js +213 -0
- package/lib/implicit-strategy/sharedTreeBranchManager.js.map +1 -0
- package/lib/implicit-strategy/sharedTreeDiff.d.ts +102 -0
- package/lib/implicit-strategy/sharedTreeDiff.d.ts.map +1 -0
- package/lib/implicit-strategy/sharedTreeDiff.js +515 -0
- package/lib/implicit-strategy/sharedTreeDiff.js.map +1 -0
- package/lib/implicit-strategy/utils.d.ts +21 -0
- package/lib/implicit-strategy/utils.d.ts.map +1 -0
- package/lib/implicit-strategy/utils.js +43 -0
- package/lib/implicit-strategy/utils.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/public.d.ts +19 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/mocharc.cjs +14 -0
- package/package.json +165 -0
- package/prettier.config.cjs +8 -0
- package/src/aiCollab.ts +86 -0
- package/src/aiCollabApi.ts +184 -0
- package/src/explicit-strategy/agentEditReducer.ts +498 -0
- package/src/explicit-strategy/agentEditTypes.ts +177 -0
- package/src/explicit-strategy/idGenerator.ts +90 -0
- package/src/explicit-strategy/index.ts +364 -0
- package/src/explicit-strategy/jsonTypes.ts +27 -0
- package/src/explicit-strategy/promptGeneration.ts +294 -0
- package/src/explicit-strategy/typeGeneration.ts +374 -0
- package/src/explicit-strategy/utils.ts +60 -0
- package/src/implicit-strategy/README.md +4 -0
- package/src/implicit-strategy/index.ts +21 -0
- package/src/implicit-strategy/sharedTreeBranchManager.ts +294 -0
- package/src/implicit-strategy/sharedTreeDiff.ts +735 -0
- package/src/implicit-strategy/utils.ts +54 -0
- package/src/index.ts +39 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +12 -0
- package/tsdoc.json +4 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type TreeMapNode, type TreeArrayNode, NodeKind } from "@fluidframework/tree";
|
|
7
|
+
|
|
8
|
+
import type { ObjectPath } from "./sharedTreeDiff.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the given object is an {@link TreeMapNode}.
|
|
12
|
+
*/
|
|
13
|
+
export function isTreeMapNode(obj: unknown): obj is TreeMapNode {
|
|
14
|
+
if (typeof obj === "object" && obj !== null) {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
16
|
+
const maybeNodeKind: unknown = Object.getPrototypeOf(obj)?.constructor?.kind;
|
|
17
|
+
return maybeNodeKind === NodeKind.Map;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the given object is an {@link TreeArrayNode}.
|
|
24
|
+
*/
|
|
25
|
+
export function isTreeArrayNode(obj: unknown): obj is TreeArrayNode {
|
|
26
|
+
if (typeof obj === "object" && obj !== null) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
28
|
+
const maybeNodeKind: unknown = Object.getPrototypeOf(obj)?.constructor?.kind;
|
|
29
|
+
return maybeNodeKind === NodeKind.Array;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Traverses the provided {@link ObjectPath} on the provided Shared Tree or JSON object and returns the value at the end of the path.
|
|
36
|
+
*
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
export function sharedTreeTraverse<T = unknown>(
|
|
40
|
+
jsonObject: TreeMapNode | TreeArrayNode | Record<string, unknown>,
|
|
41
|
+
path: ObjectPath,
|
|
42
|
+
): T | undefined {
|
|
43
|
+
let current: unknown = jsonObject;
|
|
44
|
+
|
|
45
|
+
for (const key of path) {
|
|
46
|
+
if (current === undefined || current === null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
current = isTreeMapNode(current) ? current.get(key as string) : current[key];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return current as T;
|
|
54
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Experimental package for utilities that enable/simplify interaction with LLMs for apps based on SharedTree.
|
|
8
|
+
*
|
|
9
|
+
* See {@link https://github.com/microsoft/FluidFramework/tree/main/packages/framework/ai-collab#readme | README.md }
|
|
10
|
+
* for an overview of the package.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
type DifferenceCreate,
|
|
17
|
+
type DifferenceChange,
|
|
18
|
+
type DifferenceMove,
|
|
19
|
+
type DifferenceRemove,
|
|
20
|
+
type Difference,
|
|
21
|
+
type ObjectPath,
|
|
22
|
+
type Options,
|
|
23
|
+
sharedTreeDiff,
|
|
24
|
+
createMergableIdDiffSeries,
|
|
25
|
+
createMergableDiffSeries,
|
|
26
|
+
SharedTreeBranchManager,
|
|
27
|
+
sharedTreeTraverse,
|
|
28
|
+
} from "./implicit-strategy/index.js";
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
type AiCollabOptions,
|
|
32
|
+
type AiCollabSuccessResponse,
|
|
33
|
+
type AiCollabErrorResponse,
|
|
34
|
+
type TokenUsage,
|
|
35
|
+
type TokenLimits,
|
|
36
|
+
type OpenAiClientOptions,
|
|
37
|
+
} from "./aiCollabApi.js";
|
|
38
|
+
|
|
39
|
+
export { aiCollab } from "./aiCollab.js";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
|
|
3
|
+
"include": ["src/**/*"],
|
|
4
|
+
"exclude": ["src/test/**/*"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"outDir": "./lib",
|
|
8
|
+
// SharedTree seems to have issues with exactOptionalPropertyTypes: true. It has it set to false itself, and if it's
|
|
9
|
+
// not set to false here the build fails complaining about types in SharedTree's .d.ts files.
|
|
10
|
+
"exactOptionalPropertyTypes": false,
|
|
11
|
+
},
|
|
12
|
+
}
|
package/tsdoc.json
ADDED