@dxos/plugin-chess 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (186) hide show
  1. package/dist/lib/browser/ChessboardContainer-IS4PXWJD.mjs +81 -0
  2. package/dist/lib/browser/ChessboardContainer-IS4PXWJD.mjs.map +7 -0
  3. package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs +18 -0
  4. package/dist/lib/browser/blueprint-definition-5RUGJ64Z.mjs.map +7 -0
  5. package/dist/lib/browser/blueprints/index.mjs +11 -0
  6. package/dist/lib/browser/{chunk-T275KG4U.mjs → chunk-7OZ7J7LF.mjs} +19 -39
  7. package/dist/lib/browser/chunk-7OZ7J7LF.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-DH4WQRZH.mjs +229 -0
  9. package/dist/lib/browser/chunk-DH4WQRZH.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-H3NUMCQ6.mjs +21 -0
  11. package/dist/lib/browser/chunk-H3NUMCQ6.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  13. package/dist/lib/browser/{chunk-KD4I5VTZ.mjs → chunk-MV2GQK7M.mjs} +2 -2
  14. package/dist/lib/browser/chunk-UUMPZ2FM.mjs +271 -0
  15. package/dist/lib/browser/chunk-UUMPZ2FM.mjs.map +7 -0
  16. package/dist/lib/browser/cli/index.mjs +28 -0
  17. package/dist/lib/browser/cli/index.mjs.map +7 -0
  18. package/dist/lib/browser/index.mjs +53 -79
  19. package/dist/lib/browser/index.mjs.map +4 -4
  20. package/dist/lib/browser/meta.json +1 -1
  21. package/dist/lib/browser/react-surface-GQE7XMWH.mjs +37 -0
  22. package/dist/lib/browser/react-surface-GQE7XMWH.mjs.map +7 -0
  23. package/dist/lib/browser/types/index.mjs +3 -5
  24. package/dist/lib/node-esm/ChessboardContainer-S3T6OE7P.mjs +82 -0
  25. package/dist/lib/node-esm/ChessboardContainer-S3T6OE7P.mjs.map +7 -0
  26. package/dist/lib/node-esm/blueprint-definition-RYKASBIJ.mjs +19 -0
  27. package/dist/lib/node-esm/blueprint-definition-RYKASBIJ.mjs.map +7 -0
  28. package/dist/lib/node-esm/blueprints/index.mjs +12 -0
  29. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  30. package/dist/lib/node-esm/{chunk-Q5LJYIMO.mjs → chunk-DOBR6ILE.mjs} +2 -2
  31. package/dist/lib/node-esm/{chunk-6OWCPDUA.mjs → chunk-F5OMIM4F.mjs} +5 -11
  32. package/dist/lib/node-esm/chunk-F5OMIM4F.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  34. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-LKJ5GDAB.mjs +272 -0
  36. package/dist/lib/node-esm/chunk-LKJ5GDAB.mjs.map +7 -0
  37. package/dist/lib/node-esm/{chunk-5DYLCQBR.mjs → chunk-NAYRVJR4.mjs} +19 -39
  38. package/dist/lib/node-esm/chunk-NAYRVJR4.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-NFDJU7XQ.mjs +230 -0
  40. package/dist/lib/node-esm/chunk-NFDJU7XQ.mjs.map +7 -0
  41. package/dist/lib/node-esm/cli/index.mjs +29 -0
  42. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  43. package/dist/lib/node-esm/index.mjs +53 -79
  44. package/dist/lib/node-esm/index.mjs.map +4 -4
  45. package/dist/lib/node-esm/meta.json +1 -1
  46. package/dist/lib/node-esm/{react-surface-SBM22GEU.mjs → react-surface-7UZLIVN6.mjs} +15 -16
  47. package/dist/lib/node-esm/react-surface-7UZLIVN6.mjs.map +7 -0
  48. package/dist/lib/node-esm/types/index.mjs +3 -5
  49. package/dist/types/src/ChessPlugin.d.ts +2 -1
  50. package/dist/types/src/ChessPlugin.d.ts.map +1 -1
  51. package/dist/types/src/blueprints/chess-blueprint.d.ts +21 -0
  52. package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
  53. package/dist/types/src/blueprints/functions/create.d.ts +15 -0
  54. package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
  55. package/dist/types/src/{functions → blueprints/functions}/index.d.ts +1 -0
  56. package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
  57. package/dist/types/src/{functions → blueprints/functions}/move.d.ts +1 -1
  58. package/dist/types/src/blueprints/functions/move.d.ts.map +1 -0
  59. package/dist/types/src/{functions → blueprints/functions}/play.d.ts +1 -1
  60. package/dist/types/src/blueprints/functions/play.d.ts.map +1 -0
  61. package/dist/types/src/blueprints/functions/print.d.ts +8 -0
  62. package/dist/types/src/blueprints/functions/print.d.ts.map +1 -0
  63. package/dist/types/src/blueprints/index.d.ts +3 -0
  64. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  66. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  68. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  70. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  71. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  72. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  73. package/dist/types/src/capabilities/index.d.ts +1 -3
  74. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  76. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  78. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  79. package/dist/types/src/cli/index.d.ts +2 -0
  80. package/dist/types/src/cli/index.d.ts.map +1 -0
  81. package/dist/types/src/cli/plugin.d.ts +3 -0
  82. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  83. package/dist/types/src/components/Card.stories.d.ts +10 -9
  84. package/dist/types/src/components/Card.stories.d.ts.map +1 -1
  85. package/dist/types/src/components/Chessboard.d.ts +2 -1
  86. package/dist/types/src/components/Chessboard.d.ts.map +1 -1
  87. package/dist/types/src/components/Chessboard.stories.d.ts +15 -13
  88. package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
  89. package/dist/types/src/components/ChessboardArticle.d.ts +3 -4
  90. package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -1
  91. package/dist/types/src/components/ChessboardContainer.d.ts +3 -5
  92. package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -1
  93. package/dist/types/src/components/Info.d.ts.map +1 -1
  94. package/dist/types/src/components/index.d.ts +1 -1
  95. package/dist/types/src/components/index.d.ts.map +1 -1
  96. package/dist/types/src/index.d.ts +1 -1
  97. package/dist/types/src/index.d.ts.map +1 -1
  98. package/dist/types/src/meta.d.ts +2 -3
  99. package/dist/types/src/meta.d.ts.map +1 -1
  100. package/dist/types/src/translations.d.ts +9 -8
  101. package/dist/types/src/translations.d.ts.map +1 -1
  102. package/dist/types/src/types/Chess.d.ts +17 -17
  103. package/dist/types/src/types/Chess.d.ts.map +1 -1
  104. package/dist/types/src/types/index.d.ts +0 -1
  105. package/dist/types/src/types/index.d.ts.map +1 -1
  106. package/dist/types/tsconfig.tsbuildinfo +1 -1
  107. package/package.json +64 -50
  108. package/src/ChessPlugin.tsx +26 -53
  109. package/src/blueprints/chess-blueprint.ts +28 -0
  110. package/src/blueprints/functions/create.ts +38 -0
  111. package/src/{functions → blueprints/functions}/index.ts +1 -0
  112. package/src/{functions → blueprints/functions}/move.ts +13 -7
  113. package/src/{functions → blueprints/functions}/play.ts +13 -7
  114. package/src/blueprints/functions/print.ts +42 -0
  115. package/src/blueprints/index.ts +6 -0
  116. package/src/capabilities/artifact-definition/artifact-definition.ts +135 -0
  117. package/src/capabilities/artifact-definition/index.ts +7 -0
  118. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  119. package/src/capabilities/blueprint-definition/index.ts +7 -0
  120. package/src/capabilities/index.ts +1 -6
  121. package/src/capabilities/react-surface/index.ts +7 -0
  122. package/src/capabilities/react-surface/react-surface.tsx +27 -0
  123. package/src/cli/index.ts +5 -0
  124. package/src/cli/plugin.ts +26 -0
  125. package/src/components/Card.stories.tsx +19 -40
  126. package/src/components/Chessboard.stories.tsx +18 -15
  127. package/src/components/Chessboard.tsx +21 -10
  128. package/src/components/ChessboardArticle.tsx +13 -11
  129. package/src/components/ChessboardContainer.tsx +9 -13
  130. package/src/components/Info.tsx +17 -13
  131. package/src/index.ts +1 -1
  132. package/src/meta.ts +6 -6
  133. package/src/translations.ts +9 -8
  134. package/src/types/Chess.ts +23 -31
  135. package/src/types/index.ts +0 -1
  136. package/dist/lib/browser/ChessboardContainer-LIZDOGHI.mjs +0 -97
  137. package/dist/lib/browser/ChessboardContainer-LIZDOGHI.mjs.map +0 -7
  138. package/dist/lib/browser/blueprint-definition-I6UFJHT6.mjs +0 -11
  139. package/dist/lib/browser/chunk-EKNL3H3U.mjs +0 -306
  140. package/dist/lib/browser/chunk-EKNL3H3U.mjs.map +0 -7
  141. package/dist/lib/browser/chunk-M2MBU2O6.mjs +0 -163
  142. package/dist/lib/browser/chunk-M2MBU2O6.mjs.map +0 -7
  143. package/dist/lib/browser/chunk-PE3IWOFR.mjs +0 -28
  144. package/dist/lib/browser/chunk-PE3IWOFR.mjs.map +0 -7
  145. package/dist/lib/browser/chunk-T275KG4U.mjs.map +0 -7
  146. package/dist/lib/browser/intent-resolver-RV2DQSJP.mjs +0 -25
  147. package/dist/lib/browser/intent-resolver-RV2DQSJP.mjs.map +0 -7
  148. package/dist/lib/browser/react-surface-I6CZUR5C.mjs +0 -38
  149. package/dist/lib/browser/react-surface-I6CZUR5C.mjs.map +0 -7
  150. package/dist/lib/node-esm/ChessboardContainer-XWVQ5K7N.mjs +0 -98
  151. package/dist/lib/node-esm/ChessboardContainer-XWVQ5K7N.mjs.map +0 -7
  152. package/dist/lib/node-esm/blueprint-definition-F7WQTNQ7.mjs +0 -12
  153. package/dist/lib/node-esm/chunk-5DYLCQBR.mjs.map +0 -7
  154. package/dist/lib/node-esm/chunk-6OWCPDUA.mjs.map +0 -7
  155. package/dist/lib/node-esm/chunk-EGBWRJWH.mjs +0 -307
  156. package/dist/lib/node-esm/chunk-EGBWRJWH.mjs.map +0 -7
  157. package/dist/lib/node-esm/chunk-TUWE7Y5Z.mjs +0 -164
  158. package/dist/lib/node-esm/chunk-TUWE7Y5Z.mjs.map +0 -7
  159. package/dist/lib/node-esm/intent-resolver-TJF7I4UB.mjs +0 -26
  160. package/dist/lib/node-esm/intent-resolver-TJF7I4UB.mjs.map +0 -7
  161. package/dist/lib/node-esm/react-surface-SBM22GEU.mjs.map +0 -7
  162. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  163. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  164. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -6
  165. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  166. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  167. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  168. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  169. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  170. package/dist/types/src/functions/create.d.ts +0 -14
  171. package/dist/types/src/functions/create.d.ts.map +0 -1
  172. package/dist/types/src/functions/index.d.ts.map +0 -1
  173. package/dist/types/src/functions/move.d.ts.map +0 -1
  174. package/dist/types/src/functions/play.d.ts.map +0 -1
  175. package/dist/types/src/types/ChessAction.d.ts +0 -24
  176. package/dist/types/src/types/ChessAction.d.ts.map +0 -1
  177. package/src/capabilities/artifact-definition.ts +0 -128
  178. package/src/capabilities/blueprint-definition.ts +0 -36
  179. package/src/capabilities/intent-resolver.ts +0 -22
  180. package/src/capabilities/react-surface.tsx +0 -23
  181. package/src/functions/create.ts +0 -30
  182. package/src/types/ChessAction.ts +0 -19
  183. /package/dist/lib/browser/{blueprint-definition-I6UFJHT6.mjs.map → blueprints/index.mjs.map} +0 -0
  184. /package/dist/lib/{node-esm/blueprint-definition-F7WQTNQ7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
  185. /package/dist/lib/browser/{chunk-KD4I5VTZ.mjs.map → chunk-MV2GQK7M.mjs.map} +0 -0
  186. /package/dist/lib/node-esm/{chunk-Q5LJYIMO.mjs.map → chunk-DOBR6ILE.mjs.map} +0 -0
@@ -1,14 +0,0 @@
1
- declare const _default: import("@dxos/functions").FunctionDefinition<{
2
- readonly pgn?: string | undefined;
3
- readonly fen?: string | undefined;
4
- }, import("@dxos/live-object").Live<import("@dxos/echo/Type").OfKind<import("@dxos/echo-schema").EntityKind.Object> & {
5
- name?: string | undefined;
6
- players?: {
7
- white?: string | undefined;
8
- black?: string | undefined;
9
- } | undefined;
10
- pgn?: string | undefined;
11
- fen?: string | undefined;
12
- }>>;
13
- export default _default;
14
- //# sourceMappingURL=create.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/functions/create.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,wBAmBG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/functions/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../../src/functions/move.ts"],"names":[],"mappings":";;;;;;AAYA,wBA8BG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"play.d.ts","sourceRoot":"","sources":["../../../../src/functions/play.ts"],"names":[],"mappings":";;;;;;;AAYA,wBAwCG"}
@@ -1,24 +0,0 @@
1
- import { Schema } from 'effect';
2
- declare const Create_base: Schema.TaggedClass<Create, `${string}/action/create`, {
3
- readonly _tag: Schema.tag<`${string}/action/create`>;
4
- } & {
5
- input: Schema.Struct<{
6
- name: Schema.optional<typeof Schema.String>;
7
- pgn: Schema.optional<typeof Schema.String>;
8
- }>;
9
- output: Schema.Struct<{
10
- object: import("@dxos/echo/Type").obj<Schema.Struct<{
11
- name: Schema.optional<typeof Schema.String>;
12
- players: Schema.optional<Schema.mutable<Schema.Struct<{
13
- white: Schema.optional<Schema.SchemaClass<string, string, never>>;
14
- black: Schema.optional<Schema.SchemaClass<string, string, never>>;
15
- }>>>;
16
- pgn: Schema.optional<Schema.SchemaClass<string, string, never>>;
17
- fen: Schema.optional<Schema.SchemaClass<string, string, never>>;
18
- }>>;
19
- }>;
20
- }>;
21
- export declare class Create extends Create_base {
22
- }
23
- export {};
24
- //# sourceMappingURL=ChessAction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChessAction.d.ts","sourceRoot":"","sources":["../../../../src/types/ChessAction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;AAMhC,qBAAa,MAAO,SAAQ,WAQ1B;CAAG"}
@@ -1,128 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- // ISSUE(burdon): defineArtifact
6
- // @ts-nocheck
7
-
8
- import { Chess as ChessJS } from 'chess.js';
9
- import { Schema, pipe } from 'effect';
10
-
11
- import { ToolResult, createTool } from '@dxos/ai';
12
- import { Capabilities, type PromiseIntentDispatcher, chain, contributes, createIntent } from '@dxos/app-framework';
13
- import { ArtifactId, VersionPin, createArtifactElement } from '@dxos/assistant';
14
- import { defineArtifact } from '@dxos/blueprints';
15
- import { Obj } from '@dxos/echo';
16
- import { invariant } from '@dxos/invariant';
17
- import { SpaceAction } from '@dxos/plugin-space/types';
18
- import { Filter, type Space } from '@dxos/react-client/echo';
19
- import { trim } from '@dxos/util';
20
-
21
- import { meta } from '../meta';
22
- import { Chess, ChessAction } from '../types';
23
-
24
- // TODO(burdon): Factor out.
25
- declare global {
26
- interface ToolContextExtensions {
27
- space?: Space;
28
- dispatch?: PromiseIntentDispatcher;
29
- }
30
- }
31
-
32
- export default () => {
33
- const definition = defineArtifact({
34
- id: `artifact:${meta.id}`,
35
- name: meta.name,
36
- description: 'Provides a simple chess engine.',
37
- instructions: trim`
38
- - If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.
39
- - Always inspect the chess game at the start of every prompt realting to a chess game, as it might have changed since the interaction.
40
- `,
41
- schema: Chess.Game,
42
- tools: [
43
- createTool(meta.id, {
44
- name: 'create',
45
- description: 'Create a new chess game. Returns the artifact definition for the game.',
46
- caption: 'Creating chess game...',
47
- schema: Schema.Struct({
48
- pgn: Schema.String.annotations({ description: 'The state of the chess game in the PGN format.' }),
49
- }),
50
- execute: async ({ pgn }, { extensions }) => {
51
- invariant(extensions?.space, 'No space');
52
- invariant(extensions?.dispatch, 'No intent dispatcher');
53
- const intent = pipe(
54
- createIntent(ChessAction.Create, { pgn }),
55
- chain(SpaceAction.AddObject, { target: extensions.space }),
56
- );
57
- const { data, error } = await extensions.dispatch(intent);
58
- if (!data || error) {
59
- return ToolResult.Error(error?.message ?? 'Failed to create chess game');
60
- }
61
-
62
- return ToolResult.Success(createArtifactElement(data.id), [
63
- VersionPin.createBlock(VersionPin.fromObject(data.object)),
64
- ]);
65
- },
66
- }),
67
- createTool(meta.id, {
68
- name: 'list',
69
- description: 'Query all active chess games.',
70
- caption: 'Getting games...',
71
- schema: Schema.Struct({}),
72
- execute: async (_, { extensions }) => {
73
- invariant(extensions?.space, 'No space');
74
- const { objects: games } = await extensions.space.db.query(Filter.type(Chess.Game)).run();
75
- invariant(games.length > 0, 'No chess games found');
76
-
77
- return ToolResult.Success(games);
78
- },
79
- }),
80
- createTool(meta.id, {
81
- name: 'inspect',
82
- description: 'Get the current state of the chess game.',
83
- caption: 'Inspecting game...',
84
- schema: Schema.Struct({ id: ArtifactId }),
85
- execute: async ({ id }, { extensions }) => {
86
- invariant(extensions?.space, 'No space');
87
- const game = await extensions.space.db
88
- .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
89
- .first();
90
- invariant(Obj.instanceOf(Chess.Game, game));
91
-
92
- return ToolResult.Success(game.pgn);
93
- },
94
- }),
95
- createTool(meta.id, {
96
- name: 'move',
97
- description: 'Make a move in the chess game.',
98
- caption: 'Making chess move...',
99
- schema: Schema.Struct({
100
- id: ArtifactId,
101
- move: Schema.String.annotations({
102
- description: 'The move to make in the chess game.',
103
- examples: ['e4', 'Bf3'],
104
- }),
105
- }),
106
- execute: async ({ id, move }, { extensions }) => {
107
- invariant(extensions?.space, 'No space');
108
- const game = await extensions.space.db
109
- .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
110
- .first();
111
- invariant(Obj.instanceOf(Chess.Game, game));
112
-
113
- const chess = new ChessJS(game.pgn);
114
- try {
115
- chess.move(move);
116
- } catch (error: any) {
117
- return ToolResult.Error(error.message);
118
- }
119
-
120
- game.pgn = chess.pgn();
121
- return ToolResult.Success(game.pgn);
122
- },
123
- }),
124
- ],
125
- });
126
-
127
- return contributes(Capabilities.ArtifactDefinition, definition);
128
- };
@@ -1,36 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, contributes } from '@dxos/app-framework';
6
- import { Blueprint, Template } from '@dxos/blueprints';
7
- import { type FunctionDefinition } from '@dxos/functions';
8
- import { trim } from '@dxos/util';
9
-
10
- import { create, move, play } from '../functions';
11
-
12
- export const BLUEPRINT_KEY = 'dxos.org/blueprint/chess';
13
-
14
- const functions: FunctionDefinition[] = [create, move, play];
15
-
16
- export default () => {
17
- return [
18
- contributes(Capabilities.Functions, functions),
19
- contributes(
20
- Capabilities.BlueprintDefinition,
21
- Blueprint.make({
22
- key: BLUEPRINT_KEY,
23
- name: 'Chess',
24
- tools: Blueprint.toolDefinitions({ functions }),
25
- instructions: Template.make({
26
- source: trim`
27
- You are an expert chess player.
28
- To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
29
- You could suggest a good next move or offer to play a move.
30
- Don't actually make a move unless you are asked to.
31
- `,
32
- }),
33
- }),
34
- ),
35
- ];
36
- };
@@ -1,22 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
6
-
7
- import { Chess, ChessAction } from '../types';
8
-
9
- export default () =>
10
- contributes(
11
- Capabilities.IntentResolver,
12
- createResolver({
13
- intent: ChessAction.Create,
14
- resolve: ({ name, pgn }) => {
15
- return {
16
- data: {
17
- object: Chess.makeGame({ name, pgn }),
18
- },
19
- };
20
- },
21
- }),
22
- );
@@ -1,23 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { Obj } from '@dxos/echo';
9
-
10
- import { ChessboardContainer } from '../components';
11
- import { meta } from '../meta';
12
- import { Chess } from '../types';
13
-
14
- export default () =>
15
- contributes(Capabilities.ReactSurface, [
16
- createSurface({
17
- id: meta.id,
18
- role: ['article', 'section', 'card--intrinsic', 'card--extrinsic', 'card--popover', 'card--transclusion'],
19
- // TODO(burdon): Could this be standardized so that we don't require a subject property.
20
- filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),
21
- component: ({ data, role }) => <ChessboardContainer game={data.subject} role={role} />,
22
- }),
23
- ]);
@@ -1,30 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Effect, Schema } from 'effect';
6
-
7
- import { DatabaseService, defineFunction } from '@dxos/functions';
8
-
9
- import { Chess } from '../types';
10
-
11
- export default defineFunction({
12
- name: 'dxos.org/function/chess/create',
13
- description: 'Creates a new chess game.',
14
- inputSchema: Schema.Struct({
15
- pgn: Schema.optional(
16
- Schema.String.annotations({
17
- description: 'Portable Game Notation.',
18
- }),
19
- ),
20
- fen: Schema.optional(
21
- Schema.String.annotations({
22
- description: 'Forsyth-Edwards Notation.',
23
- }),
24
- ),
25
- }),
26
- outputSchema: Chess.Game,
27
- handler: Effect.fn(function* ({ data: { pgn, fen } }) {
28
- return yield* DatabaseService.add(Chess.makeGame({ pgn, fen }));
29
- }),
30
- });
@@ -1,19 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Schema } from 'effect';
6
-
7
- import { meta } from '../meta';
8
-
9
- import { Game } from './Chess';
10
-
11
- export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
12
- input: Schema.Struct({
13
- name: Schema.optional(Schema.String),
14
- pgn: Schema.optional(Schema.String),
15
- }),
16
- output: Schema.Struct({
17
- object: Game,
18
- }),
19
- }) {}