@opencow-ai/opencow-agent-sdk 0.4.25 → 0.4.27

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Codex 插件把第三方授权写成「按名引用」的宿主专属字段:`env_vars`、
3
+ * `bearer_token_env_var`、`env_http_headers`、`http_headers`。MCP 协议与本运行时
4
+ * 都不读这些键,`McpServerConfigSchema` 会把它们当未知字段静默丢弃 —— 结果是插件
5
+ * MCP 启动时没有 Authorization / env,请求必然失败。
6
+ *
7
+ * 因此在校验前把它们翻译成运行时真正读取的 `env` / `headers`,值写成 `${VAR}`
8
+ * 引用,交由 `resolvePluginMcpEnvironment` 展开(值来源见 `SdkManagedPlugin.env`)。
9
+ *
10
+ * 与 Host 侧 `src/shared/mcpConfigConvert.ts` 同一语义;Host 的渲染层依赖使它无法
11
+ * 引用 SDK,两份实现必须同步修改。差异:Host 还要把 mcpb/Claude 的占位写法
12
+ * (`${input:…}`、`${user_config.…}`、`${{ secrets.… }}`)改写成待配置变量,
13
+ * 那是无 user-config 通道时的兜底;这里 `${user_config.…}` 由运行时原生支持,
14
+ * 不做改写。
15
+ */
16
+ /**
17
+ * 翻译单个 MCP server 配置(不是 `{ mcpServers: … }` 包装层)。
18
+ * 输入不被修改;非对象输入原样返回。
19
+ */
20
+ export declare function normalizeCodexMcpFields(input: unknown): Record<string, unknown>;
@@ -4,9 +4,12 @@
4
4
  /**
5
5
  * Expand environment variables in a string value
6
6
  * Handles ${VAR} and ${VAR:-default} syntax
7
+ * @param env Lookup source for variable values. Defaults to `process.env`;
8
+ * callers pass a per-plugin overlay so plugin-scoped values (e.g. credentials
9
+ * the host collected for that plugin) win over the ambient process env.
7
10
  * @returns Object with expanded string and list of missing variables
8
11
  */
