@symerian/symi 3.0.18 → 3.0.19

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 (116) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  3. package/package.json +1 -1
  4. package/extensions/copilot-proxy/README.md +0 -24
  5. package/extensions/copilot-proxy/index.ts +0 -154
  6. package/extensions/copilot-proxy/node_modules/.bin/symi +0 -21
  7. package/extensions/copilot-proxy/package.json +0 -15
  8. package/extensions/copilot-proxy/symi.plugin.json +0 -9
  9. package/extensions/device-pair/index.ts +0 -642
  10. package/extensions/device-pair/symi.plugin.json +0 -20
  11. package/extensions/diagnostics-otel/index.ts +0 -15
  12. package/extensions/diagnostics-otel/node_modules/.bin/acorn +0 -21
  13. package/extensions/diagnostics-otel/node_modules/.bin/symi +0 -21
  14. package/extensions/diagnostics-otel/package.json +0 -27
  15. package/extensions/diagnostics-otel/src/service.test.ts +0 -290
  16. package/extensions/diagnostics-otel/src/service.ts +0 -666
  17. package/extensions/diagnostics-otel/symi.plugin.json +0 -8
  18. package/extensions/google-antigravity-auth/README.md +0 -24
  19. package/extensions/google-antigravity-auth/index.ts +0 -424
  20. package/extensions/google-antigravity-auth/node_modules/.bin/symi +0 -21
  21. package/extensions/google-antigravity-auth/package.json +0 -15
  22. package/extensions/google-antigravity-auth/symi.plugin.json +0 -9
  23. package/extensions/google-gemini-cli-auth/README.md +0 -35
  24. package/extensions/google-gemini-cli-auth/index.ts +0 -75
  25. package/extensions/google-gemini-cli-auth/node_modules/.bin/symi +0 -21
  26. package/extensions/google-gemini-cli-auth/oauth.test.ts +0 -162
  27. package/extensions/google-gemini-cli-auth/oauth.ts +0 -636
  28. package/extensions/google-gemini-cli-auth/package.json +0 -15
  29. package/extensions/google-gemini-cli-auth/symi.plugin.json +0 -9
  30. package/extensions/learning-loop/index.ts +0 -159
  31. package/extensions/learning-loop/node_modules/.bin/symi +0 -21
  32. package/extensions/learning-loop/package.json +0 -18
  33. package/extensions/learning-loop/src/analytics/gateway-methods.ts +0 -230
  34. package/extensions/learning-loop/src/analytics/metrics-aggregator.ts +0 -153
  35. package/extensions/learning-loop/src/capture/run-tracker.ts +0 -181
  36. package/extensions/learning-loop/src/capture/serializer.ts +0 -74
  37. package/extensions/learning-loop/src/db.ts +0 -583
  38. package/extensions/learning-loop/src/feedback/explicit-feedback.ts +0 -58
  39. package/extensions/learning-loop/src/feedback/implicit-signals.ts +0 -89
  40. package/extensions/learning-loop/src/graph/edge-inference.ts +0 -189
  41. package/extensions/learning-loop/src/graph/graph-retrieval.ts +0 -144
  42. package/extensions/learning-loop/src/graph/graph-store.ts +0 -183
  43. package/extensions/learning-loop/src/hooks.ts +0 -244
  44. package/extensions/learning-loop/src/injection/cache.ts +0 -73
  45. package/extensions/learning-loop/src/injection/context-injector.ts +0 -104
  46. package/extensions/learning-loop/src/injection/prompt-builder.ts +0 -43
  47. package/extensions/learning-loop/src/learning/embedding-bridge.ts +0 -54
  48. package/extensions/learning-loop/src/learning/learning-extractor.ts +0 -217
  49. package/extensions/learning-loop/src/learning/learning-store.ts +0 -158
  50. package/extensions/learning-loop/src/learning/retrieval.ts +0 -87
  51. package/extensions/learning-loop/src/math/confidence-intervals.ts +0 -62
  52. package/extensions/learning-loop/src/math/ewma.ts +0 -51
  53. package/extensions/learning-loop/src/math/weighted-scorer.ts +0 -42
  54. package/extensions/learning-loop/src/schema.ts +0 -176
  55. package/extensions/learning-loop/src/scoring/normalization.ts +0 -32
  56. package/extensions/learning-loop/src/scoring/quality-engine.ts +0 -78
  57. package/extensions/learning-loop/src/scoring/signal-extractors.ts +0 -155
  58. package/extensions/learning-loop/src/test/context-injector.test.ts +0 -142
  59. package/extensions/learning-loop/src/test/fixes.test.ts +0 -1286
  60. package/extensions/learning-loop/src/test/graph.test.ts +0 -711
  61. package/extensions/learning-loop/src/test/integration.test.ts +0 -312
  62. package/extensions/learning-loop/src/test/learning-store.test.ts +0 -191
  63. package/extensions/learning-loop/src/test/math.test.ts +0 -148
  64. package/extensions/learning-loop/src/test/quality-engine.test.ts +0 -231
  65. package/extensions/learning-loop/src/test/run-tracker.test.ts +0 -143
  66. package/extensions/learning-loop/src/types.ts +0 -281
  67. package/extensions/learning-loop/symi.plugin.json +0 -46
  68. package/extensions/llm-task/README.md +0 -97
  69. package/extensions/llm-task/index.ts +0 -6
  70. package/extensions/llm-task/package.json +0 -12
  71. package/extensions/llm-task/src/llm-task-tool.test.ts +0 -138
  72. package/extensions/llm-task/src/llm-task-tool.ts +0 -249
  73. package/extensions/llm-task/symi.plugin.json +0 -21
  74. package/extensions/memory-lancedb/config.ts +0 -161
  75. package/extensions/memory-lancedb/index.test.ts +0 -330
  76. package/extensions/memory-lancedb/index.ts +0 -670
  77. package/extensions/memory-lancedb/node_modules/.bin/arrow2csv +0 -21
  78. package/extensions/memory-lancedb/node_modules/.bin/openai +0 -21
  79. package/extensions/memory-lancedb/node_modules/.bin/symi +0 -21
  80. package/extensions/memory-lancedb/package.json +0 -20
  81. package/extensions/memory-lancedb/symi.plugin.json +0 -71
  82. package/extensions/minimax-portal-auth/README.md +0 -33
  83. package/extensions/minimax-portal-auth/index.ts +0 -161
  84. package/extensions/minimax-portal-auth/node_modules/.bin/symi +0 -21
  85. package/extensions/minimax-portal-auth/oauth.ts +0 -247
  86. package/extensions/minimax-portal-auth/package.json +0 -15
  87. package/extensions/minimax-portal-auth/symi.plugin.json +0 -9
  88. package/extensions/model-equalizer/index.ts +0 -80
  89. package/extensions/model-equalizer/skills/model-equalizer/SKILL.md +0 -58
  90. package/extensions/model-equalizer/src/detection.ts +0 -62
  91. package/extensions/model-equalizer/src/enhancer.ts +0 -63
  92. package/extensions/model-equalizer/src/test/detection.test.ts +0 -218
  93. package/extensions/model-equalizer/src/test/enhancer.test.ts +0 -137
  94. package/extensions/model-equalizer/src/test/integration.test.ts +0 -185
  95. package/extensions/model-equalizer/src/types.ts +0 -24
  96. package/extensions/model-equalizer/symi.plugin.json +0 -12
  97. package/extensions/phone-control/index.ts +0 -421
  98. package/extensions/phone-control/symi.plugin.json +0 -10
  99. package/extensions/pipeline/README.md +0 -75
  100. package/extensions/pipeline/SKILL.md +0 -97
  101. package/extensions/pipeline/index.ts +0 -18
  102. package/extensions/pipeline/package.json +0 -11
  103. package/extensions/pipeline/src/pipeline-tool.test.ts +0 -345
  104. package/extensions/pipeline/src/pipeline-tool.ts +0 -266
  105. package/extensions/pipeline/src/windows-spawn.test.ts +0 -148
  106. package/extensions/pipeline/src/windows-spawn.ts +0 -193
  107. package/extensions/pipeline/symi.plugin.json +0 -10
  108. package/extensions/qwen-portal-auth/README.md +0 -24
  109. package/extensions/qwen-portal-auth/index.ts +0 -134
  110. package/extensions/qwen-portal-auth/oauth.ts +0 -190
  111. package/extensions/qwen-portal-auth/symi.plugin.json +0 -9
  112. package/extensions/talk-voice/index.ts +0 -150
  113. package/extensions/talk-voice/symi.plugin.json +0 -10
  114. package/extensions/thread-ownership/index.test.ts +0 -180
  115. package/extensions/thread-ownership/index.ts +0 -133
  116. package/extensions/thread-ownership/symi.plugin.json +0 -28
