@loom-node/core 0.1.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/LICENSE +21 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.js +32 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/event-bus.test.d.ts +2 -0
- package/dist/__tests__/event-bus.test.d.ts.map +1 -0
- package/dist/__tests__/event-bus.test.js +34 -0
- package/dist/__tests__/event-bus.test.js.map +1 -0
- package/dist/__tests__/interceptor.test.d.ts +2 -0
- package/dist/__tests__/interceptor.test.d.ts.map +1 -0
- package/dist/__tests__/interceptor.test.js +38 -0
- package/dist/__tests__/interceptor.test.js.map +1 -0
- package/dist/agent/agent-loop.d.ts +23 -0
- package/dist/agent/agent-loop.d.ts.map +1 -0
- package/dist/agent/agent-loop.js +38 -0
- package/dist/agent/agent-loop.js.map +1 -0
- package/dist/agent/agent.d.ts +52 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +96 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +3 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/strategies/react.d.ts +7 -0
- package/dist/agent/strategies/react.d.ts.map +1 -0
- package/dist/agent/strategies/react.js +105 -0
- package/dist/agent/strategies/react.js.map +1 -0
- package/dist/agent/strategies/stream-helper.d.ts +8 -0
- package/dist/agent/strategies/stream-helper.d.ts.map +1 -0
- package/dist/agent/strategies/stream-helper.js +42 -0
- package/dist/agent/strategies/stream-helper.js.map +1 -0
- package/dist/agent/strategies/tool-use.d.ts +7 -0
- package/dist/agent/strategies/tool-use.d.ts.map +1 -0
- package/dist/agent/strategies/tool-use.js +100 -0
- package/dist/agent/strategies/tool-use.js.map +1 -0
- package/dist/context/context-orchestrator.d.ts +25 -0
- package/dist/context/context-orchestrator.d.ts.map +1 -0
- package/dist/context/context-orchestrator.js +82 -0
- package/dist/context/context-orchestrator.js.map +1 -0
- package/dist/errors/agent.d.ts +10 -0
- package/dist/errors/agent.d.ts.map +1 -0
- package/dist/errors/agent.js +18 -0
- package/dist/errors/agent.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/llm.d.ts +23 -0
- package/dist/errors/llm.d.ts.map +1 -0
- package/dist/errors/llm.js +48 -0
- package/dist/errors/llm.js.map +1 -0
- package/dist/errors/tool.d.ts +15 -0
- package/dist/errors/tool.d.ts.map +1 -0
- package/dist/errors/tool.js +27 -0
- package/dist/errors/tool.js.map +1 -0
- package/dist/events/event-bus.d.ts +89 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +63 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +2 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor/index.d.ts +3 -0
- package/dist/interceptor/index.d.ts.map +1 -0
- package/dist/interceptor/index.js +2 -0
- package/dist/interceptor/index.js.map +1 -0
- package/dist/interceptor/interceptor.d.ts +17 -0
- package/dist/interceptor/interceptor.d.ts.map +1 -0
- package/dist/interceptor/interceptor.js +18 -0
- package/dist/interceptor/interceptor.js.map +1 -0
- package/dist/session/index.d.ts +3 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +2 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/session.d.ts +14 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +12 -0
- package/dist/session/session.js.map +1 -0
- package/dist/types/amoeba.d.ts +107 -0
- package/dist/types/amoeba.d.ts.map +1 -0
- package/dist/types/amoeba.js +2 -0
- package/dist/types/amoeba.js.map +1 -0
- package/dist/types/context.d.ts +25 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +3 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/events.d.ts +53 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/knowledge.d.ts +95 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +2 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/llm.d.ts +49 -0
- package/dist/types/llm.d.ts.map +1 -0
- package/dist/types/llm.js +2 -0
- package/dist/types/llm.js.map +1 -0
- package/dist/types/memory.d.ts +44 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +2 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/message.d.ts +30 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +2 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/skill.d.ts +58 -0
- package/dist/types/skill.d.ts.map +1 -0
- package/dist/types/skill.js +2 -0
- package/dist/types/skill.js.map +1 -0
- package/dist/types/strategy.d.ts +25 -0
- package/dist/types/strategy.d.ts.map +1 -0
- package/dist/types/strategy.js +2 -0
- package/dist/types/strategy.js.map +1 -0
- package/dist/types/tool.d.ts +31 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +2 -0
- package/dist/types/tool.js.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type { Message, SystemMessage, UserMessage, AssistantMessage, ToolMessage, ToolCall, ContentPart } from './types/message.js';
|
|
2
|
+
export type { AgentEvent, TextDeltaEvent, ToolCallStartEvent, ToolCallEndEvent, StepStartEvent, StepEndEvent, ErrorEvent, DoneEvent, TokenUsage } from './types/events.js';
|
|
3
|
+
export type { LLMProvider, CompletionParams, CompletionResult, StreamChunk, StreamOptions, JsonToolDefinition, JsonSchema } from './types/llm.js';
|
|
4
|
+
export type { ToolSchema, ToolDefinition, ToolContext, ToolExecutionConfig, ToolResult } from './types/tool.js';
|
|
5
|
+
export type { MemoryLayer, MemoryEntry, MemoryManager, PersistentStore, SearchOptions, ImportanceScorer, Tokenizer, MemoryCompressor } from './types/memory.js';
|
|
6
|
+
export type { Skill, SkillExample, SkillTrigger, KeywordTrigger, PatternTrigger, SemanticTrigger, CustomTrigger, SkillActivation, SkillRegistry, SkillLoader, ActivationLevel } from './types/skill.js';
|
|
7
|
+
export type { Document, Chunk, Chunker, Retriever, RetrieverOptions, RetrievalResult, KnowledgeBase, EmbeddingProvider, VectorEntry, VectorStore, VectorSearchResult, GraphNode, GraphEdge, GraphStore, ExtractedEntity, ExtractedRelation, EntityExtractor } from './types/knowledge.js';
|
|
8
|
+
export type { ContextSource, ContextFragment, ContextProvider, ContextOrchestrator, TokenBudget, BudgetRatios } from './types/context.js';
|
|
9
|
+
export type { CapabilityProfile, RewardSignal, RewardRecord, AgentNodeStatus, AgentNode, TaskAd, TaskResult, TaskResultMetadata, Bid, SubTask, TaskSpec, ComplexityEstimate, IScratchpad, MitosisContext } from './types/amoeba.js';
|
|
10
|
+
export type { LoopStrategy, LoopContext } from './types/strategy.js';
|
|
11
|
+
export { ToolUseStrategy } from './agent/strategies/tool-use.js';
|
|
12
|
+
export { ReactStrategy } from './agent/strategies/react.js';
|
|
13
|
+
export { LoomError, LLMError, LLMRateLimitError, LLMAuthError, LLMStreamInterruptedError } from './errors/llm.js';
|
|
14
|
+
export { ToolError, ToolTimeoutError, ToolResultTooLargeError } from './errors/tool.js';
|
|
15
|
+
export { AgentAbortError, AgentMaxStepsError } from './errors/agent.js';
|
|
16
|
+
export { Agent } from './agent/agent.js';
|
|
17
|
+
export type { AgentConfig } from './agent/agent.js';
|
|
18
|
+
export { agentLoop } from './agent/agent-loop.js';
|
|
19
|
+
export { TypedEventBus } from './events/event-bus.js';
|
|
20
|
+
export { getCurrentSession, runInSession } from './session/session.js';
|
|
21
|
+
export type { SessionContext } from './session/session.js';
|
|
22
|
+
export { ContextOrchestratorImpl } from './context/context-orchestrator.js';
|
|
23
|
+
export type { BudgetConfig } from './context/context-orchestrator.js';
|
|
24
|
+
export { InterceptorChain } from './interceptor/interceptor.js';
|
|
25
|
+
export type { Interceptor, InterceptorContext, Next } from './interceptor/interceptor.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpI,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3K,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAClJ,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChK,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE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EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Strategies
|
|
2
|
+
export { ToolUseStrategy } from './agent/strategies/tool-use.js';
|
|
3
|
+
export { ReactStrategy } from './agent/strategies/react.js';
|
|
4
|
+
// Errors
|
|
5
|
+
export { LoomError, LLMError, LLMRateLimitError, LLMAuthError, LLMStreamInterruptedError } from './errors/llm.js';
|
|
6
|
+
export { ToolError, ToolTimeoutError, ToolResultTooLargeError } from './errors/tool.js';
|
|
7
|
+
export { AgentAbortError, AgentMaxStepsError } from './errors/agent.js';
|
|
8
|
+
// Agent
|
|
9
|
+
export { Agent } from './agent/agent.js';
|
|
10
|
+
export { agentLoop } from './agent/agent-loop.js';
|
|
11
|
+
// Events
|
|
12
|
+
export { TypedEventBus } from './events/event-bus.js';
|
|
13
|
+
// Session
|
|
14
|
+
export { getCurrentSession, runInSession } from './session/session.js';
|
|
15
|
+
// Context
|
|
16
|
+
export { ContextOrchestratorImpl } from './context/context-orchestrator.js';
|
|
17
|
+
// Interceptor
|
|
18
|
+
export { InterceptorChain } from './interceptor/interceptor.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,aAAa;AACb,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,SAAS;AACT,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE,QAAQ;AACR,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,SAAS;AACT,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGvE,UAAU;AACV,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interceptor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interceptor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Message } from '../types/message.js';
|
|
2
|
+
export type Next = () => Promise<void>;
|
|
3
|
+
export interface Interceptor {
|
|
4
|
+
name: string;
|
|
5
|
+
intercept(ctx: InterceptorContext, next: Next): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface InterceptorContext {
|
|
8
|
+
messages: Message[];
|
|
9
|
+
metadata: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare class InterceptorChain {
|
|
12
|
+
private interceptors;
|
|
13
|
+
constructor(interceptors?: Interceptor[]);
|
|
14
|
+
use(interceptor: Interceptor): void;
|
|
15
|
+
run(ctx: InterceptorContext): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.d.ts","sourceRoot":"","sources":["../../src/interceptor/interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,gBAAgB;IACf,OAAO,CAAC,YAAY;gBAAZ,YAAY,GAAE,WAAW,EAAO;IAEpD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAI7B,GAAG,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAOlD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class InterceptorChain {
|
|
2
|
+
interceptors;
|
|
3
|
+
constructor(interceptors = []) {
|
|
4
|
+
this.interceptors = interceptors;
|
|
5
|
+
}
|
|
6
|
+
use(interceptor) {
|
|
7
|
+
this.interceptors.push(interceptor);
|
|
8
|
+
}
|
|
9
|
+
async run(ctx) {
|
|
10
|
+
const dispatch = (i) => {
|
|
11
|
+
if (i >= this.interceptors.length)
|
|
12
|
+
return Promise.resolve();
|
|
13
|
+
return this.interceptors[i].intercept(ctx, () => dispatch(i + 1));
|
|
14
|
+
};
|
|
15
|
+
return dispatch(0);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../src/interceptor/interceptor.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,eAA8B,EAAE;QAAhC,iBAAY,GAAZ,YAAY,CAAoB;IAAG,CAAC;IAExD,GAAG,CAAC,WAAwB;QAC1B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAuB;QAC/B,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAiB,EAAE;YAC5C,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM;gBAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;QACF,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemoryManager } from '../types/memory.js';
|
|
2
|
+
import type { ContextOrchestrator } from '../types/context.js';
|
|
3
|
+
import { TypedEventBus } from '../events/event-bus.js';
|
|
4
|
+
export interface SessionContext {
|
|
5
|
+
tenantId: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
memory: MemoryManager;
|
|
9
|
+
events: TypedEventBus;
|
|
10
|
+
context?: ContextOrchestrator;
|
|
11
|
+
}
|
|
12
|
+
export declare function getCurrentSession(): SessionContext;
|
|
13
|
+
export declare function runInSession<T>(session: SessionContext, fn: () => Promise<T>): Promise<T>;
|
|
14
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAID,wBAAgB,iBAAiB,IAAI,cAAc,CAIlD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEzF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
const sessionStore = new AsyncLocalStorage();
|
|
3
|
+
export function getCurrentSession() {
|
|
4
|
+
const ctx = sessionStore.getStore();
|
|
5
|
+
if (!ctx)
|
|
6
|
+
throw new Error('No active session');
|
|
7
|
+
return ctx;
|
|
8
|
+
}
|
|
9
|
+
export function runInSession(session, fn) {
|
|
10
|
+
return sessionStore.run(session, fn);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAcrD,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAE7D,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IACpC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,OAAuB,EAAE,EAAoB;IAC3E,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Agent } from '../agent/agent.js';
|
|
2
|
+
import type { ContextOrchestrator } from './context.js';
|
|
3
|
+
import type { MemoryManager } from './memory.js';
|
|
4
|
+
export interface CapabilityProfile {
|
|
5
|
+
scores: Map<string, number>;
|
|
6
|
+
tools: string[];
|
|
7
|
+
totalTasks: number;
|
|
8
|
+
successRate: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RewardSignal {
|
|
11
|
+
quality: number;
|
|
12
|
+
efficiency: number;
|
|
13
|
+
reliability: number;
|
|
14
|
+
}
|
|
15
|
+
export interface RewardRecord {
|
|
16
|
+
taskId: string;
|
|
17
|
+
reward: number;
|
|
18
|
+
domain: string;
|
|
19
|
+
tokenCost: number;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
}
|
|
22
|
+
export type AgentNodeStatus = 'idle' | 'busy' | 'splitting' | 'dying';
|
|
23
|
+
export interface AgentNode {
|
|
24
|
+
id: string;
|
|
25
|
+
parentId?: string;
|
|
26
|
+
depth: number;
|
|
27
|
+
capabilities: CapabilityProfile;
|
|
28
|
+
rewardHistory: RewardRecord[];
|
|
29
|
+
status: AgentNodeStatus;
|
|
30
|
+
load: number;
|
|
31
|
+
agent: Agent;
|
|
32
|
+
lastActiveAt: number;
|
|
33
|
+
consecutiveLosses: number;
|
|
34
|
+
}
|
|
35
|
+
export interface TaskAd {
|
|
36
|
+
taskId: string;
|
|
37
|
+
domain: string;
|
|
38
|
+
description: string;
|
|
39
|
+
estimatedComplexity: number;
|
|
40
|
+
priority: 'low' | 'normal' | 'high' | 'critical';
|
|
41
|
+
deadline?: number;
|
|
42
|
+
requiredTools?: string[];
|
|
43
|
+
tokenBudget?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface TaskResultMetadata {
|
|
46
|
+
confidence?: number;
|
|
47
|
+
keyFindings?: string[];
|
|
48
|
+
toolsUsed?: string[];
|
|
49
|
+
summary?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface TaskResult {
|
|
52
|
+
taskId: string;
|
|
53
|
+
agentId: string;
|
|
54
|
+
content: string;
|
|
55
|
+
success: boolean;
|
|
56
|
+
tokenCost: number;
|
|
57
|
+
errorCount: number;
|
|
58
|
+
durationMs: number;
|
|
59
|
+
metadata?: TaskResultMetadata;
|
|
60
|
+
}
|
|
61
|
+
export interface Bid {
|
|
62
|
+
agentId: string;
|
|
63
|
+
taskId: string;
|
|
64
|
+
score: number;
|
|
65
|
+
breakdown: {
|
|
66
|
+
capabilityMatch: number;
|
|
67
|
+
availability: number;
|
|
68
|
+
historySuccess: number;
|
|
69
|
+
toolCoverage: number;
|
|
70
|
+
};
|
|
71
|
+
estimatedTokens: number;
|
|
72
|
+
}
|
|
73
|
+
export interface SubTask {
|
|
74
|
+
id: string;
|
|
75
|
+
parentTaskId: string;
|
|
76
|
+
description: string;
|
|
77
|
+
domain: string;
|
|
78
|
+
dependencies: string[];
|
|
79
|
+
resolvedInputs?: Record<string, string>;
|
|
80
|
+
}
|
|
81
|
+
export interface TaskSpec {
|
|
82
|
+
task: TaskAd;
|
|
83
|
+
objective: string;
|
|
84
|
+
outputFormat?: string;
|
|
85
|
+
boundaries?: string;
|
|
86
|
+
toolGuidance?: string;
|
|
87
|
+
domainHints: string[];
|
|
88
|
+
}
|
|
89
|
+
export interface ComplexityEstimate {
|
|
90
|
+
score: number;
|
|
91
|
+
domains: string[];
|
|
92
|
+
reasoning?: string;
|
|
93
|
+
method: 'heuristic' | 'llm';
|
|
94
|
+
}
|
|
95
|
+
export interface IScratchpad {
|
|
96
|
+
readDependencies(depIds: string[]): Record<string, string>;
|
|
97
|
+
readAll(): Record<string, string>;
|
|
98
|
+
}
|
|
99
|
+
export interface MitosisContext {
|
|
100
|
+
parentTaskSpec: Pick<TaskSpec, 'objective' | 'outputFormat' | 'boundaries' | 'toolGuidance'>;
|
|
101
|
+
subtask: SubTask;
|
|
102
|
+
scratchpad: IScratchpad;
|
|
103
|
+
parentTools?: string[];
|
|
104
|
+
context?: ContextOrchestrator;
|
|
105
|
+
memory?: MemoryManager;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=amoeba.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amoeba.d.ts","sourceRoot":"","sources":["../../src/types/amoeba.ts"],"names":[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;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,GAAG,KAAK,CAAC;CAC7B;AAGD,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3D,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC;IAC7F,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amoeba.js","sourceRoot":"","sources":["../../src/types/amoeba.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ContextSource = 'memory' | 'knowledge' | 'skill' | 'cluster' | 'mitosis';
|
|
2
|
+
export interface ContextFragment {
|
|
3
|
+
source: ContextSource;
|
|
4
|
+
content: string;
|
|
5
|
+
tokens: number;
|
|
6
|
+
relevance: number;
|
|
7
|
+
metadata: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface ContextProvider {
|
|
10
|
+
readonly source: ContextSource;
|
|
11
|
+
provide(query: string, budget: number): Promise<ContextFragment[]>;
|
|
12
|
+
}
|
|
13
|
+
export interface TokenBudget {
|
|
14
|
+
total: number;
|
|
15
|
+
reservedOutput: number;
|
|
16
|
+
systemPromptTokens: number;
|
|
17
|
+
available: number;
|
|
18
|
+
}
|
|
19
|
+
export type BudgetRatios = Partial<Record<ContextSource, number>>;
|
|
20
|
+
export interface ContextOrchestrator {
|
|
21
|
+
register(provider: ContextProvider): void;
|
|
22
|
+
gather(query: string, totalBudget: number): Promise<ContextFragment[]>;
|
|
23
|
+
computeBudget(systemPrompt?: string): TokenBudget;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAErF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACvE,aAAa,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,qCAAqC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type AgentEvent = TextDeltaEvent | ToolCallStartEvent | ToolCallDeltaEvent | ToolCallEndEvent | StepStartEvent | StepEndEvent | ErrorEvent | DoneEvent;
|
|
2
|
+
export interface TextDeltaEvent {
|
|
3
|
+
type: 'text-delta';
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ToolCallStartEvent {
|
|
7
|
+
type: 'tool-call-start';
|
|
8
|
+
toolCallId: string;
|
|
9
|
+
toolName: string;
|
|
10
|
+
input: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolCallDeltaEvent {
|
|
13
|
+
type: 'tool-call-delta';
|
|
14
|
+
toolCallId: string;
|
|
15
|
+
partialArgs: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ToolCallEndEvent {
|
|
18
|
+
type: 'tool-call-end';
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
toolName: string;
|
|
21
|
+
result: unknown;
|
|
22
|
+
durationMs: number;
|
|
23
|
+
tokenCost: number;
|
|
24
|
+
}
|
|
25
|
+
export interface StepStartEvent {
|
|
26
|
+
type: 'step-start';
|
|
27
|
+
step: number;
|
|
28
|
+
totalSteps: number;
|
|
29
|
+
}
|
|
30
|
+
export interface StepEndEvent {
|
|
31
|
+
type: 'step-end';
|
|
32
|
+
step: number;
|
|
33
|
+
reason: 'tool-use' | 'complete' | 'max-steps' | 'abort';
|
|
34
|
+
}
|
|
35
|
+
export interface ErrorEvent {
|
|
36
|
+
type: 'error';
|
|
37
|
+
error: Error;
|
|
38
|
+
recoverable: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface DoneEvent {
|
|
41
|
+
type: 'done';
|
|
42
|
+
content: string;
|
|
43
|
+
usage: TokenUsage;
|
|
44
|
+
steps: number;
|
|
45
|
+
durationMs: number;
|
|
46
|
+
}
|
|
47
|
+
export interface TokenUsage {
|
|
48
|
+
promptTokens: number;
|
|
49
|
+
completionTokens: number;
|
|
50
|
+
totalTokens: number;
|
|
51
|
+
estimatedCost?: number;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,eAAe,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;CACzD;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './message.js';
|
|
2
|
+
export * from './events.js';
|
|
3
|
+
export * from './llm.js';
|
|
4
|
+
export * from './tool.js';
|
|
5
|
+
export * from './memory.js';
|
|
6
|
+
export * from './skill.js';
|
|
7
|
+
export * from './knowledge.js';
|
|
8
|
+
export * from './context.js';
|
|
9
|
+
export * from './amoeba.js';
|
|
10
|
+
export * from './strategy.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './message.js';
|
|
2
|
+
export * from './events.js';
|
|
3
|
+
export * from './llm.js';
|
|
4
|
+
export * from './tool.js';
|
|
5
|
+
export * from './memory.js';
|
|
6
|
+
export * from './skill.js';
|
|
7
|
+
export * from './knowledge.js';
|
|
8
|
+
export * from './context.js';
|
|
9
|
+
export * from './amoeba.js';
|
|
10
|
+
export * from './strategy.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface EmbeddingProvider {
|
|
2
|
+
embed(text: string): Promise<number[]>;
|
|
3
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
4
|
+
readonly dimensions: number;
|
|
5
|
+
}
|
|
6
|
+
export interface VectorEntry {
|
|
7
|
+
id: string;
|
|
8
|
+
vector: number[];
|
|
9
|
+
content: string;
|
|
10
|
+
metadata: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface VectorStore {
|
|
13
|
+
upsert(entries: VectorEntry[]): Promise<void>;
|
|
14
|
+
search(vector: number[], limit: number, filter?: Record<string, unknown>): Promise<VectorSearchResult[]>;
|
|
15
|
+
delete(ids: string[]): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface VectorSearchResult {
|
|
18
|
+
id: string;
|
|
19
|
+
score: number;
|
|
20
|
+
content: string;
|
|
21
|
+
metadata: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface GraphNode {
|
|
24
|
+
id: string;
|
|
25
|
+
type: string;
|
|
26
|
+
name: string;
|
|
27
|
+
properties: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface GraphEdge {
|
|
30
|
+
id: string;
|
|
31
|
+
source: string;
|
|
32
|
+
target: string;
|
|
33
|
+
relation: string;
|
|
34
|
+
properties: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
export interface GraphStore {
|
|
37
|
+
addNodes(nodes: GraphNode[]): Promise<void>;
|
|
38
|
+
addEdges(edges: GraphEdge[]): Promise<void>;
|
|
39
|
+
getNeighbors(nodeId: string, depth?: number): Promise<{
|
|
40
|
+
nodes: GraphNode[];
|
|
41
|
+
edges: GraphEdge[];
|
|
42
|
+
}>;
|
|
43
|
+
search(query: string, limit: number): Promise<GraphNode[]>;
|
|
44
|
+
deleteByDocument(documentId: string): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface ExtractedEntity {
|
|
47
|
+
name: string;
|
|
48
|
+
type: string;
|
|
49
|
+
properties: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface ExtractedRelation {
|
|
52
|
+
source: string;
|
|
53
|
+
target: string;
|
|
54
|
+
relation: string;
|
|
55
|
+
}
|
|
56
|
+
export interface EntityExtractor {
|
|
57
|
+
extract(text: string): Promise<{
|
|
58
|
+
entities: ExtractedEntity[];
|
|
59
|
+
relations: ExtractedRelation[];
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export interface Document {
|
|
63
|
+
id: string;
|
|
64
|
+
content: string;
|
|
65
|
+
metadata: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
export interface Chunk {
|
|
68
|
+
id: string;
|
|
69
|
+
documentId: string;
|
|
70
|
+
content: string;
|
|
71
|
+
index: number;
|
|
72
|
+
tokens?: number;
|
|
73
|
+
metadata: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
export interface Chunker {
|
|
76
|
+
chunk(doc: Document): Chunk[];
|
|
77
|
+
}
|
|
78
|
+
export interface RetrieverOptions {
|
|
79
|
+
limit?: number;
|
|
80
|
+
filter?: Record<string, unknown>;
|
|
81
|
+
minScore?: number;
|
|
82
|
+
}
|
|
83
|
+
export interface RetrievalResult {
|
|
84
|
+
chunk: Chunk;
|
|
85
|
+
score: number;
|
|
86
|
+
}
|
|
87
|
+
export interface Retriever {
|
|
88
|
+
retrieve(query: string, options?: RetrieverOptions): Promise<RetrievalResult[]>;
|
|
89
|
+
}
|
|
90
|
+
export interface KnowledgeBase {
|
|
91
|
+
ingest(docs: Document[]): Promise<void>;
|
|
92
|
+
query(query: string, options?: RetrieverOptions): Promise<RetrievalResult[]>;
|
|
93
|
+
delete(documentIds: string[]): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/types/knowledge.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,UAAU,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Q,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,GAAG,EAAE,QAAQ,GAAG,KAAK,EAAE,CAAC;CAC/B;AAGD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACjF;AAGD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.js","sourceRoot":"","sources":["../../src/types/knowledge.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Message, ToolCall } from './message.js';
|
|
2
|
+
import type { TokenUsage } from './events.js';
|
|
3
|
+
export interface LLMProvider {
|
|
4
|
+
complete(params: CompletionParams): Promise<CompletionResult>;
|
|
5
|
+
stream(params: CompletionParams, opts?: StreamOptions): AsyncGenerator<StreamChunk>;
|
|
6
|
+
}
|
|
7
|
+
export interface CompletionParams {
|
|
8
|
+
messages: Message[];
|
|
9
|
+
tools?: JsonToolDefinition[];
|
|
10
|
+
temperature?: number;
|
|
11
|
+
maxTokens?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface StreamOptions {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
export interface CompletionResult {
|
|
17
|
+
content: string;
|
|
18
|
+
toolCalls?: ToolCall[];
|
|
19
|
+
usage: TokenUsage;
|
|
20
|
+
finishReason: 'stop' | 'tool_calls' | 'length';
|
|
21
|
+
}
|
|
22
|
+
export type StreamChunk = {
|
|
23
|
+
type: 'text';
|
|
24
|
+
content: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'tool-call-delta';
|
|
27
|
+
toolCallId: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'usage';
|
|
32
|
+
usage: Partial<TokenUsage>;
|
|
33
|
+
};
|
|
34
|
+
export interface JsonToolDefinition {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
parameters: JsonSchema;
|
|
38
|
+
}
|
|
39
|
+
export interface JsonSchema {
|
|
40
|
+
type?: string;
|
|
41
|
+
properties?: Record<string, JsonSchema>;
|
|
42
|
+
required?: string[];
|
|
43
|
+
description?: string;
|
|
44
|
+
items?: JsonSchema;
|
|
45
|
+
enum?: unknown[];
|
|
46
|
+
default?: unknown;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/types/llm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,g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