9
- export declare function expandEnvVarsInString(value: string): {
12
+ export declare function expandEnvVarsInString(value: string, env?: Record<string, string | undefined>): {
10
13
  expanded: string;
11
14
  missingVars: string[];
12
15
  };
@@ -25,6 +25,7 @@ export declare const McpStdioServerConfigSchema: () => z.ZodObject<{
25
25
  command: z.ZodString;
26
26
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
27
27
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
28
+ cwd: z.ZodOptional<z.ZodString>;
28
29
  }, z.core.$strip>;
29
30
  export declare const McpSSEServerConfigSchema: () => z.ZodObject<{
30
31
  type: z.ZodLiteral<"sse">;
@@ -83,6 +84,7 @@ export declare const McpServerConfigSchema: () => z.ZodUnion<readonly [z.ZodObje
83
84
  command: z.ZodString;
84
85
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
85
86
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
87
+ cwd: z.ZodOptional<z.ZodString>;
86
88
  }, z.core.$strip>, z.ZodObject<{
87
89
  type: z.ZodLiteral<"sse">;
88
90
  url: z.ZodString;
@@ -148,6 +150,7 @@ export declare const McpJsonConfigSchema: () => z.ZodObject<{
148
150
  command: z.ZodString;
149
151
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
150
152
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
153
+ cwd: z.ZodOptional<z.ZodString>;
151
154
  }, z.core.$strip>, z.ZodObject<{
152
155
  type: z.ZodLiteral<"sse">;
153
156
  url: z.ZodString;
@@ -21,6 +21,7 @@ export declare function resolvePluginLspEnvironment(config: LspServerConfig, plu
21
21
  path: string;
22
22
  source: string;
23
23
  dataPath?: string;
24
+ env?: Record<string, string>;
24
25
  }, userConfig?: PluginOptionValues, _errors?: PluginError[]): LspServerConfig;
25
26
  /**
26
27
  * Add plugin scope to LSP server configs
@@ -48,6 +48,7 @@ export declare function resolvePluginMcpEnvironment(config: McpServerConfig, plu
48
48
  path: string;
49
49
  source: string;
50
50
  dataPath?: string;
51
+ env?: Record<string, string>;
51
52
  }, userConfig?: UserConfigValues, errors?: PluginError[], pluginName?: string, serverName?: string): McpServerConfig;
52
53
  /**
53
54
  * Get MCP servers from a specific plugin with environment variable resolution and scoping
@@ -86,6 +86,12 @@ export declare function substitutePluginVariables(value: string, plugin: {
86
86
  source?: string;
87
87
  dataPath?: string;
88
88
  }): string;
89
+ /**
90
+ * Substitute host-defined `${NAME}` content variables from the session's
91
+ * managed plugin snapshot. Single pass, so substituted values are never
92
+ * re-expanded; names the host did not define stay literal.
93
+ */
94
+ export declare function substitutePluginContentVariables(value: string, variables?: Readonly<Record<string, string>>): string;
89
95
  /**
90
96
  * Substitute ${user_config.KEY} with saved option values.
91
97
  *
@@ -262,6 +262,7 @@ export declare const PluginManifestSchema: () => z.ZodObject<{
262
262
  command: z.ZodString;
263
263
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
264
264
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
265
+ cwd: z.ZodOptional<z.ZodString>;
265
266
  }, z.core.$strip>, z.ZodObject<{
266
267
  type: z.ZodLiteral<"sse">;
267
268
  url: z.ZodString;
@@ -312,6 +313,7 @@ export declare const PluginManifestSchema: () => z.ZodObject<{
312
313
  command: z.ZodString;
313
314
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
314
315
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
316
+ cwd: z.ZodOptional<z.ZodString>;
315
317
  }, z.core.$strip>, z.ZodObject<{
316
318
  type: z.ZodLiteral<"sse">;
317
319
  url: z.ZodString;
@@ -759,6 +761,7 @@ export declare const PluginMarketplaceEntrySchema: () => z.ZodObject<{
759
761
  command: z.ZodString;
760
762
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
761
763
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
764
+ cwd: z.ZodOptional<z.ZodString>;
762
765
  }, z.core.$strip>, z.ZodObject<{
763
766
  type: z.ZodLiteral<"sse">;
764
767
  url: z.ZodString;
@@ -809,6 +812,7 @@ export declare const PluginMarketplaceEntrySchema: () => z.ZodObject<{
809
812
  command: z.ZodString;
810
813
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
811
814
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
815
+ cwd: z.ZodOptional<z.ZodString>;
812
816
  }, z.core.$strip>, z.ZodObject<{
813
817
  type: z.ZodLiteral<"sse">;
814
818
  url: z.ZodString;
@@ -1147,6 +1151,7 @@ export declare const PluginMarketplaceSchema: () => z.ZodObject<{
1147
1151
  command: z.ZodString;
1148
1152
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
1149
1153
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1154
+ cwd: z.ZodOptional<z.ZodString>;
1150
1155
  }, z.core.$strip>, z.ZodObject<{
1151
1156
  type: z.ZodLiteral<"sse">;
1152
1157
  url: z.ZodString;
@@ -1197,6 +1202,7 @@ export declare const PluginMarketplaceSchema: () => z.ZodObject<{
1197
1202
  command: z.ZodString;
1198
1203
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
1199
1204
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1205
+ cwd: z.ZodOptional<z.ZodString>;
1200
1206
  }, z.core.$strip>, z.ZodObject<{
1201
1207
  type: z.ZodLiteral<"sse">;
1202
1208
  url: z.ZodString;
@@ -15,6 +15,8 @@ export type ExplicitPluginRuntimeBundle = {
15
15
  lspManager: LSPServerManager | null;
16
16
  outputStyles: readonly OutputStyleConfig[];
17
17
  dataPaths: ReadonlyMap<string, string>;
18
+ /** Host-defined content variables from the managed snapshot. */
19
+ contentVariables?: Readonly<Record<string, string>>;
18
20
  state: SdkPluginState;
19
21
  dispose(): Promise<void>;
20
22
  };