@vibeiao/sdk 0.1.37 → 0.1.38
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 +6 -0
- package/dist/agentLoop.d.ts +30 -2
- package/dist/agentLoop.js +55 -5
- package/dist/index.js +1 -1
- package/dist/treasuryGuardian.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -585,6 +585,12 @@ const loop = createAgentLoop({
|
|
|
585
585
|
By default, `createAgentLoop(...)` also enables strict-memory runtime checks in `observe` mode.
|
|
586
586
|
To make it hard-enforced, set `strictMemory.mode = 'enforce'` and provide snapshot fields for gating (`taskText`, `isMutation`, `contextPackPrepared`, `semanticRecallConfirmed`, `approvalPreflightPassed`).
|
|
587
587
|
|
|
588
|
+
You can also enforce dual-mode work arbitration:
|
|
589
|
+
- `owner_bound` agents: human-first (owner work preempts autonomous work)
|
|
590
|
+
- `unbound` agents: autonomous-first (run autonomous work by default)
|
|
591
|
+
|
|
592
|
+
Use `autonomy.rolloutMode='enforce'` to apply hard arbitration behavior.
|
|
593
|
+
|
|
588
594
|
```ts
|
|
589
595
|
const loop = createAgentLoop({
|
|
590
596
|
survival,
|
package/dist/agentLoop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResourceSnapshot, SelfRelianceState, SelfReliance } from './selfReliance.js';
|
|
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';
|
|
@@ -44,6 +44,31 @@ type AgentLoopStrictMemoryConfig = {
|
|
|
44
44
|
/** Optional hook when strict-memory evaluation runs. */
|
|
45
45
|
onEvaluation?: (ev: StrictMemoryEvaluation) => Promise<void> | void;
|
|
46
46
|
};
|
|
47
|
+
type AgentOwnershipMode = 'owner_bound' | 'unbound';
|
|
48
|
+
type AgentPriorityMode = 'human_first' | 'autonomous_first';
|
|
49
|
+
type AgentHumanDemand = {
|
|
50
|
+
pending: boolean;
|
|
51
|
+
count?: number;
|
|
52
|
+
source?: string;
|
|
53
|
+
};
|
|
54
|
+
type AgentWorkArbitrationDecision = {
|
|
55
|
+
ownershipMode: AgentOwnershipMode;
|
|
56
|
+
priorityMode: AgentPriorityMode;
|
|
57
|
+
rolloutMode: 'observe' | 'enforce';
|
|
58
|
+
humanDemand: AgentHumanDemand;
|
|
59
|
+
runHumanTask: boolean;
|
|
60
|
+
runAutonomousTask: boolean;
|
|
61
|
+
reason: string;
|
|
62
|
+
};
|
|
63
|
+
type AgentLoopAutonomyConfig = {
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
ownershipMode?: AgentOwnershipMode;
|
|
66
|
+
priorityMode?: AgentPriorityMode;
|
|
67
|
+
rolloutMode?: 'observe' | 'enforce';
|
|
68
|
+
resolveHumanDemand?: () => Promise<boolean | AgentHumanDemand> | boolean | AgentHumanDemand;
|
|
69
|
+
onAutonomous?: (ctx: AgentLoopContext) => Promise<void> | void;
|
|
70
|
+
onArbitration?: (decision: AgentWorkArbitrationDecision, ctx: AgentLoopContext) => Promise<void> | void;
|
|
71
|
+
};
|
|
47
72
|
type AgentLoopContext = {
|
|
48
73
|
snapshot: ResourceSnapshot;
|
|
49
74
|
survivalState: SelfRelianceState;
|
|
@@ -63,6 +88,8 @@ type AgentLoopContext = {
|
|
|
63
88
|
strictMemoryPreset?: StrictMemoryRuntimePreset;
|
|
64
89
|
strictMemoryEvaluation?: StrictMemoryEvaluation;
|
|
65
90
|
strictMemoryUpgrade?: StrictMemoryUpgradeResult;
|
|
91
|
+
/** Human-vs-autonomous work arbitration decision for this cycle. */
|
|
92
|
+
workArbitration?: AgentWorkArbitrationDecision;
|
|
66
93
|
timestamp: number;
|
|
67
94
|
};
|
|
68
95
|
type AgentLoopMemoryConfig = {
|
|
@@ -141,6 +168,7 @@ type AgentLoopConfig = {
|
|
|
141
168
|
memory?: AgentLoopMemoryConfig;
|
|
142
169
|
durability?: AgentLoopDurabilityConfig;
|
|
143
170
|
strictMemory?: AgentLoopStrictMemoryConfig;
|
|
171
|
+
autonomy?: AgentLoopAutonomyConfig;
|
|
144
172
|
};
|
|
145
173
|
/**
|
|
146
174
|
* Create a closed-loop runner that:
|
|
@@ -158,4 +186,4 @@ declare const createAgentLoop: (config: AgentLoopConfig) => {
|
|
|
158
186
|
runOnce: () => Promise<void>;
|
|
159
187
|
};
|
|
160
188
|
|
|
161
|
-
export { type AgentLoopConfig, type AgentLoopContext, type AgentLoopDurabilityConfig, type AgentLoopEscapeHatchConfig, type AgentLoopEscapeHatchInput, type AgentLoopHooks, type AgentLoopMemoryConfig, type AgentLoopStrictMemoryConfig, createAgentLoop };
|
|
189
|
+
export { type AgentHumanDemand, type AgentLoopAutonomyConfig, type AgentLoopConfig, type AgentLoopContext, type AgentLoopDurabilityConfig, type AgentLoopEscapeHatchConfig, type AgentLoopEscapeHatchInput, type AgentLoopHooks, type AgentLoopMemoryConfig, type AgentLoopStrictMemoryConfig, type AgentOwnershipMode, type AgentPriorityMode, type AgentWorkArbitrationDecision, createAgentLoop };
|
package/dist/agentLoop.js
CHANGED
|
@@ -59,6 +59,10 @@ var createAgentLoop = (config) => {
|
|
|
59
59
|
const strictMemoryEnabled = config.strictMemory?.enabled ?? true;
|
|
60
60
|
const strictMode = config.strictMemory?.mode ?? "observe";
|
|
61
61
|
const strictMemoryPreset = createStrictMemoryRuntimePreset(config.strictMemory?.preset || {});
|
|
62
|
+
const autonomyEnabled = config.autonomy?.enabled ?? true;
|
|
63
|
+
const ownershipMode = config.autonomy?.ownershipMode ?? "owner_bound";
|
|
64
|
+
const priorityMode = config.autonomy?.priorityMode ?? (ownershipMode === "unbound" ? "autonomous_first" : "human_first");
|
|
65
|
+
const rolloutMode = config.autonomy?.rolloutMode ?? "enforce";
|
|
62
66
|
const strictMemoryUpgrade = upgradeToStrictMemoryRuntimePreset({
|
|
63
67
|
current: strictMemoryPreset,
|
|
64
68
|
targetMode: strictMode,
|
|
@@ -174,6 +178,16 @@ var createAgentLoop = (config) => {
|
|
|
174
178
|
approvalPreflightPassed: Boolean(raw.approvalPreflightPassed)
|
|
175
179
|
};
|
|
176
180
|
};
|
|
181
|
+
const resolveHumanDemand = async () => {
|
|
182
|
+
const raw = await config.autonomy?.resolveHumanDemand?.();
|
|
183
|
+
if (typeof raw === "boolean") return { pending: raw };
|
|
184
|
+
if (!raw || typeof raw !== "object") return { pending: false };
|
|
185
|
+
return {
|
|
186
|
+
pending: Boolean(raw.pending),
|
|
187
|
+
count: raw.count,
|
|
188
|
+
source: raw.source
|
|
189
|
+
};
|
|
190
|
+
};
|
|
177
191
|
const runOnce = async () => {
|
|
178
192
|
try {
|
|
179
193
|
const memoryUpgrade = await ensureMemoryUpgrade();
|
|
@@ -223,6 +237,27 @@ var createAgentLoop = (config) => {
|
|
|
223
237
|
await config.strictMemory.onEvaluation(strictMemoryEvaluation);
|
|
224
238
|
}
|
|
225
239
|
}
|
|
240
|
+
const humanDemand = autonomyEnabled ? await resolveHumanDemand() : { pending: false };
|
|
241
|
+
const arbitrationBase = {
|
|
242
|
+
ownershipMode,
|
|
243
|
+
priorityMode,
|
|
244
|
+
rolloutMode,
|
|
245
|
+
humanDemand,
|
|
246
|
+
runHumanTask: true,
|
|
247
|
+
runAutonomousTask: false,
|
|
248
|
+
reason: "legacy_onAct"
|
|
249
|
+
};
|
|
250
|
+
if (autonomyEnabled && config.autonomy?.onAutonomous) {
|
|
251
|
+
if (priorityMode === "human_first") {
|
|
252
|
+
arbitrationBase.runHumanTask = humanDemand.pending;
|
|
253
|
+
arbitrationBase.runAutonomousTask = !humanDemand.pending;
|
|
254
|
+
arbitrationBase.reason = humanDemand.pending ? "human_pending_preempts_autonomous" : "idle_autonomous_window";
|
|
255
|
+
} else {
|
|
256
|
+
arbitrationBase.runHumanTask = humanDemand.pending;
|
|
257
|
+
arbitrationBase.runAutonomousTask = true;
|
|
258
|
+
arbitrationBase.reason = humanDemand.pending ? "autonomous_first_with_human_pending" : "autonomous_first_idle";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
226
261
|
const ctx = {
|
|
227
262
|
snapshot,
|
|
228
263
|
survivalState,
|
|
@@ -237,15 +272,13 @@ var createAgentLoop = (config) => {
|
|
|
237
272
|
strictMemoryPreset: strictMemoryEnabled ? strictMemoryPreset : void 0,
|
|
238
273
|
strictMemoryEvaluation,
|
|
239
274
|
strictMemoryUpgrade: strictMemoryEnabled ? strictMemoryUpgrade : void 0,
|
|
275
|
+
workArbitration: arbitrationBase,
|
|
240
276
|
timestamp
|
|
241
277
|
};
|
|
242
278
|
if (hooks.onCycle) await hooks.onCycle(ctx);
|
|
243
279
|
if (hooks.onReflection) await hooks.onReflection(ctx);
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
const missing = ctx.strictMemoryEvaluation.missingSteps.join(",");
|
|
247
|
-
throw new Error(`strict_memory_blocked:${missing}`);
|
|
248
|
-
}
|
|
280
|
+
const runHumanTask = async () => {
|
|
281
|
+
if (!hooks.onAct) return;
|
|
249
282
|
if (guardAct) {
|
|
250
283
|
const allowed = await config.survival.guard();
|
|
251
284
|
if (allowed) {
|
|
@@ -254,6 +287,23 @@ var createAgentLoop = (config) => {
|
|
|
254
287
|
} else {
|
|
255
288
|
await hooks.onAct(ctx);
|
|
256
289
|
}
|
|
290
|
+
};
|
|
291
|
+
const runAutonomousTask = async () => {
|
|
292
|
+
if (!config.autonomy?.onAutonomous) return;
|
|
293
|
+
await config.autonomy.onAutonomous(ctx);
|
|
294
|
+
};
|
|
295
|
+
if (strictMemoryEnabled && strictMode === "enforce" && ctx.strictMemoryEvaluation && !ctx.strictMemoryEvaluation.allowed) {
|
|
296
|
+
const missing = ctx.strictMemoryEvaluation.missingSteps.join(",");
|
|
297
|
+
throw new Error(`strict_memory_blocked:${missing}`);
|
|
298
|
+
}
|
|
299
|
+
if (autonomyEnabled && config.autonomy?.onAutonomous && rolloutMode === "enforce") {
|
|
300
|
+
if (ctx.workArbitration?.runHumanTask) await runHumanTask();
|
|
301
|
+
if (ctx.workArbitration?.runAutonomousTask) await runAutonomousTask();
|
|
302
|
+
} else {
|
|
303
|
+
await runHumanTask();
|
|
304
|
+
}
|
|
305
|
+
if (config.autonomy?.onArbitration) {
|
|
306
|
+
await config.autonomy.onArbitration(ctx.workArbitration, ctx);
|
|
257
307
|
}
|
|
258
308
|
} catch (err) {
|
|
259
309
|
const e = err instanceof Error ? err : new Error("agent_loop_failed");
|
package/dist/index.js
CHANGED
|
@@ -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.37" ? "0.1.37" : "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;
|
|
@@ -1105,7 +1105,7 @@ declare class ReviewGate {
|
|
|
1105
1105
|
assertClear(listingId: string, wallet: string): void;
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
|
-
declare const compareVersions: (currentVersion: string, latestVersion: string) =>
|
|
1108
|
+
declare const compareVersions: (currentVersion: string, latestVersion: string) => 1 | 0 | -1;
|
|
1109
1109
|
declare const buildSdkUpdateCommand: (packageName?: string) => string;
|
|
1110
1110
|
declare const checkForSdkUpdate: (options?: SdkUpdateCheckOptions) => Promise<SdkUpdateStatus>;
|
|
1111
1111
|
declare const checkForSdkUpdatePolicy: (options: SdkUpdatePolicyCheckOptions) => Promise<SdkUpdateStatus>;
|