@teaflask/assistant 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/custom-elements.json +264 -0
- package/dist/appearance/theme.d.ts +138 -0
- package/dist/components/approval-card.js +3 -3
- package/dist/components/approval-context.d.ts +20 -0
- package/dist/components/assistant-companion.d.ts +15 -0
- package/dist/components/assistant-page.d.ts +61 -0
- package/dist/components/assistant-palette.d.ts +12 -0
- package/dist/components/assistant-palette.js +2 -2
- package/dist/components/child-transcript.js +1 -1
- package/dist/components/companion-header-disclosure.js +1 -1
- package/dist/components/companion-history-menu.js +1 -1
- package/dist/components/composer.js +11 -65
- package/dist/components/conversation-context.d.ts +6 -0
- package/dist/components/conversation-gate-card.js +1 -1
- package/dist/components/conversation-view.d.ts +11 -0
- package/dist/components/elicitation-context.d.ts +39 -0
- package/dist/components/model-picker-chip.js +4 -2
- package/dist/components/primitives/button.js +25 -17
- package/dist/components/primitives/floating-panel.js +1 -1
- package/dist/components/provider-chip.js +8 -1
- package/dist/components/question-panel-footer.js +1 -1
- package/dist/components/react-tool-view.d.ts +7 -0
- package/dist/components/subagent-count-pill.js +2 -2
- package/dist/components/subagent-group-row.js +1 -26
- package/dist/components/subagent-preview-popover.js +1 -1
- package/dist/components/subscription-connect-arms.js +6 -4
- package/dist/components/subscription-connect-flow.js +30 -45
- package/dist/components/subscription-connected-standing.js +9 -6
- package/dist/components/subscription-plan-notice.js +4 -2
- package/dist/components/teaflask-assistant-provider.d.ts +99 -0
- package/dist/components/teaflask-assistant.d.ts +33 -0
- package/dist/components/tool-views/action-view.js +1 -1
- package/dist/components/tool-views/parts-classes.d.ts +5 -5
- package/dist/components/tool-views/parts-classes.js +5 -5
- package/dist/components/tool-views/parts.d.ts +44 -0
- package/dist/components/tool-views/questions-view.js +2 -2
- package/dist/components/tool-views/view-dom.d.ts +76 -0
- package/dist/components/transcript.js +2 -2
- package/dist/components/use-assistant-activity.d.ts +5 -0
- package/dist/components/use-assistant-conversation.d.ts +99 -2
- package/dist/components/use-store-cell.d.ts +5 -0
- package/dist/components/use-thread-dispatches.js +8 -366
- package/dist/components/use-transcript-folds.js +2 -1
- package/dist/components/use-transcript.d.ts +55 -2
- package/dist/components/use-transcript.js +7 -2
- package/dist/contract/actions-adapter.d.ts +78 -0
- package/dist/contract/errors.d.ts +6 -1
- package/dist/contract/events.d.ts +1 -3
- package/dist/contract/identity.d.ts +1 -1
- package/dist/contract/subscriptions.d.ts +2 -2
- package/dist/contract/subscriptions.js +1 -1
- package/dist/contract/telemetry.d.ts +45 -0
- package/dist/contract/threads.d.ts +5 -1
- package/dist/core/activity.d.ts +44 -0
- package/dist/core/approval-inbox.d.ts +69 -0
- package/dist/core/assistant-session-registry.js +15 -0
- package/dist/core/composer-attachments.js +82 -0
- package/dist/core/composer-input-state.js +1 -0
- package/dist/core/composer-policy.d.ts +20 -0
- package/dist/core/connection-epoch.d.ts +65 -2
- package/dist/core/conversation-adoption.js +3 -0
- package/dist/core/conversation-contract.d.ts +112 -1
- package/dist/core/conversation-publish.js +1 -0
- package/dist/core/conversation-store.d.ts +3 -0
- package/dist/core/conversation-store.js +7 -0
- package/dist/core/dispatch-poll.js +81 -0
- package/dist/core/elicitation-answers.js +12 -0
- package/dist/core/elicitation-cards.d.ts +14 -0
- package/dist/core/elicitation-pickers.d.ts +16 -0
- package/dist/core/memory-provenance-anchors.d.ts +16 -0
- package/dist/core/observable-cell.d.ts +12 -0
- package/dist/core/pending-decision-gap.d.ts +9 -0
- package/dist/core/question-drafts.d.ts +59 -0
- package/dist/core/receipt-anchors.d.ts +9 -0
- package/dist/core/segment-timing.d.ts +23 -0
- package/dist/core/subagent-delivery-anchors.d.ts +7 -0
- package/dist/core/subagent-ledger-join.js +176 -0
- package/dist/core/subagent-rows.d.ts +68 -0
- package/dist/core/thread-dispatch-ledger.js +303 -0
- package/dist/core/tool-call-display.d.ts +71 -0
- package/dist/core/tool-call-presentation.d.ts +34 -1
- package/dist/core/tool-call-presentation.js +0 -1
- package/dist/core/tool-schema-anchors.d.ts +6 -0
- package/dist/core/tool-view.d.ts +174 -1
- package/dist/core/transcript-rows.d.ts +138 -3
- package/dist/core/turn-failed-anchors.d.ts +4 -0
- package/dist/core/user-turn-ledger.d.ts +3 -0
- package/dist/generated/models/apiErrorCode.d.ts +1 -0
- package/dist/generated/models/apiErrorCode.js +1 -0
- package/dist/generated/models/assistantTurnStatus.d.ts +16 -0
- package/dist/generated/models/servingAssistantThreadResponse.d.ts +23 -0
- package/dist/generated/models/servingAttachmentResponse.d.ts +29 -0
- package/dist/generated/models/servingErrorCode.d.ts +18 -0
- package/dist/generated/models/servingTurnAttachmentResponse.d.ts +12 -0
- package/dist/generated/models/siteTheme.d.ts +1 -0
- package/dist/generated/models/thinkingEffort.d.ts +10 -0
- package/dist/generated/models/threadModelPickResponse.d.ts +12 -0
- package/dist/headless.d.ts +9 -4
- package/dist/index.d.ts +2 -6
- package/dist/index.js +0 -3
- package/dist/persistence/stored-thread.d.ts +5 -0
- package/dist/styles.css +1 -1
- package/dist/transport/serving-error.d.ts +21 -0
- package/package.json +6 -25
- package/dist/affordances/highlight.d.ts +0 -3
- package/dist/affordances/prefill.d.ts +0 -14
- package/dist/components/activity-rail.d.ts +0 -12
- package/dist/components/activity-shelf.d.ts +0 -7
- package/dist/components/agent-identity-mark.d.ts +0 -7
- package/dist/components/appearance-context.d.ts +0 -14
- package/dist/components/approval-card.d.ts +0 -7
- package/dist/components/assistant-palette-body.d.ts +0 -3
- package/dist/components/assistant-transcript.d.ts +0 -47
- package/dist/components/attachment-chips.d.ts +0 -4
- package/dist/components/child-transcript.d.ts +0 -22
- package/dist/components/companion-drawer-body.d.ts +0 -1
- package/dist/components/companion-drawer.d.ts +0 -10
- package/dist/components/companion-header-disclosure.d.ts +0 -20
- package/dist/components/companion-history-menu.d.ts +0 -15
- package/dist/components/companion-mark-image.d.ts +0 -3
- package/dist/components/companion-mark-image.js +0 -18
- package/dist/components/companion-mark.d.ts +0 -1
- package/dist/components/companion-mode-menu.d.ts +0 -15
- package/dist/components/composer-attachment-chip.d.ts +0 -7
- package/dist/components/composer-banner.d.ts +0 -4
- package/dist/components/composer.d.ts +0 -4
- package/dist/components/conversation-gate-card.d.ts +0 -8
- package/dist/components/conversation-surfaces-provider.d.ts +0 -6
- package/dist/components/copy-text-button.d.ts +0 -5
- package/dist/components/elicitation-receipt-row.d.ts +0 -4
- package/dist/components/human-file-size.d.ts +0 -1
- package/dist/components/icons.d.ts +0 -15
- package/dist/components/lazy-body.d.ts +0 -4
- package/dist/components/markdown/assistant-markdown.d.ts +0 -3
- package/dist/components/markdown/code-block.d.ts +0 -4
- package/dist/components/markdown/highlight.d.ts +0 -1
- package/dist/components/markdown/markdown-structure.d.ts +0 -16
- package/dist/components/markdown/memoized-blocks.d.ts +0 -6
- package/dist/components/markdown/paced-assistant-markdown.d.ts +0 -4
- package/dist/components/markdown/reveal-pacer.d.ts +0 -20
- package/dist/components/markdown/shiki-highlighter.d.ts +0 -1
- package/dist/components/markdown/streaming-repair.d.ts +0 -1
- package/dist/components/markdown/use-highlighted-html.d.ts +0 -1
- package/dist/components/markdown/use-paced-reveal.d.ts +0 -5
- package/dist/components/memory-updated-footer.d.ts +0 -4
- package/dist/components/message-list-row.d.ts +0 -13
- package/dist/components/message-list-slots.d.ts +0 -25
- package/dist/components/message-list-slots.js +0 -1
- package/dist/components/message-list.d.ts +0 -23
- package/dist/components/model-picker-chip.d.ts +0 -1
- package/dist/components/model-picker-effort.d.ts +0 -4
- package/dist/components/model-picker-panels.d.ts +0 -22
- package/dist/components/notice-banner.d.ts +0 -8
- package/dist/components/operation-icons.d.ts +0 -19
- package/dist/components/pretty-print.d.ts +0 -1
- package/dist/components/primitives/autofocus.d.ts +0 -1
- package/dist/components/primitives/button.d.ts +0 -10
- package/dist/components/primitives/cx.d.ts +0 -1
- package/dist/components/primitives/dialog.d.ts +0 -7
- package/dist/components/primitives/disclosure.d.ts +0 -22
- package/dist/components/primitives/file-input.d.ts +0 -5
- package/dist/components/primitives/floating-panel.d.ts +0 -15
- package/dist/components/primitives/kbd.d.ts +0 -2
- package/dist/components/primitives/sheet.d.ts +0 -11
- package/dist/components/primitives/sheet.js +0 -18
- package/dist/components/primitives/textarea.d.ts +0 -7
- package/dist/components/primitives/use-dock-reflow.d.ts +0 -2
- package/dist/components/primitives/use-swipe-dismiss.d.ts +0 -17
- package/dist/components/provider-chip.d.ts +0 -8
- package/dist/components/question-panel-answers.d.ts +0 -29
- package/dist/components/question-panel-footer.d.ts +0 -9
- package/dist/components/question-panel.d.ts +0 -4
- package/dist/components/reasoning-row.d.ts +0 -4
- package/dist/components/receipt-rows.d.ts +0 -3
- package/dist/components/run-status-announcer.d.ts +0 -5
- package/dist/components/scroll-follow-guards.d.ts +0 -1
- package/dist/components/served-suggestions.d.ts +0 -3
- package/dist/components/slot-boundary.d.ts +0 -11
- package/dist/components/standing-poll.d.ts +0 -1
- package/dist/components/streaming-states.d.ts +0 -12
- package/dist/components/subagent-count-pill.d.ts +0 -8
- package/dist/components/subagent-current-work.d.ts +0 -6
- package/dist/components/subagent-delegation-surface.d.ts +0 -9
- package/dist/components/subagent-delivery-divider.d.ts +0 -5
- package/dist/components/subagent-drill-in.d.ts +0 -8
- package/dist/components/subagent-execution-work.d.ts +0 -3
- package/dist/components/subagent-group-row.d.ts +0 -26
- package/dist/components/subagent-preview-popover.d.ts +0 -8
- package/dist/components/subscription-connect-arms.d.ts +0 -25
- package/dist/components/subscription-connect-flow.d.ts +0 -60
- package/dist/components/subscription-connected-standing.d.ts +0 -16
- package/dist/components/subscription-plan-notice.d.ts +0 -1
- package/dist/components/subscription-recheck.d.ts +0 -10
- package/dist/components/surface-boundary.d.ts +0 -8
- package/dist/components/suspension-surfaces.d.ts +0 -3
- package/dist/components/thread-list.d.ts +0 -16
- package/dist/components/tool-arguments-summary.d.ts +0 -2
- package/dist/components/tool-call-rows.d.ts +0 -10
- package/dist/components/tool-row.d.ts +0 -7
- package/dist/components/tool-view-registry-context.d.ts +0 -3
- package/dist/components/tool-view-slot.d.ts +0 -11
- package/dist/components/tool-views/action-view.d.ts +0 -1
- package/dist/components/tool-views/command-view.d.ts +0 -1
- package/dist/components/tool-views/docs-search-view.d.ts +0 -10
- package/dist/components/tool-views/file-edit-view.d.ts +0 -1
- package/dist/components/tool-views/questions-view.d.ts +0 -1
- package/dist/components/transcript.d.ts +0 -3
- package/dist/components/use-agent-subscriber.d.ts +0 -3
- package/dist/components/use-agent-subscriber.js +0 -13
- package/dist/components/use-answer-list-fold.d.ts +0 -6
- package/dist/components/use-assistant-surface-presence.d.ts +0 -2
- package/dist/components/use-child-replay-stream.d.ts +0 -20
- package/dist/components/use-latest-ref.d.ts +0 -2
- package/dist/components/use-member-toggle-outrank.d.ts +0 -6
- package/dist/components/use-perch-clearance.d.ts +0 -2
- package/dist/components/use-question-panel-keys.d.ts +0 -32
- package/dist/components/use-register-assistant-surface.d.ts +0 -2
- package/dist/components/use-resolved-theme-mode.d.ts +0 -3
- package/dist/components/use-roster-disclosure.d.ts +0 -20
- package/dist/components/use-roster-preview.d.ts +0 -24
- package/dist/components/use-thread-dispatches.d.ts +0 -8
- package/dist/components/use-transcript-folds.d.ts +0 -26
- package/dist/components/user-message.d.ts +0 -6
- package/dist/contract/actions-adapter.js +0 -1
- package/dist/contract/assistant-config.js +0 -1
- package/dist/contract/dispatches.d.ts +0 -15
- package/dist/contract/errors.js +0 -1
- package/dist/contract/identity.js +0 -1
- package/dist/core/activity-title.d.ts +0 -1
- package/dist/core/agent-identity.d.ts +0 -2
- package/dist/core/approval-decision.d.ts +0 -6
- package/dist/core/approval-resolved.d.ts +0 -7
- package/dist/core/assistant-prose.d.ts +0 -2
- package/dist/core/assistant-session-registry.d.ts +0 -51
- package/dist/core/attachment-uploads.d.ts +0 -5
- package/dist/core/block-timing-anchors.d.ts +0 -5
- package/dist/core/companion-drawer-flag.d.ts +0 -4
- package/dist/core/companion-presence.d.ts +0 -7
- package/dist/core/composer-input-state.d.ts +0 -8
- package/dist/core/connection-driver.d.ts +0 -3
- package/dist/core/conversation-adoption.d.ts +0 -13
- package/dist/core/conversation-contract.js +0 -1
- package/dist/core/conversation-publish.d.ts +0 -8
- package/dist/core/conversation-refresh.d.ts +0 -4
- package/dist/core/conversation-send.d.ts +0 -6
- package/dist/core/disposable-subscriber.d.ts +0 -6
- package/dist/core/disposable-subscriber.js +0 -18
- package/dist/core/dock-reflow.d.ts +0 -5
- package/dist/core/elicitation-answers.d.ts +0 -7
- package/dist/core/epoch-sync.d.ts +0 -12
- package/dist/core/error-copy.d.ts +0 -3
- package/dist/core/execution-driver.d.ts +0 -37
- package/dist/core/host-fill.d.ts +0 -1
- package/dist/core/hotkey.d.ts +0 -18
- package/dist/core/identity-pair.d.ts +0 -14
- package/dist/core/idle-recheck.d.ts +0 -3
- package/dist/core/messages-cell.d.ts +0 -11
- package/dist/core/perch-clearance.d.ts +0 -19
- package/dist/core/question-receipt.d.ts +0 -11
- package/dist/core/reasoning-copy.d.ts +0 -2
- package/dist/core/run-folds.d.ts +0 -43
- package/dist/core/run-status.d.ts +0 -4
- package/dist/core/settle-refresh.d.ts +0 -9
- package/dist/core/step-caption.d.ts +0 -2
- package/dist/core/stop-copy.d.ts +0 -1
- package/dist/core/stop-settle.d.ts +0 -5
- package/dist/core/stream-trouble.d.ts +0 -5
- package/dist/core/subagent-brief.d.ts +0 -3
- package/dist/core/subagent-presence.d.ts +0 -10
- package/dist/core/subagent-roster.d.ts +0 -35
- package/dist/core/surface-registry.d.ts +0 -16
- package/dist/core/suspension-queue.d.ts +0 -14
- package/dist/core/tail-slot-pool.d.ts +0 -13
- package/dist/core/time-labels.d.ts +0 -7
- package/dist/core/tool-call-display-anchors.d.ts +0 -11
- package/dist/core/tool-cancel-anchors.d.ts +0 -5
- package/dist/core/tool-decision-anchors.d.ts +0 -6
- package/dist/core/tool-error-anchors.d.ts +0 -5
- package/dist/core/tool-flag-anchors.d.ts +0 -9
- package/dist/core/tool-offload-anchors.d.ts +0 -5
- package/dist/core/tool-outcome.d.ts +0 -9
- package/dist/core/tool-refusal-anchors.d.ts +0 -5
- package/dist/core/tool-result-envelope.d.ts +0 -3
- package/dist/core/tool-sentence-anchors.d.ts +0 -11
- package/dist/core/transcript-lease.d.ts +0 -2
- package/dist/core/turn-failure-copy.d.ts +0 -4
- package/dist/core/turns-backfill.d.ts +0 -14
- package/dist/core/wire-sentence-cap.d.ts +0 -1
- package/dist/generated/serving.d.ts +0 -38
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.js +0 -4
- package/dist/persistence/execution-ledger.d.ts +0 -7
- package/dist/persistence/panel-mode.d.ts +0 -6
- package/dist/persistence/plan-notice.d.ts +0 -3
- package/dist/reader/accessible-name.d.ts +0 -3
- package/dist/reader/interactivity.d.ts +0 -11
- package/dist/reader/layout-probe.d.ts +0 -29
- package/dist/reader/line-diff.d.ts +0 -1
- package/dist/reader/read-page.d.ts +0 -12
- package/dist/reader/redaction.d.ts +0 -3
- package/dist/reader/render.d.ts +0 -3
- package/dist/reader/roles.d.ts +0 -8
- package/dist/reader/snapshot-compaction.d.ts +0 -5
- package/dist/reader/snapshot-node.d.ts +0 -4
- package/dist/reader/snapshot-root.d.ts +0 -15
- package/dist/reader/snapshot.d.ts +0 -60
- package/dist/reader/visibility.d.ts +0 -8
- package/dist/scroll.d.ts +0 -1
- package/dist/scroll.js +0 -1
- package/dist/transcript-ui.d.ts +0 -15
- package/dist/transcript-ui.js +0 -8
- package/dist/transcript.d.ts +0 -43
- package/dist/transcript.js +0 -38
- package/dist/transport/actions-adapter.d.ts +0 -4
- package/dist/transport/door-budget.d.ts +0 -4
- package/dist/transport/serving-api.d.ts +0 -33
- package/dist/transport/serving-fetch.d.ts +0 -11
|
@@ -13,23 +13,86 @@ import { type ToolCallSchemas } from "./tool-schema-anchors.js";
|
|
|
13
13
|
import { type AnchoredTurnFailReceipts } from "./turn-failed-anchors.js";
|
|
14
14
|
import { type TurnUsage } from "./turn-usage-anchors.js";
|
|
15
15
|
import { type UserTurnLedger } from "./user-turn-ledger.js";
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Lookup tables of extra facts the stream reports alongside the messages, keyed
|
|
18
|
+
* by message id, tool call id or memory id. transcriptRowsOf joins them into
|
|
19
|
+
* rows; read them directly only for custom rendering.
|
|
20
|
+
*/
|
|
21
|
+
export interface TranscriptMarkers {
|
|
22
|
+
/**
|
|
23
|
+
* Ids of messages where an interrupted response was retried. Calls left
|
|
24
|
+
* unfinished before that point in the same turn show as superseded; the
|
|
25
|
+
* values are internal and can be ignored.
|
|
26
|
+
*/
|
|
17
27
|
resumeAnchors: ReadonlyMap<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Failure sentences for turns that failed outside any single tool call,
|
|
30
|
+
* keyed by the id of the message they are shown next to.
|
|
31
|
+
*/
|
|
18
32
|
turnFailedAnchors: ReadonlyMap<string, AnchoredTurnFailReceipts>;
|
|
33
|
+
/**
|
|
34
|
+
* Finished sub-agent results reported by a turn the assistant started on
|
|
35
|
+
* its own, keyed by the id of that turn's first message.
|
|
36
|
+
*/
|
|
19
37
|
subagentDeliveryAnchors: ReadonlyMap<string, DeliveredResult[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Error text for tool calls that failed, keyed by tool call id; an empty
|
|
40
|
+
* string means the failure is described by the call's result text.
|
|
41
|
+
*/
|
|
20
42
|
toolErrorAnchors: ReadonlyMap<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Ids of tool calls cancelled before they ran, for example because the user
|
|
45
|
+
* stopped the response.
|
|
46
|
+
*/
|
|
21
47
|
toolCancelAnchors: ReadonlySet<string>;
|
|
48
|
+
/**
|
|
49
|
+
* The tool's explanation for each call it declined, keyed by tool call id.
|
|
50
|
+
*/
|
|
22
51
|
toolRefusalAnchors: ReadonlyMap<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Ids of tool calls whose output was too large and was replaced by a
|
|
54
|
+
* shortened stand-in.
|
|
55
|
+
*/
|
|
23
56
|
toolOffloadAnchors: ReadonlySet<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Ids of tool calls the user was asked to approve or answer a question for.
|
|
59
|
+
* Treat a missing set as empty.
|
|
60
|
+
*/
|
|
24
61
|
toolDecisionAnchors?: ReadonlySet<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Ids of tool calls whose approval the user declined. Treat a missing set
|
|
64
|
+
* as empty.
|
|
65
|
+
*/
|
|
25
66
|
toolDenialAnchors?: ReadonlySet<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Server-supplied captions, status text, icons and tool view references,
|
|
69
|
+
* keyed by tool call id.
|
|
70
|
+
*/
|
|
26
71
|
toolCallDisplayAnchors: ReadonlyMap<string, ToolCallDisplay>;
|
|
72
|
+
/**
|
|
73
|
+
* The JSON Schemas declared for each call's arguments and result, keyed by
|
|
74
|
+
* tool call id; a call with no entry declared none.
|
|
75
|
+
*/
|
|
27
76
|
toolSchemaAnchors: ReadonlyMap<string, ToolCallSchemas>;
|
|
77
|
+
/**
|
|
78
|
+
* Server timestamps for each message and tool call, keyed by message id or
|
|
79
|
+
* tool call id; a missing entry means the timing is unknown.
|
|
80
|
+
*/
|
|
28
81
|
blockTimingAnchors: ReadonlyMap<string, BlockTiming>;
|
|
29
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Every memory the assistant saved in this conversation, keyed by memory
|
|
84
|
+
* id, in the order saved.
|
|
85
|
+
*/
|
|
30
86
|
memoryProvenanceAnchors: ReadonlyMap<string, MemoryUpdated>;
|
|
87
|
+
/**
|
|
88
|
+
* For each saved memory id, the id of the assistant message it is shown
|
|
89
|
+
* under; a memory with no entry is shown under no message.
|
|
90
|
+
*/
|
|
31
91
|
memoryAttributionAnchors: ReadonlyMap<string, string>;
|
|
32
92
|
}
|
|
93
|
+
export interface MarkerAnchorsSnapshot extends TranscriptMarkers {
|
|
94
|
+
turnUsageAnchors: ReadonlyMap<string, TurnUsage>;
|
|
95
|
+
}
|
|
33
96
|
export declare function markerAnchorsOf(resume: StreamResumeStore): MarkerAnchorsSnapshot;
|
|
34
97
|
export interface ConnectionEpochDeps {
|
|
35
98
|
epochId: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clearStoredThread, readStoredThread, readStoredThreadFor, writeStoredThread, } from "../persistence/stored-thread.js";
|
|
2
2
|
import { getAssistantThread, listAssistantThreads, } from "../transport/serving-api.js";
|
|
3
|
+
import { noteThreadRead } from "./dispatch-poll.js";
|
|
3
4
|
import { ServingApiError } from "../transport/serving-error.js";
|
|
4
5
|
import { StreamResumeStore } from "../transport/stream-resume.js";
|
|
5
6
|
import { ApprovalInbox, SERVING_APPROVAL_CAPABILITIES, } from "./approval-inbox.js";
|
|
@@ -134,6 +135,7 @@ function _finishAdoption(store, detail) {
|
|
|
134
135
|
if (!_someTurnIsLive(detail.turns)) {
|
|
135
136
|
store._stopping = false;
|
|
136
137
|
}
|
|
138
|
+
noteThreadRead(store, detail.thread.id);
|
|
137
139
|
publishStore(store);
|
|
138
140
|
}
|
|
139
141
|
function adoptCoworkerRequests(store, turns) {
|
|
@@ -177,6 +179,7 @@ export function adoptRefreshedDetail(store, detail) {
|
|
|
177
179
|
if (!_someTurnIsLive(detail.turns)) {
|
|
178
180
|
store._stopping = false;
|
|
179
181
|
}
|
|
182
|
+
noteThreadRead(store, detail.thread.id);
|
|
180
183
|
publishStore(store);
|
|
181
184
|
}
|
|
182
185
|
function _adoptWireModelPick(store, thread, { evenWhenDirty }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServedThinkingEffort } from "../contract/assistant-config.js";
|
|
1
|
+
import type { ServedAttachmentPolicy, ServedThinkingEffort } from "../contract/assistant-config.js";
|
|
2
2
|
import type { AssistantTelemetryEvent } from "../contract/telemetry.js";
|
|
3
3
|
import type { ServingAssistantThread, ServingAssistantTurn, TurnAttachment } from "../contract/threads.js";
|
|
4
4
|
import type { ServingReplayStreamAgent } from "../transport/replay-stream-agent.js";
|
|
@@ -18,34 +18,143 @@ export interface ActiveConversation {
|
|
|
18
18
|
approvalInbox: ApprovalInbox;
|
|
19
19
|
coworkerRequestTurns: readonly ServingAssistantTurn[];
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* State and controls for writing and sending messages in the open conversation,
|
|
23
|
+
* returned by useConversation() (inside <TeaflaskAssistantProvider>) and as
|
|
24
|
+
* AssistantConversation.composerContract.
|
|
25
|
+
*/
|
|
21
26
|
export interface ComposerContract {
|
|
27
|
+
/**
|
|
28
|
+
* True while a message is being sent or the assistant is replying; disable
|
|
29
|
+
* sending and offer a Stop button. False once the agent has stopped
|
|
30
|
+
* actively waiting on an unanswered approval or question (the card reads
|
|
31
|
+
* parked).
|
|
32
|
+
*/
|
|
22
33
|
busy: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* True while a message is on its way to the server, before it is accepted.
|
|
36
|
+
* There is no reply to stop yet, so hide Stop during this window.
|
|
37
|
+
*/
|
|
23
38
|
pendingSend: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Sends a message (with the ids of already-uploaded attachments and their
|
|
41
|
+
* display details for the instant echo), starting a new conversation if
|
|
42
|
+
* none is open. Resolves true once the server accepts it, or false if it
|
|
43
|
+
* was refused (sendError explains why); it does not clear the draft, so
|
|
44
|
+
* clear and restore it yourself.
|
|
45
|
+
*/
|
|
24
46
|
sendMessage: (message: string, attachmentIds?: string[], optimisticAttachments?: TurnAttachment[]) => Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* The message just sent, to show immediately until the transcript includes
|
|
49
|
+
* it; null otherwise. useTranscript().displayRows already includes it, so
|
|
50
|
+
* don't draw it again if you render those.
|
|
51
|
+
*/
|
|
25
52
|
pendingEcho: {
|
|
26
53
|
messageId: string;
|
|
27
54
|
text: string;
|
|
28
55
|
attachments: TurnAttachment[];
|
|
29
56
|
} | null;
|
|
57
|
+
/**
|
|
58
|
+
* True after a send or stop has gone through and before your input takes
|
|
59
|
+
* focus back. When it is true and busy is false, focus your input and call
|
|
60
|
+
* markComposerRefocusHandled.
|
|
61
|
+
*/
|
|
30
62
|
composerRefocusPending: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Call once you have handled composerRefocusPending, to reset it to false.
|
|
65
|
+
*/
|
|
31
66
|
markComposerRefocusHandled: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* True from a Stop press until the reply has stopped (or the wait gives
|
|
69
|
+
* up); show a "Stopping" state and don't offer Stop again.
|
|
70
|
+
*/
|
|
32
71
|
stopping: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Stops the reply in progress. Does nothing when nothing is running, a send
|
|
74
|
+
* is still in flight, or a stop is already under way; if the stop fails,
|
|
75
|
+
* sendError says so.
|
|
76
|
+
*/
|
|
33
77
|
stopTurn: () => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* The model and reasoning effort the next reply will use, as chosen for
|
|
80
|
+
* this conversation. Null means the assistant's configured model and
|
|
81
|
+
* effort.
|
|
82
|
+
*/
|
|
34
83
|
modelPick: ComposerModelPick | null;
|
|
84
|
+
/**
|
|
85
|
+
* Chooses the model and effort for this conversation's replies. It goes out
|
|
86
|
+
* with the next message and is then saved on the conversation; starting a
|
|
87
|
+
* new conversation resets it.
|
|
88
|
+
*/
|
|
35
89
|
setModelPick: (pick: ComposerModelPick) => void;
|
|
90
|
+
/**
|
|
91
|
+
* The unsaved draft and staged attachments, as a separate observable so
|
|
92
|
+
* typing doesn't re-render everything else; read it with useCell. It
|
|
93
|
+
* survives reconnects and remounts, and is cleared when the visitor
|
|
94
|
+
* switches to or starts another conversation.
|
|
95
|
+
*/
|
|
36
96
|
composerInput: ReadonlyCell<ComposerInput>;
|
|
97
|
+
/**
|
|
98
|
+
* Replaces the draft text, with a value or an updater function like React's
|
|
99
|
+
* setState.
|
|
100
|
+
*/
|
|
37
101
|
setDraft: (next: string | ((current: string) => string)) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Replaces the staged attachments, with a value or an updater function like
|
|
104
|
+
* React's setState.
|
|
105
|
+
*/
|
|
38
106
|
setAttachments: (next: readonly AttachmentDraft[] | ((current: readonly AttachmentDraft[]) => readonly AttachmentDraft[])) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Uploads files and stages them on the draft: each appears in
|
|
109
|
+
* composerInput's attachments as uploading, then ready (carrying the id to
|
|
110
|
+
* pass to sendMessage) or failed with a sentence for the visitor. A file
|
|
111
|
+
* over its kind's size limit or past the per-message count never shows as
|
|
112
|
+
* uploading and appears as failed from the start, and if the assistant is
|
|
113
|
+
* configured without attachments, or its configuration could not be loaded,
|
|
114
|
+
* every file in the call fails that way. Resolves once every file has
|
|
115
|
+
* settled. A pick may wait for the assistant's configuration to load, and
|
|
116
|
+
* if the visitor switches or starts another conversation during that wait
|
|
117
|
+
* the pick is dropped rather than staged on the new one.
|
|
118
|
+
*/
|
|
119
|
+
addFiles: (files: Iterable<File>) => Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Tells the assistant which of your inputs has keyboard focus (a name you
|
|
122
|
+
* choose for that surface), or null on blur. Used to put the caret back
|
|
123
|
+
* after an automatic reconnect remounts the input.
|
|
124
|
+
*/
|
|
39
125
|
noteComposerFocus: (owner: string | null) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Call when your input mounts, with the same surface name; returns true
|
|
128
|
+
* (once) if that input had focus when a reconnect remounted it, meaning you
|
|
129
|
+
* should focus it again.
|
|
130
|
+
*/
|
|
40
131
|
takeComposerCaretReturn: (surface: string) => boolean;
|
|
41
132
|
}
|
|
133
|
+
/** The composer's unsaved input, as read from composerInput. */
|
|
42
134
|
export interface ComposerInput {
|
|
135
|
+
/**
|
|
136
|
+
* An opaque token naming the conversation this input belongs to; it changes
|
|
137
|
+
* whenever the visitor switches or starts a conversation. Compare it before
|
|
138
|
+
* and after an awaited send so you only restore a refused draft into the
|
|
139
|
+
* conversation it was typed in.
|
|
140
|
+
*/
|
|
43
141
|
scope: string;
|
|
142
|
+
/** The text typed but not yet sent. */
|
|
44
143
|
draft: string;
|
|
144
|
+
/** Files staged for the next message, in the order they were added. */
|
|
45
145
|
attachments: readonly AttachmentDraft[];
|
|
46
146
|
}
|
|
147
|
+
/** A model and reasoning-effort choice for the conversation's replies. */
|
|
47
148
|
export interface ComposerModelPick {
|
|
149
|
+
/**
|
|
150
|
+
* Id of one of the models the assistant offers, or null to keep the
|
|
151
|
+
* assistant's configured model.
|
|
152
|
+
*/
|
|
48
153
|
modelId: string | null;
|
|
154
|
+
/**
|
|
155
|
+
* How much reasoning the model spends per reply (low, medium, high, xhigh
|
|
156
|
+
* or max), or null for the assistant's configured setting.
|
|
157
|
+
*/
|
|
49
158
|
effort: ServedThinkingEffort | null;
|
|
50
159
|
}
|
|
51
160
|
export type { AttachmentDraft } from "./composer-policy.js";
|
|
@@ -74,6 +183,8 @@ export interface ConversationStoreDeps {
|
|
|
74
183
|
onTelemetry: (event: AssistantTelemetryEvent) => void;
|
|
75
184
|
onGateRefusal: (error: ServingApiError) => void;
|
|
76
185
|
onTurnSettled: () => void;
|
|
186
|
+
attachmentPolicy: ReadonlyCell<ServedAttachmentPolicy | null>;
|
|
187
|
+
ensureAttachmentPolicy: () => Promise<ServedAttachmentPolicy | null>;
|
|
77
188
|
}
|
|
78
189
|
export interface ConnectionSnapshot {
|
|
79
190
|
epochId: number;
|
|
@@ -76,6 +76,7 @@ export function composerSnapshotOf(store) {
|
|
|
76
76
|
composerInput: store._composerInput,
|
|
77
77
|
setDraft: store.setComposerDraft,
|
|
78
78
|
setAttachments: store.setComposerAttachments,
|
|
79
|
+
addFiles: store.addComposerFiles,
|
|
79
80
|
noteComposerFocus: store.noteComposerFocus,
|
|
80
81
|
takeComposerCaretReturn: store.takeComposerCaretReturn,
|
|
81
82
|
};
|
|
@@ -61,6 +61,7 @@ export declare class AssistantConversationStore {
|
|
|
61
61
|
_modelPickDirty: boolean;
|
|
62
62
|
readonly _composerInput: ObservableCell<ComposerInput>;
|
|
63
63
|
_nextUnboundScope: number;
|
|
64
|
+
_composerInputResets: number;
|
|
64
65
|
_composerFocusOwned: string | null;
|
|
65
66
|
_composerCaretReturnPending: string | null;
|
|
66
67
|
_tier: VisitorTier | null;
|
|
@@ -78,6 +79,7 @@ export declare class AssistantConversationStore {
|
|
|
78
79
|
_deliveryProbeRearm: boolean;
|
|
79
80
|
_idleRecheckTimer: ReturnType<typeof setInterval> | null;
|
|
80
81
|
_idleRecheckInFlight: boolean;
|
|
82
|
+
_disarmDispatchPoll: (() => void) | null;
|
|
81
83
|
_disposed: boolean;
|
|
82
84
|
_epoch: ConnectionEpoch | null;
|
|
83
85
|
_epochResume: StreamResumeStore | null;
|
|
@@ -102,6 +104,7 @@ export declare class AssistantConversationStore {
|
|
|
102
104
|
noteComposerFocus: (owner: string | null) => void;
|
|
103
105
|
takeComposerCaretReturn: (surface: string) => boolean;
|
|
104
106
|
uploadAttachment: (file: File) => Promise<ServingAttachment>;
|
|
107
|
+
addComposerFiles: (files: Iterable<File>) => Promise<void>;
|
|
105
108
|
mintAttachmentDownloadUrl: (attachmentId: string) => Promise<MintedDownloadUrl>;
|
|
106
109
|
acquireTranscriptLease: (surface: string) => (() => void);
|
|
107
110
|
submitApprovalDecision: (card: ApprovalCardModel, decision: ApprovalDecisionInput) => Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDLE_ACTIVITY, } from "./activity.js";
|
|
2
2
|
import { noteDispatchSettledFromStore, refreshConversationFromStore, } from "./conversation-refresh.js";
|
|
3
3
|
import { mintAttachmentDownloadUrlFromStore, uploadAttachmentFromStore, } from "./attachment-uploads.js";
|
|
4
|
+
import { addComposerFilesFromStore } from "./composer-attachments.js";
|
|
4
5
|
import { handleUserMessageInjectedFromStore, markComposerRefocusHandledFromStore, sendMessageFromStore, stopTurnFromStore, } from "./conversation-send.js";
|
|
5
6
|
import { noteComposerFocusFromStore, setComposerAttachmentsFromStore, setComposerDraftFromStore, setModelPickFromStore, takeComposerCaretReturnFromStore, } from "./composer-input-state.js";
|
|
6
7
|
import { submitApprovalDecisionFromStore } from "./approval-decision.js";
|
|
@@ -12,6 +13,7 @@ import { SettleRefreshScheduler } from "./settle-refresh.js";
|
|
|
12
13
|
import { handleStreamClosedQuietlyFromStore, handleStreamErrorFromStore, handleWorkflowRestartedFromStore, retryStreamFromStore, } from "./stream-trouble.js";
|
|
13
14
|
import { acquireTranscriptLeaseFromStore } from "./transcript-lease.js";
|
|
14
15
|
import { clearIdleRecheck, syncIdleRecheck } from "./idle-recheck.js";
|
|
16
|
+
import { armDispatchPoll, disarmDispatchPoll } from "./dispatch-poll.js";
|
|
15
17
|
import { ConsumedInterruptFold } from "./consumed-interrupts.js";
|
|
16
18
|
import { composerSnapshotOf, conversationSnapshotOf, publishStore, } from "./conversation-publish.js";
|
|
17
19
|
import { retireEpoch } from "./epoch-sync.js";
|
|
@@ -82,6 +84,7 @@ export class AssistantConversationStore {
|
|
|
82
84
|
attachments: [],
|
|
83
85
|
});
|
|
84
86
|
_nextUnboundScope = 1;
|
|
87
|
+
_composerInputResets = 0;
|
|
85
88
|
_composerFocusOwned = null;
|
|
86
89
|
_composerCaretReturnPending = null;
|
|
87
90
|
_tier = null;
|
|
@@ -103,6 +106,7 @@ export class AssistantConversationStore {
|
|
|
103
106
|
_deliveryProbeRearm = false;
|
|
104
107
|
_idleRecheckTimer = null;
|
|
105
108
|
_idleRecheckInFlight = false;
|
|
109
|
+
_disarmDispatchPoll = null;
|
|
106
110
|
_disposed = false;
|
|
107
111
|
_epoch = null;
|
|
108
112
|
_epochResume = null;
|
|
@@ -157,6 +161,7 @@ export class AssistantConversationStore {
|
|
|
157
161
|
this.resumeStoredThread();
|
|
158
162
|
loadHistoryOnceExpected(this);
|
|
159
163
|
syncIdleRecheck(this);
|
|
164
|
+
armDispatchPoll(this);
|
|
160
165
|
}
|
|
161
166
|
setTier(tier) {
|
|
162
167
|
if (this._tier === tier) {
|
|
@@ -172,6 +177,7 @@ export class AssistantConversationStore {
|
|
|
172
177
|
this._settleScheduler.dispose();
|
|
173
178
|
this._gapGate.dispose();
|
|
174
179
|
clearIdleRecheck(this);
|
|
180
|
+
disarmDispatchPoll(this);
|
|
175
181
|
retireEpoch(this);
|
|
176
182
|
}
|
|
177
183
|
resumeStoredThread = () => {
|
|
@@ -196,6 +202,7 @@ export class AssistantConversationStore {
|
|
|
196
202
|
};
|
|
197
203
|
takeComposerCaretReturn = (surface) => takeComposerCaretReturnFromStore(this, surface);
|
|
198
204
|
uploadAttachment = async (file) => uploadAttachmentFromStore(this, file);
|
|
205
|
+
addComposerFiles = async (files) => addComposerFilesFromStore(this, files);
|
|
199
206
|
mintAttachmentDownloadUrl = async (attachmentId) => mintAttachmentDownloadUrlFromStore(this, attachmentId);
|
|
200
207
|
acquireTranscriptLease = (surface) => acquireTranscriptLeaseFromStore(this, surface);
|
|
201
208
|
submitApprovalDecision = async (card, decision) => submitApprovalDecisionFromStore(this, card, decision);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { demandInputOfMessages, dispatchDemandOf, dispatchJoinKeyOf, RESUME_SUBAGENT_TOOL_NAME, staleDeliveredOrdinalsKeyOf, } from "./subagent-ledger-join.js";
|
|
2
|
+
import { DISPATCH_SUBAGENT_TOOL_NAME } from "./subagent-rows.js";
|
|
3
|
+
import { EMPTY_THREAD_DISPATCHES, threadDispatchLedgerFor, } from "./thread-dispatch-ledger.js";
|
|
4
|
+
export function armDispatchPoll(store) {
|
|
5
|
+
if (store._disarmDispatchPoll !== null) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const ledger = threadDispatchLedgerFor(store.deps.session);
|
|
9
|
+
ledger.setSettleListener(store, store.noteDispatchSettled);
|
|
10
|
+
ledger.setPauseListener(store, store.noteDispatchPaused);
|
|
11
|
+
let queued = false;
|
|
12
|
+
let lastTapKey = "";
|
|
13
|
+
const judge = () => {
|
|
14
|
+
queued = false;
|
|
15
|
+
if (store._disposed || store._disarmDispatchPoll === null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
lastTapKey = _judgeDemand(store, ledger, lastTapKey);
|
|
19
|
+
};
|
|
20
|
+
const schedule = () => {
|
|
21
|
+
if (queued) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
queued = true;
|
|
25
|
+
queueMicrotask(judge);
|
|
26
|
+
};
|
|
27
|
+
const unsubscribes = [
|
|
28
|
+
store.messages.subscribe(schedule),
|
|
29
|
+
store.markerAnchors.subscribe(schedule),
|
|
30
|
+
store.connection.subscribe(schedule),
|
|
31
|
+
ledger.cell.subscribe(schedule),
|
|
32
|
+
];
|
|
33
|
+
store._disarmDispatchPoll = () => {
|
|
34
|
+
for (const unsubscribe of unsubscribes) {
|
|
35
|
+
unsubscribe();
|
|
36
|
+
}
|
|
37
|
+
ledger.setDemand(store, null);
|
|
38
|
+
ledger.setSettleListener(store, null);
|
|
39
|
+
ledger.setPauseListener(store, null);
|
|
40
|
+
};
|
|
41
|
+
schedule();
|
|
42
|
+
}
|
|
43
|
+
export function disarmDispatchPoll(store) {
|
|
44
|
+
const disarm = store._disarmDispatchPoll;
|
|
45
|
+
if (disarm === null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
store._disarmDispatchPoll = null;
|
|
49
|
+
disarm();
|
|
50
|
+
}
|
|
51
|
+
export function noteThreadRead(store, threadId) {
|
|
52
|
+
threadDispatchLedgerFor(store.deps.session).noteThreadAnswered(threadId);
|
|
53
|
+
}
|
|
54
|
+
function _judgeDemand(store, ledger, lastTapKey) {
|
|
55
|
+
const threadId = store.connection.get()?.threadId ?? null;
|
|
56
|
+
const messages = store.messages.get();
|
|
57
|
+
if (threadId === null || !_delegates(messages)) {
|
|
58
|
+
ledger.setDemand(store, null);
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
const input = demandInputOfMessages(messages, store.markerAnchors.get());
|
|
62
|
+
const read = ledger.cell.get();
|
|
63
|
+
const map = read !== null && read.threadId === threadId
|
|
64
|
+
? read.map
|
|
65
|
+
: EMPTY_THREAD_DISPATCHES;
|
|
66
|
+
ledger.setDemand(store, {
|
|
67
|
+
threadId,
|
|
68
|
+
...dispatchDemandOf(input, map),
|
|
69
|
+
joinKey: dispatchJoinKeyOf(input),
|
|
70
|
+
});
|
|
71
|
+
const tapKey = staleDeliveredOrdinalsKeyOf(input, map);
|
|
72
|
+
if (tapKey !== "" && tapKey !== lastTapKey) {
|
|
73
|
+
void ledger.refresh(threadId);
|
|
74
|
+
}
|
|
75
|
+
return tapKey;
|
|
76
|
+
}
|
|
77
|
+
function _delegates(messages) {
|
|
78
|
+
return messages.some((message) => message.role === "assistant" &&
|
|
79
|
+
(message.toolCalls ?? []).some((call) => call.function.name === DISPATCH_SUBAGENT_TOOL_NAME ||
|
|
80
|
+
call.function.name === RESUME_SUBAGENT_TOOL_NAME));
|
|
81
|
+
}
|
|
@@ -14,6 +14,7 @@ async function _deliverQuestionSetReport(store, card, result, answered) {
|
|
|
14
14
|
const epoch = store._epoch;
|
|
15
15
|
const active = store._active;
|
|
16
16
|
if (epoch === null || active === null) {
|
|
17
|
+
_stampAnswerNotSent(store, card);
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
const inbox = epoch.executionInbox;
|
|
@@ -57,6 +58,17 @@ async function _deliverQuestionSetReport(store, card, result, answered) {
|
|
|
57
58
|
publishIfCurrent();
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
function _stampAnswerNotSent(store, card) {
|
|
62
|
+
store._elicitationErrors.set(card.interruptId, ANSWER_NOT_SENT_SENTENCE);
|
|
63
|
+
const cards = store._elicitationsCell.get();
|
|
64
|
+
const next = cards.map((item) => item.interruptId === card.interruptId &&
|
|
65
|
+
item.errorSentence !== ANSWER_NOT_SENT_SENTENCE
|
|
66
|
+
? { ...item, errorSentence: ANSWER_NOT_SENT_SENTENCE }
|
|
67
|
+
: item);
|
|
68
|
+
if (next.some((item, index) => item !== cards[index])) {
|
|
69
|
+
store._elicitationsCell.set(next);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
60
72
|
function _turnNoLongerAwaitingToolResults(error) {
|
|
61
73
|
return (error instanceof ServingApiError &&
|
|
62
74
|
error.code === "ASSISTANT_TURN_NOT_AWAITING_TOOL_RESULTS");
|
|
@@ -10,8 +10,18 @@ interface ElicitationCardBase {
|
|
|
10
10
|
status: ElicitationCardStatus;
|
|
11
11
|
errorSentence: string | null;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A set of up to five questions the agent asked the visitor, answered together
|
|
15
|
+
* in one submission or dismissed together.
|
|
16
|
+
*/
|
|
13
17
|
export interface QuestionSetCardModel extends ElicitationCardBase {
|
|
18
|
+
/** The questions, in the order the visitor should see them. */
|
|
14
19
|
questions: readonly QuestionModel[];
|
|
20
|
+
/**
|
|
21
|
+
* What this page submitted, either the answers or a cancellation. Null
|
|
22
|
+
* before it submits, and for sets answered elsewhere or earlier in the
|
|
23
|
+
* conversation, where the transcript's tool row shows the outcome.
|
|
24
|
+
*/
|
|
15
25
|
answered: AnsweredQuestions | null;
|
|
16
26
|
}
|
|
17
27
|
export type AnsweredQuestions = {
|
|
@@ -23,6 +33,10 @@ export type AnsweredQuestions = {
|
|
|
23
33
|
} | {
|
|
24
34
|
kind: "cancelled";
|
|
25
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* A request from the agent for the visitor to answer questions; currently
|
|
38
|
+
* always a question set.
|
|
39
|
+
*/
|
|
26
40
|
export type ElicitationCardModel = QuestionSetCardModel;
|
|
27
41
|
export declare function elicitationCardsOf(entries: readonly ExecutionEntryModel[], errorSentences: ReadonlyMap<string, string>, questionAnswers?: ReadonlyMap<string, AnsweredQuestions>): ElicitationCardModel[];
|
|
28
42
|
export declare function sameElicitationCards(a: readonly ElicitationCardModel[], b: readonly ElicitationCardModel[]): boolean;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
/** One suggested answer to a question. */
|
|
1
2
|
export interface QuestionOptionModel {
|
|
3
|
+
/**
|
|
4
|
+
* The suggestion as the visitor reads it; if they pick it, submit this
|
|
5
|
+
* exact text as their answer.
|
|
6
|
+
*/
|
|
2
7
|
text: string;
|
|
8
|
+
/** A one-line explanation of the suggestion, or null when there is none. */
|
|
3
9
|
description: string | null;
|
|
4
10
|
}
|
|
11
|
+
/** One question in a question set. */
|
|
5
12
|
export interface QuestionModel {
|
|
13
|
+
/**
|
|
14
|
+
* The question's id, unique within its set; use it as the id of its answer.
|
|
15
|
+
*/
|
|
6
16
|
id: string;
|
|
17
|
+
/** A short label for the question, a few words long. */
|
|
7
18
|
heading: string;
|
|
19
|
+
/** The question, exactly as the visitor should read it. */
|
|
8
20
|
prompt: string;
|
|
21
|
+
/**
|
|
22
|
+
* Suggested answers, up to eight; empty for an open question. Always let
|
|
23
|
+
* the visitor write their own answer as well.
|
|
24
|
+
*/
|
|
9
25
|
options: readonly QuestionOptionModel[];
|
|
10
26
|
}
|
|
11
27
|
export declare function askQuestionsActionOf(action: Record<string, unknown> | null): {
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { AgentSubscriber } from "@ag-ui/client";
|
|
2
|
+
/**
|
|
3
|
+
* A notice that the assistant saved a memory. It never contains the memory's
|
|
4
|
+
* content.
|
|
5
|
+
*/
|
|
2
6
|
export interface MemoryUpdated {
|
|
7
|
+
/**
|
|
8
|
+
* The saved memory's id; a repeated report of the same save carries the
|
|
9
|
+
* same id, so use it to de-duplicate.
|
|
10
|
+
*/
|
|
3
11
|
memoryId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Who the memory is for: "org" is shared across all your users, "user" is
|
|
14
|
+
* private to the current user. Show any other value generically.
|
|
15
|
+
*/
|
|
4
16
|
scope: string;
|
|
17
|
+
/**
|
|
18
|
+
* A short sentence for the user saying a memory was saved, not the memory
|
|
19
|
+
* itself.
|
|
20
|
+
*/
|
|
5
21
|
summary: string;
|
|
6
22
|
}
|
|
7
23
|
export declare const EMPTY_MEMORY_PROVENANCE_ANCHORS: ReadonlyMap<string, MemoryUpdated>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An observable value from the assistant, readable without React (use useCell
|
|
3
|
+
* inside React).
|
|
4
|
+
*/
|
|
1
5
|
export interface ReadonlyCell<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the current value. The returned object only changes identity when
|
|
8
|
+
* the value changes, so you can compare by reference.
|
|
9
|
+
*/
|
|
2
10
|
get: () => T;
|
|
11
|
+
/**
|
|
12
|
+
* Calls the listener after every change and returns a function that
|
|
13
|
+
* unsubscribes it.
|
|
14
|
+
*/
|
|
3
15
|
subscribe: (listener: () => void) => () => void;
|
|
4
16
|
}
|
|
5
17
|
export declare class ObservableCell<T> implements ReadonlyCell<T> {
|
|
@@ -9,8 +9,17 @@ export interface GapJudgeableTurn {
|
|
|
9
9
|
interface InterruptHolder {
|
|
10
10
|
interruptId: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The agent is waiting on requests that nothing on this page can show or
|
|
14
|
+
* answer, which usually means the conversation needs reloading.
|
|
15
|
+
*/
|
|
12
16
|
export interface PendingDecisionGap {
|
|
17
|
+
/** The id of the waiting turn. */
|
|
13
18
|
turnId: string;
|
|
19
|
+
/**
|
|
20
|
+
* The ids of the waiting requests (approvals, questions or page actions)
|
|
21
|
+
* that have nothing on this page to answer them.
|
|
22
|
+
*/
|
|
14
23
|
missingInterruptIds: readonly string[];
|
|
15
24
|
}
|
|
16
25
|
export declare function pendingDecisionGapOf(turn: GapJudgeableTurn | null, approvalCards: readonly InterruptHolder[], elicitationCards: readonly InterruptHolder[], executionEntries: readonly InterruptHolder[], consumedInterruptIds?: ReadonlySet<string>): PendingDecisionGap | null;
|
|
@@ -4,29 +4,88 @@ type ActiveChoice = {
|
|
|
4
4
|
} | {
|
|
5
5
|
kind: "custom";
|
|
6
6
|
} | null;
|
|
7
|
+
/** The visitor's unsent answer to one question. */
|
|
7
8
|
export interface QuestionAnswerDraft {
|
|
9
|
+
/**
|
|
10
|
+
* The selected answer, either { kind: "option", text } for a suggestion, {
|
|
11
|
+
* kind: "custom" } for the visitor's own text, or null when nothing is
|
|
12
|
+
* selected yet.
|
|
13
|
+
*/
|
|
8
14
|
active: ActiveChoice;
|
|
15
|
+
/**
|
|
16
|
+
* The visitor's own typed answer. Kept when they select a suggestion
|
|
17
|
+
* instead, so they can switch back.
|
|
18
|
+
*/
|
|
9
19
|
customText: string;
|
|
10
20
|
}
|
|
21
|
+
/** The visitor's unsent answers to one question set. */
|
|
11
22
|
export interface QuestionSetDraft {
|
|
23
|
+
/** Index of the question the visitor is on, starting at 0. */
|
|
12
24
|
cursor: number;
|
|
25
|
+
/**
|
|
26
|
+
* Unsent answers keyed by question id; questions the visitor hasn't touched
|
|
27
|
+
* are absent.
|
|
28
|
+
*/
|
|
13
29
|
answers: ReadonlyMap<string, QuestionAnswerDraft>;
|
|
14
30
|
}
|
|
15
31
|
export interface QuestionLike {
|
|
16
32
|
id: string;
|
|
17
33
|
}
|
|
18
34
|
export declare const MAX_ANSWER_TEXT_CHARS = 1900;
|
|
35
|
+
/**
|
|
36
|
+
* Holds the visitor's unsent answers to question sets, keyed by the card's
|
|
37
|
+
* interruptId then the question's id. Subscribe to it (for example with React's
|
|
38
|
+
* useSyncExternalStore and get) to re-render as answers change.
|
|
39
|
+
*/
|
|
19
40
|
export declare class QuestionDraftStore {
|
|
20
41
|
private readonly drafts;
|
|
21
42
|
private readonly listeners;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the unsent answers for one question set, or an empty draft
|
|
45
|
+
* (cursor 0, no answers) if nothing has been entered. The same object is
|
|
46
|
+
* returned until that draft changes.
|
|
47
|
+
*/
|
|
22
48
|
get: (interruptId: string) => QuestionSetDraft;
|
|
49
|
+
/**
|
|
50
|
+
* Calls the listener after any draft changes and returns a function that
|
|
51
|
+
* unsubscribes it.
|
|
52
|
+
*/
|
|
23
53
|
subscribe: (listener: () => void) => (() => void);
|
|
54
|
+
/**
|
|
55
|
+
* True when the visitor has selected or typed anything for this question
|
|
56
|
+
* set; use it to confirm before discarding on cancel.
|
|
57
|
+
*/
|
|
24
58
|
hasContent(interruptId: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Selects the suggestion with this text as the answer to one question,
|
|
61
|
+
* keeping any text the visitor typed.
|
|
62
|
+
*/
|
|
25
63
|
selectOption(interruptId: string, questionId: string, text: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Selects the visitor's own typed answer for one question, without changing
|
|
66
|
+
* its text.
|
|
67
|
+
*/
|
|
26
68
|
selectCustom(interruptId: string, questionId: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Sets the visitor's own answer to one question and selects it. Control
|
|
71
|
+
* characters are removed, except that vertical tabs and form feeds become
|
|
72
|
+
* line breaks.
|
|
73
|
+
*/
|
|
27
74
|
setCustomText(interruptId: string, questionId: string, text: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Records which question the visitor is on (an index into the set's
|
|
77
|
+
* questions), so returning to the set shows the same question.
|
|
78
|
+
*/
|
|
28
79
|
setCursor(interruptId: string, cursor: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* Discards the unsent answers for one question set. Answers are already
|
|
82
|
+
* cleared after a successful submit or cancel.
|
|
83
|
+
*/
|
|
29
84
|
clear(interruptId: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Discards the unsent answers for every question set. Already done when the
|
|
87
|
+
* visitor switches or starts a conversation.
|
|
88
|
+
*/
|
|
30
89
|
clearAll(): void;
|
|
31
90
|
private updateAnswer;
|
|
32
91
|
private notify;
|