stratagate-dsh 0.3.47 → 0.3.49

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/plugin.js CHANGED
@@ -14099,6 +14099,10 @@ var StrataGateRuntime = class _StrataGateRuntime {
14099
14099
  derivationTimers = /* @__PURE__ */ new Map();
14100
14100
  derivationRuns = /* @__PURE__ */ new Map();
14101
14101
  knownSessions = /* @__PURE__ */ new Map();
14102
+ // The agent loop claims a turn's Inbox message before assembling the system
14103
+ // prompt, and only appends that message to the session after assembly. Keep
14104
+ // the claimed user text available for this request-path retrieval window.
14105
+ pendingUserInputs = /* @__PURE__ */ new WeakMap();
14102
14106
  pendingSurfaceSync = /* @__PURE__ */ new Map();
14103
14107
  surfaceMaintenance = /* @__PURE__ */ new Map();
14104
14108
  surfaceMaintenanceRuns = /* @__PURE__ */ new Set();
@@ -15192,14 +15196,28 @@ var StrataGateRuntime = class _StrataGateRuntime {
15192
15196
  if (state?.session === session) this.scheduleSurfaceMaintenance(state);
15193
15197
  }
15194
15198
  }
15199
+ /**
15200
+ * Capture a user message at the Inbox-claimed boundary. The host appends the
15201
+ * same message to the session immediately after system-prompt assembly, so
15202
+ * this bridge makes first-request automatic recall see the input without
15203
+ * changing the durable session ordering.
15204
+ */
15205
+ noteClaimedUserMessage(session, content) {
15206
+ const text3 = renderBlocks(content).trim();
15207
+ const pending = this.pendingUserInputs.get(session);
15208
+ if (pending) pending.push(text3);
15209
+ else this.pendingUserInputs.set(session, [text3]);
15210
+ }
15195
15211
  async assembleAutoContext(session) {
15212
+ const pendingUserInputs = this.pendingUserInputs.get(session);
15213
+ this.pendingUserInputs.delete(session);
15196
15214
  await this.flush();
15197
15215
  const memory = await this.space(session);
15198
15216
  await this.refreshExternalImportMemory(this.namespaceFor(session), memory);
15199
15217
  const threadId = String(session.id);
15200
15218
  await this.syncRequestSurface(session, memory);
15201
15219
  const openTail = memory.listOpenTail(threadId);
15202
- const activationQuery = [currentUserMessage(session), renderMessages(recentTurns(openTail, 2))].filter(Boolean).join("\n\n");
15220
+ const activationQuery = [pendingUserInputs?.join("\n\n") ?? currentUserMessage(session), renderMessages(recentTurns(openTail, 2))].filter(Boolean).join("\n\n");
15203
15221
  const vectorRanking = activationQuery ? await this.computeVectorRanking(memory, activationQuery) : void 0;
15204
15222
  const eventHits = activationQuery ? await memory.searchEvents(activationQuery, {
15205
15223
  limit: 20,
@@ -21363,6 +21381,10 @@ async function apply(ctx, config) {
21363
21381
  }
21364
21382
  });
21365
21383
  ctx.systemPrompt.section({ name: "tool:stratagate-memory", order: 113, text: () => runtime.graphEnabled ? memoryProtocol(runtime.dailyNotesEnabled, runtime.dailyNotes.injectionDays) : memoryProtocol(runtime.dailyNotesEnabled, runtime.dailyNotes.injectionDays).split("\n").map((line) => line.includes("Use memory_search_events for what happened") ? "- Use memory_search_events to retrieve durable facts and changes. Knowledge Graph is disabled." : line.replaceAll("Event/Graph", "Event").replaceAll("Event or Graph", "Event").replaceAll(", Graph node,", ",")).join("\n") });
21384
+ ctx.on("agent/inbox/claimed", ({ agent, message }) => {
21385
+ if (message.source.kind !== "user") return;
21386
+ runtime.noteClaimedUserMessage(agent.session, message.content);
21387
+ });
21366
21388
  if (AGENT_FEEDBACK_ENABLED) ctx.systemPrompt.section({ name: "tool:stratagate-feedback", order: 114, text: FEEDBACK_PROTOCOL });
21367
21389
  ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
21368
21390
  const assembled = await next();