@agencer/reverie-loop 0.1.0-alpha.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -69
- package/LICENSE +8 -199
- package/README.md +118 -56
- package/dist/contracts.d.ts +161 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +28 -0
- package/dist/contracts.js.map +1 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +47 -21
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +44 -107
- package/dist/logger.js.map +1 -0
- package/dist/opus-client.d.ts +60 -0
- package/dist/opus-client.d.ts.map +1 -0
- package/dist/opus-client.js +301 -0
- package/dist/opus-client.js.map +1 -0
- package/dist/pair-sink.d.ts +36 -0
- package/dist/pair-sink.d.ts.map +1 -0
- package/dist/pair-sink.js +132 -0
- package/dist/pair-sink.js.map +1 -0
- package/dist/reverie-loop.d.ts +83 -0
- package/dist/reverie-loop.d.ts.map +1 -0
- package/dist/reverie-loop.js +216 -0
- package/dist/reverie-loop.js.map +1 -0
- package/dist/reverie-trigger.d.ts +67 -0
- package/dist/reverie-trigger.d.ts.map +1 -0
- package/dist/reverie-trigger.js +271 -0
- package/dist/reverie-trigger.js.map +1 -0
- package/package.json +43 -12
- package/dist/compat.d.ts +0 -22
- package/dist/compat.js +0 -81
- package/dist/types.d.ts +0 -34
- package/dist/types.js +0 -8
package/dist/compat.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ReverieEntry, type ReverieFailureReason, type ReverieLoggerConfig, type WhisperResultEntry } from "./types.js";
|
|
2
|
-
export declare function initReverieLogger(config: ReverieLoggerConfig): void;
|
|
3
|
-
export declare function logReverie(userMessage: string, miniResponse: string, opusResponse: string, failureReason: ReverieFailureReason, whisperModelId: string): void;
|
|
4
|
-
export declare function logWhisperResult(outcome: "success" | "failure", modelId: string, userMessage: string, response: string): void;
|
|
5
|
-
/**
|
|
6
|
-
* Read the reverie log.
|
|
7
|
-
*
|
|
8
|
-
* Callers may pass an explicit directory (used in tests and diagnostic tools),
|
|
9
|
-
* or rely on the directory set by {@link initReverieLogger}. With no init and
|
|
10
|
-
* no argument, returns `[]`.
|
|
11
|
-
*
|
|
12
|
-
* When an explicit `logDir` is given AND a singleton has been initialized with
|
|
13
|
-
* a custom `reverieFilename`, the singleton's filename is honored. This keeps
|
|
14
|
-
* the compat API internally consistent: writes and reads target the same file.
|
|
15
|
-
*/
|
|
16
|
-
export declare function readReverieLog(logDir?: string): ReverieEntry[];
|
|
17
|
-
/**
|
|
18
|
-
* Read the whisper-result log. Same explicit-dir / singleton-filename semantics
|
|
19
|
-
* as {@link readReverieLog}.
|
|
20
|
-
*/
|
|
21
|
-
export declare function readWhisperResultLog(logDir?: string): WhisperResultEntry[];
|
|
22
|
-
export declare function resetReverieLoggerSingletonForTests(): void;
|
package/dist/compat.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { ReverieLogger } from "./logger.js";
|
|
4
|
-
import { DEFAULT_REVERIE_FILENAME, DEFAULT_WHISPER_RESULT_FILENAME, } from "./types.js";
|
|
5
|
-
// Module-level singleton. Mirrors the dual-API shape of @agencer/session-logger.
|
|
6
|
-
// Calls without a prior `initReverieLogger` are silent no-ops (preserves the
|
|
7
|
-
// "NEVER break caller" discipline even when init is forgotten).
|
|
8
|
-
let singleton = null;
|
|
9
|
-
export function initReverieLogger(config) {
|
|
10
|
-
singleton = new ReverieLogger(config);
|
|
11
|
-
}
|
|
12
|
-
export function logReverie(userMessage, miniResponse, opusResponse, failureReason, whisperModelId) {
|
|
13
|
-
if (!singleton)
|
|
14
|
-
return;
|
|
15
|
-
singleton.logReverie(userMessage, miniResponse, opusResponse, failureReason, whisperModelId);
|
|
16
|
-
}
|
|
17
|
-
export function logWhisperResult(outcome, modelId, userMessage, response) {
|
|
18
|
-
if (!singleton)
|
|
19
|
-
return;
|
|
20
|
-
singleton.logWhisperResult(outcome, modelId, userMessage, response);
|
|
21
|
-
}
|
|
22
|
-
function readJsonlLenient(logPath) {
|
|
23
|
-
try {
|
|
24
|
-
if (!fs.existsSync(logPath))
|
|
25
|
-
return [];
|
|
26
|
-
const raw = fs.readFileSync(logPath, "utf-8");
|
|
27
|
-
const out = [];
|
|
28
|
-
for (const line of raw.split("\n")) {
|
|
29
|
-
if (line.length === 0)
|
|
30
|
-
continue;
|
|
31
|
-
try {
|
|
32
|
-
out.push(JSON.parse(line));
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// Skip torn/corrupt lines, keep valid records.
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Read the reverie log.
|
|
46
|
-
*
|
|
47
|
-
* Callers may pass an explicit directory (used in tests and diagnostic tools),
|
|
48
|
-
* or rely on the directory set by {@link initReverieLogger}. With no init and
|
|
49
|
-
* no argument, returns `[]`.
|
|
50
|
-
*
|
|
51
|
-
* When an explicit `logDir` is given AND a singleton has been initialized with
|
|
52
|
-
* a custom `reverieFilename`, the singleton's filename is honored. This keeps
|
|
53
|
-
* the compat API internally consistent: writes and reads target the same file.
|
|
54
|
-
*/
|
|
55
|
-
export function readReverieLog(logDir) {
|
|
56
|
-
if (logDir !== undefined) {
|
|
57
|
-
const filename = singleton ? singleton.reverieFilename : DEFAULT_REVERIE_FILENAME;
|
|
58
|
-
return readJsonlLenient(path.join(logDir, filename));
|
|
59
|
-
}
|
|
60
|
-
if (!singleton)
|
|
61
|
-
return [];
|
|
62
|
-
return singleton.readReverieLog();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Read the whisper-result log. Same explicit-dir / singleton-filename semantics
|
|
66
|
-
* as {@link readReverieLog}.
|
|
67
|
-
*/
|
|
68
|
-
export function readWhisperResultLog(logDir) {
|
|
69
|
-
if (logDir !== undefined) {
|
|
70
|
-
const filename = singleton
|
|
71
|
-
? singleton.whisperResultFilename
|
|
72
|
-
: DEFAULT_WHISPER_RESULT_FILENAME;
|
|
73
|
-
return readJsonlLenient(path.join(logDir, filename));
|
|
74
|
-
}
|
|
75
|
-
if (!singleton)
|
|
76
|
-
return [];
|
|
77
|
-
return singleton.readWhisperResultLog();
|
|
78
|
-
}
|
|
79
|
-
export function resetReverieLoggerSingletonForTests() {
|
|
80
|
-
singleton = null;
|
|
81
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type ReverieFailureReason = "weak_response" | "user_corrected" | "timeout" | "error";
|
|
2
|
-
export interface ReverieEntry {
|
|
3
|
-
type: "reverie";
|
|
4
|
-
user_message: string;
|
|
5
|
-
mini_response: string;
|
|
6
|
-
opus_response: string;
|
|
7
|
-
failure_reason: ReverieFailureReason;
|
|
8
|
-
whisper_model_id: string;
|
|
9
|
-
timestamp: string;
|
|
10
|
-
}
|
|
11
|
-
export interface WhisperResultEntry {
|
|
12
|
-
type: "whisper_result";
|
|
13
|
-
outcome: "success" | "failure";
|
|
14
|
-
model_id: string;
|
|
15
|
-
user_message: string;
|
|
16
|
-
response_length: number;
|
|
17
|
-
timestamp: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ReverieLoggerConfig {
|
|
20
|
-
/** Absolute directory to write the JSONL files into. Required. */
|
|
21
|
-
readonly logDir: string;
|
|
22
|
-
/** Filename inside {@link logDir} for reverie entries. Default: "reveries.jsonl". */
|
|
23
|
-
readonly reverieFilename?: string;
|
|
24
|
-
/** Filename inside {@link logDir} for whisper-result entries. Default: "whisper-results.jsonl". */
|
|
25
|
-
readonly whisperResultFilename?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare const DEFAULT_REVERIE_FILENAME = "reveries.jsonl";
|
|
28
|
-
export declare const DEFAULT_WHISPER_RESULT_FILENAME = "whisper-results.jsonl";
|
|
29
|
-
/**
|
|
30
|
-
* Max stored length for `WhisperResultEntry.user_message`. The legacy
|
|
31
|
-
* source truncated to 200 chars; the Lego preserves that to keep the
|
|
32
|
-
* ingestion shape stable for the learning-loop `sync.py` pipeline.
|
|
33
|
-
*/
|
|
34
|
-
export declare const WHISPER_RESULT_USER_MESSAGE_MAX_LENGTH = 200;
|
package/dist/types.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_REVERIE_FILENAME = "reveries.jsonl";
|
|
2
|
-
export const DEFAULT_WHISPER_RESULT_FILENAME = "whisper-results.jsonl";
|
|
3
|
-
/**
|
|
4
|
-
* Max stored length for `WhisperResultEntry.user_message`. The legacy
|
|
5
|
-
* source truncated to 200 chars; the Lego preserves that to keep the
|
|
6
|
-
* ingestion shape stable for the learning-loop `sync.py` pipeline.
|
|
7
|
-
*/
|
|
8
|
-
export const WHISPER_RESULT_USER_MESSAGE_MAX_LENGTH = 200;
|