@unieai/rabi-host-plugin-inventory 0.2.1-rc.3 → 0.2.2-rc.5

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/lib/index.js CHANGED
@@ -125,11 +125,20 @@ async function readPluginInventory(ctx) {
125
125
  if (entry.options.group) continue;
126
126
  const base = entry.parent.tree.ctx.baseUrl;
127
127
  const meta = base === void 0 ? void 0 : packages?.metaOf(entry.options.name, base);
128
+ const fiber = entry.fiber;
129
+ const fiberPhase = fiber === void 0 ? null : FIBER_PHASE[fiber.state];
130
+ let diagnostic;
131
+ if (fiber !== void 0 && fiberPhase === "failed") try {
132
+ await fiber.await();
133
+ } catch (error) {
134
+ diagnostic = error instanceof Error ? error.message : String(error);
135
+ }
128
136
  entries.push({
129
137
  entryId: pluginEntryId(entry.id),
130
138
  moduleName: entry.options.name,
131
139
  enabled: !entry.disabled,
132
- fiberPhase: entry.fiber === void 0 ? null : FIBER_PHASE[entry.fiber.state],
140
+ fiberPhase,
141
+ ...diagnostic === void 0 ? {} : { diagnostic },
133
142
  ...meta === void 0 ? {} : { meta }
134
143
  });
135
144
  }
@@ -21,6 +21,7 @@ const _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema = ()
21
21
  }).readonly().optional().describe('Local package display metadata, independent of whether the entry is enabled.'),
22
22
  'enabled': z.boolean().readonly().describe('Effective Loader enablement, including disabled ancestor groups.'),
23
23
  'fiberPhase': z.union([z.literal(null), z.literal("failed"), z.literal("pending"), z.literal("active"), z.literal("loading"), z.literal("unloading")]).readonly(),
24
+ 'diagnostic': z.string().readonly().optional().describe('Current startup failure message; absent when this entry has no failed fiber.'),
24
25
  })).readonly(),
25
26
  'agentPresets': z.array(z.object({
26
27
  'id': z.string().readonly().describe('Stable preset id.'),
@@ -21,6 +21,7 @@ const _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema = ()
21
21
  }).readonly().optional().describe('Local package display metadata, independent of whether the entry is enabled.'),
22
22
  'enabled': z.boolean().readonly().describe('Effective Loader enablement, including disabled ancestor groups.'),
23
23
  'fiberPhase': z.union([z.literal(null), z.literal("failed"), z.literal("pending"), z.literal("active"), z.literal("loading"), z.literal("unloading")]).readonly(),
24
+ 'diagnostic': z.string().readonly().optional().describe('Current startup failure message; absent when this entry has no failed fiber.'),
24
25
  })).readonly(),
