@mccaskie-labs/workbench-ai 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mccaskie-labs/workbench-ai
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Breaking: there is no built-in Gateway address any more (hard rule 13, `docs/install-plan.md`). `DEFAULT_GATEWAY_URL` is removed from workbench-config, `createAi` needs `url`, and `createMailer`'s gateway transport needs `gateway.url`. Pass the app's `WORKBENCH_GATEWAY_URL`, which Control writes into `wrangler.jsonc` when it creates a project. A missing address fails at start-up with `invalid_config` and the message "WORKBENCH_GATEWAY_URL is missing". The gateway manifest marks `WORKBENCH_GATEWAY_URL` required with no default.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @mccaskie-labs/workbench-config@0.2.0
13
+
3
14
  ## 0.1.5
4
15
 
5
16
  ### Patch Changes
package/README.md CHANGED
@@ -10,14 +10,14 @@ npm install @mccaskie-labs/workbench-ai @mccaskie-labs/workbench-config zod
10
10
  import { createAi } from '@mccaskie-labs/workbench-ai'
11
11
  import { workbenchEnv } from '@mccaskie-labs/workbench-config'
12
12
 
13
- const ai = createAi({ key: env.WORKBENCH_GATEWAY_KEY, env: workbenchEnv(env) })
13
+ const ai = createAi({ key: env.WORKBENCH_GATEWAY_KEY, env: workbenchEnv(env), url: env.WORKBENCH_GATEWAY_URL })
14
14
  const r = await ai.text({ model: 'claude-default', job: 'article.write', prompt })
15
15
  await save({ text: r.text, model: r.model, requestId: r.requestId })
16
16
  ```
17
17
 
18
18
  | Export | What it does |
19
19
  | --- | --- |
20
- | `createAi({ key, env, url?, fetch? })` | The client. Throws `invalid_config` at once if the key isn't for `env` (`wbk_dev_`, `wbk_stg_`, `wbk_prd_`) |
20
+ | `createAi({ key, env, url, fetch? })` | The client. `url` is this install's Gateway address (`WORKBENCH_GATEWAY_URL`); there is no built-in one. Throws `invalid_config` at once if it is missing or the key isn't for `env` (`wbk_dev_`, `wbk_stg_`, `wbk_prd_`) |
21
21
  | `ai.text(req)` | One reply as text. Throws `refused` on a refusal and `truncated` on `max_tokens`; never returns partial text |
22
22
  | `ai.structured({ ...req, schema, mayLack? })` | JSON matching a zod schema, through structured outputs (`output_config.format`, not forced tool use). Asks once more for required fields left empty, except those in `mayLack`; throws `invalid_output` if they're still empty |
23
23
  | `ai.stream(req)` | Async iterable of Anthropic stream events, then `finalMessage()`, which throws like `text` |
package/dist/ai.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import Anthropic from "@anthropic-ai/sdk";
2
2
  import { zodOutputFormat } from "@anthropic-ai/sdk/helpers/zod";
3
- import { DEFAULT_GATEWAY_URL } from "@mccaskie-labs/workbench-config";
4
3
  import { createCapture, isGatewayMeta, REQUEST_ID_HEADER } from "./capture.js";
5
4
  import { errorFromGateway, WorkbenchAiError } from "./errors.js";
6
5
  import { gatewayFetch } from "./http.js";
@@ -34,7 +33,11 @@ export function createAi(opts) {
34
33
  if (!opts.key.startsWith(prefix)) {
35
34
  throw new WorkbenchAiError("invalid_config", `WORKBENCH_GATEWAY_KEY is not a ${env} key (expected the ${prefix} prefix)`);
36
35
  }
37
- const url = (opts.url ?? DEFAULT_GATEWAY_URL).replace(/\/+$/, "");
36
+ // No built-in address: each Workbench install has its own Gateway (hard rule 13).
37
+ if (typeof opts.url !== "string" || opts.url === "") {
38
+ throw new WorkbenchAiError("invalid_config", "WORKBENCH_GATEWAY_URL is missing");
39
+ }
40
+ const url = opts.url.replace(/\/+$/, "");
38
41
  const baseFetch = opts.fetch ?? ((input, init) => globalThis.fetch(input, init));
39
42
  const client = (f) => new Anthropic({
40
43
  apiKey: opts.key,
package/dist/types.d.ts CHANGED
@@ -10,8 +10,8 @@ export interface AiOptions {
10
10
  key: string;
11
11
  /** From `workbenchEnv(env)`. Must match the key's environment. */
12
12
  env: WorkbenchEnv;
13
- /** Gateway base URL; defaults to `DEFAULT_GATEWAY_URL`. Leave unset outside tests. */
14
- url?: string;
13
+ /** This install's Gateway address (`WORKBENCH_GATEWAY_URL`). There is no built-in one. */
14
+ url: string;
15
15
  fetch?: typeof fetch;
16
16
  }
17
17
  export interface TextRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-ai",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Claude through the Workbench Gateway: text, structured output, streaming and budget status, with no Anthropic key in the app. Refusals and truncations throw; createFakeAi for tests.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@anthropic-ai/sdk": "^1.5.0",
39
- "@mccaskie-labs/workbench-config": "^0.1.14"
39
+ "@mccaskie-labs/workbench-config": "^0.2.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "zod": "^4.1.0"