@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.70

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 (146) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +76 -3
  13. package/agent-docs/plugin-format.md +51 -12
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +60 -13
  22. package/dist/cards.js +88 -18
  23. package/dist/channel.d.ts +128 -47
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +28 -6
  30. package/dist/config-ui.js +88 -25
  31. package/dist/config-url-fetch.d.ts +19 -0
  32. package/dist/config-url-fetch.js +43 -0
  33. package/dist/connector-auth.d.ts +13 -2
  34. package/dist/connector-auth.js +82 -8
  35. package/dist/connector.d.ts +74 -32
  36. package/dist/context.d.ts +40 -0
  37. package/dist/context.js +2 -0
  38. package/dist/ctx.d.ts +210 -30
  39. package/dist/ctx.js +9 -1
  40. package/dist/define-extension.d.ts +23 -13
  41. package/dist/define-extension.js +19 -5
  42. package/dist/device-denied-paths.d.ts +20 -0
  43. package/dist/device-denied-paths.js +118 -0
  44. package/dist/device-operation.d.ts +339 -0
  45. package/dist/device-operation.js +312 -0
  46. package/dist/device-protocol.d.ts +285 -50
  47. package/dist/device-protocol.js +755 -90
  48. package/dist/device-provider.d.ts +708 -0
  49. package/dist/device-provider.js +325 -0
  50. package/dist/device-service.d.ts +52 -0
  51. package/dist/device-service.js +105 -0
  52. package/dist/dial-in.d.ts +239 -0
  53. package/dist/dial-in.js +155 -0
  54. package/dist/directory.d.ts +15 -12
  55. package/dist/extension-point.d.ts +2 -0
  56. package/dist/extension-point.js +6 -2
  57. package/dist/field-meta.d.ts +19 -0
  58. package/dist/field-meta.js +54 -0
  59. package/dist/file-preview.d.ts +26 -10
  60. package/dist/git-hosts.d.ts +53 -0
  61. package/dist/git-hosts.js +98 -0
  62. package/dist/hooks.d.ts +125 -20
  63. package/dist/hooks.js +5 -0
  64. package/dist/http-access.d.ts +62 -0
  65. package/dist/http-access.js +12 -0
  66. package/dist/identity.d.ts +38 -9
  67. package/dist/identity.js +21 -1
  68. package/dist/index.d.ts +31 -4
  69. package/dist/index.js +31 -4
  70. package/dist/model-params.d.ts +41 -22
  71. package/dist/model-params.js +28 -15
  72. package/dist/model.d.ts +210 -75
  73. package/dist/model.js +152 -19
  74. package/dist/net.d.ts +52 -0
  75. package/dist/net.js +34 -0
  76. package/dist/network-classes.d.ts +98 -0
  77. package/dist/network-classes.js +291 -0
  78. package/dist/permissions.d.ts +65 -22
  79. package/dist/permissions.js +139 -43
  80. package/dist/platform-only.d.ts +27 -0
  81. package/dist/platform-only.js +35 -0
  82. package/dist/plugin-manifest.d.ts +40 -9
  83. package/dist/plugin-manifest.js +171 -60
  84. package/dist/plugin-package.d.ts +82 -39
  85. package/dist/plugin-package.js +68 -41
  86. package/dist/push.d.ts +75 -0
  87. package/dist/push.js +87 -0
  88. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  89. package/dist/sandbox-linux-runtime-source.js +2343 -0
  90. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  91. package/dist/sandbox-native-runtime-source.js +476 -0
  92. package/dist/sandbox-runtime-source.d.ts +47 -0
  93. package/dist/sandbox-runtime-source.js +73 -0
  94. package/dist/sandbox-write-denies.d.ts +139 -0
  95. package/dist/sandbox-write-denies.js +869 -0
  96. package/dist/secret.d.ts +8 -2
  97. package/dist/secret.js +11 -4
  98. package/dist/setup-check.d.ts +128 -0
  99. package/dist/setup-check.js +142 -0
  100. package/dist/setup-guide-parse.d.ts +121 -0
  101. package/dist/setup-guide-parse.js +356 -0
  102. package/dist/setup-guide-render.d.ts +45 -0
  103. package/dist/setup-guide-render.js +351 -0
  104. package/dist/setup-guide.d.ts +86 -72
  105. package/dist/setup-guide.js +340 -108
  106. package/dist/shell-capabilities.d.ts +211 -0
  107. package/dist/shell-capabilities.js +44 -0
  108. package/dist/shell-environment.d.ts +57 -0
  109. package/dist/shell-environment.js +21 -0
  110. package/dist/skill.d.ts +27 -17
  111. package/dist/skill.js +40 -26
  112. package/dist/storage.d.ts +52 -25
  113. package/dist/svg-viewbox.d.ts +10 -0
  114. package/dist/svg-viewbox.js +24 -0
  115. package/dist/theme-assets.d.ts +55 -0
  116. package/dist/theme-assets.js +489 -0
  117. package/dist/theme-readability.d.ts +37 -0
  118. package/dist/theme-readability.js +145 -0
  119. package/dist/theme-tokens.generated.d.ts +299 -0
  120. package/dist/theme-tokens.generated.js +184 -0
  121. package/dist/theme.d.ts +190 -0
  122. package/dist/theme.js +471 -0
  123. package/dist/tool.d.ts +104 -30
  124. package/dist/tool.js +29 -9
  125. package/dist/ui-parts.d.ts +23 -0
  126. package/dist/ui-parts.js +385 -0
  127. package/dist/ui-resolve.d.ts +35 -0
  128. package/dist/ui-resolve.js +42 -0
  129. package/dist/ui-slots.d.ts +65 -0
  130. package/dist/ui-slots.js +261 -0
  131. package/dist/ui.d.ts +221 -77
  132. package/dist/ui.js +104 -27
  133. package/dist/url.d.ts +4 -1
  134. package/dist/url.js +4 -1
  135. package/dist/web.d.ts +26 -20
  136. package/package.json +13 -1
  137. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  138. package/schemas/bootstrap.v1.schema.json +20 -0
  139. package/schemas/connector-template.v1.schema.json +62 -4
  140. package/schemas/plugin.v1.schema.json +93 -143
  141. package/schemas/theme.v1.schema.json +302 -0
  142. package/agent-docs/extension-points/sandbox.md +0 -15
  143. package/dist/org-access.d.ts +0 -27
  144. package/dist/org-access.js +0 -35
  145. package/dist/sandbox.d.ts +0 -254
  146. package/dist/sandbox.js +0 -153
