@supersolutions/super-chat-core 0.4.2 → 0.4.4

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
@@ -2371,6 +2371,13 @@ type ToolCallOutcome = {
2371
2371
  unlockTools?: string[];
2372
2372
  ms: number;
2373
2373
  };
2374
+ /**
2375
+ * What the model reads when the person says no to an approval. The same words
2376
+ * go into the `{ error }` of the denied result and into the `reason` of the
2377
+ * answer a tool that asks for itself receives, so `userDeclined` (stop.ts) can
2378
+ * tell a person's "no" from a host that cannot ask.
2379
+ */
2380
+ declare const USER_DECLINED = "The user declined.";
2374
2381
  /** Shrink an error to something worth carrying in history. */
2375
2382
  declare function compactError(e: unknown): {
2376
2383
  error: string;
@@ -2677,10 +2684,31 @@ declare const tokenBudgetExceeded: (maxTotal: number) => StopCondition;
2677
2684
  * step cap, producing nothing but latency and spend.
2678
2685
  */
2679
2686
  declare const consecutiveFailures: (n: number) => StopCondition;
2680
- /** Stop when the user declined an interactive card — proceeding would ignore them. */
2687
+ /**
2688
+ * Whether an outcome is the person saying no, as opposed to a tool failing or a
2689
+ * host that cannot ask. Three shapes carry it:
2690
+ *
2691
+ * - an approval the runtime asked for (`side: "confirm"`): `failure: "denied"`
2692
+ * and the error is `USER_DECLINED`;
2693
+ * - a tool that asks for itself (`confirmation: "tool"`) and returns the
2694
+ * answer it was given: `{ cancelled: true }`;
2695
+ * - an interactive card from `visualize`: `{ response: { cancelled: true } }`.
2696
+ */
2697
+ declare function isUserDecline(outcome: ToolCallOutcome): boolean;
2698
+ /**
2699
+ * Stop the run as soon as the person has declined something.
2700
+ *
2701
+ * Opt-in. By default a decline is only a result the model reads ("The user
2702
+ * declined."): the run goes on, and the model decides what to do, usually to say
2703
+ * what was left undone and ask. Use this when your product treats a "no" as the
2704
+ * end of the turn. It is not in `DEFAULT_STOP_CONDITIONS`.
2705
+ */
2681
2706
  declare const userDeclined: StopCondition;
2682
2707
  declare function shouldStop(conditions: readonly StopCondition[] | undefined, ctx: StopContext): boolean;
2683
- /** A sane default set for an interactive chat agent. */
2708
+ /**
2709
+ * A sane default set for an interactive chat agent. A person's "no" is not here:
2710
+ * it is told to the model and the run continues (see `userDeclined`).
2711
+ */
2684
2712
  declare const DEFAULT_STOP_CONDITIONS: StopCondition[];
2685
2713
 
2686
2714
  type RunConfig = {
@@ -3142,4 +3170,4 @@ declare function createMcpSkill(serverName: string, defs: readonly ToolDefinitio
3142
3170
  */
3143
3171
  declare function elicitViaCard(requestCard: (spec: CardSpec) => Promise<unknown>): McpElicitHandler;
3144
3172
 
3145
- export { A2UI_VERSION, type A2uiMessage, ANTHROPIC_OFFICIAL_PROFILE, AgentError, type AgentErrorKind, type AppAction, type AppStateBinding, type AppStateSourceOptions, type AppliedEdit, BUILTIN_CARDS, type BindingScope, type BudgetShares, type BuiltContext, type BuiltinCard, type BuiltinCardKind, CARD_COMPONENT, CARD_ENTRY_PREFIX, CARD_KEY, CARD_PLACEMENTS, CARD_REF_LIMITS, CARD_REF_SCHEME, CallOptions, type CalloutCard, type Card, type CardAction, type CardCarrier, type CardKindDefinition, type CardPlacement, type CardRef, type CardRefEvent, type CardRefHost, type CardRefParse, type CardRefResult, CardRegistry, type CardSpec, type CardTone, type CardValidation, type CardValueFormat, type ChartAnnotation, type ChartCard, type ChartSeries, type ChecklistCard, type ChoiceCard, type CitationsCard, type CodeCard, type CompactionResult, type ComparisonCard, type ConfirmCard, ContentPart, ContextBuilder, type ContextBuilderOptions, type ContextLayer, type ContextSource, type ContextSourceInput, type ContextSourceResult, type ContextTrace, DEFAULT_PRESETS, DEFAULT_STOP_CONDITIONS, type DiffCard, type DirectTransportConfig, type DocumentCard, type DocumentEdit, type DocumentOutlineEntry, type DocumentQuoteRef, type DocumentSnapshot, type DocumentStore, type DocumentToolsOptions, type EditHunk, type EditRejection, type EditResult, type EditReviewCard, type EmailCard, type ExecuteToolOptions, type FileStore, FinishReason, type FormCard, type FormField, type FunnelCard, type GaugeCard, type GenerateImageToolOptions, GenerateResult, type GeneratedMedia, type GeneratedMediaKind, type ImageGenerationRequest, JSONSchema, JobHandle, JobStatus, type KeyValueCard, type LayerId, MAILTO_SAFE_LENGTH, MESSAGE_OVERHEAD_TOKENS, type MailtoLink, type MarkdownBlock, type MarkdownBlockKind, type MarkdownCard, type McpCallResult, McpClient, type McpClientConfig, type McpContent, type McpElicitHandler, type McpElicitRequest, type McpElicitResult, type McpImportOptions, McpRpcError, type McpServerInfo, type McpTool, type MediaCard, type MediaJobHandle, type MediaJobSnapshot, type MediaProvider, type MediaProviderCapabilities, MediaSource, type MemoryEntry, type MemorySourceOptions, type MemoryStore, Message, MessageRole, type MeterSink, type MeteringError, type MeteringRecord, type MeteringSource, type MeteringStatus, ModelInfo, NormalizedRequest, OPENAI_OFFICIAL_PROFILE, type OpenAIImageProviderConfig, PartialJsonParser, type PartialToolCall, type PresetName, type ProfileDirectTransportConfig, type ProgressCard, type ProgressStep, Provider, ProviderCapabilities, ProviderFileRef, type ProviderProfile, type ProviderProtocol, type ProxyEnvelope, type ProxyTransportConfig, QUOTES_METADATA_KEY, type QuoteDrift, type RepairResult, type ResolvedSkill, type RestThreadStoreConfig, type RetrievalDoc, type RetrievalSourceOptions, type RetrievedChunk, type Retriever, RetryPolicy, type RunConfig, type RunEvent, type RunMeteringRecord, type RunMode, type RunState, SSEDecoder, type SSEMessage, SURFACE_A2UI_CATALOG_ID, SURFACE_ARTIFACT_KIND, SURFACE_CARD_KIND, SURFACE_EVENT_METADATA_KEY, SURFACE_FORMAT_VERSION, SURFACE_GUIDE, SURFACE_LIMITS, SURFACE_PRIMITIVES, SURFACE_SKILL_ID, SURFACE_TOOL_NAMES, type SchemaCheckOptions, type SchemaProblem, type SerializedMultipartBody, type Skill, type SkillContext, type SkillMatch, type SkillMatcher, type SkillMode, SkillRegistry, type SkillRegistryOptions, type SkillSection, type SpeechGenerationRequest, type StatItem, type StatsCard, type StepMeteringRecord, type StopCondition, type StopContext, type StoredFile, type StoredThread, type Summarizer, type SurfaceAction, type SurfaceActivity, type SurfaceActivityState, type SurfaceAggregateOp, type SurfaceBinding, type SurfaceBuildContext, type SurfaceBuildResult, type SurfaceCardAnswer, SurfaceCatalogue, type SurfaceCatalogueOptions, type SurfaceComponent, type SurfaceComponentCategory, type SurfaceComponentDefinition, type SurfaceCondition, type SurfaceConditionOp, type SurfaceEventRecord, type SurfaceIssue, type SurfaceIssueCode, type SurfaceItemBinding, SurfaceLedger, type SurfaceOperation, type SurfacePathBinding, type SurfacePendingPart, type SurfaceQuery, type SurfaceQueryBinding, type SurfaceSpec, type SurfaceTemplateBinding, type SurfaceToolAuthorization, type SurfaceToolRunConfig, type SurfaceToolsOptions, type SurfaceValidationContext, type SurfaceWhere, type SurfaceWhereOp, THREAD_SCHEMA_VERSION, type TableCard, type TableColumn, type ThreadMeta, type ThreadStore, type TimelineCard, type TokenBudget, type TokenCounter, type ToolApproval, type ToolCallOutcome, type ToolCallRequest, ToolCallStatus, type ToolDefinition, type ToolExecutionContext, ToolFailureKind, type ToolLoading, type ToolLoadingHint, ToolRegistry, type ToolResolution, type ToolResult, type ToolResultExtras, type ToolSide, ToolSpec, type TraceEntry, type Transcript, type TranscriptionRequest, Transport, TransportRequest, type TreeCard, type TreeNode, type TurnLayoutOptions, type TurnSegment, type UnsafeFinding, Usage, type VideoGenerationRequest, type VisualizePlacement, type VisualizeToolOptions, afterTool, appendReasoning, appendText, applyEdits, applySurfaceOperations, approvalCard, assistantMessage, authorizeSurfaceTool, backoffDelay, base64ToBytes, bindingProblems, buildEml, buildMailto, buildSummaryPrompt, buildSurface, buildUrl, bytesToBase64, calloutCard, chartCard, check, checkQuoteDrift, checkSchema, checklistCard, childrenOf, choiceCard, citationsCard, codeCard, combineMeteringSources, compactError, compactHistory, comparisonCard, confirmCard, consecutiveFailures, countMessageTokens, countMessagesTokens, createAppActionTools, createAppStateSource, createBudget, createBuiltinTools, createDirectTransport, createDirectTransportForProfile, createDocumentTools, createEmailDraftTool, createGenerateImageTool, createHttpTransport, createKeywordRetriever, createLoadSkillTool, createLocalDocumentStore, createLocalFileStore, createLocalMemoryStore, createLocalThreadStore, createMcpSkill, createMemoryDocumentStore, createMemoryFileStore, createMemoryMemoryStore, createMemorySource, createMemoryThreadStore, createOpenAICompatibleProfile, createOpenAIImageProvider, createProviderFromProfile, createProxyTransport, createRememberTool, createRestThreadStore, createRetrievalSource, createSurfaceContextSource, createSurfaceSkill, createSurfaceTools, createUpdateCardTool, createVisualizeTool, deliverMetering, diffCard, documentCard, editReviewCard, elicitViaCard, emailCard, emlFilename, errorFromResponse, estimateJsonTokens, estimateTokens, evaluateSurfaceCondition, executeToolCall, executeToolCalls, file, findUnsafe, foldSurfaces, formCard, formatQuotes, formatTemplate, funnelCard, gaugeCard, generatedMediaUrl, getAt, hasTurnOrder, humanizeFieldName, hunksOf, image, importMcpTools, initialRunState, isAgentError, isCardCarrier, isCardPlacement, isScriptUrl, isSurfaceBinding, isSurfaceId, isSurfaceSpec, isTextPart, isToolCallPart, isToolResultPart, keyValueCard, kindFromStatus, lastUserText, latestLeaf, layoutTurn, linkLinear, makeCard, mapMcpResult, markdownCard, matchSkills, mediaCard, message, messageText, nextId, noToolCalls, normalizeProviderProfile, normalizeToolName, outlineOf, packByPriority, parseCardRef, parsePartialJson, parsePointer, parseRetryAfter, parseSSE, parseSSEJson, pathTo, previewSurface, progressCard, quoteDrift, quotesOf, reduceRunEvent, removeAt, renderSkill, repairToolArguments, resolvePartialCard, resolveSurfaceAction, resolveSurfaceValue, resolveToolLoading, runAgent, runSurfaceQuery, runSurfaceToolAction, safeCutIndex, safeSurfaceUrl, sanitizeSurfaceSpec, scoreSkill, searchBlocks, setAt, shouldStop, siblingsOf, spanOf, splitBlocks, statsCard, stepCountIs, stripCardPayload, stripUiOnlyParts, surfaceActionTools, surfaceCardId, tableCard, text, threadSnapshot, timelineCard, toA2uiMessages, toAgentError, tokenBudgetExceeded, tokenize, toolCall, toolCallsIn, toolResult, totalAllocated, treeCard, trimHistory, usageSource, userDeclined, userMessage, usesBinding, validateSurfaceAction, validateSurfaceComponent, validateSurfaceComponents, validateSurfaceGraph, withCard, withQuotes, withRetry };
3173
+ export { A2UI_VERSION, type A2uiMessage, ANTHROPIC_OFFICIAL_PROFILE, AgentError, type AgentErrorKind, type AppAction, type AppStateBinding, type AppStateSourceOptions, type AppliedEdit, BUILTIN_CARDS, type BindingScope, type BudgetShares, type BuiltContext, type BuiltinCard, type BuiltinCardKind, CARD_COMPONENT, CARD_ENTRY_PREFIX, CARD_KEY, CARD_PLACEMENTS, CARD_REF_LIMITS, CARD_REF_SCHEME, CallOptions, type CalloutCard, type Card, type CardAction, type CardCarrier, type CardKindDefinition, type CardPlacement, type CardRef, type CardRefEvent, type CardRefHost, type CardRefParse, type CardRefResult, CardRegistry, type CardSpec, type CardTone, type CardValidation, type CardValueFormat, type ChartAnnotation, type ChartCard, type ChartSeries, type ChecklistCard, type ChoiceCard, type CitationsCard, type CodeCard, type CompactionResult, type ComparisonCard, type ConfirmCard, ContentPart, ContextBuilder, type ContextBuilderOptions, type ContextLayer, type ContextSource, type ContextSourceInput, type ContextSourceResult, type ContextTrace, DEFAULT_PRESETS, DEFAULT_STOP_CONDITIONS, type DiffCard, type DirectTransportConfig, type DocumentCard, type DocumentEdit, type DocumentOutlineEntry, type DocumentQuoteRef, type DocumentSnapshot, type DocumentStore, type DocumentToolsOptions, type EditHunk, type EditRejection, type EditResult, type EditReviewCard, type EmailCard, type ExecuteToolOptions, type FileStore, FinishReason, type FormCard, type FormField, type FunnelCard, type GaugeCard, type GenerateImageToolOptions, GenerateResult, type GeneratedMedia, type GeneratedMediaKind, type ImageGenerationRequest, JSONSchema, JobHandle, JobStatus, type KeyValueCard, type LayerId, MAILTO_SAFE_LENGTH, MESSAGE_OVERHEAD_TOKENS, type MailtoLink, type MarkdownBlock, type MarkdownBlockKind, type MarkdownCard, type McpCallResult, McpClient, type McpClientConfig, type McpContent, type McpElicitHandler, type McpElicitRequest, type McpElicitResult, type McpImportOptions, McpRpcError, type McpServerInfo, type McpTool, type MediaCard, type MediaJobHandle, type MediaJobSnapshot, type MediaProvider, type MediaProviderCapabilities, MediaSource, type MemoryEntry, type MemorySourceOptions, type MemoryStore, Message, MessageRole, type MeterSink, type MeteringError, type MeteringRecord, type MeteringSource, type MeteringStatus, ModelInfo, NormalizedRequest, OPENAI_OFFICIAL_PROFILE, type OpenAIImageProviderConfig, PartialJsonParser, type PartialToolCall, type PresetName, type ProfileDirectTransportConfig, type ProgressCard, type ProgressStep, Provider, ProviderCapabilities, ProviderFileRef, type ProviderProfile, type ProviderProtocol, type ProxyEnvelope, type ProxyTransportConfig, QUOTES_METADATA_KEY, type QuoteDrift, type RepairResult, type ResolvedSkill, type RestThreadStoreConfig, type RetrievalDoc, type RetrievalSourceOptions, type RetrievedChunk, type Retriever, RetryPolicy, type RunConfig, type RunEvent, type RunMeteringRecord, type RunMode, type RunState, SSEDecoder, type SSEMessage, SURFACE_A2UI_CATALOG_ID, SURFACE_ARTIFACT_KIND, SURFACE_CARD_KIND, SURFACE_EVENT_METADATA_KEY, SURFACE_FORMAT_VERSION, SURFACE_GUIDE, SURFACE_LIMITS, SURFACE_PRIMITIVES, SURFACE_SKILL_ID, SURFACE_TOOL_NAMES, type SchemaCheckOptions, type SchemaProblem, type SerializedMultipartBody, type Skill, type SkillContext, type SkillMatch, type SkillMatcher, type SkillMode, SkillRegistry, type SkillRegistryOptions, type SkillSection, type SpeechGenerationRequest, type StatItem, type StatsCard, type StepMeteringRecord, type StopCondition, type StopContext, type StoredFile, type StoredThread, type Summarizer, type SurfaceAction, type SurfaceActivity, type SurfaceActivityState, type SurfaceAggregateOp, type SurfaceBinding, type SurfaceBuildContext, type SurfaceBuildResult, type SurfaceCardAnswer, SurfaceCatalogue, type SurfaceCatalogueOptions, type SurfaceComponent, type SurfaceComponentCategory, type SurfaceComponentDefinition, type SurfaceCondition, type SurfaceConditionOp, type SurfaceEventRecord, type SurfaceIssue, type SurfaceIssueCode, type SurfaceItemBinding, SurfaceLedger, type SurfaceOperation, type SurfacePathBinding, type SurfacePendingPart, type SurfaceQuery, type SurfaceQueryBinding, type SurfaceSpec, type SurfaceTemplateBinding, type SurfaceToolAuthorization, type SurfaceToolRunConfig, type SurfaceToolsOptions, type SurfaceValidationContext, type SurfaceWhere, type SurfaceWhereOp, THREAD_SCHEMA_VERSION, type TableCard, type TableColumn, type ThreadMeta, type ThreadStore, type TimelineCard, type TokenBudget, type TokenCounter, type ToolApproval, type ToolCallOutcome, type ToolCallRequest, ToolCallStatus, type ToolDefinition, type ToolExecutionContext, ToolFailureKind, type ToolLoading, type ToolLoadingHint, ToolRegistry, type ToolResolution, type ToolResult, type ToolResultExtras, type ToolSide, ToolSpec, type TraceEntry, type Transcript, type TranscriptionRequest, Transport, TransportRequest, type TreeCard, type TreeNode, type TurnLayoutOptions, type TurnSegment, USER_DECLINED, type UnsafeFinding, Usage, type VideoGenerationRequest, type VisualizePlacement, type VisualizeToolOptions, afterTool, appendReasoning, appendText, applyEdits, applySurfaceOperations, approvalCard, assistantMessage, authorizeSurfaceTool, backoffDelay, base64ToBytes, bindingProblems, buildEml, buildMailto, buildSummaryPrompt, buildSurface, buildUrl, bytesToBase64, calloutCard, chartCard, check, checkQuoteDrift, checkSchema, checklistCard, childrenOf, choiceCard, citationsCard, codeCard, combineMeteringSources, compactError, compactHistory, comparisonCard, confirmCard, consecutiveFailures, countMessageTokens, countMessagesTokens, createAppActionTools, createAppStateSource, createBudget, createBuiltinTools, createDirectTransport, createDirectTransportForProfile, createDocumentTools, createEmailDraftTool, createGenerateImageTool, createHttpTransport, createKeywordRetriever, createLoadSkillTool, createLocalDocumentStore, createLocalFileStore, createLocalMemoryStore, createLocalThreadStore, createMcpSkill, createMemoryDocumentStore, createMemoryFileStore, createMemoryMemoryStore, createMemorySource, createMemoryThreadStore, createOpenAICompatibleProfile, createOpenAIImageProvider, createProviderFromProfile, createProxyTransport, createRememberTool, createRestThreadStore, createRetrievalSource, createSurfaceContextSource, createSurfaceSkill, createSurfaceTools, createUpdateCardTool, createVisualizeTool, deliverMetering, diffCard, documentCard, editReviewCard, elicitViaCard, emailCard, emlFilename, errorFromResponse, estimateJsonTokens, estimateTokens, evaluateSurfaceCondition, executeToolCall, executeToolCalls, file, findUnsafe, foldSurfaces, formCard, formatQuotes, formatTemplate, funnelCard, gaugeCard, generatedMediaUrl, getAt, hasTurnOrder, humanizeFieldName, hunksOf, image, importMcpTools, initialRunState, isAgentError, isCardCarrier, isCardPlacement, isScriptUrl, isSurfaceBinding, isSurfaceId, isSurfaceSpec, isTextPart, isToolCallPart, isToolResultPart, isUserDecline, keyValueCard, kindFromStatus, lastUserText, latestLeaf, layoutTurn, linkLinear, makeCard, mapMcpResult, markdownCard, matchSkills, mediaCard, message, messageText, nextId, noToolCalls, normalizeProviderProfile, normalizeToolName, outlineOf, packByPriority, parseCardRef, parsePartialJson, parsePointer, parseRetryAfter, parseSSE, parseSSEJson, pathTo, previewSurface, progressCard, quoteDrift, quotesOf, reduceRunEvent, removeAt, renderSkill, repairToolArguments, resolvePartialCard, resolveSurfaceAction, resolveSurfaceValue, resolveToolLoading, runAgent, runSurfaceQuery, runSurfaceToolAction, safeCutIndex, safeSurfaceUrl, sanitizeSurfaceSpec, scoreSkill, searchBlocks, setAt, shouldStop, siblingsOf, spanOf, splitBlocks, statsCard, stepCountIs, stripCardPayload, stripUiOnlyParts, surfaceActionTools, surfaceCardId, tableCard, text, threadSnapshot, timelineCard, toA2uiMessages, toAgentError, tokenBudgetExceeded, tokenize, toolCall, toolCallsIn, toolResult, totalAllocated, treeCard, trimHistory, usageSource, userDeclined, userMessage, usesBinding, validateSurfaceAction, validateSurfaceComponent, validateSurfaceComponents, validateSurfaceGraph, withCard, withQuotes, withRetry };
package/dist/index.js CHANGED
@@ -4793,6 +4793,7 @@ function approvalCard(tool, input, options = {}) {
4793
4793
 
4794
4794
  // src/runtime/execute-tools.ts
4795
4795
  var MAX_ERROR_CHARS = 400;
4796
+ var USER_DECLINED = "The user declined.";
4796
4797
  function compactError(e) {
4797
4798
  if (e instanceof AgentError) {
4798
4799
  return { error: e.message.slice(0, MAX_ERROR_CHARS), kind: e.kind };
@@ -4805,7 +4806,7 @@ async function confirmationRefusal(tool, call, opts) {
4805
4806
  if (tool.confirmation === "tool") return void 0;
4806
4807
  const answer = await opts.requestCard(call.callId, approvalCard(tool, call.input));
4807
4808
  if (opts.signal?.aborted) return "The run was stopped before this was approved.";
4808
- return answer?.confirmed === true ? void 0 : "The user declined.";
4809
+ return answer?.confirmed === true ? void 0 : USER_DECLINED;
4809
4810
  }
4810
4811
  var isToolResult = (v) => typeof v === "object" && v !== null && "output" in v && Object.keys(v).every((k) => ["output", "card", "failure", "cardId", "unlockTools", "placement"].includes(k));
4811
4812
  async function executeToolCall(call, opts) {
@@ -5592,10 +5593,11 @@ function createVisualizeTool(opts) {
5592
5593
  const full = { ...spec ?? {}, kind };
5593
5594
  const verdict = cards.validate(full);
5594
5595
  if (!verdict.ok) {
5596
+ const shape = verdict.expected ?? cards.get(kind)?.summary;
5595
5597
  return {
5596
5598
  // Returned as data, not thrown: the model reads the correction and
5597
5599
  // retries with a valid spec on the next step.
5598
- output: { ok: false, error: verdict.error, ...verdict.expected ? { expected: verdict.expected } : {} },
5600
+ output: { ok: false, error: verdict.error, ...shape ? { expected: shape } : {} },
5599
5601
  failure: "invalid-input"
5600
5602
  };
5601
5603
  }
@@ -5871,14 +5873,20 @@ var consecutiveFailures = (n) => {
5871
5873
  return streak >= n;
5872
5874
  };
5873
5875
  };
5874
- var userDeclined = (ctx) => ctx.outcomes.some(
5875
- (o) => typeof o.output === "object" && o.output !== null && o.output.cancelled === true
5876
- );
5876
+ function isUserDecline(outcome2) {
5877
+ const output = outcome2.output;
5878
+ if (typeof output !== "object" || output === null) return false;
5879
+ const o = output;
5880
+ if (outcome2.failure === "denied" && o.error === USER_DECLINED) return true;
5881
+ if (o.cancelled === true) return true;
5882
+ return typeof o.response === "object" && o.response !== null && o.response.cancelled === true;
5883
+ }
5884
+ var userDeclined = (ctx) => ctx.outcomes.some(isUserDecline);
5877
5885
  function shouldStop(conditions, ctx) {
5878
5886
  if (!conditions?.length) return false;
5879
5887
  return conditions.some((c) => c(ctx));
5880
5888
  }
5881
- var DEFAULT_STOP_CONDITIONS = [consecutiveFailures(3), userDeclined];
5889
+ var DEFAULT_STOP_CONDITIONS = [consecutiveFailures(3)];
5882
5890
 
5883
5891
  // src/runtime/run.ts
5884
5892
  async function* runAgent(messages, config) {
@@ -6128,7 +6136,7 @@ async function* runAgent(messages, config) {
6128
6136
  channel.push({ type: "awaiting-user", callId, card });
6129
6137
  const action = await config.onUserDecision(callId, card);
6130
6138
  channel.push({ type: "user-responded", callId, action });
6131
- return action.type === "cancel" || action.type === "dismiss" ? { cancelled: true, reason: "The user declined." } : action.value ?? { confirmed: true };
6139
+ return action.type === "cancel" || action.type === "dismiss" ? { cancelled: true, reason: USER_DECLINED } : action.value ?? { confirmed: true };
6132
6140
  } : void 0
6133
6141
  }).finally(() => channel.close());
6134
6142
  for await (const event of channel) yield event;
@@ -7211,6 +7219,7 @@ export {
7211
7219
  SurfaceLedger,
7212
7220
  THREAD_SCHEMA_VERSION,
7213
7221
  ToolRegistry,
7222
+ USER_DECLINED,
7214
7223
  afterTool,
7215
7224
  appendReasoning,
7216
7225
  appendText,
@@ -7329,6 +7338,7 @@ export {
7329
7338
  isTextPart,
7330
7339
  isToolCallPart,
7331
7340
  isToolResultPart,
7341
+ isUserDecline,
7332
7342
  keyValueCard,
7333
7343
  kindFromStatus,
7334
7344
  lastUserText,