praisonai 1.0.19 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/context.d.ts +68 -0
- package/dist/agent/context.js +119 -0
- package/dist/agent/enhanced.d.ts +92 -0
- package/dist/agent/enhanced.js +267 -0
- package/dist/agent/handoff.d.ts +82 -0
- package/dist/agent/handoff.js +124 -0
- package/dist/agent/image.d.ts +51 -0
- package/dist/agent/image.js +93 -0
- package/dist/agent/prompt-expander.d.ts +40 -0
- package/dist/agent/prompt-expander.js +84 -0
- package/dist/agent/query-rewriter.d.ts +38 -0
- package/dist/agent/query-rewriter.js +79 -0
- package/dist/agent/research.d.ts +52 -0
- package/dist/agent/research.js +118 -0
- package/dist/agent/router.d.ts +77 -0
- package/dist/agent/router.js +113 -0
- package/dist/agent/simple.js +1 -1
- package/dist/agent/types.js +2 -2
- package/dist/auto/index.d.ts +56 -0
- package/dist/auto/index.js +142 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.js +150 -0
- package/dist/db/index.d.ts +23 -0
- package/dist/db/index.js +72 -0
- package/dist/db/memory-adapter.d.ts +42 -0
- package/dist/db/memory-adapter.js +146 -0
- package/dist/db/types.d.ts +113 -0
- package/dist/db/types.js +5 -0
- package/dist/eval/index.d.ts +61 -0
- package/dist/eval/index.js +157 -0
- package/dist/guardrails/index.d.ts +82 -0
- package/dist/guardrails/index.js +202 -0
- package/dist/guardrails/llm-guardrail.d.ts +40 -0
- package/dist/guardrails/llm-guardrail.js +91 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +122 -1
- package/dist/knowledge/chunking.d.ts +55 -0
- package/dist/knowledge/chunking.js +157 -0
- package/dist/knowledge/rag.d.ts +80 -0
- package/dist/knowledge/rag.js +147 -0
- package/dist/llm/openai.js +1 -1
- package/dist/llm/providers/anthropic.d.ts +33 -0
- package/dist/llm/providers/anthropic.js +291 -0
- package/dist/llm/providers/base.d.ts +25 -0
- package/dist/llm/providers/base.js +43 -0
- package/dist/llm/providers/google.d.ts +27 -0
- package/dist/llm/providers/google.js +275 -0
- package/dist/llm/providers/index.d.ts +43 -0
- package/dist/llm/providers/index.js +116 -0
- package/dist/llm/providers/openai.d.ts +18 -0
- package/dist/llm/providers/openai.js +203 -0
- package/dist/llm/providers/types.d.ts +94 -0
- package/dist/llm/providers/types.js +5 -0
- package/dist/memory/memory.d.ts +92 -0
- package/dist/memory/memory.js +169 -0
- package/dist/observability/index.d.ts +86 -0
- package/dist/observability/index.js +166 -0
- package/dist/planning/index.d.ts +133 -0
- package/dist/planning/index.js +228 -0
- package/dist/session/index.d.ts +111 -0
- package/dist/session/index.js +250 -0
- package/dist/skills/index.d.ts +70 -0
- package/dist/skills/index.js +233 -0
- package/dist/telemetry/index.d.ts +102 -0
- package/dist/telemetry/index.js +187 -0
- package/dist/tools/decorator.d.ts +91 -0
- package/dist/tools/decorator.js +165 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/mcpSse.d.ts +41 -0
- package/dist/tools/mcpSse.js +108 -0
- package/dist/workflows/index.d.ts +97 -0
- package/dist/workflows/index.js +216 -0
- package/package.json +5 -2
package/dist/memory/memory.js
CHANGED
|
@@ -1 +1,170 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Memory System - Conversation and context memory management
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Memory = void 0;
|
|
7
|
+
exports.createMemory = createMemory;
|
|
8
|
+
/**
|
|
9
|
+
* Memory class for managing conversation history and context
|
|
10
|
+
*/
|
|
11
|
+
class Memory {
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
this.entries = new Map();
|
|
14
|
+
this.maxEntries = config.maxEntries ?? 1000;
|
|
15
|
+
this.maxTokens = config.maxTokens ?? 100000;
|
|
16
|
+
this.embeddingProvider = config.embeddingProvider;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Add a memory entry
|
|
20
|
+
*/
|
|
21
|
+
async add(content, role, metadata) {
|
|
22
|
+
const id = this.generateId();
|
|
23
|
+
const entry = {
|
|
24
|
+
id,
|
|
25
|
+
content,
|
|
26
|
+
role,
|
|
27
|
+
timestamp: Date.now(),
|
|
28
|
+
metadata
|
|
29
|
+
};
|
|
30
|
+
if (this.embeddingProvider) {
|
|
31
|
+
entry.embedding = await this.embeddingProvider.embed(content);
|
|
32
|
+
}
|
|
33
|
+
this.entries.set(id, entry);
|
|
34
|
+
this.enforceLimit();
|
|
35
|
+
return entry;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get a memory entry by ID
|
|
39
|
+
*/
|
|
40
|
+
get(id) {
|
|
41
|
+
return this.entries.get(id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all entries
|
|
45
|
+
*/
|
|
46
|
+
getAll() {
|
|
47
|
+
return Array.from(this.entries.values())
|
|
48
|
+
.sort((a, b) => a.timestamp - b.timestamp);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get recent entries
|
|
52
|
+
*/
|
|
53
|
+
getRecent(count) {
|
|
54
|
+
return this.getAll().slice(-count);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Search memory by text similarity
|
|
58
|
+
*/
|
|
59
|
+
async search(query, limit = 5) {
|
|
60
|
+
if (!this.embeddingProvider) {
|
|
61
|
+
// Fallback to simple text matching
|
|
62
|
+
return this.textSearch(query, limit);
|
|
63
|
+
}
|
|
64
|
+
const queryEmbedding = await this.embeddingProvider.embed(query);
|
|
65
|
+
const results = [];
|
|
66
|
+
for (const entry of this.entries.values()) {
|
|
67
|
+
if (entry.embedding) {
|
|
68
|
+
const score = this.cosineSimilarity(queryEmbedding, entry.embedding);
|
|
69
|
+
results.push({ entry, score });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return results
|
|
73
|
+
.sort((a, b) => b.score - a.score)
|
|
74
|
+
.slice(0, limit);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Simple text search fallback
|
|
78
|
+
*/
|
|
79
|
+
textSearch(query, limit) {
|
|
80
|
+
const queryLower = query.toLowerCase();
|
|
81
|
+
const results = [];
|
|
82
|
+
for (const entry of this.entries.values()) {
|
|
83
|
+
const contentLower = entry.content.toLowerCase();
|
|
84
|
+
if (contentLower.includes(queryLower)) {
|
|
85
|
+
const score = queryLower.length / contentLower.length;
|
|
86
|
+
results.push({ entry, score: Math.min(score * 10, 1) });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return results
|
|
90
|
+
.sort((a, b) => b.score - a.score)
|
|
91
|
+
.slice(0, limit);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculate cosine similarity
|
|
95
|
+
*/
|
|
96
|
+
cosineSimilarity(a, b) {
|
|
97
|
+
if (a.length !== b.length)
|
|
98
|
+
return 0;
|
|
99
|
+
let dotProduct = 0;
|
|
100
|
+
let normA = 0;
|
|
101
|
+
let normB = 0;
|
|
102
|
+
for (let i = 0; i < a.length; i++) {
|
|
103
|
+
dotProduct += a[i] * b[i];
|
|
104
|
+
normA += a[i] * a[i];
|
|
105
|
+
normB += b[i] * b[i];
|
|
106
|
+
}
|
|
107
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
108
|
+
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Delete a memory entry
|
|
112
|
+
*/
|
|
113
|
+
delete(id) {
|
|
114
|
+
return this.entries.delete(id);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Clear all memory
|
|
118
|
+
*/
|
|
119
|
+
clear() {
|
|
120
|
+
this.entries.clear();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get memory size
|
|
124
|
+
*/
|
|
125
|
+
get size() {
|
|
126
|
+
return this.entries.size;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build context string from recent memory
|
|
130
|
+
*/
|
|
131
|
+
buildContext(count) {
|
|
132
|
+
const entries = count ? this.getRecent(count) : this.getAll();
|
|
133
|
+
return entries
|
|
134
|
+
.map(e => `${e.role}: ${e.content}`)
|
|
135
|
+
.join('\n');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Export memory to JSON
|
|
139
|
+
*/
|
|
140
|
+
toJSON() {
|
|
141
|
+
return this.getAll();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Import memory from JSON
|
|
145
|
+
*/
|
|
146
|
+
fromJSON(entries) {
|
|
147
|
+
this.entries.clear();
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
this.entries.set(entry.id, entry);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
generateId() {
|
|
153
|
+
return `mem_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
154
|
+
}
|
|
155
|
+
enforceLimit() {
|
|
156
|
+
while (this.entries.size > this.maxEntries) {
|
|
157
|
+
const oldest = this.getAll()[0];
|
|
158
|
+
if (oldest) {
|
|
159
|
+
this.entries.delete(oldest.id);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.Memory = Memory;
|
|
165
|
+
/**
|
|
166
|
+
* Create a memory instance
|
|
167
|
+
*/
|
|
168
|
+
function createMemory(config) {
|
|
169
|
+
return new Memory(config);
|
|
170
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability - Tracing, logging, and metrics hooks
|
|
3
|
+
*/
|
|
4
|
+
export type SpanKind = 'llm' | 'tool' | 'agent' | 'workflow' | 'custom';
|
|
5
|
+
export type SpanStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
6
|
+
export interface SpanData {
|
|
7
|
+
id: string;
|
|
8
|
+
traceId: string;
|
|
9
|
+
parentId?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
kind: SpanKind;
|
|
12
|
+
status: SpanStatus;
|
|
13
|
+
startTime: number;
|
|
14
|
+
endTime?: number;
|
|
15
|
+
attributes: Record<string, any>;
|
|
16
|
+
events: SpanEvent[];
|
|
17
|
+
}
|
|
18
|
+
export interface SpanEvent {
|
|
19
|
+
name: string;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
attributes?: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
export interface TraceData {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
startTime: number;
|
|
27
|
+
endTime?: number;
|
|
28
|
+
status: SpanStatus;
|
|
29
|
+
spans: SpanData[];
|
|
30
|
+
metadata: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Observability Adapter Protocol
|
|
34
|
+
*/
|
|
35
|
+
export interface ObservabilityAdapter {
|
|
36
|
+
startTrace(name: string, metadata?: Record<string, any>): TraceContext;
|
|
37
|
+
endTrace(traceId: string, status?: SpanStatus): void;
|
|
38
|
+
startSpan(traceId: string, name: string, kind: SpanKind, parentId?: string): SpanContext;
|
|
39
|
+
endSpan(spanId: string, status?: SpanStatus, attributes?: Record<string, any>): void;
|
|
40
|
+
addEvent(spanId: string, name: string, attributes?: Record<string, any>): void;
|
|
41
|
+
flush(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export interface TraceContext {
|
|
44
|
+
traceId: string;
|
|
45
|
+
startSpan(name: string, kind: SpanKind): SpanContext;
|
|
46
|
+
end(status?: SpanStatus): void;
|
|
47
|
+
}
|
|
48
|
+
export interface SpanContext {
|
|
49
|
+
spanId: string;
|
|
50
|
+
traceId: string;
|
|
51
|
+
addEvent(name: string, attributes?: Record<string, any>): void;
|
|
52
|
+
setAttributes(attributes: Record<string, any>): void;
|
|
53
|
+
end(status?: SpanStatus): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* In-memory observability adapter for development
|
|
57
|
+
*/
|
|
58
|
+
export declare class MemoryObservabilityAdapter implements ObservabilityAdapter {
|
|
59
|
+
private traces;
|
|
60
|
+
private spans;
|
|
61
|
+
startTrace(name: string, metadata?: Record<string, any>): TraceContext;
|
|
62
|
+
endTrace(traceId: string, status?: SpanStatus): void;
|
|
63
|
+
startSpan(traceId: string, name: string, kind: SpanKind, parentId?: string): SpanContext;
|
|
64
|
+
endSpan(spanId: string, status?: SpanStatus, attributes?: Record<string, any>): void;
|
|
65
|
+
addEvent(spanId: string, name: string, attributes?: Record<string, any>): void;
|
|
66
|
+
flush(): Promise<void>;
|
|
67
|
+
getTrace(traceId: string): TraceData | undefined;
|
|
68
|
+
getSpan(spanId: string): SpanData | undefined;
|
|
69
|
+
getAllTraces(): TraceData[];
|
|
70
|
+
clear(): void;
|
|
71
|
+
private generateId;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Console observability adapter for debugging
|
|
75
|
+
*/
|
|
76
|
+
export declare class ConsoleObservabilityAdapter implements ObservabilityAdapter {
|
|
77
|
+
private memory;
|
|
78
|
+
startTrace(name: string, metadata?: Record<string, any>): TraceContext;
|
|
79
|
+
endTrace(traceId: string, status?: SpanStatus): void;
|
|
80
|
+
startSpan(traceId: string, name: string, kind: SpanKind, parentId?: string): SpanContext;
|
|
81
|
+
endSpan(spanId: string, status?: SpanStatus, attributes?: Record<string, any>): void;
|
|
82
|
+
addEvent(spanId: string, name: string, attributes?: Record<string, any>): void;
|
|
83
|
+
flush(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
export declare function setObservabilityAdapter(adapter: ObservabilityAdapter): void;
|
|
86
|
+
export declare function getObservabilityAdapter(): ObservabilityAdapter;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Observability - Tracing, logging, and metrics hooks
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConsoleObservabilityAdapter = exports.MemoryObservabilityAdapter = void 0;
|
|
7
|
+
exports.setObservabilityAdapter = setObservabilityAdapter;
|
|
8
|
+
exports.getObservabilityAdapter = getObservabilityAdapter;
|
|
9
|
+
/**
|
|
10
|
+
* In-memory observability adapter for development
|
|
11
|
+
*/
|
|
12
|
+
class MemoryObservabilityAdapter {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.traces = new Map();
|
|
15
|
+
this.spans = new Map();
|
|
16
|
+
}
|
|
17
|
+
startTrace(name, metadata = {}) {
|
|
18
|
+
const traceId = this.generateId();
|
|
19
|
+
const trace = {
|
|
20
|
+
id: traceId,
|
|
21
|
+
name,
|
|
22
|
+
startTime: Date.now(),
|
|
23
|
+
status: 'running',
|
|
24
|
+
spans: [],
|
|
25
|
+
metadata
|
|
26
|
+
};
|
|
27
|
+
this.traces.set(traceId, trace);
|
|
28
|
+
const self = this;
|
|
29
|
+
return {
|
|
30
|
+
traceId,
|
|
31
|
+
startSpan(spanName, kind) {
|
|
32
|
+
return self.startSpan(traceId, spanName, kind);
|
|
33
|
+
},
|
|
34
|
+
end(status = 'completed') {
|
|
35
|
+
self.endTrace(traceId, status);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
endTrace(traceId, status = 'completed') {
|
|
40
|
+
const trace = this.traces.get(traceId);
|
|
41
|
+
if (trace) {
|
|
42
|
+
trace.endTime = Date.now();
|
|
43
|
+
trace.status = status;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
startSpan(traceId, name, kind, parentId) {
|
|
47
|
+
const spanId = this.generateId();
|
|
48
|
+
const span = {
|
|
49
|
+
id: spanId,
|
|
50
|
+
traceId,
|
|
51
|
+
parentId,
|
|
52
|
+
name,
|
|
53
|
+
kind,
|
|
54
|
+
status: 'running',
|
|
55
|
+
startTime: Date.now(),
|
|
56
|
+
attributes: {},
|
|
57
|
+
events: []
|
|
58
|
+
};
|
|
59
|
+
this.spans.set(spanId, span);
|
|
60
|
+
const trace = this.traces.get(traceId);
|
|
61
|
+
if (trace) {
|
|
62
|
+
trace.spans.push(span);
|
|
63
|
+
}
|
|
64
|
+
const self = this;
|
|
65
|
+
return {
|
|
66
|
+
spanId,
|
|
67
|
+
traceId,
|
|
68
|
+
addEvent(eventName, attributes) {
|
|
69
|
+
self.addEvent(spanId, eventName, attributes);
|
|
70
|
+
},
|
|
71
|
+
setAttributes(attributes) {
|
|
72
|
+
const s = self.spans.get(spanId);
|
|
73
|
+
if (s) {
|
|
74
|
+
s.attributes = { ...s.attributes, ...attributes };
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
end(status = 'completed') {
|
|
78
|
+
self.endSpan(spanId, status);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
endSpan(spanId, status = 'completed', attributes) {
|
|
83
|
+
const span = this.spans.get(spanId);
|
|
84
|
+
if (span) {
|
|
85
|
+
span.endTime = Date.now();
|
|
86
|
+
span.status = status;
|
|
87
|
+
if (attributes) {
|
|
88
|
+
span.attributes = { ...span.attributes, ...attributes };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
addEvent(spanId, name, attributes) {
|
|
93
|
+
const span = this.spans.get(spanId);
|
|
94
|
+
if (span) {
|
|
95
|
+
span.events.push({
|
|
96
|
+
name,
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
attributes
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async flush() {
|
|
103
|
+
// No-op for memory adapter
|
|
104
|
+
}
|
|
105
|
+
// Utility methods
|
|
106
|
+
getTrace(traceId) {
|
|
107
|
+
return this.traces.get(traceId);
|
|
108
|
+
}
|
|
109
|
+
getSpan(spanId) {
|
|
110
|
+
return this.spans.get(spanId);
|
|
111
|
+
}
|
|
112
|
+
getAllTraces() {
|
|
113
|
+
return Array.from(this.traces.values());
|
|
114
|
+
}
|
|
115
|
+
clear() {
|
|
116
|
+
this.traces.clear();
|
|
117
|
+
this.spans.clear();
|
|
118
|
+
}
|
|
119
|
+
generateId() {
|
|
120
|
+
return Math.random().toString(36).substring(2, 15);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.MemoryObservabilityAdapter = MemoryObservabilityAdapter;
|
|
124
|
+
/**
|
|
125
|
+
* Console observability adapter for debugging
|
|
126
|
+
*/
|
|
127
|
+
class ConsoleObservabilityAdapter {
|
|
128
|
+
constructor() {
|
|
129
|
+
this.memory = new MemoryObservabilityAdapter();
|
|
130
|
+
}
|
|
131
|
+
startTrace(name, metadata) {
|
|
132
|
+
console.log(`[TRACE START] ${name}`, metadata || '');
|
|
133
|
+
return this.memory.startTrace(name, metadata);
|
|
134
|
+
}
|
|
135
|
+
endTrace(traceId, status) {
|
|
136
|
+
console.log(`[TRACE END] ${traceId} - ${status || 'completed'}`);
|
|
137
|
+
this.memory.endTrace(traceId, status);
|
|
138
|
+
}
|
|
139
|
+
startSpan(traceId, name, kind, parentId) {
|
|
140
|
+
console.log(` [SPAN START] ${name} (${kind})`);
|
|
141
|
+
return this.memory.startSpan(traceId, name, kind, parentId);
|
|
142
|
+
}
|
|
143
|
+
endSpan(spanId, status, attributes) {
|
|
144
|
+
console.log(` [SPAN END] ${spanId} - ${status || 'completed'}`, attributes || '');
|
|
145
|
+
this.memory.endSpan(spanId, status, attributes);
|
|
146
|
+
}
|
|
147
|
+
addEvent(spanId, name, attributes) {
|
|
148
|
+
console.log(` [EVENT] ${name}`, attributes || '');
|
|
149
|
+
this.memory.addEvent(spanId, name, attributes);
|
|
150
|
+
}
|
|
151
|
+
async flush() {
|
|
152
|
+
await this.memory.flush();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.ConsoleObservabilityAdapter = ConsoleObservabilityAdapter;
|
|
156
|
+
// Global observability instance
|
|
157
|
+
let globalAdapter = null;
|
|
158
|
+
function setObservabilityAdapter(adapter) {
|
|
159
|
+
globalAdapter = adapter;
|
|
160
|
+
}
|
|
161
|
+
function getObservabilityAdapter() {
|
|
162
|
+
if (!globalAdapter) {
|
|
163
|
+
globalAdapter = new MemoryObservabilityAdapter();
|
|
164
|
+
}
|
|
165
|
+
return globalAdapter;
|
|
166
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning System - Plans, Steps, and TodoLists
|
|
3
|
+
*/
|
|
4
|
+
export type PlanStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
|
5
|
+
export type TodoStatus = 'pending' | 'in_progress' | 'completed';
|
|
6
|
+
export interface PlanConfig {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
metadata?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
export interface PlanStepConfig {
|
|
12
|
+
description: string;
|
|
13
|
+
status?: PlanStatus;
|
|
14
|
+
order?: number;
|
|
15
|
+
dependencies?: string[];
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface TodoItemConfig {
|
|
19
|
+
content: string;
|
|
20
|
+
priority?: 'low' | 'medium' | 'high';
|
|
21
|
+
status?: TodoStatus;
|
|
22
|
+
dueDate?: Date;
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* PlanStep - A single step in a plan
|
|
27
|
+
*/
|
|
28
|
+
export declare class PlanStep {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
description: string;
|
|
31
|
+
status: PlanStatus;
|
|
32
|
+
order: number;
|
|
33
|
+
dependencies: string[];
|
|
34
|
+
metadata: Record<string, any>;
|
|
35
|
+
startedAt?: number;
|
|
36
|
+
completedAt?: number;
|
|
37
|
+
constructor(config: PlanStepConfig);
|
|
38
|
+
start(): this;
|
|
39
|
+
complete(): this;
|
|
40
|
+
fail(): this;
|
|
41
|
+
cancel(): this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Plan - A collection of steps to accomplish a goal
|
|
45
|
+
*/
|
|
46
|
+
export declare class Plan {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
steps: PlanStep[];
|
|
51
|
+
status: PlanStatus;
|
|
52
|
+
metadata: Record<string, any>;
|
|
53
|
+
createdAt: number;
|
|
54
|
+
updatedAt: number;
|
|
55
|
+
constructor(config: PlanConfig);
|
|
56
|
+
addStep(step: PlanStep): this;
|
|
57
|
+
removeStep(stepId: string): boolean;
|
|
58
|
+
getStep(stepId: string): PlanStep | undefined;
|
|
59
|
+
getNextStep(): PlanStep | undefined;
|
|
60
|
+
getProgress(): {
|
|
61
|
+
completed: number;
|
|
62
|
+
total: number;
|
|
63
|
+
percentage: number;
|
|
64
|
+
};
|
|
65
|
+
start(): this;
|
|
66
|
+
complete(): this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* TodoItem - A single todo item
|
|
70
|
+
*/
|
|
71
|
+
export declare class TodoItem {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
content: string;
|
|
74
|
+
priority: 'low' | 'medium' | 'high';
|
|
75
|
+
status: TodoStatus;
|
|
76
|
+
dueDate?: Date;
|
|
77
|
+
metadata: Record<string, any>;
|
|
78
|
+
createdAt: number;
|
|
79
|
+
completedAt?: number;
|
|
80
|
+
constructor(config: TodoItemConfig);
|
|
81
|
+
start(): this;
|
|
82
|
+
complete(): this;
|
|
83
|
+
reset(): this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* TodoList - A collection of todo items
|
|
87
|
+
*/
|
|
88
|
+
export declare class TodoList {
|
|
89
|
+
readonly id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
items: TodoItem[];
|
|
92
|
+
createdAt: number;
|
|
93
|
+
constructor(name?: string);
|
|
94
|
+
add(item: TodoItem): this;
|
|
95
|
+
remove(itemId: string): boolean;
|
|
96
|
+
get(itemId: string): TodoItem | undefined;
|
|
97
|
+
getPending(): TodoItem[];
|
|
98
|
+
getCompleted(): TodoItem[];
|
|
99
|
+
getByPriority(priority: 'low' | 'medium' | 'high'): TodoItem[];
|
|
100
|
+
getProgress(): {
|
|
101
|
+
completed: number;
|
|
102
|
+
total: number;
|
|
103
|
+
percentage: number;
|
|
104
|
+
};
|
|
105
|
+
clear(): this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* PlanStorage - Persist plans (in-memory implementation)
|
|
109
|
+
*/
|
|
110
|
+
export declare class PlanStorage {
|
|
111
|
+
private plans;
|
|
112
|
+
private todoLists;
|
|
113
|
+
savePlan(plan: Plan): void;
|
|
114
|
+
getPlan(planId: string): Plan | undefined;
|
|
115
|
+
deletePlan(planId: string): boolean;
|
|
116
|
+
listPlans(): Plan[];
|
|
117
|
+
saveTodoList(list: TodoList): void;
|
|
118
|
+
getTodoList(listId: string): TodoList | undefined;
|
|
119
|
+
deleteTodoList(listId: string): boolean;
|
|
120
|
+
listTodoLists(): TodoList[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a Plan
|
|
124
|
+
*/
|
|
125
|
+
export declare function createPlan(config: PlanConfig): Plan;
|
|
126
|
+
/**
|
|
127
|
+
* Create a TodoList
|
|
128
|
+
*/
|
|
129
|
+
export declare function createTodoList(name?: string): TodoList;
|
|
130
|
+
/**
|
|
131
|
+
* Create a PlanStorage
|
|
132
|
+
*/
|
|
133
|
+
export declare function createPlanStorage(): PlanStorage;
|