diff --git a/.github/workflows/upload.yaml b/.github/workflows/upload.yaml index 41b1440..5d66419 100644 --- a/.github/workflows/upload.yaml +++ b/.github/workflows/upload.yaml @@ -36,7 +36,7 @@ jobs: - uses: calcit-lang/setup-calcit@v1.5.0 with: tools: calcit,caps - caps-version: "0.1.1" + caps-version: "0.1.2" deps-file: deps.cirru - name: Resolve Calcit dependencies @@ -138,7 +138,7 @@ jobs: - name: Upload and verify web assets on COS if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository - uses: worktools/cos-upload-action@v1.2.0 + uses: worktools/cos-upload-action@v1.3.0 with: source-dir: dist bucket: ${{ secrets.COS_BUCKET }} diff --git a/README.md b/README.md index a146e85..81a7bf3 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Demo:。Gemini 文档:> states :message-box) :data - {} (:content |) (:search? false) (:think? false) (:focus-mode? false) - if - and (struct? raw-message-box-state) (&struct:matches? raw-message-box-state MessageBoxState) - struct-match raw-message-box-state (MessageBoxState typed typed) - _ other $ raise "|Expected MessageBoxState" - decode-map-as - if (struct? raw-message-box-state) - if - = (&struct:get-name raw-message-box-state) :MessageBoxState - &struct:to-map raw-message-box-state - raise "|Expected MessageBoxState" - , raw-message-box-state - , 'app.schema/MessageBoxState + message-box-state $ decode-message-box-state $ .unwrap-or + &map:get (>> states :message-box) :data + {} (:content |) (:search? false) (:think? false) (:focus-mode? false) sessions-plugin $ use-drawer (>> states :sessions-modal) {} (:title "|History Sessions") :style $ {} (:min-width "||max(320px,30vw)\"") (:max-width |80vw) @@ -672,7 +656,8 @@ raw $ let host-value $ js-await $ db-get archive-key if - or (nil? host-value) + or + .none? $ nil->option host-value = (js/typeof host-value) |undefined , | $ contract/expect-string "|Archive storage value" host-value if (blank? raw) (js/alert "|No archives found!") @@ -1000,20 +985,8 @@ (:none) ([]) state $ match (get states :data) (:none) - %{} MessageBoxState (:content |) (:search? false) (:think? false) (:focus-mode? false) - (:some raw-message-box-state) - if - and (struct? raw-message-box-state) (&struct:matches? raw-message-box-state MessageBoxState) - struct-match raw-message-box-state (MessageBoxState typed typed) - _ other $ raise "|Expected MessageBoxState" - decode-map-as - if (struct? raw-message-box-state) - if - = (&struct:get-name raw-message-box-state) :MessageBoxState - &struct:to-map raw-message-box-state - raise "|Expected MessageBoxState" - , raw-message-box-state - , 'app.schema/MessageBoxState + MessageBoxState :content | :search? false :think? false :focus-mode? false + (:some raw-message-box-state) (decode-message-box-state raw-message-box-state) [] (effect-focus) (on-fill cursor state on-submit) div {} $ :class-name $ str-spaced css/center style-message-box-panel @@ -1240,7 +1213,8 @@ raw $ let host-value $ js-await $ db-get archive-key if - or (nil? host-value) + or + .none? $ nil->option host-value = (js/typeof host-value) |undefined , | $ contract/expect-string "|Archive storage value" host-value old-archives $ if (blank? raw) (take sessions 0) @@ -1293,7 +1267,9 @@ parts0 $ if (js-present-dynamic? content0) (contract/object-field "|GenAI stream" content0 |parts) js/undefined part0 $ if (js-present-dynamic? parts0) (contract/object-field "|GenAI stream" parts0 |0) js/undefined thought0 $ if (js-present-dynamic? part0) (contract/object-field "|GenAI stream" part0 |thought) js/undefined - thinking? $ if (bool? thought0) (contract/expect-bool "|GenAI thought" thought0) false + thinking? $ match (try-decode-map-as thought0 Bool) + (:ok value) value + (:err _) false part-text $ if (js-present-dynamic? part0) (contract/object-field "|GenAI stream" part0 |text) js/undefined chunk-text $ contract/object-field "|GenAI stream" chunk-data |text primary-text $ if (js-present-dynamic? part-text) part-text chunk-text @@ -1310,6 +1286,22 @@ assert= |blocked $ :text decoded assert= false $ :thinking? decoded :schema $ quote $ Fn T (-> StreamChunk) (:generics T) (:features :js-ffi) + 'decode-message-box-state $ %{} 'CodeEntry (:doc |) + :code $ quote $ defn decode-message-box-state (raw-message-box-state) + if + and (struct? raw-message-box-state) (&struct:matches? raw-message-box-state MessageBoxState) + struct-match raw-message-box-state (MessageBoxState typed typed) + _ other $ raise "|Expected MessageBoxState" + decode-map-as + if (struct? raw-message-box-state) + if + = (&struct:get-name raw-message-box-state) :MessageBoxState + &struct:to-map raw-message-box-state + raise "|Expected MessageBoxState" + , raw-message-box-state + , 'app.schema/MessageBoxState + :examples $ [] + :schema $ quote $ Fn Input (-> MessageBoxState) (:generics Input) (:open :decode) 'download-sessions! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn download-sessions! (sessions) let @@ -1570,7 +1562,7 @@ if (tag? model-value) model-value :gemini , :thinking $ stream-text $ .unwrap-or (get data :thinking) | :examples $ [] - :schema $ quote $ Fn T (-> ChatState) (:generics T) (:features :js-ffi) + :schema $ quote $ Fn T (-> ChatState) (:generics T) (:features :js-ffi) (:open :decode) :tests $ [] $ %{} 'TestEntry (:name |legacy-nil-fields) :code $ quote $ let legacy $ normalize-chat-state $ {} (:answer nil) (:loading? false) (:done? true) @@ -1685,7 +1677,9 @@ :schema $ quote $ Fn Store ChatState (-> Store) 'stream-text $ %{} 'CodeEntry (:doc |) :code $ quote $ defn stream-text (value) - if (string? value) value | + match (try-decode-map-as value String) + (:ok text) text + (:err _) | :examples $ [] :schema $ quote $ Fn T (-> String) (:generics T) (:features :js-ffi) :tests $ [] @@ -2276,7 +2270,7 @@ js/window.addEventListener |dblclick $ fn (event) (.!preventDefault event) js/window.addEventListener |wheel fn (event) - if + when contract/expect-bool |ctrlKey $ js/Boolean $ .-ctrlKey event .!preventDefault event js-object $ :passive false @@ -2288,7 +2282,7 @@ visibility-state $ .unwrap-or js-nullish->option $ .-visibilityState document , | - if (= |hidden visibility-state) (persist-storage!) + when (= |hidden visibility-state) (persist-storage!) , &unit if config/chrome-extension? $ listen-extension! sync-gemini-key! @@ -2320,7 +2314,7 @@ , data _ $ do (eprintln "|unknown op:" raw) (schema/DispatchOp :unhandled) :examples $ [] - :schema $ quote $ Fn Input (-> schema/DispatchOp) (:generics Input) (:features :io) + :schema $ quote $ Fn Input (-> schema/DispatchOp) (:generics Input) (:features :io) (:open :decode) 'on-control! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn on-control! (control) (dispatch! control) :examples $ [] @@ -2488,7 +2482,7 @@ assert= store $ normalize-store empty-wire 'normalize-chat-message $ %{} 'CodeEntry (:doc |) :code $ quote $ defn normalize-chat-message (raw) - hint-fn $ Fn T (-> ChatMessage) (:generics T) (:features :js-ffi) + hint-fn $ Fn T (-> ChatMessage) (:generics T) (:features :js-ffi) (:open :decode) if and (struct? raw) (&struct:matches? raw ChatMessage) struct-match raw @@ -2513,10 +2507,10 @@ decode-map-as (assoc data :thinking normalized-thinking) 'app.schema/ChatMessage raise "|Expected chat message map" :examples $ [] - :schema $ quote $ Fn T (-> ChatMessage) (:generics T) (:features :js-ffi) + :schema $ quote $ Fn T (-> ChatMessage) (:generics T) (:features :js-ffi) (:open :decode) 'normalize-chat-session $ %{} 'CodeEntry (:doc |) :code $ quote $ defn normalize-chat-session (raw) - hint-fn $ Fn T (-> ChatSession) (:generics T) (:features :js-ffi) + hint-fn $ Fn T (-> ChatSession) (:generics T) (:features :js-ffi) (:open :decode) if and (struct? raw) (&struct:matches? raw ChatSession) struct-match raw @@ -2550,7 +2544,7 @@ ChatSession :id (:id base) :created-at (:created-at base) :messages messages :model (:model base) :preview (:preview base) :is-history? $ :is-history? base raise "|Expected chat session map" :examples $ [] - :schema $ quote $ Fn T (-> ChatSession) (:generics T) (:features :js-ffi) + :schema $ quote $ Fn T (-> ChatSession) (:generics T) (:features :js-ffi) (:open :decode) :tests $ [] $ %{} 'TestEntry (:name |accepts-typed-and-map) :code $ quote $ let typed $ ChatSession :id |typed :created-at 1 :messages ([]) :model :gemini :preview |Typed :is-history? true @@ -2566,7 +2560,7 @@ :tags $ #{} :regression :unit 'normalize-store $ %{} 'CodeEntry (:doc |) :code $ quote $ defn normalize-store (raw) - hint-fn $ Fn T (-> Store) (:generics T) (:features :js-ffi) + hint-fn $ Fn T (-> Store) (:generics T) (:features :js-ffi) (:open :decode) if and (struct? raw) match (struct-definition raw) @@ -2615,7 +2609,7 @@ true None decode-map-as patched 'app.schema/Store :examples $ [] - :schema $ quote $ Fn T (-> Store) (:generics T) (:features :js-ffi) + :schema $ quote $ Fn T (-> Store) (:generics T) (:features :js-ffi) (:open :decode) :tests $ [] %{} 'TestEntry (:name |migrates-legacy-message-thinking) :code $ quote $ let @@ -2783,7 +2777,7 @@ assoc :current-session-id None _ store :examples $ [] - :schema $ quote $ Fn Store app.schema/DispatchOp String Number (-> Store) + :schema $ quote $ Fn Store app.schema/DispatchOp String Number (-> Store) (:open :decode) :tests $ [] $ %{} 'TestEntry (:name |mixed-cursor-latest-state-merge) :code $ quote $ let cursor $ [] :panel |draft 7 diff --git a/deps.cirru b/deps.cirru index c9eeaac..3d0e4a5 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,9 +1,9 @@ -{} (:calcit-version |0.47.1) +{} (:calcit-version |0.53.0) :version |0.0.10 - :dependencies $ {} (|Respo/alerts.calcit |0.14.13) - |Respo/reel.calcit |0.11.11 - |Respo/respo-markdown.calcit |0.9.11 - |Respo/respo-ui.calcit |0.16.7 - |Respo/respo.calcit |0.20.1 - |calcit-lang/js-ffi |0.2.26 + :dependencies $ {} (|Respo/alerts.calcit |0.14.17) + |Respo/reel.calcit |0.11.16 + |Respo/respo-markdown.calcit |0.9.14 + |Respo/respo-ui.calcit |0.16.11 + |Respo/respo.calcit |0.20.5 + |calcit-lang/js-ffi |0.2.31 diff --git a/package.json b/package.json index f38cd95..69f7ef7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@calcit/procs": "0.47.1", + "@calcit/procs": "0.53.0", "@google/genai": "2.23.0", "@tiye/main-fonts": "0.0.1", "axios": "1.20.0", diff --git a/yarn.lock b/yarn.lock index d156fde..6ad2835 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,15 +12,15 @@ __metadata: languageName: node linkType: hard -"@calcit/procs@npm:0.47.1": - version: 0.47.1 - resolution: "@calcit/procs@npm:0.47.1" +"@calcit/procs@npm:0.53.0": + version: 0.53.0 + resolution: "@calcit/procs@npm:0.53.0" dependencies: "@calcit/finger-vec": "npm:0.1.1" "@calcit/ternary-tree": "npm:0.0.26" "@cirru/parser.ts": "npm:0.0.10" "@cirru/writer.ts": "npm:^0.1.9" - checksum: 10c0/15a3e5a69a3412dde325fd8512c71303a27c86ca580083c69ca11595f0d6c5324aed670d9ccf46d55dc82b833e23035ce3eaede0f5222129ecd6c81784deb431 + checksum: 10c0/c4019ecb1e4bd5768404d70310d538d1c835df62641379ec3cdd1266b1cb37f0dea9558850bd5ce67b5109501467f36c04a4f0394d6c1a767374ec1453fbcdc5 languageName: node linkType: hard @@ -1540,7 +1540,7 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: - "@calcit/procs": "npm:0.47.1" + "@calcit/procs": "npm:0.53.0" "@google/genai": "npm:2.23.0" "@tiye/main-fonts": "npm:0.0.1" axios: "npm:1.20.0"