wecool-chat 0.8.0 → 0.10.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 +83 -0
- package/README.ja.md +234 -20
- package/README.md +419 -21
- package/dist/CopyIndicator-RR3hSsBA.js +51 -0
- package/dist/MarkdownBody-EIz0jnQy.js +14910 -0
- package/dist/VoiceControls-A7N4uPTo.js +146 -0
- package/dist/VoiceRuntime-DrYjNkZK.js +459 -0
- package/dist/abort-BjeyCmGn.js +6 -0
- package/dist/blank-line-CUDmZ-mX.js +143 -0
- package/dist/{browser-Cgo1GySj.js → browser-M7mS-hAN.js} +5 -5
- package/dist/clsx-Cf23UI1w.js +16 -0
- package/dist/core/client.d.ts +37 -4
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/consume-stream.d.ts.map +1 -1
- package/dist/core/error-reporter.d.ts +59 -0
- package/dist/core/error-reporter.d.ts.map +1 -0
- package/dist/core/global-error-capture.d.ts +10 -0
- package/dist/core/global-error-capture.d.ts.map +1 -0
- package/dist/core/i18n/messages.d.ts +139 -1
- package/dist/core/i18n/messages.d.ts.map +1 -1
- package/dist/core/sanitize-user-message.d.ts +11 -0
- package/dist/core/sanitize-user-message.d.ts.map +1 -0
- package/dist/core/stream-state.d.ts.map +1 -1
- package/dist/core/tool-confirmation.d.ts +35 -0
- package/dist/core/tool-confirmation.d.ts.map +1 -0
- package/dist/core/tool-runner.d.ts +8 -0
- package/dist/core/tool-runner.d.ts.map +1 -1
- package/dist/core/types.d.ts +123 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/widget-origin.d.ts +33 -0
- package/dist/core/widget-origin.d.ts.map +1 -0
- package/dist/createLucideIcon-C7wGkK-Q.js +43 -0
- package/dist/default-sNAxTmdF.js +8 -0
- package/dist/index.css +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7548 -26290
- package/dist/jsx-runtime-Cyy0mp0f.js +328 -0
- package/dist/lib-DG_DjiCr.js +15 -0
- package/dist/loader.d.ts +12 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/messages-FvtWi3lI.js +247 -0
- package/dist/observe/__tests__/format.test.d.ts +2 -0
- package/dist/observe/__tests__/format.test.d.ts.map +1 -0
- package/dist/observe/__tests__/http.test.d.ts +2 -0
- package/dist/observe/__tests__/http.test.d.ts.map +1 -0
- package/dist/observe/__tests__/index.test.d.ts +2 -0
- package/dist/observe/__tests__/index.test.d.ts.map +1 -0
- package/dist/observe/__tests__/js-error.test.d.ts +2 -0
- package/dist/observe/__tests__/js-error.test.d.ts.map +1 -0
- package/dist/observe/__tests__/redact.test.d.ts +2 -0
- package/dist/observe/__tests__/redact.test.d.ts.map +1 -0
- package/dist/observe/__tests__/ring-buffer.test.d.ts +2 -0
- package/dist/observe/__tests__/ring-buffer.test.d.ts.map +1 -0
- package/dist/observe/format.d.ts +10 -0
- package/dist/observe/format.d.ts.map +1 -0
- package/dist/observe/index.d.ts +33 -0
- package/dist/observe/index.d.ts.map +1 -0
- package/dist/observe/observers/http.d.ts +24 -0
- package/dist/observe/observers/http.d.ts.map +1 -0
- package/dist/observe/observers/js-error.d.ts +22 -0
- package/dist/observe/observers/js-error.d.ts.map +1 -0
- package/dist/observe/redact.d.ts +27 -0
- package/dist/observe/redact.d.ts.map +1 -0
- package/dist/observe/ring-buffer.d.ts +20 -0
- package/dist/observe/ring-buffer.d.ts.map +1 -0
- package/dist/observe/types.d.ts +25 -0
- package/dist/observe/types.d.ts.map +1 -0
- package/dist/plugin/registry.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +19 -1
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugins/page-reader/__tests__/get-meta.test.d.ts +2 -0
- package/dist/plugins/page-reader/__tests__/get-meta.test.d.ts.map +1 -0
- package/dist/plugins/page-reader/__tests__/index.test.d.ts +2 -0
- package/dist/plugins/page-reader/__tests__/index.test.d.ts.map +1 -0
- package/dist/plugins/page-reader/__tests__/read-content.test.d.ts +2 -0
- package/dist/plugins/page-reader/__tests__/read-content.test.d.ts.map +1 -0
- package/dist/plugins/page-reader/__tests__/scroll.test.d.ts +2 -0
- package/dist/plugins/page-reader/__tests__/scroll.test.d.ts.map +1 -0
- package/dist/plugins/page-reader/index.d.ts +18 -0
- package/dist/plugins/page-reader/index.d.ts.map +1 -0
- package/dist/plugins/page-reader/tools/get-meta.d.ts +29 -0
- package/dist/plugins/page-reader/tools/get-meta.d.ts.map +1 -0
- package/dist/plugins/page-reader/tools/read-content.d.ts +34 -0
- package/dist/plugins/page-reader/tools/read-content.d.ts.map +1 -0
- package/dist/plugins/page-reader/tools/scroll.d.ts +29 -0
- package/dist/plugins/page-reader/tools/scroll.d.ts.map +1 -0
- package/dist/plugins/page-reader.d.ts +2 -0
- package/dist/plugins/page-reader.js +230 -0
- package/dist/plugins/qrcode/tool.d.ts.map +1 -1
- package/dist/plugins/qrcode.js +52 -42
- package/dist/plugins/shared/abort.d.ts +7 -0
- package/dist/plugins/shared/abort.d.ts.map +1 -0
- package/dist/remark-gfm-Bzy1u34W.js +1962 -0
- package/dist/remark-parse-BnwSmQr-.js +2486 -0
- package/dist/stable-prefix-BHsGj4tL.js +21 -0
- package/dist/ui/builtin-tools/get-current-page-info.d.ts.map +1 -1
- package/dist/ui/builtin-tools/index.d.ts +1 -1
- package/dist/ui/builtin-tools/index.d.ts.map +1 -1
- package/dist/ui/builtin-tools/merge-builtin-tools.d.ts +9 -0
- package/dist/ui/builtin-tools/merge-builtin-tools.d.ts.map +1 -1
- package/dist/ui/commands/builtin-commands.d.ts +46 -0
- package/dist/ui/commands/builtin-commands.d.ts.map +1 -0
- package/dist/ui/components/ChatErrorBoundary.d.ts +30 -0
- package/dist/ui/components/ChatErrorBoundary.d.ts.map +1 -0
- package/dist/ui/components/ChatFooter.d.ts +32 -2
- package/dist/ui/components/ChatFooter.d.ts.map +1 -1
- package/dist/ui/components/ChatHeader.d.ts +13 -2
- package/dist/ui/components/ChatHeader.d.ts.map +1 -1
- package/dist/ui/components/ChatHeaderMenu.d.ts +28 -2
- package/dist/ui/components/ChatHeaderMenu.d.ts.map +1 -1
- package/dist/ui/components/ChatPanel.d.ts +38 -4
- package/dist/ui/components/ChatPanel.d.ts.map +1 -1
- package/dist/ui/components/ChatWidget.d.ts +1 -1
- package/dist/ui/components/ChatWidget.d.ts.map +1 -1
- package/dist/ui/components/CommandConfirmationCard.d.ts +28 -0
- package/dist/ui/components/CommandConfirmationCard.d.ts.map +1 -0
- package/dist/ui/components/CommandOverlays.d.ts +40 -0
- package/dist/ui/components/CommandOverlays.d.ts.map +1 -0
- package/dist/ui/components/CommandPalette.d.ts +25 -0
- package/dist/ui/components/CommandPalette.d.ts.map +1 -0
- package/dist/ui/components/FooterActions.d.ts +18 -0
- package/dist/ui/components/FooterActions.d.ts.map +1 -0
- package/dist/ui/components/HelpDialogContent.d.ts +7 -0
- package/dist/ui/components/HelpDialogContent.d.ts.map +1 -0
- package/dist/ui/components/MessageList.d.ts +12 -1
- package/dist/ui/components/MessageList.d.ts.map +1 -1
- package/dist/ui/components/MessageRow.d.ts +7 -1
- package/dist/ui/components/MessageRow.d.ts.map +1 -1
- package/dist/ui/components/MessageRowActions.d.ts +9 -3
- package/dist/ui/components/MessageRowActions.d.ts.map +1 -1
- package/dist/ui/components/MicButton.d.ts +11 -0
- package/dist/ui/components/MicButton.d.ts.map +1 -0
- package/dist/ui/components/ResizeHandles.d.ts +15 -0
- package/dist/ui/components/ResizeHandles.d.ts.map +1 -0
- package/dist/ui/components/ToolConfirmationCard.d.ts +22 -0
- package/dist/ui/components/ToolConfirmationCard.d.ts.map +1 -0
- package/dist/ui/components/ToolConfirmationRecord.d.ts +16 -0
- package/dist/ui/components/ToolConfirmationRecord.d.ts.map +1 -0
- package/dist/ui/components/ToolsDialogContent.d.ts +20 -0
- package/dist/ui/components/ToolsDialogContent.d.ts.map +1 -0
- package/dist/ui/components/VoiceControls.d.ts +22 -0
- package/dist/ui/components/VoiceControls.d.ts.map +1 -0
- package/dist/ui/components/VoiceLoopStatusBar.d.ts +17 -0
- package/dist/ui/components/VoiceLoopStatusBar.d.ts.map +1 -0
- package/dist/ui/components/VoiceLoopToggle.d.ts +15 -0
- package/dist/ui/components/VoiceLoopToggle.d.ts.map +1 -0
- package/dist/ui/components/VoiceRuntime.d.ts +16 -0
- package/dist/ui/components/VoiceRuntime.d.ts.map +1 -0
- package/dist/ui/components/WidgetDialog.d.ts +22 -0
- package/dist/ui/components/WidgetDialog.d.ts.map +1 -0
- package/dist/ui/components/lazy-voice.d.ts +19 -0
- package/dist/ui/components/lazy-voice.d.ts.map +1 -0
- package/dist/ui/components/markdown/MarkdownBody.d.ts +28 -0
- package/dist/ui/components/markdown/MarkdownBody.d.ts.map +1 -0
- package/dist/ui/components/markdown/MarkdownMessage.d.ts +12 -13
- package/dist/ui/components/markdown/MarkdownMessage.d.ts.map +1 -1
- package/dist/ui/hooks/conversationPersistence.d.ts +21 -0
- package/dist/ui/hooks/conversationPersistence.d.ts.map +1 -0
- package/dist/ui/hooks/resize-geometry.d.ts +42 -0
- package/dist/ui/hooks/resize-geometry.d.ts.map +1 -0
- package/dist/ui/hooks/use-command-execution.d.ts +60 -0
- package/dist/ui/hooks/use-command-execution.d.ts.map +1 -0
- package/dist/ui/hooks/use-command-palette.d.ts +45 -0
- package/dist/ui/hooks/use-command-palette.d.ts.map +1 -0
- package/dist/ui/hooks/use-fullscreen.d.ts +21 -0
- package/dist/ui/hooks/use-fullscreen.d.ts.map +1 -0
- package/dist/ui/hooks/use-global-error-capture.d.ts +16 -0
- package/dist/ui/hooks/use-global-error-capture.d.ts.map +1 -0
- package/dist/ui/hooks/use-locale-preference.d.ts +14 -0
- package/dist/ui/hooks/use-locale-preference.d.ts.map +1 -0
- package/dist/ui/hooks/use-menu-keyboard.d.ts +7 -1
- package/dist/ui/hooks/use-menu-keyboard.d.ts.map +1 -1
- package/dist/ui/hooks/use-message-history.d.ts +14 -0
- package/dist/ui/hooks/use-message-history.d.ts.map +1 -1
- package/dist/ui/hooks/use-mic-button.d.ts +29 -0
- package/dist/ui/hooks/use-mic-button.d.ts.map +1 -0
- package/dist/ui/hooks/use-send-message.d.ts +6 -0
- package/dist/ui/hooks/use-send-message.d.ts.map +1 -1
- package/dist/ui/hooks/use-speak-message.d.ts +26 -0
- package/dist/ui/hooks/use-speak-message.d.ts.map +1 -0
- package/dist/ui/hooks/use-tool-confirmation.d.ts +22 -0
- package/dist/ui/hooks/use-tool-confirmation.d.ts.map +1 -0
- package/dist/ui/hooks/use-tool-runner.d.ts +17 -2
- package/dist/ui/hooks/use-tool-runner.d.ts.map +1 -1
- package/dist/ui/hooks/use-visitor-id.d.ts +22 -0
- package/dist/ui/hooks/use-visitor-id.d.ts.map +1 -0
- package/dist/ui/hooks/use-voice-input.d.ts +38 -0
- package/dist/ui/hooks/use-voice-input.d.ts.map +1 -0
- package/dist/ui/hooks/use-voice-loop-speech.d.ts +38 -0
- package/dist/ui/hooks/use-voice-loop-speech.d.ts.map +1 -0
- package/dist/ui/hooks/use-voice-loop.d.ts +12 -0
- package/dist/ui/hooks/use-voice-loop.d.ts.map +1 -0
- package/dist/ui/hooks/use-voice-runtime-snapshot.d.ts +19 -0
- package/dist/ui/hooks/use-voice-runtime-snapshot.d.ts.map +1 -0
- package/dist/ui/hooks/use-voice-runtime.d.ts +29 -0
- package/dist/ui/hooks/use-voice-runtime.d.ts.map +1 -0
- package/dist/ui/hooks/useChatStream.d.ts +19 -0
- package/dist/ui/hooks/useChatStream.d.ts.map +1 -1
- package/dist/ui/hooks/useConversationList.d.ts +12 -1
- package/dist/ui/hooks/useConversationList.d.ts.map +1 -1
- package/dist/ui/hooks/useDraggablePanel.d.ts +2 -0
- package/dist/ui/hooks/useDraggablePanel.d.ts.map +1 -1
- package/dist/ui/hooks/useResizablePanel.d.ts +48 -0
- package/dist/ui/hooks/useResizablePanel.d.ts.map +1 -0
- package/dist/ui/utils/speech-text.d.ts +29 -0
- package/dist/ui/utils/speech-text.d.ts.map +1 -0
- package/dist/ui/utils/voice-locale.d.ts +3 -0
- package/dist/ui/utils/voice-locale.d.ts.map +1 -0
- package/dist/ui/utils/voice-loop-cue.d.ts +23 -0
- package/dist/ui/utils/voice-loop-cue.d.ts.map +1 -0
- package/dist/ui/utils/voice-loop-status.d.ts +17 -0
- package/dist/ui/utils/voice-loop-status.d.ts.map +1 -0
- package/dist/ui/utils/voice-loop-types.d.ts +40 -0
- package/dist/ui/utils/voice-loop-types.d.ts.map +1 -0
- package/dist/ui/utils/voice-runtime.d.ts +38 -0
- package/dist/ui/utils/voice-runtime.d.ts.map +1 -0
- package/dist/ui/utils/voice-support.d.ts +9 -0
- package/dist/ui/utils/voice-support.d.ts.map +1 -0
- package/dist/unified-DctkAd9P.js +518 -0
- package/dist/use-voice-input-LtJJz-zQ.js +102 -0
- package/dist/version.d.ts +17 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/voice-runtime-F5NxN_0m.js +11 -0
- package/dist/voice-support-BeOiOzcn.js +9 -0
- package/package.json +41 -23
- package/dist/messages-B7Kpa6yx.js +0 -117
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/observe/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA4C7C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,aAAa,EAAE,KAAG,MAkBvE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type { ObservedEvent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* observe の設定。`ChatConfig.observe` に渡る。
|
|
4
|
+
* - 省略 / `true`: 既定 ON(全チャネル観測)
|
|
5
|
+
* - `false`: 完全無効(パッチを一切当てない)
|
|
6
|
+
* - オブジェクト: チャネル単位で無効化できる
|
|
7
|
+
*/
|
|
8
|
+
export type ObserveConfig = boolean | {
|
|
9
|
+
/** HTTP エラー(4xx/5xx)観測。既定 true */
|
|
10
|
+
http?: boolean;
|
|
11
|
+
/** JS エラー(未捕捉/reject/console.error)観測。既定 true */
|
|
12
|
+
errors?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** observe 稼働中のハンドル。ChatWidget が保持し、getContext / 破棄に使う */
|
|
15
|
+
export type ObserveController = {
|
|
16
|
+
/**
|
|
17
|
+
* 直近イベントを redact 済みの英語構造化ブロックにして返す。
|
|
18
|
+
* イベント 0 件なら空文字(呼び出し側は本文へ付与しない)。
|
|
19
|
+
*/
|
|
20
|
+
getContext: () => string;
|
|
21
|
+
/** 全 observer を解除し、ホストの fetch / console / listener を原状復帰する */
|
|
22
|
+
dispose: () => void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* observe を起動する。有効なチャネルの observer を購読し、controller を返す。
|
|
26
|
+
* `observe: false`(全チャネル無効)のときは何も購読せず、getContext が常に空を返す
|
|
27
|
+
* no-op controller を返す(パッチを一切当てない)。
|
|
28
|
+
*
|
|
29
|
+
* @param config - `ChatConfig.observe`
|
|
30
|
+
* @returns 観測ハンドル
|
|
31
|
+
*/
|
|
32
|
+
export declare const startObserve: (config: ObserveConfig | undefined) => ObserveController;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observe/index.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP;IACE,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAKN,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AASF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,aAAa,GAAG,SAAS,KAAG,iBA2BhE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ObservedEvent } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* fetch / XHR の 4xx / 5xx を観測する module-level シングルトン。
|
|
4
|
+
*
|
|
5
|
+
* Why module-level: 同一ページに複数 ChatWidget が居ても window.fetch のラップは 1 組だけ張り、
|
|
6
|
+
* 各 controller の record へ fan-out する(global-error-capture.ts と同じ方針)。ラップを
|
|
7
|
+
* インスタンス毎に重ねると多重ラップになり解除順序が壊れる。
|
|
8
|
+
*
|
|
9
|
+
* 非破壊の担保: レスポンス body は一切読まない(status / url のみ記録)。よって clone も
|
|
10
|
+
* 消費もせず、ホスト側の body 読み取りに影響しない。ラップは元関数を必ず呼び、最後の
|
|
11
|
+
* 購読解除で確実に原状復帰する。
|
|
12
|
+
*/
|
|
13
|
+
type HttpRecord = (event: Extract<ObservedEvent, {
|
|
14
|
+
kind: "http";
|
|
15
|
+
}>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* HTTP エラー観測へ record を登録する。最初の購読でラップを張り、最後の解除で外す。
|
|
18
|
+
*
|
|
19
|
+
* @param record - 4xx/5xx を受け取るコールバック
|
|
20
|
+
* @returns 購読解除関数(多重呼び出しは無害)
|
|
21
|
+
*/
|
|
22
|
+
export declare const subscribeHttpObserver: (record: HttpRecord) => (() => void);
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/observe/observers/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;GAUG;AAEH,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,KAAK,IAAI,CAAC;AA2G5E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,UAAU,KAAG,CAAC,MAAM,IAAI,CAUrE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ObservedEvent } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* JS エラー(未捕捉例外・Promise reject・console.error)を観測する module-level シングルトン。
|
|
4
|
+
*
|
|
5
|
+
* error-reporter(core/global-error-capture.ts)とは逆に、**widget 起源フィルタをかけない**。
|
|
6
|
+
* observe の目的はホスト側で起きているエラーを AI へ伝えることなので、ページ上の全エラーを拾う。
|
|
7
|
+
*
|
|
8
|
+
* console.error は window の `error` イベントを発火しないため、ここだけは元関数をラップする
|
|
9
|
+
* (元 console.error を必ず呼び、ホストの既存ロガーを壊さない)。最後の購読解除で原状復帰する。
|
|
10
|
+
*/
|
|
11
|
+
type ErrorRecord = (event: Extract<ObservedEvent, {
|
|
12
|
+
kind: "js-error";
|
|
13
|
+
}>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* JS エラー観測へ record を登録する。最初の購読で購読/ラップを張り、最後の解除で外す。
|
|
16
|
+
*
|
|
17
|
+
* @param record - JS エラーを受け取るコールバック
|
|
18
|
+
* @returns 購読解除関数(多重呼び出しは無害)
|
|
19
|
+
*/
|
|
20
|
+
export declare const subscribeJsErrorObserver: (record: ErrorRecord) => (() => void);
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=js-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-error.d.ts","sourceRoot":"","sources":["../../../src/observe/observers/js-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;GAQG;AAEH,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,KAAK,IAAI,CAAC;AAsEjF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,WAAW,KAAG,CAAC,MAAM,IAAI,CAOzE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 観測データから個人情報・秘匿情報を取り除く。observe は既定 ON で同意に頼らないため、
|
|
3
|
+
* ここが「LLM へ個人情報を渡さない」最後の砦(#253 PII redact と方針を揃える)。
|
|
4
|
+
*
|
|
5
|
+
* 判断がつかない値はマスク側に倒す(安全側)。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* URL をマスクする。2 段構え:
|
|
9
|
+
* 1. 秘匿キー(token/key/email 等)のクエリ値を [redacted] に置換
|
|
10
|
+
* 2. 置換後の URL 全体に自由文 redact(メール形式・トークン様文字列)を適用し、
|
|
11
|
+
* パスや非秘匿キーの値に紛れた PII / トークンも拾う
|
|
12
|
+
*
|
|
13
|
+
* 秘匿キー名に依存せず「値の見た目」でも拾うので、`/users/john@example.com` や
|
|
14
|
+
* `?ref=<長いトークン>` のような素通りを防ぐ。相対 URL でもダミー origin を基準に解釈する。
|
|
15
|
+
*
|
|
16
|
+
* @param raw - redact 前の URL 文字列
|
|
17
|
+
* @returns マスク済み URL
|
|
18
|
+
*/
|
|
19
|
+
export declare const redactUrl: (raw: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* 自由文(エラーメッセージ等)から個人情報・トークン様文字列をマスクする。
|
|
22
|
+
*
|
|
23
|
+
* @param raw - redact 前の文字列
|
|
24
|
+
* @returns マスク済み文字列
|
|
25
|
+
*/
|
|
26
|
+
export declare const redactText: (raw: string) => string;
|
|
27
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/observe/redact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,MAqBvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAC+B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 直近 N 件だけを保持するリングバッファ。上限を超えたら古いものから捨てる。
|
|
3
|
+
* observe が蓄積するイベント量を頭打ちにし、LLM へ渡す背景情報とメモリを一定に保つ。
|
|
4
|
+
*/
|
|
5
|
+
export declare class RingBuffer<T> {
|
|
6
|
+
private readonly capacity;
|
|
7
|
+
private items;
|
|
8
|
+
/**
|
|
9
|
+
* @param capacity - 保持する最大件数。1 未満を渡したら 1 に丸める
|
|
10
|
+
*/
|
|
11
|
+
constructor(capacity: number);
|
|
12
|
+
/** 1 件追加する。上限超過分は先頭(最古)から捨てる */
|
|
13
|
+
push(item: T): void;
|
|
14
|
+
/** 挿入順(古い→新しい)のコピーを返す */
|
|
15
|
+
toArray(): readonly T[];
|
|
16
|
+
/** 全件破棄する(同意ゲート false 化時など) */
|
|
17
|
+
clear(): void;
|
|
18
|
+
get size(): number;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ring-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-buffer.d.ts","sourceRoot":"","sources":["../../src/observe/ring-buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,UAAU,CAAC,CAAC;IAMX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IALrC,OAAO,CAAC,KAAK,CAAW;IAExB;;OAEG;gBAC0B,QAAQ,EAAE,MAAM;IAI7C,gCAAgC;IAChC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAOnB,yBAAyB;IACzB,OAAO,IAAI,SAAS,CAAC,EAAE;IAIvB,+BAA+B;IAC/B,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* observe モジュールが蓄積する 1 イベント。Phase A は HTTP エラーと JS エラーの 2 種のみ。
|
|
3
|
+
*
|
|
4
|
+
* 時刻は持たない: Phase A の観測対象は「失敗が起きた事実」であり、滞在時間などの
|
|
5
|
+
* 時系列指標はスコープ外。整形時は署名でグルーピングして件数を数えるため、順序は
|
|
6
|
+
* リングバッファの挿入順で足りる。
|
|
7
|
+
*/
|
|
8
|
+
export type ObservedEvent = {
|
|
9
|
+
readonly kind: "http";
|
|
10
|
+
/** HTTP メソッド(大文字)。取得できなければ "GET" */
|
|
11
|
+
readonly method: string;
|
|
12
|
+
/** redact 前の生 URL。整形直前に redact する */
|
|
13
|
+
readonly url: string;
|
|
14
|
+
/** 4xx / 5xx のステータスコード */
|
|
15
|
+
readonly status: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "js-error";
|
|
18
|
+
/** redact 前の生メッセージ。整形直前に redact する */
|
|
19
|
+
readonly message: string;
|
|
20
|
+
/** エラー名(`TypeError` 等)。取得できなければ undefined */
|
|
21
|
+
readonly errorName?: string;
|
|
22
|
+
};
|
|
23
|
+
/** observe が記録する 1 イベントを受け取るコールバック。observer → controller の一方向 */
|
|
24
|
+
export type RecordEvent = (event: ObservedEvent) => void;
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/observe/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEN,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugin/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AAI9D,OAAO,KAAK,EACV,UAAU,EAMX,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG;IAC5B,mCAAmC;IACnC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,4CAA4C;IAC5C,aAAa,EAAE,WAAW,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qCAAqC;IACrC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,8BAA8B;IAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugin/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AAI9D,OAAO,KAAK,EACV,UAAU,EAMX,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG;IAC5B,mCAAmC;IACnC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,4CAA4C;IAC5C,aAAa,EAAE,WAAW,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qCAAqC;IACrC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,8BAA8B;IAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAkLF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,SAAS,UAAU,EAAE,EAC9B,MAAM,eAAe,KACpB,OAAO,CAAC,iBAAiB,CAI3B,CAAC"}
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolParameters } from '../core/types';
|
|
1
|
+
import { LocalizedText, ToolParameters } from '../core/types';
|
|
2
2
|
/**
|
|
3
3
|
* Plugin SDK の contract version。
|
|
4
4
|
*
|
|
@@ -45,6 +45,24 @@ export type PluginTool<TArgs extends Record<string, unknown> = Record<string, un
|
|
|
45
45
|
description: string;
|
|
46
46
|
parameters: ToolParameters;
|
|
47
47
|
handler: (args: TArgs, ctx: PluginToolInvocation) => TResult | Promise<TResult>;
|
|
48
|
+
/**
|
|
49
|
+
* 実行前にユーザー承認 UI を挟む (`Tool.requiresConfirmation` と同義)。
|
|
50
|
+
* 破壊的操作 (削除・上書き・外部送信等) を行う tool は宣言すること。
|
|
51
|
+
* optional 追加のため `pluginApiVersion: 1` 互換。
|
|
52
|
+
*/
|
|
53
|
+
requiresConfirmation?: boolean;
|
|
54
|
+
/** 承認 UI に表示する確認文言 (`Tool.confirmationMessage` と同義) */
|
|
55
|
+
confirmationMessage?: string;
|
|
56
|
+
/**
|
|
57
|
+
* `/tools` 一覧に表示する訪問者向けの表示名 (`Tool.displayName` と同義)。
|
|
58
|
+
* UI 表示専用で LLM には送信されない。optional 追加のため `pluginApiVersion: 1` 互換。
|
|
59
|
+
*/
|
|
60
|
+
displayName?: LocalizedText;
|
|
61
|
+
/**
|
|
62
|
+
* `/tools` 一覧に出す質問例 (`Tool.exampleQueries` と同義)。
|
|
63
|
+
* クリックで入力欄に挿入される。UI 表示専用で LLM には送信されない。
|
|
64
|
+
*/
|
|
65
|
+
exampleQueries?: LocalizedText[];
|
|
48
66
|
};
|
|
49
67
|
/**
|
|
50
68
|
* Plugin setup 時に渡される context。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,iBAAiB;IACjB,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,CACpB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,OAAO,GAAG,OAAO,IACf;IACF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,oBAAoB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChF;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC;IACpC;;;OAGG;IACH,YAAY,EAAE,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAC3D,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,KAC7B,IAAI,CAAC;IACV,6CAA6C;IAC7C,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACpD,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,yDAAyD;IACzD,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-meta.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/__tests__/get-meta.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/__tests__/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-content.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/__tests__/read-content.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.test.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/__tests__/scroll.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChatPlugin } from '../../plugin/types';
|
|
2
|
+
export type { ReadContentArgs, ReadContentResult } from './tools/read-content';
|
|
3
|
+
export type { MetaInfoResult } from './tools/get-meta';
|
|
4
|
+
export type { ScrollArgs, ScrollResult } from './tools/scroll';
|
|
5
|
+
/** `createPageReaderPlugin` の任意設定 */
|
|
6
|
+
export type PageReaderPluginOptions = {
|
|
7
|
+
/** read_page_content のデフォルト最大文字数。default 5000 */
|
|
8
|
+
defaultMaxLength?: number;
|
|
9
|
+
/** up_a_bit / down_a_bit のスクロール量(ビューポート高さに対する比率)。default 0.5 */
|
|
10
|
+
scrollAmount?: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* ページ読取プラグインを組み立てる。
|
|
14
|
+
*
|
|
15
|
+
* @param opts - 既定値の上書き。省略可
|
|
16
|
+
*/
|
|
17
|
+
export declare const createPageReaderPlugin: (opts?: PageReaderPluginOptions) => ChatPlugin;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/page-reader/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/D,qCAAqC;AACrC,MAAM,MAAM,uBAAuB,GAAG;IACpC,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAM,uBAA4B,KAAG,UAmBxE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginTool } from '../../../plugin/types';
|
|
2
|
+
type OgMeta = {
|
|
3
|
+
title: string | null;
|
|
4
|
+
description: string | null;
|
|
5
|
+
image: string | null;
|
|
6
|
+
type: string | null;
|
|
7
|
+
siteName: string | null;
|
|
8
|
+
};
|
|
9
|
+
type MetaInfoResultOk = {
|
|
10
|
+
ok: true;
|
|
11
|
+
url: string;
|
|
12
|
+
hostname: string;
|
|
13
|
+
pathname: string;
|
|
14
|
+
title: string;
|
|
15
|
+
language: string;
|
|
16
|
+
description: string | null;
|
|
17
|
+
canonicalUrl: string | null;
|
|
18
|
+
og: OgMeta;
|
|
19
|
+
};
|
|
20
|
+
type MetaInfoResultErr = {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: "browser_only";
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export type MetaInfoResult = MetaInfoResultOk | MetaInfoResultErr;
|
|
26
|
+
/** get_meta_info ツールを組み立てる */
|
|
27
|
+
export declare const buildGetMetaTool: () => PluginTool<Record<string, never>, MetaInfoResult>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=get-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-meta.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/tools/get-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,uBAAuB,CAAC;AAI9E,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAyBlE,8BAA8B;AAC9B,eAAO,MAAM,gBAAgB,QAAO,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,CAWlF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PluginTool } from '../../../plugin/types';
|
|
2
|
+
/** buildReadContentTool に渡すオプション */
|
|
3
|
+
export type ReadContentOpts = {
|
|
4
|
+
defaultMaxLength: number;
|
|
5
|
+
};
|
|
6
|
+
/** read_page_content tool が LLM から受け取る引数 */
|
|
7
|
+
export type ReadContentArgs = {
|
|
8
|
+
maxLength?: number;
|
|
9
|
+
selector?: string;
|
|
10
|
+
};
|
|
11
|
+
type ReadContentResultOk = {
|
|
12
|
+
ok: true;
|
|
13
|
+
content: string;
|
|
14
|
+
truncated: boolean;
|
|
15
|
+
totalLength: number;
|
|
16
|
+
selector: string;
|
|
17
|
+
};
|
|
18
|
+
type ReadContentResultErr = {
|
|
19
|
+
ok: false;
|
|
20
|
+
error: "selector_not_found" | "browser_only";
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
export type ReadContentResult = ReadContentResultOk | ReadContentResultErr;
|
|
24
|
+
/** 連続する空白・改行を正規化する */
|
|
25
|
+
export declare const normalizeWhitespace: (text: string) => string;
|
|
26
|
+
/** maxLength で切り詰める。超過時は末尾に "…" を付与 */
|
|
27
|
+
export declare const truncateText: (text: string, maxLength: number) => {
|
|
28
|
+
content: string;
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** read_page_content ツールを組み立てる */
|
|
32
|
+
export declare const buildReadContentTool: (opts: ReadContentOpts) => PluginTool<ReadContentArgs, ReadContentResult>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=read-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-content.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/tools/read-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,uBAAuB,CAAC;AAI9E,oCAAoC;AACpC,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,oBAAoB,GAAG,cAAc,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AA0B3E,sBAAsB;AACtB,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,MAIxC,CAAC;AAEZ,uCAAuC;AACvC,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAGvC,CAAC;AA0BF,kCAAkC;AAClC,eAAO,MAAM,oBAAoB,GAC/B,MAAM,eAAe,KACpB,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAW9C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginTool } from '../../../plugin/types';
|
|
2
|
+
/** buildScrollTool に渡すオプション */
|
|
3
|
+
export type ScrollOpts = {
|
|
4
|
+
scrollAmount: number;
|
|
5
|
+
};
|
|
6
|
+
/** scroll_page tool が LLM から受け取る引数 */
|
|
7
|
+
export type ScrollArgs = {
|
|
8
|
+
action: string;
|
|
9
|
+
selector?: string;
|
|
10
|
+
};
|
|
11
|
+
type ScrollResultOk = {
|
|
12
|
+
ok: true;
|
|
13
|
+
action: string;
|
|
14
|
+
scrollY: number;
|
|
15
|
+
scrollHeight: number;
|
|
16
|
+
viewportHeight: number;
|
|
17
|
+
};
|
|
18
|
+
type ScrollResultErr = {
|
|
19
|
+
ok: false;
|
|
20
|
+
error: "element_not_found" | "selector_required" | "invalid_action" | "browser_only";
|
|
21
|
+
message: string;
|
|
22
|
+
action?: string;
|
|
23
|
+
selector?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ScrollResult = ScrollResultOk | ScrollResultErr;
|
|
26
|
+
/** scroll_page ツールを組み立てる */
|
|
27
|
+
export declare const buildScrollTool: (opts: ScrollOpts) => PluginTool<ScrollArgs, ScrollResult>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../../src/plugins/page-reader/tools/scroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,uBAAuB,CAAC;AAI9E,+BAA+B;AAC/B,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,sCAAsC;AACtC,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACrF,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;AAmF5D,4BAA4B;AAC5B,eAAO,MAAM,eAAe,GAAI,MAAM,UAAU,KAAG,UAAU,CAAC,UAAU,EAAE,YAAY,CAWpF,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { t as c } from "../define-DZ0itsfG.js";
|
|
2
|
+
import { t as a } from "../abort-BjeyCmGn.js";
|
|
3
|
+
var u = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
maxLength: {
|
|
7
|
+
type: "number",
|
|
8
|
+
description: "Maximum number of characters to return (default: 5000)"
|
|
9
|
+
},
|
|
10
|
+
selector: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "CSS selector to read a specific element only (e.g. 'main', 'article'). Defaults to the whole body"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, m = 'Read the text content of the currently displayed page. Use when the user asks about the page content, e.g., "what is this page about?", "summarize this article", 「このページの内容は?」「この記事を要約して」.', d = (e) => e.replace(/\n{3,}/g, `
|
|
16
|
+
|
|
17
|
+
`).replace(/[ \t]+/g, " ").trim(), p = (e, t) => e.length <= t ? {
|
|
18
|
+
content: e,
|
|
19
|
+
truncated: !1
|
|
20
|
+
} : {
|
|
21
|
+
content: e.slice(0, t) + "…",
|
|
22
|
+
truncated: !0
|
|
23
|
+
}, g = (e) => typeof e == "object" && e !== null && "ok" in e && e.ok === !1, f = (e) => {
|
|
24
|
+
try {
|
|
25
|
+
const t = document.querySelector(e);
|
|
26
|
+
return t || {
|
|
27
|
+
ok: !1,
|
|
28
|
+
error: "selector_not_found",
|
|
29
|
+
message: `No element found for selector "${e}"`
|
|
30
|
+
};
|
|
31
|
+
} catch {
|
|
32
|
+
return {
|
|
33
|
+
ok: !1,
|
|
34
|
+
error: "selector_not_found",
|
|
35
|
+
message: `Invalid CSS selector "${e}"`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}, h = (e) => ({
|
|
39
|
+
name: "read_page_content",
|
|
40
|
+
description: m,
|
|
41
|
+
parameters: u,
|
|
42
|
+
displayName: {
|
|
43
|
+
ja: "ページ内容の読み取り",
|
|
44
|
+
en: "Read page content"
|
|
45
|
+
},
|
|
46
|
+
exampleQueries: [{
|
|
47
|
+
ja: "このページの内容を教えて",
|
|
48
|
+
en: "What is this page about?"
|
|
49
|
+
}, {
|
|
50
|
+
ja: "この記事を要約して",
|
|
51
|
+
en: "Summarize this article"
|
|
52
|
+
}],
|
|
53
|
+
handler: (t, o) => y(t, o, e)
|
|
54
|
+
}), w = (e) => e ? f(e) : document.body, _ = (e, t) => {
|
|
55
|
+
const o = e instanceof HTMLElement ? e.innerText : e.textContent ?? "", r = d(o), { content: l, truncated: s } = p(r, t);
|
|
56
|
+
return {
|
|
57
|
+
ok: !0,
|
|
58
|
+
content: l,
|
|
59
|
+
truncated: s,
|
|
60
|
+
totalLength: r.length
|
|
61
|
+
};
|
|
62
|
+
}, y = (e, t, o) => {
|
|
63
|
+
if (a(t.signal), typeof document > "u") return {
|
|
64
|
+
ok: !1,
|
|
65
|
+
error: "browser_only",
|
|
66
|
+
message: "read_page_content requires a browser environment"
|
|
67
|
+
};
|
|
68
|
+
const r = w(e.selector);
|
|
69
|
+
return g(r) ? r : {
|
|
70
|
+
..._(r, e.maxLength ?? o.defaultMaxLength),
|
|
71
|
+
selector: e.selector ?? "body"
|
|
72
|
+
};
|
|
73
|
+
}, b = {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: {}
|
|
76
|
+
}, v = 'Get the current page URL, title, and OGP metadata. Use when the user asks about the page identity or metadata, e.g., "what page am I on?", "show me the OGP info", 「今どこのページ?」「OGP情報を確認したい」. For basic info (URL / title) alone, getCurrentPageInfo is sufficient; use this tool when OGP or canonical URL is needed.', n = (e) => document.querySelector(e)?.getAttribute("content") ?? null, S = (e) => document.querySelector(e)?.getAttribute("href") ?? null, T = () => ({
|
|
77
|
+
name: "get_meta_info",
|
|
78
|
+
description: v,
|
|
79
|
+
parameters: b,
|
|
80
|
+
displayName: {
|
|
81
|
+
ja: "ページ情報の取得",
|
|
82
|
+
en: "Get page info"
|
|
83
|
+
},
|
|
84
|
+
exampleQueries: [{
|
|
85
|
+
ja: "今どこのページ?",
|
|
86
|
+
en: "What page am I on?"
|
|
87
|
+
}, {
|
|
88
|
+
ja: "OGP情報を確認したい",
|
|
89
|
+
en: "Show me the OGP info"
|
|
90
|
+
}],
|
|
91
|
+
handler: (e, t) => k(t)
|
|
92
|
+
}), k = (e) => (a(e.signal), typeof document > "u" ? {
|
|
93
|
+
ok: !1,
|
|
94
|
+
error: "browser_only",
|
|
95
|
+
message: "get_meta_info requires a browser environment"
|
|
96
|
+
} : {
|
|
97
|
+
ok: !0,
|
|
98
|
+
url: window.location.href,
|
|
99
|
+
hostname: window.location.hostname,
|
|
100
|
+
pathname: window.location.pathname,
|
|
101
|
+
title: document.title,
|
|
102
|
+
language: document.documentElement.lang || navigator.language,
|
|
103
|
+
description: n('meta[name="description"]'),
|
|
104
|
+
canonicalUrl: S('link[rel="canonical"]'),
|
|
105
|
+
og: {
|
|
106
|
+
title: n('meta[property="og:title"]'),
|
|
107
|
+
description: n('meta[property="og:description"]'),
|
|
108
|
+
image: n('meta[property="og:image"]'),
|
|
109
|
+
type: n('meta[property="og:type"]'),
|
|
110
|
+
siteName: n('meta[property="og:site_name"]')
|
|
111
|
+
}
|
|
112
|
+
}), i = [
|
|
113
|
+
"top",
|
|
114
|
+
"bottom",
|
|
115
|
+
"up_a_bit",
|
|
116
|
+
"down_a_bit",
|
|
117
|
+
"to_element"
|
|
118
|
+
], A = {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
action: {
|
|
122
|
+
type: "string",
|
|
123
|
+
enum: [...i],
|
|
124
|
+
description: "top: to the top / bottom: to the bottom / up_a_bit: up slightly / down_a_bit: down slightly / to_element: to the element matched by selector"
|
|
125
|
+
},
|
|
126
|
+
selector: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "CSS selector of the target element when action is to_element (e.g. 'footer', '#contact-form', '.pricing')"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
required: ["action"]
|
|
132
|
+
}, E = 'Scroll the page. Use when the user asks to scroll, e.g., "scroll to the bottom", "back to top", "down a bit", "to the contact form", 「下まで行って」「最初に戻って」「フッターまで」.', R = (e) => i.some((t) => t === e), I = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth", L = (e) => ({
|
|
133
|
+
ok: !0,
|
|
134
|
+
action: e,
|
|
135
|
+
scrollY: window.scrollY,
|
|
136
|
+
scrollHeight: document.documentElement.scrollHeight,
|
|
137
|
+
viewportHeight: window.innerHeight
|
|
138
|
+
}), P = (e) => typeof e == "object" && e !== null && "ok" in e && e.ok === !1, j = (e) => {
|
|
139
|
+
try {
|
|
140
|
+
const t = document.querySelector(e);
|
|
141
|
+
return t || {
|
|
142
|
+
ok: !1,
|
|
143
|
+
error: "element_not_found",
|
|
144
|
+
message: `No element found for selector "${e}"`,
|
|
145
|
+
action: "to_element",
|
|
146
|
+
selector: e
|
|
147
|
+
};
|
|
148
|
+
} catch {
|
|
149
|
+
return {
|
|
150
|
+
ok: !1,
|
|
151
|
+
error: "element_not_found",
|
|
152
|
+
message: `Invalid CSS selector "${e}"`,
|
|
153
|
+
action: "to_element",
|
|
154
|
+
selector: e
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}, C = (e) => ({
|
|
158
|
+
name: "scroll_page",
|
|
159
|
+
description: E,
|
|
160
|
+
parameters: A,
|
|
161
|
+
displayName: {
|
|
162
|
+
ja: "ページのスクロール",
|
|
163
|
+
en: "Scroll the page"
|
|
164
|
+
},
|
|
165
|
+
exampleQueries: [{
|
|
166
|
+
ja: "一番下までスクロールして",
|
|
167
|
+
en: "Scroll to the bottom"
|
|
168
|
+
}, {
|
|
169
|
+
ja: "最初に戻って",
|
|
170
|
+
en: "Back to top"
|
|
171
|
+
}],
|
|
172
|
+
handler: (t, o) => N(t, o, e)
|
|
173
|
+
}), M = (e, t) => {
|
|
174
|
+
if (!e) return {
|
|
175
|
+
ok: !1,
|
|
176
|
+
error: "selector_required",
|
|
177
|
+
message: 'action "to_element" requires a selector parameter'
|
|
178
|
+
};
|
|
179
|
+
const o = j(e);
|
|
180
|
+
return P(o) ? o : (o.scrollIntoView({
|
|
181
|
+
behavior: t,
|
|
182
|
+
block: "start"
|
|
183
|
+
}), null);
|
|
184
|
+
}, x = (e, t, o, r) => {
|
|
185
|
+
switch (e) {
|
|
186
|
+
case "top":
|
|
187
|
+
return window.scrollTo({
|
|
188
|
+
top: 0,
|
|
189
|
+
behavior: r
|
|
190
|
+
}), null;
|
|
191
|
+
case "bottom":
|
|
192
|
+
return window.scrollTo({
|
|
193
|
+
top: document.documentElement.scrollHeight,
|
|
194
|
+
behavior: r
|
|
195
|
+
}), null;
|
|
196
|
+
case "up_a_bit":
|
|
197
|
+
return window.scrollBy({
|
|
198
|
+
top: -(window.innerHeight * o.scrollAmount),
|
|
199
|
+
behavior: r
|
|
200
|
+
}), null;
|
|
201
|
+
case "down_a_bit":
|
|
202
|
+
return window.scrollBy({
|
|
203
|
+
top: window.innerHeight * o.scrollAmount,
|
|
204
|
+
behavior: r
|
|
205
|
+
}), null;
|
|
206
|
+
case "to_element":
|
|
207
|
+
return M(t.selector, r);
|
|
208
|
+
default:
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
}, N = (e, t, o) => (a(t.signal), typeof window > "u" ? {
|
|
212
|
+
ok: !1,
|
|
213
|
+
error: "browser_only",
|
|
214
|
+
message: "scroll_page requires a browser environment"
|
|
215
|
+
} : R(e.action) ? x(e.action, e, o, I()) ?? L(e.action) : {
|
|
216
|
+
ok: !1,
|
|
217
|
+
error: "invalid_action",
|
|
218
|
+
message: `Invalid action "${e.action}". Valid actions: ${i.join(", ")}`,
|
|
219
|
+
action: e.action
|
|
220
|
+
}), O = 5e3, G = 0.5, H = (e = {}) => c({
|
|
221
|
+
pluginApiVersion: 1,
|
|
222
|
+
id: "wecool/page-reader",
|
|
223
|
+
version: "0.1.0",
|
|
224
|
+
setup(t) {
|
|
225
|
+
t.registerTool(h({ defaultMaxLength: e.defaultMaxLength ?? O })), t.registerTool(T()), t.registerTool(C({ scrollAmount: e.scrollAmount ?? G })), t.logger.debug("page-reader plugin registered");
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
export {
|
|
229
|
+
H as createPageReaderPlugin
|
|
230
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/plugins/qrcode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAE5F,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/plugins/qrcode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAE5F,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAIL,KAAK,oBAAoB,EAEzB,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAEzB,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,cAAc,GAAG,cAAc,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AA4CrD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,YAAY,KACjB,UAAU,CAAC,cAAc,EAAE,kBAAkB,CAsB/C,CAAC"}
|