@@ -1,75 +0,0 @@
1
- # Pipeline (plugin)
2
-
3
- Adds the `pipeline` agent tool as an **optional** plugin tool.
4
-
5
- ## What this is
6
-
7
- - Pipeline is a standalone workflow shell (typed JSON-first pipelines + approvals/resume).
8
- - This plugin integrates Pipeline with Symi _without core changes_.
9
-
10
- ## Enable
11
-
12
- Because this tool can trigger side effects (via workflows), it is registered with `optional: true`.
13
-
14
- Enable it in an agent allowlist:
15
-
16
- ```json
17
- {
18
- "agents": {
19
- "list": [
20
- {
21
- "id": "main",
22
- "tools": {
23
- "allow": [
24
- "pipeline" // plugin id (enables all tools from this plugin)
25
- ]
26
- }
27
- }
28
- ]
29
- }
30
- }
31
- ```
32
-
33
- ## Using `symi.invoke` (Pipeline → Symi tools)
34
-
35
- Some pipelines may include a `symi.invoke` step to call back into Symi tools/plugins (for example: `gog` for Google Workspace, `gh` for GitHub, `message.send`, etc.).
36
-
37
- For this to work, the Symi Gateway must expose the tool bridge endpoint and the target tool must be allowed by policy:
38
-
39
- - Symi provides an HTTP endpoint: `POST /tools/invoke`.
40
- - The request is gated by **gateway auth** (e.g. `Authorization: Bearer …` when token auth is enabled).
41
- - The invoked tool is gated by **tool policy** (global + per-agent + provider + group policy). If the tool is not allowed, Symi returns `404 Tool not available`.
42
-
43
- ### Allowlisting recommended
44
-
45
- To avoid letting workflows call arbitrary tools, set a tight allowlist on the agent that will be used by `symi.invoke`.
46
-
47
- Example (allow only a small set of tools):
48
-
49
- ```jsonc
50
- {
51
- "agents": {
52
- "list": [
53
- {
54
- "id": "main",
55
- "tools": {
56
- "allow": ["pipeline", "web_fetch", "web_search", "gog", "gh"],
57
- "deny": ["gateway"],
58
- },
59
- },
60
- ],
61
- },
62
- }
63
- ```
64
-
65
- Notes:
66
-
67
- - If `tools.allow` is omitted or empty, it behaves like "allow everything (except denied)". For a real allowlist, set a **non-empty** `allow`.
68
- - Tool names depend on which plugins you have installed/enabled.
69
-
70
- ## Security
71
-
72
- - Runs the pipeline executable as a local subprocess.
73
- - Does not manage OAuth/tokens.
74
- - Uses timeouts, stdout caps, and strict JSON envelope parsing.
75
- - Ensure the pipeline runtime is available on `PATH` for the gateway process.
@@ -1,97 +0,0 @@
1
- # Pipeline
2
-
3
- Pipeline executes multi-step workflows with approval checkpoints. Use it when:
4
-
5
- - User wants a repeatable automation (triage, monitor, sync)
6
- - Actions need human approval before executing (send, post, delete)
7
- - Multiple tool calls should run as one deterministic operation
8
-
9
- ## When to use Pipeline
10
-
11
- | User intent | Use Pipeline? |
12
- | ------------------------------------------------------ | --------------------------------------------- |
13
- | "Triage my email" | Yes — multi-step, may send replies |
14
- | "Send a message" | No — single action, use message tool directly |
15
- | "Check my email every morning and ask before replying" | Yes — scheduled workflow with approval |
16
- | "What's the weather?" | No — simple query |
17
- | "Monitor this PR and notify me of changes" | Yes — stateful, recurring |
18
-
19
- ## Basic usage
20
-
21
- ### Run a pipeline
22
-
23
- ```json
24
- {
25
- "action": "run",
26
- "pipeline": "gog.gmail.search --query 'newer_than:1d' --max 20 | email.triage"
27
- }
28
- ```
29
-
30
- Returns structured result:
31
-
32
- ```json
33
- {
34
- "protocolVersion": 1,
35
- "ok": true,
36
- "status": "ok",
37
- "output": [{ "summary": {...}, "items": [...] }],
38
- "requiresApproval": null
39
- }
40
- ```
41
-
42
- ### Handle approval
43
-
44
- If the workflow needs approval:
45
-
46
- ```json
47
- {
48
- "status": "needs_approval",
49
- "output": [],
50
- "requiresApproval": {
51
- "prompt": "Send 3 draft replies?",
52
- "items": [...],
53
- "resumeToken": "..."
54
- }
55
- }
56
- ```
57
-
58
- Present the prompt to the user. If they approve:
59
-
60
- ```json
61
- {
62
- "action": "resume",
63
- "token": "<resumeToken>",
64
- "approve": true
65
- }
66
- ```
67
-
68
- ## Example workflows
69
-
70
- ### Email triage
71
-
72
- ```
73
- gog.gmail.search --query 'newer_than:1d' --max 20 | email.triage
74
- ```
75
-
76
- Fetches recent emails, classifies into buckets (needs_reply, needs_action, fyi).
77
-
78
- ### Email triage with approval gate
79
-
80
- ```
81
- gog.gmail.search --query 'newer_than:1d' | email.triage | approve --prompt 'Process these?'
82
- ```
83
-
84
- Same as above, but halts for approval before returning.
85
-
86
- ## Key behaviors
87
-
88
- - **Deterministic**: Same input → same output (no LLM variance in pipeline execution)
89
- - **Approval gates**: `approve` command halts execution, returns token
90
- - **Resumable**: Use `resume` action with token to continue
91
- - **Structured output**: Always returns JSON envelope with `protocolVersion`
92
-
93
- ## Don't use Pipeline for
94
-
95
- - Simple single-action requests (just use the tool directly)
96
- - Queries that need LLM interpretation mid-flow
97
- - One-off tasks that won't be repeated
@@ -1,18 +0,0 @@
1
- import type {
2
- AnyAgentTool,
3
- SymiPluginApi,
4
- SymiPluginToolFactory,
5
- } from "../../src/plugins/types.js";
6
- import { createPipelineTool } from "./src/pipeline-tool.js";
7
-
8
- export default function register(api: SymiPluginApi) {
9
- api.registerTool(
10
- ((ctx) => {
11
- if (ctx.sandboxed) {
12
- return null;
13
- }
14
- return createPipelineTool(api) as AnyAgentTool;
15
- }) as SymiPluginToolFactory,
16
- { optional: true },
17
- );
18
- }
@@ -1,11 +0,0 @@
1
- {
2
- "name": "@symi/pipeline",
3
- "version": "3.0.9",
4
- "description": "Pipeline workflow tool plugin (typed pipelines + resumable approvals)",
5
- "type": "module",
6
- "symi": {
7
- "extensions": [
8
- "./index.ts"
9
- ]
10
- }
11
- }
@@ -1,345 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- import fs from "node:fs/promises";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { PassThrough } from "node:stream";
6
- import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
7
- import type { SymiPluginApi, SymiPluginToolContext } from "../../../src/plugins/types.js";
8
-
9
- const spawnState = vi.hoisted(() => ({
10
- queue: [] as Array<{ stdout: string; stderr?: string; exitCode?: number }>,
11
- spawn: vi.fn(),
12
- }));
13
-
14
- vi.mock("node:child_process", () => ({
15
- spawn: (...args: unknown[]) => spawnState.spawn(...args),
16
- }));
17
-
18
- let createPipelineTool: typeof import("./pipeline-tool.js").createPipelineTool;
19
-
20
- function fakeApi(overrides: Partial<SymiPluginApi> = {}): SymiPluginApi {
21
- return {
22
- id: "pipeline",
23
- name: "pipeline",
24
- source: "test",
25
- config: {},
26
- pluginConfig: {},
27
- // oxlint-disable-next-line typescript/no-explicit-any
28
- runtime: { version: "test" } as any,
29
- logger: { info() {}, warn() {}, error() {}, debug() {} },
30
- registerTool() {},
31
- registerHttpHandler() {},
32
- registerChannel() {},
33
- registerGatewayMethod() {},
34
- registerCli() {},
35
- registerService() {},
36
- registerProvider() {},
37
- registerHook() {},
38
- registerHttpRoute() {},
39
- registerCommand() {},
40
- on() {},
41
- resolvePath: (p) => p,
42
- ...overrides,
43
- };
44
- }
45
-
46
- function fakeCtx(overrides: Partial<SymiPluginToolContext> = {}): SymiPluginToolContext {
47
- return {
48
- config: {},
49
- workspaceDir: "/tmp",
50
- agentDir: "/tmp",
51
- agentId: "main",
52
- sessionKey: "main",
53
- messageChannel: undefined,
54
- agentAccountId: undefined,
55
- sandboxed: false,
56
- ...overrides,
57
- };
58
- }
59
-
60
- function setProcessPlatform(platform: NodeJS.Platform) {
61
- Object.defineProperty(process, "platform", {
62
- value: platform,
63
- configurable: true,
64
- });
65
- }
66
-
67
- describe("pipeline plugin tool", () => {
68
- let tempDir = "";
69
- const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");
70
- const originalPath = process.env.PATH;
71
- const originalPathAlt = process.env.Path;
72
- const originalPathExt = process.env.PATHEXT;
73
- const originalPathExtAlt = process.env.Pathext;
74
-
75
- beforeAll(async () => {
76
- ({ createPipelineTool } = await import("./pipeline-tool.js"));
77
-
78
- tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "symi-pipeline-plugin-"));
79
- });
80
-
81
- afterEach(() => {
82
- if (originalPlatform) {
83
- Object.defineProperty(process, "platform", originalPlatform);
84
- }
85
- if (originalPath === undefined) {
86
- delete process.env.PATH;
87
- } else {
88
- process.env.PATH = originalPath;
89
- }
90
- if (originalPathAlt === undefined) {
91
- delete process.env.Path;
92
- } else {
93
- process.env.Path = originalPathAlt;
94
- }
95
- if (originalPathExt === undefined) {
96
- delete process.env.PATHEXT;
97
- } else {
98
- process.env.PATHEXT = originalPathExt;
99
- }
100
- if (originalPathExtAlt === undefined) {
101
- delete process.env.Pathext;
102
- } else {
103
- process.env.Pathext = originalPathExtAlt;
104
- }
105
- });
106
-
107
- afterAll(async () => {
108
- if (!tempDir) {
109
- return;
110
- }
111
- if (process.platform === "win32") {
112
- await fs.rm(tempDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
113
- } else {
114
- await fs.rm(tempDir, { recursive: true, force: true });
115
- }
116
- });
117
-
118
- beforeEach(() => {
119
- spawnState.queue.length = 0;
120
- spawnState.spawn.mockReset();
121
- spawnState.spawn.mockImplementation(() => {
122
- const next = spawnState.queue.shift() ?? { stdout: "" };
123
- const stdout = new PassThrough();
124
- const stderr = new PassThrough();
125
- const child = new EventEmitter() as EventEmitter & {
126
- stdout: PassThrough;
127
- stderr: PassThrough;
128
- kill: (signal?: string) => boolean;
129
- };
130
- child.stdout = stdout;
131
- child.stderr = stderr;
132
- child.kill = () => true;
133
-
134
- setImmediate(() => {
135
- if (next.stderr) {
136
- stderr.end(next.stderr);
137
- } else {
138
- stderr.end();
139
- }
140
- stdout.end(next.stdout);
141
- child.emit("exit", next.exitCode ?? 0);
142
- });
143
-
144
- return child;
145
- });
146
- });
147
-
148
- const queueSuccessfulEnvelope = (hello = "world") => {
149
- spawnState.queue.push({
150
- stdout: JSON.stringify({
151
- ok: true,
152
- status: "ok",
153
- output: [{ hello }],
154
- requiresApproval: null,
155
- }),
156
- });
157
- };
158
-
159
- const createWindowsShimFixture = async (params: {
160
- shimPath: string;
161
- scriptPath: string;
162
- scriptToken: string;
163
- }) => {
164
- await fs.mkdir(path.dirname(params.scriptPath), { recursive: true });
165
- await fs.mkdir(path.dirname(params.shimPath), { recursive: true });
166
- await fs.writeFile(params.scriptPath, "module.exports = {};\n", "utf8");
167
- await fs.writeFile(params.shimPath, `@echo off\r\n"${params.scriptToken}" %*\r\n`, "utf8");
168
- };
169
-
170
- it("runs pipeline and returns parsed envelope in details", async () => {
171
- spawnState.queue.push({
172
- stdout: JSON.stringify({
173
- ok: true,
174
- status: "ok",
175
- output: [{ hello: "world" }],
176
- requiresApproval: null,
177
- }),
178
- });
179
-
180
- const tool = createPipelineTool(fakeApi());
181
- const res = await tool.execute("call1", {
182
- action: "run",
183
- pipeline: "noop",
184
- timeoutMs: 1000,
185
- });
186
-
187
- expect(spawnState.spawn).toHaveBeenCalled();
188
- expect(res.details).toMatchObject({ ok: true, status: "ok" });
189
- });
190
-
191
- it("tolerates noisy stdout before the JSON envelope", async () => {
192
- const payload = { ok: true, status: "ok", output: [], requiresApproval: null };
193
- spawnState.queue.push({
194
- stdout: `noise before json\n${JSON.stringify(payload)}`,
195
- });
196
-
197
- const tool = createPipelineTool(fakeApi());
198
- const res = await tool.execute("call-noisy", {
199
- action: "run",
200
- pipeline: "noop",
201
- timeoutMs: 1000,
202
- });
203
-
204
- expect(res.details).toMatchObject({ ok: true, status: "ok" });
205
- });
206
-
207
- it("requires action", async () => {
208
- const tool = createPipelineTool(fakeApi());
209
- await expect(tool.execute("call-action-missing", {})).rejects.toThrow(/action required/);
210
- });
211
-
212
- it("requires pipeline for run action", async () => {
213
- const tool = createPipelineTool(fakeApi());
214
- await expect(
215
- tool.execute("call-pipeline-missing", {
216
- action: "run",
217
- }),
218
- ).rejects.toThrow(/pipeline required/);
219
- });
220
-
221
- it("requires token and approve for resume action", async () => {
222
- const tool = createPipelineTool(fakeApi());
223
- await expect(
224
- tool.execute("call-resume-token-missing", {
225
- action: "resume",
226
- approve: true,
227
- }),
228
- ).rejects.toThrow(/token required/);
229
- await expect(
230
- tool.execute("call-resume-approve-missing", {
231
- action: "resume",
232
- token: "resume-token",
233
- }),
234
- ).rejects.toThrow(/approve required/);
235
- });
236
-
237
- it("rejects unknown action", async () => {
238
- const tool = createPipelineTool(fakeApi());
239
- await expect(
240
- tool.execute("call-action-unknown", {
241
- action: "explode",
242
- }),
243
- ).rejects.toThrow(/Unknown action/);
244
- });
245
-
246
- it("rejects absolute cwd", async () => {
247
- const tool = createPipelineTool(fakeApi());
248
- await expect(
249
- tool.execute("call2c", {
250
- action: "run",
251
- pipeline: "noop",
252
- cwd: "/tmp",
253
- }),
254
- ).rejects.toThrow(/cwd must be a relative path/);
255
- });
256
-
257
- it("rejects cwd that escapes the gateway working directory", async () => {
258
- const tool = createPipelineTool(fakeApi());
259
- await expect(
260
- tool.execute("call2d", {
261
- action: "run",
262
- pipeline: "noop",
263
- cwd: "../../etc",
264
- }),
265
- ).rejects.toThrow(/must stay within/);
266
- });
267
-
268
- it("rejects invalid JSON from pipeline", async () => {
269
- spawnState.queue.push({ stdout: "nope" });
270
-
271
- const tool = createPipelineTool(fakeApi());
272
- await expect(
273
- tool.execute("call3", {
274
- action: "run",
275
- pipeline: "noop",
276
- }),
277
- ).rejects.toThrow(/invalid JSON/);
278
- });
279
-
280
- it("runs Windows cmd shims through Node without enabling shell", async () => {
281
- setProcessPlatform("win32");
282
- const shimScriptPath = path.join(tempDir, "shim-dist", "lobster-cli.cjs");
283
- const shimPath = path.join(tempDir, "shim-bin", "lobster.cmd");
284
- await createWindowsShimFixture({
285
- shimPath,
286
- scriptPath: shimScriptPath,
287
- scriptToken: "%dp0%\\..\\shim-dist\\lobster-cli.cjs",
288
- });
289
- process.env.PATHEXT = ".CMD;.EXE";
290
- process.env.PATH = `${path.dirname(shimPath)};${process.env.PATH ?? ""}`;
291
- queueSuccessfulEnvelope();
292
-
293
- const tool = createPipelineTool(fakeApi());
294
- await tool.execute("call-win-shim", {
295
- action: "run",
296
- pipeline: "noop",
297
- });
298
-
299
- const [command, argv, options] = spawnState.spawn.mock.calls[0] ?? [];
300
- expect(command).toBe(process.execPath);
301
- expect(argv).toEqual([shimScriptPath, "run", "--mode", "tool", "noop"]);
302
- expect(options).toMatchObject({ windowsHide: true });
303
- expect(options).not.toHaveProperty("shell");
304
- });
305
-
306
- it("does not retry a failed Windows spawn with shell fallback", async () => {
307
- setProcessPlatform("win32");
308
- spawnState.spawn.mockReset();
309
- spawnState.spawn.mockImplementationOnce(() => {
310
- const child = new EventEmitter() as EventEmitter & {
311
- stdout: PassThrough;
312
- stderr: PassThrough;
313
- kill: (signal?: string) => boolean;
314
- };
315
- child.stdout = new PassThrough();
316
- child.stderr = new PassThrough();
317
- child.kill = () => true;
318
- const err = Object.assign(new Error("spawn failed"), { code: "ENOENT" });
319
- setImmediate(() => child.emit("error", err));
320
- return child;
321
- });
322
-
323
- const tool = createPipelineTool(fakeApi());
324
- await expect(
325
- tool.execute("call-win-no-retry", {
326
- action: "run",
327
- pipeline: "noop",
328
- }),
329
- ).rejects.toThrow(/spawn failed/);
330
- expect(spawnState.spawn).toHaveBeenCalledTimes(1);
331
- });
332
-
333
- it("can be gated off in sandboxed contexts", async () => {
334
- const api = fakeApi();
335
- const factoryTool = (ctx: SymiPluginToolContext) => {
336
- if (ctx.sandboxed) {
337
- return null;
338
- }
339
- return createPipelineTool(api);
340
- };
341
-
342
- expect(factoryTool(fakeCtx({ sandboxed: true }))).toBeNull();
343
- expect(factoryTool(fakeCtx({ sandboxed: false }))?.name).toBe("pipeline");
344
- });
345
- });