@poncho-ai/harness 0.60.1 → 0.61.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @poncho-ai/harness@0.60.1 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
2
+ > @poncho-ai/harness@0.61.1 build /home/runner/work/poncho-ai/poncho-ai/packages/harness
3
3
  > node scripts/embed-docs.js && tsup src/index.ts --format esm --dts
4
4
 
5
5
  [embed-docs] Generated poncho-docs.ts with 4 topics
@@ -8,9 +8,9 @@
8
8
  CLI tsup v8.5.1
9
9
  CLI Target: es2022
10
10
  ESM Build start
11
- ESM dist/index.js 574.16 KB
11
+ ESM dist/index.js 580.50 KB
12
12
  ESM dist/isolate-F2PPSUL6.js 53.82 KB
13
- ESM ⚡️ Build success in 245ms
13
+ ESM ⚡️ Build success in 227ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 7563ms
16
- DTS dist/index.d.ts 105.62 KB
15
+ DTS ⚡️ Build success in 7778ms
16
+ DTS dist/index.d.ts 110.56 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # @poncho-ai/harness
2
2
 
3
+ ## 0.61.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a16f4fa`](https://github.com/cesr/poncho-ai/commit/a16f4fa32f0809d6ff73f0041cb0e0a3fb980bb1) Thanks [@cesr](https://github.com/cesr)! - Fix: checkpoint-resume no longer drops a turn's user message from the model
8
+ transcript. Extract the checkpoint→transcript assembly the orchestrator's
9
+ `resumeRunFromCheckpoint` used into shared, exported helpers —
10
+ `assembleCheckpointMessages`, `buildToolResultMessage`, `buildResumeCheckpoints`
11
+ — so external embedders (which execute gated tools themselves) reconstruct the
12
+ canonical transcript identically instead of re-deriving the index arithmetic
13
+ and drifting. Add a transcript-integrity guard in `applyTurnMetadata` that
14
+ logs when a finalize would leave the latest user message out of the
15
+ model-facing transcript.
16
+
17
+ ## 0.61.0
18
+
19
+ ### Minor Changes
20
+
21
+ - [#192](https://github.com/cesr/poncho-ai/pull/192) [`bfd8012`](https://github.com/cesr/poncho-ai/commit/bfd80125ad71cd4401221c598faebf71afda2078) Thanks [@cesr](https://github.com/cesr)! - Fix context-compaction correctness so the agent stops losing context and
22
+ mislabeling failed work after a compaction:
23
+ - **Turn-based retention.** Compaction now preserves the last N whole _turns_
24
+ verbatim (new `compaction.keepRecentTurns`, default 4) instead of N messages,
25
+ which in tool-heavy turns collapsed to just the summary. The preserved side is
26
+ bounded by a token budget (≤ 50% of the context window) so keeping recent turns
27
+ can't leave the post-compaction context above the trigger (re-compaction
28
+ thrash / overflow). Adds exported `findSafeSplitPointByTurns`.
29
+ - **Faithful summaries.** The summarization output cap is raised 768 → 8192
30
+ tokens (768 physically truncated summaries mid-content); per-message truncation
31
+ 1200 → 4000 chars, with a total summarizer-input budget that drops the oldest
32
+ non-error messages first. The prompt now requires a non-omittable "Unresolved
33
+ errors & failures" section, a "Pending promises" section, forbids claiming
34
+ unconfirmed completion, and preserves identifiers verbatim.
35
+ - **Structured subagent task outcome.** New `PendingSubagentResult.taskOutcome`
36
+ (`succeeded | failed | partial | unknown`) distinct from run status: a subagent
37
+ that ran but failed its task is no longer recorded as "completed". Subagents
38
+ self-report a machine-readable verdict; it is parsed deterministically
39
+ (defaulting to "unknown", never success) and rendered in the callback header
40
+ and compaction ledger. The subagent digest is enlarged (2000 chars, ungated on
41
+ status) so the failure reason survives compaction.
42
+ - **Per-run `maxSteps` override.** New `RunInput.maxSteps` lets a caller raise the
43
+ step ceiling for foreground turns without raising it for background/job turns
44
+ that share the same agent definition.
45
+
46
+ ### Patch Changes
47
+
48
+ - Updated dependencies [[`bfd8012`](https://github.com/cesr/poncho-ai/commit/bfd80125ad71cd4401221c598faebf71afda2078)]:
49
+ - @poncho-ai/sdk@1.17.0
50
+
3
51
  ## 0.60.1
4
52
 
5
53
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -43,6 +43,16 @@ interface AgentFrontmatter {
43
43
  interface CompactionConfig {
44
44
  enabled: boolean;
45
45
  trigger: number;
46
+ /**
47
+ * Primary retention unit: number of whole recent *turns* (a user message plus
48
+ * the assistant/tool messages that follow it) preserved verbatim after the
49
+ * summary. See `findSafeSplitPointByTurns`.
50
+ */
51
+ keepRecentTurns: number;
52
+ /**
53
+ * Fallback retention floor, in messages, used only for the single-giant-turn
54
+ * case where no turn boundary yields a safe split.
55
+ */
46
56
  keepRecentMessages: number;
47
57
  instructions?: string;
48
58
  }
@@ -105,8 +115,37 @@ declare const estimateTotalTokens: (systemPrompt: string, messages: Message[], t
105
115
  * Returns -1 if no valid split point is found.
106
116
  */
107
117
  declare const findSafeSplitPoint: (messages: Message[], keepRecentMessages: number) => number;
118
+ /**
119
+ * Find the split index that preserves the last `keepRecentTurns` whole *turns*
120
+ * verbatim. A turn begins at a `role:"user"` message and runs until the next
121
+ * `user` message. Everything before the split is folded into the summary;
122
+ * everything from the split onward is kept as-is.
123
+ *
124
+ * Two guards make a candidate split acceptable:
125
+ * 1. The compacted side has at least `MIN_COMPACTABLE_MESSAGES` messages.
126
+ * 2. The preserved side estimates at most `maxPreservedTokens` — so keeping N
127
+ * large turns can never leave the post-compaction context above the
128
+ * compaction trigger (which caused re-compaction thrash / window overflow).
129
+ * The tool-call-orphan guard (`splitOrphansToolCalls`) is preserved: a split
130
+ * that would strand an assistant tool-call on the compacted side steps to an
131
+ * earlier user boundary (which only preserves more, always safe).
132
+ *
133
+ * We try the largest N (up to `keepRecentTurns`) first and decrement, so we
134
+ * keep as many turns as fit. If no turn boundary yields a safe split (e.g. a
135
+ * single giant turn near the window), fall back to the message-based
136
+ * `findSafeSplitPoint` so the middle of that turn still compacts.
137
+ *
138
+ * Returns -1 when nothing safe can be compacted.
139
+ */
140
+ declare const findSafeSplitPointByTurns: (messages: Message[], keepRecentTurns: number, keepRecentMessagesFallback: number, maxPreservedTokens: number) => number;
108
141
  interface CompactMessagesOptions {
109
142
  instructions?: string;
143
+ /**
144
+ * The model's context window (tokens). Used to bound the preserved side of a
145
+ * turn-based split so keeping N recent turns can't leave the post-compaction
146
+ * context above the compaction trigger. Defaults to 200k when omitted.
147
+ */
148
+ contextWindow?: number;
110
149
  }
111
150
  interface CompactResult {
112
151
  compacted: boolean;
@@ -207,10 +246,22 @@ interface StateStore {
207
246
  set(state: ConversationState): Promise<void>;
208
247
  delete(runId: string): Promise<void>;
209
248
  }
249
+ /**
250
+ * Whether a subagent actually accomplished its task — distinct from the *run*
251
+ * status (`status` below), which is "completed" whenever the run merely
252
+ * finished. A subagent that ran to completion but could not do the task (e.g.
253
+ * lacked the required tools) is `runStatus:"completed"` but `taskOutcome:
254
+ * "failed"`. Derived at subagent finalize; "unknown" when it can't be
255
+ * determined. Consumed by the compaction subagent ledger so a failed task can
256
+ * never be summarized as "completed".
257
+ */
258
+ type SubagentTaskOutcome = "succeeded" | "failed" | "partial" | "unknown";
210
259
  interface PendingSubagentResult {
211
260
  subagentId: string;
212
261
  task: string;
213
262
  status: "completed" | "error" | "stopped";
263
+ /** Did the subagent accomplish its task? See {@link SubagentTaskOutcome}. */
264
+ taskOutcome: SubagentTaskOutcome;
214
265
  result?: _poncho_ai_sdk.RunResult;
215
266
  error?: _poncho_ai_sdk.AgentFailure;
216
267
  timestamp: number;
@@ -2171,6 +2222,40 @@ declare const buildApprovalCheckpoints: ({ approvals, runId, checkpointMessages,
2171
2222
  pendingToolCalls: PendingToolCall[];
2172
2223
  kind?: "approval" | "device";
2173
2224
  }) => NonNullable<Conversation["pendingApprovals"]>;
2225
+ /** Reconstruct the full canonical transcript a checkpoint resumes from: the
2226
+ * prior history (before the checkpointed turn) + the checkpoint delta.
2227
+ * Handles both storage conventions via `normalizeApprovalCheckpoint` — the
2228
+ * initial checkpoint (base = prior length, delta) and a resume-created one
2229
+ * (base 0, full canonical). */
2230
+ declare const assembleCheckpointMessages: (conversation: Conversation, checkpoint: StoredApproval) => Message[];
2231
+ /** Pair an assistant tool-call message's `tool_calls` with externally-computed
2232
+ * results into the single `role:"tool"` message a continuation reads.
2233
+ * Returns undefined when `assistantMsg` isn't an assistant message with
2234
+ * parseable tool calls. Used to persist the resume's canonical history so it
2235
+ * matches what `continueFromToolResult` fed the model. Missing results
2236
+ * default to the deferred-error marker (same text the run uses). */
2237
+ declare const buildToolResultMessage: (assistantMsg: Message | undefined, toolResults: Array<{
2238
+ callId: string;
2239
+ toolName: string;
2240
+ result?: unknown;
2241
+ error?: string;
2242
+ }>) => Message | undefined;
2243
+ /** Build the `pendingApprovals` rows for a checkpoint reached DURING a resume
2244
+ * continuation. Stores the WHOLE canonical history the continuation ran with
2245
+ * (`priorMessages` = prior + tool result + new delta) with
2246
+ * `baseMessageCount: 0`. Keeping the full history here — rather than a delta
2247
+ * + a base count into a different message array — is what lets the next
2248
+ * resume reconstruct with no index arithmetic. */
2249
+ declare const buildResumeCheckpoints: ({ priorMessages, checkpointEvent, runId, kind, }: {
2250
+ priorMessages: Message[];
2251
+ checkpointEvent: {
2252
+ approvals: ApprovalEventItem[];
2253
+ checkpointMessages: Message[];
2254
+ pendingToolCalls: PendingToolCall[];
2255
+ };
2256
+ runId: string;
2257
+ kind?: "approval" | "device";
2258
+ }) => NonNullable<Conversation["pendingApprovals"]>;
2174
2259
  declare const applyTurnMetadata: (conv: Conversation, meta: TurnResultMetadata, opts?: {
2175
2260
  clearContinuation?: boolean;
2176
2261
  clearApprovals?: boolean;
@@ -2404,6 +2489,12 @@ interface RunConversationTurnOpts {
2404
2489
  * built with an OTLP exporter attached.
2405
2490
  */
2406
2491
  suppressTelemetry?: boolean;
2492
+ /**
2493
+ * Forwarded to `RunInput.maxSteps`: per-run step-ceiling override. Lets the
2494
+ * foreground chat turn run a higher ceiling than background/job turns that
2495
+ * share the same agent definition.
2496
+ */
2497
+ maxSteps?: number;
2407
2498
  /**
2408
2499
  * Forwarded to `RunInput.telemetryAttributes` — extra attributes for the
2409
2500
  * `invoke_agent` root span (e.g. run kind / job name for segmentation).
@@ -2446,4 +2537,4 @@ type NewEntryNoId = NewConversationEntry extends infer T ? T extends NewConversa
2446
2537
  */
2447
2538
  declare const appendEntriesSafe: (store: ConversationStore, conversation: Pick<Conversation, "conversationId" | "ownerId" | "tenantId">, entries: NewEntryNoId[], log: Logger) => Promise<ConversationEntry[]>;
2448
2539
 
2449
- export { type ActiveConversationRun, type ActiveSubagentRun, type AgentFrontmatter, AgentHarness, type AgentIdentity, type AgentLimitsConfig, type AgentModelConfig, AgentOrchestrator, type ApprovalEventItem, type ArchivedToolResult$1 as ArchivedToolResult, type BashConfig, BashEnvironmentManager, type BashExecutionLimits, type BuiltInToolToggles, CALLBACK_LOCK_STALE_MS, type CallbackStartedEntry, type CompactMessagesOptions, type CompactResult, type CompactionConfig, type ContinuationHooks, type Conversation, type ConversationCreateInit, type ConversationEntry, type ConversationState, type ConversationStatusSnapshot, type ConversationStore, type ConversationSummary, type CreateSkillToolsOptions, type CronJobConfig, DEFAULT_AGENT_DESCRIPTION, DEFAULT_AGENT_NAME, DEFAULT_MAX_STEPS, DEFAULT_MODEL_NAME, DEFAULT_MODEL_PROVIDER, DEFAULT_TAGLINE, DEFAULT_TEMPERATURE, DEFAULT_TIMEOUT, type DefaultAgentDefinitionOptions, type EventSink, type ExecuteTurnResult, type HarnessOptions, type HarnessRunOutput, type HistorySource, InMemoryConversationStore, InMemoryEngine, InMemoryStateStore, type IsolateBinding, type IsolateConfig, LocalMcpBridge, LocalUploadStore, MAX_CONCURRENT_SUBAGENTS, MAX_CONTINUATION_COUNT, MAX_SUBAGENT_CALLBACK_COUNT, MAX_SUBAGENT_NESTING, type MainMemory, type McpConfig, type MemoryConfig, type MemoryStore, type MessagingChannelConfig, type ModelProviderFactory, type MountProvider, type NetworkConfig, type NewConversationEntry, OPENAI_CODEX_CLIENT_ID, type OpenAICodexAuthConfig, type OpenAICodexDeviceAuthRequest, type OpenAICodexSession, type OrchestratorHooks, type OrchestratorOptions, type OtlpConfig, type OtlpOption, PONCHO_UPLOAD_SCHEME, type ParsedAgent, type PendingSubagentApproval, type PendingSubagentResult, type PendingToolCall, type PonchoConfig, PonchoFsAdapter, PostgresEngine, type ProviderConfig, type Recurrence, type RecurrenceType, type Reminder, type ReminderCreateInput, type ReminderStatus, type ReminderStore, type RemoteMcpServerConfig, type RunConversationTurnOpts, type RunConversationTurnResult, type RunOutcome, type RunRequest, type RuntimeRenderContext, S3UploadStore, STALE_SUBAGENT_THRESHOLD_MS, STORAGE_SCHEMA_VERSION, type SecretsStore, type SkillContextEntry, type SkillMetadata, type SkillSource, SqliteEngine, type StateConfig, type StateProviderName, type StateStore, type StorageConfig, type StorageEngine, type StorageFactoryOptions, type StorageProvider, type StoredApproval, type SubagentManager, type SubagentResult, type SubagentResultEntry, type SubagentSpawnResult, type SubagentSummary, type SubagentTranscript, type SubagentTranscriptMode, TOOL_RESULT_ARCHIVE_PARAM, type TelemetryConfig, TelemetryEmitter, type TenantTokenPayload, type ToolAccess, type ToolCall, ToolDispatcher, type ToolExecutionResult, type TurnDraftState, type TurnResultMetadata, type TurnSection, type UploadStore, type UploadsConfig, VFS_SCHEME, VercelBlobUploadStore, type VfsDirEntry, type VfsStat, type VirtualMount, abnormalEndResponse, appendEntriesSafe, applyTurnMetadata, buildAgentDirectoryName, buildApprovalCheckpoints, buildAssistantMetadata, buildSkillContextWindow, buildToolCompletedText, cloneSections, compactMessages, completeOpenAICodexDeviceAuth, computeNextOccurrence, createBashTool, createConversationStore, createConversationStoreFromEngine, createDefaultTools, createDeleteDirectoryTool, createDeleteTool, createEditTool, createMemoryStore, createMemoryStoreFromEngine, createMemoryTools, createModelProvider, createReminderStore, createReminderStoreFromEngine, createReminderTools, createSearchTools, createSecretsStore, createSkillTools, createStateStore, createStorageEngine, createSubagentTools, createTodoStoreFromEngine, createTurnDraftState, createUploadStore, createWriteTool, decodeFileInputData, defaultAgentDefinition, deleteOpenAICodexSession, deriveUploadKey, ensureAgentIdentity, estimateTokens, estimateTotalTokens, executeConversationTurn, findSafeSplitPoint, flushTurnDraft, generateAgentId, getAgentStoreDirectory, getModelContextWindow, getOpenAICodexAccessToken, getOpenAICodexAuthFilePath, getOpenAICodexRequiredScopes, getPendingSubagentResults, getPonchoStoreRoot, isMessageArray, jsonSchemaToZod, lastAssistantText, loadCanonicalHistory, loadPonchoConfig, loadRunHistory, loadSkillContext, loadSkillInstructions, loadSkillMetadata, loadSkillMetadataFromDirs, loadVfsSkillMetadata, mergeSkills, normalizeApprovalCheckpoint, normalizeOtlp, normalizeScriptPolicyPath, normalizeToolAccess, parseAgentFile, parseAgentMarkdown, parseSkillFrontmatter, ponchoDocsTool, readOpenAICodexSession, readSkillResource, realResponseText, recordStandardTurnEvent, renderAgentPrompt, resolveAgentIdentity, resolveCompactionConfig, resolveEnv, resolveMemoryConfig, resolveRunRequest, resolveSkillDirs, resolveStateConfig, runConversationTurn, slugifyStorageComponent, startOpenAICodexDeviceAuth, stripPillMetaTokens, verifyTenantToken, withToolResultArchiveParam, writeOpenAICodexSession };
2540
+ export { type ActiveConversationRun, type ActiveSubagentRun, type AgentFrontmatter, AgentHarness, type AgentIdentity, type AgentLimitsConfig, type AgentModelConfig, AgentOrchestrator, type ApprovalEventItem, type ArchivedToolResult$1 as ArchivedToolResult, type BashConfig, BashEnvironmentManager, type BashExecutionLimits, type BuiltInToolToggles, CALLBACK_LOCK_STALE_MS, type CallbackStartedEntry, type CompactMessagesOptions, type CompactResult, type CompactionConfig, type ContinuationHooks, type Conversation, type ConversationCreateInit, type ConversationEntry, type ConversationState, type ConversationStatusSnapshot, type ConversationStore, type ConversationSummary, type CreateSkillToolsOptions, type CronJobConfig, DEFAULT_AGENT_DESCRIPTION, DEFAULT_AGENT_NAME, DEFAULT_MAX_STEPS, DEFAULT_MODEL_NAME, DEFAULT_MODEL_PROVIDER, DEFAULT_TAGLINE, DEFAULT_TEMPERATURE, DEFAULT_TIMEOUT, type DefaultAgentDefinitionOptions, type EventSink, type ExecuteTurnResult, type HarnessOptions, type HarnessRunOutput, type HistorySource, InMemoryConversationStore, InMemoryEngine, InMemoryStateStore, type IsolateBinding, type IsolateConfig, LocalMcpBridge, LocalUploadStore, MAX_CONCURRENT_SUBAGENTS, MAX_CONTINUATION_COUNT, MAX_SUBAGENT_CALLBACK_COUNT, MAX_SUBAGENT_NESTING, type MainMemory, type McpConfig, type MemoryConfig, type MemoryStore, type MessagingChannelConfig, type ModelProviderFactory, type MountProvider, type NetworkConfig, type NewConversationEntry, OPENAI_CODEX_CLIENT_ID, type OpenAICodexAuthConfig, type OpenAICodexDeviceAuthRequest, type OpenAICodexSession, type OrchestratorHooks, type OrchestratorOptions, type OtlpConfig, type OtlpOption, PONCHO_UPLOAD_SCHEME, type ParsedAgent, type PendingSubagentApproval, type PendingSubagentResult, type PendingToolCall, type PonchoConfig, PonchoFsAdapter, PostgresEngine, type ProviderConfig, type Recurrence, type RecurrenceType, type Reminder, type ReminderCreateInput, type ReminderStatus, type ReminderStore, type RemoteMcpServerConfig, type RunConversationTurnOpts, type RunConversationTurnResult, type RunOutcome, type RunRequest, type RuntimeRenderContext, S3UploadStore, STALE_SUBAGENT_THRESHOLD_MS, STORAGE_SCHEMA_VERSION, type SecretsStore, type SkillContextEntry, type SkillMetadata, type SkillSource, SqliteEngine, type StateConfig, type StateProviderName, type StateStore, type StorageConfig, type StorageEngine, type StorageFactoryOptions, type StorageProvider, type StoredApproval, type SubagentManager, type SubagentResult, type SubagentResultEntry, type SubagentSpawnResult, type SubagentSummary, type SubagentTaskOutcome, type SubagentTranscript, type SubagentTranscriptMode, TOOL_RESULT_ARCHIVE_PARAM, type TelemetryConfig, TelemetryEmitter, type TenantTokenPayload, type ToolAccess, type ToolCall, ToolDispatcher, type ToolExecutionResult, type TurnDraftState, type TurnResultMetadata, type TurnSection, type UploadStore, type UploadsConfig, VFS_SCHEME, VercelBlobUploadStore, type VfsDirEntry, type VfsStat, type VirtualMount, abnormalEndResponse, appendEntriesSafe, applyTurnMetadata, assembleCheckpointMessages, buildAgentDirectoryName, buildApprovalCheckpoints, buildAssistantMetadata, buildResumeCheckpoints, buildSkillContextWindow, buildToolCompletedText, buildToolResultMessage, cloneSections, compactMessages, completeOpenAICodexDeviceAuth, computeNextOccurrence, createBashTool, createConversationStore, createConversationStoreFromEngine, createDefaultTools, createDeleteDirectoryTool, createDeleteTool, createEditTool, createMemoryStore, createMemoryStoreFromEngine, createMemoryTools, createModelProvider, createReminderStore, createReminderStoreFromEngine, createReminderTools, createSearchTools, createSecretsStore, createSkillTools, createStateStore, createStorageEngine, createSubagentTools, createTodoStoreFromEngine, createTurnDraftState, createUploadStore, createWriteTool, decodeFileInputData, defaultAgentDefinition, deleteOpenAICodexSession, deriveUploadKey, ensureAgentIdentity, estimateTokens, estimateTotalTokens, executeConversationTurn, findSafeSplitPoint, findSafeSplitPointByTurns, flushTurnDraft, generateAgentId, getAgentStoreDirectory, getModelContextWindow, getOpenAICodexAccessToken, getOpenAICodexAuthFilePath, getOpenAICodexRequiredScopes, getPendingSubagentResults, getPonchoStoreRoot, isMessageArray, jsonSchemaToZod, lastAssistantText, loadCanonicalHistory, loadPonchoConfig, loadRunHistory, loadSkillContext, loadSkillInstructions, loadSkillMetadata, loadSkillMetadataFromDirs, loadVfsSkillMetadata, mergeSkills, normalizeApprovalCheckpoint, normalizeOtlp, normalizeScriptPolicyPath, normalizeToolAccess, parseAgentFile, parseAgentMarkdown, parseSkillFrontmatter, ponchoDocsTool, readOpenAICodexSession, readSkillResource, realResponseText, recordStandardTurnEvent, renderAgentPrompt, resolveAgentIdentity, resolveCompactionConfig, resolveEnv, resolveMemoryConfig, resolveRunRequest, resolveSkillDirs, resolveStateConfig, runConversationTurn, slugifyStorageComponent, startOpenAICodexDeviceAuth, stripPillMetaTokens, verifyTenantToken, withToolResultArchiveParam, writeOpenAICodexSession };