@ycodium-ai/plugin-api 0.2.4343 → 0.2.4368

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/README.md CHANGED
@@ -9,11 +9,12 @@ own state across restarts.
9
9
  ## Install
10
10
 
11
11
  ```
12
- npm install --save-dev @ycodium-ai/plugin-api
12
+ npm install --save-dev @ycodium-ai/plugin-api esbuild
13
13
  ```
14
14
 
15
15
  Types are erased at build time. Runtime exports such as `definePlugin` come from the
16
- Ycodium host's shared copy; keep this package external when bundling your plugin.
16
+ Ycodium host's shared copy; keep this package external when bundling your plugin, except
17
+ `@ycodium-ai/plugin-api/version`, which must be inlined.
17
18
 
18
19
  The CSS subpath `@ycodium-ai/plugin-api/ui.css` is the public Tailwind preset for
19
20
  plugin pages: control-axis utilities, semantic colors, status animations, and
@@ -58,10 +59,11 @@ And export the definition:
58
59
 
59
60
  ```ts
60
61
  import { definePlugin } from "@ycodium-ai/plugin-api";
62
+ import { PLUGIN_API_VERSION } from "@ycodium-ai/plugin-api/version";
61
63
 
62
64
  export default definePlugin({
63
65
  id: "my-plugin",
64
- apiVersion: 109,
66
+ apiVersion: PLUGIN_API_VERSION,
65
67
  activate: (ctx) => {
66
68
  ctx.log.info("hello");
67
69
 
@@ -90,15 +92,38 @@ ycodium plugin add my-ycodium-plugin
90
92
  ## Bundle your entry file
91
93
 
92
94
  Bundle your own code and private dependencies into an ESM entry. Keep
93
- `@ycodium-ai/plugin-api` and its subpaths external. For esbuild:
95
+ `@ycodium-ai/plugin-api` and its subpaths external, except `@ycodium-ai/plugin-api/version`.
96
+ That one subpath must be bundled so the published file carries the API version of the package
97
+ you built against. Esbuild's `--external:<package>` also matches subpaths, so the CLI cannot exempt
98
+ `/version`; use `onResolve` in `build.mjs` instead:
94
99
 
95
100
  ```js
