@x-otto/plugin-otto-wire-protocols 0.1.0-alpha.14
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 +112 -0
- package/otto-plugin.json +8 -0
- package/package.json +30 -0
- package/plugin-dist/meta.json +1 -0
- package/plugin-dist/plugin.cjs +17924 -0
- package/plugin.ts +68 -0
- package/src/anthropic-messages.ts +967 -0
- package/src/anthropic-usage.ts +81 -0
- package/src/openai-completions.ts +175 -0
- package/src/openai-responses.ts +609 -0
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @x-otto/plugin-otto-wire-protocols
|
|
2
|
+
|
|
3
|
+
> Standard wire protocol implementations for the otto provider system.
|
|
4
|
+
|
|
5
|
+
Provides three standard wire protocol implementations that were physically migrated out of the framework core: `anthropic-messages`, `openai-responses`, and `openai-completions`. Any declarative or code-based provider plugin that declares one of these `wireApi` values uses this plugin at runtime.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
This is a **code-based protocol plugin**. It registers three `wireProtocols` factories via `definePlugin`:
|
|
10
|
+
|
|
11
|
+
- **`anthropic-messages`** — Wraps `createAnthropicProvider` for Claude API compatibility (Anthropic SDK format).
|
|
12
|
+
- **`openai-responses`** — Wraps `createOpenAIResponsesProvider` for the OpenAI Responses API format.
|
|
13
|
+
- **`openai-completions`** — Wraps `createOpenAICompletionsProvider` for the OpenAI Completions/Chat Completions API format.
|
|
14
|
+
|
|
15
|
+
Each factory accepts a `WireProtocolFactoryInput` with `resolveAuth`, `resolveBaseUrl`, headers, and customization callbacks. Provider plugins (like `plugin-anthropic`, `plugin-deepseek`) reference these protocols by name rather than embedding protocol logic.
|
|
16
|
+
|
|
17
|
+
This plugin is a **required peer dependency** of any provider plugin that uses the declarative `wireApi` or code-based `getWireProtocol` patterns.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
otto extension install wire-protocols
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
All three protocols report cache token support through `meta.reportsCacheTokens`.
|
|
26
|
+
|
|
27
|
+
## Standalone installation (non-CLI hosts, e.g. desktop apps)
|
|
28
|
+
|
|
29
|
+
This plugin is published standalone to npm so hosts that depend only on `@x-otto/coding`
|
|
30
|
+
(not the full `@x-otto/cli`, which pulls in ink/react/zustand/yoga-layout and other
|
|
31
|
+
terminal-UI dependencies) can install it directly:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @x-otto/plugin-otto-wire-protocols
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then pass its installed directory's **parent** directory to `AppOptions.pluginBundledDirs`
|
|
38
|
+
(the same mechanism `@x-otto/cli` uses for its own `dist/bundled-extensions/`):
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createApp } from '@x-otto/coding'
|
|
42
|
+
import { dirname, join } from 'node:path'
|
|
43
|
+
import { fileURLToPath } from 'node:url'
|
|
44
|
+
|
|
45
|
+
// import.meta.resolve gives the installed package's entry file; its grandparent
|
|
46
|
+
// directory (node_modules/@x-otto/) is what discoverPlugins expects as bundledDirs —
|
|
47
|
+
// it scans that directory's immediate children for otto-plugin.json manifests.
|
|
48
|
+
const pkgEntry = fileURLToPath(import.meta.resolve('@x-otto/plugin-otto-wire-protocols'))
|
|
49
|
+
const bundledDir = dirname(dirname(pkgEntry)) // .../node_modules/@x-otto
|
|
50
|
+
|
|
51
|
+
const app = createApp({
|
|
52
|
+
// ...other options
|
|
53
|
+
pluginBundledDirs: [bundledDir],
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Plugins discovered through `pluginBundledDirs` get `scope: 'bundled'`, which
|
|
58
|
+
auto-grants declared high-risk capabilities (this plugin declares `wire-protocol`) —
|
|
59
|
+
same trust semantics as the CLI's own bundled extensions (RFC-341 M9): the host
|
|
60
|
+
distributing the plugin is implicitly trusted by the user who installed the host.
|
|
61
|
+
|
|
62
|
+
### Known deployment gap: prebuilt artifact freshness check fails after a standalone publish
|
|
63
|
+
|
|
64
|
+
**Status as of the first standalone publish (2026-09, alpha.14): this is a known,
|
|
65
|
+
unfixed gap in the release pipeline — verified against a real `pnpm pack` tarball,
|
|
66
|
+
not a hypothetical.** A fresh `npm install @x-otto/plugin-otto-wire-protocols`
|
|
67
|
+
(no extra copy step) currently makes the *first* load recompile instead of using the
|
|
68
|
+
prebuilt `plugin-dist/plugin.cjs`, and that recompile fails unless `@anthropic-ai/sdk`
|
|
69
|
+
is also resolvable (it is a normal `dependencies` entry, so `npm install` does bring
|
|
70
|
+
it in as a sibling in `node_modules` — but bare/isolated environments without a full
|
|
71
|
+
`npm install`, e.g. hand-built sanity checks, will see `Could not resolve
|
|
72
|
+
"@anthropic-ai/sdk"`).
|
|
73
|
+
|
|
74
|
+
Root cause: the freshness check (`isArtifactMetaCurrent` in `@x-otto/coding`)
|
|
75
|
+
recomputes a source hash from whatever `.ts`/`.json` files currently exist in the
|
|
76
|
+
plugin directory. `plugin-dist/meta.json`'s stored hash is computed at `pnpm build`
|
|
77
|
+
time **against the monorepo source directory**, which includes `tests/` and
|
|
78
|
+
`tsconfig.json`. The published npm package (filtered by `package.json`'s `files`
|
|
79
|
+
field) does not include those — so the two hashes structurally can never match,
|
|
80
|
+
regardless of how carefully the tarball is built. This is not specific to a copy
|
|
81
|
+
step; it reproduces from a plain `pnpm pack` → extract → load with zero manual
|
|
82
|
+
copying.
|
|
83
|
+
|
|
84
|
+
If your `npm install` also resolves `@anthropic-ai/sdk` normally (the common case —
|
|
85
|
+
npm's own dependency resolution handles this), the one-time recompile succeeds
|
|
86
|
+
silently and you will not notice this gap; it only surfaces as a hard failure in
|
|
87
|
+
constrained/offline environments. Either way it costs an unnecessary recompile on
|
|
88
|
+
first load.
|
|
89
|
+
|
|
90
|
+
**Workaround** (until the release pipeline is fixed to rewrite `plugin-dist/meta.json`
|
|
91
|
+
against the exact `files`-filtered file set before publish, mirroring what
|
|
92
|
+
`bundle-builtin-extensions.mjs` already does for the CLI-bundled distribution path):
|
|
93
|
+
if you see `Could not resolve "@anthropic-ai/sdk"` on first load, run `npm install`
|
|
94
|
+
in the environment to ensure the dependency is actually present, or call
|
|
95
|
+
`rewriteArtifactSourceHash(installedDir)` (exported from `@x-otto/coding`) against
|
|
96
|
+
the installed package directory before first load:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { rewriteArtifactSourceHash } from '@x-otto/coding'
|
|
100
|
+
rewriteArtifactSourceHash('/path/to/node_modules/@x-otto/plugin-otto-wire-protocols')
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This is tracked as a release-pipeline follow-up, not a per-consumer workaround you
|
|
104
|
+
should need long-term.
|
|
105
|
+
|
|
106
|
+
## Dependencies
|
|
107
|
+
|
|
108
|
+
- `@x-otto/provider` (workspace)
|
|
109
|
+
- `@x-otto/interchange` (workspace)
|
|
110
|
+
- `@x-otto/shared` (workspace)
|
|
111
|
+
- `@anthropic-ai/sdk` (0.88.0)
|
|
112
|
+
- `@x-otto/plugin` (dev, build-time only)
|
package/otto-plugin.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "plugin-otto-wire-protocols",
|
|
3
|
+
"name": "Otto Wire Protocols",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Three standard wire protocol implementations (anthropic-messages/openai-responses/openai-completions) — physically migrated out of the framework core (RFC-148). Provides runtime support for any declarative or code-based provider plugin that declares one of these wireApi values.",
|
|
6
|
+
"capabilities": ["wire-protocol"],
|
|
7
|
+
"engines": { "otto": ">=1.0.0" }
|
|
8
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-otto/plugin-otto-wire-protocols",
|
|
3
|
+
"version": "0.1.0-alpha.14",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Three standard wire protocol implementations (anthropic-messages/openai-responses/openai-completions) — runtime support for provider plugins. Publishable standalone so non-CLI hosts (e.g. desktop apps depending only on @x-otto/coding) can install it without the full @x-otto/cli dependency tree.",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@anthropic-ai/sdk": "0.88.0",
|
|
8
|
+
"@x-otto/shared": "0.1.0-alpha.14",
|
|
9
|
+
"@x-otto/interchange": "0.1.0-alpha.14",
|
|
10
|
+
"@x-otto/provider": "0.1.0-alpha.14",
|
|
11
|
+
"@x-otto/plugin": "0.1.0-alpha.14"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"files": [
|
|
15
|
+
"otto-plugin.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"plugin.ts",
|
|
18
|
+
"src",
|
|
19
|
+
"plugin-dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org",
|
|
24
|
+
"tag": "alpha"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "vitest run"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"apiVersion":1,"compilerVersion":"0.1.0-alpha.14","sourceHash":"e93b544b123bd6f45757457f819cbda2d08a419f276e399561dadf654f9abeb1"}
|