@copilotkit/sdk-js 1.56.3 → 1.56.4

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.
@@ -1,13 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_types = require('./langgraph/types.cjs');
3
3
  const require_utils = require('./langgraph/utils.cjs');
4
+ const require_state_schema = require('./langgraph/state-schema.cjs');
4
5
 
5
6
  //#region src/langchain.ts
6
7
  console.warn("Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.");
7
8
 
8
9
  //#endregion
9
10
  exports.CopilotKitPropertiesAnnotation = require_types.CopilotKitPropertiesAnnotation;
11
+ exports.CopilotKitPropertiesSchema = require_types.CopilotKitPropertiesSchema;
10
12
  exports.CopilotKitStateAnnotation = require_types.CopilotKitStateAnnotation;
13
+ exports.CopilotKitStateSchema = require_state_schema.CopilotKitStateSchema;
11
14
  exports.convertActionToDynamicStructuredTool = require_utils.convertActionToDynamicStructuredTool;
12
15
  exports.convertActionsToDynamicStructuredTools = require_utils.convertActionsToDynamicStructuredTools;
13
16
  exports.copilotKitCustomizeConfig = require_utils.copilotkitCustomizeConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.cjs","names":[],"sources":["../src/langchain.ts"],"sourcesContent":["console.warn(\n \"Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.\",\n);\n\nexport {\n CopilotKitPropertiesAnnotation,\n CopilotKitStateAnnotation,\n type CopilotKitState,\n type CopilotKitProperties,\n copilotkitCustomizeConfig as copilotKitCustomizeConfig,\n copilotkitExit as copilotKitExit,\n copilotkitEmitState as copilotKitEmitState,\n copilotkitEmitMessage as copilotKitEmitMessage,\n copilotkitEmitToolCall as copilotKitEmitToolCall,\n convertActionToDynamicStructuredTool,\n convertActionsToDynamicStructuredTools,\n} from \"./langgraph\";\n"],"mappings":";;;;;AAAA,QAAQ,KACN,oJACD"}
