@averyyy/pi-coding-agent 1.3.0-piclient.3 → 1.3.0-piclient.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 (50) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/bundle/chunks/{anthropic-messages-VGILSZE4.js → anthropic-messages-JKZEYO3X.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-RQ4TCY4V.js → azure-openai-responses-CALHHRO4.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-S7GW7ZCV.js → chunk-2TBKESBE.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-VWVP4RBU.js → chunk-3IAHLZM6.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-QRZH73DC.js → chunk-6AK3I2ZG.js} +18 -16
  7. package/dist/bundle/chunks/{chunk-NB2YR6RG.js → chunk-A5PVA2BG.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-SWXCGFWB.js → chunk-KO7M2ZFM.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-S2W5KTDO.js → chunk-NAPMJL5U.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-MPZ232UI.js → chunk-WEGEKOLF.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-TOASJ3OW.js → chunk-XIQJS2WK.js} +1 -1
  12. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-PET7FI2G.js → cloudflare-workers-ai-system-one-W3JVUOXV.js} +1 -1
  13. package/dist/bundle/chunks/github-copilot.js +1 -1
  14. package/dist/bundle/chunks/{google-generative-ai-ZFNZ3LG6.js → google-generative-ai-4YEPBKDH.js} +1 -1
  15. package/dist/bundle/chunks/{google-vertex-UC7CFP4J.js → google-vertex-5HD3H47T.js} +1 -1
  16. package/dist/bundle/chunks/{mistral-conversations-KZROP3MF.js → mistral-conversations-IDNVOMLP.js} +1 -1
  17. package/dist/bundle/chunks/{openai-codex-responses-2CXWT4CB.js → openai-codex-responses-TWAB375R.js} +1 -1
  18. package/dist/bundle/chunks/{openai-completions-WV22DQI3.js → openai-completions-3LCSEI2J.js} +1 -1
  19. package/dist/bundle/chunks/{openai-decisions-BL7TXE4H.js → openai-decisions-CWANEVXX.js} +1 -1
  20. package/dist/bundle/chunks/{openai-responses-4SZGS7GF.js → openai-responses-JEQACBMR.js} +1 -1
  21. package/dist/bundle/chunks/{typesafe-system-one-KIQLTPSL.js → typesafe-system-one-JJVDHYHL.js} +1 -1
  22. package/dist/bundle/chunks/{virtual-modules-NPAAMEVD.js → virtual-modules-2YGWEC7J.js} +1 -1
  23. package/dist/bundle/cli-runtime.js +1 -1
  24. package/dist/bundle/index.js +1 -1
  25. package/dist/bundle/rpc-entry.js +1 -1
  26. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  27. package/dist/core/agent-session-runtime.js +3 -0
  28. package/dist/core/agent-session-runtime.js.map +1 -1
  29. package/dist/core/agent-session.d.ts +11 -0
  30. package/dist/core/agent-session.d.ts.map +1 -1
  31. package/dist/core/agent-session.js +48 -18
  32. package/dist/core/agent-session.js.map +1 -1
  33. package/dist/core/model-resolver.d.ts +4 -0
  34. package/dist/core/model-resolver.d.ts.map +1 -1
  35. package/dist/core/model-resolver.js +9 -1
  36. package/dist/core/model-resolver.js.map +1 -1
  37. package/dist/core/pi-server-observer.d.ts +93 -0
  38. package/dist/core/pi-server-observer.d.ts.map +1 -0
  39. package/dist/core/pi-server-observer.js +452 -0
  40. package/dist/core/pi-server-observer.js.map +1 -0
  41. package/dist/core/sdk.d.ts.map +1 -1
  42. package/dist/core/sdk.js +3 -0
  43. package/dist/core/sdk.js.map +1 -1
  44. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  45. package/dist/modes/interactive/components/model-selector.js +8 -10
  46. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  47. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  48. package/dist/modes/interactive/interactive-mode.js +36 -13
  49. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  50. package/package.json +4 -4
@@ -35,6 +35,7 @@ import { emitSessionShutdownEvent } from "./extensions/runner.js";
35
35
  import { createToolNameMatcher, isMcpToolName } from "./mcp-servers.js";
36
36
  import { convertToLlm } from "./messages.js";
37
37
  import { ModelRegistry } from "./model-registry.js";
38
+ import { getAvailableScopedModels } from "./model-resolver.js";
38
39
  import { NestedToolCallRunner } from "./nested-tool-calls.js";
39
40
  import { cancelPiServerOperations, compactPiServer, hashStaticContext, } from "./pi-server-client.js";