25
26
  'agentPresets': z.array(z.object({
26
27
  'id': z.string().readonly().describe('Stable preset id.'),
@@ -108,11 +108,23 @@ export async function readPluginInventory(ctx) {
108
108
  continue;
109
109
  const base = entry.parent.tree.ctx.baseUrl;
110
110
  const meta = base === undefined ? undefined : packages?.metaOf(entry.options.name, base);
111
+ const fiber = entry.fiber;
112
+ const fiberPhase = fiber === undefined ? null : FIBER_PHASE[fiber.state];
113
+ let diagnostic;
114
+ if (fiber !== undefined && fiberPhase === 'failed') {
115
+ try {
116
+ await fiber.await();
117
+ }
118
+ catch (error) {
119
+ diagnostic = error instanceof Error ? error.message : String(error);
120
+ }
121
+ }
111
122
  entries.push({
112
123
  entryId: pluginEntryId(entry.id),
113
124
  moduleName: entry.options.name,
114
125
  enabled: !entry.disabled,
115
- fiberPhase: entry.fiber === undefined ? null : FIBER_PHASE[entry.fiber.state],
126
+ fiberPhase,
127
+ ...diagnostic === undefined ? {} : { diagnostic },
116
128
  ...meta === undefined ? {} : { meta },
117
129
  });
118
130
  }
@@ -14,6 +14,8 @@ export interface PluginInventoryEntry {
14
14
  /** Effective Loader enablement, including disabled ancestor groups. */
15
15
  readonly enabled: boolean;
16
16
  readonly fiberPhase: PluginFiberPhase;
17
+ /** Current startup failure message; absent when this entry has no failed fiber. */
18
+ readonly diagnostic?: string;
17
19
  }
18
20
  /** Effective enablement of one preset composition row. */
19
21
  export type PresetPluginEnablement = boolean | 'conditional';
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Plugin-Manifestdienst",
4
+ "description": "Bietet eine schreibgeschützte Liste der aktuellen Plug-In-Einträge, des Aktivierungsstatus der Konfiguration und des Ausführungsstatus."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Servicio de manifiesto de complemento",
4
+ "description": "Proporciona una lista de solo lectura de las entradas de complementos actuales, el estado de habilitación de la configuración y el estado de ejecución."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Service de manifeste de plugin",
4
+ "description": "Fournit une liste en lecture seule des entrées actuelles du plug-in, de l'état d'activation de la configuration et de l'état d'exécution."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "プラグイン一覧サービス",
4
+ "description": "現在のプラグイン項目、設定上の有効状態、実行状態の読み取り専用一覧を提供します。"
5
+ }
6
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Serviço de manifesto de plug-in",
4
+ "description": "Fornece uma listagem somente leitura das entradas atuais do plug-in, do status de ativação da configuração e do status de execução."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Служба манифеста плагина",
4
+ "description": "Предоставляет доступный только для чтения список текущих записей подключаемого модуля, состояние включения конфигурации и состояние работы."
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unieai/rabi-host-plugin-inventory",
3
3
  "description": "Read-only Remote projection of current Cordis Loader plugin state",
4
- "version": "0.2.1-rc.3",
4
+ "version": "0.2.2-rc.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -34,22 +34,26 @@
34
34
  "lib/index.js",
35
35
  "lib/types/**/*.js",
36
36
  "lib/types/**/*.d.ts",
37
+ "lib/types/**/*.d.ts.map",
38
+ "lib/**/*.js.map",
37
39
  "lib/typert.host.js",
38
40
  "lib/typert.host.d.ts",
39
41
  "lib/typert.remote-client.js",
40
42
  "lib/typert.remote-client.d.ts",
43
+ "lib/typert.remote-client.d.ts.map",
44
+ "src",
41
45
  "README.md"
42
46
  ],
43
47
  "license": "MIT",
44
48
  "dependencies": {
45
- "zod": "4.4.3"
49
+ "zod": "4.6.6"
46
50
  },
47
51
  "peerDependencies": {
48
- "@unieai/cordis-plugin-loader": "1.0.6",
49
- "@unieai/rabi-agent-preset-registry": "0.2.1-rc.3",
50
- "@unieai/rabi-brand": "0.2.1-rc.3",
51
- "@unieai/rabi-typert-protocol": "0.2.1-rc.3",
52
- "@unieai/cordis": "4.0.5"
52
+ "@unieai/cordis-plugin-loader": "1.1.0",
53
+ "@unieai/rabi-agent-preset-registry": "0.2.2-rc.5",
54
+ "@unieai/rabi-brand": "0.2.2-rc.5",
55
+ "@unieai/rabi-typert-protocol": "0.2.2-rc.5",
56
+ "@unieai/cordis": "4.1.0"
53
57
  },
54
58
  "peerDependenciesMeta": {
55
59
  "@unieai/rabi-agent-preset-registry": {
package/src/index.ts ADDED
@@ -0,0 +1,121 @@
1
+ /** Read-only projection of the current Cordis Loader plugin entries. */
2
+
3
+ import type { Context, FiberState } from '@unieai/cordis'
4
+ import type {} from '@unieai/cordis-plugin-loader'
5
+ // Type-only: the optional agent-preset roster resolved through `ctx.get`.
6
+ import type {} from '@unieai/rabi-agent-preset-registry'
7
+ import type {} from '@unieai/rabi-app-boot'
8
+ import { TypertRemoteService, Remote } from '@unieai/rabi-typert-protocol'
9
+ // Typert-generated ./typert and ./remote artifacts import Zod at runtime.
10
+ import type {} from 'zod'
11
+ import type {
12
+ AgentPresetPluginGroup,
13
+ PluginEntryId,
14
+ PluginFiberPhase,
15
+ PluginInventoryEntry,
16
+ PluginInventorySnapshot,
17
+ } from './types.ts'
18
+
19
+ export type * from './types.ts'
20
+
21
+ /**
22
+ * Brand an existing Loader-tree entry id at the owning boundary.
23
+ * @param value - the entry id as the Loader tree spells it.
24
+ * @returns the same id as the inventory's branded entry id.
25
+ */
26
+ export function pluginEntryId(value: string): PluginEntryId {
27
+ return value as PluginEntryId
28
+ }
29
+
30
+ /** Runtime mirror: FiberState is a cross-package const enum. */
31
+ const FIBER_STATE = {
32
+ PENDING: 0 as FiberState.PENDING,
33
+ LOADING: 1 as FiberState.LOADING,
34
+ ACTIVE: 2 as FiberState.ACTIVE,
35
+ FAILED: 3 as FiberState.FAILED,
36
+ DISPOSED: 4 as FiberState.DISPOSED,
37
+ UNLOADING: 5 as FiberState.UNLOADING,
38
+ } as const
39
+
40
+ /** Complete public projection of Cordis Fiber states. */
41
+ const FIBER_PHASE = {
42
+ [FIBER_STATE.PENDING]: 'pending',
43
+ [FIBER_STATE.LOADING]: 'loading',
44
+ [FIBER_STATE.ACTIVE]: 'active',
45
+ [FIBER_STATE.FAILED]: 'failed',
46
+ [FIBER_STATE.DISPOSED]: null,
47
+ [FIBER_STATE.UNLOADING]: 'unloading',
48
+ } as const satisfies Record<FiberState, PluginFiberPhase>
49
+
50
+ /** Remote-only service exposing the Loader's current non-group entry state. */
51
+ export class PluginInventoryGateway extends TypertRemoteService {
52
+ static inject = ['loader']
53
+
54
+ constructor(ctx: Context) {
55
+ super(ctx, 'pluginInventory')
56
+ }
57
+
58
+ /**
59
+ * Read the Loader directly on every call. Cordis's internal plugin/status
60
+ * events already maintain Entry.fiber and Fiber.state, so a second cache
61
+ * would only add another lifecycle truth to keep synchronized.
62
+ *
63
+ * When an agent-preset roster is composed, the snapshot also carries each
64
+ * preset's composition rows, because those rows — not the Loader's own
65
+ * entries — are where a deployment that mounts the roster runs its
66
+ * model-facing plugins.
67
+ * @returns Current non-group Loader entries in Loader order, with optional display metadata
68
+ * and per-preset compositions when a roster is composed.
69
+ */
70
+ @Remote('list')
71
+ async list(): Promise<PluginInventorySnapshot> {
72
+ return readPluginInventory(this.ctx)
73
+ }
74
+ }
75
+
76
+ export default PluginInventoryGateway
77
+
78
+ /** Read current Loader entries and optional preset compositions.
79
+ * @param ctx Context with the Loader service.
80
+ * @returns Current inventory with optional display metadata and no separate runtime cache.
81
+ */
82
+ export async function readPluginInventory(ctx: Context): Promise<PluginInventorySnapshot> {
83
+ const entries: PluginInventoryEntry[] = []
84
+ const packages = ctx.get('pluginPackages')
85
+ for (const entry of ctx.loader.entries()) {
86
+ if (entry.options.group) continue
87
+ const base = entry.parent.tree.ctx.baseUrl
88
+ const meta = base === undefined ? undefined : packages?.metaOf(entry.options.name, base)
89
+ const fiber = entry.fiber
90
+ const fiberPhase = fiber === undefined ? null : FIBER_PHASE[fiber.state]
91
+ let diagnostic: string | undefined
92
+ if (fiber !== undefined && fiberPhase === 'failed') {
93
+ try { await fiber.await() } catch (error) { diagnostic = error instanceof Error ? error.message : String(error) }
94
+ }
95
+ entries.push({
96
+ entryId: pluginEntryId(entry.id),
97
+ moduleName: entry.options.name,
98
+ enabled: !entry.disabled,
99
+ fiberPhase,
100
+ ...diagnostic === undefined ? {} : { diagnostic },
101
+ ...meta === undefined ? {} : { meta },
102
+ })
103
+ }
104
+ const presets = ctx.get('agentPresets')
105
+ const management = ctx.get('pluginManager') === undefined ? {} : { managementAvailable: true }
106
+ if (presets === undefined) return { entries, ...management }
107
+ const agentPresets: AgentPresetPluginGroup[] = (await presets.compositionInventory()).map(
108
+ composition => ({
109
+ ...composition,
110
+ rows: composition.rows.map(({ fiberState, ...row }) => {
111
+ const meta = ctx.baseUrl === undefined ? undefined : packages?.metaOf(row.moduleName, ctx.baseUrl)
112
+ return {
113
+ ...row,
114
+ fiberPhase: fiberState === undefined ? null : FIBER_PHASE[fiberState],
115
+ ...meta === undefined ? {} : { meta },
116
+ }
117
+ }),
118
+ }),
119
+ )
120
+ return { entries, agentPresets, ...management }
121
+ }
package/src/types.ts ADDED
@@ -0,0 +1,77 @@
1
+ import type { Branded } from '@unieai/rabi-brand'
2
+ import type { PluginLocalizedMeta } from '@unieai/rabi-package-manifest'
3
+
4
+ /** Stable Loader-tree identity of one configured plugin entry. */
5
+ export type PluginEntryId = Branded<'PluginEntryId'>
6
+
7
+ /** Lifecycle state of an entry's root Fiber, or null when it has no live root Fiber. */
8
+ export type PluginFiberPhase =
9
+ | 'pending'
10
+ | 'loading'
11
+ | 'active'
12
+ | 'failed'
13
+ | 'unloading'
14
+ | null
15
+
16
+ /** One non-group Loader entry exposed to trusted clients. */
17
+ export interface PluginInventoryEntry {
18
+ readonly entryId: PluginEntryId
19
+ /** Exact module specifier imported by the Loader entry. */
20
+ readonly moduleName: string
21
+ /** Local package display metadata, independent of whether the entry is enabled. */
22
+ readonly meta?: PluginLocalizedMeta
23
+ /** Effective Loader enablement, including disabled ancestor groups. */
24
+ readonly enabled: boolean
25
+ readonly fiberPhase: PluginFiberPhase
26
+ /** Current startup failure message; absent when this entry has no failed fiber. */
27
+ readonly diagnostic?: string
28
+ }
29
+
30
+ /** Effective enablement of one preset composition row. */
31
+ export type PresetPluginEnablement = boolean | 'conditional'
32
+
33
+ /** One plugin row an agent preset's composition names. */
34
+ export interface AgentPresetPluginRow {
35
+ /** Composition row id, or null when the row declares none. */
36
+ readonly entryId: string | null
37
+ /** Module specifier the row names. */
38
+ readonly moduleName: string
39
+ /** Local package display metadata, independent of whether the preset is mounted. */
40
+ readonly meta?: PluginLocalizedMeta
41
+ /**
42
+ * Effective enablement, including disabled ancestor groups. `'conditional'`
43
+ * marks a `!!js` disabled expression on a composition no session has
44
+ * mounted, which only a Loader context can decide.
45
+ */
46
+ readonly enabled: PresetPluginEnablement
47
+ /** The row's own `!!js` disabled expression, when it carries one. */
48
+ readonly condition?: string
49
+ /** Root-fiber phase when the composition is live; null otherwise. */
50
+ readonly fiberPhase: PluginFiberPhase
51
+ }
52
+
53
+ /** One agent preset's identity and flattened composition in the inventory. */
54
+ export interface AgentPresetPluginGroup {
55
+ /** Stable preset id. */
56
+ readonly id: string
57
+ /** Display name the preset published; a reader falls back to the id. */
58
+ readonly name?: string
59
+ /** Whether a session naming no preset composes this one. */
60
+ readonly isDefault: boolean
61
+ /** Why this preset's composition cannot be read; absent when rows answer. */
62
+ readonly broken?: string
63
+ /** Plugin rows in composition order; empty when the preset is broken. */
64
+ readonly rows: readonly AgentPresetPluginRow[]
65
+ }
66
+
67
+ /** Point-in-time inventory returned by the plugin inventory Remote. */
68
+ export interface PluginInventorySnapshot {
69
+ /** Whether this Host exposes persistent current-profile management. */
70
+ readonly managementAvailable?: boolean
71
+ readonly entries: readonly PluginInventoryEntry[]
72
+ /**
73
+ * Per-preset compositions, present only when an agent-preset roster is
74
+ * composed in this deployment.
75
+ */
76
+ readonly agentPresets?: readonly AgentPresetPluginGroup[]
77
+ }