1
+ {"version":3,"file":"langchain.cjs","names":[],"sources":["../src/langchain.ts"],"sourcesContent":["console.warn(\n \"Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.\",\n);\n\nexport {\n CopilotKitPropertiesAnnotation,\n CopilotKitPropertiesSchema,\n CopilotKitStateAnnotation,\n CopilotKitStateSchema,\n type CopilotKitState,\n type CopilotKitSchemaState,\n type CopilotKitSchemaUpdate,\n type CopilotKitProperties,\n copilotkitCustomizeConfig as copilotKitCustomizeConfig,\n copilotkitExit as copilotKitExit,\n copilotkitEmitState as copilotKitEmitState,\n copilotkitEmitMessage as copilotKitEmitMessage,\n copilotkitEmitToolCall as copilotKitEmitToolCall,\n convertActionToDynamicStructuredTool,\n convertActionsToDynamicStructuredTools,\n} from \"./langgraph\";\n"],"mappings":";;;;;;AAAA,QAAQ,KACN,oJACD"}
@@ -1,3 +1,4 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation } from "./langgraph/types.cjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation } from "./langgraph/types.cjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.cjs";
3
- export { type CopilotKitProperties, CopilotKitPropertiesAnnotation, type CopilotKitState, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
3
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.cjs";
4
+ export { type CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, type CopilotKitSchemaState, type CopilotKitSchemaUpdate, type CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
@@ -1,4 +1,5 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
3
4
  import "./langgraph.mjs";
4
- export { type CopilotKitProperties, CopilotKitPropertiesAnnotation, type CopilotKitState, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
5
+ export { type CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, type CopilotKitSchemaState, type CopilotKitSchemaUpdate, type CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
@@ -1,9 +1,10 @@
1
- import { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
1
+ import { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
+ import { CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
3
4
 
4
5
  //#region src/langchain.ts
5
6
  console.warn("Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.");
6
7
 
7
8
  //#endregion
8
- export { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
9
+ export { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation, CopilotKitStateSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotkitCustomizeConfig as copilotKitCustomizeConfig, copilotkitEmitMessage as copilotKitEmitMessage, copilotkitEmitState as copilotKitEmitState, copilotkitEmitToolCall as copilotKitEmitToolCall, copilotkitExit as copilotKitExit };
9
10
  //# sourceMappingURL=langchain.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.mjs","names":[],"sources":["../src/langchain.ts"],"sourcesContent":["console.warn(\n \"Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.\",\n);\n\nexport {\n CopilotKitPropertiesAnnotation,\n CopilotKitStateAnnotation,\n type CopilotKitState,\n type CopilotKitProperties,\n copilotkitCustomizeConfig as copilotKitCustomizeConfig,\n copilotkitExit as copilotKitExit,\n copilotkitEmitState as copilotKitEmitState,\n copilotkitEmitMessage as copilotKitEmitMessage,\n copilotkitEmitToolCall as copilotKitEmitToolCall,\n convertActionToDynamicStructuredTool,\n convertActionsToDynamicStructuredTools,\n} from \"./langgraph\";\n"],"mappings":";;;;AAAA,QAAQ,KACN,oJACD"}
1
+ {"version":3,"file":"langchain.mjs","names":[],"sources":["../src/langchain.ts"],"sourcesContent":["console.warn(\n \"Warning: '@copilotkit/sdk-js/langchain' is deprecated and will be removed in a future release. Please use '@copilotkit/sdk-js/langgraph' instead.\",\n);\n\nexport {\n CopilotKitPropertiesAnnotation,\n CopilotKitPropertiesSchema,\n CopilotKitStateAnnotation,\n CopilotKitStateSchema,\n type CopilotKitState,\n type CopilotKitSchemaState,\n type CopilotKitSchemaUpdate,\n type CopilotKitProperties,\n copilotkitCustomizeConfig as copilotKitCustomizeConfig,\n copilotkitExit as copilotKitExit,\n copilotkitEmitState as copilotKitEmitState,\n copilotkitEmitMessage as copilotKitEmitMessage,\n copilotkitEmitToolCall as copilotKitEmitToolCall,\n convertActionToDynamicStructuredTool,\n convertActionsToDynamicStructuredTools,\n} from \"./langgraph\";\n"],"mappings":";;;;;AAAA,QAAQ,KACN,oJACD"}
@@ -0,0 +1,37 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_types = require('./types.cjs');
3
+ let _langchain_langgraph = require("@langchain/langgraph");
4
+
5
+ //#region src/langgraph/state-schema.ts
6
+ /**
7
+ * CopilotKit agent state defined with LangGraph's modern
8
+ * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)
9
+ * API.
10
+ *
11
+ * Prefer this over `CopilotKitStateAnnotation` when starting a new
12
+ * TypeScript agent. `Annotation.Root` is still supported by LangGraph but
13
+ * `StateSchema` is the recommended API going forward.
14
+ *
15
+ * ### Example
16
+ *
17
+ * ```typescript
18
+ * import { StateSchema } from "@langchain/langgraph";
19
+ * import { CopilotKitStateSchema } from "@copilotkit/sdk-js/langgraph";
20
+ * import { z } from "zod";
21
+ *
22
+ * export const AgentStateSchema = new StateSchema({
23
+ * language: z.enum(["english", "spanish"]),
24
+ * ...CopilotKitStateSchema.fields,
25
+ * });
26
+ *
27
+ * export type AgentState = typeof AgentStateSchema.State;
28
+ * ```
29
+ */
30
+ const CopilotKitStateSchema = new _langchain_langgraph.StateSchema({
31
+ copilotkit: require_types.CopilotKitPropertiesSchema,
32
+ messages: _langchain_langgraph.MessagesValue
33
+ });
34
+
35
+ //#endregion
36
+ exports.CopilotKitStateSchema = CopilotKitStateSchema;
37
+ //# sourceMappingURL=state-schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-schema.cjs","names":["StateSchema","CopilotKitPropertiesSchema","MessagesValue"],"sources":["../../src/langgraph/state-schema.ts"],"sourcesContent":["import { MessagesValue, StateSchema } from \"@langchain/langgraph\";\nimport { CopilotKitPropertiesSchema } from \"./types\";\n\n/**\n * CopilotKit agent state defined with LangGraph's modern\n * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)\n * API.\n *\n * Prefer this over `CopilotKitStateAnnotation` when starting a new\n * TypeScript agent. `Annotation.Root` is still supported by LangGraph but\n * `StateSchema` is the recommended API going forward.\n *\n * ### Example\n *\n * ```typescript\n * import { StateSchema } from \"@langchain/langgraph\";\n * import { CopilotKitStateSchema } from \"@copilotkit/sdk-js/langgraph\";\n * import { z } from \"zod\";\n *\n * export const AgentStateSchema = new StateSchema({\n * language: z.enum([\"english\", \"spanish\"]),\n * ...CopilotKitStateSchema.fields,\n * });\n *\n * export type AgentState = typeof AgentStateSchema.State;\n * ```\n */\nexport const CopilotKitStateSchema = new StateSchema({\n copilotkit: CopilotKitPropertiesSchema,\n messages: MessagesValue,\n});\n\nexport type CopilotKitSchemaState = typeof CopilotKitStateSchema.State;\nexport type CopilotKitSchemaUpdate = typeof CopilotKitStateSchema.Update;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,wBAAwB,IAAIA,iCAAY;CACnD,YAAYC;CACZ,UAAUC;CACX,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { StandardSerializableSchema } from "./types.cjs";
2
+ import * as _langchain_langgraph0 from "@langchain/langgraph";
3
+ import { StateSchema } from "@langchain/langgraph";
4
+ import * as _langchain_core_messages0 from "@langchain/core/messages";
5
+ import * as langchain from "langchain";
6
+
7
+ //#region src/langgraph/state-schema.d.ts
8
+ /**
9
+ * CopilotKit agent state defined with LangGraph's modern
10
+ * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)
11
+ * API.
12
+ *
13
+ * Prefer this over `CopilotKitStateAnnotation` when starting a new
14
+ * TypeScript agent. `Annotation.Root` is still supported by LangGraph but
15
+ * `StateSchema` is the recommended API going forward.
16
+ *
17
+ * ### Example
18
+ *
19
+ * ```typescript
20
+ * import { StateSchema } from "@langchain/langgraph";
21
+ * import { CopilotKitStateSchema } from "@copilotkit/sdk-js/langgraph";
22
+ * import { z } from "zod";
23
+ *
24
+ * export const AgentStateSchema = new StateSchema({
25
+ * language: z.enum(["english", "spanish"]),
26
+ * ...CopilotKitStateSchema.fields,
27
+ * });
28
+ *
29
+ * export type AgentState = typeof AgentStateSchema.State;
30
+ * ```
31
+ */
32
+ declare const CopilotKitStateSchema: StateSchema<{
33
+ copilotkit: StandardSerializableSchema<_langchain_langgraph0.StateType<{
34
+ actions: {
35
+ (): _langchain_langgraph0.LastValue<any[]>;
36
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
37
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
38
+ };
39
+ context: {
40
+ (): _langchain_langgraph0.LastValue<{
41
+ description: string;
42
+ value: string;
43
+ }[]>;
44
+ (annotation: _langchain_langgraph0.SingleReducer<{
45
+ description: string;
46
+ value: string;
47
+ }[], {
48
+ description: string;
49
+ value: string;
50
+ }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
51
+ description: string;
52
+ value: string;
53
+ }[], {
54
+ description: string;
55
+ value: string;
56
+ }[]>;
57
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
58
+ };
59
+ interceptedToolCalls: {
60
+ (): _langchain_langgraph0.LastValue<any[]>;
61
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
62
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
63
+ };
64
+ originalAIMessageId: {
65
+ (): _langchain_langgraph0.LastValue<string>;
66
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
67
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
68
+ };
69
+ }>, _langchain_langgraph0.StateType<{
70
+ actions: {
71
+ (): _langchain_langgraph0.LastValue<any[]>;
72
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
73
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
74
+ };
75
+ context: {
76
+ (): _langchain_langgraph0.LastValue<{
77
+ description: string;
78
+ value: string;
79
+ }[]>;
80
+ (annotation: _langchain_langgraph0.SingleReducer<{
81
+ description: string;
82
+ value: string;
83
+ }[], {
84
+ description: string;
85
+ value: string;
86
+ }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
87
+ description: string;
88
+ value: string;
89
+ }[], {
90
+ description: string;
91
+ value: string;
92
+ }[]>;
93
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
94
+ };
95
+ interceptedToolCalls: {
96
+ (): _langchain_langgraph0.LastValue<any[]>;
97
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
98
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
99
+ };
100
+ originalAIMessageId: {
101
+ (): _langchain_langgraph0.LastValue<string>;
102
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
103
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
104
+ };
105
+ }>>;
106
+ messages: _langchain_langgraph0.ReducedValue<langchain.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], _langchain_langgraph0.Messages>;
107
+ }>;
108
+ type CopilotKitSchemaState = typeof CopilotKitStateSchema.State;
109
+ type CopilotKitSchemaUpdate = typeof CopilotKitStateSchema.Update;
110
+ //#endregion
111
+ export { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema };
112
+ //# sourceMappingURL=state-schema.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-schema.d.cts","names":[],"sources":["../../src/langgraph/state-schema.ts"],"mappings":";;;;;;;;;;;;;AA2BA;;;;;;;;;;;;;;;;;;cAAa,qBAAA,EAAqB,WAAA;;;UAGhC,qBAAA,CAAA,SAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEU,qBAAA,UAA+B,qBAAA,CAAsB,KAAA;AAAA,KACrD,sBAAA,UAAgC,qBAAA,CAAsB,MAAA"}
@@ -0,0 +1,112 @@
1
+ import { StandardSerializableSchema } from "./types.mjs";
2
+ import * as _langchain_langgraph0 from "@langchain/langgraph";
3
+ import { StateSchema } from "@langchain/langgraph";
4
+ import * as _langchain_core_messages0 from "@langchain/core/messages";
5
+ import * as langchain from "langchain";
6
+
7
+ //#region src/langgraph/state-schema.d.ts
8
+ /**
9
+ * CopilotKit agent state defined with LangGraph's modern
10
+ * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)
11
+ * API.
12
+ *
13
+ * Prefer this over `CopilotKitStateAnnotation` when starting a new
14
+ * TypeScript agent. `Annotation.Root` is still supported by LangGraph but
15
+ * `StateSchema` is the recommended API going forward.
16
+ *
17
+ * ### Example
18
+ *
19
+ * ```typescript
20
+ * import { StateSchema } from "@langchain/langgraph";
21
+ * import { CopilotKitStateSchema } from "@copilotkit/sdk-js/langgraph";
22
+ * import { z } from "zod";
23
+ *
24
+ * export const AgentStateSchema = new StateSchema({
25
+ * language: z.enum(["english", "spanish"]),
26
+ * ...CopilotKitStateSchema.fields,
27
+ * });
28
+ *
29
+ * export type AgentState = typeof AgentStateSchema.State;
30
+ * ```
31
+ */
32
+ declare const CopilotKitStateSchema: StateSchema<{
33
+ copilotkit: StandardSerializableSchema<_langchain_langgraph0.StateType<{
34
+ actions: {
35
+ (): _langchain_langgraph0.LastValue<any[]>;
36
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
37
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
38
+ };
39
+ context: {
40
+ (): _langchain_langgraph0.LastValue<{
41
+ description: string;
42
+ value: string;
43
+ }[]>;
44
+ (annotation: _langchain_langgraph0.SingleReducer<{
45
+ description: string;
46
+ value: string;
47
+ }[], {
48
+ description: string;
49
+ value: string;
50
+ }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
51
+ description: string;
52
+ value: string;
53
+ }[], {
54
+ description: string;
55
+ value: string;
56
+ }[]>;
57
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
58
+ };
59
+ interceptedToolCalls: {
60
+ (): _langchain_langgraph0.LastValue<any[]>;
61
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
62
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
63
+ };
64
+ originalAIMessageId: {
65
+ (): _langchain_langgraph0.LastValue<string>;
66
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
67
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
68
+ };
69
+ }>, _langchain_langgraph0.StateType<{
70
+ actions: {
71
+ (): _langchain_langgraph0.LastValue<any[]>;
72
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
73
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
74
+ };
75
+ context: {
76
+ (): _langchain_langgraph0.LastValue<{
77
+ description: string;
78
+ value: string;
79
+ }[]>;
80
+ (annotation: _langchain_langgraph0.SingleReducer<{
81
+ description: string;
82
+ value: string;
83
+ }[], {
84
+ description: string;
85
+ value: string;
86
+ }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
87
+ description: string;
88
+ value: string;
89
+ }[], {
90
+ description: string;
91
+ value: string;
92
+ }[]>;
93
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
94
+ };
95
+ interceptedToolCalls: {
96
+ (): _langchain_langgraph0.LastValue<any[]>;
97
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
98
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
99
+ };
100
+ originalAIMessageId: {
101
+ (): _langchain_langgraph0.LastValue<string>;
102
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
103
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
104
+ };
105
+ }>>;
106
+ messages: _langchain_langgraph0.ReducedValue<langchain.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], _langchain_langgraph0.Messages>;
107
+ }>;
108
+ type CopilotKitSchemaState = typeof CopilotKitStateSchema.State;
109
+ type CopilotKitSchemaUpdate = typeof CopilotKitStateSchema.Update;
110
+ //#endregion
111
+ export { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema };
112
+ //# sourceMappingURL=state-schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-schema.d.mts","names":[],"sources":["../../src/langgraph/state-schema.ts"],"mappings":";;;;;;;;;;;;;AA2BA;;;;;;;;;;;;;;;;;;cAAa,qBAAA,EAAqB,WAAA;;;UAGhC,qBAAA,CAAA,SAAA;MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEU,qBAAA,UAA+B,qBAAA,CAAsB,KAAA;AAAA,KACrD,sBAAA,UAAgC,qBAAA,CAAsB,MAAA"}
@@ -0,0 +1,36 @@
1
+ import { CopilotKitPropertiesSchema } from "./types.mjs";
2
+ import { MessagesValue, StateSchema } from "@langchain/langgraph";
3
+
4
+ //#region src/langgraph/state-schema.ts
5
+ /**
6
+ * CopilotKit agent state defined with LangGraph's modern
7
+ * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)
8
+ * API.
9
+ *
10
+ * Prefer this over `CopilotKitStateAnnotation` when starting a new
11
+ * TypeScript agent. `Annotation.Root` is still supported by LangGraph but
12
+ * `StateSchema` is the recommended API going forward.
13
+ *
14
+ * ### Example
15
+ *
16
+ * ```typescript
17
+ * import { StateSchema } from "@langchain/langgraph";
18
+ * import { CopilotKitStateSchema } from "@copilotkit/sdk-js/langgraph";
19
+ * import { z } from "zod";
20
+ *
21
+ * export const AgentStateSchema = new StateSchema({
22
+ * language: z.enum(["english", "spanish"]),
23
+ * ...CopilotKitStateSchema.fields,
24
+ * });
25
+ *
26
+ * export type AgentState = typeof AgentStateSchema.State;
27
+ * ```
28
+ */
29
+ const CopilotKitStateSchema = new StateSchema({
30
+ copilotkit: CopilotKitPropertiesSchema,
31
+ messages: MessagesValue
32
+ });
33
+
34
+ //#endregion
35
+ export { CopilotKitStateSchema };
36
+ //# sourceMappingURL=state-schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-schema.mjs","names":[],"sources":["../../src/langgraph/state-schema.ts"],"sourcesContent":["import { MessagesValue, StateSchema } from \"@langchain/langgraph\";\nimport { CopilotKitPropertiesSchema } from \"./types\";\n\n/**\n * CopilotKit agent state defined with LangGraph's modern\n * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)\n * API.\n *\n * Prefer this over `CopilotKitStateAnnotation` when starting a new\n * TypeScript agent. `Annotation.Root` is still supported by LangGraph but\n * `StateSchema` is the recommended API going forward.\n *\n * ### Example\n *\n * ```typescript\n * import { StateSchema } from \"@langchain/langgraph\";\n * import { CopilotKitStateSchema } from \"@copilotkit/sdk-js/langgraph\";\n * import { z } from \"zod\";\n *\n * export const AgentStateSchema = new StateSchema({\n * language: z.enum([\"english\", \"spanish\"]),\n * ...CopilotKitStateSchema.fields,\n * });\n *\n * export type AgentState = typeof AgentStateSchema.State;\n * ```\n */\nexport const CopilotKitStateSchema = new StateSchema({\n copilotkit: CopilotKitPropertiesSchema,\n messages: MessagesValue,\n});\n\nexport type CopilotKitSchemaState = typeof CopilotKitStateSchema.State;\nexport type CopilotKitSchemaUpdate = typeof CopilotKitStateSchema.Update;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,wBAAwB,IAAI,YAAY;CACnD,YAAY;CACZ,UAAU;CACX,CAAC"}
@@ -12,8 +12,49 @@ const CopilotKitStateAnnotation = _langchain_langgraph.Annotation.Root({
12
12
  copilotkit: _langchain_langgraph.Annotation,
13
13
  ..._langchain_langgraph.MessagesAnnotation.spec
14
14
  });
15
+ const COPILOTKIT_PROPERTIES_JSON_SCHEMA = {
16
+ type: "object",
17
+ properties: {
18
+ actions: {
19
+ type: "array",
20
+ items: {}
21
+ },
22
+ context: {
23
+ type: "array",
24
+ items: {
25
+ type: "object",
26
+ properties: {
27
+ description: { type: "string" },
28
+ value: { type: "string" }
29
+ },
30
+ required: ["description", "value"]
31
+ }
32
+ },
33
+ interceptedToolCalls: {
34
+ type: "array",
35
+ items: {}
36
+ },
37
+ originalAIMessageId: { type: "string" }
38
+ }
39
+ };
40
+ /**
41
+ * Standard Schema describing the `copilotkit` field on agent state.
42
+ *
43
+ * CopilotKit populates these fields at runtime, so the schema accepts any
44
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
45
+ */
46
+ const CopilotKitPropertiesSchema = { "~standard": {
47
+ version: 1,
48
+ vendor: "@copilotkit/sdk-js",
49
+ validate: (value) => ({ value }),
50
+ jsonSchema: {
51
+ input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,
52
+ output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA
53
+ }
54
+ } };
15
55
 
16
56
  //#endregion
17
57
  exports.CopilotKitPropertiesAnnotation = CopilotKitPropertiesAnnotation;
58
+ exports.CopilotKitPropertiesSchema = CopilotKitPropertiesSchema;
18
59
  exports.CopilotKitStateAnnotation = CopilotKitStateAnnotation;
19
60
  //# sourceMappingURL=types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":["Annotation","MessagesAnnotation"],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;;AAEA,MAAa,iCAAiCA,gCAAW,KAAK;CAC5D,SAASA;CACT,SAASA;CACT,sBAAsBA;CACtB,qBAAqBA;CACtB,CAAC;AAEF,MAAa,4BAA4BA,gCAAW,KAAK;CACvD,YAAYA;CACZ,GAAGC,wCAAmB;CACvB,CAAC"}
1
+ {"version":3,"file":"types.cjs","names":["Annotation","MessagesAnnotation"],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport interface StandardSerializableSchema<Input, Output = Input> {\n readonly \"~standard\": {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: unknown,\n ) => { value: Output } | { issues: ReadonlyArray<{ message: string }> };\n readonly types?: { readonly input: Input; readonly output: Output };\n readonly jsonSchema: {\n readonly input: (options: { target: string }) => Record<string, unknown>;\n readonly output: (options: { target: string }) => Record<string, unknown>;\n };\n };\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nconst COPILOTKIT_PROPERTIES_JSON_SCHEMA = {\n type: \"object\",\n properties: {\n actions: { type: \"array\", items: {} },\n context: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: { type: \"string\" },\n value: { type: \"string\" },\n },\n required: [\"description\", \"value\"],\n },\n },\n interceptedToolCalls: { type: \"array\", items: {} },\n originalAIMessageId: { type: \"string\" },\n },\n};\n\n/**\n * Standard Schema describing the `copilotkit` field on agent state.\n *\n * CopilotKit populates these fields at runtime, so the schema accepts any\n * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.\n */\nexport const CopilotKitPropertiesSchema: StandardSerializableSchema<\n typeof CopilotKitPropertiesAnnotation.State\n> = {\n \"~standard\": {\n version: 1,\n vendor: \"@copilotkit/sdk-js\",\n validate: (value) => ({\n value: value as typeof CopilotKitPropertiesAnnotation.State,\n }),\n jsonSchema: {\n input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n },\n },\n};\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;;AAiBA,MAAa,iCAAiCA,gCAAW,KAAK;CAC5D,SAASA;CACT,SAASA;CACT,sBAAsBA;CACtB,qBAAqBA;CACtB,CAAC;AAEF,MAAa,4BAA4BA,gCAAW,KAAK;CACvD,YAAYA;CACZ,GAAGC,wCAAmB;CACvB,CAAC;AAEF,MAAM,oCAAoC;CACxC,MAAM;CACN,YAAY;EACV,SAAS;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EACrC,SAAS;GACP,MAAM;GACN,OAAO;IACL,MAAM;IACN,YAAY;KACV,aAAa,EAAE,MAAM,UAAU;KAC/B,OAAO,EAAE,MAAM,UAAU;KAC1B;IACD,UAAU,CAAC,eAAe,QAAQ;IACnC;GACF;EACD,sBAAsB;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EAClD,qBAAqB,EAAE,MAAM,UAAU;EACxC;CACF;;;;;;;AAQD,MAAa,6BAET,EACF,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EACb,OACR;CACD,YAAY;EACV,aAAa;EACb,cAAc;EACf;CACF,EACF"}
@@ -3,6 +3,31 @@ import * as _langchain_core_messages0 from "@langchain/core/messages";
3
3
  import * as langchain from "langchain";
4
4
 
5
5
  //#region src/langgraph/types.d.ts
6
+ interface StandardSerializableSchema<Input, Output = Input> {
7
+ readonly "~standard": {
8
+ readonly version: 1;
9
+ readonly vendor: string;
10
+ readonly validate: (value: unknown) => {
11
+ value: Output;
12
+ } | {
13
+ issues: ReadonlyArray<{
14
+ message: string;
15
+ }>;
16
+ };
17
+ readonly types?: {
18
+ readonly input: Input;
19
+ readonly output: Output;
20
+ };
21
+ readonly jsonSchema: {
22
+ readonly input: (options: {
23
+ target: string;
24
+ }) => Record<string, unknown>;
25
+ readonly output: (options: {
26
+ target: string;
27
+ }) => Record<string, unknown>;
28
+ };
29
+ };
30
+ }
6
31
  declare const CopilotKitPropertiesAnnotation: _langchain_langgraph0.AnnotationRoot<{
7
32
  actions: {
8
33
  (): _langchain_langgraph0.LastValue<any[]>;
@@ -228,6 +253,13 @@ declare const CopilotKitStateAnnotation: _langchain_langgraph0.AnnotationRoot<{
228
253
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
229
254
  };
230
255
  }>;
256
+ /**
257
+ * Standard Schema describing the `copilotkit` field on agent state.
258
+ *
259
+ * CopilotKit populates these fields at runtime, so the schema accepts any
260
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
261
+ */
262
+ declare const CopilotKitPropertiesSchema: StandardSerializableSchema<typeof CopilotKitPropertiesAnnotation.State>;
231
263
  interface IntermediateStateConfig {
232
264
  stateKey: string;
233
265
  tool: string;
@@ -242,5 +274,5 @@ interface OptionsConfig {
242
274
  type CopilotKitState = typeof CopilotKitStateAnnotation.State;
243
275
  type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;
244
276
  //#endregion
245
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig };
277
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema };
246
278
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;cAEa,8BAAA,wBAA8B,cAAA;;QAKzC,qBAAA,CAAA,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;2HAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAEe,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;UAEiB,0BAAA,iBAA2C,KAAA;EAAA,SACjD,WAAA;IAAA,SACE,OAAA;IAAA,SACA,MAAA;IAAA,SACA,QAAA,GACP,KAAA;MACK,KAAA,EAAO,MAAA;IAAA;MAAa,MAAA,EAAQ,aAAA;QAAgB,OAAA;MAAA;IAAA;IAAA,SAC1C,KAAA;MAAA,SAAmB,KAAA,EAAO,KAAA;MAAA,SAAgB,MAAA,EAAQ,MAAA;IAAA;IAAA,SAClD,UAAA;MAAA,SACE,KAAA,GAAQ,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;MAAA,SACxC,MAAA,GAAS,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;IAAA;EAAA;AAAA;AAAA,cAK3C,8BAAA,wBAA8B,cAAA;;QAKzC,qBAAA,CAAA,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;2HAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BW,0BAAA,EAA4B,0BAAA,QAChC,8BAAA,CAA+B,KAAA;AAAA,UAevB,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
@@ -3,6 +3,31 @@ import * as _langchain_core_messages0 from "@langchain/core/messages";
3
3
  import * as langchain from "langchain";
4
4
 
5
5
  //#region src/langgraph/types.d.ts
6
+ interface StandardSerializableSchema<Input, Output = Input> {
7
+ readonly "~standard": {
8
+ readonly version: 1;
9
+ readonly vendor: string;
10
+ readonly validate: (value: unknown) => {
11
+ value: Output;
12
+ } | {
13
+ issues: ReadonlyArray<{
14
+ message: string;
15
+ }>;
16
+ };
17
+ readonly types?: {
18
+ readonly input: Input;
19
+ readonly output: Output;
20
+ };
21
+ readonly jsonSchema: {
22
+ readonly input: (options: {
23
+ target: string;
24
+ }) => Record<string, unknown>;
25
+ readonly output: (options: {
26
+ target: string;
27
+ }) => Record<string, unknown>;
28
+ };
29
+ };
30
+ }
6
31
  declare const CopilotKitPropertiesAnnotation: _langchain_langgraph0.AnnotationRoot<{
7
32
  actions: {
8
33
  (): _langchain_langgraph0.LastValue<any[]>;
@@ -228,6 +253,13 @@ declare const CopilotKitStateAnnotation: _langchain_langgraph0.AnnotationRoot<{
228
253
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
229
254
  };
230
255
  }>;
256
+ /**
257
+ * Standard Schema describing the `copilotkit` field on agent state.
258
+ *
259
+ * CopilotKit populates these fields at runtime, so the schema accepts any
260
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
261
+ */
262
+ declare const CopilotKitPropertiesSchema: StandardSerializableSchema<typeof CopilotKitPropertiesAnnotation.State>;
231
263
  interface IntermediateStateConfig {
232
264
  stateKey: string;
233
265
  tool: string;
@@ -242,5 +274,5 @@ interface OptionsConfig {
242
274
  type CopilotKitState = typeof CopilotKitStateAnnotation.State;
243
275
  type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;
244
276
  //#endregion
245
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig };
277
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema };
246
278
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;cAEa,8BAAA,wBAA8B,cAAA;;QAKzC,qBAAA,CAAA,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;2HAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAEe,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;UAEiB,0BAAA,iBAA2C,KAAA;EAAA,SACjD,WAAA;IAAA,SACE,OAAA;IAAA,SACA,MAAA;IAAA,SACA,QAAA,GACP,KAAA;MACK,KAAA,EAAO,MAAA;IAAA;MAAa,MAAA,EAAQ,aAAA;QAAgB,OAAA;MAAA;IAAA;IAAA,SAC1C,KAAA;MAAA,SAAmB,KAAA,EAAO,KAAA;MAAA,SAAgB,MAAA,EAAQ,MAAA;IAAA;IAAA,SAClD,UAAA;MAAA,SACE,KAAA,GAAQ,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;MAAA,SACxC,MAAA,GAAS,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;IAAA;EAAA;AAAA;AAAA,cAK3C,8BAAA,wBAA8B,cAAA;;QAKzC,qBAAA,CAAA,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;2HAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BW,0BAAA,EAA4B,0BAAA,QAChC,8BAAA,CAA+B,KAAA;AAAA,UAevB,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
@@ -11,7 +11,47 @@ const CopilotKitStateAnnotation = Annotation.Root({
11
11
  copilotkit: Annotation,
12
12
  ...MessagesAnnotation.spec
13
13
  });
14
+ const COPILOTKIT_PROPERTIES_JSON_SCHEMA = {
15
+ type: "object",
16
+ properties: {
17
+ actions: {
18
+ type: "array",
19
+ items: {}
20
+ },
21
+ context: {
22
+ type: "array",
23
+ items: {
24
+ type: "object",
25
+ properties: {
26
+ description: { type: "string" },
27
+ value: { type: "string" }
28
+ },
29
+ required: ["description", "value"]
30
+ }
31
+ },
32
+ interceptedToolCalls: {
33
+ type: "array",
34
+ items: {}
35
+ },
36
+ originalAIMessageId: { type: "string" }
37
+ }
38
+ };
39
+ /**
40
+ * Standard Schema describing the `copilotkit` field on agent state.
41
+ *
42
+ * CopilotKit populates these fields at runtime, so the schema accepts any
43
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
44
+ */
45
+ const CopilotKitPropertiesSchema = { "~standard": {
46
+ version: 1,
47
+ vendor: "@copilotkit/sdk-js",
48
+ validate: (value) => ({ value }),
49
+ jsonSchema: {
50
+ input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,
51
+ output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA
52
+ }
53
+ } };
14
54
 
15
55
  //#endregion
16
- export { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation };
56
+ export { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation };
17
57
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;AAEA,MAAa,iCAAiC,WAAW,KAAK;CAC5D,SAAS;CACT,SAAS;CACT,sBAAsB;CACtB,qBAAqB;CACtB,CAAC;AAEF,MAAa,4BAA4B,WAAW,KAAK;CACvD,YAAY;CACZ,GAAG,mBAAmB;CACvB,CAAC"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport interface StandardSerializableSchema<Input, Output = Input> {\n readonly \"~standard\": {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: unknown,\n ) => { value: Output } | { issues: ReadonlyArray<{ message: string }> };\n readonly types?: { readonly input: Input; readonly output: Output };\n readonly jsonSchema: {\n readonly input: (options: { target: string }) => Record<string, unknown>;\n readonly output: (options: { target: string }) => Record<string, unknown>;\n };\n };\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nconst COPILOTKIT_PROPERTIES_JSON_SCHEMA = {\n type: \"object\",\n properties: {\n actions: { type: \"array\", items: {} },\n context: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: { type: \"string\" },\n value: { type: \"string\" },\n },\n required: [\"description\", \"value\"],\n },\n },\n interceptedToolCalls: { type: \"array\", items: {} },\n originalAIMessageId: { type: \"string\" },\n },\n};\n\n/**\n * Standard Schema describing the `copilotkit` field on agent state.\n *\n * CopilotKit populates these fields at runtime, so the schema accepts any\n * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.\n */\nexport const CopilotKitPropertiesSchema: StandardSerializableSchema<\n typeof CopilotKitPropertiesAnnotation.State\n> = {\n \"~standard\": {\n version: 1,\n vendor: \"@copilotkit/sdk-js\",\n validate: (value) => ({\n value: value as typeof CopilotKitPropertiesAnnotation.State,\n }),\n jsonSchema: {\n input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n },\n },\n};\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;AAiBA,MAAa,iCAAiC,WAAW,KAAK;CAC5D,SAAS;CACT,SAAS;CACT,sBAAsB;CACtB,qBAAqB;CACtB,CAAC;AAEF,MAAa,4BAA4B,WAAW,KAAK;CACvD,YAAY;CACZ,GAAG,mBAAmB;CACvB,CAAC;AAEF,MAAM,oCAAoC;CACxC,MAAM;CACN,YAAY;EACV,SAAS;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EACrC,SAAS;GACP,MAAM;GACN,OAAO;IACL,MAAM;IACN,YAAY;KACV,aAAa,EAAE,MAAM,UAAU;KAC/B,OAAO,EAAE,MAAM,UAAU;KAC1B;IACD,UAAU,CAAC,eAAe,QAAQ;IACnC;GACF;EACD,sBAAsB;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EAClD,qBAAqB,EAAE,MAAM,UAAU;EACxC;CACF;;;;;;;AAQD,MAAa,6BAET,EACF,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EACb,OACR;CACD,YAAY;EACV,aAAa;EACb,cAAc;EACf;CACF,EACF"}
@@ -2,9 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_types = require('./langgraph/types.cjs');
3
3
  const require_utils = require('./langgraph/utils.cjs');
4
4
  const require_middleware = require('./langgraph/middleware.cjs');
5
+ const require_state_schema = require('./langgraph/state-schema.cjs');
5
6
 
6
7
  exports.CopilotKitPropertiesAnnotation = require_types.CopilotKitPropertiesAnnotation;
8
+ exports.CopilotKitPropertiesSchema = require_types.CopilotKitPropertiesSchema;
7
9
  exports.CopilotKitStateAnnotation = require_types.CopilotKitStateAnnotation;
10
+ exports.CopilotKitStateSchema = require_state_schema.CopilotKitStateSchema;
8
11
  exports.convertActionToDynamicStructuredTool = require_utils.convertActionToDynamicStructuredTool;
9
12
  exports.convertActionsToDynamicStructuredTools = require_utils.convertActionsToDynamicStructuredTools;
10
13
  exports.copilotKitInterrupt = require_utils.copilotKitInterrupt;
@@ -1,4 +1,5 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig } from "./langgraph/types.cjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema } from "./langgraph/types.cjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.cjs";
3
3
  import { copilotkitMiddleware } from "./langgraph/middleware.cjs";
4
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
4
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.cjs";
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
@@ -1,4 +1,5 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig } from "./langgraph/types.mjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
3
  import { copilotkitMiddleware } from "./langgraph/middleware.mjs";
4
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
4
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
@@ -1,5 +1,6 @@
1
- import { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
1
+ import { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
3
  import { copilotkitMiddleware } from "./langgraph/middleware.mjs";
4
+ import { CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
4
5
 
5
- export { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
6
+ export { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation, CopilotKitStateSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/sdk-js",
3
- "version": "1.56.3",
3
+ "version": "1.56.4",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@ag-ui/langgraph": "0.0.29",
52
- "@copilotkit/shared": "1.56.3"
52
+ "@copilotkit/shared": "1.56.4"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@langchain/core": "^1.1.8",
package/src/langchain.ts CHANGED
@@ -4,8 +4,12 @@ console.warn(
4
4
 
5
5
  export {
6
6
  CopilotKitPropertiesAnnotation,
7
+ CopilotKitPropertiesSchema,
7
8
  CopilotKitStateAnnotation,
9
+ CopilotKitStateSchema,
8
10
  type CopilotKitState,
11
+ type CopilotKitSchemaState,
12
+ type CopilotKitSchemaUpdate,
9
13
  type CopilotKitProperties,
10
14
  copilotkitCustomizeConfig as copilotKitCustomizeConfig,
11
15
  copilotkitExit as copilotKitExit,
@@ -0,0 +1,85 @@
1
+ import { StateGraph, END, START, StateSchema } from "@langchain/langgraph";
2
+ import { HumanMessage } from "@langchain/core/messages";
3
+ import * as z from "zod";
4
+
5
+ import { CopilotKitStateSchema } from "../state-schema";
6
+ import { CopilotKitPropertiesSchema } from "../types";
7
+
8
+ describe("CopilotKitStateSchema", () => {
9
+ it("exposes `copilotkit` and `messages` fields for composition", () => {
10
+ expect(Object.keys(CopilotKitStateSchema.fields).sort()).toEqual([
11
+ "copilotkit",
12
+ "messages",
13
+ ]);
14
+ });
15
+
16
+ it("can be used directly as a StateGraph schema", async () => {
17
+ const graph = new StateGraph(CopilotKitStateSchema)
18
+ .addNode("echo", (state) => ({ messages: state.messages }))
19
+ .addEdge(START, "echo")
20
+ .addEdge("echo", END)
21
+ .compile();
22
+
23
+ const result = await graph.invoke({
24
+ messages: [new HumanMessage("hello")],
25
+ });
26
+
27
+ expect(result.messages).toHaveLength(1);
28
+ expect(result.messages[0].content).toBe("hello");
29
+ });
30
+
31
+ it("can be extended with user fields via spread", async () => {
32
+ const AgentStateSchema = new StateSchema({
33
+ language: z.enum(["english", "spanish"]).default("english"),
34
+ ...CopilotKitStateSchema.fields,
35
+ });
36
+
37
+ const graph = new StateGraph(AgentStateSchema)
38
+ .addNode("chat", (state) => ({ language: state.language }))
39
+ .addEdge(START, "chat")
40
+ .addEdge("chat", END)
41
+ .compile();
42
+
43
+ const result = await graph.invoke({
44
+ language: "spanish",
45
+ messages: [new HumanMessage("hola")],
46
+ });
47
+
48
+ expect(result.language).toBe("spanish");
49
+ expect(result.messages).toHaveLength(1);
50
+ });
51
+
52
+ it("preserves copilotkit runtime state across nodes", async () => {
53
+ const graph = new StateGraph(CopilotKitStateSchema)
54
+ .addNode("noop", (state) => ({ copilotkit: state.copilotkit }))
55
+ .addEdge(START, "noop")
56
+ .addEdge("noop", END)
57
+ .compile();
58
+
59
+ const result = await graph.invoke({
60
+ copilotkit: {
61
+ actions: [{ name: "doThing" }],
62
+ context: [{ description: "user", value: "alice" }],
63
+ interceptedToolCalls: [],
64
+ originalAIMessageId: "msg-1",
65
+ },
66
+ messages: [],
67
+ });
68
+
69
+ expect(result.copilotkit.actions).toEqual([{ name: "doThing" }]);
70
+ expect(result.copilotkit.context).toEqual([
71
+ { description: "user", value: "alice" },
72
+ ]);
73
+ expect(result.copilotkit.originalAIMessageId).toBe("msg-1");
74
+ });
75
+
76
+ it("exposes a standard schema shape for copilotkit properties", () => {
77
+ expect(CopilotKitPropertiesSchema["~standard"].version).toBe(1);
78
+ expect(CopilotKitPropertiesSchema["~standard"].vendor).toBe(
79
+ "@copilotkit/sdk-js",
80
+ );
81
+ expect(
82
+ typeof CopilotKitPropertiesSchema["~standard"].jsonSchema.input,
83
+ ).toBe("function");
84
+ });
85
+ });
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
2
  export * from "./utils";
3
3
  export * from "./middleware";
4
+ export * from "./state-schema";
@@ -0,0 +1,34 @@
1
+ import { MessagesValue, StateSchema } from "@langchain/langgraph";
2
+ import { CopilotKitPropertiesSchema } from "./types";
3
+
4
+ /**
5
+ * CopilotKit agent state defined with LangGraph's modern
6
+ * [`StateSchema`](https://docs.langchain.com/oss/javascript/langgraph/graph-api)
7
+ * API.
8
+ *
9
+ * Prefer this over `CopilotKitStateAnnotation` when starting a new
10
+ * TypeScript agent. `Annotation.Root` is still supported by LangGraph but
11
+ * `StateSchema` is the recommended API going forward.
12
+ *
13
+ * ### Example
14
+ *
15
+ * ```typescript
16
+ * import { StateSchema } from "@langchain/langgraph";
17
+ * import { CopilotKitStateSchema } from "@copilotkit/sdk-js/langgraph";
18
+ * import { z } from "zod";
19
+ *
20
+ * export const AgentStateSchema = new StateSchema({
21
+ * language: z.enum(["english", "spanish"]),
22
+ * ...CopilotKitStateSchema.fields,
23
+ * });
24
+ *
25
+ * export type AgentState = typeof AgentStateSchema.State;
26
+ * ```
27
+ */
28
+ export const CopilotKitStateSchema = new StateSchema({
29
+ copilotkit: CopilotKitPropertiesSchema,
30
+ messages: MessagesValue,
31
+ });
32
+
33
+ export type CopilotKitSchemaState = typeof CopilotKitStateSchema.State;
34
+ export type CopilotKitSchemaUpdate = typeof CopilotKitStateSchema.Update;
@@ -1,5 +1,20 @@
1
1
  import { Annotation, MessagesAnnotation } from "@langchain/langgraph";
2
2
 
3
+ export interface StandardSerializableSchema<Input, Output = Input> {
4
+ readonly "~standard": {
5
+ readonly version: 1;
6
+ readonly vendor: string;
7
+ readonly validate: (
8
+ value: unknown,
9
+ ) => { value: Output } | { issues: ReadonlyArray<{ message: string }> };
10
+ readonly types?: { readonly input: Input; readonly output: Output };
11
+ readonly jsonSchema: {
12
+ readonly input: (options: { target: string }) => Record<string, unknown>;
13
+ readonly output: (options: { target: string }) => Record<string, unknown>;
14
+ };
15
+ };
16
+ }
17
+
3
18
  export const CopilotKitPropertiesAnnotation = Annotation.Root({
4
19
  actions: Annotation<any[]>,
5
20
  context: Annotation<{ description: string; value: string }[]>,
@@ -12,6 +27,48 @@ export const CopilotKitStateAnnotation = Annotation.Root({
12
27
  ...MessagesAnnotation.spec,
13
28
  });
14
29
 
30
+ const COPILOTKIT_PROPERTIES_JSON_SCHEMA = {
31
+ type: "object",
32
+ properties: {
33
+ actions: { type: "array", items: {} },
34
+ context: {
35
+ type: "array",
36
+ items: {
37
+ type: "object",
38
+ properties: {
39
+ description: { type: "string" },
40
+ value: { type: "string" },
41
+ },
42
+ required: ["description", "value"],
43
+ },
44
+ },
45
+ interceptedToolCalls: { type: "array", items: {} },
46
+ originalAIMessageId: { type: "string" },
47
+ },
48
+ };
49
+
50
+ /**
51
+ * Standard Schema describing the `copilotkit` field on agent state.
52
+ *
53
+ * CopilotKit populates these fields at runtime, so the schema accepts any
54
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
55
+ */
56
+ export const CopilotKitPropertiesSchema: StandardSerializableSchema<
57
+ typeof CopilotKitPropertiesAnnotation.State
58
+ > = {
59
+ "~standard": {
60
+ version: 1,
61
+ vendor: "@copilotkit/sdk-js",
62
+ validate: (value) => ({
63
+ value: value as typeof CopilotKitPropertiesAnnotation.State,
64
+ }),
65
+ jsonSchema: {
66
+ input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,
67
+ output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,
68
+ },
69
+ },
70
+ };
71
+
15
72
  export interface IntermediateStateConfig {
16
73
  stateKey: string;
17
74
  tool: string;