package/dist/index.js CHANGED
@@ -1,33 +1,60 @@
1
- export const SDK_VERSION = "0.1.0-rc.7";
1
+ export const SDK_VERSION = "0.1.0-rc.70";
2
2
  export * from "./agent-template.js";
3
+ export * from "./avatar-presets.js";
3
4
  export * from "./bootstrap.js";
4
5
  export * from "./cards.js";
5
6
  export * from "./channel.js";
7
+ export * from "./client-css.js";
8
+ export * from "./client-section.js";
6
9
  export * from "./config-ui.js";
10
+ export * from "./config-url-fetch.js";
7
11
  export * from "./connector.js";
8
12
  export * from "./connector-auth.js";
13
+ export * from "./context.js";
9
14
  export * from "./ctx.js";
10
15
  export * from "./define-extension.js";
11
- export * from "./device-protocol.js";
16
+ export { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS } from "./device-denied-paths.js";
17
+ export * from "./device-operation.js";
18
+ export * from "./device-provider.js";
19
+ export * from "./device-service.js";
20
+ export * from "./dial-in.js";
12
21
  export * from "./directory.js";
13
22
  export * from "./extension-point.js";
14
23
  export * from "./file-preview.js";
24
+ export * from "./git-hosts.js";
15
25
  export * from "./hooks.js";
26
+ export * from "./http-access.js";
16
27
  export * from "./identity.js";
17
28
  export * from "./marketplace.js";
18
29
  export * from "./model.js";
19
30
  export * from "./model-params.js";
20
- export * from "./org-access.js";
31
+ export * from "./net.js";
32
+ export * from "./network-classes.js";
21
33
  export * from "./permissions.js";
34
+ export * from "./platform-only.js";
22
35
  export * from "./plugin-manifest.js";
23
36
  export * from "./plugin-package.js";
24
- export * from "./sandbox.js";
37
+ export * from "./push.js";
38
+ export { SANDBOX_RUNTIME_SOURCE, } from "./sandbox-runtime-source.js";
39
+ export { isSandboxHomeWriteDenied, isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_HOME_WRITE_DENIES, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, SANDBOX_RESERVED_NAME_PREFIX, SANDBOX_RUNTIME_DIRECTORIES, SANDBOX_SYSTEM_WRITE_DENIES, sandboxRuntimeDirectoryOf, } from "./sandbox-write-denies.js";
25
40
  export * from "./secret.js";
