@superdurable/dex-agents-vercel-ai-cli 0.0.0 → 0.6.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,105 @@
1
+ # License
2
+
3
+ Copyright (c) 2026 Super Durable, Inc.
4
+
5
+ Portions of this software are licensed as follows:
6
+
7
+ - Legacy Materials remain under their original licenses as described in
8
+ `LEGACY_NOTICES.md`.
9
+ - Third-Party Materials remain under the licenses provided by their owners.
10
+ - The `docs/` and `examples/` directories are not licensed under the
11
+ Sustainable Use License and retain their existing licensing status.
12
+ - All other material owned or licensable by Super Durable, Inc. is available
13
+ under the Sustainable Use License below.
14
+
15
+ See `LEGACY_NOTICES.md` for the applicable legacy and third-party notices.
16
+
17
+ ## Sustainable Use License
18
+
19
+ Version 1.0
20
+
21
+ ### Acceptance
22
+
23
+ By using the software, you agree to all of the terms and conditions below.
24
+
25
+ ### Copyright License
26
+
27
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
28
+ non-sublicensable, non-transferable license to use, copy, distribute, make
29
+ available, and prepare derivative works of the software, in each case subject
30
+ to the limitations below.
31
+
32
+ ### Limitations
33
+
34
+ You may use or modify the software only for your own internal business purposes
35
+ or for non-commercial or personal use. You may distribute the software or
36
+ provide it to others only if you do so free of charge for non-commercial
37
+ purposes. You may not alter, remove, or obscure any licensing, copyright, or
38
+ other notices of the licensor in the software. Any use of the licensor's
39
+ trademarks is subject to applicable law.
40
+
41
+ ### Patents
42
+
43
+ The licensor grants you a license, under any patent claims the licensor can
44
+ license, or becomes able to license, to make, have made, use, sell, offer for
45
+ sale, import and have imported the software, in each case subject to the
46
+ limitations and conditions in this license. This license does not cover any
47
+ patent claims that you cause to be infringed by modifications or additions to
48
+ the software.
49
+
50
+ If you or your company make any written claim that the software infringes or
51
+ contributes to infringement of any patent, your patent license for the software
52
+ granted under these terms ends immediately. If your company makes such a claim,
53
+ your patent license ends immediately for work on behalf of your company.
54
+
55
+ ### Notices
56
+
57
+ You must ensure that anyone who gets a copy of any part of the software from
58
+ you also gets a copy of these terms. If you modify the software, you must
59
+ include in any modified copies of the software a prominent notice stating that
60
+ you have modified the software.
61
+
62
+ ### No Other Rights
63
+
64
+ These terms do not imply any licenses other than those expressly granted in
65
+ these terms.
66
+
67
+ ### Termination
68
+
69
+ If you use the software in violation of these terms, such use is not licensed,
70
+ and your license will automatically terminate. If the licensor provides you
71
+ with a notice of your violation, and you cease all violation of this license no
72
+ later than 30 days after you receive that notice, your license will be
73
+ reinstated retroactively. However, if you violate these terms after such
74
+ reinstatement, any additional violation of these terms will cause your license
75
+ to terminate automatically and permanently.
76
+
77
+ ### No Liability
78
+
79
+ As far as the law allows, the software comes as is, without any warranty or
80
+ condition, and the licensor will not be liable to you for any damages arising
81
+ out of these terms or the use or nature of the software, under any kind of
82
+ legal claim.
83
+
84
+ ### Definitions
85
+
86
+ The "licensor" is the entity offering these terms.
87
+
88
+ The "software" is the software the licensor makes available under these terms,
89
+ including any portion of it.
90
+
91
+ "You" refers to the individual or entity agreeing to these terms.
92
+
93
+ "Your company" is any legal entity, sole proprietorship, or other kind of
94
+ organization that you work for, plus all organizations that have control over,
95
+ are under the control of, or are under common control with that organization.
96
+ Control means ownership of substantially all the assets of an entity, or the
97
+ power to direct its management and policies by vote, contract, or otherwise.
98
+ Control can be direct or indirect.
99
+
100
+ "Your license" is the license granted to you for the software under these
101
+ terms.
102
+
103
+ "Use" means anything you do with the software requiring your license.
104
+
105
+ "Trademark" means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -1,6 +1,77 @@
1
1
  # @superdurable/dex-agents-vercel-ai-cli
