@pipeshub-ai/mcp 2.0.1 → 2.2.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/README.md +90 -2
- package/bin/mcp-server.js +1156 -213
- package/bin/mcp-server.js.map +30 -16
- package/esm/funcs/agentsListAgents.d.ts +10 -0
- package/esm/funcs/agentsListAgents.d.ts.map +1 -0
- package/esm/funcs/agentsListAgents.js +83 -0
- package/esm/funcs/agentsListAgents.js.map +1 -0
- package/esm/funcs/agentsStreamConversation.d.ts +10 -0
- package/esm/funcs/agentsStreamConversation.d.ts.map +1 -0
- package/esm/funcs/agentsStreamConversation.js +83 -0
- package/esm/funcs/agentsStreamConversation.js.map +1 -0
- package/esm/funcs/agentsStreamMessage.d.ts +10 -0
- package/esm/funcs/agentsStreamMessage.d.ts.map +1 -0
- package/esm/funcs/agentsStreamMessage.js +86 -0
- package/esm/funcs/agentsStreamMessage.js.map +1 -0
- package/esm/funcs/connectorGetRecordContent.d.ts +43 -0
- package/esm/funcs/connectorGetRecordContent.d.ts.map +1 -0
- package/esm/funcs/connectorGetRecordContent.js +114 -0
- package/esm/funcs/connectorGetRecordContent.js.map +1 -0
- package/esm/funcs/conversationsStreamConversation.d.ts.map +1 -1
- package/esm/funcs/conversationsStreamConversation.js +2 -4
- package/esm/funcs/conversationsStreamConversation.js.map +1 -1
- package/esm/funcs/conversationsStreamMessage.d.ts.map +1 -1
- package/esm/funcs/conversationsStreamMessage.js +0 -7
- package/esm/funcs/conversationsStreamMessage.js.map +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js +1 -1
- package/esm/funcs/userGroupsGetAllUserGroups.js.map +1 -1
- package/esm/hooks/registration.d.ts.map +1 -1
- package/esm/hooks/registration.js +2 -1
- package/esm/hooks/registration.js.map +1 -1
- package/esm/hooks/request-context.d.ts +10 -0
- package/esm/hooks/request-context.d.ts.map +1 -0
- package/esm/hooks/request-context.js +38 -0
- package/esm/hooks/request-context.js.map +1 -0
- package/esm/hooks/requestid.d.ts +5 -0
- package/esm/hooks/requestid.d.ts.map +1 -0
- package/esm/hooks/requestid.js +58 -0
- package/esm/hooks/requestid.js.map +1 -0
- package/esm/mcp-server/instructions.d.ts +2 -0
- package/esm/mcp-server/instructions.d.ts.map +1 -0
- package/esm/mcp-server/instructions.js +106 -0
- package/esm/mcp-server/instructions.js.map +1 -0
- package/esm/mcp-server/prompts/pipeshubAssistant.d.ts +8 -0
- package/esm/mcp-server/prompts/pipeshubAssistant.d.ts.map +1 -0
- package/esm/mcp-server/prompts/pipeshubAssistant.js +31 -0
- package/esm/mcp-server/prompts/pipeshubAssistant.js.map +1 -0
- package/esm/mcp-server/server.d.ts.map +1 -1
- package/esm/mcp-server/server.js +16 -62
- package/esm/mcp-server/server.js.map +1 -1
- package/esm/mcp-server/tools/_helpers.d.ts +78 -0
- package/esm/mcp-server/tools/_helpers.d.ts.map +1 -1
- package/esm/mcp-server/tools/_helpers.js +155 -1
- package/esm/mcp-server/tools/_helpers.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubAgents.d.ts +8 -0
- package/esm/mcp-server/tools/pipeshubAgents.d.ts.map +1 -0
- package/esm/mcp-server/tools/pipeshubAgents.js +62 -0
- package/esm/mcp-server/tools/pipeshubAgents.js.map +1 -0
- package/esm/mcp-server/tools/pipeshubChat.d.ts +6 -1
- package/esm/mcp-server/tools/pipeshubChat.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubChat.js +79 -23
- package/esm/mcp-server/tools/pipeshubChat.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubDirectory.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubDirectory.js +0 -1
- package/esm/mcp-server/tools/pipeshubDirectory.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubDownloadRecord.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubDownloadRecord.js +0 -3
- package/esm/mcp-server/tools/pipeshubDownloadRecord.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts +8 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.d.ts.map +1 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js +63 -0
- package/esm/mcp-server/tools/pipeshubGetRecordContent.js.map +1 -0
- package/esm/mcp-server/tools/pipeshubSearch.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubSearch.js +8 -7
- package/esm/mcp-server/tools/pipeshubSearch.js.map +1 -1
- package/esm/mcp-server/tools/pipeshubSources.d.ts.map +1 -1
- package/esm/mcp-server/tools/pipeshubSources.js +0 -4
- package/esm/mcp-server/tools/pipeshubSources.js.map +1 -1
- package/esm/mcp-server/tools.d.ts.map +1 -1
- package/esm/mcp-server/tools.js +13 -1
- package/esm/mcp-server/tools.js.map +1 -1
- package/esm/models/agentops.d.ts +119 -0
- package/esm/models/agentops.d.ts.map +1 -0
- package/esm/models/agentops.js +97 -0
- package/esm/models/agentops.js.map +1 -0
- package/esm/models/getrecordcontentop.d.ts +6 -0
- package/esm/models/getrecordcontentop.d.ts.map +1 -0
- package/esm/models/getrecordcontentop.js +5 -0
- package/esm/models/getrecordcontentop.js.map +1 -0
- package/esm/tool-names.d.ts.map +1 -1
- package/esm/tool-names.js +10 -2
- package/esm/tool-names.js.map +1 -1
- package/package.json +3 -2
- package/src/funcs/agentsListAgents.ts +141 -0
- package/src/funcs/agentsStreamConversation.ts +144 -0
- package/src/funcs/agentsStreamMessage.ts +147 -0
- package/src/funcs/connectorGetRecordContent.ts +179 -0
- package/src/funcs/conversationsStreamConversation.ts +2 -4
- package/src/funcs/conversationsStreamMessage.ts +0 -8
- package/src/funcs/userGroupsGetAllUserGroups.ts +1 -1
- package/src/hooks/registration.ts +2 -1
- package/src/hooks/request-context.ts +47 -0
- package/src/hooks/requestid.ts +62 -0
- package/src/mcp-server/instructions.ts +106 -0
- package/src/mcp-server/prompts/pipeshubAssistant.ts +37 -0
- package/src/mcp-server/server.ts +18 -64
- package/src/mcp-server/tools/_helpers.ts +216 -1
- package/src/mcp-server/tools/pipeshubAgents.ts +68 -0
- package/src/mcp-server/tools/pipeshubChat.ts +78 -23
- package/src/mcp-server/tools/pipeshubDirectory.ts +0 -1
- package/src/mcp-server/tools/pipeshubDownloadRecord.ts +0 -4
- package/src/mcp-server/tools/pipeshubGetRecordContent.ts +67 -0
- package/src/mcp-server/tools/pipeshubSearch.ts +8 -7
- package/src/mcp-server/tools/pipeshubSources.ts +0 -5
- package/src/mcp-server/tools.ts +14 -1
- package/src/models/agentops.ts +160 -0
- package/src/models/getrecordcontentop.ts +11 -0
- package/src/tool-names.ts +10 -2
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Mirrors `usersGetAllUsers.ts`
|
|
2
|
+
// but hits `GET /agents` (operationId `listAgents`). Returns the raw JSON
|
|
3
|
+
// `Response`; the caller parses the `{ success, agents, pagination }` envelope.
|
|
4
|
+
|
|
5
|
+
import { PipeshubCore } from "../core.js";
|
|
6
|
+
import { encodeFormQuery } from "../lib/encodings.js";
|
|
7
|
+
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
9
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import {
|
|
13
|
+
ListAgentsRequest,
|
|
14
|
+
ListAgentsRequest$zodSchema,
|
|
15
|
+
} from "../models/agentops.js";
|
|
16
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
17
|
+
import {
|
|
18
|
+
ConnectionError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
RequestAbortedError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
UnexpectedClientError,
|
|
23
|
+
} from "../models/errors/httpclienterrors.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
export function agentsListAgents(
|
|
29
|
+
client$: PipeshubCore,
|
|
30
|
+
request?: ListAgentsRequest | undefined,
|
|
31
|
+
options?: RequestOptions,
|
|
32
|
+
): APIPromise<
|
|
33
|
+
Result<
|
|
34
|
+
Response,
|
|
35
|
+
| APIError
|
|
36
|
+
| SDKValidationError
|
|
37
|
+
| UnexpectedClientError
|
|
38
|
+
| InvalidRequestError
|
|
39
|
+
| RequestAbortedError
|
|
40
|
+
| RequestTimeoutError
|
|
41
|
+
| ConnectionError
|
|
42
|
+
>
|
|
43
|
+
> {
|
|
44
|
+
return new APIPromise($do(client$, request, options));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function $do(
|
|
48
|
+
client$: PipeshubCore,
|
|
49
|
+
request?: ListAgentsRequest | undefined,
|
|
50
|
+
options?: RequestOptions,
|
|
51
|
+
): Promise<
|
|
52
|
+
[
|
|
53
|
+
Result<
|
|
54
|
+
Response,
|
|
55
|
+
| APIError
|
|
56
|
+
| SDKValidationError
|
|
57
|
+
| UnexpectedClientError
|
|
58
|
+
| InvalidRequestError
|
|
59
|
+
| RequestAbortedError
|
|
60
|
+
| RequestTimeoutError
|
|
61
|
+
| ConnectionError
|
|
62
|
+
>,
|
|
63
|
+
APICall,
|
|
64
|
+
]
|
|
65
|
+
> {
|
|
66
|
+
const parsed$ = safeParse(
|
|
67
|
+
request,
|
|
68
|
+
(value$) => ListAgentsRequest$zodSchema.optional().parse(value$),
|
|
69
|
+
"Input validation failed",
|
|
70
|
+
);
|
|
71
|
+
if (!parsed$.ok) {
|
|
72
|
+
return [parsed$, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const payload$ = parsed$.value;
|
|
75
|
+
const body$ = null;
|
|
76
|
+
const path$ = pathToFunc("/agents")();
|
|
77
|
+
const query$ = encodeFormQuery({
|
|
78
|
+
"page": payload$?.page,
|
|
79
|
+
"limit": payload$?.limit,
|
|
80
|
+
"search": payload$?.search,
|
|
81
|
+
"sort_by": payload$?.sortBy,
|
|
82
|
+
"sort_order": payload$?.sortOrder,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const headers$ = new Headers(compactMap({
|
|
86
|
+
Accept: "application/json",
|
|
87
|
+
}));
|
|
88
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
89
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
90
|
+
|
|
91
|
+
const context = {
|
|
92
|
+
options: client$._options,
|
|
93
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
94
|
+
operationID: "listAgents",
|
|
95
|
+
oAuth2Scopes: ["agent:read"],
|
|
96
|
+
resolvedSecurity: requestSecurity,
|
|
97
|
+
securitySource: client$._options.security,
|
|
98
|
+
retryConfig: options?.retries
|
|
99
|
+
|| client$._options.retryConfig
|
|
100
|
+
|| { strategy: "none" },
|
|
101
|
+
retryCodes: options?.retryCodes || [
|
|
102
|
+
"429",
|
|
103
|
+
"500",
|
|
104
|
+
"502",
|
|
105
|
+
"503",
|
|
106
|
+
"504",
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const requestRes = client$._createRequest(context, {
|
|
111
|
+
security: requestSecurity,
|
|
112
|
+
method: "GET",
|
|
113
|
+
baseURL: options?.serverURL,
|
|
114
|
+
path: path$,
|
|
115
|
+
headers: headers$,
|
|
116
|
+
query: query$,
|
|
117
|
+
body: body$,
|
|
118
|
+
userAgent: client$._options.userAgent,
|
|
119
|
+
timeoutMs: options?.timeoutMs || client$._options.timeoutMs
|
|
120
|
+
|| -1,
|
|
121
|
+
}, options);
|
|
122
|
+
if (!requestRes.ok) {
|
|
123
|
+
return [requestRes, { status: "invalid" }];
|
|
124
|
+
}
|
|
125
|
+
const req$ = requestRes.value;
|
|
126
|
+
|
|
127
|
+
const doResult = await client$._do(req$, {
|
|
128
|
+
context,
|
|
129
|
+
errorCodes: [],
|
|
130
|
+
retryConfig: context.retryConfig,
|
|
131
|
+
retryCodes: context.retryCodes,
|
|
132
|
+
});
|
|
133
|
+
if (!doResult.ok) {
|
|
134
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
135
|
+
}
|
|
136
|
+
return [doResult, {
|
|
137
|
+
status: "complete",
|
|
138
|
+
"request": req$,
|
|
139
|
+
response: doResult.value,
|
|
140
|
+
}];
|
|
141
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// POST `/agents/{agentKey}/conversations/stream` (operationId
|
|
2
|
+
// `streamAgentConversation`) to start a conversation with a specific agent.
|
|
3
|
+
// Returns the raw streaming `Response`; the caller parses `text/event-stream`
|
|
4
|
+
// line-by-line.
|
|
5
|
+
|
|
6
|
+
import { PipeshubCore } from "../core.js";
|
|
7
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
AgentStreamCreateConversationRequest,
|
|
15
|
+
AgentStreamCreateConversationRequest$zodSchema,
|
|
16
|
+
} from "../models/agentops.js";
|
|
17
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
18
|
+
import {
|
|
19
|
+
ConnectionError,
|
|
20
|
+
InvalidRequestError,
|
|
21
|
+
RequestAbortedError,
|
|
22
|
+
RequestTimeoutError,
|
|
23
|
+
UnexpectedClientError,
|
|
24
|
+
} from "../models/errors/httpclienterrors.js";
|
|
25
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
export function agentsStreamConversation(
|
|
30
|
+
client$: PipeshubCore,
|
|
31
|
+
request: AgentStreamCreateConversationRequest,
|
|
32
|
+
options?: RequestOptions,
|
|
33
|
+
): APIPromise<
|
|
34
|
+
Result<
|
|
35
|
+
Response,
|
|
36
|
+
| APIError
|
|
37
|
+
| SDKValidationError
|
|
38
|
+
| UnexpectedClientError
|
|
39
|
+
| InvalidRequestError
|
|
40
|
+
| RequestAbortedError
|
|
41
|
+
| RequestTimeoutError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
>
|
|
44
|
+
> {
|
|
45
|
+
return new APIPromise($do(client$, request, options));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function $do(
|
|
49
|
+
client$: PipeshubCore,
|
|
50
|
+
request: AgentStreamCreateConversationRequest,
|
|
51
|
+
options?: RequestOptions,
|
|
52
|
+
): Promise<
|
|
53
|
+
[
|
|
54
|
+
Result<
|
|
55
|
+
Response,
|
|
56
|
+
| APIError
|
|
57
|
+
| SDKValidationError
|
|
58
|
+
| UnexpectedClientError
|
|
59
|
+
| InvalidRequestError
|
|
60
|
+
| RequestAbortedError
|
|
61
|
+
| RequestTimeoutError
|
|
62
|
+
| ConnectionError
|
|
63
|
+
>,
|
|
64
|
+
APICall,
|
|
65
|
+
]
|
|
66
|
+
> {
|
|
67
|
+
const parsed$ = safeParse(
|
|
68
|
+
request,
|
|
69
|
+
(value$) => AgentStreamCreateConversationRequest$zodSchema.parse(value$),
|
|
70
|
+
"Input validation failed",
|
|
71
|
+
);
|
|
72
|
+
if (!parsed$.ok) {
|
|
73
|
+
return [parsed$, { status: "invalid" }];
|
|
74
|
+
}
|
|
75
|
+
const payload$ = parsed$.value;
|
|
76
|
+
const body$ = encodeJSON("body", payload$.body, { explode: true });
|
|
77
|
+
|
|
78
|
+
const pathParams$ = {
|
|
79
|
+
agentKey: encodeSimple("agentKey", payload$.agentKey, {
|
|
80
|
+
explode: false,
|
|
81
|
+
charEncoding: "percent",
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
const path$ = pathToFunc(
|
|
85
|
+
"/agents/{agentKey}/conversations/stream",
|
|
86
|
+
)(pathParams$);
|
|
87
|
+
|
|
88
|
+
const headers$ = new Headers(compactMap({
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
Accept: "text/event-stream",
|
|
91
|
+
}));
|
|
92
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
93
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
94
|
+
|
|
95
|
+
const context = {
|
|
96
|
+
options: client$._options,
|
|
97
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
98
|
+
operationID: "streamAgentConversation",
|
|
99
|
+
oAuth2Scopes: ["agent:execute"],
|
|
100
|
+
resolvedSecurity: requestSecurity,
|
|
101
|
+
securitySource: client$._options.security,
|
|
102
|
+
retryConfig: options?.retries
|
|
103
|
+
|| client$._options.retryConfig
|
|
104
|
+
|| { strategy: "none" },
|
|
105
|
+
retryCodes: options?.retryCodes || [
|
|
106
|
+
"429",
|
|
107
|
+
"500",
|
|
108
|
+
"502",
|
|
109
|
+
"503",
|
|
110
|
+
"504",
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const requestRes = client$._createRequest(context, {
|
|
115
|
+
security: requestSecurity,
|
|
116
|
+
method: "POST",
|
|
117
|
+
baseURL: options?.serverURL,
|
|
118
|
+
path: path$,
|
|
119
|
+
headers: headers$,
|
|
120
|
+
body: body$,
|
|
121
|
+
userAgent: client$._options.userAgent,
|
|
122
|
+
// SSE streams are long-lived; let the caller's AbortSignal cap it.
|
|
123
|
+
timeoutMs: options?.timeoutMs || -1,
|
|
124
|
+
}, options);
|
|
125
|
+
if (!requestRes.ok) {
|
|
126
|
+
return [requestRes, { status: "invalid" }];
|
|
127
|
+
}
|
|
128
|
+
const req$ = requestRes.value;
|
|
129
|
+
|
|
130
|
+
const doResult = await client$._do(req$, {
|
|
131
|
+
context,
|
|
132
|
+
errorCodes: [],
|
|
133
|
+
retryConfig: context.retryConfig,
|
|
134
|
+
retryCodes: context.retryCodes,
|
|
135
|
+
});
|
|
136
|
+
if (!doResult.ok) {
|
|
137
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
138
|
+
}
|
|
139
|
+
return [doResult, {
|
|
140
|
+
status: "complete",
|
|
141
|
+
"request": req$,
|
|
142
|
+
response: doResult.value,
|
|
143
|
+
}];
|
|
144
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// POSTs to `/agents/{agentKey}/conversations/{conversationId}/messages/stream`
|
|
2
|
+
// (operationId `streamAgentConversationMessage`) to append a follow-up turn
|
|
3
|
+
// to an existing agent conversation. Returns the raw streaming `Response`.
|
|
4
|
+
|
|
5
|
+
import { PipeshubCore } from "../core.js";
|
|
6
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
9
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import {
|
|
13
|
+
AgentAddMessageStreamRequest,
|
|
14
|
+
AgentAddMessageStreamRequest$zodSchema,
|
|
15
|
+
} from "../models/agentops.js";
|
|
16
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
17
|
+
import {
|
|
18
|
+
ConnectionError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
RequestAbortedError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
UnexpectedClientError,
|
|
23
|
+
} from "../models/errors/httpclienterrors.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
export function agentsStreamMessage(
|
|
29
|
+
client$: PipeshubCore,
|
|
30
|
+
request: AgentAddMessageStreamRequest,
|
|
31
|
+
options?: RequestOptions,
|
|
32
|
+
): APIPromise<
|
|
33
|
+
Result<
|
|
34
|
+
Response,
|
|
35
|
+
| APIError
|
|
36
|
+
| SDKValidationError
|
|
37
|
+
| UnexpectedClientError
|
|
38
|
+
| InvalidRequestError
|
|
39
|
+
| RequestAbortedError
|
|
40
|
+
| RequestTimeoutError
|
|
41
|
+
| ConnectionError
|
|
42
|
+
>
|
|
43
|
+
> {
|
|
44
|
+
return new APIPromise($do(client$, request, options));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function $do(
|
|
48
|
+
client$: PipeshubCore,
|
|
49
|
+
request: AgentAddMessageStreamRequest,
|
|
50
|
+
options?: RequestOptions,
|
|
51
|
+
): Promise<
|
|
52
|
+
[
|
|
53
|
+
Result<
|
|
54
|
+
Response,
|
|
55
|
+
| APIError
|
|
56
|
+
| SDKValidationError
|
|
57
|
+
| UnexpectedClientError
|
|
58
|
+
| InvalidRequestError
|
|
59
|
+
| RequestAbortedError
|
|
60
|
+
| RequestTimeoutError
|
|
61
|
+
| ConnectionError
|
|
62
|
+
>,
|
|
63
|
+
APICall,
|
|
64
|
+
]
|
|
65
|
+
> {
|
|
66
|
+
const parsed$ = safeParse(
|
|
67
|
+
request,
|
|
68
|
+
(value$) => AgentAddMessageStreamRequest$zodSchema.parse(value$),
|
|
69
|
+
"Input validation failed",
|
|
70
|
+
);
|
|
71
|
+
if (!parsed$.ok) {
|
|
72
|
+
return [parsed$, { status: "invalid" }];
|
|
73
|
+
}
|
|
74
|
+
const payload$ = parsed$.value;
|
|
75
|
+
const body$ = encodeJSON("body", payload$.body, { explode: true });
|
|
76
|
+
|
|
77
|
+
const pathParams$ = {
|
|
78
|
+
agentKey: encodeSimple("agentKey", payload$.agentKey, {
|
|
79
|
+
explode: false,
|
|
80
|
+
charEncoding: "percent",
|
|
81
|
+
}),
|
|
82
|
+
conversationId: encodeSimple("conversationId", payload$.conversationId, {
|
|
83
|
+
explode: false,
|
|
84
|
+
charEncoding: "percent",
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
const path$ = pathToFunc(
|
|
88
|
+
"/agents/{agentKey}/conversations/{conversationId}/messages/stream",
|
|
89
|
+
)(pathParams$);
|
|
90
|
+
|
|
91
|
+
const headers$ = new Headers(compactMap({
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
Accept: "text/event-stream",
|
|
94
|
+
}));
|
|
95
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
96
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
97
|
+
|
|
98
|
+
const context = {
|
|
99
|
+
options: client$._options,
|
|
100
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
101
|
+
operationID: "streamAgentConversationMessage",
|
|
102
|
+
oAuth2Scopes: ["agent:execute"],
|
|
103
|
+
resolvedSecurity: requestSecurity,
|
|
104
|
+
securitySource: client$._options.security,
|
|
105
|
+
retryConfig: options?.retries
|
|
106
|
+
|| client$._options.retryConfig
|
|
107
|
+
|| { strategy: "none" },
|
|
108
|
+
retryCodes: options?.retryCodes || [
|
|
109
|
+
"429",
|
|
110
|
+
"500",
|
|
111
|
+
"502",
|
|
112
|
+
"503",
|
|
113
|
+
"504",
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const requestRes = client$._createRequest(context, {
|
|
118
|
+
security: requestSecurity,
|
|
119
|
+
method: "POST",
|
|
120
|
+
baseURL: options?.serverURL,
|
|
121
|
+
path: path$,
|
|
122
|
+
headers: headers$,
|
|
123
|
+
body: body$,
|
|
124
|
+
userAgent: client$._options.userAgent,
|
|
125
|
+
// SSE streams are long-lived; let the caller's AbortSignal cap it.
|
|
126
|
+
timeoutMs: options?.timeoutMs || -1,
|
|
127
|
+
}, options);
|
|
128
|
+
if (!requestRes.ok) {
|
|
129
|
+
return [requestRes, { status: "invalid" }];
|
|
130
|
+
}
|
|
131
|
+
const req$ = requestRes.value;
|
|
132
|
+
|
|
133
|
+
const doResult = await client$._do(req$, {
|
|
134
|
+
context,
|
|
135
|
+
errorCodes: [],
|
|
136
|
+
retryConfig: context.retryConfig,
|
|
137
|
+
retryCodes: context.retryCodes,
|
|
138
|
+
});
|
|
139
|
+
if (!doResult.ok) {
|
|
140
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
141
|
+
}
|
|
142
|
+
return [doResult, {
|
|
143
|
+
status: "complete",
|
|
144
|
+
"request": req$,
|
|
145
|
+
response: doResult.value,
|
|
146
|
+
}];
|
|
147
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from Speakeasy-generated connectorGetRecordContent.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PipeshubCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import { compactMap } from "../lib/primitives.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
9
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
10
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
|
+
import { pathToFunc } from "../lib/url.js";
|
|
12
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
21
|
+
import {
|
|
22
|
+
GetRecordContentRequest,
|
|
23
|
+
GetRecordContentRequest$zodSchema,
|
|
24
|
+
} from "../models/getrecordcontentop.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get a record's full parsed content and metadata
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Retrieve the full parsed content and metadata of a single record —
|
|
33
|
+
* the same content PipesHub's own RAG/chat pipeline uses to answer
|
|
34
|
+
* questions, returned directly instead of via chat.
|
|
35
|
+
*
|
|
36
|
+
* **When to use this vs. the other record endpoints:**
|
|
37
|
+
* - `GET /knowledgeBase/record/{recordId}` returns metadata only
|
|
38
|
+
* (name, type, indexing status, size) — no content.
|
|
39
|
+
* - `GET /knowledgeBase/stream/record/{recordId}` returns the original,
|
|
40
|
+
* unparsed file bytes — use it to download/open the source file.
|
|
41
|
+
* - **This endpoint** returns the record's full parsed content as a
|
|
42
|
+
* single plain-text `content` string (a metadata header, then the
|
|
43
|
+
* block/table text in reading order) — use it when you need the
|
|
44
|
+
* record's actual textual/tabular content without downloading and
|
|
45
|
+
* re-parsing the original file yourself.
|
|
46
|
+
*
|
|
47
|
+
* **Typical flow:** obtain a `recordId` from a `pipeshub_search` hit or
|
|
48
|
+
* a chat citation's `recordId`, then call this endpoint to read the
|
|
49
|
+
* full content when the search snippet or citation excerpt isn't
|
|
50
|
+
* enough to answer the question.
|
|
51
|
+
*
|
|
52
|
+
* **Permission scoping:**
|
|
53
|
+
*
|
|
54
|
+
* The requesting user/token must have access to the record; access is
|
|
55
|
+
* verified via the knowledge graph before content is returned — a
|
|
56
|
+
* caller with a valid scope but no access to this specific record gets
|
|
57
|
+
* a `403`.
|
|
58
|
+
*
|
|
59
|
+
* If set, this operation will use either {@link Security.bearerAuth} or {@link Security.oauth2} from the global security.
|
|
60
|
+
*/
|
|
61
|
+
export function connectorGetRecordContent(
|
|
62
|
+
client$: PipeshubCore,
|
|
63
|
+
request: GetRecordContentRequest,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): APIPromise<
|
|
66
|
+
Result<
|
|
67
|
+
Response,
|
|
68
|
+
| APIError
|
|
69
|
+
| SDKValidationError
|
|
70
|
+
| UnexpectedClientError
|
|
71
|
+
| InvalidRequestError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| ConnectionError
|
|
75
|
+
>
|
|
76
|
+
> {
|
|
77
|
+
return new APIPromise($do(
|
|
78
|
+
client$,
|
|
79
|
+
request,
|
|
80
|
+
options,
|
|
81
|
+
));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function $do(
|
|
85
|
+
client$: PipeshubCore,
|
|
86
|
+
request: GetRecordContentRequest,
|
|
87
|
+
options?: RequestOptions,
|
|
88
|
+
): Promise<
|
|
89
|
+
[
|
|
90
|
+
Result<
|
|
91
|
+
Response,
|
|
92
|
+
| APIError
|
|
93
|
+
| SDKValidationError
|
|
94
|
+
| UnexpectedClientError
|
|
95
|
+
| InvalidRequestError
|
|
96
|
+
| RequestAbortedError
|
|
97
|
+
| RequestTimeoutError
|
|
98
|
+
| ConnectionError
|
|
99
|
+
>,
|
|
100
|
+
APICall,
|
|
101
|
+
]
|
|
102
|
+
> {
|
|
103
|
+
const parsed$ = safeParse(
|
|
104
|
+
request,
|
|
105
|
+
(value$) => GetRecordContentRequest$zodSchema.parse(value$),
|
|
106
|
+
"Input validation failed",
|
|
107
|
+
);
|
|
108
|
+
if (!parsed$.ok) {
|
|
109
|
+
return [parsed$, { status: "invalid" }];
|
|
110
|
+
}
|
|
111
|
+
const payload$ = parsed$.value;
|
|
112
|
+
const body$ = null;
|
|
113
|
+
|
|
114
|
+
const pathParams$ = {
|
|
115
|
+
recordId: encodeSimple("recordId", payload$.recordId, {
|
|
116
|
+
explode: false,
|
|
117
|
+
charEncoding: "percent",
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
120
|
+
const path$ = pathToFunc("/connectors/record/{recordId}/content")(
|
|
121
|
+
pathParams$,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const headers$ = new Headers(compactMap({
|
|
125
|
+
Accept: "application/json",
|
|
126
|
+
}));
|
|
127
|
+
const securityInput = await extractSecurity(client$._options.security);
|
|
128
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
129
|
+
|
|
130
|
+
const context = {
|
|
131
|
+
options: client$._options,
|
|
132
|
+
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
133
|
+
operationID: "getRecordContent",
|
|
134
|
+
oAuth2Scopes: ["connector:read"],
|
|
135
|
+
resolvedSecurity: requestSecurity,
|
|
136
|
+
securitySource: client$._options.security,
|
|
137
|
+
retryConfig: options?.retries
|
|
138
|
+
|| client$._options.retryConfig
|
|
139
|
+
|| { strategy: "none" },
|
|
140
|
+
retryCodes: options?.retryCodes || [
|
|
141
|
+
"429",
|
|
142
|
+
"500",
|
|
143
|
+
"502",
|
|
144
|
+
"503",
|
|
145
|
+
"504",
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const requestRes = client$._createRequest(context, {
|
|
150
|
+
security: requestSecurity,
|
|
151
|
+
method: "GET",
|
|
152
|
+
baseURL: options?.serverURL,
|
|
153
|
+
path: path$,
|
|
154
|
+
headers: headers$,
|
|
155
|
+
body: body$,
|
|
156
|
+
userAgent: client$._options.userAgent,
|
|
157
|
+
timeoutMs: options?.timeoutMs || client$._options.timeoutMs
|
|
158
|
+
|| -1,
|
|
159
|
+
}, options);
|
|
160
|
+
if (!requestRes.ok) {
|
|
161
|
+
return [requestRes, { status: "invalid" }];
|
|
162
|
+
}
|
|
163
|
+
const req$ = requestRes.value;
|
|
164
|
+
|
|
165
|
+
const doResult = await client$._do(req$, {
|
|
166
|
+
context,
|
|
167
|
+
errorCodes: [],
|
|
168
|
+
retryConfig: context.retryConfig,
|
|
169
|
+
retryCodes: context.retryCodes,
|
|
170
|
+
});
|
|
171
|
+
if (!doResult.ok) {
|
|
172
|
+
return [doResult, { status: "request-error", request: req$ }];
|
|
173
|
+
}
|
|
174
|
+
return [doResult, {
|
|
175
|
+
status: "complete",
|
|
176
|
+
"request": req$,
|
|
177
|
+
response: doResult.value,
|
|
178
|
+
}];
|
|
179
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// `conversationsCreateConversation.ts` but POSTs to `/conversations/stream`
|
|
3
|
-
// and asks for an SSE response. The body shape is identical to the
|
|
1
|
+
// POSTs to `/conversations/stream` and asks for an SSE response. The body shape is identical to the
|
|
4
2
|
// non-streaming sibling, so we reuse `CreateConversationRequest`'s zod
|
|
5
3
|
// schema. Returns the raw streaming `Response`; the caller is expected to
|
|
6
4
|
// parse `text/event-stream` line-by-line.
|
|
@@ -89,7 +87,7 @@ async function $do(
|
|
|
89
87
|
options: client$._options,
|
|
90
88
|
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
91
89
|
operationID: "streamConversation",
|
|
92
|
-
oAuth2Scopes: ["conversation:
|
|
90
|
+
oAuth2Scopes: ["conversation:chat"],
|
|
93
91
|
resolvedSecurity: requestSecurity,
|
|
94
92
|
securitySource: client$._options.security,
|
|
95
93
|
retryConfig: options?.retries
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
// Hand-written supplement (NOT generated). Mirrors
|
|
2
|
-
// `conversationsAddMessage.ts` but POSTs to
|
|
3
|
-
// `/conversations/{conversationId}/messages/stream` and asks for an SSE
|
|
4
|
-
// response. The body shape is identical to the non-streaming sibling, so
|
|
5
|
-
// we reuse `AddMessageRequestRequest`'s zod schema. Returns the raw
|
|
6
|
-
// streaming `Response`; the caller is expected to parse `text/event-stream`
|
|
7
|
-
// line-by-line.
|
|
8
|
-
|
|
9
1
|
import { PipeshubCore } from "../core.js";
|
|
10
2
|
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
11
3
|
import { compactMap } from "../lib/primitives.js";
|
|
@@ -114,7 +114,7 @@ async function $do(
|
|
|
114
114
|
options: client$._options,
|
|
115
115
|
baseURL: options?.serverURL ?? client$._baseURL ?? "",
|
|
116
116
|
operationID: "getAllUserGroups",
|
|
117
|
-
oAuth2Scopes: [],
|
|
117
|
+
oAuth2Scopes: ["usergroup:read"],
|
|
118
118
|
resolvedSecurity: requestSecurity,
|
|
119
119
|
securitySource: client$._options.security,
|
|
120
120
|
retryConfig: options?.retries
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestIDHook } from "./requestid.js";
|
|
1
2
|
import { Hooks } from "./types.js";
|
|
2
3
|
|
|
3
4
|
/*
|
|
@@ -6,9 +7,9 @@ import { Hooks } from "./types.js";
|
|
|
6
7
|
* in this file or in separate files in the hooks folder.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
// @ts-expect-error remove this line when you add your first hook and hooks is used
|
|
10
10
|
export function initHooks(hooks: Hooks) {
|
|
11
11
|
// Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
|
|
12
12
|
// with an instance of a hook that implements that specific Hook interface
|
|
13
13
|
// Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
|
|
14
|
+
hooks.registerBeforeRequestHook(new RequestIDHook());
|
|
14
15
|
}
|