@wildo-ai/saas-frontend-lib 1.1.15 → 1.1.16

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 (94) hide show
  1. package/dist/esm/components/flows-actors/approval.labels.d.ts.map +1 -1
  2. package/dist/esm/components/flows-actors/approval.labels.js +3 -0
  3. package/dist/esm/components/flows-actors/approval.labels.js.map +1 -1
  4. package/dist/esm/components/flows-actors/task-detail.d.ts +12 -1
  5. package/dist/esm/components/flows-actors/task-detail.d.ts.map +1 -1
  6. package/dist/esm/components/flows-actors/task-detail.js +2 -2
  7. package/dist/esm/components/flows-actors/task-detail.js.map +1 -1
  8. package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts +79 -0
  9. package/dist/esm/components/settings/AppPage_AgentActivitySettings.d.ts.map +1 -0
  10. package/dist/esm/components/settings/AppPage_AgentActivitySettings.js +271 -0
  11. package/dist/esm/components/settings/AppPage_AgentActivitySettings.js.map +1 -0
  12. package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts +3 -0
  13. package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.d.ts.map +1 -0
  14. package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js +66 -0
  15. package/dist/esm/components/settings/AppPage_AgentActivitySettings.labels.js.map +1 -0
  16. package/dist/esm/components/settings/SettingsHub.d.ts.map +1 -1
  17. package/dist/esm/components/settings/SettingsHub.js +6 -0
  18. package/dist/esm/components/settings/SettingsHub.js.map +1 -1
  19. package/dist/esm/components/views/composite-view/CompositeView.d.ts +6 -0
  20. package/dist/esm/components/views/composite-view/CompositeView.d.ts.map +1 -1
  21. package/dist/esm/components/views/composite-view/CompositeView.js +12 -2
  22. package/dist/esm/components/views/composite-view/CompositeView.js.map +1 -1
  23. package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts +57 -0
  24. package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.d.ts.map +1 -0
  25. package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js +136 -0
  26. package/dist/esm/components/views/flows-actors-view/ConversationLinkPage.js.map +1 -0
  27. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts +20 -0
  28. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.d.ts.map +1 -1
  29. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js +139 -22
  30. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.js.map +1 -1
  31. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.d.ts.map +1 -1
  32. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js +5 -0
  33. package/dist/esm/components/views/flows-actors-view/FlowsActorsView.labels.js.map +1 -1
  34. package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts +4 -0
  35. package/dist/esm/components/views/flows-actors-view/held-conversation-selection.d.ts.map +1 -1
  36. package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js +19 -0
  37. package/dist/esm/components/views/flows-actors-view/held-conversation-selection.js.map +1 -1
  38. package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts +26 -0
  39. package/dist/esm/components/views/flows-actors-view/linked-conversation.context.d.ts.map +1 -0
  40. package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js +3 -0
  41. package/dist/esm/components/views/flows-actors-view/linked-conversation.context.js.map +1 -0
  42. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.d.ts.map +1 -1
  43. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js +1 -0
  44. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js.map +1 -1
  45. package/dist/esm/core/config/composite-view.schemas.d.ts +19 -0
  46. package/dist/esm/core/config/composite-view.schemas.d.ts.map +1 -1
  47. package/dist/esm/core/config/composite-view.schemas.js.map +1 -1
  48. package/dist/esm/core/config/engine-settings-destinations.d.ts.map +1 -1
  49. package/dist/esm/core/config/engine-settings-destinations.js +23 -0
  50. package/dist/esm/core/config/engine-settings-destinations.js.map +1 -1
  51. package/dist/esm/core/config/settings-hub-presentation.frontend.utils.d.ts.map +1 -1
  52. package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js +3 -0
  53. package/dist/esm/core/config/settings-hub-presentation.frontend.utils.js.map +1 -1
  54. package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts +12 -0
  55. package/dist/esm/core/config/settings-hub.frontend.schemas.d.ts.map +1 -1
  56. package/dist/esm/core/config/settings-hub.frontend.schemas.js +12 -0
  57. package/dist/esm/core/config/settings-hub.frontend.schemas.js.map +1 -1
  58. package/dist/esm/core/events/events.frontend.schemas.d.ts +16 -0
  59. package/dist/esm/core/events/events.frontend.schemas.d.ts.map +1 -1
  60. package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts +10 -1
  61. package/dist/esm/core/flows-actors/FlowsActorsContext.d.ts.map +1 -1
  62. package/dist/esm/core/flows-actors/FlowsActorsContext.js +12 -3
  63. package/dist/esm/core/flows-actors/FlowsActorsContext.js.map +1 -1
  64. package/dist/esm/core/flows-actors/conversation-history.model.d.ts +19 -1
  65. package/dist/esm/core/flows-actors/conversation-history.model.d.ts.map +1 -1
  66. package/dist/esm/core/flows-actors/conversation-history.model.js +45 -4
  67. package/dist/esm/core/flows-actors/conversation-history.model.js.map +1 -1
  68. package/dist/esm/core/navigation/NavigationContentAreas.d.ts +0 -5
  69. package/dist/esm/core/navigation/NavigationContentAreas.d.ts.map +1 -1
  70. package/dist/esm/core/navigation/NavigationContentAreas.js +27 -1
  71. package/dist/esm/core/navigation/NavigationContentAreas.js.map +1 -1
  72. package/dist/esm/core/navigation/navigation.schemas.d.ts +20 -0
  73. package/dist/esm/core/navigation/navigation.schemas.d.ts.map +1 -1
  74. package/dist/esm/core/navigation/navigation.schemas.js +4 -0
  75. package/dist/esm/core/navigation/navigation.schemas.js.map +1 -1
  76. package/dist/esm/core/navigation/useNavigationRouterSync.d.ts.map +1 -1
  77. package/dist/esm/core/navigation/useNavigationRouterSync.js +5 -1
  78. package/dist/esm/core/navigation/useNavigationRouterSync.js.map +1 -1
  79. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +20 -1
  80. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
  81. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +25 -0
  82. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js.map +1 -1
  83. package/dist/esm/core/resources/resources-repository.frontend.service.d.ts.map +1 -1
  84. package/dist/esm/core/resources/resources-repository.frontend.service.js +2 -0
  85. package/dist/esm/core/resources/resources-repository.frontend.service.js.map +1 -1
  86. package/dist/esm/core/runtime/AppRouter.d.ts.map +1 -1
  87. package/dist/esm/core/runtime/AppRouter.js +2 -1
  88. package/dist/esm/core/runtime/AppRouter.js.map +1 -1
  89. package/dist/esm/core/runtime/routes.frontend.definitions.d.ts +6 -0
  90. package/dist/esm/core/runtime/routes.frontend.definitions.d.ts.map +1 -1
  91. package/dist/esm/core/runtime/routes.frontend.definitions.js +7 -1
  92. package/dist/esm/core/runtime/routes.frontend.definitions.js.map +1 -1
  93. package/dist/tsconfig.build.tsbuildinfo +1 -1
  94. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"FlowsActorsContext.js","sourceRoot":"","sources":["../../../../src/core/flows-actors/FlowsActorsContext.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,QAAQ,EAAa,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3G,OAAO,EAKL,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAElB,6CAA6C,EAI7C,4CAA4C,EAE5C,8BAA8B,EAM9B,kBAAkB,EAGlB,iCAAiC,EAKjC,kBAAkB,EAGlB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,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;QAEF,OAAO,GAAG,EAAE;YACV,YAAY,EAAE,CAAC;YACf,YAAY,EAAE,CAAC;YACf,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IAEvC,MAAM,YAAY,GAAG,OAAO,CAAyB,GAAG,EAAE,CAAC,CAAC;QAC1D,OAAO;QACP,gBAAgB;QAChB,UAAU;QACV,kBAAkB;QAClB,wBAAwB;QACxB,SAAS;QACT,KAAK;QACL,UAAU;QACV,cAAc;QACd,iBAAiB;QACjB,cAAc;QACd,eAAe;QACf,cAAc;QACd,YAAY;QACZ,SAAS;QACT,cAAc;QACd,wBAAwB;QACxB,kBAAkB;KACnB,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,wBAAwB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEpS,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC7C,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { createContext, useState, ReactNode, useMemo, useEffect, useCallback, useRef } from 'react';\nimport {\n FlowActorSystem_FrontendInfo,\n FlowsActors_FrontendInfoResponse,\n type FlowsActors_AutonomousAgent_FrontendInfo,\n type FlowsActors_ChatAgent_FrontendInfo,\n MAIN_API_BASE_PATH,\n ManualControllerRouteKey,\n CoreWebSocketEvent,\n type FlowsActors_ConversationHistoryResponse,\n FlowsActors_ConversationHistoryResponseSchema,\n type WS_FlowsActorsStartPayload,\n type WS_FlowsActorsStartedPayload,\n type WS_FlowsActorsMessagePayload,\n WS_FlowsActorsApprovalAnnouncementDataSchema,\n type WS_FlowsActorsApprovalAnnouncementData,\n FlowsActors_ExecutionErrorCode,\n type WS_FlowsActorsApprovalModificationRefusal,\n type WS_FlowsActorsApprovalResponsePayload,\n type WS_FlowsActorsCancelPayload,\n type WS_FlowsActorsCompletedPayload,\n type WS_FlowsActorsTurnUsage,\n FlowsActors_Status,\n type FlowsActors_MessageContentType,\n type WS_FlowsActorsErrorPayload,\n canonicalizeFlowsActorsContextRef,\n type HumanDecision_RouteKind,\n type HumanDecision_Presentation,\n type HumanDecision_Request,\n type HumanDecision_AnswerValue,\n AskPersonOptionRef,\n type WorkUnitRef,\n type ResourceOperationRiskLevel,\n buildManualControllerRoutePath,\n} from '@wildo-ai/saas-models';\nimport type { SerializableZodSchema } from '@wildo-ai/zod-decorators';\nimport { LoggerFrontendService } from '~wildo-frontend-lib/core/monitoring/logger.frontend.service';\nimport { errorManagement } from '~wildo-frontend-lib/core/errors/error-management.frontend.service';\nimport { useApplication } from '~wildo-frontend-lib/core/runtime/useApplication';\nimport { useUserOrgs } from '~wildo-frontend-lib/core/security/useUserOrgs';\nimport { useAppScopeSafe } from '~wildo-frontend-lib/core/scope/useAppScope';\nimport { useWebSocket } from '~wildo-frontend-lib/core/requests/websockets/useWebSocket';\nimport { readJsonResponse } from '~wildo-frontend-lib/core/requests/json-response-reading.frontend';\nimport { useEmitLoadingScope } from '~wildo-frontend-lib/core/loading/useEmitLoadingScope';\nimport { ContextLoadingIdentifier } from '~wildo-frontend-lib/core/loading/loading-types.frontend.schemas';\n\nconst logger: LoggerFrontendService = LoggerFrontendService.getLogger();\nconst logDebug: (message: string, context?: Record<string, unknown>) => void = logger.debugByType('FlowsActorsContext');\nlogger.setDebugTypeLogging('FlowsActorsContext', false);\n\nconst MAX_MESSAGES_PER_EXECUTION: number = 500;\n\ntype ExecutionMessage = FlowsActorsExecution['messages'][number];\n\nfunction appendMessages(existing: ExecutionMessage[], ...newMsgs: ExecutionMessage[]): ExecutionMessage[] {\n const combined = [...existing, ...newMsgs];\n return combined.length > MAX_MESSAGES_PER_EXECUTION\n ? combined.slice(combined.length - MAX_MESSAGES_PER_EXECUTION)\n : combined;\n}\n\n/**\n * Merge one streamed message event into the list. When the event carries a\n * `messageId` matching an existing message, that message is updated in place:\n * a delta event (`isFinal !== true`) appends its `content`; the terminal event\n * (`isFinal === true`) replaces `content` with the authoritative full text (and\n * adopts its rendered `type`, e.g. text → markdown). Events without a known\n * `messageId` are appended as new entries (one-shot / legacy behavior).\n */\nfunction mergeStreamedMessage(\n existing: ExecutionMessage[],\n incoming: ExecutionMessage,\n isFinal: boolean,\n): ExecutionMessage[] {\n if (incoming.messageId) {\n const index = existing.findIndex(m => m.messageId === incoming.messageId);\n if (index >= 0) {\n const updated = [...existing];\n const prev = updated[index];\n updated[index] = {\n ...prev,\n type: incoming.type,\n content: isFinal ? incoming.content : prev.content + incoming.content,\n data: incoming.data ?? prev.data,\n timestamp: incoming.timestamp,\n };\n return updated;\n }\n }\n return appendMessages(existing, incoming);\n}\n\n/**\n * How a turn stands in THIS CLIENT — its view of a turn, which is not the server's run status.\n *\n * Kept distinct on purpose (#2524): the client knows states the server never holds — STARTING (the start is sent and\n * not yet acknowledged), and an ERROR it detects itself when the socket drops — and the server knows states the\n * client never shows (READY, ABORTED). The WIRE speaks the server's vocabulary (`FlowsActors_Status` on\n * `FLOWS_ACTORS_COMPLETED`), and {@link turnStatusFromServer} is the ONE place that reads it into this one.\n */\nexport enum FlowsActorsExecutionStatus {\n IDLE = 'idle',\n STARTING = 'starting',\n RUNNING = 'running',\n AWAITING_APPROVAL = 'awaiting_approval',\n COMPLETED = 'completed',\n /** The person stopped the turn (#2524). Not an error: nothing failed, and the turn's thread continues. */\n CANCELLED = 'cancelled',\n ERROR = 'error',\n}\n\n/**\n * The client's turn status for a status the server ENDED a turn with (`FLOWS_ACTORS_COMPLETED.status`). Total over the\n * server vocabulary, so a status added to it is a compile error here rather than a turn the client never settles.\n */\nconst TURN_STATUS_FROM_SERVER: Record<FlowsActors_Status, FlowsActorsExecutionStatus> = {\n [FlowsActors_Status.COMPLETED]: FlowsActorsExecutionStatus.COMPLETED,\n [FlowsActors_Status.CANCELLED]: FlowsActorsExecutionStatus.CANCELLED,\n [FlowsActors_Status.AWAITING_APPROVAL]: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n [FlowsActors_Status.PROCESSING]: FlowsActorsExecutionStatus.RUNNING,\n [FlowsActors_Status.PENDING]: FlowsActorsExecutionStatus.STARTING,\n [FlowsActors_Status.READY]: FlowsActorsExecutionStatus.STARTING,\n // A run the server ended without completing it, whatever the reason, is an error to the person watching it.\n [FlowsActors_Status.FAILED]: FlowsActorsExecutionStatus.ERROR,\n [FlowsActors_Status.ABORTED]: FlowsActorsExecutionStatus.ERROR,\n};\n\n/** Read a server run status into the client's turn status — the one mapping (#2524). */\nexport function turnStatusFromServer(status: FlowsActors_Status): FlowsActorsExecutionStatus {\n return TURN_STATUS_FROM_SERVER[status] ?? FlowsActorsExecutionStatus.ERROR;\n}\n\n/**\n * The one mapping from a server approval announcement to the client's pending decision — shared by the\n * live socket handler and the history seeding (#1601), so a decision reached either way renders and\n * answers identically.\n *\n * It carries the announcement's typed state and no sentence (#3201). The card words the decision itself, from its\n * presentation's title (`describeHumanDecisionCard`'s phrase) and the tool's title in `flows_actors_tools`, in the\n * reader's language. It used to carry the server's English `Waiting for approval to run \"<tool>\".` as\n * `actionDescription`, which the card rendered as written, naming the tool by its identifier.\n */\nfunction pendingApprovalFromAnnouncement(\n announcement: WS_FlowsActorsApprovalAnnouncementData,\n): NonNullable<FlowsActorsExecution['pendingApproval']> {\n const { approvalId, decisionRef, routeKind, toolName, toolArgs, toolInputSchema, requestedAt, expiresAt, reasonCodes, riskLevel, question, presentation, presentationId } = announcement;\n return {\n approvalId,\n ...(riskLevel ? { riskLevel } : {}),\n toolName,\n toolArgs,\n // A descriptor the transport does not re-validate (#587) — typed here for the editor, which falls\n // back to raw JSON for any shape it cannot render as fields.\n toolInputSchema: toolInputSchema as SerializableZodSchema | undefined,\n requestedAt: new Date(requestedAt),\n expiresAt: expiresAt ? new Date(expiresAt) : undefined,\n decisionRef,\n routeKind,\n ...(reasonCodes && reasonCodes.length > 0 ? { reasonCodes } : {}),\n ...(question ? { question } : {}),\n ...(presentation ? { presentation } : {}),\n ...(presentationId ? { presentationId } : {}),\n };\n}\n\n/**\n * Active Execution State\n */\nexport interface FlowsActorsExecution {\n executionId: string;\n systemRef: string;\n status: FlowsActorsExecutionStatus;\n messages: Array<{\n /** The message vocabulary's VALUE (`FlowsActors_MessageContentType`), the wire's `messageType`. */\n type: `${FlowsActors_MessageContentType}`;\n content: string;\n data?: Record<string, unknown>;\n timestamp: Date;\n /**\n * Correlation id for streamed messages. Consecutive `messageId`-sharing\n * events belong to one logical message: non-final events append their\n * delta to `content`; the final event replaces `content` with the full text.\n * Absent for one-shot messages (each is its own entry).\n */\n messageId?: string;\n }>;\n /**\n * The decision a paused turn is waiting on, read from `WS_FlowsActorsApprovalAnnouncementData` — carried in the `data`\n * bag of a PROGRESS message: tool name, tool arguments, timing, the isolation axis (#528), and the risk the call's\n * approval gate declares (#2526).\n */\n pendingApproval?: {\n approvalId: string;\n /**\n * The risk the call's approval gate DECLARES (`humanApproval.riskLevel`), as the decision's inbox card carries it\n * (#2526). Absent when the gate declares none; a surface then shows no risk claim, because nothing declared one.\n */\n riskLevel?: ResourceOperationRiskLevel;\n expiresAt?: Date;\n /** The tool call being gated, and its arguments — the structured thing being approved. */\n toolName?: string;\n toolArgs?: Record<string, unknown>;\n /**\n * The gated tool's input schema as a serialized descriptor (#587), so an editor can offer the\n * tool's fields. A rendering hint only — the server re-validates every modification.\n */\n toolInputSchema?: SerializableZodSchema;\n /**\n * The server's refusal of the approver's last edit, when it refused one (#587). The approval is\n * still pending when this is set: a refused modification leaves the pause standing, so the\n * surface keeps the decision on screen with the reason instead of dropping it.\n *\n * STRUCTURED, not the server's sentence (#1186): the card renders a label per reason, naming the\n * tool and the offending arguments as parameters. A server that sent no structure (older than the\n * field) yields an empty `reason`, which the card reads as \"refused, reason not stated\".\n */\n modificationRefusal?: WS_FlowsActorsApprovalModificationRefusal;\n /** The arguments the approver submitted in that refused edit, so the editor reopens on them (#587). */\n rejectedToolArgs?: Record<string, unknown>;\n /**\n * What the server built for the person to read (#2903): the arguments as strings it already projected, which the card\n * renders verbatim. Absent on a turn paused before decisions were routed.\n */\n presentation?: HumanDecision_Presentation;\n /** The presentation's id, echoed on the answer: the server refuses an answer that does not name what it was given on. */\n presentationId?: string;\n requestedAt?: Date;\n /**\n * The decision's one id (#1594), ECHOED back on the answer. The server addresses the decision by\n * it and reads everything else — owner, credential, agent instance — off the row.\n */\n decisionRef?: string;\n /**\n * Who answers it (#1594). Anything but OWNER is answered by a reviewer from their inbox, and the person\n * whose conversation this is may not answer it — so a surface shows it as waiting rather than offering\n * buttons the server would refuse. Absent means OWNER (a pause raised before routes existed).\n */\n routeKind?: HumanDecision_RouteKind;\n /**\n * The reason codes the answer may carry (#1921) — the application's declared vocabulary, offered when the approver\n * changes or rejects the call. Absent when the application declares none.\n */\n reasonCodes?: readonly string[];\n /**\n * Set when the server refused the last answer's reason code (#1921): the pause stands, the approval is back on\n * screen, and the card says the reason was not one the application offers. Cleared by the next answer.\n */\n reasonCodeRefused?: boolean;\n /**\n * The QUESTION, when the paused call is the agent asking its person (#2720): its questions, its two answers and the\n * form they are asked through. Answered with `answerQuestion`, never approved.\n */\n question?: HumanDecision_Request;\n };\n /** Set when the last error is recoverable (UI can offer a retry action) */\n recoverable?: boolean;\n /**\n * The approval this client last ANSWERED, kept until the server's reaction is known (#587).\n *\n * Answering clears `pendingApproval` at once, which is right when the decision lands. But a refused\n * modification leaves the server's pause standing, and without this the surface would have nothing to\n * put back on screen — the approval would vanish while still waiting. `submittedToolArgs` is what the\n * approver authored, so a restored editor reopens on their edit rather than on the model's call.\n */\n answeredApproval?: {\n approval: NonNullable<FlowsActorsExecution['pendingApproval']>;\n submittedToolArgs?: Record<string, unknown>;\n };\n duration?: number;\n /** The tokens the turn spent — present only for a person who may read model cost (#2524). */\n usage?: WS_FlowsActorsTurnUsage;\n errorCode?: string;\n}\n\n/**\n * FlowsActors Context Type\n */\nexport interface FlowsActorsContextType {\n /** Available frontend-visible FlowActorSystems */\n systems: FlowActorSystem_FrontendInfo[];\n\n /**\n * The autonomous agents the application declares (#1611), in declaration order — the closed set an\n * organization OAuth client may be bound to, so a binding form offers these rather than free text (#1812).\n * Empty until the first fetch settles, and when the application declares none.\n */\n autonomousAgents: FlowsActors_AutonomousAgent_FrontendInfo[];\n\n /**\n * The chat agents the application declares (#2665), in declaration order — the closed set an organization's chat\n * setting may name. Empty until the first fetch settles, and when the application declares none.\n */\n chatAgents: FlowsActors_ChatAgent_FrontendInfo[];\n\n /**\n * The chat connections an organization may choose an agent for (#2665): the application's providers enabled here\n * with a chat endpoint (`slack`, `microsoft-teams-bot`). Empty until the first fetch settles, and when there is none.\n */\n chatConnectionRefs: string[];\n\n /**\n * Ask for the agent declarations — {@link autonomousAgents}, {@link chatAgents} and {@link chatConnectionRefs} — to be\n * loaded, whatever else this application renders.\n *\n * The provider bootstraps `/flows-actors/frontend-info` only when the application configures a flows/actors\n * VIEW (pinned: an application with no chat surface makes no such request). Neither an autonomous agent nor a chat\n * agent needs a view, so a surface that needs the declarations (the OAuth client binding form, #1812; the chat\n * settings form, #2665) calls this instead. It fetches once per sign-in, and does nothing when a fetch already ran or\n * cannot run yet (signed out, no backend endpoint, no http client). Idempotent, so call it from an effect.\n */\n requestAgentDeclarations: () => void;\n\n /** Loading state */\n isLoading: boolean;\n\n /** Error state */\n error: Error | null;\n\n /** Active executions */\n executions: Map<string, FlowsActorsExecution>;\n\n /** Start a new execution (fire-and-forget via WebSocket; returns local executionId) */\n /**\n * Send a turn. A new `executionId` opens a thread; an existing one continues it. The optional\n * identifiers are folded into the thread's `contextRef` on open (see `fetchConversationHistory`).\n *\n * `options.caseRef` (#1598) names the case the thread works on — a row of a resource declared `workUnit: true` —\n * so the model calls it makes are attributed to that case. Read when the thread OPENS; a later turn keeps the\n * thread's case. The server admits it only if the caller can read that row.\n */\n startExecution: (\n systemRef: string,\n initialInput?: Record<string, unknown>,\n existingExecutionId?: string,\n extraContextResourceIdentifiers?: Record<string, string>,\n /**\n * `messageId`: the id the person's message is stored under (#2525 review N1). A page drawing the message before the\n * record holds it mints one, and recognises the stored message by it.\n */\n options?: { caseRef?: WorkUnitRef; messageId?: string },\n ) => string | null;\n\n /** Respond to an approval request (fire-and-forget via WebSocket) */\n /**\n * `modifiedToolArgs` (#566) replaces the arguments the agent proposed. Absent means \"run the call\n * as proposed\"; the server validates the edit against the tool's own schema and refuses through\n * `FLOWS_ACTORS_ERROR` with the approval left pending.\n */\n /** `reasonCode` is one of the approval's `reasonCodes` (#1921), given when the approver changes or rejects the call. */\n respondToApproval: (executionId: string, approvalId: string, approved: boolean, comment?: string, modifiedToolArgs?: Record<string, unknown>, reasonCode?: string) => void;\n\n /**\n * Answer the paused turn's QUESTION (#2720): the option chosen and, when it sends answers, one value per question as\n * its JSON (what `HumanDecisionForm` reads). The server checks the values with the question's own form and refuses\n * through `FLOWS_ACTORS_ERROR` with the question left pending.\n */\n answerQuestion: (executionId: string, optionRef: string, values: readonly { ref: string; value: HumanDecision_AnswerValue }[], comment?: string) => void;\n\n /**\n * Stop the person's own running turn (#2524). The server ends it CANCELLED, keeping what it had produced, and the\n * turn settles on `FLOWS_ACTORS_COMPLETED` like any other — nothing is settled here, so a stop that races the turn's\n * own end cannot leave the two disagreeing.\n */\n cancelExecution: (executionId: string) => void;\n\n /** Remove a completed/errored execution from state */\n clearExecution: (executionId: string) => void;\n\n /** Get execution by ID (reads from ref; consume `executions` to re-render on changes) */\n getExecution: (executionId: string) => FlowsActorsExecution | undefined;\n\n /** Get system by ref */\n getSystem: (systemRef: string) => FlowActorSystem_FrontendInfo | undefined;\n\n /** Refresh systems from backend */\n refreshSystems: () => Promise<void>;\n\n /**\n * The caller's OWN persisted threads for a system, server-authoritative (the executions resource, USER_SELF-scoped to\n * the caller): what repopulates the discussion list and the transcripts on a fresh page load. With\n * `contextResourceIdentifiers`, only the threads opened in that context — the same identifiers passed to\n * `startExecution`, canonicalised the same way — which is how a surface hosting one system for several subjects keeps\n * them apart.\n *\n * Reads a PAGE (#2528): the newest threads, or with `before` (the oldest `createdAt` a host already holds) the ones\n * before it, inclusive — so a host keeps each `executionId` once. `hasOlder` says whether another page remains.\n *\n * Resolves an empty page when there are none, or when the backend has no flows-actors history surface (feature\n * absent), and `undefined` when the read FAILED (#2525 review M4). The two must not look alike: a host re-reads after\n * every turn, and treating a failure as \"no threads\" emptied its discussion list and transcript — under the very\n * outage that had just ended the turn. Keep the last good list on `undefined`.\n */\n fetchConversationHistory: (\n systemRef: string,\n contextResourceIdentifiers?: Record<string, string>,\n page?: { readonly before?: string },\n ) => Promise<FlowsActors_ConversationHistoryResponse | undefined>;\n\n /**\n * Delete ONE of the caller's own persisted conversations (a discussion). Runs\n * under the caller's auth, so the executions resource's USER_SELF owner filter\n * only ever deletes the caller's own row. Resolves once the server confirms.\n */\n deleteConversation: (executionId: string) => Promise<void>;\n}\n\n/**\n * FlowsActors Context\n * @internal - Use useFlowsActors() hook instead of accessing this directly\n */\nexport const FlowsActorsContext: React.Context<FlowsActorsContextType | undefined> = createContext<FlowsActorsContextType | undefined>(undefined);\n\n/**\n * FlowsActors Provider\n *\n * Manages:\n * - Available FlowActorSystems (fetched at startup)\n * - Active execution state\n * - WebSocket communication for real-time updates\n */\nexport const FlowsActorsProvider: React.FC<{ children: ReactNode }> = ({ children }) => {\n const { appConfig, frontendConfiguration, httpClient } = useApplication();\n const userOrgs = useUserOrgs();\n const appScope = useAppScopeSafe();\n const { on, emit, isConnected } = useWebSocket();\n const hasInitializedRef = useRef(false);\n const hasConfiguredFlowsActorsViews = (frontendConfiguration?.flowsActorsViews?.length ?? 0) > 0;\n\n const [systems, setSystems] = useState<FlowActorSystem_FrontendInfo[]>([]);\n const [autonomousAgents, setAutonomousAgents] = useState<FlowsActors_AutonomousAgent_FrontendInfo[]>([]);\n const [chatAgents, setChatAgents] = useState<FlowsActors_ChatAgent_FrontendInfo[]>([]);\n const [chatConnectionRefs, setChatConnectionRefs] = useState<string[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [executions, setExecutions] = useState<Map<string, FlowsActorsExecution>>(new Map());\n // L-2.b: explicit \"has the registry ever completed at least one successful\n // fetch\" marker, distinct from `systems.length > 0` (an empty registry is\n // still a successful fetch — the backend may legitimately ship zero\n // flow-actor systems for a given app, and we don't want every refresh of an\n // empty registry to render as INITIAL phase).\n const [hasCompletedFetch, setHasCompletedFetch] = useState(false);\n\n useEmitLoadingScope({\n identifier: ContextLoadingIdentifier.FLOWS_ACTORS,\n isLoading,\n hasLoadedOnce: hasCompletedFetch,\n });\n const executionsRef = useRef(executions);\n executionsRef.current = executions;\n\n const updateExecution = useCallback((\n executionId: string,\n updater: (execution: FlowsActorsExecution) => FlowsActorsExecution,\n ): void => {\n setExecutions(prev => {\n const existing = prev.get(executionId);\n if (!existing) return prev;\n const next = new Map(prev);\n next.set(executionId, updater(existing));\n return next;\n });\n }, []);\n\n /**\n * Fetch frontend-visible systems from backend\n */\n const refreshSystems = useCallback(async () => {\n if (!appConfig?.runtime?.endPoints?.main_backend_api) {\n logDebug('Cannot refresh systems - API endpoint not configured');\n return;\n }\n\n if (!httpClient) {\n logDebug('Cannot refresh systems - httpClient not available');\n return;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n // Use httpClient which handles authentication automatically. The path is\n // built from the shared route registry (same source the backend controller\n // registers with) so both sides stay in lockstep under MAIN_API_BASE_PATH.\n const data = await httpClient.get<FlowsActors_FrontendInfoResponse>(\n `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_FRONTEND_INFO)}`\n );\n setSystems(data.systems);\n setAutonomousAgents(data.autonomousAgents);\n setChatAgents(data.chatAgents);\n setChatConnectionRefs(data.chatConnectionRefs);\n setHasCompletedFetch(true);\n\n logDebug('Systems refreshed', { count: data.systems.length });\n\n } catch (err) {\n if (errorManagement.isNotFoundError(err)) {\n logDebug('FlowsActors backend support not available - skipping systems bootstrap');\n setSystems([]);\n setAutonomousAgents([]);\n setChatAgents([]);\n setChatConnectionRefs([]);\n setError(null);\n setHasCompletedFetch(true);\n return;\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n logDebug('Failed to refresh systems', { error: error.message });\n } finally {\n setIsLoading(false);\n }\n }, [appConfig?.runtime?.endPoints?.main_backend_api, httpClient]);\n\n /**\n * Fetch the caller's persisted conversation history for a system. Runs under\n * the caller's own auth (httpClient), so the executions resource's USER_SELF\n * owner filter restricts rows to the caller's threads. A missing backend\n * surface (feature absent) resolves to `[]`, never an error.\n */\n const fetchConversationHistory = useCallback(async (\n systemRef: string,\n contextResourceIdentifiers?: Record<string, string>,\n page?: { readonly before?: string },\n ): Promise<FlowsActors_ConversationHistoryResponse | undefined> => {\n if (!httpClient) {\n logDebug('Cannot fetch conversation history - httpClient not available');\n return undefined;\n }\n try {\n const basePath = `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_HISTORY)}`;\n const contextRef = contextResourceIdentifiers === undefined\n ? undefined\n : canonicalizeFlowsActorsContextRef({\n ...(appScope?.currentOrganizationId ? { organizationId: appScope.currentOrganizationId } : {}),\n ...contextResourceIdentifiers,\n });\n const query = `?systemRef=${encodeURIComponent(systemRef)}${contextRef === undefined ? '' : `&contextRef=${encodeURIComponent(contextRef)}`}`\n + (page?.before ? `&before=${encodeURIComponent(page.before)}` : '');\n // Its dates restored (#3478): the history's message dates arrive as RFC 3339 strings.\n const data: FlowsActors_ConversationHistoryResponse = readJsonResponse(FlowsActors_ConversationHistoryResponseSchema, await httpClient.get<unknown>(`${basePath}${query}`));\n logDebug('Conversation history fetched', { systemRef, count: data.executions.length });\n /*\n * A thread whose turn is paused on a decision becomes an execution here, carrying that\n * decision (#1601). The pause is announced only over the live socket, so a page that loaded\n * after it — a reload, a second tab, a restart — had a thread waiting on an answer and nothing\n * to answer it with: the creator saw their message sit unanswered. The history route now\n * returns the same announcement the socket carried, and it is folded through the same mapping.\n *\n * A live entry is never replaced: the socket is the fresher source for a turn this page is\n * watching, and a seeded copy could revive a decision this client just answered. Except one: an\n * entry in ERROR with DECISION_PENDING, which says only \"the thread waits for a decision this\n * page does not hold\", so the stored decision is the fresher of the two. It arrives two ways: a\n * message this page sent was refused (#2721 review F-2), or a turn this page was watching ended\n * because another turn's decision now holds the thread (#2721 re-review N-1), including the turn\n * this page resumed by answering. That last case cannot revive the answered decision: the event\n * names the decision that waits (`waitingDecisionRef`), the error arm records the entry only when\n * it is NOT the decision the page holds (re-review R-2), and the row history returns holds that\n * waiting decision, not the answered one.\n */\n const paused = data.executions.filter((row) => row.pendingApproval !== undefined);\n if (paused.length > 0) {\n setExecutions((prev) => {\n let next: Map<string, FlowsActorsExecution> | undefined;\n for (const row of paused) {\n const live = prev.get(row.executionId);\n // #2903: an answer refused as stale leaves the decision waiting as it is NOW, which only the stored row says.\n // #2923: so does an answer refused for carrying no step-up the decision requires.\n const refusedForAnUnheldDecision = live?.status === FlowsActorsExecutionStatus.ERROR\n && (live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PENDING\n || live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PRESENTATION_STALE\n || live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_STEP_UP_REQUIRED);\n if ((live && !refusedForAnUnheldDecision) || row.pendingApproval === undefined) continue;\n next ??= new Map(prev);\n next.set(row.executionId, {\n executionId: row.executionId,\n systemRef: row.systemRef,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n messages: [],\n pendingApproval: pendingApprovalFromAnnouncement(row.pendingApproval),\n });\n }\n return next ?? prev;\n });\n }\n return { executions: data.executions, hasOlder: data.hasOlder === true };\n } catch (err) {\n if (errorManagement.isNotFoundError(err)) {\n logDebug('FlowsActors history surface not available - returning empty history', { systemRef });\n return { executions: [], hasOlder: false };\n }\n // A failed read is not an empty history: the host keeps what it last read (#2525 review M4).\n logger.warn('Failed to fetch conversation history', { systemRef, error: err instanceof Error ? err.message : 'unknown' });\n return undefined;\n }\n }, [httpClient, appScope?.currentOrganizationId]);\n\n /**\n * Delete one of the caller's persisted conversations. Owner-scoped server-side\n * (USER_SELF), so a user can only delete their own discussion.\n */\n const deleteConversation = useCallback(async (executionId: string): Promise<void> => {\n if (!httpClient) {\n logDebug('Cannot delete conversation - httpClient not available');\n return;\n }\n const basePath = `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_HISTORY)}`;\n await httpClient.delete(`${basePath}?executionId=${encodeURIComponent(executionId)}`);\n logDebug('Conversation deleted', { executionId });\n }, [httpClient]);\n\n /**\n * Start a new execution via WebSocket (fire-and-forget).\n * Errors are delivered asynchronously via FLOWS_ACTORS_STARTED / FLOWS_ACTORS_ERROR events.\n */\n const startExecution = useCallback((\n systemRef: string,\n initialInput?: Record<string, unknown>,\n existingExecutionId?: string,\n extraContextResourceIdentifiers?: Record<string, string>,\n options?: { caseRef?: WorkUnitRef; messageId?: string },\n ): string | null => {\n if (!isConnected) {\n logDebug('Cannot start execution — WebSocket not connected', { systemRef });\n return null;\n }\n\n // Reuse the id to CONTINUE a discussion (one execution = one thread); mint a\n // new one to start a fresh discussion.\n const executionId = existingExecutionId ?? crypto.randomUUID();\n logDebug('Starting execution', { systemRef, executionId, hasInput: !!initialInput, isContinuation: !!existingExecutionId });\n\n /*\n * The scope's own identifiers first, the caller's on top: a surface that hosts one system for\n * several subjects (a tool pointed at one application at a time) names the subject here, and\n * the backend folds the whole set into the thread's `contextRef`, which `fetchConversationHistory`\n * lists by when handed the same identifiers.\n */\n const contextResourceIdentifiers: Record<string, string> = {};\n if (appScope?.currentOrganizationId) {\n contextResourceIdentifiers.organizationId = appScope.currentOrganizationId;\n }\n Object.assign(contextResourceIdentifiers, extraContextResourceIdentifiers ?? {});\n\n setExecutions(prev => {\n const next = new Map(prev);\n // Reset messages every turn: the live execution holds ONLY the current\n // turn's streamed reply. Prior turns of a continued thread live in the\n // view's transcript, so keeping them here would make the streamed bubble\n // replay the whole thread (duplicate content).\n next.set(executionId, {\n executionId,\n systemRef,\n status: FlowsActorsExecutionStatus.STARTING,\n messages: [],\n });\n return next;\n });\n\n emit<WS_FlowsActorsStartPayload>(CoreWebSocketEvent.FLOWS_ACTORS_START, {\n systemRef,\n executionId,\n contextResourceIdentifiers,\n initialInput,\n ...(options?.caseRef ? { caseRef: options.caseRef } : {}),\n ...(options?.messageId ? { messageId: options.messageId } : {}),\n });\n\n return executionId;\n }, [isConnected, emit, appScope?.currentOrganizationId]);\n\n /**\n * Respond to an approval request via WebSocket (fire-and-forget).\n * The resumed turn sends no FLOWS_ACTORS_STARTED: it continues the paused turn, streams to the conversation's\n * owner, and ends on FLOWS_ACTORS_COMPLETED (completed, cancelled) or FLOWS_ACTORS_ERROR.\n */\n const respondToApproval = useCallback((\n executionId: string,\n approvalId: string,\n approved: boolean,\n comment?: string,\n modifiedToolArgs?: Record<string, unknown>,\n reasonCode?: string,\n ): void => {\n const execution = executionsRef.current.get(executionId);\n if (!execution) {\n logDebug('Cannot respond to approval — execution not found', { executionId, approvalId });\n return;\n }\n\n if (!isConnected) {\n logDebug('Cannot respond to approval — WebSocket not connected', { executionId, approvalId });\n return;\n }\n\n logDebug('Responding to approval', { executionId, approvalId, approved, modified: modifiedToolArgs !== undefined });\n\n emit<WS_FlowsActorsApprovalResponsePayload>(CoreWebSocketEvent.FLOWS_ACTORS_APPROVAL_RESPONSE, {\n systemRef: execution.systemRef,\n executionId,\n approvalId,\n approved,\n comment,\n /*\n * The decision's id, echoed (#1594). The server addresses the answer by it and reads the owner,\n * credential and agent instance off the row — so nothing here can point the answer at a different\n * conversation, and a reviewer answering someone else's decision reaches it.\n */\n ...(execution.pendingApproval?.decisionRef ? { decisionRef: execution.pendingApproval.decisionRef } : {}),\n // #2903: the presentation this answer was given on. The server refuses an answer naming none, or a stale one.\n ...(execution.pendingApproval?.presentationId ? { presentationId: execution.pendingApproval.presentationId } : {}),\n /*\n * The arguments the approver AUTHORED (#566), when they edited the proposed call.\n *\n * Sent only when present. Sending `{}` for an unedited approval would reach the server as a\n * modification the tool's schema then rejects, turning every ordinary approval into a\n * refusal — the mirror of the defect that made this field necessary.\n */\n ...(modifiedToolArgs ? { modifiedToolArgs } : {}),\n // Why the approver changed or rejected the call (#1921), one of the application's declared codes. The server\n // checks it against the same vocabulary and refuses an undeclared one, leaving the pause standing.\n ...(reasonCode ? { reasonCode } : {}),\n });\n\n updateExecution(executionId, exec => ({\n ...exec,\n status: approved ? FlowsActorsExecutionStatus.RUNNING : exec.status,\n // The refusal an earlier answer met is answered by this one: a later pause must not inherit its code (#2525).\n errorCode: undefined,\n recoverable: undefined,\n pendingApproval: undefined,\n // Kept until the server reacts: a REFUSED modification leaves the pause standing, and this is\n // what the error handler restores — with the arguments the approver submitted (#587).\n answeredApproval: exec.pendingApproval\n ? { approval: exec.pendingApproval, ...(modifiedToolArgs ? { submittedToolArgs: modifiedToolArgs } : {}) }\n : undefined,\n }));\n }, [isConnected, emit, updateExecution]);\n\n const answerQuestion = useCallback((\n executionId: string,\n optionRef: string,\n values: readonly { ref: string; value: HumanDecision_AnswerValue }[],\n comment?: string,\n ): void => {\n const execution = executionsRef.current.get(executionId);\n const pending = execution?.pendingApproval;\n if (!execution || !pending?.question || !pending.decisionRef || !isConnected) {\n logDebug('Cannot answer a question — no paused question, or the WebSocket is not connected', { executionId });\n return;\n }\n const sendsAnswers = optionRef === AskPersonOptionRef.ANSWER;\n emit<WS_FlowsActorsApprovalResponsePayload>(CoreWebSocketEvent.FLOWS_ACTORS_APPROVAL_RESPONSE, {\n systemRef: execution.systemRef,\n executionId,\n approvalId: pending.approvalId,\n decisionRef: pending.decisionRef,\n // #2903: the presentation this answer was given on.\n ...(pending.presentationId ? { presentationId: pending.presentationId } : {}),\n // Not read for a question: the answer below is what settles it. Sent because the payload requires a verdict.\n approved: sendsAnswers,\n answer: { decisionId: pending.decisionRef, optionRef, values: [...values] },\n // A note in the person's own words travels with the answer, or with the decline, to the agent.\n ...(comment ? { comment } : {}),\n });\n updateExecution(executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.RUNNING,\n errorCode: undefined,\n recoverable: undefined,\n pendingApproval: undefined,\n // Kept until the server reacts: an answer its form refuses leaves the question pending, and this restores it.\n answeredApproval: exec.pendingApproval ? { approval: exec.pendingApproval } : undefined,\n }));\n }, [isConnected, emit, updateExecution]);\n\n /**\n * Get execution by ID\n */\n const getExecution = useCallback((executionId: string): FlowsActorsExecution | undefined => {\n return executionsRef.current.get(executionId);\n }, []);\n\n /**\n * Get system by ref\n */\n const getSystem = useCallback((systemRef: string): FlowActorSystem_FrontendInfo | undefined => {\n return systems.find(s => s.ref === systemRef);\n }, [systems]);\n\n const cancelExecution = useCallback((executionId: string): void => {\n const execution = executionsRef.current.get(executionId);\n if (!execution || !isConnected) return;\n emit<WS_FlowsActorsCancelPayload>(CoreWebSocketEvent.FLOWS_ACTORS_CANCEL, { systemRef: execution.systemRef, executionId });\n }, [isConnected, emit]);\n\n const clearExecution = useCallback((executionId: string): void => {\n setExecutions(prev => {\n if (!prev.has(executionId)) return prev;\n const next = new Map(prev);\n next.delete(executionId);\n return next;\n });\n }, []);\n\n /**\n * Initialize on mount when authenticated\n */\n useEffect(() => {\n if (userOrgs.isAuthenticated()) {\n return;\n }\n\n hasInitializedRef.current = false;\n setSystems([]);\n setAutonomousAgents([]);\n setChatAgents([]);\n setChatConnectionRefs([]);\n setError(null);\n setExecutions(new Map());\n }, [userOrgs]);\n\n const requestAgentDeclarations = useCallback((): void => {\n if (\n hasInitializedRef.current\n || !appConfig?.runtime?.endPoints?.main_backend_api\n || !httpClient\n || !userOrgs.isAuthenticated()\n ) {\n return;\n }\n hasInitializedRef.current = true;\n void refreshSystems();\n }, [appConfig?.runtime?.endPoints?.main_backend_api, httpClient, userOrgs, refreshSystems]);\n\n useEffect(() => {\n if (\n !hasInitializedRef.current\n && hasConfiguredFlowsActorsViews\n && appConfig?.runtime?.endPoints?.main_backend_api\n && httpClient\n && userOrgs.isAuthenticated()\n ) {\n hasInitializedRef.current = true;\n refreshSystems();\n }\n }, [\n appConfig?.runtime?.endPoints?.main_backend_api,\n hasConfiguredFlowsActorsViews,\n httpClient,\n userOrgs,\n refreshSystems,\n ]);\n\n /**\n * A dropped socket ENDS every turn still in flight on it.\n *\n * The server emits a turn's events to the socket that started it (`conversational-execution`'s\n * emitter is bound to that socket), so once it drops, no `STARTED`, `MESSAGE`, `COMPLETED` or\n * `ERROR` for that turn can ever arrive — not after a reconnect either, which opens a different\n * socket. Before this, a turn sent into a companion that restarted a second later stayed `STARTING`\n * for good: the page showed neither the question nor an error, and the composer sat on its stop\n * button (measured for eight minutes on the creation workbench, 2026-09-24, #1464).\n *\n * Only `STARTING` and `RUNNING` end. A turn `AWAITING_APPROVAL` is a persisted suspension the person\n * answers later, over whatever socket is live then, so a drop does not end it. The error is\n * RECOVERABLE and names its cause with a CLIENT-DETECTED code, carrying no text of its own: every\n * surface already words an errored turn, and a surviving server still completes and persists the\n * turn, which the thread's history then shows.\n */\n const wasConnectedRef = useRef(isConnected);\n useEffect(() => {\n const dropped = wasConnectedRef.current && !isConnected;\n wasConnectedRef.current = isConnected;\n if (!dropped) return;\n setExecutions(prev => {\n let next: Map<string, FlowsActorsExecution> | null = null;\n for (const [executionId, execution] of prev) {\n if (execution.status !== FlowsActorsExecutionStatus.STARTING && execution.status !== FlowsActorsExecutionStatus.RUNNING) continue;\n next ??= new Map(prev);\n next.set(executionId, {\n ...execution,\n status: FlowsActorsExecutionStatus.ERROR,\n recoverable: true,\n errorCode: FlowsActors_ExecutionErrorCode.CONNECTION_LOST,\n });\n }\n return next ?? prev;\n });\n }, [isConnected]);\n\n /**\n * WebSocket event listeners for FlowsActors inbound events.\n * Follows the WebSocketEventBridge pattern: subscribe on connect, cleanup on disconnect.\n */\n useEffect(() => {\n if (!isConnected) {\n return;\n }\n\n const unsubStarted = on<WS_FlowsActorsStartedPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_STARTED,\n (payload) => {\n logDebug('Execution started', { executionId: payload.executionId });\n // Only ever a success: a turn that could not start reports on FLOWS_ACTORS_ERROR (#2524).\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.RUNNING,\n }));\n }\n );\n\n const unsubMessage = on<WS_FlowsActorsMessagePayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_MESSAGE,\n (payload) => {\n logDebug('Execution message', { executionId: payload.executionId, type: payload.messageType, messageId: payload.messageId, isFinal: payload.isFinal });\n\n /*\n * A pause is announced HERE, inside a PROGRESS message's `data` bag — never on a separate\n * approval-request event, which nothing emitted and #2524 removed. Parsed rather than key-picked, so\n * the browser and the producer share one named contract; a bag that is not an announcement\n * simply fails the parse and the message is stored like any other (#528).\n */\n const announcement = WS_FlowsActorsApprovalAnnouncementDataSchema.safeParse(payload.data);\n if (announcement.success) {\n const { approvalId, toolName } = announcement.data;\n logDebug('Approval requested', { executionId: payload.executionId, approvalId, toolName });\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n // A new pause supersedes whatever this client answered before it.\n answeredApproval: undefined,\n // The typed announcement only: the card words it in the reader's language (#3201). The PROGRESS text is\n // the tool's name, never a sentence to render.\n pendingApproval: pendingApprovalFromAnnouncement(announcement.data),\n }));\n }\n\n updateExecution(payload.executionId, exec => ({\n ...exec,\n messages: mergeStreamedMessage(\n exec.messages,\n {\n type: payload.messageType,\n content: payload.content,\n data: payload.data,\n timestamp: payload.timestamp instanceof Date ? payload.timestamp : new Date(payload.timestamp),\n messageId: payload.messageId,\n },\n payload.isFinal === true,\n ),\n }));\n }\n );\n\n const unsubCompleted = on<WS_FlowsActorsCompletedPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_COMPLETED,\n (payload) => {\n logDebug('Execution completed', { executionId: payload.executionId, status: payload.status, duration: payload.duration });\n // The server's run status, read through the one mapping (#2524): COMPLETED, or CANCELLED when the person\n // stopped it. A failure never arrives here — it reports on FLOWS_ACTORS_ERROR with its reason.\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: turnStatusFromServer(payload.status),\n pendingApproval: undefined,\n duration: payload.duration,\n ...(payload.usage ? { usage: payload.usage } : {}),\n }));\n }\n );\n\n const unsubError = on<WS_FlowsActorsErrorPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_ERROR,\n (payload) => {\n logDebug('Execution error', { executionId: payload.executionId, errorCode: payload.errorCode, recoverable: payload.recoverable });\n updateExecution(payload.executionId, exec => {\n /*\n * A refused MODIFICATION is not a failed turn (#587). The server leaves the pause standing and\n * says so with `recoverable: true`, so the decision goes back on screen — with the reason, and\n * with the arguments the approver submitted — instead of vanishing while the server still\n * waits for it. Treating it as ERROR is what made the approval disappear on every refusal.\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.APPROVAL_MODIFICATION_REJECTED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: payload.approvalModificationRefusal ?? { reason: '' },\n rejectedToolArgs: exec.answeredApproval.submittedToolArgs,\n // A refusal of THIS answer, not the reason code of an earlier one (#1921).\n reasonCodeRefused: undefined,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * A reason code the application does not declare is refused while the pause stands (#1921). The approval goes\n * back on screen as it was asked, and the card says why in its own labels — the server's English sentence is\n * not appended to the conversation, because words a reader sees come from the label tree.\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.APPROVAL_REASON_CODE_REJECTED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: undefined,\n rejectedToolArgs: undefined,\n reasonCodeRefused: true,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * A decision refused by the application's consent requirement is not a failed turn either (#534). The\n * server checks the requirement BEFORE it releases the pause, so the approval still stands and can be\n * answered once the person has recorded their consent: it goes back on screen with its `errorCode`, which\n * the conversation thread words (`consentRequired`) above the decision rather than as an argument-edit error.\n * The server's English `errorMessage` is not appended to the turn: it is no reply, and no translator reaches\n * it (#2525).\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.SERVICE_CONSENT_REQUIRED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n // Restored as it was ASKED, not as it was last refused: an earlier refused edit's error must not\n // reappear, and the arguments just submitted reopen the editor (#534 fourth review F5).\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: undefined,\n rejectedToolArgs: exec.answeredApproval.submittedToolArgs,\n reasonCodeRefused: undefined,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * DECISION_PENDING is not this tab's failure either (#2721 review F-2). It arrives for a message refused\n * because the thread waits for a decision, and as the END of a turn whose own end was not written because\n * another turn's decision now holds the thread (#2721 re-review N-1). It reaches every tab of the owner's\n * room, so a tab that holds THAT decision — asked, or answered and awaiting the server — keeps it exactly as\n * it is: the decision is the thread's state, and clearing it here took the card away from the one tab that\n * could act on it. Any other tab records it as ERROR, worded by `decisionPending`, and its history reload\n * restores the waiting decision over it (`fetchConversationHistory`). That includes a tab holding a\n * DIFFERENT decision (#2721 re-review R-2): the tab that answered D1 while another door's turn paused the\n * thread on D2, or a second tab still showing the settled D1. Kept, either stayed RUNNING or on a dead card,\n * and history could not help, since it never replaces an entry it does not see as refused.\n */\n const heldDecisionRef = exec.pendingApproval?.decisionRef ?? exec.answeredApproval?.approval.decisionRef;\n if (payload.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PENDING\n && heldDecisionRef !== undefined && heldDecisionRef === payload.waitingDecisionRef) {\n return exec;\n }\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.ERROR,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: undefined,\n answeredApproval: undefined,\n };\n });\n }\n );\n\n return () => {\n unsubStarted();\n unsubMessage();\n unsubCompleted();\n unsubError();\n };\n }, [isConnected, on, updateExecution]);\n\n const contextValue = useMemo<FlowsActorsContextType>(() => ({\n systems,\n autonomousAgents,\n chatAgents,\n chatConnectionRefs,\n requestAgentDeclarations,\n isLoading,\n error,\n executions,\n startExecution,\n respondToApproval,\n answerQuestion,\n cancelExecution,\n clearExecution,\n getExecution,\n getSystem,\n refreshSystems,\n fetchConversationHistory,\n deleteConversation,\n }), [systems, autonomousAgents, chatAgents, chatConnectionRefs, requestAgentDeclarations, isLoading, error, executions, startExecution, respondToApproval, answerQuestion, cancelExecution, clearExecution, getExecution, getSystem, refreshSystems, fetchConversationHistory, deleteConversation]);\n\n return (\n <FlowsActorsContext.Provider value={contextValue}>\n {children}\n </FlowsActorsContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"FlowsActorsContext.js","sourceRoot":"","sources":["../../../../src/core/flows-actors/FlowsActorsContext.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,QAAQ,EAAa,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3G,OAAO,EAKL,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAGlB,6CAA6C,EAI7C,4CAA4C,EAE5C,8BAA8B,EAM9B,kBAAkB,EAGlB,iCAAiC,EAKjC,kBAAkB,EAGlB,8BAA8B,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1D,OAAO;QACP,gBAAgB;QAChB,UAAU;QACV,kBAAkB;QAClB,wBAAwB;QACxB,SAAS;QACT,KAAK;QACL,UAAU;QACV,cAAc;QACd,iBAAiB;QACjB,cAAc;QACd,eAAe;QACf,cAAc;QACd,YAAY;QACZ,SAAS;QACT,cAAc;QACd,wBAAwB;QACxB,iBAAiB;QACjB,kBAAkB;KACnB,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEvT,OAAO,CACL,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC7C,QAAQ,GACmB,CAC/B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { createContext, useState, ReactNode, useMemo, useEffect, useCallback, useRef } from 'react';\nimport {\n FlowActorSystem_FrontendInfo,\n FlowsActors_FrontendInfoResponse,\n type FlowsActors_AutonomousAgent_FrontendInfo,\n type FlowsActors_ChatAgent_FrontendInfo,\n MAIN_API_BASE_PATH,\n ManualControllerRouteKey,\n CoreWebSocketEvent,\n type FlowsActors_ConversationExecution,\n type FlowsActors_ConversationHistoryResponse,\n FlowsActors_ConversationHistoryResponseSchema,\n type WS_FlowsActorsStartPayload,\n type WS_FlowsActorsStartedPayload,\n type WS_FlowsActorsMessagePayload,\n WS_FlowsActorsApprovalAnnouncementDataSchema,\n type WS_FlowsActorsApprovalAnnouncementData,\n FlowsActors_ExecutionErrorCode,\n type WS_FlowsActorsApprovalModificationRefusal,\n type WS_FlowsActorsApprovalResponsePayload,\n type WS_FlowsActorsCancelPayload,\n type WS_FlowsActorsCompletedPayload,\n type WS_FlowsActorsTurnUsage,\n FlowsActors_Status,\n type FlowsActors_MessageContentType,\n type WS_FlowsActorsErrorPayload,\n canonicalizeFlowsActorsContextRef,\n type HumanDecision_RouteKind,\n type HumanDecision_Presentation,\n type HumanDecision_Request,\n type HumanDecision_AnswerValue,\n AskPersonOptionRef,\n type WorkUnitRef,\n type ResourceOperationRiskLevel,\n buildManualControllerRoutePath,\n} from '@wildo-ai/saas-models';\nimport type { SerializableZodSchema } from '@wildo-ai/zod-decorators';\nimport { LoggerFrontendService } from '~wildo-frontend-lib/core/monitoring/logger.frontend.service';\nimport { errorManagement } from '~wildo-frontend-lib/core/errors/error-management.frontend.service';\nimport { useApplication } from '~wildo-frontend-lib/core/runtime/useApplication';\nimport { useUserOrgs } from '~wildo-frontend-lib/core/security/useUserOrgs';\nimport { useAppScopeSafe } from '~wildo-frontend-lib/core/scope/useAppScope';\nimport { useWebSocket } from '~wildo-frontend-lib/core/requests/websockets/useWebSocket';\nimport { readJsonResponse } from '~wildo-frontend-lib/core/requests/json-response-reading.frontend';\nimport { useEmitLoadingScope } from '~wildo-frontend-lib/core/loading/useEmitLoadingScope';\nimport { ContextLoadingIdentifier } from '~wildo-frontend-lib/core/loading/loading-types.frontend.schemas';\n\nconst logger: LoggerFrontendService = LoggerFrontendService.getLogger();\nconst logDebug: (message: string, context?: Record<string, unknown>) => void = logger.debugByType('FlowsActorsContext');\nlogger.setDebugTypeLogging('FlowsActorsContext', false);\n\nconst MAX_MESSAGES_PER_EXECUTION: number = 500;\n\ntype ExecutionMessage = FlowsActorsExecution['messages'][number];\n\nfunction appendMessages(existing: ExecutionMessage[], ...newMsgs: ExecutionMessage[]): ExecutionMessage[] {\n const combined = [...existing, ...newMsgs];\n return combined.length > MAX_MESSAGES_PER_EXECUTION\n ? combined.slice(combined.length - MAX_MESSAGES_PER_EXECUTION)\n : combined;\n}\n\n/**\n * Merge one streamed message event into the list. When the event carries a\n * `messageId` matching an existing message, that message is updated in place:\n * a delta event (`isFinal !== true`) appends its `content`; the terminal event\n * (`isFinal === true`) replaces `content` with the authoritative full text (and\n * adopts its rendered `type`, e.g. text → markdown). Events without a known\n * `messageId` are appended as new entries (one-shot / legacy behavior).\n */\nfunction mergeStreamedMessage(\n existing: ExecutionMessage[],\n incoming: ExecutionMessage,\n isFinal: boolean,\n): ExecutionMessage[] {\n if (incoming.messageId) {\n const index = existing.findIndex(m => m.messageId === incoming.messageId);\n if (index >= 0) {\n const updated = [...existing];\n const prev = updated[index];\n updated[index] = {\n ...prev,\n type: incoming.type,\n content: isFinal ? incoming.content : prev.content + incoming.content,\n data: incoming.data ?? prev.data,\n timestamp: incoming.timestamp,\n };\n return updated;\n }\n }\n return appendMessages(existing, incoming);\n}\n\n/**\n * How a turn stands in THIS CLIENT — its view of a turn, which is not the server's run status.\n *\n * Kept distinct on purpose (#2524): the client knows states the server never holds — STARTING (the start is sent and\n * not yet acknowledged), and an ERROR it detects itself when the socket drops — and the server knows states the\n * client never shows (READY, ABORTED). The WIRE speaks the server's vocabulary (`FlowsActors_Status` on\n * `FLOWS_ACTORS_COMPLETED`), and {@link turnStatusFromServer} is the ONE place that reads it into this one.\n */\nexport enum FlowsActorsExecutionStatus {\n IDLE = 'idle',\n STARTING = 'starting',\n RUNNING = 'running',\n AWAITING_APPROVAL = 'awaiting_approval',\n COMPLETED = 'completed',\n /** The person stopped the turn (#2524). Not an error: nothing failed, and the turn's thread continues. */\n CANCELLED = 'cancelled',\n ERROR = 'error',\n}\n\n/**\n * The client's turn status for a status the server ENDED a turn with (`FLOWS_ACTORS_COMPLETED.status`). Total over the\n * server vocabulary, so a status added to it is a compile error here rather than a turn the client never settles.\n */\nconst TURN_STATUS_FROM_SERVER: Record<FlowsActors_Status, FlowsActorsExecutionStatus> = {\n [FlowsActors_Status.COMPLETED]: FlowsActorsExecutionStatus.COMPLETED,\n [FlowsActors_Status.CANCELLED]: FlowsActorsExecutionStatus.CANCELLED,\n [FlowsActors_Status.AWAITING_APPROVAL]: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n [FlowsActors_Status.PROCESSING]: FlowsActorsExecutionStatus.RUNNING,\n [FlowsActors_Status.PENDING]: FlowsActorsExecutionStatus.STARTING,\n [FlowsActors_Status.READY]: FlowsActorsExecutionStatus.STARTING,\n // A run the server ended without completing it, whatever the reason, is an error to the person watching it.\n [FlowsActors_Status.FAILED]: FlowsActorsExecutionStatus.ERROR,\n [FlowsActors_Status.ABORTED]: FlowsActorsExecutionStatus.ERROR,\n};\n\n/** Read a server run status into the client's turn status — the one mapping (#2524). */\nexport function turnStatusFromServer(status: FlowsActors_Status): FlowsActorsExecutionStatus {\n return TURN_STATUS_FROM_SERVER[status] ?? FlowsActorsExecutionStatus.ERROR;\n}\n\n/**\n * The one mapping from a server approval announcement to the client's pending decision — shared by the\n * live socket handler and the history seeding (#1601), so a decision reached either way renders and\n * answers identically.\n *\n * It carries the announcement's typed state and no sentence (#3201). The card words the decision itself, from its\n * presentation's title (`describeHumanDecisionCard`'s phrase) and the tool's title in `flows_actors_tools`, in the\n * reader's language. It used to carry the server's English `Waiting for approval to run \"<tool>\".` as\n * `actionDescription`, which the card rendered as written, naming the tool by its identifier.\n */\nfunction pendingApprovalFromAnnouncement(\n announcement: WS_FlowsActorsApprovalAnnouncementData,\n): NonNullable<FlowsActorsExecution['pendingApproval']> {\n const { approvalId, decisionRef, routeKind, toolName, toolArgs, toolInputSchema, requestedAt, expiresAt, reasonCodes, riskLevel, question, presentation, presentationId } = announcement;\n return {\n approvalId,\n ...(riskLevel ? { riskLevel } : {}),\n toolName,\n toolArgs,\n // A descriptor the transport does not re-validate (#587) — typed here for the editor, which falls\n // back to raw JSON for any shape it cannot render as fields.\n toolInputSchema: toolInputSchema as SerializableZodSchema | undefined,\n requestedAt: new Date(requestedAt),\n expiresAt: expiresAt ? new Date(expiresAt) : undefined,\n decisionRef,\n routeKind,\n ...(reasonCodes && reasonCodes.length > 0 ? { reasonCodes } : {}),\n ...(question ? { question } : {}),\n ...(presentation ? { presentation } : {}),\n ...(presentationId ? { presentationId } : {}),\n };\n}\n\n/**\n * Active Execution State\n */\nexport interface FlowsActorsExecution {\n executionId: string;\n systemRef: string;\n status: FlowsActorsExecutionStatus;\n messages: Array<{\n /** The message vocabulary's VALUE (`FlowsActors_MessageContentType`), the wire's `messageType`. */\n type: `${FlowsActors_MessageContentType}`;\n content: string;\n data?: Record<string, unknown>;\n timestamp: Date;\n /**\n * Correlation id for streamed messages. Consecutive `messageId`-sharing\n * events belong to one logical message: non-final events append their\n * delta to `content`; the final event replaces `content` with the full text.\n * Absent for one-shot messages (each is its own entry).\n */\n messageId?: string;\n }>;\n /**\n * The decision a paused turn is waiting on, read from `WS_FlowsActorsApprovalAnnouncementData` — carried in the `data`\n * bag of a PROGRESS message: tool name, tool arguments, timing, the isolation axis (#528), and the risk the call's\n * approval gate declares (#2526).\n */\n pendingApproval?: {\n approvalId: string;\n /**\n * The risk the call's approval gate DECLARES (`humanApproval.riskLevel`), as the decision's inbox card carries it\n * (#2526). Absent when the gate declares none; a surface then shows no risk claim, because nothing declared one.\n */\n riskLevel?: ResourceOperationRiskLevel;\n expiresAt?: Date;\n /** The tool call being gated, and its arguments — the structured thing being approved. */\n toolName?: string;\n toolArgs?: Record<string, unknown>;\n /**\n * The gated tool's input schema as a serialized descriptor (#587), so an editor can offer the\n * tool's fields. A rendering hint only — the server re-validates every modification.\n */\n toolInputSchema?: SerializableZodSchema;\n /**\n * The server's refusal of the approver's last edit, when it refused one (#587). The approval is\n * still pending when this is set: a refused modification leaves the pause standing, so the\n * surface keeps the decision on screen with the reason instead of dropping it.\n *\n * STRUCTURED, not the server's sentence (#1186): the card renders a label per reason, naming the\n * tool and the offending arguments as parameters. A server that sent no structure (older than the\n * field) yields an empty `reason`, which the card reads as \"refused, reason not stated\".\n */\n modificationRefusal?: WS_FlowsActorsApprovalModificationRefusal;\n /** The arguments the approver submitted in that refused edit, so the editor reopens on them (#587). */\n rejectedToolArgs?: Record<string, unknown>;\n /**\n * What the server built for the person to read (#2903): the arguments as strings it already projected, which the card\n * renders verbatim. Absent on a turn paused before decisions were routed.\n */\n presentation?: HumanDecision_Presentation;\n /** The presentation's id, echoed on the answer: the server refuses an answer that does not name what it was given on. */\n presentationId?: string;\n requestedAt?: Date;\n /**\n * The decision's one id (#1594), ECHOED back on the answer. The server addresses the decision by\n * it and reads everything else — owner, credential, agent instance — off the row.\n */\n decisionRef?: string;\n /**\n * Who answers it (#1594). Anything but OWNER is answered by a reviewer from their inbox, and the person\n * whose conversation this is may not answer it — so a surface shows it as waiting rather than offering\n * buttons the server would refuse. Absent means OWNER (a pause raised before routes existed).\n */\n routeKind?: HumanDecision_RouteKind;\n /**\n * The reason codes the answer may carry (#1921) — the application's declared vocabulary, offered when the approver\n * changes or rejects the call. Absent when the application declares none.\n */\n reasonCodes?: readonly string[];\n /**\n * Set when the server refused the last answer's reason code (#1921): the pause stands, the approval is back on\n * screen, and the card says the reason was not one the application offers. Cleared by the next answer.\n */\n reasonCodeRefused?: boolean;\n /**\n * The QUESTION, when the paused call is the agent asking its person (#2720): its questions, its two answers and the\n * form they are asked through. Answered with `answerQuestion`, never approved.\n */\n question?: HumanDecision_Request;\n };\n /** Set when the last error is recoverable (UI can offer a retry action) */\n recoverable?: boolean;\n /**\n * The approval this client last ANSWERED, kept until the server's reaction is known (#587).\n *\n * Answering clears `pendingApproval` at once, which is right when the decision lands. But a refused\n * modification leaves the server's pause standing, and without this the surface would have nothing to\n * put back on screen — the approval would vanish while still waiting. `submittedToolArgs` is what the\n * approver authored, so a restored editor reopens on their edit rather than on the model's call.\n */\n answeredApproval?: {\n approval: NonNullable<FlowsActorsExecution['pendingApproval']>;\n submittedToolArgs?: Record<string, unknown>;\n };\n duration?: number;\n /** The tokens the turn spent — present only for a person who may read model cost (#2524). */\n usage?: WS_FlowsActorsTurnUsage;\n errorCode?: string;\n}\n\n/**\n * FlowsActors Context Type\n */\nexport interface FlowsActorsContextType {\n /** Available frontend-visible FlowActorSystems */\n systems: FlowActorSystem_FrontendInfo[];\n\n /**\n * The autonomous agents the application declares (#1611), in declaration order — the closed set an\n * organization OAuth client may be bound to, so a binding form offers these rather than free text (#1812).\n * Empty until the first fetch settles, and when the application declares none.\n */\n autonomousAgents: FlowsActors_AutonomousAgent_FrontendInfo[];\n\n /**\n * The chat agents the application declares (#2665), in declaration order — the closed set an organization's chat\n * setting may name. Empty until the first fetch settles, and when the application declares none.\n */\n chatAgents: FlowsActors_ChatAgent_FrontendInfo[];\n\n /**\n * The chat connections an organization may choose an agent for (#2665): the application's providers enabled here\n * with a chat endpoint (`slack`, `microsoft-teams-bot`). Empty until the first fetch settles, and when there is none.\n */\n chatConnectionRefs: string[];\n\n /**\n * Ask for the agent declarations — {@link autonomousAgents}, {@link chatAgents} and {@link chatConnectionRefs} — to be\n * loaded, whatever else this application renders.\n *\n * The provider bootstraps `/flows-actors/frontend-info` only when the application configures a flows/actors\n * VIEW (pinned: an application with no chat surface makes no such request). Neither an autonomous agent nor a chat\n * agent needs a view, so a surface that needs the declarations (the OAuth client binding form, #1812; the chat\n * settings form, #2665) calls this instead. It fetches once per sign-in, and does nothing when a fetch already ran or\n * cannot run yet (signed out, no backend endpoint, no http client). Idempotent, so call it from an effect.\n */\n requestAgentDeclarations: () => void;\n\n /** Loading state */\n isLoading: boolean;\n\n /** Error state */\n error: Error | null;\n\n /** Active executions */\n executions: Map<string, FlowsActorsExecution>;\n\n /** Start a new execution (fire-and-forget via WebSocket; returns local executionId) */\n /**\n * Send a turn. A new `executionId` opens a thread; an existing one continues it. The optional\n * identifiers are folded into the thread's `contextRef` on open (see `fetchConversationHistory`).\n *\n * `options.caseRef` (#1598) names the case the thread works on — a row of a resource declared `workUnit: true` —\n * so the model calls it makes are attributed to that case. Read when the thread OPENS; a later turn keeps the\n * thread's case. The server admits it only if the caller can read that row.\n */\n startExecution: (\n systemRef: string,\n initialInput?: Record<string, unknown>,\n existingExecutionId?: string,\n extraContextResourceIdentifiers?: Record<string, string>,\n /**\n * `messageId`: the id the person's message is stored under (#2525 review N1). A page drawing the message before the\n * record holds it mints one, and recognises the stored message by it.\n */\n options?: { caseRef?: WorkUnitRef; messageId?: string },\n ) => string | null;\n\n /** Respond to an approval request (fire-and-forget via WebSocket) */\n /**\n * `modifiedToolArgs` (#566) replaces the arguments the agent proposed. Absent means \"run the call\n * as proposed\"; the server validates the edit against the tool's own schema and refuses through\n * `FLOWS_ACTORS_ERROR` with the approval left pending.\n */\n /** `reasonCode` is one of the approval's `reasonCodes` (#1921), given when the approver changes or rejects the call. */\n respondToApproval: (executionId: string, approvalId: string, approved: boolean, comment?: string, modifiedToolArgs?: Record<string, unknown>, reasonCode?: string) => void;\n\n /**\n * Answer the paused turn's QUESTION (#2720): the option chosen and, when it sends answers, one value per question as\n * its JSON (what `HumanDecisionForm` reads). The server checks the values with the question's own form and refuses\n * through `FLOWS_ACTORS_ERROR` with the question left pending.\n */\n answerQuestion: (executionId: string, optionRef: string, values: readonly { ref: string; value: HumanDecision_AnswerValue }[], comment?: string) => void;\n\n /**\n * Stop the person's own running turn (#2524). The server ends it CANCELLED, keeping what it had produced, and the\n * turn settles on `FLOWS_ACTORS_COMPLETED` like any other — nothing is settled here, so a stop that races the turn's\n * own end cannot leave the two disagreeing.\n */\n cancelExecution: (executionId: string) => void;\n\n /** Remove a completed/errored execution from state */\n clearExecution: (executionId: string) => void;\n\n /** Get execution by ID (reads from ref; consume `executions` to re-render on changes) */\n getExecution: (executionId: string) => FlowsActorsExecution | undefined;\n\n /** Get system by ref */\n getSystem: (systemRef: string) => FlowActorSystem_FrontendInfo | undefined;\n\n /** Refresh systems from backend */\n refreshSystems: () => Promise<void>;\n\n /**\n * The caller's OWN persisted threads for a system, server-authoritative (the executions resource, USER_SELF-scoped to\n * the caller): what repopulates the discussion list and the transcripts on a fresh page load. With\n * `contextResourceIdentifiers`, only the threads opened in that context — the same identifiers passed to\n * `startExecution`, canonicalised the same way — which is how a surface hosting one system for several subjects keeps\n * them apart.\n *\n * Reads a PAGE (#2528): the newest threads, or with `before` (the oldest `createdAt` a host already holds) the ones\n * before it, inclusive — so a host keeps each `executionId` once. `hasOlder` says whether another page remains.\n *\n * Resolves an empty page when there are none, or when the backend has no flows-actors history surface (feature\n * absent), and `undefined` when the read FAILED (#2525 review M4). The two must not look alike: a host re-reads after\n * every turn, and treating a failure as \"no threads\" emptied its discussion list and transcript — under the very\n * outage that had just ended the turn. Keep the last good list on `undefined`.\n */\n fetchConversationHistory: (\n systemRef: string,\n contextResourceIdentifiers?: Record<string, string>,\n page?: { readonly before?: string },\n ) => Promise<FlowsActors_ConversationHistoryResponse | undefined>;\n\n /**\n * ONE of the caller's own threads, read by id (#4013): the one a link named, which may be older than the newest page a\n * host holds. Read through the same confined history route, so with `contextResourceIdentifiers` it answers only a\n * thread opened in that context, exactly as a page would list it.\n *\n * Resolves the thread, `null` when the caller has no such thread here (deleted, someone else's, another system or\n * context), and `undefined` when the read FAILED: as for a page, the two must not look alike.\n */\n fetchConversation: (\n systemRef: string,\n contextResourceIdentifiers: Record<string, string> | undefined,\n executionId: string,\n ) => Promise<FlowsActors_ConversationExecution | null | undefined>;\n\n /**\n * Delete ONE of the caller's own persisted conversations (a discussion). Runs\n * under the caller's auth, so the executions resource's USER_SELF owner filter\n * only ever deletes the caller's own row. Resolves once the server confirms.\n */\n deleteConversation: (executionId: string) => Promise<void>;\n}\n\n/**\n * FlowsActors Context\n * @internal - Use useFlowsActors() hook instead of accessing this directly\n */\nexport const FlowsActorsContext: React.Context<FlowsActorsContextType | undefined> = createContext<FlowsActorsContextType | undefined>(undefined);\n\n/**\n * FlowsActors Provider\n *\n * Manages:\n * - Available FlowActorSystems (fetched at startup)\n * - Active execution state\n * - WebSocket communication for real-time updates\n */\nexport const FlowsActorsProvider: React.FC<{ children: ReactNode }> = ({ children }) => {\n const { appConfig, frontendConfiguration, httpClient } = useApplication();\n const userOrgs = useUserOrgs();\n const appScope = useAppScopeSafe();\n const { on, emit, isConnected } = useWebSocket();\n const hasInitializedRef = useRef(false);\n const hasConfiguredFlowsActorsViews = (frontendConfiguration?.flowsActorsViews?.length ?? 0) > 0;\n\n const [systems, setSystems] = useState<FlowActorSystem_FrontendInfo[]>([]);\n const [autonomousAgents, setAutonomousAgents] = useState<FlowsActors_AutonomousAgent_FrontendInfo[]>([]);\n const [chatAgents, setChatAgents] = useState<FlowsActors_ChatAgent_FrontendInfo[]>([]);\n const [chatConnectionRefs, setChatConnectionRefs] = useState<string[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [executions, setExecutions] = useState<Map<string, FlowsActorsExecution>>(new Map());\n // L-2.b: explicit \"has the registry ever completed at least one successful\n // fetch\" marker, distinct from `systems.length > 0` (an empty registry is\n // still a successful fetch — the backend may legitimately ship zero\n // flow-actor systems for a given app, and we don't want every refresh of an\n // empty registry to render as INITIAL phase).\n const [hasCompletedFetch, setHasCompletedFetch] = useState(false);\n\n useEmitLoadingScope({\n identifier: ContextLoadingIdentifier.FLOWS_ACTORS,\n isLoading,\n hasLoadedOnce: hasCompletedFetch,\n });\n const executionsRef = useRef(executions);\n executionsRef.current = executions;\n\n const updateExecution = useCallback((\n executionId: string,\n updater: (execution: FlowsActorsExecution) => FlowsActorsExecution,\n ): void => {\n setExecutions(prev => {\n const existing = prev.get(executionId);\n if (!existing) return prev;\n const next = new Map(prev);\n next.set(executionId, updater(existing));\n return next;\n });\n }, []);\n\n /**\n * Fetch frontend-visible systems from backend\n */\n const refreshSystems = useCallback(async () => {\n if (!appConfig?.runtime?.endPoints?.main_backend_api) {\n logDebug('Cannot refresh systems - API endpoint not configured');\n return;\n }\n\n if (!httpClient) {\n logDebug('Cannot refresh systems - httpClient not available');\n return;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n // Use httpClient which handles authentication automatically. The path is\n // built from the shared route registry (same source the backend controller\n // registers with) so both sides stay in lockstep under MAIN_API_BASE_PATH.\n const data = await httpClient.get<FlowsActors_FrontendInfoResponse>(\n `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_FRONTEND_INFO)}`\n );\n setSystems(data.systems);\n setAutonomousAgents(data.autonomousAgents);\n setChatAgents(data.chatAgents);\n setChatConnectionRefs(data.chatConnectionRefs);\n setHasCompletedFetch(true);\n\n logDebug('Systems refreshed', { count: data.systems.length });\n\n } catch (err) {\n if (errorManagement.isNotFoundError(err)) {\n logDebug('FlowsActors backend support not available - skipping systems bootstrap');\n setSystems([]);\n setAutonomousAgents([]);\n setChatAgents([]);\n setChatConnectionRefs([]);\n setError(null);\n setHasCompletedFetch(true);\n return;\n }\n\n const error = err instanceof Error ? err : new Error('Unknown error');\n setError(error);\n logDebug('Failed to refresh systems', { error: error.message });\n } finally {\n setIsLoading(false);\n }\n }, [appConfig?.runtime?.endPoints?.main_backend_api, httpClient]);\n\n /**\n * Fetch the caller's persisted conversation history for a system. Runs under\n * the caller's own auth (httpClient), so the executions resource's USER_SELF\n * owner filter restricts rows to the caller's threads. A missing backend\n * surface (feature absent) resolves to `[]`, never an error.\n */\n const readConversationHistory = useCallback(async (\n systemRef: string,\n contextResourceIdentifiers: Record<string, string> | undefined,\n page: { readonly before?: string; readonly executionId?: string },\n ): Promise<FlowsActors_ConversationHistoryResponse | undefined> => {\n if (!httpClient) {\n logDebug('Cannot fetch conversation history - httpClient not available');\n return undefined;\n }\n try {\n const basePath = `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_HISTORY)}`;\n const contextRef = contextResourceIdentifiers === undefined\n ? undefined\n : canonicalizeFlowsActorsContextRef({\n ...(appScope?.currentOrganizationId ? { organizationId: appScope.currentOrganizationId } : {}),\n ...contextResourceIdentifiers,\n });\n const query = `?systemRef=${encodeURIComponent(systemRef)}${contextRef === undefined ? '' : `&contextRef=${encodeURIComponent(contextRef)}`}`\n + (page.before ? `&before=${encodeURIComponent(page.before)}` : '')\n + (page.executionId ? `&executionId=${encodeURIComponent(page.executionId)}` : '');\n // Its dates restored (#3478): the history's message dates arrive as RFC 3339 strings.\n const data: FlowsActors_ConversationHistoryResponse = readJsonResponse(FlowsActors_ConversationHistoryResponseSchema, await httpClient.get<unknown>(`${basePath}${query}`));\n logDebug('Conversation history fetched', { systemRef, count: data.executions.length });\n /*\n * A thread whose turn is paused on a decision becomes an execution here, carrying that\n * decision (#1601). The pause is announced only over the live socket, so a page that loaded\n * after it — a reload, a second tab, a restart — had a thread waiting on an answer and nothing\n * to answer it with: the creator saw their message sit unanswered. The history route now\n * returns the same announcement the socket carried, and it is folded through the same mapping.\n *\n * A live entry is never replaced: the socket is the fresher source for a turn this page is\n * watching, and a seeded copy could revive a decision this client just answered. Except one: an\n * entry in ERROR with DECISION_PENDING, which says only \"the thread waits for a decision this\n * page does not hold\", so the stored decision is the fresher of the two. It arrives two ways: a\n * message this page sent was refused (#2721 review F-2), or a turn this page was watching ended\n * because another turn's decision now holds the thread (#2721 re-review N-1), including the turn\n * this page resumed by answering. That last case cannot revive the answered decision: the event\n * names the decision that waits (`waitingDecisionRef`), the error arm records the entry only when\n * it is NOT the decision the page holds (re-review R-2), and the row history returns holds that\n * waiting decision, not the answered one.\n */\n const paused = data.executions.filter((row) => row.pendingApproval !== undefined);\n if (paused.length > 0) {\n setExecutions((prev) => {\n let next: Map<string, FlowsActorsExecution> | undefined;\n for (const row of paused) {\n const live = prev.get(row.executionId);\n // #2903: an answer refused as stale leaves the decision waiting as it is NOW, which only the stored row says.\n // #2923: so does an answer refused for carrying no step-up the decision requires.\n const refusedForAnUnheldDecision = live?.status === FlowsActorsExecutionStatus.ERROR\n && (live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PENDING\n || live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PRESENTATION_STALE\n || live.errorCode === FlowsActors_ExecutionErrorCode.DECISION_STEP_UP_REQUIRED);\n if ((live && !refusedForAnUnheldDecision) || row.pendingApproval === undefined) continue;\n next ??= new Map(prev);\n next.set(row.executionId, {\n executionId: row.executionId,\n systemRef: row.systemRef,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n messages: [],\n pendingApproval: pendingApprovalFromAnnouncement(row.pendingApproval),\n });\n }\n return next ?? prev;\n });\n }\n return { executions: data.executions, hasOlder: data.hasOlder === true };\n } catch (err) {\n if (errorManagement.isNotFoundError(err)) {\n logDebug('FlowsActors history surface not available - returning empty history', { systemRef });\n return { executions: [], hasOlder: false };\n }\n // A failed read is not an empty history: the host keeps what it last read (#2525 review M4).\n logger.warn('Failed to fetch conversation history', { systemRef, error: err instanceof Error ? err.message : 'unknown' });\n return undefined;\n }\n }, [httpClient, appScope?.currentOrganizationId]);\n\n const fetchConversationHistory = useCallback((\n systemRef: string,\n contextResourceIdentifiers?: Record<string, string>,\n page?: { readonly before?: string },\n ) => readConversationHistory(systemRef, contextResourceIdentifiers, page?.before ? { before: page.before } : {}), [readConversationHistory]);\n\n const fetchConversation = useCallback(async (\n systemRef: string,\n contextResourceIdentifiers: Record<string, string> | undefined,\n executionId: string,\n ): Promise<FlowsActors_ConversationExecution | null | undefined> => {\n const page = await readConversationHistory(systemRef, contextResourceIdentifiers, { executionId });\n if (page === undefined) return undefined;\n return page.executions.find((thread) => thread.executionId === executionId) ?? null;\n }, [readConversationHistory]);\n\n /**\n * Delete one of the caller's persisted conversations. Owner-scoped server-side\n * (USER_SELF), so a user can only delete their own discussion.\n */\n const deleteConversation = useCallback(async (executionId: string): Promise<void> => {\n if (!httpClient) {\n logDebug('Cannot delete conversation - httpClient not available');\n return;\n }\n const basePath = `${MAIN_API_BASE_PATH}${buildManualControllerRoutePath(ManualControllerRouteKey.FLOWS_ACTORS_HISTORY)}`;\n await httpClient.delete(`${basePath}?executionId=${encodeURIComponent(executionId)}`);\n logDebug('Conversation deleted', { executionId });\n }, [httpClient]);\n\n /**\n * Start a new execution via WebSocket (fire-and-forget).\n * Errors are delivered asynchronously via FLOWS_ACTORS_STARTED / FLOWS_ACTORS_ERROR events.\n */\n const startExecution = useCallback((\n systemRef: string,\n initialInput?: Record<string, unknown>,\n existingExecutionId?: string,\n extraContextResourceIdentifiers?: Record<string, string>,\n options?: { caseRef?: WorkUnitRef; messageId?: string },\n ): string | null => {\n if (!isConnected) {\n logDebug('Cannot start execution — WebSocket not connected', { systemRef });\n return null;\n }\n\n // Reuse the id to CONTINUE a discussion (one execution = one thread); mint a\n // new one to start a fresh discussion.\n const executionId = existingExecutionId ?? crypto.randomUUID();\n logDebug('Starting execution', { systemRef, executionId, hasInput: !!initialInput, isContinuation: !!existingExecutionId });\n\n /*\n * The scope's own identifiers first, the caller's on top: a surface that hosts one system for\n * several subjects (a tool pointed at one application at a time) names the subject here, and\n * the backend folds the whole set into the thread's `contextRef`, which `fetchConversationHistory`\n * lists by when handed the same identifiers.\n */\n const contextResourceIdentifiers: Record<string, string> = {};\n if (appScope?.currentOrganizationId) {\n contextResourceIdentifiers.organizationId = appScope.currentOrganizationId;\n }\n Object.assign(contextResourceIdentifiers, extraContextResourceIdentifiers ?? {});\n\n setExecutions(prev => {\n const next = new Map(prev);\n // Reset messages every turn: the live execution holds ONLY the current\n // turn's streamed reply. Prior turns of a continued thread live in the\n // view's transcript, so keeping them here would make the streamed bubble\n // replay the whole thread (duplicate content).\n next.set(executionId, {\n executionId,\n systemRef,\n status: FlowsActorsExecutionStatus.STARTING,\n messages: [],\n });\n return next;\n });\n\n emit<WS_FlowsActorsStartPayload>(CoreWebSocketEvent.FLOWS_ACTORS_START, {\n systemRef,\n executionId,\n contextResourceIdentifiers,\n initialInput,\n ...(options?.caseRef ? { caseRef: options.caseRef } : {}),\n ...(options?.messageId ? { messageId: options.messageId } : {}),\n });\n\n return executionId;\n }, [isConnected, emit, appScope?.currentOrganizationId]);\n\n /**\n * Respond to an approval request via WebSocket (fire-and-forget).\n * The resumed turn sends no FLOWS_ACTORS_STARTED: it continues the paused turn, streams to the conversation's\n * owner, and ends on FLOWS_ACTORS_COMPLETED (completed, cancelled) or FLOWS_ACTORS_ERROR.\n */\n const respondToApproval = useCallback((\n executionId: string,\n approvalId: string,\n approved: boolean,\n comment?: string,\n modifiedToolArgs?: Record<string, unknown>,\n reasonCode?: string,\n ): void => {\n const execution = executionsRef.current.get(executionId);\n if (!execution) {\n logDebug('Cannot respond to approval — execution not found', { executionId, approvalId });\n return;\n }\n\n if (!isConnected) {\n logDebug('Cannot respond to approval — WebSocket not connected', { executionId, approvalId });\n return;\n }\n\n logDebug('Responding to approval', { executionId, approvalId, approved, modified: modifiedToolArgs !== undefined });\n\n emit<WS_FlowsActorsApprovalResponsePayload>(CoreWebSocketEvent.FLOWS_ACTORS_APPROVAL_RESPONSE, {\n systemRef: execution.systemRef,\n executionId,\n approvalId,\n approved,\n comment,\n /*\n * The decision's id, echoed (#1594). The server addresses the answer by it and reads the owner,\n * credential and agent instance off the row — so nothing here can point the answer at a different\n * conversation, and a reviewer answering someone else's decision reaches it.\n */\n ...(execution.pendingApproval?.decisionRef ? { decisionRef: execution.pendingApproval.decisionRef } : {}),\n // #2903: the presentation this answer was given on. The server refuses an answer naming none, or a stale one.\n ...(execution.pendingApproval?.presentationId ? { presentationId: execution.pendingApproval.presentationId } : {}),\n /*\n * The arguments the approver AUTHORED (#566), when they edited the proposed call.\n *\n * Sent only when present. Sending `{}` for an unedited approval would reach the server as a\n * modification the tool's schema then rejects, turning every ordinary approval into a\n * refusal — the mirror of the defect that made this field necessary.\n */\n ...(modifiedToolArgs ? { modifiedToolArgs } : {}),\n // Why the approver changed or rejected the call (#1921), one of the application's declared codes. The server\n // checks it against the same vocabulary and refuses an undeclared one, leaving the pause standing.\n ...(reasonCode ? { reasonCode } : {}),\n });\n\n updateExecution(executionId, exec => ({\n ...exec,\n status: approved ? FlowsActorsExecutionStatus.RUNNING : exec.status,\n // The refusal an earlier answer met is answered by this one: a later pause must not inherit its code (#2525).\n errorCode: undefined,\n recoverable: undefined,\n pendingApproval: undefined,\n // Kept until the server reacts: a REFUSED modification leaves the pause standing, and this is\n // what the error handler restores — with the arguments the approver submitted (#587).\n answeredApproval: exec.pendingApproval\n ? { approval: exec.pendingApproval, ...(modifiedToolArgs ? { submittedToolArgs: modifiedToolArgs } : {}) }\n : undefined,\n }));\n }, [isConnected, emit, updateExecution]);\n\n const answerQuestion = useCallback((\n executionId: string,\n optionRef: string,\n values: readonly { ref: string; value: HumanDecision_AnswerValue }[],\n comment?: string,\n ): void => {\n const execution = executionsRef.current.get(executionId);\n const pending = execution?.pendingApproval;\n if (!execution || !pending?.question || !pending.decisionRef || !isConnected) {\n logDebug('Cannot answer a question — no paused question, or the WebSocket is not connected', { executionId });\n return;\n }\n const sendsAnswers = optionRef === AskPersonOptionRef.ANSWER;\n emit<WS_FlowsActorsApprovalResponsePayload>(CoreWebSocketEvent.FLOWS_ACTORS_APPROVAL_RESPONSE, {\n systemRef: execution.systemRef,\n executionId,\n approvalId: pending.approvalId,\n decisionRef: pending.decisionRef,\n // #2903: the presentation this answer was given on.\n ...(pending.presentationId ? { presentationId: pending.presentationId } : {}),\n // Not read for a question: the answer below is what settles it. Sent because the payload requires a verdict.\n approved: sendsAnswers,\n answer: { decisionId: pending.decisionRef, optionRef, values: [...values] },\n // A note in the person's own words travels with the answer, or with the decline, to the agent.\n ...(comment ? { comment } : {}),\n });\n updateExecution(executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.RUNNING,\n errorCode: undefined,\n recoverable: undefined,\n pendingApproval: undefined,\n // Kept until the server reacts: an answer its form refuses leaves the question pending, and this restores it.\n answeredApproval: exec.pendingApproval ? { approval: exec.pendingApproval } : undefined,\n }));\n }, [isConnected, emit, updateExecution]);\n\n /**\n * Get execution by ID\n */\n const getExecution = useCallback((executionId: string): FlowsActorsExecution | undefined => {\n return executionsRef.current.get(executionId);\n }, []);\n\n /**\n * Get system by ref\n */\n const getSystem = useCallback((systemRef: string): FlowActorSystem_FrontendInfo | undefined => {\n return systems.find(s => s.ref === systemRef);\n }, [systems]);\n\n const cancelExecution = useCallback((executionId: string): void => {\n const execution = executionsRef.current.get(executionId);\n if (!execution || !isConnected) return;\n emit<WS_FlowsActorsCancelPayload>(CoreWebSocketEvent.FLOWS_ACTORS_CANCEL, { systemRef: execution.systemRef, executionId });\n }, [isConnected, emit]);\n\n const clearExecution = useCallback((executionId: string): void => {\n setExecutions(prev => {\n if (!prev.has(executionId)) return prev;\n const next = new Map(prev);\n next.delete(executionId);\n return next;\n });\n }, []);\n\n /**\n * Initialize on mount when authenticated\n */\n useEffect(() => {\n if (userOrgs.isAuthenticated()) {\n return;\n }\n\n hasInitializedRef.current = false;\n setSystems([]);\n setAutonomousAgents([]);\n setChatAgents([]);\n setChatConnectionRefs([]);\n setError(null);\n setExecutions(new Map());\n }, [userOrgs]);\n\n const requestAgentDeclarations = useCallback((): void => {\n if (\n hasInitializedRef.current\n || !appConfig?.runtime?.endPoints?.main_backend_api\n || !httpClient\n || !userOrgs.isAuthenticated()\n ) {\n return;\n }\n hasInitializedRef.current = true;\n void refreshSystems();\n }, [appConfig?.runtime?.endPoints?.main_backend_api, httpClient, userOrgs, refreshSystems]);\n\n useEffect(() => {\n if (\n !hasInitializedRef.current\n && hasConfiguredFlowsActorsViews\n && appConfig?.runtime?.endPoints?.main_backend_api\n && httpClient\n && userOrgs.isAuthenticated()\n ) {\n hasInitializedRef.current = true;\n refreshSystems();\n }\n }, [\n appConfig?.runtime?.endPoints?.main_backend_api,\n hasConfiguredFlowsActorsViews,\n httpClient,\n userOrgs,\n refreshSystems,\n ]);\n\n /**\n * A dropped socket ENDS every turn still in flight on it.\n *\n * The server emits a turn's events to the socket that started it (`conversational-execution`'s\n * emitter is bound to that socket), so once it drops, no `STARTED`, `MESSAGE`, `COMPLETED` or\n * `ERROR` for that turn can ever arrive — not after a reconnect either, which opens a different\n * socket. Before this, a turn sent into a companion that restarted a second later stayed `STARTING`\n * for good: the page showed neither the question nor an error, and the composer sat on its stop\n * button (measured for eight minutes on the creation workbench, 2026-09-24, #1464).\n *\n * Only `STARTING` and `RUNNING` end. A turn `AWAITING_APPROVAL` is a persisted suspension the person\n * answers later, over whatever socket is live then, so a drop does not end it. The error is\n * RECOVERABLE and names its cause with a CLIENT-DETECTED code, carrying no text of its own: every\n * surface already words an errored turn, and a surviving server still completes and persists the\n * turn, which the thread's history then shows.\n */\n const wasConnectedRef = useRef(isConnected);\n useEffect(() => {\n const dropped = wasConnectedRef.current && !isConnected;\n wasConnectedRef.current = isConnected;\n if (!dropped) return;\n setExecutions(prev => {\n let next: Map<string, FlowsActorsExecution> | null = null;\n for (const [executionId, execution] of prev) {\n if (execution.status !== FlowsActorsExecutionStatus.STARTING && execution.status !== FlowsActorsExecutionStatus.RUNNING) continue;\n next ??= new Map(prev);\n next.set(executionId, {\n ...execution,\n status: FlowsActorsExecutionStatus.ERROR,\n recoverable: true,\n errorCode: FlowsActors_ExecutionErrorCode.CONNECTION_LOST,\n });\n }\n return next ?? prev;\n });\n }, [isConnected]);\n\n /**\n * WebSocket event listeners for FlowsActors inbound events.\n * Follows the WebSocketEventBridge pattern: subscribe on connect, cleanup on disconnect.\n */\n useEffect(() => {\n if (!isConnected) {\n return;\n }\n\n const unsubStarted = on<WS_FlowsActorsStartedPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_STARTED,\n (payload) => {\n logDebug('Execution started', { executionId: payload.executionId });\n // Only ever a success: a turn that could not start reports on FLOWS_ACTORS_ERROR (#2524).\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.RUNNING,\n }));\n }\n );\n\n const unsubMessage = on<WS_FlowsActorsMessagePayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_MESSAGE,\n (payload) => {\n logDebug('Execution message', { executionId: payload.executionId, type: payload.messageType, messageId: payload.messageId, isFinal: payload.isFinal });\n\n /*\n * A pause is announced HERE, inside a PROGRESS message's `data` bag — never on a separate\n * approval-request event, which nothing emitted and #2524 removed. Parsed rather than key-picked, so\n * the browser and the producer share one named contract; a bag that is not an announcement\n * simply fails the parse and the message is stored like any other (#528).\n */\n const announcement = WS_FlowsActorsApprovalAnnouncementDataSchema.safeParse(payload.data);\n if (announcement.success) {\n const { approvalId, toolName } = announcement.data;\n logDebug('Approval requested', { executionId: payload.executionId, approvalId, toolName });\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n // A new pause supersedes whatever this client answered before it.\n answeredApproval: undefined,\n // The typed announcement only: the card words it in the reader's language (#3201). The PROGRESS text is\n // the tool's name, never a sentence to render.\n pendingApproval: pendingApprovalFromAnnouncement(announcement.data),\n }));\n }\n\n updateExecution(payload.executionId, exec => ({\n ...exec,\n messages: mergeStreamedMessage(\n exec.messages,\n {\n type: payload.messageType,\n content: payload.content,\n data: payload.data,\n timestamp: payload.timestamp instanceof Date ? payload.timestamp : new Date(payload.timestamp),\n messageId: payload.messageId,\n },\n payload.isFinal === true,\n ),\n }));\n }\n );\n\n const unsubCompleted = on<WS_FlowsActorsCompletedPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_COMPLETED,\n (payload) => {\n logDebug('Execution completed', { executionId: payload.executionId, status: payload.status, duration: payload.duration });\n // The server's run status, read through the one mapping (#2524): COMPLETED, or CANCELLED when the person\n // stopped it. A failure never arrives here — it reports on FLOWS_ACTORS_ERROR with its reason.\n updateExecution(payload.executionId, exec => ({\n ...exec,\n status: turnStatusFromServer(payload.status),\n pendingApproval: undefined,\n duration: payload.duration,\n ...(payload.usage ? { usage: payload.usage } : {}),\n }));\n }\n );\n\n const unsubError = on<WS_FlowsActorsErrorPayload>(\n CoreWebSocketEvent.FLOWS_ACTORS_ERROR,\n (payload) => {\n logDebug('Execution error', { executionId: payload.executionId, errorCode: payload.errorCode, recoverable: payload.recoverable });\n updateExecution(payload.executionId, exec => {\n /*\n * A refused MODIFICATION is not a failed turn (#587). The server leaves the pause standing and\n * says so with `recoverable: true`, so the decision goes back on screen — with the reason, and\n * with the arguments the approver submitted — instead of vanishing while the server still\n * waits for it. Treating it as ERROR is what made the approval disappear on every refusal.\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.APPROVAL_MODIFICATION_REJECTED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: payload.approvalModificationRefusal ?? { reason: '' },\n rejectedToolArgs: exec.answeredApproval.submittedToolArgs,\n // A refusal of THIS answer, not the reason code of an earlier one (#1921).\n reasonCodeRefused: undefined,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * A reason code the application does not declare is refused while the pause stands (#1921). The approval goes\n * back on screen as it was asked, and the card says why in its own labels — the server's English sentence is\n * not appended to the conversation, because words a reader sees come from the label tree.\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.APPROVAL_REASON_CODE_REJECTED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: undefined,\n rejectedToolArgs: undefined,\n reasonCodeRefused: true,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * A decision refused by the application's consent requirement is not a failed turn either (#534). The\n * server checks the requirement BEFORE it releases the pause, so the approval still stands and can be\n * answered once the person has recorded their consent: it goes back on screen with its `errorCode`, which\n * the conversation thread words (`consentRequired`) above the decision rather than as an argument-edit error.\n * The server's English `errorMessage` is not appended to the turn: it is no reply, and no translator reaches\n * it (#2525).\n */\n if (\n payload.recoverable\n && payload.errorCode === FlowsActors_ExecutionErrorCode.SERVICE_CONSENT_REQUIRED\n && exec.answeredApproval\n ) {\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.AWAITING_APPROVAL,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n // Restored as it was ASKED, not as it was last refused: an earlier refused edit's error must not\n // reappear, and the arguments just submitted reopen the editor (#534 fourth review F5).\n pendingApproval: {\n ...exec.answeredApproval.approval,\n modificationRefusal: undefined,\n rejectedToolArgs: exec.answeredApproval.submittedToolArgs,\n reasonCodeRefused: undefined,\n },\n answeredApproval: undefined,\n };\n }\n /*\n * DECISION_PENDING is not this tab's failure either (#2721 review F-2). It arrives for a message refused\n * because the thread waits for a decision, and as the END of a turn whose own end was not written because\n * another turn's decision now holds the thread (#2721 re-review N-1). It reaches every tab of the owner's\n * room, so a tab that holds THAT decision — asked, or answered and awaiting the server — keeps it exactly as\n * it is: the decision is the thread's state, and clearing it here took the card away from the one tab that\n * could act on it. Any other tab records it as ERROR, worded by `decisionPending`, and its history reload\n * restores the waiting decision over it (`fetchConversationHistory`). That includes a tab holding a\n * DIFFERENT decision (#2721 re-review R-2): the tab that answered D1 while another door's turn paused the\n * thread on D2, or a second tab still showing the settled D1. Kept, either stayed RUNNING or on a dead card,\n * and history could not help, since it never replaces an entry it does not see as refused.\n */\n const heldDecisionRef = exec.pendingApproval?.decisionRef ?? exec.answeredApproval?.approval.decisionRef;\n if (payload.errorCode === FlowsActors_ExecutionErrorCode.DECISION_PENDING\n && heldDecisionRef !== undefined && heldDecisionRef === payload.waitingDecisionRef) {\n return exec;\n }\n return {\n ...exec,\n status: FlowsActorsExecutionStatus.ERROR,\n recoverable: payload.recoverable,\n errorCode: payload.errorCode,\n pendingApproval: undefined,\n answeredApproval: undefined,\n };\n });\n }\n );\n\n return () => {\n unsubStarted();\n unsubMessage();\n unsubCompleted();\n unsubError();\n };\n }, [isConnected, on, updateExecution]);\n\n const contextValue = useMemo<FlowsActorsContextType>(() => ({\n systems,\n autonomousAgents,\n chatAgents,\n chatConnectionRefs,\n requestAgentDeclarations,\n isLoading,\n error,\n executions,\n startExecution,\n respondToApproval,\n answerQuestion,\n cancelExecution,\n clearExecution,\n getExecution,\n getSystem,\n refreshSystems,\n fetchConversationHistory,\n fetchConversation,\n deleteConversation,\n }), [systems, autonomousAgents, chatAgents, chatConnectionRefs, requestAgentDeclarations, isLoading, error, executions, startExecution, respondToApproval, answerQuestion, cancelExecution, clearExecution, getExecution, getSystem, refreshSystems, fetchConversationHistory, fetchConversation, deleteConversation]);\n\n return (\n <FlowsActorsContext.Provider value={contextValue}>\n {children}\n </FlowsActorsContext.Provider>\n );\n};\n"]}
@@ -8,11 +8,29 @@ import type { FlowsActors_ConversationExecution, FlowsActors_ConversationHistory
8
8
  * pages fill in what lies before it.
9
9
  */
10
10
  export interface HeldConversationHistory {
11
- /** Newest first, each discussion once. */
11
+ /** The discussions read page by page: newest first, each once. The cursor for the next older page is the oldest of them. */
12
12
  readonly threads: readonly FlowsActors_ConversationExecution[];
13
13
  /** Whether discussions older than the oldest held remain to be read. */
14
14
  readonly hasOlder: boolean;
15
+ /**
16
+ * Discussions read ONE BY ONE, by id, that the pages read so far do not reach (#4013): the one a link named, older
17
+ * than the newest page. Kept apart from {@link threads} because the next older page starts from the oldest PAGED
18
+ * discussion: counting one of these as paged would skip every discussion between the two. A page that reaches one
19
+ * takes it over. Absent when none was read.
20
+ */
21
+ readonly beyondPages?: readonly FlowsActors_ConversationExecution[];
15
22
  }
23
+ /** Every discussion held, paged or read by id, newest first, each once: what a host lists and opens. */
24
+ export declare function heldConversations(held: HeldConversationHistory): readonly FlowsActors_ConversationExecution[];
25
+ /** The ids of the discussions held only because they were read by id: the ones a host re-reads one by one. */
26
+ export declare function conversationsHeldBeyondPages(held: HeldConversationHistory): readonly string[];
27
+ /**
28
+ * Fold in ONE discussion read by id (#4013). Held among the paged ones, it replaces that copy; otherwise it is held
29
+ * beyond the pages, replacing any earlier read of it.
30
+ */
31
+ export declare function withConversationReadById(held: HeldConversationHistory, thread: FlowsActors_ConversationExecution): HeldConversationHistory;
32
+ /** Drop one discussion wherever it is held: deleted by the person, or gone when it was read again by id. */
33
+ export declare function withoutConversation(held: HeldConversationHistory, executionId: string): HeldConversationHistory;
16
34
  /**
17
35
  * Fold in a fresh read of the NEWEST page. Inside the page's window (from its oldest discussion on) the page is the
18
36
  * whole truth: a discussion deleted meanwhile is gone, and one changed is replaced. Older pages already read are kept,
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-history.model.d.ts","sourceRoot":"","sources":["../../../../src/core/flows-actors/conversation-history.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAExH;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,iCAAiC,EAAE,CAAC;IAC/D,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAUD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,uCAAuC,GAAG,uBAAuB,CAU3I;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,uCAAuC,GAAG,uBAAuB,CAI1I;AAED,kHAAkH;AAClH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAGpF;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,uCAAuC,GAAG,SAAS,CAAC,GAC9G,OAAO,CAAC,SAAS,iCAAiC,EAAE,GAAG,SAAS,CAAC,CAanE"}
1
+ {"version":3,"file":"conversation-history.model.d.ts","sourceRoot":"","sources":["../../../../src/core/flows-actors/conversation-history.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAExH;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC,4HAA4H;IAC5H,QAAQ,CAAC,OAAO,EAAE,SAAS,iCAAiC,EAAE,CAAC;IAC/D,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,iCAAiC,EAAE,CAAC;CACrE;AAED,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,uBAAuB,GAAG,SAAS,iCAAiC,EAAE,CAI7G;AAED,8GAA8G;AAC9G,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,uBAAuB,GAAG,SAAS,MAAM,EAAE,CAE7F;AASD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,uBAAuB,EAAE,MAAM,EAAE,iCAAiC,GAAG,uBAAuB,CAM1I;AAED,4GAA4G;AAC5G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,GAAG,uBAAuB,CAG/G;AAUD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,uCAAuC,GAAG,uBAAuB,CAiB3I;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,uCAAuC,GAAG,uBAAuB,CAM1I;AAED,kHAAkH;AAClH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAGpF;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,uCAAuC,GAAG,SAAS,CAAC,GAC9G,OAAO,CAAC,SAAS,iCAAiC,EAAE,GAAG,SAAS,CAAC,CAanE"}
@@ -1,3 +1,36 @@
1
+ /** Every discussion held, paged or read by id, newest first, each once: what a host lists and opens. */
2
+ export function heldConversations(held) {
3
+ if (!held.beyondPages?.length)
4
+ return held.threads;
5
+ const paged = new Set(held.threads.map((thread) => thread.executionId));
6
+ return newestFirst([...held.threads, ...held.beyondPages.filter((thread) => !paged.has(thread.executionId))]);
7
+ }
8
+ /** The ids of the discussions held only because they were read by id: the ones a host re-reads one by one. */
9
+ export function conversationsHeldBeyondPages(held) {
10
+ return (held.beyondPages ?? []).map((thread) => thread.executionId);
11
+ }
12
+ /** The discussions read by id that the paged ones do not already hold, once a page has been folded in. */
13
+ function stillBeyond(beyondPages, threads) {
14
+ const paged = new Set(threads.map((thread) => thread.executionId));
15
+ const remaining = (beyondPages ?? []).filter((thread) => !paged.has(thread.executionId));
16
+ return remaining.length > 0 ? { beyondPages: remaining } : {};
17
+ }
18
+ /**
19
+ * Fold in ONE discussion read by id (#4013). Held among the paged ones, it replaces that copy; otherwise it is held
20
+ * beyond the pages, replacing any earlier read of it.
21
+ */
22
+ export function withConversationReadById(held, thread) {
23
+ if (held.threads.some((paged) => paged.executionId === thread.executionId)) {
24
+ return { ...held, threads: held.threads.map((paged) => (paged.executionId === thread.executionId ? thread : paged)) };
25
+ }
26
+ const others = (held.beyondPages ?? []).filter((read) => read.executionId !== thread.executionId);
27
+ return { ...held, beyondPages: [...others, thread] };
28
+ }
29
+ /** Drop one discussion wherever it is held: deleted by the person, or gone when it was read again by id. */
30
+ export function withoutConversation(held, executionId) {
31
+ const threads = held.threads.filter((thread) => thread.executionId !== executionId);
32
+ return { threads, hasOlder: held.hasOlder, ...stillBeyond(held.beyondPages?.filter((thread) => thread.executionId !== executionId), threads) };
33
+ }
1
34
  function instantOf(thread) {
2
35
  return new Date(thread.createdAt).getTime();
3
36
  }
@@ -10,15 +43,21 @@ function newestFirst(threads) {
10
43
  * and so is what was known about whether more remain beyond them.
11
44
  */
12
45
  export function withNewestHistoryPage(held, page) {
13
- if (!page.hasOlder)
14
- return { threads: newestFirst(page.executions), hasOlder: false };
46
+ if (!page.hasOlder) {
47
+ const threads = newestFirst(page.executions);
48
+ // This page holds every discussion of the scope, so one read by id and absent from it was deleted meanwhile.
49
+ return { threads, hasOlder: false };
50
+ }
15
51
  const floor = Math.min(...page.executions.map(instantOf));
16
52
  const inPage = new Set(page.executions.map((thread) => thread.executionId));
17
53
  const olderHeld = held.threads.filter((thread) => instantOf(thread) < floor && !inPage.has(thread.executionId));
54
+ const threads = newestFirst([...page.executions, ...olderHeld]);
18
55
  return {
19
- threads: newestFirst([...page.executions, ...olderHeld]),
56
+ threads,
20
57
  // Older pages were read already: whether more remain beyond them is still what the last of them said.
21
58
  hasOlder: olderHeld.length > 0 ? held.hasOlder : true,
59
+ // A discussion read by id stays beyond the pages unless this page reached it; it is re-read by id, not by this page.
60
+ ...stillBeyond(held.beyondPages, threads),
22
61
  };
23
62
  }
24
63
  /**
@@ -29,7 +68,9 @@ export function withOlderHistoryPage(held, page) {
29
68
  const byId = new Map(held.threads.map((thread) => [thread.executionId, thread]));
30
69
  for (const thread of page.executions)
31
70
  byId.set(thread.executionId, thread);
32
- return { threads: newestFirst(byId.values()), hasOlder: page.hasOlder };
71
+ const threads = newestFirst(byId.values());
72
+ // A page that reaches a discussion read by id takes it over: it is paged from now on.
73
+ return { threads, hasOlder: page.hasOlder, ...stillBeyond(held.beyondPages, threads) };
33
74
  }
34
75
  /** The cursor for the next older page: the instant of the oldest discussion held, or `undefined` when none is. */
35
76
  export function olderHistoryCursor(held) {
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-history.model.js","sourceRoot":"","sources":["../../../../src/core/flows-actors/conversation-history.model.ts"],"names":[],"mappings":"AAiBA,SAAS,SAAS,CAAC,MAA4D;IAC7E,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,OAAoD;IACvE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,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AAE,MAAM;QACvD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC","sourcesContent":["import type { FlowsActors_ConversationExecution, FlowsActors_ConversationHistoryResponse } from '@wildo-ai/saas-models';\n\n/**\n * The discussions a host holds, read a page at a time (#2528).\n *\n * The history route answers the newest page, and older pages on request (`before`, the oldest instant already held,\n * inclusive). A host re-reads the NEWEST page after every turn, so these two merges keep what it already read of older\n * pages without letting it go stale: the newest page is the truth for every discussion inside its window, and older\n * pages fill in what lies before it.\n */\nexport interface HeldConversationHistory {\n /** Newest first, each discussion once. */\n readonly threads: readonly FlowsActors_ConversationExecution[];\n /** Whether discussions older than the oldest held remain to be read. */\n readonly hasOlder: boolean;\n}\n\nfunction instantOf(thread: Pick<FlowsActors_ConversationExecution, 'createdAt'>): number {\n return new Date(thread.createdAt).getTime();\n}\n\nfunction newestFirst(threads: Iterable<FlowsActors_ConversationExecution>): FlowsActors_ConversationExecution[] {\n return [...threads].sort((left, right) => instantOf(right) - instantOf(left));\n}\n\n/**\n * Fold in a fresh read of the NEWEST page. Inside the page's window (from its oldest discussion on) the page is the\n * whole truth: a discussion deleted meanwhile is gone, and one changed is replaced. Older pages already read are kept,\n * and so is what was known about whether more remain beyond them.\n */\nexport function withNewestHistoryPage(held: HeldConversationHistory, page: FlowsActors_ConversationHistoryResponse): HeldConversationHistory {\n if (!page.hasOlder) return { threads: newestFirst(page.executions), hasOlder: false };\n const floor = Math.min(...page.executions.map(instantOf));\n const inPage = new Set(page.executions.map((thread) => thread.executionId));\n const olderHeld = held.threads.filter((thread) => instantOf(thread) < floor && !inPage.has(thread.executionId));\n return {\n threads: newestFirst([...page.executions, ...olderHeld]),\n // Older pages were read already: whether more remain beyond them is still what the last of them said.\n hasOlder: olderHeld.length > 0 ? held.hasOlder : true,\n };\n}\n\n/**\n * Fold in an OLDER page. Its first discussion may be one already held (the cursor is inclusive), so each is kept once,\n * the page's copy winning.\n */\nexport function withOlderHistoryPage(held: HeldConversationHistory, page: FlowsActors_ConversationHistoryResponse): HeldConversationHistory {\n const byId = new Map(held.threads.map((thread) => [thread.executionId, thread] as const));\n for (const thread of page.executions) byId.set(thread.executionId, thread);\n return { threads: newestFirst(byId.values()), hasOlder: page.hasOlder };\n}\n\n/** The cursor for the next older page: the instant of the oldest discussion held, or `undefined` when none is. */\nexport function olderHistoryCursor(held: HeldConversationHistory): string | undefined {\n const oldest = held.threads.at(-1);\n return oldest ? new Date(oldest.createdAt).toISOString() : undefined;\n}\n\n/**\n * Every discussion of a context, read page after page, newest first: for a host that LISTS them all (the workbench's\n * conversation rail) rather than offering \"load older\".\n *\n * `undefined` when any page fails, so a host keeps the list it last read instead of showing part of one. The cursor is\n * inclusive, so each older page repeats the oldest discussion already held; a page that adds nothing new ends the read\n * rather than asking for the same page again. That can stop short only when more discussions share one instant than a\n * page holds.\n */\nexport async function readAllConversationHistory(\n readPage: (page?: { readonly before?: string }) => Promise<FlowsActors_ConversationHistoryResponse | undefined>,\n): Promise<readonly FlowsActors_ConversationExecution[] | undefined> {\n const newest = await readPage();\n if (!newest) return undefined;\n let held = withNewestHistoryPage({ threads: [], hasOlder: false }, newest);\n while (held.hasOlder) {\n const before = olderHistoryCursor(held);\n const page = await readPage(before ? { before } : undefined);\n if (!page) return undefined;\n const next = withOlderHistoryPage(held, page);\n if (next.threads.length === held.threads.length) break;\n held = next;\n }\n return held.threads;\n}\n"]}
1
+ {"version":3,"file":"conversation-history.model.js","sourceRoot":"","sources":["../../../../src/core/flows-actors/conversation-history.model.ts"],"names":[],"mappings":"AAwBA,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAAC,IAA6B;IAC7D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,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YAAE,OAAO,SAAS,CAAC;QAC5B,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM;QACvD,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC","sourcesContent":["import type { FlowsActors_ConversationExecution, FlowsActors_ConversationHistoryResponse } from '@wildo-ai/saas-models';\n\n/**\n * The discussions a host holds, read a page at a time (#2528).\n *\n * The history route answers the newest page, and older pages on request (`before`, the oldest instant already held,\n * inclusive). A host re-reads the NEWEST page after every turn, so these two merges keep what it already read of older\n * pages without letting it go stale: the newest page is the truth for every discussion inside its window, and older\n * pages fill in what lies before it.\n */\nexport interface HeldConversationHistory {\n /** The discussions read page by page: newest first, each once. The cursor for the next older page is the oldest of them. */\n readonly threads: readonly FlowsActors_ConversationExecution[];\n /** Whether discussions older than the oldest held remain to be read. */\n readonly hasOlder: boolean;\n /**\n * Discussions read ONE BY ONE, by id, that the pages read so far do not reach (#4013): the one a link named, older\n * than the newest page. Kept apart from {@link threads} because the next older page starts from the oldest PAGED\n * discussion: counting one of these as paged would skip every discussion between the two. A page that reaches one\n * takes it over. Absent when none was read.\n */\n readonly beyondPages?: readonly FlowsActors_ConversationExecution[];\n}\n\n/** Every discussion held, paged or read by id, newest first, each once: what a host lists and opens. */\nexport function heldConversations(held: HeldConversationHistory): readonly FlowsActors_ConversationExecution[] {\n if (!held.beyondPages?.length) return held.threads;\n const paged = new Set(held.threads.map((thread) => thread.executionId));\n return newestFirst([...held.threads, ...held.beyondPages.filter((thread) => !paged.has(thread.executionId))]);\n}\n\n/** The ids of the discussions held only because they were read by id: the ones a host re-reads one by one. */\nexport function conversationsHeldBeyondPages(held: HeldConversationHistory): readonly string[] {\n return (held.beyondPages ?? []).map((thread) => thread.executionId);\n}\n\n/** The discussions read by id that the paged ones do not already hold, once a page has been folded in. */\nfunction stillBeyond(beyondPages: HeldConversationHistory['beyondPages'], threads: readonly FlowsActors_ConversationExecution[]): Pick<HeldConversationHistory, 'beyondPages'> {\n const paged = new Set(threads.map((thread) => thread.executionId));\n const remaining = (beyondPages ?? []).filter((thread) => !paged.has(thread.executionId));\n return remaining.length > 0 ? { beyondPages: remaining } : {};\n}\n\n/**\n * Fold in ONE discussion read by id (#4013). Held among the paged ones, it replaces that copy; otherwise it is held\n * beyond the pages, replacing any earlier read of it.\n */\nexport function withConversationReadById(held: HeldConversationHistory, thread: FlowsActors_ConversationExecution): HeldConversationHistory {\n if (held.threads.some((paged) => paged.executionId === thread.executionId)) {\n return { ...held, threads: held.threads.map((paged) => (paged.executionId === thread.executionId ? thread : paged)) };\n }\n const others = (held.beyondPages ?? []).filter((read) => read.executionId !== thread.executionId);\n return { ...held, beyondPages: [...others, thread] };\n}\n\n/** Drop one discussion wherever it is held: deleted by the person, or gone when it was read again by id. */\nexport function withoutConversation(held: HeldConversationHistory, executionId: string): HeldConversationHistory {\n const threads = held.threads.filter((thread) => thread.executionId !== executionId);\n return { threads, hasOlder: held.hasOlder, ...stillBeyond(held.beyondPages?.filter((thread) => thread.executionId !== executionId), threads) };\n}\n\nfunction instantOf(thread: Pick<FlowsActors_ConversationExecution, 'createdAt'>): number {\n return new Date(thread.createdAt).getTime();\n}\n\nfunction newestFirst(threads: Iterable<FlowsActors_ConversationExecution>): FlowsActors_ConversationExecution[] {\n return [...threads].sort((left, right) => instantOf(right) - instantOf(left));\n}\n\n/**\n * Fold in a fresh read of the NEWEST page. Inside the page's window (from its oldest discussion on) the page is the\n * whole truth: a discussion deleted meanwhile is gone, and one changed is replaced. Older pages already read are kept,\n * and so is what was known about whether more remain beyond them.\n */\nexport function withNewestHistoryPage(held: HeldConversationHistory, page: FlowsActors_ConversationHistoryResponse): HeldConversationHistory {\n if (!page.hasOlder) {\n const threads = newestFirst(page.executions);\n // This page holds every discussion of the scope, so one read by id and absent from it was deleted meanwhile.\n return { threads, hasOlder: false };\n }\n const floor = Math.min(...page.executions.map(instantOf));\n const inPage = new Set(page.executions.map((thread) => thread.executionId));\n const olderHeld = held.threads.filter((thread) => instantOf(thread) < floor && !inPage.has(thread.executionId));\n const threads = newestFirst([...page.executions, ...olderHeld]);\n return {\n threads,\n // Older pages were read already: whether more remain beyond them is still what the last of them said.\n hasOlder: olderHeld.length > 0 ? held.hasOlder : true,\n // A discussion read by id stays beyond the pages unless this page reached it; it is re-read by id, not by this page.\n ...stillBeyond(held.beyondPages, threads),\n };\n}\n\n/**\n * Fold in an OLDER page. Its first discussion may be one already held (the cursor is inclusive), so each is kept once,\n * the page's copy winning.\n */\nexport function withOlderHistoryPage(held: HeldConversationHistory, page: FlowsActors_ConversationHistoryResponse): HeldConversationHistory {\n const byId = new Map(held.threads.map((thread) => [thread.executionId, thread] as const));\n for (const thread of page.executions) byId.set(thread.executionId, thread);\n const threads = newestFirst(byId.values());\n // A page that reaches a discussion read by id takes it over: it is paged from now on.\n return { threads, hasOlder: page.hasOlder, ...stillBeyond(held.beyondPages, threads) };\n}\n\n/** The cursor for the next older page: the instant of the oldest discussion held, or `undefined` when none is. */\nexport function olderHistoryCursor(held: HeldConversationHistory): string | undefined {\n const oldest = held.threads.at(-1);\n return oldest ? new Date(oldest.createdAt).toISOString() : undefined;\n}\n\n/**\n * Every discussion of a context, read page after page, newest first: for a host that LISTS them all (the workbench's\n * conversation rail) rather than offering \"load older\".\n *\n * `undefined` when any page fails, so a host keeps the list it last read instead of showing part of one. The cursor is\n * inclusive, so each older page repeats the oldest discussion already held; a page that adds nothing new ends the read\n * rather than asking for the same page again. That can stop short only when more discussions share one instant than a\n * page holds.\n */\nexport async function readAllConversationHistory(\n readPage: (page?: { readonly before?: string }) => Promise<FlowsActors_ConversationHistoryResponse | undefined>,\n): Promise<readonly FlowsActors_ConversationExecution[] | undefined> {\n const newest = await readPage();\n if (!newest) return undefined;\n let held = withNewestHistoryPage({ threads: [], hasOlder: false }, newest);\n while (held.hasOlder) {\n const before = olderHistoryCursor(held);\n const page = await readPage(before ? { before } : undefined);\n if (!page) return undefined;\n const next = withOlderHistoryPage(held, page);\n if (next.threads.length === held.threads.length) break;\n held = next;\n }\n return held.threads;\n}\n"]}
@@ -22,11 +22,6 @@ interface NavigationContentAreasProps {
22
22
  * or DESTROYS a mounted surface, and that is not observable from anything else in this module.
23
23
  */
24
24
  export declare function getContentKey(content: NavigationContent, entryId?: string): string;
25
- /**
26
- * Render content based on NavigationContent type.
27
- *
28
- * Exported for reuse by overlay presets (e.g., ContainerDialogs_Default).
29
- */
30
25
  export declare const NavigationContentRenderer: React.FC<{
31
26
  content: NavigationContent;
32
27
  zone: NavigationZone;
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationContentAreas.d.ts","sourceRoot":"","sources":["../../../../src/core/navigation/NavigationContentAreas.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EACL,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAsB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAShF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAyB,0BAA0B,EAAwB,MAAM,sBAAsB,CAAC;AAsElJ,UAAU,2BAA2B;IACnC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC;CACjC;AAeD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAgElF;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC/C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,CAAC,EAAE,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uB,CAO1B;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAQ3C;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG;IAC7F,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB,CAMA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAChC,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,EACtB,cAAc,EAAE,MAAM,GACrB;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B,CA2FA;AAqRD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA0mBxE,CAAC;AAuHF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAEtC,CAAC"}
1
+ {"version":3,"file":"NavigationContentAreas.d.ts","sourceRoot":"","sources":["../../../../src/core/navigation/NavigationContentAreas.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EACL,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MA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