adminforth 2.58.5 → 2.59.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/dist/spa/src/types/adapters/ChatSurfaceAdapter.ts +84 -0
- package/dist/spa/src/types/adapters/EmailAdapter.ts +2 -2
- package/dist/spa/src/types/adapters/index.ts +7 -0
- package/dist/types/adapters/ChatSurfaceAdapter.d.ts +66 -0
- package/dist/types/adapters/ChatSurfaceAdapter.d.ts.map +1 -0
- package/dist/types/adapters/ChatSurfaceAdapter.js +2 -0
- package/dist/types/adapters/ChatSurfaceAdapter.js.map +1 -0
- package/dist/types/adapters/EmailAdapter.d.ts +2 -2
- package/dist/types/adapters/EmailAdapter.d.ts.map +1 -1
- package/dist/types/adapters/index.d.ts +1 -0
- package/dist/types/adapters/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AdminUser } from "../Common.js";
|
|
2
|
+
import type { IAdminForth } from "../Back.js";
|
|
3
|
+
|
|
4
|
+
export type ChatSurfaceRequestContext = {
|
|
5
|
+
body: unknown;
|
|
6
|
+
headers: Record<string, unknown>;
|
|
7
|
+
abortSignal: AbortSignal;
|
|
8
|
+
rawRequest?: unknown;
|
|
9
|
+
rawResponse?: unknown;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ChatSurfaceIncomingMessage = {
|
|
13
|
+
surface: string;
|
|
14
|
+
prompt: string;
|
|
15
|
+
externalConversationId: string;
|
|
16
|
+
externalUserId: string;
|
|
17
|
+
userTimeZone?: string;
|
|
18
|
+
modeName?: string | null;
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ChatSurfaceEvent =
|
|
23
|
+
| {
|
|
24
|
+
type: "text_delta";
|
|
25
|
+
delta: string;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
type: "reasoning_delta";
|
|
29
|
+
delta: string;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
type: "tool_call";
|
|
33
|
+
event: unknown;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
type: "done";
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
type: "error";
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export interface ChatSurfaceEventSink {
|
|
45
|
+
emit(event: ChatSurfaceEvent): void | Promise<void>;
|
|
46
|
+
close?(): void | Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ChatSurfaceAdapter {
|
|
50
|
+
/**
|
|
51
|
+
* Stable surface identifier used in webhook URLs and session ids.
|
|
52
|
+
*/
|
|
53
|
+
name: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Validates adapter configuration during plugin initialization.
|
|
57
|
+
*/
|
|
58
|
+
validate(): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Converts an incoming surface webhook/request into an AdminForth Agent prompt.
|
|
62
|
+
* Return null when the request is not a supported chat message.
|
|
63
|
+
*/
|
|
64
|
+
parseIncomingMessage(
|
|
65
|
+
ctx: ChatSurfaceRequestContext,
|
|
66
|
+
): ChatSurfaceIncomingMessage | null | Promise<ChatSurfaceIncomingMessage | null>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Creates a response sink for sending agent events back to the external surface.
|
|
70
|
+
*/
|
|
71
|
+
createEventSink(
|
|
72
|
+
ctx: ChatSurfaceRequestContext,
|
|
73
|
+
incoming: ChatSurfaceIncomingMessage,
|
|
74
|
+
): ChatSurfaceEventSink | Promise<ChatSurfaceEventSink>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Maps an external surface user to an authorized AdminForth admin user.
|
|
78
|
+
* Return null to reject the incoming chat message.
|
|
79
|
+
*/
|
|
80
|
+
resolveAdminUser(input: {
|
|
81
|
+
adminforth: IAdminForth;
|
|
82
|
+
incoming: ChatSurfaceIncomingMessage;
|
|
83
|
+
}): AdminUser | null | Promise<AdminUser | null>;
|
|
84
|
+
}
|
|
@@ -11,14 +11,14 @@ export interface EmailAdapter {
|
|
|
11
11
|
* @param from - The sender's email address
|
|
12
12
|
* @param to - The recipient's email address
|
|
13
13
|
* @param text - The plain text version of the email
|
|
14
|
-
* @param html - The HTML version of the email
|
|
14
|
+
* @param html - The optional HTML version of the email
|
|
15
15
|
* @param subject - The subject of the email
|
|
16
16
|
*/
|
|
17
17
|
sendEmail(
|
|
18
18
|
from: string,
|
|
19
19
|
to: string,
|
|
20
20
|
text: string,
|
|
21
|
-
html: string,
|
|
21
|
+
html: string | undefined,
|
|
22
22
|
subject: string
|
|
23
23
|
): Promise<{
|
|
24
24
|
error?: string;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export type { EmailAdapter } from './EmailAdapter.js';
|
|
2
|
+
export type {
|
|
3
|
+
ChatSurfaceAdapter,
|
|
4
|
+
ChatSurfaceEvent,
|
|
5
|
+
ChatSurfaceEventSink,
|
|
6
|
+
ChatSurfaceIncomingMessage,
|
|
7
|
+
ChatSurfaceRequestContext,
|
|
8
|
+
} from './ChatSurfaceAdapter.js';
|
|
2
9
|
export type {
|
|
3
10
|
CompletionAdapter,
|
|
4
11
|
CompletionAdapterLangChainAgentPurpose,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AdminUser } from "../Common.js";
|
|
2
|
+
import type { IAdminForth } from "../Back.js";
|
|
3
|
+
export type ChatSurfaceRequestContext = {
|
|
4
|
+
body: unknown;
|
|
5
|
+
headers: Record<string, unknown>;
|
|
6
|
+
abortSignal: AbortSignal;
|
|
7
|
+
rawRequest?: unknown;
|
|
8
|
+
rawResponse?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type ChatSurfaceIncomingMessage = {
|
|
11
|
+
surface: string;
|
|
12
|
+
prompt: string;
|
|
13
|
+
externalConversationId: string;
|
|
14
|
+
externalUserId: string;
|
|
15
|
+
userTimeZone?: string;
|
|
16
|
+
modeName?: string | null;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
export type ChatSurfaceEvent = {
|
|
20
|
+
type: "text_delta";
|
|
21
|
+
delta: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: "reasoning_delta";
|
|
24
|
+
delta: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "tool_call";
|
|
27
|
+
event: unknown;
|
|
28
|
+
} | {
|
|
29
|
+
type: "done";
|
|
30
|
+
text: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "error";
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
export interface ChatSurfaceEventSink {
|
|
36
|
+
emit(event: ChatSurfaceEvent): void | Promise<void>;
|
|
37
|
+
close?(): void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface ChatSurfaceAdapter {
|
|
40
|
+
/**
|
|
41
|
+
* Stable surface identifier used in webhook URLs and session ids.
|
|
42
|
+
*/
|
|
43
|
+
name: string;
|
|
44
|
+
/**
|
|
45
|
+
* Validates adapter configuration during plugin initialization.
|
|
46
|
+
*/
|
|
47
|
+
validate(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Converts an incoming surface webhook/request into an AdminForth Agent prompt.
|
|
50
|
+
* Return null when the request is not a supported chat message.
|
|
51
|
+
*/
|
|
52
|
+
parseIncomingMessage(ctx: ChatSurfaceRequestContext): ChatSurfaceIncomingMessage | null | Promise<ChatSurfaceIncomingMessage | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a response sink for sending agent events back to the external surface.
|
|
55
|
+
*/
|
|
56
|
+
createEventSink(ctx: ChatSurfaceRequestContext, incoming: ChatSurfaceIncomingMessage): ChatSurfaceEventSink | Promise<ChatSurfaceEventSink>;
|
|
57
|
+
/**
|
|
58
|
+
* Maps an external surface user to an authorized AdminForth admin user.
|
|
59
|
+
* Return null to reject the incoming chat message.
|
|
60
|
+
*/
|
|
61
|
+
resolveAdminUser(input: {
|
|
62
|
+
adminforth: IAdminForth;
|
|
63
|
+
incoming: ChatSurfaceIncomingMessage;
|
|
64
|
+
}): AdminUser | null | Promise<AdminUser | null>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ChatSurfaceAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSurfaceAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/ChatSurfaceAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;OAGG;IACH,oBAAoB,CAClB,GAAG,EAAE,yBAAyB,GAC7B,0BAA0B,GAAG,IAAI,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAElF;;OAEG;IACH,eAAe,CACb,GAAG,EAAE,yBAAyB,EAC9B,QAAQ,EAAE,0BAA0B,GACnC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAExD;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE;QACtB,UAAU,EAAE,WAAW,CAAC;QACxB,QAAQ,EAAE,0BAA0B,CAAC;KACtC,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatSurfaceAdapter.js","sourceRoot":"","sources":["../../../types/adapters/ChatSurfaceAdapter.ts"],"names":[],"mappings":""}
|
|
@@ -9,10 +9,10 @@ export interface EmailAdapter {
|
|
|
9
9
|
* @param from - The sender's email address
|
|
10
10
|
* @param to - The recipient's email address
|
|
11
11
|
* @param text - The plain text version of the email
|
|
12
|
-
* @param html - The HTML version of the email
|
|
12
|
+
* @param html - The optional HTML version of the email
|
|
13
13
|
* @param subject - The subject of the email
|
|
14
14
|
*/
|
|
15
|
-
sendEmail(from: string, to: string, text: string, html: string, subject: string): Promise<{
|
|
15
|
+
sendEmail(from: string, to: string, text: string, html: string | undefined, subject: string): Promise<{
|
|
16
16
|
error?: string;
|
|
17
17
|
ok?: boolean;
|
|
18
18
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/EmailAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAE3B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;;;OAOG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"EmailAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/EmailAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAE3B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;;;;;OAOG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,EAAE,CAAC,EAAE,OAAO,CAAC;KACd,CAAC,CAAC;CACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { EmailAdapter } from './EmailAdapter.js';
|
|
2
|
+
export type { ChatSurfaceAdapter, ChatSurfaceEvent, ChatSurfaceEventSink, ChatSurfaceIncomingMessage, ChatSurfaceRequestContext, } from './ChatSurfaceAdapter.js';
|
|
2
3
|
export type { CompletionAdapter, CompletionAdapterLangChainAgentPurpose, CompletionAdapterLangChainAgentSpec, CompletionReasoningEffort, LangChainAgentCompletionAdapter, CompletionRequest, CompletionStreamEvent, CompletionTool, } from './CompletionAdapter.js';
|
|
3
4
|
export type { ImageGenerationAdapter } from './ImageGenerationAdapter.js';
|
|
4
5
|
export type { KeyValueAdapter } from './KeyValueAdapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../types/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EACX,iBAAiB,EACjB,sCAAsC,EACtC,mCAAmC,EACnC,yBAAyB,EACzB,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EACX,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACd,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../types/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EACX,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,iBAAiB,EACjB,sCAAsC,EACtC,mCAAmC,EACnC,yBAAyB,EACzB,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EACX,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACd,MAAM,mBAAmB,CAAC"}
|