@myclaw163/clawclaw-cli 0.7.6 → 0.7.8

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.
Files changed (51) hide show
  1. package/docs/desktop-event-push.md +37 -3
  2. package/docs/runtime/README.md +1 -0
  3. package/docs/runtime/official-perception-modules.md +346 -0
  4. package/package.json +1 -1
  5. package/src/commands/game/index.ts +1 -1
  6. package/src/lib/service-status.test.ts +56 -0
  7. package/src/lib/service-status.ts +111 -0
  8. package/src/pipeline/event-format.test.ts +26 -0
  9. package/src/pipeline/event-format.ts +22 -1
  10. package/src/pipeline/event-hints.test.ts +18 -3
  11. package/src/pipeline/event-hints.ts +11 -0
  12. package/src/pipeline/game-sync-event-normalization.test.ts +54 -1
  13. package/src/pipeline/game-sync-event-normalization.ts +39 -6
  14. package/src/pipeline/player-projection.test.ts +19 -2
  15. package/src/pipeline/player-projection.ts +17 -2
  16. package/src/runtime/clawclaw/agent-event-policy.test.ts +4 -0
  17. package/src/runtime/clawclaw/agent-event-policy.ts +1 -0
  18. package/src/runtime/clawclaw/owner.ts +6 -0
  19. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +24 -0
  20. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +29 -0
  21. package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +39 -0
  22. package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +71 -0
  23. package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -0
  24. package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +6 -0
  25. package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +6 -0
  26. package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +6 -0
  27. package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +6 -0
  28. package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +6 -0
  29. package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +6 -0
  30. package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +6 -0
  31. package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +11 -0
  32. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +8 -0
  33. package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +12 -0
  34. package/src/runtime/clawclaw/plugins/perception/perception-source.ts +37 -1
  35. package/src/runtime/clawclaw/plugins/source/room-transport.ts +2 -1
  36. package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +214 -1
  37. package/src/runtime/clawclaw/plugins/source/source-plugin.ts +109 -21
  38. package/src/runtime/clawclaw/plugins/source/types.ts +1 -0
  39. package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +6 -0
  40. package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +4 -0
  41. package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +4 -0
  42. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +36 -0
  43. package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +13 -0
  44. package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +22 -0
  45. package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +46 -16
  46. package/src/runtime/clawclaw-event-catalog.test.ts +2 -0
  47. package/src/runtime/clawclaw-event-catalog.ts +1 -0
  48. package/src/sdk/perception-plugin/index.ts +14 -0
  49. package/src/sdk/resource-metadata.test.ts +40 -0
  50. package/src/sdk/resource-metadata.ts +63 -0
  51. package/src/sdk/strategy-plugin/index.ts +14 -0
@@ -0,0 +1,63 @@
1
+ export interface ClawclawLocalizedResourceText {
2
+ readonly name: string;
3
+ readonly description: string;
4
+ }
5
+
6
+ export type ClawclawResourceLocalizations = Readonly<
7
+ Record<string, ClawclawLocalizedResourceText>
8
+ >;
9
+
10
+ export interface ClawclawResourceMetadata {
11
+ readonly id: string;
12
+ readonly name: string;
13
+ readonly description: string;
14
+ readonly localizations?: ClawclawResourceLocalizations;
15
+ }
16
+
17
+ export interface ClawclawResolvedResourceMetadata {
18
+ readonly id: string;
19
+ readonly name: string;
20
+ readonly description: string;
21
+ }
22
+
23
+ function normalizedLocale(value: string): string {
24
+ return value.trim().replaceAll('_', '-').toLowerCase();
25
+ }
26
+
27
+ export function hasValidClawclawResourceLocalizations(
28
+ localizations: ClawclawResourceLocalizations | undefined,
29
+ ): boolean {
30
+ if (localizations === undefined) return true;
31
+ if (!localizations || typeof localizations !== 'object' || Array.isArray(localizations)) return false;
32
+ return Object.entries(localizations).every(([locale, text]) => (
33
+ normalizedLocale(locale).length > 0
34
+ && !!text
35
+ && typeof text === 'object'
36
+ && !Array.isArray(text)
37
+ && typeof text.name === 'string'
38
+ && text.name.trim().length > 0
39
+ && typeof text.description === 'string'
40
+ && text.description.trim().length > 0
41
+ ));
42
+ }
43
+
44
+ /** Resolves localized display text while preserving manifest text as the fallback. */
45
+ export function resolveClawclawResourceMetadata(
46
+ metadata: ClawclawResourceMetadata,
47
+ locale: string,
48
+ ): ClawclawResolvedResourceMetadata {
49
+ const requested = normalizedLocale(locale);
50
+ const entries = Object.entries(metadata.localizations ?? {});
51
+ const exact = entries.find(([key]) => normalizedLocale(key) === requested)?.[1];
52
+ const language = requested.split('-')[0];
53
+ const languageMatch = entries.find(([key]) => normalizedLocale(key) === language)?.[1];
54
+ const regionalMatch = entries.find(([key]) => (
55
+ normalizedLocale(key).startsWith(`${language}-`)
56
+ ))?.[1];
57
+ const localized = exact ?? languageMatch ?? regionalMatch;
58
+ return {
59
+ id: metadata.id,
60
+ name: localized?.name ?? metadata.name,
61
+ description: localized?.description ?? metadata.description,
62
+ };
63
+ }
@@ -22,6 +22,19 @@ import type {
22
22
 
23
23
  export const STRATEGY_PLUGIN_API_VERSION = 1 as const;
24
24
 
25
+ export {
26
+ hasValidClawclawResourceLocalizations,
27
+ resolveClawclawResourceMetadata,
28
+ } from '../resource-metadata.js';
29
+ export type {
30
+ ClawclawLocalizedResourceText,
31
+ ClawclawResolvedResourceMetadata,
32
+ ClawclawResourceLocalizations,
33
+ ClawclawResourceMetadata,
34
+ } from '../resource-metadata.js';
35
+
36
+ import type { ClawclawResourceLocalizations } from '../resource-metadata.js';
37
+
25
38
  export interface StrategyScope {
26
39
  readonly sessionId: string;
27
40
  readonly segmentId: string;
@@ -292,6 +305,7 @@ export interface ClawclawStrategyManifest {
292
305
  readonly id: string;
293
306
  readonly name: string;
294
307
  readonly description: string;
308
+ readonly localizations?: ClawclawResourceLocalizations;
295
309
  readonly controls?: readonly StrategyControlSpec[];
296
310
  /** Omitted means the stateful, serial update() compatibility contract. */
297
311
  readonly execution?: 'parallel_compute' | 'parallel_analyze';