40
41
  import { hashPiServerProviderMessages } from "./pi-server-protocol.js";
@@ -819,9 +820,15 @@ export class AgentSession {
819
820
  this._resolveIdleWait = undefined;
820
821
  resolve();
821
822
  }
823
+ _setAgentRunActive(running) {
824
+ if (this._isAgentRunActive === running)
825
+ return;
826
+ this._isAgentRunActive = running;
827
+ this._emit({ type: "run_state_changed", running });
828
+ }
822
829
  async _emitAgentSettled() {
823
830
  this._cacheWarmer?.onAgentSettled();
824
- this._isAgentRunActive = false;
831
+ this._setAgentRunActive(false);
825
832
  this._isEmittingAgentSettled = true;
826
833
  try {
827
834
  const aborted = this._agentRunAbortRequested;
@@ -905,8 +912,12 @@ export class AgentSession {
905
912
  // Regular LLM message - persist as SessionMessageEntry
906
913
  entryId = this.sessionManager.appendMessage(event.message);
907
914
  }
908
- if (entryId)
915
+ if (entryId) {
909
916
  this._entryIdsByMessage.set(event.message, entryId);
917
+ const entry = this.sessionManager.getEntry(entryId);
918
+ if (entry)
919
+ this._emit({ type: "message_committed", entry });
920
+ }
910
921
  // Other message types (bashExecution, compactionSummary, branchSummary) are persisted elsewhere
911
922
  if (event.message.role === "assistant") {
912
923
  const assistantMsg = event.message;
@@ -1050,6 +1061,7 @@ export class AgentSession {
1050
1061
  this.sessionManager.resetLeaf();
1051
1062
  }
1052
1063
  this._refreshFinalizedContext();
1064
+ this._emit({ type: "session_tree_changed" });
1053
1065
  return;
1054
1066
  }
1055
1067
  // Preserve metadata after the failed attempt. The canonical projection can
@@ -1086,6 +1098,7 @@ export class AgentSession {
1086
1098
  }
1087
1099
  const sessionContext = this.sessionManager.buildSessionContext();
1088
1100
  this.agent.state.messages = sessionContext.messages;
1101
+ this._emit({ type: "session_tree_changed" });
1089
1102
  }
1090
1103
  _replaceMessageInPlace(target, replacement) {
1091
1104
  // Agent-core stores the finalized message object in its state before emitting message_end.
@@ -1216,6 +1229,7 @@ export class AgentSession {
1216
1229
  * Call this when completely done with the session.
1217
1230
  */
1218
1231
  dispose() {
1232
+ this._emit({ type: "session_disposed" });
1219
1233
  try {
1220
1234
  this.abortRetry();
1221
1235
  this.abortCompaction();
@@ -1241,6 +1255,7 @@ export class AgentSession {
1241
1255
  /** Refresh the public finalized transcript from the canonical session projection. */
1242
1256
  refreshContext() {
1243
1257
  this._refreshFinalizedContext();
1258
+ this._emit({ type: "session_tree_changed" });
1244
1259
  }
1245
1260
  /** Full agent state */
1246
1261
  get state() {
@@ -1622,7 +1637,7 @@ export class AgentSession {
1622
1637
  * @param onStarted Called once the run's messages are prepared, before the first request.
1623
1638
  */
1624
1639
  async _startRun(trigger, onStarted) {
1625
- this._isAgentRunActive = true;
1640
+ this._setAgentRunActive(true);
1626
1641
  this._agentRunAbortRequested = false;
1627
1642
  let messages;
1628
1643
  this._isPreparingRun = true;
@@ -1630,7 +1645,7 @@ export class AgentSession {
1630
1645
  messages = await this._prepareRun(trigger);
1631
1646
  }
1632
1647
  catch (error) {
1633
- this._isAgentRunActive = false;
1648
+ this._setAgentRunActive(false);
1634
1649
  this._flushPendingBashMessages();
1635
1650
  this._flushPendingCustomMessages();
1636
1651
  this._resolveIdleWaitIfIdle();
@@ -1645,23 +1660,29 @@ export class AgentSession {
1645
1660
  this._flushPendingCustomMessages();
1646
1661
  if (!messages) {
1647
1662
  // Aborted during pre-run compaction: no run was started.
1648
- this._isAgentRunActive = false;
1663
+ this._setAgentRunActive(false);
1649
1664
  this._resolveIdleWaitIfIdle();
1650
1665
  return;
1651
1666
  }
1652
- onStarted?.();
1653
- const startMessages = messages;
1654
- await this._runAgentOperation(() => this.agent.prompt(startMessages));
1667
+ try {
1668
+ onStarted?.();
1669
+ const startMessages = messages;
1670
+ await this._runAgentOperation(() => this.agent.prompt(startMessages));
1671
+ }
1672
+ catch (error) {
1673
+ this._setAgentRunActive(false);
1674
+ throw error;
1675
+ }
1655
1676
  }
1656
1677
  async _runAgentOperation(start) {
1657
1678
  // Compaction before the prompt may have scheduled a retry; the new prompt replaces it.
1658
1679
  this._failedResponse = undefined;
1659
- this._recordSelection();
1660
- // The run records the loadout in the transcript; restored tools that did not register by now
1661
- // are dropped, so a tool that never registers does not stay pending.
1662
- this._pendingToolNames.clear();
1663
- this._isAgentRunActive = true;
1680
+ this._setAgentRunActive(true);
1664
1681
  try {
1682
+ this._recordSelection();
1683
+ // The run records the loadout in the transcript; restored tools that did not register by now
1684
+ // are dropped, so a tool that never registers does not stay pending.
1685
+ this._pendingToolNames.clear();
1665
1686
  await start();
1666
1687
  while (!this._agentRunAbortRequested) {
1667
1688
  const shouldContinue = await this._handlePostAgentRun();
@@ -2240,10 +2261,13 @@ export class AgentSession {
2240
2261
  }
2241
2262
  }
2242
2263
  _appendCustomMessage(appMessage) {
2243
- this.sessionManager.appendCustomMessageEntry(appMessage.customType, appMessage.content, appMessage.display, appMessage.details);
2264
+ const entryId = this.sessionManager.appendCustomMessageEntry(appMessage.customType, appMessage.content, appMessage.display, appMessage.details);
2244
2265
  this._refreshFinalizedContext();
2245
2266
  this._emit({ type: "message_start", message: appMessage });
2246
2267
  this._emit({ type: "message_end", message: appMessage });
2268
+ const entry = this.sessionManager.getEntry(entryId);
2269
+ if (entry)
2270
+ this._emit({ type: "message_committed", entry });
2247
2271
  }
2248
2272
  /**
2249
2273
  * Append custom messages queued while the agent was running.
@@ -2490,8 +2514,7 @@ export class AgentSession {
2490
2514
  return this._cycleAvailableModel(direction, options);
2491
2515
  }
2492
2516
  async _cycleScopedModel(direction, options) {
2493
- const availableIds = new Set(this._modelRuntime.getAvailableSnapshot().map((model) => `${model.provider}\0${model.id}`));
2494
- const scopedModels = this._scopedModels.filter((scoped) => availableIds.has(`${scoped.model.provider}\0${scoped.model.id}`));
2517
+ const scopedModels = getAvailableScopedModels(this._scopedModels, this._modelRuntime.getAvailableSnapshot());
2495
2518
  if (scopedModels.length <= 1)
2496
2519
  return undefined;
2497
2520
  const currentModel = this.model;
@@ -3926,8 +3949,11 @@ export class AgentSession {
3926
3949
  this._pendingBashMessages.push(bashMessage);
3927
3950
  }
3928
3951
  else {
3929
- this.sessionManager.appendMessage(bashMessage);
3952
+ const entryId = this.sessionManager.appendMessage(bashMessage);
3930
3953
  this._refreshFinalizedContext();
3954
+ const entry = this.sessionManager.getEntry(entryId);
3955
+ if (entry)
3956
+ this._emit({ type: "message_committed", entry });
3931
3957
  }
3932
3958
  }
3933
3959
  /**
@@ -3954,7 +3980,10 @@ export class AgentSession {
3954
3980
  if (this._pendingBashMessages.length === 0)
3955
3981
  return;
3956
3982
  for (const bashMessage of this._pendingBashMessages) {
3957
- this.sessionManager.appendMessage(bashMessage);
3983
+ const entryId = this.sessionManager.appendMessage(bashMessage);
3984
+ const entry = this.sessionManager.getEntry(entryId);
3985
+ if (entry)
3986
+ this._emit({ type: "message_committed", entry });
3958
3987
  }
3959
3988
  this._pendingBashMessages = [];
3960
3989
  this._refreshFinalizedContext();
@@ -4135,6 +4164,7 @@ export class AgentSession {
4135
4164
  // Update finalized context from the canonical session projection.
4136
4165
  this._refreshFinalizedContext();
4137
4166
  this._restoreToolsFromTranscript();
4167
+ this._emit({ type: "session_tree_changed" });
4138
4168
  // Emit session_tree event
4139
4169
  await this._extensionRunner.emit({
4140
4170
  type: "session_tree",