@aaep/typescript-producer 1.0.1
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 +170 -0
- package/dist/agent.d.ts +41 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +336 -0
- package/dist/agent.js.map +1 -0
- package/dist/coalescer.d.ts +57 -0
- package/dist/coalescer.d.ts.map +1 -0
- package/dist/coalescer.js +124 -0
- package/dist/coalescer.js.map +1 -0
- package/dist/emitter.d.ts +111 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +320 -0
- package/dist/emitter.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +258 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -0
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* HTTP/SSE server wrapping the TypeScript AgentLoop for conformance testing.
|
|
4
|
+
*
|
|
5
|
+
* Endpoints (identical to the Python example servers):
|
|
6
|
+
* POST /sessions - Start a new session
|
|
7
|
+
* GET /events - SSE event stream
|
|
8
|
+
* POST /messages - Reply messages (confirmation, clarification)
|
|
9
|
+
* GET /healthz - Health check
|
|
10
|
+
*
|
|
11
|
+
* Run with:
|
|
12
|
+
* npm run server (auto-restart via tsx)
|
|
13
|
+
* node dist/server.js (after `npm run build`)
|
|
14
|
+
*
|
|
15
|
+
* Then test with:
|
|
16
|
+
* aaep-conformance producer --endpoint http://localhost:8084 --level 2
|
|
17
|
+
*
|
|
18
|
+
* Cross-language conformance: the same Python conformance suite verifies
|
|
19
|
+
* this TypeScript server. Pass Level 2 here AND in the Python examples
|
|
20
|
+
* = AAEP is language-independent in practice, not just in theory.
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* HTTP/SSE server wrapping the TypeScript AgentLoop for conformance testing.
|
|
4
|
+
*
|
|
5
|
+
* Endpoints (identical to the Python example servers):
|
|
6
|
+
* POST /sessions - Start a new session
|
|
7
|
+
* GET /events - SSE event stream
|
|
8
|
+
* POST /messages - Reply messages (confirmation, clarification)
|
|
9
|
+
* GET /healthz - Health check
|
|
10
|
+
*
|
|
11
|
+
* Run with:
|
|
12
|
+
* npm run server (auto-restart via tsx)
|
|
13
|
+
* node dist/server.js (after `npm run build`)
|
|
14
|
+
*
|
|
15
|
+
* Then test with:
|
|
16
|
+
* aaep-conformance producer --endpoint http://localhost:8084 --level 2
|
|
17
|
+
*
|
|
18
|
+
* Cross-language conformance: the same Python conformance suite verifies
|
|
19
|
+
* this TypeScript server. Pass Level 2 here AND in the Python examples
|
|
20
|
+
* = AAEP is language-independent in practice, not just in theory.
|
|
21
|
+
*/
|
|
22
|
+
import { createServer } from "node:http";
|
|
23
|
+
import { AAEPEmitter } from "./emitter.js";
|
|
24
|
+
import { AgentLoop } from "./agent.js";
|
|
25
|
+
// === Event broadcaster ===
|
|
26
|
+
class EventBroadcaster {
|
|
27
|
+
subscribers = new Set();
|
|
28
|
+
buffer = [];
|
|
29
|
+
maxBuffer = 1000;
|
|
30
|
+
publish(event) {
|
|
31
|
+
this.buffer.push(event);
|
|
32
|
+
if (this.buffer.length > this.maxBuffer) {
|
|
33
|
+
// Critical event bypass: never drop critical events on overflow
|
|
34
|
+
const dropIndex = this.buffer.findIndex((e) => e.urgency !== "critical");
|
|
35
|
+
if (dropIndex >= 0) {
|
|
36
|
+
this.buffer.splice(dropIndex, 1);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.buffer.shift(); // all critical; reluctantly drop oldest
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const data = `data: ${JSON.stringify(event)}\n\n`;
|
|
43
|
+
for (const res of this.subscribers) {
|
|
44
|
+
try {
|
|
45
|
+
res.write(data);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
this.subscribers.delete(res);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
addSubscriber(res) {
|
|
53
|
+
this.subscribers.add(res);
|
|
54
|
+
// Replay buffer to new subscribers
|
|
55
|
+
for (const event of this.buffer) {
|
|
56
|
+
try {
|
|
57
|
+
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
this.subscribers.delete(res);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
removeSubscriber(res) {
|
|
66
|
+
this.subscribers.delete(res);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// === Request body parsing ===
|
|
70
|
+
async function readJsonBody(req) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const chunks = [];
|
|
73
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
74
|
+
req.on("end", () => {
|
|
75
|
+
try {
|
|
76
|
+
const text = Buffer.concat(chunks).toString("utf-8");
|
|
77
|
+
resolve(text ? JSON.parse(text) : {});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
reject(err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
req.on("error", reject);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// === CORS headers ===
|
|
87
|
+
function corsHeaders() {
|
|
88
|
+
return {
|
|
89
|
+
"Access-Control-Allow-Origin": "*",
|
|
90
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
91
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// === Main ===
|
|
95
|
+
async function main() {
|
|
96
|
+
const port = Number(process.env.PORT ?? 8084);
|
|
97
|
+
const host = process.env.HOST ?? "127.0.0.1";
|
|
98
|
+
const broadcaster = new EventBroadcaster();
|
|
99
|
+
const emitter = new AAEPEmitter({
|
|
100
|
+
sendEvent: (event) => broadcaster.publish(event),
|
|
101
|
+
agentId: "aaep-typescript-server",
|
|
102
|
+
agentName: "AAEP TypeScript Test Server",
|
|
103
|
+
model: "mock-model",
|
|
104
|
+
});
|
|
105
|
+
const agent = new AgentLoop({ emitter });
|
|
106
|
+
const server = createServer(async (req, res) => {
|
|
107
|
+
// CORS preflight
|
|
108
|
+
if (req.method === "OPTIONS") {
|
|
109
|
+
res.writeHead(204, corsHeaders());
|
|
110
|
+
res.end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const url = req.url ?? "/";
|
|
114
|
+
try {
|
|
115
|
+
// GET /healthz
|
|
116
|
+
if (req.method === "GET" && url === "/healthz") {
|
|
117
|
+
res.writeHead(200, {
|
|
118
|
+
...corsHeaders(),
|
|
119
|
+
"Content-Type": "application/json",
|
|
120
|
+
});
|
|
121
|
+
res.end(JSON.stringify({
|
|
122
|
+
status: "ok",
|
|
123
|
+
aaep_version: "1.0.0",
|
|
124
|
+
implementation: "typescript-minimal",
|
|
125
|
+
}));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// GET /events (SSE stream)
|
|
129
|
+
if (req.method === "GET" && url === "/events") {
|
|
130
|
+
res.writeHead(200, {
|
|
131
|
+
...corsHeaders(),
|
|
132
|
+
"Content-Type": "text/event-stream",
|
|
133
|
+
"Cache-Control": "no-cache",
|
|
134
|
+
"Connection": "keep-alive",
|
|
135
|
+
"X-Accel-Buffering": "no",
|
|
136
|
+
});
|
|
137
|
+
broadcaster.addSubscriber(res);
|
|
138
|
+
req.on("close", () => broadcaster.removeSubscriber(res));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// POST /sessions
|
|
142
|
+
if (req.method === "POST" && url === "/sessions") {
|
|
143
|
+
const body = (await readJsonBody(req));
|
|
144
|
+
if (typeof body.user_message !== "string" || !body.user_message.trim()) {
|
|
145
|
+
res.writeHead(400, {
|
|
146
|
+
...corsHeaders(),
|
|
147
|
+
"Content-Type": "application/json",
|
|
148
|
+
});
|
|
149
|
+
res.end(JSON.stringify({ error: "user_message must be a non-empty string" }));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Schedule the agent run as a background task
|
|
153
|
+
agent.run(body.user_message, {
|
|
154
|
+
userId: typeof body.user_id === "string" ? body.user_id : undefined,
|
|
155
|
+
}).catch((err) => {
|
|
156
|
+
console.error("Session failed:", err);
|
|
157
|
+
});
|
|
158
|
+
// Small delay to let the session.started event be queued
|
|
159
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
160
|
+
res.writeHead(202, {
|
|
161
|
+
...corsHeaders(),
|
|
162
|
+
"Content-Type": "application/json",
|
|
163
|
+
});
|
|
164
|
+
res.end(JSON.stringify({
|
|
165
|
+
status: "started",
|
|
166
|
+
user_message: body.user_message,
|
|
167
|
+
}));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// POST /messages
|
|
171
|
+
if (req.method === "POST" && url === "/messages") {
|
|
172
|
+
const body = (await readJsonBody(req));
|
|
173
|
+
const replyToken = body.reply_token;
|
|
174
|
+
if (typeof replyToken !== "string" || !replyToken) {
|
|
175
|
+
res.writeHead(400, {
|
|
176
|
+
...corsHeaders(),
|
|
177
|
+
"Content-Type": "application/json",
|
|
178
|
+
});
|
|
179
|
+
res.end(JSON.stringify({ error: "reply_token is required" }));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const msgType = body.type;
|
|
183
|
+
if (msgType === "confirmation.reply") {
|
|
184
|
+
const decision = body.decision;
|
|
185
|
+
if (decision !== "accept" && decision !== "reject") {
|
|
186
|
+
res.writeHead(400, {
|
|
187
|
+
...corsHeaders(),
|
|
188
|
+
"Content-Type": "application/json",
|
|
189
|
+
});
|
|
190
|
+
res.end(JSON.stringify({ error: "decision must be accept or reject" }));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
emitter.submitReply(replyToken, decision);
|
|
194
|
+
res.writeHead(200, {
|
|
195
|
+
...corsHeaders(),
|
|
196
|
+
"Content-Type": "application/json",
|
|
197
|
+
});
|
|
198
|
+
res.end(JSON.stringify({ status: "received" }));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (msgType === "clarification.reply") {
|
|
202
|
+
const response = body.response;
|
|
203
|
+
if (response === undefined) {
|
|
204
|
+
res.writeHead(400, {
|
|
205
|
+
...corsHeaders(),
|
|
206
|
+
"Content-Type": "application/json",
|
|
207
|
+
});
|
|
208
|
+
res.end(JSON.stringify({ error: "response field required" }));
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
emitter.submitReply(replyToken, String(response));
|
|
212
|
+
res.writeHead(200, {
|
|
213
|
+
...corsHeaders(),
|
|
214
|
+
"Content-Type": "application/json",
|
|
215
|
+
});
|
|
216
|
+
res.end(JSON.stringify({ status: "received" }));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
res.writeHead(400, {
|
|
220
|
+
...corsHeaders(),
|
|
221
|
+
"Content-Type": "application/json",
|
|
222
|
+
});
|
|
223
|
+
res.end(JSON.stringify({ error: `unsupported message type: ${String(msgType)}` }));
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
// 404
|
|
227
|
+
res.writeHead(404, {
|
|
228
|
+
...corsHeaders(),
|
|
229
|
+
"Content-Type": "application/json",
|
|
230
|
+
});
|
|
231
|
+
res.end(JSON.stringify({ error: "Not found" }));
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
235
|
+
console.error("Request handler error:", err);
|
|
236
|
+
res.writeHead(500, {
|
|
237
|
+
...corsHeaders(),
|
|
238
|
+
"Content-Type": "application/json",
|
|
239
|
+
});
|
|
240
|
+
res.end(JSON.stringify({ error: err.message }));
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
server.listen(port, host, () => {
|
|
244
|
+
console.log(`Starting AAEP TypeScript server on http://${host}:${port}`);
|
|
245
|
+
console.log(`Test with: aaep-conformance producer --endpoint http://${host}:${port} --level 2`);
|
|
246
|
+
});
|
|
247
|
+
// Graceful shutdown
|
|
248
|
+
process.on("SIGINT", () => {
|
|
249
|
+
console.log("\nShutting down...");
|
|
250
|
+
server.close(() => process.exit(0));
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
// === Entry point ===
|
|
254
|
+
main().catch((err) => {
|
|
255
|
+
console.error("Server failed:", err);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
});
|
|
258
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAmC,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,4BAA4B;AAE5B,MAAM,gBAAgB;IACD,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC7C,MAAM,GAAgB,EAAE,CAAC;IACzB,SAAS,GAAG,IAAI,CAAC;IAElC,OAAO,CAAC,KAAgB;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAA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KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC;AAGD,sBAAsB;AAEtB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for AAEP events.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces match the JSON Schemas exactly. Importing this file
|
|
5
|
+
* gives you full type safety: editor autocomplete shows valid field names,
|
|
6
|
+
* the compiler catches missing required fields, and discriminated unions
|
|
7
|
+
* allow exhaustive switch statements on event type.
|
|
8
|
+
*
|
|
9
|
+
* See https://aaep-protocol.org/schemas/v1/ for the canonical schemas.
|
|
10
|
+
*/
|
|
11
|
+
export type Urgency = "normal" | "critical";
|
|
12
|
+
export type Verbosity = "terse" | "normal" | "detailed";
|
|
13
|
+
export type AgentState = "idle" | "thinking" | "calling_tool" | "writing_output" | "awaiting_user" | "completed";
|
|
14
|
+
export type RiskLevel = "low" | "medium" | "high";
|
|
15
|
+
export type ToolStatus = "success" | "error" | "timeout";
|
|
16
|
+
export type CoalesceHint = "none" | "word" | "sentence" | "paragraph" | "completion";
|
|
17
|
+
export type Decision = "accept" | "reject";
|
|
18
|
+
export type ErrorCategory = "timeout" | "network" | "authentication" | "authorization" | "rate_limit" | "invalid_input" | "policy" | "internal" | "transient" | "unknown";
|
|
19
|
+
export type CancelledBy = "user" | "system" | "timeout" | "policy";
|
|
20
|
+
export type Reversibility = "reversible_easy" | "reversible_with_effort" | "irreversible";
|
|
21
|
+
export interface Producer {
|
|
22
|
+
agent_id: string;
|
|
23
|
+
agent_version?: string;
|
|
24
|
+
agent_name?: string;
|
|
25
|
+
model?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface LocalizationHints {
|
|
28
|
+
primary_language?: string;
|
|
29
|
+
text_direction?: "ltr" | "rtl";
|
|
30
|
+
available_languages?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface AAEPEnvelope {
|
|
33
|
+
"@context": string;
|
|
34
|
+
aaep_version?: string;
|
|
35
|
+
type: string;
|
|
36
|
+
event_id: string;
|
|
37
|
+
session_id: string;
|
|
38
|
+
sequence_number?: number;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
producer: Producer;
|
|
41
|
+
urgency: Urgency;
|
|
42
|
+
verbosity?: Verbosity;
|
|
43
|
+
localization_hints?: LocalizationHints;
|
|
44
|
+
summary_terse?: string;
|
|
45
|
+
summary_normal: string;
|
|
46
|
+
summary_detailed?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SessionStartedEvent extends AAEPEnvelope {
|
|
49
|
+
type: "aaep:agent.session.started";
|
|
50
|
+
request_text?: string;
|
|
51
|
+
requested_by?: string;
|
|
52
|
+
expected_duration_ms?: number;
|
|
53
|
+
tools_available?: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface SessionCompletedEvent extends AAEPEnvelope {
|
|
56
|
+
type: "aaep:agent.session.completed";
|
|
57
|
+
duration_ms?: number;
|
|
58
|
+
tool_invocations_count?: number;
|
|
59
|
+
output_summary?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface SessionErroredEvent extends AAEPEnvelope {
|
|
62
|
+
type: "aaep:agent.session.errored";
|
|
63
|
+
urgency: "critical";
|
|
64
|
+
error_category: ErrorCategory;
|
|
65
|
+
error_message?: string;
|
|
66
|
+
recoverable?: boolean;
|
|
67
|
+
remediation_hint?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface SessionCancelledEvent extends AAEPEnvelope {
|
|
70
|
+
type: "aaep:agent.session.cancelled";
|
|
71
|
+
cancelled_by: CancelledBy;
|
|
72
|
+
cancellation_reason?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface StateChangedEvent extends AAEPEnvelope {
|
|
75
|
+
type: "aaep:agent.state.changed";
|
|
76
|
+
from_state: AgentState | string;
|
|
77
|
+
to_state: AgentState | string;
|
|
78
|
+
}
|
|
79
|
+
export interface ProgressUpdatedEvent extends AAEPEnvelope {
|
|
80
|
+
type: "aaep:agent.progress.updated";
|
|
81
|
+
progress_percent?: number;
|
|
82
|
+
progress_message?: string;
|
|
83
|
+
estimated_remaining_ms?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface ToolInvokedEvent extends AAEPEnvelope {
|
|
86
|
+
type: "aaep:agent.tool.invoked";
|
|
87
|
+
tool: string;
|
|
88
|
+
tool_call_id?: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
args_summary: string;
|
|
91
|
+
expected_duration_ms?: number;
|
|
92
|
+
risk_level: RiskLevel;
|
|
93
|
+
irreversible: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface ToolCompletedEvent extends AAEPEnvelope {
|
|
96
|
+
type: "aaep:agent.tool.completed";
|
|
97
|
+
tool: string;
|
|
98
|
+
tool_call_id?: string;
|
|
99
|
+
status: ToolStatus;
|
|
100
|
+
error_message?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface OutputStreamingEvent extends AAEPEnvelope {
|
|
103
|
+
type: "aaep:agent.output.streaming";
|
|
104
|
+
chunk: string;
|
|
105
|
+
position: number;
|
|
106
|
+
complete: boolean;
|
|
107
|
+
coalesce_hint: CoalesceHint;
|
|
108
|
+
output_id?: string;
|
|
109
|
+
content_type?: string;
|
|
110
|
+
language?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface AwaitingConfirmationEvent extends AAEPEnvelope {
|
|
113
|
+
type: "aaep:agent.awaiting.confirmation";
|
|
114
|
+
urgency: "critical";
|
|
115
|
+
action: string;
|
|
116
|
+
consequence: string;
|
|
117
|
+
reply_token: string;
|
|
118
|
+
timeout_seconds: number;
|
|
119
|
+
default_decision: Decision;
|
|
120
|
+
risk_level: RiskLevel;
|
|
121
|
+
irreversible: boolean;
|
|
122
|
+
reversibility?: Reversibility;
|
|
123
|
+
}
|
|
124
|
+
export interface AwaitingClarificationEvent extends AAEPEnvelope {
|
|
125
|
+
type: "aaep:agent.awaiting.clarification";
|
|
126
|
+
urgency: "critical";
|
|
127
|
+
question: string;
|
|
128
|
+
reply_token: string;
|
|
129
|
+
timeout_seconds: number;
|
|
130
|
+
options?: string[];
|
|
131
|
+
multi_select?: boolean;
|
|
132
|
+
free_form_allowed?: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface HandoffRequestedEvent extends AAEPEnvelope {
|
|
135
|
+
type: "aaep:agent.handoff.requested";
|
|
136
|
+
urgency: "critical";
|
|
137
|
+
reason: string;
|
|
138
|
+
handoff_target: string;
|
|
139
|
+
context_summary?: string;
|
|
140
|
+
}
|
|
141
|
+
export type AAEPEvent = SessionStartedEvent | SessionCompletedEvent | SessionErroredEvent | SessionCancelledEvent | StateChangedEvent | ProgressUpdatedEvent | ToolInvokedEvent | ToolCompletedEvent | OutputStreamingEvent | AwaitingConfirmationEvent | AwaitingClarificationEvent | HandoffRequestedEvent;
|
|
142
|
+
export interface SubscriptionRequest {
|
|
143
|
+
type: "subscription.request";
|
|
144
|
+
aaep_version: string;
|
|
145
|
+
subscriber_id: string;
|
|
146
|
+
subscriber_name?: string;
|
|
147
|
+
subscriber_version?: string;
|
|
148
|
+
capabilities: Capabilities;
|
|
149
|
+
}
|
|
150
|
+
export interface Capabilities {
|
|
151
|
+
max_events_per_second?: number;
|
|
152
|
+
preferred_verbosity?: Verbosity;
|
|
153
|
+
languages?: string[];
|
|
154
|
+
supports_confirmation_reply?: boolean;
|
|
155
|
+
supports_clarification_reply?: boolean;
|
|
156
|
+
coalesce_boundaries?: CoalesceHint[];
|
|
157
|
+
event_filters?: {
|
|
158
|
+
include?: string[];
|
|
159
|
+
exclude?: string[];
|
|
160
|
+
};
|
|
161
|
+
supported_conformance_levels?: number[];
|
|
162
|
+
supported_extensions?: string[];
|
|
163
|
+
cognitive_load?: "high" | "medium" | "low";
|
|
164
|
+
pace_wpm?: number;
|
|
165
|
+
accept_signed_manifests_only?: boolean;
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
}
|
|
168
|
+
export interface SubscriptionAccepted {
|
|
169
|
+
type: "subscription.accepted";
|
|
170
|
+
subscription_id: string;
|
|
171
|
+
aaep_version: string;
|
|
172
|
+
producer: Producer;
|
|
173
|
+
honored_capabilities: Capabilities;
|
|
174
|
+
signed_manifest?: string;
|
|
175
|
+
}
|
|
176
|
+
export type RejectReason = "version_unsupported" | "manifest_signature_required" | "capabilities_incompatible" | "rate_limit" | "authentication_required" | "authorization_denied" | "transport_unavailable" | "unknown";
|
|
177
|
+
export interface SubscriptionRejected {
|
|
178
|
+
type: "subscription.rejected";
|
|
179
|
+
reason_code: RejectReason;
|
|
180
|
+
reason_message: string;
|
|
181
|
+
retry_after_seconds?: number;
|
|
182
|
+
}
|
|
183
|
+
export interface ConfirmationReply {
|
|
184
|
+
type: "confirmation.reply";
|
|
185
|
+
reply_token: string;
|
|
186
|
+
decision: Decision;
|
|
187
|
+
subscription_id?: string;
|
|
188
|
+
decided_by?: string;
|
|
189
|
+
timestamp: string;
|
|
190
|
+
decision_reason?: string;
|
|
191
|
+
}
|
|
192
|
+
export interface ClarificationReply {
|
|
193
|
+
type: "clarification.reply";
|
|
194
|
+
reply_token: string;
|
|
195
|
+
response: unknown;
|
|
196
|
+
subscription_id?: string;
|
|
197
|
+
decided_by?: string;
|
|
198
|
+
timestamp: string;
|
|
199
|
+
}
|
|
200
|
+
export declare function isSessionEvent(event: AAEPEvent): event is SessionStartedEvent | SessionCompletedEvent | SessionErroredEvent | SessionCancelledEvent;
|
|
201
|
+
export declare function isToolEvent(event: AAEPEvent): event is ToolInvokedEvent | ToolCompletedEvent;
|
|
202
|
+
export declare function isAwaitingEvent(event: AAEPEvent): event is AwaitingConfirmationEvent | AwaitingClarificationEvent;
|
|
203
|
+
export declare function isCriticalEvent(event: AAEPEvent): boolean;
|
|
204
|
+
export declare const AAEP_CONTEXT_URL = "https://aaep-protocol.org/context/v1";
|
|
205
|
+
export declare const AAEP_VERSION = "1.0.0";
|
|
206
|
+
export declare const CRITICAL_URGENCY_EVENT_TYPES: Set<"aaep:agent.session.errored" | "aaep:agent.awaiting.confirmation" | "aaep:agent.awaiting.clarification" | "aaep:agent.handoff.requested">;
|
|
207
|
+
export declare const HIGH_RISK_TOOL_NAMES: Set<"send_email" | "transfer_funds" | "delete_record" | "delete_file" | "publish_post" | "make_payment" | "execute_trade" | "send_sms" | "send_message">;
|
|
208
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAC5C,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AACxD,MAAM,MAAM,UAAU,GAChB,MAAM,GACN,UAAU,GACV,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,WAAW,CAAC;AAClB,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AACzD,MAAM,MAAM,YAAY,GAClB,MAAM,GACN,MAAM,GACN,UAAU,GACV,WAAW,GACX,YAAY,CAAC;AACnB,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC3C,MAAM,MAAM,aAAa,GACnB,SAAS,GACT,SAAS,GACT,gBAAgB,GAChB,eAAe,GACf,YAAY,GACZ,eAAe,GACf,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,CAAC;AAChB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,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gB,GAAG,kBAAkB,CAGhD;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,SAAS,GACjB,KAAK,IAAI,yBAAyB,GAAG,0BAA0B,CAEjE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEzD;AAKD,eAAO,MAAM,gBAAgB,yCAAyC,CAAC;AACvE,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,eAAO,MAAM,4BAA4B,+IAK9B,CAAC;AAEZ,eAAO,MAAM,oBAAoB,0JAUtB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for AAEP events.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces match the JSON Schemas exactly. Importing this file
|
|
5
|
+
* gives you full type safety: editor autocomplete shows valid field names,
|
|
6
|
+
* the compiler catches missing required fields, and discriminated unions
|
|
7
|
+
* allow exhaustive switch statements on event type.
|
|
8
|
+
*
|
|
9
|
+
* See https://aaep-protocol.org/schemas/v1/ for the canonical schemas.
|
|
10
|
+
*/
|
|
11
|
+
// === Type guards ===
|
|
12
|
+
export function isSessionEvent(event) {
|
|
13
|
+
return event.type.startsWith("aaep:agent.session.");
|
|
14
|
+
}
|
|
15
|
+
export function isToolEvent(event) {
|
|
16
|
+
return event.type === "aaep:agent.tool.invoked"
|
|
17
|
+
|| event.type === "aaep:agent.tool.completed";
|
|
18
|
+
}
|
|
19
|
+
export function isAwaitingEvent(event) {
|
|
20
|
+
return event.type.startsWith("aaep:agent.awaiting.");
|
|
21
|
+
}
|
|
22
|
+
export function isCriticalEvent(event) {
|
|
23
|
+
return event.urgency === "critical";
|
|
24
|
+
}
|
|
25
|
+
// === Constants ===
|
|
26
|
+
export const AAEP_CONTEXT_URL = "https://aaep-protocol.org/context/v1";
|
|
27
|
+
export const AAEP_VERSION = "1.0.0";
|
|
28
|
+
export const CRITICAL_URGENCY_EVENT_TYPES = new Set([
|
|
29
|
+
"aaep:agent.session.errored",
|
|
30
|
+
"aaep:agent.awaiting.confirmation",
|
|
31
|
+
"aaep:agent.awaiting.clarification",
|
|
32
|
+
"aaep:agent.handoff.requested",
|
|
33
|
+
]);
|
|
34
|
+
export const HIGH_RISK_TOOL_NAMES = new Set([
|
|
35
|
+
"send_email",
|
|
36
|
+
"transfer_funds",
|
|
37
|
+
"delete_record",
|
|
38
|
+
"delete_file",
|
|
39
|
+
"publish_post",
|
|
40
|
+
"make_payment",
|
|
41
|
+
"execute_trade",
|
|
42
|
+
"send_sms",
|
|
43
|
+
"send_message",
|
|
44
|
+
]);
|
|
45
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2RH,sBAAsB;AAEtB,MAAM,UAAU,cAAc,CAC1B,KAAgB;IAGhB,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,WAAW,CACvB,KAAgB;IAEhB,OAAO,KAAK,CAAC,IAAI,KAAK,yBAAyB;WACxC,KAAK,CAAC,IAAI,KAAK,2BAA2B,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,eAAe,CAC3B,KAAgB;IAEhB,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAgB;IAC5C,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC;AACxC,CAAC;AAGD,oBAAoB;AAEpB,MAAM,CAAC,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AAEpC,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAChD,4BAA4B;IAC5B,kCAAkC;IAClC,mCAAmC;IACnC,8BAA8B;CACxB,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACxC,YAAY;IACZ,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,cAAc;IACd,cAAc;IACd,eAAe;IACf,UAAU;IACV,cAAc;CACR,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aaep/typescript-producer",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "AAEP producer example in TypeScript / Node.js — manual loop pattern with full safety machinery",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"aaep",
|
|
7
|
+
"accessibility",
|
|
8
|
+
"agent",
|
|
9
|
+
"typescript",
|
|
10
|
+
"nodejs",
|
|
11
|
+
"screen-reader",
|
|
12
|
+
"assistive-technology"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://aaep-protocol.org",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/Ramseyxlil/aaep.git",
|
|
18
|
+
"directory": "examples/producers/typescript-minimal"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Ramseyxlil/aaep/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Abdulrafiu Izuafa",
|
|
26
|
+
"email": "Abdulrafiu@izusoft.tech",
|
|
27
|
+
"url": "https://aaep-protocol.org"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./emitter": {
|
|
38
|
+
"types": "./dist/emitter.d.ts",
|
|
39
|
+
"import": "./dist/emitter.js"
|
|
40
|
+
},
|
|
41
|
+
"./agent": {
|
|
42
|
+
"types": "./dist/agent.d.ts",
|
|
43
|
+
"import": "./dist/agent.js"
|
|
44
|
+
},
|
|
45
|
+
"./types": {
|
|
46
|
+
"types": "./dist/types.d.ts",
|
|
47
|
+
"import": "./dist/types.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist/",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"bin": {
|
|
56
|
+
"aaep-ts-server": "./dist/server.js"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsc",
|
|
60
|
+
"watch": "tsc --watch",
|
|
61
|
+
"demo": "tsx src/agent.ts",
|
|
62
|
+
"server": "tsx src/server.ts",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"lint": "tsc --noEmit",
|
|
66
|
+
"clean": "rm -rf dist"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=18.0.0"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/node": "^20.10.0",
|
|
74
|
+
"tsx": "^4.7.0",
|
|
75
|
+
"typescript": "^5.3.0",
|
|
76
|
+
"vitest": "^1.2.0"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
}
|
|
81
|
+
}
|