@object-ui/plugin-chatbot 5.4.2 → 6.0.0
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/CHANGELOG.md +28 -0
- package/README.md +43 -0
- package/dist/index.js +1311 -581
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts +38 -0
- package/dist/packages/plugin-chatbot/src/AiPendingActionsInbox.d.ts.map +1 -0
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts +27 -0
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/index.d.ts +7 -1
- package/dist/packages/plugin-chatbot/src/index.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/mapMessages.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/useHitlInChat.d.ts +66 -0
- package/dist/packages/plugin-chatbot/src/useHitlInChat.d.ts.map +1 -0
- package/dist/packages/plugin-chatbot/src/usePendingActions.d.ts +120 -0
- package/dist/packages/plugin-chatbot/src/usePendingActions.d.ts.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export type PendingActionStatus = 'pending' | 'approved' | 'executed' | 'failed' | 'rejected';
|
|
9
|
+
/**
|
|
10
|
+
* Wire-format row returned by
|
|
11
|
+
* `GET /api/v1/ai/pending-actions` and friends. Mirrors the
|
|
12
|
+
* `ai_pending_action` object schema declared in
|
|
13
|
+
* `@objectstack/service-ai`.
|
|
14
|
+
*/
|
|
15
|
+
export interface PendingActionRow {
|
|
16
|
+
id: string;
|
|
17
|
+
conversation_id?: string | null;
|
|
18
|
+
message_id?: string | null;
|
|
19
|
+
object_name: string;
|
|
20
|
+
action_name: string;
|
|
21
|
+
tool_name: string;
|
|
22
|
+
/** JSON-encoded string. Consumers typically `JSON.parse` to render. */
|
|
23
|
+
tool_input: string;
|
|
24
|
+
status: PendingActionStatus | string;
|
|
25
|
+
result?: string | null;
|
|
26
|
+
error?: string | null;
|
|
27
|
+
rejection_reason?: string | null;
|
|
28
|
+
proposed_by?: string | null;
|
|
29
|
+
decided_by?: string | null;
|
|
30
|
+
proposed_at?: string;
|
|
31
|
+
decided_at?: string | null;
|
|
32
|
+
created_at?: string;
|
|
33
|
+
updated_at?: string;
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Successful approval outcome returned by
|
|
38
|
+
* `POST /api/v1/ai/pending-actions/:id/approve`.
|
|
39
|
+
*
|
|
40
|
+
* The HTTP status is 200 when `status === 'executed'` and 500 when the
|
|
41
|
+
* downstream dispatcher failed (`status === 'failed'`). The hook surfaces
|
|
42
|
+
* both as a normal resolved value so the UI can show the error inline
|
|
43
|
+
* without throwing.
|
|
44
|
+
*/
|
|
45
|
+
export interface ApproveOutcome {
|
|
46
|
+
id: string;
|
|
47
|
+
status: 'executed' | 'failed' | string;
|
|
48
|
+
result?: unknown;
|
|
49
|
+
error?: string;
|
|
50
|
+
[k: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
export interface RejectOutcome {
|
|
53
|
+
id: string;
|
|
54
|
+
status: 'rejected' | string;
|
|
55
|
+
}
|
|
56
|
+
export interface UsePendingActionsOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Base URL of the AI service, e.g. `http://localhost:3000/api/v1/ai`.
|
|
59
|
+
* Falls back to `/api/v1/ai` (same-origin) when unset.
|
|
60
|
+
*/
|
|
61
|
+
apiBase?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Status filter forwarded as `?status=` to the list endpoint. Set to
|
|
64
|
+
* `'all'` (or undefined) to fetch every row.
|
|
65
|
+
*/
|
|
66
|
+
status?: PendingActionStatus | 'all';
|
|
67
|
+
/**
|
|
68
|
+
* Conversation filter forwarded as `?conversationId=`. Useful for
|
|
69
|
+
* scoping the inbox to a specific chat thread.
|
|
70
|
+
*/
|
|
71
|
+
conversationId?: string;
|
|
72
|
+
/** Hard limit forwarded as `?limit=`. */
|
|
73
|
+
limit?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Extra headers merged into every request (e.g. `X-Environment-Id`,
|
|
76
|
+
* `Authorization`). Cookies are always sent via `credentials: 'include'`.
|
|
77
|
+
*/
|
|
78
|
+
headers?: Record<string, string>;
|
|
79
|
+
/**
|
|
80
|
+
* Polling interval in ms. `0` disables polling (caller must invoke
|
|
81
|
+
* `refresh()` manually). Default: 5000.
|
|
82
|
+
*/
|
|
83
|
+
pollInterval?: number;
|
|
84
|
+
/** Disable the hook entirely (skips initial fetch + polling). */
|
|
85
|
+
enabled?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface UsePendingActionsReturn {
|
|
88
|
+
items: PendingActionRow[];
|
|
89
|
+
total: number;
|
|
90
|
+
isLoading: boolean;
|
|
91
|
+
error: Error | undefined;
|
|
92
|
+
/** Re-fetch the list. Awaitable. */
|
|
93
|
+
refresh: () => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Approve a row. Resolves with the dispatcher outcome (success or
|
|
96
|
+
* failed). Re-fetches the list on completion. Throws on transport,
|
|
97
|
+
* 404, or 409 errors.
|
|
98
|
+
*/
|
|
99
|
+
approve: (id: string) => Promise<ApproveOutcome>;
|
|
100
|
+
/**
|
|
101
|
+
* Reject a row with an optional reason. Re-fetches the list on
|
|
102
|
+
* completion. Throws on transport, 404, or 409 errors.
|
|
103
|
+
*/
|
|
104
|
+
reject: (id: string, reason?: string) => Promise<RejectOutcome>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Hook that drives the HITL pending-actions inbox.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* const { items, isLoading, error, approve, reject, refresh } =
|
|
112
|
+
* usePendingActions({
|
|
113
|
+
* apiBase: 'http://localhost:3004/api/v1/ai',
|
|
114
|
+
* status: 'pending',
|
|
115
|
+
* headers: { 'X-Environment-Id': 'env_local' },
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function usePendingActions(options?: UsePendingActionsOptions): UsePendingActionsReturn;
|
|
120
|
+
//# sourceMappingURL=usePendingActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePendingActions.d.ts","sourceRoot":"","sources":["../../../../src/usePendingActions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,CAAC;AAEf;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC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C;IACjD;;;OAGG;IACH,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CACjE;AAgDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAiFzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-chatbot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Chatbot interface plugin for Object UI",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"shiki": "^4.0.2",
|
|
39
39
|
"streamdown": "^1.4.1",
|
|
40
40
|
"use-stick-to-bottom": "^1.1.1",
|
|
41
|
-
"@object-ui/
|
|
42
|
-
"@object-ui/
|
|
43
|
-
"@object-ui/react": "
|
|
44
|
-
"@object-ui/types": "
|
|
41
|
+
"@object-ui/core": "6.0.0",
|
|
42
|
+
"@object-ui/components": "6.0.0",
|
|
43
|
+
"@object-ui/react": "6.0.0",
|
|
44
|
+
"@object-ui/types": "6.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|