41
+ export * from "./setup-check.js";
26
42
  export * from "./setup-guide.js";
43
+ export { parseSetupGuide, } from "./setup-guide-parse.js";
44
+ export * from "./setup-guide-render.js";
45
+ export * from "./shell-capabilities.js";
46
+ export * from "./shell-environment.js";
27
47
  export * from "./skill.js";
28
48
  export * from "./skill-invocation.js";
29
49
  export * from "./storage.js";
50
+ export * from "./theme.js";
51
+ export * from "./theme-assets.js";
52
+ export * from "./theme-readability.js";
53
+ export * from "./theme-tokens.generated.js";
30
54
  export * from "./tool.js";
31
55
  export * from "./tool-key.js";
32
56
  export * from "./ui.js";
57
+ export * from "./ui-parts.js";
58
+ export * from "./ui-resolve.js";
59
+ export * from "./ui-slots.js";
33
60
  export * from "./web.js";
@@ -1,22 +1,29 @@
1
1
  /**
2
- * `model-provider@2` 的参数声明与校验(纯函数;issue / 错误信息用英文,供日志与 API 返回)。
3
- * 每个模型在 `ModelInfo.parameters` 中声明自己支持的参数,取值约束是受限的 JSON Schema 子集。
2
+ * Parameter declarations and validation for `model-provider@2` (pure functions; issues / error
3
+ * messages are in English, for logs and API responses).
4
+ * Each model declares in `ModelInfo.parameters` the parameters it supports; value constraints are a
5
+ * restricted JSON Schema subset.
4
6
  */
5
7
  export type Effort = "low" | "medium" | "high" | "xhigh" | "max";
6
8
  /**
7
- * 标准旋钮:平台统一语义,界面专门渲染,换模型或兜底时语义可迁移;插件负责映射到原生参数。
8
- * - `effort`:思考深度,`{ type: "string", enum }`,取值是 `low|medium|high|xhigh|max` 的子集;
9
- * - `thinking`:思考模式,`{ type: "string", enum }`,取值是 `off|on|summarized` 的子集;
10
- * - `temperature`:`{ type: "number" }`(可带范围);
11
- * - `maxOutputTokens`:最大输出 token,`{ type: "integer" }`(可带范围)。
9
+ * Standard knobs: uniform platform semantics, rendered specially by the UI, with semantics that
10
+ * carry over when switching models or falling back; the plugin maps them to native parameters.
11
+ * - `effort`: thinking depth, `{ type: "string", enum }`, values a subset of
12
+ * `low|medium|high|xhigh|max`;
13
+ * - `thinking`: thinking mode, `{ type: "string", enum }`, values a subset of `off|on|summarized`;
14
+ * - `temperature`: `{ type: "number" }` (may carry a range);
15
+ * - `maxOutputTokens`: maximum output tokens, `{ type: "integer" }` (may carry a range).
12
16
  */
13
17
  export type StandardKnob = "effort" | "thinking" | "temperature" | "maxOutputTokens";
14
18
  export declare const STANDARD_KNOBS: readonly StandardKnob[];
15
- /** `effort` 旋钮允许的取值全集。 */
19
+ /** The full set of values the `effort` knob allows. */
16
20
  export declare const EFFORT_VALUES: readonly Effort[];
17
- /** `thinking` 旋钮允许的取值全集。 */
21
+ /** The full set of values the `thinking` knob allows. */
18
22
  export declare const THINKING_VALUES: readonly string[];
