opencode-viking-memory 0.1.5 → 0.1.7
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/README.md +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +51 -33
- package/dist/services/client.d.ts.map +1 -1
- package/dist/services/compaction.d.ts.map +1 -1
- package/dist/services/viking_memory.d.ts +107 -0
- package/dist/services/viking_memory.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ export VIKING_MEMORY_RESOURCE_ID="mem-..."
|
|
|
25
25
|
|
|
26
26
|
**Or let your agent do it** - paste this into OpenCode:
|
|
27
27
|
```
|
|
28
|
-
Install opencode-viking-memory by following https://raw.githubusercontent.com/
|
|
28
|
+
Install opencode-viking-memory by following https://raw.githubusercontent.com/heaoxiang-ai/opencode-viking-memory/main/README.md
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### For LLM Agents
|
package/dist/cli.js
CHANGED
|
@@ -82,8 +82,8 @@ var OPENCODE_CONFIG_DIR = join(homedir(), ".config", "opencode");
|
|
|
82
82
|
var OPENCODE_COMMAND_DIR = join(OPENCODE_CONFIG_DIR, "command");
|
|
83
83
|
var OH_MY_OPENCODE_CONFIG = join(OPENCODE_CONFIG_DIR, "oh-my-opencode.json");
|
|
84
84
|
var PLUGIN_NAME = "opencode-viking-memory@latest";
|
|
85
|
-
var
|
|
86
|
-
description: Initialize
|
|
85
|
+
var VIKING_MEMORY_INIT_COMMAND = `---
|
|
86
|
+
description: Initialize VikingMemory with comprehensive codebase knowledge
|
|
87
87
|
---
|
|
88
88
|
|
|
89
89
|
# Initializing VikingMemory
|
|
@@ -318,9 +318,9 @@ function createNewConfig() {
|
|
|
318
318
|
}
|
|
319
319
|
function createCommand() {
|
|
320
320
|
mkdirSync(OPENCODE_COMMAND_DIR, { recursive: true });
|
|
321
|
-
const commandPath = join(OPENCODE_COMMAND_DIR, "
|
|
322
|
-
writeFileSync(commandPath,
|
|
323
|
-
console.log(`✓ Created /
|
|
321
|
+
const commandPath = join(OPENCODE_COMMAND_DIR, "viking-memory-init.md");
|
|
322
|
+
writeFileSync(commandPath, VIKING_MEMORY_INIT_COMMAND);
|
|
323
|
+
console.log(`✓ Created /viking-memory-init command`);
|
|
324
324
|
return true;
|
|
325
325
|
}
|
|
326
326
|
function isOhMyOpencodeInstalled() {
|
|
@@ -397,9 +397,9 @@ async function install(options) {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
console.log(`
|
|
400
|
-
Step 2: Create /
|
|
400
|
+
Step 2: Create /viking-memory-init command`);
|
|
401
401
|
if (options.tui) {
|
|
402
|
-
const shouldCreate = await confirm(rl, "Add /
|
|
402
|
+
const shouldCreate = await confirm(rl, "Add /viking-memory-init command?");
|
|
403
403
|
if (!shouldCreate) {
|
|
404
404
|
console.log("Skipped.");
|
|
405
405
|
} else {
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAoFA,eAAO,MAAM,qBAAqB,oBAAyD,CAAC;AAC5F,eAAO,MAAM,yBAAyB,oBAAiE,CAAA;AAEvG,eAAO,MAAM,MAAM;;;;;;;;;;;CAclB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/dist/index.js
CHANGED
|
@@ -12345,7 +12345,7 @@ function log(message, data) {
|
|
|
12345
12345
|
appendFileSync(LOG_FILE, line);
|
|
12346
12346
|
}
|
|
12347
12347
|
|
|
12348
|
-
// src/services/
|
|
12348
|
+
// src/services/viking_memory.ts
|
|
12349
12349
|
class VikingMemory {
|
|
12350
12350
|
apiKey;
|
|
12351
12351
|
url;
|
|
@@ -12366,7 +12366,7 @@ class VikingMemory {
|
|
|
12366
12366
|
},
|
|
12367
12367
|
body: JSON.stringify({
|
|
12368
12368
|
query,
|
|
12369
|
-
filter: { user_id: containerTag, memory_type: "
|
|
12369
|
+
filter: { user_id: containerTag, memory_type: "sys_event_vibe_coding_v1" },
|
|
12370
12370
|
limit: options?.limit,
|
|
12371
12371
|
resource_id: this.resource_id
|
|
12372
12372
|
})
|
|
@@ -12409,7 +12409,7 @@ class VikingMemory {
|
|
|
12409
12409
|
"X-Viking-Debug": "1"
|
|
12410
12410
|
},
|
|
12411
12411
|
body: JSON.stringify({
|
|
12412
|
-
filter: { user_id: containerTag, memory_type: "
|
|
12412
|
+
filter: { user_id: containerTag, memory_type: "sys_profile_vibe_coding_v1" },
|
|
12413
12413
|
query,
|
|
12414
12414
|
resource_id: this.resource_id
|
|
12415
12415
|
})
|
|
@@ -12442,12 +12442,15 @@ class VikingMemory {
|
|
|
12442
12442
|
async addMemory(content, containerTag, metadata) {
|
|
12443
12443
|
try {
|
|
12444
12444
|
const requestBody = {
|
|
12445
|
-
|
|
12445
|
+
memory_info: { summary: content },
|
|
12446
12446
|
resource_id: this.resource_id,
|
|
12447
|
-
|
|
12447
|
+
event_type: "sys_event_vibe_coding_v1",
|
|
12448
|
+
time: Date.now(),
|
|
12449
|
+
user_id: containerTag,
|
|
12450
|
+
update_profiles: [{ profile_type: "sys_profile_vibe_coding_v1" }]
|
|
12448
12451
|
};
|
|
12449
|
-
log("addMemory: request", { url: `${this.url}/api/memory/
|
|
12450
|
-
const response = await fetch(`${this.url}/api/memory/
|
|
12452
|
+
log("addMemory: request", { url: `${this.url}/api/memory/event/add`, method: "POST", body: requestBody });
|
|
12453
|
+
const response = await fetch(`${this.url}/api/memory/event/add`, {
|
|
12451
12454
|
method: "POST",
|
|
12452
12455
|
headers: {
|
|
12453
12456
|
"Content-Type": "application/json",
|
|
@@ -12465,7 +12468,7 @@ class VikingMemory {
|
|
|
12465
12468
|
const result = await response.json();
|
|
12466
12469
|
const dataObj = result.data;
|
|
12467
12470
|
log("addMemory: response", { status: response.status, result });
|
|
12468
|
-
return { success: true, id: dataObj.
|
|
12471
|
+
return { success: true, id: dataObj.event_id || "" };
|
|
12469
12472
|
} catch (error45) {
|
|
12470
12473
|
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
12471
12474
|
log("addMemory: error", { error: errorMessage });
|
|
@@ -12507,9 +12510,8 @@ class VikingMemory {
|
|
|
12507
12510
|
"X-Viking-Debug": "1"
|
|
12508
12511
|
},
|
|
12509
12512
|
body: JSON.stringify({
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
limit: 5000,
|
|
12513
|
+
filter: { user_id: containerTag, memory_type: "sys_event_vibe_coding_v1" },
|
|
12514
|
+
limit,
|
|
12513
12515
|
resource_id: this.resource_id
|
|
12514
12516
|
})
|
|
12515
12517
|
});
|
|
@@ -12688,7 +12690,9 @@ var DEFAULTS = {
|
|
|
12688
12690
|
injectProfile: true,
|
|
12689
12691
|
containerTagPrefix: "opencode",
|
|
12690
12692
|
filterPrompt: "You are a stateful coding agent. Remember all the information, including but not limited to user's coding preferences, tech stack, behaviours, workflows, and any other relevant details.",
|
|
12691
|
-
keywordPatterns: []
|
|
12693
|
+
keywordPatterns: [],
|
|
12694
|
+
compressionThreshold: 0.8,
|
|
12695
|
+
debug: false
|
|
12692
12696
|
};
|
|
12693
12697
|
function isValidRegex(pattern) {
|
|
12694
12698
|
try {
|
|
@@ -12721,6 +12725,8 @@ var CONFIG = {
|
|
|
12721
12725
|
injectProfile: fileConfig.injectProfile ?? DEFAULTS.injectProfile,
|
|
12722
12726
|
containerTagPrefix: fileConfig.containerTagPrefix ?? DEFAULTS.containerTagPrefix,
|
|
12723
12727
|
filterPrompt: fileConfig.filterPrompt ?? DEFAULTS.filterPrompt,
|
|
12728
|
+
compressionThreshold: fileConfig.compressionThreshold ?? DEFAULTS.compressionThreshold,
|
|
12729
|
+
debug: fileConfig.debug ?? DEFAULTS.debug,
|
|
12724
12730
|
keywordPatterns: [
|
|
12725
12731
|
...DEFAULT_KEYWORD_PATTERNS,
|
|
12726
12732
|
...(fileConfig.keywordPatterns ?? []).filter(isValidRegex)
|
|
@@ -12953,11 +12959,10 @@ import { join as join3 } from "node:path";
|
|
|
12953
12959
|
import { homedir as homedir3 } from "node:os";
|
|
12954
12960
|
var MESSAGE_STORAGE = join3(homedir3(), ".opencode", "messages");
|
|
12955
12961
|
var PART_STORAGE = join3(homedir3(), ".opencode", "parts");
|
|
12956
|
-
var DEFAULT_THRESHOLD =
|
|
12957
|
-
var MIN_TOKENS_FOR_COMPACTION =
|
|
12962
|
+
var DEFAULT_THRESHOLD = CONFIG.compressionThreshold;
|
|
12963
|
+
var MIN_TOKENS_FOR_COMPACTION = 30000;
|
|
12958
12964
|
var COMPACTION_COOLDOWN_MS = 30000;
|
|
12959
|
-
var CLAUDE_DEFAULT_CONTEXT_LIMIT =
|
|
12960
|
-
var CLAUDE_MODEL_PATTERN = /claude-(opus|sonnet|haiku)/i;
|
|
12965
|
+
var CLAUDE_DEFAULT_CONTEXT_LIMIT = 128000;
|
|
12961
12966
|
function createCompactionPrompt(projectMemories) {
|
|
12962
12967
|
const memoriesSection = projectMemories.length > 0 ? `
|
|
12963
12968
|
## Project Knowledge (from VikingMemory)
|
|
@@ -12997,9 +13002,6 @@ ${memoriesSection}
|
|
|
12997
13002
|
This context is critical for maintaining continuity after compaction.
|
|
12998
13003
|
`;
|
|
12999
13004
|
}
|
|
13000
|
-
function isSupportedModel(modelID) {
|
|
13001
|
-
return CLAUDE_MODEL_PATTERN.test(modelID);
|
|
13002
|
-
}
|
|
13003
13005
|
function getMessageDir(sessionID) {
|
|
13004
13006
|
if (!existsSync2(MESSAGE_STORAGE))
|
|
13005
13007
|
return null;
|
|
@@ -13153,16 +13155,28 @@ ${summaryContent}`, tags.project, { type: "conversation" });
|
|
|
13153
13155
|
}
|
|
13154
13156
|
}
|
|
13155
13157
|
async function checkAndTriggerCompaction(sessionID, lastAssistant) {
|
|
13156
|
-
if (state.compactionInProgress.has(sessionID))
|
|
13158
|
+
if (state.compactionInProgress.has(sessionID)) {
|
|
13159
|
+
if (CONFIG.debug)
|
|
13160
|
+
log("[compaction] compaction already in progress", { sessionID });
|
|
13157
13161
|
return;
|
|
13162
|
+
}
|
|
13158
13163
|
const lastCompaction = state.lastCompactionTime.get(sessionID) ?? 0;
|
|
13159
|
-
if (Date.now() - lastCompaction < COMPACTION_COOLDOWN_MS)
|
|
13164
|
+
if (Date.now() - lastCompaction < COMPACTION_COOLDOWN_MS) {
|
|
13165
|
+
if (CONFIG.debug)
|
|
13166
|
+
log("[compaction] compaction cooldown active", { sessionID, lastCompaction });
|
|
13160
13167
|
return;
|
|
13161
|
-
|
|
13168
|
+
}
|
|
13169
|
+
if (lastAssistant.summary === true) {
|
|
13170
|
+
if (CONFIG.debug)
|
|
13171
|
+
log("[compaction] message is already a summary", { sessionID });
|
|
13162
13172
|
return;
|
|
13173
|
+
}
|
|
13163
13174
|
const tokens = lastAssistant.tokens;
|
|
13164
|
-
if (!tokens)
|
|
13175
|
+
if (!tokens) {
|
|
13176
|
+
if (CONFIG.debug)
|
|
13177
|
+
log("[compaction] no token information available", { sessionID });
|
|
13165
13178
|
return;
|
|
13179
|
+
}
|
|
13166
13180
|
let modelID = lastAssistant.modelID ?? "";
|
|
13167
13181
|
let providerID = lastAssistant.providerID ?? "";
|
|
13168
13182
|
let agent;
|
|
@@ -13175,15 +13189,14 @@ ${summaryContent}`, tags.project, { type: "conversation" });
|
|
|
13175
13189
|
modelID = storedMessage.model.modelID;
|
|
13176
13190
|
}
|
|
13177
13191
|
agent = storedMessage?.agent;
|
|
13178
|
-
if (!isSupportedModel(modelID)) {
|
|
13179
|
-
log("[compaction] skipping unsupported model", { modelID });
|
|
13180
|
-
return;
|
|
13181
|
-
}
|
|
13182
13192
|
const configLimit = getModelLimit?.(providerID, modelID);
|
|
13183
13193
|
const contextLimit = configLimit ?? CLAUDE_DEFAULT_CONTEXT_LIMIT;
|
|
13184
13194
|
const totalUsed = tokens.input + tokens.cache.read + tokens.output;
|
|
13185
|
-
if (totalUsed < MIN_TOKENS_FOR_COMPACTION)
|
|
13195
|
+
if (totalUsed < MIN_TOKENS_FOR_COMPACTION) {
|
|
13196
|
+
if (CONFIG.debug)
|
|
13197
|
+
log("[compaction] token usage below minimum threshold", { sessionID, totalUsed, MIN_TOKENS_FOR_COMPACTION });
|
|
13186
13198
|
return;
|
|
13199
|
+
}
|
|
13187
13200
|
const usageRatio = totalUsed / contextLimit;
|
|
13188
13201
|
log("[compaction] checking", {
|
|
13189
13202
|
sessionID,
|
|
@@ -13192,11 +13205,16 @@ ${summaryContent}`, tags.project, { type: "conversation" });
|
|
|
13192
13205
|
usageRatio: usageRatio.toFixed(2),
|
|
13193
13206
|
threshold
|
|
13194
13207
|
});
|
|
13195
|
-
if (usageRatio < threshold)
|
|
13208
|
+
if (usageRatio < threshold) {
|
|
13209
|
+
if (CONFIG.debug)
|
|
13210
|
+
log("[compaction] usage ratio below compaction threshold", { sessionID, usageRatio, threshold });
|
|
13196
13211
|
return;
|
|
13212
|
+
}
|
|
13197
13213
|
state.compactionInProgress.add(sessionID);
|
|
13198
13214
|
state.lastCompactionTime.set(sessionID, Date.now());
|
|
13199
13215
|
if (!providerID || !modelID) {
|
|
13216
|
+
if (CONFIG.debug)
|
|
13217
|
+
log("[compaction] missing providerID or modelID", { sessionID, providerID, modelID });
|
|
13200
13218
|
state.compactionInProgress.delete(sessionID);
|
|
13201
13219
|
return;
|
|
13202
13220
|
}
|
|
@@ -13349,7 +13367,7 @@ var CODE_BLOCK_PATTERN = /```[\s\S]*?```/g;
|
|
|
13349
13367
|
var INLINE_CODE_PATTERN = /`[^`]+`/g;
|
|
13350
13368
|
var MEMORY_KEYWORD_PATTERN = new RegExp(`\\b(${CONFIG.keywordPatterns.join("|")})\\b`, "i");
|
|
13351
13369
|
var MEMORY_NUDGE_MESSAGE = `[MEMORY TRIGGER DETECTED]
|
|
13352
|
-
The user wants you to remember something. You MUST use the \`
|
|
13370
|
+
The user wants you to remember something. You MUST use the \`viking_memory\` tool with \`mode: "add"\` to save this information.
|
|
13353
13371
|
|
|
13354
13372
|
Extract the key information the user wants remembered and save it as a concise, searchable memory.
|
|
13355
13373
|
- Use \`scope: "project"\` for project-specific preferences (e.g., "run lint with tests")
|
|
@@ -13398,7 +13416,7 @@ var VikingMemoryPlugin = async (ctx) => {
|
|
|
13398
13416
|
if (detectMemoryKeyword(userMessage)) {
|
|
13399
13417
|
log("chat.message: memory keyword detected");
|
|
13400
13418
|
const nudgePart = {
|
|
13401
|
-
id: `
|
|
13419
|
+
id: `viking-memory-nudge-${Date.now()}`,
|
|
13402
13420
|
sessionID: input.sessionID,
|
|
13403
13421
|
messageID: output.message.id,
|
|
13404
13422
|
type: "text",
|
|
@@ -13432,7 +13450,7 @@ var VikingMemoryPlugin = async (ctx) => {
|
|
|
13432
13450
|
const memoryContext = formatContextForPrompt(profile, userMemories, projectMemories);
|
|
13433
13451
|
if (memoryContext) {
|
|
13434
13452
|
const contextPart = {
|
|
13435
|
-
id: `
|
|
13453
|
+
id: `viking-memory-context-${Date.now()}`,
|
|
13436
13454
|
sessionID: input.sessionID,
|
|
13437
13455
|
messageID: output.message.id,
|
|
13438
13456
|
type: "text",
|
|
@@ -13483,7 +13501,7 @@ var VikingMemoryPlugin = async (ctx) => {
|
|
|
13483
13501
|
case "help": {
|
|
13484
13502
|
return JSON.stringify({
|
|
13485
13503
|
success: true,
|
|
13486
|
-
message: "
|
|
13504
|
+
message: "VikingMemory Usage Guide",
|
|
13487
13505
|
commands: [
|
|
13488
13506
|
{
|
|
13489
13507
|
command: "add",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAe3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,EAAE,MAAM,CAAA;iBAAE,CAAC;gBAAC,IAAI,EAAE;oBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;oBAAC,KAAK,EAAE,KAAK,CAAC;wBAAE,IAAI,EAAE,MAAM,CAAC;wBAAC,IAAI,EAAE,MAAM,CAAA;qBAAE,CAAC,CAAA;iBAAE,CAAC;gBAAC,KAAK,EAAE;oBAAE,SAAS,EAAE,MAAM,CAAA;iBAAE,CAAA;aAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;SAC3K,CAAC;QACF,GAAG,EAAE;YACH,SAAS,EAAE,CAAC,MAAM,EAAE;gBAAE,IAAI,EAAE;oBAAE,KAAK,EAAE,MAAM,CAAC;oBAAC,OAAO,EAAE,MAAM,CAAC;oBAAC,OAAO,EAAE,MAAM,CAAC;oBAAC,QAAQ,EAAE,MAAM,CAAA;iBAAE,CAAA;aAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;SAC1H,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,CAAC,EAAE,iBAAiB;qBAoPF;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;EAgE3E"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export declare class VikingMemory {
|
|
2
|
+
private apiKey;
|
|
3
|
+
private url;
|
|
4
|
+
private resource_id;
|
|
5
|
+
constructor(options: {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
url: string;
|
|
8
|
+
resource_id: string;
|
|
9
|
+
});
|
|
10
|
+
searchMemories(query: string, containerTag: string, // user_id
|
|
11
|
+
options?: {
|
|
12
|
+
threshold?: number;
|
|
13
|
+
limit?: number;
|
|
14
|
+
searchMode?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
success: true;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
results: Array<{
|
|
19
|
+
id: string;
|
|
20
|
+
memory?: string;
|
|
21
|
+
chunk?: string;
|
|
22
|
+
similarity: number;
|
|
23
|
+
}>;
|
|
24
|
+
total: number;
|
|
25
|
+
timing: number;
|
|
26
|
+
} | {
|
|
27
|
+
success: false;
|
|
28
|
+
error: string;
|
|
29
|
+
results: [];
|
|
30
|
+
total: 0;
|
|
31
|
+
timing: 0;
|
|
32
|
+
}>;
|
|
33
|
+
getProfile(containerTag: string, query?: string): Promise<{
|
|
34
|
+
success: true;
|
|
35
|
+
profile: {
|
|
36
|
+
static: string[];
|
|
37
|
+
dynamic: string[];
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
success: false;
|
|
41
|
+
error: string;
|
|
42
|
+
profile: null;
|
|
43
|
+
}>;
|
|
44
|
+
addMemory(content: string, containerTag: string, metadata?: {
|
|
45
|
+
type?: string;
|
|
46
|
+
tool?: string;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
success: true;
|
|
50
|
+
id: string;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
} | {
|
|
53
|
+
success: false;
|
|
54
|
+
error: string;
|
|
55
|
+
}>;
|
|
56
|
+
deleteMemory(memoryId: string): Promise<{
|
|
57
|
+
success: true;
|
|
58
|
+
} | {
|
|
59
|
+
success: false;
|
|
60
|
+
error: string;
|
|
61
|
+
}>;
|
|
62
|
+
listMemories(containerTag: string, limit?: number, options?: {
|
|
63
|
+
order?: string;
|
|
64
|
+
sort?: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
success: true;
|
|
67
|
+
memories: Array<{
|
|
68
|
+
id: string;
|
|
69
|
+
summary: string;
|
|
70
|
+
createdAt: string;
|
|
71
|
+
metadata?: Record<string, unknown>;
|
|
72
|
+
}>;
|
|
73
|
+
pagination: {
|
|
74
|
+
currentPage: number;
|
|
75
|
+
totalItems: number;
|
|
76
|
+
totalPages: number;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
success: false;
|
|
80
|
+
error: string;
|
|
81
|
+
memories: [];
|
|
82
|
+
pagination: {
|
|
83
|
+
currentPage: 1;
|
|
84
|
+
totalItems: 0;
|
|
85
|
+
totalPages: 0;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
ingestConversation(conversationId: string, messages: Array<{
|
|
89
|
+
role: string;
|
|
90
|
+
content: string | Array<{
|
|
91
|
+
type: string;
|
|
92
|
+
text?: string;
|
|
93
|
+
}>;
|
|
94
|
+
name?: string;
|
|
95
|
+
tool_calls?: unknown;
|
|
96
|
+
tool_call_id?: string;
|
|
97
|
+
}>, containerTags: string[], metadata?: Record<string, string | number | boolean>): Promise<{
|
|
98
|
+
success: true;
|
|
99
|
+
id: string;
|
|
100
|
+
conversationId: string;
|
|
101
|
+
status: string;
|
|
102
|
+
} | {
|
|
103
|
+
success: false;
|
|
104
|
+
error: string;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=viking_memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viking_memory.d.ts","sourceRoot":"","sources":["../../src/services/viking_memory.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC;IAMlE,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EAAE,UAAU;IAChC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CA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