2
2
 
3
- This version is a placeholder that reserves the package name. It contains no code.
4
- The first real release of this Dex agents package will replace it.
3
+ `@superdurable/dex-agents-vercel-ai-cli` provides the `dex-agents-vercel-ai`
4
+ command. It runs a [Vercel AI SDK](https://ai-sdk.dev) agent as a durable Dex
5
+ agent session and chats with it in your terminal. The shared CLI core,
6
+ [`@superdurable/dex-agents-cli-core`](../core/README.md), starts or reuses
7
+ `dexcli dev`, connects the connectors MCP server, offers the local tools, and
8
+ runs the Worker. This package only builds the agent with the
9
+ [Vercel AI SDK adapter](../../../typescript/vercel-ai/README.md).
5
10
 
6
- Source: https://github.com/superdurable/dex/tree/main/agents/cli/typescript/vercel-ai
11
+ ## Running it
12
+
13
+ The command needs Node.js 22 or 24 and a provider API key:
14
+
15
+ ```bash
16
+ export OPENAI_API_KEY=sk-...
17
+ npx -p @superdurable/dex-agents-vercel-ai-cli dex-agents-vercel-ai
18
+ ```
19
+
20
+ The first run asks the `init` questions and writes
21
+ `~/.dex/agents/vercel-ai.yaml`. Then type a message. Approve or reject tool
22
+ calls with `y` or `n`, and type `/exit` to leave. The session stays in Dex,
23
+ and the command prints the `--resume` line that continues it. See the
24
+ [CLI core README](../core/README.md) for every subcommand and option, and
25
+ [`agents/cli`](../../README.md) for the configuration file.
26
+
27
+ ## Models and keys
28
+
29
+ The model defaults to `openai/gpt-5.2`; set `model` in the file or pass
30
+ `--model` to change it. A model ID names its provider:
31
+
32
+ | Model ID | Provider package | Environment variables |
33
+ | --- | --- | --- |
34
+ | `openai/<model>`, such as `openai/gpt-5.2` | `@ai-sdk/openai`, Responses API | `OPENAI_API_KEY`, optional `OPENAI_BASE_URL` |
35
+ | `anthropic/<model>`, such as `anthropic/claude-sonnet-4-5` | `@ai-sdk/anthropic` | `ANTHROPIC_API_KEY`, optional `ANTHROPIC_BASE_URL` |
36
+
37
+ Any other model ID stops the command, or fails the turn when session settings
38
+ set it. The command never passes a model ID string to the AI SDK, so no model
39
+ call goes to the Vercel AI Gateway. It never prints or stores a key; the
40
+ provider package reads it from the environment on each model call.
41
+
42
+ ## Configuration and tools
43
+
44
+ The `vercel_ai` section has no options yet, and any key in it is a
45
+ configuration error.
46
+
47
+ The agent offers the connectors MCP server's tools and the CLI core's
48
+ [local tools](../core/README.md#local-tools), each call in its own tool Step
49
+ with the CLI core's approval rules. The adapter takes one model and fixed
50
+ instructions per Flow, so the command passes it a language model,
51
+ **TurnLanguageModel**, that serves each model call with the running turn's
52
+ model and adds the turn's instructions as the system message. Each turn
53
+ therefore uses the model and instructions its session settings resolve to.
54
+
55
+ ## Images
56
+
57
+ `/image <path>` attaches an image file to the next message. The command gives
58
+ the Vercel AI SDK adapter the media store of `media.store`, so the model sees the
59
+ image, and images that tools return go to the same store. See
60
+ [Images](../../README.md#images).
61
+
62
+ ## Development
63
+
64
+ `ci.sh` builds the core, the Vercel AI SDK adapter, and the CLI core, which this
65
+ package installs from the repository, then typechecks and runs the integration
66
+ tests against a private `dexcli dev`:
67
+
68
+ ```bash
69
+ cd agents/cli/typescript/vercel-ai
70
+ DEXCLI=/path/to/dexcli ./ci.sh
71
+ ```
72
+
73
+ `dex-server-zd` must sit next to `dexcli`. The tests run the command as a child
74
+ process with a private home and an explicit environment allow list. Its
75
+ `@ai-sdk/openai` model calls `test/fixtures/mock-responses-api.ts`, a scripted
76
+ Responses API on 127.0.0.1, through `OPENAI_BASE_URL`, and its connector tools
77
+ come from `test/fixtures/fake-connectors-mcp-server.ts`.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) 2026 Super Durable, Inc.
3
+ //
4
+ // Licensed under the Sustainable Use License 1.0.
5
+ // You may not use this file except in compliance with the License.
6
+ // See the LICENSE file in the repository root.
7
+ //
8
+ // SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
9
+ import { processAgentCliIo, runAgentCli } from "@superdurable/dex-agents-cli-core";
10
+ import { vercelAiHarness } from "./vercel-ai-harness.js";
11
+ // Exit explicitly: open connections can keep Node running after the chat ends.
12
+ process.exit(await runAgentCli(vercelAiHarness, processAgentCliIo()));
13
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":";AACA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,+EAA+E;AAC/E,OAAO,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,eAAe,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The `dex-agents-vercel-ai` command: a Vercel AI SDK agent in the terminal. It builds the agent session Flow with
3
+ * the Vercel AI SDK adapter and runs it with the shared Dex Agents CLI core.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ export { createProviderLanguageModel, supportedModelProviders } from "./provider-language-models.js";
8
+ export { TurnLanguageModel } from "./turn-language-model.js";
9
+ export { createVercelAiCliSessionFlow, defaultInstructions, defaultVercelAiModel, validateVercelAiSection, vercelAiCliFlowType, vercelAiHarness, } from "./vercel-ai-harness.js";
@@ -0,0 +1,17 @@
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
+ /**
9
+ * The `dex-agents-vercel-ai` command: a Vercel AI SDK agent in the terminal. It builds the agent session Flow with
10
+ * the Vercel AI SDK adapter and runs it with the shared Dex Agents CLI core.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { createProviderLanguageModel, supportedModelProviders } from "./provider-language-models.js";
15
+ export { TurnLanguageModel } from "./turn-language-model.js";
16
+ export { createVercelAiCliSessionFlow, defaultInstructions, defaultVercelAiModel, validateVercelAiSection, vercelAiCliFlowType, vercelAiHarness, } from "./vercel-ai-harness.js";
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D;;;;;GAKG;AAEH,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { LanguageModelV4 } from "@ai-sdk/provider";
2
+ /**
3
+ * The model providers the command supports, as the prefix of a `<provider>/<model>` model ID. Each provider
4
+ * package reads its standard environment variables: `OPENAI_API_KEY` and `OPENAI_BASE_URL`, or
5
+ * `ANTHROPIC_API_KEY` and `ANTHROPIC_BASE_URL`.
6
+ *
7
+ * @since 0.5.0
8
+ */
9
+ export declare const supportedModelProviders: readonly string[];
10
+ /**
11
+ * Returns the AI SDK language model of a `<provider>/<model>` model ID, such as `openai/gpt-5.2` or
12
+ * `anthropic/claude-sonnet-4-5`. OpenAI models use the Responses API.
13
+ *
14
+ * A model ID string is never passed to the AI SDK itself, which would send it to the Vercel AI Gateway.
15
+ *
16
+ * @param modelId - The model ID.
17
+ * @returns The model.
18
+ * @throws {Error} When the prefix is not one of {@link supportedModelProviders}. The message leaves the model ID
19
+ * out, because session settings may hold it.
20
+ * @since 0.5.0
21
+ */
22
+ export declare function createProviderLanguageModel(modelId: string): LanguageModelV4;
@@ -0,0 +1,44 @@
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 { anthropic } from "@ai-sdk/anthropic";
9
+ import { openai } from "@ai-sdk/openai";
10
+ /**
11
+ * The model providers the command supports, as the prefix of a `<provider>/<model>` model ID. Each provider
12
+ * package reads its standard environment variables: `OPENAI_API_KEY` and `OPENAI_BASE_URL`, or
13
+ * `ANTHROPIC_API_KEY` and `ANTHROPIC_BASE_URL`.
14
+ *
15
+ * @since 0.5.0
16
+ */
17
+ export const supportedModelProviders = Object.freeze(["openai", "anthropic"]);
18
+ /**
19
+ * Returns the AI SDK language model of a `<provider>/<model>` model ID, such as `openai/gpt-5.2` or
20
+ * `anthropic/claude-sonnet-4-5`. OpenAI models use the Responses API.
21
+ *
22
+ * A model ID string is never passed to the AI SDK itself, which would send it to the Vercel AI Gateway.
23
+ *
24
+ * @param modelId - The model ID.
25
+ * @returns The model.
26
+ * @throws {Error} When the prefix is not one of {@link supportedModelProviders}. The message leaves the model ID
27
+ * out, because session settings may hold it.
28
+ * @since 0.5.0
29
+ */
30
+ export function createProviderLanguageModel(modelId) {
31
+ const separator = modelId.indexOf("/");
32
+ const provider = separator < 0 ? "" : modelId.slice(0, separator);
33
+ const providerModelId = modelId.slice(separator + 1);
34
+ if (providerModelId !== "") {
35
+ if (provider === "openai") {
36
+ return openai(providerModelId);
37
+ }
38
+ if (provider === "anthropic") {
39
+ return anthropic(providerModelId);
40
+ }
41
+ }
42
+ throw new Error("the model must be openai/<model> or anthropic/<model>");
43
+ }
44
+ //# sourceMappingURL=provider-language-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-language-models.js","sourceRoot":"","sources":["../../src/provider-language-models.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAEjG;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAe;IACzD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACrD,IAAI,eAAe,KAAK,EAAE,EAAE,CAAC;QAC3B,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC,eAAe,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC,eAAe,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from "@ai-sdk/provider";
2
+ import type { ResolvedTurn } from "@superdurable/dex-agents-cli-core";
3
+ /**
4
+ * An AI SDK language model that serves each call with the model and instructions of the turn whose model call is
5
+ * running.
6
+ *
7
+ * The Vercel AI SDK adapter takes one model and fixed instructions for the whole Flow, while a CLI session may
8
+ * change both per turn through its session settings. This model reads the running turn on every call, delegates
9
+ * to that turn's model, and adds the turn's instructions as the system message when the prompt has none.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const model = new TurnLanguageModel(() => context.currentTurn(), createProviderLanguageModel, "Help the user.");
14
+ * const flow = createVercelAiAgentSessionFlow({ model, toolSources: context.toolSources }, context.flowType);
15
+ * ```
16
+ * @since 0.5.0
17
+ */
18
+ export declare class TurnLanguageModel implements LanguageModelV4 {
19
+ private readonly currentTurn;
20
+ private readonly createModel;
21
+ private readonly defaultInstructions;
22
+ /** The AI SDK specification version. */
23
+ readonly specificationVersion = "v4";
24
+ private readonly models;
25
+ /**
26
+ * Creates the model.
27
+ *
28
+ * @param currentTurn - Returns the running turn's configuration, such as `HarnessContext.currentTurn`.
29
+ * @param createModel - Returns the language model of a model ID; its result is cached per ID.
30
+ * @param defaultInstructions - The instructions of a turn that sets none.
31
+ */
32
+ constructor(currentTurn: () => ResolvedTurn, createModel: (modelId: string) => LanguageModelV4, defaultInstructions: string);
33
+ /** The running turn's model provider. */
34
+ get provider(): string;
35
+ /** The running turn's provider model ID. */
36
+ get modelId(): string;
37
+ /** The URLs the running turn's model accepts. */
38
+ get supportedUrls(): LanguageModelV4["supportedUrls"];
39
+ /**
40
+ * Generates with the running turn's model.
41
+ *
42
+ * @param options - The call options.
43
+ * @returns The model's result.
44
+ */
45
+ doGenerate(options: LanguageModelV4CallOptions): PromiseLike<LanguageModelV4GenerateResult>;
46
+ /**
47
+ * Streams with the running turn's model.
48
+ *
49
+ * @param options - The call options.
50
+ * @returns The model's stream.
51
+ */
52
+ doStream(options: LanguageModelV4CallOptions): PromiseLike<LanguageModelV4StreamResult>;
53
+ private turnModel;
54
+ private withInstructions;
55
+ }
@@ -0,0 +1,89 @@
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
+ /**
9
+ * An AI SDK language model that serves each call with the model and instructions of the turn whose model call is
10
+ * running.
11
+ *
12
+ * The Vercel AI SDK adapter takes one model and fixed instructions for the whole Flow, while a CLI session may
13
+ * change both per turn through its session settings. This model reads the running turn on every call, delegates
14
+ * to that turn's model, and adds the turn's instructions as the system message when the prompt has none.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const model = new TurnLanguageModel(() => context.currentTurn(), createProviderLanguageModel, "Help the user.");
19
+ * const flow = createVercelAiAgentSessionFlow({ model, toolSources: context.toolSources }, context.flowType);
20
+ * ```
21
+ * @since 0.5.0
22
+ */
23
+ export class TurnLanguageModel {
24
+ currentTurn;
25
+ createModel;
26
+ defaultInstructions;
27
+ /** The AI SDK specification version. */
28
+ specificationVersion = "v4";
29
+ models = new Map();
30
+ /**
31
+ * Creates the model.
32
+ *
33
+ * @param currentTurn - Returns the running turn's configuration, such as `HarnessContext.currentTurn`.
34
+ * @param createModel - Returns the language model of a model ID; its result is cached per ID.
35
+ * @param defaultInstructions - The instructions of a turn that sets none.
36
+ */
37
+ constructor(currentTurn, createModel, defaultInstructions) {
38
+ this.currentTurn = currentTurn;
39
+ this.createModel = createModel;
40
+ this.defaultInstructions = defaultInstructions;
41
+ }
42
+ /** The running turn's model provider. */
43
+ get provider() {
44
+ return this.turnModel().provider;
45
+ }
46
+ /** The running turn's provider model ID. */
47
+ get modelId() {
48
+ return this.turnModel().modelId;
49
+ }
50
+ /** The URLs the running turn's model accepts. */
51
+ get supportedUrls() {
52
+ return this.turnModel().supportedUrls;
53
+ }
54
+ /**
55
+ * Generates with the running turn's model.
56
+ *
57
+ * @param options - The call options.
58
+ * @returns The model's result.
59
+ */
60
+ doGenerate(options) {
61
+ return this.turnModel().doGenerate(this.withInstructions(options));
62
+ }
63
+ /**
64
+ * Streams with the running turn's model.
65
+ *
66
+ * @param options - The call options.
67
+ * @returns The model's stream.
68
+ */
69
+ doStream(options) {
70
+ return this.turnModel().doStream(this.withInstructions(options));
71
+ }
72
+ turnModel() {
73
+ const modelId = this.currentTurn().model;
74
+ let model = this.models.get(modelId);
75
+ if (model === undefined) {
76
+ model = this.createModel(modelId);
77
+ this.models.set(modelId, model);
78
+ }
79
+ return model;
80
+ }
81
+ withInstructions(options) {
82
+ if (options.prompt.some((message) => message.role === "system")) {
83
+ return options;
84
+ }
85
+ const instructions = this.currentTurn().instructions ?? this.defaultInstructions;
86
+ return { ...options, prompt: [{ role: "system", content: instructions }, ...options.prompt] };
87
+ }
88
+ }
89
+ //# sourceMappingURL=turn-language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-language-model.js","sourceRoot":"","sources":["../../src/turn-language-model.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAU1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,iBAAiB;IAaT;IACA;IACA;IAdnB,wCAAwC;IACxB,oBAAoB,GAAG,IAAI,CAAC;IAC3B,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAE7D;;;;;;OAMG;IACH,YACmB,WAA+B,EAC/B,WAAiD,EACjD,mBAA2B;QAF3B,gBAAW,GAAX,WAAW,CAAoB;QAC/B,gBAAW,GAAX,WAAW,CAAsC;QACjD,wBAAmB,GAAnB,mBAAmB,CAAQ;IAC3C,CAAC;IAEJ,yCAAyC;IACzC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,4CAA4C;IAC5C,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,iDAAiD;IACjD,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,OAAmC;QACnD,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,OAAmC;QACjD,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAEO,SAAS;QACf,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;QACzC,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,gBAAgB,CAAC,OAAmC;QAC1D,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;YAChE,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,YAAY,IAAI,IAAI,CAAC,mBAAmB,CAAC;QACjF,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IAChG,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ import { type AgentHarness, type HarnessContext } from "@superdurable/dex-agents-cli-core";
2
+ import { createVercelAiAgentSessionFlow } from "@superdurable/dex-agents-vercel-ai";
3
+ /**
4
+ * The base Flow type of the command's sessions, before the CLI core namespaces it.
5
+ *
6
+ * @since 0.5.0
7
+ */
8
+ export declare const vercelAiCliFlowType = "DexAgentsVercelAiCliSession";
9
+ /**
10
+ * The model the command uses when the configuration file sets none.
11
+ *
12
+ * @since 0.5.0
13
+ */
14
+ export declare const defaultVercelAiModel = "openai/gpt-5.2";
15
+ /**
16
+ * The instructions the agent gets when the configuration sets none.
17
+ *
18
+ * @since 0.5.0
19
+ */
20
+ export declare const defaultInstructions: string;
21
+ /**
22
+ * The `dex-agents-vercel-ai` command: a Vercel AI SDK agent in the terminal.
23
+ *
24
+ * The agent offers the CLI core's connector and local tools. The model ID is `openai/<model>` or
25
+ * `anthropic/<model>`; each turn uses the model and instructions its session settings resolve to. The
26
+ * `vercel_ai` section has no options yet; any key in it is a configuration error.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { processAgentCliIo, runAgentCli } from "@superdurable/dex-agents-cli-core";
31
+ * import { vercelAiHarness } from "@superdurable/dex-agents-vercel-ai-cli";
32
+ *
33
+ * process.exit(await runAgentCli(vercelAiHarness, processAgentCliIo()));
34
+ * ```
35
+ * @since 0.5.0
36
+ */
37
+ export declare const vercelAiHarness: AgentHarness;
38
+ /**
39
+ * Builds the Vercel AI SDK agent session Flow from the effective configuration.
40
+ *
41
+ * @param context - The configuration, workspace, and tool sources.
42
+ * @returns The Flow, with `context.flowType` as its type.
43
+ * @throws {ConfigError} When the `vercel_ai` section has a key.
44
+ * @throws {Error} When the file's model is not `openai/<model>` or `anthropic/<model>`.
45
+ * @since 0.5.0
46
+ */
47
+ export declare function createVercelAiCliSessionFlow(context: HarnessContext): ReturnType<typeof createVercelAiAgentSessionFlow>;
48
+ /**
49
+ * Rejects every key of the `vercel_ai` section, which has no options yet.
50
+ *
51
+ * @param options - The section, `{}` when the file omits it.
52
+ * @throws {ConfigError} A `schema` error with the first key's JSON Pointer.
53
+ * @since 0.5.0
54
+ */
55
+ export declare function validateVercelAiSection(options: Readonly<Record<string, unknown>>): void;
@@ -0,0 +1,87 @@
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 { ConfigError } from "@superdurable/dex-agents-cli-core";
9
+ import { createVercelAiAgentSessionFlow } from "@superdurable/dex-agents-vercel-ai";
10
+ import { createProviderLanguageModel } from "./provider-language-models.js";
11
+ import { TurnLanguageModel } from "./turn-language-model.js";
12
+ /**
13
+ * The base Flow type of the command's sessions, before the CLI core namespaces it.
14
+ *
15
+ * @since 0.5.0
16
+ */
17
+ export const vercelAiCliFlowType = "DexAgentsVercelAiCliSession";
18
+ /**
19
+ * The model the command uses when the configuration file sets none.
20
+ *
21
+ * @since 0.5.0
22
+ */
23
+ export const defaultVercelAiModel = "openai/gpt-5.2";
24
+ /**
25
+ * The instructions the agent gets when the configuration sets none.
26
+ *
27
+ * @since 0.5.0
28
+ */
29
+ export const defaultInstructions = "You are a helpful assistant. Use your tools to work with the files and commands in your workspace and with " +
30
+ "the connected services.";
31
+ /**
32
+ * The `dex-agents-vercel-ai` command: a Vercel AI SDK agent in the terminal.
33
+ *
34
+ * The agent offers the CLI core's connector and local tools. The model ID is `openai/<model>` or
35
+ * `anthropic/<model>`; each turn uses the model and instructions its session settings resolve to. The
36
+ * `vercel_ai` section has no options yet; any key in it is a configuration error.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { processAgentCliIo, runAgentCli } from "@superdurable/dex-agents-cli-core";
41
+ * import { vercelAiHarness } from "@superdurable/dex-agents-vercel-ai-cli";
42
+ *
43
+ * process.exit(await runAgentCli(vercelAiHarness, processAgentCliIo()));
44
+ * ```
45
+ * @since 0.5.0
46
+ */
47
+ export const vercelAiHarness = {
48
+ name: "vercel-ai",
49
+ configSection: "vercel_ai",
50
+ flowType: vercelAiCliFlowType,
51
+ defaultModel: defaultVercelAiModel,
52
+ createSessionFlow: (context) => createVercelAiCliSessionFlow(context),
53
+ };
54
+ /**
55
+ * Builds the Vercel AI SDK agent session Flow from the effective configuration.
56
+ *
57
+ * @param context - The configuration, workspace, and tool sources.
58
+ * @returns The Flow, with `context.flowType` as its type.
59
+ * @throws {ConfigError} When the `vercel_ai` section has a key.
60
+ * @throws {Error} When the file's model is not `openai/<model>` or `anthropic/<model>`.
61
+ * @since 0.5.0
62
+ */
63
+ export function createVercelAiCliSessionFlow(context) {
64
+ validateVercelAiSection(context.harnessOptions);
65
+ // Fail at startup, not at the first turn, when the file's model has no supported provider.
66
+ createProviderLanguageModel(context.config.model);
67
+ const model = new TurnLanguageModel(() => context.currentTurn(), createProviderLanguageModel, defaultInstructions);
68
+ return createVercelAiAgentSessionFlow({ model, toolSources: context.toolSources }, context.flowType, {
69
+ ...(context.mediaStore === undefined ? {} : { mediaStore: context.mediaStore }),
70
+ summaryAttributesIndexed: context.isSessionSummaryIndexed === true,
71
+ });
72
+ }
73
+ /**
74
+ * Rejects every key of the `vercel_ai` section, which has no options yet.
75
+ *
76
+ * @param options - The section, `{}` when the file omits it.
77
+ * @throws {ConfigError} A `schema` error with the first key's JSON Pointer.
78
+ * @since 0.5.0
79
+ */
80
+ export function validateVercelAiSection(options) {
81
+ const [firstKey] = Object.keys(options).sort();
82
+ if (firstKey !== undefined) {
83
+ const escaped = firstKey.replaceAll("~", "~0").replaceAll("/", "~1");
84
+ throw new ConfigError("schema", `/vercel_ai/${escaped}`, "additionalProperties");
85
+ }
86
+ }
87
+ //# sourceMappingURL=vercel-ai-harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-ai-harness.js","sourceRoot":"","sources":["../../src/vercel-ai-harness.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EAAE,WAAW,EAA0C,MAAM,mCAAmC,CAAC;AACxG,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AAEpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,6GAA6G;IAC7G,yBAAyB,CAAC;AAE5B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,IAAI,EAAE,WAAW;IACjB,aAAa,EAAE,WAAW;IAC1B,QAAQ,EAAE,mBAAmB;IAC7B,YAAY,EAAE,oBAAoB;IAClC,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC;CACtE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAuB;IAClE,uBAAuB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAChD,2FAA2F;IAC3F,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,2BAA2B,EAAE,mBAAmB,CAAC,CAAC;IACnH,OAAO,8BAA8B,CACnC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,EAC3C,OAAO,CAAC,QAAQ,EAChB;QACE,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;QAC/E,wBAAwB,EAAE,OAAO,CAAC,uBAAuB,KAAK,IAAI;KACnE,CACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA0C;IAChF,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrE,MAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,cAAc,OAAO,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACnF,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@superdurable/dex-agents-vercel-ai-cli",
3
- "version": "0.0.0",
4
- "description": "Placeholder that reserves the name for a Dex agents package. It contains no code; the first real release follows.",
3
+ "version": "0.6.0",
4
+ "description": "The dex-agents-vercel-ai command: a durable Vercel AI SDK agent in your terminal",
5
5
  "license": "LicenseRef-Sustainable-Use-1.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,10 +9,57 @@
9
9
  "directory": "agents/cli/typescript/vercel-ai"
10
10
  },
11
11
  "homepage": "https://github.com/superdurable/dex/tree/main/agents/cli/typescript/vercel-ai#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/superdurable/dex/issues"
14
+ },
15
+ "type": "module",
16
+ "types": "./dist/src/index.d.ts",
17
+ "engines": {
18
+ "node": "^22.0.0 || ^24.0.0 || ^26.0.0"
19
+ },
20
+ "bin": {
21
+ "dex-agents-vercel-ai": "dist/src/bin.js"
22
+ },
12
23
  "files": [
13
- "README.md"
24
+ "dist/src",
25
+ "README.md",
26
+ "LICENSE"
14
27
  ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/src/index.d.ts",
31
+ "import": "./dist/src/index.js"
32
+ }
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "typecheck": "tsc -p tsconfig.json --noEmit",
37
+ "test": "npm run build && node --test --test-concurrency=1 --test-timeout=300000 'dist/test/integ/*.integration.test.js'"
38
+ },
39
+ "dependencies": {
40
+ "@ai-sdk/anthropic": "4.0.94",
41
+ "@ai-sdk/openai": "4.0.106",
42
+ "@ai-sdk/provider": "4.0.35",
43
+ "ai": "7.0.159"
44
+ },
45
+ "peerDependencies": {
46
+ "@superdurable/dex": "1.45.0",
47
+ "@superdurable/dex-agents": "^0.6.0",
48
+ "@superdurable/dex-agents-cli-core": "^0.6.0",
49
+ "@superdurable/dex-agents-vercel-ai": "^0.6.0"
50
+ },
51
+ "devDependencies": {
52
+ "@modelcontextprotocol/sdk": "1.32.2",
53
+ "@superdurable/dex": "1.45.0",
54
+ "@superdurable/dex-agents": "file:../../../typescript/core",
55
+ "@superdurable/dex-agents-cli-core": "file:../core",
56
+ "@superdurable/dex-agents-vercel-ai": "file:../../../typescript/vercel-ai",
57
+ "@types/node": "22.20.5",
58
+ "typescript": "5.9.3",
59
+ "zod": "4.6.7"
60
+ },
15
61
  "publishConfig": {
16
- "access": "public"
62
+ "access": "public",
63
+ "provenance": true
17
64
  }
18
- }
65
+ }