@superdurable/connector-flurouter 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # FluRouter TypeScript connector
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Read model IDs visible to the connected FluRouter API Key.
4
+
5
+ Install `@superdurable/connector-flurouter` and use `newProjectConnection` with the static connection name in the runnable [`examples/basic`](examples/basic) Flow. Configure the connection and provider credentials in Dex Web Connections. The operation `listModels` resolves credentials for each call. Local conformance tests replay the Go provider scenarios; live provider authorization has not been verified.
@@ -0,0 +1,52 @@
1
+ {
2
+ "connectorId": "flurouter",
3
+ "releaseTag": "connectors/flurouter/go/v0.1.0",
4
+ "package": {
5
+ "ecosystem": "npm",
6
+ "name": "@superdurable/connector-flurouter",
7
+ "version": "0.1.0"
8
+ },
9
+ "factories": [
10
+ {
11
+ "name": "newListModelsStep",
12
+ "kind": "query",
13
+ "operationId": "listModels",
14
+ "inputType": "ListModelsInput",
15
+ "description": "List model IDs currently visible to the connected Key.",
16
+ "fields": {
17
+ "stepType": "stepType",
18
+ "annotations": "annotations",
19
+ "connectionName": "connectionName",
20
+ "resultAttribute": "resultAttribute"
21
+ },
22
+ "branches": [
23
+ {
24
+ "id": "found",
25
+ "field": "found",
26
+ "optional": false
27
+ },
28
+ {
29
+ "id": "providerRejected",
30
+ "field": "providerRejected",
31
+ "optional": true
32
+ },
33
+ {
34
+ "id": "invalidResponse",
35
+ "field": "invalidResponse",
36
+ "optional": true
37
+ },
38
+ {
39
+ "id": "defect",
40
+ "field": "defect",
41
+ "optional": true
42
+ }
43
+ ],
44
+ "inputSchema": {
45
+ "additionalProperties": false,
46
+ "description": "ListModelsInput has no input because the API Key determines visible models.",
47
+ "properties": {},
48
+ "type": "object"
49
+ }
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,113 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
4
+ var ConfigSchema = z.object({
5
+ "timeoutMs": z.number().int().optional(),
6
+ "maxResponseBytes": z.number().int().optional()
7
+ });
8
+ var CredentialMaterialError = class extends TypeError {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = "CredentialMaterialError";
12
+ }
13
+ };
14
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
15
+ "project credential decoding failed",
16
+ "shared project credential decoding failed",
17
+ "project credential decoding failed: this connector version does not support shared credentials"
18
+ ]);
19
+ function isCredentialMaterialError(error) {
20
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
21
+ }
22
+ function decodeCredentials(value) {
23
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
24
+ const fields = value;
25
+ const allowed = /* @__PURE__ */ new Set(["apiKey"]);
26
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
27
+ if (fields["apiKey"] != null && !(typeof fields["apiKey"] === "string")) throw new CredentialMaterialError("credential apiKey has an invalid type");
28
+ const credentials = {};
29
+ if (!fields["apiKey"]) throw new CredentialMaterialError("credential apiKey is required");
30
+ credentials.apiKey = new SecretString(fields["apiKey"] ?? "");
31
+ return credentials;
32
+ }
33
+ var ListModelsInputSchema = z.strictObject({});
34
+ var ListModelsOutputSchema = z.strictObject({
35
+ "modelIDs": z.array(z.string()).nullable()
36
+ });
37
+
38
+ // src/generated/definitions.ts
39
+ var ConnectorID = "flurouter";
40
+ var ProviderID = "flurouter";
41
+ var ListModelsBranch = {
42
+ Found: "found",
43
+ ProviderRejected: "providerRejected",
44
+ InvalidResponse: "invalidResponse",
45
+ Defect: "defect"
46
+ };
47
+ var ListModelsBranchFound = ListModelsBranch.Found;
48
+ var ListModelsBranchProviderRejected = ListModelsBranch.ProviderRejected;
49
+ var ListModelsBranchInvalidResponse = ListModelsBranch.InvalidResponse;
50
+ var ListModelsBranchDefect = ListModelsBranch.Defect;
51
+ var ListModelsDefinition = {
52
+ operation: { connectorId: ConnectorID, operationId: "listModels" },
53
+ branches: [
54
+ { id: "found", description: "FluRouter returned the Key-visible model list." },
55
+ { id: "providerRejected", description: "FluRouter rejected the Key or request.", optional: true },
56
+ { id: "invalidResponse", description: "FluRouter returned malformed or oversized model data.", optional: true },
57
+ { id: "defect", description: "The local API Key is invalid.", optional: true }
58
+ ],
59
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async", executeRetry: { initialIntervalMs: 2e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 3, totalDurationMs: 3e5 } }
60
+ };
61
+ var ListModelsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
62
+
63
+ // src/generated/connection.ts
64
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
65
+ var Connection = class {
66
+ /** Stable provider and connection name. */
67
+ reference;
68
+ /** Bound provider operations. */
69
+ operations;
70
+ /** Validate a reference and bind operations. */
71
+ constructor(reference, operations) {
72
+ this.reference = ConnectionRefSchema.parse(reference);
73
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
74
+ if (!operations) throw new TypeError("connector operations are required");
75
+ this.operations = operations;
76
+ }
77
+ };
78
+ function newConnection(client, reference) {
79
+ if (!client) throw new TypeError("connector client is required");
80
+ return new Connection(reference, client);
81
+ }
82
+ function newConnectionWithOperations(operations, reference) {
83
+ return new Connection(reference, operations);
84
+ }
85
+ function newProjectConnection(project, connectionName, createClient) {
86
+ if (!project) throw new TypeError("loaded project is required");
87
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
88
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
89
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
90
+ return newConnection(createClient(project, connectionName), reference);
91
+ }
92
+
93
+ export {
94
+ ConfigSchema,
95
+ CredentialMaterialError,
96
+ isCredentialMaterialError,
97
+ decodeCredentials,
98
+ ListModelsInputSchema,
99
+ ListModelsOutputSchema,
100
+ ConnectorID,
101
+ ProviderID,
102
+ ListModelsBranch,
103
+ ListModelsBranchFound,
104
+ ListModelsBranchProviderRejected,
105
+ ListModelsBranchInvalidResponse,
106
+ ListModelsBranchDefect,
107
+ ListModelsDefinition,
108
+ ListModelsMetadata,
109
+ Connection,
110
+ newConnection,
111
+ newConnectionWithOperations,
112
+ newProjectConnection
113
+ };
@@ -0,0 +1,65 @@
1
+ import { CredentialProvider, SecretString, Query, ConnectionRef } from '@superdurable/connectors-sdk';
2
+ import { z } from 'zod';
3
+
4
+ /** Connector configuration; omitted fields use manifest defaults. */
5
+ interface Config {
6
+ /** Maximum duration of one model-list HTTP request as a positive Go duration such as 5s or 1m. Blank uses the displayed default; increase only for a slow approved network. Runtime value in milliseconds. */
7
+ timeoutMs?: number;
8
+ /** Maximum provider response size in bytes as a positive integer. Blank uses the displayed default; increase only for a large authorized model catalog. */
9
+ maxResponseBytes?: number;
10
+ }
11
+ /** Runtime schema for manifest configuration. */
12
+ declare const ConfigSchema: z.ZodObject<{
13
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
14
+ maxResponseBytes: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>;
16
+ /** Private connector credentials resolved by the host. */
17
+ interface Credentials {
18
+ /** Secret sk-il- API Key from https://flurouter.net/guide > Console > API Keys. Create a Key and copy it when first shown; blank prevents requests. Dex stores it as a secret. */
19
+ apiKey: SecretString;
20
+ }
21
+ /** Stored credential material that fails the connector credential checks, so no retry can succeed. */
22
+ declare class CredentialMaterialError extends TypeError {
23
+ constructor(message: string);
24
+ }
25
+ /** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
26
+ declare function isCredentialMaterialError(error: unknown): boolean;
27
+ /** Decode private credential fields for the connector. */
28
+ declare function decodeCredentials(value: unknown): Credentials;
29
+ /** Host-owned source of private connector credentials. */
30
+ type CredentialSource = CredentialProvider<Credentials>;
31
+ /** ListModelsInput has no input because the API Key determines visible models. */
32
+ interface ListModelsInput {
33
+ }
34
+ /** ListModelsOutput contains only model IDs visible to the connected Key. */
35
+ interface ListModelsOutput {
36
+ /** ModelIDs are the model identifiers to use in later inference requests. */
37
+ "modelIDs": Array<string> | null;
38
+ }
39
+ /** Runtime validator for ListModelsInput. */
40
+ declare const ListModelsInputSchema: z.ZodObject<{}, z.core.$strict>;
41
+ /** Runtime validator for ListModelsOutput. */
42
+ declare const ListModelsOutputSchema: z.ZodObject<{
43
+ modelIDs: z.ZodNullable<z.ZodArray<z.ZodString>>;
44
+ }, z.core.$strict>;
45
+
46
+ /** Typed operations supplied by a client or mock. */
47
+ interface Operations {
48
+ /** Invoke listModels through this connection. */
49
+ listModels(): Query<ListModelsInput, ListModelsOutput>;
50
+ }
51
+ /** Named connector connection kept outside Flow state. */
52
+ declare class Connection<BoundOperations = Operations> {
53
+ /** Stable provider and connection name. */
54
+ readonly reference: ConnectionRef;
55
+ /** Bound provider operations. */
56
+ readonly operations: BoundOperations;
57
+ /** Validate a reference and bind operations. */
58
+ constructor(reference: ConnectionRef, operations: BoundOperations);
59
+ }
60
+ /** Bind a client to a named connection. */
61
+ declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
62
+ /** Bind scripted operations to a named connection. */
63
+ declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
64
+
65
+ export { Connection as C, type ListModelsInput as L, type Operations as O, type ListModelsOutput as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, ListModelsInputSchema as g, ListModelsOutputSchema as h, decodeCredentials as i, isCredentialMaterialError as j, newConnectionWithOperations as k, newConnection as n };
@@ -0,0 +1,89 @@
1
+ import { L as ListModelsInput, a as ListModelsOutput, C as Connection, O as Operations, b as Config, c as Credentials } from './connection-CLcILwb-.js';
2
+ export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as ListModelsInputSchema, h as ListModelsOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-CLcILwb-.js';
3
+ import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
4
+ import { StepTarget } from '@superdurable/dex';
5
+ import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
6
+ import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
7
+ import 'zod';
8
+
9
+ /** Stable connector identity. */
10
+ declare const ConnectorID = "flurouter";
11
+ /** Provider identity for named connections. */
12
+ declare const ProviderID = "flurouter";
13
+ /** Branch IDs for listModels. */
14
+ declare const ListModelsBranch: {
15
+ readonly Found: "found";
16
+ readonly ProviderRejected: "providerRejected";
17
+ readonly InvalidResponse: "invalidResponse";
18
+ readonly Defect: "defect";
19
+ };
20
+ /** FluRouter returned the Key-visible model list. */
21
+ declare const ListModelsBranchFound: "found";
22
+ /** FluRouter rejected the Key or request. */
23
+ declare const ListModelsBranchProviderRejected: "providerRejected";
24
+ /** FluRouter returned malformed or oversized model data. */
25
+ declare const ListModelsBranchInvalidResponse: "invalidResponse";
26
+ /** The local API Key is invalid. */
27
+ declare const ListModelsBranchDefect: "defect";
28
+ /** Manifest definition for listModels. */
29
+ declare const ListModelsDefinition: QueryDefinition;
30
+ /** Manifest metadata for listModels. */
31
+ declare const ListModelsMetadata: {
32
+ readonly kind: "query";
33
+ readonly idempotency: "none";
34
+ readonly authorization: "required";
35
+ };
36
+
37
+ /** Configuration for the listModels connector Step. */
38
+ interface ListModelsStepConfig<StepInput, OperationInput = ListModelsInput, OperationOutput = ListModelsOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
39
+ /** Named connection supplying this operation. */
40
+ connection: Connection<{
41
+ listModels(): Query<OperationInput, OperationOutput>;
42
+ }>;
43
+ /** Name matching the bound connection. */
44
+ connectionName: string;
45
+ /** FluRouter returned the Key-visible model list. */
46
+ found: StepTarget<QueryResult<OperationOutput>>;
47
+ /** FluRouter rejected the Key or request. */
48
+ providerRejected?: StepTarget<QueryResult<OperationOutput>>;
49
+ /** FluRouter returned malformed or oversized model data. */
50
+ invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
51
+ /** The local API Key is invalid. */
52
+ defect?: StepTarget<QueryResult<OperationOutput>>;
53
+ }
54
+ /** Build the listModels Step from a named connection. */
55
+ declare function newListModelsStep<StepInput, OperationInput = ListModelsInput, OperationOutput = ListModelsOutput>(configuration: ListModelsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
56
+
57
+ /** Open one named Flurouter connection from Dex project configuration. */
58
+ declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
59
+
60
+ /** Optional provider sender for local tests. */
61
+ interface FlurouterClientOptions {
62
+ /** Sender; omitted uses the SDK HTTP transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
63
+ }
64
+ /** Read model identifiers visible to the connected FluRouter key. */
65
+ declare class FlurouterClient {
66
+ private readonly credentials;
67
+ private readonly timeoutMs;
68
+ private readonly maxResponseBytes;
69
+ private readonly send;
70
+ /** Validate local limits without contacting FluRouter. */
71
+ constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: FlurouterClientOptions);
72
+ /** Bind the model-list Query. */ listModels(): ListModelsOperation;
73
+ /** Send one bounded model-list request. */
74
+ list(call: Call): Promise<{
75
+ response?: ProviderResponse;
76
+ error?: 'credential' | 'transport' | 'tooLarge';
77
+ retryAfterMs: number;
78
+ }>;
79
+ }
80
+ /** Read the current FluRouter model catalog. */
81
+ declare class ListModelsOperation implements Query<ListModelsInput, ListModelsOutput> {
82
+ private readonly client;
83
+ /** Bind the provider client. */ constructor(client: FlurouterClient);
84
+ /** Return the generated Query definition. */ definition(): QueryDefinition;
85
+ /** Classify one model-list request using the Go connector contract. */
86
+ invoke(call: Call): Promise<QueryAttempt<ListModelsOutput>>;
87
+ }
88
+
89
+ export { Config, Connection, ConnectorID, Credentials, FlurouterClient, type FlurouterClientOptions, ListModelsBranch, ListModelsBranchDefect, ListModelsBranchFound, ListModelsBranchInvalidResponse, ListModelsBranchProviderRejected, ListModelsDefinition, ListModelsInput, ListModelsMetadata, ListModelsOutput, type ListModelsStepConfig, ProviderID, newListModelsStep, newProjectConnection };
package/dist/index.js ADDED
@@ -0,0 +1,185 @@
1
+ import {
2
+ ConfigSchema,
3
+ Connection,
4
+ ConnectorID,
5
+ CredentialMaterialError,
6
+ ListModelsBranch,
7
+ ListModelsBranchDefect,
8
+ ListModelsBranchFound,
9
+ ListModelsBranchInvalidResponse,
10
+ ListModelsBranchProviderRejected,
11
+ ListModelsDefinition,
12
+ ListModelsInputSchema,
13
+ ListModelsMetadata,
14
+ ListModelsOutputSchema,
15
+ ProviderID,
16
+ decodeCredentials,
17
+ isCredentialMaterialError,
18
+ newConnection,
19
+ newConnectionWithOperations,
20
+ newProjectConnection
21
+ } from "./chunk-MADGN63K.js";
22
+
23
+ // src/generated/steps.ts
24
+ import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
25
+ function newListModelsStep(configuration) {
26
+ const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
27
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
28
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listModels(), connection: connection.reference, branches: [
29
+ goToBranch("found", found),
30
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
31
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
32
+ ...defect ? [goToBranch("defect", defect)] : []
33
+ ] });
34
+ }
35
+
36
+ // src/client.ts
37
+ import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
38
+ import { BodyTooLargeError, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
39
+ var modelsEndpoint = "https://flurouter.net/v1/models";
40
+ var FlurouterClient = class {
41
+ /** Validate local limits without contacting FluRouter. */
42
+ constructor(config, credentials, options = {}) {
43
+ this.credentials = credentials;
44
+ if (!config || !credentials) throw new TypeError("FluRouter configuration and credentials are required");
45
+ this.timeoutMs = config.timeoutMs || 1e4;
46
+ this.maxResponseBytes = config.maxResponseBytes || 1048576;
47
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || this.maxResponseBytes > 16 << 20) throw new TypeError("FluRouter request limits are invalid");
48
+ this.send = options.send ?? sendProviderRequest;
49
+ }
50
+ credentials;
51
+ timeoutMs;
52
+ maxResponseBytes;
53
+ send;
54
+ /** Bind the model-list Query. */
55
+ listModels() {
56
+ return new ListModelsOperation(this);
57
+ }
58
+ /** Send one bounded model-list request. */
59
+ async list(call) {
60
+ let apiKey = "";
61
+ try {
62
+ const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
63
+ apiKey = credentials.apiKey instanceof SecretString ? credentials.apiKey.reveal() : "";
64
+ } catch {
65
+ return { error: "credential", retryAfterMs: 0 };
66
+ }
67
+ if (!apiKey.startsWith("sk-il-") || apiKey.length > 1024 || /[^\x21-\x7e]/.test(apiKey)) return { error: "credential", retryAfterMs: 0 };
68
+ const request = { url: modelsEndpoint, method: "GET", headers: { Authorization: "Bearer " + apiKey, Accept: "application/json" }, timeoutMs: this.timeoutMs, maxResponseBytes: this.maxResponseBytes, addressPolicy: "publicHTTPS", signal: call.context.cancellationSignal };
69
+ let response;
70
+ try {
71
+ response = await this.send(request);
72
+ } catch (error) {
73
+ if (error instanceof BodyTooLargeError && error.status !== void 0) return { response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() }, error: "tooLarge", retryAfterMs: 0 };
74
+ return { error: "transport", retryAfterMs: 0 };
75
+ }
76
+ return { response, error: response.body.length > this.maxResponseBytes ? "tooLarge" : void 0, retryAfterMs: parseRetryAfter(header(response.headers, "retry-after")) };
77
+ }
78
+ };
79
+ var ListModelsOperation = class {
80
+ /** Bind the provider client. */
81
+ constructor(client) {
82
+ this.client = client;
83
+ }
84
+ client;
85
+ /** Return the generated Query definition. */
86
+ definition() {
87
+ return ListModelsDefinition;
88
+ }
89
+ /** Classify one model-list request using the Go connector contract. */
90
+ async invoke(call) {
91
+ const exchange = await this.client.list(call);
92
+ if (exchange.error === "credential") return branch("defect", "AUTHENTICATION");
93
+ if (exchange.error === "transport" || !exchange.response) return retry("AVAILABILITY");
94
+ const { status, body } = exchange.response;
95
+ if (status === 429) return retry("RATE_LIMIT", exchange.retryAfterMs);
96
+ if (status === 408 || status >= 500) return retry("AVAILABILITY", exchange.retryAfterMs);
97
+ if (status !== 200) return branch("providerRejected", status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION");
98
+ if (exchange.error === "tooLarge") return branch("invalidResponse", "RESPONSE_TOO_LARGE");
99
+ let wire;
100
+ try {
101
+ wire = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
102
+ } catch {
103
+ wire = void 0;
104
+ }
105
+ if (!isObject(wire) || wire.object !== "list" || !Array.isArray(wire.data) || wire.data.length > 1e3) return branch("invalidResponse", "PROTOCOL");
106
+ const modelIDs = [];
107
+ const seen = /* @__PURE__ */ new Set();
108
+ for (const model of wire.data) {
109
+ if (!isObject(model) || typeof model.id !== "string" || !model.id || model.id.length > 256 || /[^\x21-\x7e]/.test(model.id) || model.object !== "model" || seen.has(model.id)) return branch("invalidResponse", "PROTOCOL");
110
+ seen.add(model.id);
111
+ modelIDs.push(model.id);
112
+ }
113
+ return newQueryBranch("found", { modelIDs });
114
+ }
115
+ };
116
+ function isObject(value) {
117
+ return typeof value === "object" && value !== null && !Array.isArray(value);
118
+ }
119
+ function header(headers, name) {
120
+ const value = Object.entries(headers).find(([key]) => key.toLowerCase() === name)?.[1];
121
+ return Array.isArray(value) ? value[0] ?? "" : value ?? "";
122
+ }
123
+ function failure(kind) {
124
+ return { provider: "flurouter", operation: "listModels", kind, message: "FluRouter model query failed" };
125
+ }
126
+ function branch(name, kind) {
127
+ return newQueryBranch(name, { modelIDs: [] }, {}, failure(kind));
128
+ }
129
+ function retry(kind, delay = 0) {
130
+ return newQueryRetry(failure(kind), delay);
131
+ }
132
+
133
+ // src/project.ts
134
+ function newProjectConnection2(project, connectionName) {
135
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
136
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "flurouter" && entry.connectionName === name);
137
+ if (!selected) throw new TypeError("Flurouter project connection is not configured");
138
+ const fields = selected.configuration;
139
+ const config = ConfigSchema.parse({ ...fields, ...fields.timeout !== void 0 ? { timeoutMs: parseDurationMilliseconds(fields.timeout) } : {} });
140
+ const credentials = {
141
+ async resolve(_call, signal) {
142
+ return decodeCredentials(await loadedProject.resolveCredential("flurouter", name, signal));
143
+ }
144
+ };
145
+ return new FlurouterClient(config, credentials);
146
+ });
147
+ }
148
+ function parseDurationMilliseconds(value) {
149
+ if (typeof value === "number") return Math.ceil(value / 1e6);
150
+ if (typeof value !== "string") throw new TypeError("timeout must be a duration");
151
+ let remaining = value;
152
+ let milliseconds = 0;
153
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
154
+ while (remaining) {
155
+ const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
156
+ if (!part) throw new TypeError("timeout must be a positive Go duration");
157
+ milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
158
+ remaining = remaining.slice(part[0].length);
159
+ }
160
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("timeout must resolve to positive whole milliseconds");
161
+ return milliseconds;
162
+ }
163
+ export {
164
+ ConfigSchema,
165
+ Connection,
166
+ ConnectorID,
167
+ CredentialMaterialError,
168
+ FlurouterClient,
169
+ ListModelsBranch,
170
+ ListModelsBranchDefect,
171
+ ListModelsBranchFound,
172
+ ListModelsBranchInvalidResponse,
173
+ ListModelsBranchProviderRejected,
174
+ ListModelsDefinition,
175
+ ListModelsInputSchema,
176
+ ListModelsMetadata,
177
+ ListModelsOutputSchema,
178
+ ProviderID,
179
+ decodeCredentials,
180
+ isCredentialMaterialError,
181
+ newConnection,
182
+ newConnectionWithOperations,
183
+ newListModelsStep,
184
+ newProjectConnection2 as newProjectConnection
185
+ };
package/dist/mock.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
2
+ import { Failure } from '@superdurable/connectors-sdk';
3
+ import { O as Operations, C as Connection, L as ListModelsInput, a as ListModelsOutput } from './connection-CLcILwb-.js';
4
+ import 'zod';
5
+
6
+ /** Go zero value for ListModelsInput in scripted cases. */
7
+ declare const emptyListModelsInput: ListModelsInput;
8
+ /** Go zero value for ListModelsOutput in scripted cases. */
9
+ declare const emptyListModelsOutput: ListModelsOutput;
10
+ /** Script the found branch. */
11
+ declare function listModelsFound(value: ListModelsOutput, failure?: Failure): Case<ListModelsOutput>;
12
+ /** Script the providerRejected branch. */
13
+ declare function listModelsProviderRejected(value: ListModelsOutput, failure?: Failure): Case<ListModelsOutput>;
14
+ /** Script the invalidResponse branch. */
15
+ declare function listModelsInvalidResponse(value: ListModelsOutput, failure?: Failure): Case<ListModelsOutput>;
16
+ /** Script the defect branch. */
17
+ declare function listModelsDefect(value: ListModelsOutput, failure?: Failure): Case<ListModelsOutput>;
18
+ /** Script a safe retry of listModels. */
19
+ declare function listModelsRetry(failure: Failure, retryAfterMs?: number): Case<ListModelsOutput>;
20
+ /** Manifest scenario availableModels for listModels. */
21
+ declare function listModelsAvailableModels(): Case<ListModelsOutput>;
22
+ /** Default listModels scenario. */
23
+ declare function listModelsDefault(): Case<ListModelsOutput>;
24
+ /** Manifest scenario noModels for listModels. */
25
+ declare function listModelsNoModels(): Case<ListModelsOutput>;
26
+ /** Scripted operations and manifest defaults for this connector. */
27
+ declare class GeneratedMock implements Operations {
28
+ #private;
29
+ constructor(connectionName: string);
30
+ connection(): Connection;
31
+ listModels(): MockQuery<ListModelsInput, ListModelsOutput>;
32
+ assertNoFailures(): void;
33
+ }
34
+
35
+ export { GeneratedMock, emptyListModelsInput, emptyListModelsOutput, listModelsAvailableModels, listModelsDefault, listModelsDefect, listModelsFound, listModelsInvalidResponse, listModelsNoModels, listModelsProviderRejected, listModelsRetry };
package/dist/mock.js ADDED
@@ -0,0 +1,70 @@
1
+ import {
2
+ ListModelsDefinition,
3
+ ListModelsInputSchema,
4
+ ListModelsOutputSchema,
5
+ ProviderID,
6
+ newConnectionWithOperations
7
+ } from "./chunk-MADGN63K.js";
8
+
9
+ // src/generated/mock.ts
10
+ import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
11
+ var emptyListModelsInput = ListModelsInputSchema.parse({});
12
+ var emptyListModelsOutput = ListModelsOutputSchema.parse({
13
+ "modelIDs": []
14
+ });
15
+ function listModelsFound(value, failure) {
16
+ return branchCase("found", value, failure);
17
+ }
18
+ function listModelsProviderRejected(value, failure) {
19
+ return branchCase("providerRejected", value, failure);
20
+ }
21
+ function listModelsInvalidResponse(value, failure) {
22
+ return branchCase("invalidResponse", value, failure);
23
+ }
24
+ function listModelsDefect(value, failure) {
25
+ return branchCase("defect", value, failure);
26
+ }
27
+ function listModelsRetry(failure, retryAfterMs = 0) {
28
+ return retryCase(failure, retryAfterMs);
29
+ }
30
+ function listModelsAvailableModels() {
31
+ const value = ListModelsOutputSchema.parse({ "modelIDs": ["demo-chat", "demo-embedding"] });
32
+ return branchCase("found", value);
33
+ }
34
+ function listModelsDefault() {
35
+ return listModelsAvailableModels();
36
+ }
37
+ function listModelsNoModels() {
38
+ const value = ListModelsOutputSchema.parse({ "modelIDs": [] });
39
+ return branchCase("found", value);
40
+ }
41
+ var GeneratedMock = class {
42
+ #listModels;
43
+ #connection;
44
+ constructor(connectionName) {
45
+ this.#listModels = newQuery(ListModelsDefinition).default(listModelsDefault());
46
+ this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
47
+ }
48
+ connection() {
49
+ return this.#connection;
50
+ }
51
+ listModels() {
52
+ return this.#listModels;
53
+ }
54
+ assertNoFailures() {
55
+ this.#listModels.assertNoFailures();
56
+ }
57
+ };
58
+ export {
59
+ GeneratedMock,
60
+ emptyListModelsInput,
61
+ emptyListModelsOutput,
62
+ listModelsAvailableModels,
63
+ listModelsDefault,
64
+ listModelsDefect,
65
+ listModelsFound,
66
+ listModelsInvalidResponse,
67
+ listModelsNoModels,
68
+ listModelsProviderRejected,
69
+ listModelsRetry
70
+ };
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@superdurable/connector-flurouter",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "flurouter connector for Dex TypeScript applications",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/superdurable/dex-connectors-library.git",
9
+ "directory": "connectors/flurouter/typescript"
10
+ },
11
+ "type": "module",
12
+ "engines": {
13
+ "node": "^22.0.0 || ^24.0.0"
14
+ },
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./mock": {
23
+ "types": "./dist/mock.d.ts",
24
+ "import": "./dist/mock.js"
25
+ },
26
+ "./dex-connector.json": "./dex-connector.json"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "LICENSE",
32
+ "dex-connector.json"
33
+ ],
34
+ "scripts": {
35
+ "prepack": "npm run build",
36
+ "build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src test examples",
39
+ "test": "vitest run --exclude test/integration/**",
40
+ "test:integration": "vitest run test/integration/*.integration.test.ts",
41
+ "example:worker": "tsx examples/basic/worker.ts",
42
+ "example:start": "tsx examples/basic/start.ts",
43
+ "check": "npm run typecheck && npm run lint && npm test && npm run build"
44
+ },
45
+ "dependencies": {
46
+ "@superdurable/connectors-sdk": "0.1.1",
47
+ "@superdurable/dex": ">=1.28.0",
48
+ "zod": "^4.1.0"
49
+ },
50
+ "devDependencies": {
51
+ "@eslint/js": "^9.0.0",
52
+ "@types/node": "^22.0.0",
53
+ "eslint": "^9.0.0",
54
+ "tsup": "^8.0.0",
55
+ "tsx": "^4.23.15",
56
+ "typescript": "^5.9.0",
57
+ "typescript-eslint": "^8.0.0",
58
+ "vitest": "^3.0.0",
59
+ "yaml": "^2.9.1"
60
+ }
61
+ }