@almadar/agent 1.6.4 → 2.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/LICENSE +21 -72
- package/README.md +25 -0
- package/dist/agent/event-budget.d.ts +28 -0
- package/dist/agent/experimental/hitl-v2.d.ts +161 -0
- package/dist/agent/experimental/hitl-workflow-integration.d.ts +182 -0
- package/dist/agent/index.d.ts +14 -13
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/interrupt-config.d.ts +51 -0
- package/dist/agent/session-manager.d.ts +204 -0
- package/dist/agent/skill-agent.d.ts +182 -0
- package/dist/agent/workflow-middleware.d.ts +63 -0
- package/dist/agent/workflow-tool-wrapper.d.ts +87 -0
- package/dist/{api-types-CXrq-fts.d.ts → api-types.d.ts} +85 -51
- package/dist/context/compaction.d.ts +191 -0
- package/dist/context-compaction.d.ts +55 -0
- package/dist/evals/online-sampling.d.ts +114 -0
- package/dist/evals/utils/compact-orbital.d.ts +100 -0
- package/dist/event-transformer/event-transformer.d.ts +120 -0
- package/dist/event-transformer/index.d.ts +4 -122
- package/dist/events.d.ts +85 -0
- package/dist/index.d.ts +58 -1678
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/MemoryManager.d.ts +243 -0
- package/dist/memory/PreferenceLearner.d.ts +59 -0
- package/dist/memory/agentic-search.d.ts +116 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/memory-orbital.d.ts +66 -0
- package/dist/memory/types.d.ts +143 -0
- package/dist/metrics.d.ts +77 -0
- package/dist/multi-user.d.ts +155 -0
- package/dist/observability/index.d.ts +14 -0
- package/dist/observability/langsmith-integration.d.ts +203 -0
- package/dist/observability.d.ts +196 -0
- package/dist/orbitals/archive/sanitize.d.ts +24 -0
- package/dist/orbitals/batch/batch-generator.d.ts +41 -0
- package/dist/orbitals/batch/concurrency.d.ts +54 -0
- package/dist/orbitals/batch/index.d.ts +14 -0
- package/dist/orbitals/batch/prompt-assembler.d.ts +92 -0
- package/dist/orbitals/batch/types.d.ts +103 -0
- package/dist/orbitals/cache/index.d.ts +11 -0
- package/dist/orbitals/cache/orbital-fingerprint.d.ts +37 -0
- package/dist/orbitals/cache/prompt-assembler.d.ts +65 -0
- package/dist/orbitals/cache/structural-templates.d.ts +33 -0
- package/dist/orbitals/combiner/index.d.ts +102 -0
- package/dist/orbitals/domain-language/index.d.ts +9 -0
- package/dist/orbitals/domain-language/prompts/index.d.ts +11 -0
- package/dist/orbitals/domain-language/prompts/odl-examples.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-patterns.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-syntax.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-to-schema.d.ts +8 -0
- package/dist/orbitals/generation/index.d.ts +10 -0
- package/dist/orbitals/generation/orbital-generator.d.ts +120 -0
- package/dist/orbitals/shared/constants.d.ts +65 -0
- package/dist/orbitals/shared/index.d.ts +11 -0
- package/dist/orbitals/shared/types.d.ts +187 -0
- package/dist/orbitals/shared/utils.d.ts +97 -0
- package/dist/orchestration/complexity-classifier.d.ts +38 -0
- package/dist/orchestration/fixing-orchestrator.d.ts +53 -0
- package/dist/orchestration/index.d.ts +31 -0
- package/dist/orchestration/provider-router.d.ts +45 -0
- package/dist/{firestore-checkpointer-CkNKXoun.d.ts → persistence/firestore-checkpointer.d.ts} +13 -58
- package/dist/persistence/firestore-session-store.d.ts +75 -0
- package/dist/persistence/firestore-store.d.ts +86 -0
- package/dist/persistence/index.d.ts +7 -198
- package/dist/persistence/memory-backend.d.ts +33 -0
- package/dist/persistence/types.d.ts +40 -0
- package/dist/security/audit-log.d.ts +44 -0
- package/dist/state-sync.d.ts +171 -0
- package/dist/subagents.d.ts +38 -0
- package/dist/tools/combine-schemas.d.ts +154 -0
- package/dist/tools/composition.d.ts +119 -0
- package/dist/{orbital-subagent-BdFuf77p.d.ts → tools/domain-orbital.d.ts} +22 -461
- package/dist/tools/execute.d.ts +38 -0
- package/dist/tools/finish-task.d.ts +56 -0
- package/dist/tools/generate-schema.d.ts +53 -0
- package/dist/tools/github.d.ts +297 -0
- package/dist/tools/index.d.ts +1318 -8
- package/dist/tools/orbital-batch-subagent.d.ts +85 -0
- package/dist/tools/orbital-subagent.d.ts +454 -0
- package/dist/tools/orchestrated-fixing.d.ts +74 -0
- package/dist/tools/orchestrated-generation.d.ts +75 -0
- package/dist/tools/sandbox-executor.d.ts +31 -0
- package/dist/tools/schema-chunking.d.ts +117 -0
- package/dist/tools/trait-subagent.d.ts +179 -0
- package/dist/tools/validate-schema.d.ts +17 -0
- package/dist/types.d.ts +14 -17
- package/dist/utils/safety/capability-token.d.ts +50 -0
- package/dist/utils/safety/circuit-breaker.d.ts +71 -0
- package/dist/utils/safety/index.d.ts +19 -0
- package/dist/utils/safety/rate-limiter.d.ts +39 -0
- package/dist/utils/safety/threshold-auth.d.ts +70 -0
- package/dist/workspace/git-client.d.ts +51 -0
- package/dist/workspace/index.d.ts +29 -346
- package/dist/workspace/index.js +39 -0
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/memory-files.d.ts +31 -0
- package/dist/workspace/sink-manager.d.ts +26 -0
- package/dist/workspace/sinks/firestore-sink.d.ts +41 -0
- package/dist/workspace/sinks/git-sink.d.ts +47 -0
- package/dist/workspace/sinks/index.d.ts +9 -0
- package/dist/workspace/templates.d.ts +32 -0
- package/dist/workspace/types.d.ts +86 -0
- package/dist/workspace/workspace-manager.d.ts +57 -0
- package/package.json +12 -10
- package/dist/index-DW3F-Ihx.d.ts +0 -2501
- package/dist/index-DZn69no8.d.ts +0 -1014
package/dist/index-DZn69no8.d.ts
DELETED
|
@@ -1,1014 +0,0 @@
|
|
|
1
|
-
import { LLMProvider } from '@almadar/llm';
|
|
2
|
-
import { S as SubagentEventCallback, O as OrbitalCompleteCallback, a as DomainOrbitalCompleteCallback } from './orbital-subagent-BdFuf77p.js';
|
|
3
|
-
import { BaseCheckpointSaver } from '@langchain/langgraph-checkpoint';
|
|
4
|
-
import { P as PersistenceMode, b as FirestoreDb$1, S as SessionMetadata, e as SessionRecord } from './firestore-checkpointer-CkNKXoun.js';
|
|
5
|
-
import { OrbitalSchema } from '@almadar/core';
|
|
6
|
-
import { BaseMessage } from '@langchain/core/messages';
|
|
7
|
-
import '@langchain/langgraph';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Context Compaction for DeepAgent
|
|
11
|
-
*
|
|
12
|
-
* Provides middleware to manage context length in long-running agent sessions.
|
|
13
|
-
* Uses @langchain/core's trimMessages to keep context within token limits.
|
|
14
|
-
*
|
|
15
|
-
* @packageDocumentation
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Configuration for context compaction.
|
|
20
|
-
*/
|
|
21
|
-
interface ContextCompactionConfig {
|
|
22
|
-
/**
|
|
23
|
-
* Maximum number of tokens before triggering compaction.
|
|
24
|
-
* Default: 150000 (leaves headroom for Claude's 200K context)
|
|
25
|
-
*/
|
|
26
|
-
maxTokens?: number;
|
|
27
|
-
/**
|
|
28
|
-
* Number of recent messages to always keep.
|
|
29
|
-
* Default: 10
|
|
30
|
-
*/
|
|
31
|
-
keepRecentMessages?: number;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to include the system message in trimming.
|
|
34
|
-
* Default: false (system message is always kept)
|
|
35
|
-
*/
|
|
36
|
-
includeSystem?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Strategy for trimming: 'first' keeps first messages, 'last' keeps last messages.
|
|
39
|
-
* Default: 'last'
|
|
40
|
-
*/
|
|
41
|
-
strategy?: 'first' | 'last';
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Default configuration for context compaction.
|
|
45
|
-
*/
|
|
46
|
-
declare const DEFAULT_COMPACTION_CONFIG: Required<ContextCompactionConfig>;
|
|
47
|
-
/**
|
|
48
|
-
* Check if messages need compaction based on estimated token count.
|
|
49
|
-
*/
|
|
50
|
-
declare function needsCompaction(messages: BaseMessage[], threshold?: number): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Create a message summarizer prompt for compacting old context.
|
|
53
|
-
*/
|
|
54
|
-
declare function createSummaryPrompt(messages: BaseMessage[]): string;
|
|
55
|
-
/**
|
|
56
|
-
* Estimate token count for messages using character-based heuristic.
|
|
57
|
-
*/
|
|
58
|
-
declare function estimateTokens(messages: BaseMessage[]): number;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Memory System Types
|
|
62
|
-
*
|
|
63
|
-
* Additional types for the memory system beyond the core orbital types.
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* User feedback on a generation session
|
|
67
|
-
*/
|
|
68
|
-
interface UserFeedback {
|
|
69
|
-
/** Unique feedback ID */
|
|
70
|
-
feedbackId: string;
|
|
71
|
-
/** Session this feedback is for */
|
|
72
|
-
sessionId: string;
|
|
73
|
-
/** User who gave the feedback */
|
|
74
|
-
userId: string;
|
|
75
|
-
/** Type of feedback */
|
|
76
|
-
type: 'positive' | 'negative' | 'correction' | 'suggestion';
|
|
77
|
-
/** Optional comment */
|
|
78
|
-
comment?: string;
|
|
79
|
-
/** Suggested correction or improvement */
|
|
80
|
-
suggestion?: string;
|
|
81
|
-
/** Timestamp of feedback */
|
|
82
|
-
timestamp: Date;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Pattern affinity - tracks how well patterns work for a user
|
|
86
|
-
*/
|
|
87
|
-
interface PatternAffinity {
|
|
88
|
-
/** User ID */
|
|
89
|
-
userId: string;
|
|
90
|
-
/** Pattern ID */
|
|
91
|
-
patternId: string;
|
|
92
|
-
/** How many times used */
|
|
93
|
-
usageCount: number;
|
|
94
|
-
/** Successful uses */
|
|
95
|
-
successCount: number;
|
|
96
|
-
/** Failed uses */
|
|
97
|
-
failureCount: number;
|
|
98
|
-
/** Contexts where this pattern was used */
|
|
99
|
-
contexts?: {
|
|
100
|
-
entityType?: string;
|
|
101
|
-
useCase?: string;
|
|
102
|
-
}[];
|
|
103
|
-
/** Last time this pattern was used */
|
|
104
|
-
lastUsedAt: Date;
|
|
105
|
-
/** When tracking started */
|
|
106
|
-
createdAt: Date;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Checkpoint record - tracks checkpoint history for learning
|
|
110
|
-
*/
|
|
111
|
-
interface CheckpointRecord {
|
|
112
|
-
/** Unique checkpoint ID */
|
|
113
|
-
checkpointId: string;
|
|
114
|
-
/** Thread/session ID */
|
|
115
|
-
threadId: string;
|
|
116
|
-
/** User who owns this checkpoint */
|
|
117
|
-
userId: string;
|
|
118
|
-
/** Parent checkpoint ID (for rollback tracking) */
|
|
119
|
-
parentCheckpointId?: string;
|
|
120
|
-
/** Checkpoint metadata */
|
|
121
|
-
metadata: {
|
|
122
|
-
step?: number;
|
|
123
|
-
skill?: string;
|
|
124
|
-
status?: string;
|
|
125
|
-
[key: string]: unknown;
|
|
126
|
-
};
|
|
127
|
-
/** When checkpoint was created */
|
|
128
|
-
createdAt: Date;
|
|
129
|
-
/** Number of times rolled back to this checkpoint */
|
|
130
|
-
rollbackCount: number;
|
|
131
|
-
/** Whether this checkpoint was a successful outcome */
|
|
132
|
-
wasSuccessful: boolean;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Interrupt record - tracks human-in-the-loop decisions
|
|
136
|
-
*/
|
|
137
|
-
interface InterruptRecord {
|
|
138
|
-
/** Unique interrupt ID */
|
|
139
|
-
interruptId: string;
|
|
140
|
-
/** Session this interrupt occurred in */
|
|
141
|
-
sessionId: string;
|
|
142
|
-
/** User who made the decision */
|
|
143
|
-
userId: string;
|
|
144
|
-
/** Tool that was interrupted */
|
|
145
|
-
toolName: string;
|
|
146
|
-
/** Tool arguments that were being executed */
|
|
147
|
-
toolArgs: Record<string, unknown>;
|
|
148
|
-
/** User's decision: approved, rejected, or modified */
|
|
149
|
-
decision: 'approved' | 'rejected' | 'modified';
|
|
150
|
-
/** Modified arguments if decision was 'modified' */
|
|
151
|
-
modifiedArgs?: Record<string, unknown>;
|
|
152
|
-
/** Reason for the decision */
|
|
153
|
-
reason?: string;
|
|
154
|
-
/** Timestamp of the interrupt */
|
|
155
|
-
timestamp: Date;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Tool approval preferences - learned from interrupt history
|
|
159
|
-
*/
|
|
160
|
-
interface ToolApprovalPreference {
|
|
161
|
-
/** User ID */
|
|
162
|
-
userId: string;
|
|
163
|
-
/** Tool name */
|
|
164
|
-
toolName: string;
|
|
165
|
-
/** Auto-approve this tool in the future */
|
|
166
|
-
autoApprove: boolean;
|
|
167
|
-
/** Confidence in this preference (0-1) */
|
|
168
|
-
confidence: number;
|
|
169
|
-
/** Number of times this tool has been approved */
|
|
170
|
-
approvedCount: number;
|
|
171
|
-
/** Number of times this tool has been rejected */
|
|
172
|
-
rejectedCount: number;
|
|
173
|
-
/** Last decision timestamp */
|
|
174
|
-
lastDecisionAt: Date;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Memory Orbital Schema
|
|
179
|
-
*
|
|
180
|
-
* Defines the structure for agent memory using Orbital types.
|
|
181
|
-
* This is an OrbitalSchema that represents user memory, preferences,
|
|
182
|
-
* and generation history.
|
|
183
|
-
*
|
|
184
|
-
* @packageDocumentation
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* The complete Memory Orbital Schema
|
|
189
|
-
* This defines the structure for storing agent memory
|
|
190
|
-
*/
|
|
191
|
-
declare const MemoryOrbitalSchema: OrbitalSchema;
|
|
192
|
-
type UserPreference = {
|
|
193
|
-
id: string;
|
|
194
|
-
userId: string;
|
|
195
|
-
namingConvention: 'PascalCase' | 'camelCase' | 'snake_case';
|
|
196
|
-
validationStyle: 'strict' | 'minimal' | 'none';
|
|
197
|
-
preferredPatterns: string[];
|
|
198
|
-
commonEntities: string[];
|
|
199
|
-
commonTraits: string[];
|
|
200
|
-
learnedAt: Date;
|
|
201
|
-
confidence: number;
|
|
202
|
-
};
|
|
203
|
-
type GenerationSession = {
|
|
204
|
-
id: string;
|
|
205
|
-
userId: string;
|
|
206
|
-
threadId: string;
|
|
207
|
-
prompt: string;
|
|
208
|
-
skill: string;
|
|
209
|
-
generatedSchema?: Record<string, unknown>;
|
|
210
|
-
entities: string[];
|
|
211
|
-
patterns: string[];
|
|
212
|
-
validationResult?: {
|
|
213
|
-
valid: boolean;
|
|
214
|
-
errors: unknown[];
|
|
215
|
-
};
|
|
216
|
-
createdAt: Date;
|
|
217
|
-
completedAt?: Date;
|
|
218
|
-
success: boolean;
|
|
219
|
-
};
|
|
220
|
-
type ProjectContext = {
|
|
221
|
-
id: string;
|
|
222
|
-
appId: string;
|
|
223
|
-
userId: string;
|
|
224
|
-
projectName?: string;
|
|
225
|
-
description?: string;
|
|
226
|
-
existingEntities: string[];
|
|
227
|
-
conventions: string[];
|
|
228
|
-
domain: 'business' | 'ecommerce' | 'cms' | 'dashboard' | 'workflow';
|
|
229
|
-
lastUpdatedAt: Date;
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Memory Manager - GAP-001: Orbital Memory System
|
|
234
|
-
*
|
|
235
|
-
* Manages user memory and preferences using Firestore persistence.
|
|
236
|
-
* Provides the foundation for personalized AI assistance by learning
|
|
237
|
-
* from user interactions and feedback.
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Minimal Firestore interface to avoid importing firebase-admin.
|
|
242
|
-
* These match the interfaces defined in firestore-checkpointer.ts
|
|
243
|
-
*/
|
|
244
|
-
interface FirestoreDb {
|
|
245
|
-
collection(path: string): FirestoreCollectionRef;
|
|
246
|
-
batch(): FirestoreBatch;
|
|
247
|
-
}
|
|
248
|
-
interface FirestoreCollectionRef {
|
|
249
|
-
doc(id: string): FirestoreDocRef;
|
|
250
|
-
where(field: string, op: string, value: unknown): FirestoreQuery;
|
|
251
|
-
orderBy(field: string, direction?: string): FirestoreQuery;
|
|
252
|
-
limit(n: number): FirestoreQuery;
|
|
253
|
-
}
|
|
254
|
-
interface FirestoreDocRef {
|
|
255
|
-
set(data: unknown): Promise<unknown>;
|
|
256
|
-
get(): Promise<FirestoreDocSnapshot>;
|
|
257
|
-
update(data: unknown): Promise<unknown>;
|
|
258
|
-
delete(): Promise<unknown>;
|
|
259
|
-
}
|
|
260
|
-
interface FirestoreDocSnapshot {
|
|
261
|
-
exists: boolean;
|
|
262
|
-
data(): Record<string, unknown> | undefined;
|
|
263
|
-
}
|
|
264
|
-
interface FirestoreQuery {
|
|
265
|
-
where(field: string, op: string, value: unknown): FirestoreQuery;
|
|
266
|
-
orderBy(field: string, direction?: string): FirestoreQuery;
|
|
267
|
-
limit(n: number): FirestoreQuery;
|
|
268
|
-
startAfter(doc: unknown): FirestoreQuery;
|
|
269
|
-
get(): Promise<FirestoreQuerySnapshot>;
|
|
270
|
-
}
|
|
271
|
-
interface FirestoreQuerySnapshot {
|
|
272
|
-
empty: boolean;
|
|
273
|
-
docs: FirestoreQueryDocSnapshot[];
|
|
274
|
-
size: number;
|
|
275
|
-
}
|
|
276
|
-
interface FirestoreQueryDocSnapshot {
|
|
277
|
-
data(): Record<string, unknown>;
|
|
278
|
-
}
|
|
279
|
-
interface FirestoreBatch {
|
|
280
|
-
set(ref: unknown, data: unknown): void;
|
|
281
|
-
delete(ref: unknown): void;
|
|
282
|
-
commit(): Promise<unknown>;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Options for MemoryManager
|
|
286
|
-
*/
|
|
287
|
-
interface MemoryManagerOptions {
|
|
288
|
-
/**
|
|
289
|
-
* Firestore database instance (injected)
|
|
290
|
-
*/
|
|
291
|
-
db: FirestoreDb;
|
|
292
|
-
/**
|
|
293
|
-
* Collection name for user preferences
|
|
294
|
-
* @default 'agent_memory_users'
|
|
295
|
-
*/
|
|
296
|
-
usersCollection?: string;
|
|
297
|
-
/**
|
|
298
|
-
* Collection name for generation sessions
|
|
299
|
-
* @default 'agent_memory_generations'
|
|
300
|
-
*/
|
|
301
|
-
generationsCollection?: string;
|
|
302
|
-
/**
|
|
303
|
-
* Collection name for project context
|
|
304
|
-
* @default 'agent_memory_projects'
|
|
305
|
-
*/
|
|
306
|
-
projectsCollection?: string;
|
|
307
|
-
/**
|
|
308
|
-
* Collection name for pattern affinity
|
|
309
|
-
* @default 'agent_memory_patterns'
|
|
310
|
-
*/
|
|
311
|
-
patternsCollection?: string;
|
|
312
|
-
/**
|
|
313
|
-
* Collection name for user feedback
|
|
314
|
-
* @default 'agent_memory_feedback'
|
|
315
|
-
*/
|
|
316
|
-
feedbackCollection?: string;
|
|
317
|
-
/**
|
|
318
|
-
* Collection name for interrupt records
|
|
319
|
-
* @default 'agent_memory_interrupts'
|
|
320
|
-
*/
|
|
321
|
-
interruptsCollection?: string;
|
|
322
|
-
/**
|
|
323
|
-
* Collection name for tool approval preferences
|
|
324
|
-
* @default 'agent_memory_tool_preferences'
|
|
325
|
-
*/
|
|
326
|
-
toolPreferencesCollection?: string;
|
|
327
|
-
/**
|
|
328
|
-
* Collection name for checkpoint records
|
|
329
|
-
* @default 'agent_memory_checkpoints'
|
|
330
|
-
*/
|
|
331
|
-
checkpointsCollection?: string;
|
|
332
|
-
}
|
|
333
|
-
declare class MemoryManager {
|
|
334
|
-
private db;
|
|
335
|
-
private usersCollection;
|
|
336
|
-
private generationsCollection;
|
|
337
|
-
private projectsCollection;
|
|
338
|
-
private patternsCollection;
|
|
339
|
-
private feedbackCollection;
|
|
340
|
-
private interruptsCollection;
|
|
341
|
-
private toolPreferencesCollection;
|
|
342
|
-
private checkpointsCollection;
|
|
343
|
-
constructor(options: MemoryManagerOptions);
|
|
344
|
-
/**
|
|
345
|
-
* Get user preferences with defaults
|
|
346
|
-
*/
|
|
347
|
-
getUserPreferences(userId: string): Promise<UserPreference | null>;
|
|
348
|
-
/**
|
|
349
|
-
* Update user preferences
|
|
350
|
-
*/
|
|
351
|
-
updateUserPreferences(userId: string, preferences: Partial<Omit<UserPreference, 'id' | 'userId' | 'learnedAt'>>): Promise<void>;
|
|
352
|
-
/**
|
|
353
|
-
* Record a new generation session
|
|
354
|
-
*/
|
|
355
|
-
recordGeneration(userId: string, session: Omit<GenerationSession, 'id' | 'userId' | 'createdAt'>): Promise<string>;
|
|
356
|
-
/**
|
|
357
|
-
* Get a specific generation session
|
|
358
|
-
*/
|
|
359
|
-
getGenerationSession(sessionId: string): Promise<GenerationSession | null>;
|
|
360
|
-
/**
|
|
361
|
-
* Get generation history for a user
|
|
362
|
-
*/
|
|
363
|
-
getUserGenerationHistory(userId: string, limit?: number): Promise<GenerationSession[]>;
|
|
364
|
-
/**
|
|
365
|
-
* Update generation session status
|
|
366
|
-
*/
|
|
367
|
-
updateGenerationStatus(sessionId: string, status: GenerationSession['success'], validationResult?: GenerationSession['validationResult']): Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* Get project context
|
|
370
|
-
*/
|
|
371
|
-
getProjectContext(appId: string): Promise<ProjectContext | null>;
|
|
372
|
-
/**
|
|
373
|
-
* Update project context with new information
|
|
374
|
-
*/
|
|
375
|
-
updateProjectContext(appId: string, update: Partial<Omit<ProjectContext, 'id' | 'appId'>>): Promise<void>;
|
|
376
|
-
/**
|
|
377
|
-
* Update pattern affinity based on usage
|
|
378
|
-
*/
|
|
379
|
-
updatePatternAffinity(userId: string, patternId: string, outcome: 'success' | 'failure' | 'partial', context?: {
|
|
380
|
-
entityType?: string;
|
|
381
|
-
useCase?: string;
|
|
382
|
-
}): Promise<void>;
|
|
383
|
-
/**
|
|
384
|
-
* Get pattern affinity for a user
|
|
385
|
-
*/
|
|
386
|
-
getPatternAffinity(userId: string, patternId: string): Promise<PatternAffinity | null>;
|
|
387
|
-
/**
|
|
388
|
-
* Get all patterns used by a user
|
|
389
|
-
*/
|
|
390
|
-
getUserPatterns(userId: string): Promise<PatternAffinity[]>;
|
|
391
|
-
/**
|
|
392
|
-
* Record user feedback on a generation
|
|
393
|
-
*/
|
|
394
|
-
recordFeedback(sessionId: string, feedback: Omit<UserFeedback, 'feedbackId' | 'sessionId' | 'timestamp'>): Promise<void>;
|
|
395
|
-
/**
|
|
396
|
-
* Get feedback for a session
|
|
397
|
-
*/
|
|
398
|
-
getSessionFeedback(sessionId: string): Promise<UserFeedback[]>;
|
|
399
|
-
private parsePreference;
|
|
400
|
-
private serializePreference;
|
|
401
|
-
private parseSession;
|
|
402
|
-
private serializeSession;
|
|
403
|
-
private parseContext;
|
|
404
|
-
private serializeContext;
|
|
405
|
-
/**
|
|
406
|
-
* Record an interrupt decision for learning
|
|
407
|
-
*/
|
|
408
|
-
recordInterruptDecision(sessionId: string, userId: string, interruptData: {
|
|
409
|
-
toolName: string;
|
|
410
|
-
toolArgs: Record<string, unknown>;
|
|
411
|
-
decision: 'approved' | 'rejected' | 'modified';
|
|
412
|
-
modifiedArgs?: Record<string, unknown>;
|
|
413
|
-
reason?: string;
|
|
414
|
-
}): Promise<void>;
|
|
415
|
-
/**
|
|
416
|
-
* Get interrupt history for a session
|
|
417
|
-
*/
|
|
418
|
-
getSessionInterrupts(sessionId: string): Promise<InterruptRecord[]>;
|
|
419
|
-
/**
|
|
420
|
-
* Get interrupt history for a user
|
|
421
|
-
*/
|
|
422
|
-
getUserInterrupts(userId: string, limit?: number): Promise<InterruptRecord[]>;
|
|
423
|
-
/**
|
|
424
|
-
* Get tool approval preference for a user
|
|
425
|
-
*/
|
|
426
|
-
getToolApprovalPreference(userId: string, toolName: string): Promise<ToolApprovalPreference | null>;
|
|
427
|
-
/**
|
|
428
|
-
* Update tool approval preference based on interrupt decisions
|
|
429
|
-
*/
|
|
430
|
-
private updateToolApprovalPreference;
|
|
431
|
-
/**
|
|
432
|
-
* Get all tool approval preferences for a user
|
|
433
|
-
*/
|
|
434
|
-
getUserToolPreferences(userId: string): Promise<ToolApprovalPreference[]>;
|
|
435
|
-
/**
|
|
436
|
-
* Check if a tool should be auto-approved for a user
|
|
437
|
-
*/
|
|
438
|
-
shouldAutoApproveTool(userId: string, toolName: string): Promise<boolean>;
|
|
439
|
-
/**
|
|
440
|
-
* Record a checkpoint for learning
|
|
441
|
-
*/
|
|
442
|
-
recordCheckpoint(userId: string, checkpointData: {
|
|
443
|
-
checkpointId: string;
|
|
444
|
-
threadId: string;
|
|
445
|
-
parentCheckpointId?: string;
|
|
446
|
-
metadata?: Record<string, unknown>;
|
|
447
|
-
}): Promise<void>;
|
|
448
|
-
/**
|
|
449
|
-
* Record a rollback to a checkpoint
|
|
450
|
-
*/
|
|
451
|
-
recordRollback(userId: string, checkpointId: string, reason?: string): Promise<void>;
|
|
452
|
-
/**
|
|
453
|
-
* Mark a checkpoint as successful (terminal state)
|
|
454
|
-
*/
|
|
455
|
-
markCheckpointSuccessful(userId: string, checkpointId: string): Promise<void>;
|
|
456
|
-
/**
|
|
457
|
-
* Get checkpoint history for a user
|
|
458
|
-
*/
|
|
459
|
-
getUserCheckpoints(userId: string, limit?: number): Promise<CheckpointRecord[]>;
|
|
460
|
-
/**
|
|
461
|
-
* Get checkpoints for a thread
|
|
462
|
-
*/
|
|
463
|
-
getThreadCheckpoints(threadId: string): Promise<CheckpointRecord[]>;
|
|
464
|
-
/**
|
|
465
|
-
* Get frequently rolled-back checkpoints (problem areas)
|
|
466
|
-
*/
|
|
467
|
-
getProblemCheckpoints(userId: string, minRollbackCount?: number): Promise<CheckpointRecord[]>;
|
|
468
|
-
/**
|
|
469
|
-
* Get successful checkpoint patterns for learning
|
|
470
|
-
*/
|
|
471
|
-
getSuccessfulCheckpoints(userId: string, limit?: number): Promise<CheckpointRecord[]>;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
interface SessionManagerOptions {
|
|
475
|
-
/**
|
|
476
|
-
* Persistence mode.
|
|
477
|
-
* @default 'memory'
|
|
478
|
-
*/
|
|
479
|
-
mode?: PersistenceMode;
|
|
480
|
-
/**
|
|
481
|
-
* Firestore database instance. Required when mode is 'firestore'.
|
|
482
|
-
*/
|
|
483
|
-
firestoreDb?: FirestoreDb$1;
|
|
484
|
-
/**
|
|
485
|
-
* Memory manager for session-to-memory sync (GAP-002D).
|
|
486
|
-
* When provided, completed sessions are recorded to orbital memory.
|
|
487
|
-
*/
|
|
488
|
-
memoryManager?: MemoryManager;
|
|
489
|
-
/**
|
|
490
|
-
* Context compaction configuration (GAP-005).
|
|
491
|
-
* When provided, enables automatic context length management.
|
|
492
|
-
*/
|
|
493
|
-
compactionConfig?: ContextCompactionConfig;
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Unified session management for agent sessions.
|
|
497
|
-
*
|
|
498
|
-
* Handles both session metadata and LangGraph checkpointers.
|
|
499
|
-
*/
|
|
500
|
-
declare class SessionManager {
|
|
501
|
-
private mode;
|
|
502
|
-
private memoryBackend;
|
|
503
|
-
private memoryCheckpointers;
|
|
504
|
-
private firestoreCheckpointer;
|
|
505
|
-
private firestoreSessionStore;
|
|
506
|
-
private memoryManager;
|
|
507
|
-
private compactionConfig;
|
|
508
|
-
constructor(options?: SessionManagerOptions);
|
|
509
|
-
/**
|
|
510
|
-
* Get the persistence mode.
|
|
511
|
-
*/
|
|
512
|
-
getMode(): PersistenceMode;
|
|
513
|
-
/**
|
|
514
|
-
* Get or create a checkpointer for a session.
|
|
515
|
-
*/
|
|
516
|
-
getCheckpointer(threadId: string): BaseCheckpointSaver<any>;
|
|
517
|
-
/**
|
|
518
|
-
* Store session metadata.
|
|
519
|
-
*/
|
|
520
|
-
store(threadId: string, metadata: SessionMetadata): void;
|
|
521
|
-
/**
|
|
522
|
-
* Get session metadata (sync, memory only).
|
|
523
|
-
*/
|
|
524
|
-
get(threadId: string): SessionMetadata | undefined;
|
|
525
|
-
/**
|
|
526
|
-
* Get session metadata (async, supports Firestore).
|
|
527
|
-
*/
|
|
528
|
-
getAsync(threadId: string): Promise<SessionMetadata | undefined>;
|
|
529
|
-
/**
|
|
530
|
-
* Clear a session's checkpointer and metadata.
|
|
531
|
-
*/
|
|
532
|
-
clear(threadId: string): boolean;
|
|
533
|
-
/**
|
|
534
|
-
* List all sessions (sync, memory only).
|
|
535
|
-
*/
|
|
536
|
-
list(): SessionRecord[];
|
|
537
|
-
/**
|
|
538
|
-
* List all sessions (async, supports Firestore).
|
|
539
|
-
*/
|
|
540
|
-
listAsync(): Promise<SessionRecord[]>;
|
|
541
|
-
/**
|
|
542
|
-
* Sync a completed session to orbital memory.
|
|
543
|
-
* This enables the agent to learn from past sessions.
|
|
544
|
-
*
|
|
545
|
-
* @param threadId - The session thread ID
|
|
546
|
-
* @param userId - The user ID for memory association
|
|
547
|
-
* @param sessionData - Additional session data to record
|
|
548
|
-
* @returns Promise that resolves when sync is complete
|
|
549
|
-
*/
|
|
550
|
-
syncSessionToMemory(threadId: string, userId: string, sessionData: {
|
|
551
|
-
appId: string;
|
|
552
|
-
inputDescription: string;
|
|
553
|
-
generatedOrbital?: string;
|
|
554
|
-
patternsUsed?: string[];
|
|
555
|
-
entities?: string[];
|
|
556
|
-
success: boolean;
|
|
557
|
-
errorMessage?: string;
|
|
558
|
-
}): Promise<void>;
|
|
559
|
-
/**
|
|
560
|
-
* Record an interrupt decision to memory.
|
|
561
|
-
* This enables learning from HITL (Human-in-the-Loop) decisions.
|
|
562
|
-
*
|
|
563
|
-
* @param sessionId - The session thread ID
|
|
564
|
-
* @param userId - The user who made the decision
|
|
565
|
-
* @param interruptData - The interrupt decision data
|
|
566
|
-
* @returns Promise that resolves when sync is complete
|
|
567
|
-
*/
|
|
568
|
-
recordInterruptDecision(sessionId: string, userId: string, interruptData: {
|
|
569
|
-
toolName: string;
|
|
570
|
-
toolArgs: Record<string, unknown>;
|
|
571
|
-
decision: 'approved' | 'rejected' | 'modified';
|
|
572
|
-
modifiedArgs?: Record<string, unknown>;
|
|
573
|
-
reason?: string;
|
|
574
|
-
}): Promise<void>;
|
|
575
|
-
/**
|
|
576
|
-
* Get interrupt history for a session.
|
|
577
|
-
*/
|
|
578
|
-
getSessionInterrupts(sessionId: string): Promise<InterruptRecord[]>;
|
|
579
|
-
/**
|
|
580
|
-
* Check if a tool should be auto-approved for a user.
|
|
581
|
-
*/
|
|
582
|
-
shouldAutoApproveTool(userId: string, toolName: string): Promise<boolean>;
|
|
583
|
-
/**
|
|
584
|
-
* Record a checkpoint to memory for learning.
|
|
585
|
-
*
|
|
586
|
-
* @param userId - The user who owns this checkpoint
|
|
587
|
-
* @param checkpointData - Checkpoint information
|
|
588
|
-
* @returns Promise that resolves when checkpoint is recorded
|
|
589
|
-
*/
|
|
590
|
-
recordCheckpoint(userId: string, checkpointData: {
|
|
591
|
-
checkpointId: string;
|
|
592
|
-
threadId: string;
|
|
593
|
-
parentCheckpointId?: string;
|
|
594
|
-
metadata?: Record<string, unknown>;
|
|
595
|
-
}): Promise<void>;
|
|
596
|
-
/**
|
|
597
|
-
* Record a rollback to a checkpoint.
|
|
598
|
-
*
|
|
599
|
-
* @param userId - The user who performed the rollback
|
|
600
|
-
* @param checkpointId - The checkpoint rolled back to
|
|
601
|
-
* @param reason - Optional reason for rollback
|
|
602
|
-
* @returns Promise that resolves when rollback is recorded
|
|
603
|
-
*/
|
|
604
|
-
recordRollback(userId: string, checkpointId: string, reason?: string): Promise<void>;
|
|
605
|
-
/**
|
|
606
|
-
* Mark a checkpoint as successful (terminal state).
|
|
607
|
-
*
|
|
608
|
-
* @param userId - The user who owns this checkpoint
|
|
609
|
-
* @param checkpointId - The checkpoint that was successful
|
|
610
|
-
* @returns Promise that resolves when success is recorded
|
|
611
|
-
*/
|
|
612
|
-
markCheckpointSuccessful(userId: string, checkpointId: string): Promise<void>;
|
|
613
|
-
/**
|
|
614
|
-
* Get checkpoint history for a thread.
|
|
615
|
-
*
|
|
616
|
-
* @param threadId - The thread to get checkpoints for
|
|
617
|
-
* @returns Array of checkpoint records
|
|
618
|
-
*/
|
|
619
|
-
getThreadCheckpoints(threadId: string): Promise<CheckpointRecord[]>;
|
|
620
|
-
/**
|
|
621
|
-
* Get frequently rolled-back checkpoints (problem areas).
|
|
622
|
-
*
|
|
623
|
-
* @param userId - The user to get problem checkpoints for
|
|
624
|
-
* @param minRollbackCount - Minimum rollback count (default: 2)
|
|
625
|
-
* @returns Array of checkpoint records with rollback issues
|
|
626
|
-
*/
|
|
627
|
-
getProblemCheckpoints(userId: string, minRollbackCount?: number): Promise<CheckpointRecord[]>;
|
|
628
|
-
/**
|
|
629
|
-
* Get the context compaction configuration.
|
|
630
|
-
* @returns The compaction configuration or null if not configured.
|
|
631
|
-
*/
|
|
632
|
-
getCompactionConfig(): ContextCompactionConfig | null;
|
|
633
|
-
/**
|
|
634
|
-
* Check if a session's messages need compaction based on token count.
|
|
635
|
-
* Uses character-based estimation for quick checks.
|
|
636
|
-
*
|
|
637
|
-
* @param messages - Array of messages to check
|
|
638
|
-
* @returns True if compaction is recommended
|
|
639
|
-
*/
|
|
640
|
-
shouldCompactMessages(messages: {
|
|
641
|
-
content: string | unknown;
|
|
642
|
-
}[]): boolean;
|
|
643
|
-
/**
|
|
644
|
-
* Record a compaction event for a session.
|
|
645
|
-
* This helps track when and why compaction occurs.
|
|
646
|
-
*
|
|
647
|
-
* @param threadId - The session thread ID
|
|
648
|
-
* @param originalMessageCount - Number of messages before compaction
|
|
649
|
-
* @param compactedMessageCount - Number of messages after compaction
|
|
650
|
-
* @param reason - Reason for compaction
|
|
651
|
-
*/
|
|
652
|
-
recordCompaction(threadId: string, originalMessageCount: number, compactedMessageCount: number, reason?: string): Promise<void>;
|
|
653
|
-
/**
|
|
654
|
-
* Get compaction history for a session.
|
|
655
|
-
*
|
|
656
|
-
* @param threadId - The session thread ID
|
|
657
|
-
* @returns Array of compaction events
|
|
658
|
-
*/
|
|
659
|
-
getCompactionHistory(threadId: string): Array<{
|
|
660
|
-
timestamp: number;
|
|
661
|
-
originalMessageCount: number;
|
|
662
|
-
compactedMessageCount: number;
|
|
663
|
-
reason: string;
|
|
664
|
-
}>;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Skill-Based DeepAgent Factory
|
|
669
|
-
*
|
|
670
|
-
* Creates DeepAgent instances that use skills as the primary prompt source.
|
|
671
|
-
* No custom system prompts - all agent behavior is defined through skills.
|
|
672
|
-
*
|
|
673
|
-
* Uses deepagents library primitives:
|
|
674
|
-
* - createDeepAgent() for agent creation
|
|
675
|
-
* - FilesystemBackend for file operations
|
|
676
|
-
*
|
|
677
|
-
* Skill loading is injected via SkillLoader functions, keeping this package
|
|
678
|
-
* independent of any specific skill registry location.
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* Skill definition loaded by the consumer.
|
|
683
|
-
*/
|
|
684
|
-
interface Skill {
|
|
685
|
-
name: string;
|
|
686
|
-
description: string;
|
|
687
|
-
content: string;
|
|
688
|
-
allowedTools?: string[];
|
|
689
|
-
version?: string;
|
|
690
|
-
references: string[];
|
|
691
|
-
path?: string;
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Function to load a skill by name.
|
|
695
|
-
*/
|
|
696
|
-
type SkillLoader = (name: string) => Skill | null;
|
|
697
|
-
/**
|
|
698
|
-
* Function to load a skill reference by skill name and ref name.
|
|
699
|
-
*/
|
|
700
|
-
type SkillRefLoader = (skillName: string, refName: string) => string | null;
|
|
701
|
-
/**
|
|
702
|
-
* Options for creating a skill agent.
|
|
703
|
-
*/
|
|
704
|
-
interface SkillAgentOptions {
|
|
705
|
-
/** Required: The skill(s) to use. Can be a single skill or array of skills. */
|
|
706
|
-
skill: string | string[];
|
|
707
|
-
/** Required: Working directory for the agent */
|
|
708
|
-
workDir: string;
|
|
709
|
-
/** Required: Function to load skills */
|
|
710
|
-
skillLoader: SkillLoader;
|
|
711
|
-
/** Optional: Function to load skill references */
|
|
712
|
-
skillRefLoader?: SkillRefLoader;
|
|
713
|
-
/** Optional: Thread ID for session continuity */
|
|
714
|
-
threadId?: string;
|
|
715
|
-
/** Optional: LLM provider for main agent */
|
|
716
|
-
provider?: LLMProvider;
|
|
717
|
-
/** Optional: Model name for main agent */
|
|
718
|
-
model?: string;
|
|
719
|
-
/** Optional: LLM provider for subagents (orbital, trait, domain generation). Defaults to 'anthropic' */
|
|
720
|
-
subagentProvider?: LLMProvider;
|
|
721
|
-
/** Optional: Model name for subagents. Defaults to 'claude-sonnet-4-20250514' */
|
|
722
|
-
subagentModel?: string;
|
|
723
|
-
/** Optional: Enable verbose logging */
|
|
724
|
-
verbose?: boolean;
|
|
725
|
-
/** Optional: Disable human-in-the-loop interrupts (for eval/testing) */
|
|
726
|
-
noInterrupt?: boolean;
|
|
727
|
-
/** Optional: Callback for subagent events (orbital generation) */
|
|
728
|
-
onSubagentEvent?: SubagentEventCallback;
|
|
729
|
-
/** Optional: Session manager instance (shared across requests) */
|
|
730
|
-
sessionManager?: SessionManager;
|
|
731
|
-
/** Optional: Extracted requirements from analysis phase (for orbital skill) */
|
|
732
|
-
requirements?: {
|
|
733
|
-
entities?: string[];
|
|
734
|
-
states?: string[];
|
|
735
|
-
events?: string[];
|
|
736
|
-
guards?: string[];
|
|
737
|
-
pages?: string[];
|
|
738
|
-
effects?: string[];
|
|
739
|
-
rawRequirements?: string[];
|
|
740
|
-
};
|
|
741
|
-
/** Optional: GitHub integration configuration */
|
|
742
|
-
githubConfig?: {
|
|
743
|
-
/** GitHub personal access token */
|
|
744
|
-
token: string;
|
|
745
|
-
/** Repository owner (e.g., 'octocat') */
|
|
746
|
-
owner?: string;
|
|
747
|
-
/** Repository name (e.g., 'hello-world') */
|
|
748
|
-
repo?: string;
|
|
749
|
-
};
|
|
750
|
-
/** Optional: Memory manager for user/project memory (GAP-001) */
|
|
751
|
-
memoryManager?: MemoryManager;
|
|
752
|
-
/** Optional: User ID for memory lookup */
|
|
753
|
-
userId?: string;
|
|
754
|
-
/** Optional: App ID for project context */
|
|
755
|
-
appId?: string;
|
|
756
|
-
/** Optional: Tool wrapper for workflow execution (adds retry, telemetry) */
|
|
757
|
-
toolWrapper?: <T extends {
|
|
758
|
-
name: string;
|
|
759
|
-
invoke: (...args: any[]) => Promise<any>;
|
|
760
|
-
}>(tool: T) => T;
|
|
761
|
-
/** Optional: Use orchestrated generation/fixing with complexity-based routing */
|
|
762
|
-
useOrchestration?: boolean;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Agent interface with stream method (simplified from DeepAgent)
|
|
766
|
-
*/
|
|
767
|
-
interface SkillAgent {
|
|
768
|
-
stream: (input: {
|
|
769
|
-
messages: Array<{
|
|
770
|
-
role: string;
|
|
771
|
-
content: string;
|
|
772
|
-
}>;
|
|
773
|
-
}, config: {
|
|
774
|
-
configurable: {
|
|
775
|
-
thread_id: string;
|
|
776
|
-
};
|
|
777
|
-
}) => Promise<AsyncIterable<{
|
|
778
|
-
events?: Array<{
|
|
779
|
-
type: string;
|
|
780
|
-
[key: string]: unknown;
|
|
781
|
-
}>;
|
|
782
|
-
model_request?: {
|
|
783
|
-
messages?: Array<{
|
|
784
|
-
kwargs?: {
|
|
785
|
-
content?: Array<{
|
|
786
|
-
type: string;
|
|
787
|
-
}>;
|
|
788
|
-
};
|
|
789
|
-
}>;
|
|
790
|
-
};
|
|
791
|
-
}>>;
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Result from creating a skill agent.
|
|
795
|
-
*/
|
|
796
|
-
interface SkillAgentResult {
|
|
797
|
-
/** The agent instance (from deepagents library) */
|
|
798
|
-
agent: SkillAgent;
|
|
799
|
-
/** Thread ID for session resumption */
|
|
800
|
-
threadId: string;
|
|
801
|
-
/** The loaded skill(s) - primary skill when single, all skills when multiple */
|
|
802
|
-
skill: Skill;
|
|
803
|
-
/** All loaded skills (same as skill when single) */
|
|
804
|
-
skills: Skill[];
|
|
805
|
-
/** Working directory */
|
|
806
|
-
workDir: string;
|
|
807
|
-
/** Orbital tool setter for wiring SSE callback (if orbital tool enabled) */
|
|
808
|
-
setOrbitalEventCallback?: (callback: SubagentEventCallback) => void;
|
|
809
|
-
/** Orbital tool setter for wiring persistence callback */
|
|
810
|
-
setOrbitalCompleteCallback?: (callback: OrbitalCompleteCallback) => void;
|
|
811
|
-
/** Domain orbital callback for lean skill Firestore persistence */
|
|
812
|
-
setDomainCompleteCallback?: (callback: DomainOrbitalCompleteCallback) => void;
|
|
813
|
-
/** User preferences loaded from memory (GAP-001) */
|
|
814
|
-
userPreferences?: UserPreference | null;
|
|
815
|
-
/** Project context loaded from memory (GAP-001) */
|
|
816
|
-
projectContext?: ProjectContext | null;
|
|
817
|
-
/** Memory manager instance (GAP-001) */
|
|
818
|
-
memoryManager?: MemoryManager;
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Create a skill-based DeepAgent.
|
|
822
|
-
*
|
|
823
|
-
* Uses the specified skill's content as the system prompt.
|
|
824
|
-
* When multiple skills are provided, the agent sees all skill descriptions
|
|
825
|
-
* and can choose the appropriate one based on the user's request.
|
|
826
|
-
*
|
|
827
|
-
* @throws Error if any skill is not found
|
|
828
|
-
*/
|
|
829
|
-
declare function createSkillAgent(options: SkillAgentOptions): Promise<SkillAgentResult>;
|
|
830
|
-
/**
|
|
831
|
-
* Resume a skill agent session.
|
|
832
|
-
*
|
|
833
|
-
* Loads the skill from session metadata and creates agent with same threadId.
|
|
834
|
-
*
|
|
835
|
-
* @throws Error if session not found
|
|
836
|
-
*/
|
|
837
|
-
declare function resumeSkillAgent(threadId: string, options: {
|
|
838
|
-
verbose?: boolean;
|
|
839
|
-
noInterrupt?: boolean;
|
|
840
|
-
skillLoader: SkillLoader;
|
|
841
|
-
skillRefLoader?: SkillRefLoader;
|
|
842
|
-
sessionManager?: SessionManager;
|
|
843
|
-
}): Promise<SkillAgentResult>;
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Event Budget Configuration
|
|
847
|
-
*
|
|
848
|
-
* Prevents runaway agent loops with soft/hard event limits per skill.
|
|
849
|
-
*/
|
|
850
|
-
/**
|
|
851
|
-
* Event budget limits for different skills.
|
|
852
|
-
* - soft: Warning threshold (agent reminded to finish up)
|
|
853
|
-
* - hard: Maximum events before forced completion
|
|
854
|
-
*/
|
|
855
|
-
declare const EVENT_BUDGETS: Record<string, {
|
|
856
|
-
soft: number;
|
|
857
|
-
hard: number;
|
|
858
|
-
}>;
|
|
859
|
-
/**
|
|
860
|
-
* Get event budget for a skill.
|
|
861
|
-
*/
|
|
862
|
-
declare function getEventBudget(skillName: string): {
|
|
863
|
-
soft: number;
|
|
864
|
-
hard: number;
|
|
865
|
-
};
|
|
866
|
-
/**
|
|
867
|
-
* Generate a budget warning message to inject into the agent.
|
|
868
|
-
*/
|
|
869
|
-
declare function getBudgetWarningMessage(eventCount: number, budget: {
|
|
870
|
-
soft: number;
|
|
871
|
-
hard: number;
|
|
872
|
-
}): string | null;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Interrupt Configuration
|
|
876
|
-
*
|
|
877
|
-
* Human-in-the-loop configuration for agent tools.
|
|
878
|
-
*
|
|
879
|
-
* Threshold-gated actions (require k-of-n approval):
|
|
880
|
-
*
|
|
881
|
-
* | Action | Risk | Gate |
|
|
882
|
-
* |----------------------------------------------|-----------------------|-------|
|
|
883
|
-
* | pnpm publish / npm publish | Irreversible registry | 2-of-2 |
|
|
884
|
-
* | git push to main / production deploy | Live users affected | 2-of-2 |
|
|
885
|
-
* | rm -rf / destructive file ops | Data loss | 2-of-2 |
|
|
886
|
-
* | Database migration / persist delete-all | Production data | 2-of-2 |
|
|
887
|
-
* | Read/write .env, secrets, service accounts | Credential exposure | 2-of-2 |
|
|
888
|
-
* | Cross-user data operations | Privacy violation | 2-of-2 |
|
|
889
|
-
* | Schema deploy to production orbital | Breaking change risk | 1-of-2 |
|
|
890
|
-
*
|
|
891
|
-
* Routine actions (no gate): compile, validate, read files, npm install.
|
|
892
|
-
*/
|
|
893
|
-
/**
|
|
894
|
-
* Skill metadata (minimal interface for interrupt config).
|
|
895
|
-
*/
|
|
896
|
-
interface SkillMeta {
|
|
897
|
-
name: string;
|
|
898
|
-
allowedTools?: string[];
|
|
899
|
-
}
|
|
900
|
-
/** Risk level of an agent action. */
|
|
901
|
-
type ActionGate = 'none' | 'sensitive' | 'critical';
|
|
902
|
-
/**
|
|
903
|
-
* Maps tool names / command patterns to their required approval gate.
|
|
904
|
-
* Used by the security layer to decide when ThresholdAuthorizer is needed.
|
|
905
|
-
*/
|
|
906
|
-
declare const TOOL_GATES: Record<string, ActionGate>;
|
|
907
|
-
/**
|
|
908
|
-
* Command patterns that classify a shell command as critical.
|
|
909
|
-
* Matched against the command string before execution.
|
|
910
|
-
*/
|
|
911
|
-
declare const CRITICAL_COMMAND_PATTERNS: RegExp[];
|
|
912
|
-
/**
|
|
913
|
-
* Classify a shell command's risk level.
|
|
914
|
-
* Returns 'critical' if the command matches any CRITICAL_COMMAND_PATTERNS,
|
|
915
|
-
* 'sensitive' otherwise.
|
|
916
|
-
*/
|
|
917
|
-
declare function classifyCommand(command: string): ActionGate;
|
|
918
|
-
/**
|
|
919
|
-
* Get interrupt configuration for a skill.
|
|
920
|
-
*
|
|
921
|
-
* Default: require approval for execute tool.
|
|
922
|
-
* Skills can override via frontmatter (future enhancement).
|
|
923
|
-
*/
|
|
924
|
-
declare function getInterruptConfig(_skill: SkillMeta): Record<string, boolean>;
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* Workflow Tool Wrapper
|
|
928
|
-
*
|
|
929
|
-
* Wraps tool execution with workflow capabilities:
|
|
930
|
-
* - Retry on failure with exponential backoff
|
|
931
|
-
* - Per-tool telemetry (duration, retries, success/failure)
|
|
932
|
-
* - Timeout handling
|
|
933
|
-
*
|
|
934
|
-
* Usage:
|
|
935
|
-
* ```typescript
|
|
936
|
-
* const wrapper = createWorkflowToolWrapper({ maxRetries: 3 });
|
|
937
|
-
*
|
|
938
|
-
* const { agent } = await createSkillAgent({
|
|
939
|
-
* skill: 'kflow-orbitals',
|
|
940
|
-
* toolWrapper: wrapper.wrap,
|
|
941
|
-
* });
|
|
942
|
-
*
|
|
943
|
-
* // After execution
|
|
944
|
-
* const telemetry = wrapper.getTelemetry();
|
|
945
|
-
* ```
|
|
946
|
-
*/
|
|
947
|
-
interface WorkflowToolWrapperOptions {
|
|
948
|
-
/** Max retry attempts per tool (default: 3) */
|
|
949
|
-
maxRetries?: number;
|
|
950
|
-
/** Enable telemetry collection (default: true) */
|
|
951
|
-
enableTelemetry?: boolean;
|
|
952
|
-
/** Max execution time per tool in ms (default: 60000) */
|
|
953
|
-
timeoutMs?: number;
|
|
954
|
-
/** Initial backoff in ms (default: 1000) */
|
|
955
|
-
backoffMs?: number;
|
|
956
|
-
}
|
|
957
|
-
interface ToolTelemetry {
|
|
958
|
-
toolName: string;
|
|
959
|
-
durationMs: number;
|
|
960
|
-
retries: number;
|
|
961
|
-
success: boolean;
|
|
962
|
-
error?: string;
|
|
963
|
-
}
|
|
964
|
-
interface WorkflowToolWrapper {
|
|
965
|
-
/** Wrap a tool with retry/telemetry */
|
|
966
|
-
wrap<T extends {
|
|
967
|
-
name: string;
|
|
968
|
-
invoke: (...args: any[]) => Promise<any>;
|
|
969
|
-
}>(tool: T): T;
|
|
970
|
-
/** Get collected telemetry */
|
|
971
|
-
getTelemetry(): ToolTelemetry[];
|
|
972
|
-
/** Reset telemetry */
|
|
973
|
-
resetTelemetry(): void;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Create a workflow tool wrapper
|
|
977
|
-
*
|
|
978
|
-
* @param options - Wrapper configuration
|
|
979
|
-
* @returns Wrapper with wrap() and getTelemetry() methods
|
|
980
|
-
*
|
|
981
|
-
* @example
|
|
982
|
-
* ```typescript
|
|
983
|
-
* const workflow = createWorkflowToolWrapper({ maxRetries: 3 });
|
|
984
|
-
*
|
|
985
|
-
* const { agent } = await createSkillAgent({
|
|
986
|
-
* skill: 'kflow-orbitals',
|
|
987
|
-
* toolWrapper: workflow.wrap,
|
|
988
|
-
* });
|
|
989
|
-
*
|
|
990
|
-
* // Run agent...
|
|
991
|
-
*
|
|
992
|
-
* // Get results
|
|
993
|
-
* console.log(workflow.getTelemetry());
|
|
994
|
-
* // [{ toolName: 'generate_orbital', durationMs: 5000, retries: 1, success: true }]
|
|
995
|
-
* ```
|
|
996
|
-
*/
|
|
997
|
-
declare function createWorkflowToolWrapper(options?: WorkflowToolWrapperOptions): WorkflowToolWrapper;
|
|
998
|
-
/**
|
|
999
|
-
* Create a workflow wrapper specifically for evaluation comparison
|
|
1000
|
-
*
|
|
1001
|
-
* This wrapper logs telemetry to console for debugging
|
|
1002
|
-
*/
|
|
1003
|
-
declare function createEvalWorkflowWrapper(options?: WorkflowToolWrapperOptions): {
|
|
1004
|
-
wrap: <T extends {
|
|
1005
|
-
name: string;
|
|
1006
|
-
invoke: (...args: any[]) => Promise<any>;
|
|
1007
|
-
}>(tool: T) => T;
|
|
1008
|
-
/** Get collected telemetry */
|
|
1009
|
-
getTelemetry(): ToolTelemetry[];
|
|
1010
|
-
/** Reset telemetry */
|
|
1011
|
-
resetTelemetry(): void;
|
|
1012
|
-
};
|
|
1013
|
-
|
|
1014
|
-
export { type ActionGate as A, resumeSkillAgent as B, CRITICAL_COMMAND_PATTERNS as C, DEFAULT_COMPACTION_CONFIG as D, EVENT_BUDGETS as E, type SkillAgent as F, type GenerationSession as G, type InterruptRecord as I, MemoryManager as M, type PatternAffinity as P, SessionManager as S, TOOL_GATES as T, type UserPreference as U, type WorkflowToolWrapper as W, type CheckpointRecord as a, type ContextCompactionConfig as b, type MemoryManagerOptions as c, MemoryOrbitalSchema as d, type ProjectContext as e, type SessionManagerOptions as f, type Skill as g, type SkillAgentOptions as h, type SkillAgentResult as i, type SkillLoader as j, type SkillMeta as k, type SkillRefLoader as l, type ToolApprovalPreference as m, type ToolTelemetry as n, type UserFeedback as o, type WorkflowToolWrapperOptions as p, classifyCommand as q, createEvalWorkflowWrapper as r, createSkillAgent as s, createSummaryPrompt as t, createWorkflowToolWrapper as u, estimateTokens as v, getBudgetWarningMessage as w, getEventBudget as x, getInterruptConfig as y, needsCompaction as z };
|