@forbocai/core 0.5.7 → 0.5.8
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/ans104-QFXL554Z.mjs +190 -0
- package/dist/chunk-M3F3ED7H.mjs +83 -0
- package/dist/index.d.mts +89 -284
- package/dist/index.d.ts +89 -284
- package/dist/index.js +313 -986
- package/dist/index.mjs +238 -760
- package/dist/soul-QXKV5H2R.mjs +20 -0
- package/package.json +2 -7
package/dist/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ interface CortexStatus {
|
|
|
20
20
|
engine: 'mock' | 'remote' | 'node-llama-cpp' | 'web-llm';
|
|
21
21
|
}
|
|
22
22
|
interface ICortex {
|
|
23
|
-
init(): Promise<CortexStatus>;
|
|
23
|
+
init(onProgress?: (progress: number) => void): Promise<CortexStatus>;
|
|
24
24
|
complete(prompt: string, options?: CompletionOptions): Promise<string>;
|
|
25
25
|
completeStream(prompt: string, options?: CompletionOptions): AsyncGenerator<string>;
|
|
26
26
|
}
|
|
@@ -56,6 +56,15 @@ interface AgentResponse {
|
|
|
56
56
|
action?: AgentAction;
|
|
57
57
|
thought?: string;
|
|
58
58
|
}
|
|
59
|
+
/** Dialogue Request (Full API-side logic) */
|
|
60
|
+
interface DialogueRequest {
|
|
61
|
+
diagMessage: string;
|
|
62
|
+
diagContext?: Array<[string, string]>;
|
|
63
|
+
}
|
|
64
|
+
/** Dialogue Response (Full API-side logic) */
|
|
65
|
+
interface DialogueResponse {
|
|
66
|
+
diagReply: string;
|
|
67
|
+
}
|
|
59
68
|
interface MemoryItem {
|
|
60
69
|
id: string;
|
|
61
70
|
text: string;
|
|
@@ -157,12 +166,21 @@ interface ValidationResult {
|
|
|
157
166
|
reason?: string;
|
|
158
167
|
correctedAction?: AgentAction;
|
|
159
168
|
}
|
|
160
|
-
interface
|
|
169
|
+
interface BridgeRule {
|
|
170
|
+
ruleName: string;
|
|
171
|
+
ruleDescription: string;
|
|
172
|
+
ruleActionTypes: string[];
|
|
173
|
+
}
|
|
174
|
+
interface DirectiveRuleSet {
|
|
175
|
+
rulesetId: string;
|
|
176
|
+
rulesetRules: BridgeRule[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use BridgeRule for data-only rules.
|
|
180
|
+
* Local validation execution is no longer supported in the SDK ("API is The Law").
|
|
181
|
+
*/
|
|
182
|
+
interface ValidationRule extends BridgeRule {
|
|
161
183
|
id: string;
|
|
162
|
-
name: string;
|
|
163
|
-
description: string;
|
|
164
|
-
actionTypes: string[];
|
|
165
|
-
validate: (action: AgentAction, context: ValidationContext) => ValidationResult;
|
|
166
184
|
}
|
|
167
185
|
interface Soul {
|
|
168
186
|
id: string;
|
|
@@ -173,83 +191,53 @@ interface Soul {
|
|
|
173
191
|
state: AgentState;
|
|
174
192
|
signature?: string;
|
|
175
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Soul configuration (Thin Client)
|
|
196
|
+
*/
|
|
197
|
+
interface SoulConfig {
|
|
198
|
+
apiUrl?: string;
|
|
199
|
+
gatewayUrl?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Soul export result
|
|
203
|
+
*/
|
|
204
|
+
interface SoulExportResult {
|
|
205
|
+
txId: string;
|
|
206
|
+
url: string;
|
|
207
|
+
soul: Soul;
|
|
208
|
+
}
|
|
176
209
|
|
|
177
210
|
/**
|
|
178
211
|
* Interface for Agent operations
|
|
179
212
|
*/
|
|
180
213
|
interface IAgent {
|
|
181
|
-
/**
|
|
182
|
-
* Processes an input string with optional context to generate a response.
|
|
183
|
-
* Follows the multi-round protocol: directive → context → verdict.
|
|
184
|
-
* @param input - The input string from the user or system.
|
|
185
|
-
* @param context - Optional context data to influence the agent's response.
|
|
186
|
-
* @returns A promise that resolves to the agent's response.
|
|
187
|
-
*/
|
|
188
214
|
process(input: string, context?: Record<string, unknown>): Promise<AgentResponse>;
|
|
189
|
-
/**
|
|
190
|
-
* Generates a conversational response (bypassing the multi-round ruleset evaluation).
|
|
191
|
-
* @param message - The input message.
|
|
192
|
-
* @param context - Optional context overrides.
|
|
193
|
-
* @returns A promise resolving to the agent's textual reply.
|
|
194
|
-
*/
|
|
195
215
|
speak(message: string, context?: Record<string, unknown>): Promise<string>;
|
|
196
|
-
/**
|
|
197
|
-
* Alias for `speak()`.
|
|
198
|
-
*/
|
|
199
216
|
reply(message: string, context?: Record<string, unknown>): Promise<string>;
|
|
200
|
-
/**
|
|
201
|
-
* Retrieves the current state of the agent.
|
|
202
|
-
* @returns The current AgentState.
|
|
203
|
-
*/
|
|
204
217
|
getState(): AgentState;
|
|
205
|
-
/**
|
|
206
|
-
* Updates the agent's state.
|
|
207
|
-
* @param newState - The new state to set.
|
|
208
|
-
*/
|
|
209
218
|
setState(newState: AgentState): void;
|
|
210
|
-
|
|
211
|
-
* Exports the agent's data to a Soul object.
|
|
212
|
-
* @returns A promise resolving to the Soul representation of the agent.
|
|
213
|
-
*/
|
|
219
|
+
dialogue(message: string, context?: Array<[string, string]>): Promise<string>;
|
|
214
220
|
export(): Promise<Soul>;
|
|
221
|
+
exportSoul(config?: SoulConfig): Promise<SoulExportResult>;
|
|
215
222
|
}
|
|
216
223
|
/**
|
|
217
224
|
* Pure function to create initial agent state
|
|
218
|
-
* @param partial - Optional partial state to initialize with.
|
|
219
|
-
* @returns The initialized AgentState.
|
|
220
225
|
*/
|
|
221
226
|
declare const createInitialState: (partial?: Partial<AgentState>) => AgentState;
|
|
222
227
|
/**
|
|
223
228
|
* Pure function to update agent state
|
|
224
|
-
* Returns new state without mutating original
|
|
225
|
-
* @param currentState - The current state of the agent.
|
|
226
|
-
* @param updates - The updates to apply to the state.
|
|
227
|
-
* @returns A new AgentState object with the updates applied.
|
|
228
229
|
*/
|
|
229
230
|
declare const updateAgentState: (currentState: AgentState, updates: Partial<AgentState>) => AgentState;
|
|
230
231
|
/**
|
|
231
232
|
* Pure function to export agent to Soul
|
|
232
|
-
* @param agentId - The ID of the agent.
|
|
233
|
-
* @param name - The name of the agent.
|
|
234
|
-
* @param persona - The persona description of the agent.
|
|
235
|
-
* @param state - The current state of the agent.
|
|
236
|
-
* @param memories - The list of memories associated with the agent.
|
|
237
|
-
* @returns A Soul object representing the agent.
|
|
238
233
|
*/
|
|
239
234
|
declare const exportToSoul: (agentId: string, name: string, persona: string, state: AgentState, memories: MemoryItem[]) => Soul;
|
|
240
235
|
/**
|
|
241
236
|
* Factory function to create Agent (Functional/Closure based)
|
|
242
|
-
* Implements the multi-round protocol where the SDK is a dumb executor.
|
|
243
|
-
* @param config - The configuration object for creating the agent.
|
|
244
|
-
* @returns An instance of IAgent.
|
|
245
237
|
*/
|
|
246
238
|
declare const createAgent: (config: AgentConfig) => IAgent;
|
|
247
239
|
/**
|
|
248
240
|
* Pure function to import Agent from Soul
|
|
249
|
-
* @param soul - The Soul object to import from.
|
|
250
|
-
* @param cortex - The Cortex instance for the agent.
|
|
251
|
-
* @param memory - Optional memory instance.
|
|
252
|
-
* @returns An instantiated IAgent.
|
|
253
241
|
*/
|
|
254
242
|
declare const fromSoul: (soul: Soul, cortex: ICortex, memory?: IMemory | null) => Promise<IAgent>;
|
|
255
243
|
|
|
@@ -257,103 +245,43 @@ declare const fromSoul: (soul: Soul, cortex: ICortex, memory?: IMemory | null) =
|
|
|
257
245
|
* Bridge configuration
|
|
258
246
|
*/
|
|
259
247
|
interface BridgeConfig {
|
|
260
|
-
/** Base URL for the API. */
|
|
261
248
|
apiUrl?: string;
|
|
262
|
-
|
|
263
|
-
strictMode?: boolean;
|
|
264
|
-
/** Custom validation rules to apply. */
|
|
265
|
-
customRules?: ValidationRule[];
|
|
249
|
+
agentId?: string;
|
|
266
250
|
}
|
|
267
251
|
/**
|
|
268
252
|
* Interface for Bridge operations
|
|
269
253
|
*/
|
|
270
254
|
interface IBridge {
|
|
271
255
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* @param context - Optional validation context.
|
|
275
|
-
* @returns A promise that resolves to the validation result.
|
|
256
|
+
* Validate an action against the API.
|
|
257
|
+
* If agentId is provided in config, uses agent-scoped validation.
|
|
276
258
|
*/
|
|
277
259
|
validate(action: AgentAction, context?: ValidationContext): Promise<ValidationResult>;
|
|
278
260
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @param rule - The rule to register.
|
|
261
|
+
* List all rulesets currently registered on the API.
|
|
281
262
|
*/
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Lists all registered validation rules.
|
|
285
|
-
* @returns An array of ValidationRule objects.
|
|
286
|
-
*/
|
|
287
|
-
listRules(): ValidationRule[];
|
|
288
|
-
/**
|
|
289
|
-
* Removes a validation rule by its ID.
|
|
290
|
-
* @param ruleId - The ID of the rule to remove.
|
|
291
|
-
* @returns True if the rule was removed, false otherwise.
|
|
292
|
-
*/
|
|
293
|
-
removeRule(ruleId: string): boolean;
|
|
263
|
+
listRulesets(): Promise<DirectiveRuleSet[]>;
|
|
294
264
|
}
|
|
295
265
|
/**
|
|
296
|
-
* Factory function to create Bridge instance
|
|
297
|
-
*
|
|
298
|
-
* @returns An instance of IBridge.
|
|
266
|
+
* Factory function to create Bridge instance
|
|
267
|
+
* All validation logic now resides on the server ("API is The Law").
|
|
299
268
|
*/
|
|
300
269
|
declare const createBridge: (config?: BridgeConfig) => IBridge;
|
|
301
270
|
/**
|
|
302
|
-
*
|
|
303
|
-
* @
|
|
304
|
-
* @param rules - The list of rules to validate against.
|
|
305
|
-
* @param context - Optional validation context.
|
|
306
|
-
* @returns The result of the validation.
|
|
271
|
+
* Standalone validation helper (deprecated locally, calls API)
|
|
272
|
+
* @deprecated Use createBridge(config).validate(action, context)
|
|
307
273
|
*/
|
|
308
|
-
declare const validateAction: (action: AgentAction,
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Soul export configuration
|
|
312
|
-
*/
|
|
313
|
-
interface SoulExportConfig {
|
|
314
|
-
/** Include memories in export */
|
|
315
|
-
includeMemories?: boolean;
|
|
316
|
-
/** Arweave wallet JWK (object or JSON string) for direct uploads */
|
|
317
|
-
walletJwk?: Record<string, unknown> | string;
|
|
318
|
-
/** Deprecated: use walletJwk */
|
|
319
|
-
privateKey?: Record<string, unknown> | string;
|
|
320
|
-
/** Bundler URL for ANS-104 data item uploads */
|
|
321
|
-
bundlerUrl?: string;
|
|
322
|
-
/** Gateway URL for read access (default: https://arweave.net) */
|
|
323
|
-
gatewayUrl?: string;
|
|
324
|
-
}
|
|
274
|
+
declare const validateAction: (action: AgentAction, context?: ValidationContext, config?: BridgeConfig) => Promise<ValidationResult>;
|
|
325
275
|
/**
|
|
326
|
-
*
|
|
276
|
+
* Register a server-side rule preset for an agent session.
|
|
327
277
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
txId: string;
|
|
331
|
-
/** Gateway URL to access the soul. */
|
|
332
|
-
url: string;
|
|
333
|
-
/** The exported Soul object. */
|
|
334
|
-
soul: Soul;
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Soul import configuration
|
|
338
|
-
*/
|
|
339
|
-
interface SoulImportConfig {
|
|
340
|
-
/** Gateway URL for Arweave (defaults to https://arweave.net) */
|
|
341
|
-
gatewayUrl?: string;
|
|
342
|
-
}
|
|
278
|
+
declare const loadPreset: (presetName: string, apiUrl?: string) => Promise<DirectiveRuleSet>;
|
|
279
|
+
|
|
343
280
|
/**
|
|
344
281
|
* Interface for Soul operations
|
|
345
282
|
*/
|
|
346
283
|
interface ISoul {
|
|
347
|
-
|
|
348
|
-
* Exports the Soul to Arweave.
|
|
349
|
-
* @param config - Export configuration.
|
|
350
|
-
* @returns A promise resolving to the export result.
|
|
351
|
-
*/
|
|
352
|
-
export(config?: SoulExportConfig): Promise<SoulExportResult>;
|
|
353
|
-
/**
|
|
354
|
-
* Returns the raw Soul data object.
|
|
355
|
-
* @returns The Soul object.
|
|
356
|
-
*/
|
|
284
|
+
export(config?: SoulConfig): Promise<SoulExportResult>;
|
|
357
285
|
toJSON(): Soul;
|
|
358
286
|
}
|
|
359
287
|
/**
|
|
@@ -369,31 +297,18 @@ declare const serializeSoul: (soul: Soul) => string;
|
|
|
369
297
|
*/
|
|
370
298
|
declare const deserializeSoul: (json: string) => Soul;
|
|
371
299
|
/**
|
|
372
|
-
*
|
|
300
|
+
* Export agent Soul to Arweave via API
|
|
373
301
|
*/
|
|
374
|
-
declare const
|
|
302
|
+
declare const exportSoul: (agentId: string, _soul: Soul, // Soul data is derived from agent state on the API
|
|
303
|
+
config?: SoulConfig) => Promise<SoulExportResult>;
|
|
375
304
|
/**
|
|
376
|
-
*
|
|
305
|
+
* Import Soul from Arweave by TXID via API
|
|
377
306
|
*/
|
|
378
|
-
declare const
|
|
307
|
+
declare const importSoulFromArweave: (txId: string, config?: SoulConfig) => Promise<Soul>;
|
|
379
308
|
/**
|
|
380
|
-
*
|
|
309
|
+
* Get list of all exported Souls from the API
|
|
381
310
|
*/
|
|
382
|
-
declare const
|
|
383
|
-
/**
|
|
384
|
-
* Soul entry in the listing
|
|
385
|
-
*/
|
|
386
|
-
interface SoulListEntry {
|
|
387
|
-
txId: string;
|
|
388
|
-
name: string;
|
|
389
|
-
agentId?: string;
|
|
390
|
-
exportedAt: string;
|
|
391
|
-
url: string;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Get list of all exported Souls
|
|
395
|
-
*/
|
|
396
|
-
declare const getSoulList: (limit?: number, apiUrl?: string) => Promise<SoulListEntry[]>;
|
|
311
|
+
declare const getSoulList: (limit?: number, apiUrl?: string) => Promise<any[]>;
|
|
397
312
|
/**
|
|
398
313
|
* Factory function to create Soul instance
|
|
399
314
|
*/
|
|
@@ -410,108 +325,59 @@ declare const validateSoul: (soul: Soul) => {
|
|
|
410
325
|
* Ghost test configuration
|
|
411
326
|
*/
|
|
412
327
|
interface GhostConfig {
|
|
413
|
-
/** API URL for ghost orchestration */
|
|
414
328
|
apiUrl?: string;
|
|
415
|
-
/** Test suite to run */
|
|
416
329
|
testSuite: 'exploration' | 'combat' | 'dialogue' | 'pathfinding' | 'full';
|
|
417
|
-
/** Maximum duration in seconds */
|
|
418
330
|
duration: number;
|
|
419
|
-
/** Capture screenshots on failure */
|
|
420
331
|
captureScreenshots?: boolean;
|
|
421
|
-
/** Custom test parameters */
|
|
422
332
|
params?: Record<string, unknown>;
|
|
423
333
|
}
|
|
424
334
|
/**
|
|
425
335
|
* Ghost session status
|
|
426
336
|
*/
|
|
427
337
|
interface GhostStatus {
|
|
428
|
-
/** The unique ID of the session. */
|
|
429
338
|
sessionId: string;
|
|
430
|
-
/** The current status of the session. */
|
|
431
339
|
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
432
|
-
/** Progress percentage (0-100). */
|
|
433
340
|
progress: number;
|
|
434
|
-
/** ISO timestamp when the session started. */
|
|
435
341
|
startedAt: string;
|
|
436
|
-
/** Duration in seconds elapsed. */
|
|
437
342
|
duration: number;
|
|
438
|
-
/** Number of errors encountered. */
|
|
439
343
|
errors: number;
|
|
440
344
|
}
|
|
441
345
|
/**
|
|
442
346
|
* Individual test result
|
|
443
347
|
*/
|
|
444
348
|
interface GhostTestResult {
|
|
445
|
-
/** Name of the test case. */
|
|
446
349
|
name: string;
|
|
447
|
-
/** Whether the test passed. */
|
|
448
350
|
passed: boolean;
|
|
449
|
-
/** Duration of the test in milliseconds. */
|
|
450
351
|
duration: number;
|
|
451
|
-
/** Error message if the test failed. */
|
|
452
352
|
error?: string;
|
|
453
|
-
/** URL or path to a screenshot if captured. */
|
|
454
353
|
screenshot?: string;
|
|
455
354
|
}
|
|
456
355
|
/**
|
|
457
356
|
* Complete session results
|
|
458
357
|
*/
|
|
459
358
|
interface GhostResults {
|
|
460
|
-
/** The session ID. */
|
|
461
359
|
sessionId: string;
|
|
462
|
-
/** Total number of tests run. */
|
|
463
360
|
totalTests: number;
|
|
464
|
-
/** Number of passed tests. */
|
|
465
361
|
passed: number;
|
|
466
|
-
/** Number of failed tests. */
|
|
467
362
|
failed: number;
|
|
468
|
-
/** Number of skipped tests. */
|
|
469
363
|
skipped: number;
|
|
470
|
-
/** Total duration in milliseconds. */
|
|
471
364
|
duration: number;
|
|
472
|
-
/** List of individual test results. */
|
|
473
365
|
tests: GhostTestResult[];
|
|
474
|
-
/** Code/Feature coverage (0.0-1.0). */
|
|
475
366
|
coverage: number;
|
|
476
|
-
/** Additional metrics collected during the session. */
|
|
477
367
|
metrics: Record<string, number>;
|
|
478
368
|
}
|
|
479
369
|
/**
|
|
480
370
|
* Interface for Ghost operations
|
|
481
371
|
*/
|
|
482
372
|
interface IGhost {
|
|
483
|
-
/**
|
|
484
|
-
* Starts a Ghost session.
|
|
485
|
-
* @returns A promise resolving to the session ID.
|
|
486
|
-
*/
|
|
487
373
|
run(): Promise<string>;
|
|
488
|
-
/**
|
|
489
|
-
* Gets the current status of the session.
|
|
490
|
-
* @returns A promise resolving to the GhostStatus.
|
|
491
|
-
*/
|
|
492
374
|
status(): Promise<GhostStatus>;
|
|
493
|
-
/**
|
|
494
|
-
* Gets the results of the session.
|
|
495
|
-
* @returns A promise resolving to the GhostResults.
|
|
496
|
-
*/
|
|
497
375
|
results(): Promise<GhostResults>;
|
|
498
|
-
/**
|
|
499
|
-
* Stops the current session.
|
|
500
|
-
*/
|
|
501
376
|
stop(): Promise<void>;
|
|
502
|
-
/**
|
|
503
|
-
* Waits for the session to complete.
|
|
504
|
-
* @param pollIntervalMs - Polling interval in milliseconds.
|
|
505
|
-
* @param timeoutMs - Timeout in milliseconds.
|
|
506
|
-
* @param onProgress - Optional callback for progress updates.
|
|
507
|
-
* @returns A promise resolving to the GhostResults.
|
|
508
|
-
*/
|
|
509
377
|
waitForCompletion(pollIntervalMs?: number, timeoutMs?: number, onProgress?: (status: GhostStatus) => void): Promise<GhostResults>;
|
|
510
378
|
}
|
|
511
379
|
/**
|
|
512
380
|
* Start a Ghost testing session
|
|
513
|
-
* @param config - The configuration for the Ghost session.
|
|
514
|
-
* @returns A promise resolving to an object containing the session ID and initial status.
|
|
515
381
|
*/
|
|
516
382
|
declare const startGhostSession: (config: GhostConfig) => Promise<{
|
|
517
383
|
sessionId: string;
|
|
@@ -519,40 +385,24 @@ declare const startGhostSession: (config: GhostConfig) => Promise<{
|
|
|
519
385
|
}>;
|
|
520
386
|
/**
|
|
521
387
|
* Get Ghost session status
|
|
522
|
-
* @param sessionId - The ID of the session to check.
|
|
523
|
-
* @param apiUrl - Optional API URL override.
|
|
524
|
-
* @returns A promise resolving to the GhostStatus.
|
|
525
388
|
*/
|
|
526
389
|
declare const getGhostStatus: (sessionId: string, apiUrl?: string) => Promise<GhostStatus>;
|
|
527
390
|
/**
|
|
528
391
|
* Get Ghost session results
|
|
529
|
-
* @param sessionId - The ID of the session to retrieve results for.
|
|
530
|
-
* @param apiUrl - Optional API URL override.
|
|
531
|
-
* @returns A promise resolving to the GhostResults.
|
|
532
392
|
*/
|
|
533
393
|
declare const getGhostResults: (sessionId: string, apiUrl?: string) => Promise<GhostResults>;
|
|
534
394
|
/**
|
|
535
395
|
* Poll Ghost session until completion
|
|
536
|
-
* @param sessionId - The ID of the session to wait for.
|
|
537
|
-
* @param pollIntervalMs - Polling interval in milliseconds.
|
|
538
|
-
* @param timeoutMs - Timeout in milliseconds.
|
|
539
|
-
* @param apiUrl - Optional API URL override.
|
|
540
|
-
* @param onProgress - Optional callback for progress updates.
|
|
541
|
-
* @returns A promise resolving to the GhostResults upon completion.
|
|
542
396
|
*/
|
|
543
397
|
declare const waitForGhostCompletion: (sessionId: string, pollIntervalMs?: number, timeoutMs?: number, apiUrl?: string, onProgress?: (status: GhostStatus) => void) => Promise<GhostResults>;
|
|
544
398
|
/**
|
|
545
399
|
* Stop a running Ghost session
|
|
546
|
-
* @param sessionId - The ID of the session to stop.
|
|
547
|
-
* @param apiUrl - Optional API URL override.
|
|
548
|
-
* @returns A promise resolving to the stop status.
|
|
549
400
|
*/
|
|
550
401
|
declare const stopGhostSession: (sessionId: string, apiUrl?: string) => Promise<{
|
|
551
402
|
stopped: boolean;
|
|
552
|
-
status: string;
|
|
553
403
|
}>;
|
|
554
404
|
/**
|
|
555
|
-
*
|
|
405
|
+
* Ghost session history entry
|
|
556
406
|
*/
|
|
557
407
|
interface GhostHistoryEntry {
|
|
558
408
|
sessionId: string;
|
|
@@ -564,15 +414,10 @@ interface GhostHistoryEntry {
|
|
|
564
414
|
}
|
|
565
415
|
/**
|
|
566
416
|
* Get Ghost session history
|
|
567
|
-
* @param limit - Max number of entries to retrieve.
|
|
568
|
-
* @param apiUrl - Optional API URL override.
|
|
569
|
-
* @returns A promise resolving to an array of GhostHistoryEntry.
|
|
570
417
|
*/
|
|
571
418
|
declare const getGhostHistory: (limit?: number, apiUrl?: string) => Promise<GhostHistoryEntry[]>;
|
|
572
419
|
/**
|
|
573
420
|
* Factory function to create Ghost session (Functional/Closure based)
|
|
574
|
-
* @param config - The configuration for the Ghost session.
|
|
575
|
-
* @returns An instance of IGhost.
|
|
576
421
|
*/
|
|
577
422
|
declare const createGhost: (config: GhostConfig) => IGhost;
|
|
578
423
|
|
|
@@ -586,92 +431,52 @@ declare const createRemoteCortex: (apiUrl: string, cortexId?: string, apiKey?: s
|
|
|
586
431
|
* Consume an async token stream, calling `onChunk` for each token.
|
|
587
432
|
* Useful for rendering typewriter effects in UI.
|
|
588
433
|
*/
|
|
589
|
-
declare
|
|
434
|
+
declare const streamToCallback: (stream: AsyncGenerator<string, void, unknown>, onChunk: (chunk: string) => void) => Promise<void>;
|
|
590
435
|
/**
|
|
591
436
|
* Consume an async token stream and return the full accumulated string.
|
|
592
437
|
*/
|
|
593
|
-
declare
|
|
438
|
+
declare const streamToString: (stream: AsyncGenerator<string, void, unknown>) => Promise<string>;
|
|
594
439
|
/**
|
|
595
440
|
* Stream tokens from a cortex directly to a callback.
|
|
596
441
|
* Convenience wrapper combining cortex.completeStream + streamToCallback.
|
|
597
|
-
*
|
|
598
|
-
* @example
|
|
599
|
-
* // Typewriter effect in a React component:
|
|
600
|
-
* await streamFromCortex(cortex, prompt, (token) => {
|
|
601
|
-
* setDisplayText(prev => prev + token);
|
|
602
|
-
* });
|
|
603
442
|
*/
|
|
604
|
-
declare
|
|
443
|
+
declare const streamFromCortex: (cortex: ICortex, prompt: string, onChunk: (chunk: string) => void, options?: {
|
|
605
444
|
temperature?: number;
|
|
606
445
|
maxTokens?: number;
|
|
607
446
|
stop?: string[];
|
|
608
|
-
})
|
|
447
|
+
}) => Promise<string>;
|
|
609
448
|
/**
|
|
610
449
|
* Stream tokens from a cortex with a delay between tokens (for typewriter pacing).
|
|
611
450
|
*
|
|
612
451
|
* @param delayMs - Milliseconds to wait between tokens (default: 30ms)
|
|
613
|
-
*
|
|
614
|
-
* @example
|
|
615
|
-
* await streamFromCortexWithDelay(cortex, prompt, (token) => {
|
|
616
|
-
* setDisplayText(prev => prev + token);
|
|
617
|
-
* }, { delayMs: 25 });
|
|
618
452
|
*/
|
|
619
|
-
declare
|
|
453
|
+
declare const streamFromCortexWithDelay: (cortex: ICortex, prompt: string, onChunk: (chunk: string) => void, options?: {
|
|
620
454
|
temperature?: number;
|
|
621
455
|
maxTokens?: number;
|
|
622
456
|
stop?: string[];
|
|
623
457
|
delayMs?: number;
|
|
624
|
-
})
|
|
625
|
-
|
|
626
|
-
interface RPGAgentState extends AgentState {
|
|
627
|
-
inventory: string[];
|
|
628
|
-
hp: number;
|
|
629
|
-
mana: number;
|
|
630
|
-
skills: Record<string, number>;
|
|
631
|
-
relationships: Record<string, number>;
|
|
632
|
-
mood: string;
|
|
633
|
-
}
|
|
634
|
-
declare const RPG_MOODS: {
|
|
635
|
-
readonly hostile: "hostile";
|
|
636
|
-
readonly suspicious: "suspicious";
|
|
637
|
-
readonly neutral: "neutral";
|
|
638
|
-
readonly friendly: "friendly";
|
|
639
|
-
readonly loyal: "loyal";
|
|
640
|
-
};
|
|
641
|
-
declare const RPG_MEMORY_TYPES: {
|
|
642
|
-
readonly observation: "observation";
|
|
643
|
-
readonly experience: "experience";
|
|
644
|
-
readonly knowledge: "knowledge";
|
|
645
|
-
readonly emotion: "emotion";
|
|
646
|
-
};
|
|
647
|
-
declare const createRPGState: (partial?: Partial<RPGAgentState>) => RPGAgentState;
|
|
648
|
-
declare const movementRule: ValidationRule;
|
|
649
|
-
declare const attackRule: ValidationRule;
|
|
650
|
-
declare const interactRule: ValidationRule;
|
|
651
|
-
declare const speakRule: ValidationRule;
|
|
652
|
-
declare const resourceRule: ValidationRule;
|
|
653
|
-
declare const rpgRules: ValidationRule[];
|
|
654
|
-
declare const spatialRules: ValidationRule[];
|
|
655
|
-
declare const socialRules: ValidationRule[];
|
|
656
|
-
declare const puzzleRules: ValidationRule[];
|
|
458
|
+
}) => Promise<string>;
|
|
657
459
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
declare const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
declare const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Pure Functional Utilities for ForbocAI SDK
|
|
462
|
+
*/
|
|
463
|
+
/**
|
|
464
|
+
* Delay execution for a specified number of milliseconds.
|
|
465
|
+
*/
|
|
466
|
+
declare const delay: (ms: number) => Promise<void>;
|
|
467
|
+
/**
|
|
468
|
+
* Functional pipe for chaining functions.
|
|
469
|
+
*/
|
|
470
|
+
declare const pipe: <T>(...fns: Array<(arg: T) => T>) => (initialValue: T) => T;
|
|
471
|
+
/**
|
|
472
|
+
* Closure-based memoization for async functions (single value cache).
|
|
473
|
+
*/
|
|
474
|
+
declare const memoiseAsync: <T>(fn: () => Promise<T>) => () => Promise<T>;
|
|
475
|
+
/**
|
|
476
|
+
* Closure-based memoization for sync functions (single value cache).
|
|
477
|
+
*/
|
|
478
|
+
declare const memoise: <T>(fn: () => T) => () => T;
|
|
674
479
|
|
|
675
480
|
declare const SDK_VERSION = "0.5.7";
|
|
676
481
|
|
|
677
|
-
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type CompletionOptions, type ContextRequest, type ContextResponse, type CortexConfig, type CortexStatus, type DirectiveRequest, type DirectiveResponse, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryItem, type MemoryRecallInstruction, type MemoryStoreInstruction, type PromptConstraints, type RecalledMemory, SDK_VERSION, type Soul, type
|
|
482
|
+
export { type AgentAction, type AgentConfig, type AgentResponse, type AgentState, type BridgeConfig, type BridgeRule, type CompletionOptions, type ContextRequest, type ContextResponse, type CortexConfig, type CortexStatus, type DialogueRequest, type DialogueResponse, type DirectiveRequest, type DirectiveResponse, type DirectiveRuleSet, type GhostConfig, type GhostHistoryEntry, type GhostResults, type GhostStatus, type GhostTestResult, type IAgent, type IBridge, type ICortex, type IGhost, type IMemory, type ISoul, type MemoryItem, type MemoryRecallInstruction, type MemoryStoreInstruction, type PromptConstraints, type RecalledMemory, SDK_VERSION, type Soul, type SoulConfig, type SoulExportResult, type SpeakRequest, type SpeakResponse, type ValidationContext, type ValidationResult, type ValidationRule, type VerdictRequest, type VerdictResponse, createAgent, createBridge, createGhost, createInitialState, createRemoteCortex, createSoul, createSoulInstance, delay, deserializeSoul, exportSoul, exportToSoul, fromSoul, getGhostHistory, getGhostResults, getGhostStatus, getSoulList, importSoulFromArweave, loadPreset, memoise, memoiseAsync, pipe, serializeSoul, startGhostSession, stopGhostSession, streamFromCortex, streamFromCortexWithDelay, streamToCallback, streamToString, updateAgentState, validateAction, validateSoul, waitForGhostCompletion };
|