@vibeiao/sdk 0.1.36 → 0.1.37
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/README.md +14 -0
- package/dist/agentLoop.d.ts +28 -1
- package/dist/agentLoop.js +40 -0
- package/dist/index.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -582,6 +582,20 @@ const loop = createAgentLoop({
|
|
|
582
582
|
});
|
|
583
583
|
```
|
|
584
584
|
|
|
585
|
+
By default, `createAgentLoop(...)` also enables strict-memory runtime checks in `observe` mode.
|
|
586
|
+
To make it hard-enforced, set `strictMemory.mode = 'enforce'` and provide snapshot fields for gating (`taskText`, `isMutation`, `contextPackPrepared`, `semanticRecallConfirmed`, `approvalPreflightPassed`).
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
const loop = createAgentLoop({
|
|
590
|
+
survival,
|
|
591
|
+
fetchSnapshot,
|
|
592
|
+
strictMemory: {
|
|
593
|
+
enabled: true,
|
|
594
|
+
mode: 'enforce',
|
|
595
|
+
},
|
|
596
|
+
});
|
|
597
|
+
```
|
|
598
|
+
|
|
585
599
|
Disable only if you already run an equivalent external memory-control plane:
|
|
586
600
|
|
|
587
601
|
```ts
|
package/dist/agentLoop.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { SelfReliance, ResourceSnapshot, SelfRelianceState } from './selfRelianc
|
|
|
2
2
|
import { SurvivalMode, SurvivalRecommendation } from './survivalPlaybook.js';
|
|
3
3
|
import { EscapeHatchDecision, EscapeHatchPolicy, EscapeHatchSnapshot } from './survivalEscapeHatch.js';
|
|
4
4
|
import { CompoundingMemoryUpgradeResult, CompoundingMemoryRequiredSetResult } from './compoundingMemory.js';
|
|
5
|
+
import { StrictMemoryRuntimePreset, StrictMemoryEvaluation, StrictMemoryUpgradeResult } from './strictMemoryRuntime.js';
|
|
5
6
|
|
|
6
7
|
type AgentLoopEscapeHatchInput = {
|
|
7
8
|
snapshot: ResourceSnapshot;
|
|
@@ -22,6 +23,27 @@ type AgentLoopEscapeHatchConfig = {
|
|
|
22
23
|
/** Called when an escape-hatch decision is produced. */
|
|
23
24
|
onDecision?: (decision: EscapeHatchDecision, input: AgentLoopEscapeHatchInput) => Promise<void> | void;
|
|
24
25
|
};
|
|
26
|
+
type AgentLoopStrictMemoryConfig = {
|
|
27
|
+
/** Enable strict memory runtime checks in loop. Default true. */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** observe (default) records decisions; enforce blocks onAct when checks fail. */
|
|
30
|
+
mode?: 'observe' | 'enforce';
|
|
31
|
+
/** Optional preset overrides. */
|
|
32
|
+
preset?: Partial<StrictMemoryRuntimePreset>;
|
|
33
|
+
/** Build per-cycle evaluation input. Defaults to best-effort snapshot fields. */
|
|
34
|
+
buildInput?: (ctx: {
|
|
35
|
+
snapshot: ResourceSnapshot;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
}) => {
|
|
38
|
+
taskText: string;
|
|
39
|
+
isMutation: boolean;
|
|
40
|
+
contextPackPrepared: boolean;
|
|
41
|
+
semanticRecallConfirmed: boolean;
|
|
42
|
+
approvalPreflightPassed: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Optional hook when strict-memory evaluation runs. */
|
|
45
|
+
onEvaluation?: (ev: StrictMemoryEvaluation) => Promise<void> | void;
|
|
46
|
+
};
|
|
25
47
|
type AgentLoopContext = {
|
|
26
48
|
snapshot: ResourceSnapshot;
|
|
27
49
|
survivalState: SelfRelianceState;
|
|
@@ -37,6 +59,10 @@ type AgentLoopContext = {
|
|
|
37
59
|
memoryUpgrade?: CompoundingMemoryUpgradeResult;
|
|
38
60
|
/** Present when required-set maintenance check runs (default daily). */
|
|
39
61
|
memoryRequiredSet?: CompoundingMemoryRequiredSetResult;
|
|
62
|
+
/** Strict-memory runtime preset + per-cycle evaluation status. */
|
|
63
|
+
strictMemoryPreset?: StrictMemoryRuntimePreset;
|
|
64
|
+
strictMemoryEvaluation?: StrictMemoryEvaluation;
|
|
65
|
+
strictMemoryUpgrade?: StrictMemoryUpgradeResult;
|
|
40
66
|
timestamp: number;
|
|
41
67
|
};
|
|
42
68
|
type AgentLoopMemoryConfig = {
|
|
@@ -114,6 +140,7 @@ type AgentLoopConfig = {
|
|
|
114
140
|
escapeHatch?: AgentLoopEscapeHatchConfig;
|
|
115
141
|
memory?: AgentLoopMemoryConfig;
|
|
116
142
|
durability?: AgentLoopDurabilityConfig;
|
|
143
|
+
strictMemory?: AgentLoopStrictMemoryConfig;
|
|
117
144
|
};
|
|
118
145
|
/**
|
|
119
146
|
* Create a closed-loop runner that:
|
|
@@ -131,4 +158,4 @@ declare const createAgentLoop: (config: AgentLoopConfig) => {
|
|
|
131
158
|
runOnce: () => Promise<void>;
|
|
132
159
|
};
|
|
133
160
|
|
|
134
|
-
export { type AgentLoopConfig, type AgentLoopContext, type AgentLoopDurabilityConfig, type AgentLoopEscapeHatchConfig, type AgentLoopEscapeHatchInput, type AgentLoopHooks, type AgentLoopMemoryConfig, createAgentLoop };
|
|
161
|
+
export { type AgentLoopConfig, type AgentLoopContext, type AgentLoopDurabilityConfig, type AgentLoopEscapeHatchConfig, type AgentLoopEscapeHatchInput, type AgentLoopHooks, type AgentLoopMemoryConfig, type AgentLoopStrictMemoryConfig, createAgentLoop };
|
package/dist/agentLoop.js
CHANGED
|
@@ -8,6 +8,11 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
createSelfRelianceMonitor
|
|
10
10
|
} from "./chunk-M7DQTU5R.js";
|
|
11
|
+
import {
|
|
12
|
+
createStrictMemoryRuntimePreset,
|
|
13
|
+
evaluateStrictMemoryExecution,
|
|
14
|
+
upgradeToStrictMemoryRuntimePreset
|
|
15
|
+
} from "./chunk-RUKN3KQ2.js";
|
|
11
16
|
import {
|
|
12
17
|
evaluateEscapeHatch,
|
|
13
18
|
formatEscapeHatchDecision
|
|
@@ -51,6 +56,16 @@ var createAgentLoop = (config) => {
|
|
|
51
56
|
const requiredSetIntervalMs = Math.max(6e4, config.memory?.requiredSetIntervalMs ?? 24 * 60 * 60 * 1e3);
|
|
52
57
|
const requiredSetRunOnStart = config.memory?.requiredSetRunOnStart ?? true;
|
|
53
58
|
const requiredSetRunRestoreDrill = config.memory?.requiredSetRunRestoreDrill ?? true;
|
|
59
|
+
const strictMemoryEnabled = config.strictMemory?.enabled ?? true;
|
|
60
|
+
const strictMode = config.strictMemory?.mode ?? "observe";
|
|
61
|
+
const strictMemoryPreset = createStrictMemoryRuntimePreset(config.strictMemory?.preset || {});
|
|
62
|
+
const strictMemoryUpgrade = upgradeToStrictMemoryRuntimePreset({
|
|
63
|
+
current: strictMemoryPreset,
|
|
64
|
+
targetMode: strictMode,
|
|
65
|
+
backupCreated: true,
|
|
66
|
+
healthcheckPassed: true,
|
|
67
|
+
recentBlockRate: 0
|
|
68
|
+
});
|
|
54
69
|
const durabilityEnabled = config.durability?.enabled ?? false;
|
|
55
70
|
const durabilityClient = durabilityEnabled ? createDurabilityProxyClient({
|
|
56
71
|
baseUrl: config.durability?.baseUrl || "",
|
|
@@ -149,6 +164,16 @@ var createAgentLoop = (config) => {
|
|
|
149
164
|
}
|
|
150
165
|
lastDurabilitySyncCheckedAt = memoryRequiredSet.checkedAt;
|
|
151
166
|
};
|
|
167
|
+
const defaultStrictInputBuilder = (ctx) => {
|
|
168
|
+
const raw = ctx.snapshot;
|
|
169
|
+
return {
|
|
170
|
+
taskText: String(raw.taskText || raw.objective || ""),
|
|
171
|
+
isMutation: Boolean(raw.isMutation),
|
|
172
|
+
contextPackPrepared: Boolean(raw.contextPackPrepared),
|
|
173
|
+
semanticRecallConfirmed: Boolean(raw.semanticRecallConfirmed),
|
|
174
|
+
approvalPreflightPassed: Boolean(raw.approvalPreflightPassed)
|
|
175
|
+
};
|
|
176
|
+
};
|
|
152
177
|
const runOnce = async () => {
|
|
153
178
|
try {
|
|
154
179
|
const memoryUpgrade = await ensureMemoryUpgrade();
|
|
@@ -190,6 +215,14 @@ var createAgentLoop = (config) => {
|
|
|
190
215
|
}
|
|
191
216
|
}
|
|
192
217
|
const survivalDecisionBlock = [survivalFormatted, escapeHatchFormatted].filter(Boolean).join("\n\n");
|
|
218
|
+
let strictMemoryEvaluation;
|
|
219
|
+
if (strictMemoryEnabled) {
|
|
220
|
+
const strictInput = (config.strictMemory?.buildInput || defaultStrictInputBuilder)({ snapshot, timestamp });
|
|
221
|
+
strictMemoryEvaluation = evaluateStrictMemoryExecution(strictInput, strictMemoryPreset);
|
|
222
|
+
if (config.strictMemory?.onEvaluation) {
|
|
223
|
+
await config.strictMemory.onEvaluation(strictMemoryEvaluation);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
193
226
|
const ctx = {
|
|
194
227
|
snapshot,
|
|
195
228
|
survivalState,
|
|
@@ -201,11 +234,18 @@ var createAgentLoop = (config) => {
|
|
|
201
234
|
escapeHatchFormatted,
|
|
202
235
|
memoryUpgrade: memoryUpgrade ?? void 0,
|
|
203
236
|
memoryRequiredSet: memoryRequiredSet ?? void 0,
|
|
237
|
+
strictMemoryPreset: strictMemoryEnabled ? strictMemoryPreset : void 0,
|
|
238
|
+
strictMemoryEvaluation,
|
|
239
|
+
strictMemoryUpgrade: strictMemoryEnabled ? strictMemoryUpgrade : void 0,
|
|
204
240
|
timestamp
|
|
205
241
|
};
|
|
206
242
|
if (hooks.onCycle) await hooks.onCycle(ctx);
|
|
207
243
|
if (hooks.onReflection) await hooks.onReflection(ctx);
|
|
208
244
|
if (hooks.onAct) {
|
|
245
|
+
if (strictMemoryEnabled && strictMode === "enforce" && ctx.strictMemoryEvaluation && !ctx.strictMemoryEvaluation.allowed) {
|
|
246
|
+
const missing = ctx.strictMemoryEvaluation.missingSteps.join(",");
|
|
247
|
+
throw new Error(`strict_memory_blocked:${missing}`);
|
|
248
|
+
}
|
|
209
249
|
if (guardAct) {
|
|
210
250
|
const allowed = await config.survival.guard();
|
|
211
251
|
if (allowed) {
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,6 @@ import {
|
|
|
5
5
|
fetchTokenBalances,
|
|
6
6
|
normalizeHumanAppCategory
|
|
7
7
|
} from "./chunk-2U6HLZEF.js";
|
|
8
|
-
import {
|
|
9
|
-
STRICT_MEMORY_RUNTIME_SCHEMA,
|
|
10
|
-
createStrictMemoryRuntimePreset,
|
|
11
|
-
evaluateStrictMemoryExecution,
|
|
12
|
-
isComplexTask,
|
|
13
|
-
upgradeToStrictMemoryRuntimePreset
|
|
14
|
-
} from "./chunk-RUKN3KQ2.js";
|
|
15
8
|
import {
|
|
16
9
|
getSurvivalPlaybookDecision,
|
|
17
10
|
getSurvivalPlaybookDecisionFromSelfReliance
|
|
@@ -34,6 +27,13 @@ import {
|
|
|
34
27
|
createSurvivalMiddleware,
|
|
35
28
|
withSurvival
|
|
36
29
|
} from "./chunk-M7DQTU5R.js";
|
|
30
|
+
import {
|
|
31
|
+
STRICT_MEMORY_RUNTIME_SCHEMA,
|
|
32
|
+
createStrictMemoryRuntimePreset,
|
|
33
|
+
evaluateStrictMemoryExecution,
|
|
34
|
+
isComplexTask,
|
|
35
|
+
upgradeToStrictMemoryRuntimePreset
|
|
36
|
+
} from "./chunk-RUKN3KQ2.js";
|
|
37
37
|
import {
|
|
38
38
|
evaluateEscapeHatch,
|
|
39
39
|
formatEscapeHatchDecision
|
|
@@ -362,7 +362,7 @@ var ReviewGate = class {
|
|
|
362
362
|
var DEFAULT_API_BASE = "https://api.vibeiao.com";
|
|
363
363
|
var DEFAULT_WEB_BASE = "https://vibeiao.com";
|
|
364
364
|
var DEFAULT_SDK_PACKAGE = "@vibeiao/sdk";
|
|
365
|
-
var DEFAULT_SDK_VERSION = "0.1.
|
|
365
|
+
var DEFAULT_SDK_VERSION = "0.1.36" ? "0.1.36" : "0.1.4";
|
|
366
366
|
var DEFAULT_SDK_REGISTRY = "https://registry.npmjs.org";
|
|
367
367
|
var DEFAULT_SDK_POLICY_PATH = "/v1/sdk/policy";
|
|
368
368
|
var DEFAULT_SDK_CHECK_INTERVAL_MS = 1e3 * 60 * 30;
|