@myclaw163/clawclaw-cli 0.10.15 → 0.10.17
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 +1 -1
- package/cli-runtime/cli.js +16 -1
- package/cli-runtime/commands/runtime.js +35 -0
- package/cli-runtime/lib/account-resource-lock.js +15 -0
- package/cli-runtime/lib/agent-workspace-skills.js +3 -1
- package/cli-runtime/lib/desktop-mode.js +3 -0
- package/cli-runtime/lib/harness-context.js +20 -0
- package/cli-runtime/lib/init-command.js +2 -1
- package/cli-runtime/lib/lobby-host-context.js +1 -2
- package/cli-runtime/lib/skill-host.js +2 -0
- package/cli-runtime/lib/user-data.js +4 -2
- package/cli-runtime/runtime/clawclaw/behavior-reflex-control.js +27 -36
- package/cli-runtime/runtime/clawclaw/behavior-trigger.js +25 -46
- package/cli-runtime/runtime/clawclaw/owner-lock.js +2 -1
- package/cli-runtime/runtime/clawclaw/owner.js +7 -6
- package/cli-runtime/runtime/clawclaw/plugins/assembly.js +8 -7
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-source.js +6 -5
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-plugin.js +5 -2
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-runner.js +2 -1
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.js +7 -1
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.ts +7 -1
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-module-loader.js +7 -17
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-plugin.js +3 -30
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.js +0 -2
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +0 -2
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/host.js +58 -1
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/sdk-sdk.js +46 -25
- package/docs/configuration.md +6 -0
- package/docs/custom-modules/README.md +1 -2
- package/docs/custom-modules/api-reference.md +8 -10
- package/docs/custom-modules/behavior.md +21 -23
- package/docs/custom-modules/examples/auto-escape.ts +17 -19
- package/docs/custom-modules/perception.md +2 -2
- package/docs/runtime/README.md +1 -1
- package/docs/runtime/behavior-runtime.md +4 -5
- package/docs/runtime/components-and-boundaries.md +4 -5
- package/docs/runtime/events-and-state.md +1 -1
- package/docs/runtime/owner-lifecycle-and-observability.md +2 -2
- package/docs/user-guide/README.md +1 -1
- package/docs/user-guide/api-reference.md +8 -10
- package/docs/user-guide/behavior.md +21 -23
- package/docs/user-guide/perception.md +2 -2
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +3 -3
- package/skills/clawclaw/references/BEHAVIORS.md +1 -1
- package/skills/clawclaw-creator/SKILL.md +1 -1
- package/skills/clawclaw-creator/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +21 -23
- package/skills/clawclaw-creator/references/CUSTOM-MODULE-API.md +8 -10
- package/skills/clawclaw-creator/references/CUSTOM-MODULES.md +1 -2
- package/skills/clawclaw-creator/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +2 -2
- package/src/cli.ts +12 -1
- package/src/commands/runtime.ts +26 -0
- package/src/lib/account-resource-lock.ts +14 -0
- package/src/lib/agent-workspace-skills.ts +3 -2
- package/src/lib/desktop-mode.ts +4 -0
- package/src/lib/harness-context.ts +21 -0
- package/src/lib/init-command.ts +2 -1
- package/src/lib/lobby-host-context.ts +2 -2
- package/src/lib/skill-host.ts +2 -0
- package/src/lib/user-data.ts +5 -2
- package/src/runtime/clawclaw/behavior-reflex-control.ts +26 -22
- package/src/runtime/clawclaw/behavior-trigger.ts +20 -41
- package/src/runtime/clawclaw/owner-lock.ts +2 -1
- package/src/runtime/clawclaw/owner.ts +7 -6
- package/src/runtime/clawclaw/plugins/assembly.ts +11 -8
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +7 -6
- package/src/runtime/clawclaw/plugins/perception/perception-module-plugin.ts +6 -2
- package/src/runtime/clawclaw/plugins/perception/perception-module-runner.ts +2 -1
- package/src/runtime/clawclaw/plugins/perception/perception-module-worker.ts +7 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +1 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +8 -19
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +4 -37
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +0 -2
- package/src/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +0 -2
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ ccl game quit # 退出当前匹配、房间或游戏
|
|
|
53
53
|
|
|
54
54
|
## 自定义模块
|
|
55
55
|
|
|
56
|
-
策略资源默认导出 Strategy
|
|
56
|
+
策略资源默认导出 Strategy 执行类,可在同文件具名导出继承 ClawclawPerception 的 Trigger。感知插件运行该类并判断反射条件,感知持续观察并组织通知。 装配一个反射策略就能使用本局实时改参和开关。策略使用 ClawclawStrategy,感知使用 Perception API v3。
|
|
57
57
|
|
|
58
58
|
npm 包提供龙虾杀接入、公共 SDK 和官方 Agent Skill,通过 `@myclaw163/game-agent-runtime` 提供通用运行机制。官方模块、第三方模块和玩家自己的线上模块由当前账号 Hub loadout 获取,纯本地模块由玩家自行创建。实际可用内容以本次 `ccl load` 和对应的 `list` 命令为准。保存或同步源码后,下次正常启动 Runtime 时加载生效。
|
|
59
59
|
|
package/cli-runtime/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ const registry = [
|
|
|
22
22
|
if (!name2 || name2 === "game") p.addCommand(module.createGameCommand());
|
|
23
23
|
} },
|
|
24
24
|
{ names: ["account"], register: async (p) => p.addCommand((await import("./commands/account.js")).createAccountCommand()) },
|
|
25
|
+
{ names: ["runtime"], register: async (p) => p.addCommand((await import("./commands/runtime.js")).createRuntimeCommand()) },
|
|
25
26
|
{ names: ["auth"], register: async (p) => p.addCommand((await import("./commands/auth.js")).createAuthCommand()) },
|
|
26
27
|
{ names: ["competition"], register: async (p) => p.addCommand((await import("./commands/competition.js")).createCompetitionCommand()) },
|
|
27
28
|
{ names: ["capability", "cap"], register: async (p) => p.addCommand((await import("./commands/capability.js")).createCapabilityCommand()) },
|
|
@@ -72,7 +73,21 @@ try {
|
|
|
72
73
|
}
|
|
73
74
|
startupMark("cli.modules_loaded");
|
|
74
75
|
startupMark("cli.parse_ready");
|
|
75
|
-
await
|
|
76
|
+
const context = (await import("./lib/harness-context.js")).harnessContext();
|
|
77
|
+
if (context && !context.session && (name === "join" || name === "start" || name === "game" && ["start", "s", "join-room", "create-room", "training"].includes(args[1] ?? "")) && !args.includes("--help")) {
|
|
78
|
+
throw new Error("INVALID_HARNESS_CONTEXT: game launch requires CLAWCLAW_HOST_SESSION_ID.");
|
|
79
|
+
}
|
|
80
|
+
const writesResources = ["prepare", "capability", "cap", "hub", "skill", "persona", "prs", "memory", "mem", "strategy", "behavior", "beh", "perception", "pcp", "trigger", "trg"];
|
|
81
|
+
let guard;
|
|
82
|
+
if (name && writesResources.includes(name) && !args.includes("--help") && !args.includes("-h")) {
|
|
83
|
+
const { acquireAccountResourceLock } = await import("./lib/account-resource-lock.js");
|
|
84
|
+
guard = acquireAccountResourceLock();
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await program.parseAsync();
|
|
88
|
+
} finally {
|
|
89
|
+
guard?.release();
|
|
90
|
+
}
|
|
76
91
|
startupMark("cli.complete");
|
|
77
92
|
} catch (err) {
|
|
78
93
|
process.stderr.write(`${formatCommandError(err)}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { getWorkspaceDir } from "../lib/init-command.js";
|
|
5
|
+
import { getRuntimeDir } from "../lib/user-data.js";
|
|
6
|
+
import { resolveBundledClawclawSkill } from "../lib/skill-host.js";
|
|
7
|
+
function createRuntimeCommand() {
|
|
8
|
+
const command = new Command("runtime").description("Inspect the effective local CCL installation");
|
|
9
|
+
command.command("info").option("--json").action(() => {
|
|
10
|
+
const workspace = getWorkspaceDir();
|
|
11
|
+
const skillDirectory = resolveBundledClawclawSkill();
|
|
12
|
+
const root = dirname(dirname(skillDirectory));
|
|
13
|
+
const { version } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
14
|
+
console.log(JSON.stringify({
|
|
15
|
+
protocolVersion: 1,
|
|
16
|
+
version,
|
|
17
|
+
workspace,
|
|
18
|
+
runtimeDirectory: getRuntimeDir(workspace),
|
|
19
|
+
skillDirectory,
|
|
20
|
+
executable: process.execPath,
|
|
21
|
+
cli: join(root, "bin", "clawclaw-cli.mjs")
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
command.command("skills").option("--json").action(async () => {
|
|
25
|
+
const { AuthStore } = await import("../lib/auth.js");
|
|
26
|
+
const { accountManagedSkillSources } = await import("../lib/agent-workspace-skills.js");
|
|
27
|
+
const profile = new AuthStore().getActive();
|
|
28
|
+
const sources = profile ? accountManagedSkillSources(getWorkspaceDir(), profile) : /* @__PURE__ */ new Map();
|
|
29
|
+
console.log(JSON.stringify(Array.from(sources, ([name, directory]) => ({ name, directory }))));
|
|
30
|
+
});
|
|
31
|
+
return command;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createRuntimeCommand
|
|
35
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { tryAcquireRuntimeLock } from "@myclaw163/game-agent-runtime/owner/runtime-lock.js";
|
|
3
|
+
import { AuthStore } from "./auth.js";
|
|
4
|
+
import { getWorkspaceDir } from "./init-command.js";
|
|
5
|
+
import { getUserDataAccountDir } from "./user-data.js";
|
|
6
|
+
function acquireAccountResourceLock() {
|
|
7
|
+
const profile = new AuthStore().getActive();
|
|
8
|
+
if (!profile) return;
|
|
9
|
+
const lock = tryAcquireRuntimeLock(join(getUserDataAccountDir(getWorkspaceDir(), profile), ".resource-lock"));
|
|
10
|
+
if (!lock) throw new Error("ACCOUNT_RESOURCES_BUSY: another command is using this account\u2019s resources. Retry after it finishes.");
|
|
11
|
+
return lock;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
acquireAccountResourceLock
|
|
15
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { harnessContext } from "./harness-context.js";
|
|
1
2
|
import { isPackageManagedSkill, reservedSkillName } from "./package-skills.js";
|
|
2
3
|
import {
|
|
3
4
|
existsSync,
|
|
@@ -154,7 +155,7 @@ function accountManagedSkillSources(workspaceDir, profile, includeInactive = fal
|
|
|
154
155
|
return sources;
|
|
155
156
|
}
|
|
156
157
|
function switchActiveAccountSkillLinks(workspaceDir, previousProfile, nextProfile, dependencies = {}) {
|
|
157
|
-
if (previousProfile?.apiKey === nextProfile?.apiKey) return { removed: [], linked: [] };
|
|
158
|
+
if (harnessContext() || previousProfile?.apiKey === nextProfile?.apiKey) return { removed: [], linked: [] };
|
|
158
159
|
const guard = tryAcquireWorkspaceRuntimeLock(workspaceDir);
|
|
159
160
|
if (!guard) throw new Error("A ClawClaw runtime is running in this workspace. Stop it before switching accounts.");
|
|
160
161
|
guard.release();
|
|
@@ -447,6 +448,7 @@ function syncAgentWorkspaceSkills(workspaceDir, profile, snapshot, dependencies
|
|
|
447
448
|
};
|
|
448
449
|
}
|
|
449
450
|
export {
|
|
451
|
+
accountManagedSkillSources,
|
|
450
452
|
inspectSkillNameConflicts,
|
|
451
453
|
switchActiveAccountSkillLinks,
|
|
452
454
|
syncAgentWorkspaceSkills
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { harnessContext } from "./harness-context.js";
|
|
1
2
|
function isDesktopMode(env = process.env) {
|
|
3
|
+
const mode = harnessContext(env)?.auth;
|
|
4
|
+
if (mode) return mode === "managed";
|
|
2
5
|
return env.CLAWCLAW_IS_DESKTOP === "true";
|
|
3
6
|
}
|
|
4
7
|
const DESKTOP_LOGIN_MESSAGE = "\u8BF7\u5728\u5BA2\u6237\u7AEF\u767B\u5F55\u6E38\u620F\u8D26\u53F7\u3002CCL \u7684\u767B\u5F55\u8D26\u53F7\u7531\u5BA2\u6237\u7AEF\u7BA1\u7406\u3002";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
function harnessContext(env = process.env) {
|
|
4
|
+
const { CLAWCLAW_HOST_KIND: kind, CLAWCLAW_HOST_INSTANCE_ID: instance, CLAWCLAW_HOST_SESSION_ID: session, CLAWCLAW_AUTH_MODE: auth } = env;
|
|
5
|
+
if (kind === void 0 && auth === void 0) return void 0;
|
|
6
|
+
if (!kind || !/^[a-z][a-z0-9-]{0,63}$/.test(kind) || !instance || !/^[^\s\p{Cc}]{1,128}$/u.test(instance) || session !== void 0 && !/^[^\s\p{Cc}]{1,128}$/u.test(session) || auth !== void 0 && auth !== "managed" && auth !== "standalone") {
|
|
7
|
+
throw new Error("INVALID_HARNESS_CONTEXT: provide a valid kind, persistent instance ID and optional session/auth mode.");
|
|
8
|
+
}
|
|
9
|
+
return { kind, instance, session, auth };
|
|
10
|
+
}
|
|
11
|
+
function stateRoot(workspace) {
|
|
12
|
+
const context = harnessContext();
|
|
13
|
+
if (!context) return workspace;
|
|
14
|
+
const id = createHash("sha256").update(JSON.stringify([context.kind, context.instance])).digest("hex");
|
|
15
|
+
return join(workspace, "contexts", id);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
harnessContext,
|
|
19
|
+
stateRoot
|
|
20
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { stateRoot } from "./harness-context.js";
|
|
1
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2
3
|
import { isAbsolute, join, resolve, win32 } from "path";
|
|
3
4
|
import { homedir } from "os";
|
|
@@ -56,7 +57,7 @@ function cmdInit(force = false) {
|
|
|
56
57
|
return { created: !alreadyExists, path: workspaceDir };
|
|
57
58
|
}
|
|
58
59
|
function getAccountDir(accountId) {
|
|
59
|
-
return join(getWorkspaceDir(), "accounts", accountId);
|
|
60
|
+
return join(stateRoot(getWorkspaceDir()), "accounts", accountId);
|
|
60
61
|
}
|
|
61
62
|
function createAccountDirs(accountId) {
|
|
62
63
|
const accountDir = getAccountDir(accountId);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { isDesktopMode } from "./desktop-mode.js";
|
|
3
2
|
import { ApiError } from "./http-transport.js";
|
|
4
3
|
const agentInstanceId = randomUUID();
|
|
5
4
|
class InvalidHostContextError extends Error {
|
|
@@ -32,7 +31,7 @@ function validateLobbyHostContext(value) {
|
|
|
32
31
|
function resolveLobbyHostContext(env = process.env) {
|
|
33
32
|
const instanceId = env.CLAWCLAW_HOST_INSTANCE_ID;
|
|
34
33
|
const sessionId = env.CLAWCLAW_HOST_SESSION_ID;
|
|
35
|
-
if (
|
|
34
|
+
if (env.CLAWCLAW_IS_DESKTOP === "true") {
|
|
36
35
|
if (!validId(instanceId) || !validId(sessionId)) {
|
|
37
36
|
throw new InvalidHostContextError("Desktop must provide CLAWCLAW_HOST_INSTANCE_ID and CLAWCLAW_HOST_SESSION_ID (1\u2013128 characters, no whitespace/control characters).");
|
|
38
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { harnessContext } from "./harness-context.js";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
2
3
|
import {
|
|
3
4
|
cpSync,
|
|
@@ -83,6 +84,7 @@ function openClawSkillsDir(homeDir) {
|
|
|
83
84
|
return join(homeDir, ".openclaw", "skills");
|
|
84
85
|
}
|
|
85
86
|
function agentSkillTargets(name) {
|
|
87
|
+
if (harnessContext()) return [];
|
|
86
88
|
const homeDir = homedir();
|
|
87
89
|
const claudeHome = process.env.CLAUDE_CONFIG_DIR?.trim() || join(homeDir, ".claude");
|
|
88
90
|
const codexHome = process.env.CODEX_HOME?.trim() || join(homeDir, ".codex");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { harnessContext, stateRoot } from "./harness-context.js";
|
|
1
2
|
import {
|
|
2
3
|
copyFileSync,
|
|
3
4
|
existsSync,
|
|
@@ -18,10 +19,10 @@ function getUserDataDir(workspaceDir) {
|
|
|
18
19
|
return join(workspaceDir, USER_DATA_DIR);
|
|
19
20
|
}
|
|
20
21
|
function getRuntimeDir(workspaceDir) {
|
|
21
|
-
return join(workspaceDir, RUNTIME_DIR);
|
|
22
|
+
return join(stateRoot(workspaceDir), RUNTIME_DIR);
|
|
22
23
|
}
|
|
23
24
|
function getUserDataAuthFile(workspaceDir) {
|
|
24
|
-
return join(getUserDataDir(workspaceDir), "auth.json");
|
|
25
|
+
return join(getUserDataDir(stateRoot(workspaceDir)), "auth.json");
|
|
25
26
|
}
|
|
26
27
|
function getRuntimeAuthStateFile(workspaceDir) {
|
|
27
28
|
return join(getRuntimeDir(workspaceDir), "auth-state.json");
|
|
@@ -258,6 +259,7 @@ function ensureUserDataLayout(workspaceDir) {
|
|
|
258
259
|
ensureDir(getUserDataTriggersDir(workspaceDir));
|
|
259
260
|
ensureDir(getUserDataHubDir(workspaceDir));
|
|
260
261
|
ensureDir(getRuntimeDir(workspaceDir));
|
|
262
|
+
if (harnessContext()) return result;
|
|
261
263
|
const auth = migrateAuth(workspaceDir, result);
|
|
262
264
|
migrateAccountFiles(workspaceDir, auth, result);
|
|
263
265
|
writeMigrationMarker(workspaceDir, result);
|
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
import { normalizeBehaviorInput } from "./behavior-input-fields.js";
|
|
2
2
|
const same = (a, b) => a.sessionId === b.sessionId && a.segmentId === b.segmentId;
|
|
3
3
|
class BehaviorReflexControl {
|
|
4
|
-
constructor(modules, behavior, catalog, scope,
|
|
4
|
+
constructor(modules, behavior, catalog, scope, embedded = []) {
|
|
5
5
|
this.modules = modules;
|
|
6
6
|
this.behavior = behavior;
|
|
7
7
|
this.catalog = catalog;
|
|
8
8
|
this.scope = scope;
|
|
9
|
-
this.
|
|
9
|
+
this.embedded = embedded;
|
|
10
10
|
}
|
|
11
11
|
modules;
|
|
12
12
|
behavior;
|
|
13
13
|
catalog;
|
|
14
14
|
scope;
|
|
15
|
-
|
|
15
|
+
embedded;
|
|
16
16
|
parameters = /* @__PURE__ */ new Map();
|
|
17
17
|
currentScope;
|
|
18
18
|
tail = Promise.resolve();
|
|
19
|
-
embedded(id) {
|
|
20
|
-
return (this.triggers?.descriptors() ?? []).filter((item) => item.embedded && (id === void 0 || item.behavior === id));
|
|
21
|
-
}
|
|
22
19
|
status(id) {
|
|
23
20
|
this.refreshScope();
|
|
24
21
|
const active = this.behavior.status().stack.reflex;
|
|
25
|
-
|
|
26
|
-
source: "strategy",
|
|
27
|
-
behavior_id: item.behavior,
|
|
28
|
-
trigger_id: item.id,
|
|
29
|
-
available: true,
|
|
30
|
-
enabled: item.enabled,
|
|
31
|
-
waiting_for_input: item.waitingForInput,
|
|
32
|
-
armed: item.armed,
|
|
33
|
-
cooldown_remaining_ms: item.cooldownRemainingMs,
|
|
34
|
-
priority: item.reflexPriority,
|
|
35
|
-
cooldown_ms: item.cooldownMs,
|
|
36
|
-
rearm: item.rearm,
|
|
37
|
-
max_runtime_ms: item.maxRuntimeMs
|
|
38
|
-
}));
|
|
39
|
-
return [...embedded, ...this.modules?.bindings(id) ?? []].map((binding) => ({
|
|
22
|
+
return (this.modules?.bindings(id) ?? []).map((binding) => ({
|
|
40
23
|
...binding,
|
|
24
|
+
...this.embedded.some((source) => source.id === binding.perception_id) ? { source: "strategy", behavior_id: binding.id, config: this.modules?.status(binding.perception_id)[0]?.input } : {},
|
|
41
25
|
active: active?.triggerId === binding.trigger_id,
|
|
42
26
|
...active?.triggerId === binding.trigger_id ? {
|
|
43
27
|
activation_id: active.activationId,
|
|
@@ -63,8 +47,7 @@ class BehaviorReflexControl {
|
|
|
63
47
|
if (!guard()) throw Error("stale_runtime_scope");
|
|
64
48
|
const entry = this.catalog.list().find((entry2) => entry2.id === id);
|
|
65
49
|
if (!entry) throw Error("behavior_not_found");
|
|
66
|
-
|
|
67
|
-
if (operation !== "update" && !embedded) {
|
|
50
|
+
if (operation !== "update") {
|
|
68
51
|
const bindings = this.modules?.bindings(id) ?? [];
|
|
69
52
|
if (!bindings.length || operation === "enable" && !bindings.some((binding) => binding.available)) {
|
|
70
53
|
throw Error("perception_binding_unavailable");
|
|
@@ -72,23 +55,31 @@ class BehaviorReflexControl {
|
|
|
72
55
|
}
|
|
73
56
|
let input = this.parameters.get(id) ?? {}, updated = 0;
|
|
74
57
|
if (operation === "update" || Object.keys(patch).length) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
()
|
|
58
|
+
const source = this.embedded.find((source2) => source2.embedded?.strategyId === id);
|
|
59
|
+
const fields = source?.module?.inputs ?? [];
|
|
60
|
+
const detectorPatch = {};
|
|
61
|
+
const executionPatch = {};
|
|
62
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
63
|
+
const observed = fields.some((field) => field.id === key);
|
|
64
|
+
if (observed) detectorPatch[key] = value;
|
|
65
|
+
if (!observed || entry.inputs.some((field) => field.id === key)) executionPatch[key] = value;
|
|
66
|
+
}
|
|
67
|
+
const configureDetector = () => {
|
|
68
|
+
if (source && Object.keys(detectorPatch).length) this.modules?.configure(source.id, detectorPatch, guard);
|
|
69
|
+
};
|
|
70
|
+
if (Object.keys(executionPatch).length || !Object.keys(detectorPatch).length) {
|
|
71
|
+
input = normalizeBehaviorInput({ ...input, ...executionPatch }, entry.inputs);
|
|
72
|
+
updated = await this.behavior.configureInput(id, input, executionPatch, guard, () => {
|
|
73
|
+
configureDetector();
|
|
82
74
|
this.parameters.set(id, input);
|
|
83
|
-
this.triggers?.configureEmbedded(id, { input });
|
|
84
75
|
this.modules?.behaviorInputChanged(id);
|
|
85
|
-
}
|
|
86
|
-
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
configureDetector();
|
|
79
|
+
}
|
|
87
80
|
}
|
|
88
81
|
if (operation !== "update") {
|
|
89
|
-
|
|
90
|
-
if (embedded) this.triggers?.configureEmbedded(id, { enabled: operation === "enable" });
|
|
91
|
-
const triggerIds = embedded ? [embedded.id] : this.modules?.setWatch(id, operation === "enable", guard);
|
|
82
|
+
const triggerIds = this.modules?.setWatch(id, operation === "enable", guard);
|
|
92
83
|
if (!triggerIds) throw Error("perception_binding_unavailable");
|
|
93
84
|
if (operation === "disable") for (const triggerId of triggerIds) {
|
|
94
85
|
updated += Number(await this.behavior.updateReflex(triggerId, void 0, guard));
|
|
@@ -1,59 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"consumes",
|
|
8
|
-
"defaultReflexPriority",
|
|
9
|
-
"defaultCooldownMs",
|
|
10
|
-
"defaultRearm",
|
|
11
|
-
"defaultMaxRuntimeMs"
|
|
12
|
-
]);
|
|
13
|
-
function normalizeStrategyTriggerManifest(value) {
|
|
14
|
-
const manifest = value;
|
|
15
|
-
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest) || manifest.apiVersion !== TRIGGER_PLUGIN_API_VERSION || Object.keys(manifest).some((key) => !fields.has(key))) {
|
|
16
|
-
throw new Error("strategy_trigger_manifest_invalid");
|
|
1
|
+
import { normalizePerceptionModuleManifest } from "./perception-module-manifest.js";
|
|
2
|
+
function normalizeStrategyPerception(value, strategyId) {
|
|
3
|
+
const manifest = normalizePerceptionModuleManifest(value);
|
|
4
|
+
const bindings = Object.values(manifest.behaviors ?? {});
|
|
5
|
+
if (!bindings.length || bindings.some((binding) => binding.name !== strategyId || binding.resourceId !== void 0)) {
|
|
6
|
+
throw Error("strategy_perception_self_binding_required");
|
|
17
7
|
}
|
|
18
|
-
|
|
19
|
-
if (!Array.isArray(consumes) || consumes.some((type) => typeof type !== "string" || !/^(?:\\*|[a-z0-9][a-z0-9._-]*)$/.test(type)) || new Set(consumes).size !== consumes.length) {
|
|
20
|
-
throw new Error("strategy_trigger_consumes_invalid");
|
|
21
|
-
}
|
|
22
|
-
const {
|
|
23
|
-
defaultReflexPriority = 0,
|
|
24
|
-
defaultCooldownMs = 1e3,
|
|
25
|
-
defaultRearm = "after_clear",
|
|
26
|
-
defaultMaxRuntimeMs = 1e4
|
|
27
|
-
} = manifest;
|
|
28
|
-
if (!Number.isSafeInteger(defaultReflexPriority) || !Number.isSafeInteger(defaultCooldownMs) || defaultCooldownMs < 0 || defaultRearm !== "after_clear" && defaultRearm !== "after_cooldown" || !Number.isSafeInteger(defaultMaxRuntimeMs) || defaultMaxRuntimeMs < 1 || defaultMaxRuntimeMs > MAX_TRIGGER_RUNTIME_MS) {
|
|
29
|
-
throw new Error("strategy_trigger_defaults_invalid");
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
apiVersion: TRIGGER_PLUGIN_API_VERSION,
|
|
33
|
-
consumes: [...consumes],
|
|
34
|
-
defaultReflexPriority,
|
|
35
|
-
defaultCooldownMs,
|
|
36
|
-
defaultRearm,
|
|
37
|
-
defaultMaxRuntimeMs
|
|
38
|
-
};
|
|
8
|
+
return manifest;
|
|
39
9
|
}
|
|
40
10
|
function strategyTriggerSource(source) {
|
|
41
11
|
if (!source.trigger) return void 0;
|
|
42
|
-
const { name, description, sourcePath, sourceRoot, inputs } = source;
|
|
43
|
-
const id = "behavior:" + source.id;
|
|
44
12
|
const { manifest, sha256 } = source.trigger;
|
|
13
|
+
const id = "strategy:" + source.id;
|
|
14
|
+
const name = manifest.name ?? manifest.id;
|
|
15
|
+
const behaviors = Object.fromEntries(Object.entries(manifest.behaviors).map(([key, binding]) => [key, { ...binding, name: source.id }]));
|
|
45
16
|
return {
|
|
46
|
-
apiVersion: manifest.apiVersion,
|
|
47
17
|
id,
|
|
48
18
|
name,
|
|
49
|
-
description,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
19
|
+
description: manifest.description,
|
|
20
|
+
apiVersion: 3,
|
|
21
|
+
sourcePath: source.sourcePath,
|
|
22
|
+
sourceRoot: source.sourceRoot,
|
|
23
|
+
embedded: { strategyId: source.id, sha256, declaredManifest: manifest },
|
|
24
|
+
module: { ...manifest, behaviors },
|
|
25
|
+
manifest: {
|
|
26
|
+
apiVersion: 2,
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
description: manifest.description,
|
|
30
|
+
subjectScope: "self_and_others",
|
|
31
|
+
produces: manifest.produces ?? []
|
|
32
|
+
}
|
|
54
33
|
};
|
|
55
34
|
}
|
|
56
35
|
export {
|
|
57
|
-
|
|
36
|
+
normalizeStrategyPerception,
|
|
58
37
|
strategyTriggerSource
|
|
59
38
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { stateRoot } from "../../lib/harness-context.js";
|
|
1
2
|
import { timeStartup } from "../../../bin/startup-trace.mjs";
|
|
2
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
4
|
import { mkdirSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -27,7 +28,7 @@ function workspaceOwnerRecordPath(workspaceDir = getWorkspaceDir()) {
|
|
|
27
28
|
return join(getRuntimeDir(workspaceDir), "owner.json");
|
|
28
29
|
}
|
|
29
30
|
function workspaceOwnerIdentity(workspaceDir = getWorkspaceDir()) {
|
|
30
|
-
const real = realpathSync(workspaceDir);
|
|
31
|
+
const real = realpathSync(stateRoot(workspaceDir));
|
|
31
32
|
return createHash("sha256").update(process.platform === "win32" ? real.toLowerCase() : real).digest("hex");
|
|
32
33
|
}
|
|
33
34
|
function readOwnerRecord(path) {
|
|
@@ -485,9 +485,8 @@ async function runClawclawOwner(options) {
|
|
|
485
485
|
reason: source2.triggerError
|
|
486
486
|
});
|
|
487
487
|
const trigger = strategyTriggerSource(source2);
|
|
488
|
-
return trigger ? [
|
|
488
|
+
return trigger ? [trigger] : [];
|
|
489
489
|
});
|
|
490
|
-
const triggers = [...legacyTriggers, ...embeddedTriggers];
|
|
491
490
|
const disabledPerceptions = new Set(gameplayConfig.disabled_perception_modules);
|
|
492
491
|
const agentPerceptionSources = agentWorkspace ? listAgentWorkspacePerceptionSources(workspaceDir, options.profile, agentWorkspace) : [];
|
|
493
492
|
const localPerceptionSources = discoveredLocalCapabilities.perceptions.filter(({ source: source2, entry }) => entry.selection === "equipped" && !disabledPerceptions.has(source2.id) && !agentWorkspace?.items.perception.some((item) => item.resourceId === entry.hub?.resourceId)).map(({ source: source2 }) => source2);
|
|
@@ -513,7 +512,8 @@ async function runClawclawOwner(options) {
|
|
|
513
512
|
triggerDiagnosticsEnabled: fullDiagnosticsEnabled,
|
|
514
513
|
fallbackBehaviors,
|
|
515
514
|
behaviorEventTypes,
|
|
516
|
-
triggers
|
|
515
|
+
triggers: legacyTriggers,
|
|
516
|
+
embeddedPerceptions: embeddedTriggers
|
|
517
517
|
});
|
|
518
518
|
await assembly.behavior.setIdleMs(gameplayConfig.idle_ms);
|
|
519
519
|
const epochPlugins = assembly.plugins;
|
|
@@ -528,7 +528,7 @@ async function runClawclawOwner(options) {
|
|
|
528
528
|
assembly.behavior,
|
|
529
529
|
behaviorCatalog,
|
|
530
530
|
() => runtime.publicScope(),
|
|
531
|
-
|
|
531
|
+
embeddedTriggers
|
|
532
532
|
);
|
|
533
533
|
const runtimeDone = startupSpan("owner.runtime_init");
|
|
534
534
|
runtime = createClawclawRuntime(options.profile, {
|
|
@@ -595,7 +595,7 @@ async function runClawclawOwner(options) {
|
|
|
595
595
|
} : null
|
|
596
596
|
},
|
|
597
597
|
perception: assembly.perception.diagnosticSnapshot(),
|
|
598
|
-
trigger: assembly.trigger
|
|
598
|
+
trigger: assembly.trigger?.diagnosticSnapshot()
|
|
599
599
|
}, {
|
|
600
600
|
component: "runtime.diagnostics",
|
|
601
601
|
scope: runtime?.publicScope()
|
|
@@ -611,7 +611,7 @@ async function runClawclawOwner(options) {
|
|
|
611
611
|
throw new Error("The configured Runtime repository does not support durable Mailbox delivery.");
|
|
612
612
|
}
|
|
613
613
|
const mailboxRepository = runtime.repository;
|
|
614
|
-
const perceptionSourceById = new Map(perceptionSources.map((source2) => [source2.id, source2]));
|
|
614
|
+
const perceptionSourceById = new Map([...perceptionSources, ...embeddedTriggers].map((source2) => [source2.id, source2]));
|
|
615
615
|
const perceptionReportAdapter = new GameSyncPerceptionReportAdapter({
|
|
616
616
|
producerPluginIds: [assembly.perception.id, assembly.reminders.id, ...assembly.modules ? [assembly.modules.id] : []],
|
|
617
617
|
descriptor: (id) => {
|
|
@@ -1157,6 +1157,7 @@ async function runClawclawOwner(options) {
|
|
|
1157
1157
|
if (!currentTriggerSources.some((source2) => source2.id === request.trigger)) {
|
|
1158
1158
|
return { ok: false, type: "trigger_configure", error: "trigger_source_unavailable" };
|
|
1159
1159
|
}
|
|
1160
|
+
if (!assembly.trigger) return { ok: false, type: request.type, error: "trigger_runtime_restart_required" };
|
|
1160
1161
|
assembly.trigger.configure(triggerRegistrations(
|
|
1161
1162
|
currentTriggerSources,
|
|
1162
1163
|
latest,
|
|
@@ -79,14 +79,15 @@ function assembleClawclawPlugins(client, options = {}) {
|
|
|
79
79
|
if (configuredTrigger && !(configuredTrigger instanceof ClawclawTriggerPlugin)) {
|
|
80
80
|
throw new Error(`Runtime Plugin ${CLAWCLAW_TRIGGER_PLUGIN_ID} is not a ClawclawTriggerPlugin.`);
|
|
81
81
|
}
|
|
82
|
-
const trigger = configuredTrigger ?? new ClawclawTriggerPlugin({
|
|
82
|
+
const trigger = configuredTrigger ?? (options.triggers?.length ? new ClawclawTriggerPlugin({
|
|
83
83
|
after: [],
|
|
84
84
|
triggers: options.triggers,
|
|
85
85
|
diagnosticsEnabled: options.triggerDiagnosticsEnabled
|
|
86
|
-
});
|
|
87
|
-
if (!configuredTrigger) plugins.push(trigger);
|
|
88
|
-
const
|
|
89
|
-
|
|
86
|
+
}) : void 0);
|
|
87
|
+
if (trigger && !configuredTrigger) plugins.push(trigger);
|
|
88
|
+
const sources = [...moduleSources, ...options.embeddedPerceptions ?? []];
|
|
89
|
+
const modules = sources.length ? new ClawclawPerceptionModulePlugin({
|
|
90
|
+
sources,
|
|
90
91
|
after: [],
|
|
91
92
|
behaviors: () => options.behaviorCatalog?.list?.() ?? []
|
|
92
93
|
}) : void 0;
|
|
@@ -111,11 +112,11 @@ function assembleClawclawPlugins(client, options = {}) {
|
|
|
111
112
|
});
|
|
112
113
|
if (!configuredBehavior) plugins.push(behavior);
|
|
113
114
|
const strategyMemory = new ClawclawStrategyMemory();
|
|
114
|
-
trigger
|
|
115
|
+
trigger?.attachMemory(strategyMemory);
|
|
115
116
|
behavior.attachMemory(strategyMemory);
|
|
116
117
|
modules?.attachMemory(strategyMemory);
|
|
117
118
|
modules?.attachDriver(behavior);
|
|
118
|
-
trigger
|
|
119
|
+
trigger?.attachDriver(behavior);
|
|
119
120
|
action.attachAgentActivity(() => {
|
|
120
121
|
void behavior.noteAgentActivity().catch(() => {
|
|
121
122
|
});
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
hasValidClawclawResourceLocalizations
|
|
16
16
|
} from "../../../../sdk/behavior-plugin/index.js";
|
|
17
17
|
import { parseLiteralBehaviorInputFields, parseLiteralModuleManifest } from "../behavior-input-source.js";
|
|
18
|
-
import {
|
|
18
|
+
import { normalizeStrategyPerception } from "../../behavior-trigger.js";
|
|
19
19
|
import {
|
|
20
20
|
behaviorProducesDiagnostic,
|
|
21
21
|
deepFreezeBehaviorValue,
|
|
@@ -26,7 +26,7 @@ const MAX_BEHAVIOR_SOURCE_BYTES = 2 * 1024 * 1024;
|
|
|
26
26
|
const SAFE_IMPORT = /(?:\bfrom\s*|\bimport\s*)["'](?:@myclaw163\/clawclaw-cli|clawclaw-cli)\/(?:behavior|strategy)-plugin["']/;
|
|
27
27
|
const DEFAULT_CLASS = /export\s+default\s+class(?:\s+[A-Za-z_$][\w$]*)?\s+extends\s+Clawclaw(?:Behavior|Strategy)(?:\s*<[\s\S]{0,4000}?>)?\s*\{/;
|
|
28
28
|
const NAMED_TRIGGER = /export\s+class\s+Trigger\b/;
|
|
29
|
-
const TRIGGER_CLASS = /^export\s+class\s+Trigger\s+extends\s+
|
|
29
|
+
const TRIGGER_CLASS = /^export\s+class\s+Trigger\s+extends\s+ClawclawPerception(?:\s*<[\s\S]{0,4000}?>)?\s*\{/;
|
|
30
30
|
const STATIC_MANIFEST = /\bstatic\s+(?:override\s+)?(?:readonly\s+)?manifest\s*=\s*\{/;
|
|
31
31
|
const BEHAVIOR_ID = /^[a-z0-9][a-z0-9._-]*$/;
|
|
32
32
|
const MANIFEST_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -462,10 +462,11 @@ function inspectClawclawBehaviorSource(sourcePath, sourceRoot) {
|
|
|
462
462
|
if (namedTrigger) {
|
|
463
463
|
try {
|
|
464
464
|
const match = TRIGGER_CLASS.exec(masked.slice(namedTrigger.index));
|
|
465
|
-
if (match)
|
|
466
|
-
|
|
465
|
+
if (!match) throw Error("strategy_trigger_requires_perception_v3");
|
|
466
|
+
match.index = namedTrigger.index;
|
|
467
|
+
const literal = classManifest(source, match);
|
|
467
468
|
trigger = {
|
|
468
|
-
manifest:
|
|
469
|
+
manifest: normalizeStrategyPerception(literal && parseLiteralModuleManifest(literal), compatible.id),
|
|
469
470
|
sha256: createHash("sha256").update(source).digest("hex")
|
|
470
471
|
};
|
|
471
472
|
} catch (error) {
|
|
@@ -94,6 +94,8 @@ function createAdapter(options) {
|
|
|
94
94
|
const { input, game, frame, facts, eventStates, boundary, common } = prepared.value;
|
|
95
95
|
const events = facts.filter((event) => source.module.consumes?.includes(event.type));
|
|
96
96
|
const comparison = comparePerceptionTasks(baseline, input, boundary);
|
|
97
|
+
const embedded = sourceValue(source).embedded;
|
|
98
|
+
const declaredTargets = embedded && bindings.availableBindings.length ? Object.values(embedded.declaredManifest.behaviors ?? {}).map((binding) => binding.name) : [];
|
|
97
99
|
const moduleInput = {
|
|
98
100
|
...common,
|
|
99
101
|
moduleId: source.id,
|
|
@@ -107,7 +109,7 @@ function createAdapter(options) {
|
|
|
107
109
|
state,
|
|
108
110
|
config,
|
|
109
111
|
...bindings,
|
|
110
|
-
availableStrategies: bindings.availableBehaviors,
|
|
112
|
+
availableStrategies: [.../* @__PURE__ */ new Set([...bindings.availableBehaviors, ...declaredTargets])],
|
|
111
113
|
taskChanges: comparison.changes,
|
|
112
114
|
boundary
|
|
113
115
|
};
|
|
@@ -134,7 +136,8 @@ class ClawclawPerceptionModulePlugin extends PerceptionHost {
|
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
localizedModuleDescriptors(locale) {
|
|
137
|
-
|
|
139
|
+
const descriptors = super.localizedModuleDescriptors(locale);
|
|
140
|
+
return descriptors.filter((item) => !item.id.startsWith("strategy:"));
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
export {
|
|
@@ -5,7 +5,8 @@ class PerceptionModuleRunner extends PerceptionWorker {
|
|
|
5
5
|
constructor(source, bindMemory) {
|
|
6
6
|
super({ compatibilityError: source.compatibilityError, workerData: {
|
|
7
7
|
modulePath: source.sourcePath,
|
|
8
|
-
expectedManifest: source.module,
|
|
8
|
+
expectedManifest: source.embedded?.declaredManifest ?? source.module,
|
|
9
|
+
embeddedSha256: source.embedded?.sha256,
|
|
9
10
|
legacy: !!source.reaction,
|
|
10
11
|
runtimeModuleBootstrap: {
|
|
11
12
|
hostUrl: new URL("./perception-module-worker.ts", import.meta.url).href,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
1
3
|
import { pathToFileURL } from "node:url";
|
|
2
4
|
import { runPerceptionWorker } from "@myclaw163/game-agent-runtime/perception/perception-worker-host.js";
|
|
3
5
|
import { ClawclawPerception, ClawclawReaction } from "../../../../sdk/perception-plugin/index.js";
|
|
@@ -5,7 +7,11 @@ import { normalizePerceptionModuleManifest } from "../../perception-module-manif
|
|
|
5
7
|
import { normalizeReactionManifest } from "../../reaction-manifest.js";
|
|
6
8
|
import { CLAWCLAW_PERCEPTION_SPATIAL_API } from "./spatial-facts.js";
|
|
7
9
|
await runPerceptionWorker(async (data) => {
|
|
8
|
-
|
|
10
|
+
if (data.embeddedSha256 && createHash("sha256").update(readFileSync(data.modulePath)).digest("hex") !== data.embeddedSha256) {
|
|
11
|
+
throw Error("strategy_perception_source_changed");
|
|
12
|
+
}
|
|
13
|
+
const exports = await import(pathToFileURL(data.modulePath).href);
|
|
14
|
+
const Module = data.embeddedSha256 ? exports.Trigger : exports.default;
|
|
9
15
|
if (!(Module?.prototype instanceof (data.legacy ? ClawclawReaction : ClawclawPerception)) || Module.prototype.evaluate === ClawclawPerception.prototype.evaluate) throw Error("PERCEPTION_MODULE_CLASS_INVALID");
|
|
10
16
|
const legacy = data.legacy ? normalizeReactionManifest(Module.manifest) : void 0;
|
|
11
17
|
const { kind: _kind, ...common } = legacy ?? {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
1
3
|
import { pathToFileURL } from 'node:url';
|
|
2
4
|
import { runPerceptionWorker } from '@myclaw163/game-agent-runtime/perception/perception-worker-host.js';
|
|
3
5
|
import { ClawclawPerception, ClawclawReaction } from '../../../../sdk/perception-plugin/index.js';
|
|
@@ -7,7 +9,11 @@ import { normalizeReactionManifest } from '../../reaction-manifest.js';
|
|
|
7
9
|
import { CLAWCLAW_PERCEPTION_SPATIAL_API } from './spatial-facts.js';
|
|
8
10
|
|
|
9
11
|
await runPerceptionWorker<PerceptionModuleInput>(async data => {
|
|
10
|
-
|
|
12
|
+
if (data.embeddedSha256 && createHash('sha256').update(readFileSync(data.modulePath)).digest('hex') !== data.embeddedSha256) {
|
|
13
|
+
throw Error('strategy_perception_source_changed');
|
|
14
|
+
}
|
|
15
|
+
const exports = await import(pathToFileURL(data.modulePath).href);
|
|
16
|
+
const Module = data.embeddedSha256 ? exports.Trigger : exports.default;
|
|
11
17
|
if (!(Module?.prototype instanceof (data.legacy ? ClawclawReaction : ClawclawPerception))
|
|
12
18
|
|| Module.prototype.evaluate === ClawclawPerception.prototype.evaluate) throw Error('PERCEPTION_MODULE_CLASS_INVALID');
|
|
13
19
|
const legacy = data.legacy ? normalizeReactionManifest(Module.manifest) : undefined;
|