@averyyy/pi-coding-agent 1.0.0-piclient.1 → 1.0.0-piclient.2

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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bundle/chunks/{anthropic-messages-UID2PALB.js → anthropic-messages-5Z4I6I54.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-WK37QQ3X.js → azure-openai-responses-TXH53UDQ.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-2LGHNI5Y.js → chunk-43NAB75E.js} +20 -20
  5. package/dist/bundle/chunks/{chunk-Z772OFUN.js → chunk-4ILNOXGR.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-SQXKOUF6.js → chunk-AV6LYFGH.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-7JGR3GZN.js → chunk-F42GKQ7R.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-CWVWZD3J.js → chunk-JTLRGL3E.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-OSKPX3Z5.js → chunk-PXGUCLIP.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-6D7LHLKG.js → chunk-WGS2XTDX.js} +1 -1
  11. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-NPQN263E.js → cloudflare-workers-ai-system-one-TF36V7KG.js} +1 -1
  12. package/dist/bundle/chunks/{google-generative-ai-OHRSHIE7.js → google-generative-ai-XQU2LTWM.js} +1 -1
  13. package/dist/bundle/chunks/{google-vertex-KXEB3MVO.js → google-vertex-F6Q2CN55.js} +1 -1
  14. package/dist/bundle/chunks/{mistral-conversations-DKVFNQL6.js → mistral-conversations-XAJWHQFR.js} +1 -1
  15. package/dist/bundle/chunks/{openai-codex-responses-WVERB76N.js → openai-codex-responses-3EHOMZYM.js} +1 -1
  16. package/dist/bundle/chunks/{openai-completions-JXDDPZ23.js → openai-completions-QC2IQHSC.js} +1 -1
  17. package/dist/bundle/chunks/{openai-responses-WDT74L23.js → openai-responses-JPLD2GJS.js} +1 -1
  18. package/dist/bundle/chunks/{typesafe-system-one-A4CZTQWZ.js → typesafe-system-one-7DJTDUKY.js} +1 -1
  19. package/dist/bundle/chunks/{virtual-modules-XLXFDFIX.js → virtual-modules-X5AB6TM6.js} +1 -1
  20. package/dist/bundle/cli-runtime.js +1 -1
  21. package/dist/bundle/index.js +1 -1
  22. package/dist/bundle/rpc-entry.js +1 -1
  23. package/dist/core/agent-session.d.ts.map +1 -1
  24. package/dist/core/agent-session.js +29 -2
  25. package/dist/core/agent-session.js.map +1 -1
  26. package/dist/core/cache-warmer.d.ts.map +1 -1
  27. package/dist/core/cache-warmer.js +11 -3
  28. package/dist/core/cache-warmer.js.map +1 -1
  29. package/dist/core/model-resolver.js +1 -1
  30. package/dist/core/model-resolver.js.map +1 -1
  31. package/dist/core/model-runtime.d.ts +16 -0
  32. package/dist/core/model-runtime.d.ts.map +1 -1
  33. package/dist/core/model-runtime.js +325 -31
  34. package/dist/core/model-runtime.js.map +1 -1
  35. package/dist/core/pi-server-client.d.ts +21 -1
  36. package/dist/core/pi-server-client.d.ts.map +1 -1
  37. package/dist/core/pi-server-client.js +308 -22
  38. package/dist/core/pi-server-client.js.map +1 -1
  39. package/dist/core/pi-server-protocol.d.ts +12 -1
  40. package/dist/core/pi-server-protocol.d.ts.map +1 -1
  41. package/dist/core/pi-server-protocol.js +1 -0
  42. package/dist/core/pi-server-protocol.js.map +1 -1
  43. package/dist/core/sdk.d.ts.map +1 -1
  44. package/dist/core/sdk.js +51 -18
  45. package/dist/core/sdk.js.map +1 -1
  46. package/dist/main.d.ts.map +1 -1
  47. package/dist/main.js +24 -17
  48. package/dist/main.js.map +1 -1
  49. package/package.json +4 -4
@@ -344,6 +344,8 @@ export class AgentSession {
344
344
  env: result.env,
345
345
  };
346
346
  }
