@almadar/agent 2.0.2 → 2.0.3
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/index.js +4 -5
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/session-manager.d.ts +1 -1
- package/dist/contracts.d.ts +218 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/tools/domain-orbital.d.ts +16 -16
- package/dist/tools/index.d.ts +16 -16
- package/dist/tools/index.js +4 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/orbital-batch-subagent.d.ts +5 -5
- package/dist/tools/orbital-subagent.d.ts +8 -8
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@ export declare class SessionManager {
|
|
|
52
52
|
/**
|
|
53
53
|
* Get or create a checkpointer for a session.
|
|
54
54
|
*/
|
|
55
|
-
getCheckpointer(threadId: string): BaseCheckpointSaver
|
|
55
|
+
getCheckpointer(threadId: string): BaseCheckpointSaver;
|
|
56
56
|
/**
|
|
57
57
|
* Store session metadata.
|
|
58
58
|
*/
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Contracts for @almadar/agent
|
|
3
|
+
*
|
|
4
|
+
* Typed contracts for agent services callable from .orb schemas via
|
|
5
|
+
* `["call-service", "serviceName", "action", { params }]`.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { ServiceAction, ServiceContract, ServiceEvents } from '@almadar/core';
|
|
10
|
+
/** Actions available on the Session service. */
|
|
11
|
+
export type SessionActions = {
|
|
12
|
+
create: {
|
|
13
|
+
params: {
|
|
14
|
+
threadId: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
};
|
|
17
|
+
result: {
|
|
18
|
+
threadId: string;
|
|
19
|
+
created: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
get: {
|
|
23
|
+
params: {
|
|
24
|
+
threadId: string;
|
|
25
|
+
};
|
|
26
|
+
result: {
|
|
27
|
+
session: Record<string, unknown> | null;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
list: {
|
|
31
|
+
params: {
|
|
32
|
+
userId?: string;
|
|
33
|
+
};
|
|
34
|
+
result: {
|
|
35
|
+
sessions: Array<{
|
|
36
|
+
threadId: string;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
clear: {
|
|
42
|
+
params: {
|
|
43
|
+
threadId: string;
|
|
44
|
+
};
|
|
45
|
+
result: {
|
|
46
|
+
cleared: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Service contract for session management. */
|
|
51
|
+
export type SessionServiceContract = ServiceContract<SessionActions>;
|
|
52
|
+
/** Actions available on the Memory service. */
|
|
53
|
+
export type MemoryActions = {
|
|
54
|
+
getUserPreferences: {
|
|
55
|
+
params: {
|
|
56
|
+
userId: string;
|
|
57
|
+
};
|
|
58
|
+
result: {
|
|
59
|
+
preferences: Record<string, unknown> | null;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
updateUserPreferences: {
|
|
63
|
+
params: {
|
|
64
|
+
userId: string;
|
|
65
|
+
preferences: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
result: {
|
|
68
|
+
updated: boolean;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
recordGeneration: {
|
|
72
|
+
params: {
|
|
73
|
+
userId: string;
|
|
74
|
+
prompt: string;
|
|
75
|
+
result: string;
|
|
76
|
+
skill?: string;
|
|
77
|
+
};
|
|
78
|
+
result: {
|
|
79
|
+
sessionId: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
getGenerationHistory: {
|
|
83
|
+
params: {
|
|
84
|
+
userId: string;
|
|
85
|
+
limit?: number;
|
|
86
|
+
};
|
|
87
|
+
result: {
|
|
88
|
+
sessions: Array<{
|
|
89
|
+
id: string;
|
|
90
|
+
prompt: string;
|
|
91
|
+
createdAt: number;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** Service contract for user memory and generation history. */
|
|
97
|
+
export type MemoryServiceContract = ServiceContract<MemoryActions>;
|
|
98
|
+
/** Actions available on the Agent service. */
|
|
99
|
+
export type AgentActions = {
|
|
100
|
+
sendMessage: {
|
|
101
|
+
params: {
|
|
102
|
+
message: string;
|
|
103
|
+
threadId?: string;
|
|
104
|
+
skill?: string;
|
|
105
|
+
context?: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
result: {
|
|
108
|
+
response: string;
|
|
109
|
+
threadId: string;
|
|
110
|
+
toolCalls: unknown[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
cancelGeneration: {
|
|
114
|
+
params: {
|
|
115
|
+
threadId: string;
|
|
116
|
+
};
|
|
117
|
+
result: {
|
|
118
|
+
cancelled: boolean;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/** Service contract for the AI agent itself. */
|
|
123
|
+
export type AgentServiceContract = ServiceContract<AgentActions>;
|
|
124
|
+
/** Events emitted by the state sync manager. */
|
|
125
|
+
export type StateSyncEventMap = {
|
|
126
|
+
STATE_CHANGE: {
|
|
127
|
+
path: string;
|
|
128
|
+
value: unknown;
|
|
129
|
+
source: string;
|
|
130
|
+
timestamp: number;
|
|
131
|
+
};
|
|
132
|
+
STATE_RECONCILED: {
|
|
133
|
+
path: string;
|
|
134
|
+
resolvedValue: unknown;
|
|
135
|
+
strategy: string;
|
|
136
|
+
};
|
|
137
|
+
CONFLICT_DETECTED: {
|
|
138
|
+
path: string;
|
|
139
|
+
localValue: unknown;
|
|
140
|
+
remoteValue: unknown;
|
|
141
|
+
};
|
|
142
|
+
REMOTE_CHANGE: {
|
|
143
|
+
path: string;
|
|
144
|
+
value: unknown;
|
|
145
|
+
source: string;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
};
|
|
148
|
+
CONFIG_UPDATED: {
|
|
149
|
+
syncInterval: number;
|
|
150
|
+
conflictResolution: string;
|
|
151
|
+
};
|
|
152
|
+
SYNC_REQUIRED: {
|
|
153
|
+
pendingChanges: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/** Events emitted by the online eval sampler. */
|
|
157
|
+
export type EvalSamplerEventMap = {
|
|
158
|
+
EVAL_SAMPLE_DROPPED: {
|
|
159
|
+
reason: string;
|
|
160
|
+
};
|
|
161
|
+
EVAL_SAMPLE_COLLECTED: {
|
|
162
|
+
sampleId: string;
|
|
163
|
+
category: string;
|
|
164
|
+
};
|
|
165
|
+
EVAL_SAMPLE_VALIDATED: {
|
|
166
|
+
sampleId: string;
|
|
167
|
+
passed: boolean;
|
|
168
|
+
score: number;
|
|
169
|
+
};
|
|
170
|
+
EVAL_VALIDATION_ERROR: {
|
|
171
|
+
sampleId: string;
|
|
172
|
+
error: string;
|
|
173
|
+
};
|
|
174
|
+
EVAL_ALERT: {
|
|
175
|
+
type: string;
|
|
176
|
+
message: string;
|
|
177
|
+
threshold: number;
|
|
178
|
+
actual: number;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
/** Events emitted by agent sessions. */
|
|
182
|
+
export type AgentSessionEventMap = {
|
|
183
|
+
SESSION_CREATED: {
|
|
184
|
+
threadId: string;
|
|
185
|
+
userId: string;
|
|
186
|
+
};
|
|
187
|
+
SESSION_COMPACTED: {
|
|
188
|
+
threadId: string;
|
|
189
|
+
messagesBefore: number;
|
|
190
|
+
messagesAfter: number;
|
|
191
|
+
};
|
|
192
|
+
SESSION_CLEARED: {
|
|
193
|
+
threadId: string;
|
|
194
|
+
};
|
|
195
|
+
AGENT_MESSAGE_SENT: {
|
|
196
|
+
threadId: string;
|
|
197
|
+
messageLength: number;
|
|
198
|
+
};
|
|
199
|
+
AGENT_RESPONSE_RECEIVED: {
|
|
200
|
+
threadId: string;
|
|
201
|
+
tokensUsed: number;
|
|
202
|
+
latencyMs: number;
|
|
203
|
+
};
|
|
204
|
+
AGENT_GENERATION_CANCELLED: {
|
|
205
|
+
threadId: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
/** Combined event map for all agent events. */
|
|
209
|
+
export type AgentEventMap = StateSyncEventMap & EvalSamplerEventMap & AgentSessionEventMap;
|
|
210
|
+
/** Typed event emitter for agent events. */
|
|
211
|
+
export type AgentServiceEvents = ServiceEvents<AgentEventMap>;
|
|
212
|
+
/** All agent service contracts grouped by service name. */
|
|
213
|
+
export interface AgentServiceContracts {
|
|
214
|
+
session: SessionServiceContract;
|
|
215
|
+
memory: MemoryServiceContract;
|
|
216
|
+
agent: AgentServiceContract;
|
|
217
|
+
}
|
|
218
|
+
export type { ServiceAction, ServiceContract };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,3 +57,4 @@ export { executeSandboxed } from './tools/sandbox-executor.js';
|
|
|
57
57
|
export type { SandboxOptions, SandboxResult } from './tools/sandbox-executor.js';
|
|
58
58
|
export { classifyCommand, TOOL_GATES, CRITICAL_COMMAND_PATTERNS } from './agent/interrupt-config.js';
|
|
59
59
|
export type { ActionGate } from './agent/interrupt-config.js';
|
|
60
|
+
export type { SessionActions, SessionServiceContract, MemoryActions, MemoryServiceContract, AgentActions, AgentServiceContract, AgentServiceContracts, } from './contracts.js';
|
package/dist/index.js
CHANGED
|
@@ -1151,14 +1151,15 @@ function createOrbitalBatchSubagentTool(options = {}) {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
};
|
|
1153
1153
|
const batchTool = tool(
|
|
1154
|
-
async ({ orbitals, options: batchOptions }) => {
|
|
1155
|
-
if (!
|
|
1154
|
+
async ({ orbitals: rawOrbitals, options: batchOptions }) => {
|
|
1155
|
+
if (!rawOrbitals || rawOrbitals.length === 0) {
|
|
1156
1156
|
return JSON.stringify({
|
|
1157
1157
|
success: false,
|
|
1158
1158
|
error: "No orbitals provided for batch generation.",
|
|
1159
1159
|
orbitals: []
|
|
1160
1160
|
});
|
|
1161
1161
|
}
|
|
1162
|
+
const orbitals = rawOrbitals;
|
|
1162
1163
|
console.log(`[OrbitalBatchSubagent] Starting batch generation for ${orbitals.length} orbitals`);
|
|
1163
1164
|
try {
|
|
1164
1165
|
emitEvent("batch", 0, 1, "message", {
|
|
@@ -1288,8 +1289,7 @@ var init_orbital_batch_subagent = __esm({
|
|
|
1288
1289
|
init_shared();
|
|
1289
1290
|
init_batch();
|
|
1290
1291
|
OrbitalBatchInputSchema = z.object({
|
|
1291
|
-
|
|
1292
|
-
orbitals: z.array(z.any()).describe("Array of OrbitalUnits to generate"),
|
|
1292
|
+
orbitals: z.array(z.record(z.unknown())).describe("Array of OrbitalUnits to generate"),
|
|
1293
1293
|
options: z.object({
|
|
1294
1294
|
mode: z.enum(["single-call", "parallel-individual", "adaptive"]).optional().default("adaptive"),
|
|
1295
1295
|
batchSize: z.number().optional(),
|
|
@@ -6068,7 +6068,6 @@ var SessionManager = class {
|
|
|
6068
6068
|
/**
|
|
6069
6069
|
* Get or create a checkpointer for a session.
|
|
6070
6070
|
*/
|
|
6071
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6072
6071
|
getCheckpointer(threadId) {
|
|
6073
6072
|
if (this.mode === "firestore" && this.firestoreCheckpointer) {
|
|
6074
6073
|
return this.firestoreCheckpointer;
|