@nxisai/agent-harness 0.2.4 → 0.3.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/README.md +89 -2
- package/dist/a2ui/stepper.d.ts +1 -1
- package/dist/a2ui/stepper.d.ts.map +1 -1
- package/dist/a2ui/stepper.js +2 -2
- package/dist/a2ui/stepper.js.map +1 -1
- package/dist/engine.d.ts +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +1 -0
- package/dist/engine.js.map +1 -1
- package/dist/harness/harness.d.ts +38 -0
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/harness.js +127 -4
- package/dist/harness/harness.js.map +1 -1
- package/dist/harness/renderer.d.ts +30 -0
- package/dist/harness/renderer.d.ts.map +1 -1
- package/dist/harness/steps.d.ts +101 -0
- package/dist/harness/steps.d.ts.map +1 -0
- package/dist/harness/steps.js +102 -0
- package/dist/harness/steps.js.map +1 -0
- package/dist/harness/tools/action-tools.d.ts +213 -0
- package/dist/harness/tools/action-tools.d.ts.map +1 -0
- package/dist/harness/tools/action-tools.js +724 -0
- package/dist/harness/tools/action-tools.js.map +1 -0
- package/dist/harness/tools/bridge.d.ts.map +1 -1
- package/dist/harness/tools/bridge.js +28 -2
- package/dist/harness/tools/bridge.js.map +1 -1
- package/dist/harness/tools/pending-action.d.ts +55 -0
- package/dist/harness/tools/pending-action.d.ts.map +1 -0
- package/dist/harness/tools/pending-action.js +93 -0
- package/dist/harness/tools/pending-action.js.map +1 -0
- package/dist/harness/tools/resume.d.ts +92 -0
- package/dist/harness/tools/resume.d.ts.map +1 -0
- package/dist/harness/tools/resume.js +84 -0
- package/dist/harness/tools/resume.js.map +1 -0
- package/dist/harness/tools/schema.js +29 -2
- package/dist/harness/tools/schema.js.map +1 -1
- package/dist/harness/tools/site-actions.d.ts +69 -0
- package/dist/harness/tools/site-actions.d.ts.map +1 -0
- package/dist/harness/tools/site-actions.js +310 -0
- package/dist/harness/tools/site-actions.js.map +1 -0
- package/dist/harness/tools/source.d.ts +40 -3
- package/dist/harness/tools/source.d.ts.map +1 -1
- package/dist/harness/tools/source.js +54 -7
- package/dist/harness/tools/source.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/proxy.d.ts +5 -0
- package/dist/providers/proxy.d.ts.map +1 -1
- package/dist/providers/proxy.js +16 -1
- package/dist/providers/proxy.js.map +1 -1
- package/dist/providers/types.d.ts +15 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/types.d.ts +7 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/agent-fullscreen.d.ts.map +1 -1
- package/dist/ui/agent-fullscreen.js +766 -35
- package/dist/ui/agent-fullscreen.js.map +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/journey.d.ts +33 -0
- package/dist/ui/journey.d.ts.map +1 -0
- package/dist/ui/journey.js +27 -0
- package/dist/ui/journey.js.map +1 -0
- package/dist/ui/tailwind.generated.d.ts +1 -1
- package/dist/ui/tailwind.generated.d.ts.map +1 -1
- package/dist/ui/tailwind.generated.js +1 -1
- package/dist/ui/tailwind.generated.js.map +1 -1
- package/dist/webmcp-contract.d.ts +6 -2
- package/dist/webmcp-contract.d.ts.map +1 -1
- package/docs/remote-providers.md +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { ModelContext, ModelContextTool, ModelContextToolInfo } from '../../types.js';
|
|
2
|
+
import type { NxisAction } from '../../webmcp-contract.js';
|
|
3
|
+
/** Marks a tool this module registered. */
|
|
4
|
+
export declare const SITE_ACTION_HINT = "ai.nxis/siteAction";
|
|
5
|
+
/** The `@id`s a site tool covers. */
|
|
6
|
+
export declare const ACTION_IDS_HINT = "ai.nxis/actionIds";
|
|
7
|
+
/** The pages those actions live on. */
|
|
8
|
+
export declare const PAGE_URLS_HINT = "ai.nxis/pageUrls";
|
|
9
|
+
/** What the page's own script names the same actions. */
|
|
10
|
+
export declare const PAGE_TOOL_NAMES_HINT = "ai.nxis/pageToolNames";
|
|
11
|
+
/**
|
|
12
|
+
* Marks a response that started a page change instead of submitting.
|
|
13
|
+
*
|
|
14
|
+
* Carried in `structuredContent`, where a renderer can find it without
|
|
15
|
+
* parsing prose.
|
|
16
|
+
*/
|
|
17
|
+
export declare const HANDOFF_RESULT = "ai.nxis/handoff";
|
|
18
|
+
/** The field whose value says which of the covered actions a call means. */
|
|
19
|
+
export declare const CHOOSER_HINT = "ai.nxis/chooser";
|
|
20
|
+
/** That field's values, one per covered action, in the same order. */
|
|
21
|
+
export declare const CHOICES_HINT = "ai.nxis/choices";
|
|
22
|
+
/** The `@id` of the action a page tool came from, where the page records it. */
|
|
23
|
+
export declare const ACTION_ID_HINT = "ai.nxis/actionId";
|
|
24
|
+
/** One tool: the actions it covers, and how the caller picks between them. */
|
|
25
|
+
export interface SiteActionTool {
|
|
26
|
+
/** The registered tool name. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** The actions this tool can run, in a stable order. */
|
|
29
|
+
actions: NxisAction[];
|
|
30
|
+
/**
|
|
31
|
+
* The field that says which action to run.
|
|
32
|
+
*
|
|
33
|
+
* A real field of the form when one tells the actions apart, otherwise the
|
|
34
|
+
* added `target` field. Absent when the tool covers a single action.
|
|
35
|
+
*/
|
|
36
|
+
discriminator?: string;
|
|
37
|
+
/** The value of {@link discriminator} for each action, in the same order. */
|
|
38
|
+
choices?: string[];
|
|
39
|
+
/** The tool as registered. */
|
|
40
|
+
definition: ModelContextTool;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An action name as a tool name.
|
|
44
|
+
*
|
|
45
|
+
* Mirrors the page script's own sanitiser, so the two agree on what a given
|
|
46
|
+
* action is called.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeToolName(name: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* The name a site-wide tool is registered under.
|
|
51
|
+
*
|
|
52
|
+
* The stem is the action's own name, so the model still reads what the form is
|
|
53
|
+
* called and matches it to what the visitor asked for; the suffix says this is
|
|
54
|
+
* the one that reaches the form from any page, and keeps it clear of the
|
|
55
|
+
* page's own tool of the same name.
|
|
56
|
+
*
|
|
57
|
+
* @param actionName - The action's name, as the record gives it.
|
|
58
|
+
* @returns The tool name, within the length a registry accepts.
|
|
59
|
+
*/
|
|
60
|
+
export declare function siteToolName(actionName: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* A tool's name without the site-wide suffix, for showing to a person.
|
|
63
|
+
*
|
|
64
|
+
* `quote_form_anywhere` exists to be told apart from the page's `quote_form`
|
|
65
|
+
* in a registry; to the visitor both are the quote form.
|
|
66
|
+
*/
|
|
67
|
+
export declare function withoutSiteSuffix(toolName: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Which field distinguishes the members of a group.
|
|
70
|
+
*
|
|
71
|
+
* The crawler records what a form already says about itself: on a per-business
|
|
72
|
+
* quote form, the `business` field carries that business's name as its default.
|
|
73
|
+
* A field every member fills with a different value is therefore the site's own
|
|
74
|
+
* way of naming the target, and is used in preference to anything invented.
|
|
75
|
+
*
|
|
76
|
+
* @param actions - The group's actions, in order.
|
|
77
|
+
* @returns The field name and each action's value, or null when no field
|
|
78
|
+
* separates them.
|
|
79
|
+
*/
|
|
80
|
+
export declare function findDiscriminator(actions: NxisAction[]): {
|
|
81
|
+
field: string;
|
|
82
|
+
values: string[];
|
|
83
|
+
} | null;
|
|
84
|
+
/** Where the agent currently is, so a tool can default to this page's action. */
|
|
85
|
+
export interface BuildOptions {
|
|
86
|
+
/** The current page URL. Defaults to the browser's. */
|
|
87
|
+
href?: string;
|
|
88
|
+
/** Where a confirmed call waits while the browser moves. Defaults to `sessionStorage`. */
|
|
89
|
+
storage?: Storage | null;
|
|
90
|
+
/** How to go to another page. Defaults to assigning `location`. */
|
|
91
|
+
navigate?: (url: string) => void;
|
|
92
|
+
/** The conversation a travelling call should report back to. */
|
|
93
|
+
conversationId?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Group the site's actions and build one tool definition for each group.
|
|
97
|
+
*
|
|
98
|
+
* Names are derived from the whole set rather than the order actions arrive
|
|
99
|
+
* in, so a tool is called the same thing on every page of the site.
|
|
100
|
+
*
|
|
101
|
+
* @param actions - The site's actions.
|
|
102
|
+
* @param mc - The registry the tools will run against, used to find the page's
|
|
103
|
+
* own tool when the agent is already on the right page.
|
|
104
|
+
* @param opts - The current page.
|
|
105
|
+
* @returns One entry per group, ordered by tool name.
|
|
106
|
+
*/
|
|
107
|
+
export declare function buildSiteActionTools(actions: NxisAction[], mc: ModelContext, opts?: BuildOptions): SiteActionTool[];
|
|
108
|
+
/**
|
|
109
|
+
* Whether a tool is a site-wide one, reaching a form from any page.
|
|
110
|
+
*
|
|
111
|
+
* Checked against what this page built, then the tool's annotations, so it
|
|
112
|
+
* holds even where a native registry has stripped them.
|
|
113
|
+
*/
|
|
114
|
+
export declare function isSiteTool(tool: ModelContextToolInfo): boolean;
|
|
115
|
+
/** Which page tool to look for: the action's id, and the name it would have. */
|
|
116
|
+
export interface PageToolRef {
|
|
117
|
+
/** The action's `@id`. */
|
|
118
|
+
id: string;
|
|
119
|
+
/** The name the page's script derives from the action's name. */
|
|
120
|
+
name: string;
|
|
121
|
+
}
|
|
122
|
+
/** The reference for an action. */
|
|
123
|
+
export declare const pageToolRef: (action: NxisAction) => PageToolRef;
|
|
124
|
+
/** The page's own tool for an action: by recorded `@id`, else by name. */
|
|
125
|
+
export declare function findPageTool(mc: ModelContext, ref: PageToolRef): Promise<ModelContextToolInfo | null>;
|
|
126
|
+
/**
|
|
127
|
+
* Wait for the page's own tool to register.
|
|
128
|
+
*
|
|
129
|
+
* After a page change the agent is running before the page's script has read
|
|
130
|
+
* its JSON-LD, so the tool a resumed call needs does not exist yet.
|
|
131
|
+
*
|
|
132
|
+
* @param mc - The page's registry.
|
|
133
|
+
* @param ref - The tool to wait for.
|
|
134
|
+
* @param timeoutMs - How long to wait before giving up.
|
|
135
|
+
* @returns The tool, or null if it never appears.
|
|
136
|
+
*/
|
|
137
|
+
export declare function awaitPageTool(mc: ModelContext, ref: PageToolRef, timeoutMs?: number): Promise<ModelContextToolInfo | null>;
|
|
138
|
+
/** Where a call is bound for, when that is not the page the agent is on. */
|
|
139
|
+
export interface Handoff {
|
|
140
|
+
/** The action that will run. */
|
|
141
|
+
actionId: string;
|
|
142
|
+
/** The page it will run on. */
|
|
143
|
+
pageUrl: string;
|
|
144
|
+
/** What to call that destination in a sentence. */
|
|
145
|
+
label: string;
|
|
146
|
+
/** The name the page's own tool is expected to have. */
|
|
147
|
+
pageToolName: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Where a call to a site tool will have to go, if not here.
|
|
151
|
+
*
|
|
152
|
+
* Needs nothing but the tool, so a caller holding only what the registry
|
|
153
|
+
* reported — the harness, labelling a confirmation — can tell that pressing
|
|
154
|
+
* submit also means a page change.
|
|
155
|
+
*
|
|
156
|
+
* @param tool - The tool about to be called.
|
|
157
|
+
* @param values - The arguments resolved so far.
|
|
158
|
+
* @param href - The current page. Defaults to the browser's.
|
|
159
|
+
* @returns The destination, or null when the call runs here, when the tool is
|
|
160
|
+
* not one of these, or when the values do not yet say which action is meant.
|
|
161
|
+
*/
|
|
162
|
+
export declare function handoffFor(tool: ModelContextToolInfo, values: Record<string, unknown>, href?: string): Handoff | null;
|
|
163
|
+
/**
|
|
164
|
+
* Register a tool for each of the site's actions.
|
|
165
|
+
*
|
|
166
|
+
* @param mc - The registry to register into.
|
|
167
|
+
* @param actions - The site's actions.
|
|
168
|
+
* @param opts - The current page.
|
|
169
|
+
* @returns The names registered. A name the registry already holds is left
|
|
170
|
+
* alone, and a registration it refuses is warned about rather than thrown.
|
|
171
|
+
*/
|
|
172
|
+
export declare function registerSiteActionTools(mc: ModelContext, actions: NxisAction[], opts?: BuildOptions): Promise<string[]>;
|
|
173
|
+
/** How many site-wide tools a turn may carry, before relevance decides. */
|
|
174
|
+
export declare const DEFAULT_SITE_TOOL_LIMIT = 8;
|
|
175
|
+
/** Options for {@link selectSiteTools}. */
|
|
176
|
+
export interface SelectOptions {
|
|
177
|
+
/** How many site-wide tools to keep. Defaults to {@link DEFAULT_SITE_TOOL_LIMIT}. */
|
|
178
|
+
limit?: number;
|
|
179
|
+
/** The current page. Defaults to the browser's. */
|
|
180
|
+
href?: string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Narrow the site-wide tools to those this turn could plausibly need.
|
|
184
|
+
*
|
|
185
|
+
* Every registered tool's schema is written into every prompt, and a site
|
|
186
|
+
* with many distinct forms would fill the context with forms nobody asked
|
|
187
|
+
* about. Tools belonging to the page the agent is on are always kept — they
|
|
188
|
+
* are what "this form" means — and the rest compete on how well they answer
|
|
189
|
+
* what was asked.
|
|
190
|
+
*
|
|
191
|
+
* Only site-wide tools are ever dropped. The page's own tools and the
|
|
192
|
+
* retrieval tools are few, and losing one of those loses a capability rather
|
|
193
|
+
* than trimming a list.
|
|
194
|
+
*
|
|
195
|
+
* @param tools - The tools on offer this turn.
|
|
196
|
+
* @param goal - What the user asked for.
|
|
197
|
+
* @param opts - The budget and the current page.
|
|
198
|
+
* @returns The tools to show, in the order they arrived.
|
|
199
|
+
*/
|
|
200
|
+
export declare function selectSiteTools(tools: ModelContextToolInfo[], goal: string, opts?: SelectOptions): ModelContextToolInfo[];
|
|
201
|
+
/**
|
|
202
|
+
* Drop page tools that a site tool already covers.
|
|
203
|
+
*
|
|
204
|
+
* On the page an action belongs to, the page's script registers its own tool
|
|
205
|
+
* and the site tool delegates to it. Both in the prompt would offer the model
|
|
206
|
+
* two ways to do one thing, and the second is chosen half the time.
|
|
207
|
+
*
|
|
208
|
+
* @param tools - Every tool the registry reported.
|
|
209
|
+
* @param href - The current page. Defaults to the browser's.
|
|
210
|
+
* @returns The tools to show the model.
|
|
211
|
+
*/
|
|
212
|
+
export declare function withoutShadowedTools(tools: ModelContextToolInfo[], href?: string): ModelContextToolInfo[];
|
|
213
|
+
//# sourceMappingURL=action-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-tools.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/action-tools.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAc,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAA4B,MAAM,gBAAgB,CAAC;AACjI,OAAO,KAAK,EAAE,UAAU,EAAiD,MAAM,0BAA0B,CAAC;AAE1G,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AACrD,qCAAqC;AACrC,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,uCAAuC;AACvC,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAC5D;;;;;GAKG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,4EAA4E;AAC5E,eAAO,MAAM,YAAY,oBAAoB,CAAC;AAC9C,sEAAsE;AACtE,eAAO,MAAM,YAAY,oBAAoB,CAAC;AAC9C,gFAAgF;AAChF,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAOjD,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8BAA8B;IAC9B,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUrD;AAED;;;;;;;;;;GAU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