96
- external: ["@ycodium-ai/plugin-api", "@ycodium-ai/plugin-api/*"];
101
+ import { build } from "esbuild";
102
+
103
+ const versionModule = "@ycodium-ai/plugin-api/version";
104
+ await build({
105
+ entryPoints: ["src/index.ts"],
106
+ outfile: "dist/index.js",
107
+ bundle: true,
108
+ format: "esm",
109
+ platform: "node",
110
+ plugins: [
111
+ {
112
+ name: "ycodium-host-api",
113
+ setup(build) {
114
+ build.onResolve({ filter: /^@ycodium-ai\/plugin-api(?:\/.*)?$/ }, (args) =>
115
+ args.path === versionModule ? undefined : { path: args.path, external: true },
116
+ );
117
+ },
118
+ },
119
+ ],
120
+ });
97
121
  ```
98
122
 
99
- The host resolves these imports to its shared API module, including for bundled official
123
+ The host resolves the other imports to its shared API module, including for bundled official
100
124
  plugins, npm installations, local directories, and temporary plugins. Plugins do not need
101
125
  to copy the API into their package or depend on a particular installation directory.
126
+ The host refuses to resolve `@ycodium-ai/plugin-api/version` at runtime.
102
127
 
103
128
  Browser bundles use the same rule. Map runtime API imports to the host's module table,
104
129
  `window.__ycodiumPluginHost.modules`, as you map React to the host's React instance.
@@ -212,6 +237,19 @@ plugin depends on it.
212
237
 
213
238
  ## Permissions
214
239
 
240
+ Both `ctx.process` and executor `host.process.spawn` accept bare program names or absolute paths.
241
+ Exact lowercase `node` / `python` select Ycodium's managed runtime and its required environment; a missing
242
+ runtime fails without falling back to PATH. Other bare names, including `Node`, `node.exe` and `python3`,
243
+ use the machine's PATH. Windows resolution accepts executable extensions and ignores filename case.
244
+ Relative paths containing either separator are rejected. For a packaged executable, pass
245
+ `path.join(ctx.paths.pluginDir, "bin/helper")`; for downloaded programs, build from `ctx.paths.dataDir`.
246
+
247
+ Ordinary plugins declare `process.spawn.programs` as bare names, `./` paths inside the plugin,
248
+ `data:<relative path>`, or `config:<key>`. These prefixes describe allowed locations; calls pass the absolute
249
+ path or a declared `{ key }`. Bare names match verbatim, paths match normalized declaration paths.
250
+ `host:*` aliases are unsupported in declarations and calls. Executor plugins retain their existing
251
+ executor permission boundary. All resolution runs on the plugin's machine, including remote connections.
252
+
215
253
  `ctx.process.spawn` accepts `jobPolicy: "strict" | "allowExplicitBreakaway" | "none"`
216
254
  (Windows only, default `strict`). Explicit breakaway retains Job ownership for ordinary
217
255
  descendants and permits only children created with `CREATE_BREAKAWAY_FROM_JOB` to leave;
@@ -248,13 +286,14 @@ is refused with `reason: "undeclared"`.
248
286
  | `communication.read` | Read the messages exchanged in projects, including their text |
249
287
  | `memory.read` | Read and search project memory, including earlier versions |
250
288
 
251
- The wording the user sees for each is in `packages/shared/src/pluginPermissionLabel.ts`; the schema is
252
- `packages/contracts/src/pluginPermissions.ts`.
289
+ The installation review explains each permission before the user accepts it. Declare only the
290
+ capabilities your plugin uses; the public TypeScript declarations define each request's shape.
253
291
 
254
292
  ## Shaping the model's turn
255
293
 
256
- Four permissions let a plugin act on the agent's turn rather than beside it. Types are in
257
- `@ycodium-ai/plugin-api` (`capabilityPorts.ts`); `plugins/pentest` uses all four.
294
+ Four permissions let a plugin act on the agent's turn rather than beside it. Their types are
295
+ exported from `@ycodium-ai/plugin-api`; the user documentation's prompt and guard guide walks
296
+ through all four.
258
297
 
259
298
  - **`ctx.systemPrompt.section({ id, text, whenPresetId? })`** and **`ctx.systemPrompt.context(fn)`**
260
299
  (`systemPrompt`). The host composes every plugin's sections and per-turn contexts into one block
@@ -334,6 +373,19 @@ npm search keywords:ycodium-plugin
334
373
  Ycodium's plugin settings search the same way, so a published package with that keyword
335
374
  shows up there without anyone registering it.
336
375
 
376
+ ## Executor program paths
377
+
378
+ An executor card can let the host find its CLI by declaring a bare `commandName` and a
379
+ `configSchema` property with `control: "executable-path"`. The property key is up to the plugin.
380
+ Its value must be a non-empty absolute path on the target machine. Adding a provider detects the
381
+ command on that machine and fills the first such field in form order; installing from the add
382
+ dialog fills that same field after a successful installation. A card without this control gets no
383
+ automatic detection or post-install fill. On the edit form, each executable-path field's lookup
384
+ button writes back to that field.
385
+
386
+ Install-and-add also needs an executable installation declaration: `install: { kind: "npm" }` with
387
+ `npmPackage`, or a `vendorScript` installation. A download page alone does not provide it.
388
+
337
389
  ## Auxiliary executor operations
338
390
 
339
391
  Forward the host's abort signal through every auxiliary operation, including
@@ -391,24 +443,90 @@ try {
391
443
  }
392
444
  ```
393
445
 
446
+ ## Reporting a failure
447
+
448
+ Report each failure once. A turn that fails ends with a failed `turn.completed`; its `errorMessage`
449
+ is what the user reads. Emit `runtime.error` for a failure that is not part of a turn. Its payload is
450
+ `ExecutorRuntimeErrorPayload`, typed on `ExecutorEventOf<"runtime.error">`:
451
+
452
+ ```ts
453
+ import type { ExecutorEventOf } from "@ycodium-ai/plugin-api/executor";
454
+ import { lastStderrLines, redactStderrExcerpt } from "@ycodium-ai/plugin-api/process-stdin";
455
+
456
+ const event: ExecutorEventOf<"runtime.error"> = {
457
+ eventId,
458
+ provider: "myAgent",
459
+ threadId,
460
+ createdAt: new Date().toISOString(),
461
+ type: "runtime.error",
462
+ payload: {
463
+ // Required: one English sentence for the user, the reason first.
464
+ message: `My agent could not load its config.\n${lastStderrLines(redactStderrExcerpt(stderrTail), 800)}`,
465
+ // Optional: only when you know which kind of failure it is.
466
+ failureCategory: "auth",
467
+ // Optional: kept for logs and diagnostics, never shown.
468
+ detail: { configPath },
469
+ },
470
+ };
471
+ ```
472
+
473
+ - `message` is the session's failure text, the timeline's error row, and the `detail` of
474
+ `thread.failed`. The timeline row keeps the first 180 characters, so put the reason first. Pass any
475
+ child-process output through `redactStderrExcerpt` first; `lastStderrLines` keeps its last lines
476
+ within a length: whole lines when they fit, and a single over-long line is cut without splitting a
477
+ surrogate pair or a redaction marker.
478
+ - `failureCategory` chooses the explanation and next step the user sees. Leave it off when you are
479
+ not sure; never derive it from message text. `process-exit` means your agent process exited after
480
+ the session was established; `transport` means the network path to the provider broke. Only
481
+ `transport` tells the user to check network and proxy settings.
482
+ - `thread.failed` fires once per failure: after it fires, the host fires it again only once the
483
+ session has left the failed state, a new turn was requested, or a queued message started being
484
+ sent. If you emit `runtime.error` and
485
+ also fail the turn, the session keeps the later message while `thread.failed` carries the first.
486
+
487
+ Plugins built on `ycodium-acp-executor` get this for agent exits: pass the spawn handle's `exited`
488
+ and `stderrTail` to `createAcpExecutor`, and a mid-turn exit fails the turn with `process-exit`, the
489
+ exit code and the end of the agent's stderr. Do not add your own `runtime.error` for it.
490
+
394
491
  ## THERE WILL BE COMPATIBILITY-BREAKING CHANGES
