@livx.cc/agentx 0.99.13 → 0.99.14

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-DYMSg21f.js';
2
- export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-DYMSg21f.js';
1
+ import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-CsVuR2O0.js';
2
+ export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-CsVuR2O0.js';
3
3
  export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, modelShortLabel, resolveModelAlias, resolveModelSwitch } from './models.js';
4
4
  import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
5
5
  export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
package/dist/index.js CHANGED
@@ -3280,7 +3280,34 @@ var AgentOptions = class {
3280
3280
  * `'off'`/undefined = none; `'low'|'medium'|'high'` or a raw token budget. Mapped to the
3281
3281
  * provider-specific request shape via {@link reasoningToChatFragment}; explicit `providerOptions` wins. */
3282
3282
  reasoning;
3283
+ /** Seed a fresh `run()` with prior conversation turns (real role/content messages) so the model
3284
+ * sees history as structured turns instead of a flattened text blob. They are inserted AFTER the
3285
+ * stable system prompt and BEFORE the current user turn — so the cached system(+tools) prefix never
3286
+ * shifts. Turns are normalized before sending (empties dropped, adjacent same-role coalesced, and the
3287
+ * first tail turn forced to `user`) so the transcript is always a valid Anthropic alternation ending
3288
+ * at the current user prompt. Unset/empty ⇒ current behavior, byte-for-byte. */
3289
+ priorMessages;
3283
3290
  };
3291
+ function seedTranscriptTail(prior, current) {
3292
+ const seq = (prior ?? []).filter((m) => contentText(m.content).trim().length > 0).map((m) => ({ role: m.role, content: m.content }));
3293
+ seq.push({ role: "user", content: current });
3294
+ const out = [];
3295
+ for (const m of seq) {
3296
+ const last = out[out.length - 1];
3297
+ if (last && last.role === m.role) {
3298
+ if (typeof last.content === "string" && typeof m.content === "string") {
3299
+ last.content = `${last.content}
3300
+
3301
+ ${m.content}`;
3302
+ continue;
3303
+ }
3304
+ out.push({ role: m.role === "user" ? "assistant" : "user", content: "(continuing)" });
3305
+ }
3306
+ out.push({ role: m.role, content: m.content });
3307
+ }
3308
+ if (out.length && out[0].role !== "user") out.unshift({ role: "user", content: "(Earlier conversation)" });
3309
+ return out;
3310
+ }
3284
3311
  var Agent = class _Agent {
3285
3312
  options;
3286
3313
  transcript = [];
@@ -3448,7 +3475,9 @@ var Agent = class _Agent {
3448
3475
  const userContent = await this.applyPromptSubmit(task);
3449
3476
  this.transcript = [
3450
3477
  { role: "system", content: systemPrompt + (startCtx ? "\n\n" + startCtx : "") },
3451
- { role: "user", content: userContent }
3478
+ // Prior turns (if any) sit between the stable system prefix and the live user turn — the cached
3479
+ // system(+tools) prefix is unaffected; normalization keeps the alternation valid.
3480
+ ...seedTranscriptTail(this.options.priorMessages, userContent)
3452
3481
  ];
3453
3482
  return this.runLoop();
3454
3483
  }