@sovara/sdk 0.0.0-stage → 0.9.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/LICENSE +202 -0
- package/README.md +36 -2
- package/dist/apiTypes.d.ts +5 -0
- package/dist/apiTypes.d.ts.map +1 -0
- package/dist/apiTypes.js +5 -0
- package/dist/apiTypes.js.map +1 -0
- package/dist/capture/requestEnvelope.d.ts +10 -0
- package/dist/capture/requestEnvelope.d.ts.map +1 -0
- package/dist/capture/requestEnvelope.js +79 -0
- package/dist/capture/requestEnvelope.js.map +1 -0
- package/dist/capture/responseEnvelope.d.ts +17 -0
- package/dist/capture/responseEnvelope.d.ts.map +1 -0
- package/dist/capture/responseEnvelope.js +72 -0
- package/dist/capture/responseEnvelope.js.map +1 -0
- package/dist/capture/sensitiveHeaders.d.ts +7 -0
- package/dist/capture/sensitiveHeaders.d.ts.map +1 -0
- package/dist/capture/sensitiveHeaders.js +41 -0
- package/dist/capture/sensitiveHeaders.js.map +1 -0
- package/dist/capture/sseUtils.d.ts +3 -0
- package/dist/capture/sseUtils.d.ts.map +1 -0
- package/dist/capture/sseUtils.js +69 -0
- package/dist/capture/sseUtils.js.map +1 -0
- package/dist/capture/streamCapture.d.ts +5 -0
- package/dist/capture/streamCapture.d.ts.map +1 -0
- package/dist/capture/streamCapture.js +19 -0
- package/dist/capture/streamCapture.js.map +1 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +66 -0
- package/dist/client.js.map +1 -0
- package/dist/codeVersion.d.ts +17 -0
- package/dist/codeVersion.d.ts.map +1 -0
- package/dist/codeVersion.js +107 -0
- package/dist/codeVersion.js.map +1 -0
- package/dist/compatibility.d.ts +26 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +130 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +37 -0
- package/dist/constants.js.map +1 -0
- package/dist/context.d.ts +55 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +380 -0
- package/dist/context.js.map +1 -0
- package/dist/endpointPatterns.json +90 -0
- package/dist/endpointWhitelist.d.ts +2 -0
- package/dist/endpointWhitelist.d.ts.map +1 -0
- package/dist/endpointWhitelist.js +11 -0
- package/dist/endpointWhitelist.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +11 -0
- package/dist/env.js.map +1 -0
- package/dist/failsafe.d.ts +5 -0
- package/dist/failsafe.d.ts.map +1 -0
- package/dist/failsafe.js +25 -0
- package/dist/failsafe.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcpPatch.d.ts +2 -0
- package/dist/mcpPatch.d.ts.map +1 -0
- package/dist/mcpPatch.js +202 -0
- package/dist/mcpPatch.js.map +1 -0
- package/dist/openaiAgentsPatch.d.ts +2 -0
- package/dist/openaiAgentsPatch.d.ts.map +1 -0
- package/dist/openaiAgentsPatch.js +112 -0
- package/dist/openaiAgentsPatch.js.map +1 -0
- package/dist/payload/editIoExcludePatterns.json +322 -0
- package/dist/payload/filterDict.d.ts +3 -0
- package/dist/payload/filterDict.d.ts.map +1 -0
- package/dist/payload/filterDict.js +26 -0
- package/dist/payload/filterDict.js.map +1 -0
- package/dist/payload/flatten.d.ts +6 -0
- package/dist/payload/flatten.d.ts.map +1 -0
- package/dist/payload/flatten.js +79 -0
- package/dist/payload/flatten.js.map +1 -0
- package/dist/payload/wrap.d.ts +10 -0
- package/dist/payload/wrap.d.ts.map +1 -0
- package/dist/payload/wrap.js +82 -0
- package/dist/payload/wrap.js.map +1 -0
- package/dist/platformSession.d.ts +3 -0
- package/dist/platformSession.d.ts.map +1 -0
- package/dist/platformSession.js +21 -0
- package/dist/platformSession.js.map +1 -0
- package/dist/runtimeClient.d.ts +117 -0
- package/dist/runtimeClient.d.ts.map +1 -0
- package/dist/runtimeClient.js +287 -0
- package/dist/runtimeClient.js.map +1 -0
- package/dist/serverLifecycle.d.ts +12 -0
- package/dist/serverLifecycle.d.ts.map +1 -0
- package/dist/serverLifecycle.js +77 -0
- package/dist/serverLifecycle.js.map +1 -0
- package/dist/toolTraceUtils.d.ts +38 -0
- package/dist/toolTraceUtils.d.ts.map +1 -0
- package/dist/toolTraceUtils.js +189 -0
- package/dist/toolTraceUtils.js.map +1 -0
- package/dist/trace.d.ts +13 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +133 -0
- package/dist/trace.js.map +1 -0
- package/dist/traceLogCapture.d.ts +18 -0
- package/dist/traceLogCapture.d.ts.map +1 -0
- package/dist/traceLogCapture.js +125 -0
- package/dist/traceLogCapture.js.map +1 -0
- package/dist/transport/awsSdkHttp2Patch.d.ts +2 -0
- package/dist/transport/awsSdkHttp2Patch.d.ts.map +1 -0
- package/dist/transport/awsSdkHttp2Patch.js +442 -0
- package/dist/transport/awsSdkHttp2Patch.js.map +1 -0
- package/dist/transport/fetchPatch.d.ts +3 -0
- package/dist/transport/fetchPatch.d.ts.map +1 -0
- package/dist/transport/fetchPatch.js +257 -0
- package/dist/transport/fetchPatch.js.map +1 -0
- package/dist/transport/nodeHttpPatch.d.ts +3 -0
- package/dist/transport/nodeHttpPatch.d.ts.map +1 -0
- package/dist/transport/nodeHttpPatch.js +532 -0
- package/dist/transport/nodeHttpPatch.js.map +1 -0
- package/dist/util/logger.d.ts +2 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +9 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/stableJson.d.ts +2 -0
- package/dist/util/stableJson.d.ts.map +1 -0
- package/dist/util/stableJson.js +22 -0
- package/dist/util/stableJson.js.map +1 -0
- package/dist/util/stackTrace.d.ts +2 -0
- package/dist/util/stackTrace.d.ts.map +1 -0
- package/dist/util/stackTrace.js +11 -0
- package/dist/util/stackTrace.js.map +1 -0
- package/package.json +70 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sovara/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Record supported LLM, MCP and tool calls in [Sovara](https://docs.sovara-labs.com).
|
|
4
|
+
Requires Node.js 24.22.1 or later, a project name, and an exec-server supporting runner-api 5.
|
|
5
|
+
For local recording, install the current Sovara CLI, which supplies exec-server.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sovara/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { SovaraClient } from "@sovara/sdk";
|
|
13
|
+
|
|
14
|
+
const client = new SovaraClient({ projectName: "My Project" });
|
|
15
|
+
await client.trace("support-agent", async () => {
|
|
16
|
+
await runAgent();
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Use `client.turn({ turnInput })` for explicit conversation turns and `client.subtrace`
|
|
21
|
+
for child work. Operations outside a turn have null turn membership. Use `trace`
|
|
22
|
+
for custom functions; supported transports and framework tools are automatic.
|
|
23
|
+
|
|
24
|
+
Remote agents pass `url` and `agentToken` to `SovaraClient`. A caller-owned `fetch`
|
|
25
|
+
can supply custom transport behavior. Keep tokens out of logs.
|
|
26
|
+
|
|
27
|
+
- [Quickstart](https://docs.sovara-labs.com/sdks/typescript/quickstart)
|
|
28
|
+
- [Usage and turns](https://docs.sovara-labs.com/sdks/typescript/use-the-sdk)
|
|
29
|
+
- [API reference](https://docs.sovara-labs.com/sdks/typescript/api-reference)
|
|
30
|
+
- [Troubleshooting](https://docs.sovara-labs.com/sdks/typescript/troubleshooting)
|
|
31
|
+
- [Provider compatibility](../python-sdk/COMPATIBILITY.md)
|
|
32
|
+
|
|
33
|
+
## Develop
|
|
34
|
+
|
|
35
|
+
From this directory: `npm ci && npm run typecheck && npm test && npm run build`.
|
|
36
|
+
Release using `typescript-sdk-v<version>` after updating `package.json` and lockfile;
|
|
37
|
+
see [release policy](../README.md#release-surfaces).
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const API_TYPE_HTTPX_CLIENT_SEND = "httpx.Client.send";
|
|
2
|
+
export declare const API_TYPE_HTTPX_ASYNC_CLIENT_SEND = "httpx.AsyncClient.send";
|
|
3
|
+
export declare const API_TYPE_MCP_CLIENT_SESSION_SEND_REQUEST = "MCP.ClientSession.send_request";
|
|
4
|
+
export declare const API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN = "openai_agents.FunctionTool.run";
|
|
5
|
+
//# sourceMappingURL=apiTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiTypes.d.ts","sourceRoot":"","sources":["../src/apiTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,sBAAsB,CAAC;AAC9D,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AACzE,eAAO,MAAM,wCAAwC,mCAAmC,CAAC;AACzF,eAAO,MAAM,wCAAwC,mCAAmC,CAAC"}
|
package/dist/apiTypes.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const API_TYPE_HTTPX_CLIENT_SEND = "httpx.Client.send";
|
|
2
|
+
export const API_TYPE_HTTPX_ASYNC_CLIENT_SEND = "httpx.AsyncClient.send";
|
|
3
|
+
export const API_TYPE_MCP_CLIENT_SESSION_SEND_REQUEST = "MCP.ClientSession.send_request";
|
|
4
|
+
export const API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN = "openai_agents.FunctionTool.run";
|
|
5
|
+
//# sourceMappingURL=apiTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiTypes.js","sourceRoot":"","sources":["../src/apiTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AAC9D,MAAM,CAAC,MAAM,gCAAgC,GAAG,wBAAwB,CAAC;AACzE,MAAM,CAAC,MAAM,wCAAwC,GAAG,gCAAgC,CAAC;AACzF,MAAM,CAAC,MAAM,wCAAwC,GAAG,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RequestEnvelope = {
|
|
2
|
+
url: string;
|
|
3
|
+
body: unknown;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
method: string;
|
|
6
|
+
bodySupported: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const UNSUPPORTED_REQUEST_BODY = "<unsupported>";
|
|
9
|
+
export declare function buildRequestEnvelope(input: RequestInfo | URL, init?: RequestInit): Promise<RequestEnvelope>;
|
|
10
|
+
//# sourceMappingURL=requestEnvelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestEnvelope.d.ts","sourceRoot":"","sources":["../../src/capture/requestEnvelope.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AA4DxD,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAwBjH"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export const UNSUPPORTED_REQUEST_BODY = "<unsupported>";
|
|
2
|
+
function headersToObject(headers) {
|
|
3
|
+
const out = {};
|
|
4
|
+
for (const [key, value] of headers.entries()) {
|
|
5
|
+
out[key.toLowerCase()] = value;
|
|
6
|
+
}
|
|
7
|
+
return out;
|
|
8
|
+
}
|
|
9
|
+
function mergeHeaders(base, override) {
|
|
10
|
+
const merged = new Headers(base);
|
|
11
|
+
if (!override) {
|
|
12
|
+
return merged;
|
|
13
|
+
}
|
|
14
|
+
const extra = new Headers(override);
|
|
15
|
+
for (const [key, value] of extra.entries()) {
|
|
16
|
+
merged.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
return merged;
|
|
19
|
+
}
|
|
20
|
+
async function bodyInitToText(body) {
|
|
21
|
+
if (body == null) {
|
|
22
|
+
return { bodyText: "", supported: true };
|
|
23
|
+
}
|
|
24
|
+
if (typeof body === "string") {
|
|
25
|
+
return { bodyText: body, supported: true };
|
|
26
|
+
}
|
|
27
|
+
if (body instanceof URLSearchParams) {
|
|
28
|
+
return { bodyText: body.toString(), supported: true };
|
|
29
|
+
}
|
|
30
|
+
if (body instanceof Blob) {
|
|
31
|
+
return { bodyText: await body.text(), supported: true };
|
|
32
|
+
}
|
|
33
|
+
if (body instanceof Uint8Array) {
|
|
34
|
+
return { bodyText: new TextDecoder().decode(body), supported: true };
|
|
35
|
+
}
|
|
36
|
+
if (body instanceof ArrayBuffer) {
|
|
37
|
+
return { bodyText: new TextDecoder().decode(new Uint8Array(body)), supported: true };
|
|
38
|
+
}
|
|
39
|
+
if (ArrayBuffer.isView(body)) {
|
|
40
|
+
return { bodyText: new TextDecoder().decode(new Uint8Array(body.buffer)), supported: true };
|
|
41
|
+
}
|
|
42
|
+
return { bodyText: UNSUPPORTED_REQUEST_BODY, supported: false };
|
|
43
|
+
}
|
|
44
|
+
function parseBody(text) {
|
|
45
|
+
if (!text) {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(text);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function buildRequestEnvelope(input, init) {
|
|
56
|
+
if (input instanceof Request) {
|
|
57
|
+
const mergedHeaders = mergeHeaders(input.headers, init?.headers);
|
|
58
|
+
const bodyFromInit = init?.body != null ? await bodyInitToText(init.body) : null;
|
|
59
|
+
const text = bodyFromInit ? bodyFromInit.bodyText : await input.clone().text();
|
|
60
|
+
return {
|
|
61
|
+
url: input.url,
|
|
62
|
+
body: parseBody(text),
|
|
63
|
+
headers: headersToObject(mergedHeaders),
|
|
64
|
+
method: (init?.method ?? input.method ?? "GET").toUpperCase(),
|
|
65
|
+
bodySupported: bodyFromInit ? bodyFromInit.supported : true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const url = String(input);
|
|
69
|
+
const headers = headersToObject(new Headers(init?.headers));
|
|
70
|
+
const { bodyText, supported } = await bodyInitToText(init?.body);
|
|
71
|
+
return {
|
|
72
|
+
url,
|
|
73
|
+
body: parseBody(bodyText),
|
|
74
|
+
headers,
|
|
75
|
+
method: (init?.method ?? "GET").toUpperCase(),
|
|
76
|
+
bodySupported: supported,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=requestEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestEnvelope.js","sourceRoot":"","sources":["../../src/capture/requestEnvelope.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AAExD,SAAS,eAAe,CAAC,OAAgB;IACvC,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAA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,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QAC/E,OAAO;YACL,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;YACrB,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC;YACvC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE;YAC7D,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;SAC5D,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,OAAO;QACL,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC;QACzB,OAAO;QACP,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE;QAC7C,aAAa,EAAE,SAAS;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ResponseEnvelope = {
|
|
2
|
+
status_code: number;
|
|
3
|
+
reason_phrase: string;
|
|
4
|
+
request_url: string | null;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
content?: unknown;
|
|
7
|
+
_response_format?: "sse" | "ndjson";
|
|
8
|
+
sse?: {
|
|
9
|
+
events: Array<Record<string, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
ndjson?: {
|
|
12
|
+
events: unknown[];
|
|
13
|
+
};
|
|
14
|
+
_encoding?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function buildResponseEnvelope(response: Response): Promise<ResponseEnvelope>;
|
|
17
|
+
//# sourceMappingURL=responseEnvelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseEnvelope.d.ts","sourceRoot":"","sources":["../../src/capture/responseEnvelope.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACpC,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;IACjD,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA0CF,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkCzF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { scrubSensitiveHeaders } from "./sensitiveHeaders.js";
|
|
2
|
+
import { parseSseEvents } from "./sseUtils.js";
|
|
3
|
+
function headersToObject(headers) {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const [key, value] of headers.entries()) {
|
|
6
|
+
out[key.toLowerCase()] = value;
|
|
7
|
+
}
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
function inferEncoding(contentType) {
|
|
11
|
+
if (!contentType) {
|
|
12
|
+
return "utf-8";
|
|
13
|
+
}
|
|
14
|
+
const match = /charset=([^;]+)/i.exec(contentType);
|
|
15
|
+
return match ? match[1].trim() : "utf-8";
|
|
16
|
+
}
|
|
17
|
+
function shouldParseNdjson(requestUrl) {
|
|
18
|
+
if (!requestUrl) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const path = new URL(requestUrl).pathname;
|
|
23
|
+
return path.endsWith("/api/chat") || path.endsWith("/api/generate");
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function parseNdjsonEvents(text) {
|
|
30
|
+
const lines = text.split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
31
|
+
if (lines.length < 2) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return lines.map((line) => JSON.parse(line));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export async function buildResponseEnvelope(response) {
|
|
42
|
+
const headers = scrubSensitiveHeaders(headersToObject(response.headers));
|
|
43
|
+
const contentType = response.headers.get("content-type");
|
|
44
|
+
const text = await response.text();
|
|
45
|
+
const envelope = {
|
|
46
|
+
status_code: response.status,
|
|
47
|
+
reason_phrase: response.statusText,
|
|
48
|
+
request_url: response.url || null,
|
|
49
|
+
headers,
|
|
50
|
+
_encoding: inferEncoding(contentType),
|
|
51
|
+
};
|
|
52
|
+
const parsedSse = parseSseEvents(text);
|
|
53
|
+
if (parsedSse !== null) {
|
|
54
|
+
envelope._response_format = "sse";
|
|
55
|
+
envelope.sse = { events: parsedSse };
|
|
56
|
+
return envelope;
|
|
57
|
+
}
|
|
58
|
+
const parsedNdjson = shouldParseNdjson(envelope.request_url) ? parseNdjsonEvents(text) : null;
|
|
59
|
+
if (parsedNdjson !== null) {
|
|
60
|
+
envelope._response_format = "ndjson";
|
|
61
|
+
envelope.ndjson = { events: parsedNdjson };
|
|
62
|
+
return envelope;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
envelope.content = JSON.parse(text);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
envelope.content = text;
|
|
69
|
+
}
|
|
70
|
+
return envelope;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=responseEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseEnvelope.js","sourceRoot":"","sources":["../../src/capture/responseEnvelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAc/C,SAAS,eAAe,CAAC,OAAgB;IACvC,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7C,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,WAA0B;IAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAyB;IAClD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;QAC1C,OAAO,IAAI,CAAC,QAAQ,CAAC,WAA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Q,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAClC,QAAQ,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,YAAY,GAAG,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9F,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC;QACrC,QAAQ,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isSensitiveHeader(name: string): boolean;
|
|
2
|
+
export declare function scrubSensitiveHeaders(headers: Record<string, string>): Record<string, string>;
|
|
3
|
+
export declare function scrubRequestEnvelopeForStorage<T extends {
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
}>(envelope: T): T;
|
|
6
|
+
export declare function extractSensitiveHeaders(headers: Record<string, string>): Record<string, string>;
|
|
7
|
+
//# sourceMappingURL=sensitiveHeaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitiveHeaders.d.ts","sourceRoot":"","sources":["../../src/capture/sensitiveHeaders.ts"],"names":[],"mappings":"AAcA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB;AAKD,wBAAgB,8BAA8B,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC1F,QAAQ,EAAE,CAAC,GACV,CAAC,CAEH;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Provider auth / session headers that must never be persisted to recorded
|
|
2
|
+
// trace data. They are stripped from stored request/response envelopes; replay
|
|
3
|
+
// re-supplies auth from the user's configured API key, so dropping them here is
|
|
4
|
+
// safe. Live outbound requests keep their headers (see fetch patch re-merge).
|
|
5
|
+
const SENSITIVE_HEADER_NAMES = new Set([
|
|
6
|
+
"authorization",
|
|
7
|
+
"proxy-authorization",
|
|
8
|
+
"x-api-key",
|
|
9
|
+
"api-key",
|
|
10
|
+
"x-goog-api-key",
|
|
11
|
+
"cookie",
|
|
12
|
+
"set-cookie",
|
|
13
|
+
]);
|
|
14
|
+
export function isSensitiveHeader(name) {
|
|
15
|
+
return SENSITIVE_HEADER_NAMES.has(name.toLowerCase());
|
|
16
|
+
}
|
|
17
|
+
export function scrubSensitiveHeaders(headers) {
|
|
18
|
+
const out = {};
|
|
19
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
20
|
+
if (!isSensitiveHeader(key)) {
|
|
21
|
+
out[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
// Returns a copy of a request envelope safe to persist: auth headers are
|
|
27
|
+
// stripped while the original (used for the live outbound request) is left
|
|
28
|
+
// untouched. Generic over the envelope shape to avoid an import cycle.
|
|
29
|
+
export function scrubRequestEnvelopeForStorage(envelope) {
|
|
30
|
+
return { ...envelope, headers: scrubSensitiveHeaders(envelope.headers) };
|
|
31
|
+
}
|
|
32
|
+
export function extractSensitiveHeaders(headers) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
35
|
+
if (isSensitiveHeader(key)) {
|
|
36
|
+
out[key] = value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=sensitiveHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitiveHeaders.js","sourceRoot":"","sources":["../../src/capture/sensitiveHeaders.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAC1D,eAAe;IACf,qBAAqB;IACrB,WAAW;IACX,SAAS;IACT,gBAAgB;IAChB,QAAQ;IACR,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAA+B;IAE/B,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,UAAU,8BAA8B,CAC5C,QAAW;IAEX,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,OAA+B;IAE/B,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sseUtils.d.ts","sourceRoot":"","sources":["../../src/capture/sseUtils.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CA2D5F;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAMxF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function stripOptionalSpace(payload) {
|
|
2
|
+
return payload.startsWith(" ") ? payload.slice(1) : payload;
|
|
3
|
+
}
|
|
4
|
+
function parseSseDataValue(payload) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(payload);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return payload;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function parseSseEvents(decodedContent) {
|
|
13
|
+
if (!decodedContent.trim()) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const events = [];
|
|
17
|
+
let dataLines = [];
|
|
18
|
+
let currentEvent = {};
|
|
19
|
+
let sawSseLine = false;
|
|
20
|
+
const flushEvent = () => {
|
|
21
|
+
if (dataLines.length > 0) {
|
|
22
|
+
currentEvent.data = parseSseDataValue(dataLines.join("\n"));
|
|
23
|
+
dataLines = [];
|
|
24
|
+
}
|
|
25
|
+
if (Object.keys(currentEvent).length === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
events.push(currentEvent);
|
|
29
|
+
currentEvent = {};
|
|
30
|
+
};
|
|
31
|
+
for (const line of decodedContent.split(/\r\n|\r|\n/)) {
|
|
32
|
+
if (line.length === 0) {
|
|
33
|
+
flushEvent();
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (line.startsWith(":")) {
|
|
37
|
+
sawSseLine = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
sawSseLine = true;
|
|
41
|
+
const separatorIndex = line.indexOf(":");
|
|
42
|
+
const field = separatorIndex >= 0 ? line.slice(0, separatorIndex) : line;
|
|
43
|
+
const rawValue = separatorIndex >= 0 ? line.slice(separatorIndex + 1) : "";
|
|
44
|
+
const value = stripOptionalSpace(rawValue);
|
|
45
|
+
if (field === "data") {
|
|
46
|
+
dataLines.push(value);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (field === "event" || field === "id") {
|
|
50
|
+
currentEvent[field] = value;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (field === "retry") {
|
|
54
|
+
currentEvent.retry = /^\d+$/.test(value) ? Number(value) : value;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
flushEvent();
|
|
60
|
+
return sawSseLine && events.length > 0 ? events : null;
|
|
61
|
+
}
|
|
62
|
+
export function extractSseDisplayContent(events) {
|
|
63
|
+
const values = events.filter((event) => "data" in event).map((event) => event.data);
|
|
64
|
+
if (values.length === 0) {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
return values.length === 1 ? values[0] : values;
|
|
68
|
+
}
|
|
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CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,MAAsC;IAC7E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamCapture.d.ts","sourceRoot":"","sources":["../../src/capture/streamCapture.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC;IAAE,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAqB3E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function teeReadableStream(stream) {
|
|
2
|
+
const [userStream, captureStream] = stream.tee();
|
|
3
|
+
const capturedText = (async () => {
|
|
4
|
+
const reader = captureStream.getReader();
|
|
5
|
+
const decoder = new TextDecoder();
|
|
6
|
+
let text = "";
|
|
7
|
+
while (true) {
|
|
8
|
+
const { done, value } = await reader.read();
|
|
9
|
+
if (done) {
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
text += decoder.decode(value, { stream: true });
|
|
13
|
+
}
|
|
14
|
+
text += decoder.decode();
|
|
15
|
+
return text;
|
|
16
|
+
})();
|
|
17
|
+
return { userStream, capturedText };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=streamCapture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamCapture.js","sourceRoot":"","sources":["../../src/capture/streamCapture.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAC/B,MAAkC;IAElC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,IAAI,GAAG,EAAE,CAAC;QAEd,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM;YACR,CAAC;YACD,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACtC,CAAC"}
|