395
492
 
396
493
  The definition's `apiVersion` is checked against a closed window: the host loads every version from
397
- its minimum through its current one, and refuses every other value. Declare the version your plugin
398
- targets as a literal; do not read the host's `PLUGIN_API_VERSION` to make the declaration
399
- automatically match. Declare the oldest version that has everything your plugin uses: a newer
400
- declaration narrows which Ycodium can load it. The examples here declare the window minimum. Ycodium's own plugins have the literal written by their build instead: they
401
- import `PLUGIN_API_VERSION` from `@ycodium-ai/plugin-api/version` and bundle that one subpath, so the
402
- published file still carries the version it was built for. If you do the same, that subpath must be
403
- bundled, never left external. Plugins targeting an API older than the window are refused before
404
- activation; the message names the version the plugin declared and the versions this Ycodium loads,
405
- and the plugin card offers an update. A plugin that declares a version newer than the window is
406
- refused until Ycodium itself is updated, with no update button. There is no compatibility layer:
407
- update against the new types and republish.
494
+ its minimum through its current one, and refuses every other value. A published plugin declares the
495
+ version it was built against as a literal in its bundle; it must not read the host's constant at
496
+ runtime and automatically match every host. Import `PLUGIN_API_VERSION` from
497
+ `@ycodium-ai/plugin-api/version` and bundle that one subpath. This declares the current version of
498
+ the interface package you installed, not an inferred minimum. To support an older host, install its
499
+ interface package, check the APIs you use, and rebuild. A newer declaration narrows which Ycodium
500
+ can load the plugin.
501
+
502
+ Unbundled local directories and selfdev single-file definitions instead declare the oldest API
503
+ version they need as a literal. Do not read the host's constant: after a breaking upgrade, that could
504
+ let old code pass as if it were new. The examples declare the window minimum, maintained by the
505
+ version generator. In a selfdev session, `ycodium_inspect` section `api`, topic `shape`, names the
506
+ window this host accepts. Install and load errors also name the declared version and the accepted
507
+ range.
508
+
509
+ Plugins targeting an API older than the window are refused before activation; the message names the
510
+ version the plugin declared and the versions this Ycodium loads, and the plugin card offers an
511
+ update. A plugin that declares a version newer than the window is refused until Ycodium itself is
512
+ updated, with no update button. There is no compatibility layer: update against the new types and
513
+ republish.
408
514
 
409
515
  <!-- plugin-api-versions:start (generated by scripts/gen-plugin-api-version.ts from packages/plugin-api/version-history.json; edit that file) -->
410
516
 
411
- The current API is **109**. This Ycodium loads only plugins declaring 109.
517
+ The current API is **112**. This Ycodium loads plugins declaring 111 through 112.
518
+
519
+ API 112 adds optional requestSummary to member runtime reports
520
+
521
+ API 111 adds the machine action `runtime.diagnostics` and its optional `minutes` input to the machine task data ports, so a plugin can ask a machine to collect its recent server log and connection status
522
+
523
+ API 111 uses managed Node and Python for exact `node` / `python` program names in both plugin process APIs, including their required environment; rejects relative program arguments and removes `host:*` aliases. Keep `./`, `data:` and `config:` in permission declarations, and pass absolute paths when launching packaged programs.
524
+
525
+ API 110 adds the `process-exit` failure category (the agent process exited after the session was established; `transport` now means only the network channel to the provider) and types the `runtime.error` payload as `ExecutorRuntimeErrorPayload`: one user-facing sentence in `message`, optional `failureCategory`, `detail` and `class`. Adds `lastStderrLines(redacted, maxChars)` to `@ycodium-ai/plugin-api/process-stdin` for putting the end of a redacted stderr excerpt into such a message: it starts at a whole line when one fits, and a single over-long line is cut without splitting a surrogate pair or a redaction marker.
526
+
527
+ API 110 fires `thread.failed` once per failure: when an executor both emits `runtime.error` and fails the turn, the session is set to error twice but plugins get one `thread.failed`, carrying the first report's words. It fires again once a new attempt starts: the session left the error state, a new turn was requested, or a queued message started sending.
528
+
529
+ API 110 adds the optional accepted plugin API version range to machineSettings.config.get.
412
530
 
