@ai-matrx/chat 0.4.19 → 0.4.21

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.
@@ -20,7 +20,7 @@ type WithToolLookups = WithTools & {
20
20
  };
21
21
  export declare const fetchAvailableTools: import("@reduxjs/toolkit").AsyncThunk<{
22
22
  admin_only: boolean;
23
- annotations: import("../../../host/db-types.js").Json | null;
23
+ annotations: import("@ai-matrx/data/types").Json | null;
24
24
  category: string | null;
25
25
  created_at: string;
26
26
  created_by: string | null;
@@ -28,22 +28,22 @@ export declare const fetchAvailableTools: import("@reduxjs/toolkit").AsyncThunk<
28
28
  dedupe_exempt: boolean;
29
29
  deleted_at: string | null;
30
30
  description: string;
31
- gating: import("../../../host/db-types.js").Json;
31
+ gating: import("@ai-matrx/data/types").Json;
32
32
  icon: string | null;
33
33
  id: string;
34
34
  is_active: boolean;
35
35
  managed_by_server_id: string | null;
36
36
  max_client_wait_seconds: number | null;
37
- metadata: import("../../../host/db-types.js").Json;
37
+ metadata: import("@ai-matrx/data/types").Json;
38
38
  name: string;
39
39
  organization_id: string;
40
- output_schema: import("../../../host/db-types.js").Json | null;
41
- parameters: import("../../../host/db-types.js").Json;
40
+ output_schema: import("@ai-matrx/data/types").Json | null;
41
+ parameters: import("@ai-matrx/data/types").Json;
42
42
  published_to_web: boolean;
43
43
  published_to_web_at: string | null;
44
44
  published_to_web_by: string | null;
45
45
  semver: string | null;
46
- shown_to: import("../../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
46
+ shown_to: import("@ai-matrx/data/types").Database["platform"]["Enums"]["shown_to"] | null;
47
47
  side_effect_class: string | null;
48
48
  source_kind: string;
49
49
  tags: string[] | null;
@@ -55,7 +55,7 @@ export declare const fetchAvailableTools: import("@reduxjs/toolkit").AsyncThunk<
55
55
  updated_by_tier: string | null;
56
56
  validation_exempt: boolean;
57
57
  version: number;
58
- visibility: import("../../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
58
+ visibility: import("@ai-matrx/data/types").Database["platform"]["Enums"]["visibility"];
59
59
  }[], void, {
60
60
  dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>;
61
61
  extra?: unknown;
@@ -76,7 +76,7 @@ export declare const fetchAvailableTools: import("@reduxjs/toolkit").AsyncThunk<
76
76
  */
77
77
  export declare const fetchToolById: import("@reduxjs/toolkit").AsyncThunk<{
78
78
  admin_only: boolean;
79
- annotations: import("../../../host/db-types.js").Json | null;
79
+ annotations: import("@ai-matrx/data/types").Json | null;
80
80
  category: string | null;
81
81
  created_at: string;
82
82
  created_by: string | null;
@@ -84,22 +84,22 @@ export declare const fetchToolById: import("@reduxjs/toolkit").AsyncThunk<{
84
84
  dedupe_exempt: boolean;
85
85
  deleted_at: string | null;
86
86
  description: string;
87
- gating: import("../../../host/db-types.js").Json;
87
+ gating: import("@ai-matrx/data/types").Json;
88
88
  icon: string | null;
89
89
  id: string;
90
90
  is_active: boolean;
91
91
  managed_by_server_id: string | null;
92
92
  max_client_wait_seconds: number | null;
93
- metadata: import("../../../host/db-types.js").Json;
93
+ metadata: import("@ai-matrx/data/types").Json;
94
94
  name: string;
95
95
  organization_id: string;
96
- output_schema: import("../../../host/db-types.js").Json | null;
97
- parameters: import("../../../host/db-types.js").Json;
96
+ output_schema: import("@ai-matrx/data/types").Json | null;
97
+ parameters: import("@ai-matrx/data/types").Json;
98
98
  published_to_web: boolean;
99
99
  published_to_web_at: string | null;
100
100
  published_to_web_by: string | null;
101
101
  semver: string | null;
102
- shown_to: import("../../../host/db-types.js").Database["platform"]["Enums"]["shown_to"] | null;
102
+ shown_to: import("@ai-matrx/data/types").Database["platform"]["Enums"]["shown_to"] | null;
103
103
  side_effect_class: string | null;
104
104
  source_kind: string;
105
105
  tags: string[] | null;
@@ -111,7 +111,7 @@ export declare const fetchToolById: import("@reduxjs/toolkit").AsyncThunk<{
111
111
  updated_by_tier: string | null;
112
112
  validation_exempt: boolean;
113
113
  version: number;
114
- visibility: import("../../../host/db-types.js").Database["platform"]["Enums"]["visibility"];
114
+ visibility: import("@ai-matrx/data/types").Database["platform"]["Enums"]["visibility"];
115
115
  }, string, {
116
116
  dispatch?: import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>;
117
117
  extra?: unknown;
@@ -0,0 +1,31 @@
1
+ export interface CredentialCaptureField {
2
+ fieldKey: string;
3
+ label: string;
4
+ /** Mask the box (password-style). */
5
+ secret: boolean;
6
+ }
7
+ /** The card's spec. Field NAMES only — a value has no place to ride in on it. */
8
+ export interface CredentialCaptureSpec {
9
+ /** Stable id of this request (tool call id or handoff id); scopes input ids. */
10
+ id: string;
11
+ host: string;
12
+ displayName: string;
13
+ branch: "known" | "unknown";
14
+ /** Epoch ms after which the agent has moved on and no write may happen. */
15
+ expiresAtMs: number;
16
+ fields: CredentialCaptureField[];
17
+ }
18
+ export type CredentialCaptureSaveResult = {
19
+ ok: true;
20
+ } | {
21
+ ok: false;
22
+ message?: string;
23
+ };
24
+ export type CredentialCaptureDismissReason = "cancelled" | "expired";
25
+ export interface CredentialCaptureCardProps {
26
+ spec: CredentialCaptureSpec;
27
+ save: (values: Record<string, string>) => Promise<CredentialCaptureSaveResult>;
28
+ dismiss: (reason: CredentialCaptureDismissReason) => void | Promise<void>;
29
+ }
30
+ export declare function CredentialCaptureCard({ spec, save, dismiss }: CredentialCaptureCardProps): import("react").JSX.Element;
31
+ export default CredentialCaptureCard;
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { KeyRound, Loader2, ShieldCheck } from "lucide-react";
5
+ import { Input } from "@ai-matrx/design-system";
6
+ import { Button } from "@ai-matrx/design-system/controls";
7
+ import { AgentCardShell } from "./AgentCardShell.js";
8
+ function CredentialCaptureCard({ spec, save, dismiss }) {
9
+ const [values, setValues] = useState({});
10
+ const [busy, setBusy] = useState(false);
11
+ const [error, setError] = useState(null);
12
+ const [expired, setExpired] = useState(() => Date.now() >= spec.expiresAtMs);
13
+ const busyRef = useRef(false);
14
+ const dismissRef = useRef(dismiss);
15
+ dismissRef.current = dismiss;
16
+ useEffect(() => () => setValues({}), []);
17
+ useEffect(() => {
18
+ const ms = spec.expiresAtMs - Date.now();
19
+ if (ms <= 0) return;
20
+ const timer = setTimeout(() => {
21
+ setExpired(true);
22
+ if (busyRef.current) return;
23
+ setValues({});
24
+ void Promise.resolve(dismissRef.current("expired")).catch(() => void 0);
25
+ }, ms);
26
+ return () => clearTimeout(timer);
27
+ }, [spec.id, spec.expiresAtMs]);
28
+ const allFilled = spec.fields.every((f) => (values[f.fieldKey] ?? "").length > 0);
29
+ const onCancel = useCallback(async () => {
30
+ setValues({});
31
+ setBusy(true);
32
+ try {
33
+ await dismiss(expired ? "expired" : "cancelled");
34
+ } catch (cause) {
35
+ setError(cause instanceof Error ? cause.message : "Could not close this sign-in request.");
36
+ } finally {
37
+ setBusy(false);
38
+ }
39
+ }, [dismiss, expired]);
40
+ const onSave = useCallback(async () => {
41
+ if (busyRef.current) return;
42
+ if (expired || Date.now() >= spec.expiresAtMs) {
43
+ setExpired(true);
44
+ setValues({});
45
+ return;
46
+ }
47
+ busyRef.current = true;
48
+ setBusy(true);
49
+ setError(null);
50
+ const typed = {};
51
+ for (const f of spec.fields) typed[f.fieldKey] = values[f.fieldKey] ?? "";
52
+ let result;
53
+ try {
54
+ result = await save(typed);
55
+ } catch (cause) {
56
+ result = { ok: false, message: cause instanceof Error ? cause.message : void 0 };
57
+ }
58
+ setValues({});
59
+ busyRef.current = false;
60
+ setBusy(false);
61
+ if (result.ok) return;
62
+ if (Date.now() >= spec.expiresAtMs) {
63
+ setExpired(true);
64
+ void Promise.resolve(dismiss("expired")).catch(() => void 0);
65
+ return;
66
+ }
67
+ setError(result.message || "Could not save this sign-in. Try again or cancel.");
68
+ }, [dismiss, expired, save, spec, values]);
69
+ return /* @__PURE__ */ jsxs(
70
+ AgentCardShell,
71
+ {
72
+ tone: "warning",
73
+ icon: KeyRound,
74
+ eyebrow: "Sign-in needed",
75
+ title: `Save a login for ${spec.host}`,
76
+ titleInline: true,
77
+ "aria-label": `Save a login for ${spec.host}`,
78
+ badge: spec.branch === "known" ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs", children: [
79
+ /* @__PURE__ */ jsx(ShieldCheck, { className: "size-3" }),
80
+ " Known site"
81
+ ] }) : null,
82
+ footer: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2", children: [
83
+ /* @__PURE__ */ jsx(Button, { variant: "quiet", disabled: busy, onClick: () => void onCancel(), children: expired ? "Dismiss" : "Cancel" }),
84
+ /* @__PURE__ */ jsxs(
85
+ Button,
86
+ {
87
+ variant: "primary",
88
+ disabled: busy || expired || !allFilled,
89
+ onClick: () => void onSave(),
90
+ children: [
91
+ busy ? /* @__PURE__ */ jsx(Loader2, { className: "mr-1 size-3 animate-spin" }) : null,
92
+ "Save and continue"
93
+ ]
94
+ }
95
+ )
96
+ ] }),
97
+ children: [
98
+ /* @__PURE__ */ jsxs("p", { className: "mb-3 text-xs text-muted-foreground", children: [
99
+ "Your agent needs to sign in to",
100
+ " ",
101
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: spec.displayName }),
102
+ ". Enter it here; it goes to your vault and ",
103
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: "the agent never sees it" }),
104
+ "."
105
+ ] }),
106
+ /* @__PURE__ */ jsx("div", { className: "grid gap-2", children: spec.fields.map((field) => {
107
+ const inputId = `capture-${spec.id}-${field.fieldKey}`;
108
+ return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: "grid gap-1", children: [
109
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: field.label }),
110
+ /* @__PURE__ */ jsx(
111
+ Input,
112
+ {
113
+ id: inputId,
114
+ type: field.secret ? "password" : "text",
115
+ autoComplete: field.secret ? "new-password" : "off",
116
+ value: values[field.fieldKey] ?? "",
117
+ disabled: busy || expired,
118
+ className: "text-base",
119
+ onChange: (event) => {
120
+ const next = event.target.value;
121
+ setValues((prev) => ({ ...prev, [field.fieldKey]: next }));
122
+ }
123
+ }
124
+ )
125
+ ] }, field.fieldKey);
126
+ }) }),
127
+ expired ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "This request expired and your agent has moved on. Ask it to try the sign-in again." }) : null,
128
+ error ? /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-destructive", children: error }) : null
129
+ ]
130
+ }
131
+ );
132
+ }
133
+ var CredentialCaptureCard_default = CredentialCaptureCard;
134
+ export {
135
+ CredentialCaptureCard,
136
+ CredentialCaptureCard_default as default
137
+ };