@copilotkit/runtime-client-gql 1.5.1-test-custom-tag-prerelease-1.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -4
- package/package.json +3 -3
- package/src/client/CopilotRuntimeClient.ts +25 -14
- package/src/graphql/definitions/queries.ts +13 -0
- package/dist/chunk-7ECCT6PK.mjs +0 -1
- package/dist/chunk-7ECCT6PK.mjs.map +0 -1
- package/dist/chunk-ACDKKTFY.mjs +0 -77
- package/dist/chunk-ACDKKTFY.mjs.map +0 -1
- package/dist/chunk-BYWDDBGW.mjs +0 -86
- package/dist/chunk-BYWDDBGW.mjs.map +0 -1
- package/dist/chunk-FK5N2ZKU.mjs +0 -81
- package/dist/chunk-FK5N2ZKU.mjs.map +0 -1
- package/dist/chunk-QCGJU5JF.mjs +0 -200
- package/dist/chunk-QCGJU5JF.mjs.map +0 -1
- package/dist/chunk-TPGZVGXM.mjs +0 -52
- package/dist/chunk-TPGZVGXM.mjs.map +0 -1
- package/dist/client/CopilotRuntimeClient.d.ts +0 -30
- package/dist/client/CopilotRuntimeClient.js +0 -182
- package/dist/client/CopilotRuntimeClient.js.map +0 -1
- package/dist/client/CopilotRuntimeClient.mjs +0 -9
- package/dist/client/CopilotRuntimeClient.mjs.map +0 -1
- package/dist/client/conversion.d.ts +0 -11
- package/dist/client/conversion.js +0 -296
- package/dist/client/conversion.js.map +0 -1
- package/dist/client/conversion.mjs +0 -17
- package/dist/client/conversion.mjs.map +0 -1
- package/dist/client/index.d.ts +0 -8
- package/dist/client/index.js +0 -472
- package/dist/client/index.js.map +0 -1
- package/dist/client/index.mjs +0 -36
- package/dist/client/index.mjs.map +0 -1
- package/dist/client/types.d.ts +0 -55
- package/dist/client/types.js +0 -113
- package/dist/client/types.js.map +0 -1
- package/dist/client/types.mjs +0 -18
- package/dist/client/types.mjs.map +0 -1
- package/dist/graphql/definitions/mutations.d.ts +0 -9
- package/dist/graphql/definitions/mutations.js +0 -111
- package/dist/graphql/definitions/mutations.js.map +0 -1
- package/dist/graphql/definitions/mutations.mjs +0 -8
- package/dist/graphql/definitions/mutations.mjs.map +0 -1
- package/dist/graphql-f7416114.d.ts +0 -395
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -518
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -51
- package/dist/index.mjs.map +0 -1
- package/src/graphql/@generated/fragment-masking.ts +0 -87
- package/src/graphql/@generated/gql.ts +0 -42
- package/src/graphql/@generated/graphql.ts +0 -298
- package/src/graphql/@generated/index.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
# @copilotkit/runtime-client-gql
|
|
2
2
|
|
|
3
|
-
## 1.5.1
|
|
3
|
+
## 1.5.1
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
7
|
+
- 5c01e9e: test prerelease #4
|
|
8
|
+
- da280ed: Test prerelease script
|
|
9
|
+
- 27e42d7: testing a prerelease
|
|
10
|
+
- 05240a9: test pre #2
|
|
11
|
+
- 33218fe: test prerelease #3
|
|
12
|
+
- 03f3d6f: Test next prerelease
|
|
13
|
+
- 649ebcc: - fix: add warning when using agents that are not available on agent related hooks
|
|
14
|
+
- Updated dependencies [5c01e9e]
|
|
15
|
+
- Updated dependencies [da280ed]
|
|
16
|
+
- Updated dependencies [27e42d7]
|
|
17
|
+
- Updated dependencies [05240a9]
|
|
18
|
+
- Updated dependencies [33218fe]
|
|
19
|
+
- Updated dependencies [03f3d6f]
|
|
20
|
+
- @copilotkit/shared@1.5.1
|
|
21
|
+
|
|
22
|
+
## 1.5.1-next.3
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 33218fe: test prerelease #3
|
|
27
|
+
- Updated dependencies [33218fe]
|
|
28
|
+
- @copilotkit/shared@1.5.1-next.3
|
|
29
|
+
|
|
30
|
+
## 1.5.1-next.2
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- da280ed: Test prerelease script
|
|
35
|
+
- 649ebcc: - fix: add warning when using agents that are not available on agent related hooks
|
|
36
|
+
- Updated dependencies [da280ed]
|
|
37
|
+
- @copilotkit/shared@1.5.1-next.2
|
|
38
|
+
|
|
39
|
+
## 1.5.1-next.1
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 03f3d6f: Test next prerelease
|
|
44
|
+
- Updated dependencies [03f3d6f]
|
|
45
|
+
- @copilotkit/shared@1.5.1-next.1
|
|
46
|
+
|
|
47
|
+
## 1.5.1-next.0
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- 27e42d7: testing a prerelease
|
|
52
|
+
- Updated dependencies [27e42d7]
|
|
53
|
+
- @copilotkit/shared@1.5.1-next.0
|
|
10
54
|
|
|
11
55
|
## 1.5.0
|
|
12
56
|
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.5.1
|
|
12
|
+
"version": "1.5.1",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"tsup": "^6.7.0",
|
|
44
44
|
"typescript": "^5.4.5",
|
|
45
45
|
"graphql": "^16.8.1",
|
|
46
|
-
"@copilotkit/runtime": "1.5.1
|
|
46
|
+
"@copilotkit/runtime": "1.5.1"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@urql/core": "^5.0.3",
|
|
50
50
|
"untruncate-json": "^0.0.1",
|
|
51
51
|
"urql": "^4.1.0",
|
|
52
|
-
"@copilotkit/shared": "1.5.1
|
|
52
|
+
"@copilotkit/shared": "1.5.1"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"copilotkit",
|
|
@@ -2,12 +2,31 @@ import { Client, cacheExchange, fetchExchange } from "@urql/core";
|
|
|
2
2
|
import * as packageJson from "../../package.json";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
AvailableAgentsQuery,
|
|
5
6
|
GenerateCopilotResponseMutation,
|
|
6
7
|
GenerateCopilotResponseMutationVariables,
|
|
7
8
|
} from "../graphql/@generated/graphql";
|
|
8
9
|
import { generateCopilotResponseMutation } from "../graphql/definitions/mutations";
|
|
10
|
+
import { getAvailableAgentsQuery } from "../graphql/definitions/queries";
|
|
9
11
|
import { OperationResultSource, OperationResult } from "urql";
|
|
10
12
|
|
|
13
|
+
const createFetchFn =
|
|
14
|
+
(signal?: AbortSignal) =>
|
|
15
|
+
async (...args: Parameters<typeof fetch>) => {
|
|
16
|
+
const result = await fetch(args[0], { ...(args[1] ?? {}), signal });
|
|
17
|
+
if (result.status !== 200) {
|
|
18
|
+
switch (result.status) {
|
|
19
|
+
case 404:
|
|
20
|
+
throw new Error(
|
|
21
|
+
"Runtime URL seems to be invalid - got 404 response. Please check the runtimeUrl passed to CopilotKit",
|
|
22
|
+
);
|
|
23
|
+
default:
|
|
24
|
+
throw new Error("Could not fetch copilot response");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
|
|
11
30
|
export interface CopilotRuntimeClientOptions {
|
|
12
31
|
url: string;
|
|
13
32
|
publicApiKey?: string;
|
|
@@ -55,20 +74,7 @@ export class CopilotRuntimeClient {
|
|
|
55
74
|
properties?: GenerateCopilotResponseMutationVariables["properties"];
|
|
56
75
|
signal?: AbortSignal;
|
|
57
76
|
}) {
|
|
58
|
-
const fetchFn =
|
|
59
|
-
const result = await fetch(args[0], { ...(args[1] ?? {}), signal });
|
|
60
|
-
if (result.status !== 200) {
|
|
61
|
-
switch (result.status) {
|
|
62
|
-
case 404:
|
|
63
|
-
throw new Error(
|
|
64
|
-
"Runtime URL seems to be invalid - got 404 response. Please check the runtimeUrl passed to CopilotKit",
|
|
65
|
-
);
|
|
66
|
-
default:
|
|
67
|
-
throw new Error("Could not fetch copilot response");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
};
|
|
77
|
+
const fetchFn = createFetchFn(signal);
|
|
72
78
|
const result = this.client.mutation<
|
|
73
79
|
GenerateCopilotResponseMutation,
|
|
74
80
|
GenerateCopilotResponseMutationVariables
|
|
@@ -97,4 +103,9 @@ export class CopilotRuntimeClient {
|
|
|
97
103
|
},
|
|
98
104
|
});
|
|
99
105
|
}
|
|
106
|
+
|
|
107
|
+
availableAgents() {
|
|
108
|
+
const fetchFn = createFetchFn();
|
|
109
|
+
return this.client.query<AvailableAgentsQuery>(getAvailableAgentsQuery, {}, { fetch: fetchFn });
|
|
110
|
+
}
|
|
100
111
|
}
|
package/dist/chunk-7ECCT6PK.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-7ECCT6PK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-ACDKKTFY.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MessageRole
|
|
3
|
-
} from "./chunk-TPGZVGXM.mjs";
|
|
4
|
-
|
|
5
|
-
// src/client/types.ts
|
|
6
|
-
import { randomId } from "@copilotkit/shared";
|
|
7
|
-
var Message = class {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
props.id ?? (props.id = randomId());
|
|
10
|
-
props.status ?? (props.status = { code: "Success" /* Success */ });
|
|
11
|
-
props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
|
|
12
|
-
Object.assign(this, props);
|
|
13
|
-
}
|
|
14
|
-
isTextMessage() {
|
|
15
|
-
return this.type === "TextMessage";
|
|
16
|
-
}
|
|
17
|
-
isActionExecutionMessage() {
|
|
18
|
-
return this.type === "ActionExecutionMessage";
|
|
19
|
-
}
|
|
20
|
-
isResultMessage() {
|
|
21
|
-
return this.type === "ResultMessage";
|
|
22
|
-
}
|
|
23
|
-
isAgentStateMessage() {
|
|
24
|
-
return this.type === "AgentStateMessage";
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var Role = MessageRole;
|
|
28
|
-
var TextMessage = class extends Message {
|
|
29
|
-
constructor(props) {
|
|
30
|
-
super(props);
|
|
31
|
-
this.type = "TextMessage";
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var ActionExecutionMessage = class extends Message {
|
|
35
|
-
constructor(props) {
|
|
36
|
-
super(props);
|
|
37
|
-
this.type = "ActionExecutionMessage";
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var ResultMessage = class extends Message {
|
|
41
|
-
constructor(props) {
|
|
42
|
-
super(props);
|
|
43
|
-
this.type = "ResultMessage";
|
|
44
|
-
}
|
|
45
|
-
static decodeResult(result) {
|
|
46
|
-
try {
|
|
47
|
-
return JSON.parse(result);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
static encodeResult(result) {
|
|
53
|
-
if (result === void 0) {
|
|
54
|
-
return "";
|
|
55
|
-
} else if (typeof result === "string") {
|
|
56
|
-
return result;
|
|
57
|
-
} else {
|
|
58
|
-
return JSON.stringify(result);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var AgentStateMessage = class extends Message {
|
|
63
|
-
constructor(props) {
|
|
64
|
-
super(props);
|
|
65
|
-
this.type = "AgentStateMessage";
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
Message,
|
|
71
|
-
Role,
|
|
72
|
-
TextMessage,
|
|
73
|
-
ActionExecutionMessage,
|
|
74
|
-
ResultMessage,
|
|
75
|
-
AgentStateMessage
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=chunk-ACDKKTFY.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/types.ts"],"sourcesContent":["import { randomId } from \"@copilotkit/shared\";\nimport {\n ActionExecutionMessageInput,\n MessageRole,\n MessageStatus,\n ResultMessageInput,\n TextMessageInput,\n BaseMessageOutput,\n AgentStateMessageInput,\n MessageStatusCode,\n} from \"../graphql/@generated/graphql\";\n\ntype MessageType = \"TextMessage\" | \"ActionExecutionMessage\" | \"ResultMessage\" | \"AgentStateMessage\";\n\nexport class Message {\n type: MessageType;\n id: BaseMessageOutput[\"id\"];\n createdAt: BaseMessageOutput[\"createdAt\"];\n status: MessageStatus;\n\n constructor(props: any) {\n props.id ??= randomId();\n props.status ??= { code: MessageStatusCode.Success };\n props.createdAt ??= new Date();\n Object.assign(this, props);\n }\n\n isTextMessage(): this is TextMessage {\n return this.type === \"TextMessage\";\n }\n\n isActionExecutionMessage(): this is ActionExecutionMessage {\n return this.type === \"ActionExecutionMessage\";\n }\n\n isResultMessage(): this is ResultMessage {\n return this.type === \"ResultMessage\";\n }\n\n isAgentStateMessage(): this is AgentStateMessage {\n return this.type === \"AgentStateMessage\";\n }\n}\n\n// alias Role to MessageRole\nexport const Role = MessageRole;\n\n// when constructing any message, the base fields are optional\ntype MessageConstructorOptions = Partial<Message>;\n\ntype TextMessageConstructorOptions = MessageConstructorOptions & TextMessageInput;\n\nexport class TextMessage extends Message implements TextMessageConstructorOptions {\n role: TextMessageInput[\"role\"];\n content: TextMessageInput[\"content\"];\n parentMessageId: TextMessageInput[\"parentMessageId\"];\n\n constructor(props: TextMessageConstructorOptions) {\n super(props);\n this.type = \"TextMessage\";\n }\n}\n\ntype ActionExecutionMessageConstructorOptions = MessageConstructorOptions &\n Omit<ActionExecutionMessageInput, \"arguments\"> & {\n arguments: Record<string, any>;\n };\n\nexport class ActionExecutionMessage\n extends Message\n implements Omit<ActionExecutionMessageInput, \"arguments\" | \"scope\">\n{\n name: ActionExecutionMessageInput[\"name\"];\n arguments: Record<string, any>;\n parentMessageId: ActionExecutionMessageInput[\"parentMessageId\"];\n constructor(props: ActionExecutionMessageConstructorOptions) {\n super(props);\n this.type = \"ActionExecutionMessage\";\n }\n}\n\ntype ResultMessageConstructorOptions = MessageConstructorOptions & ResultMessageInput;\n\nexport class ResultMessage extends Message implements ResultMessageConstructorOptions {\n actionExecutionId: ResultMessageInput[\"actionExecutionId\"];\n actionName: ResultMessageInput[\"actionName\"];\n result: ResultMessageInput[\"result\"];\n\n constructor(props: ResultMessageConstructorOptions) {\n super(props);\n this.type = \"ResultMessage\";\n }\n\n static decodeResult(result: string): any {\n try {\n return JSON.parse(result);\n } catch (e) {\n return result;\n }\n }\n\n static encodeResult(result: any): string {\n if (result === undefined) {\n return \"\";\n } else if (typeof result === \"string\") {\n return result;\n } else {\n return JSON.stringify(result);\n }\n }\n}\n\nexport class AgentStateMessage extends Message implements Omit<AgentStateMessageInput, \"state\"> {\n agentName: AgentStateMessageInput[\"agentName\"];\n state: any;\n running: AgentStateMessageInput[\"running\"];\n threadId: AgentStateMessageInput[\"threadId\"];\n role: AgentStateMessageInput[\"role\"];\n nodeName: AgentStateMessageInput[\"nodeName\"];\n runId: AgentStateMessageInput[\"runId\"];\n active: AgentStateMessageInput[\"active\"];\n\n constructor(props: any) {\n super(props);\n this.type = \"AgentStateMessage\";\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AAclB,IAAM,UAAN,MAAc;AAAA,EAMnB,YAAY,OAAY;AACtB,UAAM,OAAN,MAAM,KAAO,SAAS;AACtB,UAAM,WAAN,MAAM,SAAW,EAAE,8BAAgC;AACnD,UAAM,cAAN,MAAM,YAAc,oBAAI,KAAK;AAC7B,WAAO,OAAO,MAAM,KAAK;AAAA,EAC3B;AAAA,EAEA,gBAAqC;AACnC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,2BAA2D;AACzD,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,kBAAyC;AACvC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,sBAAiD;AAC/C,WAAO,KAAK,SAAS;AAAA,EACvB;AACF;AAGO,IAAM,OAAO;AAOb,IAAM,cAAN,cAA0B,QAAiD;AAAA,EAKhF,YAAY,OAAsC;AAChD,UAAM,KAAK;AACX,SAAK,OAAO;AAAA,EACd;AACF;AAOO,IAAM,yBAAN,cACG,QAEV;AAAA,EAIE,YAAY,OAAiD;AAC3D,UAAM,KAAK;AACX,SAAK,OAAO;AAAA,EACd;AACF;AAIO,IAAM,gBAAN,cAA4B,QAAmD;AAAA,EAKpF,YAAY,OAAwC;AAClD,UAAM,KAAK;AACX,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,OAAO,aAAa,QAAqB;AACvC,QAAI;AACF,aAAO,KAAK,MAAM,MAAM;AAAA,IAC1B,SAAS,GAAP;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,aAAa,QAAqB;AACvC,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT,WAAW,OAAO,WAAW,UAAU;AACrC,aAAO;AAAA,IACT,OAAO;AACL,aAAO,KAAK,UAAU,MAAM;AAAA,IAC9B;AAAA,EACF;AACF;AAEO,IAAM,oBAAN,cAAgC,QAAyD;AAAA,EAU9F,YAAY,OAAY;AACtB,UAAM,KAAK;AACX,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/dist/chunk-BYWDDBGW.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GenerateCopilotResponseDocument
|
|
3
|
-
} from "./chunk-TPGZVGXM.mjs";
|
|
4
|
-
|
|
5
|
-
// src/graphql/@generated/gql.ts
|
|
6
|
-
var documents = {
|
|
7
|
-
"\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n }\n }\n": GenerateCopilotResponseDocument
|
|
8
|
-
};
|
|
9
|
-
function graphql(source) {
|
|
10
|
-
return documents[source] ?? {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// src/graphql/definitions/mutations.ts
|
|
14
|
-
var generateCopilotResponseMutation = graphql(
|
|
15
|
-
/** GraphQL **/
|
|
16
|
-
`
|
|
17
|
-
mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {
|
|
18
|
-
generateCopilotResponse(data: $data, properties: $properties) {
|
|
19
|
-
threadId
|
|
20
|
-
runId
|
|
21
|
-
... on CopilotResponse @defer {
|
|
22
|
-
status {
|
|
23
|
-
... on BaseResponseStatus {
|
|
24
|
-
code
|
|
25
|
-
}
|
|
26
|
-
... on FailedResponseStatus {
|
|
27
|
-
reason
|
|
28
|
-
details
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
messages @stream {
|
|
33
|
-
__typename
|
|
34
|
-
... on BaseMessageOutput {
|
|
35
|
-
id
|
|
36
|
-
createdAt
|
|
37
|
-
}
|
|
38
|
-
... on BaseMessageOutput @defer {
|
|
39
|
-
status {
|
|
40
|
-
... on SuccessMessageStatus {
|
|
41
|
-
code
|
|
42
|
-
}
|
|
43
|
-
... on FailedMessageStatus {
|
|
44
|
-
code
|
|
45
|
-
reason
|
|
46
|
-
}
|
|
47
|
-
... on PendingMessageStatus {
|
|
48
|
-
code
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
... on TextMessageOutput {
|
|
53
|
-
content @stream
|
|
54
|
-
role
|
|
55
|
-
parentMessageId
|
|
56
|
-
}
|
|
57
|
-
... on ActionExecutionMessageOutput {
|
|
58
|
-
name
|
|
59
|
-
arguments @stream
|
|
60
|
-
parentMessageId
|
|
61
|
-
}
|
|
62
|
-
... on ResultMessageOutput {
|
|
63
|
-
result
|
|
64
|
-
actionExecutionId
|
|
65
|
-
actionName
|
|
66
|
-
}
|
|
67
|
-
... on AgentStateMessageOutput {
|
|
68
|
-
threadId
|
|
69
|
-
state
|
|
70
|
-
running
|
|
71
|
-
agentName
|
|
72
|
-
nodeName
|
|
73
|
-
runId
|
|
74
|
-
active
|
|
75
|
-
role
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
`
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
export {
|
|
84
|
-
generateCopilotResponseMutation
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=chunk-BYWDDBGW.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphql/@generated/gql.ts","../src/graphql/definitions/mutations.ts"],"sourcesContent":["/* eslint-disable */\nimport * as types from './graphql';\nimport type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\n\n/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n * 1. It is not tree-shakeable, so it will include all operations in the project.\n * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n * 3. It does not support dead code elimination, so it will add unused operations.\n *\n * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\nconst documents = {\n \"\\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\\n generateCopilotResponse(data: $data, properties: $properties) {\\n threadId\\n runId\\n ... on CopilotResponse @defer {\\n status {\\n ... on BaseResponseStatus {\\n code\\n }\\n ... on FailedResponseStatus {\\n reason\\n details\\n }\\n }\\n }\\n messages @stream {\\n __typename\\n ... on BaseMessageOutput {\\n id\\n createdAt\\n }\\n ... on BaseMessageOutput @defer {\\n status {\\n ... on SuccessMessageStatus {\\n code\\n }\\n ... on FailedMessageStatus {\\n code\\n reason\\n }\\n ... on PendingMessageStatus {\\n code\\n }\\n }\\n }\\n ... on TextMessageOutput {\\n content @stream\\n role\\n parentMessageId\\n }\\n ... on ActionExecutionMessageOutput {\\n name\\n arguments @stream\\n parentMessageId\\n }\\n ... on ResultMessageOutput {\\n result\\n actionExecutionId\\n actionName\\n }\\n ... on AgentStateMessageOutput {\\n threadId\\n state\\n running\\n agentName\\n nodeName\\n runId\\n active\\n role\\n }\\n }\\n }\\n }\\n\": types.GenerateCopilotResponseDocument,\n};\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n *\n * @example\n * ```ts\n * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n * ```\n *\n * The query argument is unknown!\n * Please regenerate the types.\n */\nexport function graphql(source: string): unknown;\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\nexport function graphql(source: \"\\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\\n generateCopilotResponse(data: $data, properties: $properties) {\\n threadId\\n runId\\n ... on CopilotResponse @defer {\\n status {\\n ... on BaseResponseStatus {\\n code\\n }\\n ... on FailedResponseStatus {\\n reason\\n details\\n }\\n }\\n }\\n messages @stream {\\n __typename\\n ... on BaseMessageOutput {\\n id\\n createdAt\\n }\\n ... on BaseMessageOutput @defer {\\n status {\\n ... on SuccessMessageStatus {\\n code\\n }\\n ... on FailedMessageStatus {\\n code\\n reason\\n }\\n ... on PendingMessageStatus {\\n code\\n }\\n }\\n }\\n ... on TextMessageOutput {\\n content @stream\\n role\\n parentMessageId\\n }\\n ... on ActionExecutionMessageOutput {\\n name\\n arguments @stream\\n parentMessageId\\n }\\n ... on ResultMessageOutput {\\n result\\n actionExecutionId\\n actionName\\n }\\n ... on AgentStateMessageOutput {\\n threadId\\n state\\n running\\n agentName\\n nodeName\\n runId\\n active\\n role\\n }\\n }\\n }\\n }\\n\"): (typeof documents)[\"\\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\\n generateCopilotResponse(data: $data, properties: $properties) {\\n threadId\\n runId\\n ... on CopilotResponse @defer {\\n status {\\n ... on BaseResponseStatus {\\n code\\n }\\n ... on FailedResponseStatus {\\n reason\\n details\\n }\\n }\\n }\\n messages @stream {\\n __typename\\n ... on BaseMessageOutput {\\n id\\n createdAt\\n }\\n ... on BaseMessageOutput @defer {\\n status {\\n ... on SuccessMessageStatus {\\n code\\n }\\n ... on FailedMessageStatus {\\n code\\n reason\\n }\\n ... on PendingMessageStatus {\\n code\\n }\\n }\\n }\\n ... on TextMessageOutput {\\n content @stream\\n role\\n parentMessageId\\n }\\n ... on ActionExecutionMessageOutput {\\n name\\n arguments @stream\\n parentMessageId\\n }\\n ... on ResultMessageOutput {\\n result\\n actionExecutionId\\n actionName\\n }\\n ... on AgentStateMessageOutput {\\n threadId\\n state\\n running\\n agentName\\n nodeName\\n runId\\n active\\n role\\n }\\n }\\n }\\n }\\n\"];\n\nexport function graphql(source: string) {\n return (documents as any)[source] ?? {};\n}\n\nexport type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;","import { graphql } from \"../@generated/gql\";\n\nexport const generateCopilotResponseMutation = graphql(/** GraphQL **/ `\n mutation generateCopilotResponse($data: GenerateCopilotResponseInput!, $properties: JSONObject) {\n generateCopilotResponse(data: $data, properties: $properties) {\n threadId\n runId\n ... on CopilotResponse @defer {\n status {\n ... on BaseResponseStatus {\n code\n }\n ... on FailedResponseStatus {\n reason\n details\n }\n }\n }\n messages @stream {\n __typename\n ... on BaseMessageOutput {\n id\n createdAt\n }\n ... on BaseMessageOutput @defer {\n status {\n ... on SuccessMessageStatus {\n code\n }\n ... on FailedMessageStatus {\n code\n reason\n }\n ... on PendingMessageStatus {\n code\n }\n }\n }\n ... on TextMessageOutput {\n content @stream\n role\n parentMessageId\n }\n ... on ActionExecutionMessageOutput {\n name\n arguments @stream\n parentMessageId\n }\n ... on ResultMessageOutput {\n result\n actionExecutionId\n actionName\n }\n ... on AgentStateMessageOutput {\n threadId\n state\n running\n agentName\n nodeName\n runId\n active\n role\n }\n }\n }\n }\n`);\n"],"mappings":";;;;;AAcA,IAAM,YAAY;AAAA,EACd,g+CAAs+C;AAC1+C;AAqBO,SAAS,QAAQ,QAAgB;AACtC,SAAQ,UAAkB,MAAM,KAAK,CAAC;AACxC;;;ACrCO,IAAM,kCAAkC;AAAA;AAAA,EAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgEtE;","names":[]}
|
package/dist/chunk-FK5N2ZKU.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateCopilotResponseMutation
|
|
3
|
-
} from "./chunk-BYWDDBGW.mjs";
|
|
4
|
-
|
|
5
|
-
// src/client/CopilotRuntimeClient.ts
|
|
6
|
-
import { Client, cacheExchange, fetchExchange } from "@urql/core";
|
|
7
|
-
|
|
8
|
-
// package.json
|
|
9
|
-
var version = "1.5.1-test-custom-tag-prerelease-1.0";
|
|
10
|
-
|
|
11
|
-
// src/client/CopilotRuntimeClient.ts
|
|
12
|
-
var CopilotRuntimeClient = class {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
const headers = {};
|
|
15
|
-
this.handleGQLErrors = options.handleGQLErrors;
|
|
16
|
-
if (options.headers) {
|
|
17
|
-
Object.assign(headers, options.headers);
|
|
18
|
-
}
|
|
19
|
-
if (options.publicApiKey) {
|
|
20
|
-
headers["x-copilotcloud-public-api-key"] = options.publicApiKey;
|
|
21
|
-
}
|
|
22
|
-
this.client = new Client({
|
|
23
|
-
url: options.url,
|
|
24
|
-
exchanges: [cacheExchange, fetchExchange],
|
|
25
|
-
fetchOptions: {
|
|
26
|
-
headers: {
|
|
27
|
-
...headers,
|
|
28
|
-
"X-CopilotKit-Runtime-Client-GQL-Version": version
|
|
29
|
-
},
|
|
30
|
-
...options.credentials ? { credentials: options.credentials } : {}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
generateCopilotResponse({
|
|
35
|
-
data,
|
|
36
|
-
properties,
|
|
37
|
-
signal
|
|
38
|
-
}) {
|
|
39
|
-
const fetchFn = async (...args) => {
|
|
40
|
-
const result2 = await fetch(args[0], { ...args[1] ?? {}, signal });
|
|
41
|
-
if (result2.status !== 200) {
|
|
42
|
-
switch (result2.status) {
|
|
43
|
-
case 404:
|
|
44
|
-
throw new Error(
|
|
45
|
-
"Runtime URL seems to be invalid - got 404 response. Please check the runtimeUrl passed to CopilotKit"
|
|
46
|
-
);
|
|
47
|
-
default:
|
|
48
|
-
throw new Error("Could not fetch copilot response");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result2;
|
|
52
|
-
};
|
|
53
|
-
const result = this.client.mutation(generateCopilotResponseMutation, { data, properties }, { fetch: fetchFn });
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
asStream(source) {
|
|
57
|
-
const handleGQLErrors = this.handleGQLErrors;
|
|
58
|
-
return new ReadableStream({
|
|
59
|
-
start(controller) {
|
|
60
|
-
source.subscribe(({ data, hasNext, error }) => {
|
|
61
|
-
if (error) {
|
|
62
|
-
controller.error(error);
|
|
63
|
-
if (handleGQLErrors) {
|
|
64
|
-
handleGQLErrors(error);
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
controller.enqueue(data);
|
|
68
|
-
if (!hasNext) {
|
|
69
|
-
controller.close();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export {
|
|
79
|
-
CopilotRuntimeClient
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=chunk-FK5N2ZKU.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/CopilotRuntimeClient.ts","../package.json"],"sourcesContent":["import { Client, cacheExchange, fetchExchange } from \"@urql/core\";\nimport * as packageJson from \"../../package.json\";\n\nimport {\n GenerateCopilotResponseMutation,\n GenerateCopilotResponseMutationVariables,\n} from \"../graphql/@generated/graphql\";\nimport { generateCopilotResponseMutation } from \"../graphql/definitions/mutations\";\nimport { OperationResultSource, OperationResult } from \"urql\";\n\nexport interface CopilotRuntimeClientOptions {\n url: string;\n publicApiKey?: string;\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n handleGQLErrors?: (error: Error) => void;\n}\n\nexport class CopilotRuntimeClient {\n client: Client;\n public handleGQLErrors?: (error: Error) => void;\n\n constructor(options: CopilotRuntimeClientOptions) {\n const headers: Record<string, string> = {};\n\n this.handleGQLErrors = options.handleGQLErrors;\n\n if (options.headers) {\n Object.assign(headers, options.headers);\n }\n\n if (options.publicApiKey) {\n headers[\"x-copilotcloud-public-api-key\"] = options.publicApiKey;\n }\n\n this.client = new Client({\n url: options.url,\n exchanges: [cacheExchange, fetchExchange],\n fetchOptions: {\n headers: {\n ...headers,\n \"X-CopilotKit-Runtime-Client-GQL-Version\": packageJson.version,\n },\n ...(options.credentials ? { credentials: options.credentials } : {}),\n },\n });\n }\n\n generateCopilotResponse({\n data,\n properties,\n signal,\n }: {\n data: GenerateCopilotResponseMutationVariables[\"data\"];\n properties?: GenerateCopilotResponseMutationVariables[\"properties\"];\n signal?: AbortSignal;\n }) {\n const fetchFn = async (...args: Parameters<typeof fetch>) => {\n const result = await fetch(args[0], { ...(args[1] ?? {}), signal });\n if (result.status !== 200) {\n switch (result.status) {\n case 404:\n throw new Error(\n \"Runtime URL seems to be invalid - got 404 response. Please check the runtimeUrl passed to CopilotKit\",\n );\n default:\n throw new Error(\"Could not fetch copilot response\");\n }\n }\n return result;\n };\n const result = this.client.mutation<\n GenerateCopilotResponseMutation,\n GenerateCopilotResponseMutationVariables\n >(generateCopilotResponseMutation, { data, properties }, { fetch: fetchFn });\n\n return result;\n }\n\n public asStream<S, T>(source: OperationResultSource<OperationResult<S, { data: T }>>) {\n const handleGQLErrors = this.handleGQLErrors;\n return new ReadableStream<S>({\n start(controller) {\n source.subscribe(({ data, hasNext, error }) => {\n if (error) {\n controller.error(error);\n if (handleGQLErrors) {\n handleGQLErrors(error);\n }\n } else {\n controller.enqueue(data);\n if (!hasNext) {\n controller.close();\n }\n }\n });\n },\n });\n }\n}\n","{\n \"name\": \"@copilotkit/runtime-client-gql\",\n \"private\": false,\n \"homepage\": \"https://github.com/CopilotKit/CopilotKit\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/CopilotKit/CopilotKit.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.5.1-test-custom-tag-prerelease-1.0\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"dev\": \"tsup --watch --no-splitting\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"graphql-codegen\": \"graphql-codegen\",\n \"graphql-codegen:watch\": \"graphql-codegen --watch\",\n \"link:global\": \"pnpm link --global\",\n \"unlink:global\": \"pnpm unlink --global\"\n },\n \"peerDependencies\": {\n \"react\": \"^18 || ^19 || ^19.0.0-rc\"\n },\n \"devDependencies\": {\n \"@graphql-codegen/cli\": \"^5.0.2\",\n \"@graphql-codegen/client-preset\": \"^4.2.6\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.0.7\",\n \"@graphql-codegen/typescript-operations\": \"^4.2.1\",\n \"@graphql-codegen/typescript-urql\": \"^4.0.0\",\n \"@graphql-codegen/urql-introspection\": \"^3.0.0\",\n \"@graphql-typed-document-node/core\": \"^3.2.0\",\n \"@parcel/watcher\": \"^2.4.1\",\n \"@types/node\": \"^20.12.12\",\n \"esbuild\": \"^0.23.0\",\n \"jest\": \"^29.6.4\",\n \"ts-jest\": \"^29.1.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.4.5\",\n \"@copilotkit/runtime\": \"workspace:*\",\n \"graphql\": \"^16.8.1\"\n },\n \"dependencies\": {\n \"@copilotkit/shared\": \"workspace:*\",\n \"@urql/core\": \"^5.0.3\",\n \"untruncate-json\": \"^0.0.1\",\n \"urql\": \"^4.1.0\"\n },\n \"keywords\": [\n \"copilotkit\",\n \"copilot\",\n \"react\",\n \"nextjs\",\n \"nodejs\",\n \"ai\",\n \"assistant\",\n \"javascript\",\n \"automation\",\n \"textarea\"\n ]\n}\n"],"mappings":";;;;;AAAA,SAAS,QAAQ,eAAe,qBAAqB;;;ACWnD,cAAW;;;ADON,IAAM,uBAAN,MAA2B;AAAA,EAIhC,YAAY,SAAsC;AAChD,UAAM,UAAkC,CAAC;AAEzC,SAAK,kBAAkB,QAAQ;AAE/B,QAAI,QAAQ,SAAS;AACnB,aAAO,OAAO,SAAS,QAAQ,OAAO;AAAA,IACxC;AAEA,QAAI,QAAQ,cAAc;AACxB,cAAQ,+BAA+B,IAAI,QAAQ;AAAA,IACrD;AAEA,SAAK,SAAS,IAAI,OAAO;AAAA,MACvB,KAAK,QAAQ;AAAA,MACb,WAAW,CAAC,eAAe,aAAa;AAAA,MACxC,cAAc;AAAA,QACZ,SAAS;AAAA,UACP,GAAG;AAAA,UACH,2CAAuD;AAAA,QACzD;AAAA,QACA,GAAI,QAAQ,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;AAAA,MACpE;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,wBAAwB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,UAAU,UAAU,SAAmC;AAC3D,YAAMA,UAAS,MAAM,MAAM,KAAK,CAAC,GAAG,EAAE,GAAI,KAAK,CAAC,KAAK,CAAC,GAAI,OAAO,CAAC;AAClE,UAAIA,QAAO,WAAW,KAAK;AACzB,gBAAQA,QAAO,QAAQ;AAAA,UACrB,KAAK;AACH,kBAAM,IAAI;AAAA,cACR;AAAA,YACF;AAAA,UACF;AACE,kBAAM,IAAI,MAAM,kCAAkC;AAAA,QACtD;AAAA,MACF;AACA,aAAOA;AAAA,IACT;AACA,UAAM,SAAS,KAAK,OAAO,SAGzB,iCAAiC,EAAE,MAAM,WAAW,GAAG,EAAE,OAAO,QAAQ,CAAC;AAE3E,WAAO;AAAA,EACT;AAAA,EAEO,SAAe,QAAgE;AACpF,UAAM,kBAAkB,KAAK;AAC7B,WAAO,IAAI,eAAkB;AAAA,MAC3B,MAAM,YAAY;AAChB,eAAO,UAAU,CAAC,EAAE,MAAM,SAAS,MAAM,MAAM;AAC7C,cAAI,OAAO;AACT,uBAAW,MAAM,KAAK;AACtB,gBAAI,iBAAiB;AACnB,8BAAgB,KAAK;AAAA,YACvB;AAAA,UACF,OAAO;AACL,uBAAW,QAAQ,IAAI;AACvB,gBAAI,CAAC,SAAS;AACZ,yBAAW,MAAM;AAAA,YACnB;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["result"]}
|
package/dist/chunk-QCGJU5JF.mjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionExecutionMessage,
|
|
3
|
-
AgentStateMessage,
|
|
4
|
-
ResultMessage,
|
|
5
|
-
TextMessage
|
|
6
|
-
} from "./chunk-ACDKKTFY.mjs";
|
|
7
|
-
|
|
8
|
-
// src/client/conversion.ts
|
|
9
|
-
import untruncateJson from "untruncate-json";
|
|
10
|
-
function filterAgentStateMessages(messages) {
|
|
11
|
-
return messages.filter((message) => !message.isAgentStateMessage());
|
|
12
|
-
}
|
|
13
|
-
function convertMessagesToGqlInput(messages) {
|
|
14
|
-
return messages.map((message) => {
|
|
15
|
-
if (message.isTextMessage()) {
|
|
16
|
-
return {
|
|
17
|
-
id: message.id,
|
|
18
|
-
createdAt: message.createdAt,
|
|
19
|
-
textMessage: {
|
|
20
|
-
content: message.content,
|
|
21
|
-
role: message.role,
|
|
22
|
-
parentMessageId: message.parentMessageId
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
} else if (message.isActionExecutionMessage()) {
|
|
26
|
-
return {
|
|
27
|
-
id: message.id,
|
|
28
|
-
createdAt: message.createdAt,
|
|
29
|
-
actionExecutionMessage: {
|
|
30
|
-
name: message.name,
|
|
31
|
-
arguments: JSON.stringify(message.arguments),
|
|
32
|
-
parentMessageId: message.parentMessageId
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
} else if (message.isResultMessage()) {
|
|
36
|
-
return {
|
|
37
|
-
id: message.id,
|
|
38
|
-
createdAt: message.createdAt,
|
|
39
|
-
resultMessage: {
|
|
40
|
-
result: message.result,
|
|
41
|
-
actionExecutionId: message.actionExecutionId,
|
|
42
|
-
actionName: message.actionName
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
} else if (message.isAgentStateMessage()) {
|
|
46
|
-
return {
|
|
47
|
-
id: message.id,
|
|
48
|
-
createdAt: message.createdAt,
|
|
49
|
-
agentStateMessage: {
|
|
50
|
-
threadId: message.threadId,
|
|
51
|
-
role: message.role,
|
|
52
|
-
agentName: message.agentName,
|
|
53
|
-
nodeName: message.nodeName,
|
|
54
|
-
runId: message.runId,
|
|
55
|
-
active: message.active,
|
|
56
|
-
running: message.running,
|
|
57
|
-
state: JSON.stringify(message.state)
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
} else {
|
|
61
|
-
throw new Error("Unknown message type");
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function filterAdjacentAgentStateMessages(messages) {
|
|
66
|
-
const filteredMessages = [];
|
|
67
|
-
messages.forEach((message, i) => {
|
|
68
|
-
if (message.__typename !== "AgentStateMessageOutput") {
|
|
69
|
-
filteredMessages.push(message);
|
|
70
|
-
} else {
|
|
71
|
-
const prevAgentStateMessageIndex = filteredMessages.findIndex(
|
|
72
|
-
// TODO: also check runId
|
|
73
|
-
(m) => m.__typename === "AgentStateMessageOutput" && m.agentName === message.agentName
|
|
74
|
-
);
|
|
75
|
-
if (prevAgentStateMessageIndex === -1) {
|
|
76
|
-
filteredMessages.push(message);
|
|
77
|
-
} else {
|
|
78
|
-
filteredMessages[prevAgentStateMessageIndex] = message;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return filteredMessages;
|
|
83
|
-
}
|
|
84
|
-
function convertGqlOutputToMessages(messages) {
|
|
85
|
-
return messages.map((message) => {
|
|
86
|
-
if (message.__typename === "TextMessageOutput") {
|
|
87
|
-
return new TextMessage({
|
|
88
|
-
id: message.id,
|
|
89
|
-
role: message.role,
|
|
90
|
-
content: message.content.join(""),
|
|
91
|
-
parentMessageId: message.parentMessageId,
|
|
92
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
93
|
-
status: message.status || { code: "Pending" /* Pending */ }
|
|
94
|
-
});
|
|
95
|
-
} else if (message.__typename === "ActionExecutionMessageOutput") {
|
|
96
|
-
return new ActionExecutionMessage({
|
|
97
|
-
id: message.id,
|
|
98
|
-
name: message.name,
|
|
99
|
-
arguments: getPartialArguments(message.arguments),
|
|
100
|
-
parentMessageId: message.parentMessageId,
|
|
101
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
102
|
-
status: message.status || { code: "Pending" /* Pending */ }
|
|
103
|
-
});
|
|
104
|
-
} else if (message.__typename === "ResultMessageOutput") {
|
|
105
|
-
return new ResultMessage({
|
|
106
|
-
id: message.id,
|
|
107
|
-
result: message.result,
|
|
108
|
-
actionExecutionId: message.actionExecutionId,
|
|
109
|
-
actionName: message.actionName,
|
|
110
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
111
|
-
status: message.status || { code: "Pending" /* Pending */ }
|
|
112
|
-
});
|
|
113
|
-
} else if (message.__typename === "AgentStateMessageOutput") {
|
|
114
|
-
return new AgentStateMessage({
|
|
115
|
-
id: message.id,
|
|
116
|
-
threadId: message.threadId,
|
|
117
|
-
role: message.role,
|
|
118
|
-
agentName: message.agentName,
|
|
119
|
-
nodeName: message.nodeName,
|
|
120
|
-
runId: message.runId,
|
|
121
|
-
active: message.active,
|
|
122
|
-
running: message.running,
|
|
123
|
-
state: JSON.parse(message.state),
|
|
124
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
throw new Error("Unknown message type");
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
function loadMessagesFromJsonRepresentation(json) {
|
|
131
|
-
const result = [];
|
|
132
|
-
for (const item of json) {
|
|
133
|
-
if ("content" in item) {
|
|
134
|
-
result.push(
|
|
135
|
-
new TextMessage({
|
|
136
|
-
id: item.id,
|
|
137
|
-
role: item.role,
|
|
138
|
-
content: item.content,
|
|
139
|
-
parentMessageId: item.parentMessageId,
|
|
140
|
-
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
141
|
-
status: item.status || { code: "Success" /* Success */ }
|
|
142
|
-
})
|
|
143
|
-
);
|
|
144
|
-
} else if ("arguments" in item) {
|
|
145
|
-
result.push(
|
|
146
|
-
new ActionExecutionMessage({
|
|
147
|
-
id: item.id,
|
|
148
|
-
name: item.name,
|
|
149
|
-
arguments: item.arguments,
|
|
150
|
-
parentMessageId: item.parentMessageId,
|
|
151
|
-
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
152
|
-
status: item.status || { code: "Success" /* Success */ }
|
|
153
|
-
})
|
|
154
|
-
);
|
|
155
|
-
} else if ("result" in item) {
|
|
156
|
-
result.push(
|
|
157
|
-
new ResultMessage({
|
|
158
|
-
id: item.id,
|
|
159
|
-
result: item.result,
|
|
160
|
-
actionExecutionId: item.actionExecutionId,
|
|
161
|
-
actionName: item.actionName,
|
|
162
|
-
createdAt: item.createdAt || /* @__PURE__ */ new Date(),
|
|
163
|
-
status: item.status || { code: "Success" /* Success */ }
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
} else if ("state" in item) {
|
|
167
|
-
result.push(
|
|
168
|
-
new AgentStateMessage({
|
|
169
|
-
id: item.id,
|
|
170
|
-
threadId: item.threadId,
|
|
171
|
-
role: item.role,
|
|
172
|
-
agentName: item.agentName,
|
|
173
|
-
nodeName: item.nodeName,
|
|
174
|
-
runId: item.runId,
|
|
175
|
-
active: item.active,
|
|
176
|
-
running: item.running,
|
|
177
|
-
state: item.state,
|
|
178
|
-
createdAt: item.createdAt || /* @__PURE__ */ new Date()
|
|
179
|
-
})
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
function getPartialArguments(args) {
|
|
186
|
-
try {
|
|
187
|
-
return JSON.parse(untruncateJson(args.join("")));
|
|
188
|
-
} catch (e) {
|
|
189
|
-
return {};
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export {
|
|
194
|
-
filterAgentStateMessages,
|
|
195
|
-
convertMessagesToGqlInput,
|
|
196
|
-
filterAdjacentAgentStateMessages,
|
|
197
|
-
convertGqlOutputToMessages,
|
|
198
|
-
loadMessagesFromJsonRepresentation
|
|
199
|
-
};
|
|
200
|
-
//# sourceMappingURL=chunk-QCGJU5JF.mjs.map
|