@superdurable/dex-agents 0.3.0 → 0.5.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 +598 -45
- package/dist/src/agent-context-compaction.d.ts +1 -1
- package/dist/src/agent-framework-runner.d.ts +210 -10
- package/dist/src/agent-framework-runner.js +30 -0
- package/dist/src/agent-framework-runner.js.map +1 -1
- package/dist/src/agent-local-directory-media-store.d.ts +111 -0
- package/dist/src/agent-local-directory-media-store.js +417 -0
- package/dist/src/agent-local-directory-media-store.js.map +1 -0
- package/dist/src/agent-media.d.ts +279 -0
- package/dist/src/agent-media.js +457 -0
- package/dist/src/agent-media.js.map +1 -0
- package/dist/src/agent-session-codecs.d.ts +3 -1
- package/dist/src/agent-session-codecs.js +53 -4
- package/dist/src/agent-session-codecs.js.map +1 -1
- package/dist/src/agent-session-failure.d.ts +4 -2
- package/dist/src/agent-session-failure.js +6 -2
- package/dist/src/agent-session-failure.js.map +1 -1
- package/dist/src/agent-session-flow-graph.d.ts +46 -0
- package/dist/src/agent-session-flow-graph.js +51 -0
- package/dist/src/agent-session-flow-graph.js.map +1 -1
- package/dist/src/agent-session-flow-graph.json +98 -81
- package/dist/src/agent-session-flow.d.ts +5 -3
- package/dist/src/agent-session-flow.js +10 -1
- package/dist/src/agent-session-flow.js.map +1 -1
- package/dist/src/agent-session-start.d.ts +1 -1
- package/dist/src/agent-session-start.js +2 -2
- package/dist/src/agent-session-start.js.map +1 -1
- package/dist/src/agent-session-steps.d.ts +9 -0
- package/dist/src/agent-session-steps.js +219 -34
- package/dist/src/agent-session-steps.js.map +1 -1
- package/dist/src/agent-session-tracer.js +1 -1
- package/dist/src/agent-session-tracer.js.map +1 -1
- package/dist/src/agent-session-transitions.d.ts +4 -0
- package/dist/src/agent-session-transitions.js +29 -1
- package/dist/src/agent-session-transitions.js.map +1 -1
- package/dist/src/agent-session-values.d.ts +112 -1
- package/dist/src/agent-session-values.js +6 -0
- package/dist/src/agent-session-values.js.map +1 -1
- package/dist/src/agent-session-wait-steps.js +17 -5
- package/dist/src/agent-session-wait-steps.js.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +15 -3
- package/dist/src/ai-sdk/ai-sdk-model-client.js +36 -7
- package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -1
- package/dist/src/ai-sdk/index.d.ts +1 -1
- package/dist/src/ai-sdk/index.js +1 -1
- package/dist/src/ai-sdk/index.js.map +1 -1
- package/dist/src/{stepwise → builtin-loop}/agent-definition.d.ts +120 -5
- package/dist/src/builtin-loop/agent-definition.js.map +1 -0
- package/dist/src/builtin-loop/builtin-agent-session-flow.d.ts +69 -0
- package/dist/src/{stepwise/stepwise-agent-session-flow.js → builtin-loop/builtin-agent-session-flow.js} +15 -9
- package/dist/src/builtin-loop/builtin-agent-session-flow.js.map +1 -0
- package/dist/src/{stepwise/stepwise-agent-runner.d.ts → builtin-loop/builtin-loop-agent-runner.d.ts} +85 -26
- package/dist/src/{stepwise/stepwise-agent-runner.js → builtin-loop/builtin-loop-agent-runner.js} +320 -213
- package/dist/src/builtin-loop/builtin-loop-agent-runner.js.map +1 -0
- package/dist/src/{stepwise/stepwise-input-items.d.ts → builtin-loop/builtin-loop-input-items.d.ts} +7 -3
- package/dist/src/{stepwise/stepwise-input-items.js → builtin-loop/builtin-loop-input-items.js} +57 -10
- package/dist/src/builtin-loop/builtin-loop-input-items.js.map +1 -0
- package/dist/src/builtin-loop/function-tool.d.ts +282 -0
- package/dist/src/{stepwise → builtin-loop}/function-tool.js +63 -3
- package/dist/src/builtin-loop/function-tool.js.map +1 -0
- package/dist/src/builtin-loop/index.d.ts +8 -0
- package/dist/src/builtin-loop/index.js +13 -0
- package/dist/src/builtin-loop/index.js.map +1 -0
- package/dist/src/builtin-loop/json-schema-validation.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/model-client.d.ts +36 -7
- package/dist/src/builtin-loop/model-client.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/scripted-model-client.d.ts +8 -5
- package/dist/src/{stepwise → builtin-loop}/scripted-model-client.js +8 -5
- package/dist/src/builtin-loop/scripted-model-client.js.map +1 -0
- package/dist/src/{stepwise → builtin-loop}/tool-source.d.ts +13 -3
- package/dist/src/builtin-loop/tool-source.js.map +1 -0
- package/dist/src/connectors/connector-input-schema.d.ts +19 -0
- package/dist/src/connectors/connector-input-schema.js +228 -0
- package/dist/src/connectors/connector-input-schema.js.map +1 -0
- package/dist/src/connectors/connector-step-context.d.ts +94 -0
- package/dist/src/connectors/connector-step-context.js +180 -0
- package/dist/src/connectors/connector-step-context.js.map +1 -0
- package/dist/src/connectors/connector-tool-source.d.ts +401 -0
- package/dist/src/connectors/connector-tool-source.js +628 -0
- package/dist/src/connectors/connector-tool-source.js.map +1 -0
- package/dist/src/connectors/index.d.ts +3 -0
- package/dist/src/connectors/index.js +11 -0
- package/dist/src/connectors/index.js.map +1 -0
- package/dist/src/index.d.ts +7 -3
- package/dist/src/index.js +6 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts +1 -0
- package/dist/src/mcp/index.js +1 -0
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/mcp-dex-conventions.d.ts +57 -0
- package/dist/src/mcp/mcp-dex-conventions.js +90 -0
- package/dist/src/mcp/mcp-dex-conventions.js.map +1 -0
- package/dist/src/mcp/mcp-image-content.d.ts +20 -0
- package/dist/src/mcp/mcp-image-content.js +82 -0
- package/dist/src/mcp/mcp-image-content.js.map +1 -0
- package/dist/src/mcp/mcp-tool-source.d.ts +178 -17
- package/dist/src/mcp/mcp-tool-source.js +237 -34
- package/dist/src/mcp/mcp-tool-source.js.map +1 -1
- package/dist/src/s3/index.d.ts +1 -0
- package/dist/src/s3/index.js +9 -0
- package/dist/src/s3/index.js.map +1 -0
- package/dist/src/s3/s3-media-store.d.ts +138 -0
- package/dist/src/s3/s3-media-store.js +255 -0
- package/dist/src/s3/s3-media-store.js.map +1 -0
- package/dist/src/stepwise/index.d.ts +41 -8
- package/dist/src/stepwise/index.js +35 -5
- package/dist/src/stepwise/index.js.map +1 -1
- package/dist/src/testing/agent-session-test-client.d.ts +6 -3
- package/dist/src/testing/agent-session-test-client.js +10 -3
- package/dist/src/testing/agent-session-test-client.js.map +1 -1
- package/dist/src/testing/scripted-model-client.d.ts +1 -1
- package/dist/src/testing/scripted-model-client.js +2 -2
- package/dist/src/testing/scripted-model-client.js.map +1 -1
- package/dist/src/tool-source-router.d.ts +211 -0
- package/dist/src/tool-source-router.js +380 -0
- package/dist/src/tool-source-router.js.map +1 -0
- package/dist/src/ui-stream/agent-event-json.d.ts +2 -1
- package/dist/src/ui-stream/agent-event-json.js +3 -1
- package/dist/src/ui-stream/agent-event-json.js.map +1 -1
- package/dist/src/ui-stream/agent-ui-messages.d.ts +11 -3
- package/dist/src/ui-stream/agent-ui-messages.js +29 -5
- package/dist/src/ui-stream/agent-ui-messages.js.map +1 -1
- package/package.json +25 -3
- package/dist/src/stepwise/agent-definition.js.map +0 -1
- package/dist/src/stepwise/function-tool.d.ts +0 -130
- package/dist/src/stepwise/function-tool.js.map +0 -1
- package/dist/src/stepwise/json-schema-validation.js.map +0 -1
- package/dist/src/stepwise/model-client.js.map +0 -1
- package/dist/src/stepwise/scripted-model-client.js.map +0 -1
- package/dist/src/stepwise/stepwise-agent-runner.js.map +0 -1
- package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +0 -35
- package/dist/src/stepwise/stepwise-agent-session-flow.js.map +0 -1
- package/dist/src/stepwise/stepwise-input-items.js.map +0 -1
- package/dist/src/stepwise/tool-source.js.map +0 -1
- /package/dist/src/{stepwise → builtin-loop}/agent-definition.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.d.ts +0 -0
- /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/model-client.js +0 -0
- /package/dist/src/{stepwise → builtin-loop}/tool-source.js +0 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
// Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
// You may not use this file except in compliance with the License.
|
|
5
|
+
// See the LICENSE file in the repository root.
|
|
6
|
+
//
|
|
7
|
+
// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
import { RetryError, createCall, defaultConnectorStepExecuteRetryPolicy, runMutation, runQuery, throwDexRetry, } from "@superdurable/connectors-sdk";
|
|
9
|
+
import { ToolExecutionError, ToolOutcomeUnknownError, } from "../agent-framework-runner.js";
|
|
10
|
+
import { serializeJsonWithSpacedSeparators } from "../builtin-loop/json-schema-validation.js";
|
|
11
|
+
import { checkConnectorInputSchema, compareCodePoints, findConnectorInputViolation } from "./connector-input-schema.js";
|
|
12
|
+
import { ConnectorStepContext, hasReadCheckpoint, isFenceMarker, readFenceEvidence, readPreviousCheckpoint, } from "./connector-step-context.js";
|
|
13
|
+
/**
|
|
14
|
+
* Default {@link ConnectorToolSource.sourceName}.
|
|
15
|
+
* @since 0.4.0
|
|
16
|
+
*/
|
|
17
|
+
export const defaultConnectorSourceName = "connectors";
|
|
18
|
+
/**
|
|
19
|
+
* Default bound, in bytes of UTF-8 text, on the result one connector tool call gives the model: 64 KiB.
|
|
20
|
+
* @since 0.4.0
|
|
21
|
+
*/
|
|
22
|
+
export const defaultConnectorResultMaxBytes = 64 * 1024;
|
|
23
|
+
/**
|
|
24
|
+
* Note appended to a truncated result; `{total_bytes}` is the size of the full result. The same text as the
|
|
25
|
+
* Python core.
|
|
26
|
+
* @since 0.4.0
|
|
27
|
+
*/
|
|
28
|
+
export const connectorResultTruncatedNote = "[Dex] truncated, {total_bytes} bytes";
|
|
29
|
+
/**
|
|
30
|
+
* Error text of a single-attempt write whose fence proved no send before the connector's Retry; the same text as
|
|
31
|
+
* the Python core.
|
|
32
|
+
* @since 0.4.0
|
|
33
|
+
*/
|
|
34
|
+
export const connectorNotSentRetryLater = "not sent; the provider asked to retry later";
|
|
35
|
+
// The most CallTool attempts of any tool; a connector's own policy can only narrow it.
|
|
36
|
+
const maximumToolAttempts = 3;
|
|
37
|
+
const defectBranch = "defect";
|
|
38
|
+
const uncertainBranch = "uncertain";
|
|
39
|
+
/**
|
|
40
|
+
* Returns what a connector tool call records for one selected branch.
|
|
41
|
+
*
|
|
42
|
+
* The rules apply in this order. The manifest listing comes after the checks that can only tighten an outcome to
|
|
43
|
+
* `outcome_unknown`:
|
|
44
|
+
*
|
|
45
|
+
* 1. `uncertain` is `outcome_unknown`, whatever `agent.branches` says or whether it is declared required. It means
|
|
46
|
+
* the write may have happened, so a listing of it as `rejected` is a manifest error.
|
|
47
|
+
* 2. A Mutation's `defect` is `outcome_unknown`, whatever `agent.branches` says or whether it is declared required.
|
|
48
|
+
* The Connector SDK selects `defect` for some attempts that already called the provider, such as an invalid
|
|
49
|
+
* attempt or an undeclared branch, and a host cannot tell those apart.
|
|
50
|
+
* 3. A required branch other than `defect` is `succeeded`.
|
|
51
|
+
* 4. On a Mutation, any other branch is `outcome_unknown` when `mayHaveDispatched` is set: its single-dispatch
|
|
52
|
+
* fence cannot prove that no request reached the provider.
|
|
53
|
+
* 5. A branch that `agent.branches` lists as `rejected` is `rejected`.
|
|
54
|
+
* 6. A branch that `agent.branches` lists as `unknown` is `outcome_unknown`.
|
|
55
|
+
* 7. Any other optional branch of a Mutation is `outcome_unknown`.
|
|
56
|
+
* 8. Any other branch of a Query, including `defect`, is `failed`.
|
|
57
|
+
*
|
|
58
|
+
* The rule fails closed: an optional branch of a Mutation that the manifest does not classify is
|
|
59
|
+
* `outcome_unknown`, because the write may have happened.
|
|
60
|
+
*
|
|
61
|
+
* Changed in 0.5.0: added `mayHaveDispatched`. `agent.branches` no longer decides a Mutation's `defect`, which is
|
|
62
|
+
* `outcome_unknown` instead of `failed`. A Query's `defect` follows `agent.branches`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* classifyConnectorBranch({ kind: "mutation", branch: "defect", requiredBranches: new Set(["refunded"]),
|
|
67
|
+
* agentBranches: { defect: "rejected" } }); // "outcome_unknown"
|
|
68
|
+
* ```
|
|
69
|
+
* @param options - The operation kind, the selected branch, the required branches, `agent.branches`, and
|
|
70
|
+
* `mayHaveDispatched`: whether the attempt's single-dispatch fence checkpoints leave open that the request reached
|
|
71
|
+
* the provider, because this attempt claimed a send and no canResend followed, or the earlier attempt's checkpoint
|
|
72
|
+
* is missing, not a fence marker, malformed, foreign, or does not allow this attempt a send.
|
|
73
|
+
* {@link ConnectorToolSource} computes it. It defaults to `false`
|
|
74
|
+
* and applies only to a Mutation.
|
|
75
|
+
* @returns The outcome to record.
|
|
76
|
+
* @since 0.4.0
|
|
77
|
+
*/
|
|
78
|
+
export function classifyConnectorBranch(options) {
|
|
79
|
+
const { kind, branch, requiredBranches, agentBranches } = options;
|
|
80
|
+
if (branch === uncertainBranch || (kind === "mutation" && branch === defectBranch)) {
|
|
81
|
+
return "outcome_unknown";
|
|
82
|
+
}
|
|
83
|
+
if (branch !== defectBranch && requiredBranches.has(branch)) {
|
|
84
|
+
return "succeeded";
|
|
85
|
+
}
|
|
86
|
+
if (kind === "mutation" && options.mayHaveDispatched === true) {
|
|
87
|
+
return "outcome_unknown";
|
|
88
|
+
}
|
|
89
|
+
const listed = Object.hasOwn(agentBranches, branch) ? agentBranches[branch] : undefined;
|
|
90
|
+
if (listed === "rejected") {
|
|
91
|
+
return "rejected";
|
|
92
|
+
}
|
|
93
|
+
if (listed === "unknown" || kind === "mutation") {
|
|
94
|
+
return "outcome_unknown";
|
|
95
|
+
}
|
|
96
|
+
return "failed";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Offers one reviewed Connector operation to a built-in loop agent as a tool.
|
|
100
|
+
*
|
|
101
|
+
* The tool's name, description, and argument schema come from the operation's entry in its package's
|
|
102
|
+
* `dex-connector.json`. Only an operation whose entry says `agent.exposed: true` can become a tool; nothing is
|
|
103
|
+
* exposed by default, and the application still names each operation it offers.
|
|
104
|
+
*
|
|
105
|
+
* The manifest decides how the call runs. A Query is `read` and runs in `CallTool`. A Mutation with
|
|
106
|
+
* `agent.retry: safe` is `idempotent_write` and runs in `CallTool`, whose retries stay inside the operation's own
|
|
107
|
+
* Execute retry policy and timeout. Any other Mutation is `non_idempotent_write` and runs once in
|
|
108
|
+
* `CallSingleAttemptTool`. The effect always comes from the manifest; a session's `toolPolicies` entry for the
|
|
109
|
+
* tool changes only its approval.
|
|
110
|
+
*
|
|
111
|
+
* A call waits for `resolve_interrupt` when the manifest says `agent.approval: recommended`;
|
|
112
|
+
* {@link ConnectorToolOptions.requiresApproval} overrides that. Arguments that break the schema never run, so
|
|
113
|
+
* they never wait for approval.
|
|
114
|
+
*
|
|
115
|
+
* Changed in 0.5.0: the default tool name keeps an acronym run as one word, as the Connector library does:
|
|
116
|
+
* `listStoryIDs` becomes `list_story_ids`, not `list_story_i_d_s`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import manifest from "@superdurable/connector-stripe/dex-connector.json" with { type: "json" };
|
|
121
|
+
* import { CreateRefundInputSchema, newProjectConnection } from "@superdurable/connector-stripe";
|
|
122
|
+
*
|
|
123
|
+
* const stripe = newProjectConnection(project, "billing-stripe");
|
|
124
|
+
* const refund = connectorTool(stripe.operations.createRefund(), stripe.reference, {
|
|
125
|
+
* manifest,
|
|
126
|
+
* inputValidator: CreateRefundInputSchema,
|
|
127
|
+
* requiresApproval: (args) => Number(args["amount"]) > 5000,
|
|
128
|
+
* });
|
|
129
|
+
* const source = new ConnectorToolSource([refund]);
|
|
130
|
+
* ```
|
|
131
|
+
* @typeParam Input - The operation's input type.
|
|
132
|
+
* @typeParam Output - The operation's result value type.
|
|
133
|
+
* @param operation - The connector operation, a Query or a Mutation.
|
|
134
|
+
* @param connection - The logical connection reference the call runs with. Only the reference is stored; the
|
|
135
|
+
* Worker resolves credentials.
|
|
136
|
+
* @param options - The manifest, the input validator, and the application's choices.
|
|
137
|
+
* @returns The tool.
|
|
138
|
+
* @throws {TypeError} When the manifest has no entry for the operation, the entry is not `agent.exposed: true`,
|
|
139
|
+
* its kind differs from the operation's, its `agent` block holds an unknown value or lists a branch it may not,
|
|
140
|
+
* or its `inputSchema` uses a keyword the agent core cannot check.
|
|
141
|
+
* @throws {RangeError} When `maxResultBytes` is not positive.
|
|
142
|
+
* @since 0.4.0
|
|
143
|
+
*/
|
|
144
|
+
export function connectorTool(operation, connection, options) {
|
|
145
|
+
const definition = operation.definition();
|
|
146
|
+
const isMutation = typeof operation.idempotencyKey === "function";
|
|
147
|
+
const kind = isMutation ? "mutation" : "query";
|
|
148
|
+
const { connectorId, operationId } = definition.operation;
|
|
149
|
+
const label = `${connectorId} ${operationId}`;
|
|
150
|
+
const manifest = options.manifest;
|
|
151
|
+
if (manifest.connectorId !== connectorId) {
|
|
152
|
+
throw new TypeError(`${label}: the manifest describes Connector ${String(manifest.connectorId)}`);
|
|
153
|
+
}
|
|
154
|
+
const factory = manifest.factories.find((entry) => entry.operationId === operationId);
|
|
155
|
+
if (factory === undefined) {
|
|
156
|
+
throw new TypeError(`${label}: the manifest has no entry for this operation`);
|
|
157
|
+
}
|
|
158
|
+
const agent = factory.agent;
|
|
159
|
+
if (typeof agent !== "object" || agent === null || agent.exposed !== true) {
|
|
160
|
+
throw new TypeError(`${label} is not exposed to agents: its manifest lacks agent.exposed: true`);
|
|
161
|
+
}
|
|
162
|
+
if (factory.kind !== kind) {
|
|
163
|
+
throw new TypeError(`${label}: the manifest says ${String(factory.kind)}, the operation is a ${kind}`);
|
|
164
|
+
}
|
|
165
|
+
const { approval, retry } = agent;
|
|
166
|
+
const branches = agent.branches ?? {};
|
|
167
|
+
if (approval !== undefined && approval !== "recommended") {
|
|
168
|
+
throw new TypeError(`${label}: unknown agent.approval ${JSON.stringify(approval)}`);
|
|
169
|
+
}
|
|
170
|
+
if ((retry !== undefined && retry !== "safe") || (retry !== undefined && kind === "query")) {
|
|
171
|
+
throw new TypeError(`${label}: unknown agent.retry ${JSON.stringify(retry)}`);
|
|
172
|
+
}
|
|
173
|
+
if (typeof branches !== "object" ||
|
|
174
|
+
branches === null ||
|
|
175
|
+
Array.isArray(branches) ||
|
|
176
|
+
Object.values(branches).some((value) => value !== "rejected" && value !== "unknown")) {
|
|
177
|
+
throw new TypeError(`${label}: agent.branches values must be rejected or unknown`);
|
|
178
|
+
}
|
|
179
|
+
const agentBranches = branches;
|
|
180
|
+
const optionalBranches = new Set(definition.branches.filter((branch) => branch.optional === true).map((branch) => branch.id));
|
|
181
|
+
if (Object.keys(agentBranches).some((branch) => !optionalBranches.has(branch))) {
|
|
182
|
+
throw new TypeError(`${label}: agent.branches may list only optional branches`);
|
|
183
|
+
}
|
|
184
|
+
if (kind === "query" && Object.values(agentBranches).includes("unknown")) {
|
|
185
|
+
throw new TypeError(`${label}: agent.branches unknown is for Mutations only`);
|
|
186
|
+
}
|
|
187
|
+
const schema = factory.inputSchema;
|
|
188
|
+
if (typeof schema !== "object" || schema === null) {
|
|
189
|
+
throw new TypeError(`${label}: the manifest has no inputSchema`);
|
|
190
|
+
}
|
|
191
|
+
checkConnectorInputSchema(schema);
|
|
192
|
+
if (options.maxResultBytes !== undefined && !(options.maxResultBytes >= 1)) {
|
|
193
|
+
throw new RangeError("maxResultBytes must be positive");
|
|
194
|
+
}
|
|
195
|
+
const effect = kind === "query" ? "read" : retry === "safe" ? "idempotent_write" : "non_idempotent_write";
|
|
196
|
+
const inputValidator = options.inputValidator;
|
|
197
|
+
const toolName = options.name ?? `${connectorId}_${lowerCamelToSnake(operationId)}`;
|
|
198
|
+
const invoke = async (call, toolArguments) => {
|
|
199
|
+
const parsed = inputValidator.safeParse(toolArguments);
|
|
200
|
+
if (!parsed.success) {
|
|
201
|
+
// A fixed text: validator messages differ between languages and versions.
|
|
202
|
+
throw new ToolExecutionError(`invalid arguments for ${toolName}: arguments do not decode`);
|
|
203
|
+
}
|
|
204
|
+
return isMutation
|
|
205
|
+
? runMutation(operation, call, parsed.data)
|
|
206
|
+
: runQuery(operation, call, parsed.data);
|
|
207
|
+
};
|
|
208
|
+
const timeout = definition.stepDefaults.executeMethodTimeoutMs;
|
|
209
|
+
return {
|
|
210
|
+
name: toolName,
|
|
211
|
+
description: options.description ?? factory.description ?? "",
|
|
212
|
+
inputSchema: schema,
|
|
213
|
+
connectorId,
|
|
214
|
+
operationId,
|
|
215
|
+
kind,
|
|
216
|
+
effect,
|
|
217
|
+
isApprovalRecommended: approval === "recommended",
|
|
218
|
+
requiresApproval: options.requiresApproval,
|
|
219
|
+
maxResultBytes: options.maxResultBytes,
|
|
220
|
+
connection,
|
|
221
|
+
agentBranches: { ...agentBranches },
|
|
222
|
+
requiredBranches: new Set(definition.branches.filter((branch) => branch.optional !== true).map((branch) => branch.id)),
|
|
223
|
+
executeMethodTimeout: timeout === undefined || timeout === 0 ? undefined : timeout,
|
|
224
|
+
retryPolicy: boundedRetryPolicy(definition.stepDefaults.executeRetry ?? defaultConnectorStepExecuteRetryPolicy()),
|
|
225
|
+
invoke,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Offers reviewed Connector operations to a built-in loop agent as tools.
|
|
230
|
+
*
|
|
231
|
+
* Put it in `AgentDefinition.toolSources`, as `McpToolSource` is. It lists exactly the tools the application
|
|
232
|
+
* passes; no Connector is exposed by default. Each call runs one operation invocation in its own tool Step, through
|
|
233
|
+
* the Connector SDK's `runQuery` or `runMutation`, so the connector's Call ID, idempotency key, credential
|
|
234
|
+
* handling, and single-dispatch fence apply. The Call ID is derived from the Flow ID and the tool Step's execution
|
|
235
|
+
* ID, so it is the same on every attempt of that Step.
|
|
236
|
+
*
|
|
237
|
+
* Before anything runs, the model's arguments are checked against the manifest's `inputSchema` and then decoded
|
|
238
|
+
* with the package's input validator. Either failure is a `failed` call the model can correct; the operation never
|
|
239
|
+
* runs.
|
|
240
|
+
*
|
|
241
|
+
* Connector writes of one model response run one at a time in the model's order, and reads run in parallel. A
|
|
242
|
+
* write whose approval is needed waits for it only when its turn comes. Once a write does not succeed, the later
|
|
243
|
+
* writes of that response are recorded `failed` with `skipped` set.
|
|
244
|
+
*
|
|
245
|
+
* The selected branch maps as {@link classifyConnectorBranch} describes. A connector retry throws through the
|
|
246
|
+
* Step, so the tool Step's retry policy applies. A single-attempt write that asks to retry ends `outcome_unknown`,
|
|
247
|
+
* unless its single-dispatch fence saved a `notSent` or `canResend` marker in this attempt: that proves the
|
|
248
|
+
* provider did not process the request, so the call records `failed` with {@link connectorNotSentRetryLater}.
|
|
249
|
+
* Either way it stops the later writes. A result longer than `maxResultBytes` reaches the model truncated, with
|
|
250
|
+
* {@link connectorResultTruncatedNote}, and the record's `truncatedOutputBytes` holds the full size.
|
|
251
|
+
*
|
|
252
|
+
* Install `@superdurable/connectors-sdk` next to this package; it is an optional peer dependency.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* const flow = createBuiltinAgentSessionFlow(
|
|
257
|
+
* { name: "support", instructions: "You help customers.", model,
|
|
258
|
+
* toolSources: [new ConnectorToolSource([refund, reply])] },
|
|
259
|
+
* "SupportAgent",
|
|
260
|
+
* );
|
|
261
|
+
* ```
|
|
262
|
+
* @since 0.4.0
|
|
263
|
+
*/
|
|
264
|
+
export class ConnectorToolSource {
|
|
265
|
+
/** The source's stable name, stored with each call; keep it across deploys. */
|
|
266
|
+
sourceName;
|
|
267
|
+
toolsByName;
|
|
268
|
+
definitions;
|
|
269
|
+
maxResultBytes;
|
|
270
|
+
/**
|
|
271
|
+
* Creates the source.
|
|
272
|
+
* @param tools - The tools to offer, in the order the model sees them.
|
|
273
|
+
* @param options - `sourceName`, default {@link defaultConnectorSourceName}, and `maxResultBytes`, default
|
|
274
|
+
* {@link defaultConnectorResultMaxBytes}.
|
|
275
|
+
* @throws {TypeError} When two tools share a name or `sourceName` is blank.
|
|
276
|
+
* @throws {RangeError} When `maxResultBytes` is not positive.
|
|
277
|
+
*/
|
|
278
|
+
constructor(tools, options = {}) {
|
|
279
|
+
const sourceName = options.sourceName ?? defaultConnectorSourceName;
|
|
280
|
+
if (sourceName.trim() === "") {
|
|
281
|
+
throw new TypeError("sourceName must not be blank");
|
|
282
|
+
}
|
|
283
|
+
const maxResultBytes = options.maxResultBytes ?? defaultConnectorResultMaxBytes;
|
|
284
|
+
if (!(maxResultBytes >= 1)) {
|
|
285
|
+
throw new RangeError("maxResultBytes must be positive");
|
|
286
|
+
}
|
|
287
|
+
this.toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
288
|
+
if (this.toolsByName.size !== tools.length) {
|
|
289
|
+
throw new TypeError("two connector tools share a name");
|
|
290
|
+
}
|
|
291
|
+
this.sourceName = sourceName;
|
|
292
|
+
this.maxResultBytes = maxResultBytes;
|
|
293
|
+
this.definitions = tools.map((tool) => ({
|
|
294
|
+
name: tool.name,
|
|
295
|
+
description: tool.description,
|
|
296
|
+
inputSchema: tool.inputSchema,
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Returns the tools; the list is fixed when the source is built.
|
|
301
|
+
* @returns The tool definitions.
|
|
302
|
+
*/
|
|
303
|
+
async listTools() {
|
|
304
|
+
return this.definitions;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Returns the tools without I/O.
|
|
308
|
+
* @returns The tool definitions.
|
|
309
|
+
*/
|
|
310
|
+
cachedTools() {
|
|
311
|
+
return this.definitions;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Returns every tool name, so the runner refuses a collision.
|
|
315
|
+
* @returns The names.
|
|
316
|
+
*/
|
|
317
|
+
declaredToolNames() {
|
|
318
|
+
return new Set(this.toolsByName.keys());
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Builds the call with the manifest's effect and the call's approval.
|
|
322
|
+
* @param turn - The `RunModel` context; a `toolPolicies` entry for the tool changes only its approval.
|
|
323
|
+
* @param call - The model's tool call.
|
|
324
|
+
* @returns The deferred call, ordered when it is a write.
|
|
325
|
+
*/
|
|
326
|
+
deferredToolCall(turn, call) {
|
|
327
|
+
const tool = this.requireTool(call.toolName);
|
|
328
|
+
const sessionPolicy = turn.toolPolicies !== undefined && Object.hasOwn(turn.toolPolicies, call.toolName)
|
|
329
|
+
? turn.toolPolicies[call.toolName]
|
|
330
|
+
: undefined;
|
|
331
|
+
const requiresApproval = sessionPolicy?.requiresApproval ?? requiresApprovalOf(tool, call.arguments);
|
|
332
|
+
return {
|
|
333
|
+
toolCallId: call.toolCallId,
|
|
334
|
+
toolName: call.toolName,
|
|
335
|
+
arguments: call.arguments,
|
|
336
|
+
policy: { effect: tool.effect, requiresApproval },
|
|
337
|
+
toolSourceReference: serializeJsonWithSpacedSeparators({ tool: tool.name }),
|
|
338
|
+
ordered: tool.effect !== "read",
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Returns the operation's timeout and retry policy for the call's tool Step.
|
|
343
|
+
* @param toolCall - The record whose tool Step starts.
|
|
344
|
+
* @returns The options, or `undefined` when this source no longer has the tool.
|
|
345
|
+
*/
|
|
346
|
+
toolCallStepOptions(toolCall) {
|
|
347
|
+
const tool = this.toolsByName.get(referenceToolName(toolCall));
|
|
348
|
+
if (tool === undefined) {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
...(tool.executeMethodTimeout === undefined ? {} : { executeMethodTimeout: tool.executeMethodTimeout }),
|
|
353
|
+
executeRetry: tool.retryPolicy,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Checks, decodes, and runs one call, then maps the selected branch.
|
|
358
|
+
* @param call - The approved call, with the tool Step's live context.
|
|
359
|
+
* @returns The result value as JSON text, bounded by `maxResultBytes`.
|
|
360
|
+
* @throws {ToolExecutionError} When the arguments break the schema or do not decode, the operation selected a
|
|
361
|
+
* `rejected` or failed branch, or a single-attempt write asked to retry after its fence recorded `notSent` or
|
|
362
|
+
* `canResend` in this attempt, which proves the provider did not process it ({@link connectorNotSentRetryLater}).
|
|
363
|
+
* @throws {ToolOutcomeUnknownError} When the operation selected an unknown branch.
|
|
364
|
+
* @throws {RangeError} When this source no longer has the tool, so the effect decides the outcome.
|
|
365
|
+
* @throws Any other error, such as a connector retry for the tool Step's retry policy.
|
|
366
|
+
*/
|
|
367
|
+
async executeDeferredToolCall(call) {
|
|
368
|
+
const record = call.toolCall;
|
|
369
|
+
const tool = this.toolsByName.get(referenceToolName(record));
|
|
370
|
+
if (tool === undefined) {
|
|
371
|
+
throw new RangeError(`connector tool ${record.toolName} is not configured on this Worker`);
|
|
372
|
+
}
|
|
373
|
+
const toolArguments = parseToolArguments(tool.name, record.arguments);
|
|
374
|
+
const problem = findConnectorInputViolation(toolArguments, tool.inputSchema);
|
|
375
|
+
if (problem !== undefined) {
|
|
376
|
+
throw new ToolExecutionError(`invalid arguments for ${tool.name}: ${problem}`);
|
|
377
|
+
}
|
|
378
|
+
if (call.context === undefined) {
|
|
379
|
+
throw new Error("a connector tool call needs the tool Step's context");
|
|
380
|
+
}
|
|
381
|
+
const stepContext = new ConnectorStepContext(call.context, {
|
|
382
|
+
previousCheckpoint: call.heartbeatCheckpoint,
|
|
383
|
+
heartbeat: () => call.heartbeat(),
|
|
384
|
+
...(call.saveHeartbeatCheckpoint === undefined
|
|
385
|
+
? {}
|
|
386
|
+
: { saveCheckpoint: (checkpoint) => call.saveHeartbeatCheckpoint(checkpoint) }),
|
|
387
|
+
});
|
|
388
|
+
const connectorCall = createCall(stepContext, tool.connection, {
|
|
389
|
+
connectorId: tool.connectorId,
|
|
390
|
+
operationId: tool.operationId,
|
|
391
|
+
});
|
|
392
|
+
let result;
|
|
393
|
+
try {
|
|
394
|
+
result = await tool.invoke(connectorCall, toolArguments);
|
|
395
|
+
}
|
|
396
|
+
catch (error) {
|
|
397
|
+
if (error instanceof RetryError) {
|
|
398
|
+
if (tool.effect === "non_idempotent_write" && isProvenNotSent(connectorCall, stepContext)) {
|
|
399
|
+
// One attempt only, so a Retry would record outcome_unknown though nothing was sent.
|
|
400
|
+
throw new ToolExecutionError(notSentDetail(tool, error.failure));
|
|
401
|
+
}
|
|
402
|
+
throwDexRetry(error);
|
|
403
|
+
}
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
406
|
+
const outcome = classifyConnectorBranch({
|
|
407
|
+
kind: tool.kind,
|
|
408
|
+
branch: result.branch,
|
|
409
|
+
requiredBranches: tool.requiredBranches,
|
|
410
|
+
agentBranches: tool.agentBranches,
|
|
411
|
+
mayHaveDispatched: mayHaveDispatched(connectorCall, stepContext),
|
|
412
|
+
});
|
|
413
|
+
if (outcome === "succeeded") {
|
|
414
|
+
return boundConnectorResult(encodeResultValue(result.value), tool.maxResultBytes ?? this.maxResultBytes);
|
|
415
|
+
}
|
|
416
|
+
const detail = branchDetail(tool, result.branch, result.failure);
|
|
417
|
+
if (outcome === "outcome_unknown") {
|
|
418
|
+
throw new ToolOutcomeUnknownError(detail);
|
|
419
|
+
}
|
|
420
|
+
throw new ToolExecutionError(detail);
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Refuses a poll: connector tools never start tool tasks.
|
|
424
|
+
* @param poll - The call.
|
|
425
|
+
* @returns Never.
|
|
426
|
+
* @throws {RangeError} Always.
|
|
427
|
+
*/
|
|
428
|
+
async pollToolTask(poll) {
|
|
429
|
+
throw new RangeError(`connector tool ${poll.toolCall.toolName} starts no task`);
|
|
430
|
+
}
|
|
431
|
+
requireTool(toolName) {
|
|
432
|
+
const tool = this.toolsByName.get(toolName);
|
|
433
|
+
if (tool === undefined) {
|
|
434
|
+
throw new RangeError(`connector tool ${toolName} is not configured on this Worker`);
|
|
435
|
+
}
|
|
436
|
+
return tool;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Returns `output` whole, or its first `maxResultBytes` bytes and {@link connectorResultTruncatedNote}.
|
|
441
|
+
* @param output - The full result text.
|
|
442
|
+
* @param maxResultBytes - The bound, in bytes of UTF-8 text, on the kept part.
|
|
443
|
+
* @returns The result, with `truncatedOutputBytes` set when it was cut.
|
|
444
|
+
* @since 0.4.0
|
|
445
|
+
*/
|
|
446
|
+
export function boundConnectorResult(output, maxResultBytes) {
|
|
447
|
+
const encoded = Buffer.from(output, "utf8");
|
|
448
|
+
if (encoded.length <= maxResultBytes) {
|
|
449
|
+
return { output };
|
|
450
|
+
}
|
|
451
|
+
let end = maxResultBytes;
|
|
452
|
+
// A cut inside a character drops its partial bytes, as Python's "ignore" decoding does.
|
|
453
|
+
while (end > 0 && ((encoded[end] ?? 0) & 0xc0) === 0x80) {
|
|
454
|
+
end -= 1;
|
|
455
|
+
}
|
|
456
|
+
const kept = encoded.subarray(0, end).toString("utf8");
|
|
457
|
+
const note = connectorResultTruncatedNote.replace("{total_bytes}", String(encoded.length));
|
|
458
|
+
return { output: `${kept}\n${note}`, truncatedOutputBytes: encoded.length };
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Returns the text the model reads for one result value, the same in every core: keys sorted by code point, no
|
|
462
|
+
* spaces, unescaped UTF-8, and a number with no fractional part written as an integer.
|
|
463
|
+
* @param jsonText - The result value as JSON text.
|
|
464
|
+
* @returns The canonical text.
|
|
465
|
+
* @since 0.4.0
|
|
466
|
+
*/
|
|
467
|
+
export function formatConnectorResult(jsonText) {
|
|
468
|
+
return JSON.stringify(sortObjectKeys(JSON.parse(jsonText)));
|
|
469
|
+
}
|
|
470
|
+
function sortObjectKeys(value) {
|
|
471
|
+
if (Array.isArray(value)) {
|
|
472
|
+
return value.map(sortObjectKeys);
|
|
473
|
+
}
|
|
474
|
+
if (typeof value === "object" && value !== null) {
|
|
475
|
+
const record = value;
|
|
476
|
+
return Object.fromEntries(Object.keys(record)
|
|
477
|
+
.sort(compareCodePoints)
|
|
478
|
+
.map((key) => [key, sortObjectKeys(record[key])]));
|
|
479
|
+
}
|
|
480
|
+
return value;
|
|
481
|
+
}
|
|
482
|
+
function encodeResultValue(value) {
|
|
483
|
+
return value === undefined || value === null ? "null" : formatConnectorResult(JSON.stringify(value));
|
|
484
|
+
}
|
|
485
|
+
function requiresApprovalOf(tool, toolArguments) {
|
|
486
|
+
const choice = tool.requiresApproval;
|
|
487
|
+
if (choice === undefined) {
|
|
488
|
+
return tool.isApprovalRecommended;
|
|
489
|
+
}
|
|
490
|
+
if (typeof choice === "boolean") {
|
|
491
|
+
return choice;
|
|
492
|
+
}
|
|
493
|
+
let values;
|
|
494
|
+
try {
|
|
495
|
+
values = JSON.parse(toolArguments === "" ? "{}" : toolArguments);
|
|
496
|
+
}
|
|
497
|
+
catch {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
if (!isRecord(values) || findConnectorInputViolation(values, tool.inputSchema) !== undefined) {
|
|
501
|
+
// The tool Step refuses these arguments before the operation runs.
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
try {
|
|
505
|
+
return Boolean(choice(values));
|
|
506
|
+
}
|
|
507
|
+
catch {
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function parseToolArguments(toolName, toolArguments) {
|
|
512
|
+
let values;
|
|
513
|
+
try {
|
|
514
|
+
values = JSON.parse(toolArguments === "" ? "{}" : toolArguments);
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
throw new ToolExecutionError(`invalid arguments for ${toolName}: arguments are not valid JSON`);
|
|
518
|
+
}
|
|
519
|
+
if (!isRecord(values)) {
|
|
520
|
+
throw new ToolExecutionError(`invalid arguments for ${toolName}: expected a JSON object`);
|
|
521
|
+
}
|
|
522
|
+
return values;
|
|
523
|
+
}
|
|
524
|
+
/** Reports whether fence events leave open that the request was sent, as sdkgo does. */
|
|
525
|
+
export function mayHaveDispatched(call, context) {
|
|
526
|
+
return observeFence(call, context).mayHaveDispatched;
|
|
527
|
+
}
|
|
528
|
+
/** Reports whether this attempt's fence recorded proof that the write was not sent. */
|
|
529
|
+
export function isProvenNotSent(call, context) {
|
|
530
|
+
return observeFence(call, context).isProvenNotSent;
|
|
531
|
+
}
|
|
532
|
+
function observeFence(call, context) {
|
|
533
|
+
const evidence = readFenceEvidence(context, call.id);
|
|
534
|
+
const isClaimed = evidence?.isClaimed ?? false;
|
|
535
|
+
const hasNotSentProof = evidence?.hasNotSentProof ?? false;
|
|
536
|
+
const isPriorDispatchPossible = hasReadCheckpoint(context) && isPriorDispatchPossibleFor(call, context);
|
|
537
|
+
const isDispatchPossible = isClaimed || isPriorDispatchPossible;
|
|
538
|
+
return { mayHaveDispatched: isDispatchPossible, isProvenNotSent: hasNotSentProof && !isDispatchPossible };
|
|
539
|
+
}
|
|
540
|
+
/** Reports whether the earlier attempt's checkpoint denies this attempt a send. */
|
|
541
|
+
function isPriorDispatchPossibleFor(call, context) {
|
|
542
|
+
const previousCheckpoint = readPreviousCheckpoint(context);
|
|
543
|
+
if (previousCheckpoint === undefined) {
|
|
544
|
+
// A lost checkpoint after attempt one may hide an earlier send.
|
|
545
|
+
return context.attempt > 1;
|
|
546
|
+
}
|
|
547
|
+
let previous;
|
|
548
|
+
try {
|
|
549
|
+
previous = JSON.parse(previousCheckpoint);
|
|
550
|
+
}
|
|
551
|
+
catch {
|
|
552
|
+
return true;
|
|
553
|
+
}
|
|
554
|
+
// Not a marker or malformed: the fence fails closed, and so does this.
|
|
555
|
+
const isSendAllowed = isFenceMarker(previous) &&
|
|
556
|
+
previous["callId"] === call.id &&
|
|
557
|
+
previous["attempt"] === context.attempt - 1 &&
|
|
558
|
+
(previous["state"] === "notSent" || previous["state"] === "canResend") &&
|
|
559
|
+
(previous["providerId"] === undefined || previous["providerId"] === "");
|
|
560
|
+
return !isSendAllowed;
|
|
561
|
+
}
|
|
562
|
+
function notSentDetail(tool, failure) {
|
|
563
|
+
const detail = `${tool.connectorId} ${tool.operationId} ${connectorNotSentRetryLater}`;
|
|
564
|
+
return failure === undefined ? detail : `${detail}: ${failure.kind}: ${failure.message}`;
|
|
565
|
+
}
|
|
566
|
+
function branchDetail(tool, branch, failure) {
|
|
567
|
+
const detail = `${tool.connectorId} ${tool.operationId} returned ${branch}`;
|
|
568
|
+
return failure === undefined ? detail : `${detail}: ${failure.kind}: ${failure.message}`;
|
|
569
|
+
}
|
|
570
|
+
function referenceToolName(record) {
|
|
571
|
+
try {
|
|
572
|
+
const reference = JSON.parse(record.toolSourceReference ?? "");
|
|
573
|
+
const name = isRecord(reference) ? reference["tool"] : undefined;
|
|
574
|
+
return typeof name === "string" ? name : record.toolName;
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
return record.toolName;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function boundedRetryPolicy(policy) {
|
|
581
|
+
const attempts = policy.maximumAttempts;
|
|
582
|
+
return {
|
|
583
|
+
initialIntervalMs: policy.initialIntervalMs,
|
|
584
|
+
backoffCoefficient: policy.backoffCoefficient,
|
|
585
|
+
maximumIntervalMs: policy.maximumIntervalMs,
|
|
586
|
+
maximumAttempts: attempts <= 0 ? maximumToolAttempts : Math.min(attempts, maximumToolAttempts),
|
|
587
|
+
totalDurationMs: policy.totalDurationMs,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Returns an operation ID in snake case, as connectorctl `lowerCamelToSnake` names the Python Step factories.
|
|
592
|
+
* @param operationId - The lower camel case operation ID, such as `listStoryIDs`.
|
|
593
|
+
* @returns The snake case name, such as `list_story_ids`.
|
|
594
|
+
*/
|
|
595
|
+
export function lowerCamelToSnake(operationId) {
|
|
596
|
+
const characters = Array.from(operationId);
|
|
597
|
+
let converted = "";
|
|
598
|
+
for (const [index, character] of characters.entries()) {
|
|
599
|
+
if (!isAsciiUpper(character)) {
|
|
600
|
+
converted += character;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
const previous = characters[index - 1];
|
|
604
|
+
const following = characters[index + 1];
|
|
605
|
+
const isPreviousLowerOrDigit = isAsciiLower(previous) || isAsciiDigit(previous);
|
|
606
|
+
// A trailing lowercase s pluralizes the acronym, as in listStoryIDs.
|
|
607
|
+
const isAcronymPlural = following === "s" && !isAsciiLower(characters[index + 2]);
|
|
608
|
+
const isEndOfAcronym = isAsciiUpper(previous) && isAsciiLower(following) && !isAcronymPlural;
|
|
609
|
+
if (isPreviousLowerOrDigit || isEndOfAcronym) {
|
|
610
|
+
converted += "_";
|
|
611
|
+
}
|
|
612
|
+
converted += character.toLowerCase();
|
|
613
|
+
}
|
|
614
|
+
return converted;
|
|
615
|
+
}
|
|
616
|
+
function isAsciiUpper(character) {
|
|
617
|
+
return character !== undefined && character >= "A" && character <= "Z";
|
|
618
|
+
}
|
|
619
|
+
function isAsciiLower(character) {
|
|
620
|
+
return character !== undefined && character >= "a" && character <= "z";
|
|
621
|
+
}
|
|
622
|
+
function isAsciiDigit(character) {
|
|
623
|
+
return character !== undefined && character >= "0" && character <= "9";
|
|
624
|
+
}
|
|
625
|
+
function isRecord(value) {
|
|
626
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
627
|
+
}
|
|
628
|
+
//# sourceMappingURL=connector-tool-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-tool-source.js","sourceRoot":"","sources":["../../../src/connectors/connector-tool-source.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAG1D,OAAO,EACL,UAAU,EACV,UAAU,EACV,sCAAsC,EACtC,WAAW,EACX,QAAQ,EACR,aAAa,GAQd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GAQxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAE9F,OAAO,E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AAY,CAAC,SAA6B;IACjD,OAAO,SAAS,KAAK,SAAS,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ConnectorToolSource, boundConnectorResult, classifyConnectorBranch, connectorNotSentRetryLater, connectorResultTruncatedNote, connectorTool, defaultConnectorResultMaxBytes, defaultConnectorSourceName, formatConnectorResult, type ApprovalPredicate, type ConnectorBranchOutcome, type ConnectorInputValidator, type ConnectorManifestFactory, type ConnectorPackageManifest, type ConnectorTool, type ConnectorToolOptions, } from "./connector-tool-source.js";
|
|
2
|
+
export { ConnectorStepContext, type ConnectorStepHeartbeats } from "./connector-step-context.js";
|
|
3
|
+
export { checkConnectorInputSchema, findConnectorInputViolation } from "./connector-input-schema.js";
|