abmind 0.2.6 → 0.2.7-alpha.1
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/SUPPORTED-SURFACE.md +20 -2
- package/dist/cli/abmind-hook-recall.js +17 -40
- package/dist/cli/abmind-hook-recall.js.map +1 -1
- package/dist/cli/abmind-hook-store.js +10 -31
- package/dist/cli/abmind-hook-store.js.map +1 -1
- package/dist/cli/abmind-hook-wakeup.js +17 -3
- package/dist/cli/abmind-hook-wakeup.js.map +1 -1
- package/dist/cli/abmind-install.js +19 -19
- package/dist/cli/abmind-install.js.map +1 -1
- package/dist/cli/abmind-restore.js +10 -0
- package/dist/cli/abmind-restore.js.map +1 -1
- package/dist/cli/abmind-sleep.d.ts +9 -5
- package/dist/cli/abmind-sleep.d.ts.map +1 -1
- package/dist/cli/abmind-sleep.js +61 -14
- package/dist/cli/abmind-sleep.js.map +1 -1
- package/dist/cli/hook-lifecycle-adapter.d.ts +11 -0
- package/dist/cli/hook-lifecycle-adapter.d.ts.map +1 -0
- package/dist/cli/hook-lifecycle-adapter.js +33 -0
- package/dist/cli/hook-lifecycle-adapter.js.map +1 -0
- package/dist/src/context-engine.d.ts +13 -3
- package/dist/src/context-engine.d.ts.map +1 -1
- package/dist/src/context-engine.js +22 -5
- package/dist/src/context-engine.js.map +1 -1
- package/dist/src/context-orchestrator.d.ts +20 -2
- package/dist/src/context-orchestrator.d.ts.map +1 -1
- package/dist/src/context-orchestrator.js +11 -3
- package/dist/src/context-orchestrator.js.map +1 -1
- package/dist/src/context-tier-renderer.d.ts +8 -1
- package/dist/src/context-tier-renderer.d.ts.map +1 -1
- package/dist/src/context-tier-renderer.js +7 -2
- package/dist/src/context-tier-renderer.js.map +1 -1
- package/dist/src/ensure-initialized.d.ts +5 -0
- package/dist/src/ensure-initialized.d.ts.map +1 -1
- package/dist/src/ensure-initialized.js +19 -28
- package/dist/src/ensure-initialized.js.map +1 -1
- package/dist/src/host-integration/identity.d.ts +10 -0
- package/dist/src/host-integration/identity.d.ts.map +1 -0
- package/dist/src/host-integration/identity.js +66 -0
- package/dist/src/host-integration/identity.js.map +1 -0
- package/dist/src/host-integration/index.d.ts +5 -0
- package/dist/src/host-integration/index.d.ts.map +1 -0
- package/dist/src/host-integration/index.js +4 -0
- package/dist/src/host-integration/index.js.map +1 -0
- package/dist/src/host-integration/lifecycle.d.ts +14 -0
- package/dist/src/host-integration/lifecycle.d.ts.map +1 -0
- package/dist/src/host-integration/lifecycle.js +192 -0
- package/dist/src/host-integration/lifecycle.js.map +1 -0
- package/dist/src/host-integration/render.d.ts +5 -0
- package/dist/src/host-integration/render.d.ts.map +1 -0
- package/dist/src/host-integration/render.js +20 -0
- package/dist/src/host-integration/render.js.map +1 -0
- package/dist/src/host-integration/types.d.ts +107 -0
- package/dist/src/host-integration/types.d.ts.map +1 -0
- package/dist/src/host-integration/types.js +2 -0
- package/dist/src/host-integration/types.js.map +1 -0
- package/dist/src/imemory-system.d.ts +1 -1
- package/dist/src/imemory-system.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/maintenance-service.d.ts +11 -0
- package/dist/src/maintenance-service.d.ts.map +1 -1
- package/dist/src/maintenance-service.js +43 -0
- package/dist/src/maintenance-service.js.map +1 -1
- package/dist/src/memory-manager.d.ts +6 -2
- package/dist/src/memory-manager.d.ts.map +1 -1
- package/dist/src/memory-manager.js +9 -5
- package/dist/src/memory-manager.js.map +1 -1
- package/dist/src/message-store.d.ts +15 -3
- package/dist/src/message-store.d.ts.map +1 -1
- package/dist/src/message-store.js +28 -9
- package/dist/src/message-store.js.map +1 -1
- package/dist/src/openclaw-plugin/index.d.ts.map +1 -1
- package/dist/src/openclaw-plugin/index.js +3 -2
- package/dist/src/openclaw-plugin/index.js.map +1 -1
- package/dist/src/pi-plugin/abtars-client.d.ts +22 -0
- package/dist/src/pi-plugin/abtars-client.d.ts.map +1 -0
- package/dist/src/pi-plugin/abtars-client.js +153 -0
- package/dist/src/pi-plugin/abtars-client.js.map +1 -0
- package/dist/src/pi-plugin/abtars-tools.d.ts +8 -0
- package/dist/src/pi-plugin/abtars-tools.d.ts.map +1 -0
- package/dist/src/pi-plugin/abtars-tools.js +317 -0
- package/dist/src/pi-plugin/abtars-tools.js.map +1 -0
- package/dist/src/pi-plugin/identity.d.ts +8 -0
- package/dist/src/pi-plugin/identity.d.ts.map +1 -0
- package/dist/src/pi-plugin/identity.js +37 -0
- package/dist/src/pi-plugin/identity.js.map +1 -0
- package/dist/src/pi-plugin/index.d.ts +3 -0
- package/dist/src/pi-plugin/index.d.ts.map +1 -0
- package/dist/src/pi-plugin/index.js +139 -0
- package/dist/src/pi-plugin/index.js.map +1 -0
- package/dist/src/pi-plugin/messages.d.ts +4 -0
- package/dist/src/pi-plugin/messages.d.ts.map +1 -0
- package/dist/src/pi-plugin/messages.js +36 -0
- package/dist/src/pi-plugin/messages.js.map +1 -0
- package/dist/src/pi-plugin/pi-types.d.ts +126 -0
- package/dist/src/pi-plugin/pi-types.d.ts.map +1 -0
- package/dist/src/pi-plugin/pi-types.js +15 -0
- package/dist/src/pi-plugin/pi-types.js.map +1 -0
- package/dist/src/pi-plugin/runtime.d.ts +21 -0
- package/dist/src/pi-plugin/runtime.d.ts.map +1 -0
- package/dist/src/pi-plugin/runtime.js +60 -0
- package/dist/src/pi-plugin/runtime.js.map +1 -0
- package/dist/src/pi-plugin/tools.d.ts +11 -0
- package/dist/src/pi-plugin/tools.d.ts.map +1 -0
- package/dist/src/pi-plugin/tools.js +136 -0
- package/dist/src/pi-plugin/tools.js.map +1 -0
- package/dist/src/reconcile.d.ts +2 -0
- package/dist/src/reconcile.d.ts.map +1 -1
- package/dist/src/reconcile.js +21 -4
- package/dist/src/reconcile.js.map +1 -1
- package/dist/src/session-context.d.ts +1 -0
- package/dist/src/session-context.d.ts.map +1 -1
- package/dist/src/session-context.js +42 -23
- package/dist/src/session-context.js.map +1 -1
- package/dist/src/sleep/basic.d.ts +1 -1
- package/dist/src/sleep/basic.d.ts.map +1 -1
- package/dist/src/sleep/basic.js +5 -2
- package/dist/src/sleep/basic.js.map +1 -1
- package/dist/src/sleep/catchup.d.ts +3 -5
- package/dist/src/sleep/catchup.d.ts.map +1 -1
- package/dist/src/sleep/catchup.js +37 -55
- package/dist/src/sleep/catchup.js.map +1 -1
- package/dist/src/sleep/contracts.d.ts +112 -0
- package/dist/src/sleep/contracts.d.ts.map +1 -0
- package/dist/src/sleep/contracts.js +25 -0
- package/dist/src/sleep/contracts.js.map +1 -0
- package/dist/src/sleep/llm-budget.d.ts +34 -14
- package/dist/src/sleep/llm-budget.d.ts.map +1 -1
- package/dist/src/sleep/llm-budget.js +66 -52
- package/dist/src/sleep/llm-budget.js.map +1 -1
- package/dist/src/sleep/orchestrator.d.ts +19 -69
- package/dist/src/sleep/orchestrator.d.ts.map +1 -1
- package/dist/src/sleep/orchestrator.js +286 -270
- package/dist/src/sleep/orchestrator.js.map +1 -1
- package/dist/src/sleep/state.d.ts +7 -19
- package/dist/src/sleep/state.d.ts.map +1 -1
- package/dist/src/sleep/state.js +5 -38
- package/dist/src/sleep/state.js.map +1 -1
- package/dist/src/sleep/test-harness.d.ts +3 -1
- package/dist/src/sleep/test-harness.d.ts.map +1 -1
- package/dist/src/sleep/test-harness.js +3 -2
- package/dist/src/sleep/test-harness.js.map +1 -1
- package/dist/src/soul-seeder.d.ts +36 -0
- package/dist/src/soul-seeder.d.ts.map +1 -0
- package/dist/src/soul-seeder.js +69 -0
- package/dist/src/soul-seeder.js.map +1 -0
- package/dist/src/wake-up-builder.d.ts +3 -1
- package/dist/src/wake-up-builder.d.ts.map +1 -1
- package/dist/src/wake-up-builder.js +29 -5
- package/dist/src/wake-up-builder.js.map +1 -1
- package/package.json +20 -2
- package/dist/cli/abmind-rollback.d.ts +0 -8
- package/dist/cli/abmind-rollback.d.ts.map +0 -1
- package/dist/cli/abmind-rollback.js +0 -78
- package/dist/cli/abmind-rollback.js.map +0 -1
- package/dist/src/native-loader.d.ts +0 -7
- package/dist/src/native-loader.d.ts.map +0 -1
- package/dist/src/native-loader.js +0 -21
- package/dist/src/native-loader.js.map +0 -1
- package/dist/src/recall-benchmark.d.ts +0 -13
- package/dist/src/recall-benchmark.d.ts.map +0 -1
- package/dist/src/recall-benchmark.js +0 -260
- package/dist/src/recall-benchmark.js.map +0 -1
- package/dist/src/sleep/runtime.d.ts +0 -15
- package/dist/src/sleep/runtime.d.ts.map +0 -1
- package/dist/src/sleep/runtime.js +0 -2
- package/dist/src/sleep/runtime.js.map +0 -1
- package/dist/src/wake-up-renderer.d.ts +0 -24
- package/dist/src/wake-up-renderer.d.ts.map +0 -1
- package/dist/src/wake-up-renderer.js +0 -148
- package/dist/src/wake-up-renderer.js.map +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sleep/contracts.ts — host-neutral public contract for the abmind sleep
|
|
3
|
+
* engine (#1353).
|
|
4
|
+
*
|
|
5
|
+
* abmind owns memory-domain maintenance: step ordering, shared variables,
|
|
6
|
+
* budget, checkpoints, resume/catch-up, watermark, and the final domain
|
|
7
|
+
* result. An embedding host (abtars, OpenClaw, Hermes, the standalone CLI)
|
|
8
|
+
* owns scheduling, authenticated/manual admission, model/provider transport,
|
|
9
|
+
* agent/session lifecycle, and delivery. This file is the seam between them.
|
|
10
|
+
*
|
|
11
|
+
* These types are exported from the package root and listed in
|
|
12
|
+
* SUPPORTED-SURFACE.md. Internal state-file shapes (SleepState, StepResult,
|
|
13
|
+
* lock-file JSON) remain private — a host must never read them directly.
|
|
14
|
+
*/
|
|
15
|
+
import type { Level } from "./levels.js";
|
|
16
|
+
import type { MemoryConfig } from "../memory-config.js";
|
|
17
|
+
/** One model-completion request for a single sleep step.
|
|
18
|
+
* `signal` combines the caller's cancellation with the configured wall-clock
|
|
19
|
+
* timeout — hosts must pass it through to their own transport/abort logic. */
|
|
20
|
+
export interface SleepCompletionRequest {
|
|
21
|
+
prompt: string;
|
|
22
|
+
stepId: string;
|
|
23
|
+
runId: string;
|
|
24
|
+
signal: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/** Host-injected model runtime. One method: send a prompt, get text back.
|
|
27
|
+
* Reject on transport failure — abmind does not operate a provider retry
|
|
28
|
+
* loop; a rejection maps directly to abmind's own essential-step/suspend
|
|
29
|
+
* policy. Hosts own their own provider retry/fallback before rejecting. */
|
|
30
|
+
export interface SleepRuntime {
|
|
31
|
+
complete(request: SleepCompletionRequest): Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
/** "manual" runs (e.g. an explicit "/sleep now") still run housekeeping even
|
|
34
|
+
* with zero new messages since the last cycle — matching the historical
|
|
35
|
+
* --force behavior. "scheduled" and "resume" respect the no-work guard. */
|
|
36
|
+
export type SleepRunMode = "scheduled" | "manual" | "resume";
|
|
37
|
+
export interface SleepRunOptions {
|
|
38
|
+
runtime: SleepRuntime;
|
|
39
|
+
mode?: SleepRunMode;
|
|
40
|
+
level?: Level;
|
|
41
|
+
/** Caller-supplied cancellation — combined internally with the wall-clock timeout. */
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
/** Discard prior state and start with a clean budget. Used by manual "now" runs. */
|
|
44
|
+
fresh?: boolean;
|
|
45
|
+
/** Best-effort lifecycle observer. A throwing handler never alters the run. */
|
|
46
|
+
onEvent?: (event: SleepEvent) => void;
|
|
47
|
+
now?: () => number;
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
memoryConfigOverride?: Partial<MemoryConfig>;
|
|
50
|
+
/** Internal test seam — delay between bounded domain retries (empty/invalid
|
|
51
|
+
* response). Not part of the documented public contract; defaults to 6000ms. */
|
|
52
|
+
domainRetryDelayMs?: number;
|
|
53
|
+
/** Internal test seam — inter-step backoff after a non-essential step
|
|
54
|
+
* failure, keyed by consecutive-failure count. Not part of the documented
|
|
55
|
+
* public contract; defaults to [10,30,60]s capped. */
|
|
56
|
+
betweenStepBackoffMs?: (consecutiveFailures: number) => number;
|
|
57
|
+
}
|
|
58
|
+
export type SleepTerminalStatus = "completed" | "no_work" | "partial" | "failed" | "cancelled" | "already_running";
|
|
59
|
+
export interface SleepStepSummary {
|
|
60
|
+
id: string;
|
|
61
|
+
status: "completed" | "skipped" | "failed" | "timeout";
|
|
62
|
+
essential: boolean;
|
|
63
|
+
attempts: number;
|
|
64
|
+
durationMs?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface SleepRunResult {
|
|
67
|
+
runId: string;
|
|
68
|
+
status: SleepTerminalStatus;
|
|
69
|
+
startedAt: number;
|
|
70
|
+
finishedAt: number;
|
|
71
|
+
llmCalls: number;
|
|
72
|
+
steps: readonly SleepStepSummary[];
|
|
73
|
+
essentialFailures: readonly string[];
|
|
74
|
+
resumable: boolean;
|
|
75
|
+
watermarkAdvanced: boolean;
|
|
76
|
+
report: string;
|
|
77
|
+
}
|
|
78
|
+
/** Neutral lifecycle events. Bounded metadata only — never prompts or raw
|
|
79
|
+
* model responses. Exactly one `cycle_finished` is attempted for every run
|
|
80
|
+
* that emitted `cycle_started`. */
|
|
81
|
+
export type SleepEvent = {
|
|
82
|
+
type: "cycle_started";
|
|
83
|
+
runId: string;
|
|
84
|
+
totalSteps: number;
|
|
85
|
+
resumed: boolean;
|
|
86
|
+
} | {
|
|
87
|
+
type: "step_started";
|
|
88
|
+
runId: string;
|
|
89
|
+
stepId: string;
|
|
90
|
+
index: number;
|
|
91
|
+
total: number;
|
|
92
|
+
} | {
|
|
93
|
+
type: "step_completed";
|
|
94
|
+
runId: string;
|
|
95
|
+
step: SleepStepSummary;
|
|
96
|
+
} | {
|
|
97
|
+
type: "step_skipped";
|
|
98
|
+
runId: string;
|
|
99
|
+
step: SleepStepSummary;
|
|
100
|
+
} | {
|
|
101
|
+
type: "step_failed";
|
|
102
|
+
runId: string;
|
|
103
|
+
step: SleepStepSummary;
|
|
104
|
+
} | {
|
|
105
|
+
type: "cycle_finished";
|
|
106
|
+
runId: string;
|
|
107
|
+
result: SleepRunResult;
|
|
108
|
+
};
|
|
109
|
+
/** Best-effort event dispatch — an observer that throws must never alter the
|
|
110
|
+
* memory transaction, ordering, or final result (#1353 constraint 5). */
|
|
111
|
+
export declare function emitSleepEvent(handler: ((event: SleepEvent) => void) | undefined, event: SleepEvent): void;
|
|
112
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/sleep/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;+EAE+E;AAC/E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;4EAG4E;AAC5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D;AAED;;4EAE4E;AAC5E,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,oFAAoF;IACpF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAGtC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,SA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,KAAK,EAAE,MAAM,CAAA;CAAE,GACrF;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAEtE;0EAC0E;AAC1E,wBAAgB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAG1G"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sleep/contracts.ts — host-neutral public contract for the abmind sleep
|
|
3
|
+
* engine (#1353).
|
|
4
|
+
*
|
|
5
|
+
* abmind owns memory-domain maintenance: step ordering, shared variables,
|
|
6
|
+
* budget, checkpoints, resume/catch-up, watermark, and the final domain
|
|
7
|
+
* result. An embedding host (abtars, OpenClaw, Hermes, the standalone CLI)
|
|
8
|
+
* owns scheduling, authenticated/manual admission, model/provider transport,
|
|
9
|
+
* agent/session lifecycle, and delivery. This file is the seam between them.
|
|
10
|
+
*
|
|
11
|
+
* These types are exported from the package root and listed in
|
|
12
|
+
* SUPPORTED-SURFACE.md. Internal state-file shapes (SleepState, StepResult,
|
|
13
|
+
* lock-file JSON) remain private — a host must never read them directly.
|
|
14
|
+
*/
|
|
15
|
+
/** Best-effort event dispatch — an observer that throws must never alter the
|
|
16
|
+
* memory transaction, ordering, or final result (#1353 constraint 5). */
|
|
17
|
+
export function emitSleepEvent(handler, event) {
|
|
18
|
+
if (!handler)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
handler(event);
|
|
22
|
+
}
|
|
23
|
+
catch { /* host display only — never fail the cycle */ }
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/sleep/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA4FH;0EAC0E;AAC1E,MAAM,UAAU,cAAc,CAAC,OAAkD,EAAE,KAAiB;IAClG,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC;QAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,8CAA8C,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* sleep/llm-budget.ts — LLM call budget tracking and retry
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* sleep/llm-budget.ts — LLM call budget tracking and bounded domain retry.
|
|
3
|
+
*
|
|
4
|
+
* #1353: transport retry/backoff is a host responsibility, not abmind's.
|
|
5
|
+
* `SleepRuntime.complete()` is one host-supervised model operation — if it
|
|
6
|
+
* rejects, the host has already exhausted its own provider retry/fallback
|
|
7
|
+
* policy. Abmind records a transport-unavailable step outcome and follows
|
|
8
|
+
* its existing essential-step stop/suspend rules; it does not sleep and
|
|
9
|
+
* retry the provider itself.
|
|
10
|
+
*
|
|
11
|
+
* The bounded retry that remains here is a DOMAIN retry: a structurally
|
|
12
|
+
* empty or invalid *successful* response is retried a small number of times
|
|
13
|
+
* because another model call is semantically meaningful (the model may
|
|
14
|
+
* simply produce a better answer next time). Every model-reaching attempt —
|
|
15
|
+
* retried or not — is charged to the LLM budget.
|
|
5
16
|
*/
|
|
6
17
|
import { LLMUnavailableError } from "../sleep-pipeline.js";
|
|
7
|
-
import type { SleepRuntime } from "./
|
|
18
|
+
import type { SleepRuntime } from "./contracts.js";
|
|
8
19
|
import type { SleepState } from "./state.js";
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
export declare class
|
|
16
|
-
constructor(
|
|
20
|
+
/** Bounded retries for an empty/invalid domain response. Not a transport retry. */
|
|
21
|
+
export declare const MAX_DOMAIN_RETRIES = 3;
|
|
22
|
+
/** Thrown when the host's `runtime.complete()` rejects — a transport failure,
|
|
23
|
+
* not a domain one. Extends LLMUnavailableError so buildDailySummary/
|
|
24
|
+
* extractFromDaily propagate it naturally (they check instanceof
|
|
25
|
+
* LLMUnavailableError to bubble errors up to the orchestrator). */
|
|
26
|
+
export declare class TransportUnavailableError extends LLMUnavailableError {
|
|
27
|
+
constructor(stepId: string, cause?: unknown);
|
|
17
28
|
}
|
|
18
|
-
/** Budget tracker — shared across all
|
|
29
|
+
/** Budget tracker — shared across all completion calls in a sleep cycle. */
|
|
19
30
|
export declare class LlmBudget {
|
|
20
31
|
private state;
|
|
21
32
|
private readonly statePath;
|
|
@@ -25,5 +36,14 @@ export declare class LlmBudget {
|
|
|
25
36
|
consume(): boolean;
|
|
26
37
|
get calls(): number;
|
|
27
38
|
}
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Send one prompt through the host runtime with bounded domain retry for
|
|
41
|
+
* empty/invalid responses. A runtime rejection is NOT retried here — it
|
|
42
|
+
* propagates immediately as TransportUnavailableError so the orchestrator
|
|
43
|
+
* can apply its own essential-step stop/suspend policy.
|
|
44
|
+
*
|
|
45
|
+
* Returns null if the budget is already exhausted, or after MAX_DOMAIN_RETRIES
|
|
46
|
+
* consecutive empty responses.
|
|
47
|
+
*/
|
|
48
|
+
export declare function sendToRuntime(runtime: SleepRuntime, prompt: string, stepId: string, runId: string, signal: AbortSignal, budget?: LlmBudget, delayMs?: number): Promise<string | null>;
|
|
29
49
|
//# sourceMappingURL=llm-budget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-budget.d.ts","sourceRoot":"","sources":["../../../src/sleep/llm-budget.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"llm-budget.d.ts","sourceRoot":"","sources":["../../../src/sleep/llm-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,gBAAgB,CAAC;AAE3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;oEAGoE;AACpE,qBAAa,yBAA0B,SAAQ,mBAAmB;gBACpD,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK5C;AAED,4EAA4E;AAC5E,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,SAAS,UAAS;gBAEN,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM;IAKhD,2DAA2D;IAC3D,OAAO,IAAI,OAAO;IAUlB,IAAI,KAAK,IAAI,MAAM,CAAqC;CACzD;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,SAAS,EAClB,OAAO,SAAO,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyCxB"}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* sleep/llm-budget.ts — LLM call budget tracking and retry
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* sleep/llm-budget.ts — LLM call budget tracking and bounded domain retry.
|
|
3
|
+
*
|
|
4
|
+
* #1353: transport retry/backoff is a host responsibility, not abmind's.
|
|
5
|
+
* `SleepRuntime.complete()` is one host-supervised model operation — if it
|
|
6
|
+
* rejects, the host has already exhausted its own provider retry/fallback
|
|
7
|
+
* policy. Abmind records a transport-unavailable step outcome and follows
|
|
8
|
+
* its existing essential-step stop/suspend rules; it does not sleep and
|
|
9
|
+
* retry the provider itself.
|
|
10
|
+
*
|
|
11
|
+
* The bounded retry that remains here is a DOMAIN retry: a structurally
|
|
12
|
+
* empty or invalid *successful* response is retried a small number of times
|
|
13
|
+
* because another model call is semantically meaningful (the model may
|
|
14
|
+
* simply produce a better answer next time). Every model-reaching attempt —
|
|
15
|
+
* retried or not — is charged to the LLM budget.
|
|
5
16
|
*/
|
|
6
17
|
import { getAbmindEnv } from "../env-schema.js";
|
|
7
|
-
import { logWarn, logError
|
|
18
|
+
import { logWarn, logError } from "../mem-logger.js";
|
|
8
19
|
import { LLMUnavailableError } from "../sleep-pipeline.js";
|
|
9
20
|
import { writeStateFile } from "./state.js";
|
|
10
21
|
const TAG = "abmind-sleep";
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
export class
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
/** Bounded retries for an empty/invalid domain response. Not a transport retry. */
|
|
23
|
+
export const MAX_DOMAIN_RETRIES = 3;
|
|
24
|
+
/** Thrown when the host's `runtime.complete()` rejects — a transport failure,
|
|
25
|
+
* not a domain one. Extends LLMUnavailableError so buildDailySummary/
|
|
26
|
+
* extractFromDaily propagate it naturally (they check instanceof
|
|
27
|
+
* LLMUnavailableError to bubble errors up to the orchestrator). */
|
|
28
|
+
export class TransportUnavailableError extends LLMUnavailableError {
|
|
29
|
+
constructor(stepId, cause) {
|
|
30
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
31
|
+
super(`Runtime rejected for step "${stepId}": ${msg}`);
|
|
32
|
+
this.name = "TransportUnavailableError";
|
|
21
33
|
}
|
|
22
34
|
}
|
|
23
|
-
/** Budget tracker — shared across all
|
|
35
|
+
/** Budget tracker — shared across all completion calls in a sleep cycle. */
|
|
24
36
|
export class LlmBudget {
|
|
25
37
|
state;
|
|
26
38
|
statePath;
|
|
@@ -41,52 +53,54 @@ export class LlmBudget {
|
|
|
41
53
|
}
|
|
42
54
|
get calls() { return this.state.llmCalls ?? 0; }
|
|
43
55
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Send one prompt through the host runtime with bounded domain retry for
|
|
58
|
+
* empty/invalid responses. A runtime rejection is NOT retried here — it
|
|
59
|
+
* propagates immediately as TransportUnavailableError so the orchestrator
|
|
60
|
+
* can apply its own essential-step stop/suspend policy.
|
|
61
|
+
*
|
|
62
|
+
* Returns null if the budget is already exhausted, or after MAX_DOMAIN_RETRIES
|
|
63
|
+
* consecutive empty responses.
|
|
64
|
+
*/
|
|
65
|
+
export async function sendToRuntime(runtime, prompt, stepId, runId, signal, budget, delayMs = 6000) {
|
|
50
66
|
if (budget?.exhausted) {
|
|
51
|
-
logWarn(TAG, `[BUDGET] LLM call limit (${getAbmindEnv().sleepMaxLlmCalls}) reached at step ${
|
|
67
|
+
logWarn(TAG, `[BUDGET] LLM call limit (${getAbmindEnv().sleepMaxLlmCalls}) reached at step ${stepId} — suspending`);
|
|
52
68
|
return null;
|
|
53
69
|
}
|
|
70
|
+
let emptyAttempts = 0;
|
|
54
71
|
while (true) {
|
|
72
|
+
if (signal.aborted)
|
|
73
|
+
return null;
|
|
74
|
+
const request = { prompt, stepId, runId, signal };
|
|
75
|
+
let result;
|
|
55
76
|
try {
|
|
56
|
-
|
|
57
|
-
// Real call reached the model — count it now (success OR empty, never a throw).
|
|
58
|
-
if (budget && !budget.consume()) {
|
|
59
|
-
logWarn(TAG, `[BUDGET] LLM call limit (${getAbmindEnv().sleepMaxLlmCalls}) reached at step ${stepName} — suspending`);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
if (!result || !result.trim()) {
|
|
63
|
-
emptyAttempts++;
|
|
64
|
-
logWarn(TAG, `Step ${stepName} attempt ${emptyAttempts}/${MAX_RETRIES} returned empty response`);
|
|
65
|
-
if (emptyAttempts >= MAX_RETRIES) {
|
|
66
|
-
logError(TAG, `Step ${stepName} failed after ${MAX_RETRIES} attempts (empty), skipping`);
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (delayMs > 0)
|
|
70
|
-
await new Promise(r => setTimeout(r, delayMs));
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
77
|
+
result = await runtime.complete(request);
|
|
74
78
|
}
|
|
75
79
|
catch (err) {
|
|
76
|
-
// Transport failure — model unreachable
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
// Transport failure — model unreachable via the host's own transport.
|
|
81
|
+
// No abmind-side backoff/retry window: the host has already exhausted
|
|
82
|
+
// its provider policy. Surface immediately.
|
|
83
|
+
throw new TransportUnavailableError(stepId, err);
|
|
84
|
+
}
|
|
85
|
+
// Real call reached the model — count it now (success OR empty, never a throw).
|
|
86
|
+
if (budget && !budget.consume()) {
|
|
87
|
+
logWarn(TAG, `[BUDGET] LLM call limit (${getAbmindEnv().sleepMaxLlmCalls}) reached at step ${stepId} — suspending`);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
if (!result || !result.trim()) {
|
|
91
|
+
emptyAttempts++;
|
|
92
|
+
logWarn(TAG, `Step ${stepId} attempt ${emptyAttempts}/${MAX_DOMAIN_RETRIES} returned empty response`);
|
|
93
|
+
if (emptyAttempts >= MAX_DOMAIN_RETRIES) {
|
|
94
|
+
logError(TAG, `Step ${stepId} failed after ${MAX_DOMAIN_RETRIES} attempts (empty), skipping`);
|
|
95
|
+
return null;
|
|
85
96
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
if (signal.aborted)
|
|
98
|
+
return null;
|
|
99
|
+
if (delayMs > 0)
|
|
100
|
+
await new Promise(r => setTimeout(r, delayMs));
|
|
101
|
+
continue;
|
|
89
102
|
}
|
|
103
|
+
return result;
|
|
90
104
|
}
|
|
91
105
|
}
|
|
92
106
|
//# sourceMappingURL=llm-budget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-budget.js","sourceRoot":"","sources":["../../../src/sleep/llm-budget.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"llm-budget.js","sourceRoot":"","sources":["../../../src/sleep/llm-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,MAAM,GAAG,GAAG,cAAc,CAAC;AAE3B,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;;oEAGoE;AACpE,MAAM,OAAO,yBAA0B,SAAQ,mBAAmB;IAChE,YAAY,MAAc,EAAE,KAAe;QACzC,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,KAAK,CAAC,8BAA8B,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,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node
|
|
2
2
|
/**
|
|
3
|
-
* abmind sleep orchestrator —
|
|
3
|
+
* abmind sleep orchestrator — host-neutral memory-maintenance engine (#1353).
|
|
4
4
|
*
|
|
5
|
-
* Called via runSleepCycle(
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Called via runSleepCycle(options). Gathers system state, runs through a
|
|
6
|
+
* pipeline of prompt-driven steps (gc-noise, daily-summary, extract-memories,
|
|
7
|
+
* retrospective, retro-derive, etc.), persists audit log, returns a structured
|
|
8
|
+
* SleepRunResult.
|
|
9
|
+
*
|
|
10
|
+
* abmind owns: step ordering, shared variables/outputs, wired memory
|
|
11
|
+
* maintenance, essential-step/continuation rules, LLM-call budget, durable
|
|
12
|
+
* checkpoints/resume/catch-up/watermark, and the final domain result.
|
|
13
|
+
*
|
|
14
|
+
* The embedding host owns: scheduling, admission, model/provider transport,
|
|
15
|
+
* agent/session lifecycle, cancellation on shutdown, and delivery. The host
|
|
16
|
+
* never reads sleep_*.lock — SleepRunResult is the only supported way to
|
|
17
|
+
* learn what happened.
|
|
8
18
|
*
|
|
9
19
|
* Library-only — no CLI entry point here. Standalone entry lives in
|
|
10
20
|
* cli/abmind-sleep.ts.
|
|
11
|
-
*
|
|
12
|
-
* Flags (passed via RunOpts.flags):
|
|
13
|
-
* --dry-run Gather state + build prompts, print to stdout, skip LLM calls
|
|
14
|
-
* --verbose Detailed logging at each orchestration step
|
|
15
|
-
* --force Run housekeeping even if no messages since last sleep
|
|
16
21
|
*/
|
|
17
|
-
import type {
|
|
18
|
-
import { type Level } from "./levels.js";
|
|
19
|
-
import type { SleepStepEvent } from "./state.js";
|
|
22
|
+
import type { SleepRunOptions, SleepRunResult } from "./contracts.js";
|
|
20
23
|
/** Steps whose failure blocks watermark advance. Public so tests can derive reject targets. */
|
|
21
24
|
export { ESSENTIAL_STEPS } from "./catchup.js";
|
|
22
25
|
/** Thrown by runSleepCycle when memory layer fails to initialize. */
|
|
23
26
|
export declare class SleepInitError extends Error {
|
|
24
27
|
constructor(message: string);
|
|
25
28
|
}
|
|
26
|
-
/** Thrown by runSleepCycle when the wall-clock timeout expires before completion. */
|
|
27
|
-
export declare class SleepTimeoutError extends Error {
|
|
28
|
-
constructor(message: string);
|
|
29
|
-
}
|
|
30
|
-
/** Step-lifecycle event fired by the orchestrator at each step boundary (#895).
|
|
31
|
-
* Best-effort — a throwing handler must never break memory consolidation. */
|
|
32
|
-
export type { SleepStepEvent } from "./state.js";
|
|
33
|
-
/** Options for runSleepCycle. All optional — defaults preserve current main() behavior. */
|
|
34
|
-
export interface RunOpts {
|
|
35
|
-
flags?: RawArgs;
|
|
36
|
-
runtime: SleepRuntime;
|
|
37
|
-
/** Which prompt set to run. Defaults to SLEEP_QUALITY env or "normal". */
|
|
38
|
-
level?: Level;
|
|
39
|
-
/** Discard prior state and start with a clean budget. Used by /sleep now. */
|
|
40
|
-
fresh?: boolean;
|
|
41
|
-
/** Inject a deterministic clock for decision sites (today/weekday/startedAt). Observations use real Date.now. */
|
|
42
|
-
now?: () => number;
|
|
43
|
-
/** Override the wall-clock timeout in ms. Default from SLEEP_TIMEOUT_MIN env. */
|
|
44
|
-
timeoutMs?: number;
|
|
45
|
-
/** Override inter-step backoff. Default: [10,30,60]s on consecutive failures. Tests: () => 0. */
|
|
46
|
-
backoffMs?: (consecutiveFailures: number) => number;
|
|
47
|
-
/** Override intra-step retry delay in ms. Default: 6000. Tests: 0. */
|
|
48
|
-
retryDelayMs?: number;
|
|
49
|
-
/** Override transport-failure backoff per attempt (ms). Default: capped exp (30s/60s/120s). Tests: () => 0. */
|
|
50
|
-
transportBackoffMs?: (attempt: number) => number;
|
|
51
|
-
/** Override transport-failure retry window (ms). Default: 8 minutes. Tests: small value. */
|
|
52
|
-
transportRetryWindowMs?: number;
|
|
53
|
-
/** Override memory config (temp dirs in tests). */
|
|
54
|
-
memoryConfigOverride?: Partial<import("../memory-config.js").MemoryConfig>;
|
|
55
|
-
/** Step-lifecycle hook (#895) — fired at each step boundary.
|
|
56
|
-
* Display-only: a throwing handler never breaks the cycle. */
|
|
57
|
-
onStep?: (e: SleepStepEvent) => void;
|
|
58
|
-
/** Hook fired once at the start of a cycle (before any step runs).
|
|
59
|
-
* Used by hosts to create a stepped card, reset per-night state, etc. */
|
|
60
|
-
onCycleStart?: (e: {
|
|
61
|
-
totalSteps: number;
|
|
62
|
-
}) => void;
|
|
63
|
-
}
|
|
64
|
-
/** Result of runSleepCycle — thrown errors handled separately. */
|
|
65
|
-
export interface RunResult {
|
|
66
|
-
ok: boolean;
|
|
67
|
-
failCount: number;
|
|
68
|
-
}
|
|
69
|
-
export type RawArgs = {
|
|
70
|
-
dryRun: boolean;
|
|
71
|
-
verbose: boolean;
|
|
72
|
-
force: boolean;
|
|
73
|
-
};
|
|
74
|
-
export declare function parseArgs(argv: string[]): RawArgs;
|
|
75
|
-
/** LLM call entry for sleep steps — caller provides the runtime via RunOpts. */
|
|
76
29
|
/**
|
|
77
|
-
* Run the full sleep cycle
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* - Returns { ok, failCount } for observable outcomes
|
|
81
|
-
*
|
|
82
|
-
* Default args preserve current main() behavior exactly.
|
|
30
|
+
* Run the full sleep cycle against a host-injected runtime. Returns a
|
|
31
|
+
* structured SleepRunResult projected from the authoritative on-disk state —
|
|
32
|
+
* hosts never need to read the lock file themselves.
|
|
83
33
|
*/
|
|
84
|
-
export declare function runSleepCycle(
|
|
34
|
+
export declare function runSleepCycle(options: SleepRunOptions): Promise<SleepRunResult>;
|
|
85
35
|
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/sleep/orchestrator.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/sleep/orchestrator.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;GAmBG;AA2BH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAIxB,+FAA+F;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,qEAAqE;AACrE,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAC5B;AASD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA4pBrF"}
|