@x-otto/plugin 0.1.0-alpha.4 → 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/dist/index.d.ts +41 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { TypedEventEmitter } from "@x-otto/shared";
|
|
|
3
3
|
import * as _$_x_otto_interchange0 from "@x-otto/interchange";
|
|
4
4
|
import { PluginInputRegistry, SigilEntry, SigilKind, SigilPrefix, SigilProvider, SigilSource, sigilOf } from "@x-otto/interchange";
|
|
5
5
|
import * as _$_x_otto_provider0 from "@x-otto/provider";
|
|
6
|
+
import { HookAbortSignal, HookPayloadMap, WaterfallTiming } from "@x-otto/hook-contracts";
|
|
6
7
|
|
|
7
8
|
//#region src/capabilities.d.ts
|
|
8
9
|
/**
|
|
@@ -2355,6 +2356,10 @@ type PreToolUseDecision = {
|
|
|
2355
2356
|
* RFC-129 D1 边界纪律:新增的 9 个字段全部是 observer-only——不开放任何可变换消息/参数的
|
|
2356
2357
|
* interceptor timing(`messages.transform`/`chat.params`/`system.prompt.transform`/
|
|
2357
2358
|
* `chat.message.after` 均不对插件开放,见 RFC-129 §1.2 非目标 + 放弃方案)。
|
|
2359
|
+
*
|
|
2360
|
+
* RFC-327 修订 D1(M1)显式修订:上述边界纪律对 `waterfall` 贡献面**不再成立**——
|
|
2361
|
+
* waterfall 是**新的贡献面**(不是 observer 改 interceptor),经受控白名单 timing
|
|
2362
|
+
* (`WaterfallTiming`)开放三个受控中间产物的改写点,见下方 `waterfall` 字段说明。
|
|
2358
2363
|
*/
|
|
2359
2364
|
interface PluginHooks {
|
|
2360
2365
|
preToolUse?: (ctx: ToolUseContext) => PreToolUseDecision | void | Promise<PreToolUseDecision | void>;
|
|
@@ -2436,7 +2441,36 @@ interface PluginHooks {
|
|
|
2436
2441
|
taskId: string;
|
|
2437
2442
|
agent: string;
|
|
2438
2443
|
}) => void | Promise<void>;
|
|
2444
|
+
/**
|
|
2445
|
+
* RFC-327 修订 D1(M1):waterfall 贡献面——插件经受控白名单 timing 改写主循环中间产物。
|
|
2446
|
+
*
|
|
2447
|
+
* 语义对齐 HookRegistry 既有 interceptor(priority 序 → 共享可变 output → 后续可见前者
|
|
2448
|
+
* 改写),**外加** serial-with-early-bail:任一 handler 返回 `{ abort: true }` →
|
|
2449
|
+
* 终止该 timing 的整条 hook 链,output 保留已累积值(后续引擎 hook 不执行)。
|
|
2450
|
+
*
|
|
2451
|
+
* 安全边界(R1'/R10):
|
|
2452
|
+
* - 只作用于白名单 timing 的**受控中间产物**(`system.prompt.transform` /
|
|
2453
|
+
* `chat.params` / `messages.transform`)——不开放历史消息、用户输入、tool 参数;
|
|
2454
|
+
* - 白名单编译期强制(`WaterfallTiming` 从 `HookPayloadMap` Pick),装载器运行时校验兜底,
|
|
2455
|
+
* 白名单外 timing 一律拒绝注册(fail-closed);
|
|
2456
|
+
* - `system.prompt.transform` 默认只开放 `systemTail`(volatile,cache 断点后,逐轮可变)
|
|
2457
|
+
* + 预算闸(4KB 顶)——`systemPrompt`(stable,进 prompt cache)**第一版不开放**,
|
|
2458
|
+
* 尝试写入被装载器拒绝(fail-closed,写入会永久污染后续所有轮次的 prompt cache 前缀);
|
|
2459
|
+
* - 全程审计(pluginId + timing + 变更摘要),走既有 capability/trust/隔离 RPC 三重门,
|
|
2460
|
+
* 不另建旁路。
|
|
2461
|
+
*
|
|
2462
|
+
* 能力面跃迁声明:从「插件只能 deny/ask 升级限制」到「插件能改写受控中间产物」是质变,
|
|
2463
|
+
* 本字段是新贡献面(非 observer 改 interceptor),配套 D1a 分权与安全门见 RFC-327 修订 §3。
|
|
2464
|
+
*/
|
|
2465
|
+
waterfall?: PluginWaterfallHooks;
|
|
2439
2466
|
}
|
|
2467
|
+
/**
|
|
2468
|
+
* RFC-327 修订 D1(M1):waterfall handler 逐 timing 签名——input/output 与引擎
|
|
2469
|
+
* `HookPayloadMap` 对齐(编译期逐 timing 精确类型,无双重断言),返回值支持 abort 哨兵。
|
|
2470
|
+
*/
|
|
2471
|
+
type PluginWaterfallHandler<T extends WaterfallTiming> = (input: HookPayloadMap[T]['input'], output: HookPayloadMap[T]['output']) => void | HookAbortSignal | Promise<void | HookAbortSignal>;
|
|
2472
|
+
/** RFC-327 修订 D1(M1):waterfall 贡献面的逐 timing 映射(mapped type 保持 per-key 类型精确)。 */
|
|
2473
|
+
type PluginWaterfallHooks = { [T in WaterfallTiming]?: PluginWaterfallHandler<T> };
|
|
2440
2474
|
/** 装载时注入工厂的上下文。 */
|
|
2441
2475
|
interface PluginContext {
|
|
2442
2476
|
/** 插件 id(= manifest.id = source 标签)。 */
|
|
@@ -2579,6 +2613,12 @@ interface PluginTool {
|
|
|
2579
2613
|
data?: unknown;
|
|
2580
2614
|
error?: unknown;
|
|
2581
2615
|
};
|
|
2616
|
+
/**
|
|
2617
|
+
* 模型侧序列化契约(与 @x-otto/interchange 的 AgentTool.parameters 对齐):
|
|
2618
|
+
* provider 序列化时无此方法则模型收到空 {} schema、参数完全不可见。
|
|
2619
|
+
* 手写 schema 必须与 safeParse 成对提供(2026-08-13 终局复核回归教训)。
|
|
2620
|
+
*/
|
|
2621
|
+
toJSONSchema?: () => unknown;
|
|
2582
2622
|
};
|
|
2583
2623
|
/**
|
|
2584
2624
|
* 执行体。第二参数 `ctx` 为 RFC-303 M4 可选上下文(pluginId/workspaceDir/logger/
|
|
@@ -3299,5 +3339,5 @@ declare class PluginI18nRegistry extends TypedEventEmitter<PluginI18nRegistryEve
|
|
|
3299
3339
|
t(fullKey: string, locale?: string): string;
|
|
3300
3340
|
}
|
|
3301
3341
|
//#endregion
|
|
3302
|
-
export { type ActionContribution, type AgentContribution, type CommandContribution, type CommandRef, type ContextKeyProvider, type ContextMap, type ContextSourceContribution, type ContributionPoint, type DiscoverPluginsOptions, type DiscoveredPlugin, type DispatchCaps, EXTENSION_POINTS, type EngineCompatResult, type FeedbackIssueInput, type FeedbackIssueResult, type FeedbackProvider, type FileProviderOptions, HIGH_RISK_CAPABILITIES, type HostAskInput, ID_RE, MAX_I18N_ENTRIES_PER_PLUGIN, MAX_I18N_FILE_BYTES, MAX_I18N_LOCALE_FILES_PER_PLUGIN, MAX_I18N_TRANSLATION_BYTES, MAX_THEME_PRESETS_PER_PLUGIN, type McpContribution, type McpTransport, type MenuContribution, type MonitorEvent, type OAuthContribution, PLUGIN_API_VERSION, PLUGIN_CAPABILITIES, PLUGIN_MANIFEST_FILENAME, POINT, type PerfMetricContribution, type PluginA2uiComponentEntry, type PluginA2uiRendererEntry, type PluginCapability, type PluginCliContribution, type PluginContext, type PluginContributes, type PluginContributions, type PluginExecutableSurface, type PluginFactory, type PluginFileViewerEntry, type PluginHooks, type PluginHostCapabilities, type PluginI18nContribution, type PluginI18nEntry, PluginI18nRegistry, type PluginInputRegistry, type PluginManifest, type PluginModelEntry, type PluginModule, type PluginMonitor, type PluginPanelEntry, type PluginProviderEntry, type PluginProviderFactory, type PluginRendererEntry, type PluginScheduleSubscription, type PluginScopedStorageShape, type PluginScripts, type PluginService, type PluginServiceContext, type PluginServiceNotification, type PluginThemePresetColors, type PluginThemePresetContribution, type PluginTool, type PluginToolContext, type PluginTrustVerdict, type PluginWireProtocolRegistration, type PreToolUseDecision, type PulseSurveyEntry, type PulseSurveyRating, type PulseSurveyResolvedConfig, type ResolvedAction, SHELL_POINTS, type ScheduleTickNotification, type SessionIdleNotification, type SigilEntry, type SigilEntryContribution, type SigilKind, type SigilPrefix, type SigilProvider, type SigilSource, type SkillContribution, type StatusItemContribution, type StatusWidgetContribution, type ToolUseContext, type TopoSortResult, type TranscriptMessage, createBuiltinHashtags, createFileProvider, createPluginInputRegistry, definePlugin, detectPluginExecutableSurface, discoverPlugins, dispatch, evaluateContextKey, evaluateContextKeys, evaluatePluginTrust, evaluateWhen, expandPath, filterEngineCompatible, grantPluginCapabilities, grantedPluginCapabilities, isEngineCompatible, isPathTrusted, isPluginTrusted, mergeContributions, parsePluginManifest, pluginTrustStorePath, readHighRiskCapabilities, resolveActions, resolveActivationEvents, sigilOf, topoSortPlugins, trustPath, trustPlugin, untrustPath, untrustPlugin };
|
|
3342
|
+
export { type ActionContribution, type AgentContribution, type CommandContribution, type CommandRef, type ContextKeyProvider, type ContextMap, type ContextSourceContribution, type ContributionPoint, type DiscoverPluginsOptions, type DiscoveredPlugin, type DispatchCaps, EXTENSION_POINTS, type EngineCompatResult, type FeedbackIssueInput, type FeedbackIssueResult, type FeedbackProvider, type FileProviderOptions, HIGH_RISK_CAPABILITIES, type HostAskInput, ID_RE, MAX_I18N_ENTRIES_PER_PLUGIN, MAX_I18N_FILE_BYTES, MAX_I18N_LOCALE_FILES_PER_PLUGIN, MAX_I18N_TRANSLATION_BYTES, MAX_THEME_PRESETS_PER_PLUGIN, type McpContribution, type McpTransport, type MenuContribution, type MonitorEvent, type OAuthContribution, PLUGIN_API_VERSION, PLUGIN_CAPABILITIES, PLUGIN_MANIFEST_FILENAME, POINT, type PerfMetricContribution, type PluginA2uiComponentEntry, type PluginA2uiRendererEntry, type PluginCapability, type PluginCliContribution, type PluginContext, type PluginContributes, type PluginContributions, type PluginExecutableSurface, type PluginFactory, type PluginFileViewerEntry, type PluginHooks, type PluginHostCapabilities, type PluginI18nContribution, type PluginI18nEntry, PluginI18nRegistry, type PluginInputRegistry, type PluginManifest, type PluginModelEntry, type PluginModule, type PluginMonitor, type PluginPanelEntry, type PluginProviderEntry, type PluginProviderFactory, type PluginRendererEntry, type PluginScheduleSubscription, type PluginScopedStorageShape, type PluginScripts, type PluginService, type PluginServiceContext, type PluginServiceNotification, type PluginThemePresetColors, type PluginThemePresetContribution, type PluginTool, type PluginToolContext, type PluginTrustVerdict, type PluginWaterfallHandler, type PluginWaterfallHooks, type PluginWireProtocolRegistration, type PreToolUseDecision, type PulseSurveyEntry, type PulseSurveyRating, type PulseSurveyResolvedConfig, type ResolvedAction, SHELL_POINTS, type ScheduleTickNotification, type SessionIdleNotification, type SigilEntry, type SigilEntryContribution, type SigilKind, type SigilPrefix, type SigilProvider, type SigilSource, type SkillContribution, type StatusItemContribution, type StatusWidgetContribution, type ToolUseContext, type TopoSortResult, type TranscriptMessage, createBuiltinHashtags, createFileProvider, createPluginInputRegistry, definePlugin, detectPluginExecutableSurface, discoverPlugins, dispatch, evaluateContextKey, evaluateContextKeys, evaluatePluginTrust, evaluateWhen, expandPath, filterEngineCompatible, grantPluginCapabilities, grantedPluginCapabilities, isEngineCompatible, isPathTrusted, isPluginTrusted, mergeContributions, parsePluginManifest, pluginTrustStorePath, readHighRiskCapabilities, resolveActions, resolveActivationEvents, sigilOf, topoSortPlugins, trustPath, trustPlugin, untrustPath, untrustPlugin };
|
|
3303
3343
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-otto/plugin",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"README.md"
|
|
@@ -22,10 +22,11 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"semver": "7.7.4",
|
|
24
24
|
"zod": "4.3.6",
|
|
25
|
-
"@x-otto/
|
|
26
|
-
"@x-otto/
|
|
25
|
+
"@x-otto/hook-contracts": "0.0.1-alpha.2",
|
|
26
|
+
"@x-otto/provider": "0.1.0-alpha.5",
|
|
27
27
|
"@x-otto/shared": "0.1.0-alpha.6",
|
|
28
|
-
"@x-otto/
|
|
28
|
+
"@x-otto/interchange": "0.1.0-alpha.4",
|
|
29
|
+
"@x-otto/env": "0.1.0-alpha.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/semver": "7.7.1"
|