@app-assistant/host 0.2.0 → 0.2.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 CHANGED
@@ -129,6 +129,9 @@ import { AssistantChat } from "@app-assistant/host/react";
129
129
  <AssistantChat app="shipnote" botUrl="https://bot.example.com" sessionUrl="/api/assistant/session" />;
130
130
  ```
131
131
 
132
+ Optional props: `label` (the button, default "Write with AI"), `position` (`"left"`), and `scheduleLabel` (the word
133
+ before a draft's time picker when your `context` sends `post_times`: "Post at", "Send at"; default "Publish at").
134
+
132
135
  It loads the bot's `widget.js` once per page; the widget draws its own floating open button and panel. Optional:
133
136
  `label` (the button's words), `position` (`"left"` or `"right"`), and `children` for an open button of your own
134
137
  in the page (`className` styles it). `openAssistant()` opens the chat from anywhere.
@@ -11,6 +11,8 @@ interface AssistantChatProps {
11
11
  /** The open button's words. The widget's default is "Write with AI". */
12
12
  label?: string;
13
13
  position?: "left" | "right";
14
+ /** The draft's time picker, in your app's words ("Post at", "Send at"). Default "Publish at". */
15
+ scheduleLabel?: string;
14
16
  /** An open button of your own, in your page's flow, as well as the widget's floating one. */
15
17
  children?: ReactNode;
16
18
  /** The class of your open button. */
@@ -7,7 +7,7 @@ var MARK = "data-app-assistant-host";
7
7
  function openAssistant() {
8
8
  window.dispatchEvent(new Event("assistant:open"));
9
9
  }
10
- function loadWidget({ app, botUrl, sessionUrl, label, position }) {
10
+ function loadWidget({ app, botUrl, sessionUrl, label, position, scheduleLabel }) {
11
11
  if (document.querySelector(`script[${MARK}]`) || document.getElementById("assistant-widget")) return;
12
12
  const script = document.createElement("script");
13
13
  script.src = `${botUrl.replace(/\/+$/, "")}/widget.js`;
@@ -17,11 +17,15 @@ function loadWidget({ app, botUrl, sessionUrl, label, position }) {
17
17
  script.dataset.sessionUrl = sessionUrl ?? "/api/assistant/session";
18
18
  if (label) script.dataset.label = label;
19
19
  if (position) script.dataset.position = position;
20
+ if (scheduleLabel) script.dataset.scheduleLabel = scheduleLabel;
20
21
  document.body.appendChild(script);
21
22
  }
22
23
  function AssistantChat(props) {
23
- const { app, botUrl, sessionUrl, label, position, children, className } = props;
24
- useEffect(() => loadWidget({ app, botUrl, sessionUrl, label, position }), [app, botUrl, sessionUrl, label, position]);
24
+ const { app, botUrl, sessionUrl, label, position, scheduleLabel, children, className } = props;
25
+ useEffect(
26
+ () => loadWidget({ app, botUrl, sessionUrl, label, position, scheduleLabel }),
27
+ [app, botUrl, sessionUrl, label, position, scheduleLabel]
28
+ );
25
29
  if (children === void 0 || children === null) return null;
26
30
  return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: openAssistant, children });
27
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@app-assistant/host",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Host the app-assistant writing bot in a JavaScript app: the contract's four endpoints, its pack and tokens on Web Request/Response, and the chat window for React.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/mikedutuandu/app-assistant/tree/main/sdk/js#readme",