@sixb/app 0.2.3 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +8 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +5 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +3 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +114 -5
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +190 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.d.ts.map +1 -1
- package/dist/agent/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +278 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +9 -1
- package/src/agent/agent-chat.tsx +57 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +92 -45
- package/src/agent/conversation.ts +203 -54
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +64 -61
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +33 -6
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +14 -5
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- package/src/artifacts/renderers/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- package/src/artifacts/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +101 -41
- package/src/index.ts +8 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { AgentContextEntryInput } from "@sixb/core/agents/context"
|
|
2
|
+
import { createContext, useContext, useRef } from "react"
|
|
3
|
+
import type { ViewerTarget } from "../artifacts/target"
|
|
4
|
+
import type { AgentFileRef } from "./types"
|
|
5
|
+
|
|
6
|
+
const MAX_STORED_THREADS = 50
|
|
7
|
+
|
|
8
|
+
export interface ThreadComposerDraft {
|
|
9
|
+
readonly text: string
|
|
10
|
+
readonly attachments: readonly AgentFileRef[]
|
|
11
|
+
readonly explicitContext: readonly AgentContextEntryInput[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ThreadStateEntry {
|
|
15
|
+
draft?: ThreadComposerDraft
|
|
16
|
+
panelTarget?: ViewerTarget
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class ThreadStateStore {
|
|
20
|
+
private readonly entries = new Map<string, ThreadStateEntry>()
|
|
21
|
+
|
|
22
|
+
readDraft(draftKey: string): ThreadComposerDraft | null {
|
|
23
|
+
if (!draftKey) return null
|
|
24
|
+
const draft = this.entries.get(draftKey)?.draft
|
|
25
|
+
return draft && !isEmptyDraft(draft) ? draft : null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
writeDraft(draftKey: string, draft: ThreadComposerDraft): void {
|
|
29
|
+
if (!draftKey) return
|
|
30
|
+
const existing = this.entries.get(draftKey)
|
|
31
|
+
if (isEmptyDraft(draft)) {
|
|
32
|
+
if (!existing) return
|
|
33
|
+
if (existing.panelTarget) {
|
|
34
|
+
this.touch(draftKey, { panelTarget: existing.panelTarget })
|
|
35
|
+
} else {
|
|
36
|
+
this.entries.delete(draftKey)
|
|
37
|
+
}
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
this.touch(draftKey, {
|
|
41
|
+
...(existing?.panelTarget ? { panelTarget: existing.panelTarget } : {}),
|
|
42
|
+
draft,
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
clearDraft(draftKey: string): void {
|
|
47
|
+
this.writeDraft(draftKey, { text: "", attachments: [], explicitContext: [] })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
readPanelTarget(scopeKey: string): ViewerTarget | null {
|
|
51
|
+
if (!scopeKey || scopeKey === "draft") return null
|
|
52
|
+
return this.entries.get(scopeKey)?.panelTarget ?? null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
writePanelTarget(scopeKey: string, target: ViewerTarget | null): void {
|
|
56
|
+
if (!scopeKey || scopeKey === "draft") return
|
|
57
|
+
const existing = this.entries.get(scopeKey)
|
|
58
|
+
if (target === null) {
|
|
59
|
+
if (!existing) return
|
|
60
|
+
if (existing.draft) {
|
|
61
|
+
this.touch(scopeKey, { draft: existing.draft })
|
|
62
|
+
} else {
|
|
63
|
+
this.entries.delete(scopeKey)
|
|
64
|
+
}
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
this.touch(scopeKey, {
|
|
68
|
+
...(existing?.draft ? { draft: existing.draft } : {}),
|
|
69
|
+
panelTarget: target,
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private touch(key: string, entry: ThreadStateEntry): void {
|
|
74
|
+
if (this.entries.has(key)) {
|
|
75
|
+
this.entries.delete(key)
|
|
76
|
+
} else if (this.entries.size >= MAX_STORED_THREADS) {
|
|
77
|
+
const oldest = this.entries.keys().next().value
|
|
78
|
+
if (oldest !== undefined) this.entries.delete(oldest)
|
|
79
|
+
}
|
|
80
|
+
this.entries.set(key, entry)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const storesByOwner = new WeakMap<object, ThreadStateStore>()
|
|
85
|
+
|
|
86
|
+
/** Return the `ThreadStateStore` scoped to an app-lifetime owner such as `QueryClient`. */
|
|
87
|
+
export function threadStateStoreFor(owner: object): ThreadStateStore {
|
|
88
|
+
let store = storesByOwner.get(owner)
|
|
89
|
+
if (!store) {
|
|
90
|
+
store = new ThreadStateStore()
|
|
91
|
+
storesByOwner.set(owner, store)
|
|
92
|
+
}
|
|
93
|
+
return store
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const ThreadStateContext = createContext<ThreadStateStore | null>(null)
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The surrounding conversation store when inside `AgentChat`, or a mount-local store when a
|
|
100
|
+
* component such as `ArtifactPanelRoot` is rendered standalone.
|
|
101
|
+
*/
|
|
102
|
+
export function useThreadStateStore(owner?: object | null): ThreadStateStore {
|
|
103
|
+
const inherited = useContext(ThreadStateContext)
|
|
104
|
+
const fallbackRef = useRef<ThreadStateStore | null>(null)
|
|
105
|
+
if (inherited) return inherited
|
|
106
|
+
if (owner) return threadStateStoreFor(owner)
|
|
107
|
+
fallbackRef.current ??= new ThreadStateStore()
|
|
108
|
+
return fallbackRef.current
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isEmptyDraft(draft: ThreadComposerDraft): boolean {
|
|
112
|
+
if (draft.text.length > 0) return false
|
|
113
|
+
return draft.attachments.length === 0 && draft.explicitContext.length === 0
|
|
114
|
+
}
|
|
@@ -5,13 +5,18 @@ import { isBackgroundStart } from "../background/interpret"
|
|
|
5
5
|
import { BashToolView } from "../bash/bash-tool-view"
|
|
6
6
|
import { WebFetchToolView } from "../components/web-fetch-tool-view"
|
|
7
7
|
import { WebSearchToolView } from "../components/web-search-tool-view"
|
|
8
|
+
import { EditToolView, WriteToolView } from "../file-edits/file-edit-tool-view"
|
|
8
9
|
import type { NormalizedTool } from "../parts"
|
|
9
10
|
import { OpenArtifactToolView } from "../publish-artifact/open-artifact-tool-view"
|
|
10
11
|
import { PublishArtifactToolView } from "../publish-artifact/publish-artifact-tool-view"
|
|
11
12
|
import { ReadToolView } from "../read/read-tool-view"
|
|
13
|
+
import { coerceGlobOutput, coerceGrepOutput } from "../search/interpret"
|
|
14
|
+
import { GlobToolView, GrepToolView } from "../search/search-tool-view"
|
|
12
15
|
import { coerceWebFetchOutput } from "../utils/web-fetch"
|
|
13
16
|
import { coerceWebSearchOutput } from "../utils/web-search"
|
|
17
|
+
import { describeViewFile } from "../view-file/interpret"
|
|
14
18
|
import { ViewFileToolView } from "../view-file/view-file-tool-view"
|
|
19
|
+
import { waitsForCommandsOnly } from "../waits"
|
|
15
20
|
|
|
16
21
|
type BuiltInToolView = (tool: NormalizedTool) => ReactNode
|
|
17
22
|
|
|
@@ -37,16 +42,38 @@ const BUILT_IN_TOOL_VIEWS: ReadonlyMap<string, BuiltInToolView> = new Map([
|
|
|
37
42
|
/>
|
|
38
43
|
),
|
|
39
44
|
],
|
|
40
|
-
// A
|
|
45
|
+
// A wait or a stop for commands alone is their row; one for a sub-agent is the sub-agent's. A
|
|
46
|
+
// failed one keeps the inspector, which says why. Earlier threads hold bash_output and bash_stop.
|
|
47
|
+
...["wait", "stop", "bash_output", "bash_stop"].map((name): [string, BuiltInToolView] => [
|
|
48
|
+
name,
|
|
49
|
+
(tool) =>
|
|
50
|
+
tool.state === "output-error" || !waitsForCommandsOnly(tool) ? null : (
|
|
51
|
+
<BackgroundToolRow tool={tool} />
|
|
52
|
+
),
|
|
53
|
+
]),
|
|
54
|
+
// A file read shows as itself, an image or a PDF, keeps the view view_file had.
|
|
41
55
|
[
|
|
42
|
-
"
|
|
43
|
-
(tool) =>
|
|
56
|
+
"read",
|
|
57
|
+
(tool) =>
|
|
58
|
+
describeViewFile(tool).file ? <ViewFileToolView tool={tool} /> : <ReadToolView tool={tool} />,
|
|
44
59
|
],
|
|
60
|
+
["edit", (tool) => <EditToolView tool={tool} />],
|
|
61
|
+
["write", (tool) => <WriteToolView tool={tool} />],
|
|
45
62
|
[
|
|
46
|
-
"
|
|
47
|
-
(tool) =>
|
|
63
|
+
"glob",
|
|
64
|
+
(tool) =>
|
|
65
|
+
tool.state !== "output-available" || coerceGlobOutput(tool.output) !== null ? (
|
|
66
|
+
<GlobToolView tool={tool} />
|
|
67
|
+
) : null,
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"grep",
|
|
71
|
+
(tool) =>
|
|
72
|
+
tool.state !== "output-available" || coerceGrepOutput(tool.output) !== null ? (
|
|
73
|
+
<GrepToolView tool={tool} />
|
|
74
|
+
) : null,
|
|
48
75
|
],
|
|
49
|
-
|
|
76
|
+
// Earlier threads hold calls to it.
|
|
50
77
|
["view_file", (tool) => <ViewFileToolView tool={tool} />],
|
|
51
78
|
["publish_artifact", publishArtifact],
|
|
52
79
|
["update_artifact", publishArtifact],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentToolDefinition, InferAgentToolInput, InferAgentToolOutput } from "@sixb/core"
|
|
2
|
-
import { Component, createContext, type ReactNode, useContext, useMemo } from "react"
|
|
2
|
+
import { Component, createContext, memo, type ReactNode, useContext, useMemo } from "react"
|
|
3
3
|
import type { NormalizedPart, NormalizedTool } from "../parts"
|
|
4
4
|
import { type AgentToolView, type AgentToolViewProps, agentToolViews } from "./define"
|
|
5
5
|
|
|
@@ -34,8 +34,32 @@ export function useAgentToolView(toolName: string): AgentToolView | undefined {
|
|
|
34
34
|
* The views of the turn's tools shown in the answer, in call order. Each call keeps its row in the
|
|
35
35
|
* work; a view that fails shows nothing here.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
function sameToolSequence(a: readonly NormalizedPart[], b: readonly NormalizedPart[]): boolean {
|
|
38
|
+
if (a === b) return true
|
|
39
|
+
let i = 0
|
|
40
|
+
let j = 0
|
|
41
|
+
while (true) {
|
|
42
|
+
while (i < a.length && a[i]?.kind !== "tool") i++
|
|
43
|
+
while (j < b.length && b[j]?.kind !== "tool") j++
|
|
44
|
+
if (i >= a.length && j >= b.length) return true
|
|
45
|
+
if (i >= a.length || j >= b.length) return false
|
|
46
|
+
if (!Object.is(a[i], b[j])) return false
|
|
47
|
+
i++
|
|
48
|
+
j++
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface AnswerToolViewsProps {
|
|
53
|
+
readonly parts: readonly NormalizedPart[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function sameAnswerTools(prev: AnswerToolViewsProps, next: AnswerToolViewsProps): boolean {
|
|
57
|
+
return sameToolSequence(prev.parts, next.parts)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function AnswerToolViewsList({ parts }: AnswerToolViewsProps) {
|
|
38
61
|
const views = useContext(AgentToolViewsContext)
|
|
62
|
+
if (views.size === 0) return null
|
|
39
63
|
|
|
40
64
|
return parts.map((part, index) => {
|
|
41
65
|
if (part.kind !== "tool") return null
|
|
@@ -46,6 +70,8 @@ export function AnswerToolViews({ parts }: { readonly parts: readonly Normalized
|
|
|
46
70
|
})
|
|
47
71
|
}
|
|
48
72
|
|
|
73
|
+
export const AnswerToolViews = memo(AnswerToolViewsList, sameAnswerTools)
|
|
74
|
+
|
|
49
75
|
/** A call shown through the project's view, or through `fallback` when the view throws. */
|
|
50
76
|
export function ProjectToolView({
|
|
51
77
|
view,
|
package/src/agent/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
GetAgentResponse,
|
|
4
4
|
GetAgentRunResponse,
|
|
5
5
|
GetAgentThreadContextResponse,
|
|
6
|
+
ListAgentThreadInboxResponse,
|
|
6
7
|
ListAgentThreadMessagesResponse,
|
|
7
8
|
ListAgentThreadsResponse,
|
|
8
9
|
ListModelsResponse,
|
|
@@ -30,6 +31,12 @@ export type AgentFileRef = Extract<AgentMessagePart, { type: "file" }>["fileRef"
|
|
|
30
31
|
|
|
31
32
|
export type AgentContextPart = Extract<AgentMessagePart, { type: "context" }>
|
|
32
33
|
|
|
34
|
+
/** A message waiting in a conversation's inbox: a steer, or a turn queued behind one. */
|
|
35
|
+
export type AgentInboxItem = ListAgentThreadInboxResponse["items"][number]
|
|
36
|
+
|
|
37
|
+
/** Where a message goes while a turn runs: into it, behind it, or after stopping it. */
|
|
38
|
+
export type AgentMessageDelivery = "auto" | "steer" | "queue" | "send_now"
|
|
39
|
+
|
|
33
40
|
export type AgentRun = GetAgentRunResponse
|
|
34
41
|
|
|
35
42
|
/** A conversation's context against its model's limits: what the context meter shows. */
|
|
@@ -12,10 +12,12 @@ import { describeViewFile } from "./interpret"
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A file the agent viewed. It belongs to the work, not to the answer, so it stays in the trace: an
|
|
15
|
-
* image as
|
|
15
|
+
* image as an inline thumbnail beside its label, any other file as a compact chip, each opening in
|
|
16
|
+
* the artifact panel.
|
|
16
17
|
*/
|
|
17
18
|
export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
|
|
18
|
-
const
|
|
19
|
+
const agentMessages = useAgentMessages()
|
|
20
|
+
const messages = agentMessages.viewFile
|
|
19
21
|
const { target, file } = describeViewFile(tool)
|
|
20
22
|
const running = tool.state === "input-streaming" || tool.state === "input-available"
|
|
21
23
|
const label =
|
|
@@ -25,6 +27,31 @@ export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
|
|
|
25
27
|
? messages.running(target)
|
|
26
28
|
: messages.title(target)
|
|
27
29
|
|
|
30
|
+
if (
|
|
31
|
+
file &&
|
|
32
|
+
tool.state === "output-available" &&
|
|
33
|
+
file.source &&
|
|
34
|
+
fileView(file.fileRef) === "image"
|
|
35
|
+
) {
|
|
36
|
+
const name = file.fileRef.fileName?.trim() || agentMessages.files.file
|
|
37
|
+
return (
|
|
38
|
+
<div className="min-w-0">
|
|
39
|
+
<OpenFile file={file} name={name}>
|
|
40
|
+
<span className="group/view flex w-fit max-w-full items-center gap-2 rounded-md py-0.5 pr-1.5 text-[13px] leading-normal text-muted-foreground transition-colors hover:text-foreground">
|
|
41
|
+
<img
|
|
42
|
+
src={file.source.inlineUrl}
|
|
43
|
+
alt={name}
|
|
44
|
+
loading="lazy"
|
|
45
|
+
className="size-9 shrink-0 rounded-md border border-border/80 bg-muted/40 object-cover transition-transform group-hover/view:scale-[1.03]"
|
|
46
|
+
/>
|
|
47
|
+
<Eye className="size-3.5 shrink-0" />
|
|
48
|
+
<span className="min-w-0 truncate font-medium">{label}</span>
|
|
49
|
+
</span>
|
|
50
|
+
</OpenFile>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
return (
|
|
29
56
|
<div className="min-w-0 space-y-1.5">
|
|
30
57
|
<div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
|
|
@@ -37,32 +64,19 @@ export function ViewFileToolView({ tool }: { tool: NormalizedTool }) {
|
|
|
37
64
|
</div>
|
|
38
65
|
{file && tool.state === "output-available" ? (
|
|
39
66
|
<div className="pl-5">
|
|
40
|
-
<
|
|
67
|
+
<ViewedFileChip file={file} />
|
|
41
68
|
</div>
|
|
42
69
|
) : null}
|
|
43
70
|
</div>
|
|
44
71
|
)
|
|
45
72
|
}
|
|
46
73
|
|
|
47
|
-
function
|
|
74
|
+
function ViewedFileChip({ file }: { file: NormalizedFile }) {
|
|
48
75
|
const messages = useAgentMessages().files
|
|
49
76
|
const locale = useLocale()
|
|
50
|
-
const { fileRef
|
|
77
|
+
const { fileRef } = file
|
|
51
78
|
const name = fileRef.fileName?.trim() || messages.file
|
|
52
79
|
|
|
53
|
-
if (source && fileView(fileRef) === "image") {
|
|
54
|
-
return (
|
|
55
|
-
<OpenFile file={file} name={name}>
|
|
56
|
-
<img
|
|
57
|
-
src={source.inlineUrl}
|
|
58
|
-
alt={name}
|
|
59
|
-
loading="lazy"
|
|
60
|
-
className="block h-auto max-h-28 w-auto max-w-[min(10rem,100%)] rounded-md border border-border/70 bg-muted/40 object-contain"
|
|
61
|
-
/>
|
|
62
|
-
</OpenFile>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
80
|
return (
|
|
67
81
|
<OpenFile file={file} name={name}>
|
|
68
82
|
<span className="inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground">
|
|
@@ -91,7 +105,7 @@ function OpenFile({
|
|
|
91
105
|
const { source } = file
|
|
92
106
|
const className = cn(
|
|
93
107
|
"block w-fit max-w-full rounded-md outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring",
|
|
94
|
-
source && "hover:opacity-
|
|
108
|
+
source && "hover:opacity-85"
|
|
95
109
|
)
|
|
96
110
|
|
|
97
111
|
if (source && panel) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { NormalizedTool } from "./parts"
|
|
2
|
+
|
|
3
|
+
// `wait` and `stop` name background commands, by the `bg_` id `bash` returned, and sub-agents, by
|
|
4
|
+
// their key. Earlier threads hold the tools before them: `bash_output` and `bash_stop` for a
|
|
5
|
+
// command, `wait_agent` for sub-agents, by run id.
|
|
6
|
+
|
|
7
|
+
/** The tools that read or stop a background command, today's and earlier threads'. */
|
|
8
|
+
export const COMMAND_TOOLS: ReadonlySet<string> = new Set([
|
|
9
|
+
"wait",
|
|
10
|
+
"stop",
|
|
11
|
+
"bash_output",
|
|
12
|
+
"bash_stop",
|
|
13
|
+
])
|
|
14
|
+
|
|
15
|
+
/** What a `wait` or a `stop` names: the ids it was called with, as the model wrote them. */
|
|
16
|
+
export function namedIds(tool: Pick<NormalizedTool, "toolName" | "input">): readonly string[] {
|
|
17
|
+
const input = isRecord(tool.input) ? tool.input : {}
|
|
18
|
+
const ids = Array.isArray(input.ids)
|
|
19
|
+
? input.ids
|
|
20
|
+
: Array.isArray(input.runIds)
|
|
21
|
+
? input.runIds
|
|
22
|
+
: [input.id]
|
|
23
|
+
return ids.flatMap((id) => (typeof id === "string" && id.trim() ? [id.trim()] : []))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Whether an id names a background command rather than a sub-agent. */
|
|
27
|
+
export function isCommandId(id: string): boolean {
|
|
28
|
+
return id.startsWith("bg_")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Whether a call waits for, or stops, one of the Agent's sub-agents: its row stands for it. */
|
|
32
|
+
export function waitsForChildren(tool: Pick<NormalizedTool, "toolName" | "input">): boolean {
|
|
33
|
+
if (tool.toolName === "wait_agent") return true
|
|
34
|
+
if (tool.toolName !== "wait" && tool.toolName !== "stop") return false
|
|
35
|
+
return namedIds(tool).some((id) => !isCommandId(id))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Whether a call reads, waits for, or stops background commands alone. */
|
|
39
|
+
export function waitsForCommandsOnly(tool: Pick<NormalizedTool, "toolName" | "input">): boolean {
|
|
40
|
+
return COMMAND_TOOLS.has(tool.toolName) && !waitsForChildren(tool)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Whether a call stops what it names. */
|
|
44
|
+
export function isStop(tool: Pick<NormalizedTool, "toolName">): boolean {
|
|
45
|
+
return tool.toolName === "stop" || tool.toolName === "bash_stop"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
49
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
50
|
+
}
|