@arcadeai/arcadejs 1.4.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/lib/zod/types.d.ts +54 -13
- package/lib/zod/types.d.ts.map +1 -1
- package/lib/zod/zod.d.ts +20 -27
- package/lib/zod/zod.d.ts.map +1 -1
- package/lib/zod/zod.js +82 -72
- package/lib/zod/zod.js.map +1 -1
- package/lib/zod/zod.mjs +78 -71
- package/lib/zod/zod.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/auth.d.ts +10 -0
- package/resources/auth.d.ts.map +1 -1
- package/resources/shared.d.ts +1 -1
- package/resources/shared.d.ts.map +1 -1
- package/resources/tools/formatted.d.ts +8 -0
- package/resources/tools/formatted.d.ts.map +1 -1
- package/resources/tools/formatted.js.map +1 -1
- package/resources/tools/formatted.mjs.map +1 -1
- package/resources/tools/tools.d.ts +24 -0
- package/resources/tools/tools.d.ts.map +1 -1
- package/resources/tools/tools.js.map +1 -1
- package/resources/tools/tools.mjs.map +1 -1
- package/src/lib/zod/types.ts +61 -15
- package/src/lib/zod/zod.ts +116 -94
- package/src/resources/auth.ts +12 -0
- package/src/resources/shared.ts +1 -1
- package/src/resources/tools/formatted.ts +10 -0
- package/src/resources/tools/tools.ts +34 -0
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,98 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.0 (2025-06-02)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.5.0...v1.6.0](https://github.com/ArcadeAI/arcade-js/compare/v1.5.0...v1.6.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** add Zod support ([#122](https://github.com/ArcadeAI/arcade-js/issues/122)) ([ffb68f9](https://github.com/ArcadeAI/arcade-js/commit/ffb68f91c6a6ce4106ad152224dd39993b0a3091))
|
|
10
|
+
* **api:** api update ([55a57e3](https://github.com/ArcadeAI/arcade-js/commit/55a57e3523c302a55380eba237e14d54ed33632a))
|
|
11
|
+
* **api:** api update ([657228f](https://github.com/ArcadeAI/arcade-js/commit/657228fc1fd0fe5070968eff3a4d7ea0993fb4a7))
|
|
12
|
+
* **api:** api update ([b3597c8](https://github.com/ArcadeAI/arcade-js/commit/b3597c8ac62c154a82cc35a6a5e58580a8bd364a))
|
|
13
|
+
* **api:** api update ([b07cdec](https://github.com/ArcadeAI/arcade-js/commit/b07cdecb91eb9fe9b66aa1173c5bda4db5aff694))
|
|
14
|
+
* **api:** api update ([75a3e4b](https://github.com/ArcadeAI/arcade-js/commit/75a3e4b87368a6099aaa3747a258c4779a620eb9))
|
|
15
|
+
* **api:** api update ([9859d40](https://github.com/ArcadeAI/arcade-js/commit/9859d40462aef973df0fc322c90b190076a599af))
|
|
16
|
+
* **api:** api update ([#1](https://github.com/ArcadeAI/arcade-js/issues/1)) ([e7968d9](https://github.com/ArcadeAI/arcade-js/commit/e7968d9935a392a108736acfc5ea0e8816b00fc6))
|
|
17
|
+
* **api:** api update ([#10](https://github.com/ArcadeAI/arcade-js/issues/10)) ([1e47656](https://github.com/ArcadeAI/arcade-js/commit/1e476560fd08870d335d574397ab21c0b1de83e5))
|
|
18
|
+
* **api:** api update ([#11](https://github.com/ArcadeAI/arcade-js/issues/11)) ([563e94c](https://github.com/ArcadeAI/arcade-js/commit/563e94cb69fe2282f327dafa3b4011c46fae25de))
|
|
19
|
+
* **api:** api update ([#12](https://github.com/ArcadeAI/arcade-js/issues/12)) ([897472b](https://github.com/ArcadeAI/arcade-js/commit/897472be2a59a5af6f31b51c24558e67b095daaa))
|
|
20
|
+
* **api:** api update ([#14](https://github.com/ArcadeAI/arcade-js/issues/14)) ([1151f08](https://github.com/ArcadeAI/arcade-js/commit/1151f0877fc108e73fe905b293e40ae51d3c4742))
|
|
21
|
+
* **api:** api update ([#16](https://github.com/ArcadeAI/arcade-js/issues/16)) ([6a914f3](https://github.com/ArcadeAI/arcade-js/commit/6a914f3ad24f0a794faee60ed67759ef4448178e))
|
|
22
|
+
* **api:** api update ([#17](https://github.com/ArcadeAI/arcade-js/issues/17)) ([4875282](https://github.com/ArcadeAI/arcade-js/commit/4875282c44ab8fe24b72e2bf43e6b7b28c211d48))
|
|
23
|
+
* **api:** api update ([#21](https://github.com/ArcadeAI/arcade-js/issues/21)) ([1ca22e2](https://github.com/ArcadeAI/arcade-js/commit/1ca22e29808cf2fa8d4a864c74e84d37baa09f79))
|
|
24
|
+
* **api:** api update ([#24](https://github.com/ArcadeAI/arcade-js/issues/24)) ([20fb01c](https://github.com/ArcadeAI/arcade-js/commit/20fb01cca1fadf504bf1ac93d32b04026fd0f0b4))
|
|
25
|
+
* **api:** api update ([#26](https://github.com/ArcadeAI/arcade-js/issues/26)) ([8ec0f02](https://github.com/ArcadeAI/arcade-js/commit/8ec0f02671a61459c084720ed9426905efc3edd3))
|
|
26
|
+
* **api:** api update ([#27](https://github.com/ArcadeAI/arcade-js/issues/27)) ([111ec9b](https://github.com/ArcadeAI/arcade-js/commit/111ec9b319bff4a1fdae6ddd6dae065ceca2eab9))
|
|
27
|
+
* **api:** api update ([#29](https://github.com/ArcadeAI/arcade-js/issues/29)) ([eb2ea4d](https://github.com/ArcadeAI/arcade-js/commit/eb2ea4d2938608fa996447e1a6fb57b154e598e5))
|
|
28
|
+
* **api:** api update ([#31](https://github.com/ArcadeAI/arcade-js/issues/31)) ([ee310ab](https://github.com/ArcadeAI/arcade-js/commit/ee310ab9a70753d18ae814c30fb5f281f6baf87b))
|
|
29
|
+
* **api:** api update ([#32](https://github.com/ArcadeAI/arcade-js/issues/32)) ([fd3d50a](https://github.com/ArcadeAI/arcade-js/commit/fd3d50af03a57b246e1b53bd55d425b48c6f669c))
|
|
30
|
+
* **api:** api update ([#33](https://github.com/ArcadeAI/arcade-js/issues/33)) ([db060d2](https://github.com/ArcadeAI/arcade-js/commit/db060d28daf8e2e6c5122446d444f42a843ce687))
|
|
31
|
+
* **api:** api update ([#38](https://github.com/ArcadeAI/arcade-js/issues/38)) ([ddcc5ba](https://github.com/ArcadeAI/arcade-js/commit/ddcc5ba5d951ba0cadbabcc67abd82f1706d32dc))
|
|
32
|
+
* **api:** api update ([#4](https://github.com/ArcadeAI/arcade-js/issues/4)) ([1b690a3](https://github.com/ArcadeAI/arcade-js/commit/1b690a31872df1a5426f5b7532908cf0a63dd862))
|
|
33
|
+
* **api:** api update ([#5](https://github.com/ArcadeAI/arcade-js/issues/5)) ([10be6fd](https://github.com/ArcadeAI/arcade-js/commit/10be6fd731c5e171d2a897f181500e934c71528c))
|
|
34
|
+
* **api:** api update ([#7](https://github.com/ArcadeAI/arcade-js/issues/7)) ([2bef6fc](https://github.com/ArcadeAI/arcade-js/commit/2bef6fc7ce18294dada955a2b80a62d8c0f3e8ec))
|
|
35
|
+
* **api:** api update ([#75](https://github.com/ArcadeAI/arcade-js/issues/75)) ([36eb88d](https://github.com/ArcadeAI/arcade-js/commit/36eb88ddefc2abfb9d8f550efa20cdacdaf8f283))
|
|
36
|
+
* **api:** api update ([#76](https://github.com/ArcadeAI/arcade-js/issues/76)) ([2f699c1](https://github.com/ArcadeAI/arcade-js/commit/2f699c1ea33aac5bd168a9bafd8924f0185de3d3))
|
|
37
|
+
* **api:** api update ([#78](https://github.com/ArcadeAI/arcade-js/issues/78)) ([1fae253](https://github.com/ArcadeAI/arcade-js/commit/1fae253828f24462b3b327d03b71df0ef157efc5))
|
|
38
|
+
* **api:** api update ([#79](https://github.com/ArcadeAI/arcade-js/issues/79)) ([168b1f5](https://github.com/ArcadeAI/arcade-js/commit/168b1f550f966e6dd6d9d0870f1df32bb4d0eb9a))
|
|
39
|
+
* **api:** api update ([#83](https://github.com/ArcadeAI/arcade-js/issues/83)) ([8b701be](https://github.com/ArcadeAI/arcade-js/commit/8b701be8dc3a2ff9e623b83a601e0c3beb35889e))
|
|
40
|
+
* **api:** api update ([#84](https://github.com/ArcadeAI/arcade-js/issues/84)) ([801c58d](https://github.com/ArcadeAI/arcade-js/commit/801c58da6b947ecd5995740d8bf8afb74c527dd9))
|
|
41
|
+
* **api:** api update ([#90](https://github.com/ArcadeAI/arcade-js/issues/90)) ([2d7892d](https://github.com/ArcadeAI/arcade-js/commit/2d7892d6b4d885756d86f7f5c33a1bb081623757))
|
|
42
|
+
* **api:** api update ([#93](https://github.com/ArcadeAI/arcade-js/issues/93)) ([18eb994](https://github.com/ArcadeAI/arcade-js/commit/18eb9948ab087a4747892110e4bcd9335fabfcc3))
|
|
43
|
+
* **client:** send `X-Stainless-Timeout` header ([#87](https://github.com/ArcadeAI/arcade-js/issues/87)) ([4fef4b4](https://github.com/ArcadeAI/arcade-js/commit/4fef4b414616d4ecfd5809c3ae73ee73fad15193))
|
|
44
|
+
* **internal:** make git install file structure match npm ([#48](https://github.com/ArcadeAI/arcade-js/issues/48)) ([be11980](https://github.com/ArcadeAI/arcade-js/commit/be119808dc75304c3b85320f0cbabe479f7e1a6b))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* **api:** fix ArcadeClient type ([#126](https://github.com/ArcadeAI/arcade-js/issues/126)) ([faaf9ed](https://github.com/ArcadeAI/arcade-js/commit/faaf9ed0eb21336b6913433bd1349122c7bb791e))
|
|
50
|
+
* **api:** resolve Arcade type conflict ([#124](https://github.com/ArcadeAI/arcade-js/issues/124)) ([40562b4](https://github.com/ArcadeAI/arcade-js/commit/40562b475eb91e52b238ab6283bd4cb81af1d055))
|
|
51
|
+
* **client:** fix export map for index exports ([#92](https://github.com/ArcadeAI/arcade-js/issues/92)) ([c00087c](https://github.com/ArcadeAI/arcade-js/commit/c00087c1ee8fb8e8d06e754c3f14c854be1bf450))
|
|
52
|
+
* **client:** normalize method ([#61](https://github.com/ArcadeAI/arcade-js/issues/61)) ([7f729f2](https://github.com/ArcadeAI/arcade-js/commit/7f729f27460aa59a4cc3b19c893062fcc4ca7198))
|
|
53
|
+
* **client:** normalize method ([#70](https://github.com/ArcadeAI/arcade-js/issues/70)) ([346cc8a](https://github.com/ArcadeAI/arcade-js/commit/346cc8a5054e6120c1d8e320c98e72e9cd07ccb6))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Chores
|
|
57
|
+
|
|
58
|
+
* **ci:** bump node version for release workflows ([5c4078a](https://github.com/ArcadeAI/arcade-js/commit/5c4078ab8272e7ede6b308b9ceed38241cb963d4))
|
|
59
|
+
* **docs:** grammar improvements ([85cf666](https://github.com/ArcadeAI/arcade-js/commit/85cf6663ebd82fc2a8274bd2be2ecc5a92823899))
|
|
60
|
+
* improve publish-npm script --latest tag logic ([18435a7](https://github.com/ArcadeAI/arcade-js/commit/18435a7c7a89fd943e1f90f09078877a9f3ee447))
|
|
61
|
+
* **internal:** bump cross-spawn to v7.0.6 ([#53](https://github.com/ArcadeAI/arcade-js/issues/53)) ([d6daed2](https://github.com/ArcadeAI/arcade-js/commit/d6daed2c7f97b908c3b4a78be5ed297d66d6c818))
|
|
62
|
+
* **internal:** codegen related update ([b08b538](https://github.com/ArcadeAI/arcade-js/commit/b08b5381a35d2f730001eeeda62f1fddabdea0c5))
|
|
63
|
+
* **internal:** codegen related update ([fa2c88e](https://github.com/ArcadeAI/arcade-js/commit/fa2c88e7d34b8407242ae48fa55a45fa92db04c6))
|
|
64
|
+
* **internal:** codegen related update ([#46](https://github.com/ArcadeAI/arcade-js/issues/46)) ([e691e31](https://github.com/ArcadeAI/arcade-js/commit/e691e313f21dd618b7f0fab76de7d3d62789d1b0))
|
|
65
|
+
* **internal:** codegen related update ([#47](https://github.com/ArcadeAI/arcade-js/issues/47)) ([b1d7d2b](https://github.com/ArcadeAI/arcade-js/commit/b1d7d2b31905d76142e9e85662a3e3f2f662f620))
|
|
66
|
+
* **internal:** codegen related update ([#55](https://github.com/ArcadeAI/arcade-js/issues/55)) ([e79c1f3](https://github.com/ArcadeAI/arcade-js/commit/e79c1f31ef7a9a9aa8e3beebab2874b236c84343))
|
|
67
|
+
* **internal:** codegen related update ([#63](https://github.com/ArcadeAI/arcade-js/issues/63)) ([0b6a70b](https://github.com/ArcadeAI/arcade-js/commit/0b6a70b4882c5b70ee0f1ee4cff5621263576e11))
|
|
68
|
+
* **internal:** codegen related update ([#64](https://github.com/ArcadeAI/arcade-js/issues/64)) ([4e9b37b](https://github.com/ArcadeAI/arcade-js/commit/4e9b37bb9615b1ee869c4d7116978be04bf27650))
|
|
69
|
+
* **internal:** codegen related update ([#65](https://github.com/ArcadeAI/arcade-js/issues/65)) ([ec268d8](https://github.com/ArcadeAI/arcade-js/commit/ec268d8b98c6a2dbf35a5ffc4006abbec2850fce))
|
|
70
|
+
* **internal:** codegen related update ([#66](https://github.com/ArcadeAI/arcade-js/issues/66)) ([e2944f0](https://github.com/ArcadeAI/arcade-js/commit/e2944f04cff49300381faa8a06a53fd9be23a83d))
|
|
71
|
+
* **internal:** codegen related update ([#67](https://github.com/ArcadeAI/arcade-js/issues/67)) ([0f7971e](https://github.com/ArcadeAI/arcade-js/commit/0f7971eff276dc2b564db624340908036fba9892))
|
|
72
|
+
* **internal:** codegen related update ([#68](https://github.com/ArcadeAI/arcade-js/issues/68)) ([82e6e41](https://github.com/ArcadeAI/arcade-js/commit/82e6e41b778470ce34953905c6c6b669a4ba423e))
|
|
73
|
+
* **internal:** codegen related update ([#69](https://github.com/ArcadeAI/arcade-js/issues/69)) ([1315d00](https://github.com/ArcadeAI/arcade-js/commit/1315d00b4573c6ba6fada3cf71df1d32b11b2ce2))
|
|
74
|
+
* **internal:** codegen related update ([#72](https://github.com/ArcadeAI/arcade-js/issues/72)) ([46e5837](https://github.com/ArcadeAI/arcade-js/commit/46e58375269048cf1a58445b0fe1e266d3416402))
|
|
75
|
+
* **internal:** codegen related update ([#74](https://github.com/ArcadeAI/arcade-js/issues/74)) ([fc4035d](https://github.com/ArcadeAI/arcade-js/commit/fc4035d1067bb9d47bcf3f018d24d1f7bb878a2e))
|
|
76
|
+
* **internal:** codegen related update ([#80](https://github.com/ArcadeAI/arcade-js/issues/80)) ([42ea2ed](https://github.com/ArcadeAI/arcade-js/commit/42ea2ededb9302fba24e48f7787682a7883140f3))
|
|
77
|
+
* **internal:** codegen related update ([#82](https://github.com/ArcadeAI/arcade-js/issues/82)) ([aa80c39](https://github.com/ArcadeAI/arcade-js/commit/aa80c39657c3cec4818f626a22a4266af1f54e94))
|
|
78
|
+
* **internal:** fix devcontainers setup ([#95](https://github.com/ArcadeAI/arcade-js/issues/95)) ([3d3d397](https://github.com/ArcadeAI/arcade-js/commit/3d3d39703b80acf11de2df8999ac2156c4269def))
|
|
79
|
+
* **internal:** fix some typos ([#56](https://github.com/ArcadeAI/arcade-js/issues/56)) ([ed6c13f](https://github.com/ArcadeAI/arcade-js/commit/ed6c13f39246874d3de184e563d3f4328609757c))
|
|
80
|
+
* **internal:** remove unnecessary getRequestClient function ([#51](https://github.com/ArcadeAI/arcade-js/issues/51)) ([e95b9c6](https://github.com/ArcadeAI/arcade-js/commit/e95b9c6978a3185dc75e5af5bc575207cd7469b0))
|
|
81
|
+
* **internal:** version bump ([#57](https://github.com/ArcadeAI/arcade-js/issues/57)) ([cb0999e](https://github.com/ArcadeAI/arcade-js/commit/cb0999e9fcc375d85c08acc21a4e43e95322df0e))
|
|
82
|
+
* rebuild project due to codegen change ([#40](https://github.com/ArcadeAI/arcade-js/issues/40)) ([be75637](https://github.com/ArcadeAI/arcade-js/commit/be756379119aa4ab1e70c57641c84d182687d99d))
|
|
83
|
+
* rebuild project due to codegen change ([#41](https://github.com/ArcadeAI/arcade-js/issues/41)) ([c907244](https://github.com/ArcadeAI/arcade-js/commit/c907244da70b7af2c04a8bb4ffd185440bbaa143))
|
|
84
|
+
* rebuild project due to codegen change ([#42](https://github.com/ArcadeAI/arcade-js/issues/42)) ([f8f4502](https://github.com/ArcadeAI/arcade-js/commit/f8f4502c09bece4a7be8c3e1defba20c76bc303b))
|
|
85
|
+
* rebuild project due to codegen change ([#43](https://github.com/ArcadeAI/arcade-js/issues/43)) ([7c79beb](https://github.com/ArcadeAI/arcade-js/commit/7c79beb80c27a5e20474fd532b3c2e0af17b001c))
|
|
86
|
+
* remove redundant word in comment ([#45](https://github.com/ArcadeAI/arcade-js/issues/45)) ([6997da8](https://github.com/ArcadeAI/arcade-js/commit/6997da8e70cf0372d0b464df64d78f9cb6ecf25d))
|
|
87
|
+
* **types:** nicer error class types + jsdocs ([#54](https://github.com/ArcadeAI/arcade-js/issues/54)) ([d4ba89d](https://github.com/ArcadeAI/arcade-js/commit/d4ba89d66c1803f4bbe761c3fcb565c54238e8b2))
|
|
88
|
+
* update SDK settings ([#35](https://github.com/ArcadeAI/arcade-js/issues/35)) ([0783250](https://github.com/ArcadeAI/arcade-js/commit/0783250cca5c1cc504d41785a412d785f1dd9557))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Documentation
|
|
92
|
+
|
|
93
|
+
* minor formatting changes ([#71](https://github.com/ArcadeAI/arcade-js/issues/71)) ([0801644](https://github.com/ArcadeAI/arcade-js/commit/0801644c04394818799450624e5afd4ae10feff6))
|
|
94
|
+
* remove suggestion to use `npm` call out ([#44](https://github.com/ArcadeAI/arcade-js/issues/44)) ([e9a72fa](https://github.com/ArcadeAI/arcade-js/commit/e9a72fa97f622339dbe160e020d68da38dcbfcd5))
|
|
95
|
+
|
|
3
96
|
## 1.3.0 (2025-05-01)
|
|
4
97
|
|
|
5
98
|
Full Changelog: [v1.2.1...v1.3.0](https://github.com/ArcadeAI/arcade-js/compare/v1.2.1...v1.3.0)
|
package/lib/zod/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Arcade } from "../../index.js";
|
|
1
2
|
import { AuthorizationResponse } from "../../resources/shared.js";
|
|
2
|
-
import { ExecuteToolResponse } from "../../resources/tools/tools.js";
|
|
3
|
+
import { ExecuteToolResponse, ToolDefinition } from "../../resources/tools/tools.js";
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
/**
|
|
5
6
|
* Response returned when a tool requires authorization before execution
|
|
@@ -10,25 +11,65 @@ export interface ToolAuthorizationResponse {
|
|
|
10
11
|
url: string;
|
|
11
12
|
message: string;
|
|
12
13
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Represents a tool with Zod schema validation and execution capabilities.
|
|
15
|
-
*/
|
|
16
|
-
export interface ZodTool {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string | undefined;
|
|
19
|
-
parameters: z.ZodType;
|
|
20
|
-
output: z.ZodType | undefined;
|
|
21
|
-
execute: <T extends unknown>(input: T) => Promise<ExecuteToolResponse>;
|
|
22
|
-
executeOrAuthorize: <T extends unknown>(input: T) => Promise<ExecuteToolResponse | ToolAuthorizationResponse>;
|
|
23
|
-
}
|
|
24
14
|
/**
|
|
25
15
|
* Schema definition for an Arcade tool, containing the tool's name,
|
|
26
16
|
* description, and Zod-validated parameter structure.
|
|
27
17
|
*/
|
|
28
18
|
export interface ZodToolSchema {
|
|
19
|
+
/** Qualified name of the tool */
|
|
29
20
|
name: string;
|
|
30
|
-
|
|
21
|
+
/** Optional, human-readable description */
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
/** Zod schema for validating tool parameters */
|
|
31
24
|
parameters: z.ZodType;
|
|
25
|
+
/** Zod schema for validating tool output (if any) */
|
|
32
26
|
output: z.ZodType | undefined;
|
|
33
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Generic type for any tool execution function
|
|
30
|
+
*/
|
|
31
|
+
export type ToolExecuteFunction<TReturn> = (input: unknown) => Promise<TReturn>;
|
|
32
|
+
/**
|
|
33
|
+
* A complete tool implementation with Zod validation and execution capabilities
|
|
34
|
+
*/
|
|
35
|
+
export interface ZodTool<TReturn = ExecuteToolResponse> extends ZodToolSchema {
|
|
36
|
+
execute: ToolExecuteFunction<TReturn>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Arcade client
|
|
40
|
+
*/
|
|
41
|
+
export type ArcadeClient = Omit<Arcade, '_options'>;
|
|
42
|
+
/**
|
|
43
|
+
* Input required to create a tool execution function
|
|
44
|
+
*/
|
|
45
|
+
export interface ToolExecuteFunctionFactoryInput {
|
|
46
|
+
/** Original tool definition from Arcade */
|
|
47
|
+
toolDefinition: ToolDefinition;
|
|
48
|
+
/** Zod-validated tool schema */
|
|
49
|
+
zodToolSchema: ZodToolSchema;
|
|
50
|
+
/** Arcade client instance */
|
|
51
|
+
client: ArcadeClient;
|
|
52
|
+
/** User ID for tool execution/authorization */
|
|
53
|
+
userId: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Base input type for tool creation functions
|
|
57
|
+
*/
|
|
58
|
+
export interface BaseToolCreationInput<TReturn = ExecuteToolResponse> {
|
|
59
|
+
client: ArcadeClient;
|
|
60
|
+
userId: string;
|
|
61
|
+
executeFactory?: (props: ToolExecuteFunctionFactoryInput) => ToolExecuteFunction<TReturn>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Input required to create a single Zod tool
|
|
65
|
+
*/
|
|
66
|
+
export interface CreateZodToolInput<TReturn = ExecuteToolResponse> extends BaseToolCreationInput<TReturn> {
|
|
67
|
+
tool: ToolDefinition;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Input required to create multiple Zod tools
|
|
71
|
+
*/
|
|
72
|
+
export interface CreateMultipleZodToolsInput<TReturn = ExecuteToolResponse> extends BaseToolCreationInput<TReturn> {
|
|
73
|
+
tools: ToolDefinition[];
|
|
74
|
+
}
|
|
34
75
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/zod/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/zod/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6B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,CAAC;IAC7B,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,OAAO,GAAG,mBAAmB;IAClE,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC3F;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,GAAG,mBAAmB,CAAE,SAAQ,qBAAqB,CAAC,OAAO,CAAC;IACvG,IAAI,EAAE,cAAc,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B,CAAC,OAAO,GAAG,mBAAmB,CACxE,SAAQ,qBAAqB,CAAC,OAAO,CAAC;IACtC,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB"}
|
package/lib/zod/zod.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ToolDefinition } from "../../resources/tools/tools.js";
|
|
2
|
-
import { ZodTool, ZodToolSchema } from "./types.js";
|
|
1
|
+
import { ExecuteToolResponse, ToolDefinition } from "../../resources/tools/tools.js";
|
|
2
|
+
import { ZodTool, ZodToolSchema, ToolExecuteFunctionFactoryInput, CreateZodToolInput, CreateMultipleZodToolsInput, ToolExecuteFunction, ToolAuthorizationResponse } from "./types.js";
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import type { Arcade } from "../../index.js";
|
|
5
|
-
type ArcadeClient = Omit<Arcade, '_options'>;
|
|
6
4
|
/**
|
|
7
5
|
* Checks if an error indicates that authorization for the tool is required
|
|
8
6
|
*/
|
|
@@ -23,35 +21,30 @@ export declare function convertOutputToZodSchema(output: ToolDefinition.Output):
|
|
|
23
21
|
*/
|
|
24
22
|
export declare function convertSingleToolToSchema(tool: ToolDefinition): ZodToolSchema;
|
|
25
23
|
/**
|
|
26
|
-
* Converts
|
|
24
|
+
* Converts tools to Zod-validated tool schemas
|
|
27
25
|
* @param tools - Array of formatted tools
|
|
28
26
|
* @returns Array of Zod-validated tool schemas
|
|
29
27
|
*/
|
|
30
28
|
export declare function toZodSchema(tools: ToolDefinition[]): ZodToolSchema[];
|
|
29
|
+
/**
|
|
30
|
+
* Creates a tool execution function that will validate the input and execute the tool
|
|
31
|
+
*/
|
|
32
|
+
export declare function executeZodTool({ zodToolSchema, client, userId, }: ToolExecuteFunctionFactoryInput): ToolExecuteFunction<ExecuteToolResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a tool execution function that will execute the tool if it is authorized,
|
|
35
|
+
* otherwise it will return a ToolAuthorizationResponse
|
|
36
|
+
*/
|
|
37
|
+
export declare function executeOrAuthorizeZodTool({ zodToolSchema, toolDefinition, client, userId, }: ToolExecuteFunctionFactoryInput): ToolExecuteFunction<ExecuteToolResponse | ToolAuthorizationResponse>;
|
|
31
38
|
/**
|
|
32
39
|
* Converts a single tool to a full tool with execution capabilities
|
|
33
|
-
* @param tool - The tool to convert
|
|
34
|
-
* @param client - Arcade client instance
|
|
35
|
-
* @param userId - User ID to use for the tool execution
|
|
36
|
-
* @returns Zod-validated tool with execution methods
|
|
37
|
-
* @throws ToolConversionError if the tool is invalid
|
|
38
40
|
*/
|
|
39
|
-
export declare function createZodTool
|
|
40
|
-
tool: ToolDefinition;
|
|
41
|
-
client: ArcadeClient;
|
|
42
|
-
userId: string;
|
|
43
|
-
}): ZodTool;
|
|
41
|
+
export declare function createZodTool<TReturn = ExecuteToolResponse>(props: CreateZodToolInput<TReturn>): ZodTool<TReturn>;
|
|
44
42
|
/**
|
|
45
|
-
* Converts
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
export declare function
|
|
52
|
-
tools: ToolDefinition[];
|
|
53
|
-
client: ArcadeClient;
|
|
54
|
-
userId: string;
|
|
55
|
-
}): ZodTool[];
|
|
56
|
-
export {};
|
|
43
|
+
* Converts Arcade tools to zod tools with execution capabilities
|
|
44
|
+
*/
|
|
45
|
+
export declare function toZod<TReturn = ExecuteToolResponse>({ tools, client, userId, executeFactory: providedExecuteFactory, }: CreateMultipleZodToolsInput<TReturn>): ZodTool<TReturn>[];
|
|
46
|
+
/**
|
|
47
|
+
* Creates a record of Zod-validated tools with configurable execute functions
|
|
48
|
+
*/
|
|
49
|
+
export declare function toZodToolSet<TReturn = ExecuteToolResponse>({ tools, client, userId, executeFactory: providedExecuteFactory, }: CreateMultipleZodToolsInput<TReturn>): Record<string, ZodTool<TReturn>>;
|
|
57
50
|
//# sourceMappingURL=zod.d.ts.map
|
package/lib/zod/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod/zod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EACL,OAAO,EACP,aAAa,EACb,+BAA+B,EAC/B,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAOlE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,cAAc,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAmBxF;AA+BD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,CAMjF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,cAAc,GAAG,aAAa,CAU7E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,aAAa,EAAE,CAEpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,aAAa,EACb,MAAM,EACN,MAAM,GACP,EAAE,+BAA+B,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAgB5E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,aAAa,EACb,cAAc,EACd,MAAM,EACN,MAAM,GACP,EAAE,+BAA+B,GAAG,mBAAmB,CAAC,mBAAmB,GAAG,yBAAyB,CAAC,CAwBxG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAG,mBAAmB,EACzD,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAG,mBAAmB,EAAE,EACnD,KAAK,EACL,MAAM,EACN,MAAM,EACN,cAAc,EAAE,sBAAsB,GACvC,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAK3D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAG,mBAAmB,EAAE,EAC1D,KAAK,EACL,MAAM,EACN,MAAM,EACN,cAAc,EAAE,sBAAsB,GACvC,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAUzE"}
|
package/lib/zod/zod.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toZod = exports.createZodTool = exports.toZodSchema = exports.convertSingleToolToSchema = exports.convertOutputToZodSchema = exports.convertParametersToZodSchema = exports.isAuthorizationRequiredError = void 0;
|
|
3
|
+
exports.toZodToolSet = exports.toZod = exports.createZodTool = exports.executeOrAuthorizeZodTool = exports.executeZodTool = exports.toZodSchema = exports.convertSingleToolToSchema = exports.convertOutputToZodSchema = exports.convertParametersToZodSchema = exports.isAuthorizationRequiredError = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
6
|
* Checks if an error indicates that authorization for the tool is required
|
|
7
7
|
*/
|
|
8
8
|
function isAuthorizationRequiredError(error) {
|
|
9
|
+
const errorMessage = error?.message?.toLowerCase() || '';
|
|
9
10
|
return (error?.name === 'PermissionDeniedError' ||
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
errorMessage.includes('permission denied') ||
|
|
12
|
+
errorMessage.includes('authorization required'));
|
|
12
13
|
}
|
|
13
14
|
exports.isAuthorizationRequiredError = isAuthorizationRequiredError;
|
|
14
15
|
/**
|
|
@@ -34,33 +35,25 @@ exports.convertParametersToZodSchema = convertParametersToZodSchema;
|
|
|
34
35
|
* Converts a value schema to Zod type
|
|
35
36
|
*/
|
|
36
37
|
function convertValueSchemaToZod(schema) {
|
|
37
|
-
let baseType;
|
|
38
38
|
switch (schema.val_type) {
|
|
39
39
|
case 'string':
|
|
40
|
-
|
|
41
|
-
break;
|
|
40
|
+
return schema.enum ? zod_1.z.enum(schema.enum) : zod_1.z.string();
|
|
42
41
|
case 'integer':
|
|
43
|
-
|
|
44
|
-
break;
|
|
42
|
+
return zod_1.z.number().int();
|
|
45
43
|
case 'number':
|
|
46
|
-
|
|
47
|
-
break;
|
|
44
|
+
return zod_1.z.number();
|
|
48
45
|
case 'boolean':
|
|
49
|
-
|
|
50
|
-
break;
|
|
46
|
+
return zod_1.z.boolean();
|
|
51
47
|
case 'json':
|
|
52
|
-
|
|
53
|
-
break;
|
|
48
|
+
return zod_1.z.any();
|
|
54
49
|
case 'array':
|
|
55
50
|
if (!schema.inner_val_type) {
|
|
56
51
|
throw new Error('Array type must have inner_val_type specified');
|
|
57
52
|
}
|
|
58
|
-
|
|
59
|
-
break;
|
|
53
|
+
return zod_1.z.array(convertValueSchemaToZod({ val_type: schema.inner_val_type }));
|
|
60
54
|
default:
|
|
61
|
-
|
|
55
|
+
return zod_1.z.any();
|
|
62
56
|
}
|
|
63
|
-
return baseType;
|
|
64
57
|
}
|
|
65
58
|
/**
|
|
66
59
|
* Converts Arcade Tool Output to Zod schema
|
|
@@ -91,7 +84,7 @@ function convertSingleToolToSchema(tool) {
|
|
|
91
84
|
}
|
|
92
85
|
exports.convertSingleToolToSchema = convertSingleToolToSchema;
|
|
93
86
|
/**
|
|
94
|
-
* Converts
|
|
87
|
+
* Converts tools to Zod-validated tool schemas
|
|
95
88
|
* @param tools - Array of formatted tools
|
|
96
89
|
* @returns Array of Zod-validated tool schemas
|
|
97
90
|
*/
|
|
@@ -99,74 +92,91 @@ function toZodSchema(tools) {
|
|
|
99
92
|
return tools.map(convertSingleToolToSchema);
|
|
100
93
|
}
|
|
101
94
|
exports.toZodSchema = toZodSchema;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a tool execution function that will validate the input and execute the tool
|
|
97
|
+
*/
|
|
98
|
+
function executeZodTool({ zodToolSchema, client, userId, }) {
|
|
99
|
+
const { parameters, name: toolName } = zodToolSchema;
|
|
100
|
+
return async (input) => {
|
|
101
|
+
const validationResult = parameters.safeParse(input);
|
|
102
|
+
if (!validationResult.success) {
|
|
103
|
+
throw new Error(`Invalid input: ${validationResult.error.message}`);
|
|
104
|
+
}
|
|
105
|
+
const result = await client.tools.execute({
|
|
106
|
+
tool_name: toolName,
|
|
107
|
+
input: validationResult.data,
|
|
108
|
+
user_id: userId,
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
exports.executeZodTool = executeZodTool;
|
|
114
|
+
/**
|
|
115
|
+
* Creates a tool execution function that will execute the tool if it is authorized,
|
|
116
|
+
* otherwise it will return a ToolAuthorizationResponse
|
|
117
|
+
*/
|
|
118
|
+
function executeOrAuthorizeZodTool({ zodToolSchema, toolDefinition, client, userId, }) {
|
|
119
|
+
const { name: toolName } = zodToolSchema;
|
|
120
|
+
return async (input) => {
|
|
121
|
+
try {
|
|
122
|
+
const result = await executeZodTool({ zodToolSchema, toolDefinition, client, userId })(input);
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof Error && isAuthorizationRequiredError(error)) {
|
|
127
|
+
const response = await client.tools.authorize({
|
|
128
|
+
tool_name: toolName,
|
|
129
|
+
user_id: userId,
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
authorization_required: true,
|
|
133
|
+
authorization_response: response,
|
|
134
|
+
url: response.url ?? '',
|
|
135
|
+
message: `This tool requires authorization. Please visit the following URL to authorize the tool: ${response.url}`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.executeOrAuthorizeZodTool = executeOrAuthorizeZodTool;
|
|
102
143
|
/**
|
|
103
144
|
* Converts a single tool to a full tool with execution capabilities
|
|
104
|
-
* @param tool - The tool to convert
|
|
105
|
-
* @param client - Arcade client instance
|
|
106
|
-
* @param userId - User ID to use for the tool execution
|
|
107
|
-
* @returns Zod-validated tool with execution methods
|
|
108
|
-
* @throws ToolConversionError if the tool is invalid
|
|
109
145
|
*/
|
|
110
|
-
function createZodTool(
|
|
146
|
+
function createZodTool(props) {
|
|
147
|
+
const { tool, client, userId, executeFactory: providedExecuteFactory } = props;
|
|
111
148
|
const schema = convertSingleToolToSchema(tool);
|
|
112
149
|
const { name, description, parameters, output } = schema;
|
|
150
|
+
const factoryToUse = providedExecuteFactory ??
|
|
151
|
+
executeZodTool;
|
|
113
152
|
return {
|
|
114
153
|
name,
|
|
115
154
|
description,
|
|
116
155
|
parameters,
|
|
117
156
|
output,
|
|
118
|
-
execute:
|
|
119
|
-
const validationResult = parameters.safeParse(input);
|
|
120
|
-
if (!validationResult.success) {
|
|
121
|
-
throw new Error(`Invalid input: ${validationResult.error.message}`);
|
|
122
|
-
}
|
|
123
|
-
return client.tools.execute({
|
|
124
|
-
tool_name: name,
|
|
125
|
-
input: validationResult.data,
|
|
126
|
-
user_id: userId,
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
executeOrAuthorize: async (input) => {
|
|
130
|
-
const validationResult = parameters.safeParse(input);
|
|
131
|
-
if (!validationResult.success) {
|
|
132
|
-
throw new Error(`Invalid input: ${validationResult.error.message}`);
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
return await client.tools.execute({
|
|
136
|
-
tool_name: name,
|
|
137
|
-
input: validationResult.data,
|
|
138
|
-
user_id: userId,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
if (error instanceof Error && isAuthorizationRequiredError(error)) {
|
|
143
|
-
const response = (await client.tools.authorize({
|
|
144
|
-
tool_name: name,
|
|
145
|
-
user_id: userId,
|
|
146
|
-
}));
|
|
147
|
-
return {
|
|
148
|
-
authorization_required: true,
|
|
149
|
-
authorization_response: response,
|
|
150
|
-
url: response.url,
|
|
151
|
-
message: 'This tool requires authorization. Please visit the following URL to authorize the tool: ' +
|
|
152
|
-
response.url,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
throw error;
|
|
156
|
-
}
|
|
157
|
-
},
|
|
157
|
+
execute: factoryToUse({ toolDefinition: tool, zodToolSchema: schema, client, userId }),
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
exports.createZodTool = createZodTool;
|
|
161
161
|
/**
|
|
162
|
-
* Converts
|
|
163
|
-
* @param tools - Array of formatted tools
|
|
164
|
-
* @param client - Arcade client instance
|
|
165
|
-
* @param userId - User ID to use for the tool execution
|
|
166
|
-
* @returns Array of Zod-validated tools with execution methods
|
|
162
|
+
* Converts Arcade tools to zod tools with execution capabilities
|
|
167
163
|
*/
|
|
168
|
-
function toZod({ tools, client, userId, }) {
|
|
169
|
-
|
|
164
|
+
function toZod({ tools, client, userId, executeFactory: providedExecuteFactory, }) {
|
|
165
|
+
const factoryToUse = providedExecuteFactory ??
|
|
166
|
+
executeZodTool;
|
|
167
|
+
return tools.map((tool) => createZodTool({ tool, client, userId, executeFactory: factoryToUse }));
|
|
170
168
|
}
|
|
171
169
|
exports.toZod = toZod;
|
|
170
|
+
/**
|
|
171
|
+
* Creates a record of Zod-validated tools with configurable execute functions
|
|
172
|
+
*/
|
|
173
|
+
function toZodToolSet({ tools, client, userId, executeFactory: providedExecuteFactory, }) {
|
|
174
|
+
const factoryToUse = providedExecuteFactory ??
|
|
175
|
+
executeZodTool;
|
|
176
|
+
return Object.fromEntries(tools.map((tool) => {
|
|
177
|
+
const zodTool = createZodTool({ tool, client, userId, executeFactory: factoryToUse });
|
|
178
|
+
return [zodTool.name, zodTool];
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
exports.toZodToolSet = toZodToolSet;
|
|
172
182
|
//# sourceMappingURL=zod.js.map
|
package/lib/zod/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/lib/zod/zod.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/lib/zod/zod.ts"],"names":[],"mappings":";;;AAUA,6BAAwB;AAExB;;GAEG;AACH,SAAgB,4BAA4B,CAAC,KAAY;IACvD,MAAM,YAAY,GAAG,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACzD,OAAO,CACL,KAAK,EAAE,IAAI,KAAK,uBAAuB;QACvC,YAAY,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC1C,YAAY,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAChD,CAAC;AACJ,CAAC;AAPD,oEAOC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAAC,UAAgC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