@nexface/agent 0.1.1-alpha.5 → 0.1.1-alpha.7
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/dist/agent.d.ts +2 -19
- package/dist/agent.js +494 -268
- package/dist/agent.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +13 -0
- package/dist/internal.js.map +1 -0
- package/dist/model/binding.d.ts +2 -0
- package/dist/model/binding.js.map +1 -1
- package/dist/models/42.js +23 -0
- package/dist/protocol-response.d.ts +17 -0
- package/dist/protocol-response.js +62 -0
- package/dist/protocol-response.js.map +1 -0
- package/dist/request.d.ts +99 -0
- package/dist/request.js +238 -0
- package/dist/request.js.map +1 -0
- package/dist/types.d.ts +29 -33
- package/dist/types.js.map +1 -1
- package/package.json +17 -3
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Message, type RunAgentInput } from "@ag-ui/core";
|
|
2
|
+
export type { Message, RunAgentInput } from "@ag-ui/core";
|
|
3
|
+
import type { AgentContextEntry, AgentToolDefinition } from "@nexface/tools";
|
|
4
|
+
import type { AgentMessage, AgentModelToolCall, AgentRun, AgentRunResult, AgentRunInput } from "./types.js";
|
|
5
|
+
export interface AgentRequestState {
|
|
6
|
+
readonly nexface: RequestContinuation;
|
|
7
|
+
}
|
|
8
|
+
export type InternalAgentRunResult = AgentRunResult;
|
|
9
|
+
export type AgentResumeEntry = NonNullable<AgentRunInput["resume"]>[0] | {
|
|
10
|
+
readonly interruptId: string;
|
|
11
|
+
readonly status: "resolved";
|
|
12
|
+
readonly payload: {
|
|
13
|
+
readonly toolResultMessageId: string;
|
|
14
|
+
readonly confirmed?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export interface BrowserToolResult {
|
|
18
|
+
readonly toolCallId: string;
|
|
19
|
+
readonly result?: unknown;
|
|
20
|
+
readonly error?: {
|
|
21
|
+
readonly code: string;
|
|
22
|
+
readonly message: string;
|
|
23
|
+
};
|
|
24
|
+
readonly confirmed?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface InternalRequestInput {
|
|
27
|
+
readonly messages: readonly AgentMessage[];
|
|
28
|
+
readonly newMessages: readonly AgentMessage[];
|
|
29
|
+
readonly tools: readonly AgentToolDefinition<any, any>[];
|
|
30
|
+
readonly contexts: readonly AgentContextEntry[];
|
|
31
|
+
readonly continuation?: RequestContinuation;
|
|
32
|
+
readonly resume?: AgentResumeEntry;
|
|
33
|
+
readonly toolResult?: BrowserToolResult;
|
|
34
|
+
readonly receipts: readonly Message[];
|
|
35
|
+
}
|
|
36
|
+
export interface AgentBrowserAction {
|
|
37
|
+
readonly toolCallId: string;
|
|
38
|
+
readonly definition: AgentToolDefinition<any, any>;
|
|
39
|
+
readonly input: unknown;
|
|
40
|
+
readonly progressLabel?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface RequestContinuation {
|
|
43
|
+
version: 2;
|
|
44
|
+
threadId: string;
|
|
45
|
+
timeline: Array<{
|
|
46
|
+
messageId: string;
|
|
47
|
+
} | {
|
|
48
|
+
internal: AgentMessage;
|
|
49
|
+
}>;
|
|
50
|
+
model: {
|
|
51
|
+
provider: string;
|
|
52
|
+
model: string;
|
|
53
|
+
};
|
|
54
|
+
loadedSkills: string[];
|
|
55
|
+
browserSkillLoaded: boolean;
|
|
56
|
+
contextRevision: number;
|
|
57
|
+
lastContextSerialized?: string;
|
|
58
|
+
replay?: unknown;
|
|
59
|
+
pending?: {
|
|
60
|
+
kind: "client-tool-execution";
|
|
61
|
+
interruptId: string;
|
|
62
|
+
calls: AgentModelToolCall[];
|
|
63
|
+
definition: AgentToolDefinition<any, any>;
|
|
64
|
+
step: number;
|
|
65
|
+
recoverableFailures: number;
|
|
66
|
+
unresolvedToolFailures: string[];
|
|
67
|
+
browserSkillAvailable: boolean;
|
|
68
|
+
loadBrowserSkill: boolean;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export declare const approvalResponseSchema: {
|
|
72
|
+
type: string;
|
|
73
|
+
properties: {
|
|
74
|
+
approved: {
|
|
75
|
+
type: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
required: string[];
|
|
79
|
+
additionalProperties: boolean;
|
|
80
|
+
};
|
|
81
|
+
export declare const toolResultResponseSchema: {
|
|
82
|
+
type: string;
|
|
83
|
+
properties: {
|
|
84
|
+
toolResultMessageId: {
|
|
85
|
+
type: string;
|
|
86
|
+
};
|
|
87
|
+
confirmed: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
required: string[];
|
|
92
|
+
additionalProperties: boolean;
|
|
93
|
+
};
|
|
94
|
+
export declare function parseResume(value: unknown, allowMetadata?: boolean): AgentResumeEntry;
|
|
95
|
+
export declare function convertMessages(values: readonly Message[]): AgentMessage[];
|
|
96
|
+
export declare function decodeRequest(value: RunAgentInput): InternalRequestInput;
|
|
97
|
+
export declare function toProtocolMessages(messages: AgentMessage[]): Message[];
|
|
98
|
+
export declare function runResponse(run: AgentRun): Response;
|
|
99
|
+
export declare function mergeProtocolMessages(messages: Message[], previous: Message[]): Message[];
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { MessageSchema } from "@ag-ui/core";
|
|
2
|
+
import { getToolResultError } from "./internal.js";
|
|
3
|
+
export const approvalResponseSchema = {
|
|
4
|
+
type: "object", properties: { approved: { type: "boolean" } }, required: ["approved"], additionalProperties: false,
|
|
5
|
+
};
|
|
6
|
+
export const toolResultResponseSchema = {
|
|
7
|
+
type: "object", properties: { toolResultMessageId: { type: "string" }, confirmed: { type: "boolean" } }, required: ["toolResultMessageId"], additionalProperties: false,
|
|
8
|
+
};
|
|
9
|
+
export function parseResume(value, allowMetadata = false) {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
11
|
+
throw new Error("Invalid resume entry.");
|
|
12
|
+
const entry = value;
|
|
13
|
+
const allowed = ["interruptId", "status", "payload", ...(allowMetadata ? ["metadata"] : [])];
|
|
14
|
+
if (Object.keys(entry).some((key) => !allowed.includes(key)) || typeof entry.interruptId !== "string" || !entry.interruptId)
|
|
15
|
+
throw new Error("Invalid resume entry.");
|
|
16
|
+
if (entry.status === "cancelled") {
|
|
17
|
+
if (entry.payload !== undefined)
|
|
18
|
+
throw new Error("A cancelled response cannot carry a payload.");
|
|
19
|
+
return { interruptId: entry.interruptId, status: "cancelled" };
|
|
20
|
+
}
|
|
21
|
+
const payload = entry.payload;
|
|
22
|
+
if (entry.status !== "resolved" || !payload || typeof payload !== "object" || Array.isArray(payload))
|
|
23
|
+
throw new Error("A resolved response requires a payload.");
|
|
24
|
+
if (typeof payload.approved === "boolean" && Object.keys(payload).every((key) => key === "approved")) {
|
|
25
|
+
return { interruptId: entry.interruptId, status: "resolved", payload: { approved: payload.approved } };
|
|
26
|
+
}
|
|
27
|
+
if (typeof payload.toolResultMessageId === "string" && payload.toolResultMessageId && (payload.confirmed === undefined || typeof payload.confirmed === "boolean") && Object.keys(payload).every((key) => key === "toolResultMessageId" || key === "confirmed")) {
|
|
28
|
+
return { interruptId: entry.interruptId, status: "resolved", payload: { toolResultMessageId: payload.toolResultMessageId, ...(payload.confirmed === undefined ? {} : { confirmed: payload.confirmed }) } };
|
|
29
|
+
}
|
|
30
|
+
throw new Error("Invalid resume payload.");
|
|
31
|
+
}
|
|
32
|
+
export function convertMessages(values) {
|
|
33
|
+
const ids = new Set();
|
|
34
|
+
const calls = new Map();
|
|
35
|
+
return values.flatMap((value) => {
|
|
36
|
+
const message = MessageSchema.parse(value);
|
|
37
|
+
if (ids.has(message.id))
|
|
38
|
+
throw new Error("Duplicate message ID.");
|
|
39
|
+
ids.add(message.id);
|
|
40
|
+
if (message.role === "activity" || message.role === "reasoning")
|
|
41
|
+
return [];
|
|
42
|
+
if (message.role === "assistant") {
|
|
43
|
+
for (const call of message.toolCalls ?? [])
|
|
44
|
+
calls.set(call.id, call.function.name);
|
|
45
|
+
return [{ id: message.id, role: "assistant", content: message.content ?? null, toolCalls: (message.toolCalls ?? []).map((call) => ({ id: call.id, ...call.function })) }];
|
|
46
|
+
}
|
|
47
|
+
if (message.role === "tool") {
|
|
48
|
+
const name = calls.get(message.toolCallId);
|
|
49
|
+
if (!name)
|
|
50
|
+
throw new Error("A tool result has no preceding tool call.");
|
|
51
|
+
const content = message.error !== undefined && getToolResultError(message.content) === undefined
|
|
52
|
+
? JSON.stringify({ error: { code: "TOOL_ERROR", message: message.error }, content: message.content }) : message.content;
|
|
53
|
+
return [{ id: message.id, role: "tool", name, toolCallId: message.toolCallId, content }];
|
|
54
|
+
}
|
|
55
|
+
if (message.role === "user") {
|
|
56
|
+
if (Array.isArray(message.content) && message.content.some((part) => part.type !== "text" && part.type !== "image"))
|
|
57
|
+
throw new Error("This Agent supports text and image input only.");
|
|
58
|
+
const content = typeof message.content === "string" ? message.content.trim() : message.content;
|
|
59
|
+
if (!content.length)
|
|
60
|
+
throw new Error("Agent message content is required.");
|
|
61
|
+
return [{ id: message.id, role: "user", content: content }];
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Unsupported model history role: ${message.role}.`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function decodeRequest(value) {
|
|
67
|
+
const extension = value.forwardedProps?.nexface;
|
|
68
|
+
if (extension && (extension.version !== 2 || "checkpoint" in extension || "confirmedToolCallId" in extension))
|
|
69
|
+
throw new Error("Unsupported Nexface request version or recovery channel.");
|
|
70
|
+
const state = value.state;
|
|
71
|
+
if (state != null && (typeof state !== "object" || Array.isArray(state)))
|
|
72
|
+
throw new Error("Invalid Agent state.");
|
|
73
|
+
if (state && "nexface" in state && (!state.nexface || typeof state.nexface !== "object" || Array.isArray(state.nexface)))
|
|
74
|
+
throw new Error("Invalid Nexface state.");
|
|
75
|
+
const restored = state?.nexface;
|
|
76
|
+
if (restored && (restored.version !== 2 || restored.threadId !== value.threadId || !Array.isArray(restored.timeline)))
|
|
77
|
+
throw new Error("Agent state does not match this thread or version.");
|
|
78
|
+
const converted = new Map(convertMessages(value.messages).map((message) => [message.id, message]));
|
|
79
|
+
const source = new Map(value.messages.map((message) => [message.id, message]));
|
|
80
|
+
const used = new Set();
|
|
81
|
+
const messages = (restored?.timeline ?? []).flatMap((entry) => {
|
|
82
|
+
if ("internal" in entry) {
|
|
83
|
+
if (!entry.internal || (entry.internal.role !== "system" && entry.internal.role !== "application_context"))
|
|
84
|
+
throw new Error("Invalid internal history.");
|
|
85
|
+
return [structuredClone(entry.internal)];
|
|
86
|
+
}
|
|
87
|
+
const message = converted.get(entry.messageId);
|
|
88
|
+
if (!message || used.has(entry.messageId))
|
|
89
|
+
throw new Error("State message is missing or repeated.");
|
|
90
|
+
used.add(entry.messageId);
|
|
91
|
+
return [message];
|
|
92
|
+
});
|
|
93
|
+
const pending = restored?.pending;
|
|
94
|
+
if (value.resume && value.resume.length !== 1)
|
|
95
|
+
throw new Error("Exactly one resume entry is required.");
|
|
96
|
+
const resume = value.resume?.[0] ? parseResume(value.resume[0], true) : undefined;
|
|
97
|
+
const receipts = [];
|
|
98
|
+
let toolResult;
|
|
99
|
+
if (pending) {
|
|
100
|
+
if (!resume || resume.interruptId !== pending.interruptId || !Array.isArray(pending.calls) || !pending.calls.length)
|
|
101
|
+
throw new Error("Resume does not match the pending interrupt.");
|
|
102
|
+
if (pending.kind !== "client-tool-execution")
|
|
103
|
+
throw new Error("Invalid pending kind.");
|
|
104
|
+
if (resume.status === "resolved") {
|
|
105
|
+
if (!("toolResultMessageId" in resume.payload))
|
|
106
|
+
throw new Error("A client tool requires a result reference.");
|
|
107
|
+
const message = source.get(resume.payload.toolResultMessageId);
|
|
108
|
+
if (!message || used.has(message.id) || message.role !== "tool" || message.toolCallId !== pending.calls[0].id)
|
|
109
|
+
throw new Error("Resume result does not match the pending call.");
|
|
110
|
+
const owner = [...messages].reverse().find((item) => item.role === "assistant");
|
|
111
|
+
const ownerIndex = value.messages.findIndex((item) => item.id === owner?.id);
|
|
112
|
+
const receiptIndex = value.messages.indexOf(message);
|
|
113
|
+
if (ownerIndex < 0 || receiptIndex <= ownerIndex || value.messages.slice(ownerIndex + 1, receiptIndex).some((item) => item.role === "user" || (item.role === "assistant" && item.toolCalls?.length)))
|
|
114
|
+
throw new Error("The receipt does not belong to the pending assistant batch.");
|
|
115
|
+
let payload;
|
|
116
|
+
try {
|
|
117
|
+
payload = JSON.parse(message.content);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
if (!message.error)
|
|
121
|
+
throw new Error("Invalid tool result.");
|
|
122
|
+
}
|
|
123
|
+
if (message.error !== undefined)
|
|
124
|
+
payload = { error: { code: payload?.error?.code ?? "TOOL_ERROR", message: message.error } };
|
|
125
|
+
if (!payload || typeof payload !== "object" || (!("result" in payload) && !("error" in payload)))
|
|
126
|
+
throw new Error("Invalid tool result.");
|
|
127
|
+
if (payload.error && (typeof payload.error.code !== "string" || typeof payload.error.message !== "string"))
|
|
128
|
+
throw new Error("Invalid tool error.");
|
|
129
|
+
toolResult = { toolCallId: message.toolCallId, ...(payload.error ? { error: payload.error } : { result: payload.result }), ...(resume.payload.confirmed === undefined ? {} : { confirmed: resume.payload.confirmed }) };
|
|
130
|
+
receipts.push(message);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const owner = [...messages].reverse().find((message) => message.role === "assistant");
|
|
134
|
+
const ownerIndex = value.messages.findIndex((message) => message.id === owner?.id);
|
|
135
|
+
for (const message of value.messages.slice(ownerIndex + 1)) {
|
|
136
|
+
if (message.role === "user")
|
|
137
|
+
break;
|
|
138
|
+
if (used.has(message.id) || message.role !== "tool" || !pending.calls.some((call) => call.id === message.toolCallId))
|
|
139
|
+
continue;
|
|
140
|
+
let payload;
|
|
141
|
+
try {
|
|
142
|
+
payload = JSON.parse(message.content);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new Error("Invalid cancellation receipt.");
|
|
146
|
+
}
|
|
147
|
+
const first = message.toolCallId === pending.calls[0].id;
|
|
148
|
+
if (!(first ? ["TOOL_CANCELLED", "TOOL_CONFIRMATION_INVALIDATED"] : ["TOOL_SKIPPED", "TOOL_CANCELLED"]).includes(payload?.error?.code))
|
|
149
|
+
throw new Error("Cancellation cannot replace an execution result.");
|
|
150
|
+
if (receipts.some((receipt) => receipt.role === "tool" && receipt.toolCallId === message.toolCallId))
|
|
151
|
+
throw new Error("Repeated cancellation receipt.");
|
|
152
|
+
receipts.push(message);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (resume)
|
|
157
|
+
throw new Error("Cannot resume without a pending interrupt.");
|
|
158
|
+
const receiptIds = new Set(receipts.map((message) => message.id));
|
|
159
|
+
const newMessages = value.messages.flatMap((message) => {
|
|
160
|
+
if (used.has(message.id) || receiptIds.has(message.id))
|
|
161
|
+
return [];
|
|
162
|
+
if (pending && message.role === "tool" && pending.calls.some((call) => call.id === message.toolCallId))
|
|
163
|
+
throw new Error("Repeated or unexpected pending result.");
|
|
164
|
+
const convertedMessage = converted.get(message.id);
|
|
165
|
+
if (pending && resume?.status === "resolved" && convertedMessage)
|
|
166
|
+
throw new Error("A resolved response cannot start a new task.");
|
|
167
|
+
return convertedMessage ? [convertedMessage] : [];
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
messages, newMessages, receipts, ...(restored ? { continuation: structuredClone(restored) } : {}), ...(resume ? { resume } : {}), ...(toolResult ? { toolResult } : {}),
|
|
171
|
+
tools: value.tools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.parameters, effect: extension?.toolMetadata?.[tool.name]?.effect ?? "action" })),
|
|
172
|
+
contexts: value.context.map((context, index) => {
|
|
173
|
+
let data = context.value;
|
|
174
|
+
try {
|
|
175
|
+
data = JSON.parse(context.value);
|
|
176
|
+
}
|
|
177
|
+
catch { /* Context values may be plain text. */ }
|
|
178
|
+
if (data && typeof data === "object" && "name" in data && "value" in data)
|
|
179
|
+
return data;
|
|
180
|
+
return { name: `context${index}`, description: context.description, value: data };
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export function toProtocolMessages(messages) {
|
|
185
|
+
return messages.flatMap((message) => {
|
|
186
|
+
message.id ??= globalThis.crypto.randomUUID();
|
|
187
|
+
if (message.role === "system" || message.role === "application_context")
|
|
188
|
+
return [];
|
|
189
|
+
if (message.role === "assistant")
|
|
190
|
+
return [{ id: message.id, role: "assistant", ...(message.content === null ? {} : { content: message.content }), toolCalls: message.toolCalls.map(({ id, name, arguments: args }) => ({ id, type: "function", function: { name, arguments: args } })) }];
|
|
191
|
+
if (message.role === "tool") {
|
|
192
|
+
const error = getToolResultError(message.content);
|
|
193
|
+
return [{ id: message.id, role: "tool", toolCallId: message.toolCallId, content: message.content, ...(error === undefined ? {} : { error }) }];
|
|
194
|
+
}
|
|
195
|
+
return [{ id: message.id, role: "user", content: message.content }];
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
export function runResponse(run) {
|
|
199
|
+
const encoder = new TextEncoder();
|
|
200
|
+
const iterator = run[Symbol.asyncIterator]();
|
|
201
|
+
void run.result.catch(() => undefined);
|
|
202
|
+
return new Response(new ReadableStream({
|
|
203
|
+
async pull(controller) {
|
|
204
|
+
try {
|
|
205
|
+
const next = await iterator.next();
|
|
206
|
+
if (next.done)
|
|
207
|
+
controller.close();
|
|
208
|
+
else
|
|
209
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify(next.value)}\n\n`));
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
controller.error(error);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
async cancel() { run.cancel(); await iterator.return?.(); },
|
|
216
|
+
}), { headers: {
|
|
217
|
+
"Content-Type": "text/event-stream",
|
|
218
|
+
"Cache-Control": "no-cache, no-transform",
|
|
219
|
+
"X-Accel-Buffering": "no",
|
|
220
|
+
} });
|
|
221
|
+
}
|
|
222
|
+
export function mergeProtocolMessages(messages, previous) {
|
|
223
|
+
const remaining = new Map(messages.map((message) => [message.id, message]));
|
|
224
|
+
const mergedHistory = previous.flatMap((old) => {
|
|
225
|
+
const message = remaining.get(old.id);
|
|
226
|
+
if (!message)
|
|
227
|
+
return old.role === "activity" || old.role === "reasoning" ? [old] : [];
|
|
228
|
+
remaining.delete(old.id);
|
|
229
|
+
const merged = { ...old, ...message };
|
|
230
|
+
if (message.role === "tool" && old.role === "tool" && old.error !== undefined)
|
|
231
|
+
merged.content = old.content;
|
|
232
|
+
if (message.role === "assistant" && old.role === "assistant")
|
|
233
|
+
merged.toolCalls = message.toolCalls?.map((call) => ({ ...old.toolCalls?.find((item) => item.id === call.id), ...call }));
|
|
234
|
+
return [MessageSchema.parse(merged)];
|
|
235
|
+
});
|
|
236
|
+
return [...mergedHistory, ...remaining.values()];
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoC,MAAM,aAAa,CAAC;AAI9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA0DnD,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,oBAAoB,EAAE,KAAK;CACnH,CAAC;AACF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,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,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC5G,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;YAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;QACxL,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,aAAa,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { RegisteredAgentTool } from "@nexface/tools";
|
|
2
|
+
import type { RunAgentInput } from "./request.js";
|
|
1
3
|
import type { ToolRuntime, AgentToolInputSchema } from "@nexface/tools";
|
|
2
4
|
import type { AgentModelConfig, AgentModelInfo } from "./model/types.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type { TextInputContent, ImageInputContent, RunStartedEvent, RunFinishedEvent, RunErrorEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent } from "@ag-ui/core";
|
|
5
|
+
import type { TextInputContent, ImageInputContent, RunStartedEvent, RunFinishedEvent, RunErrorEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, CustomEvent, MessagesSnapshotEvent, StateSnapshotEvent, Message } from "@ag-ui/core";
|
|
5
6
|
export type AgentInputContent = TextInputContent | ImageInputContent;
|
|
6
7
|
export declare const agentBrand: unique symbol;
|
|
7
8
|
export type AgentMessage = {
|
|
9
|
+
id?: string;
|
|
10
|
+
} & ({
|
|
8
11
|
role: "system";
|
|
9
12
|
content: string;
|
|
10
13
|
} | {
|
|
@@ -27,7 +30,7 @@ export type AgentMessage = {
|
|
|
27
30
|
toolCallId: string;
|
|
28
31
|
name: string;
|
|
29
32
|
content: string;
|
|
30
|
-
};
|
|
33
|
+
});
|
|
31
34
|
export interface AgentModelToolCall {
|
|
32
35
|
id: string;
|
|
33
36
|
name: string;
|
|
@@ -54,7 +57,7 @@ export interface AgentRunOptions {
|
|
|
54
57
|
signal?: AbortSignal;
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
|
-
* @experimental Human-in-the-loop approval descriptor.
|
|
60
|
+
* @experimental Human-in-the-loop approval descriptor; ordinary completed Runs are not experimental.
|
|
58
61
|
* @beta
|
|
59
62
|
*/
|
|
60
63
|
export type ToolApprovalInterruptDescriptor = {
|
|
@@ -74,47 +77,43 @@ export type ToolApprovalInterruptDescriptor = {
|
|
|
74
77
|
readonly mode: "page";
|
|
75
78
|
});
|
|
76
79
|
export type AgentRunResult = {
|
|
77
|
-
readonly
|
|
80
|
+
readonly outcome: Extract<NonNullable<RunFinishedEvent["outcome"]>, {
|
|
81
|
+
type: "success";
|
|
82
|
+
}>;
|
|
78
83
|
readonly output: string;
|
|
79
84
|
} | {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
readonly status: "interrupted";
|
|
85
|
-
/**
|
|
86
|
-
* @experimental Human-in-the-loop approval descriptor.
|
|
87
|
-
* @beta
|
|
88
|
-
*/
|
|
89
|
-
readonly interrupt: ToolApprovalInterruptDescriptor;
|
|
85
|
+
readonly outcome: Extract<NonNullable<RunFinishedEvent["outcome"]>, {
|
|
86
|
+
type: "interrupt";
|
|
87
|
+
}>;
|
|
88
|
+
readonly output?: never;
|
|
90
89
|
};
|
|
91
|
-
export type AgentRunEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent;
|
|
90
|
+
export type AgentRunEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | CustomEvent | MessagesSnapshotEvent | StateSnapshotEvent;
|
|
92
91
|
export interface AgentRun extends AsyncIterable<AgentRunEvent> {
|
|
93
92
|
readonly id: string;
|
|
94
93
|
readonly result: Promise<AgentRunResult>;
|
|
95
94
|
cancel(): void;
|
|
95
|
+
toResponse(): Response;
|
|
96
96
|
}
|
|
97
97
|
export type AgentRunInput = {
|
|
98
|
-
readonly
|
|
99
|
-
readonly content: string | readonly AgentInputContent[];
|
|
100
|
-
};
|
|
101
|
-
readonly resume?: never;
|
|
102
|
-
} | {
|
|
103
|
-
readonly message?: never;
|
|
98
|
+
readonly messages?: readonly Message[];
|
|
104
99
|
/**
|
|
105
|
-
* @experimental
|
|
100
|
+
* @experimental Responds to a pending tool interrupt.
|
|
106
101
|
* @beta
|
|
107
102
|
*/
|
|
108
|
-
readonly resume
|
|
103
|
+
readonly resume?: readonly [
|
|
109
104
|
{
|
|
110
105
|
readonly interruptId: string;
|
|
106
|
+
} & ({
|
|
111
107
|
readonly status: "resolved";
|
|
112
108
|
readonly payload: {
|
|
113
109
|
readonly approved: boolean;
|
|
114
110
|
};
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
} | {
|
|
112
|
+
readonly status: "cancelled";
|
|
113
|
+
readonly payload?: never;
|
|
114
|
+
})
|
|
117
115
|
];
|
|
116
|
+
readonly threadId?: never;
|
|
118
117
|
};
|
|
119
118
|
export interface AgentSkill {
|
|
120
119
|
readonly name: string;
|
|
@@ -123,23 +122,20 @@ export interface AgentSkill {
|
|
|
123
122
|
}
|
|
124
123
|
export type CreateAgentOptions = {
|
|
125
124
|
model: AgentModelConfig;
|
|
125
|
+
toolRuntime?: ToolRuntime;
|
|
126
|
+
tools?: readonly RegisteredAgentTool[];
|
|
126
127
|
skills?: readonly AgentSkill[];
|
|
127
128
|
maxSteps?: number;
|
|
128
129
|
maxRetries?: number;
|
|
129
130
|
applicationContext?: {
|
|
130
131
|
maxSizeBytes?: number;
|
|
131
132
|
};
|
|
132
|
-
}
|
|
133
|
-
toolRuntime: ToolRuntime;
|
|
134
|
-
toolBridge?: never;
|
|
135
|
-
} | {
|
|
136
|
-
toolBridge: ToolBridge;
|
|
137
|
-
toolRuntime?: never;
|
|
138
|
-
});
|
|
133
|
+
};
|
|
139
134
|
export interface Agent {
|
|
140
135
|
readonly [agentBrand]: true;
|
|
141
136
|
readonly id: string;
|
|
142
137
|
readonly model: AgentModelInfo;
|
|
143
138
|
switchModel(model: AgentModelConfig): Promise<void>;
|
|
144
139
|
run(input: AgentRunInput, options?: AgentRunOptions): AgentRun;
|
|
140
|
+
runRequest(input: RunAgentInput, options?: AgentRunOptions): AgentRun;
|
|
145
141
|
}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,UAAU,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/agent",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.19.0"
|
|
7
7
|
},
|
|
8
8
|
"exports": {
|
|
9
|
+
"./internal": {
|
|
10
|
+
"types": "./dist/internal.d.ts",
|
|
11
|
+
"default": "./dist/internal.js"
|
|
12
|
+
},
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./dist/index.d.ts",
|
|
11
15
|
"default": "./dist/index.js"
|
|
@@ -34,7 +38,17 @@
|
|
|
34
38
|
"dependencies": {
|
|
35
39
|
"@ag-ui/core": "0.0.59"
|
|
36
40
|
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@earendil-works/pi-ai": "0.84.1",
|
|
43
|
+
"@rslib/core": "0.23.2",
|
|
44
|
+
"rspack-1-7": "npm:@rspack/core@1.7.12",
|
|
45
|
+
"@nexface/tools": "0.1.1-alpha.7"
|
|
46
|
+
},
|
|
37
47
|
"peerDependencies": {
|
|
38
|
-
"@nexface/tools": "0.1.1-alpha.
|
|
48
|
+
"@nexface/tools": "0.1.1-alpha.7"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "node ../../scripts/generate-browser-tools-skill.mjs --check && node scripts/clean.mjs && tsc -p tsconfig.json && rslib build && node scripts/clean-model-output.mjs",
|
|
52
|
+
"typecheck": "node ../../scripts/generate-browser-tools-skill.mjs --check && tsc -p tsconfig.json --noEmit"
|
|
39
53
|
}
|
|
40
|
-
}
|
|
54
|
+
}
|