pi2dsh 0.14.0 → 0.14.1

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/host.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { r as registerVisionCompanions, t as applyPiPackage } from "./runtime-Bb9Bfk4M.mjs";
2
+ import { r as registerVisionCompanions, t as applyPiPackage } from "./runtime-BiD3SeGf.mjs";
3
3
  import { t as resolvePiPackage } from "./source-0sA5z08z.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { readFile } from "node:fs/promises";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { r as registerVisionCompanions } from "./runtime-Bb9Bfk4M.mjs";
2
+ import { r as registerVisionCompanions } from "./runtime-BiD3SeGf.mjs";
3
3
  import { t as resolvePiPackage } from "./source-0sA5z08z.mjs";
4
4
  import { applyPiHost, applyPreparedPiHost, manifestForInstalled, preparePiHost } from "./host.mjs";
5
5
  import { a as PI_AI_PACKAGES, c as UI_CONTEXT_RULES, d as ruleForEvent, f as ruleForHostImport, i as HOST_IMPORT_RULES, l as ruleForApi, n as CONTEXT_RULES, o as PI_CODING_AGENT_PACKAGES, p as ruleForUiContextProperty, r as EVENT_RULES, s as PI_TUI_PACKAGES, t as API_RULES, u as ruleForContextProperty } from "./compatibility-CP2tpyhg.mjs";
@@ -4025,9 +4025,7 @@ function subscribeLifecycle(ctx, state) {
4025
4025
  }
4026
4026
  }
4027
4027
  });
4028
- cordis.on("session/event", (session, event) => {
4029
- const ownedSession = agentSession(state.ownerAgent);
4030
- if (ownedSession !== void 0 ? session !== ownedSession : isSubagentOrigin(session)) return;
4028
+ const projectSessionEvent = (session, event) => {
4031
4029
  const agent = [...state.activeAgents].find((candidate) => candidate.session === session);
4032
4030
  const eventContext = contextFor(ctx, state, agent, void 0);
4033
4031
  const type = event.type;
@@ -4174,6 +4172,14 @@ function subscribeLifecycle(ctx, state) {
4174
4172
  }, eventContext);
4175
4173
  await dispatch(state, "agent_settled", { type: "agent_settled" }, eventContext);
4176
4174
  }).catch((error) => warn("turn end lifecycle", error));
4175
+ };
4176
+ state.projectSessionEvent = projectSessionEvent;
4177
+ cordis.on("session/event", (session, event) => {
4178
+ if (state.hostAnchor) return;
4179
+ const ownedSession = agentSession(state.ownerAgent);
4180
+ if (ownedSession !== void 0 ? session !== ownedSession : isSubagentOrigin(session)) return;
4181
+ if (ownedSession !== void 0 && state.sessionEventsLive !== true) return;
4182
+ projectSessionEvent(session, event);
4177
4183
  });
4178
4184
  cordis.on("agent/request", async (payload, next) => {
4179
4185
  const config = await next();
@@ -4226,6 +4232,22 @@ async function flushPendingSessionStarts(ctx, state) {
4226
4232
  const pending = [...state.pendingSessionStarts];
4227
4233
  state.pendingSessionStarts.clear();
4228
4234
  for (const [agent, reason] of pending) await startPiSession(ctx, state, agent, reason, void 0);
4235
+ if (state.ownerAgent !== void 0 && state.projectSessionEvent !== void 0) {
4236
+ const session = agentSession(state.ownerAgent);
4237
+ if (session !== void 0) {
4238
+ const events = session.events ?? [];
4239
+ let from = -1;
4240
+ for (let index = events.length - 1; index >= 0; index -= 1) {
4241
+ if (events[index].type === "turn/end") break;
4242
+ if (events[index].type === "turn/start") {
4243
+ from = index;
4244
+ break;
4245
+ }
4246
+ }
4247
+ if (from >= 0) for (let index = from; index < events.length; index += 1) state.projectSessionEvent(session, events[index]);
4248
+ }
4249
+ state.sessionEventsLive = true;
4250
+ }
4229
4251
  }
4230
4252
  /**
4231
4253
  * Start freshly reloaded extension handlers in every live Pi host session.
@@ -6082,4 +6104,4 @@ const runtimeInternals = {
6082
6104
  //#endregion
6083
6105
  export { runtimeInternals as i, normalizeToolSchema as n, registerVisionCompanions as r, applyPiPackage as t };
6084
6106
 
6085
- //# sourceMappingURL=runtime-Bb9Bfk4M.mjs.map
6107
+ //# sourceMappingURL=runtime-BiD3SeGf.mjs.map