forbocai 0.3.16 → 0.3.17
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +25 -8
- package/dist/index.mjs +24 -8
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -460,6 +460,7 @@ declare namespace index {
|
|
|
460
460
|
export { type index_RPGAgentState as RPGAgentState, index_RPG_MEMORY_TYPES as RPG_MEMORY_TYPES, index_RPG_MOODS as RPG_MOODS, index_attackRule as attackRule, index_createRPGState as createRPGState, index_interactRule as interactRule, index_movementRule as movementRule, index_puzzleRules as puzzleRules, index_resourceRule as resourceRule, index_rpgFallbackStrategy as rpgFallbackStrategy, index_rpgRules as rpgRules, index_socialRules as socialRules, index_spatialRules as spatialRules, index_speakRule as speakRule };
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
declare const SDK_VERSION = "0.3.17";
|
|
463
464
|
declare const init: () => void;
|
|
464
465
|
|
|
465
|
-
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type CompletionOptions, type CortexConfig, type CortexStatus, type Directive, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryConfig, type MemoryItem, type MemoryModuleConfig, type MemoryType, type Mood, type Observation, type Soul, type SoulExportConfig, type SoulExportResult, type SoulImportConfig, type SoulListEntry, type ValidationContext, type ValidationResult, type ValidationRule, type VectorStatus, createAgent, createAgentFromSoul, createBridge, createCortex, createGhost, createInitialState, createMemory, createMemoryItem, createSoul, createSoulInstance, createTable, deserializeSoul, exportSoulToIPFS, exportToSoul, fromSoul, generateEmbedding, getGhostHistory, getGhostResults, getGhostStatus, getSoulList, getVectorTable, importSoulFromIPFS, init, initVectorEngine, index as presets, processAgentInput, serializeSoul, startGhostSession, stopGhostSession, updateAgentState, validateAction, validateSoul, waitForGhostCompletion };
|
|
466
|
+
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type CompletionOptions, type CortexConfig, type CortexStatus, type Directive, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryConfig, type MemoryItem, type MemoryModuleConfig, type MemoryType, type Mood, type Observation, SDK_VERSION, type Soul, type SoulExportConfig, type SoulExportResult, type SoulImportConfig, type SoulListEntry, type ValidationContext, type ValidationResult, type ValidationRule, type VectorStatus, createAgent, createAgentFromSoul, createBridge, createCortex, createGhost, createInitialState, createMemory, createMemoryItem, createSoul, createSoulInstance, createTable, deserializeSoul, exportSoulToIPFS, exportToSoul, fromSoul, generateEmbedding, getGhostHistory, getGhostResults, getGhostStatus, getSoulList, getVectorTable, importSoulFromIPFS, init, initVectorEngine, index as presets, processAgentInput, serializeSoul, startGhostSession, stopGhostSession, updateAgentState, validateAction, validateSoul, waitForGhostCompletion };
|
package/dist/index.d.ts
CHANGED
|
@@ -460,6 +460,7 @@ declare namespace index {
|
|
|
460
460
|
export { type index_RPGAgentState as RPGAgentState, index_RPG_MEMORY_TYPES as RPG_MEMORY_TYPES, index_RPG_MOODS as RPG_MOODS, index_attackRule as attackRule, index_createRPGState as createRPGState, index_interactRule as interactRule, index_movementRule as movementRule, index_puzzleRules as puzzleRules, index_resourceRule as resourceRule, index_rpgFallbackStrategy as rpgFallbackStrategy, index_rpgRules as rpgRules, index_socialRules as socialRules, index_spatialRules as spatialRules, index_speakRule as speakRule };
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
declare const SDK_VERSION = "0.3.17";
|
|
463
464
|
declare const init: () => void;
|
|
464
465
|
|
|
465
|
-
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type CompletionOptions, type CortexConfig, type CortexStatus, type Directive, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryConfig, type MemoryItem, type MemoryModuleConfig, type MemoryType, type Mood, type Observation, type Soul, type SoulExportConfig, type SoulExportResult, type SoulImportConfig, type SoulListEntry, type ValidationContext, type ValidationResult, type ValidationRule, type VectorStatus, createAgent, createAgentFromSoul, createBridge, createCortex, createGhost, createInitialState, createMemory, createMemoryItem, createSoul, createSoulInstance, createTable, deserializeSoul, exportSoulToIPFS, exportToSoul, fromSoul, generateEmbedding, getGhostHistory, getGhostResults, getGhostStatus, getSoulList, getVectorTable, importSoulFromIPFS, init, initVectorEngine, index as presets, processAgentInput, serializeSoul, startGhostSession, stopGhostSession, updateAgentState, validateAction, validateSoul, waitForGhostCompletion };
|
|
466
|
+
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type CompletionOptions, type CortexConfig, type CortexStatus, type Directive, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryConfig, type MemoryItem, type MemoryModuleConfig, type MemoryType, type Mood, type Observation, SDK_VERSION, type Soul, type SoulExportConfig, type SoulExportResult, type SoulImportConfig, type SoulListEntry, type ValidationContext, type ValidationResult, type ValidationRule, type VectorStatus, createAgent, createAgentFromSoul, createBridge, createCortex, createGhost, createInitialState, createMemory, createMemoryItem, createSoul, createSoulInstance, createTable, deserializeSoul, exportSoulToIPFS, exportToSoul, fromSoul, generateEmbedding, getGhostHistory, getGhostResults, getGhostStatus, getSoulList, getVectorTable, importSoulFromIPFS, init, initVectorEngine, index as presets, processAgentInput, serializeSoul, startGhostSession, stopGhostSession, updateAgentState, validateAction, validateSoul, waitForGhostCompletion };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
SDK_VERSION: () => SDK_VERSION,
|
|
33
34
|
createAgent: () => createAgent,
|
|
34
35
|
createAgentFromSoul: () => createAgentFromSoul,
|
|
35
36
|
createBridge: () => createBridge,
|
|
@@ -254,9 +255,10 @@ var updateAgentState = (currentState, updates) => {
|
|
|
254
255
|
};
|
|
255
256
|
};
|
|
256
257
|
var processAgentInput = (currentState, input, context = {}) => {
|
|
257
|
-
const
|
|
258
|
+
const stateKeys = Object.keys(currentState);
|
|
259
|
+
const stateSummary = stateKeys.length > 0 ? stateKeys.map((k) => `${k}=${JSON.stringify(currentState[k])}`).join(", ") : "empty";
|
|
258
260
|
return {
|
|
259
|
-
dialogue: `Processing: "${input}" (
|
|
261
|
+
dialogue: `Processing: "${input}" (State: ${stateSummary})`,
|
|
260
262
|
action: {
|
|
261
263
|
type: "respond",
|
|
262
264
|
reason: "Default processing"
|
|
@@ -295,6 +297,13 @@ var createAgent = (config) => {
|
|
|
295
297
|
let target;
|
|
296
298
|
const timestamp = Date.now();
|
|
297
299
|
apiContext.push(["timestamp", String(timestamp)]);
|
|
300
|
+
let relevantMemories = [];
|
|
301
|
+
if (config.memory && typeof config.memory.recall === "function") {
|
|
302
|
+
try {
|
|
303
|
+
relevantMemories = await config.memory.recall(input, 5);
|
|
304
|
+
} catch {
|
|
305
|
+
}
|
|
306
|
+
}
|
|
298
307
|
try {
|
|
299
308
|
const dirRes = await fetch(`${apiUrl}/agents/${agentId}/directive`, {
|
|
300
309
|
method: "POST",
|
|
@@ -306,8 +315,7 @@ var createAgent = (config) => {
|
|
|
306
315
|
dirContext: apiContext,
|
|
307
316
|
dirState: currentState,
|
|
308
317
|
// Full state dump
|
|
309
|
-
dirMemories:
|
|
310
|
-
// TODO: Integrate memory lookup
|
|
318
|
+
dirMemories: relevantMemories.map((m) => ({ text: m.text, type: m.type, importance: m.importance }))
|
|
311
319
|
})
|
|
312
320
|
});
|
|
313
321
|
if (dirRes.ok) {
|
|
@@ -337,8 +345,12 @@ var createAgent = (config) => {
|
|
|
337
345
|
directive = "Autonomous behavior";
|
|
338
346
|
}
|
|
339
347
|
}
|
|
348
|
+
const memoryContext = relevantMemories.length > 0 ? `
|
|
349
|
+
Memories:
|
|
350
|
+
${relevantMemories.map((m) => `- [${m.type}] ${m.text}`).join("\n")}
|
|
351
|
+
` : "";
|
|
340
352
|
const prompt = `System: Follow this directive strictly: ${instruction} (${directive}).
|
|
341
|
-
To Target: ${target || "None"}
|
|
353
|
+
To Target: ${target || "None"}${memoryContext}
|
|
342
354
|
User: ${input}
|
|
343
355
|
Agent:`;
|
|
344
356
|
const generatedText = await cortex.complete(prompt);
|
|
@@ -377,6 +389,10 @@ Agent:`;
|
|
|
377
389
|
action: { type: "BLOCKED", reason: "API Validation Failed" }
|
|
378
390
|
};
|
|
379
391
|
}
|
|
392
|
+
if (config.memory && typeof config.memory.store === "function") {
|
|
393
|
+
config.memory.store(`Input: "${input}" \u2192 Action: ${instruction}`, "experience", 0.5).catch(() => {
|
|
394
|
+
});
|
|
395
|
+
}
|
|
380
396
|
return {
|
|
381
397
|
dialogue: generatedText,
|
|
382
398
|
action: { ...proposedAction, signature },
|
|
@@ -462,7 +478,6 @@ var validateSoul = (soul) => {
|
|
|
462
478
|
if (!soul.id) errors.push("Missing id");
|
|
463
479
|
if (!soul.persona) errors.push("Missing persona");
|
|
464
480
|
if (!soul.state) errors.push("Missing state");
|
|
465
|
-
if (!soul.state?.mood) errors.push("Missing state.mood");
|
|
466
481
|
return {
|
|
467
482
|
valid: errors.length === 0,
|
|
468
483
|
errors
|
|
@@ -1248,14 +1263,15 @@ var socialRules = [speakRule, interactRule];
|
|
|
1248
1263
|
var puzzleRules = [movementRule, interactRule];
|
|
1249
1264
|
|
|
1250
1265
|
// src/index.ts
|
|
1266
|
+
var SDK_VERSION = "0.3.17";
|
|
1251
1267
|
var init = () => {
|
|
1252
1268
|
console.log(`
|
|
1253
|
-
\x1B[36m _ _ _ ___ _ _
|
|
1269
|
+
\x1B[36m _ _ _ ___ _ _
|
|
1254
1270
|
| \\| |___ _ _ _ __ ___ / \\ |_ _|_ _ | |_ (_|
|
|
1255
1271
|
| . / -_) || | '_ / _ \\/ _ \\ | || ' \\| _| | |
|
|
1256
1272
|
|_|\\_\\___|\\_,_| ._\\___/_/ \\_\\ |___|_||_|\\__|_|_|
|
|
1257
1273
|
|_| \x1B[0m
|
|
1258
|
-
Neuro-Symbolic Grid SDK
|
|
1274
|
+
Neuro-Symbolic Grid SDK v${SDK_VERSION}
|
|
1259
1275
|
---------------------------------
|
|
1260
1276
|
Vessel: ACTIVE
|
|
1261
1277
|
Memory: LOCAL (LanceDB)
|
|
@@ -1265,6 +1281,7 @@ var init = () => {
|
|
|
1265
1281
|
};
|
|
1266
1282
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1267
1283
|
0 && (module.exports = {
|
|
1284
|
+
SDK_VERSION,
|
|
1268
1285
|
createAgent,
|
|
1269
1286
|
createAgentFromSoul,
|
|
1270
1287
|
createBridge,
|
package/dist/index.mjs
CHANGED
|
@@ -192,9 +192,10 @@ var updateAgentState = (currentState, updates) => {
|
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
var processAgentInput = (currentState, input, context = {}) => {
|
|
195
|
-
const
|
|
195
|
+
const stateKeys = Object.keys(currentState);
|
|
196
|
+
const stateSummary = stateKeys.length > 0 ? stateKeys.map((k) => `${k}=${JSON.stringify(currentState[k])}`).join(", ") : "empty";
|
|
196
197
|
return {
|
|
197
|
-
dialogue: `Processing: "${input}" (
|
|
198
|
+
dialogue: `Processing: "${input}" (State: ${stateSummary})`,
|
|
198
199
|
action: {
|
|
199
200
|
type: "respond",
|
|
200
201
|
reason: "Default processing"
|
|
@@ -233,6 +234,13 @@ var createAgent = (config) => {
|
|
|
233
234
|
let target;
|
|
234
235
|
const timestamp = Date.now();
|
|
235
236
|
apiContext.push(["timestamp", String(timestamp)]);
|
|
237
|
+
let relevantMemories = [];
|
|
238
|
+
if (config.memory && typeof config.memory.recall === "function") {
|
|
239
|
+
try {
|
|
240
|
+
relevantMemories = await config.memory.recall(input, 5);
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
}
|
|
236
244
|
try {
|
|
237
245
|
const dirRes = await fetch(`${apiUrl}/agents/${agentId}/directive`, {
|
|
238
246
|
method: "POST",
|
|
@@ -244,8 +252,7 @@ var createAgent = (config) => {
|
|
|
244
252
|
dirContext: apiContext,
|
|
245
253
|
dirState: currentState,
|
|
246
254
|
// Full state dump
|
|
247
|
-
dirMemories:
|
|
248
|
-
// TODO: Integrate memory lookup
|
|
255
|
+
dirMemories: relevantMemories.map((m) => ({ text: m.text, type: m.type, importance: m.importance }))
|
|
249
256
|
})
|
|
250
257
|
});
|
|
251
258
|
if (dirRes.ok) {
|
|
@@ -275,8 +282,12 @@ var createAgent = (config) => {
|
|
|
275
282
|
directive = "Autonomous behavior";
|
|
276
283
|
}
|
|
277
284
|
}
|
|
285
|
+
const memoryContext = relevantMemories.length > 0 ? `
|
|
286
|
+
Memories:
|
|
287
|
+
${relevantMemories.map((m) => `- [${m.type}] ${m.text}`).join("\n")}
|
|
288
|
+
` : "";
|
|
278
289
|
const prompt = `System: Follow this directive strictly: ${instruction} (${directive}).
|
|
279
|
-
To Target: ${target || "None"}
|
|
290
|
+
To Target: ${target || "None"}${memoryContext}
|
|
280
291
|
User: ${input}
|
|
281
292
|
Agent:`;
|
|
282
293
|
const generatedText = await cortex.complete(prompt);
|
|
@@ -315,6 +326,10 @@ Agent:`;
|
|
|
315
326
|
action: { type: "BLOCKED", reason: "API Validation Failed" }
|
|
316
327
|
};
|
|
317
328
|
}
|
|
329
|
+
if (config.memory && typeof config.memory.store === "function") {
|
|
330
|
+
config.memory.store(`Input: "${input}" \u2192 Action: ${instruction}`, "experience", 0.5).catch(() => {
|
|
331
|
+
});
|
|
332
|
+
}
|
|
318
333
|
return {
|
|
319
334
|
dialogue: generatedText,
|
|
320
335
|
action: { ...proposedAction, signature },
|
|
@@ -400,7 +415,6 @@ var validateSoul = (soul) => {
|
|
|
400
415
|
if (!soul.id) errors.push("Missing id");
|
|
401
416
|
if (!soul.persona) errors.push("Missing persona");
|
|
402
417
|
if (!soul.state) errors.push("Missing state");
|
|
403
|
-
if (!soul.state?.mood) errors.push("Missing state.mood");
|
|
404
418
|
return {
|
|
405
419
|
valid: errors.length === 0,
|
|
406
420
|
errors
|
|
@@ -1186,14 +1200,15 @@ var socialRules = [speakRule, interactRule];
|
|
|
1186
1200
|
var puzzleRules = [movementRule, interactRule];
|
|
1187
1201
|
|
|
1188
1202
|
// src/index.ts
|
|
1203
|
+
var SDK_VERSION = "0.3.17";
|
|
1189
1204
|
var init = () => {
|
|
1190
1205
|
console.log(`
|
|
1191
|
-
\x1B[36m _ _ _ ___ _ _
|
|
1206
|
+
\x1B[36m _ _ _ ___ _ _
|
|
1192
1207
|
| \\| |___ _ _ _ __ ___ / \\ |_ _|_ _ | |_ (_|
|
|
1193
1208
|
| . / -_) || | '_ / _ \\/ _ \\ | || ' \\| _| | |
|
|
1194
1209
|
|_|\\_\\___|\\_,_| ._\\___/_/ \\_\\ |___|_||_|\\__|_|_|
|
|
1195
1210
|
|_| \x1B[0m
|
|
1196
|
-
Neuro-Symbolic Grid SDK
|
|
1211
|
+
Neuro-Symbolic Grid SDK v${SDK_VERSION}
|
|
1197
1212
|
---------------------------------
|
|
1198
1213
|
Vessel: ACTIVE
|
|
1199
1214
|
Memory: LOCAL (LanceDB)
|
|
@@ -1202,6 +1217,7 @@ var init = () => {
|
|
|
1202
1217
|
`);
|
|
1203
1218
|
};
|
|
1204
1219
|
export {
|
|
1220
|
+
SDK_VERSION,
|
|
1205
1221
|
createAgent,
|
|
1206
1222
|
createAgentFromSoul,
|
|
1207
1223
|
createBridge,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forbocai",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "The Infrastructure Layer for Autonomous AI Characters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"test": "vitest",
|
|
15
15
|
"test:watch": "vitest --watch",
|
|
16
16
|
"preinstall": "node scripts/check-cmake.js",
|
|
17
|
-
"postinstall": "node postinstall.js"
|
|
17
|
+
"postinstall": "node postinstall.js",
|
|
18
|
+
"sync-version": "node -e \"const v=require('./package.json').version; const f=require('fs'); const p='src/index.ts'; let s=f.readFileSync(p,'utf8'); s=s.replace(/SDK_VERSION = '[^']+'/,'SDK_VERSION = \\''+v+'\\''); f.writeFileSync(p,s);\""
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@helia/json": "^5.0.6",
|
|
@@ -48,4 +49,4 @@
|
|
|
48
49
|
"glob": "^11.0.0",
|
|
49
50
|
"rimraf": "^5.0.0"
|
|
50
51
|
}
|
|
51
|
-
}
|
|
52
|
+
}
|