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.
Files changed (96) hide show
  1. package/dist/browser.d.cts +26 -21
  2. package/dist/browser.d.ts +26 -21
  3. package/dist/chunk-4OITUYFC.js +37 -0
  4. package/dist/chunk-4OITUYFC.js.map +1 -0
  5. package/dist/{chunk-HY3U3GLE.js → chunk-5EUJNLVW.js} +1 -1
  6. package/dist/chunk-5EUJNLVW.js.map +1 -0
  7. package/dist/{chunk-KXVZQLJL.js → chunk-645GZGNM.js} +3 -2
  8. package/dist/chunk-645GZGNM.js.map +1 -0
  9. package/dist/{chunk-EPHRIRAL.js → chunk-6OLAL5CW.js} +16 -1
  10. package/dist/chunk-6OLAL5CW.js.map +1 -0
  11. package/dist/{chunk-LGUGYRR4.js → chunk-HVLCOJWI.js} +11 -6
  12. package/dist/{chunk-LGUGYRR4.js.map → chunk-HVLCOJWI.js.map} +1 -1
  13. package/dist/{chunk-5VYZV33O.js → chunk-KTZDDC7M.js} +64 -79
  14. package/dist/chunk-KTZDDC7M.js.map +1 -0
  15. package/dist/{chunk-K5KZJNDP.js → chunk-ROPAEJIM.js} +2 -2
  16. package/dist/{chunk-GYIOMQMY.js → chunk-UB77WKAU.js} +305 -429
  17. package/dist/chunk-UB77WKAU.js.map +1 -0
  18. package/dist/{chunk-KV6TC5UJ.js → chunk-XIEXGFPY.js} +3 -3
  19. package/dist/conversation.d.cts +4 -3
  20. package/dist/conversation.d.ts +4 -3
  21. package/dist/device-network-portable.cjs +2 -1
  22. package/dist/device-network-portable.cjs.map +1 -1
  23. package/dist/device-network-portable.d.cts +9 -7
  24. package/dist/device-network-portable.d.ts +9 -7
  25. package/dist/device-network-portable.js +1 -1
  26. package/dist/device-network.cjs +17 -1
  27. package/dist/device-network.cjs.map +1 -1
  28. package/dist/device-network.d.cts +6 -5
  29. package/dist/device-network.d.ts +6 -5
  30. package/dist/device-network.js +2 -2
  31. package/dist/{fetchProvider-B_vva3b3.d.ts → fetchProvider-Do8Hf1BN.d.ts} +1 -1
  32. package/dist/{fetchProvider-Bz4CE3_R.d.cts → fetchProvider-tMo6gc6N.d.cts} +1 -1
  33. package/dist/index.cjs +465 -537
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +20 -26
  36. package/dist/index.d.ts +20 -26
  37. package/dist/index.js +47 -52
  38. package/dist/index.js.map +1 -1
  39. package/dist/{interface-3C3eG8Hn.d.cts → interface-C54gkLA3.d.ts} +3 -110
  40. package/dist/{interface-3C3eG8Hn.d.ts → interface-CECFnbzR.d.cts} +3 -110
  41. package/dist/llm-providers.cjs.map +1 -1
  42. package/dist/llm-providers.d.cts +3 -2
  43. package/dist/llm-providers.d.ts +3 -2
  44. package/dist/llm-providers.js +1 -1
  45. package/dist/llm-providers.js.map +1 -1
  46. package/dist/loop-api.cjs +88 -89
  47. package/dist/loop-api.cjs.map +1 -1
  48. package/dist/loop-api.d.cts +8 -7
  49. package/dist/loop-api.d.ts +8 -7
  50. package/dist/loop-api.js +5 -5
  51. package/dist/mobile.cjs +10 -5
  52. package/dist/mobile.cjs.map +1 -1
  53. package/dist/mobile.d.cts +6 -5
  54. package/dist/mobile.d.ts +6 -5
  55. package/dist/mobile.js +3 -3
  56. package/dist/{orchestration-portable-B4udCSVd.d.ts → orchestration-portable-CQRrnoEw.d.ts} +15 -5
  57. package/dist/{orchestration-portable-BWaCsCGK.d.cts → orchestration-portable-D4KBEYQb.d.cts} +15 -5
  58. package/dist/orchestration-portable.cjs +201 -343
  59. package/dist/orchestration-portable.cjs.map +1 -1
  60. package/dist/orchestration-portable.d.cts +6 -5
  61. package/dist/orchestration-portable.d.ts +6 -5
  62. package/dist/orchestration-portable.js +1 -1
  63. package/dist/{pairingInvite-C12n-7Ak.d.cts → pairingInvite-BmCQ-bHt.d.cts} +3 -3
  64. package/dist/{pairingInvite-CPQkuhLQ.d.ts → pairingInvite-CsfsexXC.d.ts} +3 -3
  65. package/dist/{promptConcat-VLe5SEN4.d.cts → promptConcat-BqImJtVh.d.cts} +7 -4
  66. package/dist/{promptConcat-CUEIA_3T.d.ts → promptConcat-C5SEgESi.d.ts} +7 -4
  67. package/dist/{providerRegistry-CaFK_aUd.d.ts → providerRegistry-BGrwd7Zl.d.cts} +2 -2
  68. package/dist/{providerRegistry-BDGGs5gz.d.cts → providerRegistry-Bs2lJpj9.d.ts} +2 -2
  69. package/dist/{registry-DNSEVYug.d.cts → registry-CelnriUR.d.cts} +3 -3
  70. package/dist/{registry-yGnYHWhq.d.ts → registry-DVv_RVPZ.d.ts} +3 -3
  71. package/dist/{remoteClient-DwBCoHpc.d.ts → remoteClient-D1gPizds.d.ts} +1 -1
  72. package/dist/{remoteClient-DFIyCZEv.d.cts → remoteClient-DxCHC4_Z.d.cts} +1 -1
  73. package/dist/{runtime-6EELHWVB.js → runtime-SASMRN4I.js} +3 -3
  74. package/dist/{scriptDeploymentPipeline-B1q-UhrO.d.ts → scriptDeploymentPipeline-CdDLEDMS.d.cts} +10 -1
  75. package/dist/{scriptDeploymentPipeline-XJzQyYys.d.cts → scriptDeploymentPipeline-DU6sor6Y.d.ts} +10 -1
  76. package/dist/{syncCloudDevices-C8fCUhnX.d.ts → syncCloudDevices-3RmB41sA.d.cts} +6 -2
  77. package/dist/{syncCloudDevices-BFw_c1g5.d.cts → syncCloudDevices-CSLbMESm.d.ts} +6 -2
  78. package/dist/tools.cjs +63 -0
  79. package/dist/tools.cjs.map +1 -0
  80. package/dist/tools.d.cts +12 -0
  81. package/dist/tools.d.ts +12 -0
  82. package/dist/tools.js +7 -0
  83. package/dist/tools.js.map +1 -0
  84. package/dist/{types-CcFFIk8W.d.ts → types-C29NBZ2w.d.ts} +1 -1
  85. package/dist/types-CcoJ_fdH.d.cts +110 -0
  86. package/dist/types-CcoJ_fdH.d.ts +110 -0
  87. package/dist/{types-C8gnhG9M.d.cts → types-D1rAJy9l.d.cts} +1 -1
  88. package/package.json +6 -1
  89. package/dist/chunk-5VYZV33O.js.map +0 -1
  90. package/dist/chunk-EPHRIRAL.js.map +0 -1
  91. package/dist/chunk-GYIOMQMY.js.map +0 -1
  92. package/dist/chunk-HY3U3GLE.js.map +0 -1
  93. package/dist/chunk-KXVZQLJL.js.map +0 -1
  94. /package/dist/{chunk-K5KZJNDP.js.map → chunk-ROPAEJIM.js.map} +0 -0
  95. /package/dist/{chunk-KV6TC5UJ.js.map → chunk-XIEXGFPY.js.map} +0 -0
  96. /package/dist/{runtime-6EELHWVB.js.map → runtime-SASMRN4I.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ mergeAgentToolsIntoFrameworkConfig
3
+ } from "./chunk-4OITUYFC.js";
1
4
  import {
2
5
  AgentCreationController,
3
6
  AgentDefinitionEditorController,
@@ -24,7 +27,7 @@ import {
24
27
  unloadAllPlugins,
25
28
  unloadPlugin,
26
29
  validatePluginManifest
27
- } from "./chunk-KV6TC5UJ.js";
30
+ } from "./chunk-XIEXGFPY.js";
28
31
  import {
29
32
  AGENT_AGENT_LOOP_ID,
30
33
  AGENT_TOOL_LOOP_ID,
@@ -116,7 +119,7 @@ import {
116
119
  toolSchemaToJsonSchema,
117
120
  validateScript,
118
121
  waitForCondition
119
- } from "./chunk-5VYZV33O.js";
122
+ } from "./chunk-KTZDDC7M.js";
120
123
  import {
121
124
  ALL_CATEGORIES,
122
125
  getCategoryConfig,
@@ -126,7 +129,7 @@ import {
126
129
  import {
127
130
  MemoryDeviceNetworkService,
128
131
  syncCloudDevices
129
- } from "./chunk-EPHRIRAL.js";
132
+ } from "./chunk-6OLAL5CW.js";
130
133
  import {
131
134
  ChatSyncEngine,
132
135
  DEVICE_BINDING_SIGNATURE_DOMAIN,
@@ -165,7 +168,7 @@ import {
165
168
  isLibp2pSyncRequest,
166
169
  isLibp2pSyncResponse,
167
170
  parseDevicePairingInvite
168
- } from "./chunk-KXVZQLJL.js";
171
+ } from "./chunk-645GZGNM.js";
169
172
  import {
170
173
  DEFAULT_DESTINATION_POLICIES,
171
174
  DRIVER_REQUEST_API_VERSION,
@@ -228,13 +231,14 @@ import {
228
231
  detectMimeConfusion,
229
232
  featuresRequiredByClass,
230
233
  inspectAndRecordArtifact,
234
+ modelClassNameForSpec,
231
235
  restoreArtifactManagementState,
232
236
  sanitizeMarkup,
233
237
  sanitizeTerminalText,
234
238
  scanForPromptInjection,
235
239
  snapshotArtifactManagementState,
236
240
  validateArchiveManifest
237
- } from "./chunk-GYIOMQMY.js";
241
+ } from "./chunk-UB77WKAU.js";
238
242
  import {
239
243
  REMOTE_ORCHESTRATION_PROTOCOL,
240
244
  createFetchOrchestrationTransport,
@@ -250,11 +254,11 @@ import {
250
254
  import {
251
255
  resolveAgentToolLoopTerminalState,
252
256
  runAgentToolLoopTurn
253
- } from "./chunk-K5KZJNDP.js";
257
+ } from "./chunk-ROPAEJIM.js";
254
258
  import {
255
259
  createFetchLLMProvider,
256
260
  resolveFetchLLMCallSettings
257
- } from "./chunk-HY3U3GLE.js";
261
+ } from "./chunk-5EUJNLVW.js";
258
262
  import {
259
263
  HookRegistry,
260
264
  MEMELOOP_STRUCTURED_TOOL_KEY,
@@ -308,7 +312,7 @@ import {
308
312
  shouldCompact,
309
313
  truncateToolSummary,
310
314
  unregisterHook
311
- } from "./chunk-LGUGYRR4.js";
315
+ } from "./chunk-HVLCOJWI.js";
312
316
  import {
313
317
  buildLegacyChatMessageParts,
314
318
  buildToolResultSummary,
@@ -779,12 +783,13 @@ function createFleetRolloutController(_store, options) {
779
783
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
780
784
  async function reconcileRollout(request) {
781
785
  const rollout = request.resource;
782
- const status = rollout.status ?? {};
786
+ const previousStatus = rollout.status;
787
+ const status = previousStatus?.observedGeneration !== void 0 && previousStatus.observedGeneration !== rollout.metadata.generation ? void 0 : previousStatus;
783
788
  const spec = rollout.spec;
784
- if (status.phase === "Completed" || status.phase === "Failed" || status.phase === "RolledBack") {
785
- return { ready: true };
789
+ if (status?.phase === "Completed" || status?.phase === "Failed" || status?.phase === "RolledBack") {
790
+ return status.observedGeneration === rollout.metadata.generation ? { ready: true } : { status, ready: true };
786
791
  }
787
- if (!status.phase) {
792
+ if (!status || status.phase === "Pending") {
788
793
  return {
789
794
  status: {
790
795
  ...status,
@@ -1119,6 +1124,7 @@ function createFleetRolloutController(_store, options) {
1119
1124
  if (result.status) {
1120
1125
  result.status = {
1121
1126
  ...result.status,
1127
+ observedGeneration: request.resource.metadata.generation,
1122
1128
  consumedBudget: sumEvidenceUsage(result.status.evidence)
1123
1129
  };
1124
1130
  }
@@ -3225,7 +3231,7 @@ async function describeLocalModelEndpoints(driver, options) {
3225
3231
  const modelClasses = [];
3226
3232
  const endpoints = [];
3227
3233
  for (const model of models) {
3228
- const baseName = sanitizeModelName(`${model.provider}-${model.model}`);
3234
+ const baseName = modelClassNameForSpec(model);
3229
3235
  modelClasses.push(createModelClassManifest(baseName, model));
3230
3236
  endpoints.push(createModelEndpointManifest(`${baseName}-${sanitizeModelName(options.nodeId)}`, {
3231
3237
  modelClassRef: { apiVersion: MODEL_CLASS_API_VERSION, kind: MODEL_CLASS_KIND, name: baseName },
@@ -5312,9 +5318,13 @@ function createGatewayMediatedLLMProvider(options) {
5312
5318
  const messages = Array.isArray(record.messages) ? record.messages : [];
5313
5319
  const runReference = options.runRefForRequest?.(request) ?? options.runRef;
5314
5320
  return (async function* () {
5315
- const handle = await options.broker.issueModelAccessHandle({
5321
+ const selectedModel = options.resolveModelForRequest?.(request) ?? {
5316
5322
  modelClassRef: options.modelClassRef,
5317
- ...options.modelDigest !== void 0 ? { modelDigest: options.modelDigest } : {},
5323
+ ...options.modelDigest !== void 0 ? { modelDigest: options.modelDigest } : {}
5324
+ };
5325
+ const handle = await options.broker.issueModelAccessHandle({
5326
+ modelClassRef: selectedModel.modelClassRef,
5327
+ ...selectedModel.modelDigest !== void 0 ? { modelDigest: selectedModel.modelDigest } : {},
5318
5328
  ...options.policyDigest !== void 0 ? { policyDigest: options.policyDigest } : {},
5319
5329
  ...runReference ? { runRef: runReference } : {},
5320
5330
  ...runReference && options.attempt !== void 0 ? { attempt: options.attempt } : {},
@@ -5325,12 +5335,18 @@ function createGatewayMediatedLLMProvider(options) {
5325
5335
  try {
5326
5336
  for await (const chunk of options.gateway.generate({
5327
5337
  callId,
5328
- modelClassRef: options.modelClassRef,
5329
- ...options.modelDigest !== void 0 ? { modelDigest: options.modelDigest } : {},
5338
+ modelClassRef: selectedModel.modelClassRef,
5339
+ ...selectedModel.modelDigest !== void 0 ? { modelDigest: selectedModel.modelDigest } : {},
5330
5340
  messages,
5341
+ ...typeof record.maxOutputTokens === "number" ? { maxOutputTokens: record.maxOutputTokens } : typeof record.max_tokens === "number" ? { maxOutputTokens: record.max_tokens } : {},
5342
+ ...typeof record.temperature === "number" ? { temperature: record.temperature } : {},
5343
+ ...typeof record.topP === "number" ? { topP: record.topP } : {},
5344
+ ...record.providerOptions !== null && typeof record.providerOptions === "object" ? {
5345
+ providerOptions: record.providerOptions
5346
+ } : {},
5331
5347
  accessHandle: handle.token,
5332
5348
  ...options.workerKey !== void 0 ? { workerKey: options.workerKey } : {},
5333
- ...record.signal !== void 0 ? { signal: record.signal } : {}
5349
+ ...record.abortSignal ?? record.signal ? { signal: record.abortSignal ?? record.signal } : {}
5334
5350
  })) {
5335
5351
  if (chunk.type === "delta" && chunk.delta !== void 0) {
5336
5352
  yield chunk.delta;
@@ -6019,7 +6035,7 @@ function createInProcessLoopRuntimeDriver(context, options = {}) {
6019
6035
  });
6020
6036
  }
6021
6037
  }
6022
- const { createAgentLoopRunner: createAgentLoopRunner2, createAgentLoopScriptRunner: createAgentLoopScriptRunner2 } = await import("./runtime-6EELHWVB.js");
6038
+ const { createAgentLoopRunner: createAgentLoopRunner2, createAgentLoopScriptRunner: createAgentLoopScriptRunner2 } = await import("./runtime-SASMRN4I.js");
6023
6039
  let runner = null;
6024
6040
  if (workload.spec.scriptReference) {
6025
6041
  if (!request.scriptSource) {
@@ -7768,6 +7784,16 @@ function createWorkerProtocolGateway(options) {
7768
7784
  const rateLimit = options.maxRequestsPerMinute ?? DEFAULT_RATE_PER_MINUTE2;
7769
7785
  const maxResponseBytes = options.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES;
7770
7786
  const requestLog = /* @__PURE__ */ new Map();
7787
+ let nextRequestLogSweepAt = 0;
7788
+ function pruneInactiveRequestLogs(windowStart, receivedAtMs) {
7789
+ if (receivedAtMs < nextRequestLogSweepAt) return;
7790
+ for (const [sessionName, timestamps] of requestLog) {
7791
+ if (timestamps.length === 0 || timestamps[timestamps.length - 1] < windowStart) {
7792
+ requestLog.delete(sessionName);
7793
+ }
7794
+ }
7795
+ nextRequestLogSweepAt = receivedAtMs + 6e4;
7796
+ }
7771
7797
  async function audit(request, accepted, receivedAt, code) {
7772
7798
  try {
7773
7799
  await options.onAudit?.({
@@ -7826,6 +7852,7 @@ function createWorkerProtocolGateway(options) {
7826
7852
  throw protocolError("CONFLICT", "worker request sequence or nonce was already consumed");
7827
7853
  }
7828
7854
  const windowStart = received.getTime() - 6e4;
7855
+ pruneInactiveRequestLogs(windowStart, received.getTime());
7829
7856
  const log = (requestLog.get(session.name) ?? []).filter((time) => time >= windowStart);
7830
7857
  if (log.length >= rateLimit) {
7831
7858
  throw new OrchestrationError({
@@ -11656,39 +11683,6 @@ function defineTool(definition) {
11656
11683
  };
11657
11684
  }
11658
11685
 
11659
- // src/tools/hostAgentTools.ts
11660
- function isPluginConfig(value) {
11661
- return typeof value === "object" && value !== null;
11662
- }
11663
- function mergeAgentToolsIntoFrameworkConfig(frameworkConfig, agentTools) {
11664
- const baseConfig = { ...frameworkConfig ?? {} };
11665
- const rawPlugins = Array.isArray(baseConfig.plugins) ? baseConfig.plugins : [];
11666
- const pluginByToolId = /* @__PURE__ */ new Map();
11667
- const pluginWithoutToolId = [];
11668
- for (const plugin of rawPlugins) {
11669
- if (isPluginConfig(plugin) && typeof plugin.toolId === "string" && plugin.toolId.length > 0) {
11670
- pluginByToolId.set(plugin.toolId, plugin);
11671
- } else {
11672
- pluginWithoutToolId.push(plugin);
11673
- }
11674
- }
11675
- for (const tool of agentTools ?? []) {
11676
- if (!tool.toolId) continue;
11677
- pluginByToolId.set(tool.toolId, {
11678
- id: `${tool.toolId}-agent-tool`,
11679
- toolId: tool.toolId,
11680
- enabled: tool.enabled ?? true,
11681
- ...tool.parameters ?? {}
11682
- });
11683
- }
11684
- return {
11685
- ...baseConfig,
11686
- prompts: Array.isArray(baseConfig.prompts) ? baseConfig.prompts : [],
11687
- response: Array.isArray(baseConfig.response) ? baseConfig.response : void 0,
11688
- plugins: [...pluginWithoutToolId, ...pluginByToolId.values()]
11689
- };
11690
- }
11691
-
11692
11686
  // src/tools/toolRegistry.ts
11693
11687
  var ToolDefinitionRegistry = class {
11694
11688
  registry = /* @__PURE__ */ new Map();
@@ -12168,6 +12162,7 @@ export {
12168
12162
  mcpForwardImpl,
12169
12163
  mergeAgentToolsIntoFrameworkConfig,
12170
12164
  mergePermissionSets,
12165
+ modelClassNameForSpec,
12171
12166
  negotiateCapabilities,
12172
12167
  normalizeScript,
12173
12168
  onApprovalRequest,