@teaflask/assistant 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/custom-elements.json +264 -0
- package/dist/affordances/aria-dropdowns.js +315 -0
- package/dist/affordances/aria-toggles.js +39 -0
- package/dist/affordances/dropdown-display.js +129 -0
- package/dist/affordances/page-gestures.js +91 -0
- package/dist/affordances/prefill-reasons.js +75 -0
- package/dist/affordances/prefill.js +113 -62
- 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/execution-handlers.js +3 -3
- 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/reader/render.js +7 -4
- package/dist/reader/roles.js +28 -1
- package/dist/reader/snapshot-node.js +2 -29
- package/dist/reader/snapshot-root.js +14 -8
- package/dist/reader/snapshot.js +6 -1
- 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
|
@@ -1,7 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why clicking approve or deny sent nothing. "no_active_thread" means no
|
|
3
|
+
* conversation was open; "card_missing" means the request was no longer shown;
|
|
4
|
+
* "already_submitting" is a repeat click while the first answer is sending;
|
|
5
|
+
* "not_actionable_answered" and "not_actionable_stale" mean the request had
|
|
6
|
+
* already been answered or was no longer open; "no_turn_id" means no turn could
|
|
7
|
+
* be found to answer.
|
|
8
|
+
*/
|
|
1
9
|
export type ApprovalSubmitDropReason = "no_active_thread" | "card_missing" | "already_submitting" | "not_actionable_answered" | "not_actionable_stale" | "no_turn_id";
|
|
2
10
|
type ApprovalCardStatusKind = "actionable" | "submitting" | "answered" | "stale";
|
|
11
|
+
/**
|
|
12
|
+
* Reported to onTelemetry as the user answers an approval, so you can spot
|
|
13
|
+
* answers that never reached the server.
|
|
14
|
+
*/
|
|
3
15
|
export interface ApprovalSubmitTelemetryEvent {
|
|
16
|
+
/**
|
|
17
|
+
* "approval_submit_attempted" when the user clicks approve or deny,
|
|
18
|
+
* "approval_submit_sent" when the answer is posted, and
|
|
19
|
+
* "approval_submit_dropped" when nothing was posted (see drop_reason).
|
|
20
|
+
*/
|
|
4
21
|
name: "approval_submit_attempted" | "approval_submit_sent" | "approval_submit_dropped";
|
|
22
|
+
/**
|
|
23
|
+
* The request's interrupt_id, the conversation's thread_id, whether it was
|
|
24
|
+
* approved and trusted, the request's on-screen status (actionable,
|
|
25
|
+
* submitting, answered or stale), whether its turn had parked, and the
|
|
26
|
+
* drop_reason for a dropped answer.
|
|
27
|
+
*/
|
|
5
28
|
properties: {
|
|
6
29
|
interrupt_id: string;
|
|
7
30
|
thread_id: string | null;
|
|
@@ -12,9 +35,27 @@ export interface ApprovalSubmitTelemetryEvent {
|
|
|
12
35
|
drop_reason?: ApprovalSubmitDropReason;
|
|
13
36
|
};
|
|
14
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Where a stream connection failed. "network_rejected" means no response
|
|
40
|
+
* arrived (offline, DNS, CORS); "http_error" is a non-2xx response; "no_body"
|
|
41
|
+
* is a 2xx with no readable body; "mid_stream" means the connection dropped
|
|
42
|
+
* after events had arrived; "parse_or_validation" means an event could not be
|
|
43
|
+
* read; "client_abort" is a cancellation by the widget and is not reported.
|
|
44
|
+
*/
|
|
15
45
|
export type StreamFailureClass = "network_rejected" | "http_error" | "no_body" | "mid_stream" | "parse_or_validation" | "client_abort";
|
|
46
|
+
/**
|
|
47
|
+
* Reported to onTelemetry when the conversation's live stream connection fails.
|
|
48
|
+
* Cancellations made by the widget itself are not reported.
|
|
49
|
+
*/
|
|
16
50
|
export interface StreamFailedTelemetryEvent {
|
|
51
|
+
/** Always "assistant_stream_failed". */
|
|
17
52
|
name: "assistant_stream_failed";
|
|
53
|
+
/**
|
|
54
|
+
* Where the connection failed (failure_class), the HTTP status or null when
|
|
55
|
+
* no response arrived, the conversation's thread_id, and two stream
|
|
56
|
+
* positions, resume_cursor and last_committed_sse_id, that locate the
|
|
57
|
+
* failure in the conversation's event stream.
|
|
58
|
+
*/
|
|
18
59
|
properties: {
|
|
19
60
|
failure_class: StreamFailureClass;
|
|
20
61
|
status: number | null;
|
|
@@ -23,6 +64,10 @@ export interface StreamFailedTelemetryEvent {
|
|
|
23
64
|
last_committed_sse_id: string | null;
|
|
24
65
|
};
|
|
25
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Any event passed to the provider's onTelemetry callback, for forwarding to
|
|
69
|
+
* your own analytics. None carry message text, tool arguments or prompts.
|
|
70
|
+
*/
|
|
26
71
|
export type AssistantTelemetryEvent = ApprovalSubmitTelemetryEvent | StreamFailedTelemetryEvent;
|
|
27
72
|
export declare function streamFailureClassOf(error: Error, context: {
|
|
28
73
|
sawBodyBytes: boolean;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export type { CreateServingAttachmentUploadResponse as AttachmentUploadIntent, HighlightResult, NavigateResult, PrefillFormResult, ReadPageResult, ResolveServingTurnApprovalRequest as ResolveTurnApprovalRequest, ResolveServingTurnApprovalResponse as ResolveTurnApprovalResponse, ResolveServingTurnToolResultsRequest as ResolveTurnToolResultsRequest, ResolveServingTurnToolResultsResponse as ResolveTurnToolResultsResponse, SendServingAssistantMessageRequest as SendAssistantMessageRequest, SendServingAssistantMessageResponse as SendAssistantMessageResponse,
|
|
1
|
+
export type { CreateServingAttachmentUploadResponse as AttachmentUploadIntent, HighlightResult, NavigateResult, PrefillFormResult, ReadPageResult, ResolveServingTurnApprovalRequest as ResolveTurnApprovalRequest, ResolveServingTurnApprovalResponse as ResolveTurnApprovalResponse, ResolveServingTurnToolResultsRequest as ResolveTurnToolResultsRequest, ResolveServingTurnToolResultsResponse as ResolveTurnToolResultsResponse, SendServingAssistantMessageRequest as SendAssistantMessageRequest, SendServingAssistantMessageResponse as SendAssistantMessageResponse, ServingAssistantThreadDetailResponse as AssistantThreadDetailResponse, ServingAssistantThreadResponse as ServingAssistantThread, ServingAssistantTurnResponse as ServingAssistantTurn, ServingAttachmentResponse as ServingAttachment, ServingTurnAttachmentResponse as TurnAttachment, StopServingTurnResponse as StopTurnResponse, ThreadModelPickResponse as ThreadModelPick, AssistantTurnStatus as TurnStatus, } from "../generated/models/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The longest message a user can send, in characters; the composer stops input
|
|
4
|
+
* at this length and the server rejects longer messages.
|
|
5
|
+
*/
|
|
2
6
|
export declare const ASSISTANT_MESSAGE_MAX_CHARS = 4000;
|
|
3
7
|
export declare const ASSISTANT_MAX_ATTACHMENTS = 10;
|
package/dist/core/activity.d.ts
CHANGED
|
@@ -1,17 +1,61 @@
|
|
|
1
1
|
import type { ServingAssistantTurn, TurnStatus } from "../contract/threads.js";
|
|
2
2
|
import type { ApprovalCardModel } from "./approval-inbox.js";
|
|
3
3
|
import type { PendingDecisionGap } from "./pending-decision-gap.js";
|
|
4
|
+
/** How the most recent finished turn of the conversation ended. */
|
|
4
5
|
export interface AssistantActivityResult {
|
|
6
|
+
/**
|
|
7
|
+
* The id of that turn, which tells apart two identical outcomes in a row.
|
|
8
|
+
*/
|
|
5
9
|
turnId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The final status. It is one of `succeeded`, `failed`, `stopped` (the user
|
|
12
|
+
* pressed Stop) or `superseded` (the user sent a new message instead of
|
|
13
|
+
* answering what the turn was waiting on).
|
|
14
|
+
*/
|
|
6
15
|
status: TurnStatus;
|
|
16
|
+
/**
|
|
17
|
+
* The error message recorded for a failed turn. Null when the turn did not
|
|
18
|
+
* fail or no message was recorded.
|
|
19
|
+
*/
|
|
7
20
|
failureSentence: string | null;
|
|
8
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* What the assistant is doing right now, for the open conversation. When no
|
|
24
|
+
* conversation is open, every field holds its idle value (false, 0 or null).
|
|
25
|
+
*/
|
|
9
26
|
export interface AssistantActivitySnapshot {
|
|
27
|
+
/**
|
|
28
|
+
* True while a message is being sent or the agent is working on a reply.
|
|
29
|
+
*/
|
|
10
30
|
busy: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The status of the latest turn (one message and the agent's work on it),
|
|
33
|
+
* or null when there is none. `queued` and `working` mean in progress.
|
|
34
|
+
* `awaiting_input` means it is waiting on the user. `parked` means an
|
|
35
|
+
* approval went unanswered long enough for the run to pause, and answering
|
|
36
|
+
* still resumes it. The other values mean it has finished.
|
|
37
|
+
*/
|
|
11
38
|
newestTurnStatus: TurnStatus | null;
|
|
39
|
+
/**
|
|
40
|
+
* The id of the latest turn, or null. Use it to dismiss a notification for
|
|
41
|
+
* one turn without hiding later ones.
|
|
42
|
+
*/
|
|
12
43
|
newestTurnId: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* How many approvals are waiting for the user to approve or deny, including
|
|
46
|
+
* ones being submitted.
|
|
47
|
+
*/
|
|
13
48
|
pendingApprovalCount: number;
|
|
49
|
+
/**
|
|
50
|
+
* Set when the agent is waiting on the user for something this page has no
|
|
51
|
+
* prompt for, so nothing on screen lets them respond. Null otherwise. The
|
|
52
|
+
* built-in UI then shows an alert with a reload button.
|
|
53
|
+
*/
|
|
14
54
|
pendingDecisionGap: PendingDecisionGap | null;
|
|
55
|
+
/**
|
|
56
|
+
* How the most recent finished turn ended. It stays until another turn
|
|
57
|
+
* finishes, and is null until one has or when you switch conversations.
|
|
58
|
+
*/
|
|
15
59
|
lastResult: AssistantActivityResult | null;
|
|
16
60
|
}
|
|
17
61
|
export declare const IDLE_ACTIVITY: AssistantActivitySnapshot;
|
|
@@ -22,27 +22,96 @@ export type ApprovalAsker = {
|
|
|
22
22
|
ordinal: number;
|
|
23
23
|
label: string;
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* One request for the visitor to approve or deny a tool or action call before
|
|
27
|
+
* it runs.
|
|
28
|
+
*/
|
|
25
29
|
export interface ApprovalCardModel {
|
|
30
|
+
/** Unique id of this request; use it as the React key. */
|
|
26
31
|
interruptId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Name of the tool waiting for approval (an action's is action__<slug>), or
|
|
34
|
+
* null when the request is not tied to a tool call.
|
|
35
|
+
*/
|
|
27
36
|
toolName: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* What the agent passed to the call, without its short step caption. For an
|
|
39
|
+
* action, an object with path_params, query and body.
|
|
40
|
+
*/
|
|
28
41
|
toolArgs: Record<string, unknown>;
|
|
42
|
+
/** JSON Schema of the tool's input, or null when the tool declares none. */
|
|
29
43
|
toolInputSchema: Record<string, unknown> | null;
|
|
44
|
+
/**
|
|
45
|
+
* JSON Schema of the tool's output, or null when the tool declares none.
|
|
46
|
+
*/
|
|
30
47
|
toolOutputSchema: Record<string, unknown> | null;
|
|
48
|
+
/**
|
|
49
|
+
* The reason approval is needed, from the approval rules that raised it.
|
|
50
|
+
* May be empty; show a generic line such as "This tool needs your approval"
|
|
51
|
+
* then.
|
|
52
|
+
*/
|
|
31
53
|
prompt: string;
|
|
54
|
+
/**
|
|
55
|
+
* Id of the tool call waiting for approval, matching its row in the
|
|
56
|
+
* transcript, or null when there is none.
|
|
57
|
+
*/
|
|
32
58
|
toolCallId: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* True when the waiting tool call has already appeared in the transcript on
|
|
61
|
+
* this connection, so the request can be shown beside that row.
|
|
62
|
+
*/
|
|
33
63
|
anchored: boolean;
|
|
64
|
+
/** Which step of the agent's run paused for this request. */
|
|
34
65
|
round: number;
|
|
66
|
+
/** Id of the agent run that paused for this request. */
|
|
35
67
|
runId: string;
|
|
68
|
+
/**
|
|
69
|
+
* True when the agent has stopped actively waiting for an answer. The
|
|
70
|
+
* request can still be answered, and answering resumes the reply.
|
|
71
|
+
*/
|
|
36
72
|
parked: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* True when this action is set to ask for approval on every call; trust
|
|
75
|
+
* cannot skip it, so don't offer "don't ask again".
|
|
76
|
+
*/
|
|
37
77
|
gated: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* True when you may offer "approve and don't ask again" for this tool (send
|
|
80
|
+
* trust with the approval).
|
|
81
|
+
*/
|
|
38
82
|
trustAvailable: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Where the request stands. actionable means waiting for a decision (with
|
|
85
|
+
* the last failed submit's error sentence, or null), submitting means
|
|
86
|
+
* sending, answered carries the decision, and stale means it can no longer
|
|
87
|
+
* be answered (expired or answered elsewhere).
|
|
88
|
+
*/
|
|
39
89
|
status: ApprovalCardStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Who is asking, the assistant itself or one of its sub-agents (with its
|
|
92
|
+
* number and a label taken from its task), so the card can name it.
|
|
93
|
+
*/
|
|
40
94
|
asker: ApprovalAsker;
|
|
95
|
+
/**
|
|
96
|
+
* For a sub-agent's request, the turn the decision is sent to; null for the
|
|
97
|
+
* assistant's own requests.
|
|
98
|
+
*/
|
|
41
99
|
turnId: string | null;
|
|
42
100
|
}
|
|
101
|
+
/** The visitor's answer to one approval request, passed to submitDecision. */
|
|
43
102
|
export interface ApprovalDecisionInput {
|
|
103
|
+
/** True to let the call run, false to deny it. */
|
|
44
104
|
approved: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* With an approval, also stop asking about this tool for the rest of the
|
|
107
|
+
* conversation (or, for a sub-agent's request, the rest of its task). Only
|
|
108
|
+
* honored when the card's trustAvailable is true and gated is false.
|
|
109
|
+
*/
|
|
45
110
|
trust?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* For a denial, optional text telling the agent why; it is passed to the
|
|
113
|
+
* agent along with the refusal.
|
|
114
|
+
*/
|
|
46
115
|
feedback?: string;
|
|
47
116
|
}
|
|
48
117
|
export interface ApprovalInboxCapabilities {
|
|
@@ -63,6 +63,19 @@ class SessionEntry {
|
|
|
63
63
|
});
|
|
64
64
|
return fetch;
|
|
65
65
|
}
|
|
66
|
+
async _ensureAttachmentPolicy() {
|
|
67
|
+
this.ensureAssistantConfig();
|
|
68
|
+
let flight = this._assistantConfigFetch;
|
|
69
|
+
while (flight !== null) {
|
|
70
|
+
await flight;
|
|
71
|
+
const current = this._assistantConfigFetch;
|
|
72
|
+
if (current === null || current === flight) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
flight = current;
|
|
76
|
+
}
|
|
77
|
+
return this._attachmentPolicyCell.get();
|
|
78
|
+
}
|
|
66
79
|
ensureSubscriptions = () => {
|
|
67
80
|
this._subscriptionsFetch ??= this._fetchSubscriptions();
|
|
68
81
|
};
|
|
@@ -171,6 +184,8 @@ class SessionEntry {
|
|
|
171
184
|
}
|
|
172
185
|
},
|
|
173
186
|
onTurnSettled: this._onTurnSettled,
|
|
187
|
+
attachmentPolicy: this._attachmentPolicyCell,
|
|
188
|
+
ensureAttachmentPolicy: () => this._ensureAttachmentPolicy(),
|
|
174
189
|
});
|
|
175
190
|
}
|
|
176
191
|
_resolveEndUserToken() {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ASSISTANT_MAX_ATTACHMENTS } from "../contract/threads.js";
|
|
2
|
+
import { humanFileSize } from "../components/human-file-size.js";
|
|
3
|
+
import { capSlotsSpentBy, mintAttachmentDraftId, pickCapOf, } from "./composer-policy.js";
|
|
4
|
+
const ATTACHMENTS_UNAVAILABLE_SENTENCE = "Attachments aren't available right now.";
|
|
5
|
+
const UPLOAD_FAILED_SENTENCE = "The upload failed.";
|
|
6
|
+
export function attachmentRoomOf(policy) {
|
|
7
|
+
return Math.min(policy.max_per_message, ASSISTANT_MAX_ATTACHMENTS);
|
|
8
|
+
}
|
|
9
|
+
function attachmentTooLargeSentence(cap) {
|
|
10
|
+
return `Too large — the limit for ${cap.label} is ${humanFileSize(cap.bytes)}.`;
|
|
11
|
+
}
|
|
12
|
+
function tooManyAttachmentsSentence(room) {
|
|
13
|
+
return `Too many files — the limit is ${String(room)} per message.`;
|
|
14
|
+
}
|
|
15
|
+
export async function addComposerFilesFromStore(store, files) {
|
|
16
|
+
const picked = [...files];
|
|
17
|
+
if (picked.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const resets = store._composerInputResets;
|
|
21
|
+
const policy = store.deps.attachmentPolicy.get() ??
|
|
22
|
+
(await store.deps.ensureAttachmentPolicy());
|
|
23
|
+
if (store._composerInputResets !== resets) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (policy === null) {
|
|
27
|
+
_appendDrafts(store, picked.map((file) => _failedDraft(_uploadingDraftFor(file), ATTACHMENTS_UNAVAILABLE_SENTENCE)));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const room = attachmentRoomOf(policy);
|
|
31
|
+
let taken = capSlotsSpentBy(store._composerInput.get().attachments);
|
|
32
|
+
const settling = [];
|
|
33
|
+
for (const file of picked) {
|
|
34
|
+
const entry = _uploadingDraftFor(file);
|
|
35
|
+
if (taken >= room) {
|
|
36
|
+
_appendDrafts(store, [
|
|
37
|
+
_failedDraft(entry, tooManyAttachmentsSentence(room)),
|
|
38
|
+
]);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const cap = pickCapOf(file, policy.max_bytes_by_kind);
|
|
42
|
+
if (file.size > cap.bytes) {
|
|
43
|
+
_appendDrafts(store, [
|
|
44
|
+
_failedDraft(entry, attachmentTooLargeSentence(cap)),
|
|
45
|
+
]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
taken += 1;
|
|
49
|
+
_appendDrafts(store, [entry]);
|
|
50
|
+
settling.push(_uploadDraft(store, file, entry.localId));
|
|
51
|
+
}
|
|
52
|
+
await Promise.all(settling);
|
|
53
|
+
}
|
|
54
|
+
function _uploadingDraftFor(file) {
|
|
55
|
+
return {
|
|
56
|
+
localId: mintAttachmentDraftId(),
|
|
57
|
+
filename: file.name !== "" ? file.name : "attachment",
|
|
58
|
+
byteSize: file.size,
|
|
59
|
+
status: "uploading",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function _failedDraft(entry, error) {
|
|
63
|
+
return { ...entry, status: "failed", error };
|
|
64
|
+
}
|
|
65
|
+
function _appendDrafts(store, drafts) {
|
|
66
|
+
store.setComposerAttachments((current) => [...current, ...drafts]);
|
|
67
|
+
}
|
|
68
|
+
async function _uploadDraft(store, file, localId) {
|
|
69
|
+
try {
|
|
70
|
+
const settled = await store.uploadAttachment(file);
|
|
71
|
+
_settleDraft(store, localId, { status: "ready", attachment: settled });
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
_settleDraft(store, localId, {
|
|
75
|
+
status: "failed",
|
|
76
|
+
error: error instanceof Error ? error.message : UPLOAD_FAILED_SENTENCE,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function _settleDraft(store, localId, patch) {
|
|
81
|
+
store.setComposerAttachments((current) => current.map((item) => item.localId === localId ? { ...item, ...patch } : item));
|
|
82
|
+
}
|
|
@@ -20,6 +20,7 @@ export function setComposerAttachmentsFromStore(store, next) {
|
|
|
20
20
|
}
|
|
21
21
|
export function resetComposerInput(store, threadId) {
|
|
22
22
|
store._composerCaretReturnPending = null;
|
|
23
|
+
store._composerInputResets += 1;
|
|
23
24
|
store._composerInput.set({
|
|
24
25
|
scope: threadId !== null
|
|
25
26
|
? `t:${threadId}`
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { type ServingAttachment } from "../contract/threads.js";
|
|
2
2
|
import type { AttachmentKind } from "../generated/models/index.js";
|
|
3
3
|
export declare const CHARACTER_COUNT_VISIBLE_FROM: number;
|
|
4
|
+
/** One file staged in the composer for the next message. */
|
|
4
5
|
export interface AttachmentDraft<A = ServingAttachment> {
|
|
6
|
+
/**
|
|
7
|
+
* An id for this file that is unique within the page, for React keys and
|
|
8
|
+
* for updating or removing it.
|
|
9
|
+
*/
|
|
5
10
|
localId: number;
|
|
11
|
+
/** The file's name as shown to the visitor. */
|
|
6
12
|
filename: string;
|
|
13
|
+
/** The file's size in bytes. */
|
|
7
14
|
byteSize: number;
|
|
15
|
+
/**
|
|
16
|
+
* uploading while the file is being uploaded, ready once it can be sent,
|
|
17
|
+
* failed if it was rejected or the upload failed. The package composer
|
|
18
|
+
* won't send while any file is uploading or failed.
|
|
19
|
+
*/
|
|
8
20
|
status: "uploading" | "ready" | "failed";
|
|
21
|
+
/**
|
|
22
|
+
* The uploaded attachment, set once status is ready; pass its id to
|
|
23
|
+
* sendMessage.
|
|
24
|
+
*/
|
|
9
25
|
attachment?: A;
|
|
26
|
+
/**
|
|
27
|
+
* Why the file failed, as a sentence for the visitor; set only when status
|
|
28
|
+
* is failed.
|
|
29
|
+
*/
|
|
10
30
|
error?: string;
|
|
11
31
|
}
|
|
12
32
|
export declare function mintAttachmentDraftId(): number;
|
|
@@ -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
|
};
|