413
531
  API 109 gives general system notifications an optional `sourceThreadId`. Parsed notifications form a discriminated union: child kinds guarantee `childThreadId`, while general kinds can omit it. Plugins can narrow by kind before opening a child thread.
414
532
 
@@ -570,6 +570,10 @@ type Objects_83 = {
570
570
  readonly "otlpLogsUrl": string;
571
571
  readonly "fullTraceUntil"?: number;
572
572
  };
573
+ type PluginApiVersionRange = {
574
+ readonly "min": number;
575
+ readonly "max": number;
576
+ };
573
577
  type Arrays_15 = ReadonlyArray<"desktop-bootstrap" | "one-time-token">;
574
578
  type Arrays_16 = ReadonlyArray<"browser-session-cookie" | "bearer-access-token" | "dpop-access-token">;
575
579
  type Arrays_17 = ReadonlyArray<{
@@ -930,6 +934,7 @@ type Objects_167 = {
930
934
  readonly "memberId": string;
931
935
  readonly "status": "needs-approval" | "needs-input" | "plan-ready" | "running" | "failed" | "background" | "stopped" | "idle";
932
936
  readonly "lastAction"?: string;
937
+ readonly "requestSummary"?: string;
933
938
  readonly "threadId": string;
934
939
  readonly "environmentId": string;
935
940
  readonly "online": boolean;
@@ -1223,7 +1228,7 @@ type AccountMachineDiscoveryStatus = {
1223
1228
  };
1224
1229
  type Objects_12 = {
1225
1230
  readonly "actionId": string;
1226
- readonly "kind": "install" | "detect" | "sign-in" | "update" | "uninstall" | "health-check" | "restart" | "upgrade" | "command" | "project-task";
1231
+ readonly "kind": "install" | "detect" | "sign-in" | "update" | "uninstall" | "health-check" | "restart" | "upgrade" | "command" | "diagnostics" | "project-task";
1227
1232
  readonly "driver"?: string;
1228
1233
  readonly "displayName"?: string;
1229
1234
  readonly "description"?: string;
@@ -1238,6 +1243,7 @@ type Objects_145 = {
1238
1243
  readonly "args"?: Arrays_2;
1239
1244
  readonly "cwd"?: string;
1240
1245
  readonly "timeoutSeconds"?: number;
1246
+ readonly "minutes"?: number;
1241
1247
  };
1242
1248
  type Arrays_4 = ReadonlyArray<Objects_19>;
1243
1249
  type Arrays_5 = ReadonlyArray<Objects_19>;
@@ -1278,7 +1284,7 @@ type Objects_30 = {
1278
1284
  readonly "nativeModeId"?: string | undefined;
1279
1285
  readonly "activeTurnId": string | null;
1280
1286
  readonly "lastError": string | null;
1281
- readonly "failureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown" | undefined;
1287
+ readonly "failureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown" | "process-exit" | undefined;
1282
1288
  readonly "retry"?: Union_14;
1283
1289
  readonly "endReason"?: "server-restart" | undefined;
1284
1290
  readonly "updatedAt": string;
@@ -2283,7 +2289,7 @@ type Objects_16 = {
2283
2289
  readonly "interactionMode": "default" | "plan";
2284
2290
  readonly "modelSelection": Objects_18;
2285
2291
  readonly "sessionStatus": "idle" | "starting" | "running" | "ready" | "interrupted" | "stopped" | "error" | null;
2286
- readonly "sessionFailureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown";
2292
+ readonly "sessionFailureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown" | "process-exit";
2287
2293
  readonly "latestTurnState": "running" | "interrupted" | "completed" | "error" | null;
2288
2294
  readonly "status": "needs-approval" | "needs-input" | "plan-ready" | "running" | "failed" | "background" | "stopped" | "idle";
2289
2295
  readonly "worktreePath"?: string | null;
@@ -3055,6 +3061,7 @@ export type MachineSettingsMachineTasksApproveInput = {
3055
3061
  readonly "args"?: Arrays_2;
3056
3062
  readonly "cwd"?: string;
3057
3063
  readonly "timeoutSeconds"?: number;
3064
+ readonly "minutes"?: number;
3058
3065
  };
3059
3066
  readonly "rememberProject"?: boolean;
3060
3067
  };
@@ -3715,7 +3722,7 @@ export type ThreadsExecutionGetOutput = {
3715
3722
  readonly "lastError": string | null;
3716
3723
  readonly "updatedAt": string;
3717
3724
  readonly "endReason"?: "server-restart";
3718
- readonly "failureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown";
3725
+ readonly "failureCategory"?: "quota" | "rate-limit" | "context-limit" | "auth" | "model-unavailable" | "transport" | "unknown" | "process-exit";
3719
3726
  readonly "status": string;
3720
3727
  readonly "providerInstanceId": string | null;
3721
3728
  } | null;
@@ -4556,6 +4563,7 @@ export type MachineSettingsGetInput = {};
4556
4563
  export type MachineSettingsGetOutput = Objects_73;
4557
4564
  export type MachineSettingsConfigGetInput = {};
4558
4565
  export type MachineSettingsConfigGetOutput = {
4566
+ readonly "pluginApiVersionRange"?: PluginApiVersionRange;
4559
4567
  readonly "environment": {
4560
4568
  readonly "environmentId": string;
4561
4569
  readonly "label": string;
@@ -5295,7 +5303,7 @@ export type PluginsNotificationsListOutput = {
5295
5303
  readonly "pluginId"?: string | undefined;
5296
5304
  readonly "fallbackName"?: string | undefined;
5297
5305
  readonly "failure": {
5298
- readonly "kind": "npmTooOld" | "npmMissing" | "gitMissing" | "fileLocked" | "accessDenied" | "fsUnavailable" | "network" | "registryAuth" | "packageNotFound" | "buildScript" | "activation" | "missingDisplayName" | "plugin";
5306
+ readonly "kind": "npmTooOld" | "npmMissing" | "gitMissing" | "fileLocked" | "accessDenied" | "fsUnavailable" | "network" | "registryAuth" | "packageNotFound" | "buildScript" | "activation" | "missingDisplayName" | "unsupportedProcessProgram" | "plugin";
5299
5307
  readonly "summary": string;
5300
5308
  };
5301
5309
  }>;
@@ -6026,6 +6034,7 @@ export type WorkRemoteAgentPendingGetOutput = {
6026
6034
  readonly "args"?: Arrays_2;
6027
6035
  readonly "cwd"?: string;
6028
6036
  readonly "timeoutSeconds"?: number;
6037
+ readonly "minutes"?: number;
6029
6038
  };
6030
6039
  readonly "status": "queued" | "running";
6031
6040
  readonly "autoApproved"?: true;
@@ -6736,6 +6745,7 @@ export type WorkMachineTasksCreateInput = {
6736
6745
  readonly "args"?: Arrays_2;
6737
6746
  readonly "cwd"?: string;
6738
6747
  readonly "timeoutSeconds"?: number;
6748
+ readonly "minutes"?: number;
6739
6749
  };
6740
6750
  readonly "title"?: string;
6741
6751
  readonly "approval"?: string;
@@ -7475,7 +7485,7 @@ export type ProjectsMachinesListEncodedOutput = {
7475
7485
  readonly "wireProtocolVersion"?: number;
7476
7486
  readonly "actions"?: ReadonlyArray<{
7477
7487
  readonly "actionId": string;
7478
- readonly "kind": "install" | "detect" | "sign-in" | "update" | "uninstall" | "health-check" | "restart" | "upgrade" | "command" | "project-task";
7488
+ readonly "kind": "install" | "detect" | "sign-in" | "update" | "uninstall" | "health-check" | "restart" | "upgrade" | "command" | "diagnostics" | "project-task";
7479
7489
  readonly "driver"?: string;
7480
7490
  readonly "displayName"?: string;
7481
7491
  readonly "description"?: string;
@@ -8266,6 +8276,7 @@ export type MachineSettingsGetEncodedOutput = {
8266
8276
  readonly "observability": Objects_83;
8267
8277
  };
8268
8278
  export type MachineSettingsConfigGetEncodedOutput = {
8279
+ readonly "pluginApiVersionRange"?: PluginApiVersionRange;
8269
8280
  readonly "environment": {
8270
8281
  readonly "environmentId": string;
8271
8282
  readonly "label": string;