memeloop 0.2.3 → 0.2.5
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/browser.d.cts +26 -21
- package/dist/browser.d.ts +26 -21
- package/dist/chunk-4OITUYFC.js +37 -0
- package/dist/chunk-4OITUYFC.js.map +1 -0
- package/dist/{chunk-HY3U3GLE.js → chunk-5EUJNLVW.js} +1 -1
- package/dist/chunk-5EUJNLVW.js.map +1 -0
- package/dist/{chunk-KXVZQLJL.js → chunk-645GZGNM.js} +3 -2
- package/dist/chunk-645GZGNM.js.map +1 -0
- package/dist/{chunk-EPHRIRAL.js → chunk-6OLAL5CW.js} +16 -1
- package/dist/chunk-6OLAL5CW.js.map +1 -0
- package/dist/{chunk-LGUGYRR4.js → chunk-HVLCOJWI.js} +11 -6
- package/dist/{chunk-LGUGYRR4.js.map → chunk-HVLCOJWI.js.map} +1 -1
- package/dist/{chunk-5VYZV33O.js → chunk-KTZDDC7M.js} +64 -79
- package/dist/chunk-KTZDDC7M.js.map +1 -0
- package/dist/{chunk-K5KZJNDP.js → chunk-ROPAEJIM.js} +2 -2
- package/dist/{chunk-GYIOMQMY.js → chunk-UB77WKAU.js} +305 -429
- package/dist/chunk-UB77WKAU.js.map +1 -0
- package/dist/{chunk-KV6TC5UJ.js → chunk-XIEXGFPY.js} +3 -3
- package/dist/conversation.d.cts +4 -3
- package/dist/conversation.d.ts +4 -3
- package/dist/device-network-portable.cjs +2 -1
- package/dist/device-network-portable.cjs.map +1 -1
- package/dist/device-network-portable.d.cts +9 -7
- package/dist/device-network-portable.d.ts +9 -7
- package/dist/device-network-portable.js +1 -1
- package/dist/device-network.cjs +17 -1
- package/dist/device-network.cjs.map +1 -1
- package/dist/device-network.d.cts +6 -5
- package/dist/device-network.d.ts +6 -5
- package/dist/device-network.js +2 -2
- package/dist/{fetchProvider-B_vva3b3.d.ts → fetchProvider-Do8Hf1BN.d.ts} +1 -1
- package/dist/{fetchProvider-Bz4CE3_R.d.cts → fetchProvider-tMo6gc6N.d.cts} +1 -1
- package/dist/index.cjs +465 -537
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -26
- package/dist/index.d.ts +20 -26
- package/dist/index.js +47 -52
- package/dist/index.js.map +1 -1
- package/dist/{interface-3C3eG8Hn.d.cts → interface-C54gkLA3.d.ts} +3 -110
- package/dist/{interface-3C3eG8Hn.d.ts → interface-CECFnbzR.d.cts} +3 -110
- package/dist/llm-providers.cjs.map +1 -1
- package/dist/llm-providers.d.cts +3 -2
- package/dist/llm-providers.d.ts +3 -2
- package/dist/llm-providers.js +1 -1
- package/dist/llm-providers.js.map +1 -1
- package/dist/loop-api.cjs +88 -89
- package/dist/loop-api.cjs.map +1 -1
- package/dist/loop-api.d.cts +8 -7
- package/dist/loop-api.d.ts +8 -7
- package/dist/loop-api.js +5 -5
- package/dist/mobile.cjs +10 -5
- package/dist/mobile.cjs.map +1 -1
- package/dist/mobile.d.cts +6 -5
- package/dist/mobile.d.ts +6 -5
- package/dist/mobile.js +3 -3
- package/dist/{orchestration-portable-B4udCSVd.d.ts → orchestration-portable-CQRrnoEw.d.ts} +15 -5
- package/dist/{orchestration-portable-BWaCsCGK.d.cts → orchestration-portable-D4KBEYQb.d.cts} +15 -5
- package/dist/orchestration-portable.cjs +201 -343
- package/dist/orchestration-portable.cjs.map +1 -1
- package/dist/orchestration-portable.d.cts +6 -5
- package/dist/orchestration-portable.d.ts +6 -5
- package/dist/orchestration-portable.js +1 -1
- package/dist/{pairingInvite-C12n-7Ak.d.cts → pairingInvite-BmCQ-bHt.d.cts} +3 -3
- package/dist/{pairingInvite-CPQkuhLQ.d.ts → pairingInvite-CsfsexXC.d.ts} +3 -3
- package/dist/{promptConcat-VLe5SEN4.d.cts → promptConcat-BqImJtVh.d.cts} +7 -4
- package/dist/{promptConcat-CUEIA_3T.d.ts → promptConcat-C5SEgESi.d.ts} +7 -4
- package/dist/{providerRegistry-CaFK_aUd.d.ts → providerRegistry-BGrwd7Zl.d.cts} +2 -2
- package/dist/{providerRegistry-BDGGs5gz.d.cts → providerRegistry-Bs2lJpj9.d.ts} +2 -2
- package/dist/{registry-DNSEVYug.d.cts → registry-CelnriUR.d.cts} +3 -3
- package/dist/{registry-yGnYHWhq.d.ts → registry-DVv_RVPZ.d.ts} +3 -3
- package/dist/{remoteClient-DwBCoHpc.d.ts → remoteClient-D1gPizds.d.ts} +1 -1
- package/dist/{remoteClient-DFIyCZEv.d.cts → remoteClient-DxCHC4_Z.d.cts} +1 -1
- package/dist/{runtime-6EELHWVB.js → runtime-SASMRN4I.js} +3 -3
- package/dist/{scriptDeploymentPipeline-B1q-UhrO.d.ts → scriptDeploymentPipeline-CdDLEDMS.d.cts} +10 -1
- package/dist/{scriptDeploymentPipeline-XJzQyYys.d.cts → scriptDeploymentPipeline-DU6sor6Y.d.ts} +10 -1
- package/dist/{syncCloudDevices-C8fCUhnX.d.ts → syncCloudDevices-3RmB41sA.d.cts} +6 -2
- package/dist/{syncCloudDevices-BFw_c1g5.d.cts → syncCloudDevices-CSLbMESm.d.ts} +6 -2
- package/dist/tools.cjs +63 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.d.cts +12 -0
- package/dist/tools.d.ts +12 -0
- package/dist/tools.js +7 -0
- package/dist/tools.js.map +1 -0
- package/dist/{types-CcFFIk8W.d.ts → types-C29NBZ2w.d.ts} +1 -1
- package/dist/types-CcoJ_fdH.d.cts +110 -0
- package/dist/types-CcoJ_fdH.d.ts +110 -0
- package/dist/{types-C8gnhG9M.d.cts → types-D1rAJy9l.d.cts} +1 -1
- package/package.json +6 -1
- package/dist/chunk-5VYZV33O.js.map +0 -1
- package/dist/chunk-EPHRIRAL.js.map +0 -1
- package/dist/chunk-GYIOMQMY.js.map +0 -1
- package/dist/chunk-HY3U3GLE.js.map +0 -1
- package/dist/chunk-KXVZQLJL.js.map +0 -1
- /package/dist/{chunk-K5KZJNDP.js.map → chunk-ROPAEJIM.js.map} +0 -0
- /package/dist/{chunk-KV6TC5UJ.js.map → chunk-XIEXGFPY.js.map} +0 -0
- /package/dist/{runtime-6EELHWVB.js.map → runtime-SASMRN4I.js.map} +0 -0
package/dist/loop-api.cjs
CHANGED
|
@@ -913,6 +913,13 @@ var init_identityAttestationManagement = __esm({
|
|
|
913
913
|
}
|
|
914
914
|
});
|
|
915
915
|
|
|
916
|
+
// src/orchestration/drivers/modelProviderDriver.ts
|
|
917
|
+
var init_modelProviderDriver = __esm({
|
|
918
|
+
"src/orchestration/drivers/modelProviderDriver.ts"() {
|
|
919
|
+
"use strict";
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
|
|
916
923
|
// src/orchestration/drivers/localModelRegistration.ts
|
|
917
924
|
var init_localModelRegistration = __esm({
|
|
918
925
|
"src/orchestration/drivers/localModelRegistration.ts"() {
|
|
@@ -958,13 +965,6 @@ var init_managedLoopRuntimeAdapter = __esm({
|
|
|
958
965
|
}
|
|
959
966
|
});
|
|
960
967
|
|
|
961
|
-
// src/orchestration/drivers/modelProviderDriver.ts
|
|
962
|
-
var init_modelProviderDriver = __esm({
|
|
963
|
-
"src/orchestration/drivers/modelProviderDriver.ts"() {
|
|
964
|
-
"use strict";
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
|
|
968
968
|
// src/orchestration/drivers/managedModelGatewayAdapter.ts
|
|
969
969
|
var init_managedModelGatewayAdapter = __esm({
|
|
970
970
|
"src/orchestration/drivers/managedModelGatewayAdapter.ts"() {
|
|
@@ -1986,7 +1986,57 @@ var init_orchestration = __esm({
|
|
|
1986
1986
|
}
|
|
1987
1987
|
});
|
|
1988
1988
|
|
|
1989
|
+
// src/loopAPI/scriptRuntime.ts
|
|
1990
|
+
function messageStep(message) {
|
|
1991
|
+
return { type: "message", data: message };
|
|
1992
|
+
}
|
|
1993
|
+
function createScriptStepEmitter(emittedSteps, onEmit) {
|
|
1994
|
+
return (step) => {
|
|
1995
|
+
emittedSteps.push(step);
|
|
1996
|
+
onEmit?.(step);
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
function isAsyncIterable(value) {
|
|
2000
|
+
return Boolean(value && typeof value === "object" && Symbol.asyncIterator in value);
|
|
2001
|
+
}
|
|
2002
|
+
async function* drainEmittedSteps(steps) {
|
|
2003
|
+
while (steps.length > 0) {
|
|
2004
|
+
const step = steps.shift();
|
|
2005
|
+
if (step) yield step;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
async function* yieldScriptResult(result, emittedSteps) {
|
|
2009
|
+
yield* drainEmittedSteps(emittedSteps);
|
|
2010
|
+
if (isAsyncIterable(result)) {
|
|
2011
|
+
yield* result;
|
|
2012
|
+
yield* drainEmittedSteps(emittedSteps);
|
|
2013
|
+
} else if (typeof result === "string") {
|
|
2014
|
+
yield messageStep(result);
|
|
2015
|
+
} else if (Array.isArray(result)) {
|
|
2016
|
+
yield* result;
|
|
2017
|
+
} else if (result) {
|
|
2018
|
+
yield result;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
var init_scriptRuntime2 = __esm({
|
|
2022
|
+
"src/loopAPI/scriptRuntime.ts"() {
|
|
2023
|
+
"use strict";
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
|
|
1989
2027
|
// src/loopAPI/scriptLoader.ts
|
|
2028
|
+
function createBuiltinAgentLoopScriptLoader(loaderOptions) {
|
|
2029
|
+
let builtinDigestsRegistered;
|
|
2030
|
+
return async (scriptReference, policy = {}) => {
|
|
2031
|
+
builtinDigestsRegistered ??= registerBuiltinScriptSources(loaderOptions.sources);
|
|
2032
|
+
await builtinDigestsRegistered;
|
|
2033
|
+
return loadAgentLoopScript(scriptReference, {
|
|
2034
|
+
...policy,
|
|
2035
|
+
getBuiltinScriptSource: loaderOptions.getBuiltinScriptSource,
|
|
2036
|
+
scriptType: loaderOptions.scriptType
|
|
2037
|
+
});
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
1990
2040
|
function isLoadedScriptFunction(value) {
|
|
1991
2041
|
return typeof value === "function";
|
|
1992
2042
|
}
|
|
@@ -2168,34 +2218,24 @@ var init_scriptLoader = __esm({
|
|
|
2168
2218
|
});
|
|
2169
2219
|
|
|
2170
2220
|
// src/loopAPI/agent-agent-loop/scriptLoader.ts
|
|
2171
|
-
function ensureBuiltinDigestsRegistered() {
|
|
2172
|
-
builtinDigestsRegistered ??= registerBuiltinScriptSources(builtinAgentAgentLoopSources);
|
|
2173
|
-
return builtinDigestsRegistered;
|
|
2174
|
-
}
|
|
2175
2221
|
async function loadAgentAgentLoopScript(scriptReference, options = {}) {
|
|
2176
|
-
|
|
2177
|
-
return loadAgentLoopScript(scriptReference, {
|
|
2178
|
-
...options,
|
|
2179
|
-
getBuiltinScriptSource: getBuiltinAgentAgentLoopSource,
|
|
2180
|
-
scriptType: "AgentAgentLoop script"
|
|
2181
|
-
});
|
|
2222
|
+
return loadScript(scriptReference, options);
|
|
2182
2223
|
}
|
|
2183
|
-
var
|
|
2224
|
+
var loadScript;
|
|
2184
2225
|
var init_scriptLoader2 = __esm({
|
|
2185
2226
|
"src/loopAPI/agent-agent-loop/scriptLoader.ts"() {
|
|
2186
2227
|
"use strict";
|
|
2187
2228
|
init_builtinLoopSources();
|
|
2188
2229
|
init_scriptLoader();
|
|
2230
|
+
loadScript = createBuiltinAgentLoopScriptLoader({
|
|
2231
|
+
sources: builtinAgentAgentLoopSources,
|
|
2232
|
+
getBuiltinScriptSource: getBuiltinAgentAgentLoopSource,
|
|
2233
|
+
scriptType: "AgentAgentLoop script"
|
|
2234
|
+
});
|
|
2189
2235
|
}
|
|
2190
2236
|
});
|
|
2191
2237
|
|
|
2192
2238
|
// src/loopAPI/agent-agent-loop/loop.ts
|
|
2193
|
-
function isAsyncIterable(value) {
|
|
2194
|
-
return Boolean(value && typeof value === "object" && Symbol.asyncIterator in value);
|
|
2195
|
-
}
|
|
2196
|
-
function messageStep(message) {
|
|
2197
|
-
return { type: "message", data: message };
|
|
2198
|
-
}
|
|
2199
2239
|
function stepText(step) {
|
|
2200
2240
|
if (step.type !== "message") return void 0;
|
|
2201
2241
|
if (typeof step.data === "string") return step.data;
|
|
@@ -2249,10 +2289,7 @@ function createScriptArguments(input, context, emittedSteps) {
|
|
|
2249
2289
|
if (key === "agents") return agentEntries;
|
|
2250
2290
|
return readProfileAgentEntries(context.profile, key) ?? [];
|
|
2251
2291
|
};
|
|
2252
|
-
const emit = (
|
|
2253
|
-
emittedSteps.push(step);
|
|
2254
|
-
context.runtime?.emit?.(step);
|
|
2255
|
-
};
|
|
2292
|
+
const emit = createScriptStepEmitter(emittedSteps, context.runtime?.emit);
|
|
2256
2293
|
const log = (event, data) => {
|
|
2257
2294
|
context.runtime?.log?.(event, data);
|
|
2258
2295
|
};
|
|
@@ -2367,27 +2404,11 @@ function createScriptArguments(input, context, emittedSteps) {
|
|
|
2367
2404
|
loadCheckpoint: context.runtime?.loadCheckpoint ?? (async () => void 0)
|
|
2368
2405
|
};
|
|
2369
2406
|
}
|
|
2370
|
-
async function* drainEmittedSteps(steps) {
|
|
2371
|
-
while (steps.length > 0) {
|
|
2372
|
-
const step = steps.shift();
|
|
2373
|
-
if (step) yield step;
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
2407
|
async function* runScript(script, input, context) {
|
|
2377
2408
|
const emittedSteps = [];
|
|
2378
2409
|
const scriptArguments = createScriptArguments(input, context, emittedSteps);
|
|
2379
2410
|
const result = await script(scriptArguments);
|
|
2380
|
-
yield*
|
|
2381
|
-
if (isAsyncIterable(result)) {
|
|
2382
|
-
yield* result;
|
|
2383
|
-
yield* drainEmittedSteps(emittedSteps);
|
|
2384
|
-
} else if (typeof result === "string") {
|
|
2385
|
-
yield messageStep(result);
|
|
2386
|
-
} else if (Array.isArray(result)) {
|
|
2387
|
-
yield* result;
|
|
2388
|
-
} else if (result) {
|
|
2389
|
-
yield result;
|
|
2390
|
-
}
|
|
2411
|
+
yield* yieldScriptResult(result, emittedSteps);
|
|
2391
2412
|
}
|
|
2392
2413
|
function asAgentAgentContext(context) {
|
|
2393
2414
|
return context;
|
|
@@ -2450,6 +2471,7 @@ var init_loop = __esm({
|
|
|
2450
2471
|
"src/loopAPI/agent-agent-loop/loop.ts"() {
|
|
2451
2472
|
"use strict";
|
|
2452
2473
|
init_orchestration();
|
|
2474
|
+
init_scriptRuntime2();
|
|
2453
2475
|
init_scriptLoader2();
|
|
2454
2476
|
LOOP_ID = "agent-agent-loop";
|
|
2455
2477
|
LOOP_NAME = "AgentAgent Loop";
|
|
@@ -4344,6 +4366,9 @@ function resolveMaxIterations(context) {
|
|
|
4344
4366
|
const configured = context.agentToolLoop?.maxIterations;
|
|
4345
4367
|
return configured != null && configured > 0 ? configured : DEFAULT_MAX_ITERATIONS;
|
|
4346
4368
|
}
|
|
4369
|
+
function resolveLocalNodeId(context, input) {
|
|
4370
|
+
return context.localNodeId?.trim() || input?.userMessage?.originNodeId?.trim() || "local";
|
|
4371
|
+
}
|
|
4347
4372
|
function pluginToolCallSignature(calls) {
|
|
4348
4373
|
return calls.map((call) => `${call.toolId}:${JSON.stringify(call.parameters)}`).join("|");
|
|
4349
4374
|
}
|
|
@@ -4365,7 +4390,7 @@ async function blockRepeatedPluginToolCalls(context, input, state, calls, hookCo
|
|
|
4365
4390
|
const toolMessage = createChatMessage({
|
|
4366
4391
|
messageId: `${input.conversationId}:t:doom-loop:${state.iteration}:${Date.now().toString(36)}`,
|
|
4367
4392
|
conversationId: input.conversationId,
|
|
4368
|
-
originNodeId:
|
|
4393
|
+
originNodeId: resolveLocalNodeId(context, input),
|
|
4369
4394
|
lamportClock,
|
|
4370
4395
|
role: "tool",
|
|
4371
4396
|
parts: [{
|
|
@@ -4410,11 +4435,12 @@ async function startAgentToolLoopTurn(context, input, state) {
|
|
|
4410
4435
|
input.conversationId
|
|
4411
4436
|
);
|
|
4412
4437
|
const hostUserMessage = input.userMessage;
|
|
4438
|
+
const localNodeId = resolveLocalNodeId(context, input);
|
|
4413
4439
|
const userMessage = context.normalizeMessage?.({
|
|
4414
4440
|
...hostUserMessage,
|
|
4415
4441
|
messageId: hostUserMessage?.messageId ?? `${input.conversationId}:${now.toString(36)}`,
|
|
4416
4442
|
conversationId: input.conversationId,
|
|
4417
|
-
originNodeId: hostUserMessage?.originNodeId ??
|
|
4443
|
+
originNodeId: hostUserMessage?.originNodeId ?? localNodeId,
|
|
4418
4444
|
timestamp: hostUserMessage?.timestamp ?? now,
|
|
4419
4445
|
lamportClock: hostUserMessage?.lamportClock ?? lamportClock,
|
|
4420
4446
|
role: "user",
|
|
@@ -4423,7 +4449,7 @@ async function startAgentToolLoopTurn(context, input, state) {
|
|
|
4423
4449
|
...hostUserMessage,
|
|
4424
4450
|
messageId: hostUserMessage?.messageId ?? `${input.conversationId}:${now.toString(36)}`,
|
|
4425
4451
|
conversationId: input.conversationId,
|
|
4426
|
-
originNodeId: hostUserMessage?.originNodeId ??
|
|
4452
|
+
originNodeId: hostUserMessage?.originNodeId ?? localNodeId,
|
|
4427
4453
|
timestamp: hostUserMessage?.timestamp ?? now,
|
|
4428
4454
|
lamportClock: hostUserMessage?.lamportClock ?? lamportClock,
|
|
4429
4455
|
role: "user",
|
|
@@ -4534,10 +4560,11 @@ async function* runAgentToolLoopIteration(context, input, state) {
|
|
|
4534
4560
|
context.storage,
|
|
4535
4561
|
input.conversationId
|
|
4536
4562
|
);
|
|
4563
|
+
const localNodeId = resolveLocalNodeId(context, input);
|
|
4537
4564
|
const buildAssistantMessage = (content) => context.normalizeMessage?.({
|
|
4538
4565
|
messageId: assistantMessageId,
|
|
4539
4566
|
conversationId: input.conversationId,
|
|
4540
|
-
originNodeId:
|
|
4567
|
+
originNodeId: localNodeId,
|
|
4541
4568
|
timestamp: Date.now(),
|
|
4542
4569
|
lamportClock: assistantLamportClock,
|
|
4543
4570
|
role: "assistant",
|
|
@@ -4545,7 +4572,7 @@ async function* runAgentToolLoopIteration(context, input, state) {
|
|
|
4545
4572
|
}) ?? {
|
|
4546
4573
|
messageId: assistantMessageId,
|
|
4547
4574
|
conversationId: input.conversationId,
|
|
4548
|
-
originNodeId:
|
|
4575
|
+
originNodeId: localNodeId,
|
|
4549
4576
|
timestamp: Date.now(),
|
|
4550
4577
|
lamportClock: assistantLamportClock,
|
|
4551
4578
|
role: "assistant",
|
|
@@ -4764,40 +4791,24 @@ var init_directRunner = __esm({
|
|
|
4764
4791
|
});
|
|
4765
4792
|
|
|
4766
4793
|
// src/loopAPI/agent-tool-loop/scriptLoader.ts
|
|
4767
|
-
function ensureBuiltinDigestsRegistered2() {
|
|
4768
|
-
builtinDigestsRegistered2 ??= registerBuiltinScriptSources(builtinAgentToolLoopSources);
|
|
4769
|
-
return builtinDigestsRegistered2;
|
|
4770
|
-
}
|
|
4771
4794
|
async function loadAgentToolLoopScript(scriptReference, options = {}) {
|
|
4772
|
-
|
|
4773
|
-
return loadAgentLoopScript(scriptReference, {
|
|
4774
|
-
...options,
|
|
4775
|
-
getBuiltinScriptSource: getBuiltinAgentToolLoopSource,
|
|
4776
|
-
scriptType: "AgentToolLoop script"
|
|
4777
|
-
});
|
|
4795
|
+
return loadScript2(scriptReference, options);
|
|
4778
4796
|
}
|
|
4779
|
-
var
|
|
4797
|
+
var loadScript2;
|
|
4780
4798
|
var init_scriptLoader3 = __esm({
|
|
4781
4799
|
"src/loopAPI/agent-tool-loop/scriptLoader.ts"() {
|
|
4782
4800
|
"use strict";
|
|
4783
4801
|
init_builtinLoopSources2();
|
|
4784
4802
|
init_scriptLoader();
|
|
4803
|
+
loadScript2 = createBuiltinAgentLoopScriptLoader({
|
|
4804
|
+
sources: builtinAgentToolLoopSources,
|
|
4805
|
+
getBuiltinScriptSource: getBuiltinAgentToolLoopSource,
|
|
4806
|
+
scriptType: "AgentToolLoop script"
|
|
4807
|
+
});
|
|
4785
4808
|
}
|
|
4786
4809
|
});
|
|
4787
4810
|
|
|
4788
4811
|
// src/loopAPI/agent-tool-loop/scriptRunner.ts
|
|
4789
|
-
function isAsyncIterable3(value) {
|
|
4790
|
-
return Boolean(value && typeof value === "object" && Symbol.asyncIterator in value);
|
|
4791
|
-
}
|
|
4792
|
-
function messageStep2(message) {
|
|
4793
|
-
return { type: "message", data: message };
|
|
4794
|
-
}
|
|
4795
|
-
async function* drainEmittedSteps2(steps) {
|
|
4796
|
-
while (steps.length > 0) {
|
|
4797
|
-
const step = steps.shift();
|
|
4798
|
-
if (step) yield step;
|
|
4799
|
-
}
|
|
4800
|
-
}
|
|
4801
4812
|
function asAgentToolLoopContext(rawContext) {
|
|
4802
4813
|
return rawContext;
|
|
4803
4814
|
}
|
|
@@ -4809,10 +4820,7 @@ async function resolveAgentToolLoopScript(context) {
|
|
|
4809
4820
|
return loadAgentToolLoopScript(scriptReference, context.scriptPolicy);
|
|
4810
4821
|
}
|
|
4811
4822
|
function createAgentToolLoopScriptContext(input, context, emittedSteps) {
|
|
4812
|
-
const emit = (
|
|
4813
|
-
emittedSteps.push(step);
|
|
4814
|
-
context.runtime?.emit?.(step);
|
|
4815
|
-
};
|
|
4823
|
+
const emit = createScriptStepEmitter(emittedSteps, context.runtime?.emit);
|
|
4816
4824
|
return {
|
|
4817
4825
|
input,
|
|
4818
4826
|
context,
|
|
@@ -4823,7 +4831,7 @@ function createAgentToolLoopScriptContext(input, context, emittedSteps) {
|
|
|
4823
4831
|
stopTurn: (state, reason) => stopAgentToolLoopTurn(context, input, state, reason),
|
|
4824
4832
|
emit,
|
|
4825
4833
|
finish: (message) => {
|
|
4826
|
-
emit(typeof message === "string" ?
|
|
4834
|
+
emit(typeof message === "string" ? messageStep(message) : message);
|
|
4827
4835
|
},
|
|
4828
4836
|
isCancelled: () => context.runtime?.signal?.cancelled === true || context.agentToolLoop?.isCancelled?.(input.conversationId) === true,
|
|
4829
4837
|
log: (event, data) => {
|
|
@@ -4835,21 +4843,12 @@ function createAgentToolLoopScriptContext(input, context, emittedSteps) {
|
|
|
4835
4843
|
async function* runAgentToolLoopScript(script, input, context) {
|
|
4836
4844
|
const emittedSteps = [];
|
|
4837
4845
|
const result = await script(createAgentToolLoopScriptContext(input, context, emittedSteps));
|
|
4838
|
-
yield*
|
|
4839
|
-
if (isAsyncIterable3(result)) {
|
|
4840
|
-
yield* result;
|
|
4841
|
-
yield* drainEmittedSteps2(emittedSteps);
|
|
4842
|
-
} else if (typeof result === "string") {
|
|
4843
|
-
yield messageStep2(result);
|
|
4844
|
-
} else if (Array.isArray(result)) {
|
|
4845
|
-
yield* result;
|
|
4846
|
-
} else if (result) {
|
|
4847
|
-
yield result;
|
|
4848
|
-
}
|
|
4846
|
+
yield* yieldScriptResult(result, emittedSteps);
|
|
4849
4847
|
}
|
|
4850
4848
|
var init_scriptRunner = __esm({
|
|
4851
4849
|
"src/loopAPI/agent-tool-loop/scriptRunner.ts"() {
|
|
4852
4850
|
"use strict";
|
|
4851
|
+
init_scriptRuntime2();
|
|
4853
4852
|
init_scriptLoader3();
|
|
4854
4853
|
init_turnPrimitives();
|
|
4855
4854
|
}
|