@unieai/rabi-host-plugin-inventory 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +7 -2
- package/lib/index.js +168 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +83 -0
- package/lib/typert.remote-client.d.ts +25 -0
- package/lib/typert.remote-client.js +72 -0
- package/lib/types/index.d.ts +36 -0
- package/lib/types/index.js +147 -0
- package/lib/types/types.d.ts +65 -0
- package/lib/types/types.js +1 -0
- package/locale/de.json +6 -0
- package/locale/en.json +5 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +61 -4
- package/src/index.ts +121 -0
- package/src/types.ts +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @unieai/rabi-host-plugin-inventory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read-only Remote projection of current Cordis Loader plugin state
|
|
4
|
+
|
|
5
|
+
Part of Rabi, the agent harness UnieAI Code runs on. Installed as a dependency of `@unieai/rabi`;
|
|
6
|
+
not meant to be used on its own.
|
|
7
|
+
|
|
8
|
+
See LICENSE for the license and copyright of this package.
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Remote, TypertRemoteService } from "@unieai/rabi-typert-protocol";
|
|
2
|
+
//#region lib/types/index.js
|
|
3
|
+
/** Read-only projection of the current Cordis Loader plugin entries. */
|
|
4
|
+
var __runInitializers = function(thisArg, initializers, value) {
|
|
5
|
+
var useValue = arguments.length > 2;
|
|
6
|
+
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) {
|
|
11
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
12
|
+
return f;
|
|
13
|
+
}
|
|
14
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
15
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
16
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
17
|
+
var _, done = false;
|
|
18
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
19
|
+
var context = {};
|
|
20
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
21
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
22
|
+
context.addInitializer = function(f) {
|
|
23
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
24
|
+
extraInitializers.push(accept(f || null));
|
|
25
|
+
};
|
|
26
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
27
|
+
get: descriptor.get,
|
|
28
|
+
set: descriptor.set
|
|
29
|
+
} : descriptor[key], context);
|
|
30
|
+
if (kind === "accessor") {
|
|
31
|
+
if (result === void 0) continue;
|
|
32
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
33
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
34
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
35
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
36
|
+
} else if (_ = accept(result)) if (kind === "field") initializers.unshift(_);
|
|
37
|
+
else descriptor[key] = _;
|
|
38
|
+
}
|
|
39
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
40
|
+
done = true;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Brand an existing Loader-tree entry id at the owning boundary.
|
|
44
|
+
* @param value - the entry id as the Loader tree spells it.
|
|
45
|
+
* @returns the same id as the inventory's branded entry id.
|
|
46
|
+
*/
|
|
47
|
+
function pluginEntryId(value) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
/** Runtime mirror: FiberState is a cross-package const enum. */
|
|
51
|
+
const FIBER_STATE = {
|
|
52
|
+
PENDING: 0,
|
|
53
|
+
LOADING: 1,
|
|
54
|
+
ACTIVE: 2,
|
|
55
|
+
FAILED: 3,
|
|
56
|
+
DISPOSED: 4,
|
|
57
|
+
UNLOADING: 5
|
|
58
|
+
};
|
|
59
|
+
/** Complete public projection of Cordis Fiber states. */
|
|
60
|
+
const FIBER_PHASE = {
|
|
61
|
+
[FIBER_STATE.PENDING]: "pending",
|
|
62
|
+
[FIBER_STATE.LOADING]: "loading",
|
|
63
|
+
[FIBER_STATE.ACTIVE]: "active",
|
|
64
|
+
[FIBER_STATE.FAILED]: "failed",
|
|
65
|
+
[FIBER_STATE.DISPOSED]: null,
|
|
66
|
+
[FIBER_STATE.UNLOADING]: "unloading"
|
|
67
|
+
};
|
|
68
|
+
/** Remote-only service exposing the Loader's current non-group entry state. */
|
|
69
|
+
let PluginInventoryGateway = (() => {
|
|
70
|
+
let _classSuper = TypertRemoteService;
|
|
71
|
+
let _instanceExtraInitializers = [];
|
|
72
|
+
let _list_decorators;
|
|
73
|
+
return class PluginInventoryGateway extends _classSuper {
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
76
|
+
_list_decorators = [Remote("list")];
|
|
77
|
+
__esDecorate(this, null, _list_decorators, {
|
|
78
|
+
kind: "method",
|
|
79
|
+
name: "list",
|
|
80
|
+
static: false,
|
|
81
|
+
private: false,
|
|
82
|
+
access: {
|
|
83
|
+
has: (obj) => "list" in obj,
|
|
84
|
+
get: (obj) => obj.list
|
|
85
|
+
},
|
|
86
|
+
metadata: _metadata
|
|
87
|
+
}, null, _instanceExtraInitializers);
|
|
88
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: _metadata
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
static inject = ["loader"];
|
|
96
|
+
constructor(ctx) {
|
|
97
|
+
super(ctx, "pluginInventory");
|
|
98
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Read the Loader directly on every call. Cordis's internal plugin/status
|
|
102
|
+
* events already maintain Entry.fiber and Fiber.state, so a second cache
|
|
103
|
+
* would only add another lifecycle truth to keep synchronized.
|
|
104
|
+
*
|
|
105
|
+
* When an agent-preset roster is composed, the snapshot also carries each
|
|
106
|
+
* preset's composition rows, because those rows — not the Loader's own
|
|
107
|
+
* entries — are where a deployment that mounts the roster runs its
|
|
108
|
+
* model-facing plugins.
|
|
109
|
+
* @returns Current non-group Loader entries in Loader order, with optional display metadata
|
|
110
|
+
* and per-preset compositions when a roster is composed.
|
|
111
|
+
*/
|
|
112
|
+
async list() {
|
|
113
|
+
return readPluginInventory(this.ctx);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
})();
|
|
117
|
+
/** Read current Loader entries and optional preset compositions.
|
|
118
|
+
* @param ctx Context with the Loader service.
|
|
119
|
+
* @returns Current inventory with optional display metadata and no separate runtime cache.
|
|
120
|
+
*/
|
|
121
|
+
async function readPluginInventory(ctx) {
|
|
122
|
+
const entries = [];
|
|
123
|
+
const packages = ctx.get("pluginPackages");
|
|
124
|
+
for (const entry of ctx.loader.entries()) {
|
|
125
|
+
if (entry.options.group) continue;
|
|
126
|
+
const base = entry.parent.tree.ctx.baseUrl;
|
|
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
|
+
}
|
|
136
|
+
entries.push({
|
|
137
|
+
entryId: pluginEntryId(entry.id),
|
|
138
|
+
moduleName: entry.options.name,
|
|
139
|
+
enabled: !entry.disabled,
|
|
140
|
+
fiberPhase,
|
|
141
|
+
...diagnostic === void 0 ? {} : { diagnostic },
|
|
142
|
+
...meta === void 0 ? {} : { meta }
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const presets = ctx.get("agentPresets");
|
|
146
|
+
const management = ctx.get("pluginManager") === void 0 ? {} : { managementAvailable: true };
|
|
147
|
+
if (presets === void 0) return {
|
|
148
|
+
entries,
|
|
149
|
+
...management
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
entries,
|
|
153
|
+
agentPresets: (await presets.compositionInventory()).map((composition) => ({
|
|
154
|
+
...composition,
|
|
155
|
+
rows: composition.rows.map(({ fiberState, ...row }) => {
|
|
156
|
+
const meta = ctx.baseUrl === void 0 ? void 0 : packages?.metaOf(row.moduleName, ctx.baseUrl);
|
|
157
|
+
return {
|
|
158
|
+
...row,
|
|
159
|
+
fiberPhase: fiberState === void 0 ? null : FIBER_PHASE[fiberState],
|
|
160
|
+
...meta === void 0 ? {} : { meta }
|
|
161
|
+
};
|
|
162
|
+
})
|
|
163
|
+
})),
|
|
164
|
+
...management
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { PluginInventoryGateway, PluginInventoryGateway as default, pluginEntryId, readPluginInventory };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* Generated by @unieai/rabi-typert-generator from FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { createTypertRemoteInfo } from '@unieai/rabi-typert-protocol/remote-info'
|
|
5
|
+
|
|
6
|
+
let _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema$value
|
|
7
|
+
const _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema = () => (_unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema$value ??= z.object({
|
|
8
|
+
'managementAvailable': z.boolean().readonly().optional().describe('Whether this Host exposes persistent current-profile management.'),
|
|
9
|
+
'entries': z.array(z.object({
|
|
10
|
+
'entryId': z.string().readonly(),
|
|
11
|
+
'moduleName': z.string().readonly().describe('Exact module specifier imported by the Loader entry.'),
|
|
12
|
+
'meta': z.object({
|
|
13
|
+
'title': z.union([z.string(), z.intersection(z.object({
|
|
14
|
+
'en': z.string().readonly(),
|
|
15
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display title; omission preserves the consumer\'s technical-name fallback.'),
|
|
16
|
+
'description': z.union([z.string(), z.intersection(z.object({
|
|
17
|
+
'en': z.string().readonly(),
|
|
18
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display introduction after locale and package-field fallback.'),
|
|
19
|
+
'icon': z.string().readonly().optional().describe('Base64 image data URL from a package root\'s manifest icon or an exported `<specifier>/icon`; render as an image, not inline markup.'),
|
|
20
|
+
'error': z.string().readonly().optional().describe('Unmodified local metadata diagnostic; the plugin remains manageable.'),
|
|
21
|
+
}).readonly().optional().describe('Local package display metadata, independent of whether the entry is enabled.'),
|
|
22
|
+
'enabled': z.boolean().readonly().describe('Effective Loader enablement, including disabled ancestor groups.'),
|
|
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.'),
|
|
25
|
+
})).readonly(),
|
|
26
|
+
'agentPresets': z.array(z.object({
|
|
27
|
+
'id': z.string().readonly().describe('Stable preset id.'),
|
|
28
|
+
'name': z.string().readonly().optional().describe('Display name the preset published; a reader falls back to the id.'),
|
|
29
|
+
'isDefault': z.boolean().readonly().describe('Whether a session naming no preset composes this one.'),
|
|
30
|
+
'broken': z.string().readonly().optional().describe('Why this preset\'s composition cannot be read; absent when rows answer.'),
|
|
31
|
+
'rows': z.array(z.object({
|
|
32
|
+
'entryId': z.union([z.literal(null), z.string()]).readonly().describe('Composition row id, or null when the row declares none.'),
|
|
33
|
+
'moduleName': z.string().readonly().describe('Module specifier the row names.'),
|
|
34
|
+
'meta': z.object({
|
|
35
|
+
'title': z.union([z.string(), z.intersection(z.object({
|
|
36
|
+
'en': z.string().readonly(),
|
|
37
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display title; omission preserves the consumer\'s technical-name fallback.'),
|
|
38
|
+
'description': z.union([z.string(), z.intersection(z.object({
|
|
39
|
+
'en': z.string().readonly(),
|
|
40
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display introduction after locale and package-field fallback.'),
|
|
41
|
+
'icon': z.string().readonly().optional().describe('Base64 image data URL from a package root\'s manifest icon or an exported `<specifier>/icon`; render as an image, not inline markup.'),
|
|
42
|
+
'error': z.string().readonly().optional().describe('Unmodified local metadata diagnostic; the plugin remains manageable.'),
|
|
43
|
+
}).readonly().optional().describe('Local package display metadata, independent of whether the preset is mounted.'),
|
|
44
|
+
'enabled': z.union([z.literal(false), z.literal(true), z.literal("conditional")]).readonly().describe('Effective enablement, including disabled ancestor groups. `\'conditional\'` marks a `!!js` disabled expression on a composition no session has mounted, which only a Loader context can decide.'),
|
|
45
|
+
'condition': z.string().readonly().optional().describe('The row\'s own `!!js` disabled expression, when it carries one.'),
|
|
46
|
+
'fiberPhase': z.union([z.literal(null), z.literal("failed"), z.literal("pending"), z.literal("active"), z.literal("loading"), z.literal("unloading")]).readonly().describe('Root-fiber phase when the composition is live; null otherwise.'),
|
|
47
|
+
})).readonly().describe('Plugin rows in composition order; empty when the preset is broken.'),
|
|
48
|
+
})).readonly().optional().describe('Per-preset compositions, present only when an agent-preset roster is composed in this deployment.'),
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
const $remote = createTypertRemoteInfo({
|
|
52
|
+
package: '@unieai/rabi-host-plugin-inventory',
|
|
53
|
+
methods: {
|
|
54
|
+
'pluginInventory/list': {
|
|
55
|
+
service: 'pluginInventory',
|
|
56
|
+
description: 'Read the Loader directly on every call. Cordis\'s internal plugin/status events already maintain Entry.fiber and Fiber.state, so a second cache would only add another lifecycle truth to keep synchronized. When an agent-preset roster is composed, the snapshot also carries each preset\'s composition rows, because those rows — not the Loader\'s own entries — are where a deployment that mounts the roster runs its model-facing plugins.',
|
|
57
|
+
invocation: { kind: 'direct' },
|
|
58
|
+
parameters: [
|
|
59
|
+
],
|
|
60
|
+
result: {
|
|
61
|
+
mode: 'strict',
|
|
62
|
+
typeSymbol: '@unieai/rabi-host-plugin-inventory/types#PluginInventorySnapshot',
|
|
63
|
+
create: _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema,
|
|
64
|
+
description: 'Current non-group Loader entries in Loader order, with optional display metadata and per-preset compositions when a roster is composed.',
|
|
65
|
+
jsonSchemaError: 'typert tool schema: selected dictionaries require string keys and unconstrained JSON values',
|
|
66
|
+
},
|
|
67
|
+
sourceLocation: {"file":"packages/host/plugin-inventory/src/index.ts","line":71,"column":9},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}, z)
|
|
71
|
+
|
|
72
|
+
export const TYPERT = {
|
|
73
|
+
package: '@unieai/rabi-host-plugin-inventory',
|
|
74
|
+
face: 'host',
|
|
75
|
+
schemas: [
|
|
76
|
+
],
|
|
77
|
+
get invocations() { return $remote.descriptors },
|
|
78
|
+
model: {
|
|
79
|
+
"services": [],
|
|
80
|
+
"events": [],
|
|
81
|
+
"objects": []
|
|
82
|
+
},
|
|
83
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Generated by @unieai/rabi-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import type {
|
|
3
|
+
RemoteResult,
|
|
4
|
+
TypertRemoteInfo,
|
|
5
|
+
TypertRemoteMethod,
|
|
6
|
+
} from '@unieai/rabi-typert-protocol'
|
|
7
|
+
import type { PluginInventorySnapshot } from '@unieai/rabi-host-plugin-inventory/types'
|
|
8
|
+
|
|
9
|
+
declare module '@unieai/rabi-typert-protocol' {
|
|
10
|
+
interface TypertRemoteNamespace$706c7567696e496e76656e746f7279 {
|
|
11
|
+
list: () => Promise<RemoteResult<PluginInventorySnapshot>>
|
|
12
|
+
}
|
|
13
|
+
interface TypertRemoteMap {
|
|
14
|
+
'pluginInventory/list': () => Promise<RemoteResult<PluginInventorySnapshot>>
|
|
15
|
+
}
|
|
16
|
+
interface TypertRemoteNamespaceMap {
|
|
17
|
+
'pluginInventory': TypertRemoteNamespace$706c7567696e496e76656e746f7279
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare const TYPERT_REMOTE: TypertRemoteInfo<{
|
|
22
|
+
readonly 'pluginInventory/list': TypertRemoteMethod<{ }, PluginInventorySnapshot>
|
|
23
|
+
}>
|
|
24
|
+
export default TYPERT_REMOTE
|
|
25
|
+
//# sourceMappingURL=typert.remote-client.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* Generated by @unieai/rabi-typert-generator from the Host FaceModel — do not edit. */
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { createTypertRemoteInfo } from '@unieai/rabi-typert-protocol/remote-info'
|
|
5
|
+
|
|
6
|
+
let _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema$value
|
|
7
|
+
const _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema = () => (_unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema$value ??= z.object({
|
|
8
|
+
'managementAvailable': z.boolean().readonly().optional().describe('Whether this Host exposes persistent current-profile management.'),
|
|
9
|
+
'entries': z.array(z.object({
|
|
10
|
+
'entryId': z.string().readonly(),
|
|
11
|
+
'moduleName': z.string().readonly().describe('Exact module specifier imported by the Loader entry.'),
|
|
12
|
+
'meta': z.object({
|
|
13
|
+
'title': z.union([z.string(), z.intersection(z.object({
|
|
14
|
+
'en': z.string().readonly(),
|
|
15
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display title; omission preserves the consumer\'s technical-name fallback.'),
|
|
16
|
+
'description': z.union([z.string(), z.intersection(z.object({
|
|
17
|
+
'en': z.string().readonly(),
|
|
18
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display introduction after locale and package-field fallback.'),
|
|
19
|
+
'icon': z.string().readonly().optional().describe('Base64 image data URL from a package root\'s manifest icon or an exported `<specifier>/icon`; render as an image, not inline markup.'),
|
|
20
|
+
'error': z.string().readonly().optional().describe('Unmodified local metadata diagnostic; the plugin remains manageable.'),
|
|
21
|
+
}).readonly().optional().describe('Local package display metadata, independent of whether the entry is enabled.'),
|
|
22
|
+
'enabled': z.boolean().readonly().describe('Effective Loader enablement, including disabled ancestor groups.'),
|
|
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.'),
|
|
25
|
+
})).readonly(),
|
|
26
|
+
'agentPresets': z.array(z.object({
|
|
27
|
+
'id': z.string().readonly().describe('Stable preset id.'),
|
|
28
|
+
'name': z.string().readonly().optional().describe('Display name the preset published; a reader falls back to the id.'),
|
|
29
|
+
'isDefault': z.boolean().readonly().describe('Whether a session naming no preset composes this one.'),
|
|
30
|
+
'broken': z.string().readonly().optional().describe('Why this preset\'s composition cannot be read; absent when rows answer.'),
|
|
31
|
+
'rows': z.array(z.object({
|
|
32
|
+
'entryId': z.union([z.literal(null), z.string()]).readonly().describe('Composition row id, or null when the row declares none.'),
|
|
33
|
+
'moduleName': z.string().readonly().describe('Module specifier the row names.'),
|
|
34
|
+
'meta': z.object({
|
|
35
|
+
'title': z.union([z.string(), z.intersection(z.object({
|
|
36
|
+
'en': z.string().readonly(),
|
|
37
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display title; omission preserves the consumer\'s technical-name fallback.'),
|
|
38
|
+
'description': z.union([z.string(), z.intersection(z.object({
|
|
39
|
+
'en': z.string().readonly(),
|
|
40
|
+
}), z.record(z.string(), z.string()).readonly())]).readonly().optional().describe('Display introduction after locale and package-field fallback.'),
|
|
41
|
+
'icon': z.string().readonly().optional().describe('Base64 image data URL from a package root\'s manifest icon or an exported `<specifier>/icon`; render as an image, not inline markup.'),
|
|
42
|
+
'error': z.string().readonly().optional().describe('Unmodified local metadata diagnostic; the plugin remains manageable.'),
|
|
43
|
+
}).readonly().optional().describe('Local package display metadata, independent of whether the preset is mounted.'),
|
|
44
|
+
'enabled': z.union([z.literal(false), z.literal(true), z.literal("conditional")]).readonly().describe('Effective enablement, including disabled ancestor groups. `\'conditional\'` marks a `!!js` disabled expression on a composition no session has mounted, which only a Loader context can decide.'),
|
|
45
|
+
'condition': z.string().readonly().optional().describe('The row\'s own `!!js` disabled expression, when it carries one.'),
|
|
46
|
+
'fiberPhase': z.union([z.literal(null), z.literal("failed"), z.literal("pending"), z.literal("active"), z.literal("loading"), z.literal("unloading")]).readonly().describe('Root-fiber phase when the composition is live; null otherwise.'),
|
|
47
|
+
})).readonly().describe('Plugin rows in composition order; empty when the preset is broken.'),
|
|
48
|
+
})).readonly().optional().describe('Per-preset compositions, present only when an agent-preset roster is composed in this deployment.'),
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
export const TYPERT_REMOTE = createTypertRemoteInfo({
|
|
52
|
+
package: '@unieai/rabi-host-plugin-inventory',
|
|
53
|
+
methods: {
|
|
54
|
+
'pluginInventory/list': {
|
|
55
|
+
service: 'pluginInventory',
|
|
56
|
+
description: 'Read the Loader directly on every call. Cordis\'s internal plugin/status events already maintain Entry.fiber and Fiber.state, so a second cache would only add another lifecycle truth to keep synchronized. When an agent-preset roster is composed, the snapshot also carries each preset\'s composition rows, because those rows — not the Loader\'s own entries — are where a deployment that mounts the roster runs its model-facing plugins.',
|
|
57
|
+
invocation: { kind: 'direct' },
|
|
58
|
+
parameters: [
|
|
59
|
+
],
|
|
60
|
+
result: {
|
|
61
|
+
mode: 'strict',
|
|
62
|
+
typeSymbol: '@unieai/rabi-host-plugin-inventory/types#PluginInventorySnapshot',
|
|
63
|
+
create: _unieai_rabi_host_plugin_inventory_pluginInventory_list_result$schema,
|
|
64
|
+
description: 'Current non-group Loader entries in Loader order, with optional display metadata and per-preset compositions when a roster is composed.',
|
|
65
|
+
jsonSchemaError: 'typert tool schema: selected dictionaries require string keys and unconstrained JSON values',
|
|
66
|
+
},
|
|
67
|
+
sourceLocation: {"file":"packages/host/plugin-inventory/src/index.ts","line":71,"column":9},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}, z)
|
|
71
|
+
|
|
72
|
+
export default TYPERT_REMOTE
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Read-only projection of the current Cordis Loader plugin entries. */
|
|
2
|
+
import type { Context } from '@unieai/cordis';
|
|
3
|
+
import { TypertRemoteService } from '@unieai/rabi-typert-protocol';
|
|
4
|
+
import type { PluginEntryId, PluginInventorySnapshot } from './types.ts';
|
|
5
|
+
export type * from './types.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Brand an existing Loader-tree entry id at the owning boundary.
|
|
8
|
+
* @param value - the entry id as the Loader tree spells it.
|
|
9
|
+
* @returns the same id as the inventory's branded entry id.
|
|
10
|
+
*/
|
|
11
|
+
export declare function pluginEntryId(value: string): PluginEntryId;
|
|
12
|
+
/** Remote-only service exposing the Loader's current non-group entry state. */
|
|
13
|
+
export declare class PluginInventoryGateway extends TypertRemoteService {
|
|
14
|
+
static inject: string[];
|
|
15
|
+
constructor(ctx: Context);
|
|
16
|
+
/**
|
|
17
|
+
* Read the Loader directly on every call. Cordis's internal plugin/status
|
|
18
|
+
* events already maintain Entry.fiber and Fiber.state, so a second cache
|
|
19
|
+
* would only add another lifecycle truth to keep synchronized.
|
|
20
|
+
*
|
|
21
|
+
* When an agent-preset roster is composed, the snapshot also carries each
|
|
22
|
+
* preset's composition rows, because those rows — not the Loader's own
|
|
23
|
+
* entries — are where a deployment that mounts the roster runs its
|
|
24
|
+
* model-facing plugins.
|
|
25
|
+
* @returns Current non-group Loader entries in Loader order, with optional display metadata
|
|
26
|
+
* and per-preset compositions when a roster is composed.
|
|
27
|
+
*/
|
|
28
|
+
list(): Promise<PluginInventorySnapshot>;
|
|
29
|
+
}
|
|
30
|
+
export default PluginInventoryGateway;
|
|
31
|
+
/** Read current Loader entries and optional preset compositions.
|
|
32
|
+
* @param ctx Context with the Loader service.
|
|
33
|
+
* @returns Current inventory with optional display metadata and no separate runtime cache.
|
|
34
|
+
*/
|
|
35
|
+
export declare function readPluginInventory(ctx: Context): Promise<PluginInventorySnapshot>;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/** Read-only projection of the current Cordis Loader plugin entries. */
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
import { TypertRemoteService, Remote } from '@unieai/rabi-typert-protocol';
|
|
37
|
+
/**
|
|
38
|
+
* Brand an existing Loader-tree entry id at the owning boundary.
|
|
39
|
+
* @param value - the entry id as the Loader tree spells it.
|
|
40
|
+
* @returns the same id as the inventory's branded entry id.
|
|
41
|
+
*/
|
|
42
|
+
export function pluginEntryId(value) {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/** Runtime mirror: FiberState is a cross-package const enum. */
|
|
46
|
+
const FIBER_STATE = {
|
|
47
|
+
PENDING: 0,
|
|
48
|
+
LOADING: 1,
|
|
49
|
+
ACTIVE: 2,
|
|
50
|
+
FAILED: 3,
|
|
51
|
+
DISPOSED: 4,
|
|
52
|
+
UNLOADING: 5,
|
|
53
|
+
};
|
|
54
|
+
/** Complete public projection of Cordis Fiber states. */
|
|
55
|
+
const FIBER_PHASE = {
|
|
56
|
+
[FIBER_STATE.PENDING]: 'pending',
|
|
57
|
+
[FIBER_STATE.LOADING]: 'loading',
|
|
58
|
+
[FIBER_STATE.ACTIVE]: 'active',
|
|
59
|
+
[FIBER_STATE.FAILED]: 'failed',
|
|
60
|
+
[FIBER_STATE.DISPOSED]: null,
|
|
61
|
+
[FIBER_STATE.UNLOADING]: 'unloading',
|
|
62
|
+
};
|
|
63
|
+
/** Remote-only service exposing the Loader's current non-group entry state. */
|
|
64
|
+
let PluginInventoryGateway = (() => {
|
|
65
|
+
let _classSuper = TypertRemoteService;
|
|
66
|
+
let _instanceExtraInitializers = [];
|
|
67
|
+
let _list_decorators;
|
|
68
|
+
return class PluginInventoryGateway extends _classSuper {
|
|
69
|
+
static {
|
|
70
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
71
|
+
_list_decorators = [Remote('list')];
|
|
72
|
+
__esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
73
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
74
|
+
}
|
|
75
|
+
static inject = ['loader'];
|
|
76
|
+
constructor(ctx) {
|
|
77
|
+
super(ctx, 'pluginInventory');
|
|
78
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Read the Loader directly on every call. Cordis's internal plugin/status
|
|
82
|
+
* events already maintain Entry.fiber and Fiber.state, so a second cache
|
|
83
|
+
* would only add another lifecycle truth to keep synchronized.
|
|
84
|
+
*
|
|
85
|
+
* When an agent-preset roster is composed, the snapshot also carries each
|
|
86
|
+
* preset's composition rows, because those rows — not the Loader's own
|
|
87
|
+
* entries — are where a deployment that mounts the roster runs its
|
|
88
|
+
* model-facing plugins.
|
|
89
|
+
* @returns Current non-group Loader entries in Loader order, with optional display metadata
|
|
90
|
+
* and per-preset compositions when a roster is composed.
|
|
91
|
+
*/
|
|
92
|
+
async list() {
|
|
93
|
+
return readPluginInventory(this.ctx);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
})();
|
|
97
|
+
export { PluginInventoryGateway };
|
|
98
|
+
export default PluginInventoryGateway;
|
|
99
|
+
/** Read current Loader entries and optional preset compositions.
|
|
100
|
+
* @param ctx Context with the Loader service.
|
|
101
|
+
* @returns Current inventory with optional display metadata and no separate runtime cache.
|
|
102
|
+
*/
|
|
103
|
+
export async function readPluginInventory(ctx) {
|
|
104
|
+
const entries = [];
|
|
105
|
+
const packages = ctx.get('pluginPackages');
|
|
106
|
+
for (const entry of ctx.loader.entries()) {
|
|
107
|
+
if (entry.options.group)
|
|
108
|
+
continue;
|
|
109
|
+
const base = entry.parent.tree.ctx.baseUrl;
|
|
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
|
+
}
|
|
122
|
+
entries.push({
|
|
123
|
+
entryId: pluginEntryId(entry.id),
|
|
124
|
+
moduleName: entry.options.name,
|
|
125
|
+
enabled: !entry.disabled,
|
|
126
|
+
fiberPhase,
|
|
127
|
+
...diagnostic === undefined ? {} : { diagnostic },
|
|
128
|
+
...meta === undefined ? {} : { meta },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const presets = ctx.get('agentPresets');
|
|
132
|
+
const management = ctx.get('pluginManager') === undefined ? {} : { managementAvailable: true };
|
|
133
|
+
if (presets === undefined)
|
|
134
|
+
return { entries, ...management };
|
|
135
|
+
const agentPresets = (await presets.compositionInventory()).map(composition => ({
|
|
136
|
+
...composition,
|
|
137
|
+
rows: composition.rows.map(({ fiberState, ...row }) => {
|
|
138
|
+
const meta = ctx.baseUrl === undefined ? undefined : packages?.metaOf(row.moduleName, ctx.baseUrl);
|
|
139
|
+
return {
|
|
140
|
+
...row,
|
|
141
|
+
fiberPhase: fiberState === undefined ? null : FIBER_PHASE[fiberState],
|
|
142
|
+
...meta === undefined ? {} : { meta },
|
|
143
|
+
};
|
|
144
|
+
}),
|
|
145
|
+
}));
|
|
146
|
+
return { entries, agentPresets, ...management };
|
|
147
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Branded } from '@unieai/rabi-brand';
|
|
2
|
+
import type { PluginLocalizedMeta } from '@unieai/rabi-package-manifest';
|
|
3
|
+
/** Stable Loader-tree identity of one configured plugin entry. */
|
|
4
|
+
export type PluginEntryId = Branded<'PluginEntryId'>;
|
|
5
|
+
/** Lifecycle state of an entry's root Fiber, or null when it has no live root Fiber. */
|
|
6
|
+
export type PluginFiberPhase = 'pending' | 'loading' | 'active' | 'failed' | 'unloading' | null;
|
|
7
|
+
/** One non-group Loader entry exposed to trusted clients. */
|
|
8
|
+
export interface PluginInventoryEntry {
|
|
9
|
+
readonly entryId: PluginEntryId;
|
|
10
|
+
/** Exact module specifier imported by the Loader entry. */
|
|
11
|
+
readonly moduleName: string;
|
|
12
|
+
/** Local package display metadata, independent of whether the entry is enabled. */
|
|
13
|
+
readonly meta?: PluginLocalizedMeta;
|
|
14
|
+
/** Effective Loader enablement, including disabled ancestor groups. */
|
|
15
|
+
readonly enabled: boolean;
|
|
16
|
+
readonly fiberPhase: PluginFiberPhase;
|
|
17
|
+
/** Current startup failure message; absent when this entry has no failed fiber. */
|
|
18
|
+
readonly diagnostic?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Effective enablement of one preset composition row. */
|
|
21
|
+
export type PresetPluginEnablement = boolean | 'conditional';
|
|
22
|
+
/** One plugin row an agent preset's composition names. */
|
|
23
|
+
export interface AgentPresetPluginRow {
|
|
24
|
+
/** Composition row id, or null when the row declares none. */
|
|
25
|
+
readonly entryId: string | null;
|
|
26
|
+
/** Module specifier the row names. */
|
|
27
|
+
readonly moduleName: string;
|
|
28
|
+
/** Local package display metadata, independent of whether the preset is mounted. */
|
|
29
|
+
readonly meta?: PluginLocalizedMeta;
|
|
30
|
+
/**
|
|
31
|
+
* Effective enablement, including disabled ancestor groups. `'conditional'`
|
|
32
|
+
* marks a `!!js` disabled expression on a composition no session has
|
|
33
|
+
* mounted, which only a Loader context can decide.
|
|
34
|
+
*/
|
|
35
|
+
readonly enabled: PresetPluginEnablement;
|
|
36
|
+
/** The row's own `!!js` disabled expression, when it carries one. */
|
|
37
|
+
readonly condition?: string;
|
|
38
|
+
/** Root-fiber phase when the composition is live; null otherwise. */
|
|
39
|
+
readonly fiberPhase: PluginFiberPhase;
|
|
40
|
+
}
|
|
41
|
+
/** One agent preset's identity and flattened composition in the inventory. */
|
|
42
|
+
export interface AgentPresetPluginGroup {
|
|
43
|
+
/** Stable preset id. */
|
|
44
|
+
readonly id: string;
|
|
45
|
+
/** Display name the preset published; a reader falls back to the id. */
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
/** Whether a session naming no preset composes this one. */
|
|
48
|
+
readonly isDefault: boolean;
|
|
49
|
+
/** Why this preset's composition cannot be read; absent when rows answer. */
|
|
50
|
+
readonly broken?: string;
|
|
51
|
+
/** Plugin rows in composition order; empty when the preset is broken. */
|
|
52
|
+
readonly rows: readonly AgentPresetPluginRow[];
|
|
53
|
+
}
|
|
54
|
+
/** Point-in-time inventory returned by the plugin inventory Remote. */
|
|
55
|
+
export interface PluginInventorySnapshot {
|
|
56
|
+
/** Whether this Host exposes persistent current-profile management. */
|
|
57
|
+
readonly managementAvailable?: boolean;
|
|
58
|
+
readonly entries: readonly PluginInventoryEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* Per-preset compositions, present only when an agent-preset roster is
|
|
61
|
+
* composed in this deployment.
|
|
62
|
+
*/
|
|
63
|
+
readonly agentPresets?: readonly AgentPresetPluginGroup[];
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unieai/rabi-host-plugin-inventory",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Read-only Remote projection of current Cordis Loader plugin state",
|
|
4
|
+
"version": "0.2.2-rc.5",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "lib/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./types": {
|
|
17
|
+
"types": "./lib/types/types.d.ts",
|
|
18
|
+
"default": "./lib/types/types.js"
|
|
19
|
+
},
|
|
20
|
+
"./typert": {
|
|
21
|
+
"types": "./lib/typert.host.d.ts",
|
|
22
|
+
"default": "./lib/typert.host.js"
|
|
23
|
+
},
|
|
24
|
+
"./remote": {
|
|
25
|
+
"types": "./lib/typert.remote-client.d.ts",
|
|
26
|
+
"default": "./lib/typert.remote-client.js"
|
|
27
|
+
},
|
|
28
|
+
"./src/*": "./src/*",
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./locale/*.json": "./locale/*.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"locale/*.json",
|
|
34
|
+
"lib/index.js",
|
|
35
|
+
"lib/types/**/*.js",
|
|
36
|
+
"lib/types/**/*.d.ts",
|
|
37
|
+
"lib/types/**/*.d.ts.map",
|
|
38
|
+
"lib/**/*.js.map",
|
|
39
|
+
"lib/typert.host.js",
|
|
40
|
+
"lib/typert.host.d.ts",
|
|
41
|
+
"lib/typert.remote-client.js",
|
|
42
|
+
"lib/typert.remote-client.d.ts",
|
|
43
|
+
"lib/typert.remote-client.d.ts.map",
|
|
44
|
+
"src",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "4.6.6"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
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"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@unieai/rabi-agent-preset-registry": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
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
|
+
}
|