19
- /** 参数取值约束:受限的 JSON Schema 子集(可序列化后交给界面;内核自行校验,不依赖 ajv)。 */
23
+ /**
24
+ * Parameter value constraints: a restricted JSON Schema subset (serializable for the UI; the kernel
25
+ * validates it itself, without ajv).
26
+ */
20
27
  export type ParamSchema = {
21
28
  type: "string";
22
29
  enum: string[];
@@ -31,14 +38,20 @@ export type ParamSchema = {
31
38
  maximum?: number;
32
39
  };
33
40
  export type ParamValue = string | number | boolean;
34
- /** 模型声明的一个参数。 */
41
+ /** One parameter a model declares. */
35
42
  export interface ModelParameter {
36
- /** 标准旋钮名(见 {@link StandardKnob}),或厂商专有参数 `"<插件名>.<名称>"`。 */
43
+ /**
44
+ * A standard knob name (see {@link StandardKnob}), or a vendor-specific parameter `"<plugin
45
+ * name>.<name>"`.
46
+ */
37
47
  key: string;
38
- /** key 为标准旋钮时必填且必须等于 key;厂商专有参数不得填写。 */
48
+ /**
49
+ * Required when key is a standard knob and must equal key; vendor-specific parameters must not
50
+ * set it.
51
+ */
39
52
  standard?: StandardKnob;
40
53
  schema: ParamSchema;
41
- /** 未设置时使用的值;必须满足 schema。 */
54
+ /** The value used when unset; must satisfy the schema. */
42
55
  default?: ParamValue;
43
56
  label: {
44
57
  zh: string;
@@ -53,11 +66,13 @@ export interface ParamIssue {
53
66
  key: string;
54
67
  message: string;
55
68
  }
56
- /** 值不满足 schema 时返回英文原因,满足时返回 undefined。 */
69
+ /** Returns an English reason when the value does not satisfy the schema, undefined when it does. */
57
70
  export declare function checkParamValue(schema: ParamSchema, v: unknown): string | undefined;
58
71
  /**
59
- * 严格校验(保存 agent 时用):未知键、类型不符、枚举越界、超出范围都算错,逐键报告。
60
- * 成功时 `value` 为传入的参数,不补默认值;值为 undefined 的键视为未设置。
72
+ * Strict validation (used when saving an agent): unknown keys, type mismatches, enum violations and
73
+ * out-of-range values are all errors, reported per key.
74
+ * On success `value` is the input parameters, with no defaults filled in; a key whose value is
75
+ * undefined counts as unset.
61
76
  */
62
77
  export declare function validateParams(decl: ModelParameter[], params: Record<string, unknown>): {
63
78
  ok: true;
@@ -67,16 +82,20 @@ export declare function validateParams(decl: ModelParameter[], params: Record<st
67
82
  issues: ParamIssue[];
68
83
  };
69
84
  /**
70
- * 宽松版(运行时用):丢弃未知或不合法的项(键记入 `dropped`),再为未设置的已声明参数补默认值。
71
- * 用于插件升级后已保存的参数不再合法的情况,不让整轮运行失败。
85
+ * The lenient variant (used at runtime): drops unknown or invalid entries (their keys go into
86
+ * `dropped`), then fills defaults for declared parameters that are unset.
87
+ * For the case where saved parameters are no longer valid after a plugin upgrade, so that the whole
88
+ * run does not fail.
72
89
  */
73
90
  export declare function sanitizeParams(decl: ModelParameter[], params: Record<string, unknown>): {
74
91
  value: Record<string, ParamValue>;
75
92
  dropped: string[];
76
93
  };
77
94
  /**
78
- * 校验插件为一个模型声明的参数:键名是标准旋钮或 `<plugin>.<名称>`、`standard` 与键一致、
79
- * schema 属于受支持的子集、标准旋钮符合取值约定、默认值满足 schema、文案齐全、键不重复。
80
- * 有问题时抛错,信息点名插件与各个键(英文)。
95
+ * Validates the parameters a plugin declares for a model: the key is a standard knob or
96
+ * `<plugin>.<name>`, `standard` agrees with the key,
97
+ * the schema belongs to the supported subset, standard knobs satisfy the value conventions,
98
+ * defaults satisfy the schema, copy is complete, keys do not repeat.
99
+ * Throws when there is a problem, with a message naming the plugin and each key (in English).
81
100
  */
82
101
  export declare function assertValidDeclarations(plugin: string, decl: ModelParameter[]): void;
@@ -1,6 +1,8 @@
1
1
  /**
2
- * `model-provider@2` 的参数声明与校验(纯函数;issue / 错误信息用英文,供日志与 API 返回)。
3
- * 每个模型在 `ModelInfo.parameters` 中声明自己支持的参数,取值约束是受限的 JSON Schema 子集。
2
+ * Parameter declarations and validation for `model-provider@2` (pure functions; issues / error
3
+ * messages are in English, for logs and API responses).
4
+ * Each model declares in `ModelInfo.parameters` the parameters it supports; value constraints are a
5
+ * restricted JSON Schema subset.
4
6
  */
5
7
  export const STANDARD_KNOBS = [
6
8
  "effort",
@@ -8,13 +10,13 @@ export const STANDARD_KNOBS = [
8
10
  "temperature",
9
11
  "maxOutputTokens",
10
12
  ];
11
- /** `effort` 旋钮允许的取值全集。 */
13
+ /** The full set of values the `effort` knob allows. */
12
14
  export const EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
13
- /** `thinking` 旋钮允许的取值全集。 */
15
+ /** The full set of values the `thinking` knob allows. */
14
16
  export const THINKING_VALUES = ["off", "on", "summarized"];
15
17
  const isStandardKnob = (k) => STANDARD_KNOBS.includes(k);
16
18
  const VENDOR_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
17
- /** 值不满足 schema 时返回英文原因,满足时返回 undefined。 */
19
+ /** Returns an English reason when the value does not satisfy the schema, undefined when it does. */
18
20
  export function checkParamValue(schema, v) {
19
21
  switch (schema.type) {
20
22
  case "boolean":
@@ -45,11 +47,16 @@ export function checkParamValue(schema, v) {
45
47
  return `has unsupported schema type ${JSON.stringify(schema.type)}`;
46
48
  }
47
49
  }
48
- /** 按键查声明(用 Map,避免 `constructor` 等原型属性被当成已声明的键)。 */
50
+ /**
51
+ * Looks up a declaration by key (uses a Map so that prototype properties such as `constructor` are
52
+ * not mistaken for declared keys).
53
+ */
49
54
  const declMap = (decl) => new Map(decl.map((d) => [d.key, d]));
50
55
  /**
51
- * 严格校验(保存 agent 时用):未知键、类型不符、枚举越界、超出范围都算错,逐键报告。
52
- * 成功时 `value` 为传入的参数,不补默认值;值为 undefined 的键视为未设置。
56
+ * Strict validation (used when saving an agent): unknown keys, type mismatches, enum violations and
57
+ * out-of-range values are all errors, reported per key.
58
+ * On success `value` is the input parameters, with no defaults filled in; a key whose value is
59
+ * undefined counts as unset.
53
60
  */
54
61
  export function validateParams(decl, params) {
55
62
  const byKey = declMap(decl);
@@ -72,8 +79,10 @@ export function validateParams(decl, params) {
72
79
  return issues.length > 0 ? { ok: false, issues } : { ok: true, value };
73
80
  }
74
81
  /**
75
- * 宽松版(运行时用):丢弃未知或不合法的项(键记入 `dropped`),再为未设置的已声明参数补默认值。
76
- * 用于插件升级后已保存的参数不再合法的情况,不让整轮运行失败。
82
+ * The lenient variant (used at runtime): drops unknown or invalid entries (their keys go into
83
+ * `dropped`), then fills defaults for declared parameters that are unset.
84
+ * For the case where saved parameters are no longer valid after a plugin upgrade, so that the whole
85
+ * run does not fail.
77
86
  */
78
87
  export function sanitizeParams(decl, params) {
79
88
  const byKey = declMap(decl);
@@ -143,7 +152,9 @@ function schemaProblems(schema) {
143
152
  return [`unsupported schema type ${JSON.stringify(s.type)}`];
144
153
  }
145
154
  }
146
- /** 标准旋钮的取值约定(schema 本身已合法时才检查)。 */
155
+ /**
156
+ * The value conventions of standard knobs (checked only when the schema itself is already valid).
157
+ */
147
158
  function knobProblems(key, schema) {
148
159
  const values = schema.type === "string" && "enum" in schema ? schema.enum : undefined;
149
160
  switch (key) {
@@ -178,7 +189,7 @@ function textProblems(d) {
178
189
  }
179
190
  return out;
180
191
  }
181
- /** 一个参数声明的全部问题;无问题返回空数组。 */
192
+ /** All problems of one parameter declaration; an empty array when there are none. */
182
193
  function declarationProblems(plugin, d) {
183
194
  if (typeof d !== "object" || d === null)
184
195
  return ["declaration must be an object"];
@@ -198,9 +209,11 @@ function declarationProblems(plugin, d) {
198
209
  return out;
199
210
  }
200
211
  /**
201
- * 校验插件为一个模型声明的参数:键名是标准旋钮或 `<plugin>.<名称>`、`standard` 与键一致、
202
- * schema 属于受支持的子集、标准旋钮符合取值约定、默认值满足 schema、文案齐全、键不重复。
203
- * 有问题时抛错,信息点名插件与各个键(英文)。
212
+ * Validates the parameters a plugin declares for a model: the key is a standard knob or
213
+ * `<plugin>.<name>`, `standard` agrees with the key,
214
+ * the schema belongs to the supported subset, standard knobs satisfy the value conventions,
215
+ * defaults satisfy the schema, copy is complete, keys do not repeat.
216
+ * Throws when there is a problem, with a message naming the plugin and each key (in English).
204
217
  */
205
218
  export function assertValidDeclarations(plugin, decl) {
206
219
  if (!Array.isArray(decl)) {