@jini-ai/agentic 0.1.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 +201 -0
- package/dist/ag-ui.d.ts +82 -0
- package/dist/ag-ui.d.ts.map +1 -0
- package/dist/ag-ui.js +56 -0
- package/dist/ag-ui.js.map +1 -0
- package/dist/agui/encoder.d.ts +50 -0
- package/dist/agui/encoder.d.ts.map +1 -0
- package/dist/agui/encoder.js +97 -0
- package/dist/agui/encoder.js.map +1 -0
- package/dist/agui/events.d.ts +59 -0
- package/dist/agui/events.d.ts.map +1 -0
- package/dist/agui/events.js +15 -0
- package/dist/agui/events.js.map +1 -0
- package/dist/capability.d.ts +81 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +79 -0
- package/dist/capability.js.map +1 -0
- package/dist/dom/dom-page-driver.d.ts +29 -0
- package/dist/dom/dom-page-driver.d.ts.map +1 -0
- package/dist/dom/dom-page-driver.js +557 -0
- package/dist/dom/dom-page-driver.js.map +1 -0
- package/dist/dom/index.d.ts +17 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +17 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/model-context.d.ts +54 -0
- package/dist/dom/model-context.d.ts.map +1 -0
- package/dist/dom/model-context.js +36 -0
- package/dist/dom/model-context.js.map +1 -0
- package/dist/element-handles.d.ts +99 -0
- package/dist/element-handles.d.ts.map +1 -0
- package/dist/element-handles.js +39 -0
- package/dist/element-handles.js.map +1 -0
- package/dist/gen-ui/encoder.d.ts +50 -0
- package/dist/gen-ui/encoder.d.ts.map +1 -0
- package/dist/gen-ui/encoder.js +97 -0
- package/dist/gen-ui/encoder.js.map +1 -0
- package/dist/gen-ui/events.d.ts +59 -0
- package/dist/gen-ui/events.d.ts.map +1 -0
- package/dist/gen-ui/events.js +15 -0
- package/dist/gen-ui/events.js.map +1 -0
- package/dist/gen-ui/index.d.ts +18 -0
- package/dist/gen-ui/index.d.ts.map +1 -0
- package/dist/gen-ui/index.js +17 -0
- package/dist/gen-ui/index.js.map +1 -0
- package/dist/guards.d.ts +91 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +181 -0
- package/dist/guards.js.map +1 -0
- package/dist/handle.d.ts +41 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +41 -0
- package/dist/handle.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-ui-apps.d.ts +133 -0
- package/dist/mcp-ui-apps.d.ts.map +1 -0
- package/dist/mcp-ui-apps.js +134 -0
- package/dist/mcp-ui-apps.js.map +1 -0
- package/dist/mcp-ui.d.ts +133 -0
- package/dist/mcp-ui.d.ts.map +1 -0
- package/dist/mcp-ui.js +134 -0
- package/dist/mcp-ui.js.map +1 -0
- package/dist/page-capabilities.d.ts +14 -0
- package/dist/page-capabilities.d.ts.map +1 -0
- package/dist/page-capabilities.js +129 -0
- package/dist/page-capabilities.js.map +1 -0
- package/dist/page-driver.d.ts +107 -0
- package/dist/page-driver.d.ts.map +1 -0
- package/dist/page-driver.js +2 -0
- package/dist/page-driver.js.map +1 -0
- package/dist/page-executor.d.ts +87 -0
- package/dist/page-executor.d.ts.map +1 -0
- package/dist/page-executor.js +288 -0
- package/dist/page-executor.js.map +1 -0
- package/dist/webmcp.d.ts +81 -0
- package/dist/webmcp.d.ts.map +1 -0
- package/dist/webmcp.js +67 -0
- package/dist/webmcp.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated 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 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
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date 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
|
|
95
|
+
Derivative 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, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Open Design contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/ag-ui.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ag-ui
|
|
3
|
+
*
|
|
4
|
+
* Projection: {@link CapabilityDef} → an AG-UI frontend tool.
|
|
5
|
+
*
|
|
6
|
+
* AG-UI (the Agent-User Interaction Protocol) streams typed events between an agent backend and
|
|
7
|
+
* a frontend. The relevant half here is its **frontend tool calls**: the frontend passes its
|
|
8
|
+
* tools in `RunAgentInput.tools`, the agent emits a tool call, the frontend executes it, and the
|
|
9
|
+
* frontend returns a `role: "tool"` message referencing the call id. That is the same handoff
|
|
10
|
+
* Jini's capabilities describe, which is why this projection is a rename rather than a redesign.
|
|
11
|
+
*
|
|
12
|
+
* One shape difference this file exists to absorb: **AG-UI names the JSON Schema field
|
|
13
|
+
* `parameters`**, where WebMCP and MCP both name it `inputSchema`. Anything reading a manifest
|
|
14
|
+
* through the wrong name silently sends a tool with no arguments.
|
|
15
|
+
*
|
|
16
|
+
* Transport is not here — AG-UI runs over SSE or WebSocket, and this package opens no
|
|
17
|
+
* connections. This is the vocabulary translation only.
|
|
18
|
+
*/
|
|
19
|
+
import type { CapabilityDef, CapabilityInputSchema } from './capability.js';
|
|
20
|
+
/** An AG-UI tool as passed in `RunAgentInput.tools`. */
|
|
21
|
+
export interface AgUiTool {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly description: string;
|
|
24
|
+
/** JSON Schema. Note the field name: AG-UI says `parameters`, not `inputSchema`. */
|
|
25
|
+
readonly parameters: CapabilityInputSchema;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The tool-call event names AG-UI emits, agent → frontend.
|
|
29
|
+
*
|
|
30
|
+
* Arguments stream: `TOOL_CALL_ARGS` carries a `delta` fragment and may arrive many times for
|
|
31
|
+
* one call, so a consumer must accumulate by `toolCallId` and only execute after
|
|
32
|
+
* `TOOL_CALL_END`. Acting on a partial argument object is the obvious failure here.
|
|
33
|
+
*/
|
|
34
|
+
export declare const AG_UI_TOOL_CALL_EVENTS: {
|
|
35
|
+
/** Fields: `toolCallId`, `toolCallName`, optional `parentMessageId`. */
|
|
36
|
+
readonly start: "TOOL_CALL_START";
|
|
37
|
+
/** Fields: `toolCallId`, `delta` — a JSON fragment, not a complete object. */
|
|
38
|
+
readonly args: "TOOL_CALL_ARGS";
|
|
39
|
+
/** Fields: `toolCallId`. Arguments are complete only once this arrives. */
|
|
40
|
+
readonly end: "TOOL_CALL_END";
|
|
41
|
+
};
|
|
42
|
+
/** The message a frontend returns after executing a tool call. */
|
|
43
|
+
export interface AgUiToolResultMessage {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly role: 'tool';
|
|
46
|
+
readonly content: string;
|
|
47
|
+
readonly toolCallId: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Projects one capability into an AG-UI tool.
|
|
51
|
+
*
|
|
52
|
+
* @param capability - The capability to expose.
|
|
53
|
+
* @returns The tool entry for `RunAgentInput.tools`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function toAgUiTool(capability: CapabilityDef): AgUiTool;
|
|
56
|
+
/**
|
|
57
|
+
* Projects a whole manifest.
|
|
58
|
+
*
|
|
59
|
+
* @param capabilities - Capabilities to expose, already filtered by whatever policy applies.
|
|
60
|
+
* @returns One tool per capability, in manifest order.
|
|
61
|
+
*/
|
|
62
|
+
export declare function toAgUiTools(capabilities: readonly CapabilityDef[]): readonly AgUiTool[];
|
|
63
|
+
/**
|
|
64
|
+
* Builds the result message for a completed frontend tool call.
|
|
65
|
+
*
|
|
66
|
+
* AG-UI carries the result as a string, so structured output is JSON-encoded. Errors are
|
|
67
|
+
* returned through this same channel rather than thrown — the agent needs to see the refusal
|
|
68
|
+
* (a fill guard saying no, an unavailable capability) as a result it can reason about.
|
|
69
|
+
*
|
|
70
|
+
* @param messageId - Id for the result message itself.
|
|
71
|
+
* @param toolCallId - The `toolCallId` from `TOOL_CALL_START`.
|
|
72
|
+
* @param outcome - What happened.
|
|
73
|
+
* @returns The `role: "tool"` message to send back.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createAgUiToolResult(messageId: string, toolCallId: string, outcome: {
|
|
76
|
+
ok: true;
|
|
77
|
+
output: unknown;
|
|
78
|
+
} | {
|
|
79
|
+
ok: false;
|
|
80
|
+
error: string;
|
|
81
|
+
}): AgUiToolResultMessage;
|
|
82
|
+
//# sourceMappingURL=ag-ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ag-ui.d.ts","sourceRoot":"","sources":["../src/ag-ui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,wDAAwD;AACxD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;IACjC,wEAAwE;;IAExE,8EAA8E;;IAE9E,2EAA2E;;CAEnE,CAAC;AAEX,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,aAAa,GAAG,QAAQ,CAM9D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,QAAQ,EAAE,CAEvF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpE,qBAAqB,CAKvB"}
|
package/dist/ag-ui.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool-call event names AG-UI emits, agent → frontend.
|
|
3
|
+
*
|
|
4
|
+
* Arguments stream: `TOOL_CALL_ARGS` carries a `delta` fragment and may arrive many times for
|
|
5
|
+
* one call, so a consumer must accumulate by `toolCallId` and only execute after
|
|
6
|
+
* `TOOL_CALL_END`. Acting on a partial argument object is the obvious failure here.
|
|
7
|
+
*/
|
|
8
|
+
export const AG_UI_TOOL_CALL_EVENTS = {
|
|
9
|
+
/** Fields: `toolCallId`, `toolCallName`, optional `parentMessageId`. */
|
|
10
|
+
start: 'TOOL_CALL_START',
|
|
11
|
+
/** Fields: `toolCallId`, `delta` — a JSON fragment, not a complete object. */
|
|
12
|
+
args: 'TOOL_CALL_ARGS',
|
|
13
|
+
/** Fields: `toolCallId`. Arguments are complete only once this arrives. */
|
|
14
|
+
end: 'TOOL_CALL_END',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Projects one capability into an AG-UI tool.
|
|
18
|
+
*
|
|
19
|
+
* @param capability - The capability to expose.
|
|
20
|
+
* @returns The tool entry for `RunAgentInput.tools`.
|
|
21
|
+
*/
|
|
22
|
+
export function toAgUiTool(capability) {
|
|
23
|
+
return {
|
|
24
|
+
name: capability.id,
|
|
25
|
+
description: capability.description,
|
|
26
|
+
parameters: capability.inputSchema,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Projects a whole manifest.
|
|
31
|
+
*
|
|
32
|
+
* @param capabilities - Capabilities to expose, already filtered by whatever policy applies.
|
|
33
|
+
* @returns One tool per capability, in manifest order.
|
|
34
|
+
*/
|
|
35
|
+
export function toAgUiTools(capabilities) {
|
|
36
|
+
return capabilities.map(toAgUiTool);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds the result message for a completed frontend tool call.
|
|
40
|
+
*
|
|
41
|
+
* AG-UI carries the result as a string, so structured output is JSON-encoded. Errors are
|
|
42
|
+
* returned through this same channel rather than thrown — the agent needs to see the refusal
|
|
43
|
+
* (a fill guard saying no, an unavailable capability) as a result it can reason about.
|
|
44
|
+
*
|
|
45
|
+
* @param messageId - Id for the result message itself.
|
|
46
|
+
* @param toolCallId - The `toolCallId` from `TOOL_CALL_START`.
|
|
47
|
+
* @param outcome - What happened.
|
|
48
|
+
* @returns The `role: "tool"` message to send back.
|
|
49
|
+
*/
|
|
50
|
+
export function createAgUiToolResult(messageId, toolCallId, outcome) {
|
|
51
|
+
const content = outcome.ok
|
|
52
|
+
? typeof outcome.output === 'string' ? outcome.output : JSON.stringify(outcome.output ?? null)
|
|
53
|
+
: JSON.stringify({ error: outcome.error });
|
|
54
|
+
return { id: messageId, role: 'tool', content, toolCallId };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ag-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ag-ui.js","sourceRoot":"","sources":["../src/ag-ui.ts"],"names":[],"mappings":"AA4BA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,wEAAwE;IACxE,KAAK,EAAE,iBAAiB;IACxB,8EAA8E;IAC9E,IAAI,EAAE,gBAAgB;IACtB,2EAA2E;IAC3E,GAAG,EAAE,eAAe;CACZ,CAAC;AAUX;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,UAAyB;IAClD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,EAAE;QACnB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,UAAU,EAAE,UAAU,CAAC,WAAW;KACnC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,YAAsC;IAChE,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,UAAkB,EAClB,OAAqE;IAErE,MAAM,OAAO,GAAG,OAAO,CAAC,EAAE;QACxB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;QAC9F,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agui/encoder
|
|
3
|
+
*
|
|
4
|
+
* Encodes `@jini/protocol`'s `RunProtocolEvent` stream into AG-UI wire events (see
|
|
5
|
+
* `./events.ts`'s module doc). Rewritten from scratch against `@jini/protocol`'s actual
|
|
6
|
+
* current shape — the ported adapter's original encoder targeted a different, product-specific
|
|
7
|
+
* event union with no direct correspondence to `RunProtocolEvent`/`RunAgentPayload`; only the
|
|
8
|
+
* *shape* of the job (a big per-event-kind switch, unrecognized events silently dropped) carried
|
|
9
|
+
* over. See `source-map.md` for the full old→new field-mapping table and the generalization
|
|
10
|
+
* writeup for the six event kinds that had no generic equivalent before this task.
|
|
11
|
+
*
|
|
12
|
+
* Folded in 2026-07-26 from the standalone `@jini/agui` package (plan §3a) into this `src/agui/`
|
|
13
|
+
* subdirectory — kept out of the flat `ag-ui.ts` namespace because that file is a different
|
|
14
|
+
* projection ({@link CapabilityDef} → an AG-UI *frontend tool*); this one turns a run's event
|
|
15
|
+
* stream into AG-UI *wire* events. Same protocol, two unrelated halves of it.
|
|
16
|
+
*/
|
|
17
|
+
import type { RunProtocolEvent } from '@jini/protocol';
|
|
18
|
+
import type { AGUIEvent } from './events.js';
|
|
19
|
+
export interface AguiEncodeContext {
|
|
20
|
+
/** The run this event belongs to — stamped onto every produced `AGUIEvent`. */
|
|
21
|
+
readonly runId: string;
|
|
22
|
+
/** Passed through onto the produced event's `seq`, when the caller tracks one (e.g. an SSE `Last-Event-ID`-shaped cursor). Omitted entirely (not set to `undefined`) when absent, matching the original adapter's own base-field construction. */
|
|
23
|
+
readonly seq?: number;
|
|
24
|
+
/** Injectable clock for the produced event's `ts`. Defaults to `Date.now`. Test-only hook. */
|
|
25
|
+
readonly now?: () => number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A stateful AG-UI encoder for one run's event stream. Stateful because `tool_use`/`tool_result`
|
|
29
|
+
* correlation requires remembering each in-flight tool call's name/args between the two protocol
|
|
30
|
+
* events that describe its start and end — a pure per-event function cannot do this alone. Create
|
|
31
|
+
* one instance per run (e.g. one per `RunLifecycle.stream(runId, ...)` subscription); do not share
|
|
32
|
+
* an instance across multiple runs, since the correlation map has no per-run partitioning of its
|
|
33
|
+
* own (`ctx.runId` is only used to stamp the produced event, not to scope the map).
|
|
34
|
+
*/
|
|
35
|
+
export interface AguiEncoder {
|
|
36
|
+
/**
|
|
37
|
+
* Encodes one `RunProtocolEvent` into an `AGUIEvent`, or `null` if this event has no AG-UI
|
|
38
|
+
* equivalent (an unrecognized/not-yet-generalized event kind — silently dropped by the relay,
|
|
39
|
+
* matching the original adapter's own default behavior).
|
|
40
|
+
*/
|
|
41
|
+
encode(event: RunProtocolEvent, ctx: AguiEncodeContext): AGUIEvent | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a fresh `AguiEncoder` with its own, empty tool-call correlation map.
|
|
45
|
+
* @complexity `encode` is O(1) per call (one `Map` get/set/delete); memory is O(k) in the number
|
|
46
|
+
* of currently in-flight (not yet resolved) tool calls for the run this instance encodes.
|
|
47
|
+
* @overallScore 100/100
|
|
48
|
+
*/
|
|
49
|
+
export declare function createAguiEncoder(): AguiEncoder;
|
|
50
|
+
//# sourceMappingURL=encoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/agui/encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kPAAkP;IAClP,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,8FAA8F;IAC9F,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAOD;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAAC;CAC3E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAqG/C"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fresh `AguiEncoder` with its own, empty tool-call correlation map.
|
|
3
|
+
* @complexity `encode` is O(1) per call (one `Map` get/set/delete); memory is O(k) in the number
|
|
4
|
+
* of currently in-flight (not yet resolved) tool calls for the run this instance encodes.
|
|
5
|
+
* @overallScore 100/100
|
|
6
|
+
*/
|
|
7
|
+
export function createAguiEncoder() {
|
|
8
|
+
const pendingToolCalls = new Map();
|
|
9
|
+
function baseFields(ctx) {
|
|
10
|
+
const ts = ctx.now ? ctx.now() : Date.now();
|
|
11
|
+
return ctx.seq !== undefined ? { runId: ctx.runId, ts, seq: ctx.seq } : { runId: ctx.runId, ts };
|
|
12
|
+
}
|
|
13
|
+
function encodeAgentPayload(payload, ctx) {
|
|
14
|
+
const base = baseFields(ctx);
|
|
15
|
+
switch (payload.type) {
|
|
16
|
+
case 'text_delta':
|
|
17
|
+
return { ...base, kind: 'agent.message', text: payload.delta };
|
|
18
|
+
case 'tool_use':
|
|
19
|
+
// Overwrites any prior entry under the same id (a duplicate tool_use for one id) — the
|
|
20
|
+
// most recent call's name/args are what a matching tool_result should be attributed to,
|
|
21
|
+
// and there is no protocol-level guarantee ids are never reused within one run.
|
|
22
|
+
pendingToolCalls.set(payload.id, { toolName: payload.name, args: payload.input });
|
|
23
|
+
return { ...base, kind: 'tool_call', toolName: payload.name, args: payload.input, callId: payload.id, status: 'started' };
|
|
24
|
+
case 'tool_result': {
|
|
25
|
+
const pending = pendingToolCalls.get(payload.toolUseId);
|
|
26
|
+
pendingToolCalls.delete(payload.toolUseId);
|
|
27
|
+
return {
|
|
28
|
+
...base,
|
|
29
|
+
kind: 'tool_call',
|
|
30
|
+
// A tool_result with no matching prior tool_use (never observed, or already resolved/
|
|
31
|
+
// cleared — e.g. after a run-ending 'end' event, see below) falls back to an 'unknown'
|
|
32
|
+
// name and null args rather than throwing: the result itself is still real and worth
|
|
33
|
+
// relaying even when its originating call wasn't captured.
|
|
34
|
+
toolName: pending?.toolName ?? 'unknown',
|
|
35
|
+
args: pending?.args ?? null,
|
|
36
|
+
callId: payload.toolUseId,
|
|
37
|
+
status: payload.isError ? 'failed' : 'completed',
|
|
38
|
+
result: payload.content,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Generalization (see source-map.md): pipeline_stage_started/completed generalized into a
|
|
42
|
+
// named-stage boundary any multi-step driver can emit, flowing through the same 'agent'
|
|
43
|
+
// channel as tool_use/tool_result.
|
|
44
|
+
case 'stage_start':
|
|
45
|
+
return {
|
|
46
|
+
...base,
|
|
47
|
+
kind: 'run.lifecycle',
|
|
48
|
+
status: 'pipeline_stage_started',
|
|
49
|
+
stageId: payload.stageId,
|
|
50
|
+
...(payload.iteration !== undefined ? { iteration: payload.iteration } : {}),
|
|
51
|
+
};
|
|
52
|
+
case 'stage_end':
|
|
53
|
+
return {
|
|
54
|
+
...base,
|
|
55
|
+
kind: 'run.lifecycle',
|
|
56
|
+
status: 'pipeline_stage_completed',
|
|
57
|
+
stageId: payload.stageId,
|
|
58
|
+
...(payload.iteration !== undefined ? { iteration: payload.iteration } : {}),
|
|
59
|
+
};
|
|
60
|
+
// Generalization (see source-map.md): genui_surface_request/response generalized into a
|
|
61
|
+
// generic human-in-the-loop ask/answer pair.
|
|
62
|
+
case 'surface_request':
|
|
63
|
+
return { ...base, kind: 'ui.surface_requested', surfaceId: payload.surfaceId, surfaceKind: payload.surfaceKind, payload: payload.payload };
|
|
64
|
+
case 'surface_response':
|
|
65
|
+
return { ...base, kind: 'ui.surface_responded', surfaceId: payload.surfaceId, value: payload.value, respondedBy: payload.respondedBy };
|
|
66
|
+
// 'status' / 'thinking_start' / 'thinking_delta' / 'tool_input_delta' / 'usage' / 'raw':
|
|
67
|
+
// no AG-UI equivalent — silently dropped, matching the original adapter's default behavior.
|
|
68
|
+
default:
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function encode(event, ctx) {
|
|
73
|
+
switch (event.kind) {
|
|
74
|
+
case 'start':
|
|
75
|
+
return { ...baseFields(ctx), kind: 'run.lifecycle', status: 'started' };
|
|
76
|
+
case 'end': {
|
|
77
|
+
const status = event.payload.status === 'failed' ? 'failed' : event.payload.status === 'canceled' ? 'cancelled' : 'completed';
|
|
78
|
+
// A run can legitimately end while a tool_use is still in flight (its tool_result never
|
|
79
|
+
// arrived, or arrived after 'end' and was already rejected by RunLifecycle — see
|
|
80
|
+
// run-lifecycle.ts's "cannot emit on terminal run" guard). Clearing here means any such
|
|
81
|
+
// stale entries never leak past this run's own lifetime, and a same-id tool_result that
|
|
82
|
+
// somehow still reaches this encoder afterward correctly falls back to 'unknown' rather
|
|
83
|
+
// than resolving against a call from a run that has already ended.
|
|
84
|
+
pendingToolCalls.clear();
|
|
85
|
+
return { ...baseFields(ctx), kind: 'run.lifecycle', status };
|
|
86
|
+
}
|
|
87
|
+
case 'agent':
|
|
88
|
+
return encodeAgentPayload(event.payload, ctx);
|
|
89
|
+
// 'stdout' / 'stderr' / 'error': no AG-UI equivalent — silently dropped, matching the
|
|
90
|
+
// original adapter's default behavior for unrecognized event kinds.
|
|
91
|
+
default:
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { encode };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/agui/encoder.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agui/events
|
|
3
|
+
*
|
|
4
|
+
* The AG-UI wire event shapes `./encoder.ts` produces. AG-UI (Agent-User Interaction
|
|
5
|
+
* Protocol) is CopilotKit's open, external wire protocol for streaming an agent's run over SSE to
|
|
6
|
+
* a UI client — see https://github.com/ag-ui-protocol/ag-ui. This module is a near-verbatim port
|
|
7
|
+
* of a 312-line adapter that encoded a product's own run-event stream into this shape; the types
|
|
8
|
+
* themselves are unchanged in kind, only de-branded (see `source-map.md` for the full
|
|
9
|
+
* field-mapping table and provenance).
|
|
10
|
+
*
|
|
11
|
+
* Folded in 2026-07-26 from the standalone `@jini/agui` package (plan §3a) into this `src/agui/`
|
|
12
|
+
* subdirectory — see `./encoder.ts` for why it is kept apart from the flat `ag-ui.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export type AGUIEventKind = 'agent.message' | 'tool_call' | 'state_update' | 'ui.surface_requested' | 'ui.surface_responded' | 'run.lifecycle';
|
|
15
|
+
export interface AGUIEventBase {
|
|
16
|
+
kind: AGUIEventKind;
|
|
17
|
+
runId: string;
|
|
18
|
+
seq?: number;
|
|
19
|
+
ts: number;
|
|
20
|
+
}
|
|
21
|
+
export interface AGUIAgentMessageEvent extends AGUIEventBase {
|
|
22
|
+
kind: 'agent.message';
|
|
23
|
+
text: string;
|
|
24
|
+
done?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface AGUIToolCallEvent extends AGUIEventBase {
|
|
27
|
+
kind: 'tool_call';
|
|
28
|
+
toolName: string;
|
|
29
|
+
args: unknown;
|
|
30
|
+
callId?: string;
|
|
31
|
+
status?: 'started' | 'completed' | 'failed';
|
|
32
|
+
result?: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface AGUIStateUpdateEvent extends AGUIEventBase {
|
|
35
|
+
kind: 'state_update';
|
|
36
|
+
path: string;
|
|
37
|
+
value: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface AGUISurfaceRequestedEvent extends AGUIEventBase {
|
|
40
|
+
kind: 'ui.surface_requested';
|
|
41
|
+
surfaceId: string;
|
|
42
|
+
surfaceKind: 'form' | 'choice' | 'confirmation' | 'oauth-prompt';
|
|
43
|
+
payload: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface AGUISurfaceRespondedEvent extends AGUIEventBase {
|
|
46
|
+
kind: 'ui.surface_responded';
|
|
47
|
+
surfaceId: string;
|
|
48
|
+
value: unknown;
|
|
49
|
+
respondedBy: 'user' | 'agent' | 'auto' | 'cache';
|
|
50
|
+
}
|
|
51
|
+
export interface AGUIRunLifecycleEvent extends AGUIEventBase {
|
|
52
|
+
kind: 'run.lifecycle';
|
|
53
|
+
status: 'started' | 'pipeline_stage_started' | 'pipeline_stage_completed' | 'completed' | 'cancelled' | 'failed';
|
|
54
|
+
stageId?: string;
|
|
55
|
+
iteration?: number;
|
|
56
|
+
message?: string;
|
|
57
|
+
}
|
|
58
|
+
export type AGUIEvent = AGUIAgentMessageEvent | AGUIToolCallEvent | AGUIStateUpdateEvent | AGUISurfaceRequestedEvent | AGUISurfaceRespondedEvent | AGUIRunLifecycleEvent;
|
|
59
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/agui/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,WAAW,GACX,cAAc,GACd,sBAAsB,GACtB,sBAAsB,GACtB,eAAe,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC9D,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;IACjE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC9D,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,SAAS,GAAG,wBAAwB,GAAG,0BAA0B,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;IACjH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GACjB,qBAAqB,GACrB,iBAAiB,GACjB,oBAAoB,GACpB,yBAAyB,GACzB,yBAAyB,GACzB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module agui/events
|
|
3
|
+
*
|
|
4
|
+
* The AG-UI wire event shapes `./encoder.ts` produces. AG-UI (Agent-User Interaction
|
|
5
|
+
* Protocol) is CopilotKit's open, external wire protocol for streaming an agent's run over SSE to
|
|
6
|
+
* a UI client — see https://github.com/ag-ui-protocol/ag-ui. This module is a near-verbatim port
|
|
7
|
+
* of a 312-line adapter that encoded a product's own run-event stream into this shape; the types
|
|
8
|
+
* themselves are unchanged in kind, only de-branded (see `source-map.md` for the full
|
|
9
|
+
* field-mapping table and provenance).
|
|
10
|
+
*
|
|
11
|
+
* Folded in 2026-07-26 from the standalone `@jini/agui` package (plan §3a) into this `src/agui/`
|
|
12
|
+
* subdirectory — see `./encoder.ts` for why it is kept apart from the flat `ag-ui.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/agui/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|