@asgard-js/react 0.2.37-canary.1 → 0.2.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +47 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -695,6 +695,53 @@ const handleToolCall = (response: SseResponse<EventType.TOOL_CALL_START | EventT
695
695
  />;
696
696
  ```
697
697
 
698
+ <a id="tool-call-consent"></a>
699
+ <br/>
700
+
701
+ ### Tool Call Consent
702
+
703
+ When a bot provider is configured with consent-required toolsets, the SDK automatically surfaces an approval modal before each tool call executes. No additional wiring is needed — `ToolCallConsentGate` is mounted inside `<Chatbot>` automatically.
704
+
705
+ #### How it works
706
+
707
+ When the backend emits an `asgard.tool_call.consent` event, a modal appears for each pending tool call in sequence. The user chooses one of three actions:
708
+
709
+ | Action | Behaviour |
710
+ | ----------------------- | -------------------------------------------------------------------------------------------------- |
711
+ | **Allow for This Chat** | Approves this call and auto-approves all future calls to the same tool in the current chat session |
712
+ | **Allow Once** | Approves this call only |
713
+ | **Deny** | Rejects this call; the user may optionally provide a reason |
714
+
715
+ Two auto-skip rules reduce interruptions:
716
+
717
+ - **`alreadyAllowed`**: If the backend marks a call as already allowed (e.g. from a prior "Allow for This Chat" in a previous turn), the SDK silently approves it without showing a modal.
718
+ - **Same-session Allow for This Chat**: If the user approved a tool via "Allow for This Chat" earlier in the same consent batch, subsequent calls to that tool in the same batch are auto-approved.
719
+
720
+ #### Zero-config usage
721
+
722
+ ```tsx
723
+ // No consent-specific props needed — just point to a consent-enabled bot provider
724
+ <Chatbot
725
+ config={{
726
+ apiKey: 'your-api-key',
727
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
728
+ }}
729
+ customChannelId="your-channel-id"
730
+ />
731
+ ```
732
+
733
+ #### Theming
734
+
735
+ The consent modal inherits the chatbot's design tokens (`--asg-color-*`) automatically, so it follows the active theme without extra configuration. You can also override individual modal colours via CSS variables on any ancestor element:
736
+
737
+ ```css
738
+ .my-chatbot-wrapper {
739
+ --asgard-consent-modal-bg: #0f172a;
740
+ --asgard-consent-modal-accent: #6366f1;
741
+ --asgard-consent-modal-danger: #ef4444;
742
+ }
743
+ ```
744
+
698
745
  <a id="emit-action"></a>
699
746
  <br/>
700
747
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asgard-js/react",
3
- "version": "0.2.37-canary.1",
3
+ "version": "0.2.37",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -46,7 +46,7 @@
46
46
  "vite-plugin-svgr": "^4.3.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@asgard-js/core": "^0.2.37-canary.1",
49
+ "@asgard-js/core": "^0.2.37",
50
50
  "react": "^18.0.0 || ^19.0.0",
51
51
  "react-dom": "^18.0.0 || ^19.0.0"
52
52
  }