@stigmer/react 3.1.8 → 3.1.9
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/environment/EnvironmentPicker.d.ts +17 -1
- package/environment/EnvironmentPicker.d.ts.map +1 -1
- package/environment/EnvironmentPicker.js +3 -2
- package/environment/EnvironmentPicker.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/sharing/ShareAgentDialog.d.ts +10 -8
- package/sharing/ShareAgentDialog.d.ts.map +1 -1
- package/sharing/ShareAgentDialog.js +139 -54
- package/sharing/ShareAgentDialog.js.map +1 -1
- package/sharing/SharedAgentChat.d.ts +1 -1
- package/sharing/SharedAgentChat.d.ts.map +1 -1
- package/sharing/index.d.ts +4 -2
- package/sharing/index.d.ts.map +1 -1
- package/sharing/index.js +2 -1
- package/sharing/index.js.map +1 -1
- package/sharing/useAgentShare.d.ts +43 -0
- package/sharing/useAgentShare.d.ts.map +1 -0
- package/sharing/useAgentShare.js +54 -0
- package/sharing/useAgentShare.js.map +1 -0
- package/sharing/useRotateShareLink.d.ts +22 -19
- package/sharing/useRotateShareLink.d.ts.map +1 -1
- package/sharing/useRotateShareLink.js +22 -19
- package/sharing/useRotateShareLink.js.map +1 -1
- package/sharing/useSaveAgentShare.d.ts +105 -0
- package/sharing/useSaveAgentShare.d.ts.map +1 -0
- package/sharing/useSaveAgentShare.js +97 -0
- package/sharing/useSaveAgentShare.js.map +1 -0
- package/sharing/useShareAgent.d.ts +5 -4
- package/sharing/useShareAgent.d.ts.map +1 -1
- package/sharing/useShareAgent.js +5 -4
- package/sharing/useShareAgent.js.map +1 -1
- package/sharing/useShareToolReadiness.d.ts +29 -25
- package/sharing/useShareToolReadiness.d.ts.map +1 -1
- package/sharing/useShareToolReadiness.js +47 -51
- package/sharing/useShareToolReadiness.js.map +1 -1
- package/sharing/useSharedAgentProfile.d.ts +5 -4
- package/sharing/useSharedAgentProfile.d.ts.map +1 -1
- package/sharing/useSharedAgentProfile.js +6 -5
- package/sharing/useSharedAgentProfile.js.map +1 -1
- package/src/environment/EnvironmentPicker.tsx +23 -2
- package/src/index.ts +8 -4
- package/src/sharing/ShareAgentDialog.tsx +353 -119
- package/src/sharing/SharedAgentChat.tsx +1 -1
- package/src/sharing/__tests__/ShareAgentDialog.test.tsx +550 -369
- package/src/sharing/__tests__/useAgentShare.test.tsx +149 -0
- package/src/sharing/__tests__/useRotateShareLink.test.tsx +8 -8
- package/src/sharing/__tests__/useSaveAgentShare.test.tsx +241 -0
- package/src/sharing/__tests__/useShareAgent.test.tsx +6 -2
- package/src/sharing/__tests__/useShareToolReadiness.test.tsx +84 -47
- package/src/sharing/__tests__/useSharedAgentProfile.test.tsx +1 -1
- package/src/sharing/index.ts +9 -7
- package/src/sharing/useAgentShare.ts +91 -0
- package/src/sharing/useRotateShareLink.ts +30 -25
- package/src/sharing/useSaveAgentShare.ts +186 -0
- package/src/sharing/useShareAgent.tsx +5 -4
- package/src/sharing/useShareToolReadiness.ts +62 -60
- package/src/sharing/useSharedAgentProfile.ts +7 -6
- package/src/switch/Switch.tsx +6 -1
- package/src/switch/__tests__/Switch.test.tsx +19 -0
- package/switch/Switch.d.ts.map +1 -1
- package/switch/Switch.js +6 -1
- package/switch/Switch.js.map +1 -1
- package/sharing/useUpdateAgentSharing.d.ts +0 -86
- package/sharing/useUpdateAgentSharing.d.ts.map +0 -1
- package/sharing/useUpdateAgentSharing.js +0 -81
- package/sharing/useUpdateAgentSharing.js.map +0 -1
- package/src/sharing/__tests__/useUpdateAgentSharing.test.tsx +0 -200
- package/src/sharing/useUpdateAgentSharing.ts +0 -151
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentShare } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/api_pb";
|
|
2
2
|
/** Return value of {@link useRotateShareLink}. */
|
|
3
3
|
export interface UseRotateShareLinkReturn {
|
|
4
4
|
/**
|
|
5
|
-
* Rotate the
|
|
6
|
-
* Resolves with the updated
|
|
5
|
+
* Rotate the share's link token via the `rotateShareLink` RPC.
|
|
6
|
+
* Resolves with the updated share, whose `status.shareLinkToken`
|
|
7
7
|
* carries the new token for building the fresh share URL.
|
|
8
8
|
*/
|
|
9
|
-
readonly rotateShareLink: () => Promise<
|
|
9
|
+
readonly rotateShareLink: () => Promise<AgentShare | undefined>;
|
|
10
10
|
/** `true` while the RPC is in flight. */
|
|
11
11
|
readonly isPending: boolean;
|
|
12
12
|
/** The last error from the RPC, or `null`. */
|
|
13
13
|
readonly error: Error | null;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Behavior hook that rotates
|
|
16
|
+
* Behavior hook that rotates a share's link token.
|
|
17
17
|
*
|
|
18
|
-
* Wraps the `stigmer.
|
|
19
|
-
* `can_edit`) with loading and error state management. The
|
|
20
|
-
* generates the token — there is nothing to supply — and the
|
|
21
|
-
* link stops working the moment the call resolves, including
|
|
22
|
-
* visitors mid-conversation. The token lives in
|
|
23
|
-
* (server-owned
|
|
24
|
-
*
|
|
18
|
+
* Wraps the `stigmer.agentShare.rotateShareLink()` RPC (authorized by
|
|
19
|
+
* the share's `can_edit`) with loading and error state management. The
|
|
20
|
+
* server generates the token — there is nothing to supply — and the
|
|
21
|
+
* previous link stops working the moment the call resolves, including
|
|
22
|
+
* for visitors mid-conversation. The token lives in
|
|
23
|
+
* `status.shareLinkToken` (server-owned; this RPC is its sole writer),
|
|
24
|
+
* so it is never part of a share draft and survives every apply.
|
|
25
25
|
*
|
|
26
|
-
* The hook is stateless with respect to the
|
|
27
|
-
*
|
|
28
|
-
* {@link
|
|
26
|
+
* The hook is stateless with respect to the share — adopt the returned
|
|
27
|
+
* share (or refetch) so the UI shows the new tokened link, matching the
|
|
28
|
+
* {@link useSaveAgentShare} convention.
|
|
29
29
|
*
|
|
30
|
-
* Pass `null` for `
|
|
31
|
-
*
|
|
30
|
+
* Pass `null` for `shareId` to produce a stable no-op (useful while the
|
|
31
|
+
* share is still loading, or before the agent has ever been shared —
|
|
32
|
+
* there is no token to rotate until a share exists).
|
|
32
33
|
*
|
|
33
34
|
* @example
|
|
34
35
|
* ```tsx
|
|
35
|
-
* const { rotateShareLink, isPending } = useRotateShareLink(
|
|
36
|
+
* const { rotateShareLink, isPending } = useRotateShareLink(
|
|
37
|
+
* share?.metadata?.id ?? null,
|
|
38
|
+
* );
|
|
36
39
|
*
|
|
37
40
|
* const updated = await rotateShareLink();
|
|
38
41
|
* // updated.status.shareLinkToken is the new token
|
|
39
42
|
* ```
|
|
40
43
|
*/
|
|
41
|
-
export declare function useRotateShareLink(
|
|
44
|
+
export declare function useRotateShareLink(shareId: string | null): UseRotateShareLinkReturn;
|
|
42
45
|
//# sourceMappingURL=useRotateShareLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRotateShareLink.d.ts","sourceRoot":"","sources":["../../src/sharing/useRotateShareLink.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useRotateShareLink.d.ts","sourceRoot":"","sources":["../../src/sharing/useRotateShareLink.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AAK1F,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAChE,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,wBAAwB,CA0B1B"}
|
|
@@ -1,46 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback, useState } from "react";
|
|
3
3
|
import { create } from "@bufbuild/protobuf";
|
|
4
|
-
import { RotateShareLinkInputSchema } from "@stigmer/protos/ai/stigmer/agentic/
|
|
4
|
+
import { RotateShareLinkInputSchema } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/io_pb";
|
|
5
5
|
import { useStigmer } from "../hooks.js";
|
|
6
6
|
import { toError } from "../internal/toError.js";
|
|
7
7
|
/**
|
|
8
|
-
* Behavior hook that rotates
|
|
8
|
+
* Behavior hook that rotates a share's link token.
|
|
9
9
|
*
|
|
10
|
-
* Wraps the `stigmer.
|
|
11
|
-
* `can_edit`) with loading and error state management. The
|
|
12
|
-
* generates the token — there is nothing to supply — and the
|
|
13
|
-
* link stops working the moment the call resolves, including
|
|
14
|
-
* visitors mid-conversation. The token lives in
|
|
15
|
-
* (server-owned
|
|
16
|
-
*
|
|
10
|
+
* Wraps the `stigmer.agentShare.rotateShareLink()` RPC (authorized by
|
|
11
|
+
* the share's `can_edit`) with loading and error state management. The
|
|
12
|
+
* server generates the token — there is nothing to supply — and the
|
|
13
|
+
* previous link stops working the moment the call resolves, including
|
|
14
|
+
* for visitors mid-conversation. The token lives in
|
|
15
|
+
* `status.shareLinkToken` (server-owned; this RPC is its sole writer),
|
|
16
|
+
* so it is never part of a share draft and survives every apply.
|
|
17
17
|
*
|
|
18
|
-
* The hook is stateless with respect to the
|
|
19
|
-
*
|
|
20
|
-
* {@link
|
|
18
|
+
* The hook is stateless with respect to the share — adopt the returned
|
|
19
|
+
* share (or refetch) so the UI shows the new tokened link, matching the
|
|
20
|
+
* {@link useSaveAgentShare} convention.
|
|
21
21
|
*
|
|
22
|
-
* Pass `null` for `
|
|
23
|
-
*
|
|
22
|
+
* Pass `null` for `shareId` to produce a stable no-op (useful while the
|
|
23
|
+
* share is still loading, or before the agent has ever been shared —
|
|
24
|
+
* there is no token to rotate until a share exists).
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* ```tsx
|
|
27
|
-
* const { rotateShareLink, isPending } = useRotateShareLink(
|
|
28
|
+
* const { rotateShareLink, isPending } = useRotateShareLink(
|
|
29
|
+
* share?.metadata?.id ?? null,
|
|
30
|
+
* );
|
|
28
31
|
*
|
|
29
32
|
* const updated = await rotateShareLink();
|
|
30
33
|
* // updated.status.shareLinkToken is the new token
|
|
31
34
|
* ```
|
|
32
35
|
*/
|
|
33
|
-
export function useRotateShareLink(
|
|
36
|
+
export function useRotateShareLink(shareId) {
|
|
34
37
|
const stigmer = useStigmer();
|
|
35
38
|
const [isPending, setIsPending] = useState(false);
|
|
36
39
|
const [error, setError] = useState(null);
|
|
37
40
|
const rotateShareLink = useCallback(async () => {
|
|
38
|
-
if (!
|
|
41
|
+
if (!shareId)
|
|
39
42
|
return undefined;
|
|
40
43
|
setIsPending(true);
|
|
41
44
|
setError(null);
|
|
42
45
|
try {
|
|
43
|
-
return await stigmer.
|
|
46
|
+
return await stigmer.agentShare.rotateShareLink(create(RotateShareLinkInputSchema, { resourceId: shareId }));
|
|
44
47
|
}
|
|
45
48
|
catch (err) {
|
|
46
49
|
setError(toError(err));
|
|
@@ -49,7 +52,7 @@ export function useRotateShareLink(agentId) {
|
|
|
49
52
|
finally {
|
|
50
53
|
setIsPending(false);
|
|
51
54
|
}
|
|
52
|
-
}, [
|
|
55
|
+
}, [shareId, stigmer]);
|
|
53
56
|
return { rotateShareLink, isPending, error };
|
|
54
57
|
}
|
|
55
58
|
//# sourceMappingURL=useRotateShareLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRotateShareLink.js","sourceRoot":"","sources":["../../src/sharing/useRotateShareLink.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,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AO,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvB,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
2
|
+
import type { AgentShare } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/api_pb";
|
|
3
|
+
import { AgentShareAudience } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/spec_pb";
|
|
4
|
+
import type { ResourceRef } from "@stigmer/sdk";
|
|
5
|
+
/**
|
|
6
|
+
* Who can chat with a shared agent over its hosted link.
|
|
7
|
+
*
|
|
8
|
+
* - `"public"` — anyone with the link; visitors are anonymous guests.
|
|
9
|
+
* - `"org"` — signed-in members of the owning organization only.
|
|
10
|
+
* Membership is checked on every conversation turn, so access ends the
|
|
11
|
+
* moment a member leaves the org.
|
|
12
|
+
*/
|
|
13
|
+
export type SharingAudience = "public" | "org";
|
|
14
|
+
/**
|
|
15
|
+
* A complete share configuration to persist.
|
|
16
|
+
*
|
|
17
|
+
* Every field is required by design: saving **replaces the share's whole
|
|
18
|
+
* spec**, so a caller must always supply the full configuration. A
|
|
19
|
+
* partial type here would let a toggle change silently wipe
|
|
20
|
+
* `allowedOrigins`, `messages`, `environmentRefs`, or the `audience` —
|
|
21
|
+
* the required shape makes that mistake unrepresentable. (The rotatable
|
|
22
|
+
* link token is exempt: it is server-owned `status`, which survives
|
|
23
|
+
* every save verbatim.)
|
|
24
|
+
*/
|
|
25
|
+
export interface AgentShareDraft {
|
|
26
|
+
/** Whether hosted-chat access for the configured audience is enabled. */
|
|
27
|
+
readonly enabled: boolean;
|
|
28
|
+
/** Who can chat: anyone with the link, or org members only. */
|
|
29
|
+
readonly audience: SharingAudience;
|
|
30
|
+
/**
|
|
31
|
+
* Exact web origins allowed to embed the shared agent
|
|
32
|
+
* (e.g. `https://example.com`). Empty list = embeddable anywhere.
|
|
33
|
+
* Embedding is public-audience only.
|
|
34
|
+
*/
|
|
35
|
+
readonly allowedOrigins: readonly string[];
|
|
36
|
+
/** Owner-customized visitor refusal copy. Empty strings mean platform defaults. */
|
|
37
|
+
readonly messages: {
|
|
38
|
+
/** Shown when a visitor exceeds the message rate limit. */
|
|
39
|
+
readonly rateLimited: string;
|
|
40
|
+
/** Shown when the org's credits are exhausted (sharing fails closed). */
|
|
41
|
+
readonly unavailable: string;
|
|
42
|
+
/** Shown when a conversation hits its turn limit or inactivity timeout. */
|
|
43
|
+
readonly conversationEnded: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Org-shared environments whose values guest conversations receive —
|
|
47
|
+
* how a tool-using agent becomes chattable over a share link without
|
|
48
|
+
* touching its pristine default instance. Public-audience only (the
|
|
49
|
+
* proto CEL rule rejects bindings on org-audience shares, whose member
|
|
50
|
+
* sessions carry no share linkage in Phase A — decision 011 addendum).
|
|
51
|
+
*/
|
|
52
|
+
readonly environmentRefs: readonly ResourceRef[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Maps a proto {@link AgentShareAudience} to the SDK's string union.
|
|
56
|
+
* Unspecified means public by contract (a share created without an
|
|
57
|
+
* explicit audience is an anyone-with-link share).
|
|
58
|
+
*/
|
|
59
|
+
export declare function sharingAudienceFromProto(audience: AgentShareAudience | undefined): SharingAudience;
|
|
60
|
+
/** Return value of {@link useSaveAgentShare}. */
|
|
61
|
+
export interface UseSaveAgentShareReturn {
|
|
62
|
+
/**
|
|
63
|
+
* Persist the complete share configuration. Resolves with the
|
|
64
|
+
* persisted {@link AgentShare} — adopt it as the new baseline (its
|
|
65
|
+
* `status.shareLinkToken` carries the live link token).
|
|
66
|
+
*
|
|
67
|
+
* `current` is the share being edited, or `null` when the agent has
|
|
68
|
+
* never been shared — the save then creates the canonical share.
|
|
69
|
+
*/
|
|
70
|
+
readonly save: (draft: AgentShareDraft, current: AgentShare | null) => Promise<AgentShare | undefined>;
|
|
71
|
+
/** `true` while the RPC is in flight. */
|
|
72
|
+
readonly isPending: boolean;
|
|
73
|
+
/** The last error from the RPC, or `null`. */
|
|
74
|
+
readonly error: Error | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Behavior hook that persists an agent's canonical share configuration.
|
|
78
|
+
*
|
|
79
|
+
* Commits via `stigmer.agentShare.apply()` — an idempotent upsert keyed
|
|
80
|
+
* on the share's `(org, slug)` identity — so one code path serves both
|
|
81
|
+
* the first enable (creates the share; the server authorizes on the
|
|
82
|
+
* referenced agent's `can_edit`) and every later edit. There is
|
|
83
|
+
* deliberately no create/update branching: the share slug is unique per
|
|
84
|
+
* org and defaults to the agent's slug, which makes apply-by-identity
|
|
85
|
+
* exact, and the generated `AgentShareInput` carries no `metadata.id`
|
|
86
|
+
* for an update to route by anyway.
|
|
87
|
+
*
|
|
88
|
+
* Disabling is a save with `enabled: false` — a config-preserving pause
|
|
89
|
+
* (decision 011 D1). Deleting the share is a separate, destructive
|
|
90
|
+
* operation this hook does not perform.
|
|
91
|
+
*
|
|
92
|
+
* Pass `null` for `agent` to produce a stable no-op (useful while the
|
|
93
|
+
* agent is still loading).
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* const { share } = useAgentShare(agent);
|
|
98
|
+
* const { save, isPending } = useSaveAgentShare(agent);
|
|
99
|
+
*
|
|
100
|
+
* const persisted = await save({ ...draft, enabled: true }, share);
|
|
101
|
+
* // persisted.status.shareLinkToken is the live link token
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function useSaveAgentShare(agent: Agent | null): UseSaveAgentShareReturn;
|
|
105
|
+
//# sourceMappingURL=useSaveAgentShare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSaveAgentShare.d.ts","sourceRoot":"","sources":["../../src/sharing/useSaveAgentShare.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EA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AK,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,GAAG,IAAI,GAClB,uBAAuB,CAyDzB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { AgentShareAudience } from "@stigmer/protos/ai/stigmer/agentic/agentshare/v1/spec_pb";
|
|
4
|
+
import { useStigmer } from "../hooks.js";
|
|
5
|
+
import { toError } from "../internal/toError.js";
|
|
6
|
+
/**
|
|
7
|
+
* Maps a proto {@link AgentShareAudience} to the SDK's string union.
|
|
8
|
+
* Unspecified means public by contract (a share created without an
|
|
9
|
+
* explicit audience is an anyone-with-link share).
|
|
10
|
+
*/
|
|
11
|
+
export function sharingAudienceFromProto(audience) {
|
|
12
|
+
return audience === AgentShareAudience.org ? "org" : "public";
|
|
13
|
+
}
|
|
14
|
+
function sharingAudienceToProto(audience) {
|
|
15
|
+
return audience === "org"
|
|
16
|
+
? AgentShareAudience.org
|
|
17
|
+
: AgentShareAudience.public;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Behavior hook that persists an agent's canonical share configuration.
|
|
21
|
+
*
|
|
22
|
+
* Commits via `stigmer.agentShare.apply()` — an idempotent upsert keyed
|
|
23
|
+
* on the share's `(org, slug)` identity — so one code path serves both
|
|
24
|
+
* the first enable (creates the share; the server authorizes on the
|
|
25
|
+
* referenced agent's `can_edit`) and every later edit. There is
|
|
26
|
+
* deliberately no create/update branching: the share slug is unique per
|
|
27
|
+
* org and defaults to the agent's slug, which makes apply-by-identity
|
|
28
|
+
* exact, and the generated `AgentShareInput` carries no `metadata.id`
|
|
29
|
+
* for an update to route by anyway.
|
|
30
|
+
*
|
|
31
|
+
* Disabling is a save with `enabled: false` — a config-preserving pause
|
|
32
|
+
* (decision 011 D1). Deleting the share is a separate, destructive
|
|
33
|
+
* operation this hook does not perform.
|
|
34
|
+
*
|
|
35
|
+
* Pass `null` for `agent` to produce a stable no-op (useful while the
|
|
36
|
+
* agent is still loading).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const { share } = useAgentShare(agent);
|
|
41
|
+
* const { save, isPending } = useSaveAgentShare(agent);
|
|
42
|
+
*
|
|
43
|
+
* const persisted = await save({ ...draft, enabled: true }, share);
|
|
44
|
+
* // persisted.status.shareLinkToken is the live link token
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function useSaveAgentShare(agent) {
|
|
48
|
+
const stigmer = useStigmer();
|
|
49
|
+
const [isPending, setIsPending] = useState(false);
|
|
50
|
+
const [error, setError] = useState(null);
|
|
51
|
+
const agentOrg = agent?.metadata?.org ?? "";
|
|
52
|
+
const agentSlug = agent?.metadata?.slug ?? "";
|
|
53
|
+
const agentName = agent?.metadata?.name ?? "";
|
|
54
|
+
const save = useCallback(async (draft, current) => {
|
|
55
|
+
if (!agentOrg || !agentSlug)
|
|
56
|
+
return undefined;
|
|
57
|
+
setIsPending(true);
|
|
58
|
+
setError(null);
|
|
59
|
+
try {
|
|
60
|
+
return await stigmer.agentShare.apply({
|
|
61
|
+
// Identity: the existing share's org/slug when editing (a
|
|
62
|
+
// manifest-created share may carry a non-default slug — apply
|
|
63
|
+
// with the agent's slug would create a SECOND share), the
|
|
64
|
+
// agent's when creating (the server's own D2 default, made
|
|
65
|
+
// explicit).
|
|
66
|
+
org: current?.metadata?.org || agentOrg,
|
|
67
|
+
slug: current?.metadata?.slug || agentSlug,
|
|
68
|
+
name: current?.metadata?.name || agentName || agentSlug,
|
|
69
|
+
agentRef: { org: agentOrg, slug: agentSlug },
|
|
70
|
+
enabled: draft.enabled,
|
|
71
|
+
// Written as the explicit enum value, never left unspecified —
|
|
72
|
+
// a share persisted as "public" can't be silently downgraded
|
|
73
|
+
// by tooling that relies on the unspecified-means-public rule.
|
|
74
|
+
audience: sharingAudienceToProto(draft.audience),
|
|
75
|
+
allowedOrigins: [...draft.allowedOrigins],
|
|
76
|
+
messages: {
|
|
77
|
+
rateLimited: draft.messages.rateLimited,
|
|
78
|
+
unavailable: draft.messages.unavailable,
|
|
79
|
+
conversationEnded: draft.messages.conversationEnded,
|
|
80
|
+
},
|
|
81
|
+
environmentRefs: draft.environmentRefs.map((ref) => ({
|
|
82
|
+
org: ref.org,
|
|
83
|
+
slug: ref.slug,
|
|
84
|
+
})),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
setError(toError(err));
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
setIsPending(false);
|
|
93
|
+
}
|
|
94
|
+
}, [agentOrg, agentSlug, agentName, stigmer]);
|
|
95
|
+
return { save, isPending, error };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=useSaveAgentShare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSaveAgentShare.js","sourceRoot":"","sources":["../../src/sharing/useSaveAgentShare.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0DAA0D,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAqDjD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAwC;IAExC,OAAO,QAAQ,KAAK,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAyB;IACvD,OAAO,QAAQ,KAAK,KAAK;QACvB,CAAC,CAAC,kBAAkB,CAAC,GAAG;QACxB,CAAC,CAAC,kBAAkB,C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gBACtB,+DAA+D;gBAC/D,6DAA6D;gBAC7D,+DAA+D;gBAC/D,QAAQ,EAAE,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAChD,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC;gBACzC,QAAQ,EAAE;oBACR,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;oBACvC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;oBACvC,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,iBAAiB;iBACpD;gBACD,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBACnD,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,IAAI,EAAE,GAAG,CAAC,IAAI;iBACf,CAAC,CAAC;aACJ,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAC1C,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -47,10 +47,11 @@ export interface UseShareAgentReturn {
|
|
|
47
47
|
* the running agent (billed to the owning org).
|
|
48
48
|
*
|
|
49
49
|
* Owns the open-state and the `can_edit` gate — the same permission the
|
|
50
|
-
*
|
|
51
|
-
* whose changes would be rejected.
|
|
52
|
-
* agent is loading or the user cannot
|
|
53
|
-
* unconditionally fold `action` into its actions
|
|
50
|
+
* AgentShare create/apply handlers enforce on the referenced agent, so
|
|
51
|
+
* the action never appears to a user whose changes would be rejected.
|
|
52
|
+
* Returns a `null` action while the agent is loading or the user cannot
|
|
53
|
+
* edit, so the host can unconditionally fold `action` into its actions
|
|
54
|
+
* array.
|
|
54
55
|
*
|
|
55
56
|
* @example
|
|
56
57
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShareAgent.d.ts","sourceRoot":"","sources":["../../src/sharing/useShareAgent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,wCAAwC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED
|
|
1
|
+
{"version":3,"file":"useShareAgent.d.ts","sourceRoot":"","sources":["../../src/sharing/useShareAgent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,wCAAwC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,KAAe,GAChB,EAAE,iBAAiB,GAAG,mBAAmB,CA2BzC"}
|
package/sharing/useShareAgent.js
CHANGED
|
@@ -10,10 +10,11 @@ import { ShareAgentDialog } from "./ShareAgentDialog.js";
|
|
|
10
10
|
* the running agent (billed to the owning org).
|
|
11
11
|
*
|
|
12
12
|
* Owns the open-state and the `can_edit` gate — the same permission the
|
|
13
|
-
*
|
|
14
|
-
* whose changes would be rejected.
|
|
15
|
-
* agent is loading or the user cannot
|
|
16
|
-
* unconditionally fold `action` into its actions
|
|
13
|
+
* AgentShare create/apply handlers enforce on the referenced agent, so
|
|
14
|
+
* the action never appears to a user whose changes would be rejected.
|
|
15
|
+
* Returns a `null` action while the agent is loading or the user cannot
|
|
16
|
+
* edit, so the host can unconditionally fold `action` into its actions
|
|
17
|
+
* array.
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShareAgent.js","sourceRoot":"","sources":["../../src/sharing/useShareAgent.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA2CzD
|
|
1
|
+
{"version":3,"file":"useShareAgent.js","sourceRoot":"","sources":["../../src/sharing/useShareAgent.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA2CzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,KAAK,GAAG,OAAO,GACG;IAClB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,OAAO,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,IAAI,IAAI,CAAC;IAC5C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAC7C,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAC/C,UAAU,CACX,CAAC;IAEF,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpD,MAAM,MAAM,GACV,KAAK,IAAI,OAAO;QACd,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1D,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CACrB,KAAC,gBAAgB,IACf,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,SAAS,EACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;IAET,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
2
|
+
import type { AgentShareDraft } from "./useSaveAgentShare.js";
|
|
2
3
|
/**
|
|
3
|
-
* Readiness of a
|
|
4
|
-
* teammate) executions.
|
|
4
|
+
* Readiness of a share's tool credentials for visitor executions.
|
|
5
5
|
*
|
|
6
|
-
* - `na` — nothing to check: the agent uses no MCP tools,
|
|
7
|
-
*
|
|
6
|
+
* - `na` — nothing to check: the agent uses no MCP tools, sharing is
|
|
7
|
+
* off, the audience is org (bindings are public-audience only), or
|
|
8
|
+
* the deployment cannot serve guest chat (local mode).
|
|
9
|
+
* - `needs-credentials` — the agent uses MCP tools but the share has no
|
|
10
|
+
* environments bound: visitors' tool calls will fail until the owner
|
|
11
|
+
* binds credentials.
|
|
8
12
|
* - `checking` — lookups in flight.
|
|
9
|
-
* - `ready` — every environment bound to the
|
|
10
|
-
*
|
|
13
|
+
* - `ready` — every environment bound to the share is shared with the
|
|
14
|
+
* organization.
|
|
11
15
|
* - `blocked` — one or more bound environments are private; their
|
|
12
16
|
* `org/slug` references are listed for the hint copy.
|
|
13
17
|
*/
|
|
14
18
|
export type ShareToolReadiness = {
|
|
15
19
|
readonly status: "na";
|
|
20
|
+
} | {
|
|
21
|
+
readonly status: "needs-credentials";
|
|
16
22
|
} | {
|
|
17
23
|
readonly status: "checking";
|
|
18
24
|
} | {
|
|
@@ -23,26 +29,24 @@ export type ShareToolReadiness = {
|
|
|
23
29
|
};
|
|
24
30
|
/**
|
|
25
31
|
* Data hook that checks whether a tool-using shared agent's credentials
|
|
26
|
-
* will work for visitors — i.e. whether the
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* Guest and teammate executions can only use org-shared environments;
|
|
30
|
-
* a private environment's secrets are creator-only and silently
|
|
31
|
-
* unavailable to them, so the agent's tools would fail at runtime. This
|
|
32
|
-
* hook powers the Share dialog's pre-flight hint, catching the
|
|
33
|
-
* misconfiguration at share time instead of at the visitor's first
|
|
34
|
-
* message.
|
|
32
|
+
* will work for visitors — i.e. whether the share binds environments
|
|
33
|
+
* (`environment_refs`) and each one is shared with the organization
|
|
34
|
+
* (`visibility_org`).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* Guest executions receive credentials exclusively from the share's own
|
|
37
|
+
* `environment_refs`, resolved through the org-shared environment seam
|
|
38
|
+
* (decision 011 — the agent's default instance stays pristine and is
|
|
39
|
+
* never consulted). So a tool-using agent with an empty binding list is
|
|
40
|
+
* *guaranteed* broken for visitors, and this hook says so explicitly
|
|
41
|
+
* (`needs-credentials`) instead of staying silent — the gap that made
|
|
42
|
+
* session 12's misconfiguration invisible until a visitor's first
|
|
43
|
+
* message failed.
|
|
41
44
|
*
|
|
42
|
-
* The check runs only when
|
|
43
|
-
* (
|
|
44
|
-
*
|
|
45
|
-
*
|
|
45
|
+
* The check runs only when the share is enabled with a public audience
|
|
46
|
+
* (org-audience shares reject bindings at the proto boundary), the
|
|
47
|
+
* deployment is cloud (local mode has no guest runtime or secret
|
|
48
|
+
* gating), and the agent declares MCP server usages. All lookups run as
|
|
49
|
+
* the owner viewing the dialog, who can read the bound environments.
|
|
46
50
|
*/
|
|
47
|
-
export declare function useShareToolReadiness(agent: Agent,
|
|
51
|
+
export declare function useShareToolReadiness(agent: Agent, draft: AgentShareDraft): ShareToolReadiness;
|
|
48
52
|
//# sourceMappingURL=useShareToolReadiness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShareToolReadiness.d.ts","sourceRoot":"","sources":["../../src/sharing/useShareToolReadiness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"useShareToolReadiness.d.ts","sourceRoot":"","sources":["../../src/sharing/useShareToolReadiness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAIhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAKpF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,eAAe,GACrB,kBAAkB,CAwEpB"}
|