@xfxstudio/claworld 0.2.4 → 0.2.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.
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "name": "Claworld Persona Relay",
10
10
  "description": "Claworld relay world channel plugin for OpenClaw.",
11
- "version": "0.2.4",
11
+ "version": "0.2.5",
12
12
  "configSchema": {
13
13
  "type": "object",
14
14
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfxstudio/claworld",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Claworld channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -18,6 +18,19 @@ import {
18
18
  runClaworldInstallerUpdate,
19
19
  } from './core.js';
20
20
 
21
+ function resolveCliHomeDir(env = process.env) {
22
+ const envHomeDir = String(
23
+ env.HOME
24
+ || env.USERPROFILE
25
+ || (
26
+ env.HOMEDRIVE && env.HOMEPATH
27
+ ? path.join(env.HOMEDRIVE, env.HOMEPATH)
28
+ : ''
29
+ ),
30
+ ).trim();
31
+ return envHomeDir || os.homedir();
32
+ }
33
+
21
34
  function printHelp() {
22
35
  console.log(`Usage: ${CLAWORLD_INSTALLER_BIN_NAME} <command> [options]
23
36
 
@@ -79,7 +92,7 @@ function nextValue(argv, index) {
79
92
  }
80
93
 
81
94
  export function parseInstallerCliArgs(argv = process.argv.slice(2), env = process.env) {
82
- const homeDir = os.homedir();
95
+ const homeDir = resolveCliHomeDir(env);
83
96
  const options = {
84
97
  command: null,
85
98
  json: false,
@@ -36,6 +36,15 @@ export const DEFAULT_VERIFICATION_DELAY_MS = 1_000;
36
36
  export const seedManagedWorkspace = seedManagedWorkspaceContract;
37
37
  const TRACKED_PLUGIN_UPDATEABLE_SOURCES = new Set(['npm', 'marketplace']);
38
38
 
39
+ function resolveRequireGatewayRunning(env = process.env) {
40
+ const normalized = normalizeText(env?.CLAWORLD_INSTALLER_REQUIRE_GATEWAY_RUNNING, null);
41
+ if (!normalized) return true;
42
+ const lowered = normalized.toLowerCase();
43
+ if (['0', 'false', 'no', 'off'].includes(lowered)) return false;
44
+ if (['1', 'true', 'yes', 'on'].includes(lowered)) return true;
45
+ return true;
46
+ }
47
+
39
48
  function normalizeComparablePath(value) {
40
49
  if (!value) return null;
41
50
  return path.resolve(String(value));
@@ -1224,6 +1233,7 @@ export async function verifyClaworldInstall({
1224
1233
  dryRun = false,
1225
1234
  attempts = DEFAULT_VERIFICATION_ATTEMPTS,
1226
1235
  delayMs = DEFAULT_VERIFICATION_DELAY_MS,
1236
+ requireGatewayRunning = resolveRequireGatewayRunning(env),
1227
1237
  } = {}) {
1228
1238
  let lastResult = null;
1229
1239
 
@@ -1283,7 +1293,7 @@ export async function verifyClaworldInstall({
1283
1293
  const bindingReady = Boolean(bindingLine);
1284
1294
 
1285
1295
  lastResult = {
1286
- ok: pluginReady && gatewayRunning && channelReady && bindingReady,
1296
+ ok: pluginReady && channelReady && bindingReady && (!requireGatewayRunning || gatewayRunning),
1287
1297
  attempt,
1288
1298
  plugin,
1289
1299
  gatewayStatus,
@@ -1293,6 +1303,7 @@ export async function verifyClaworldInstall({
1293
1303
  gatewayRunning,
1294
1304
  channelReady,
1295
1305
  bindingReady,
1306
+ requireGatewayRunning,
1296
1307
  };
1297
1308
 
1298
1309
  if (lastResult.ok) {
@@ -1488,6 +1488,45 @@ function createDeliveryReplyDispatcher({
1488
1488
  };
1489
1489
  }
1490
1490
 
1491
+ async function runDeliveryReplyDispatch({
1492
+ runtime,
1493
+ currentCfg,
1494
+ relayClient,
1495
+ deliveryId,
1496
+ sessionKey,
1497
+ localAgentId,
1498
+ allowReply,
1499
+ logger,
1500
+ runtimeAccountId,
1501
+ inboundCtx,
1502
+ } = {}) {
1503
+ const { dispatcher, replyOptions, markDispatchIdle, didReply, getRuntimeOutputSummary } = createDeliveryReplyDispatcher({
1504
+ runtime,
1505
+ currentCfg,
1506
+ relayClient,
1507
+ deliveryId,
1508
+ sessionKey,
1509
+ localAgentId,
1510
+ allowReply,
1511
+ logger,
1512
+ runtimeAccountId,
1513
+ });
1514
+
1515
+ const dispatchResult = await runtime.channel.reply.dispatchReplyFromConfig({
1516
+ ctx: inboundCtx,
1517
+ cfg: currentCfg,
1518
+ dispatcher,
1519
+ replyOptions,
1520
+ });
1521
+ await markDispatchIdle();
1522
+
1523
+ return {
1524
+ dispatchResult,
1525
+ replied: didReply(),
1526
+ runtimeOutputSummary: getRuntimeOutputSummary(),
1527
+ };
1528
+ }
1529
+
1491
1530
  function resolveBoundLocalAgentId({ cfg = {}, runtimeConfig = {}, relayClient } = {}) {
1492
1531
  const accountId = resolveNormalizedText(runtimeConfig.accountId, null);
1493
1532
  const bindings = Array.isArray(cfg?.bindings) ? cfg.bindings : [];
@@ -1662,7 +1701,11 @@ async function maybeBridgeRuntimeDelivery({
1662
1701
  commandAuthorized,
1663
1702
  });
1664
1703
 
1665
- const { dispatcher, replyOptions, markDispatchIdle, didReply, getRuntimeOutputSummary } = createDeliveryReplyDispatcher({
1704
+ let {
1705
+ dispatchResult,
1706
+ replied,
1707
+ runtimeOutputSummary,
1708
+ } = await runDeliveryReplyDispatch({
1666
1709
  runtime,
1667
1710
  currentCfg,
1668
1711
  relayClient,
@@ -1672,16 +1715,52 @@ async function maybeBridgeRuntimeDelivery({
1672
1715
  allowReply: metadata.allowReply !== false,
1673
1716
  logger,
1674
1717
  runtimeAccountId,
1718
+ inboundCtx,
1675
1719
  });
1676
- const dispatchResult = await runtime.channel.reply.dispatchReplyFromConfig({
1677
- ctx: inboundCtx,
1678
- cfg: currentCfg,
1679
- dispatcher,
1680
- replyOptions,
1681
- });
1682
- await markDispatchIdle();
1683
- const replied = didReply();
1684
- const runtimeOutputSummary = getRuntimeOutputSummary();
1720
+
1721
+ const shouldRetryKickoffDispatch = (
1722
+ metadata.deliveryType === 'kickoff'
1723
+ && metadata.allowReply !== false
1724
+ && replied !== true
1725
+ && runtimeOutputSummary.counts.final > 0
1726
+ && runtimeOutputSummary.counts.operationalNotice > 0
1727
+ && runtimeOutputSummary.counts.final === runtimeOutputSummary.counts.operationalNotice
1728
+ && runtimeOutputSummary.counts.block === 0
1729
+ && runtimeOutputSummary.counts.tool === 0
1730
+ && runtimeOutputSummary.counts.partial === 0
1731
+ && runtimeOutputSummary.counts.reasoning === 0
1732
+ && runtimeOutputSummary.counts.toolStart === 0
1733
+ && runtimeOutputSummary.counts.assistantMessageStart === 0
1734
+ && runtimeOutputSummary.counts.reasoningEnd === 0
1735
+ && runtimeOutputSummary.counts.compactionStart === 0
1736
+ && runtimeOutputSummary.counts.compactionEnd === 0
1737
+ );
1738
+
1739
+ if (shouldRetryKickoffDispatch) {
1740
+ logger.warn?.(`[claworld:${runtimeAccountId}] kickoff delivery produced only operational notices; retrying dispatch once`, {
1741
+ deliveryId,
1742
+ sessionKey,
1743
+ localAgentId,
1744
+ runtimeOutputSummary,
1745
+ });
1746
+
1747
+ ({
1748
+ dispatchResult,
1749
+ replied,
1750
+ runtimeOutputSummary,
1751
+ } = await runDeliveryReplyDispatch({
1752
+ runtime,
1753
+ currentCfg,
1754
+ relayClient,
1755
+ deliveryId,
1756
+ sessionKey,
1757
+ localAgentId,
1758
+ allowReply: metadata.allowReply !== false,
1759
+ logger,
1760
+ runtimeAccountId,
1761
+ inboundCtx,
1762
+ }));
1763
+ }
1685
1764
 
1686
1765
  logger.info?.(`[claworld:${runtimeAccountId}] delivery bridge completed`, {
1687
1766
  deliveryId,