@nxisai/agent-harness 0.7.0 → 0.9.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/README.md +17 -5
- package/dist/a2ui/cards.d.ts +3 -0
- package/dist/a2ui/cards.d.ts.map +1 -1
- package/dist/a2ui/cards.js +11 -2
- package/dist/a2ui/cards.js.map +1 -1
- package/dist/harness/cta.d.ts +27 -0
- package/dist/harness/cta.d.ts.map +1 -0
- package/dist/harness/cta.js +43 -0
- package/dist/harness/cta.js.map +1 -0
- package/dist/harness/harness.d.ts +33 -0
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/harness.js +84 -2
- package/dist/harness/harness.js.map +1 -1
- package/dist/harness/recommend.d.ts +46 -0
- package/dist/harness/recommend.d.ts.map +1 -0
- package/dist/harness/recommend.js +144 -0
- package/dist/harness/recommend.js.map +1 -0
- package/dist/harness/records.d.ts +70 -0
- package/dist/harness/records.d.ts.map +1 -0
- package/dist/harness/records.js +209 -0
- package/dist/harness/records.js.map +1 -0
- package/dist/harness/renderer.d.ts +11 -1
- package/dist/harness/renderer.d.ts.map +1 -1
- package/dist/harness/router/coordinator.d.ts +6 -0
- package/dist/harness/router/coordinator.d.ts.map +1 -1
- package/dist/harness/router/coordinator.js +14 -0
- package/dist/harness/router/coordinator.js.map +1 -1
- package/dist/harness/tools/action-tools.d.ts +25 -0
- package/dist/harness/tools/action-tools.d.ts.map +1 -1
- package/dist/harness/tools/action-tools.js +39 -0
- package/dist/harness/tools/action-tools.js.map +1 -1
- package/dist/harness/tools/inbound.d.ts +88 -0
- package/dist/harness/tools/inbound.d.ts.map +1 -0
- package/dist/harness/tools/inbound.js +156 -0
- package/dist/harness/tools/inbound.js.map +1 -0
- package/dist/harness/tools/site-pages.js +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/ui/agent-fullscreen.d.ts.map +1 -1
- package/dist/ui/agent-fullscreen.js +154 -76
- package/dist/ui/agent-fullscreen.js.map +1 -1
- package/dist/ui/result-pick.d.ts +52 -0
- package/dist/ui/result-pick.d.ts.map +1 -0
- package/dist/ui/result-pick.js +196 -0
- package/dist/ui/result-pick.js.map +1 -0
- package/package.json +1 -1
- package/src/a2ui/cards.ts +14 -2
- package/src/harness/cta.ts +54 -0
- package/src/harness/harness.ts +93 -2
- package/src/harness/recommend.ts +194 -0
- package/src/harness/records.ts +237 -0
- package/src/harness/renderer.ts +12 -1
- package/src/harness/router/coordinator.ts +14 -0
- package/src/harness/tools/action-tools.ts +41 -0
- package/src/harness/tools/inbound.ts +189 -0
- package/src/harness/tools/site-pages.ts +1 -1
- package/src/index.ts +16 -0
- package/src/ui/agent-fullscreen.ts +162 -66
- package/src/ui/result-pick.ts +233 -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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
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 [yyyy] [name of copyright owner]
|
|
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/README.md
CHANGED
|
@@ -222,7 +222,7 @@ Both flags go false at a specialist handoff, which swaps the system prompt and t
|
|
|
222
222
|
| `mode` | `fullscreen` (default), `window`, `inline` | Cover the page; dock in the corner at `--window-w` × `--window-h` (400 × 620); or fill the box the host puts it in and stay open — for a copilot rail the host lays out. Below 520px a window covers the page anyway. |
|
|
223
223
|
| `discover` | `"false"` | Skip remote MCP discovery. |
|
|
224
224
|
| `site-actions` | `"false"` | Don't fetch the actions on other pages of the site. |
|
|
225
|
-
| `prompt-style` | `"classic"` | Use the separate ask, "Ready to send" and "Submitted" cards of earlier versions instead of the action card. |
|
|
225
|
+
| `prompt-style` | `"classic"` | Use the separate ask, "Ready to send" and "Submitted" cards, and the per-record result cards, of earlier versions instead of the action card and the recommended pick. |
|
|
226
226
|
| `cache` | `"false"` | Do not store model files in Cache Storage. |
|
|
227
227
|
| `model-host` | URL | Fetch weights from another origin. |
|
|
228
228
|
| `model-path-template` | string | Path template under `model-host`. |
|
|
@@ -283,11 +283,23 @@ Given the tool the model picked and everything already known, the harness asks w
|
|
|
283
283
|
|
|
284
284
|
| Tool | Gaps | Result |
|
|
285
285
|
|---|---|---|
|
|
286
|
-
| read (`readOnlyHint`) | none | runs
|
|
286
|
+
| read (`readOnlyHint`) | none | runs; several records end with a recommended pick |
|
|
287
287
|
| read | some | asks only for those, then runs |
|
|
288
288
|
| write | none | action card: what will be sent, and Send |
|
|
289
289
|
| write | some | action card: what it has, the fields still needed, then Send |
|
|
290
290
|
|
|
291
|
+
### Search results: a pick, and why
|
|
292
|
+
|
|
293
|
+
When a search returns two or more records, the harness asks the model one more question: which of these fits what the visitor asked, and why. The model answers through a `recommend` call (the result's number, one sentence naming it, two or three reasons). Then every reason is checked against the record it picked:
|
|
294
|
+
|
|
295
|
+
- every number in it must be one the record states ("4.7", "412", "40 minutes");
|
|
296
|
+
- "open now" and "24/7" must match the record's opening hours, read at the time of the search;
|
|
297
|
+
- it must share a meaningful word with the record, and not be about another result.
|
|
298
|
+
|
|
299
|
+
Reasons that fail are dropped. If none survive, there is no pick. The widget shows the pick with its reasons ticked, a Call button, "Their page", and "Get a quote" when the site has a form for that business. Under it, "Also good · tap to compare" lists the others. Comparing one shows its own facts without ticks, because the agent did not recommend it. With no pick, the results are a short list that opens per result.
|
|
300
|
+
|
|
301
|
+
Each record's hours become "Open now · 24/7", "Open now · until 5pm" or "Opens 7am" (`openingHoursSpecification` or `openingHours`). `recommend: false` skips the extra completion; `prompt-style="classic"` keeps the earlier result cards. `extractRecords`, `recordFacts`, `openStatus`, `recommend` and `grounded` are exported for hosts that render results themselves.
|
|
302
|
+
|
|
291
303
|
### The action card
|
|
292
304
|
|
|
293
305
|
A write, and a handoff to an agent or a person, is one message in the conversation rather than a series of cards. The card names who it goes to (the business the form belongs to, or the team or agent and whether they are available now), then moves through:
|
|
@@ -381,7 +393,7 @@ provider.loading: boolean
|
|
|
381
393
|
### `AgentHarness`
|
|
382
394
|
|
|
383
395
|
```ts
|
|
384
|
-
new AgentHarness({ renderer, provider?, toolSource?, systemPrompt?, tools?, maxSiteTools?, name?, unavailable?, profile?, context?, groupRelated?, onMessages? })
|
|
396
|
+
new AgentHarness({ renderer, provider?, toolSource?, systemPrompt?, tools?, maxSiteTools?, name?, unavailable?, profile?, context?, groupRelated?, recommend?, now?, onMessages? })
|
|
385
397
|
harness.turn(goal, messages): Promise<TurnResult>
|
|
386
398
|
harness.owns(toolName): boolean
|
|
387
399
|
harness.stop(): void // abandon the request in flight
|
|
@@ -402,7 +414,7 @@ interface HarnessRenderer {
|
|
|
402
414
|
status(text, isError?): void;
|
|
403
415
|
ask(req: AskRequest): void;
|
|
404
416
|
confirm(req: ConfirmRequest): void;
|
|
405
|
-
results(tool, res): void;
|
|
417
|
+
results(tool, res, extra?): void; // extra.pick: the recommended record and its reasons
|
|
406
418
|
detail(tool, values, text): void;
|
|
407
419
|
toolError(tool, message): void;
|
|
408
420
|
trace?(entry: TraceEntry): void; // { tool, args, text, isError, count? }
|
|
@@ -606,7 +618,7 @@ That offers two tools, `transfer_to_agent` and `talk_to_a_person`, listing only
|
|
|
606
618
|
|
|
607
619
|
Headless, `HandoffController` runs the same handoffs and reports them as `handoff` events; `registerHandoffTools` offers the tools; `AgentCoordinator`'s `handoff` option routes a handed-off conversation's turns to its target.
|
|
608
620
|
|
|
609
|
-
[docs/handoff.md](docs/handoff.md) is the contract: the relay's endpoints, the handoff extension (`https://nxis.ai/a2a/handoff/v1`: the envelope, queue, operator and hand-back parts), the lifecycle, what makes a good target, and the adapter contract for putting a help desk behind A2A.
|
|
621
|
+
[docs/handoff.md](docs/handoff.md) is the contract: the relay's endpoints, the handoff extension (`https://nxis.ai/a2a/handoff/v1`: the envelope, queue, operator and hand-back parts), the lifecycle, what makes a good target, and the adapter contract for putting a help desk behind A2A.
|
|
610
622
|
|
|
611
623
|
## Requirements
|
|
612
624
|
|
package/dist/a2ui/cards.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* rendering and none is needed.
|
|
12
12
|
*/
|
|
13
13
|
import type { A2uiMessage } from './emit.js';
|
|
14
|
+
import { type CardAction } from '../harness/cta.js';
|
|
14
15
|
/** One label and value line on a result card. */
|
|
15
16
|
export interface CardRow {
|
|
16
17
|
label: string;
|
|
@@ -26,6 +27,8 @@ export interface ResultCardData {
|
|
|
26
27
|
sub: string;
|
|
27
28
|
tags: CardTag[];
|
|
28
29
|
rows: CardRow[];
|
|
30
|
+
/** The record's own action, as at most one button. A list so a card without one draws nothing. */
|
|
31
|
+
actions: CardAction[];
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Normalise one schema.org entity into flat card data.
|
package/dist/a2ui/cards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/a2ui/cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/a2ui/cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/D,iDAAiD;AACjD,MAAM,WAAW,OAAO;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACzD,2CAA2C;AAC3C,MAAM,WAAW,OAAO;IAAG,KAAK,EAAE,MAAM,CAAA;CAAE;AAC1C,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,kGAAkG;IAClG,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAQD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAoD1E;AAyCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EAAE,EACzB,SAAS,SAAY,GACpB,WAAW,EAAE,CASf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,SAAS,SAAY,GACpB,WAAW,EAAE,CAMf;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChE,WAAW,CAKb"}
|
package/dist/a2ui/cards.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* with no rating simply has fewer entries. The basic catalog has no conditional
|
|
11
11
|
* rendering and none is needed.
|
|
12
12
|
*/
|
|
13
|
+
import { actionCta } from '../harness/cta.js';
|
|
13
14
|
const CATALOG = 'https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json';
|
|
14
15
|
const str = (v) => (v == null ? '' : String(Array.isArray(v) ? v[0] : v));
|
|
15
16
|
const humanize = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ')
|
|
@@ -66,7 +67,8 @@ export function toCardData(entity) {
|
|
|
66
67
|
push(humanize(key === 'url' ? 'website' : key), v);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
const action = actionCta(entity, title);
|
|
71
|
+
return { title, sub, tags, rows, actions: action ? [action] : [] };
|
|
70
72
|
}
|
|
71
73
|
/** Fixed component set — independent of how many results there are. */
|
|
72
74
|
function cardComponents(heading) {
|
|
@@ -77,7 +79,7 @@ function cardComponents(heading) {
|
|
|
77
79
|
{ id: 'results', component: 'List',
|
|
78
80
|
children: { path: '/results', componentId: 'card_tpl' }, direction: 'vertical' },
|
|
79
81
|
{ id: 'card_tpl', component: 'Card', child: 'card_body' },
|
|
80
|
-
{ id: 'card_body', component: 'Column', children: ['card_title', 'card_tags', 'card_sub', 'card_rows'] },
|
|
82
|
+
{ id: 'card_body', component: 'Column', children: ['card_title', 'card_tags', 'card_sub', 'card_rows', 'card_actions'] },
|
|
81
83
|
// No bold: `weight` in this catalog is a flex weight (number), and Text
|
|
82
84
|
// offers only variant caption/body. Title emphasis is not expressible in
|
|
83
85
|
// the basic catalog: it needs a custom catalog or renderer styling.
|
|
@@ -92,6 +94,13 @@ function cardComponents(heading) {
|
|
|
92
94
|
{ id: 'row_tpl', component: 'Row', children: ['row_label', 'row_value'] },
|
|
93
95
|
{ id: 'row_label', component: 'Text', text: '${label}', variant: 'caption' },
|
|
94
96
|
{ id: 'row_value', component: 'Text', text: '${value}', variant: 'caption' },
|
|
97
|
+
// The record's action: zero or one per card, so a card without one draws nothing. Pressing it
|
|
98
|
+
// dispatches nxis.ask with the message to send as the visitor; it never submits anything itself.
|
|
99
|
+
{ id: 'card_actions', component: 'List',
|
|
100
|
+
children: { path: 'actions', componentId: 'action_tpl' }, direction: 'horizontal' },
|
|
101
|
+
{ id: 'action_tpl', component: 'Button', child: 'action_label', variant: 'primary',
|
|
102
|
+
action: { event: { name: 'nxis.ask', context: { message: '${message}' } } } },
|
|
103
|
+
{ id: 'action_label', component: 'Text', text: '${label}', variant: 'body' },
|
|
95
104
|
];
|
|
96
105
|
}
|
|
97
106
|
/**
|
package/dist/a2ui/cards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/a2ui/cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/a2ui/cards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,SAAS,EAAmB,MAAM,mBAAmB,CAAC;AAE/D,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAkBlF,MAAM,GAAG,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3F,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAU,EAAE,CACrC,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC7D,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,MAA+B;IACxD,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAc,EAAE,CAAC;IAE3B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,OAAO;QAAE,IAAI,CAAC,IAAI,C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CAAC,CAAC;AACvD,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EAAE,KAAa,EAAE,MAA+B;IAEjE,OAAO;QACL,OAAO,EAAE,MAAM;QACf,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE;KACrF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The action a result card offers, chosen from the record's own `potentialAction`.
|
|
3
|
+
*
|
|
4
|
+
* One map, shared with the Typed Retrieval skill (nxis-skills) and the NxisAI app's widgets (nxis-mcp
|
|
5
|
+
* `HubWidgets`): the action's `@type` alone decides the button, and the button sends the same prompt
|
|
6
|
+
* everywhere ("Get a quote from Hatzel & Sons Plumbing"), so the funnel cannot tell which surface it came
|
|
7
|
+
* from. Commerce, read and search actions get no button here.
|
|
8
|
+
*
|
|
9
|
+
* On the site's own page every mapped action sends the prompt, a self-page form included: the on-page agent
|
|
10
|
+
* is what runs that form. Only the NxisAI app, which cannot reach the page, opens it instead.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/** What a card's action button says and sends. */
|
|
15
|
+
export interface CardAction {
|
|
16
|
+
label: string;
|
|
17
|
+
/** The message sent as the visitor when the button is pressed. */
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The button for a record, or none.
|
|
22
|
+
*
|
|
23
|
+
* @param record - The record as a tool returned it; action `@type`s may be full IRIs.
|
|
24
|
+
* @param name - What to call it in the message; the record's own name by default.
|
|
25
|
+
*/
|
|
26
|
+
export declare function actionCta(record: Record<string, unknown>, name?: string): CardAction | undefined;
|
|
27
|
+
//# sourceMappingURL=cta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cta.d.ts","sourceRoot":"","sources":["../../src/harness/cta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB;AAkBD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAUhG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The action a result card offers, chosen from the record's own `potentialAction`.
|
|
3
|
+
*
|
|
4
|
+
* One map, shared with the Typed Retrieval skill (nxis-skills) and the NxisAI app's widgets (nxis-mcp
|
|
5
|
+
* `HubWidgets`): the action's `@type` alone decides the button, and the button sends the same prompt
|
|
6
|
+
* everywhere ("Get a quote from Hatzel & Sons Plumbing"), so the funnel cannot tell which surface it came
|
|
7
|
+
* from. Commerce, read and search actions get no button here.
|
|
8
|
+
*
|
|
9
|
+
* On the site's own page every mapped action sends the prompt, a self-page form included: the on-page agent
|
|
10
|
+
* is what runs that form. Only the NxisAI app, which cannot reach the page, opens it instead.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
const MAP = {
|
|
15
|
+
QuoteAction: { label: 'Get a quote', message: (n) => `Get a quote from ${n}` },
|
|
16
|
+
AskAction: { label: 'Contact', message: (n) => `Contact ${n}` },
|
|
17
|
+
ReserveAction: { label: 'Reserve', message: (n) => `Reserve at ${n}` },
|
|
18
|
+
ScheduleAction: { label: 'Book an appointment', message: (n) => `Book an appointment at ${n}` },
|
|
19
|
+
ApplyAction: { label: 'Apply', message: (n) => `Apply to ${n}` },
|
|
20
|
+
};
|
|
21
|
+
/** When a record carries several, the first of these wins. */
|
|
22
|
+
const ORDER = Object.keys(MAP);
|
|
23
|
+
const shortType = (t) => typeof t === 'string' ? t.replace(/^https?:\/\/schema\.org\//, '') : '';
|
|
24
|
+
const list = (v) => (v == null ? [] : Array.isArray(v) ? v : [v]);
|
|
25
|
+
/**
|
|
26
|
+
* The button for a record, or none.
|
|
27
|
+
*
|
|
28
|
+
* @param record - The record as a tool returned it; action `@type`s may be full IRIs.
|
|
29
|
+
* @param name - What to call it in the message; the record's own name by default.
|
|
30
|
+
*/
|
|
31
|
+
export function actionCta(record, name) {
|
|
32
|
+
const types = list(record.potentialAction)
|
|
33
|
+
.filter((a) => !!a && typeof a === 'object')
|
|
34
|
+
.flatMap((a) => list(a['@type']).map(shortType))
|
|
35
|
+
.filter((t) => t in MAP)
|
|
36
|
+
.sort((a, b) => ORDER.indexOf(a) - ORDER.indexOf(b));
|
|
37
|
+
if (!types.length)
|
|
38
|
+
return undefined;
|
|
39
|
+
const who = (name ?? (typeof record.name === 'string' ? record.name : '')).trim() || 'them';
|
|
40
|
+
const entry = MAP[types[0]];
|
|
41
|
+
return { label: entry.label, message: entry.message(who) };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cta.js","sourceRoot":"","sources":["../../src/harness/cta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH,MAAM,GAAG,GAAyE;IAChF,WAAW,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,EAAE;IAC9E,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE;IAC/D,aAAa,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE;IACtE,cAAc,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,OAAO,EA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AC,CAAC,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC;IAC5F,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -89,6 +89,15 @@ export interface HarnessOptions {
|
|
|
89
89
|
* Defaults to true. Pass false to ask one question at a time.
|
|
90
90
|
*/
|
|
91
91
|
groupRelated?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Whether a search that finds several records ends with a recommendation:
|
|
94
|
+
* the model picks one and gives reasons, and only reasons the record backs
|
|
95
|
+
* are kept (see `recommend`). Defaults to true. Costs one more completion
|
|
96
|
+
* per search.
|
|
97
|
+
*/
|
|
98
|
+
recommend?: boolean;
|
|
99
|
+
/** The clock "open now" is judged by. For tests. */
|
|
100
|
+
now?: () => Date;
|
|
92
101
|
/** Called whenever the conversation changes, for hosts that persist it. */
|
|
93
102
|
onMessages?(messages: ChatMessage[]): void;
|
|
94
103
|
}
|
|
@@ -196,6 +205,8 @@ export declare class AgentHarness {
|
|
|
196
205
|
/** The previous request's system prompt and tool names, for the cache hint. */
|
|
197
206
|
private lastPrompt;
|
|
198
207
|
private lastTools;
|
|
208
|
+
/** What the visitor asked this turn, for a recommendation to answer. */
|
|
209
|
+
private goal;
|
|
199
210
|
constructor(opts: HarnessOptions);
|
|
200
211
|
/**
|
|
201
212
|
* End a turn that the user stopped.
|
|
@@ -254,6 +265,23 @@ export declare class AgentHarness {
|
|
|
254
265
|
* generation fails for a reason other than being aborted.
|
|
255
266
|
*/
|
|
256
267
|
turn(goal: string, messages: ChatMessage[]): Promise<TurnResult>;
|
|
268
|
+
/**
|
|
269
|
+
* Run a turn whose tool call is already decided, without asking the model.
|
|
270
|
+
*
|
|
271
|
+
* For a request that names its own action, such as a link from the NxisAI
|
|
272
|
+
* app to one business's quote form: the tool and the business are known, so
|
|
273
|
+
* the model has nothing to choose, and a model left to choose sometimes
|
|
274
|
+
* asks for the details in prose instead of opening the form. What follows
|
|
275
|
+
* the call is an ordinary turn's: the same slots, prompts and confirmation,
|
|
276
|
+
* and the call goes into the transcript as if the model had made it.
|
|
277
|
+
*
|
|
278
|
+
* @param goal - The request as the person would have said it, for the thread and transcript.
|
|
279
|
+
* @param name - The tool to call.
|
|
280
|
+
* @param args - Its arguments, e.g. which business.
|
|
281
|
+
* @param messages - The live conversation, appended to in place.
|
|
282
|
+
* @returns The decision taken, or `'unavailable'` when this agent has no such tool.
|
|
283
|
+
*/
|
|
284
|
+
begin(goal: string, name: string, args: Record<string, unknown>, messages: ChatMessage[]): Promise<TurnResult>;
|
|
257
285
|
/**
|
|
258
286
|
* Narrow the page's tools to this agent's slice.
|
|
259
287
|
*
|
|
@@ -331,6 +359,11 @@ export declare class AgentHarness {
|
|
|
331
359
|
* renderer as well saves a renderer from subscribing to anything.
|
|
332
360
|
*/
|
|
333
361
|
private emitStep;
|
|
362
|
+
/**
|
|
363
|
+
* The record to recommend from a search's results, when there are several
|
|
364
|
+
* to choose between and the model can say why from what they state.
|
|
365
|
+
*/
|
|
366
|
+
private pickFrom;
|
|
334
367
|
/** Discard a live prompt and the values typed into it. */
|
|
335
368
|
private cancel;
|
|
336
369
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.d.ts","sourceRoot":"","sources":["../../src/harness/harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAE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