347
+ if (isPiServerMode())
348
+ return { model };
347
349
  const isOAuth = this._modelRuntime.isUsingOAuth(model.provider);
348
350
  if (isOAuth) {
349
351
  throw new Error(`Authentication failed for "${model.provider}". ` +
@@ -361,7 +363,7 @@ export class AgentSession {
361
363
  signal,
362
364
  })
363
365
  : { model: selectedModel, thinkingLevel: this.thinkingLevel };
364
- if (this.agent.streamFunction === streamSimple) {
366
+ if (isPiServerMode() || this.agent.streamFunction === streamSimple) {
365
367
  return { ...(await this._getRequiredRequestAuth(model, signal)), thinkingLevel };
366
368
  }
367
369
  try {
@@ -2316,6 +2318,7 @@ export class AgentSession {
2316
2318
  return this._abortPromise;
2317
2319
  }
2318
2320
  if (this._isAborting) {
2321
+ this._continueAfterAbortRequested ||= this.agent.hasQueuedMessages();
2319
2322
  this._abortError = undefined;
2320
2323
  }
2321
2324
  else {
@@ -2352,7 +2355,10 @@ export class AgentSession {
2352
2355
  * @throws Error if no auth is configured for the model
2353
2356
  */
2354
2357
  async setModel(model, options = {}) {
2355
- if (!(await this._modelRuntime.checkAuth(model.provider))) {
2358
+ const hasAuth = isPiServerMode()
2359
+ ? this._modelRuntime.hasConfiguredAuth(model.provider)
2360
+ : await this._modelRuntime.checkAuth(model.provider);
2361
+ if (!hasAuth) {
2356
2362
  throw new Error(`No API key for ${model.provider}/${model.id}`);
2357
2363
  }
2358
2364
  if (this.isStreaming) {
@@ -2968,6 +2974,7 @@ export class AgentSession {
2968
2974
  let started = false;
2969
2975
  let fromExtension = false;
2970
2976
  let cancelledByExtension = false;
2977
+ let warmCancellationPending = false;
2971
2978
  if (externalSignal?.aborted)
2972
2979
  return false;
2973
2980
  const abortExternal = () => abortController?.abort();
@@ -2976,12 +2983,21 @@ export class AgentSession {
2976
2983
  if (!model) {
2977
2984
  return false;
2978
2985
  }
2986
+ this._cacheWarmer?.cancel();
2979
2987
  if (isPiServerMode()) {
2980
2988
  abortController = new AbortController();
2981
2989
  this._autoCompactionAbortController = abortController;
2982
2990
  started = true;
2983
2991
  this._emit({ type: "compaction_start", reason });
2984
2992
  abortController.signal.throwIfAborted();
2993
+ if (this._cacheWarmer) {
2994
+ // A warm replay can update static context. Confirm its remote cancellation
2995
+ // before compaction captures the session revision and synchronizes the tree.
2996
+ warmCancellationPending = true;
2997
+ await cancelPiServerOperations(this.sessionId);
2998
+ warmCancellationPending = false;
2999
+ abortController.signal.throwIfAborted();
3000
+ }
2985
3001
  const { model: requestModel, apiKey, headers, thinkingLevel, } = await this._getSummarizationRequestAuth(model, abortController.signal);
2986
3002
  abortController.signal.throwIfAborted();
2987
3003
  const cacheInput = await this._buildCompactionCacheInput(requestModel);
@@ -3142,6 +3158,17 @@ export class AgentSession {
3142
3158
  fromExtension,
3143
3159
  });
3144
3160
  }
3161
+ if (warmCancellationPending) {
3162
+ // Agent core records thrown preparation failures as assistant errors.
3163
+ // Keep unconfirmed cancellation terminal until an explicit abort retry.
3164
+ this._agentRunAbortRequested = true;
3165
+ this._isAborting = true;
3166
+ this._continueAfterAbortRequested ||= this.agent.hasQueuedMessages();
3167
+ this._abortError = message;
3168
+ this._abortPromise = undefined;
3169
+ this._emit({ type: "abort_error", errorMessage: message });
3170
+ throw error;
3171
+ }
3145
3172
  return false;
3146
3173
  }
3147
3174
  finally {