Skip to content

feat(aiscript): Mk:api の失敗を、本家と同じ error 値 (request_failed) で返す (#1249) - #1367

Merged
hitalin merged 3 commits into
developfrom
feat/mk-api-error-value
Nov 10, 2026
Merged

hitalin merged 3 commits into
developfrom
feat/mk-api-error-value

Conversation

@hitalin

@hitalin hitalin commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

#1366 の上に積んでいる。先に #1366 を入れてから見てほしい (この PR 固有の差分は feat(aiscript): … のコミット 1 つ)。

何を

Mk:api の失敗の返し方を Misskey 本体に揃える (#1249 で決めた方針)。

  • サーバーのエラー応答・レート制限・通信断は throw をやめ、values.ERROR('request_failed', { code, message }) を返す
    • code は Misskey のエラーコード (NO_SUCH_NOTE など) があればそれ、無いとき (通信断など) は NoteDeck の種別 (NETWORK など)。本家向けに書いた res.info.code の判定がそのまま動く
    • 生のエラー応答は載せない
  • 止めるまま: 権限 gate の拒否、アカウントが無い、要求の形の誤り、内部の失敗
  • Nd:call は変えない (止まる。キャンセルだけ error 値)

止まらなくなる分の手当て

  • error 値で返した失敗も、実行ログに 1 行残す (io.onNotice。プラグイン / ウィジェット / ウィジェット編集 / AiScript カラム / Play・スクラッチパッドの全実行面)
  • プラグインが登録した capability の handler が error 値をそのまま戻したら、値の変換で理由が潰れる (Unrecognized value type: error) 前に、理由つきの失敗として呼び出し元 (AI など) に返す
  • ドキュメント (4 言語): 書込のあとは必ず Core:type(res) == "error" を確かめる。サーバーごとの差を自分の画面で扱うなら Nd:call ではなく Mk:api を使う

なぜ

AiScript に try/catch は無く、止まると作者は失敗を自分の UI で扱えない。ストアの配布物には本家向けの「error 値なら失敗」の分岐が既に多数あり、NoteDeck では通らない。互換性を約束する 2.0.0 の前に揃える (約束の後に変えると、結果を見ないコードが「失敗しても成功と表示する」ものに変わる)。

残る危険 (承知のうえ)

  • 結果を見ないコードは、失敗しても先へ進む (本家と同じ)。プラグインが登録した capability の中で書込の結果を捨てて正常終了すると、AI には成功として返る。ホスト側では検出できないので、実行ログとドキュメントで受ける
  • ストアの配布物に、結果を見ずに成功を表示するウィジェットが 1 つある。この PR を出荷する前にストア側を直す (error 値の判定は今入れても無害)

確認

  • 追加したテスト: Mk:api の種別ごとの返し方と実行ログ、失敗の種別の判定 (remoteFailure)、登録 handler が error 値を戻したとき、本物の interpreter で本家の定型 (Core:type(res) == "error" と res.info.code) が動くこと
  • pnpm test (全件) / pnpm typecheck / pnpm lint / pnpm lint:docs は通過
  • 実機では未確認: 本家向けのプラグインで、失敗時に自前の表示が出ること

🤖 Generated with Claude Code

hitalin and others added 2 commits November 11, 2026 03:23
サーバーのエラー応答・レート制限・通信断は throw をやめ、values.ERROR('request_failed',
{ code, message }) を返す。code は Misskey のエラーコードがあればそれ、無ければ NoteDeck の
種別。AiScript に try/catch は無く、止めると作者は失敗を自分の UI で扱えない。本家向けに
書かれた「error 値なら失敗」の分岐もそのまま動く。

呼べなかったもの (権限 gate の拒否 / アカウントが無い / 要求の形の誤り / 内部の失敗) は
止めるまま。Nd:call は変えない。

止まらなくなる分の手当て:
- error 値で返した失敗も実行ログに 1 行残す (io.onNotice、全実行面)
- プラグインが登録した capability の handler が error 値をそのまま戻したら、値の変換で
  理由が潰れる前に、理由つきの失敗として呼び出し元 (AI など) に返す
- ドキュメント (4 言語): 書込のあとは必ず結果を確かめる。サーバーごとの差を自分の画面で
  扱うなら Mk:api を使う

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 356f745 and def479c.

Files selected for processing: 18

  • site/docs/dev/plugin.md
  • site/en/docs/dev/plugin.md
  • site/ko/docs/dev/plugin.md
  • site/zh/docs/dev/plugin.md
  • src/aiscript/api.test.ts
  • src/aiscript/api.ts
  • src/aiscript/common.ts
  • src/aiscript/notedeck-api.test.ts
  • src/aiscript/notedeck-api.ts
  • src/aiscript/plugin-api.ts
  • src/aiscript/sandbox.test.ts
  • src/aiscript/sandbox.ts
  • src/components/deck/DeckAiScriptColumn.vue
  • src/components/deck/widgets/WidgetAiScript.vue
  • src/components/window/WidgetEditContent.vue
  • src/composables/useAiScriptRunner.ts
  • src/services/capabilityFailure.test.ts
  • src/services/capabilityFailure.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added 📖Doc Documentation related issue/PR javascript Pull requests that update javascript code labels Nov 10, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Deploying notedeck with  Cloudflare Pages  Cloudflare Pages

Latest commit: def479c
Status: ✅  Deploy successful!
Preview URL: https://cf466885.notedeck-d3a.pages.dev
Branch Preview URL: https://feat-mk-api-error-value.notedeck-d3a.pages.dev

View logs

@hitalin hitalin self-assigned this Nov 10, 2026
@claude

claude Bot commented Nov 10, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hitalin
hitalin merged commit f045fd2 into develop Nov 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖Doc Documentation related issue/PR javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant