@agentkit-js/devtools 0.2.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/LICENSE +186 -0
- package/README.md +27 -0
- package/dist/EventLogReplay.d.ts +102 -0
- package/dist/EventLogReplay.d.ts.map +1 -0
- package/dist/EventLogReplay.js +159 -0
- package/dist/EventLogReplay.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react/DevTools.d.ts +30 -0
- package/dist/react/DevTools.d.ts.map +1 -0
- package/dist/react/DevTools.js +68 -0
- package/dist/react/DevTools.js.map +1 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as defined by the copyright owner,
|
|
48
|
+
any work of authorship, including the original version of the Work and
|
|
49
|
+
any modifications or additions to that Work or Derivative Works of the
|
|
50
|
+
Work, that is intentionally submitted to the Licensor for inclusion in
|
|
51
|
+
the Work by the copyright owner or by an individual or Legal Entity
|
|
52
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
53
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
54
|
+
or written communication sent to the Licensor or its representatives,
|
|
55
|
+
including but not limited to communication on electronic mailing lists,
|
|
56
|
+
source code control systems, and issue tracking systems that are
|
|
57
|
+
managed by, or on behalf of, the Licensor for the purpose of
|
|
58
|
+
discussing and improving the Work, but excluding communication that is
|
|
59
|
+
conspicuously marked or otherwise designated in writing by the copyright
|
|
60
|
+
owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
63
|
+
whom a Contribution has been received by the Licensor and included
|
|
64
|
+
within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a cross-claim
|
|
83
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
84
|
+
Contribution embodied within the Work constitutes patent or
|
|
85
|
+
contributory patent infringement, then any patent licenses granted
|
|
86
|
+
to You under this License for that Work shall terminate as of the date
|
|
87
|
+
such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, You must include a readable copy of the
|
|
108
|
+
attribution notices contained within such NOTICE file, in
|
|
109
|
+
at least one of the following places: within a NOTICE text
|
|
110
|
+
file distributed as part of the Derivative Works; within
|
|
111
|
+
the Source form or documentation, if provided along with the
|
|
112
|
+
Derivative Works; or, within a display generated by the
|
|
113
|
+
Derivative Works, if and wherever such third-party notices
|
|
114
|
+
normally appear. The contents of the NOTICE file are for
|
|
115
|
+
informational purposes only and do not modify the License.
|
|
116
|
+
You may add Your own attribution notices within Derivative
|
|
117
|
+
Works that You distribute, alongside or as an addendum to
|
|
118
|
+
the NOTICE text from the Work, provided that such additional
|
|
119
|
+
attribution notices cannot be construed as modifying the License.
|
|
120
|
+
|
|
121
|
+
You may add Your own license statement for Your modifications and
|
|
122
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
123
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
124
|
+
Contribution, either alone or in combination with the Work.
|
|
125
|
+
|
|
126
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
127
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
128
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
129
|
+
this License, without any additional terms or conditions.
|
|
130
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
131
|
+
the terms of any separate license agreement you may have executed
|
|
132
|
+
with Licensor regarding such Contributions.
|
|
133
|
+
|
|
134
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
135
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
136
|
+
except as required for reasonable and customary use in describing the
|
|
137
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
138
|
+
|
|
139
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
140
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
141
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
142
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
143
|
+
implied, including, without limitation, any conditions of
|
|
144
|
+
TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
145
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
146
|
+
appropriateness of using or reproducing the Work and assume any
|
|
147
|
+
risks associated with Your exercise of permissions under this License.
|
|
148
|
+
|
|
149
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
150
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
151
|
+
unless required by applicable law (such as deliberate and grossly
|
|
152
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
153
|
+
liable to You for damages, including any direct, indirect, special,
|
|
154
|
+
incidental, or exemplary damages of any character arising as a
|
|
155
|
+
result of this License or out of the use or inability to use the
|
|
156
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
157
|
+
work stoppage, computer failure or malfunction, or all other
|
|
158
|
+
commercial damages or losses), even if such Contributor has been
|
|
159
|
+
advised of the possibility of such damages.
|
|
160
|
+
|
|
161
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
162
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
163
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
164
|
+
or other liability obligations and/or rights consistent with this
|
|
165
|
+
License. However, in accepting such obligations, You may act only
|
|
166
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
167
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
168
|
+
defend, and hold each Contributor harmless for any liability
|
|
169
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
170
|
+
of your accepting any such warranty or additional liability.
|
|
171
|
+
|
|
172
|
+
END OF TERMS AND CONDITIONS
|
|
173
|
+
|
|
174
|
+
Copyright 2026 agentkit-js contributors
|
|
175
|
+
|
|
176
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
+
you may not use this file except in compliance with the License.
|
|
178
|
+
You may obtain a copy of the License at
|
|
179
|
+
|
|
180
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
+
|
|
182
|
+
Unless required by applicable law or agreed to in writing, software
|
|
183
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
+
See the License for the specific language governing permissions and
|
|
186
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @agentkit-js/devtools
|
|
2
|
+
|
|
3
|
+
Time-travel debugger — `EventLogReplay` engine + opt-in `<DevTools />` React UI.
|
|
4
|
+
|
|
5
|
+
> Part of [agentkit-js](https://github.com/telleroutlook/agentkit-js) — a TypeScript + WASM agent runtime.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @agentkit-js/devtools @agentkit-js/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Step-replay any `EventLog` and **fork from any step**. The React surface is opt-in via
|
|
16
|
+
the `/react` subpath (peer-depends on React, but never required for the core engine).
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { EventLogReplay } from "@agentkit-js/devtools";
|
|
20
|
+
import { DevTools } from "@agentkit-js/devtools/react";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
See [docs/guides/devtools.md](https://github.com/telleroutlook/agentkit-js/blob/main/docs/guides/devtools.md).
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
[Apache-2.0](./LICENSE) — © agentkit-js contributors
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2 — DevTools event-log replay engine.
|
|
3
|
+
*
|
|
4
|
+
* Pure logic. Loads a list of `LoggedEvent`s (from agentkit-js's EventLog
|
|
5
|
+
* or any equivalent source), exposes a navigable timeline, and supports
|
|
6
|
+
* "fork from step N" — produce a new event list that ends at step N so a
|
|
7
|
+
* caller can rerun the agent from that point with different inputs
|
|
8
|
+
* (changed prompt, swapped model, swapped tools).
|
|
9
|
+
*
|
|
10
|
+
* The engine intentionally does NOT know about React or any UI. The
|
|
11
|
+
* `react/` subpath wraps it in a component; this file is consumable from
|
|
12
|
+
* Node, edge runtimes, and tests alike.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentEvent } from "@agentkit-js/core";
|
|
15
|
+
/** Shape we accept — kept structurally compatible with EventLog's LoggedEvent. */
|
|
16
|
+
export interface LoggedEvent {
|
|
17
|
+
eventId: string;
|
|
18
|
+
event: AgentEvent;
|
|
19
|
+
}
|
|
20
|
+
/** Lightweight per-step view derived from the event stream. */
|
|
21
|
+
export interface ReplayStep {
|
|
22
|
+
/** 1-based step number, or 0 for events before any `step_start`. */
|
|
23
|
+
step: number;
|
|
24
|
+
/** The event id of the `step_start` (or the first event for step 0). */
|
|
25
|
+
startEventId: string;
|
|
26
|
+
/** Indices into the underlying events array — tracked for fast slicing. */
|
|
27
|
+
fromIndex: number;
|
|
28
|
+
toIndex: number;
|
|
29
|
+
/** Convenience — the events that belong to this step (live reference). */
|
|
30
|
+
events: LoggedEvent[];
|
|
31
|
+
}
|
|
32
|
+
/** Snapshot returned by select() / forkAt(). */
|
|
33
|
+
export interface ReplayCursor {
|
|
34
|
+
/** Total number of events in the underlying log. */
|
|
35
|
+
totalEvents: number;
|
|
36
|
+
/** Total number of steps (a "step" is delimited by `step_start` events). */
|
|
37
|
+
totalSteps: number;
|
|
38
|
+
/** Current step index, 0-based. 0 = pre-first-step events. */
|
|
39
|
+
currentStep: number;
|
|
40
|
+
/** All events up to and including `currentStep`. */
|
|
41
|
+
prefixEvents: LoggedEvent[];
|
|
42
|
+
/** Final answer text if a `final_answer` event exists in `prefixEvents`. */
|
|
43
|
+
finalAnswer: string | null;
|
|
44
|
+
}
|
|
45
|
+
/** Options accepted by `forkAt`. */
|
|
46
|
+
export interface ForkOptions {
|
|
47
|
+
/** Optional — replace the original task with this string when describing the fork. */
|
|
48
|
+
task?: string;
|
|
49
|
+
/** Optional — note the model id swap so docs/tools can render it. */
|
|
50
|
+
modelId?: string;
|
|
51
|
+
/** Optional — free-form note attached to the fork's metadata. */
|
|
52
|
+
note?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Result of forking — the prefix events + a metadata bundle to feed to a fresh run. */
|
|
55
|
+
export interface Fork {
|
|
56
|
+
prefixEvents: LoggedEvent[];
|
|
57
|
+
forkedAtStep: number;
|
|
58
|
+
forkedAtEventId: string;
|
|
59
|
+
meta: ForkOptions & {
|
|
60
|
+
forkedFromTraceId?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Replay engine for one trace. Construction is O(n) over the event list;
|
|
65
|
+
* navigation operations are O(1).
|
|
66
|
+
*/
|
|
67
|
+
export declare class EventLogReplay {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(events: LoggedEvent[], opts?: {
|
|
70
|
+
traceId?: string;
|
|
71
|
+
});
|
|
72
|
+
/** Number of events in the log. */
|
|
73
|
+
get eventCount(): number;
|
|
74
|
+
/** Number of distinct steps (delimited by `step_start` events). */
|
|
75
|
+
get stepCount(): number;
|
|
76
|
+
/** Read-only view of the underlying events. */
|
|
77
|
+
get events(): readonly LoggedEvent[];
|
|
78
|
+
/** Read-only view of the computed step boundaries. */
|
|
79
|
+
get steps(): readonly ReplayStep[];
|
|
80
|
+
/**
|
|
81
|
+
* Return a cursor positioned at `step`. Negative values clamp to 0;
|
|
82
|
+
* values past the end clamp to `stepCount`.
|
|
83
|
+
*
|
|
84
|
+
* `prefixEvents` includes everything up to AND INCLUDING the named step
|
|
85
|
+
* — so `select(0)` returns events before the first `step_start`, and
|
|
86
|
+
* `select(stepCount)` returns the full log.
|
|
87
|
+
*/
|
|
88
|
+
select(step: number): ReplayCursor;
|
|
89
|
+
/**
|
|
90
|
+
* Fork from the given step. Returns the prefix event list AND a metadata
|
|
91
|
+
* bundle the caller can use to spawn a fresh agent run with the prefix
|
|
92
|
+
* replayed in (eg by feeding the events into a new MessageAssembler).
|
|
93
|
+
*/
|
|
94
|
+
forkAt(step: number, opts?: ForkOptions): Fork;
|
|
95
|
+
/**
|
|
96
|
+
* Find the highest step index whose first event id is ≤ the given
|
|
97
|
+
* eventId. Lets the UI map a clicked event row back to its step.
|
|
98
|
+
* Returns 0 when the eventId precedes all `step_start`s.
|
|
99
|
+
*/
|
|
100
|
+
stepForEventId(eventId: string): number;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=EventLogReplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogReplay.d.ts","sourceRoot":"","sources":["../src/EventLogReplay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,WAAW,EAAE,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ure logic. Loads a list of `LoggedEvent`s (from agentkit-js's EventLog
|
|
5
|
+
* or any equivalent source), exposes a navigable timeline, and supports
|
|
6
|
+
* "fork from step N" — produce a new event list that ends at step N so a
|
|
7
|
+
* caller can rerun the agent from that point with different inputs
|
|
8
|
+
* (changed prompt, swapped model, swapped tools).
|
|
9
|
+
*
|
|
10
|
+
* The engine intentionally does NOT know about React or any UI. The
|
|
11
|
+
* `react/` subpath wraps it in a component; this file is consumable from
|
|
12
|
+
* Node, edge runtimes, and tests alike.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Replay engine for one trace. Construction is O(n) over the event list;
|
|
16
|
+
* navigation operations are O(1).
|
|
17
|
+
*/
|
|
18
|
+
export class EventLogReplay {
|
|
19
|
+
#events;
|
|
20
|
+
#steps;
|
|
21
|
+
#traceId;
|
|
22
|
+
constructor(events, opts = {}) {
|
|
23
|
+
// Defensive copy so external mutation cannot corrupt the timeline.
|
|
24
|
+
this.#events = [...events];
|
|
25
|
+
this.#traceId = opts.traceId;
|
|
26
|
+
this.#steps = this.#computeSteps();
|
|
27
|
+
}
|
|
28
|
+
/** Number of events in the log. */
|
|
29
|
+
get eventCount() {
|
|
30
|
+
return this.#events.length;
|
|
31
|
+
}
|
|
32
|
+
/** Number of distinct steps (delimited by `step_start` events). */
|
|
33
|
+
get stepCount() {
|
|
34
|
+
return this.#steps.length;
|
|
35
|
+
}
|
|
36
|
+
/** Read-only view of the underlying events. */
|
|
37
|
+
get events() {
|
|
38
|
+
return this.#events;
|
|
39
|
+
}
|
|
40
|
+
/** Read-only view of the computed step boundaries. */
|
|
41
|
+
get steps() {
|
|
42
|
+
return this.#steps;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Return a cursor positioned at `step`. Negative values clamp to 0;
|
|
46
|
+
* values past the end clamp to `stepCount`.
|
|
47
|
+
*
|
|
48
|
+
* `prefixEvents` includes everything up to AND INCLUDING the named step
|
|
49
|
+
* — so `select(0)` returns events before the first `step_start`, and
|
|
50
|
+
* `select(stepCount)` returns the full log.
|
|
51
|
+
*/
|
|
52
|
+
select(step) {
|
|
53
|
+
const clamped = Math.max(0, Math.min(this.#steps.length, step));
|
|
54
|
+
let prefix;
|
|
55
|
+
if (clamped === 0) {
|
|
56
|
+
prefix =
|
|
57
|
+
this.#steps.length > 0
|
|
58
|
+
? this.#events.slice(0, this.#steps[0]?.fromIndex)
|
|
59
|
+
: [...this.#events];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const stepEntry = this.#steps[clamped - 1];
|
|
63
|
+
prefix = stepEntry ? this.#events.slice(0, stepEntry.toIndex + 1) : [...this.#events];
|
|
64
|
+
}
|
|
65
|
+
const finalAnswer = findFinalAnswer(prefix);
|
|
66
|
+
return {
|
|
67
|
+
totalEvents: this.#events.length,
|
|
68
|
+
totalSteps: this.#steps.length,
|
|
69
|
+
currentStep: clamped,
|
|
70
|
+
prefixEvents: prefix,
|
|
71
|
+
finalAnswer,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fork from the given step. Returns the prefix event list AND a metadata
|
|
76
|
+
* bundle the caller can use to spawn a fresh agent run with the prefix
|
|
77
|
+
* replayed in (eg by feeding the events into a new MessageAssembler).
|
|
78
|
+
*/
|
|
79
|
+
forkAt(step, opts = {}) {
|
|
80
|
+
const cursor = this.select(step);
|
|
81
|
+
const lastEvent = cursor.prefixEvents[cursor.prefixEvents.length - 1];
|
|
82
|
+
return {
|
|
83
|
+
prefixEvents: cursor.prefixEvents,
|
|
84
|
+
forkedAtStep: cursor.currentStep,
|
|
85
|
+
forkedAtEventId: lastEvent?.eventId ?? "",
|
|
86
|
+
meta: {
|
|
87
|
+
...opts,
|
|
88
|
+
...(this.#traceId ? { forkedFromTraceId: this.#traceId } : {}),
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Find the highest step index whose first event id is ≤ the given
|
|
94
|
+
* eventId. Lets the UI map a clicked event row back to its step.
|
|
95
|
+
* Returns 0 when the eventId precedes all `step_start`s.
|
|
96
|
+
*/
|
|
97
|
+
stepForEventId(eventId) {
|
|
98
|
+
let lastMatch = 0;
|
|
99
|
+
for (let i = 0; i < this.#steps.length; i++) {
|
|
100
|
+
const step = this.#steps[i];
|
|
101
|
+
if (!step)
|
|
102
|
+
break;
|
|
103
|
+
if (step.startEventId <= eventId) {
|
|
104
|
+
lastMatch = i + 1;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return lastMatch;
|
|
111
|
+
}
|
|
112
|
+
// ── Internals ─────────────────────────────────────────────────────────────
|
|
113
|
+
#computeSteps() {
|
|
114
|
+
const out = [];
|
|
115
|
+
let stepIndex = 0;
|
|
116
|
+
for (let i = 0; i < this.#events.length; i++) {
|
|
117
|
+
const ev = this.#events[i];
|
|
118
|
+
if (!ev)
|
|
119
|
+
continue;
|
|
120
|
+
if (ev.event.event === "step_start") {
|
|
121
|
+
// Close out the previous step (if any) before opening this one.
|
|
122
|
+
const prev = out[out.length - 1];
|
|
123
|
+
if (prev)
|
|
124
|
+
prev.toIndex = i - 1;
|
|
125
|
+
stepIndex += 1;
|
|
126
|
+
out.push({
|
|
127
|
+
step: stepIndex,
|
|
128
|
+
startEventId: ev.eventId,
|
|
129
|
+
fromIndex: i,
|
|
130
|
+
toIndex: i, // tentative, fixed up below
|
|
131
|
+
events: [],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Final close-out for the last step.
|
|
136
|
+
const lastStep = out[out.length - 1];
|
|
137
|
+
if (lastStep)
|
|
138
|
+
lastStep.toIndex = this.#events.length - 1;
|
|
139
|
+
// Backfill the events arrays.
|
|
140
|
+
for (const s of out) {
|
|
141
|
+
s.events = this.#events.slice(s.fromIndex, s.toIndex + 1);
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function findFinalAnswer(events) {
|
|
147
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
148
|
+
const e = events[i]?.event;
|
|
149
|
+
if (!e)
|
|
150
|
+
continue;
|
|
151
|
+
if (e.event === "final_answer") {
|
|
152
|
+
const data = e.data;
|
|
153
|
+
if (data && typeof data.answer === "string")
|
|
154
|
+
return data.answer;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=EventLogReplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogReplay.js","sourceRoot":"","sources":["../src/EventLogReplay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAuDH;;;GAGG;AACH,MAAM,OAAO,cAAc;IAChB,OAAO,CAAgB;IACvB,MAAM,CAAe;IACrB,QAAQ,CAAqB;IAEtC,YAAY,MAAqB,EAAE,OAA6B,EAAE;QAChE,mEAAmE;QACnE,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC;IAED,mCAAmC;IACnC,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,mEAAmE;IACnE,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,+CAA+C;IAC/C,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,sDAAsD;IACtD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAY;QACjB,MAAM,OAAO,GAAG,IAAI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AAI,CAAC,MAAM,CAAC;QAClE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentkit-js/devtools — runtime-agnostic primitives.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the replay engine and helper types. The React UI lives in the
|
|
5
|
+
* `./react` subpath so consumers without React (eg server-side fork tools)
|
|
6
|
+
* don't pay the bundle cost.
|
|
7
|
+
*/
|
|
8
|
+
export type { Fork, ForkOptions, LoggedEvent, ReplayCursor, ReplayStep, } from "./EventLogReplay.js";
|
|
9
|
+
export { EventLogReplay } from "./EventLogReplay.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EACV,IAAI,EACJ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2 — DevTools React component.
|
|
3
|
+
*
|
|
4
|
+
* Renders an event timeline, a step inspector, and a "fork from step N"
|
|
5
|
+
* affordance. State and rendering only — the actual fork (running a fresh
|
|
6
|
+
* agent on the prefix) is the host application's job; this component
|
|
7
|
+
* surfaces the user's intent via `onFork`.
|
|
8
|
+
*
|
|
9
|
+
* The component is intentionally style-light — the host page can wrap it
|
|
10
|
+
* or pass `className` props at the section boundaries. We don't ship CSS
|
|
11
|
+
* to keep the bundle tiny.
|
|
12
|
+
*/
|
|
13
|
+
import { type Fork, type LoggedEvent } from "../EventLogReplay.js";
|
|
14
|
+
export interface DevToolsProps {
|
|
15
|
+
/** The full event log for one trace, as produced by EventLog.replay(). */
|
|
16
|
+
events: LoggedEvent[];
|
|
17
|
+
/** Optional trace id; surfaced in fork metadata. */
|
|
18
|
+
traceId?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Called when the user clicks "Fork from this step". The host application
|
|
21
|
+
* should kick off a fresh agent run with the supplied prefix events and
|
|
22
|
+
* the user-edited override (task / modelId / note).
|
|
23
|
+
*
|
|
24
|
+
* Returning a Promise is fine; the component does NOT await it (no spinner
|
|
25
|
+
* UI in this baseline). Add your own status display in the host page.
|
|
26
|
+
*/
|
|
27
|
+
onFork?: (fork: Fork) => void | Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare function DevTools({ events, traceId, onFork }: DevToolsProps): import("react").JSX.Element;
|
|
30
|
+
//# sourceMappingURL=DevTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevTools.d.ts","sourceRoot":"","sources":["../../src/react/DevTools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAEL,KAAK,IAAI,EAET,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,aAAa,+BA2IlE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A2 — DevTools React component.
|
|
4
|
+
*
|
|
5
|
+
* Renders an event timeline, a step inspector, and a "fork from step N"
|
|
6
|
+
* affordance. State and rendering only — the actual fork (running a fresh
|
|
7
|
+
* agent on the prefix) is the host application's job; this component
|
|
8
|
+
* surfaces the user's intent via `onFork`.
|
|
9
|
+
*
|
|
10
|
+
* The component is intentionally style-light — the host page can wrap it
|
|
11
|
+
* or pass `className` props at the section boundaries. We don't ship CSS
|
|
12
|
+
* to keep the bundle tiny.
|
|
13
|
+
*/
|
|
14
|
+
import { useMemo, useState } from "react";
|
|
15
|
+
import { EventLogReplay, } from "../EventLogReplay.js";
|
|
16
|
+
export function DevTools({ events, traceId, onFork }) {
|
|
17
|
+
const replay = useMemo(() => new EventLogReplay(events, traceId !== undefined ? { traceId } : {}), [events, traceId]);
|
|
18
|
+
const [step, setStep] = useState(replay.stepCount);
|
|
19
|
+
const [taskOverride, setTaskOverride] = useState("");
|
|
20
|
+
const [modelOverride, setModelOverride] = useState("");
|
|
21
|
+
const [note, setNote] = useState("");
|
|
22
|
+
const cursor = useMemo(() => replay.select(step), [replay, step]);
|
|
23
|
+
const triggerFork = () => {
|
|
24
|
+
const opts = {};
|
|
25
|
+
if (taskOverride.trim())
|
|
26
|
+
opts.task = taskOverride.trim();
|
|
27
|
+
if (modelOverride.trim())
|
|
28
|
+
opts.modelId = modelOverride.trim();
|
|
29
|
+
if (note.trim())
|
|
30
|
+
opts.note = note.trim();
|
|
31
|
+
const fork = replay.forkAt(step, opts);
|
|
32
|
+
void onFork?.(fork);
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs("div", { "data-testid": "agentkit-devtools", style: { fontFamily: "ui-sans-serif, system-ui", fontSize: 13 }, children: [_jsxs("header", { style: { marginBottom: 8 }, children: [_jsx("strong", { children: "Agent DevTools" }), _jsxs("span", { style: { color: "#888", marginLeft: 8 }, children: [replay.stepCount, " step", replay.stepCount === 1 ? "" : "s", " \u00B7 ", replay.eventCount, " event", replay.eventCount === 1 ? "" : "s"] })] }), _jsxs("div", { style: { display: "flex", gap: 12 }, children: [_jsxs("div", { style: { minWidth: 220, borderRight: "1px solid #eee", paddingRight: 8 }, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: 6 }, children: "Steps" }), _jsxs("ol", { style: { listStyle: "none", padding: 0, margin: 0 }, children: [_jsx("li", { children: _jsx("button", { type: "button", onClick: () => setStep(0), "aria-pressed": step === 0, style: selectedStyle(step === 0), children: "0 \u00B7 prelude" }) }), replay.steps.map((s) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => setStep(s.step), "aria-pressed": step === s.step, style: selectedStyle(step === s.step), children: [s.step, " \u00B7 ", s.events.length, " event", s.events.length === 1 ? "" : "s"] }) }, s.startEventId)))] })] }), _jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [_jsxs("div", { style: { fontWeight: 600, marginBottom: 6 }, children: ["Cursor: step ", cursor.currentStep, " / ", cursor.totalSteps] }), cursor.finalAnswer ? (_jsxs("div", { style: {
|
|
35
|
+
background: "#f6fff6",
|
|
36
|
+
border: "1px solid #cfe9cf",
|
|
37
|
+
padding: 6,
|
|
38
|
+
marginBottom: 8,
|
|
39
|
+
}, children: [_jsx("div", { style: { fontWeight: 600, fontSize: 11, color: "#3a7" }, children: "FINAL ANSWER" }), _jsx("div", { style: { whiteSpace: "pre-wrap" }, children: cursor.finalAnswer })] })) : null, _jsxs("div", { style: { marginBottom: 8 }, children: [_jsx("div", { style: { fontWeight: 600, marginBottom: 4 }, children: "Events in prefix" }), _jsx("ul", { style: { listStyle: "none", padding: 0, margin: 0, maxHeight: 200, overflow: "auto" }, children: cursor.prefixEvents.map((le) => (_jsxs("li", { style: { borderBottom: "1px solid #f3f3f3", padding: "2px 0" }, children: [_jsx("code", { style: { color: "#888", fontSize: 11 }, children: le.eventId }), " ", _jsx("strong", { children: le.event.event }), " ", _jsx("span", { style: { color: "#666" }, children: summarise(le.event) })] }, le.eventId))) })] }), _jsxs("details", { children: [_jsxs("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: ["Fork from step ", step] }), _jsxs("div", { style: { marginTop: 6, display: "grid", gap: 6 }, children: [_jsxs("label", { children: [_jsx("div", { style: { fontSize: 11, color: "#666" }, children: "Task override (optional)" }), _jsx("textarea", { rows: 2, value: taskOverride, onChange: (e) => setTaskOverride(e.target.value), style: { width: "100%", fontSize: 12 } })] }), _jsxs("label", { children: [_jsx("div", { style: { fontSize: 11, color: "#666" }, children: "Model override (optional)" }), _jsx("input", { value: modelOverride, onChange: (e) => setModelOverride(e.target.value), placeholder: "e.g. claude-haiku-4-5", style: { width: "100%", fontSize: 12 } })] }), _jsxs("label", { children: [_jsx("div", { style: { fontSize: 11, color: "#666" }, children: "Note (optional)" }), _jsx("input", { value: note, onChange: (e) => setNote(e.target.value), style: { width: "100%", fontSize: 12 } })] }), _jsx("button", { type: "button", onClick: triggerFork, children: "Fork & re-run" })] })] })] })] })] }));
|
|
40
|
+
}
|
|
41
|
+
function selectedStyle(selected) {
|
|
42
|
+
return {
|
|
43
|
+
display: "block",
|
|
44
|
+
width: "100%",
|
|
45
|
+
textAlign: "left",
|
|
46
|
+
padding: "3px 6px",
|
|
47
|
+
border: "1px solid transparent",
|
|
48
|
+
background: selected ? "#eef" : "transparent",
|
|
49
|
+
fontWeight: selected ? 600 : 400,
|
|
50
|
+
cursor: "pointer",
|
|
51
|
+
fontSize: 12,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function summarise(ev) {
|
|
55
|
+
const data = ev.data;
|
|
56
|
+
if (!data)
|
|
57
|
+
return "";
|
|
58
|
+
if ("answer" in data) {
|
|
59
|
+
const a = data.answer;
|
|
60
|
+
return typeof a === "string" ? a.slice(0, 80) : "";
|
|
61
|
+
}
|
|
62
|
+
if ("toolName" in data)
|
|
63
|
+
return String(data.toolName);
|
|
64
|
+
if ("step" in data)
|
|
65
|
+
return `step ${String(data.step)}`;
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=DevTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../src/react/DevTools.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,cAAc,GAIf,MAAM,sBAAsB,CAAC;AAkB9B,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAiB;IACjE,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1E,CAAC,MAAM,EAAE,OAAO,CAAC,CAClB,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAErC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAElE,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,MAAM,IAAI,GAAgB,EAAE,CAAC;QAC7B,IAAI,YAAY,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,IAAI,GAAG,YAAY,C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M,EAAE,SAAS;QACjB,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,EAAwB;IACzC,MAAM,IAAI,GAAI,EAAyC,CAAC,IAAI,CAAC;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,CAAC;IACD,IAAI,UAAU,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,QAAQ,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACvD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentkit-js/devtools/react — React UI for the replay engine.
|
|
3
|
+
*
|
|
4
|
+
* Imported via `import { DevTools } from "@agentkit-js/devtools/react";`.
|
|
5
|
+
* Pure component layer; the underlying logic lives in EventLogReplay
|
|
6
|
+
* (one subpath up).
|
|
7
|
+
*/
|
|
8
|
+
export type { DevToolsProps } from "./DevTools.js";
|
|
9
|
+
export { DevTools } from "./DevTools.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentkit-js/devtools",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "DevTools for agentkit-js — event timeline, step-replay, fork-from-checkpoint",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"import": "./dist/react/index.js",
|
|
15
|
+
"types": "./dist/react/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"react": {
|
|
28
|
+
"optional": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@testing-library/react": "^16.0.0",
|
|
33
|
+
"@types/react": "^18.0.0",
|
|
34
|
+
"@types/react-dom": "^18.0.0",
|
|
35
|
+
"jsdom": "^29.1.1",
|
|
36
|
+
"react": "^18.0.0",
|
|
37
|
+
"react-dom": "^18.0.0",
|
|
38
|
+
"typescript": "^5.0.0",
|
|
39
|
+
"vitest": "^2.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@agentkit-js/core": "workspace:*"
|
|
43
|
+
},
|
|
44
|
+
"license": "Apache-2.0",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/telleroutlook/agentkit-js.git",
|
|
48
|
+
"directory": "packages/devtools"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/telleroutlook/agentkit-js/tree/main/packages/devtools#readme",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/telleroutlook/agentkit-js/issues"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=20.0.0"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"agentkit",
|
|
59
|
+
"agent",
|
|
60
|
+
"ai",
|
|
61
|
+
"llm"
|
|
62
|
+
],
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"dist",
|
|
68
|
+
"LICENSE",
|
|
69
|
+
"README.md"
|
|
70
|
+
],
|
|
71
|
+
"author": "agentkit-js contributors"
|
|
72
|
+
}
|