dsh-llm-codebuddy-power 1.0.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.
Files changed (44) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +66 -0
  3. package/README.zh.md +66 -0
  4. package/cordis.patch.yml +32 -0
  5. package/lib/cli-login.js +2099 -0
  6. package/lib/client.js +2814 -0
  7. package/lib/index.js +3957 -0
  8. package/lib/types/adapter.d.ts +58 -0
  9. package/lib/types/atomic-file.d.ts +43 -0
  10. package/lib/types/auth-service.d.ts +195 -0
  11. package/lib/types/cli/login.d.ts +23 -0
  12. package/lib/types/client/AccountSwitcher.d.ts +53 -0
  13. package/lib/types/client/CodeBuddySection.d.ts +62 -0
  14. package/lib/types/client/ComposerControls.d.ts +29 -0
  15. package/lib/types/client/DrawToolCard.d.ts +24 -0
  16. package/lib/types/client/ModelPanel.d.ts +77 -0
  17. package/lib/types/client/TurnCreditPill.d.ts +33 -0
  18. package/lib/types/client/UsageIndicator.d.ts +21 -0
  19. package/lib/types/client/icons.d.ts +24 -0
  20. package/lib/types/client/index.d.ts +34 -0
  21. package/lib/types/client/locales.d.ts +90 -0
  22. package/lib/types/client/poll.d.ts +19 -0
  23. package/lib/types/client/store.d.ts +59 -0
  24. package/lib/types/client/wire.d.ts +147 -0
  25. package/lib/types/codebuddy.d.ts +187 -0
  26. package/lib/types/constants.d.ts +67 -0
  27. package/lib/types/credit-store.d.ts +25 -0
  28. package/lib/types/image-tool.d.ts +34 -0
  29. package/lib/types/index.d.ts +79 -0
  30. package/lib/types/login.d.ts +43 -0
  31. package/lib/types/model-enrich.d.ts +125 -0
  32. package/lib/types/prefs.d.ts +43 -0
  33. package/lib/types/rpc-route.d.ts +25 -0
  34. package/lib/types/selection.d.ts +35 -0
  35. package/lib/types/serialize.d.ts +37 -0
  36. package/lib/types/session-store.d.ts +63 -0
  37. package/lib/types/session.d.ts +415 -0
  38. package/lib/types/settings.d.ts +18 -0
  39. package/lib/types/sse.d.ts +22 -0
  40. package/lib/types/storage.d.ts +118 -0
  41. package/lib/types/translate.d.ts +61 -0
  42. package/lib/types/types.d.ts +345 -0
  43. package/lib/types/usage.d.ts +109 -0
  44. package/package.json +119 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pgnqukezrdxmhjso
