Commit Graph

1866 Commits

Author SHA1 Message Date
Alex Knight
4407df6c03 perf(plugin-sdk): per-phase + per-jiti-call probes for bundled channel entries (#69537)
* perf(plugin-sdk): per-phase + per-jiti-call probes for bundled channel entries

Extends the existing OPENCLAW_PLUGIN_LOAD_PROFILE infrastructure (see
src/plugins/loader.ts `profilePluginLoaderSync` and src/plugins/source-loader.ts)
with two new probe sites inside src/plugin-sdk/channel-entry-contract.ts:

1. `bundled-register:<phase>` — wraps each phase of `defineBundledChannelEntry`'s
   register() callback (`setChannelRuntime`, `loadChannelPlugin`, `registerChannel`,
   `registerCliMetadata`, `registerFull`). Lets us pinpoint which phase of plugin
   registration is responsible for cold-start cost on a per-plugin basis.

2. `bundled-entry-module-load` — instruments `loadBundledEntryModuleSync` and
   reports `getJitiMs` (jiti loader factory) vs `jitiCallMs` (actual graph walk
   + transpile + ESM linking) separately. Lets us distinguish alias-map / loader
   setup overhead from import-graph traversal cost on a per-module basis.

Both probes are gated on OPENCLAW_PLUGIN_LOAD_PROFILE=1 and have zero overhead
when the env flag is unset (early return before any `performance.now()` call).
Log format matches the existing `[plugin-load-profile]` line shape so existing
log scrapers continue to work.

The helper is a file-local mirror of `profilePluginLoaderSync` rather than a
new SDK export — keeps the SDK boundary narrow per src/plugin-sdk/AGENTS.md
and avoids cross-importing host internals.

Used to validate PR #69317 (slack startup perf) — measurements showed slack
`setChannelRuntime` dropping from 13183ms to 67ms after barrel narrowing,
which would have been undiagnosable without these per-phase probes.

* perf(plugins): per-plugin register() probe in plugin loader

Adds a `phase=${registrationMode}:register` probe wrapping each call to
`runPluginRegisterSync(register, api)` in src/plugins/loader.ts. Emits the
established `[plugin-load-profile]` line shape via `profilePluginLoaderSync`,
gated on OPENCLAW_PLUGIN_LOAD_PROFILE=1.

Two call sites are wrapped:
- The main load path (registrationMode is dynamic: "snapshot", "validate",
  "full") at the post-snapshot register block. Emits e.g.
  `phase=full:register plugin=slack elapsedMs=14102.1 source=...`
- The cli-metadata-only path (registrationMode hardcoded to "cli-metadata")
  for fast `--metadata` boot flows.

Together with the existing `phase=full` (entire load) and `phase=source-loader`
probes plus the `bundled-register:*` and `bundled-entry-module-load` probes
added in the previous commit, this gives a full breakdown:

- `phase=full plugin=slack` — total cost from import through register return
- `phase=full:register plugin=slack` — just the register() callback (NEW)
- `phase=bundled-register:setChannelRuntime plugin=slack` — sub-phase
- `phase=bundled-register:loadChannelPlugin plugin=slack` — sub-phase
- `phase=bundled-entry-module-load plugin=(bundled-entry)` — per-module load

Lets you `sort -k4 -n -r` the log output to find the slowest plugin's
register() call across all bundled+third-party plugins, then drill in via
the sub-phase probes for bundled entries.

* perf(plugins): consolidate plugin-load-profile primitives in shared module

Extracts the previously duplicated `shouldProfilePluginLoader` /
`profilePluginLoaderSync` helpers into a new `src/plugins/plugin-load-profile.ts`
module. Removes 3 file-local copies of the same env-flag check and 2
near-duplicate `try { run() } finally { console.error(...) }` wrappers.

Files updated:
- NEW src/plugins/plugin-load-profile.ts — sole owner of:
    shouldProfilePluginLoader()
    profilePluginLoaderSync<T>({phase, pluginId?, source, run, extras?})
    formatPluginLoadProfileLine({phase, pluginId?, source, elapsedMs, extras?})
- src/plugins/loader.ts — drop file-local copies, import shared helper
  (existing 4 + new 2 call sites unchanged in shape)
- src/plugins/source-loader.ts — drop renamed local copy
  (`shouldProfilePluginSourceLoader`), use shared helper with
  `pluginId: "(direct)"` to preserve the existing `plugin=(direct)` field
- src/plugin-sdk/channel-entry-contract.ts — drop file-local copies and
  inline `profileStep` closure; use shared `profilePluginLoaderSync` directly
  at all 5 `bundled-register:*` call sites; dual-timing
  `bundled-entry-module-load` probe uses `formatPluginLoadProfileLine` with
  ordered `extras` for `getJitiMs`/`jitiCallMs`

Log line format is byte-for-byte identical to before (validated against
3 cases: standard, with pluginId, dual-timing). The `extras` API is
intentionally an ordered tuple list (not a record) so that scrapers see
deterministic field order between `elapsedMs=` and `source=`.

Net: +155/-87 lines across 4 files, removing ~60 lines of duplication
while exposing a stable, documented probe surface.

Verified:
- pnpm tsgo (core) — 0 errors
- pnpm lint on all 4 files — 0 warnings, 0 errors
- pnpm test src/plugins/loader.test.ts — 102/102
- pnpm test src/plugins/contracts/plugin-entry-guardrails.test.ts — 7/7
- pnpm test src/plugin-sdk/channel-entry-contract.test.ts — 4/4
- Standalone formatter smoke test — output matches existing format byte-for-byte

* refactor(plugins): rename profilePluginLoaderSync to withProfile and bind scope at register sites

* fix(plugin-sdk): zero jiti sub-step timings on Win32 nodeRequire fast-path
2026-04-21 22:06:13 +10:00
Pavan Kumar Gondhi
31160dc069 fix(agents): enforce subagent envelope inheritance on ACP child sessions [AI-assisted] (#69383)
* fix: address issue

* fix: address review feedback

* fix: finalize issue changes

* fix: address PR review feedback

* address build faiure

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback

* fix: address PR review feedback
2026-04-21 17:25:25 +05:30
Peter Steinberger
f1805ab54d fix: centralize provider thinking profiles 2026-04-21 09:13:35 +01:00
Peter Steinberger
dc6ecd571a fix: skip workspace plugin runtime deps 2026-04-21 07:53:44 +01:00
Peter Steinberger
aacae4ce62 fix: use npm for bundled runtime dep repair 2026-04-21 07:53:44 +01:00
Peter Steinberger
0532feb0d3 fix: skip redundant bundled runtime dep repairs 2026-04-21 07:37:48 +01:00
Peter Steinberger
494cd78889 fix: tolerate pnpm-backed runtime dependency installs 2026-04-21 07:37:48 +01:00
Peter Steinberger
6ce17db11a fix: gate max thinking by model support 2026-04-21 07:02:43 +01:00
Peter Steinberger
e4adb0b0e3 fix: hide adaptive think option for GPT models 2026-04-21 06:19:29 +01:00
Patrick Erichsen
7752e3b30f onboard: clearer security disclaimer, loading spinners, api key placeholder 2026-04-21 06:08:43 +01:00
Peter Steinberger
8bb4dd7d08 fix: quiet bundled plugin runtime dep repairs 2026-04-21 05:36:09 +01:00
Peter Steinberger
6d409a6182 test: harden Parallels fresh install smoke 2026-04-21 05:34:25 +01:00
Peter Steinberger
817f861167 fix: isolate bundled plugin runtime deps 2026-04-21 04:32:12 +01:00
Andrii Furmanets
b6a8759b29 fix(web-search): restore SecretRef runtime compatibility for bundled providers (#68424)
Adds missing compatibility runtime path metadata for bundled SecretRef-capable web-search providers and keeps the manifest registry covered by a regression test.\n\nThanks @afurm!
2026-04-21 02:34:24 +01:00
Peter Steinberger
6bb6cfc68e test: use synthetic plugin channel fixtures 2026-04-21 01:32:27 +01:00
Peter Steinberger
3f274006cd refactor: share oauth callback flow 2026-04-21 01:07:09 +01:00
Peter Steinberger
503af7afa6 refactor: dedupe install scan skill spec 2026-04-21 00:32:42 +01:00
Peter Steinberger
1a834a0ff6 test: reuse runtime sidecar uniqueness helper 2026-04-21 00:32:42 +01:00
Peter Steinberger
a732b916f4 test: use synthetic media channel fixtures 2026-04-20 23:59:39 +01:00
Peter Steinberger
1f816b1561 test: share plugin install archive fixtures 2026-04-20 21:40:16 +01:00
Peter Steinberger
134a56f3e4 test: share openai codex oauth fixtures 2026-04-20 21:40:16 +01:00
Peter Steinberger
0f1ce47033 test(extensions): move provider contracts to owners 2026-04-20 20:55:39 +01:00
Tortes
3d19f018ab fix(plugins): prefer higher-precedence manifests for duplicate plugin ids
Keep only the highest-precedence manifest when distinct discovered plugins share an id, while preserving the newer installed-global precedence behavior on main. Lower-precedence duplicates now warn against the ignored manifest source instead of loading as disabled plugin entries.

Thanks @Tortes.
2026-04-20 20:49:05 +01:00
Edward Abrams
8595e6c872 fix(plugins): preserve memory capability across snapshot plugin loads
Preserve the active memory capability when non-activating plugin snapshot loads run, and add a regression test.\n\nThanks @zeroaltitude.
2026-04-20 20:43:08 +01:00
Peter Steinberger
cf7b906216 perf: defer unconfigured gateway hooks 2026-04-20 19:47:35 +01:00
Kris Wu
0a761a9eac fix(agents): rename auto_compaction_start/end to compaction_start/end [AI] (#67713)
Merged via squash.

Prepared head SHA: 03e0c69038
Co-authored-by: mpz4life <32388289+mpz4life@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
2026-04-20 11:35:40 -07:00
Peter Steinberger
456489974d test: share jiti loader cache fixture 2026-04-20 19:35:31 +01:00
Peter Steinberger
020a49de41 test: share plugin setup registry fixtures 2026-04-20 19:34:15 +01:00
Peter Steinberger
f76b426e2b perf: reduce jiti loader alias work 2026-04-20 18:06:45 +01:00
Peter Steinberger
47d42606ac fix: repair bundled plugin runtime deps on startup 2026-04-20 17:47:55 +01:00
Peter Steinberger
decdb92f34 test: enforce extension dependency ownership 2026-04-20 16:07:14 +01:00
Peter Steinberger
1148f245c8 build(deps): declare extension runtime dependencies 2026-04-20 16:07:14 +01:00
Peter Steinberger
f163432674 fix(discord): avoid native opus install path (#69339)
* fix(discord): avoid native opus install path

* test(tts): mock lazy facade values
2026-04-20 15:25:07 +01:00
Peter Steinberger
f6360da116 fix(deps): remove extension-owned deps from root install (#69335)
* fix(deps): remove extension runtime deps from root install

* fix(deps): keep bundled plugin deps local

* test(plugins): assert matrix deps stay plugin-local
2026-04-20 15:03:09 +01:00
Peter Steinberger
8642137252 refactor: share model allowlist entry helper 2026-04-20 15:02:51 +01:00
Peter Steinberger
3664119029 perf: reuse plugin loader config cache 2026-04-20 15:00:50 +01:00
Peter Steinberger
099d4b50b6 docs: clarify alias map memoization rationale 2026-04-20 15:00:50 +01:00
Peter Steinberger
53176153a2 test: cover alias map cache context 2026-04-20 15:00:50 +01:00
Alex Knight
2b64f4bf4b perf: memoize buildPluginLoaderAliasMap to enable jiti sentinel reuse
buildPluginLoaderAliasMap() creates a new alias object via spread on every
call. jiti's normalizeAliases() uses a reference-identity sentinel
(`if (e[pt]) return e`) to skip its O(N²) normalization work — but fresh
object refs defeat the sentinel, causing the full cycle to repeat on
every call.

This change caches alias maps by their inputs (modulePath, argv1,
moduleUrl, pluginSdkResolution) so identical parameters return the same
object reference. Subsequent jiti calls hit the sentinel fast-path
instead of re-running normalization.

Includes 5 new tests covering:
  - reference identity for identical inputs
  - cache isolation (different modulePath, pluginSdkResolution, argv1
    each produce distinct objects)
  - content equivalence between cached and freshly-computed results

Refs #68983, #63948
2026-04-20 15:00:50 +01:00
Peter Steinberger
eaea16f166 refactor: share google turn ordering sanitizer 2026-04-20 14:29:16 +01:00
Peter Steinberger
1ea02d231d refactor: reuse plugin contract snapshot type 2026-04-20 14:17:39 +01:00
Peter Steinberger
100e587243 refactor: share provider auth choice selection 2026-04-20 14:10:06 +01:00
Peter Steinberger
283b72f2de refactor: share setup registry scaffolding 2026-04-20 14:08:29 +01:00
Peter Steinberger
60818959b0 refactor: share bundled plugin compat decisions 2026-04-20 14:04:16 +01:00
Peter Steinberger
848348f423 refactor: share active plugin runtime lookup 2026-04-20 14:01:54 +01:00
Peter Steinberger
abe2296daf refactor: share plugin activation decisions 2026-04-20 13:31:00 +01:00
Peter Steinberger
1e4f3f2123 refactor(test): remove legacy extension test seams 2026-04-20 13:18:49 +01:00
Peter Steinberger
dafc31502a refactor: share provider and outbound helpers 2026-04-20 13:18:02 +01:00
竹田賢史
1d5b58ac18 feat(plugins): pass attachment metadata to before_model_resolve hook (#67322)
Merged via squash.

Prepared head SHA: 8af0ba9703
Co-authored-by: estack-takeda-yorichika <47170408+estack-takeda-yorichika@users.noreply.github.com>
Co-authored-by: sallyom <11166065+sallyom@users.noreply.github.com>
Reviewed-by: @sallyom
2026-04-20 00:14:50 -04:00
Mariano
bd3ad3436e tasks: add detached runtime plugin registration contract (#68915)
* tasks: register detached runtime plugins

* tasks: harden detached runtime ownership

* tasks: extract detached runtime contract types

* changelog: note detached runtime contract

* changelog: attribute detached runtime contract
2026-04-19 13:13:11 +02:00