@x-otto/plugin-anthropic 0.1.0-alpha.3 → 0.1.0-alpha.5
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/package.json +3 -3
- package/plugin-dist/meta.json +1 -1
- package/plugin-dist/plugin.js +0 -104
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-otto/plugin-anthropic",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@x-otto/provider": "0.1.0-alpha.
|
|
7
|
-
"@x-otto/plugin": "0.1.0-alpha.
|
|
6
|
+
"@x-otto/provider": "0.1.0-alpha.8",
|
|
7
|
+
"@x-otto/plugin": "0.1.0-alpha.8"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"files": [
|
package/plugin-dist/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"apiVersion":1,"compilerVersion":"0.1.0-alpha.
|
|
1
|
+
{"apiVersion":1,"compilerVersion":"0.1.0-alpha.8","sourceHash":"197c6acf0cc89b41751b77de1d0adb3391bb47bb487c6a74ec5fb0b1af8bd48d"}
|
package/plugin-dist/plugin.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const __otto_plugin_import_meta_url = require("url").pathToFileURL(__filename).href;
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// extensions/plugin-anthropic/plugin.ts
|
|
22
|
-
var plugin_exports = {};
|
|
23
|
-
__export(plugin_exports, {
|
|
24
|
-
default: () => plugin_default
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(plugin_exports);
|
|
27
|
-
|
|
28
|
-
// otto-sdk-shim:otto-plugin-sdk
|
|
29
|
-
var definePlugin = (f) => f;
|
|
30
|
-
|
|
31
|
-
// extensions/plugin-anthropic/src/claude-code-spoof.ts
|
|
32
|
-
var import_node_crypto = require("node:crypto");
|
|
33
|
-
var CLAUDE_CODE_SYSTEM_PREFIX = "You are Claude Code, Anthropic's official CLI for Claude.";
|
|
34
|
-
var CLAUDE_CODE_BETA = "claude-code-20250219";
|
|
35
|
-
var CLAUDE_CODE_VERSION = process.env["OTTO_CLAUDE_CODE_VERSION"] || "2.0.1";
|
|
36
|
-
function mergeClaudeCodeBeta(beta) {
|
|
37
|
-
const parts = (beta ? beta.split(",") : []).map((s) => s.trim()).filter(Boolean);
|
|
38
|
-
if (!parts.includes(CLAUDE_CODE_BETA)) {
|
|
39
|
-
parts.push(CLAUDE_CODE_BETA);
|
|
40
|
-
}
|
|
41
|
-
return parts.join(",");
|
|
42
|
-
}
|
|
43
|
-
function claudeCodeOAuthHeaders(beta, sessionId) {
|
|
44
|
-
return {
|
|
45
|
-
"anthropic-beta": mergeClaudeCodeBeta(beta),
|
|
46
|
-
"x-app": "cli",
|
|
47
|
-
"User-Agent": `claude-cli/${CLAUDE_CODE_VERSION} (external, cli)`,
|
|
48
|
-
"X-Claude-Code-Session-Id": sessionId
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
var cachedDeviceId;
|
|
52
|
-
function deviceId() {
|
|
53
|
-
if (!cachedDeviceId) {
|
|
54
|
-
cachedDeviceId = process.env["OTTO_CLAUDE_CODE_DEVICE_ID"] || (0, import_node_crypto.randomUUID)();
|
|
55
|
-
}
|
|
56
|
-
return cachedDeviceId;
|
|
57
|
-
}
|
|
58
|
-
function claudeCodeMetadata(sessionId, accountUuid = "") {
|
|
59
|
-
return {
|
|
60
|
-
user_id: JSON.stringify({
|
|
61
|
-
device_id: deviceId(),
|
|
62
|
-
account_uuid: accountUuid,
|
|
63
|
-
session_id: sessionId
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function prependClaudeCodeIdentity(blocks) {
|
|
68
|
-
const prefix = { type: "text", text: CLAUDE_CODE_SYSTEM_PREFIX };
|
|
69
|
-
if (!blocks || blocks.length === 0) {
|
|
70
|
-
return [prefix];
|
|
71
|
-
}
|
|
72
|
-
if (blocks[0]?.text === CLAUDE_CODE_SYSTEM_PREFIX) {
|
|
73
|
-
return blocks;
|
|
74
|
-
}
|
|
75
|
-
return [prefix, ...blocks];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// extensions/plugin-anthropic/plugin.ts
|
|
79
|
-
function customizeRequest(input) {
|
|
80
|
-
if (input.auth.mode !== "oauth") return {};
|
|
81
|
-
return {
|
|
82
|
-
defaultHeaders: claudeCodeOAuthHeaders(input.auth.beta, input.sessionId),
|
|
83
|
-
transformSystemBlocks: (blocks) => prependClaudeCodeIdentity(blocks),
|
|
84
|
-
metadata: claudeCodeMetadata(input.sessionId)
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
var plugin_default = definePlugin((ctx) => ({
|
|
88
|
-
providerFactories: {
|
|
89
|
-
anthropic: () => {
|
|
90
|
-
const protocol = ctx.getWireProtocol("anthropic-messages");
|
|
91
|
-
if (!protocol) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
"wire protocol 'anthropic-messages' is not registered \u2014 is extensions/plugin-otto-wire-protocols installed and trusted? (RFC-148)"
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return protocol.create({
|
|
97
|
-
resolveAuth: () => ctx.resolveProviderAuth("anthropic").then((a) => a ?? void 0),
|
|
98
|
-
resolveBaseUrl: async () => "https://api.anthropic.com",
|
|
99
|
-
headers: { "anthropic-version": "2023-06-01" },
|
|
100
|
-
customizeRequest
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}));
|