@rkat/mobkit-sdk 0.6.15 → 0.6.16
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/agent-builder.d.ts.map +1 -1
- package/dist/agent-builder.js +20 -3
- package/dist/agent-builder.js.map +1 -1
- package/dist/builder.d.ts +12 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +46 -2
- package/dist/builder.js.map +1 -1
- package/dist/cjs/agent-builder.cjs +19 -2
- package/dist/cjs/builder.cjs +46 -2
- package/dist/cjs/config/auth.cjs +10 -2
- package/dist/cjs/config/memory.cjs +5 -7
- package/dist/cjs/config/session-store.cjs +10 -2
- package/dist/cjs/errors.cjs +16 -5
- package/dist/cjs/index.cjs +13 -3
- package/dist/cjs/runtime.cjs +223 -2
- package/dist/cjs/types.cjs +187 -9
- package/dist/config/auth.d.ts +2 -0
- package/dist/config/auth.d.ts.map +1 -1
- package/dist/config/auth.js +10 -2
- package/dist/config/auth.js.map +1 -1
- package/dist/config/memory.d.ts +1 -0
- package/dist/config/memory.d.ts.map +1 -1
- package/dist/config/memory.js +5 -7
- package/dist/config/memory.js.map +1 -1
- package/dist/config/session-store.d.ts +2 -0
- package/dist/config/session-store.d.ts.map +1 -1
- package/dist/config/session-store.js +10 -2
- package/dist/config/session-store.js.map +1 -1
- package/dist/errors.d.ts +7 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +14 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +37 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +225 -4
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +176 -9
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/runtime.cjs
CHANGED
|
@@ -206,6 +206,16 @@ class MobKitRuntime {
|
|
|
206
206
|
if (this._config.eventLog) {
|
|
207
207
|
runtimeOptions.event_log = serializeConfig(this._config.eventLog);
|
|
208
208
|
}
|
|
209
|
+
if (this._config.consoleConfigPath) {
|
|
210
|
+
runtimeOptions.console_config_path = this._config.consoleConfigPath;
|
|
211
|
+
}
|
|
212
|
+
if (this._config.consoleRequireAppAuth !== null) {
|
|
213
|
+
runtimeOptions.console_require_app_auth =
|
|
214
|
+
this._config.consoleRequireAppAuth;
|
|
215
|
+
}
|
|
216
|
+
if (this._config.demoLlm) {
|
|
217
|
+
runtimeOptions.demo_llm = true;
|
|
218
|
+
}
|
|
209
219
|
if (this._config.implicitDelegateIdleRetireSecs !== undefined) {
|
|
210
220
|
runtimeOptions.implicit_delegate_idle_retire_secs =
|
|
211
221
|
this._config.implicitDelegateIdleRetireSecs;
|
|
@@ -217,6 +227,15 @@ class MobKitRuntime {
|
|
|
217
227
|
if (this._config.rosterProvider !== null) {
|
|
218
228
|
params.has_roster_provider = true;
|
|
219
229
|
}
|
|
230
|
+
if (this._config.continuityStore !== null) {
|
|
231
|
+
params.has_continuity_store = true;
|
|
232
|
+
}
|
|
233
|
+
if (this._config.leaseProvider !== null) {
|
|
234
|
+
params.has_lease_provider = true;
|
|
235
|
+
}
|
|
236
|
+
if (this._config.scratchDir !== null) {
|
|
237
|
+
params.scratch_dir = this._config.scratchDir;
|
|
238
|
+
}
|
|
220
239
|
if (this._config.topologyProvider !== null) {
|
|
221
240
|
params.has_topology_provider = true;
|
|
222
241
|
}
|
|
@@ -235,7 +254,19 @@ class MobKitRuntime {
|
|
|
235
254
|
const response = (await this._transport.sendAsync(request));
|
|
236
255
|
if ("error" in response) {
|
|
237
256
|
const err = response.error;
|
|
238
|
-
|
|
257
|
+
const code = Number(err.code ?? -1);
|
|
258
|
+
const message = String(err.message ?? String(err));
|
|
259
|
+
if (code === errors_js_1.CAPABILITY_UNAVAILABLE_CODE) {
|
|
260
|
+
throw new errors_js_1.CapabilityUnavailableError(message, rid, method, err.data);
|
|
261
|
+
}
|
|
262
|
+
if (code === errors_js_1.MEMORY_BACKEND_UNAVAILABLE_CODE) {
|
|
263
|
+
throw new errors_js_1.MemoryBackendUnavailableError(message, rid, method, err.data);
|
|
264
|
+
}
|
|
265
|
+
const rpcError = new errors_js_1.RpcError(code, message, rid, method, err.data);
|
|
266
|
+
if (code === errors_js_1.MOB_EVENTS_STALE_CURSOR_CODE) {
|
|
267
|
+
throw errors_js_1.MobEventsStaleError.fromRpcError(rpcError);
|
|
268
|
+
}
|
|
269
|
+
throw rpcError;
|
|
239
270
|
}
|
|
240
271
|
return response.result;
|
|
241
272
|
}
|
|
@@ -315,6 +346,14 @@ class MobKitRuntime {
|
|
|
315
346
|
async deleteIdentity(identity) {
|
|
316
347
|
return this._rpc("mobkit/delete_identity", { identity });
|
|
317
348
|
}
|
|
349
|
+
/** Inspect identity continuity/runtime state. */
|
|
350
|
+
async inspectIdentity(identity) {
|
|
351
|
+
return this._rpc("mobkit/inspect_identity", { identity });
|
|
352
|
+
}
|
|
353
|
+
/** Re-run identity-first reconciliation. */
|
|
354
|
+
async reconcileIdentity() {
|
|
355
|
+
return this._rpc("mobkit/reconcile_identity", {});
|
|
356
|
+
}
|
|
318
357
|
}
|
|
319
358
|
exports.MobKitRuntime = MobKitRuntime;
|
|
320
359
|
// -- MobHandle ------------------------------------------------------------
|
|
@@ -341,6 +380,9 @@ class MobHandle {
|
|
|
341
380
|
async capabilities() {
|
|
342
381
|
return (0, types_js_1.parseCapabilitiesResult)(await this._runtime._rpc("mobkit/capabilities"));
|
|
343
382
|
}
|
|
383
|
+
async modelsCatalog() {
|
|
384
|
+
return (0, types_js_1.parseModelsCatalogResult)(await this._runtime._rpc("mobkit/models/catalog"));
|
|
385
|
+
}
|
|
344
386
|
// -- Spawn & reconcile --------------------------------------------------
|
|
345
387
|
async spawn(spec) {
|
|
346
388
|
return (0, types_js_1.parseSpawnResult)(await this._runtime._rpc("mobkit/spawn_member", (0, models_js_1.discoverySpecToDict)(spec)));
|
|
@@ -532,7 +574,19 @@ class MobHandle {
|
|
|
532
574
|
}
|
|
533
575
|
if ("error" in body) {
|
|
534
576
|
const err = body.error;
|
|
535
|
-
|
|
577
|
+
const code = Number(err.code ?? -1);
|
|
578
|
+
const message = String(err.message ?? String(err));
|
|
579
|
+
if (code === errors_js_1.CAPABILITY_UNAVAILABLE_CODE) {
|
|
580
|
+
throw new errors_js_1.CapabilityUnavailableError(message, id, method, err.data);
|
|
581
|
+
}
|
|
582
|
+
if (code === errors_js_1.MEMORY_BACKEND_UNAVAILABLE_CODE) {
|
|
583
|
+
throw new errors_js_1.MemoryBackendUnavailableError(message, id, method, err.data);
|
|
584
|
+
}
|
|
585
|
+
const rpcError = new errors_js_1.RpcError(code, message, id, method, err.data);
|
|
586
|
+
if (code === errors_js_1.MOB_EVENTS_STALE_CURSOR_CODE) {
|
|
587
|
+
throw errors_js_1.MobEventsStaleError.fromRpcError(rpcError);
|
|
588
|
+
}
|
|
589
|
+
throw rpcError;
|
|
536
590
|
}
|
|
537
591
|
if (!response.ok) {
|
|
538
592
|
throw new errors_js_1.TransportError(`multipart RPC failed (status=${response.status}): ${responseText}`);
|
|
@@ -587,6 +641,14 @@ class MobHandle {
|
|
|
587
641
|
member_id: memberId,
|
|
588
642
|
});
|
|
589
643
|
}
|
|
644
|
+
async memberStatus(memberId) {
|
|
645
|
+
return (0, types_js_1.parseRichMemberSnapshot)(await this._runtime._rpc("mobkit/member_status", { member_id: memberId }));
|
|
646
|
+
}
|
|
647
|
+
async forceCancelMember(memberId) {
|
|
648
|
+
await this._runtime._rpc("mobkit/force_cancel_member", {
|
|
649
|
+
member_id: memberId,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
590
652
|
/**
|
|
591
653
|
* Wait until all current mob members are startup-ready for orchestration.
|
|
592
654
|
*
|
|
@@ -611,6 +673,18 @@ class MobHandle {
|
|
|
611
673
|
};
|
|
612
674
|
}
|
|
613
675
|
// -- Flows --------------------------------------------------------------
|
|
676
|
+
async cancelFlow(runId) {
|
|
677
|
+
await this._runtime._rpc("mobkit/cancel_flow", { run_id: runId });
|
|
678
|
+
}
|
|
679
|
+
async flowStatus(runId) {
|
|
680
|
+
const raw = await this._runtime._rpc("mobkit/flow_status", { run_id: runId });
|
|
681
|
+
if (raw === null)
|
|
682
|
+
return null;
|
|
683
|
+
if (typeof raw === "object" && raw !== null && raw.status === "not_found") {
|
|
684
|
+
return null;
|
|
685
|
+
}
|
|
686
|
+
return (0, types_js_1.parseMobRunSnapshot)(raw);
|
|
687
|
+
}
|
|
614
688
|
/**
|
|
615
689
|
* List all configured flow IDs in this mob definition. Relays meerkat
|
|
616
690
|
* 0.6's `MobHandle::list_flows`. Order is unspecified.
|
|
@@ -676,6 +750,38 @@ class MobHandle {
|
|
|
676
750
|
}
|
|
677
751
|
throw new Error(`unexpected run_flow response: ${JSON.stringify(raw)}`);
|
|
678
752
|
}
|
|
753
|
+
async collectCompleted() {
|
|
754
|
+
const raw = await this._runtime._rpc("mobkit/collect_completed");
|
|
755
|
+
const entries = typeof raw === "object" && raw !== null
|
|
756
|
+
? (Array.isArray(raw.completed)
|
|
757
|
+
? raw.completed
|
|
758
|
+
: [])
|
|
759
|
+
: Array.isArray(raw)
|
|
760
|
+
? raw
|
|
761
|
+
: [];
|
|
762
|
+
const result = [];
|
|
763
|
+
for (const entry of entries) {
|
|
764
|
+
const record = typeof entry === "object" && entry !== null
|
|
765
|
+
? entry
|
|
766
|
+
: {};
|
|
767
|
+
const memberId = String(record.member_id ?? "");
|
|
768
|
+
result.push([memberId, (0, types_js_1.parseRichMemberSnapshot)(record.snapshot ?? record)]);
|
|
769
|
+
}
|
|
770
|
+
return result;
|
|
771
|
+
}
|
|
772
|
+
// -- Scheduling ---------------------------------------------------------
|
|
773
|
+
async schedulingEvaluate(schedules, tickMs) {
|
|
774
|
+
return this._runtime._rpc("mobkit/scheduling/evaluate", {
|
|
775
|
+
schedules: [...schedules],
|
|
776
|
+
tick_ms: tickMs,
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
async schedulingDispatch(schedules, tickMs) {
|
|
780
|
+
return this._runtime._rpc("mobkit/scheduling/dispatch", {
|
|
781
|
+
schedules: [...schedules],
|
|
782
|
+
tick_ms: tickMs,
|
|
783
|
+
});
|
|
784
|
+
}
|
|
679
785
|
// -- Routing ------------------------------------------------------------
|
|
680
786
|
async resolveRouting(recipient, options) {
|
|
681
787
|
return (0, types_js_1.parseRoutingResolution)(await this._runtime._rpc("mobkit/routing/resolve", {
|
|
@@ -758,6 +864,9 @@ class MobHandle {
|
|
|
758
864
|
toolCaller(moduleId) {
|
|
759
865
|
return new ToolCaller(this, moduleId);
|
|
760
866
|
}
|
|
867
|
+
async sessionStoreBigQuery(options) {
|
|
868
|
+
return this._runtime._rpc("mobkit/session_store/bigquery", options);
|
|
869
|
+
}
|
|
761
870
|
// -- Gating -------------------------------------------------------------
|
|
762
871
|
async gatingEvaluate(action, actorId, options) {
|
|
763
872
|
return (0, types_js_1.parseGatingEvaluateResult)(await this._runtime._rpc("mobkit/gating/evaluate", {
|
|
@@ -801,6 +910,118 @@ class MobHandle {
|
|
|
801
910
|
async reconcileEdges() {
|
|
802
911
|
return (0, types_js_1.parseReconcileEdgesReport)(await this._runtime._rpc("mobkit/reconcile_edges"));
|
|
803
912
|
}
|
|
913
|
+
// -- Cross-mob ----------------------------------------------------------
|
|
914
|
+
async listExternalMobs() {
|
|
915
|
+
const raw = await this._runtime._rpc("mobkit/cross_mob/directory");
|
|
916
|
+
const mobs = typeof raw === "object" && raw !== null
|
|
917
|
+
? (Array.isArray(raw.mobs)
|
|
918
|
+
? raw.mobs
|
|
919
|
+
: [])
|
|
920
|
+
: [];
|
|
921
|
+
return mobs.map(types_js_1.parseCrossMobContactEntry);
|
|
922
|
+
}
|
|
923
|
+
async peerInfo(memberId) {
|
|
924
|
+
const raw = await this._runtime._rpc("mobkit/cross_mob/peer_info", {
|
|
925
|
+
member_id: memberId,
|
|
926
|
+
});
|
|
927
|
+
const out = {};
|
|
928
|
+
if (typeof raw === "object" && raw !== null) {
|
|
929
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
930
|
+
out[k] = String(v);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return out;
|
|
934
|
+
}
|
|
935
|
+
async peerPubkey() {
|
|
936
|
+
const raw = await this._runtime._rpc("mobkit/peer_pubkey");
|
|
937
|
+
return typeof raw === "object" && raw !== null
|
|
938
|
+
? String(raw.pubkey_b64 ?? "")
|
|
939
|
+
: "";
|
|
940
|
+
}
|
|
941
|
+
async wireLocal(localMemberId, remoteCommsName, remotePeerId, remoteAddress, options) {
|
|
942
|
+
const params = {
|
|
943
|
+
local_member_id: localMemberId,
|
|
944
|
+
remote_comms_name: remoteCommsName,
|
|
945
|
+
remote_peer_id: remotePeerId,
|
|
946
|
+
remote_address: remoteAddress,
|
|
947
|
+
};
|
|
948
|
+
if (options?.remotePubkeyB64) {
|
|
949
|
+
params.remote_pubkey_b64 = options.remotePubkeyB64;
|
|
950
|
+
}
|
|
951
|
+
await this._runtime._rpc("mobkit/cross_mob/wire_local", params);
|
|
952
|
+
}
|
|
953
|
+
async unwireLocal(localMemberId, remoteCommsName, remotePeerId, remoteAddress, options) {
|
|
954
|
+
const params = {
|
|
955
|
+
local_member_id: localMemberId,
|
|
956
|
+
remote_comms_name: remoteCommsName,
|
|
957
|
+
remote_peer_id: remotePeerId,
|
|
958
|
+
remote_address: remoteAddress,
|
|
959
|
+
};
|
|
960
|
+
if (options?.remotePubkeyB64) {
|
|
961
|
+
params.remote_pubkey_b64 = options.remotePubkeyB64;
|
|
962
|
+
}
|
|
963
|
+
await this._runtime._rpc("mobkit/cross_mob/unwire_local", params);
|
|
964
|
+
}
|
|
965
|
+
async wireCrossMob(localMemberId, remoteMemberId, remoteHandle) {
|
|
966
|
+
const localInfo = await this.peerInfo(localMemberId);
|
|
967
|
+
const remoteInfo = await remoteHandle.peerInfo(remoteMemberId);
|
|
968
|
+
await this.wireLocal(localMemberId, remoteInfo.comms_name, remoteInfo.peer_id, remoteInfo.address);
|
|
969
|
+
try {
|
|
970
|
+
await remoteHandle.wireLocal(remoteMemberId, localInfo.comms_name, localInfo.peer_id, localInfo.address);
|
|
971
|
+
}
|
|
972
|
+
catch (err) {
|
|
973
|
+
try {
|
|
974
|
+
await this.unwireLocal(localMemberId, remoteInfo.comms_name, remoteInfo.peer_id, remoteInfo.address);
|
|
975
|
+
}
|
|
976
|
+
catch {
|
|
977
|
+
// Best-effort rollback; preserve the original remote error.
|
|
978
|
+
}
|
|
979
|
+
throw err;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
async sendCrossMob(remoteMemberId, remoteHandle, message) {
|
|
983
|
+
return remoteHandle.send(remoteMemberId, message);
|
|
984
|
+
}
|
|
985
|
+
// -- Helper members -----------------------------------------------------
|
|
986
|
+
async spawnHelper(agentIdentity, task, options) {
|
|
987
|
+
const helperOptions = {};
|
|
988
|
+
if (options?.role)
|
|
989
|
+
helperOptions.role = options.role;
|
|
990
|
+
if (options?.runtimeMode)
|
|
991
|
+
helperOptions.runtime_mode = options.runtimeMode;
|
|
992
|
+
if (options?.backend)
|
|
993
|
+
helperOptions.backend = options.backend;
|
|
994
|
+
const params = { agent_identity: agentIdentity, task };
|
|
995
|
+
if (Object.keys(helperOptions).length > 0)
|
|
996
|
+
params.options = helperOptions;
|
|
997
|
+
return (0, types_js_1.parseHelperResult)(await this._runtime._rpc("mobkit/spawn_helper", params));
|
|
998
|
+
}
|
|
999
|
+
async forkHelper(sourceMemberId, agentIdentity, task, options) {
|
|
1000
|
+
const helperOptions = {};
|
|
1001
|
+
if (options?.role)
|
|
1002
|
+
helperOptions.role = options.role;
|
|
1003
|
+
if (options?.runtimeMode)
|
|
1004
|
+
helperOptions.runtime_mode = options.runtimeMode;
|
|
1005
|
+
if (options?.backend)
|
|
1006
|
+
helperOptions.backend = options.backend;
|
|
1007
|
+
const params = {
|
|
1008
|
+
source_member_id: sourceMemberId,
|
|
1009
|
+
agent_identity: agentIdentity,
|
|
1010
|
+
task,
|
|
1011
|
+
};
|
|
1012
|
+
if (options?.forkContext)
|
|
1013
|
+
params.fork_context = options.forkContext;
|
|
1014
|
+
if (Object.keys(helperOptions).length > 0)
|
|
1015
|
+
params.options = helperOptions;
|
|
1016
|
+
return (0, types_js_1.parseHelperResult)(await this._runtime._rpc("mobkit/fork_helper", params));
|
|
1017
|
+
}
|
|
1018
|
+
async attachSession(role, agentIdentity, sessionId) {
|
|
1019
|
+
return (0, types_js_1.parseRichMemberSnapshot)(await this._runtime._rpc("mobkit/attach_existing_session", {
|
|
1020
|
+
role,
|
|
1021
|
+
agent_identity: agentIdentity,
|
|
1022
|
+
session_id: sessionId,
|
|
1023
|
+
}));
|
|
1024
|
+
}
|
|
804
1025
|
// -- Mob/run labels — mobkit-side sidecar metadata ----------------------
|
|
805
1026
|
/**
|
|
806
1027
|
* Replace the label set associated with this mob.
|
package/dist/cjs/types.cjs
CHANGED
|
@@ -39,6 +39,15 @@ exports.parseFrameRecord = parseFrameRecord;
|
|
|
39
39
|
exports.parseLoopRecord = parseLoopRecord;
|
|
40
40
|
exports.parseLoopIterationRecord = parseLoopIterationRecord;
|
|
41
41
|
exports.parseMobRun = parseMobRun;
|
|
42
|
+
exports.parseMobUnreachablePeer = parseMobUnreachablePeer;
|
|
43
|
+
exports.parsePeerConnectivitySnapshot = parsePeerConnectivitySnapshot;
|
|
44
|
+
exports.parseRichMemberSnapshot = parseRichMemberSnapshot;
|
|
45
|
+
exports.parseHelperResult = parseHelperResult;
|
|
46
|
+
exports.parseMobRunSnapshot = parseMobRunSnapshot;
|
|
47
|
+
exports.parseCrossMobContactEntry = parseCrossMobContactEntry;
|
|
48
|
+
exports.parseCatalogEntry = parseCatalogEntry;
|
|
49
|
+
exports.parseProviderDefaults = parseProviderDefaults;
|
|
50
|
+
exports.parseModelsCatalogResult = parseModelsCatalogResult;
|
|
42
51
|
exports.parseErrorEvent = parseErrorEvent;
|
|
43
52
|
exports.parseDurableAgentSpec = parseDurableAgentSpec;
|
|
44
53
|
exports.durableAgentSpecToDict = durableAgentSpecToDict;
|
|
@@ -64,7 +73,9 @@ exports.sessionSnapshotToDict = sessionSnapshotToDict;
|
|
|
64
73
|
exports.parseLeaseGrant = parseLeaseGrant;
|
|
65
74
|
exports.leaseGrantToDict = leaseGrantToDict;
|
|
66
75
|
exports.parseLeaseAcquireResult = parseLeaseAcquireResult;
|
|
76
|
+
exports.leaseAcquireResultToDict = leaseAcquireResultToDict;
|
|
67
77
|
exports.parseLeaseRenewResult = parseLeaseRenewResult;
|
|
78
|
+
exports.leaseRenewResultToDict = leaseRenewResultToDict;
|
|
68
79
|
// -- Helpers (internal) ---------------------------------------------------
|
|
69
80
|
function asRecord(value) {
|
|
70
81
|
if (typeof value === "object" && value !== null) {
|
|
@@ -94,6 +105,15 @@ function asStringRecord(value) {
|
|
|
94
105
|
}
|
|
95
106
|
return result;
|
|
96
107
|
}
|
|
108
|
+
function validateAgentIdentity(identity) {
|
|
109
|
+
if (identity.length === 0 ||
|
|
110
|
+
identity.trim() !== identity ||
|
|
111
|
+
/\s/.test(identity) ||
|
|
112
|
+
identity.includes("/")) {
|
|
113
|
+
throw new Error(`invalid agent identity: ${identity}`);
|
|
114
|
+
}
|
|
115
|
+
return identity;
|
|
116
|
+
}
|
|
97
117
|
// -- Constants ------------------------------------------------------------
|
|
98
118
|
exports.MEMBER_STATE_ACTIVE = "active";
|
|
99
119
|
exports.MEMBER_STATE_RETIRING = "retiring";
|
|
@@ -341,6 +361,24 @@ function parseRediscoverReport(raw) {
|
|
|
341
361
|
}
|
|
342
362
|
function parseUnifiedEvent(raw) {
|
|
343
363
|
const d = asRecord(raw);
|
|
364
|
+
if (d.kind === "agent") {
|
|
365
|
+
return {
|
|
366
|
+
kind: "agent",
|
|
367
|
+
agentId: String(d.agent_id ?? d.agentId ?? ""),
|
|
368
|
+
eventType: String(d.event_type ?? d.eventType ?? ""),
|
|
369
|
+
payload: typeof d.payload === "object" && d.payload !== null
|
|
370
|
+
? asRecord(d.payload)
|
|
371
|
+
: null,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
if (d.kind === "module") {
|
|
375
|
+
return {
|
|
376
|
+
kind: "module",
|
|
377
|
+
module: String(d.module ?? ""),
|
|
378
|
+
eventType: String(d.event_type ?? d.eventType ?? ""),
|
|
379
|
+
payload: asRecord(d.payload),
|
|
380
|
+
};
|
|
381
|
+
}
|
|
344
382
|
if ("Agent" in d) {
|
|
345
383
|
const agent = asRecord(d.Agent);
|
|
346
384
|
return {
|
|
@@ -530,6 +568,103 @@ function parseMobRun(raw) {
|
|
|
530
568
|
loopIterationOutputs: iterOutputs,
|
|
531
569
|
};
|
|
532
570
|
}
|
|
571
|
+
function parseMobUnreachablePeer(raw) {
|
|
572
|
+
const d = asRecord(raw);
|
|
573
|
+
return {
|
|
574
|
+
peer: String(d.peer ?? ""),
|
|
575
|
+
reason: typeof d.reason === "string" ? d.reason : null,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function parsePeerConnectivitySnapshot(raw) {
|
|
579
|
+
const d = asRecord(raw);
|
|
580
|
+
return {
|
|
581
|
+
reachablePeerCount: Number(d.reachable_peer_count ?? 0),
|
|
582
|
+
unknownPeerCount: Number(d.unknown_peer_count ?? 0),
|
|
583
|
+
unreachablePeers: asRecordArray(d.unreachable_peers).map(parseMobUnreachablePeer),
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function parseRichMemberSnapshot(raw) {
|
|
587
|
+
const d = asRecord(raw);
|
|
588
|
+
return {
|
|
589
|
+
status: String(d.status ?? "unknown"),
|
|
590
|
+
outputPreview: typeof d.output_preview === "string" ? d.output_preview : null,
|
|
591
|
+
error: typeof d.error === "string" ? d.error : null,
|
|
592
|
+
tokensUsed: Number(d.tokens_used ?? 0),
|
|
593
|
+
isFinal: Boolean(d.is_final),
|
|
594
|
+
currentSessionId: typeof d.current_session_id === "string" ? d.current_session_id : null,
|
|
595
|
+
peerConnectivity: typeof d.peer_connectivity === "object" && d.peer_connectivity !== null
|
|
596
|
+
? parsePeerConnectivitySnapshot(d.peer_connectivity)
|
|
597
|
+
: null,
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function parseHelperResult(raw) {
|
|
601
|
+
const d = asRecord(raw);
|
|
602
|
+
return {
|
|
603
|
+
output: typeof d.output === "string" ? d.output : null,
|
|
604
|
+
tokensUsed: Number(d.tokens_used ?? 0),
|
|
605
|
+
sessionId: typeof d.session_id === "string" ? d.session_id : null,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function parseMobRunSnapshot(raw) {
|
|
609
|
+
const d = asRecord(raw);
|
|
610
|
+
return {
|
|
611
|
+
runId: String(d.run_id ?? ""),
|
|
612
|
+
mobId: String(d.mob_id ?? ""),
|
|
613
|
+
flowId: String(d.flow_id ?? ""),
|
|
614
|
+
status: String(d.status ?? "unknown"),
|
|
615
|
+
stepLedger: asRecordArray(d.step_ledger),
|
|
616
|
+
failureLedger: asRecordArray(d.failure_ledger),
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function parseCrossMobContactEntry(raw) {
|
|
620
|
+
const d = asRecord(raw);
|
|
621
|
+
let transport = d.transport;
|
|
622
|
+
if (typeof transport === "object" && transport !== null) {
|
|
623
|
+
const t = asRecord(transport);
|
|
624
|
+
if (typeof t.Tcp === "string")
|
|
625
|
+
transport = `tcp://${t.Tcp}`;
|
|
626
|
+
else if (typeof t.Uds === "string")
|
|
627
|
+
transport = `uds://${t.Uds}`;
|
|
628
|
+
else
|
|
629
|
+
transport = "inproc";
|
|
630
|
+
}
|
|
631
|
+
else if (transport === "Inproc") {
|
|
632
|
+
transport = "inproc";
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
mobId: String(d.mob_id ?? ""),
|
|
636
|
+
transport: String(transport ?? ""),
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function parseCatalogEntry(raw) {
|
|
640
|
+
const d = asRecord(raw);
|
|
641
|
+
const profile = asRecord(d.profile);
|
|
642
|
+
return {
|
|
643
|
+
id: String(d.id ?? ""),
|
|
644
|
+
displayName: String(d.display_name ?? ""),
|
|
645
|
+
provider: String(d.provider ?? ""),
|
|
646
|
+
tier: String(d.tier ?? ""),
|
|
647
|
+
contextWindow: d.context_window == null ? null : Number(d.context_window),
|
|
648
|
+
maxOutputTokens: d.max_output_tokens == null ? null : Number(d.max_output_tokens),
|
|
649
|
+
vision: Boolean(profile.vision),
|
|
650
|
+
imageToolResults: Boolean(profile.image_tool_results),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function parseProviderDefaults(raw) {
|
|
654
|
+
const d = asRecord(raw);
|
|
655
|
+
return {
|
|
656
|
+
provider: String(d.provider ?? ""),
|
|
657
|
+
defaultModelId: String(d.default_model_id ?? ""),
|
|
658
|
+
models: asRecordArray(d.models).map(parseCatalogEntry),
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function parseModelsCatalogResult(raw) {
|
|
662
|
+
const d = asRecord(raw);
|
|
663
|
+
return {
|
|
664
|
+
models: asRecordArray(d.models).map(parseCatalogEntry),
|
|
665
|
+
providerDefaults: asRecordArray(d.provider_defaults).map(parseProviderDefaults),
|
|
666
|
+
};
|
|
667
|
+
}
|
|
533
668
|
// -- ErrorCategory / ErrorEvent -------------------------------------------
|
|
534
669
|
exports.ErrorCategory = {
|
|
535
670
|
SPAWN_FAILURE: "spawn_failure",
|
|
@@ -579,7 +714,7 @@ function parseErrorEvent(raw) {
|
|
|
579
714
|
function parseDurableAgentSpec(raw) {
|
|
580
715
|
const d = asRecord(raw);
|
|
581
716
|
return {
|
|
582
|
-
identity: String(d.identity ?? ""),
|
|
717
|
+
identity: validateAgentIdentity(String(d.identity ?? "")),
|
|
583
718
|
profile: String(d.profile ?? ""),
|
|
584
719
|
addressability: String(d.addressability ?? "addressable"),
|
|
585
720
|
displayName: typeof d.display_name === "string" ? d.display_name : null,
|
|
@@ -719,10 +854,16 @@ function dispatchInputToDict(input) {
|
|
|
719
854
|
}
|
|
720
855
|
function parseManagedPeerEdge(raw) {
|
|
721
856
|
const d = asRecord(raw);
|
|
722
|
-
|
|
857
|
+
const a = validateAgentIdentity(String(d.a ?? ""));
|
|
858
|
+
const b = validateAgentIdentity(String(d.b ?? ""));
|
|
859
|
+
if (a === b) {
|
|
860
|
+
throw new Error(`managed peer edge cannot connect an identity to itself: ${a}`);
|
|
861
|
+
}
|
|
862
|
+
return a < b ? { a, b } : { a: b, b: a };
|
|
723
863
|
}
|
|
724
864
|
function managedPeerEdgeToDict(edge) {
|
|
725
|
-
|
|
865
|
+
const parsed = parseManagedPeerEdge(edge);
|
|
866
|
+
return { a: parsed.a, b: parsed.b };
|
|
726
867
|
}
|
|
727
868
|
function parseExternalToolDef(raw) {
|
|
728
869
|
const d = asRecord(raw);
|
|
@@ -897,31 +1038,68 @@ function parseLeaseGrant(raw) {
|
|
|
897
1038
|
return {
|
|
898
1039
|
identity: String(d.identity ?? ""),
|
|
899
1040
|
fencingToken: Number(d.fencing_token ?? 0),
|
|
900
|
-
ttlMs: Number(d.ttl_ms ?? 0),
|
|
1041
|
+
ttlMs: Number(d.ttl ?? d.ttl_ms ?? 0),
|
|
901
1042
|
};
|
|
902
1043
|
}
|
|
903
1044
|
function leaseGrantToDict(grant) {
|
|
904
1045
|
return {
|
|
905
1046
|
identity: grant.identity,
|
|
906
1047
|
fencing_token: grant.fencingToken,
|
|
907
|
-
|
|
1048
|
+
ttl: grant.ttlMs,
|
|
908
1049
|
};
|
|
909
1050
|
}
|
|
910
1051
|
function parseLeaseAcquireResult(raw) {
|
|
911
1052
|
const d = asRecord(raw);
|
|
912
|
-
const wireStatus = String(d.status ?? "acquired");
|
|
1053
|
+
const wireStatus = String(d.result ?? d.status ?? "acquired");
|
|
913
1054
|
const status = wireStatus === "already_held" ? "alreadyHeld" : "acquired";
|
|
914
1055
|
return {
|
|
915
1056
|
status,
|
|
916
|
-
|
|
1057
|
+
identity: typeof d.identity === "string" ? d.identity : undefined,
|
|
1058
|
+
grant: d.grant != null
|
|
1059
|
+
? parseLeaseGrant(d.grant)
|
|
1060
|
+
: status === "acquired"
|
|
1061
|
+
? parseLeaseGrant(d)
|
|
1062
|
+
: undefined,
|
|
917
1063
|
holder: typeof d.holder === "string" ? d.holder : undefined,
|
|
918
1064
|
};
|
|
919
1065
|
}
|
|
1066
|
+
function leaseAcquireResultToDict(result) {
|
|
1067
|
+
if (result.status === "alreadyHeld") {
|
|
1068
|
+
return {
|
|
1069
|
+
result: "already_held",
|
|
1070
|
+
identity: result.identity ?? result.grant?.identity ?? "",
|
|
1071
|
+
holder: result.holder ?? "",
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
const grant = result.grant;
|
|
1075
|
+
return {
|
|
1076
|
+
result: "acquired",
|
|
1077
|
+
...(grant ? leaseGrantToDict(grant) : {}),
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
920
1080
|
function parseLeaseRenewResult(raw) {
|
|
921
1081
|
const d = asRecord(raw);
|
|
922
|
-
const status = String(d.status ?? "renewed");
|
|
1082
|
+
const status = String(d.result ?? d.status ?? "renewed");
|
|
923
1083
|
return {
|
|
924
1084
|
status,
|
|
925
|
-
|
|
1085
|
+
identity: typeof d.identity === "string" ? d.identity : undefined,
|
|
1086
|
+
grant: d.grant != null
|
|
1087
|
+
? parseLeaseGrant(d.grant)
|
|
1088
|
+
: status === "renewed"
|
|
1089
|
+
? parseLeaseGrant(d)
|
|
1090
|
+
: undefined,
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
function leaseRenewResultToDict(result) {
|
|
1094
|
+
if (result.status === "lost") {
|
|
1095
|
+
return {
|
|
1096
|
+
result: "lost",
|
|
1097
|
+
identity: result.identity ?? result.grant?.identity ?? "",
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
const grant = result.grant;
|
|
1101
|
+
return {
|
|
1102
|
+
result: "renewed",
|
|
1103
|
+
...(grant ? leaseGrantToDict(grant) : {}),
|
|
926
1104
|
};
|
|
927
1105
|
}
|
package/dist/config/auth.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface GoogleAuthConfig {
|
|
|
6
6
|
readonly discoveryUrl: string;
|
|
7
7
|
readonly audience: string | null;
|
|
8
8
|
readonly leewaySeconds: number;
|
|
9
|
+
toDict(): Record<string, unknown>;
|
|
9
10
|
}
|
|
10
11
|
export declare function google(clientId: string, options?: {
|
|
11
12
|
discoveryUrl?: string;
|
|
@@ -18,6 +19,7 @@ export interface JwtAuthConfig {
|
|
|
18
19
|
readonly issuer: string | null;
|
|
19
20
|
readonly audience: string | null;
|
|
20
21
|
readonly leewaySeconds: number;
|
|
22
|
+
toDict(): Record<string, unknown>;
|
|
21
23
|
}
|
|
22
24
|
export declare function jwt(sharedSecret: string, options?: {
|
|
23
25
|
issuer?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/config/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/config/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,gBAAgB,CAalB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,gBAAgB,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAID,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,GAAG,CACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,aAAa,CAWf;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
|
package/dist/config/auth.js
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* Auth configuration for MobKit runtime.
|
|
3
3
|
*/
|
|
4
4
|
export function google(clientId, options) {
|
|
5
|
-
|
|
5
|
+
const config = {
|
|
6
6
|
clientId,
|
|
7
7
|
discoveryUrl: options?.discoveryUrl ??
|
|
8
8
|
"https://accounts.google.com/.well-known/openid-configuration",
|
|
9
9
|
audience: options?.audience ?? null,
|
|
10
10
|
leewaySeconds: options?.leewaySeconds ?? 60,
|
|
11
|
+
toDict() {
|
|
12
|
+
return googleAuthConfigToDict(config);
|
|
13
|
+
},
|
|
11
14
|
};
|
|
15
|
+
return config;
|
|
12
16
|
}
|
|
13
17
|
export function googleAuthConfigToDict(config) {
|
|
14
18
|
return {
|
|
@@ -20,12 +24,16 @@ export function googleAuthConfigToDict(config) {
|
|
|
20
24
|
};
|
|
21
25
|
}
|
|
22
26
|
export function jwt(sharedSecret, options) {
|
|
23
|
-
|
|
27
|
+
const config = {
|
|
24
28
|
sharedSecret,
|
|
25
29
|
issuer: options?.issuer ?? null,
|
|
26
30
|
audience: options?.audience ?? null,
|
|
27
31
|
leewaySeconds: options?.leewaySeconds ?? 60,
|
|
32
|
+
toDict() {
|
|
33
|
+
return jwtAuthConfigToDict(config);
|
|
34
|
+
},
|
|
28
35
|
};
|
|
36
|
+
return config;
|
|
29
37
|
}
|
|
30
38
|
export function jwtAuthConfigToDict(config) {
|
|
31
39
|
return {
|
package/dist/config/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/config/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/config/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,MAAM,UAAU,MAAM,CACpB,QAAgB,EAChB,OAIC;IAED,MAAM,MAAM,GAAG;QACb,QAAQ;QACR,YAAY,EACV,OAAO,EAAE,YAAY;YACrB,8DAA8D;QAChE,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;QACnC,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE;QAC3C,MAAM;YACJ,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,MAAwB;IAExB,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,MAAM,CAAC,QAAQ;QAC1B,aAAa,EAAE,MAAM,CAAC,YAAY;QAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ;QAC5C,cAAc,EAAE,MAAM,CAAC,aAAa;KACrC,CAAC;AACJ,CAAC;AAYD,MAAM,UAAU,GAAG,CACjB,YAAoB,EACpB,OAIC;IAED,MAAM,MAAM,GAAG;QACb,YAAY;QACZ,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,IAAI;QAC/B,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;QACnC,aAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE;QAC3C,MAAM;YACJ,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAqB;IAErB,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,MAAM,CAAC,YAAY;QAClC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,cAAc,EAAE,MAAM,CAAC,aAAa;KACrC,CAAC;AACJ,CAAC"}
|
package/dist/config/memory.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface ElephantMemoryConfig {
|
|
|
6
6
|
readonly spaceId: string | null;
|
|
7
7
|
readonly collection: string | null;
|
|
8
8
|
readonly stores: readonly string[];
|
|
9
|
+
toDict(): Record<string, unknown>;
|
|
9
10
|
}
|
|
10
11
|
export declare function elephant(endpoint: string, options?: {
|
|
11
12
|
spaceId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/config/memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/config/memory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GACA,oBAAoB,CAWtB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,oBAAoB,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB"}
|