@aria-cli/types 1.0.18 → 1.0.31
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-cjs/errors.d.ts → dist/errors.js} +20 -5
- package/dist/index.js +11 -1
- package/dist/logger.js +163 -0
- package/dist/memoria.js +10 -0
- package/dist/models.js +17 -0
- package/dist/native-tools.js +29 -0
- package/dist/relaunch.js +59 -0
- package/dist/stall-phase.js +14 -0
- package/dist/tool-outputs.js +4 -0
- package/dist-cjs/errors.js +49 -0
- package/dist-cjs/index.js +29 -1
- package/dist-cjs/logger.js +166 -0
- package/dist-cjs/memoria.js +11 -0
- package/dist-cjs/models.js +21 -0
- package/dist-cjs/native-tools.js +33 -0
- package/dist-cjs/relaunch.js +67 -0
- package/dist-cjs/stall-phase.js +18 -0
- package/dist-cjs/tool-outputs.js +5 -0
- package/package.json +4 -2
- package/dist/errors.d.ts +0 -29
- package/dist/index.d.ts +0 -11
- package/dist/logger.d.ts +0 -54
- package/dist/memoria.d.ts +0 -428
- package/dist/models.d.ts +0 -322
- package/dist/native-tools.d.ts +0 -57
- package/dist/relaunch.d.ts +0 -22
- package/dist/stall-phase.d.ts +0 -2
- package/dist/tool-outputs.d.ts +0 -37
- package/dist-cjs/index.d.ts +0 -11
- package/dist-cjs/logger.d.ts +0 -54
- package/dist-cjs/memoria.d.ts +0 -428
- package/dist-cjs/models.d.ts +0 -322
- package/dist-cjs/native-tools.d.ts +0 -57
- package/dist-cjs/relaunch.d.ts +0 -22
- package/dist-cjs/src/errors.d.ts +0 -29
- package/dist-cjs/src/index.d.ts +0 -10
- package/dist-cjs/src/logger.d.ts +0 -22
- package/dist-cjs/src/memoria.d.ts +0 -418
- package/dist-cjs/src/models.d.ts +0 -322
- package/dist-cjs/src/native-tools.d.ts +0 -57
- package/dist-cjs/src/relaunch.d.ts +0 -22
- package/dist-cjs/src/tool-outputs.d.ts +0 -37
- package/dist-cjs/stall-phase.d.ts +0 -2
- package/dist-cjs/tests/logger.test.d.ts +0 -1
- package/dist-cjs/tool-outputs.d.ts +0 -37
- package/dist-cjs/vitest.config.d.ts +0 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Native tool types and type guards for provider-native capabilities
|
|
4
|
+
* @module @aria/types/native-tools
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isFunctionTool = isFunctionTool;
|
|
8
|
+
exports.isNativeTool = isNativeTool;
|
|
9
|
+
/**
|
|
10
|
+
* Type guard to check if a tool call is a function/custom tool
|
|
11
|
+
* (as opposed to a native provider tool like search or code execution)
|
|
12
|
+
*/
|
|
13
|
+
function isFunctionTool(toolCall) {
|
|
14
|
+
// Function tools are the default - they don't have special name prefixes
|
|
15
|
+
return !isNativeTool(toolCall);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a tool call is a native provider tool
|
|
19
|
+
* Native tools have special name prefixes like "brave_search", "computer", etc.
|
|
20
|
+
*/
|
|
21
|
+
function isNativeTool(toolCall) {
|
|
22
|
+
const nativePrefixes = [
|
|
23
|
+
"brave_search",
|
|
24
|
+
"computer",
|
|
25
|
+
"code_interpreter",
|
|
26
|
+
"text_editor",
|
|
27
|
+
"bash",
|
|
28
|
+
"dalle",
|
|
29
|
+
"file_search",
|
|
30
|
+
];
|
|
31
|
+
return nativePrefixes.some((prefix) => toolCall.name.startsWith(prefix));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=native-tools.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RESTART_KIND_ENV = exports.RESUME_ARION_ENV = exports.RESUME_SESSION_ENV = exports.NO_RELAUNCH_ENV = exports.RELAUNCH_EXIT_CODE = void 0;
|
|
4
|
+
exports.getRelaunchMarkerDir = getRelaunchMarkerDir;
|
|
5
|
+
exports.getRelaunchMarkerPath = getRelaunchMarkerPath;
|
|
6
|
+
exports.writeRelaunchMarker = writeRelaunchMarker;
|
|
7
|
+
exports.readRelaunchMarker = readRelaunchMarker;
|
|
8
|
+
exports.clearRelaunchMarker = clearRelaunchMarker;
|
|
9
|
+
const node_fs_1 = require("node:fs");
|
|
10
|
+
const node_os_1 = require("node:os");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
/**
|
|
13
|
+
* Magic exit code that tells the parent supervisor to respawn the child.
|
|
14
|
+
*/
|
|
15
|
+
exports.RELAUNCH_EXIT_CODE = 199;
|
|
16
|
+
/**
|
|
17
|
+
* Environment variables used by relaunch/supervisor flows.
|
|
18
|
+
*/
|
|
19
|
+
exports.NO_RELAUNCH_ENV = "ARIA_NO_RELAUNCH";
|
|
20
|
+
exports.RESUME_SESSION_ENV = "ARIA_RESUME_SESSION_ID";
|
|
21
|
+
exports.RESUME_ARION_ENV = "ARIA_RESUME_ARION";
|
|
22
|
+
exports.RESTART_KIND_ENV = "ARIA_RESTART_KIND";
|
|
23
|
+
function getAriaDir() {
|
|
24
|
+
const ariaHome = process.env.ARIA_HOME?.trim();
|
|
25
|
+
if (ariaHome)
|
|
26
|
+
return ariaHome;
|
|
27
|
+
return (0, node_path_1.join)((0, node_os_1.homedir)(), ".aria");
|
|
28
|
+
}
|
|
29
|
+
function getRelaunchMarkerDir() {
|
|
30
|
+
return (0, node_path_1.join)(getAriaDir(), "relaunch-pending");
|
|
31
|
+
}
|
|
32
|
+
function getRelaunchMarkerPath(pid = process.pid) {
|
|
33
|
+
return (0, node_path_1.join)(getRelaunchMarkerDir(), `${pid}.json`);
|
|
34
|
+
}
|
|
35
|
+
function writeRelaunchMarker(marker) {
|
|
36
|
+
try {
|
|
37
|
+
const markerPath = getRelaunchMarkerPath(marker.pid);
|
|
38
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(markerPath), { recursive: true });
|
|
39
|
+
(0, node_fs_1.writeFileSync)(markerPath, JSON.stringify(marker), "utf-8");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Best-effort — must never prevent restart
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function readRelaunchMarker(pid = process.pid) {
|
|
46
|
+
try {
|
|
47
|
+
const markerPath = getRelaunchMarkerPath(pid);
|
|
48
|
+
if (!(0, node_fs_1.existsSync)(markerPath))
|
|
49
|
+
return null;
|
|
50
|
+
const raw = (0, node_fs_1.readFileSync)(markerPath, "utf-8");
|
|
51
|
+
return JSON.parse(raw);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function clearRelaunchMarker(pid = process.pid) {
|
|
58
|
+
try {
|
|
59
|
+
const markerPath = getRelaunchMarkerPath(pid);
|
|
60
|
+
if ((0, node_fs_1.existsSync)(markerPath))
|
|
61
|
+
(0, node_fs_1.unlinkSync)(markerPath);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Best-effort
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=relaunch.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setGlobalStallPhase = setGlobalStallPhase;
|
|
4
|
+
exports.clearGlobalStallPhase = clearGlobalStallPhase;
|
|
5
|
+
function getGlobalPhaseStore() {
|
|
6
|
+
return globalThis;
|
|
7
|
+
}
|
|
8
|
+
function setGlobalStallPhase(label) {
|
|
9
|
+
const store = getGlobalPhaseStore();
|
|
10
|
+
store.__aria_stall_phase = label;
|
|
11
|
+
store.__aria_stall_phase_ts = performance.now();
|
|
12
|
+
}
|
|
13
|
+
function clearGlobalStallPhase() {
|
|
14
|
+
const store = getGlobalPhaseStore();
|
|
15
|
+
store.__aria_stall_phase = undefined;
|
|
16
|
+
store.__aria_stall_phase_ts = undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=stall-phase.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aria-cli/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"dist/",
|
|
24
24
|
"dist-cjs/",
|
|
25
25
|
"!**/*.map",
|
|
26
|
-
"!**/*.tsbuildinfo"
|
|
26
|
+
"!**/*.tsbuildinfo",
|
|
27
|
+
"!**/*.d.ts",
|
|
28
|
+
"!**/*.d.ts.map"
|
|
27
29
|
],
|
|
28
30
|
"engines": {
|
|
29
31
|
"node": ">=20.0.0"
|
package/dist/errors.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error narrowing utilities for replacing `catch (err: any)` patterns.
|
|
3
|
-
* @module @aria/types/errors
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Extract a human-readable message from an unknown caught value.
|
|
7
|
-
*
|
|
8
|
-
* Replaces the pattern:
|
|
9
|
-
* `catch (err: any) { ... err.message ... }`
|
|
10
|
-
* with:
|
|
11
|
-
* `catch (err: unknown) { ... getErrorMessage(err) ... }`
|
|
12
|
-
*/
|
|
13
|
-
export declare function getErrorMessage(err: unknown): string;
|
|
14
|
-
/**
|
|
15
|
-
* Extract an HTTP-style status code from an unknown caught value.
|
|
16
|
-
*
|
|
17
|
-
* Replaces the pattern:
|
|
18
|
-
* `(error as any).statusCode`
|
|
19
|
-
* with:
|
|
20
|
-
* `getErrorStatusCode(error)`
|
|
21
|
-
*/
|
|
22
|
-
export declare function getErrorStatusCode(err: unknown): number | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Type guard: is this caught value an Error with a `.code` property?
|
|
25
|
-
* Common for Node.js system errors (ENOENT, ECONNREFUSED, etc.)
|
|
26
|
-
*/
|
|
27
|
-
export declare function isNodeError(err: unknown): err is Error & {
|
|
28
|
-
code: string;
|
|
29
|
-
};
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @aria/types - Minimal shared types
|
|
3
|
-
*/
|
|
4
|
-
export * from "./models.js";
|
|
5
|
-
export * from "./memoria.js";
|
|
6
|
-
export * from "./errors.js";
|
|
7
|
-
export * from "./native-tools.js";
|
|
8
|
-
export * from "./relaunch.js";
|
|
9
|
-
export * from "./stall-phase.js";
|
|
10
|
-
export { log, type LogLevel, type LogSink } from "./logger.js";
|
|
11
|
-
export type { EditFileOutput, WriteFileOutput, BashToolOutput, NotebookEditOutput, } from "./tool-outputs.js";
|
package/dist/logger.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight leveled logger for ARIA.
|
|
3
|
-
*
|
|
4
|
-
* Respects `ARIA_LOG_LEVEL` env var (debug | info | warn | error | silent).
|
|
5
|
-
* Default level: "info" — debug messages are suppressed in normal usage.
|
|
6
|
-
*
|
|
7
|
-
* Architecture: logs dispatch through pluggable sinks. The default console
|
|
8
|
-
* sink writes to stdout/stderr with ANSI styling. Execution contexts that
|
|
9
|
-
* lack a terminal (daemon, headless server) replace or supplement it with
|
|
10
|
-
* durable sinks (e.g., JSONL file sink). This decoupling makes it impossible
|
|
11
|
-
* for diagnostic output to silently go to /dev/null — every context
|
|
12
|
-
* configures the sink that matches its output channel.
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* import { log } from "@aria-cli/types";
|
|
16
|
-
* log.debug("[PhaseTimer] ..."); // only prints when ARIA_LOG_LEVEL=debug
|
|
17
|
-
* log.info("[runner] ..."); // prints at info level and above
|
|
18
|
-
* log.warn("[runner] ..."); // prints at warn level and above
|
|
19
|
-
* log.error("[runner] ..."); // always prints (unless level > error)
|
|
20
|
-
*
|
|
21
|
-
* Sink configuration (daemon example):
|
|
22
|
-
* import { log } from "@aria-cli/types";
|
|
23
|
-
* log.addSink(myFileLogSink);
|
|
24
|
-
* log.removeConsoleSink(); // stdio is /dev/null in detached mode
|
|
25
|
-
*/
|
|
26
|
-
export type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
27
|
-
/**
|
|
28
|
-
* A log sink receives raw (unstyled) log arguments and writes them
|
|
29
|
-
* to a destination. Each sink decides its own formatting.
|
|
30
|
-
*/
|
|
31
|
-
export interface LogSink {
|
|
32
|
-
write(level: LogLevel, args: unknown[]): void;
|
|
33
|
-
close?(): void;
|
|
34
|
-
}
|
|
35
|
-
export declare const log: {
|
|
36
|
-
debug(...args: unknown[]): void;
|
|
37
|
-
info(...args: unknown[]): void;
|
|
38
|
-
warn(...args: unknown[]): void;
|
|
39
|
-
error(...args: unknown[]): void;
|
|
40
|
-
setLevel(level: LogLevel): void;
|
|
41
|
-
getLevel(): LogLevel;
|
|
42
|
-
/** Add a log sink. All subsequent log calls dispatch to it. */
|
|
43
|
-
addSink(sink: LogSink): void;
|
|
44
|
-
/** Remove a previously added sink. */
|
|
45
|
-
removeSink(sink: LogSink): void;
|
|
46
|
-
/**
|
|
47
|
-
* Remove the built-in console sink.
|
|
48
|
-
*
|
|
49
|
-
* Use this in execution contexts where stdio is unavailable (detached
|
|
50
|
-
* daemon, headless server) AFTER adding a durable file sink. Prevents
|
|
51
|
-
* wasted console.* calls that go to /dev/null.
|
|
52
|
-
*/
|
|
53
|
-
removeConsoleSink(): void;
|
|
54
|
-
};
|
package/dist/memoria.d.ts
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal IMemoria interface for consumers that need memory capabilities
|
|
3
|
-
* without depending on the concrete @aria/memoria package.
|
|
4
|
-
*
|
|
5
|
-
* Structural types (MemoryItem, ToolItem, RecallResult) replace bare
|
|
6
|
-
* `unknown` returns so consumers get usable shapes without coupling to
|
|
7
|
-
* the full Memoria domain model.
|
|
8
|
-
*/
|
|
9
|
-
/** A single stored memory. */
|
|
10
|
-
export interface MemoryItem {
|
|
11
|
-
id: string;
|
|
12
|
-
content: string;
|
|
13
|
-
summary?: string;
|
|
14
|
-
network?: string;
|
|
15
|
-
importance?: number;
|
|
16
|
-
confidence?: number;
|
|
17
|
-
createdAt?: Date;
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
/** A single tool-store entry. */
|
|
21
|
-
export interface ToolItem {
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
source?: ToolSourceItem;
|
|
26
|
-
importance?: number;
|
|
27
|
-
confidence?: number;
|
|
28
|
-
tags?: string[];
|
|
29
|
-
createdAt?: Date;
|
|
30
|
-
updatedAt?: Date;
|
|
31
|
-
accessedAt?: Date;
|
|
32
|
-
accessCount?: number;
|
|
33
|
-
evidenceIds?: string[];
|
|
34
|
-
category?: "filesystem" | "code" | "shell" | "web" | "data" | "memory" | "meta" | "arion";
|
|
35
|
-
parameters?: Record<string, unknown>;
|
|
36
|
-
riskLevel?: "safe" | "moderate" | "dangerous";
|
|
37
|
-
responseTemplate?: string;
|
|
38
|
-
knowledge?: string;
|
|
39
|
-
usageHint?: string;
|
|
40
|
-
adoptedAt?: number;
|
|
41
|
-
lastUsedAt?: number;
|
|
42
|
-
usageCount?: number;
|
|
43
|
-
schema?: Record<string, unknown>;
|
|
44
|
-
capabilities?: string[];
|
|
45
|
-
metrics?: Record<string, unknown>;
|
|
46
|
-
}
|
|
47
|
-
export type ToolSourceItem = {
|
|
48
|
-
type: "built-in";
|
|
49
|
-
} | {
|
|
50
|
-
type: "external";
|
|
51
|
-
ref: string;
|
|
52
|
-
format: "skill-file" | "markdown" | "json" | "web-search";
|
|
53
|
-
} | {
|
|
54
|
-
type: "organic";
|
|
55
|
-
method: "execution" | "observation" | "feedback";
|
|
56
|
-
episodeId?: string;
|
|
57
|
-
};
|
|
58
|
-
/** Result shape returned by observation query primitives. */
|
|
59
|
-
export interface ObservationQueryResult {
|
|
60
|
-
observations: string;
|
|
61
|
-
currentTask: string | null;
|
|
62
|
-
suggestedResponse: string | null;
|
|
63
|
-
sessionId: string;
|
|
64
|
-
updatedAt: number;
|
|
65
|
-
}
|
|
66
|
-
/** Result envelope returned by the APR pipeline. */
|
|
67
|
-
export interface RecallResult {
|
|
68
|
-
memories: MemoryItem[];
|
|
69
|
-
/** @deprecated Legacy alias retained for compatibility with older callers. */
|
|
70
|
-
data?: MemoryItem[];
|
|
71
|
-
query?: string;
|
|
72
|
-
totalCount?: number;
|
|
73
|
-
degradationLevel?: "full" | "reduced" | "minimal";
|
|
74
|
-
skippedStages?: string[];
|
|
75
|
-
warnings?: string[];
|
|
76
|
-
}
|
|
77
|
-
/** Result from lightweight FTS5-only recall. */
|
|
78
|
-
export interface LightweightRecallResult {
|
|
79
|
-
memories: MemoryItem[];
|
|
80
|
-
formattedContext: {
|
|
81
|
-
context: string;
|
|
82
|
-
};
|
|
83
|
-
query: string;
|
|
84
|
-
}
|
|
85
|
-
export interface ExtractedConversationMemoryItem {
|
|
86
|
-
content: string;
|
|
87
|
-
network: "world" | "episodes" | "beliefs" | "entities" | "procedures" | "strategies";
|
|
88
|
-
/** Optional durability marker describing how the memory was routed */
|
|
89
|
-
durability?: "permanent" | "session";
|
|
90
|
-
}
|
|
91
|
-
export interface ConversationExtractionResult {
|
|
92
|
-
learned: ExtractedConversationMemoryItem[];
|
|
93
|
-
error?: string;
|
|
94
|
-
}
|
|
95
|
-
export interface SkillTriggerItem {
|
|
96
|
-
type: "keyword" | "intent" | "context" | "entity";
|
|
97
|
-
pattern: string;
|
|
98
|
-
confidence: number;
|
|
99
|
-
}
|
|
100
|
-
export interface SkillRequirementsItem {
|
|
101
|
-
bins?: string[];
|
|
102
|
-
env?: string[];
|
|
103
|
-
os?: ("darwin" | "linux" | "win32")[];
|
|
104
|
-
}
|
|
105
|
-
export type SkillSourceItem = {
|
|
106
|
-
type: "auto-learned";
|
|
107
|
-
sequenceId: string;
|
|
108
|
-
} | {
|
|
109
|
-
type: "file";
|
|
110
|
-
path: string;
|
|
111
|
-
format: "skill-file";
|
|
112
|
-
} | {
|
|
113
|
-
type: "cli";
|
|
114
|
-
command: string;
|
|
115
|
-
} | {
|
|
116
|
-
type: "web";
|
|
117
|
-
url: string;
|
|
118
|
-
} | {
|
|
119
|
-
type: "user";
|
|
120
|
-
ref?: string;
|
|
121
|
-
};
|
|
122
|
-
export interface SkillItem {
|
|
123
|
-
id: string;
|
|
124
|
-
name: string;
|
|
125
|
-
description: string;
|
|
126
|
-
content: string;
|
|
127
|
-
toolIds: string[];
|
|
128
|
-
triggers: SkillTriggerItem[];
|
|
129
|
-
requires?: SkillRequirementsItem;
|
|
130
|
-
tags: string[];
|
|
131
|
-
source: SkillSourceItem;
|
|
132
|
-
executionCount: number;
|
|
133
|
-
successCount: number;
|
|
134
|
-
lastExecuted: Date | null;
|
|
135
|
-
averageDurationMs: number | null;
|
|
136
|
-
confidence: number;
|
|
137
|
-
importance: number;
|
|
138
|
-
createdAt: Date;
|
|
139
|
-
updatedAt: Date;
|
|
140
|
-
accessedAt: Date;
|
|
141
|
-
accessCount: number;
|
|
142
|
-
archivedAt?: Date;
|
|
143
|
-
}
|
|
144
|
-
export interface SkillExecutionRecord {
|
|
145
|
-
id: string;
|
|
146
|
-
skillId: string;
|
|
147
|
-
success: boolean;
|
|
148
|
-
durationMs?: number;
|
|
149
|
-
notes?: string;
|
|
150
|
-
episodeId?: string;
|
|
151
|
-
timestamp: Date;
|
|
152
|
-
}
|
|
153
|
-
export interface ToolUseSequenceRecord {
|
|
154
|
-
tool: string;
|
|
155
|
-
input?: Record<string, unknown>;
|
|
156
|
-
output?: string;
|
|
157
|
-
success: boolean;
|
|
158
|
-
timestamp: Date;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Minimal observation engine interface for consumers that need observation
|
|
162
|
-
* capabilities without depending on the concrete @aria/memoria package.
|
|
163
|
-
*
|
|
164
|
-
* Matches the public surface of ObservationEngine from @aria/memoria.
|
|
165
|
-
*/
|
|
166
|
-
export interface IObservationEngine {
|
|
167
|
-
/** Prepare context before model call — may trigger observation and filter messages. */
|
|
168
|
-
prepareContext(opts: {
|
|
169
|
-
sessionId: string;
|
|
170
|
-
messages: unknown[];
|
|
171
|
-
originalSystemPrompt: string;
|
|
172
|
-
readOnly?: boolean;
|
|
173
|
-
signal?: AbortSignal;
|
|
174
|
-
}): Promise<{
|
|
175
|
-
messagesToSend: unknown[];
|
|
176
|
-
filteredMessageIds: Set<string>;
|
|
177
|
-
observationTriggered: boolean;
|
|
178
|
-
}>;
|
|
179
|
-
/** Track new message IDs added to the conversation since last observation. */
|
|
180
|
-
trackNewMessages(messageIds: string[]): void;
|
|
181
|
-
/** Force observation of remaining unobserved messages at session end. */
|
|
182
|
-
finalObservation(sessionId: string, messages?: unknown[], signal?: AbortSignal): Promise<void>;
|
|
183
|
-
/** Observe messages — used for explicit observation triggers. */
|
|
184
|
-
observe(sessionId: string, messages: unknown[], signal?: AbortSignal, opts?: {
|
|
185
|
-
force?: boolean;
|
|
186
|
-
}): Promise<void>;
|
|
187
|
-
/** Get the observation record for a session, or null. */
|
|
188
|
-
getRecord(sessionId: string): unknown;
|
|
189
|
-
/** Get the active observation text for a session. */
|
|
190
|
-
getActiveObservations(sessionId: string): string;
|
|
191
|
-
/** Drain pending observation work (wait for in-flight observations to complete). */
|
|
192
|
-
drain(): Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
export interface IMemoria {
|
|
195
|
-
/** Store a memory. Returns an object with `id` on success, or null. */
|
|
196
|
-
remember(content: string, options?: Record<string, unknown>): Promise<{
|
|
197
|
-
id: string;
|
|
198
|
-
} | null>;
|
|
199
|
-
/**
|
|
200
|
-
* Internal fast-path for storing execution-trace episodes without the full
|
|
201
|
-
* entity extraction pipeline. Optional for backward compatibility.
|
|
202
|
-
*/
|
|
203
|
-
storeEpisode?(content: string): Promise<{
|
|
204
|
-
id: string;
|
|
205
|
-
} | null>;
|
|
206
|
-
/** Retrieve memories matching a query. Includes degradation metadata when available. */
|
|
207
|
-
recall(query: string, options?: Record<string, unknown>): Promise<RecallResult>;
|
|
208
|
-
/** Lightweight FTS5-only recall for session seeding. No LLM calls. */
|
|
209
|
-
recallLightweight(query: string, options?: {
|
|
210
|
-
limit?: number;
|
|
211
|
-
networks?: string[];
|
|
212
|
-
}): Promise<LightweightRecallResult>;
|
|
213
|
-
/**
|
|
214
|
-
* Planner-first unified recall: 1 LLM call for classification + plan + expansion.
|
|
215
|
-
* Routes to direct lookup (skipping APR) or mixed APR + primitive execution.
|
|
216
|
-
* This is the preferred recall path — recallWithAPR delegates to this.
|
|
217
|
-
*/
|
|
218
|
-
recallUnified?(query: string, options?: {
|
|
219
|
-
limit?: number;
|
|
220
|
-
networks?: string[];
|
|
221
|
-
}): Promise<{
|
|
222
|
-
memories: MemoryItem[];
|
|
223
|
-
formattedContext?: {
|
|
224
|
-
context?: string;
|
|
225
|
-
text?: string;
|
|
226
|
-
tokenCount?: number;
|
|
227
|
-
} | null;
|
|
228
|
-
intent?: {
|
|
229
|
-
type?: string;
|
|
230
|
-
confidence?: number;
|
|
231
|
-
entities?: string[];
|
|
232
|
-
temporalFocus?: string | null;
|
|
233
|
-
extractedEntities?: string[];
|
|
234
|
-
extractedTimeframe?: Record<string, unknown>;
|
|
235
|
-
};
|
|
236
|
-
sourceStats?: unknown;
|
|
237
|
-
plan?: Array<{
|
|
238
|
-
primitive: string;
|
|
239
|
-
args: Record<string, unknown>;
|
|
240
|
-
}>;
|
|
241
|
-
planReasoning?: string;
|
|
242
|
-
primitiveResults?: Array<{
|
|
243
|
-
source: string;
|
|
244
|
-
data: unknown;
|
|
245
|
-
}>;
|
|
246
|
-
}>;
|
|
247
|
-
/** Retrieve memories via the Adaptive Parallel Retrieval pipeline. */
|
|
248
|
-
recallWithAPR(query: string, options?: {
|
|
249
|
-
limit?: number;
|
|
250
|
-
networks?: string[];
|
|
251
|
-
}): Promise<{
|
|
252
|
-
memories: MemoryItem[];
|
|
253
|
-
formattedContext?: {
|
|
254
|
-
context?: string;
|
|
255
|
-
text?: string;
|
|
256
|
-
tokenCount?: number;
|
|
257
|
-
};
|
|
258
|
-
intent?: {
|
|
259
|
-
type?: string;
|
|
260
|
-
confidence?: number;
|
|
261
|
-
entities?: string[];
|
|
262
|
-
temporalFocus?: string | null;
|
|
263
|
-
extractedEntities?: string[];
|
|
264
|
-
extractedTimeframe?: Record<string, unknown>;
|
|
265
|
-
};
|
|
266
|
-
sourceStats?: unknown;
|
|
267
|
-
query?: string;
|
|
268
|
-
totalCount?: number;
|
|
269
|
-
degradationLevel?: "full" | "reduced" | "minimal";
|
|
270
|
-
skippedStages?: string[];
|
|
271
|
-
warnings?: string[];
|
|
272
|
-
}>;
|
|
273
|
-
/**
|
|
274
|
-
* Lightweight vector-only recall with network filtering. Bypasses the full APR
|
|
275
|
-
* pipeline (no classification, no multi-index fusion, no diversity). Designed
|
|
276
|
-
* for time-critical paths like session bootstrap.
|
|
277
|
-
*/
|
|
278
|
-
recallDirect(query: string, options: {
|
|
279
|
-
networks: string[];
|
|
280
|
-
limit: number;
|
|
281
|
-
threshold?: number;
|
|
282
|
-
}): Promise<MemoryItem[]>;
|
|
283
|
-
/** Recall memories by network type. Direct SQL query, no LLM classification. */
|
|
284
|
-
recallByNetwork(network: string, options?: {
|
|
285
|
-
limit?: number;
|
|
286
|
-
}): Promise<MemoryItem[]>;
|
|
287
|
-
/** Recall recent memories, optionally filtered by network. Direct SQL query sorted by created_at DESC. */
|
|
288
|
-
recallRecent(options?: {
|
|
289
|
-
limit?: number;
|
|
290
|
-
network?: string;
|
|
291
|
-
}): Promise<MemoryItem[]>;
|
|
292
|
-
/** Recall memories by vector similarity. Uses embedding model only (0 LLM calls). */
|
|
293
|
-
recallSimilar(query: string, options?: {
|
|
294
|
-
k?: number;
|
|
295
|
-
threshold?: number;
|
|
296
|
-
}): Promise<MemoryItem[]>;
|
|
297
|
-
/** Store a tool with semantic indexing. Returns the generated id. */
|
|
298
|
-
rememberTool(tool: {
|
|
299
|
-
name: string;
|
|
300
|
-
description: string;
|
|
301
|
-
} & Record<string, unknown>): Promise<string>;
|
|
302
|
-
/** Query the tool store. */
|
|
303
|
-
recallTools(options: {
|
|
304
|
-
query: string;
|
|
305
|
-
limit?: number;
|
|
306
|
-
/** Optional offset used for paged list retrieval (matchAll mode). */
|
|
307
|
-
offset?: number;
|
|
308
|
-
minConfidence?: number;
|
|
309
|
-
/** When true, bypasses semantic/keyword matching and lists stored tools. */
|
|
310
|
-
matchAll?: boolean;
|
|
311
|
-
/** When false, recall becomes read-only and does not mutate access stats. */
|
|
312
|
-
updateAccessStats?: boolean;
|
|
313
|
-
}): Promise<ToolItem[]>;
|
|
314
|
-
/** Retrieve a single tool entry by ID. */
|
|
315
|
-
getToolById(id: string): Promise<ToolItem | null>;
|
|
316
|
-
/** Delete a tool entry by ID. Returns true if deleted, false if not found. */
|
|
317
|
-
forgetTool(id: string): Promise<boolean>;
|
|
318
|
-
/** Store a skill directly. Returns the generated skill ID. */
|
|
319
|
-
rememberSkill(skill: {
|
|
320
|
-
name: string;
|
|
321
|
-
description: string;
|
|
322
|
-
content: string;
|
|
323
|
-
toolIds?: string[];
|
|
324
|
-
triggers?: SkillTriggerItem[];
|
|
325
|
-
requires?: SkillRequirementsItem;
|
|
326
|
-
tags?: string[];
|
|
327
|
-
source: SkillSourceItem;
|
|
328
|
-
importance?: number;
|
|
329
|
-
confidence?: number;
|
|
330
|
-
}): Promise<string>;
|
|
331
|
-
/** Skill retrieval API. */
|
|
332
|
-
recallSkills(options?: {
|
|
333
|
-
query?: string;
|
|
334
|
-
triggerType?: SkillTriggerItem["type"];
|
|
335
|
-
limit?: number;
|
|
336
|
-
}): Promise<SkillItem[]>;
|
|
337
|
-
/** Skill lookup API. */
|
|
338
|
-
getSkill(idOrName: string): Promise<SkillItem | null>;
|
|
339
|
-
/** Record skill execution metrics. */
|
|
340
|
-
recordSkillExecution(options: {
|
|
341
|
-
skillId: string;
|
|
342
|
-
success: boolean;
|
|
343
|
-
durationMs?: number;
|
|
344
|
-
notes?: string;
|
|
345
|
-
episodeId?: string;
|
|
346
|
-
}): Promise<SkillExecutionRecord>;
|
|
347
|
-
/** Start recording a tool-use sequence for procedural learning. */
|
|
348
|
-
startToolSequence?(task: string, options?: {
|
|
349
|
-
sessionId?: string;
|
|
350
|
-
}): void;
|
|
351
|
-
/** Record a single tool execution within the active sequence. */
|
|
352
|
-
recordToolUse?(record: ToolUseSequenceRecord, options?: {
|
|
353
|
-
sessionId?: string;
|
|
354
|
-
}): void;
|
|
355
|
-
/** Finalize the active tool-use sequence and trigger learning. */
|
|
356
|
-
endToolSequence?(success: boolean, options?: {
|
|
357
|
-
sessionId?: string;
|
|
358
|
-
}): Promise<void>;
|
|
359
|
-
/** Delete a single memory by ID. */
|
|
360
|
-
deleteMemory(id: string): Promise<boolean>;
|
|
361
|
-
/** Merge a JSON patch into a memory's metadata. */
|
|
362
|
-
updateMemoryMetadata(id: string, patch: Record<string, unknown>): void;
|
|
363
|
-
/** Soft-invalidate a memory in place (sets confidence to 0, marks reason). Allows recovery. */
|
|
364
|
-
invalidateMemoryInPlace(memoryId: string, reason?: string): Promise<void>;
|
|
365
|
-
/** Requeue failed embedding jobs and return how many were scheduled. */
|
|
366
|
-
retryFailedEmbeddings?(): Promise<number>;
|
|
367
|
-
/** Extract memories from a user/assistant conversation turn. */
|
|
368
|
-
extractFromConversation(userMessage: string, assistantResponse: string, options?: {
|
|
369
|
-
signal?: AbortSignal;
|
|
370
|
-
}): Promise<ConversationExtractionResult>;
|
|
371
|
-
/** Observation engine for Mastra-style observation/reflection memory layer. */
|
|
372
|
-
readonly observationEngine?: IObservationEngine;
|
|
373
|
-
/**
|
|
374
|
-
* Extract durable knowledge from observation text into the knowledge graph.
|
|
375
|
-
* Optional for backward compatibility — always present on concrete Memoria instances.
|
|
376
|
-
*/
|
|
377
|
-
extractFromObservations?(observations: string, options?: {
|
|
378
|
-
sessionId?: string;
|
|
379
|
-
signal?: AbortSignal;
|
|
380
|
-
}): Promise<ConversationExtractionResult>;
|
|
381
|
-
/**
|
|
382
|
-
* Return the most recently updated observation session ID.
|
|
383
|
-
* When `arionId` is provided, scope to that arion's observation records.
|
|
384
|
-
*/
|
|
385
|
-
getMostRecentSessionId?(options?: {
|
|
386
|
-
arionId?: string;
|
|
387
|
-
}): Promise<string | null>;
|
|
388
|
-
/**
|
|
389
|
-
* Fetch persisted active observations for a session.
|
|
390
|
-
* Returns null when no observation record exists for the session.
|
|
391
|
-
*/
|
|
392
|
-
getSessionObservations?(sessionId: string): Promise<string | null>;
|
|
393
|
-
/**
|
|
394
|
-
* Full-text search across observation records (LIKE on observations, current_task, suggested_response).
|
|
395
|
-
* Returns matching records ordered by recency.
|
|
396
|
-
*/
|
|
397
|
-
searchObservations?(query: string, limit?: number): Promise<ObservationQueryResult[]>;
|
|
398
|
-
/**
|
|
399
|
-
* Retrieve a specific field from the most recent observation record.
|
|
400
|
-
* Valid fields: "suggested_response", "current_task", "active_observations".
|
|
401
|
-
*/
|
|
402
|
-
getObservationField?(field: "suggested_response" | "current_task" | "active_observations"): Promise<string | null>;
|
|
403
|
-
/**
|
|
404
|
-
* Retrieve the N most recent observation records, ordered by updated_at DESC.
|
|
405
|
-
*/
|
|
406
|
-
getRecentObservations?(limit?: number): Promise<ObservationQueryResult[]>;
|
|
407
|
-
/** Shut down the memory system and release resources. */
|
|
408
|
-
close(): Promise<void>;
|
|
409
|
-
/**
|
|
410
|
-
* Entity-first recall — fast-path for entity/self queries.
|
|
411
|
-
* Returns a formatted string when the query matches a known entity or
|
|
412
|
-
* self-query pattern. Returns null to signal fallback to APR.
|
|
413
|
-
*/
|
|
414
|
-
entityRecall(query: string): Promise<string | null>;
|
|
415
|
-
/** Whether this instance has been closed. */
|
|
416
|
-
readonly isClosed: boolean;
|
|
417
|
-
/** Return the total number of stored memories. */
|
|
418
|
-
count(): Promise<number>;
|
|
419
|
-
/** List stored memories. */
|
|
420
|
-
list(options?: {
|
|
421
|
-
limit?: number;
|
|
422
|
-
network?: string;
|
|
423
|
-
}): Promise<MemoryItem[]>;
|
|
424
|
-
/** Get a config value by key. Returns null if not found. */
|
|
425
|
-
getConfig(key: string): Promise<string | null>;
|
|
426
|
-
/** Set a config value by key. Creates or overwrites. */
|
|
427
|
-
setConfig(key: string, value: string): Promise<void>;
|
|
428
|
-
}
|