@dory-agentic/dory-agentic-sdk 0.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/LICENSE +21 -0
- package/README.md +331 -0
- package/dist/agent/createLfsAgent.d.ts +27 -0
- package/dist/agent/createLfsAgent.d.ts.map +1 -0
- package/dist/agent/createLfsAgent.js +51 -0
- package/dist/agent/loopConfig.d.ts +6 -0
- package/dist/agent/loopConfig.d.ts.map +1 -0
- package/dist/agent/loopConfig.js +5 -0
- package/dist/agent/runLfsTurn.d.ts +10 -0
- package/dist/agent/runLfsTurn.d.ts.map +1 -0
- package/dist/agent/runLfsTurn.js +20 -0
- package/dist/history/dorycodeAdapter.d.ts +16 -0
- package/dist/history/dorycodeAdapter.d.ts.map +1 -0
- package/dist/history/dorycodeAdapter.js +18 -0
- package/dist/history/formatForModel.d.ts +19 -0
- package/dist/history/formatForModel.d.ts.map +1 -0
- package/dist/history/formatForModel.js +22 -0
- package/dist/history/lanes.d.ts +3 -0
- package/dist/history/lanes.d.ts.map +1 -0
- package/dist/history/lanes.js +3 -0
- package/dist/history/messageManifest.d.ts +45 -0
- package/dist/history/messageManifest.d.ts.map +1 -0
- package/dist/history/messageManifest.js +231 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/lfs/adaptiveCoefficients.d.ts +13 -0
- package/dist/lfs/adaptiveCoefficients.d.ts.map +1 -0
- package/dist/lfs/adaptiveCoefficients.js +16 -0
- package/dist/lfs/attenuationCompiler.d.ts +16 -0
- package/dist/lfs/attenuationCompiler.d.ts.map +1 -0
- package/dist/lfs/attenuationCompiler.js +123 -0
- package/dist/lfs/chunkManager.d.ts +6 -0
- package/dist/lfs/chunkManager.d.ts.map +1 -0
- package/dist/lfs/chunkManager.js +142 -0
- package/dist/lfs/config.d.ts +23 -0
- package/dist/lfs/config.d.ts.map +1 -0
- package/dist/lfs/config.js +34 -0
- package/dist/lfs/contextAdapter.d.ts +5 -0
- package/dist/lfs/contextAdapter.d.ts.map +1 -0
- package/dist/lfs/contextAdapter.js +161 -0
- package/dist/lfs/memoryEngine.d.ts +108 -0
- package/dist/lfs/memoryEngine.d.ts.map +1 -0
- package/dist/lfs/memoryEngine.js +322 -0
- package/dist/lfs/memoryParser.d.ts +121 -0
- package/dist/lfs/memoryParser.d.ts.map +1 -0
- package/dist/lfs/memoryParser.js +743 -0
- package/dist/lfs/paritySwapper.d.ts +20 -0
- package/dist/lfs/paritySwapper.d.ts.map +1 -0
- package/dist/lfs/paritySwapper.js +317 -0
- package/dist/lfs/preflightRouter.d.ts +14 -0
- package/dist/lfs/preflightRouter.d.ts.map +1 -0
- package/dist/lfs/preflightRouter.js +24 -0
- package/dist/lfs/runtimeConfig.d.ts +31 -0
- package/dist/lfs/runtimeConfig.d.ts.map +1 -0
- package/dist/lfs/runtimeConfig.js +40 -0
- package/dist/lfs/sessionStore.d.ts +14 -0
- package/dist/lfs/sessionStore.d.ts.map +1 -0
- package/dist/lfs/sessionStore.js +52 -0
- package/dist/lfs/tokenCounter.d.ts +90 -0
- package/dist/lfs/tokenCounter.d.ts.map +1 -0
- package/dist/lfs/tokenCounter.js +26 -0
- package/dist/lfs/types.d.ts +44 -0
- package/dist/lfs/types.d.ts.map +1 -0
- package/dist/lfs/types.js +1 -0
- package/dist/lfs/vectorDb.d.ts +19 -0
- package/dist/lfs/vectorDb.d.ts.map +1 -0
- package/dist/lfs/vectorDb.js +158 -0
- package/dist/mcp/client.d.ts +23 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +60 -0
- package/dist/mcp/config.d.ts +10 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +72 -0
- package/dist/providers/ollama.d.ts +2 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +7 -0
- package/dist/providers/registry.d.ts +5 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +9 -0
- package/dist/tools/registry.d.ts +14 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +26 -0
- package/dist/tools/remind.d.ts +15 -0
- package/dist/tools/remind.d.ts.map +1 -0
- package/dist/tools/remind.js +53 -0
- package/dist/tools/skillLoader.d.ts +12 -0
- package/dist/tools/skillLoader.d.ts.map +1 -0
- package/dist/tools/skillLoader.js +38 -0
- package/package.json +66 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { AdaptiveMessage, MemorySnapshotRow, TurnMemorySnapshot } from './tokenCounter';
|
|
2
|
+
export { collectScorableMessageIds } from "../history/messageManifest";
|
|
3
|
+
/** All non-archived rows with IDs (for prompt listing). */
|
|
4
|
+
export declare function collectActiveMessageIds(history: AdaptiveMessage[]): string[];
|
|
5
|
+
/** Map agent output keys to exact IDs from history (fixes msg_1 vs msg_01; never by list position). */
|
|
6
|
+
export declare function canonicalizeMessageIds(weights: AllocationMap, activeIds: Set<string>): {
|
|
7
|
+
canonical: AllocationMap;
|
|
8
|
+
invalidIds: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Merge agent relevance % with referenced_message_ids.
|
|
12
|
+
* Cited IDs with no score get a fair share so used context is never left at 0%.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeRelevanceWithReferences(agentPercents: AllocationMap, referencedIds: string[], activeIds: Set<string>): AllocationMap;
|
|
15
|
+
/** Shared instructions for optimized-lane relevance % (server converts to credits). */
|
|
16
|
+
export declare function buildRelevanceScoringInstructions(params: {
|
|
17
|
+
budget: number;
|
|
18
|
+
history: AdaptiveMessage[];
|
|
19
|
+
}): string;
|
|
20
|
+
export type AllocationMap = Record<string, number>;
|
|
21
|
+
export type ContextShift = 'continue' | 'new_topic';
|
|
22
|
+
export interface ParsedAgentOutput {
|
|
23
|
+
thinking: string;
|
|
24
|
+
response: string;
|
|
25
|
+
referencedIds: string[];
|
|
26
|
+
creditAllocation: AllocationMap;
|
|
27
|
+
contextShift: ContextShift;
|
|
28
|
+
}
|
|
29
|
+
/** Extract |||ALLOCATION:{...}||| from any text (response body or full JSON stream). */
|
|
30
|
+
export declare function extractAllocation(content: string): AllocationMap;
|
|
31
|
+
export declare function extractReferencedIds(content: string): string[];
|
|
32
|
+
/** Map normalized 0–100% shares to credits that sum to budget (2 decimal places). */
|
|
33
|
+
export declare function percentMapToCredits(normalizedPercents: AllocationMap, budget: number): AllocationMap;
|
|
34
|
+
/**
|
|
35
|
+
* Agent sends relevance as percentages (0–100) per message ID.
|
|
36
|
+
* Values are normalized to sum to 100%, then converted to credits in the backend.
|
|
37
|
+
*/
|
|
38
|
+
export declare function normalizePercentagesToBudget(agentPercents: AllocationMap, budget: number, activeIds: Set<string>): {
|
|
39
|
+
rawPercents: AllocationMap;
|
|
40
|
+
normalizedPercents: AllocationMap;
|
|
41
|
+
credits: AllocationMap;
|
|
42
|
+
rawSum: number;
|
|
43
|
+
invalidIds: string[];
|
|
44
|
+
};
|
|
45
|
+
/** Distribute integer credits so they sum exactly to budget using relevance weights. */
|
|
46
|
+
export declare function normalizeRelevanceToBudget(weights: AllocationMap, budget: number, activeIds: Set<string>): AllocationMap;
|
|
47
|
+
export declare function parsePartialJson(jsonStr: string, isMmuActive?: boolean): ParsedAgentOutput;
|
|
48
|
+
/** Search credit_allocation JSON field, response |||ALLOCATION||| block, then stream buffer. */
|
|
49
|
+
export declare function extractAllocationFromSources(responseText: string, streamBuffer: string, parsedCreditAllocation?: AllocationMap): AllocationMap;
|
|
50
|
+
export declare function sanitizeContent(content: string): string;
|
|
51
|
+
export type MemoryRowInput = {
|
|
52
|
+
id: string;
|
|
53
|
+
role: string;
|
|
54
|
+
content: string;
|
|
55
|
+
tokenCount?: number;
|
|
56
|
+
forgetScore?: number;
|
|
57
|
+
decayApplied?: number;
|
|
58
|
+
isArchived?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export declare function deriveMemoryStatus(id: string, referencedIds: string[], creditsApplied: number, forgetScore: number, decayApplied: number, forceDecayingIds?: Set<string>): MemorySnapshotRow['status'];
|
|
61
|
+
export declare function buildTurnMemorySnapshot(params: {
|
|
62
|
+
turnBudget: number;
|
|
63
|
+
contextShift: ContextShift;
|
|
64
|
+
creditsConsumed: number;
|
|
65
|
+
agentAllocation: AllocationMap;
|
|
66
|
+
effectiveAllocation: AllocationMap;
|
|
67
|
+
usedFallback: boolean;
|
|
68
|
+
scaledAllocation: AllocationMap;
|
|
69
|
+
scale: number;
|
|
70
|
+
totalRequested: number;
|
|
71
|
+
referencedIds: string[];
|
|
72
|
+
messages: MemoryRowInput[];
|
|
73
|
+
estimateTokens: (text: string) => number;
|
|
74
|
+
/** Immediate predecessor of the outgoing message — always shown as DECAYING when decay applied. */
|
|
75
|
+
forceDecayingIds?: Set<string>;
|
|
76
|
+
invalidAgentIds?: string[];
|
|
77
|
+
}): TurnMemorySnapshot;
|
|
78
|
+
/** Turn agent relevance percentages into final credits for this round. */
|
|
79
|
+
export declare function resolveTurnCredits(params: {
|
|
80
|
+
contextShift: ContextShift;
|
|
81
|
+
agentWeights: AllocationMap;
|
|
82
|
+
referencedIds: string[];
|
|
83
|
+
budget: number;
|
|
84
|
+
activeIds: Set<string>;
|
|
85
|
+
activeTurnId?: string | null;
|
|
86
|
+
}): {
|
|
87
|
+
agentAllocation: AllocationMap;
|
|
88
|
+
effectiveAllocation: AllocationMap;
|
|
89
|
+
scaledAllocation: AllocationMap;
|
|
90
|
+
scale: number;
|
|
91
|
+
totalRequested: number;
|
|
92
|
+
usedFallback: boolean;
|
|
93
|
+
creditsConsumed: number;
|
|
94
|
+
invalidAgentIds: string[];
|
|
95
|
+
};
|
|
96
|
+
export declare function scaleAllocation(allocation: AllocationMap, budget: number, activeIds: Set<string>): {
|
|
97
|
+
validAllocation: AllocationMap;
|
|
98
|
+
scaledAllocation: AllocationMap;
|
|
99
|
+
scale: number;
|
|
100
|
+
totalRequested: number;
|
|
101
|
+
};
|
|
102
|
+
export declare function extractHydrationBeaconVariables(messages: AdaptiveMessage[], query?: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* Pre-flight speculative hydration scanner.
|
|
105
|
+
* Scans the user query for keywords that suggest a recall of archived data,
|
|
106
|
+
* then returns the list of long-term memory IDs to hydrate.
|
|
107
|
+
*
|
|
108
|
+
* This runs client-side *before* the LLM call to eliminate the "double query"
|
|
109
|
+
* penalty (where the model would otherwise need to call remind() then re-run).
|
|
110
|
+
*/
|
|
111
|
+
export declare function preFlightSpeculativeScan(userPrompt: string, longTermMemory: Record<string, AdaptiveMessage>): Promise<string[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Build an attention anchor beacon from hydrated long-term memory messages.
|
|
114
|
+
* Combines speculative hydration with the extraction of exact variable values
|
|
115
|
+
* to produce a pinned system block that guides the LLM's attention to the
|
|
116
|
+
* correct parameters.
|
|
117
|
+
*
|
|
118
|
+
* Returns empty string if no variables were found.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildAttentionAnchorBeacon(hydratedMsgs: AdaptiveMessage[]): string;
|
|
121
|
+
//# sourceMappingURL=memoryParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoryParser.d.ts","sourceRoot":"","sources":["../../src/lfs/memoryParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQ7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAGvE,2DAA2D;AAC3D,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,CAI5E;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GACrB;IAAE,SAAS,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAgBpD;AAED;;;GAGG;AACH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