Skip to content

fix(plugin-types): ActionsAPI.register handler exec-context d.ts (fn-176.1) - #5

Merged
acebytes merged 2 commits into
mainfrom
fix/action-exec-context-dts
Jul 27, 2026
Merged

fix(plugin-types): ActionsAPI.register handler exec-context d.ts (fn-176.1)#5
acebytes merged 2 commits into
mainfrom
fix/action-exec-context-dts

Conversation

@acebytes

Copy link
Copy Markdown
Contributor

Summary

Fixes known d.ts drift F1: ActionsAPI.register declared its handler as (input: AnyJSONValue) => ..., but the host invokes handlers with a single exec-context object — { invocationId, source, input, sourceId? } (host truth: AppOS-Desktop PluginActionsBridge.swift:1332-1348; host's own plugin-api.d.ts already agrees).

Flow tracking: fn-176.1 (epic fn-176-sdk-fix-actionsapiregister-handler-dts, AppOS-Desktop .flow/).

Changes

  • namespaces-core-plugins.ts — export InvocationSource ("user" | "plugin" | "agent" | "recipe" | "sequence" | "system") and ActionExecutionContext (invocationId: string; source: InvocationSource; input: AnyJSONValue; sourceId?: string, no index signature); register's handler param is now (exec: ActionExecutionContext); return type and def param unchanged; JSDoc describes exec-context dispatch. notifications.emit(input: AnyJSONValue) untouched (genuine input param).
  • TS2304 doc guidancesrc/index.ts header and README.md drop the /// <reference types="@appos.space/plugin-types" /> suggestion (package ships module exports only — no ambient globals); import-only guidance remains. README version mapping made version-agnostic (review r1).
  • New compile-only typetest src/__tests__/actions.typetest.ts importing via the public entrypoint (../index): (a) ytdlp's (exec) => exec.input as SomeShape pattern with displayName/risk/tags def extras; (b) field reads; (c) @ts-expect-error undeclared prop; (d) @ts-expect-error incompatible handler param; (e) @ts-expect-error non-member source literal comparison.
  • tsconfig.json — exclude docs-site from the root lint project (root npm run lint has been red since PR feat: automated developer docs site (TypeDoc + Starlight + CI) #4: Astro's astro:content virtual module + docs-site node_modules get swept; docs-site has its own toolchain/CI).
  • package-lock.json — 1-line sync of the plugin-types workspace stanza to the pre-staged 3.0.0.

Empirical probe outcomes (recorded in the typetest, flagged to fn-176.3 release task)

  • Case (f) dropped per task fallback rule: a legacy explicitly-typed (input: AnyJSONValue) handler does NOT assign (TS2345 — interfaces get no implicit index signature, so ActionExecutionContext is not assignable to AnyJSONValue's object arm). Changelog language for the release: source-breaking-but-runtime-correcting. Untyped (input) => ... handlers keep compiling at the call site.
  • Interface assertion caveat: exec.input as SomeInterface fails TS2352 (same TS rule); a type-alias target compiles. Real-ytdlp evidence: full tsc --noEmit against this build yields exactly one error (TS2352 at register-actions.ts:216, its interface DownloadUrlInput) — the original F1 error ("Property 'input' does not exist") is gone. Counterfactual input: unknown (host-d.ts parity) compiles ytdlp clean; the spec's R1 chose AnyJSONValue — decision deferred to the release task / ytdlp workstream (1-line interfacetype on their side also resolves it).

Evidence

  • npm run build RC=0 · npm test RC=0 (typetest enforced — unused @ts-expect-error fails compile) · root npm run lint RC=0
  • dist verification: dist/namespaces-core-plugins.d.ts contains ActionExecutionContext (re-exported via dist/index.d.ts export *; package-name import probe resolves RC=0); zero handler: (input: AnyJSONValue) in dist/
  • Grep gates: zero /// <reference types="@appos.space/plugin-types" and zero stale handler shape repo-wide (node_modules excluded)
  • Codex impl-review: round 1 NEEDS_WORK (1 Minor: README version mapping) → fixed → round 2 SHIP

Not in this PR

  • No merge to main without review; no npm publish — release is fn-176.3 (user-gated ./release.sh, occupancy-guarded 3.0.0-vs-3.0.1 decision).
  • Docs-site drift gate + full build verification is fn-176.2.

acebytes added 2 commits July 25, 2026 19:48
…ontext, not raw input (fn-176.1)

The host invokes action handlers with a single exec-context object
({ invocationId, source, input, sourceId? } — PluginActionsBridge.swift),
but the d.ts declared the handler as (input: AnyJSONValue). Known drift F1.

- Export InvocationSource (host-canonical 6-member literal union) and
  ActionExecutionContext (exact host field set, no index signature) from
  namespaces-core-plugins.ts; register's handler param is now
  (exec: ActionExecutionContext); return type and def param unchanged;
  JSDoc updated to describe exec-context dispatch.
- index.ts header + README: drop the '/// <reference types=...>' global
  usage suggestion (package ships module exports only — it produced
  TS2304); import-based guidance only.
- New compile-only typetest src/__tests__/actions.typetest.ts importing
  via the public entrypoint (../index): cases (a)-(e) per fn-176.1.
  Probe outcomes (TS 5.x, recorded in-file):
  * (a) compiles with a type-alias SomeShape; an interface target fails
    'exec.input as X' (no implicit index signature) — ytdlp's unmodified
    interface DownloadUrlInput still needs interface→type or
    'as unknown as' (flagged to fn-176.3).
  * (f) legacy (input: AnyJSONValue) handler does NOT assign
    (ActionExecutionContext has no index signature) — case dropped per
    task fallback rule; changelog language for .3:
    source-breaking-but-runtime-correcting.
- tsconfig.json: exclude docs-site from root lint project — root
  'npm run lint' has been red since PR #4 (docs-site's astro:content
  virtual module + its node_modules get swept); docs-site has its own
  toolchain and CI.
- package-lock.json: 1-line sync of the plugin-types workspace stanza
  to the pre-staged 3.0.0.

Validation: npm run build RC=0; npm test RC=0 (typetest enforced —
unused @ts-expect-error fails compile); npm run lint RC=0; dist
verification: dist surface exports ActionExecutionContext via package
entrypoint (probe RC=0), zero 'handler: (input: AnyJSONValue)' in dist;
grep gates: zero '/// <reference types="@appos.space/plugin-types"',
zero stale handler shape; notifications.emit(input:) untouched.

Task: fn-176-sdk-fix-actionsapiregister-handler-dts.1
…g, 3.0.x example (fn-176.1 review r1)

Codex impl-review round 1 Minor: README still mapped 2.4.x <-> plugin
API 2.4.x while the package ships 3.0.0. Phrase the mapping
version-agnostically so it survives future bumps (incl. a potential
3.0.1 under the epic's release fallback rule).

Task: fn-176-sdk-fix-actionsapiregister-handler-dts.1
@acebytes
acebytes merged commit 1caaced into main Jul 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant