@mearl/client 2.21.0 → 2.22.1
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 +52 -8
- package/dist/actionTimeouts.js +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/browserRegistry.d.ts +1 -1
- package/dist/check.d.ts +1 -1
- package/dist/cli.js +4 -3
- package/dist/commands.d.ts +12 -12
- package/dist/commands.js +6 -4
- package/dist/{generated-app-profile-definition.d.ts → generated/app-profile-definition.d.ts} +2 -2
- package/dist/{generated-app-profile-runtime-types.d.ts → generated/app-profile-runtime-types.d.ts} +2 -2
- package/dist/{generated-browser-action-protocol.d.ts → generated/browser-action-protocol.d.ts} +1 -1
- package/dist/{generated-plugin-diagnostics.d.ts → generated/plugin-diagnostics.d.ts} +4 -4
- package/dist/{generated-plugin-execution.d.ts → generated/plugin-execution.d.ts} +2 -2
- package/dist/generated/plugin-host-build.d.ts +1 -0
- package/dist/generated/plugin-host-build.js +2 -0
- package/dist/{generated-plugin-pages.d.ts → generated/plugin-pages.d.ts} +1 -1
- package/dist/{generated-plugin-tasks.d.ts → generated/plugin-tasks.d.ts} +2 -2
- package/dist/index.d.ts +15 -15
- package/dist/index.js +7 -7
- package/dist/pageEvalArguments.d.ts +1 -1
- package/dist/pageEvalArguments.js +1 -1
- package/dist/plugin-task-host.js +1 -1
- package/dist/plugin-worker.js +2 -2
- package/dist/plugin.d.ts +2 -118
- package/dist/plugin.js +2 -672
- package/dist/pluginModelSessionWorker.d.ts +2 -2
- package/dist/pluginModelSessionWorker.js +4 -4
- package/dist/{pluginHostConnection.d.ts → plugins/clients/pluginHostConnection.d.ts} +4 -2
- package/dist/{pluginHostConnection.js → plugins/clients/pluginHostConnection.js} +9 -8
- package/dist/{pluginModels.d.ts → plugins/clients/pluginModels.d.ts} +3 -3
- package/dist/{pluginPages.d.ts → plugins/clients/pluginPages.d.ts} +3 -3
- package/dist/{pluginPages.js → plugins/clients/pluginPages.js} +1 -1
- package/dist/{pluginState.d.ts → plugins/clients/pluginState.d.ts} +3 -3
- package/dist/{pluginTasks.d.ts → plugins/clients/pluginTasks.d.ts} +4 -4
- package/dist/{pluginTasks.js → plugins/clients/pluginTasks.js} +4 -4
- package/dist/{officialPluginInstaller.js → plugins/officialPluginInstaller.js} +1 -3
- package/dist/{pluginRegistry.d.ts → plugins/pluginRegistry.d.ts} +2 -2
- package/dist/{pluginRegistry.js → plugins/pluginRegistry.js} +14 -7
- package/dist/{pluginTaskProtocol.d.ts → plugins/pluginTaskProtocol.d.ts} +2 -2
- package/dist/{pluginCommandWorker.js → plugins/runtime/pluginCommandWorker.js} +3 -3
- package/dist/{pluginDiagnostics.d.ts → plugins/runtime/pluginDiagnostics.d.ts} +4 -4
- package/dist/{pluginDiagnostics.js → plugins/runtime/pluginDiagnostics.js} +2 -2
- package/dist/{pluginExecution.d.ts → plugins/runtime/pluginExecution.d.ts} +3 -3
- package/dist/{pluginExecution.js → plugins/runtime/pluginExecution.js} +1 -1
- package/dist/{pluginExecutor.d.ts → plugins/runtime/pluginExecutor.d.ts} +3 -3
- package/dist/{pluginExecutor.js → plugins/runtime/pluginExecutor.js} +4 -4
- package/dist/{pluginExecutorProtocol.d.ts → plugins/runtime/pluginExecutorProtocol.d.ts} +4 -4
- package/dist/{pluginHost.d.ts → plugins/runtime/pluginHost.d.ts} +3 -3
- package/dist/{pluginHostPaths.js → plugins/runtime/pluginHostPaths.js} +1 -1
- package/dist/{pluginHostServer.js → plugins/runtime/pluginHostServer.js} +11 -3
- package/dist/{pluginModelCatalog.d.ts → plugins/runtime/pluginModelCatalog.d.ts} +1 -1
- package/dist/{pluginModelSessions.js → plugins/runtime/pluginModelSessions.js} +3 -3
- package/dist/{pluginPageManager.d.ts → plugins/runtime/pluginPageManager.d.ts} +4 -4
- package/dist/{pluginPageManager.js → plugins/runtime/pluginPageManager.js} +4 -8
- package/dist/{pluginRevision.d.ts → plugins/runtime/pluginRevision.d.ts} +1 -1
- package/dist/{pluginRevision.js → plugins/runtime/pluginRevision.js} +3 -53
- package/dist/{pluginRuntimeCleanup.js → plugins/runtime/pluginRuntimeCleanup.js} +2 -2
- package/dist/{pluginStateManager.d.ts → plugins/runtime/pluginStateManager.d.ts} +2 -2
- package/dist/{pluginStateManager.js → plugins/runtime/pluginStateManager.js} +2 -2
- package/dist/{pluginStateStore.d.ts → plugins/runtime/pluginStateStore.d.ts} +1 -1
- package/dist/{pluginStateStore.js → plugins/runtime/pluginStateStore.js} +3 -8
- package/dist/{pluginTaskManager.d.ts → plugins/runtime/pluginTaskManager.d.ts} +12 -12
- package/dist/{pluginTaskManager.js → plugins/runtime/pluginTaskManager.js} +8 -12
- package/dist/{pluginTaskStore.d.ts → plugins/runtime/pluginTaskStore.d.ts} +4 -4
- package/dist/{pluginTaskStore.js → plugins/runtime/pluginTaskStore.js} +1 -1
- package/dist/{pythonPlugin.d.ts → plugins/runtime/pythonPlugin.d.ts} +2 -2
- package/dist/{pythonPlugin.js → plugins/runtime/pythonPlugin.js} +2 -2
- package/dist/plugins/sdk/plugin.d.ts +118 -0
- package/dist/plugins/sdk/plugin.js +676 -0
- package/dist/{pluginAppProfiles.d.ts → plugins/sdk/pluginAppProfiles.d.ts} +1 -1
- package/dist/{pluginAppProfiles.js → plugins/sdk/pluginAppProfiles.js} +2 -2
- package/dist/{pluginModelDefinition.d.ts → plugins/sdk/pluginModelDefinition.d.ts} +1 -1
- package/dist/{pluginModelDefinition.js → plugins/sdk/pluginModelDefinition.js} +0 -6
- package/dist/plugins/sdk/pluginPageDefinition.d.ts +2 -0
- package/dist/{pluginPageDefinition.js → plugins/sdk/pluginPageDefinition.js} +3 -19
- package/dist/{pluginRecoveryDefinition.d.ts → plugins/sdk/pluginRecoveryDefinition.d.ts} +1 -1
- package/dist/{pluginRecoveryDefinition.js → plugins/sdk/pluginRecoveryDefinition.js} +0 -3
- package/dist/plugins/sdk/pluginStateDefinition.d.ts +3 -0
- package/dist/{pluginStateDefinition.js → plugins/sdk/pluginStateDefinition.js} +0 -11
- package/dist/plugins/skillManifest.d.ts +5 -0
- package/dist/plugins/skillManifest.js +35 -0
- package/dist/runtimePaths.d.ts +4 -0
- package/dist/runtimePaths.js +8 -0
- package/dist/socket.d.ts +2 -2
- package/dist/socket.js +5 -4
- package/dist/unified.d.ts +2 -2
- package/dist/unified.js +7 -7
- package/package.json +6 -8
- package/dist/pluginPageDefinition.d.ts +0 -3
- package/dist/pluginStateDefinition.d.ts +0 -4
- /package/dist/{generated-app-profile-definition.js → generated/app-profile-definition.js} +0 -0
- /package/dist/{generated-app-profile-runtime-types.js → generated/app-profile-runtime-types.js} +0 -0
- /package/dist/{generated-browser-action-protocol.js → generated/browser-action-protocol.js} +0 -0
- /package/dist/{generated-plugin-diagnostics.js → generated/plugin-diagnostics.js} +0 -0
- /package/dist/{generated-plugin-execution.js → generated/plugin-execution.js} +0 -0
- /package/dist/{generated-plugin-models.d.ts → generated/plugin-models.d.ts} +0 -0
- /package/dist/{generated-plugin-models.js → generated/plugin-models.js} +0 -0
- /package/dist/{generated-plugin-pages.js → generated/plugin-pages.js} +0 -0
- /package/dist/{generated-plugin-recovery.d.ts → generated/plugin-recovery.d.ts} +0 -0
- /package/dist/{generated-plugin-recovery.js → generated/plugin-recovery.js} +0 -0
- /package/dist/{generated-plugin-state.d.ts → generated/plugin-state.d.ts} +0 -0
- /package/dist/{generated-plugin-state.js → generated/plugin-state.js} +0 -0
- /package/dist/{generated-plugin-tasks.js → generated/plugin-tasks.js} +0 -0
- /package/dist/{generated-toolbox-icon.d.ts → generated/toolbox-icon.d.ts} +0 -0
- /package/dist/{generated-toolbox-icon.js → generated/toolbox-icon.js} +0 -0
- /package/dist/{pluginModels.js → plugins/clients/pluginModels.js} +0 -0
- /package/dist/{pluginState.js → plugins/clients/pluginState.js} +0 -0
- /package/dist/{officialPluginCatalog.d.ts → plugins/officialPluginCatalog.d.ts} +0 -0
- /package/dist/{officialPluginCatalog.js → plugins/officialPluginCatalog.js} +0 -0
- /package/dist/{officialPluginInstaller.d.ts → plugins/officialPluginInstaller.d.ts} +0 -0
- /package/dist/{pluginPageBundle.d.ts → plugins/pluginPageBundle.d.ts} +0 -0
- /package/dist/{pluginPageBundle.js → plugins/pluginPageBundle.js} +0 -0
- /package/dist/{pluginSource.d.ts → plugins/pluginSource.d.ts} +0 -0
- /package/dist/{pluginSource.js → plugins/pluginSource.js} +0 -0
- /package/dist/{pluginTaskProtocol.js → plugins/pluginTaskProtocol.js} +0 -0
- /package/dist/{pluginTaskWire.d.ts → plugins/pluginTaskWire.d.ts} +0 -0
- /package/dist/{pluginTaskWire.js → plugins/pluginTaskWire.js} +0 -0
- /package/dist/{pluginCommandWorker.d.ts → plugins/runtime/pluginCommandWorker.d.ts} +0 -0
- /package/dist/{pluginExecutorProtocol.js → plugins/runtime/pluginExecutorProtocol.js} +0 -0
- /package/dist/{pluginExecutorSupervisor.d.ts → plugins/runtime/pluginExecutorSupervisor.d.ts} +0 -0
- /package/dist/{pluginExecutorSupervisor.js → plugins/runtime/pluginExecutorSupervisor.js} +0 -0
- /package/dist/{pluginHost.js → plugins/runtime/pluginHost.js} +0 -0
- /package/dist/{pluginHostFiles.d.ts → plugins/runtime/pluginHostFiles.d.ts} +0 -0
- /package/dist/{pluginHostFiles.js → plugins/runtime/pluginHostFiles.js} +0 -0
- /package/dist/{pluginHostPaths.d.ts → plugins/runtime/pluginHostPaths.d.ts} +0 -0
- /package/dist/{pluginHostServer.d.ts → plugins/runtime/pluginHostServer.d.ts} +0 -0
- /package/dist/{pluginModelCatalog.js → plugins/runtime/pluginModelCatalog.js} +0 -0
- /package/dist/{pluginModelSessions.d.ts → plugins/runtime/pluginModelSessions.d.ts} +0 -0
- /package/dist/{pluginProcessTree.d.ts → plugins/runtime/pluginProcessTree.d.ts} +0 -0
- /package/dist/{pluginProcessTree.js → plugins/runtime/pluginProcessTree.js} +0 -0
- /package/dist/{pluginRuntimeCleanup.d.ts → plugins/runtime/pluginRuntimeCleanup.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
3
|
-
import { validateAppProfileContribution, } from '
|
|
4
|
-
import { pluginFileVersion } from '
|
|
3
|
+
import { validateAppProfileContribution, } from '../../generated/app-profile-definition.js';
|
|
4
|
+
import { pluginFileVersion } from '../pluginSource.js';
|
|
5
5
|
/** Profile resources share the Skill root and metadata refresh rules of toolbox resources. */
|
|
6
6
|
export function loadPluginAppProfiles(entry, value) {
|
|
7
7
|
if (value === undefined)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginModelCapability, PluginModelRequest, PluginModelResult } from '
|
|
1
|
+
import type { PluginModelCapability, PluginModelRequest, PluginModelResult } from '../../generated/plugin-models.js';
|
|
2
2
|
export declare function pluginModelCapabilities(): {
|
|
3
3
|
providers: PluginModelCapability[];
|
|
4
4
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CODEX_MODEL_CAPABILITY } from '@mearl/agent-runtime/capabilities';
|
|
2
|
-
import { compilePluginStateSchema } from './pluginStateDefinition.js';
|
|
3
2
|
export function pluginModelCapabilities() {
|
|
4
3
|
return { providers: [CODEX_MODEL_CAPABILITY] };
|
|
5
4
|
}
|
|
@@ -44,7 +43,6 @@ export function normalizePluginModel(value) {
|
|
|
44
43
|
request.outputSchema.$async ||
|
|
45
44
|
Buffer.byteLength(JSON.stringify(request.outputSchema)) > 64 * 1024)
|
|
46
45
|
throw new Error('Invalid model output schema');
|
|
47
|
-
compilePluginStateSchema(request.outputSchema);
|
|
48
46
|
}
|
|
49
47
|
return JSON.parse(JSON.stringify(request));
|
|
50
48
|
}
|
|
@@ -65,10 +63,6 @@ export function validatePluginModelResult(request, value) {
|
|
|
65
63
|
code: 'PLUGIN_MODEL_SCHEMA_INVALID',
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
|
-
if (!compilePluginStateSchema(request.outputSchema)(output))
|
|
69
|
-
throw Object.assign(new Error('Model result does not match the output schema'), {
|
|
70
|
-
code: 'PLUGIN_MODEL_SCHEMA_INVALID',
|
|
71
|
-
});
|
|
72
66
|
return { ...result, output };
|
|
73
67
|
}
|
|
74
68
|
return result;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { isPluginPageMatchPattern } from './generated-plugin-pages.js';
|
|
4
|
-
const validators = new WeakMap();
|
|
1
|
+
import { Script } from 'node:vm';
|
|
2
|
+
import { isPluginPageMatchPattern } from '../../generated/plugin-pages.js';
|
|
5
3
|
export function normalizePluginPageRuntime(value) {
|
|
6
4
|
if (value === undefined)
|
|
7
5
|
return undefined;
|
|
@@ -16,12 +14,7 @@ export function normalizePluginPageRuntime(value) {
|
|
|
16
14
|
Buffer.byteLength(runtime.code) > 384 * 1024 ||
|
|
17
15
|
Buffer.byteLength(JSON.stringify(runtime)) > 448 * 1024)
|
|
18
16
|
throw new Error('Invalid plugin pageRuntime declaration');
|
|
19
|
-
|
|
20
|
-
const statement = program.body[0];
|
|
21
|
-
if (program.body.length !== 1 ||
|
|
22
|
-
statement.type !== 'ExpressionStatement' ||
|
|
23
|
-
!['ArrowFunctionExpression', 'FunctionExpression'].includes(statement.expression?.type ?? ''))
|
|
24
|
-
throw new Error('pageRuntime.code must be a self-contained function expression');
|
|
17
|
+
new Script(`(${runtime.code}\n)`, { filename: 'plugin-page-runtime.js' });
|
|
25
18
|
if (runtime.events !== undefined &&
|
|
26
19
|
(!runtime.events ||
|
|
27
20
|
typeof runtime.events !== 'object' ||
|
|
@@ -46,17 +39,8 @@ export function normalizePluginPageRuntime(value) {
|
|
|
46
39
|
event.maxPending > 64)) ||
|
|
47
40
|
event.schema.$async)
|
|
48
41
|
throw new Error(`Invalid page event binding: ${name}`);
|
|
49
|
-
compilePluginPageSchema(event.schema);
|
|
50
42
|
}
|
|
51
43
|
if (runtime.initialize !== undefined && !/^[a-z][a-z0-9-]*$/.test(runtime.initialize))
|
|
52
44
|
throw new Error('Invalid page runtime initialize command');
|
|
53
45
|
return JSON.parse(JSON.stringify(runtime));
|
|
54
46
|
}
|
|
55
|
-
export function compilePluginPageSchema(schema) {
|
|
56
|
-
let validate = validators.get(schema);
|
|
57
|
-
if (!validate) {
|
|
58
|
-
validate = new Ajv({ strict: true, allErrors: false }).compile(schema);
|
|
59
|
-
validators.set(schema, validate);
|
|
60
|
-
}
|
|
61
|
-
return validate;
|
|
62
|
-
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PluginTaskRecoveryDeclaration } from '
|
|
1
|
+
import type { PluginTaskRecoveryDeclaration } from '../../generated/plugin-recovery.js';
|
|
2
2
|
export declare function normalizePluginTaskRecovery(value: unknown): PluginTaskRecoveryDeclaration | undefined;
|
|
3
3
|
export declare function pluginRecoverySignature(value: unknown): string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { compilePluginStateSchema } from './pluginStateDefinition.js';
|
|
3
2
|
export function normalizePluginTaskRecovery(value) {
|
|
4
3
|
if (value === undefined)
|
|
5
4
|
return;
|
|
@@ -22,7 +21,6 @@ export function normalizePluginTaskRecovery(value) {
|
|
|
22
21
|
Array.isArray(definition.schema) ||
|
|
23
22
|
definition.schema.$async)
|
|
24
23
|
throw new Error('Invalid task checkpoint definition');
|
|
25
|
-
compilePluginStateSchema(definition.schema);
|
|
26
24
|
if (definition.migrateFrom !== undefined) {
|
|
27
25
|
if (!Array.isArray(definition.migrateFrom) ||
|
|
28
26
|
definition.migrateFrom.length < 1 ||
|
|
@@ -40,7 +38,6 @@ export function normalizePluginTaskRecovery(value) {
|
|
|
40
38
|
Array.isArray(source.schema) ||
|
|
41
39
|
source.schema.$async)
|
|
42
40
|
throw new Error('Checkpoint migrations require distinct older versions and schemas');
|
|
43
|
-
compilePluginStateSchema(source.schema);
|
|
44
41
|
versions.add(source.version);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PluginStateDeclaration } from '../../generated/plugin-state.js';
|
|
2
|
+
export declare function normalizePluginState(value: unknown): PluginStateDeclaration | undefined;
|
|
3
|
+
export declare function pluginStateSignature(collection: import('../../generated/plugin-state.js').PluginStateCollection): string;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { Ajv } from 'ajv';
|
|
3
|
-
const validators = new WeakMap();
|
|
4
|
-
export function compilePluginStateSchema(schema) {
|
|
5
|
-
let validate = validators.get(schema);
|
|
6
|
-
if (!validate) {
|
|
7
|
-
validate = new Ajv({ strict: true }).compile(schema);
|
|
8
|
-
validators.set(schema, validate);
|
|
9
|
-
}
|
|
10
|
-
return validate;
|
|
11
|
-
}
|
|
12
2
|
export function normalizePluginState(value) {
|
|
13
3
|
if (value === undefined)
|
|
14
4
|
return;
|
|
@@ -55,7 +45,6 @@ export function normalizePluginState(value) {
|
|
|
55
45
|
throw new Error('State TTL must be between 1 ms and 7 days');
|
|
56
46
|
if (collection.storage === 'persistent' && collection.ttlMs !== undefined)
|
|
57
47
|
throw new Error('Persistent state does not accept TTL');
|
|
58
|
-
compilePluginStateSchema(collection.schema);
|
|
59
48
|
}
|
|
60
49
|
return declaration;
|
|
61
50
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const DISABLED_SKILL_MANIFEST = "SKILL.md.mearl-disabled";
|
|
2
|
+
/** 保留的清单供工具运行时读取,但不参与 Agent 的 SKILL.md 发现。 */
|
|
3
|
+
export declare function skillManifestPath(directory: string): string | undefined;
|
|
4
|
+
export declare function getSkillEnabled(directory: string): boolean | undefined;
|
|
5
|
+
export declare function setSkillEnabled(directory: string, enabled: boolean): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, lstatSync, renameSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export const DISABLED_SKILL_MANIFEST = 'SKILL.md.mearl-disabled';
|
|
4
|
+
/** 保留的清单供工具运行时读取,但不参与 Agent 的 SKILL.md 发现。 */
|
|
5
|
+
export function skillManifestPath(directory) {
|
|
6
|
+
for (const name of ['SKILL.md', DISABLED_SKILL_MANIFEST]) {
|
|
7
|
+
const file = join(directory, name);
|
|
8
|
+
if (existsSync(file))
|
|
9
|
+
return file;
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
export function getSkillEnabled(directory) {
|
|
14
|
+
const manifest = skillManifestPath(directory);
|
|
15
|
+
return manifest ? manifest === join(directory, 'SKILL.md') : undefined;
|
|
16
|
+
}
|
|
17
|
+
export function setSkillEnabled(directory, enabled) {
|
|
18
|
+
const active = join(directory, 'SKILL.md');
|
|
19
|
+
const disabled = join(directory, DISABLED_SKILL_MANIFEST);
|
|
20
|
+
const source = enabled ? disabled : active;
|
|
21
|
+
const destination = enabled ? active : disabled;
|
|
22
|
+
const sourceStatus = lstatSync(source, { throwIfNoEntry: false });
|
|
23
|
+
const destinationStatus = lstatSync(destination, { throwIfNoEntry: false });
|
|
24
|
+
if (sourceStatus && destinationStatus) {
|
|
25
|
+
throw new Error('Skill 清单存在冲突,请检查 SKILL.md 和 SKILL.md.mearl-disabled');
|
|
26
|
+
}
|
|
27
|
+
if (!sourceStatus) {
|
|
28
|
+
if (destinationStatus?.isFile())
|
|
29
|
+
return;
|
|
30
|
+
throw new Error('找不到 Skill 清单');
|
|
31
|
+
}
|
|
32
|
+
if (!sourceStatus.isFile())
|
|
33
|
+
throw new Error('Skill 清单必须是普通文件');
|
|
34
|
+
renameSync(source, destination);
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
// Package metadata and process entries share this anchor in compiled and bundled hosts.
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
export const CLIENT_VERSION = require('../package.json').version;
|
|
6
|
+
export const PLUGIN_TASK_HOST_PATH = fileURLToPath(new URL('./plugin-task-host.js', import.meta.url));
|
|
7
|
+
export const PLUGIN_WORKER_PATH = fileURLToPath(new URL('./plugin-worker.js', import.meta.url));
|
|
8
|
+
export const PLUGIN_MODEL_SESSION_WORKER_PATH = fileURLToPath(new URL('./pluginModelSessionWorker.js', import.meta.url));
|
package/dist/socket.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* 当 Socket 不存在,或 legacy Socket 是无人监听的残留文件时,
|
|
8
8
|
* 自动尝试拉起 native host,稍后重试连接。
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
import { CLIENT_VERSION } from './runtimePaths.js';
|
|
11
|
+
export { CLIENT_VERSION };
|
|
11
12
|
/**
|
|
12
13
|
* Legacy well-known socket. New native-hosts publish per-browser sockets in the
|
|
13
14
|
* registry and we address those; this path is a fallback for pre-registry hosts
|
|
@@ -46,4 +47,3 @@ export declare function resolveLocalActionTarget(action: string, data: Record<st
|
|
|
46
47
|
* legacy well-known socket,并在 socket 不存在或已残留时自动拉起 native host。
|
|
47
48
|
*/
|
|
48
49
|
export declare function invoke(action: string, data?: Record<string, any>, options?: InvokeOptions): Promise<any>;
|
|
49
|
-
export {};
|
package/dist/socket.js
CHANGED
|
@@ -11,16 +11,16 @@ import net from 'node:net';
|
|
|
11
11
|
import fs from 'node:fs';
|
|
12
12
|
import os from 'node:os';
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
import {
|
|
14
|
+
import { CLIENT_VERSION } from './runtimePaths.js';
|
|
15
15
|
import { StringDecoder } from 'node:string_decoder';
|
|
16
16
|
import { ensureProviderControlHost, listInstalledProviders } from '@mearl/provider/host';
|
|
17
|
+
import { MEARL_PROVIDER_PROTOCOL_VERSION } from '@mearl/provider';
|
|
17
18
|
import { readLiveProvider } from '@mearl/provider/runtime';
|
|
18
19
|
import { resolveFileRefs } from './fileRefs.js';
|
|
19
20
|
import { listLiveBrowsers, findBrowser, describeBrowser, } from './browserRegistry.js';
|
|
20
21
|
import { resolveActionTimeoutSec } from './actionTimeouts.js';
|
|
21
|
-
import { isBrowserCapabilityAction } from './generated
|
|
22
|
-
|
|
23
|
-
export const CLIENT_VERSION = require('../package.json').version;
|
|
22
|
+
import { isBrowserCapabilityAction } from './generated/browser-action-protocol.js';
|
|
23
|
+
export { CLIENT_VERSION };
|
|
24
24
|
const MAX_SOCKET_BUFFER_SIZE = 64 * 1024 * 1024;
|
|
25
25
|
/**
|
|
26
26
|
* Legacy well-known socket. New native-hosts publish per-browser sockets in the
|
|
@@ -617,6 +617,7 @@ async function invokeOnce(action, data, timeoutSec, transport, socketPath, contr
|
|
|
617
617
|
action,
|
|
618
618
|
data,
|
|
619
619
|
version: CLIENT_VERSION,
|
|
620
|
+
protocolVersion: MEARL_PROVIDER_PROTOCOL_VERSION,
|
|
620
621
|
controlSource: toControlSourceWireValue(controlSource),
|
|
621
622
|
};
|
|
622
623
|
if (data[SESSION_OPTION])
|
package/dist/unified.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BrowserArtifact } from './generated
|
|
1
|
+
import type { BrowserArtifact } from './generated/browser-action-protocol.js';
|
|
2
2
|
import { type CloudConnectorListResult } from '@mearl/cloud-types';
|
|
3
|
-
import type { PluginInvocation, PluginInvokeOptions } from './plugin.js';
|
|
3
|
+
import type { PluginInvocation, PluginInvokeOptions } from './plugins/sdk/plugin.js';
|
|
4
4
|
export interface UnifiedInvokeOptions {
|
|
5
5
|
/** Use new on the first tab_open/page_snapshot, then reuse the returned id. */
|
|
6
6
|
session?: string;
|
package/dist/unified.js
CHANGED
|
@@ -3,7 +3,7 @@ import { stageFile, exportArtifact } from './artifacts.js';
|
|
|
3
3
|
import WebSocket from 'ws';
|
|
4
4
|
import { DEFAULT_CONNECT_TIMEOUT, DEFAULT_HEARTBEAT_INTERVAL, DEFAULT_REQUEST_TIMEOUT, MAX_BUFFER_SIZE, isHeartbeatMessage, resolveCloudConnectorSelector, } from '@mearl/cloud-types';
|
|
5
5
|
import { resolveActionTimeoutSec } from './actionTimeouts.js';
|
|
6
|
-
import { validateRequiredActionTabId, } from './generated
|
|
6
|
+
import { validateRequiredActionTabId, } from './generated/browser-action-protocol.js';
|
|
7
7
|
import { invoke as invokeLocalBrowser, resolveLocalActionTarget } from './socket.js';
|
|
8
8
|
import { loadCloudServerConfig, loadLocalConnectorId } from './unifiedConfig.js';
|
|
9
9
|
const RESPONSE_GRACE_MS = 1_000;
|
|
@@ -124,11 +124,11 @@ export class UnifiedClient {
|
|
|
124
124
|
this.ws = null;
|
|
125
125
|
}
|
|
126
126
|
async invokePlugin(name, invocation, options = {}) {
|
|
127
|
-
const { invokeRegisteredPlugin } = await import('./plugin.js');
|
|
127
|
+
const { invokeRegisteredPlugin } = await import('./plugins/sdk/plugin.js');
|
|
128
128
|
return invokeRegisteredPlugin(name, invocation, {
|
|
129
129
|
invoke: (action, payload, invokeOptions) => this.invoke(action, payload, invokeOptions),
|
|
130
130
|
runModel: async (plugin, request, execution) => {
|
|
131
|
-
const { PluginModelClient } = await import('./pluginModels.js');
|
|
131
|
+
const { PluginModelClient } = await import('./plugins/clients/pluginModels.js');
|
|
132
132
|
const models = new PluginModelClient({ source: options.source ?? 'sdk' });
|
|
133
133
|
try {
|
|
134
134
|
return await models.run(plugin, request, {
|
|
@@ -147,7 +147,7 @@ export class UnifiedClient {
|
|
|
147
147
|
}
|
|
148
148
|
async invoke(action, data = {}, options = {}) {
|
|
149
149
|
if (action === 'plugin_state') {
|
|
150
|
-
const { PluginStateClient } = await import('./pluginState.js');
|
|
150
|
+
const { PluginStateClient } = await import('./plugins/clients/pluginState.js');
|
|
151
151
|
const state = new PluginStateClient();
|
|
152
152
|
try {
|
|
153
153
|
return await state.call(String(data.plugin ?? ''), data.collection, data.operation, data, options);
|
|
@@ -157,7 +157,7 @@ export class UnifiedClient {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
if (action === 'plugin_model') {
|
|
160
|
-
const { PluginModelClient } = await import('./pluginModels.js');
|
|
160
|
+
const { PluginModelClient } = await import('./plugins/clients/pluginModels.js');
|
|
161
161
|
const models = new PluginModelClient();
|
|
162
162
|
try {
|
|
163
163
|
if (data.operation === 'capabilities')
|
|
@@ -175,8 +175,8 @@ export class UnifiedClient {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
if (action === 'plugin_page') {
|
|
178
|
-
const { PluginHostConnection } = await import('./pluginHostConnection.js');
|
|
179
|
-
const { PluginPageClient } = await import('./pluginPages.js');
|
|
178
|
+
const { PluginHostConnection } = await import('./plugins/clients/pluginHostConnection.js');
|
|
179
|
+
const { PluginPageClient } = await import('./plugins/clients/pluginPages.js');
|
|
180
180
|
const connection = new PluginHostConnection();
|
|
181
181
|
const pages = new PluginPageClient({}, connection);
|
|
182
182
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "Unified Mearl SDK & CLI for local and remote browsers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -60,15 +60,13 @@
|
|
|
60
60
|
"registry": "https://registry.npmjs.org"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"acorn": "^8.16.0",
|
|
64
|
-
"ajv": "^8.18.0",
|
|
65
63
|
"commander": "^15.0.0",
|
|
66
64
|
"fastest-levenshtein": "^1.0.16",
|
|
67
65
|
"ws": "^8.18.0",
|
|
68
|
-
"@mearl/
|
|
69
|
-
"@mearl/
|
|
70
|
-
"@mearl/
|
|
71
|
-
"@mearl/
|
|
66
|
+
"@mearl/cloud-types": "2.22.1",
|
|
67
|
+
"@mearl/daemon-core": "2.22.1",
|
|
68
|
+
"@mearl/provider": "2.22.1",
|
|
69
|
+
"@mearl/agent-runtime": "2.22.1"
|
|
72
70
|
},
|
|
73
71
|
"devDependencies": {
|
|
74
72
|
"@types/node": "^24.9.1",
|
|
@@ -76,7 +74,7 @@
|
|
|
76
74
|
"typescript": "^5.8.3"
|
|
77
75
|
},
|
|
78
76
|
"scripts": {
|
|
79
|
-
"build": "node ../../scripts/generate-client-action-protocol.mjs --check && rm -rf dist/ && tsc && chmod +x dist/bin.js",
|
|
77
|
+
"build": "node ../../scripts/generate-client-action-protocol.mjs --check && node ../../scripts/generate-plugin-host-build.mjs && rm -rf dist/ && tsc && chmod +x dist/bin.js",
|
|
80
78
|
"dev": "tsc --watch",
|
|
81
79
|
"typecheck": "node ../../scripts/generate-client-action-protocol.mjs --check && tsc --noEmit",
|
|
82
80
|
"test": "vitest run"
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { PluginPageRuntime } from './generated-plugin-pages.js';
|
|
2
|
-
export declare function normalizePluginPageRuntime(value: unknown): PluginPageRuntime | undefined;
|
|
3
|
-
export declare function compilePluginPageSchema(schema: Record<string, unknown>): import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PluginStateDeclaration } from './generated-plugin-state.js';
|
|
2
|
-
export declare function compilePluginStateSchema(schema: Record<string, unknown>): import("ajv/dist/core.js").AnyValidateFunction<unknown>;
|
|
3
|
-
export declare function normalizePluginState(value: unknown): PluginStateDeclaration | undefined;
|
|
4
|
-
export declare function pluginStateSignature(collection: import('./generated-plugin-state.js').PluginStateCollection): string;
|
|
File without changes
|
/package/dist/{generated-app-profile-runtime-types.js → generated/app-profile-runtime-types.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{pluginExecutorSupervisor.d.ts → plugins/runtime/pluginExecutorSupervisor.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|