@parcha/agentrun-harness-claude 0.1.0-beta.31 → 0.1.0-beta.33

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.
@@ -34,6 +34,10 @@ export interface TurnEnd {
34
34
  */
35
35
  consumed?: string[];
36
36
  sessionId?: string;
37
+ /** The turn's final answer was cut at the model's output limit (`stop_reason` max_tokens on its result): the CLI's
38
+ * own recovery of it was spent. With the turn's output tokens, as its result reports them. */
39
+ stopReason?: 'length';
40
+ outputTokens?: number;
37
41
  }
38
42
  type SdkMessage = {
39
43
  type: string;
@@ -50,6 +54,9 @@ export declare class TranscriptBuilder {
50
54
  private readonly asked;
51
55
  /** Calls that reached the session's tool server (`beforeCall`): their error, whatever its text, is theirs, not a refusal. */
52
56
  private readonly bridged;
57
+ /** The model's last message was cut at its output limit, and the turn has not ended: the CLI resumes it itself, so the
58
+ * next text the model says is a message of its own (`text_end` before it). */
59
+ private cutPending;
53
60
  constructor(sink: TranscriptSink);
54
61
  /** One message from `query()`. Returns how the turn ended for a `result`. */
55
62
  observe(m: SdkMessage): TurnEnd | undefined;
@@ -57,7 +64,7 @@ export declare class TranscriptBuilder {
57
64
  * Write the turn's last text and its end. Called at each `result`, or with
58
65
  * `interrupted` when the drive stops a turn it cannot finish.
59
66
  */
60
- endTurn(end: Pick<TurnEnd, 'status' | 'error'> | {
67
+ endTurn(end: Pick<TurnEnd, 'status' | 'error' | 'stopReason' | 'outputTokens'> | {
61
68
  status: 'interrupted';
62
69
  error?: string;
63
70
  }): void;
@@ -14,6 +14,9 @@ export class TranscriptBuilder {
14
14
  asked = new Map();
15
15
  /** Calls that reached the session's tool server (`beforeCall`): their error, whatever its text, is theirs, not a refusal. */
16
16
  bridged = new Set();
17
+ /** The model's last message was cut at its output limit, and the turn has not ended: the CLI resumes it itself, so the
18
+ * next text the model says is a message of its own (`text_end` before it). */
19
+ cutPending = false;
17
20
  constructor(sink) {
18
21
  this.sink = sink;
19
22
  }
@@ -23,8 +26,16 @@ export class TranscriptBuilder {
23
26
  return undefined;
24
27
  if (m.type === 'stream_event') {
25
28
  const ev = m.event;
26
- if (ev?.type === 'content_block_delta' && ev.delta?.type === 'text_delta' && ev.delta.text)
29
+ // A message the model's output limit cut: the CLI resumes it in the same turn ("Output token limit hit"), and the
30
+ // message that follows is the model's next one, not more of this one.
31
+ if (ev?.type === 'message_delta' && ev.delta?.stop_reason === 'max_tokens')
32
+ this.cutPending = true;
33
+ if (ev?.type === 'content_block_delta' && ev.delta?.type === 'text_delta' && ev.delta.text) {
34
+ if (this.cutPending)
35
+ this.sink.live({ type: 'text_end' });
36
+ this.cutPending = false;
27
37
  this.sink.live({ type: 'text', delta: ev.delta.text });
38
+ }
28
39
  return undefined;
29
40
  }
30
41
  if (m.type === 'assistant') {
@@ -63,9 +74,14 @@ export class TranscriptBuilder {
63
74
  : typeof m.user_message_uuid === 'string'
64
75
  ? [m.user_message_uuid]
65
76
  : undefined;
77
+ this.cutPending = false;
78
+ // The turn's final answer still cut: the CLI's recovery of it was spent.
79
+ const output = m.usage?.output_tokens;
80
+ const cut = !isError && m.stop_reason === 'max_tokens' ? { stopReason: 'length', ...(typeof output === 'number' ? { outputTokens: output } : {}) } : {};
66
81
  return {
67
82
  status: isError ? 'failed' : 'completed',
68
83
  ...(error ? { error } : {}),
84
+ ...cut,
69
85
  queued: typeof m.queued_turn_count === 'number' ? m.queued_turn_count : 0,
70
86
  ...(consumed ? { consumed } : {}),
71
87
  ...(typeof m.session_id === 'string' ? { sessionId: m.session_id } : {}),
@@ -81,7 +97,8 @@ export class TranscriptBuilder {
81
97
  if (this.said)
82
98
  this.sink.message({ type: 'message', role: 'assistant', text: this.said });
83
99
  this.said = '';
84
- this.sink.message({ type: 'turn', status: end.status, ...(end.error ? { error: end.error } : {}) });
100
+ const cut = 'stopReason' in end && end.stopReason ? { stopReason: end.stopReason, ...(end.outputTokens !== undefined ? { outputTokens: end.outputTokens } : {}) } : {};
101
+ this.sink.message({ type: 'turn', status: end.status, ...(end.error ? { error: end.error } : {}), ...cut });
85
102
  }
86
103
  /**
87
104
  * A tool call is about to run (its MCP handler was called). The message
package/dist/versions.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2026 Vercel Inc. Licensed under the Apache License, Version 2.0; see LICENSE in this package.
2
2
  // From github.com/vercel-labs/durable-harness, packages/harness-claude-code/src/versions.ts at ea8aa4060c (UPSTREAM.json records its blob and sha256).
3
- // Changed by Parcha, imports rewritten for AgentRun; patches: 002-names, 004-pins
3
+ // Changed by Parcha, and AgentRun's own since the port from upstream froze on 2026-11-07.
4
4
  import { existsSync, readFileSync } from 'node:fs';
5
5
  import { dirname, join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-harness-claude",
3
- "version": "0.1.0-beta.31",
3
+ "version": "0.1.0-beta.33",
4
4
  "description": "The Claude Agent SDK as an AgentRun harness: the host's tools as its only tools, its model behind a loopback proxy, durable in AgentRun's own store.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -13,7 +13,7 @@
13
13
  "license": "Apache-2.0",
14
14
  "author": "Parcha Labs, Inc.",
15
15
  "engines": {
16
- "node": ">=22.19.0"
16
+ "node": ">=24.11.0"
17
17
  },
18
18
  "main": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
@@ -22,6 +22,10 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "default": "./dist/index.js"
24
24
  },
25
+ "./facts": {
26
+ "types": "./dist/facts.d.ts",
27
+ "default": "./dist/facts.js"
28
+ },
25
29
  "./testing": {
26
30
  "types": "./dist/testing/index.d.ts",
27
31
  "default": "./dist/testing/index.js"
@@ -44,8 +48,8 @@
44
48
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
45
49
  },
46
50
  "dependencies": {
47
- "@parcha/agentrun-dsl": "0.1.0-beta.31",
48
- "@parcha/agentrun-kernel": "0.1.0-beta.31"
51
+ "@parcha/agentrun-dsl": "0.1.0-beta.33",
52
+ "@parcha/agentrun-kernel": "0.1.0-beta.33"
49
53
  },
50
54
  "peerDependencies": {
51
55
  "@anthropic-ai/claude-agent-sdk": "0.3.286",