@zackbart/connecta 0.24.4 → 0.26.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/AGENTS.md +43 -12
- package/CHANGELOG.md +524 -0
- package/README.md +32 -15
- package/SECURITY.md +6 -5
- package/bin/connecta.mjs +5 -1
- package/dist/activity.d.ts +10 -3
- package/dist/activity.js +10 -1
- package/dist/advertised-schema.js +53 -0
- package/dist/artifacts/connector.d.ts +55 -0
- package/dist/artifacts/connector.js +724 -0
- package/dist/artifacts/document.js +76 -0
- package/dist/artifacts/guide.js +140 -0
- package/dist/artifacts/html-scan.js +329 -0
- package/dist/artifacts/json.js +68 -0
- package/dist/artifacts/kv-store.d.ts +20 -0
- package/dist/artifacts/kv-store.js +140 -0
- package/dist/artifacts/markdown.js +449 -0
- package/dist/artifacts/module.d.ts +37 -0
- package/dist/artifacts/module.js +60 -0
- package/dist/artifacts/operations.d.ts +195 -0
- package/dist/artifacts/operations.js +944 -0
- package/dist/artifacts/refresh.d.ts +53 -0
- package/dist/artifacts/refresh.js +235 -0
- package/dist/artifacts/routes.js +194 -0
- package/dist/artifacts/types.d.ts +214 -0
- package/dist/artifacts/types.js +22 -0
- package/dist/artifacts/validate.d.ts +62 -0
- package/dist/artifacts/validate.js +652 -0
- package/dist/artifacts.d.ts +6 -0
- package/dist/artifacts.js +9 -0
- package/dist/auth/downstream-oauth.js +490 -106
- package/dist/call-admission.js +139 -113
- package/dist/catalog-service.js +152 -106
- package/dist/catalog.js +297 -38
- package/dist/concurrency.js +24 -23
- package/dist/connector-access.d.ts +18 -4
- package/dist/connector-access.js +65 -20
- package/dist/connector-caller.d.ts +8 -0
- package/dist/connector-caller.js +19 -0
- package/dist/connector-scope.js +6 -37
- package/dist/connectors/api.d.ts +2 -2
- package/dist/connectors/remote-mcp.d.ts +6 -5
- package/dist/connectors/remote-mcp.js +330 -240
- package/dist/credential-contract.d.ts +9 -0
- package/dist/credential-rules.js +2 -2
- package/dist/credentials.d.ts +6 -1
- package/dist/credentials.js +45 -3
- package/dist/errors.d.ts +16 -1
- package/dist/errors.js +28 -0
- package/dist/execute.js +745 -282
- package/dist/executor-admission.d.ts +11 -1
- package/dist/executor-admission.js +145 -63
- package/dist/executors/quickjs-runtime.js +4 -2
- package/dist/executors/quickjs.js +255 -212
- package/dist/fix-prompt.js +37 -0
- package/dist/index.d.ts +72 -7
- package/dist/index.js +281 -26
- package/dist/invocation.js +371 -286
- package/dist/meta-tools.js +213 -94
- package/dist/module-contracts.d.ts +21 -1
- package/dist/oauth-callback-outcome.js +94 -0
- package/dist/oauth-sealing.js +29 -0
- package/dist/operator-ui/fix-prompts.js +87 -0
- package/dist/operator-ui/generated.js +2 -2
- package/dist/operator-ui/model.d.ts +103 -1
- package/dist/operator-ui/setup-commands.js +53 -0
- package/dist/operator-ui/view.js +128 -3
- package/dist/program-source.js +321 -0
- package/dist/providers/notion.js +2 -2
- package/dist/providers/revenuecat.js +32 -5
- package/dist/providers/stripe.d.ts +3 -2
- package/dist/providers/vercel.js +1 -1
- package/dist/registry.d.ts +43 -7
- package/dist/registry.js +434 -288
- package/dist/resumable.js +1291 -0
- package/dist/routes/activity.js +74 -154
- package/dist/routes/actor-labels.js +114 -0
- package/dist/routes/credentials.js +196 -163
- package/dist/routes/mcp.js +228 -112
- package/dist/routes/oauth-management.js +73 -71
- package/dist/routes/oauth.js +44 -16
- package/dist/routes/operator.js +83 -0
- package/dist/routes/shared.d.ts +25 -1
- package/dist/routes/shared.js +20 -2
- package/dist/routes/ui-data.js +211 -0
- package/dist/routes/ui.js +76 -35
- package/dist/run-journal.js +347 -0
- package/dist/runtime/admission.js +43 -0
- package/dist/runtime/call-admission.js +67 -0
- package/dist/runtime/connector-scope.js +72 -0
- package/dist/runtime/run.js +174 -0
- package/dist/runtime/services.js +130 -0
- package/dist/runtime/shared-read.js +106 -0
- package/dist/runtime/storage.js +66 -0
- package/dist/server.js +137 -89
- package/dist/skills.js +28 -9
- package/dist/storage/file.js +39 -2
- package/dist/storage/memory.js +28 -16
- package/dist/timeout.js +39 -43
- package/dist/tool-safety.d.ts +27 -1
- package/dist/tool-safety.js +31 -0
- package/dist/types.d.ts +45 -7
- package/dist/ui.d.ts +25 -4
- package/dist/ui.js +77 -167
- package/dist/url-safety.js +157 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/documentation/architecture.md +367 -16
- package/documentation/auth.md +163 -2
- package/documentation/code-mode.md +274 -56
- package/documentation/meta-tools.md +200 -44
- package/ethos.md +46 -47
- package/examples/worker/AGENTS.md +6 -0
- package/examples/worker/README.md +224 -14
- package/examples/worker/src/d1-activity-row.ts +14 -2
- package/examples/worker/src/d1-activity.ts +4 -2
- package/examples/worker/src/d1-storage.ts +116 -0
- package/examples/worker/src/index.ts +42 -7
- package/examples/worker/src/r2-artifact-blobs.ts +29 -0
- package/examples/worker/wrangler.jsonc +21 -5
- package/package.json +16 -4
- package/templates/node/AGENTS.md +9 -2
- package/templates/node/README.md +31 -3
- package/templates/node/package.json +1 -1
- package/templates/node/src/index.ts +27 -0
- package/dist/auth/downstream-oauth.d.ts +0 -200
- package/dist/catalog-fingerprint.d.ts +0 -19
- package/dist/catalog-limits.d.ts +0 -9
- package/dist/catalog-service.d.ts +0 -263
- package/dist/catalog.d.ts +0 -87
- package/dist/concurrency.d.ts +0 -3
- package/dist/connectors/guarded-fetch.d.ts +0 -96
- package/dist/credential-rules.d.ts +0 -85
- package/dist/execute.d.ts +0 -154
- package/dist/executor-result.d.ts +0 -10
- package/dist/executors/quickjs-child.d.ts +0 -1
- package/dist/executors/quickjs-protocol.d.ts +0 -67
- package/dist/favicon.d.ts +0 -1
- package/dist/identity.d.ts +0 -4
- package/dist/invocation.d.ts +0 -74
- package/dist/mcp-result.d.ts +0 -8
- package/dist/meta-tools.d.ts +0 -129
- package/dist/operator-ui/generated.d.ts +0 -2
- package/dist/operator-ui/view.d.ts +0 -188
- package/dist/result-shapes.d.ts +0 -13
- package/dist/retired-toolkits.d.ts +0 -2
- package/dist/routes/activity.d.ts +0 -2
- package/dist/routes/credentials.d.ts +0 -2
- package/dist/routes/mcp.d.ts +0 -10
- package/dist/routes/oauth-management.d.ts +0 -2
- package/dist/routes/oauth.d.ts +0 -2
- package/dist/routes/ui.d.ts +0 -2
- package/dist/server.d.ts +0 -9
- package/dist/skills.d.ts +0 -44
- package/dist/timeout.d.ts +0 -21
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import type { CallErrorDetails } from "./errors.js";
|
|
2
|
-
import type { ConnectorOperationOptions, RegistryView } from "./registry.js";
|
|
3
|
-
import type { DeferredWork } from "./connector-scope.js";
|
|
4
|
-
import type { Connector, ToolDef } from "./types.js";
|
|
5
|
-
export declare const DEFAULT_SEARCH_LIMIT = 8;
|
|
6
|
-
export declare const MAX_SEARCH_LIMIT = 100;
|
|
7
|
-
export declare const MAX_DESCRIBE_ADDRESSES = 100;
|
|
8
|
-
export declare const MAX_DISCOVERY_RESULT_BYTES = 256000;
|
|
9
|
-
/**
|
|
10
|
-
* The discovery route a routing failure should send a caller back through. Same
|
|
11
|
-
* catalog logic serves both the top-level `search_tools` path and the
|
|
12
|
-
* in-program `connecta.search` path, so callers pass the route they own.
|
|
13
|
-
*/
|
|
14
|
-
export type SearchRoute = "search_tools" | "connecta.search";
|
|
15
|
-
export declare class DiscoveryPolicyError extends Error {
|
|
16
|
-
readonly code: "invalid_args" | "result_too_large";
|
|
17
|
-
constructor(code: "invalid_args" | "result_too_large", message: string);
|
|
18
|
-
}
|
|
19
|
-
/** Serialize once and count the exact bytes the MCP adapter would emit. */
|
|
20
|
-
export declare function boundedDiscoveryText(value: unknown, hint: string): string;
|
|
21
|
-
export interface CatalogSearchArgs {
|
|
22
|
-
query?: string;
|
|
23
|
-
connector?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Result classification only; never changes which tools exist or what may
|
|
26
|
-
* execute. Omitted and "all" preserve the complete configured catalog.
|
|
27
|
-
*/
|
|
28
|
-
safety?: "readOnly" | "approvalRequired" | "all";
|
|
29
|
-
limit?: number;
|
|
30
|
-
offset?: number;
|
|
31
|
-
fullDescriptions?: boolean;
|
|
32
|
-
includeSchemas?: "compact" | "json";
|
|
33
|
-
/** Code-mode helper metadata; never exposed by the public search_tools schema. */
|
|
34
|
-
includeSchemaKeys?: boolean;
|
|
35
|
-
}
|
|
36
|
-
export interface CatalogDescribeArgs {
|
|
37
|
-
address?: unknown;
|
|
38
|
-
addresses?: unknown;
|
|
39
|
-
format?: "compact" | "json";
|
|
40
|
-
fullDescriptions?: boolean;
|
|
41
|
-
}
|
|
42
|
-
interface CatalogSearchEntry {
|
|
43
|
-
connector: Connector;
|
|
44
|
-
guide?: string;
|
|
45
|
-
guideSummary?: string;
|
|
46
|
-
tool: {
|
|
47
|
-
name: string;
|
|
48
|
-
address: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
inputSchema?: unknown;
|
|
51
|
-
outputSchema?: unknown;
|
|
52
|
-
outputSchemaSource?: "observed";
|
|
53
|
-
inputSchemaTruncated?: true;
|
|
54
|
-
outputSchemaTruncated?: true;
|
|
55
|
-
inputKeys?: string[];
|
|
56
|
-
requiredInputKeys?: string[];
|
|
57
|
-
outputKeys?: string[];
|
|
58
|
-
annotations?: ToolDef["annotations"];
|
|
59
|
-
guideRequired?: true;
|
|
60
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
type GuideRequiredReason = "connector_required" | "approval_required" | "schema_truncated";
|
|
64
|
-
/**
|
|
65
|
-
* The classified-failure subset a scoped search may echo: enough to tell a
|
|
66
|
-
* transient outage from one an operator must clear, and nothing more. Kept as
|
|
67
|
-
* its own type rather than `CallErrorDetails` so widening the call-path
|
|
68
|
-
* classifier cannot widen this discovery-surface field by accident.
|
|
69
|
-
*/
|
|
70
|
-
interface CatalogFailureDetail {
|
|
71
|
-
code: string;
|
|
72
|
-
message: string;
|
|
73
|
-
retryable: boolean;
|
|
74
|
-
retryAfterMs?: number;
|
|
75
|
-
}
|
|
76
|
-
interface CatalogDescriptionFailureDetail extends CatalogFailureDetail {
|
|
77
|
-
nextAction?: NonNullable<CallErrorDetails["nextAction"]>;
|
|
78
|
-
/** Nearby canonical addresses, ranked deterministically by tool name. */
|
|
79
|
-
suggestions?: string[];
|
|
80
|
-
}
|
|
81
|
-
export interface CatalogSearchPage {
|
|
82
|
-
entries: CatalogSearchEntry[];
|
|
83
|
-
total: number;
|
|
84
|
-
offset: number;
|
|
85
|
-
limit: number;
|
|
86
|
-
hasMore: boolean;
|
|
87
|
-
nextOffset?: number;
|
|
88
|
-
matchMode?: "partial";
|
|
89
|
-
queryAnalysis?: {
|
|
90
|
-
representedTerms: string[];
|
|
91
|
-
otherResultTerms: string[];
|
|
92
|
-
unmatchedTerms: string[];
|
|
93
|
-
truncated?: true;
|
|
94
|
-
connectorScope?: string;
|
|
95
|
-
unknownConnector?: true;
|
|
96
|
-
unavailableConnectorCount?: number;
|
|
97
|
-
/** Bounded typed failure for an explicitly scoped unavailable catalog. */
|
|
98
|
-
catalogError?: CatalogFailureDetail;
|
|
99
|
-
guide?: string;
|
|
100
|
-
guideSummary?: string;
|
|
101
|
-
guideRequired?: true;
|
|
102
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
103
|
-
guidance?: string;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
export interface CatalogDescription {
|
|
107
|
-
address: string;
|
|
108
|
-
name?: string;
|
|
109
|
-
description?: string;
|
|
110
|
-
guide?: string;
|
|
111
|
-
guideSummary?: string;
|
|
112
|
-
guideRequired?: true;
|
|
113
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
114
|
-
inputSchema?: unknown;
|
|
115
|
-
outputSchema?: unknown;
|
|
116
|
-
outputSchemaSource?: "observed";
|
|
117
|
-
inputSchemaTruncated?: true;
|
|
118
|
-
outputSchemaTruncated?: true;
|
|
119
|
-
annotations?: ToolDef["annotations"];
|
|
120
|
-
error?: string;
|
|
121
|
-
errorDetails?: CatalogDescriptionFailureDetail;
|
|
122
|
-
}
|
|
123
|
-
export interface ResolvedCatalogTool {
|
|
124
|
-
connector: Connector;
|
|
125
|
-
toolName: string;
|
|
126
|
-
definition: ToolDef;
|
|
127
|
-
}
|
|
128
|
-
export type CatalogResolution = {
|
|
129
|
-
ok: true;
|
|
130
|
-
resolved: ResolvedCatalogTool;
|
|
131
|
-
catalogMs: number;
|
|
132
|
-
} | {
|
|
133
|
-
ok: false;
|
|
134
|
-
error: CallErrorDetails;
|
|
135
|
-
catalogMs: number;
|
|
136
|
-
connector?: Connector;
|
|
137
|
-
toolName?: string;
|
|
138
|
-
cause?: unknown;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Request-local catalog operations shared by MCP meta-tools and code mode.
|
|
142
|
-
* Successful catalogs may be reused inside this request; failures are not
|
|
143
|
-
* retained, and the service itself never escapes its request adapter.
|
|
144
|
-
*/
|
|
145
|
-
export declare class CatalogService {
|
|
146
|
-
private readonly registry;
|
|
147
|
-
readonly baseUrl: string;
|
|
148
|
-
readonly requestScope: object;
|
|
149
|
-
private readonly probeTimeoutMs;
|
|
150
|
-
private readonly concurrency;
|
|
151
|
-
private readonly searchRoute;
|
|
152
|
-
private readonly readOptions;
|
|
153
|
-
private readonly loaded;
|
|
154
|
-
private readonly loading;
|
|
155
|
-
constructor(registry: RegistryView, baseUrl: string, options?: {
|
|
156
|
-
requestScope?: object | undefined;
|
|
157
|
-
probeTimeoutMs?: number | undefined;
|
|
158
|
-
concurrency?: number | undefined;
|
|
159
|
-
/** The discovery route recovery records name. Default `search_tools`. */
|
|
160
|
-
searchRoute?: SearchRoute | undefined;
|
|
161
|
-
/** Runtime-owned tail for stale-while-revalidate catalog reads. */
|
|
162
|
-
defer?: DeferredWork | undefined;
|
|
163
|
-
});
|
|
164
|
-
/**
|
|
165
|
-
* Send a caller back to discovery through the surface it can actually reach.
|
|
166
|
-
* Both variants carry the same scoping arguments because `connecta.search`
|
|
167
|
-
* takes the same ones `search_tools` does; only the key naming the callable
|
|
168
|
-
* differs, the way the ambiguous-alias record already names a function.
|
|
169
|
-
*
|
|
170
|
-
* Not private: `InvocationService` builds the same class of record when a
|
|
171
|
-
* call fails schema validation, and it is this catalog's route that decides
|
|
172
|
-
* which key that record carries. Duplicating the branch there would let the
|
|
173
|
-
* two drift.
|
|
174
|
-
*/
|
|
175
|
-
searchRecovery(args: {
|
|
176
|
-
query: string;
|
|
177
|
-
connector?: string;
|
|
178
|
-
}, purpose: string): NonNullable<CallErrorDetails["nextAction"]>;
|
|
179
|
-
loadConnector(id: string, callOptions?: ConnectorOperationOptions): Promise<ToolDef[]>;
|
|
180
|
-
private loadForDiscovery;
|
|
181
|
-
private outputSchema;
|
|
182
|
-
private unknownAddressFailure;
|
|
183
|
-
private catalogLoadFailure;
|
|
184
|
-
private unknownToolFailure;
|
|
185
|
-
resolveTool(address: string, callOptions?: ConnectorOperationOptions): Promise<CatalogResolution>;
|
|
186
|
-
search(args: CatalogSearchArgs): Promise<CatalogSearchPage>;
|
|
187
|
-
describe(args: CatalogDescribeArgs): Promise<CatalogDescription[]>;
|
|
188
|
-
}
|
|
189
|
-
export declare function groupedSearchResult(page: CatalogSearchPage): {
|
|
190
|
-
queryAnalysis?: {
|
|
191
|
-
representedTerms: string[];
|
|
192
|
-
otherResultTerms: string[];
|
|
193
|
-
unmatchedTerms: string[];
|
|
194
|
-
truncated?: true;
|
|
195
|
-
connectorScope?: string;
|
|
196
|
-
unknownConnector?: true;
|
|
197
|
-
unavailableConnectorCount?: number;
|
|
198
|
-
/** Bounded typed failure for an explicitly scoped unavailable catalog. */
|
|
199
|
-
catalogError?: CatalogFailureDetail;
|
|
200
|
-
guide?: string;
|
|
201
|
-
guideSummary?: string;
|
|
202
|
-
guideRequired?: true;
|
|
203
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
204
|
-
guidance?: string;
|
|
205
|
-
};
|
|
206
|
-
matchMode?: "partial";
|
|
207
|
-
nextOffset?: number;
|
|
208
|
-
total: number;
|
|
209
|
-
offset: number;
|
|
210
|
-
limit: number;
|
|
211
|
-
hasMore: boolean;
|
|
212
|
-
connectors: {
|
|
213
|
-
id: string;
|
|
214
|
-
title?: string;
|
|
215
|
-
guide?: string;
|
|
216
|
-
guideSummary?: string;
|
|
217
|
-
tools: CatalogSearchEntry["tool"][];
|
|
218
|
-
}[];
|
|
219
|
-
};
|
|
220
|
-
export declare function flatSearchResult(page: CatalogSearchPage): {
|
|
221
|
-
queryAnalysis?: {
|
|
222
|
-
representedTerms: string[];
|
|
223
|
-
otherResultTerms: string[];
|
|
224
|
-
unmatchedTerms: string[];
|
|
225
|
-
truncated?: true;
|
|
226
|
-
connectorScope?: string;
|
|
227
|
-
unknownConnector?: true;
|
|
228
|
-
unavailableConnectorCount?: number;
|
|
229
|
-
/** Bounded typed failure for an explicitly scoped unavailable catalog. */
|
|
230
|
-
catalogError?: CatalogFailureDetail;
|
|
231
|
-
guide?: string;
|
|
232
|
-
guideSummary?: string;
|
|
233
|
-
guideRequired?: true;
|
|
234
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
235
|
-
guidance?: string;
|
|
236
|
-
};
|
|
237
|
-
matchMode?: "partial";
|
|
238
|
-
nextOffset?: number;
|
|
239
|
-
total: number;
|
|
240
|
-
offset: number;
|
|
241
|
-
limit: number;
|
|
242
|
-
hasMore: boolean;
|
|
243
|
-
tools: {
|
|
244
|
-
guideSummary?: string;
|
|
245
|
-
guide?: string;
|
|
246
|
-
connectorTitle?: string;
|
|
247
|
-
name: string;
|
|
248
|
-
address: string;
|
|
249
|
-
description?: string;
|
|
250
|
-
inputSchema?: unknown;
|
|
251
|
-
outputSchema?: unknown;
|
|
252
|
-
outputSchemaSource?: "observed";
|
|
253
|
-
inputSchemaTruncated?: true;
|
|
254
|
-
outputSchemaTruncated?: true;
|
|
255
|
-
inputKeys?: string[];
|
|
256
|
-
requiredInputKeys?: string[];
|
|
257
|
-
outputKeys?: string[];
|
|
258
|
-
annotations?: ToolDef["annotations"];
|
|
259
|
-
guideRequired?: true;
|
|
260
|
-
guideRequiredReasons?: GuideRequiredReason[];
|
|
261
|
-
}[];
|
|
262
|
-
};
|
|
263
|
-
export {};
|
package/dist/catalog.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { JsonSchema, ToolDef } from "./types.js";
|
|
2
|
-
export declare const MAX_COMPACT_DISCOVERY_SCHEMA_BYTES = 1024;
|
|
3
|
-
export declare function summarizeDescription(text: string | undefined, full: boolean): string | undefined;
|
|
4
|
-
export declare function summarizeDiscoveryDescription(text: string | undefined, full: boolean): string | undefined;
|
|
5
|
-
/** Distinct normalized terms in query order, shared by ranking and feedback. */
|
|
6
|
-
export declare function lexicalQueryTerms(query: string): string[];
|
|
7
|
-
/**
|
|
8
|
-
* Remove conversational framing before the all-term/partial decision. If
|
|
9
|
-
* every term is framing, retain the original query rather than turning a
|
|
10
|
-
* search into an unfiltered catalog browse.
|
|
11
|
-
*/
|
|
12
|
-
export declare function lexicalSearchQuery(query: string): string;
|
|
13
|
-
export type LexicalMatchMode = "all" | "partial";
|
|
14
|
-
export interface RankedTool {
|
|
15
|
-
tool: ToolDef;
|
|
16
|
-
score: number;
|
|
17
|
-
order: number;
|
|
18
|
-
exactName: boolean;
|
|
19
|
-
matchedTermCount: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Whether one query term matches a whole token of arbitrary text, under the
|
|
23
|
-
* same inflection rules the tool index uses.
|
|
24
|
-
*
|
|
25
|
-
* Connector identity — an `id` or a `title` — is deliberately not a document in
|
|
26
|
-
* that index: making it one would move ranking for every query that already
|
|
27
|
-
* matches tools. This lets a caller ask the index's question of a string that
|
|
28
|
-
* never became a document, which is what the no-match analysis needs to tell
|
|
29
|
-
* "nothing like this exists here" from "that word is a connector".
|
|
30
|
-
*/
|
|
31
|
-
export declare function matchesLexicalTerm(text: string, term: string): boolean;
|
|
32
|
-
export interface LexicalCorpusStatistics {
|
|
33
|
-
documentCount: number;
|
|
34
|
-
documentFrequency: ReadonlyMap<string, number>;
|
|
35
|
-
nameMatches: ReadonlyMap<string, ReadonlySet<ToolDef>>;
|
|
36
|
-
descriptionMatches: ReadonlyMap<string, ReadonlySet<ToolDef>>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Compute query-specific document frequencies across every available catalog.
|
|
40
|
-
* The caller does this once per search and shares the result with each
|
|
41
|
-
* connector rank, so ubiquitous words contribute less than discriminative
|
|
42
|
-
* ones without making any action word a stopword.
|
|
43
|
-
*/
|
|
44
|
-
export declare function lexicalCorpusStatistics(toolSets: ToolDef[][], query: string): LexicalCorpusStatistics;
|
|
45
|
-
/**
|
|
46
|
-
* Rank a connector's tools while caching its normalized plain-data index.
|
|
47
|
-
* `exactNameQuery` may retain framing removed from the scoring query: those
|
|
48
|
-
* words are weak term evidence, but remain part of a real tool-name phrase.
|
|
49
|
-
*/
|
|
50
|
-
export declare function rankTools(tools: ToolDef[], query: string, mode?: LexicalMatchMode, statistics?: LexicalCorpusStatistics, exactNameQuery?: string): RankedTool[];
|
|
51
|
-
/** Render and cache a compact TypeScript-like representation of JSON Schema. */
|
|
52
|
-
export declare function compactSchema(schema: JsonSchema): string;
|
|
53
|
-
/** Describe allows 8 KiB for property prose, with the same work cap as search. */
|
|
54
|
-
export declare function compactDescriptionSchema(schema: JsonSchema): CompactDiscoverySchema;
|
|
55
|
-
export interface CompactDiscoverySchema {
|
|
56
|
-
text: string;
|
|
57
|
-
truncated: boolean;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Render the schema shape carried by search results.
|
|
61
|
-
*
|
|
62
|
-
* Search is a routing step, so repeated property prose does not earn its
|
|
63
|
-
* context cost there. Required inputs render first, and the result has a hard
|
|
64
|
-
* UTF-8 budget; exact JSON and the prose-rich compact rendering remain
|
|
65
|
-
* available through the existing full retrieval paths.
|
|
66
|
-
*/
|
|
67
|
-
export declare function compactDiscoverySchema(schema: JsonSchema): CompactDiscoverySchema;
|
|
68
|
-
/** The property and required names a schema resolves to, or undefined. */
|
|
69
|
-
export interface SchemaObjectKeys {
|
|
70
|
-
properties: string[];
|
|
71
|
-
required: string[];
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Walk a schema the way renderSchema does — composing `allOf` and resolving
|
|
75
|
-
* `$ref` against the root's `$defs`/`definitions` — and collect the top-level
|
|
76
|
-
* property names it would render. A shallow `Object.keys(schema.properties)`
|
|
77
|
-
* disagrees with the rendered compact schema for exactly the shapes real
|
|
78
|
-
* connectors emit (a top-level `$ref` to a `$defs` entry, or the OpenAPI
|
|
79
|
-
* "extend this base" `allOf`), which is worse than no metadata at all: it
|
|
80
|
-
* reports an empty field list for a tool that plainly has fields.
|
|
81
|
-
*
|
|
82
|
-
* Returns undefined when the schema is not an object shape at all — a union,
|
|
83
|
-
* array, enum, or unresolvable `$ref`. Absent metadata tells a caller to read
|
|
84
|
-
* the rendered schema instead; an empty array would claim the tool takes no
|
|
85
|
-
* fields.
|
|
86
|
-
*/
|
|
87
|
-
export declare function schemaObjectKeys(schema: JsonSchema | undefined): SchemaObjectKeys | undefined;
|
package/dist/concurrency.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function resolveDiscoveryConcurrency(value: number | undefined): number;
|
|
2
|
-
/** Run `fn` over `items` with at most `limit` operations in flight. */
|
|
3
|
-
export declare function mapSettledWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<PromiseSettledResult<R>[]>;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { ConnectorContext } from "../types.js";
|
|
2
|
-
/** The methods a hand-written provider surface actually uses. */
|
|
3
|
-
type GuardedMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
4
|
-
export interface GuardedRequest {
|
|
5
|
-
method: GuardedMethod;
|
|
6
|
-
/**
|
|
7
|
-
* Provider-relative path beginning with one `/`, resolved against the base
|
|
8
|
-
* URL's own path. Never an absolute URL, and never carrying `?` or `#` —
|
|
9
|
-
* query parameters go in `query`, where they are encoded rather than parsed.
|
|
10
|
-
*/
|
|
11
|
-
path: string;
|
|
12
|
-
/** Search parameters; `undefined` values are dropped, others stringified. */
|
|
13
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* Per-request headers. `undefined` values are dropped, and a header that
|
|
16
|
-
* collides with an authentication header is refused rather than allowed to
|
|
17
|
-
* shadow it.
|
|
18
|
-
*/
|
|
19
|
-
headers?: Record<string, string | undefined>;
|
|
20
|
-
/** JSON request body. Serialized here, with the `Content-Type` to match. */
|
|
21
|
-
body?: unknown;
|
|
22
|
-
/**
|
|
23
|
-
* A pre-framed body — `FormData`, text, bytes. Mutually exclusive with
|
|
24
|
-
* `body`, and no `Content-Type` is supplied: multipart needs `fetch` to pick
|
|
25
|
-
* the boundary, and anything else knows its own type.
|
|
26
|
-
*/
|
|
27
|
-
rawBody?: BodyInit;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* One downstream response, read under the connector's byte ceiling.
|
|
31
|
-
*
|
|
32
|
-
* The accessors are the whole read surface — there is no escape to the
|
|
33
|
-
* underlying `Response`, because an unbounded `.text()` on it is exactly the
|
|
34
|
-
* mistake this type exists to remove. `status`, `ok`, and `headers` are the
|
|
35
|
-
* raw facts a provider mapper needs to make its own classification.
|
|
36
|
-
*/
|
|
37
|
-
interface GuardedResponse {
|
|
38
|
-
readonly status: number;
|
|
39
|
-
readonly ok: boolean;
|
|
40
|
-
readonly headers: Headers;
|
|
41
|
-
/** The body as bytes. */
|
|
42
|
-
bytes(): Promise<Uint8Array>;
|
|
43
|
-
/** The body decoded as UTF-8. */
|
|
44
|
-
text(): Promise<string>;
|
|
45
|
-
/** The body parsed as JSON; `undefined` for an empty body, throws on junk. */
|
|
46
|
-
json(): Promise<unknown>;
|
|
47
|
-
/** Parse JSON while distinguishing malformed content from transport failure. */
|
|
48
|
-
jsonResult(): Promise<{
|
|
49
|
-
value: unknown;
|
|
50
|
-
} | {
|
|
51
|
-
parseError: unknown;
|
|
52
|
-
}>;
|
|
53
|
-
}
|
|
54
|
-
/** Parse delta-seconds or an HTTP-date into a non-negative wait window. */
|
|
55
|
-
export declare function retryAfterMs(headers: Headers): number | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Turn one response into the provider's own result, or throw the provider's
|
|
58
|
-
* own typed failure. This is where status codes acquire meaning, and it is
|
|
59
|
-
* always the provider's code.
|
|
60
|
-
*/
|
|
61
|
-
type GuardedResponseMapper<T> = (response: GuardedResponse, ctx: ConnectorContext) => T | Promise<T>;
|
|
62
|
-
export interface GuardedFetchOptions {
|
|
63
|
-
/**
|
|
64
|
-
* Provider name as it appears in normalized failure prose — "Cloudflare",
|
|
65
|
-
* "Notion". Used for messages only; it is never parsed.
|
|
66
|
-
*/
|
|
67
|
-
provider: string;
|
|
68
|
-
/**
|
|
69
|
-
* Absolute base URL. Its origin and path prefix are the confinement: every
|
|
70
|
-
* request resolves beneath it or is refused.
|
|
71
|
-
*/
|
|
72
|
-
baseUrl: string;
|
|
73
|
-
/**
|
|
74
|
-
* Headers proving the caller's identity, resolved once per request. Throwing
|
|
75
|
-
* a typed `auth_required` from here is the documented way to report a
|
|
76
|
-
* missing credential — the helper has no opinion about what a credential is.
|
|
77
|
-
*/
|
|
78
|
-
authenticate: (ctx: ConnectorContext) => Record<string, string> | Promise<Record<string, string>>;
|
|
79
|
-
/** Constant headers sent with every request — `Accept`, an API version. */
|
|
80
|
-
headers?: Record<string, string>;
|
|
81
|
-
/**
|
|
82
|
-
* Ceiling on the response body, in bytes. Required, because a default here
|
|
83
|
-
* would be the helper guessing on a provider's behalf: what counts as an
|
|
84
|
-
* absurd response is a fact about the API, not about HTTP.
|
|
85
|
-
*/
|
|
86
|
-
maxResponseBytes: number;
|
|
87
|
-
}
|
|
88
|
-
/** Send one guarded request and map its response with provider knowledge. */
|
|
89
|
-
export type GuardedTransport = <T>(request: GuardedRequest, ctx: ConnectorContext, map: GuardedResponseMapper<T>) => Promise<T>;
|
|
90
|
-
/**
|
|
91
|
-
* Build the transport a connector sends every request through. `maxResponseBytes`
|
|
92
|
-
* is required rather than defaulted: what counts as an absurd response is a fact
|
|
93
|
-
* about the API, not about HTTP.
|
|
94
|
-
*/
|
|
95
|
-
export declare function guardedFetch(options: GuardedFetchOptions): GuardedTransport;
|
|
96
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { Connector, ConnectorCredentialConfig } from "./types.js";
|
|
2
|
-
/** Which hook a testable credential is checked with. */
|
|
3
|
-
type CredentialTestMode = "single" | "multiple";
|
|
4
|
-
/** Operator-safe explanation shared by every surface that detects shape drift. */
|
|
5
|
-
export declare const STORED_CREDENTIAL_SHAPE_MISMATCH_ERROR = "Stored credential fields do not match this connector's current declaration. Replace the credential before using or testing this connector.";
|
|
6
|
-
export type StoredCredentialShape = {
|
|
7
|
-
state: "missing";
|
|
8
|
-
} | {
|
|
9
|
-
state: "valid";
|
|
10
|
-
mode: CredentialTestMode;
|
|
11
|
-
/**
|
|
12
|
-
* Stored keys the connector no longer declares, sorted. Harmless — the
|
|
13
|
-
* credential works — but worth telling an operator about, since nothing
|
|
14
|
-
* else in `/ui` can show a field the declaration has stopped naming.
|
|
15
|
-
*/
|
|
16
|
-
undeclared: string[];
|
|
17
|
-
} | {
|
|
18
|
-
state: "mismatch";
|
|
19
|
-
mode: CredentialTestMode;
|
|
20
|
-
message: typeof STORED_CREDENTIAL_SHAPE_MISMATCH_ERROR;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Compare a connector's current declaration with the keys in its stored
|
|
24
|
-
* credential. Values are deliberately ignored: callers may pass decrypted
|
|
25
|
-
* values or `/credentials`' masked field metadata and get the same answer.
|
|
26
|
-
*
|
|
27
|
-
* The test is CONTAINMENT, not equality: the stored key set is compatible when
|
|
28
|
-
* it holds every field currently declared — the reserved `value` key for a
|
|
29
|
-
* single-value declaration, every declared name for a named one. Anything the
|
|
30
|
-
* declaration asks for and the vault does not have is `mismatch`, which is
|
|
31
|
-
* precisely what a renamed field, a newly added field, or a swap between the
|
|
32
|
-
* two shapes produces. The swap needs no special case: `value` is never one of
|
|
33
|
-
* the declared names, so single→named and named→single each leave the declared
|
|
34
|
-
* side unsatisfied. An empty stored map (reachable through a hand-written
|
|
35
|
-
* plaintext) satisfies nothing and is a mismatch too.
|
|
36
|
-
*
|
|
37
|
-
* Extra keys are NOT drift. They are what *dropping* a field leaves behind, and
|
|
38
|
-
* every accessor a connector actually uses — `ctx.credential.get("apiKey")`,
|
|
39
|
-
* `getAll().apiKey` — keeps returning the right secret across that redeploy.
|
|
40
|
-
* Calling it drift would order an operator to re-enter a working secret that
|
|
41
|
-
* many providers will not reissue in readable form. The leftovers come back as
|
|
42
|
-
* `undeclared` instead, for a surface to mention without blocking anything.
|
|
43
|
-
*/
|
|
44
|
-
export declare function storedCredentialShape(config: ConnectorCredentialConfig, stored: Readonly<Record<string, unknown>> | null): StoredCredentialShape;
|
|
45
|
-
/**
|
|
46
|
-
* The one sentence describing leftover stored fields, so every surface words it
|
|
47
|
-
* the same way. Names only — the values stay in the vault, and a field name from
|
|
48
|
-
* a previous declaration is not a secret. Deliberately reassuring: nothing is
|
|
49
|
-
* broken, and the only thing an operator gains by acting is that a connector
|
|
50
|
-
* iterating `getAll()` stops seeing a field its code no longer knows about.
|
|
51
|
-
*/
|
|
52
|
-
export declare function describeUndeclaredCredentialFields(fields: string[]): string;
|
|
53
|
-
/** A declared credential shape whose only test hook cannot test it. */
|
|
54
|
-
export interface CredentialTestMismatch {
|
|
55
|
-
/** The shape the connector declared. */
|
|
56
|
-
shape: CredentialTestMode;
|
|
57
|
-
/** The hook it implements, which that shape cannot use. */
|
|
58
|
-
hook: "testCredential" | "testCredentials";
|
|
59
|
-
}
|
|
60
|
-
export interface CredentialTestRule {
|
|
61
|
-
/** The hook to call, or null when this credential cannot be tested at all. */
|
|
62
|
-
mode: CredentialTestMode | null;
|
|
63
|
-
/** Set only when the sole implemented hook is the one the shape cannot use. */
|
|
64
|
-
mismatch?: CredentialTestMismatch;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The one rule deciding whether a connector's credential can be tested — read
|
|
68
|
-
* by /credentials' `testable` flag, by `POST /ui/credentials/<id>/test` when
|
|
69
|
-
* it picks a hook, and by the construction-time mismatch warning, so those
|
|
70
|
-
* three cannot drift apart.
|
|
71
|
-
*
|
|
72
|
-
* The declared credential *shape* selects the hook: named `credential.fields`
|
|
73
|
-
* are tested as a set by `testCredentials`, a single-value `credential` by
|
|
74
|
-
* `testCredential` on the vault's reserved `value` field. The other hook is
|
|
75
|
-
* never substituted — it would be handed a shape the connector never declared —
|
|
76
|
-
* so a connector implementing only the mismatched hook is not testable, and
|
|
77
|
-
* says so at construction rather than under an operator's click.
|
|
78
|
-
*/
|
|
79
|
-
export declare function credentialTestRule(connector: Pick<Connector, "credential" | "testCredential" | "testCredentials">): CredentialTestRule;
|
|
80
|
-
/**
|
|
81
|
-
* One clause naming a mismatch, shared by the startup warning and the test
|
|
82
|
-
* route's 400 so an operator reads the same explanation in both places.
|
|
83
|
-
*/
|
|
84
|
-
export declare function describeCredentialTestMismatch(mismatch: CredentialTestMismatch): string;
|
|
85
|
-
export {};
|