@strand-js/react 0.1.2 → 0.1.4

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/dist/index.d.mts CHANGED
@@ -11,7 +11,7 @@ declare function StrandProvider({ client, children }: StrandProviderProps): reac
11
11
  interface ConversationOptions {
12
12
  system?: string;
13
13
  tools?: ToolDefinition[];
14
- onToolCall?: (name: string, args: Record<string, unknown>, output: unknown) => void;
14
+ onToolResult?: (name: string, args: Record<string, unknown>, output: unknown) => void;
15
15
  context?: Record<string, unknown>;
16
16
  sessionId?: string;
17
17
  onFinish?: (message: Message) => void;
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare function StrandProvider({ client, children }: StrandProviderProps): reac
11
11
  interface ConversationOptions {
12
12
  system?: string;
13
13
  tools?: ToolDefinition[];
14
- onToolCall?: (name: string, args: Record<string, unknown>, output: unknown) => void;
14
+ onToolResult?: (name: string, args: Record<string, unknown>, output: unknown) => void;
15
15
  context?: Record<string, unknown>;
16
16
  sessionId?: string;
17
17
  onFinish?: (message: Message) => void;
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ function useConversation(options = {}) {
72
72
  });
73
73
  const abortRef = (0, import_react2.useRef)(null);
74
74
  const send = (0, import_react2.useCallback)((content) => {
75
- const { context, onFinish, onError, onToolCall } = optionsRef.current;
75
+ const { context, onFinish, onError, onToolResult } = optionsRef.current;
76
76
  machine.addUserMessage(content);
77
77
  machine.transition("submitting");
78
78
  const abort = new AbortController();
@@ -86,9 +86,9 @@ function useConversation(options = {}) {
86
86
  for await (const event of generator) {
87
87
  if (abort.signal.aborted) break;
88
88
  (0, import_core2.processWireEvent)(event, machine, toolStore);
89
- if (event.type === "strand:tool-result" && onToolCall) {
89
+ if (event.type === "strand:tool-result" && onToolResult) {
90
90
  const tc = machine.session.messages.flatMap((m) => m.toolCalls ?? []).find((t) => t.id === event.toolCallId);
91
- if (tc) onToolCall(tc.name, tc.input, event.result);
91
+ if (tc) onToolResult(tc.name, tc.input, event.result);
92
92
  }
93
93
  }
94
94
  if (abort.signal.aborted) {
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ function useConversation(options = {}) {
42
42
  });
43
43
  const abortRef = useRef(null);
44
44
  const send = useCallback((content) => {
45
- const { context, onFinish, onError, onToolCall } = optionsRef.current;
45
+ const { context, onFinish, onError, onToolResult } = optionsRef.current;
46
46
  machine.addUserMessage(content);
47
47
  machine.transition("submitting");
48
48
  const abort = new AbortController();
@@ -56,9 +56,9 @@ function useConversation(options = {}) {
56
56
  for await (const event of generator) {
57
57
  if (abort.signal.aborted) break;
58
58
  processWireEvent(event, machine, toolStore);
59
- if (event.type === "strand:tool-result" && onToolCall) {
59
+ if (event.type === "strand:tool-result" && onToolResult) {
60
60
  const tc = machine.session.messages.flatMap((m) => m.toolCalls ?? []).find((t) => t.id === event.toolCallId);
61
- if (tc) onToolCall(tc.name, tc.input, event.result);
61
+ if (tc) onToolResult(tc.name, tc.input, event.result);
62
62
  }
63
63
  }
64
64
  if (abort.signal.aborted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strand-js/react",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "description": "React hooks for Strand — useConversation, useToolCall, useAgentSession, useStreamingText",
6
6
  "main": "./dist/index.js",
@@ -16,15 +16,8 @@
16
16
  "files": [
17
17
  "dist"
18
18
  ],
19
- "scripts": {
20
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
21
- "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
22
- "typecheck": "tsc --noEmit",
23
- "test": "vitest run",
24
- "lint": "eslint src"
25
- },
26
19
  "dependencies": {
27
- "@strand-js/core": "workspace:*"
20
+ "@strand-js/core": "0.1.4"
28
21
  },
29
22
  "peerDependencies": {
30
23
  "react": "^18.0.0",
@@ -43,5 +36,12 @@
43
36
  },
44
37
  "publishConfig": {
45
38
  "access": "public"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
42
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
43
+ "typecheck": "tsc --noEmit",
44
+ "test": "vitest run",
45
+ "lint": "eslint src"
46
46
  }
47
- }
47
+ }