@rytass/bpm-core-react 0.18.1 → 0.20.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 +52 -0
- package/dist/chunks/{FormBuilderView-vQfVc08Z.js → FormBuilderView-CFRiw04B.js} +563 -475
- package/dist/chunks/FormBuilderView-CFRiw04B.js.map +1 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs +3 -0
- package/dist/chunks/FormBuilderView-CpUgbSbt.cjs.map +1 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js +1321 -0
- package/dist/chunks/FormRendererView-GfbVWEGa.js.map +1 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs +6 -0
- package/dist/chunks/FormRendererView-lYSaR8CQ.cjs.map +1 -0
- package/dist/chunks/{compose-DtfX8DQ9.cjs → compose-Bb5bUVFd.cjs} +2 -2
- package/dist/chunks/{compose-DtfX8DQ9.cjs.map → compose-Bb5bUVFd.cjs.map} +1 -1
- package/dist/chunks/{compose-D9ipJpF_.js → compose-egQlRjuZ.js} +5 -4
- package/dist/chunks/{compose-D9ipJpF_.js.map → compose-egQlRjuZ.js.map} +1 -1
- package/dist/chunks/{delegations-BfhCDz5e.js → delegations-9-yvWWws.js} +3 -2
- package/dist/chunks/delegations-9-yvWWws.js.map +1 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs +2 -0
- package/dist/chunks/delegations-CVmtpkRn.cjs.map +1 -0
- package/dist/chunks/delegations-CrfjsH94.cjs +2 -0
- package/dist/chunks/delegations-CrfjsH94.cjs.map +1 -0
- package/dist/chunks/{delegations-DBh5TT6G.js → delegations-CxnNvTCc.js} +3 -2
- package/dist/chunks/delegations-CxnNvTCc.js.map +1 -0
- package/dist/chunks/designer-CX9bhYJS.cjs +69 -0
- package/dist/chunks/designer-CX9bhYJS.cjs.map +1 -0
- package/dist/chunks/{designer-ubnZbP-A.js → designer-CZDlQ9Nf.js} +2341 -1584
- package/dist/chunks/designer-CZDlQ9Nf.js.map +1 -0
- package/dist/chunks/{detail-C6XKZjlF.js → detail-ByZV1XaI.js} +853 -840
- package/dist/chunks/detail-ByZV1XaI.js.map +1 -0
- package/dist/chunks/detail-ChseSF55.cjs +5 -0
- package/dist/chunks/detail-ChseSF55.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-B4zPg9kz.cjs → instance-error-message-DTARGbGo.cjs} +2 -2
- package/dist/chunks/instance-error-message-DTARGbGo.cjs.map +1 -0
- package/dist/chunks/{approver-filled-form-Bgazhbvd.js → instance-error-message-q6gy5evy.js} +44 -36
- package/dist/chunks/instance-error-message-q6gy5evy.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js +25 -0
- package/dist/chunks/workflow-chat-prompt-B4wCFKPB.js.map +1 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs +27 -0
- package/dist/chunks/workflow-chat-prompt-B803qVdt.cjs.map +1 -0
- package/dist/next/workflow-chat-route.cjs +8 -19
- package/dist/next/workflow-chat-route.cjs.map +1 -1
- package/dist/next/workflow-chat-route.d.cts +92 -4
- package/dist/next/workflow-chat-route.d.ts +92 -4
- package/dist/next/workflow-chat-route.js +127 -19
- package/dist/next/workflow-chat-route.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.js +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/FormRendererView.d.cts +25 -2
- package/dist/views/forms/renderer/FormRendererView.d.ts +25 -2
- package/dist/views/forms/renderer/file-upload-field.d.cts +84 -0
- package/dist/views/forms/renderer/file-upload-field.d.ts +84 -0
- package/dist/views/forms/renderer/form-data-source-field.d.cts +9 -1
- package/dist/views/forms/renderer/form-data-source-field.d.ts +9 -1
- package/dist/views/forms/renderer/form-value-readers.d.cts +7 -0
- package/dist/views/forms/renderer/form-value-readers.d.ts +7 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.d.cts +1 -0
- package/dist/views/forms/renderer/index.d.ts +1 -0
- package/dist/views/forms/renderer/index.js +1 -1
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/InstanceFormSection.d.cts +20 -3
- package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +20 -3
- package/dist/views/instances/detail/sections/shared.d.cts +1 -2
- package/dist/views/instances/detail/sections/shared.d.ts +1 -2
- package/dist/views/instances/instance-error-message.d.cts +5 -0
- package/dist/views/instances/instance-error-message.d.ts +5 -0
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +79 -76
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/designer-version-labels.d.cts +7 -0
- package/dist/views/templates/designer/designer-version-labels.d.ts +7 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.cts +25 -0
- package/dist/views/templates/designer/expression/DialectUpgradeModal.d.ts +25 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.cts +79 -0
- package/dist/views/templates/designer/expression/ExpressionField.d.ts +79 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.cts +22 -0
- package/dist/views/templates/designer/expression/use-workflow-expression-references.d.ts +22 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.cts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-edits.d.ts +58 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.cts +14 -0
- package/dist/views/templates/designer/expression/workflow-expression-tools.d.ts +14 -0
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.cts +7 -1
- package/dist/views/templates/designer/field-access-matrix/FieldAccessMatrixDrawer.d.ts +7 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/designer/notify-webhook-designer.d.cts +8 -0
- package/dist/views/templates/designer/notify-webhook-designer.d.ts +8 -0
- package/dist/views/templates/designer/use-workflow-designer-controller.d.cts +8 -2
- package/dist/views/templates/designer/use-workflow-designer-controller.d.ts +8 -2
- package/dist/views/templates/designer/workflow-chat-prompt.d.cts +18 -0
- package/dist/views/templates/designer/workflow-chat-prompt.d.ts +18 -0
- package/package.json +3 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs +0 -3
- package/dist/chunks/FormBuilderView-CHaAQL5v.cjs.map +0 -1
- package/dist/chunks/FormBuilderView-vQfVc08Z.js.map +0 -1
- package/dist/chunks/FormRendererView-CTLlG13b.js +0 -1106
- package/dist/chunks/FormRendererView-CTLlG13b.js.map +0 -1
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs +0 -4
- package/dist/chunks/FormRendererView-ChmM_4Yc.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-B4zPg9kz.cjs.map +0 -1
- package/dist/chunks/approver-filled-form-Bgazhbvd.js.map +0 -1
- package/dist/chunks/delegations-BfhCDz5e.js.map +0 -1
- package/dist/chunks/delegations-BmFGcuhA.cjs +0 -2
- package/dist/chunks/delegations-BmFGcuhA.cjs.map +0 -1
- package/dist/chunks/delegations-CcS0SHbf.cjs +0 -2
- package/dist/chunks/delegations-CcS0SHbf.cjs.map +0 -1
- package/dist/chunks/delegations-DBh5TT6G.js.map +0 -1
- package/dist/chunks/designer-Df79YzUn.cjs +0 -65
- package/dist/chunks/designer-Df79YzUn.cjs.map +0 -1
- package/dist/chunks/designer-ubnZbP-A.js.map +0 -1
- package/dist/chunks/detail-BBC9kqXd.cjs +0 -5
- package/dist/chunks/detail-BBC9kqXd.cjs.map +0 -1
- package/dist/chunks/detail-C6XKZjlF.js.map +0 -1
|
@@ -1,17 +1,105 @@
|
|
|
1
|
-
import { ToolSet } from 'ai';
|
|
1
|
+
import { ToolSet, UIMessage } from 'ai';
|
|
2
|
+
import { WORKFLOW_CHAT_SYSTEM_PROMPT } from '../views/templates/designer/workflow-chat-prompt.cjs';
|
|
2
3
|
/**
|
|
3
4
|
* Strict guardrail: the assistant may ONLY design this approval flow, using the
|
|
4
|
-
* provided tools.
|
|
5
|
-
*
|
|
5
|
+
* provided tools. Lives server-side so it cannot be overridden by
|
|
6
|
+
* client-supplied messages (the route drops every `system` message a client
|
|
7
|
+
* sends). Shared with the offline Chrome model through `workflow-chat-prompt`.
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export { WORKFLOW_CHAT_SYSTEM_PROMPT };
|
|
8
10
|
/** Build AI SDK tools from WORKFLOW_TOOLSET — no `execute`, so the browser runs them. */
|
|
9
11
|
export declare function buildWorkflowAiSdkTools(): ToolSet;
|
|
12
|
+
/** Upper bound on the request body, in bytes. Tool results carry snapshots. */
|
|
13
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES = 1048576;
|
|
14
|
+
/** Upper bound on the messages in one request. */
|
|
15
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES = 200;
|
|
16
|
+
/** Upper bound on the tokens the model may write per response. */
|
|
17
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS = 4096;
|
|
10
18
|
export interface WorkflowChatRouteOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Whether the route serves at all. Absent: `BPM_AI_ASSISTANT_ENABLED` is
|
|
21
|
+
* read on every request and must be `'true'`. A disabled route answers 404.
|
|
22
|
+
*/
|
|
23
|
+
readonly enabled?: boolean | (() => boolean);
|
|
24
|
+
/**
|
|
25
|
+
* The host's check that the caller may use the assistant (a session, a
|
|
26
|
+
* designer permission). Called before the body is read; `false` (or a
|
|
27
|
+
* throw) answers 401. Absent: no check, so put the route behind the host's
|
|
28
|
+
* own authentication.
|
|
29
|
+
*/
|
|
30
|
+
readonly authorize?: (request: Request) => boolean | Promise<boolean>;
|
|
31
|
+
/** Request body ceiling in bytes (413 above it). */
|
|
32
|
+
readonly maxRequestBytes?: number;
|
|
33
|
+
/** Message count ceiling (413 above it). */
|
|
34
|
+
readonly maxMessages?: number;
|
|
35
|
+
/** Output token ceiling passed to the model. */
|
|
36
|
+
readonly maxOutputTokens?: number;
|
|
11
37
|
/** Override the OpenAI model id (else BPM_LLM_MODEL env, else the default). */
|
|
12
38
|
readonly model?: string;
|
|
13
39
|
/** Override the system prompt (else the strict design-only guardrail). */
|
|
14
40
|
readonly system?: string;
|
|
15
41
|
}
|
|
42
|
+
type ReadMessagesResult = {
|
|
43
|
+
readonly messages: readonly UIMessage[];
|
|
44
|
+
readonly ok: true;
|
|
45
|
+
} | {
|
|
46
|
+
readonly ok: false;
|
|
47
|
+
readonly response: Response;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The client's messages, bounded and without any `system` message: the
|
|
51
|
+
* system prompt is the route's alone. The body is read as text first so its
|
|
52
|
+
* size is checked before anything is parsed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readWorkflowChatMessages(request: Request, limits: Readonly<{
|
|
55
|
+
maxMessages: number;
|
|
56
|
+
maxRequestBytes: number;
|
|
57
|
+
}>): Promise<ReadMessagesResult>;
|
|
58
|
+
/** The API's "who is signed in" endpoint (`apps/api` `GET /auth/me`). */
|
|
59
|
+
export declare const DEFAULT_BPM_API_SESSION_PATH = "/auth/me";
|
|
60
|
+
/** How long the session check may take before the route answers 401. */
|
|
61
|
+
export declare const DEFAULT_BPM_API_SESSION_TIMEOUT_MS = 5000;
|
|
62
|
+
export interface BPMApiSessionAuthorizeOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The absolute API origin to ask, e.g. an internal service URL. Absent:
|
|
65
|
+
* read from configuration by {@link resolveBPMApiSessionBaseUrl}.
|
|
66
|
+
*/
|
|
67
|
+
readonly apiBaseUrl?: string;
|
|
68
|
+
/** The fetch to use (tests, instrumented hosts). Default: global `fetch`. */
|
|
69
|
+
readonly fetch?: typeof fetch;
|
|
70
|
+
/** The session endpoint path. Default `/auth/me`. */
|
|
71
|
+
readonly sessionPath?: string;
|
|
72
|
+
/** Milliseconds before the check gives up and refuses. Default 5 000. */
|
|
73
|
+
readonly timeoutMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The API origin the session check asks. It comes only from configuration,
|
|
77
|
+
* never from the request: a `Host` or forwarded header the caller controls
|
|
78
|
+
* must not choose the server that decides whether the caller is signed in.
|
|
79
|
+
*
|
|
80
|
+
* 1. `apiBaseUrl` when given;
|
|
81
|
+
* 2. `BPM_API_INTERNAL_URL` (server-only, e.g. the API's in-cluster URL);
|
|
82
|
+
* 3. `NEXT_PUBLIC_API_AUTH_URL` (the `/auth/*` base);
|
|
83
|
+
* 4. the origin of `NEXT_PUBLIC_API_URL` (the GraphQL endpoint);
|
|
84
|
+
* 5. `http://localhost:17603` outside `NODE_ENV=production`.
|
|
85
|
+
*
|
|
86
|
+
* Only absolute http(s) URLs count; a relative setting is ignored. `null`
|
|
87
|
+
* when nothing applies, and the session check then refuses every request.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveBPMApiSessionBaseUrl(apiBaseUrl?: string): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* An `authorize` hook for {@link createWorkflowChatPOST} that lets in only a
|
|
92
|
+
* caller the BPM API recognises as signed in: it forwards the request's
|
|
93
|
+
* `Cookie` header (nothing else) to the API's session endpoint and accepts a
|
|
94
|
+
* `200` whose JSON names a `memberId`. No cookie, any other status, a body
|
|
95
|
+
* of another shape, a network error or a timeout refuses, so the route
|
|
96
|
+
* answers 401. The session itself is never read or kept here.
|
|
97
|
+
*
|
|
98
|
+
* Host usage (apps/client/src/app/api/chat/route.ts):
|
|
99
|
+
* export const POST = createWorkflowChatPOST({
|
|
100
|
+
* authorize: createBPMApiSessionAuthorize(),
|
|
101
|
+
* });
|
|
102
|
+
*/
|
|
103
|
+
export declare function createBPMApiSessionAuthorize(options?: BPMApiSessionAuthorizeOptions): (request: Request) => Promise<boolean>;
|
|
16
104
|
/** Create the `POST` handler for the workflow chat route. */
|
|
17
105
|
export declare function createWorkflowChatPOST(options?: WorkflowChatRouteOptions): (request: Request) => Promise<Response>;
|
|
@@ -1,17 +1,105 @@
|
|
|
1
|
-
import { ToolSet } from 'ai';
|
|
1
|
+
import { ToolSet, UIMessage } from 'ai';
|
|
2
|
+
import { WORKFLOW_CHAT_SYSTEM_PROMPT } from '../views/templates/designer/workflow-chat-prompt.js';
|
|
2
3
|
/**
|
|
3
4
|
* Strict guardrail: the assistant may ONLY design this approval flow, using the
|
|
4
|
-
* provided tools.
|
|
5
|
-
*
|
|
5
|
+
* provided tools. Lives server-side so it cannot be overridden by
|
|
6
|
+
* client-supplied messages (the route drops every `system` message a client
|
|
7
|
+
* sends). Shared with the offline Chrome model through `workflow-chat-prompt`.
|
|
6
8
|
*/
|
|
7
|
-
export
|
|
9
|
+
export { WORKFLOW_CHAT_SYSTEM_PROMPT };
|
|
8
10
|
/** Build AI SDK tools from WORKFLOW_TOOLSET — no `execute`, so the browser runs them. */
|
|
9
11
|
export declare function buildWorkflowAiSdkTools(): ToolSet;
|
|
12
|
+
/** Upper bound on the request body, in bytes. Tool results carry snapshots. */
|
|
13
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES = 1048576;
|
|
14
|
+
/** Upper bound on the messages in one request. */
|
|
15
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES = 200;
|
|
16
|
+
/** Upper bound on the tokens the model may write per response. */
|
|
17
|
+
export declare const DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS = 4096;
|
|
10
18
|
export interface WorkflowChatRouteOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Whether the route serves at all. Absent: `BPM_AI_ASSISTANT_ENABLED` is
|
|
21
|
+
* read on every request and must be `'true'`. A disabled route answers 404.
|
|
22
|
+
*/
|
|
23
|
+
readonly enabled?: boolean | (() => boolean);
|
|
24
|
+
/**
|
|
25
|
+
* The host's check that the caller may use the assistant (a session, a
|
|
26
|
+
* designer permission). Called before the body is read; `false` (or a
|
|
27
|
+
* throw) answers 401. Absent: no check, so put the route behind the host's
|
|
28
|
+
* own authentication.
|
|
29
|
+
*/
|
|
30
|
+
readonly authorize?: (request: Request) => boolean | Promise<boolean>;
|
|
31
|
+
/** Request body ceiling in bytes (413 above it). */
|
|
32
|
+
readonly maxRequestBytes?: number;
|
|
33
|
+
/** Message count ceiling (413 above it). */
|
|
34
|
+
readonly maxMessages?: number;
|
|
35
|
+
/** Output token ceiling passed to the model. */
|
|
36
|
+
readonly maxOutputTokens?: number;
|
|
11
37
|
/** Override the OpenAI model id (else BPM_LLM_MODEL env, else the default). */
|
|
12
38
|
readonly model?: string;
|
|
13
39
|
/** Override the system prompt (else the strict design-only guardrail). */
|
|
14
40
|
readonly system?: string;
|
|
15
41
|
}
|
|
42
|
+
type ReadMessagesResult = {
|
|
43
|
+
readonly messages: readonly UIMessage[];
|
|
44
|
+
readonly ok: true;
|
|
45
|
+
} | {
|
|
46
|
+
readonly ok: false;
|
|
47
|
+
readonly response: Response;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The client's messages, bounded and without any `system` message: the
|
|
51
|
+
* system prompt is the route's alone. The body is read as text first so its
|
|
52
|
+
* size is checked before anything is parsed.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readWorkflowChatMessages(request: Request, limits: Readonly<{
|
|
55
|
+
maxMessages: number;
|
|
56
|
+
maxRequestBytes: number;
|
|
57
|
+
}>): Promise<ReadMessagesResult>;
|
|
58
|
+
/** The API's "who is signed in" endpoint (`apps/api` `GET /auth/me`). */
|
|
59
|
+
export declare const DEFAULT_BPM_API_SESSION_PATH = "/auth/me";
|
|
60
|
+
/** How long the session check may take before the route answers 401. */
|
|
61
|
+
export declare const DEFAULT_BPM_API_SESSION_TIMEOUT_MS = 5000;
|
|
62
|
+
export interface BPMApiSessionAuthorizeOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The absolute API origin to ask, e.g. an internal service URL. Absent:
|
|
65
|
+
* read from configuration by {@link resolveBPMApiSessionBaseUrl}.
|
|
66
|
+
*/
|
|
67
|
+
readonly apiBaseUrl?: string;
|
|
68
|
+
/** The fetch to use (tests, instrumented hosts). Default: global `fetch`. */
|
|
69
|
+
readonly fetch?: typeof fetch;
|
|
70
|
+
/** The session endpoint path. Default `/auth/me`. */
|
|
71
|
+
readonly sessionPath?: string;
|
|
72
|
+
/** Milliseconds before the check gives up and refuses. Default 5 000. */
|
|
73
|
+
readonly timeoutMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The API origin the session check asks. It comes only from configuration,
|
|
77
|
+
* never from the request: a `Host` or forwarded header the caller controls
|
|
78
|
+
* must not choose the server that decides whether the caller is signed in.
|
|
79
|
+
*
|
|
80
|
+
* 1. `apiBaseUrl` when given;
|
|
81
|
+
* 2. `BPM_API_INTERNAL_URL` (server-only, e.g. the API's in-cluster URL);
|
|
82
|
+
* 3. `NEXT_PUBLIC_API_AUTH_URL` (the `/auth/*` base);
|
|
83
|
+
* 4. the origin of `NEXT_PUBLIC_API_URL` (the GraphQL endpoint);
|
|
84
|
+
* 5. `http://localhost:17603` outside `NODE_ENV=production`.
|
|
85
|
+
*
|
|
86
|
+
* Only absolute http(s) URLs count; a relative setting is ignored. `null`
|
|
87
|
+
* when nothing applies, and the session check then refuses every request.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveBPMApiSessionBaseUrl(apiBaseUrl?: string): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* An `authorize` hook for {@link createWorkflowChatPOST} that lets in only a
|
|
92
|
+
* caller the BPM API recognises as signed in: it forwards the request's
|
|
93
|
+
* `Cookie` header (nothing else) to the API's session endpoint and accepts a
|
|
94
|
+
* `200` whose JSON names a `memberId`. No cookie, any other status, a body
|
|
95
|
+
* of another shape, a network error or a timeout refuses, so the route
|
|
96
|
+
* answers 401. The session itself is never read or kept here.
|
|
97
|
+
*
|
|
98
|
+
* Host usage (apps/client/src/app/api/chat/route.ts):
|
|
99
|
+
* export const POST = createWorkflowChatPOST({
|
|
100
|
+
* authorize: createBPMApiSessionAuthorize(),
|
|
101
|
+
* });
|
|
102
|
+
*/
|
|
103
|
+
export declare function createBPMApiSessionAuthorize(options?: BPMApiSessionAuthorizeOptions): (request: Request) => Promise<boolean>;
|
|
16
104
|
/** Create the `POST` handler for the workflow chat route. */
|
|
17
105
|
export declare function createWorkflowChatPOST(options?: WorkflowChatRouteOptions): (request: Request) => Promise<Response>;
|
|
@@ -1,31 +1,139 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as e } from "../chunks/workflow-chat-prompt-B4wCFKPB.js";
|
|
2
|
+
import { convertToModelMessages as t, jsonSchema as n, streamText as r, tool as i } from "ai";
|
|
3
|
+
import { openai as a } from "@ai-sdk/openai";
|
|
4
|
+
import { WORKFLOW_TOOLSET as o } from "@rytass/bpm-core-shared";
|
|
4
5
|
// src/next/workflow-chat-route.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
var s = "gpt-5.4-mini";
|
|
7
|
+
function c(e) {
|
|
8
|
+
return a(e.replace(/^openai\//u, ""));
|
|
8
9
|
}
|
|
9
|
-
var c = "你是「簽核流程設計器」頁面內建的 AI 助理,唯一職責是協助使用者在這個畫布上設計/修改一個簽核審批流程(workflow)。\n\n你只能透過系統提供的工具(tools)來操作流程:新增/重命名/刪除節點、連線、設定簽核人、設定條件分流、設定系統節點動作、自動排版、查詢現況與驗證等。除了這些工具,你沒有其他能力。\n\n工作守則:\n1. 動作前,先呼叫 get_workflow_snapshot 了解目前畫布的節點與連線,再規劃要呼叫哪些工具。\n2. 盡量用高階工具(insert_approval_step / insert_notification / insert_conditional_branch)一次完成多步;需要細修時再用細顆粒工具。\n3. **重要:要果斷、先把流程畫出來。** 使用者只給一兩句話時,直接依常見公司慣例建立初稿,不要反覆追問細節。簽核人若使用者沒指定,就省略 approverResolver(系統會自動用「直屬主管」為預設,不需要真實會員 id);通知節點同理可省略 action(預設站內通知)。先把結構建好、再請使用者調整。\n4. 工具呼叫不會因為「缺簽核人/缺資料」而失敗;缺的部分會以合理預設補上,並由 validate_workflow 標示。所以放心連續呼叫工具把流程建完,不要因為怕缺欄位就停下來問。\n5. 當使用者「點名」某個人或部門當簽核人/收件者時,先用 search_members(依姓名關鍵字)、list_org_units、list_positions 查到真實 id,再用 set_user_task_approver / set_service_action 指定(如 DIRECT memberIds、ORG_UNIT_MANAGER orgUnitId、POSITION positionId)。查不到就回報並請使用者確認,不要編造 id。\n6. 節點 id 可從 snapshot 取得;連線條件需要先綁定表單欄位(若 list_form_fields 為空,提醒使用者先綁定表單版本)。\n7. **條件分流務必主動補上「其他情況」**:設計 exclusiveGateway(條件分流)時,除了符合條件的分支,一定要保留一條未設條件、標記為預設(isDefault)的「其他情況」路徑當 else(通常指向後續節點或完成)。不要把所有輸出連線都設成條件而沒有預設出口;缺預設出口時,用 set_edge_default 把其中一條設為預設。\n8. 完成後,呼叫 validate_workflow,並用一兩句話說明你建了什麼流程、哪些地方(如簽核人、條件門檻)建議使用者再確認或指定。\n9. 全程使用繁體中文(台灣用語)回覆。\n10. 欄位在各關的顯示與補填用 set_field_access_matrix 設定:nodeIds 只列這次要改的簽核節點,它們的設定會整個換掉,呼叫前先從 get_workflow_snapshot 讀出這些節點既有的「欄位設定」一併傳入。「隱藏」只影響畫面、不是權限,不能用來保密;使用者要求保密時要說明這一點。節點含舊欄位權限設定時,用 remove_legacy_field_permissions 移除(不會自動轉換)。\n\n嚴格界線:\n- 只做「設計這個簽核流程」相關的事。任何與此無關的請求(閒聊、寫詩、寫程式、查天氣/新聞、操作其他系統或頁面、回答一般知識問題等)一律婉拒,並簡短引導使用者回到流程設計,例如:「我只能協助你設計這個簽核流程,需要我幫你新增關卡或設定條件嗎?」\n- 不要假裝執行你工具以外的動作,也不要編造結果。";
|
|
10
10
|
function l() {
|
|
11
|
-
let e =
|
|
11
|
+
let e = o.map((e) => [e.name, i({
|
|
12
12
|
description: e.description,
|
|
13
|
-
inputSchema:
|
|
13
|
+
inputSchema: n(e.inputSchema)
|
|
14
14
|
})]);
|
|
15
15
|
return Object.fromEntries(e);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
var u = 1048576, d = 200, f = 4096, p = (e, t) => new Response(t, {
|
|
18
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
19
|
+
status: e
|
|
20
|
+
});
|
|
21
|
+
function m(e) {
|
|
22
|
+
return typeof e == "function" ? e() : e ?? process.env.BPM_AI_ASSISTANT_ENABLED === "true";
|
|
23
|
+
}
|
|
24
|
+
async function h(e, t) {
|
|
25
|
+
if (!t) return !0;
|
|
26
|
+
try {
|
|
27
|
+
return await t(e) === !0;
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function g(e) {
|
|
33
|
+
return typeof e == "object" && !!e && typeof e.role == "string" && Array.isArray(e.parts);
|
|
34
|
+
}
|
|
35
|
+
async function _(e, t) {
|
|
36
|
+
if (e.body === null) return "";
|
|
37
|
+
let n = e.body.getReader(), r = [], i = async (e) => {
|
|
38
|
+
let { done: a, value: o } = await n.read();
|
|
39
|
+
if (a) return e;
|
|
40
|
+
let s = e + o.byteLength;
|
|
41
|
+
return s > t ? (await n.cancel().catch(() => void 0), null) : (r.push(o), i(s));
|
|
42
|
+
}, a = await i(0);
|
|
43
|
+
if (a === null) return null;
|
|
44
|
+
let o = new Uint8Array(a);
|
|
45
|
+
return r.reduce((e, t) => (o.set(t, e), e + t.byteLength), 0), new TextDecoder().decode(o);
|
|
46
|
+
}
|
|
47
|
+
async function v(e, t) {
|
|
48
|
+
if (Number(e.headers.get("content-length") ?? "0") > t.maxRequestBytes) return {
|
|
49
|
+
ok: !1,
|
|
50
|
+
response: p(413, "Request too large")
|
|
51
|
+
};
|
|
52
|
+
let n = await _(e, t.maxRequestBytes);
|
|
53
|
+
if (n === null) return {
|
|
54
|
+
ok: !1,
|
|
55
|
+
response: p(413, "Request too large")
|
|
56
|
+
};
|
|
57
|
+
let r;
|
|
58
|
+
try {
|
|
59
|
+
r = JSON.parse(n);
|
|
60
|
+
} catch {
|
|
61
|
+
return {
|
|
62
|
+
ok: !1,
|
|
63
|
+
response: p(400, "Invalid request")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
let i = typeof r == "object" && r ? r.messages : void 0;
|
|
67
|
+
return !Array.isArray(i) || !i.every(g) ? {
|
|
68
|
+
ok: !1,
|
|
69
|
+
response: p(400, "Invalid request")
|
|
70
|
+
} : i.length > t.maxMessages ? {
|
|
71
|
+
ok: !1,
|
|
72
|
+
response: p(413, "Too many messages")
|
|
73
|
+
} : {
|
|
74
|
+
messages: i.filter((e) => e.role !== "system"),
|
|
75
|
+
ok: !0
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
var y = "http://localhost:17603", b = "/auth/me", x = 5e3, S = (e) => {
|
|
79
|
+
let t = e?.trim();
|
|
80
|
+
if (!t) return null;
|
|
81
|
+
try {
|
|
82
|
+
let e = new URL(t);
|
|
83
|
+
return e.protocol === "http:" || e.protocol === "https:" ? e.toString().replace(/\/$/u, "") : null;
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}, C = (e) => {
|
|
88
|
+
let t = S(e);
|
|
89
|
+
return t === null ? null : new URL(t).origin;
|
|
90
|
+
};
|
|
91
|
+
function w(e) {
|
|
92
|
+
return S(e) ?? S(process.env.BPM_API_INTERNAL_URL) ?? S(process.env.NEXT_PUBLIC_API_AUTH_URL) ?? C(process.env.NEXT_PUBLIC_API_URL) ?? (process.env.NODE_ENV === "production" ? null : y);
|
|
93
|
+
}
|
|
94
|
+
var T = (e) => typeof e == "object" && !!e && typeof e.memberId == "string" && e.memberId.length > 0;
|
|
95
|
+
function E(e = {}) {
|
|
96
|
+
return async function(t) {
|
|
97
|
+
let n = t.headers.get("cookie");
|
|
98
|
+
if (!n) return !1;
|
|
99
|
+
let r = w(e.apiBaseUrl);
|
|
100
|
+
if (r === null) return !1;
|
|
101
|
+
let i = e.fetch ?? fetch, a = `${r}${e.sessionPath ?? "/auth/me"}`;
|
|
102
|
+
try {
|
|
103
|
+
let t = await i(a, {
|
|
104
|
+
cache: "no-store",
|
|
105
|
+
headers: {
|
|
106
|
+
Accept: "application/json",
|
|
107
|
+
Cookie: n
|
|
108
|
+
},
|
|
109
|
+
method: "GET",
|
|
110
|
+
redirect: "manual",
|
|
111
|
+
signal: AbortSignal.timeout(e.timeoutMs ?? 5e3)
|
|
112
|
+
});
|
|
113
|
+
return t.status === 200 && T(await t.json());
|
|
114
|
+
} catch {
|
|
115
|
+
return !1;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function D(e = {}) {
|
|
120
|
+
let n = l();
|
|
19
121
|
return async function(i) {
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
122
|
+
if (!m(e.enabled)) return p(404, "Not Found");
|
|
123
|
+
if (!await h(i, e.authorize)) return p(401, "Unauthorized");
|
|
124
|
+
let a = await v(i, {
|
|
125
|
+
maxMessages: e.maxMessages ?? 200,
|
|
126
|
+
maxRequestBytes: e.maxRequestBytes ?? 1048576
|
|
127
|
+
});
|
|
128
|
+
return a.ok ? r({
|
|
129
|
+
maxOutputTokens: e.maxOutputTokens ?? 4096,
|
|
130
|
+
messages: await t([...a.messages]),
|
|
131
|
+
model: c(e.model ?? process.env.BPM_LLM_MODEL ?? s),
|
|
132
|
+
system: e.system ?? "你是「簽核流程設計器」頁面內建的 AI 助理,唯一職責是協助使用者在這個畫布上設計/修改一個簽核審批流程(workflow)。\n\n你只能透過系統提供的工具(tools)來操作流程:新增/重命名/刪除節點、連線、設定簽核人、設定條件分流、設定系統節點動作、自動排版、查詢現況與驗證等。除了這些工具,你沒有其他能力。\n\n工作守則:\n1. 動作前,先呼叫 get_workflow_snapshot 了解目前畫布的節點與連線,再規劃要呼叫哪些工具。\n2. 盡量用高階工具(insert_approval_step / insert_notification / insert_conditional_branch)一次完成多步;需要細修時再用細顆粒工具。\n3. **重要:要果斷、先把流程畫出來。** 使用者只給一兩句話時,直接依常見公司慣例建立初稿,不要反覆追問細節。簽核人若使用者沒指定,就省略 approverResolver(系統會自動用「直屬主管」為預設,不需要真實會員 id);通知節點同理可省略 action(預設站內通知)。先把結構建好、再請使用者調整。\n4. 工具呼叫不會因為「缺簽核人/缺資料」而失敗;缺的部分會以合理預設補上,並由 validate_workflow 標示。所以放心連續呼叫工具把流程建完,不要因為怕缺欄位就停下來問。\n5. 當使用者「點名」某個人或部門當簽核人/收件者時,先用 search_members(依姓名關鍵字)、list_org_units、list_positions 查到真實 id,再用 set_user_task_approver / set_service_action 指定(如 DIRECT memberIds、ORG_UNIT_MANAGER orgUnitId、POSITION positionId)。查不到就回報並請使用者確認,不要編造 id。\n6. 節點 id 可從 snapshot 取得;連線條件需要先綁定表單欄位(若 list_form_fields 為空,提醒使用者先綁定表單版本)。\n7. **條件分流務必主動補上「其他情況」**:設計 exclusiveGateway(條件分流)時,除了符合條件的分支,一定要保留一條未設條件、標記為預設(isDefault)的「其他情況」路徑當 else(通常指向後續節點或完成)。不要把所有輸出連線都設成條件而沒有預設出口;缺預設出口時,用 set_edge_default 把其中一條設為預設。\n8. 完成後,呼叫 validate_workflow,並用一兩句話說明你建了什麼流程、哪些地方(如簽核人、條件門檻)建議使用者再確認或指定。\n9. 全程使用繁體中文(台灣用語)回覆。\n10. 欄位在各關的顯示與補填用 set_field_access_matrix 設定:nodeIds 只列這次要改的簽核節點,它們的設定會整個換掉,呼叫前先從 get_workflow_snapshot 讀出這些節點既有的「欄位設定」一併傳入。「隱藏」只影響畫面、不是權限,不能用來保密;使用者要求保密時要說明這一點。節點含舊欄位權限設定時,用 remove_legacy_field_permissions 移除(不會自動轉換)。\n\n運算式(CEL)規則:\n- 運算式只在後端檢查與執行,你看不到執行結果,也不能在瀏覽器試算。寫任何運算式(發起權限、簽核人運算式、系統節點寫入欄位的值、Webhook payload、知會對象運算式)之前,先呼叫 get_expression_catalog 取得該位置可用的根、欄位與函式,只使用目錄裡的名稱;宿主函式名稱帶版本(例如 erp_costBand_v1),要照目錄原樣寫。\n- 寫入前一定先用 preview_expression 檢查(LINT)。有 ERROR 就修正後再檢查,不要直接寫入;寫入工具也會再檢查一次,未通過會被拒絕。WARNING 只是提醒,寫入後要用一句話告訴使用者。\n- 條件分流的連線條件優先用 set_edge_condition(依欄位、運算子、值,由系統產生),不要自己拼 CEL。\n- 只有從簽核關卡出去的連線才讀得到 lastDecision;條件分流、系統節點出去的連線 lastDecision 永遠是空值,不要在那裡讀它。\n- 運算式寫進草稿後不會自動發布;發布由使用者在畫面上操作,你不能也不要嘗試發布。\n\n嚴格界線:\n- 只做「設計這個簽核流程」相關的事。任何與此無關的請求(閒聊、寫詩、寫程式、查天氣/新聞、操作其他系統或頁面、回答一般知識問題等)一律婉拒,並簡短引導使用者回到流程設計,例如:「我只能協助你設計這個簽核流程,需要我幫你新增關卡或設定條件嗎?」\n- 不要假裝執行你工具以外的動作,也不要編造結果。",
|
|
133
|
+
tools: n
|
|
134
|
+
}).toUIMessageStreamResponse() : a.response;
|
|
27
135
|
};
|
|
28
136
|
}
|
|
29
|
-
export {
|
|
137
|
+
export { b as DEFAULT_BPM_API_SESSION_PATH, x as DEFAULT_BPM_API_SESSION_TIMEOUT_MS, d as DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES, f as DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS, u as DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES, e as WORKFLOW_CHAT_SYSTEM_PROMPT, l as buildWorkflowAiSdkTools, E as createBPMApiSessionAuthorize, D as createWorkflowChatPOST, v as readWorkflowChatMessages, w as resolveBPMApiSessionBaseUrl };
|
|
30
138
|
|
|
31
139
|
//# sourceMappingURL=workflow-chat-route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-chat-route.js","names":["DEFAULT_MODEL","resolveModel","openai","setting","WORKFLOW_CHAT_SYSTEM_PROMPT","buildWorkflowAiSdkTools","entries","WORKFLOW_TOOLSET","workflowTool","tool","jsonSchema","createWorkflowChatPOST","tools","body","request","streamText","convertToModelMessages","options"],"sources":["../../src/next/workflow-chat-route.ts"],"sourcesContent":["import {\n convertToModelMessages,\n jsonSchema,\n streamText,\n tool,\n type LanguageModel,\n type Tool,\n type ToolSet,\n type UIMessage,\n} from 'ai';\nimport { openai } from '@ai-sdk/openai';\nimport { WORKFLOW_TOOLSET } from '@rytass/bpm-core-shared';\n\n/**\n * Next.js route handler for the workflow designer LLM assistant.\n *\n * The model is advertised the workflow {@link WORKFLOW_TOOLSET} but the tools\n * carry **no `execute`** — so every tool call is forwarded to the browser,\n * where `useChat`'s `onToolCall` runs it against the React designer controller\n * (see `use-workflow-chat.ts`). This route only holds the API key, runs the\n * model, and streams the tool-call plan back. It never touches the canvas.\n *\n * Host usage (apps/client/src/app/api/chat/route.ts):\n * export const runtime = 'nodejs';\n * export const POST = createWorkflowChatPOST();\n */\n\n/** Default OpenAI model id (overridable via BPM_LLM_MODEL). */\nconst DEFAULT_MODEL = 'gpt-5.4-mini';\n\n/**\n * Resolve the model via the OpenAI provider directly (reads `OPENAI_API_KEY`).\n * Accepts a bare id (`gpt-5.4-mini`) or a `openai/`-prefixed id; the prefix is\n * stripped. This deployment talks to OpenAI directly — no AI Gateway.\n */\nfunction resolveModel(setting: string): LanguageModel {\n return openai(setting.replace(/^openai\\//u, ''));\n}\n\n/**\n * Strict guardrail: the assistant may ONLY design this approval flow, using the\n * provided tools. Anything else is declined. Lives server-side so it cannot be\n * overridden by client-supplied messages.\n */\nexport const WORKFLOW_CHAT_SYSTEM_PROMPT = `你是「簽核流程設計器」頁面內建的 AI 助理,唯一職責是協助使用者在這個畫布上設計/修改一個簽核審批流程(workflow)。\n\n你只能透過系統提供的工具(tools)來操作流程:新增/重命名/刪除節點、連線、設定簽核人、設定條件分流、設定系統節點動作、自動排版、查詢現況與驗證等。除了這些工具,你沒有其他能力。\n\n工作守則:\n1. 動作前,先呼叫 get_workflow_snapshot 了解目前畫布的節點與連線,再規劃要呼叫哪些工具。\n2. 盡量用高階工具(insert_approval_step / insert_notification / insert_conditional_branch)一次完成多步;需要細修時再用細顆粒工具。\n3. **重要:要果斷、先把流程畫出來。** 使用者只給一兩句話時,直接依常見公司慣例建立初稿,不要反覆追問細節。簽核人若使用者沒指定,就省略 approverResolver(系統會自動用「直屬主管」為預設,不需要真實會員 id);通知節點同理可省略 action(預設站內通知)。先把結構建好、再請使用者調整。\n4. 工具呼叫不會因為「缺簽核人/缺資料」而失敗;缺的部分會以合理預設補上,並由 validate_workflow 標示。所以放心連續呼叫工具把流程建完,不要因為怕缺欄位就停下來問。\n5. 當使用者「點名」某個人或部門當簽核人/收件者時,先用 search_members(依姓名關鍵字)、list_org_units、list_positions 查到真實 id,再用 set_user_task_approver / set_service_action 指定(如 DIRECT memberIds、ORG_UNIT_MANAGER orgUnitId、POSITION positionId)。查不到就回報並請使用者確認,不要編造 id。\n6. 節點 id 可從 snapshot 取得;連線條件需要先綁定表單欄位(若 list_form_fields 為空,提醒使用者先綁定表單版本)。\n7. **條件分流務必主動補上「其他情況」**:設計 exclusiveGateway(條件分流)時,除了符合條件的分支,一定要保留一條未設條件、標記為預設(isDefault)的「其他情況」路徑當 else(通常指向後續節點或完成)。不要把所有輸出連線都設成條件而沒有預設出口;缺預設出口時,用 set_edge_default 把其中一條設為預設。\n8. 完成後,呼叫 validate_workflow,並用一兩句話說明你建了什麼流程、哪些地方(如簽核人、條件門檻)建議使用者再確認或指定。\n9. 全程使用繁體中文(台灣用語)回覆。\n10. 欄位在各關的顯示與補填用 set_field_access_matrix 設定:nodeIds 只列這次要改的簽核節點,它們的設定會整個換掉,呼叫前先從 get_workflow_snapshot 讀出這些節點既有的「欄位設定」一併傳入。「隱藏」只影響畫面、不是權限,不能用來保密;使用者要求保密時要說明這一點。節點含舊欄位權限設定時,用 remove_legacy_field_permissions 移除(不會自動轉換)。\n\n嚴格界線:\n- 只做「設計這個簽核流程」相關的事。任何與此無關的請求(閒聊、寫詩、寫程式、查天氣/新聞、操作其他系統或頁面、回答一般知識問題等)一律婉拒,並簡短引導使用者回到流程設計,例如:「我只能協助你設計這個簽核流程,需要我幫你新增關卡或設定條件嗎?」\n- 不要假裝執行你工具以外的動作,也不要編造結果。`;\n\n/** Build AI SDK tools from WORKFLOW_TOOLSET — no `execute`, so the browser runs them. */\nexport function buildWorkflowAiSdkTools(): ToolSet {\n const entries: readonly (readonly [string, Tool])[] = WORKFLOW_TOOLSET.map(\n (workflowTool) =>\n [\n workflowTool.name,\n tool({\n description: workflowTool.description,\n inputSchema: jsonSchema(\n workflowTool.inputSchema as Parameters<typeof jsonSchema>[0],\n ),\n }),\n ] as const,\n );\n\n return Object.fromEntries(entries) as ToolSet;\n}\n\nexport interface WorkflowChatRouteOptions {\n /** Override the OpenAI model id (else BPM_LLM_MODEL env, else the default). */\n readonly model?: string;\n /** Override the system prompt (else the strict design-only guardrail). */\n readonly system?: string;\n}\n\ninterface WorkflowChatRequestBody {\n readonly messages: readonly UIMessage[];\n}\n\n/** Create the `POST` handler for the workflow chat route. */\nexport function createWorkflowChatPOST(\n options: WorkflowChatRouteOptions = {},\n): (request: Request) => Promise<Response> {\n const tools = buildWorkflowAiSdkTools();\n\n return async function POST(request: Request): Promise<Response> {\n const body = (await request.json()) as WorkflowChatRequestBody;\n const result = streamText({\n messages: await convertToModelMessages([...body.messages]),\n model: resolveModel(\n options.model ?? process.env.BPM_LLM_MODEL ?? DEFAULT_MODEL,\n ),\n system: options.system ?? WORKFLOW_CHAT_SYSTEM_PROMPT,\n tools,\n });\n\n return result.toUIMessageStreamResponse();\n };\n}\n"],"mappings":";;;;AA4BA,IAAMA,IAAgB;AAOtB,SAASC,EAAa,GAAgC;CACpD,OAAOC,EAAOC,EAAQ,QAAQ,cAAc,EAAE,CAAC;AACjD;AAOA,IAAaC,IAA8B;AAqB3C,SAAgBC,IAAmC;CACjD,IAAMC,IAAgDC,EAAiB,KACpE,MACC,CACEC,EAAa,MACbC,EAAK;EACH,aAAaD,EAAa;EAC1B,aAAaE,EACXF,EAAa,WACf;CACF,CAAC,CACH,CACJ;CAEA,OAAO,OAAO,YAAYF,CAAO;AACnC;AAcA,SAAgBK,EACd,IAAoC,CAAC,GACI;CACzC,IAAMC,IAAQP,EAAwB;CAEtC,OAAO,eAAoB,GAAqC;EAC9D,IAAMQ,IAAQ,MAAMC,EAAQ,KAAK;EAUjC,OATeC,EAAW;GACxB,UAAU,MAAMC,EAAuB,CAAC,GAAGH,EAAK,QAAQ,CAAC;GACzD,OAAOZ,EACLgB,EAAQ,SAAS,QAAQ,IAAI,iBAAiBjB,CAChD;GACA,QAAQiB,EAAQ,UAAA;GAChB;EACF,CAEO,CAAA,CAAO,0BAA0B;CAC1C;AACF"}
|
|
1
|
+
{"version":3,"file":"workflow-chat-route.js","names":["WORKFLOW_CHAT_SYSTEM_PROMPT","DEFAULT_MODEL","resolveModel","openai","setting","buildWorkflowAiSdkTools","entries","WORKFLOW_TOOLSET","workflowTool","tool","jsonSchema","DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES","DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES","DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS","plainResponse","text","isEnabled","enabled","isAuthorized","authorize","request","isUIMessage","value","readBodyWithinLimit","reader","chunks","readWithin","done","total","nextTotal","maxBytes","bytes","chunk","offset","readWorkflowChatMessages","limits","body","messages","message","LOCAL_BPM_API_ORIGIN","DEFAULT_BPM_API_SESSION_PATH","DEFAULT_BPM_API_SESSION_TIMEOUT_MS","readAbsoluteUrl","configured","url","readAbsoluteOrigin","resolveBPMApiSessionBaseUrl","apiBaseUrl","isSignedInMember","createBPMApiSessionAuthorize","cookie","baseUrl","options","fetchImpl","response","createWorkflowChatPOST","tools","read","streamText","convertToModelMessages"],"sources":["../../src/next/workflow-chat-route.ts"],"sourcesContent":["import {\n convertToModelMessages,\n jsonSchema,\n streamText,\n tool,\n type LanguageModel,\n type Tool,\n type ToolSet,\n type UIMessage,\n} from 'ai';\nimport { openai } from '@ai-sdk/openai';\nimport { WORKFLOW_TOOLSET } from '@rytass/bpm-core-shared';\nimport { WORKFLOW_CHAT_SYSTEM_PROMPT } from '../views/templates/designer/workflow-chat-prompt';\n\n/**\n * Next.js route handler for the workflow designer LLM assistant.\n *\n * The model is advertised the workflow {@link WORKFLOW_TOOLSET} but the tools\n * carry **no `execute`** — so every tool call is forwarded to the browser,\n * where `useChat`'s `onToolCall` runs it against the React designer controller\n * (see `use-workflow-chat.ts`). This route only holds the API key, runs the\n * model, and streams the tool-call plan back. It never touches the canvas.\n *\n * Host usage (apps/client/src/app/api/chat/route.ts):\n * export const runtime = 'nodejs';\n * export const POST = createWorkflowChatPOST({\n * authorize: createBPMApiSessionAuthorize(),\n * });\n *\n * The route answers 404 unless the assistant is enabled\n * (`BPM_AI_ASSISTANT_ENABLED=true`, read per request, or `options.enabled`),\n * runs the host's optional `authorize` hook (401 when it says no), bounds the\n * request (bytes and messages) and the model output (tokens), and drops any\n * `system` message the client sent (Phase 23 P4).\n */\n\n/** Default OpenAI model id (overridable via BPM_LLM_MODEL). */\nconst DEFAULT_MODEL = 'gpt-5.4-mini';\n\n/**\n * Resolve the model via the OpenAI provider directly (reads `OPENAI_API_KEY`).\n * Accepts a bare id (`gpt-5.4-mini`) or a `openai/`-prefixed id; the prefix is\n * stripped. This deployment talks to OpenAI directly — no AI Gateway.\n */\nfunction resolveModel(setting: string): LanguageModel {\n return openai(setting.replace(/^openai\\//u, ''));\n}\n\n/**\n * Strict guardrail: the assistant may ONLY design this approval flow, using the\n * provided tools. Lives server-side so it cannot be overridden by\n * client-supplied messages (the route drops every `system` message a client\n * sends). Shared with the offline Chrome model through `workflow-chat-prompt`.\n */\nexport { WORKFLOW_CHAT_SYSTEM_PROMPT };\n\n/** Build AI SDK tools from WORKFLOW_TOOLSET — no `execute`, so the browser runs them. */\nexport function buildWorkflowAiSdkTools(): ToolSet {\n const entries: readonly (readonly [string, Tool])[] = WORKFLOW_TOOLSET.map(\n (workflowTool) =>\n [\n workflowTool.name,\n tool({\n description: workflowTool.description,\n inputSchema: jsonSchema(\n workflowTool.inputSchema as Parameters<typeof jsonSchema>[0],\n ),\n }),\n ] as const,\n );\n\n return Object.fromEntries(entries) as ToolSet;\n}\n\n/** Upper bound on the request body, in bytes. Tool results carry snapshots. */\nexport const DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES = 1_048_576;\n/** Upper bound on the messages in one request. */\nexport const DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES = 200;\n/** Upper bound on the tokens the model may write per response. */\nexport const DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS = 4_096;\n\nexport interface WorkflowChatRouteOptions {\n /**\n * Whether the route serves at all. Absent: `BPM_AI_ASSISTANT_ENABLED` is\n * read on every request and must be `'true'`. A disabled route answers 404.\n */\n readonly enabled?: boolean | (() => boolean);\n /**\n * The host's check that the caller may use the assistant (a session, a\n * designer permission). Called before the body is read; `false` (or a\n * throw) answers 401. Absent: no check, so put the route behind the host's\n * own authentication.\n */\n readonly authorize?: (request: Request) => boolean | Promise<boolean>;\n /** Request body ceiling in bytes (413 above it). */\n readonly maxRequestBytes?: number;\n /** Message count ceiling (413 above it). */\n readonly maxMessages?: number;\n /** Output token ceiling passed to the model. */\n readonly maxOutputTokens?: number;\n /** Override the OpenAI model id (else BPM_LLM_MODEL env, else the default). */\n readonly model?: string;\n /** Override the system prompt (else the strict design-only guardrail). */\n readonly system?: string;\n}\n\nconst plainResponse = (status: number, text: string): Response =>\n new Response(text, {\n headers: { 'Content-Type': 'text/plain; charset=utf-8' },\n status,\n });\n\nfunction isEnabled(enabled: WorkflowChatRouteOptions['enabled']): boolean {\n if (typeof enabled === 'function') {\n return enabled();\n }\n\n return enabled ?? process.env.BPM_AI_ASSISTANT_ENABLED === 'true';\n}\n\nasync function isAuthorized(\n request: Request,\n authorize: WorkflowChatRouteOptions['authorize'],\n): Promise<boolean> {\n if (!authorize) {\n return true;\n }\n\n try {\n return (await authorize(request)) === true;\n } catch {\n return false;\n }\n}\n\nfunction isUIMessage(value: unknown): value is UIMessage {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { readonly role?: unknown }).role === 'string' &&\n Array.isArray((value as { readonly parts?: unknown }).parts)\n );\n}\n\ntype ReadMessagesResult =\n | { readonly messages: readonly UIMessage[]; readonly ok: true }\n | { readonly ok: false; readonly response: Response };\n\n/**\n * The request body as text, or `null` once it grows past `maxBytes`; reading\n * stops (and the stream is cancelled) at that point.\n */\nasync function readBodyWithinLimit(\n request: Request,\n maxBytes: number,\n): Promise<string | null> {\n if (request.body === null) {\n return '';\n }\n\n const reader = request.body.getReader();\n // Local to this read and appended in place: copying the list per chunk\n // would make a body of many tiny chunks quadratic.\n const chunks: Uint8Array[] = [];\n\n const readWithin = async (total: number): Promise<number | null> => {\n const { done, value } = await reader.read();\n\n if (done) {\n return total;\n }\n\n const nextTotal = total + value.byteLength;\n\n if (nextTotal > maxBytes) {\n await reader.cancel().catch((): void => undefined);\n\n return null;\n }\n\n chunks.push(value);\n\n return readWithin(nextTotal);\n };\n\n const total = await readWithin(0);\n\n if (total === null) {\n return null;\n }\n\n const bytes = new Uint8Array(total);\n\n chunks.reduce((offset, chunk): number => {\n bytes.set(chunk, offset);\n\n return offset + chunk.byteLength;\n }, 0);\n\n return new TextDecoder().decode(bytes);\n}\n\n/**\n * The client's messages, bounded and without any `system` message: the\n * system prompt is the route's alone. The body is read as text first so its\n * size is checked before anything is parsed.\n */\nexport async function readWorkflowChatMessages(\n request: Request,\n limits: Readonly<{ maxMessages: number; maxRequestBytes: number }>,\n): Promise<ReadMessagesResult> {\n const declaredLength = Number(request.headers.get('content-length') ?? '0');\n\n if (declaredLength > limits.maxRequestBytes) {\n return { ok: false, response: plainResponse(413, 'Request too large') };\n }\n\n // A chunked request declares no length: read it with the limit applied as\n // it arrives, so an oversized body is cut off instead of buffered whole.\n const text = await readBodyWithinLimit(request, limits.maxRequestBytes);\n\n if (text === null) {\n return { ok: false, response: plainResponse(413, 'Request too large') };\n }\n\n let body: unknown;\n\n try {\n body = JSON.parse(text);\n } catch {\n return { ok: false, response: plainResponse(400, 'Invalid request') };\n }\n\n const messages: unknown =\n typeof body === 'object' && body !== null\n ? (body as { readonly messages?: unknown }).messages\n : undefined;\n\n if (!Array.isArray(messages) || !messages.every(isUIMessage)) {\n return { ok: false, response: plainResponse(400, 'Invalid request') };\n }\n\n if (messages.length > limits.maxMessages) {\n return { ok: false, response: plainResponse(413, 'Too many messages') };\n }\n\n return {\n messages: messages.filter((message) => message.role !== 'system'),\n ok: true,\n };\n}\n\n/** Where the BPM API listens in local development (`@rytass/bpm-core-client`). */\nconst LOCAL_BPM_API_ORIGIN = 'http://localhost:17603';\n/** The API's \"who is signed in\" endpoint (`apps/api` `GET /auth/me`). */\nexport const DEFAULT_BPM_API_SESSION_PATH = '/auth/me';\n/** How long the session check may take before the route answers 401. */\nexport const DEFAULT_BPM_API_SESSION_TIMEOUT_MS = 5_000;\n\nexport interface BPMApiSessionAuthorizeOptions {\n /**\n * The absolute API origin to ask, e.g. an internal service URL. Absent:\n * read from configuration by {@link resolveBPMApiSessionBaseUrl}.\n */\n readonly apiBaseUrl?: string;\n /** The fetch to use (tests, instrumented hosts). Default: global `fetch`. */\n readonly fetch?: typeof fetch;\n /** The session endpoint path. Default `/auth/me`. */\n readonly sessionPath?: string;\n /** Milliseconds before the check gives up and refuses. Default 5 000. */\n readonly timeoutMs?: number;\n}\n\n/** An absolute http(s) URL without its trailing slash, or `null`. */\nconst readAbsoluteUrl = (value: string | undefined): string | null => {\n const configured = value?.trim();\n\n if (!configured) {\n return null;\n }\n\n try {\n const url = new URL(configured);\n\n return url.protocol === 'http:' || url.protocol === 'https:'\n ? url.toString().replace(/\\/$/u, '')\n : null;\n } catch {\n return null;\n }\n};\n\nconst readAbsoluteOrigin = (value: string | undefined): string | null => {\n const configured = readAbsoluteUrl(value);\n\n return configured === null ? null : new URL(configured).origin;\n};\n\n/**\n * The API origin the session check asks. It comes only from configuration,\n * never from the request: a `Host` or forwarded header the caller controls\n * must not choose the server that decides whether the caller is signed in.\n *\n * 1. `apiBaseUrl` when given;\n * 2. `BPM_API_INTERNAL_URL` (server-only, e.g. the API's in-cluster URL);\n * 3. `NEXT_PUBLIC_API_AUTH_URL` (the `/auth/*` base);\n * 4. the origin of `NEXT_PUBLIC_API_URL` (the GraphQL endpoint);\n * 5. `http://localhost:17603` outside `NODE_ENV=production`.\n *\n * Only absolute http(s) URLs count; a relative setting is ignored. `null`\n * when nothing applies, and the session check then refuses every request.\n */\nexport function resolveBPMApiSessionBaseUrl(\n apiBaseUrl?: string,\n): string | null {\n return (\n readAbsoluteUrl(apiBaseUrl) ??\n readAbsoluteUrl(process.env.BPM_API_INTERNAL_URL) ??\n readAbsoluteUrl(process.env.NEXT_PUBLIC_API_AUTH_URL) ??\n readAbsoluteOrigin(process.env.NEXT_PUBLIC_API_URL) ??\n (process.env.NODE_ENV === 'production' ? null : LOCAL_BPM_API_ORIGIN)\n );\n}\n\nconst isSignedInMember = (value: unknown): boolean =>\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { readonly memberId?: unknown }).memberId === 'string' &&\n (value as { readonly memberId: string }).memberId.length > 0;\n\n/**\n * An `authorize` hook for {@link createWorkflowChatPOST} that lets in only a\n * caller the BPM API recognises as signed in: it forwards the request's\n * `Cookie` header (nothing else) to the API's session endpoint and accepts a\n * `200` whose JSON names a `memberId`. No cookie, any other status, a body\n * of another shape, a network error or a timeout refuses, so the route\n * answers 401. The session itself is never read or kept here.\n *\n * Host usage (apps/client/src/app/api/chat/route.ts):\n * export const POST = createWorkflowChatPOST({\n * authorize: createBPMApiSessionAuthorize(),\n * });\n */\nexport function createBPMApiSessionAuthorize(\n options: BPMApiSessionAuthorizeOptions = {},\n): (request: Request) => Promise<boolean> {\n return async function authorize(request: Request): Promise<boolean> {\n const cookie = request.headers.get('cookie');\n\n if (!cookie) {\n return false;\n }\n\n const baseUrl = resolveBPMApiSessionBaseUrl(options.apiBaseUrl);\n\n if (baseUrl === null) {\n return false;\n }\n\n const fetchImpl = options.fetch ?? fetch;\n const url = `${baseUrl}${options.sessionPath ?? DEFAULT_BPM_API_SESSION_PATH}`;\n\n try {\n const response = await fetchImpl(url, {\n cache: 'no-store',\n headers: { Accept: 'application/json', Cookie: cookie },\n method: 'GET',\n redirect: 'manual',\n signal: AbortSignal.timeout(\n options.timeoutMs ?? DEFAULT_BPM_API_SESSION_TIMEOUT_MS,\n ),\n });\n\n if (response.status !== 200) {\n return false;\n }\n\n return isSignedInMember(await response.json());\n } catch {\n return false;\n }\n };\n}\n\n/** Create the `POST` handler for the workflow chat route. */\nexport function createWorkflowChatPOST(\n options: WorkflowChatRouteOptions = {},\n): (request: Request) => Promise<Response> {\n const tools = buildWorkflowAiSdkTools();\n\n return async function POST(request: Request): Promise<Response> {\n if (!isEnabled(options.enabled)) {\n return plainResponse(404, 'Not Found');\n }\n\n if (!(await isAuthorized(request, options.authorize))) {\n return plainResponse(401, 'Unauthorized');\n }\n\n const read = await readWorkflowChatMessages(request, {\n maxMessages: options.maxMessages ?? DEFAULT_WORKFLOW_CHAT_MAX_MESSAGES,\n maxRequestBytes:\n options.maxRequestBytes ?? DEFAULT_WORKFLOW_CHAT_MAX_REQUEST_BYTES,\n });\n\n if (!read.ok) {\n return read.response;\n }\n\n const result = streamText({\n maxOutputTokens:\n options.maxOutputTokens ?? DEFAULT_WORKFLOW_CHAT_MAX_OUTPUT_TOKENS,\n messages: await convertToModelMessages([...read.messages]),\n model: resolveModel(\n options.model ?? process.env.BPM_LLM_MODEL ?? DEFAULT_MODEL,\n ),\n system: options.system ?? WORKFLOW_CHAT_SYSTEM_PROMPT,\n tools,\n });\n\n return result.toUIMessageStreamResponse();\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/delegations-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/delegations-CVmtpkRn.cjs");let t=require("react/jsx-runtime");var n={title:`代理設定 | BPM Admin`,description:`設定簽核代理規則,讓符合範圍的待簽任務自動改派給代理人。`};function r(){return(0,t.jsx)(e.t,{})}exports.default=r,exports.metadata=n;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../chunks/delegations-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../chunks/delegations-CrfjsH94.cjs");let t=require("react/jsx-runtime");var n={title:`我的代理 | BPM Admin`,description:`設定自己的簽核代理,讓指定期間內的新待簽任務自動交由代理人處理。`};function r(){return(0,t.jsx)(e.t,{})}exports.default=r,exports.metadata=n;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/detail-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/detail-ChseSF55.cjs");let t=require("react/jsx-runtime");var n={title:`案件詳情 | BPM Admin`};async function r({params:n}){let{id:r}=await n;return(0,t.jsx)(e.t,{instanceId:r})}exports.default=r,exports.metadata=n;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/compose-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/compose-Bb5bUVFd.cjs");let t=require("react/jsx-runtime"),n=require("next/server");var r={title:`建立模板(表單 + 流程) | BPM Admin`,description:`以精靈式流程一次完成 BPM 表單與簽核流程設計並發佈。`};async function i(){return await(0,n.connection)(),(0,t.jsx)(e.t,{aiAssistantAvailable:!!process.env.OPENAI_API_KEY,showAiAssistant:process.env.BPM_AI_ASSISTANT_ENABLED===`true`})}exports.default=i,exports.metadata=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/designer-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../../../chunks/designer-CX9bhYJS.cjs");let t=require("react/jsx-runtime");var n={title:`流程設計器 | BPM Admin`,description:`以視覺化設計器編輯 BPM 簽核流程節點、條件與發佈版本。`};async function r({params:n}){let{id:r}=await n;return(0,t.jsx)(e.t,{aiAssistantAvailable:!!process.env.OPENAI_API_KEY,showAiAssistant:process.env.BPM_AI_ASSISTANT_ENABLED===`true`,showDryRun:process.env.BPM_TEMPLATE_DRY_RUN_ENABLED!==`false`,templateId:r})}exports.default=r,exports.metadata=n;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/delegations-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/delegations-CVmtpkRn.cjs");exports.AdminDelegationsView=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as AdminDelegationsView } from "../../../chunks/delegations-
|
|
1
|
+
export { t as AdminDelegationsView } from "../../../chunks/delegations-CxnNvTCc.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/users-EqSzDhuj.cjs"),t=require("../../chunks/orgs-B_2J2tLX.cjs"),n=require("../../chunks/delegations-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/users-EqSzDhuj.cjs"),t=require("../../chunks/orgs-B_2J2tLX.cjs"),n=require("../../chunks/delegations-CVmtpkRn.cjs"),r=require("./webhook-endpoints/index.cjs");exports.AdminDelegationsView=n.t,exports.AdminOrgsView=t.t,exports.AdminUsersView=e.t,exports.AdminWebhookEndpointsView=r.AdminWebhookEndpointsView;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/users-BBtiZ9QQ.js";
|
|
2
2
|
import { t } from "../../chunks/orgs-DqxMds26.js";
|
|
3
|
-
import { t as n } from "../../chunks/delegations-
|
|
3
|
+
import { t as n } from "../../chunks/delegations-CxnNvTCc.js";
|
|
4
4
|
import { AdminWebhookEndpointsView as r } from "./webhook-endpoints/index.js";
|
|
5
5
|
export { n as AdminDelegationsView, t as AdminOrgsView, e as AdminUsersView, r as AdminWebhookEndpointsView };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/delegations-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/delegations-CrfjsH94.cjs");exports.DelegationsView=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DelegationsView } from "../../chunks/delegations-
|
|
1
|
+
export { t as DelegationsView } from "../../chunks/delegations-9-yvWWws.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/FormBuilderView-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../chunks/FormBuilderView-CpUgbSbt.cjs");exports.FormBuilderView=e.t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as FormBuilderView } from "../../../chunks/FormBuilderView-
|
|
1
|
+
export { t as FormBuilderView } from "../../../chunks/FormBuilderView-CFRiw04B.js";
|