4
+ Copyright (c) 2026 Shatyuka
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # dsh-llm-codebuddy-power
2
+
3
+ ![AI-Crap](https://img.shields.io/badge/%F0%9F%92%A9-AI_crap_code-5C4033?style=flat-square) [![npm](https://img.shields.io/npm/v/dsh-llm-codebuddy-power)](https://www.npmjs.com/package/dsh-llm-codebuddy-power)
4
+
5
+ [中文](./README.zh.md)
6
+
7
+ dsh's CodeBuddy plugin — a complete set of CodeBuddy model capabilities.
8
+
9
+ Design document: [design/en/current.md](design/en/current.md).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ dsh plugin --profile web add dsh-llm-codebuddy-power
15
+ ```
16
+
17
+ **Installing through GitHub is not supported.**
18
+
19
+ ## Features
20
+
21
+ - Registers the `codebuddy` LLM provider route with models from CodeBuddy's model catalog
22
+ - Image input: image-capable models receive pasted or attached images
23
+ - Image generation tool `codebuddy-draw` callable from chat, billed against CodeBuddy credits; click a generated image to open a full-size preview (under PTC mode the tool is folded into the `run_code` SDK, so the model may not call it on its own; remind it that `codebuddy-draw` exists)
24
+ - Browser OAuth sign-in from the Web Settings → CodeBuddy page, no API key needed; several accounts can stay signed in, with each conversation choosing one
25
+ - Settings-page account badges: a badge shows only the account and can be dragged to reorder the list (the order is also the CLI's numbering and the fallback account when no default is set); the top action row carries "Choose default", and the default badge's own "Default" marker removes it
26
+ - Account control in the composer: a used-allowance ring (main and gifted allowances merged) plus an account button showing the current conversation's account
27
+ - CodeBuddy model panel beside the model selector: promotion and subscription badges, credit multiplier, per-model details on hover or tap, and context-window / max-output overrides
28
+ - Per-turn credit pill at the right end of the message tail action row (after other contributions), showing the credits spent that turn; hover it to see which accounts that turn was billed to
29
+ - Settings page preferences stored in the harness user settings document: show the allowance ring, the low-allowance alert percentage, and whether minimal-mode (agent preset `minimal`) sessions see the draw tool
30
+ - CLI account-management tool `codebuddy-power`
31
+
32
+ ## Usage examples
33
+
34
+ Web: open **Settings → CodeBuddy** and click **Sign in** to add an account; the copy button beside it puts the sign-in link on the clipboard instead of opening it, for completing sign-in in another browser or on another machine. Drag a badge to reorder the list, pick the default account with **Choose default** (the default badge's **Default** marker removes it), and sign an account out with **Multi-select**; the account button in the composer switches the current conversation's account.
35
+
36
+ CLI:
37
+
38
+ ```bash
39
+ dsh plugin --profile web codebuddy-power # sign in through the browser and append an account
40
+ ```
41
+
42
+ ### CLI arguments
43
+
44
+ | Argument | Description | Type | Required |
45
+ |---|---|---|---|
46
+ | `--status` | List every account by index with the default one marked, and show the model list | boolean | no |
47
+ | `--default <account>` | Make the given account the default (`<account>` is a uid, index, or nickname) | string | no |
48
+ | `--logout <account>` | Sign out the given account (`<account>` is a uid, index, or nickname) | string | no |
49
+ | `--logout --all` | Sign out every account | boolean | no |
50
+ | `--no-open` | Only print the sign-in link, do not open a browser | boolean | no |
51
+ | `--help` / `-h` | Print usage | boolean | no |
52
+
53
+ ## dsh version used for development
54
+
55
+ - dsh version used for development: `0.1.5-rc.2`. `@deepseek-ai/dsh-*` dependencies use `workspace:^`.
56
+
57
+ ## Secondary development
58
+
59
+ - The plugin must stay at a `packages/<group>/` path inside the dsh checkout: its `tsconfig*.json` files extend the dsh repository's `tsconfig.base*.json`, so moving it outside the checkout breaks the build.
60
+ - Local build: `pnpm --filter dsh-llm-codebuddy-power build` (`tsc -b` + `tsdown`, artifacts under `lib/`).
61
+
62
+ -----
63
+
64
+ ## Runtime invariant
65
+
66
+ No runtime invariant companion is published. Every registration this plugin makes — the `codebuddy` LLM adapter route (`ctx.llm.registerAdapter`), the `codebuddy-draw` tool, the `/codebuddy` RPC prefix route (`webServer.register`), and the `agent/created` / `agent-preset/selected` / `session/event` listeners — is effect-owned and leaves with the plugin fiber, and each owning registry (`dsh-llm`, `dsh-tools`, `dsh-host-webserver`, `dsh-agent`, `dsh-session`) asserts that relationship in its own companion. The plugin owns no cross-event durable relation and no second data source to compare: the per-turn credit record is a write-only projection into the plugin's own file, and the model panel and account control live in the browser process, beyond the host invariant service.
package/README.zh.md ADDED
@@ -0,0 +1,66 @@
1
+ # dsh-llm-codebuddy-power
2
+
3
+ ![AI-Crap](https://img.shields.io/badge/%F0%9F%92%A9-AI_crap_code-5C4033?style=flat-square) [![npm](https://img.shields.io/npm/v/dsh-llm-codebuddy-power)](https://www.npmjs.com/package/dsh-llm-codebuddy-power)
4
+
5
+ [English](./README.md)
6
+
7
+ dsh 的 CodeBuddy 插件——提供完整的 CodeBuddy 模型能力。
8
+
9
+ 设计文档:[design/zh/current.md](design/zh/current.md)。
10
+
11
+ ## 安装
12
+
13
+ ```bash
14
+ dsh plugin --profile web add dsh-llm-codebuddy-power
15
+ ```
16
+
17
+ **不支持通过 GitHub 安装。**
18
+
19
+ ## 功能
20
+
21
+ - 注册 `codebuddy` LLM 供应商路由,模型来自 CodeBuddy 模型目录
22
+ - 图片输入:支持图片的模型可接收粘贴/挂载的图片
23
+ - 聊天可调用的文生图工具 `codebuddy-draw`,按 CodeBuddy 积分计费;点击生成图片可查看大图(PTC 模式下工具被折叠进 `run_code` SDK,模型可能不会主动调用,需提醒它存在 `codebuddy-draw`)
24
+ - 浏览器 OAuth 登录(Web 设置 → CodeBuddy 页面),无需 API key;可同时登录多个账号,每个会话各选一个
25
+ - 设置页账号徽章:徽章只显示账号,可拖拽排序(该顺序同时是命令行的序号,以及没有默认账号时的兜底账号);默认账号由首行的「选择默认」选定,点徽章上的「默认」标记即可取消
26
+ - 对话框输入区的账号控件:额度圆环(主额度与赠送额度合并)+ 账号切换按钮,显示当前会话账号的昵称
27
+ - 模型选择器旁的 CodeBuddy 模型面板:促销与订阅徽章、积分倍率、悬停或点按详情,以及上下文窗口/最大输出覆写
28
+ - 消息尾部操作行最右端的每轮积分 pill(排在其他贡献之后),显示该轮消耗积分;悬停可见该轮花的是哪些账号
29
+ - 设置页偏好存于 harness 用户设置文档:是否显示额度圆环、余量告警百分比、极简模式(agent preset `minimal`)会话是否出现画图工具
30
+ - 命令行账号管理工具 `codebuddy-power`
31
+
32
+ ## 使用示例
33
+
34
+ Web:打开 **设置 → CodeBuddy**,点击 **登录** 可追加一个账号;旁边的复制按钮把登录链接放进剪贴板而不打开它,用于在别的浏览器或别的机器上完成登录。拖拽徽章可调整顺序,用 **选择默认** 指定默认账号(点徽章上的 **默认** 标记可取消),退出账号用 **多选**;对话框输入区的账号按钮可为当前会话单独切换。
35
+
36
+ CLI:
37
+
38
+ ```bash
39
+ dsh plugin --profile web codebuddy-power # 浏览器登录并追加一个账号
40
+ ```
41
+
42
+ ### CLI 参数
43
+
44
+ | 参数名 | 说明 | 类型 | 必填 |
45
+ |---|---|---|---|
46
+ | `--status` | 按序号列出全部账号与默认账号,并显示模型列表 | 布尔 | 否 |
47
+ | `--default <账号>` | 把指定账号设为默认账号(`<账号>` 为 uid、序号或昵称) | 字符串 | 否 |
48
+ | `--logout <账号>` | 退出指定账号(`<账号>` 为 uid、序号或昵称) | 字符串 | 否 |
49
+ | `--logout --all` | 退出全部账号 | 布尔 | 否 |
50
+ | `--no-open` | 仅打印登录链接,不打开浏览器 | 布尔 | 否 |
51
+ | `--help` / `-h` | 显示用法 | 布尔 | 否 |
52
+
53
+ ## 构建时使用的 dsh 版本
54
+
55
+ - 构建时使用的 dsh 版本:`0.1.5-rc.2`;`@deepseek-ai/dsh-*` 依赖使用 `workspace:^`。
56
+
57
+ ## 二次开发说明
58
+
59
+ - 插件必须位于 dsh 检出内的 `packages/<组>/` 路径下:插件的 `tsconfig*.json` 依赖 dsh 仓库的 `tsconfig.base*.json`,移出检出目录会无法构建。
60
+ - 本地构建:`pnpm --filter dsh-llm-codebuddy-power build`(`tsc -b` + `tsdown`,产物在 `lib/`)。
61
+
62
+ -----
63
+
64
+ ## 运行时 invariant
65
+
66
+ 不发布 `./invariant` companion。本插件的每一项注册——`codebuddy` LLM 适配器路由(`ctx.llm.registerAdapter`)、`codebuddy-draw` 工具、`/codebuddy` RPC 前缀路由(`webServer.register`),以及 `agent/created`、`agent-preset/selected`、`session/event` 监听——都由 effect 持有并随插件 fiber 释放,其归属关系分别由各自的宿主注册表(`dsh-llm`、`dsh-tools`、`dsh-host-webserver`、`dsh-agent`、`dsh-session`)在自己的 companion 中断言。本插件自身不持有跨事件的持久关系,也没有可供交叉比对的第二数据源:每轮积分记录是写入插件自有文件的单向投影,模型面板与账号控件位于浏览器进程内,宿主 invariant 服务无法观察。
@@ -0,0 +1,32 @@
1
+ # The dsh-llm-codebuddy-power bundle patch.
2
+ #
3
+ # Applied as ONE insert after the in-box bundle layers (dsh-base, and for the
4
+ # web profile dsh-web-app), so this row lands on top of them without touching
5
+ # any row they own. Registering a provider needs no change to the `llm` row —
6
+ # this plugin injects the `llm` service and calls
7
+ # `ctx.llm.registerAdapter()` when it activates.
8
+ #
9
+ # Activation is service-availability driven, not row-order driven: the entry
10
+ # below declares `inject: ['llm']` in code, so Cordis mounts it once the `llm`
11
+ # service from dsh-base is up, regardless of where this row sits.
12
+ #
13
+ # Config is omitted deliberately — every field of the plugin's Config is
14
+ # optional and the shipped defaults reach the public CodeBuddy service. There
15
+ # is no credential field by design; sign in through the Web Settings → CodeBuddy
16
+ # page or `dsh plugin --profile web codebuddy-power`.
17
+ #
18
+ # The `showUsage`, `dangerPct` and `drawToolInMinimal` fields are the base layer
19
+ # of the plugin's user-settings namespace: the Web Settings → CodeBuddy page
20
+ # writes the user layer over them.
21
+ #
22
+ # To pin a different endpoint, sizing, or preference default, override this row
23
+ # by id from your profile's own cordis.patch.yml, for example:
24
+ #
25
+ # - id: llm-codebuddy-power
26
+ # config:
27
+ # streamIdleTimeoutMs: 120000
28
+ # dangerPct: 80
29
+
30
+ - insert:
31
+ - id: llm-codebuddy-power
32
+ name: 'dsh-llm-codebuddy-power'