@celljs/ta-web 4.35.0 → 4.37.0

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 (175) hide show
  1. package/esm/browser/assistant/assistant-thread.js +2 -2
  2. package/esm/browser/assistant/mic-capture.d.ts +34 -0
  3. package/esm/browser/assistant/mic-capture.js +87 -0
  4. package/esm/browser/assistant/realtime-voice.d.ts +2 -2
  5. package/esm/browser/assistant/realtime-voice.js +6 -15
  6. package/esm/browser/components/board.d.ts +2 -2
  7. package/esm/browser/components/board.js +2 -2
  8. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  9. package/esm/browser/components/composer-box-hooks.d.ts +12 -0
  10. package/esm/browser/components/composer-box-hooks.js +12 -0
  11. package/esm/browser/components/composer-box-protocol.d.ts +12 -1
  12. package/esm/browser/components/composer-box.js +14 -11
  13. package/esm/browser/components/composer.js +69 -3
  14. package/esm/browser/components/extension-settings.d.ts +7 -0
  15. package/esm/browser/components/extension-settings.js +32 -0
  16. package/esm/browser/components/host-view.d.ts +1 -1
  17. package/esm/browser/components/message-list.js +3 -3
  18. package/esm/browser/components/message-steps.js +3 -3
  19. package/esm/browser/components/phone-shell.d.ts +2 -2
  20. package/esm/browser/components/request-error.d.ts +9 -0
  21. package/esm/browser/components/request-error.js +21 -0
  22. package/esm/browser/components/settings-more.js +7 -24
  23. package/esm/browser/components/storage-settings.d.ts +17 -0
  24. package/esm/browser/components/storage-settings.js +145 -0
  25. package/esm/browser/extension/icons.js +2 -1
  26. package/esm/browser/extension/web-api-contributions.d.ts +6 -7
  27. package/esm/browser/extension/web-api-spec.js +2 -0
  28. package/esm/browser/extension/web-api-targets.d.ts +11 -0
  29. package/esm/browser/extension/web-api-targets.js +2 -0
  30. package/esm/browser/extension/web-extension-api.d.ts +5 -1
  31. package/esm/browser/extension/web-extension-context.d.ts +3 -2
  32. package/esm/browser/extension/web-extension-context.js +11 -15
  33. package/esm/browser/extension/web-extension-run.d.ts +2 -0
  34. package/esm/browser/extension/web-extension-run.js +12 -0
  35. package/esm/browser/extension/web-extensions-running.d.ts +2 -0
  36. package/esm/browser/extension/web-extensions-running.js +5 -0
  37. package/esm/browser/extension/web-extensions.js +1 -0
  38. package/esm/browser/game/game-control.d.ts +6 -0
  39. package/esm/browser/game/game-control.js +28 -0
  40. package/esm/browser/game/game-host.d.ts +9 -2
  41. package/esm/browser/game/game-host.js +5 -1
  42. package/esm/browser/game/game-protocol.d.ts +8 -0
  43. package/esm/browser/game/game-runner.d.ts +7 -1
  44. package/esm/browser/game/game-runner.js +24 -2
  45. package/esm/browser/game/game-target.d.ts +22 -0
  46. package/esm/browser/game/game-target.js +84 -0
  47. package/esm/browser/game/game-util.d.ts +2 -0
  48. package/esm/browser/game/game-util.js +2 -0
  49. package/esm/browser/game/game-view.d.ts +5 -2
  50. package/esm/browser/game/game-view.js +4 -4
  51. package/esm/browser/game/game3d-protocol.d.ts +3 -1
  52. package/esm/browser/game/game3d-runner.d.ts +6 -1
  53. package/esm/browser/game/game3d-runner.js +26 -2
  54. package/esm/browser/i18n/en/chat.d.ts +4 -0
  55. package/esm/browser/i18n/en/chat.js +4 -0
  56. package/esm/browser/i18n/en/settings.d.ts +15 -0
  57. package/esm/browser/i18n/en/settings.js +15 -0
  58. package/esm/browser/i18n/ja/chat.js +4 -0
  59. package/esm/browser/i18n/ja/settings.js +15 -0
  60. package/esm/browser/i18n/locales.d.ts +20 -1
  61. package/esm/browser/i18n/messages.d.ts +19 -0
  62. package/esm/browser/i18n/zh/chat.js +4 -0
  63. package/esm/browser/i18n/zh/settings.js +15 -0
  64. package/esm/browser/i18n/zh-tw/chat.js +4 -0
  65. package/esm/browser/i18n/zh-tw/settings.js +15 -0
  66. package/esm/browser/index.d.ts +2 -0
  67. package/esm/browser/index.js +2 -0
  68. package/esm/browser/sandbox/remote/remote-copy.d.ts +1 -0
  69. package/esm/browser/sandbox/remote/remote-copy.js +16 -0
  70. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  71. package/esm/browser/settings/agent-settings.js +5 -1
  72. package/esm/browser/style/pages.d.ts +1 -1
  73. package/esm/browser/style/pages.js +2 -0
  74. package/esm/browser/style/surfaces.d.ts +1 -1
  75. package/esm/browser/style/surfaces.js +2 -3
  76. package/esm/browser/targets/targets-protocol.d.ts +54 -0
  77. package/esm/browser/targets/targets-protocol.js +34 -0
  78. package/esm/browser/targets/targets.d.ts +13 -0
  79. package/esm/browser/targets/targets.js +64 -0
  80. package/esm/browser/util/composer.d.ts +4 -2
  81. package/esm/browser/util/composer.js +7 -1
  82. package/esm/browser/util/message.d.ts +6 -0
  83. package/esm/browser/util/message.js +21 -0
  84. package/esm/browser/util/process.d.ts +1 -0
  85. package/esm/browser/util/process.js +6 -1
  86. package/esm/browser/util/progress.d.ts +2 -1
  87. package/esm/browser/util/progress.js +2 -11
  88. package/lib/browser/assistant/assistant-thread.js +2 -2
  89. package/lib/browser/assistant/mic-capture.d.ts +35 -0
  90. package/lib/browser/assistant/mic-capture.js +91 -0
  91. package/lib/browser/assistant/realtime-voice.d.ts +2 -2
  92. package/lib/browser/assistant/realtime-voice.js +6 -15
  93. package/lib/browser/components/board.d.ts +2 -2
  94. package/lib/browser/components/board.js +2 -2
  95. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  96. package/lib/browser/components/composer-box-hooks.d.ts +12 -0
  97. package/lib/browser/components/composer-box-hooks.js +13 -0
  98. package/lib/browser/components/composer-box-protocol.d.ts +12 -1
  99. package/lib/browser/components/composer-box.js +13 -10
  100. package/lib/browser/components/composer.js +69 -3
  101. package/lib/browser/components/extension-settings.d.ts +8 -0
  102. package/lib/browser/components/extension-settings.js +69 -0
  103. package/lib/browser/components/host-view.d.ts +1 -1
  104. package/lib/browser/components/message-list.js +3 -3
  105. package/lib/browser/components/message-steps.js +3 -3
  106. package/lib/browser/components/phone-shell.d.ts +2 -2
  107. package/lib/browser/components/request-error.d.ts +10 -0
  108. package/lib/browser/components/request-error.js +57 -0
  109. package/lib/browser/components/settings-more.js +6 -23
  110. package/lib/browser/components/storage-settings.d.ts +18 -0
  111. package/lib/browser/components/storage-settings.js +182 -0
  112. package/lib/browser/extension/icons.js +1 -0
  113. package/lib/browser/extension/web-api-contributions.d.ts +6 -7
  114. package/lib/browser/extension/web-api-spec.js +2 -0
  115. package/lib/browser/extension/web-api-targets.d.ts +12 -0
  116. package/lib/browser/extension/web-api-targets.js +3 -0
  117. package/lib/browser/extension/web-extension-api.d.ts +5 -1
  118. package/lib/browser/extension/web-extension-context.d.ts +3 -2
  119. package/lib/browser/extension/web-extension-context.js +11 -15
  120. package/lib/browser/extension/web-extension-run.d.ts +2 -0
  121. package/lib/browser/extension/web-extension-run.js +12 -0
  122. package/lib/browser/extension/web-extensions-running.d.ts +2 -0
  123. package/lib/browser/extension/web-extensions-running.js +5 -0
  124. package/lib/browser/extension/web-extensions.js +1 -0
  125. package/lib/browser/game/game-control.d.ts +6 -0
  126. package/lib/browser/game/game-control.js +28 -0
  127. package/lib/browser/game/game-host.d.ts +9 -2
  128. package/lib/browser/game/game-host.js +5 -1
  129. package/lib/browser/game/game-protocol.d.ts +8 -0
  130. package/lib/browser/game/game-runner.d.ts +7 -1
  131. package/lib/browser/game/game-runner.js +24 -2
  132. package/lib/browser/game/game-target.d.ts +23 -0
  133. package/lib/browser/game/game-target.js +87 -0
  134. package/lib/browser/game/game-util.d.ts +2 -0
  135. package/lib/browser/game/game-util.js +2 -0
  136. package/lib/browser/game/game-view.d.ts +5 -2
  137. package/lib/browser/game/game-view.js +4 -4
  138. package/lib/browser/game/game3d-protocol.d.ts +3 -1
  139. package/lib/browser/game/game3d-runner.d.ts +6 -1
  140. package/lib/browser/game/game3d-runner.js +26 -2
  141. package/lib/browser/i18n/en/chat.d.ts +4 -0
  142. package/lib/browser/i18n/en/chat.js +4 -0
  143. package/lib/browser/i18n/en/settings.d.ts +15 -0
  144. package/lib/browser/i18n/en/settings.js +15 -0
  145. package/lib/browser/i18n/ja/chat.js +4 -0
  146. package/lib/browser/i18n/ja/settings.js +15 -0
  147. package/lib/browser/i18n/locales.d.ts +20 -1
  148. package/lib/browser/i18n/messages.d.ts +19 -0
  149. package/lib/browser/i18n/zh/chat.js +4 -0
  150. package/lib/browser/i18n/zh/settings.js +15 -0
  151. package/lib/browser/i18n/zh-tw/chat.js +4 -0
  152. package/lib/browser/i18n/zh-tw/settings.js +15 -0
  153. package/lib/browser/index.d.ts +2 -0
  154. package/lib/browser/index.js +2 -0
  155. package/lib/browser/sandbox/remote/remote-copy.d.ts +1 -0
  156. package/lib/browser/sandbox/remote/remote-copy.js +16 -0
  157. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  158. package/lib/browser/settings/agent-settings.js +5 -1
  159. package/lib/browser/style/pages.d.ts +1 -1
  160. package/lib/browser/style/pages.js +2 -0
  161. package/lib/browser/style/surfaces.d.ts +1 -1
  162. package/lib/browser/style/surfaces.js +2 -3
  163. package/lib/browser/targets/targets-protocol.d.ts +55 -0
  164. package/lib/browser/targets/targets-protocol.js +37 -0
  165. package/lib/browser/targets/targets.d.ts +14 -0
  166. package/lib/browser/targets/targets.js +67 -0
  167. package/lib/browser/util/composer.d.ts +4 -2
  168. package/lib/browser/util/composer.js +7 -1
  169. package/lib/browser/util/message.d.ts +6 -0
  170. package/lib/browser/util/message.js +21 -0
  171. package/lib/browser/util/process.d.ts +1 -0
  172. package/lib/browser/util/process.js +6 -1
  173. package/lib/browser/util/progress.d.ts +2 -1
  174. package/lib/browser/util/progress.js +2 -11
  175. package/package.json +7 -7
@@ -15,6 +15,7 @@ class GameRunner {
15
15
  constructor(engine, config, element, page, fail) {
16
16
  this.element = element;
17
17
  this.asleep = false;
18
+ this.paused = false;
18
19
  this.disposed = false;
19
20
  this.game = new engine.Game(game_util_1.GameUtil.config(engine, config, element, fail));
20
21
  this.setPage(page);
@@ -32,6 +33,16 @@ class GameRunner {
32
33
  const { registry } = this.game;
33
34
  return this.disposed ? undefined : game_control_1.GameControlUtil.state({ score: registry.get(game_util_1.GameUtil.SCORE_KEY), over: registry.get(game_util_1.GameUtil.OVER_KEY) });
34
35
  }
36
+ /** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
37
+ observe() {
38
+ const observe = this.disposed ? undefined : this.game.registry.get(game_util_1.GameUtil.OBSERVE_KEY);
39
+ try {
40
+ return typeof observe === 'function' ? observe() : undefined;
41
+ }
42
+ catch (_a) {
43
+ return undefined;
44
+ }
45
+ }
35
46
  get sleeping() {
36
47
  return this.asleep;
37
48
  }
@@ -41,8 +52,19 @@ class GameRunner {
41
52
  return;
42
53
  }
43
54
  this.asleep = !visible;
55
+ this.apply();
56
+ }
57
+ /** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
58
+ setPaused(paused) {
59
+ if (this.disposed || paused === this.paused) {
60
+ return;
61
+ }
62
+ this.paused = paused;
63
+ this.apply();
64
+ }
65
+ apply() {
44
66
  const { loop, sound } = this.game;
45
- if (this.asleep) {
67
+ if (this.asleep || this.paused) {
46
68
  loop.sleep();
47
69
  sound === null || sound === void 0 ? void 0 : sound.pauseAll();
48
70
  }
@@ -61,7 +83,7 @@ class GameRunner {
61
83
  }
62
84
  this.disposed = true;
63
85
  this.game.destroy(true);
64
- if (this.asleep && this.game.isRunning) {
86
+ if ((this.asleep || this.paused) && this.game.isRunning) {
65
87
  this.game.loop.wake();
66
88
  }
67
89
  }
@@ -0,0 +1,23 @@
1
+ import type { TargetAction } from '@celljs/ta-protocol';
2
+ import type { TargetSpec } from '../targets/targets-protocol';
3
+ import { type GameControl } from './game-control';
4
+ import type { GameObservation, GameState } from './game-protocol';
5
+ /** What GameTarget reads of a game while it runs: none before it started or after it ended. */
6
+ export interface GameTargetRunner {
7
+ observe?(): GameObservation | undefined;
8
+ state?(): GameState | undefined;
9
+ setPaused?(paused: boolean): void;
10
+ }
11
+ /**
12
+ * A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
13
+ * and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
14
+ * by a timer, so that a program never waits on them.
15
+ */
16
+ export declare namespace GameTarget {
17
+ const HZ = 60;
18
+ function spec(id: string, title: () => string, runner: () => GameTargetRunner | undefined, control: () => GameControl | undefined): TargetSpec;
19
+ function observation(runner: GameTargetRunner | undefined): GameObservation;
20
+ /** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
21
+ function act(hands: GameControl, action: TargetAction, later?: (run: () => void, ms: number) => void): void;
22
+ }
23
+ //# sourceMappingURL=game-target.d.ts.map
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GameTarget = void 0;
4
+ const game_control_1 = require("./game-control");
5
+ const clamp = (value) => Math.min(1, Math.max(0, value));
6
+ /**
7
+ * A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
8
+ * and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
9
+ * by a timer, so that a program never waits on them.
10
+ */
11
+ var GameTarget;
12
+ (function (GameTarget) {
13
+ GameTarget.HZ = 60;
14
+ function spec(id, title, runner, control) {
15
+ return {
16
+ id,
17
+ kind: 'game',
18
+ title,
19
+ tier: 'state',
20
+ actions: ['pointer', 'key'],
21
+ hz: GameTarget.HZ,
22
+ describe: 'entities: what the game shows, each {id, type, box: {x, y, w, h} from 0 to 1 across and down the canvas}; data: its score, its round, what else it says',
23
+ observe: () => observation(runner()),
24
+ act: actions => {
25
+ const hands = control();
26
+ if (hands && runner()) {
27
+ for (const action of actions) {
28
+ act(hands, action);
29
+ }
30
+ }
31
+ },
32
+ pause: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, true); },
33
+ resume: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, false); },
34
+ };
35
+ }
36
+ GameTarget.spec = spec;
37
+ function observation(runner) {
38
+ var _a, _b;
39
+ var _c;
40
+ const seen = (_a = runner === null || runner === void 0 ? void 0 : runner.observe) === null || _a === void 0 ? void 0 : _a.call(runner);
41
+ const state = (_b = runner === null || runner === void 0 ? void 0 : runner.state) === null || _b === void 0 ? void 0 : _b.call(runner);
42
+ const data = { ...(state !== null && state !== void 0 ? state : {}), ...((_c = seen === null || seen === void 0 ? void 0 : seen.data) !== null && _c !== void 0 ? _c : {}) };
43
+ return { ...((seen === null || seen === void 0 ? void 0 : seen.entities) ? { entities: seen.entities } : {}), ...(Object.keys(data).length ? { data } : {}) };
44
+ }
45
+ GameTarget.observation = observation;
46
+ /** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
47
+ function act(hands, action, later = (run, ms) => setTimeout(run, ms)) {
48
+ var _a, _b;
49
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
50
+ if (action.kind === 'pointer') {
51
+ if (action.dx !== undefined || action.dy !== undefined) {
52
+ hands.nudge((_c = action.dx) !== null && _c !== void 0 ? _c : 0, (_d = action.dy) !== null && _d !== void 0 ? _d : 0);
53
+ return;
54
+ }
55
+ const at = action.x === undefined && action.y === undefined
56
+ ? ((_e = hands.at) !== null && _e !== void 0 ? _e : { x: 0.5, y: 0.5 })
57
+ : { x: clamp((_g = (_f = action.x) !== null && _f !== void 0 ? _f : (_a = hands.at) === null || _a === void 0 ? void 0 : _a.x) !== null && _g !== void 0 ? _g : 0.5), y: clamp((_j = (_h = action.y) !== null && _h !== void 0 ? _h : (_b = hands.at) === null || _b === void 0 ? void 0 : _b.y) !== null && _j !== void 0 ? _j : 0.5) };
58
+ const press = (_k = action.press) !== null && _k !== void 0 ? _k : 'click';
59
+ if (press === 'move') {
60
+ void hands.move(at);
61
+ }
62
+ else if (press === 'click') {
63
+ hands.pointerPress(at, true);
64
+ later(() => hands.pointerPress(at, false), game_control_1.GameControlUtil.TAP_MS);
65
+ }
66
+ else {
67
+ hands.pointerPress(at, press === 'down');
68
+ }
69
+ return;
70
+ }
71
+ if (action.kind === 'key') {
72
+ const key = game_control_1.GameControlUtil.key(action.key);
73
+ const press = (_l = action.press) !== null && _l !== void 0 ? _l : 'tap';
74
+ if (press === 'tap') {
75
+ hands.keyPress(key, true);
76
+ later(() => hands.keyPress(key, false), (_m = action.ms) !== null && _m !== void 0 ? _m : game_control_1.GameControlUtil.TAP_MS);
77
+ }
78
+ else {
79
+ hands.keyPress(key, press === 'down');
80
+ }
81
+ return;
82
+ }
83
+ throw new Error(`A game takes pointer and key actions, not ${action.kind}.`);
84
+ }
85
+ GameTarget.act = act;
86
+ })(GameTarget || (exports.GameTarget = GameTarget = {}));
87
+ //# sourceMappingURL=game-target.js.map
@@ -6,6 +6,8 @@ export declare namespace GameUtil {
6
6
  /** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
7
7
  const SCORE_KEY = "score";
8
8
  const OVER_KEY = "over";
9
+ /** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
10
+ const OBSERVE_KEY = "observe";
9
11
  /**
10
12
  * Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
11
13
  * needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
@@ -34,6 +34,8 @@ var GameUtil;
34
34
  /** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
35
35
  GameUtil.SCORE_KEY = 'score';
36
36
  GameUtil.OVER_KEY = 'over';
37
+ /** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
38
+ GameUtil.OBSERVE_KEY = 'observe';
37
39
  /**
38
40
  * Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
39
41
  * needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
@@ -1,16 +1,19 @@
1
1
  import * as React from 'react';
2
2
  import type { TaScreen } from '../screen/screen-protocol';
3
3
  import type { TaSettings } from '../settings/settings-protocol';
4
+ import type { TaTargets } from '../targets/targets-protocol';
4
5
  import type { GameProps } from './game-protocol';
5
6
  import type { Game3DProps } from './game3d-protocol';
6
7
  /** A game of a web extension on Phaser (`ui.Game`): GameRunner in a GameHost. */
7
- export declare function GameView({ settings, screen, config, onReady, title, className, style }: GameProps & {
8
+ export declare function GameView({ settings, screen, targets, config, onReady, title, className, style, }: GameProps & {
8
9
  settings: TaSettings;
9
10
  screen?: TaScreen;
11
+ targets?: TaTargets;
10
12
  }): React.JSX.Element;
11
13
  /** A 3D game of a web extension on Three.js (`ui.Game3D`): Game3DRunner in a GameHost. */
12
- export declare function Game3DView({ settings, screen, setup, onReady, title, className, style }: Game3DProps & {
14
+ export declare function Game3DView({ settings, screen, targets, setup, onReady, title, className, style, }: Game3DProps & {
13
15
  settings: TaSettings;
14
16
  screen?: TaScreen;
17
+ targets?: TaTargets;
15
18
  }): React.JSX.Element;
16
19
  //# sourceMappingURL=game-view.d.ts.map
@@ -41,7 +41,7 @@ const game_loader_1 = require("./game-loader");
41
41
  const game_runner_1 = require("./game-runner");
42
42
  const game3d_runner_1 = require("./game3d-runner");
43
43
  /** A game of a web extension on Phaser (`ui.Game`): GameRunner in a GameHost. */
44
- function GameView({ settings, screen, config, onReady, title, className, style }) {
44
+ function GameView({ settings, screen, targets, config, onReady, title, className, style, }) {
45
45
  const props = React.useRef({ config, onReady });
46
46
  props.current = { config, onReady };
47
47
  const start = React.useCallback(async (element, page, fail) => {
@@ -50,10 +50,10 @@ function GameView({ settings, screen, config, onReady, title, className, style }
50
50
  runner.game.events.once(engine.Core.Events.READY, () => { var _a, _b; return (_b = (_a = props.current).onReady) === null || _b === void 0 ? void 0 : _b.call(_a, runner.game); });
51
51
  return runner;
52
52
  }, []);
53
- return React.createElement(game_host_1.GameHost, { settings: settings, start: start, title: title, screen: screen, className: className, style: style });
53
+ return React.createElement(game_host_1.GameHost, { settings: settings, start: start, title: title, screen: screen, targets: targets, className: className, style: style });
54
54
  }
55
55
  /** A 3D game of a web extension on Three.js (`ui.Game3D`): Game3DRunner in a GameHost. */
56
- function Game3DView({ settings, screen, setup, onReady, title, className, style }) {
56
+ function Game3DView({ settings, screen, targets, setup, onReady, title, className, style, }) {
57
57
  const props = React.useRef({ setup, onReady });
58
58
  props.current = { setup, onReady };
59
59
  const start = React.useCallback(async (element, page, fail) => {
@@ -63,6 +63,6 @@ function Game3DView({ settings, screen, setup, onReady, title, className, style
63
63
  (_b = (_a = props.current).onReady) === null || _b === void 0 ? void 0 : _b.call(_a, runner.context);
64
64
  return runner;
65
65
  }, []);
66
- return React.createElement(game_host_1.GameHost, { settings: settings, start: start, title: title, screen: screen, className: className, style: style });
66
+ return React.createElement(game_host_1.GameHost, { settings: settings, start: start, title: title, screen: screen, targets: targets, className: className, style: style });
67
67
  }
68
68
  //# sourceMappingURL=game-view.js.map
@@ -1,5 +1,5 @@
1
1
  import type * as ThreeModule from 'three';
2
- import type { GamePage, GameState } from './game-protocol';
2
+ import type { GameObservation, GamePage, GameState } from './game-protocol';
3
3
  /** The addons are ES modules only, and this a CommonJS one. */
4
4
  type OrbitControlsClass = typeof import('three/addons/controls/OrbitControls.js', { with: { 'resolution-mode': 'import' } }).OrbitControls;
5
5
  type GLTFLoaderClass = typeof import('three/addons/loaders/GLTFLoader.js', { with: { 'resolution-mode': 'import' } }).GLTFLoader;
@@ -48,6 +48,8 @@ export interface Game3DLoop {
48
48
  page?(page: GamePage): void;
49
49
  /** Its score and whether its round is over, read when Ta looks at the screen: what the agent is told of it. */
50
50
  state?(): GameState | undefined;
51
+ /** What is in it now, for a program that plays it frame by frame (GameObservation). */
52
+ observe?(): GameObservation | undefined;
51
53
  /** Before the game ends; what is in the scene the page disposes itself. */
52
54
  dispose?(): void;
53
55
  }
@@ -1,5 +1,5 @@
1
1
  import type * as ThreeModule from 'three';
2
- import type { GamePage, GameState } from './game-protocol';
2
+ import type { GameObservation, GamePage, GameState } from './game-protocol';
3
3
  import type { Game3DContext, Game3DEngine, Game3DLoop, Game3DProps } from './game3d-protocol';
4
4
  /**
5
5
  * One 3D game in an element of the page, from its start to its end: a WebGLRenderer of Three.js drawing into
@@ -11,12 +11,17 @@ export declare class Game3DRunner {
11
11
  readonly context: Game3DContext;
12
12
  protected readonly loop: Game3DLoop;
13
13
  protected asleep: boolean;
14
+ protected paused: boolean;
14
15
  protected disposed: boolean;
15
16
  protected last?: number;
16
17
  protected elapsed: number;
17
18
  constructor(engine: Game3DEngine, setup: Game3DProps['setup'], element: HTMLElement, page: GamePage, onError?: (error: unknown) => void);
18
19
  /** What the game says of its round (Game3DLoop.state); nothing when that throws. */
19
20
  state(): GameState | undefined;
21
+ /** What the game says is in it now (Game3DLoop.observe); nothing when that throws. */
22
+ observe(): GameObservation | undefined;
23
+ /** Waits for a slow player: its frames still drawn, its time stopped, till it goes on. */
24
+ setPaused(paused: boolean): void;
20
25
  get sleeping(): boolean;
21
26
  protected readonly frame: (time: number) => void;
22
27
  setPage(page: GamePage): void;
@@ -17,16 +17,19 @@ class Game3DRunner {
17
17
  var _a;
18
18
  this.onError = onError;
19
19
  this.asleep = false;
20
+ this.paused = false;
20
21
  this.disposed = false;
21
22
  this.elapsed = 0;
22
23
  this.frame = (time) => {
23
24
  var _a;
24
- const seconds = this.last === undefined ? 0 : Math.min(MAX_STEP, Math.max(0, (time - this.last) / 1000));
25
+ const seconds = this.paused || this.last === undefined ? 0 : Math.min(MAX_STEP, Math.max(0, (time - this.last) / 1000));
25
26
  this.last = time;
26
27
  this.elapsed += seconds;
27
28
  const { context, loop } = this;
28
29
  try {
29
- (_a = loop.update) === null || _a === void 0 ? void 0 : _a.call(loop, seconds, this.elapsed);
30
+ if (!this.paused) {
31
+ (_a = loop.update) === null || _a === void 0 ? void 0 : _a.call(loop, seconds, this.elapsed);
32
+ }
30
33
  if (loop.render) {
31
34
  loop.render();
32
35
  }
@@ -74,6 +77,27 @@ class Game3DRunner {
74
77
  return undefined;
75
78
  }
76
79
  }
80
+ /** What the game says is in it now (Game3DLoop.observe); nothing when that throws. */
81
+ observe() {
82
+ var _a, _b;
83
+ var _c;
84
+ if (this.disposed) {
85
+ return undefined;
86
+ }
87
+ try {
88
+ return (_c = (_b = (_a = this.loop).observe) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : undefined;
89
+ }
90
+ catch (_d) {
91
+ return undefined;
92
+ }
93
+ }
94
+ /** Waits for a slow player: its frames still drawn, its time stopped, till it goes on. */
95
+ setPaused(paused) {
96
+ if (!this.disposed && paused !== this.paused) {
97
+ this.paused = paused;
98
+ this.last = undefined;
99
+ }
100
+ }
77
101
  get sleeping() {
78
102
  return this.asleep;
79
103
  }
@@ -64,6 +64,9 @@ export declare const CHAT_EN: {
64
64
  'ta.message.interrupted': string;
65
65
  'ta.message.silent': string;
66
66
  'ta.message.failedUnknown': string;
67
+ 'ta.message.failed.network': string;
68
+ 'ta.message.failed.rateLimit': string;
69
+ 'ta.message.failed.overloaded': string;
67
70
  'ta.message.resume': string;
68
71
  'ta.message.resumeText': string;
69
72
  'ta.message.thinking': string;
@@ -97,6 +100,7 @@ export declare const CHAT_EN: {
97
100
  'ta.message.used': string;
98
101
  'ta.message.modelSwitched': string;
99
102
  'ta.message.resumed': string;
103
+ 'ta.message.resumedOnline': string;
100
104
  'ta.message.usageTitle': string;
101
105
  'ta.chats.busyFilter': string;
102
106
  'ta.chats.busyClear': string;
@@ -67,6 +67,9 @@ exports.CHAT_EN = {
67
67
  'ta.message.interrupted': 'Cut off before it was done: the service stopped, or the agent ended its turn with work not finished.',
68
68
  'ta.message.silent': 'Ended without a reply: the agent may have lost the connection to its model.',
69
69
  'ta.message.failedUnknown': 'The request failed, without saying why.',
70
+ 'ta.message.failed.network': 'The network dropped, the request did not get through',
71
+ 'ta.message.failed.rateLimit': 'The model provider is limiting requests',
72
+ 'ta.message.failed.overloaded': 'The model is too busy right now',
70
73
  'ta.message.resume': 'Continue',
71
74
  'ta.message.resumeText': 'Continue',
72
75
  'ta.message.thinking': 'Thinking',
@@ -100,6 +103,7 @@ exports.CHAT_EN = {
100
103
  'ta.message.used': 'Used',
101
104
  'ta.message.modelSwitched': 'Switched to {model}',
102
105
  'ta.message.resumed': 'Carried on after Ta restarted',
106
+ 'ta.message.resumedOnline': 'Carried on once the network was back',
103
107
  'ta.message.usageTitle': '{input} tokens sent, {output} received',
104
108
  'ta.chats.busyFilter': 'Going on',
105
109
  'ta.chats.busyClear': 'Show all conversations',
@@ -71,6 +71,19 @@ export declare const SETTINGS_EN: {
71
71
  'ta.settings.server': string;
72
72
  'ta.settings.version': string;
73
73
  'ta.settings.files': string;
74
+ 'ta.storage.title': string;
75
+ 'ta.storage.hint': string;
76
+ 'ta.storage.total': string;
77
+ 'ta.storage.usage': string;
78
+ 'ta.storage.keep': string;
79
+ 'ta.storage.keepAll': string;
80
+ 'ta.storage.max': string;
81
+ 'ta.storage.maxNone': string;
82
+ 'ta.storage.keepLabel': string;
83
+ 'ta.storage.maxLabel': string;
84
+ 'ta.storage.clear': string;
85
+ 'ta.storage.clearConfirm': string;
86
+ 'ta.storage.freed': string;
74
87
  'ta.settings.files.checking': string;
75
88
  'ta.settings.files.ok': string;
76
89
  'ta.settings.files.problems': string;
@@ -225,6 +238,8 @@ export declare const SETTINGS_EN: {
225
238
  'ta.setting.retry.enabled': string;
226
239
  'ta.setting.retry.enabled.hint': string;
227
240
  'ta.setting.retry.maxRetries': string;
241
+ 'ta.setting.retry.untilOnline': string;
242
+ 'ta.setting.retry.untilOnline.hint': string;
228
243
  'ta.setting.codemode.mode': string;
229
244
  'ta.setting.codemode.mode.hint': string;
230
245
  'ta.setting.codemode.mode.only': string;
@@ -74,6 +74,19 @@ exports.SETTINGS_EN = {
74
74
  'ta.settings.server': 'Server',
75
75
  'ta.settings.version': 'Version',
76
76
  'ta.settings.files': 'Settings files',
77
+ 'ta.storage.title': 'Storage',
78
+ 'ta.storage.hint': 'What Ta keeps on this computer. Past the days or the size set, the oldest goes first, by itself.',
79
+ 'ta.storage.total': 'In all {size}',
80
+ 'ta.storage.usage': 'Takes {size}',
81
+ 'ta.storage.keep': 'Keep {days} days',
82
+ 'ta.storage.keepAll': 'Keep all',
83
+ 'ta.storage.max': 'Up to {size}',
84
+ 'ta.storage.maxNone': 'Any size',
85
+ 'ta.storage.keepLabel': 'Days kept',
86
+ 'ta.storage.maxLabel': 'Size limit',
87
+ 'ta.storage.clear': 'Clear',
88
+ 'ta.storage.clearConfirm': 'Clear “{name}”?',
89
+ 'ta.storage.freed': 'Freed {size}',
77
90
  'ta.settings.files.checking': 'Checking the files of settings…',
78
91
  'ta.settings.files.ok': '{count, plural, one {The # file of settings reads} other {All # files of settings read}}',
79
92
  'ta.settings.files.problems': '{count, plural, one {# file is left out: it does not read} other {# files are left out: they do not read}}',
@@ -228,6 +241,8 @@ exports.SETTINGS_EN = {
228
241
  'ta.setting.retry.enabled': 'Retry failed requests',
229
242
  'ta.setting.retry.enabled.hint': 'On rate limits and errors of the provider.',
230
243
  'ta.setting.retry.maxRetries': 'Retries',
244
+ 'ta.setting.retry.untilOnline': 'Carry on once the network is back',
245
+ 'ta.setting.retry.untilOnline.hint': 'When the network drops mid-task (lid closed, a move, overnight), Ta goes on when it reconnects.',
231
246
  'ta.setting.codemode.mode': 'Code mode',
232
247
  'ta.setting.codemode.mode.hint': 'How Ta calls its tools: from scripts only, or also one by one.',
233
248
  'ta.setting.codemode.mode.only': 'Scripts only',
@@ -66,6 +66,9 @@ exports.CHAT_JA = {
66
66
  'ta.message.interrupted': '途中で遮断されました:Ta サービスが停止したか、エージェントが作業を完了していません。',
67
67
  'ta.message.silent': '返信なしで終了しました。エージェントがモデルとの接続を失った可能性があります。',
68
68
  'ta.message.failedUnknown': 'リクエストが失敗しました。理由は説明されていません。',
69
+ 'ta.message.failed.network': 'ネットワークが切れて、リクエストが届きませんでした',
70
+ 'ta.message.failed.rateLimit': 'モデルのサービスがリクエストを制限しています',
71
+ 'ta.message.failed.overloaded': 'モデルが混み合っています',
69
72
  'ta.message.resume': '続行',
70
73
  'ta.message.resumeText': '続行',
71
74
  'ta.message.thinking': '思考中',
@@ -99,6 +102,7 @@ exports.CHAT_JA = {
99
102
  'ta.message.used': '使用済み',
100
103
  'ta.message.modelSwitched': '{model} に切り替えました',
101
104
  'ta.message.resumed': 'Ta 再起動後に続行',
105
+ 'ta.message.resumedOnline': 'ネットワーク復帰後に続行',
102
106
  'ta.message.usageTitle': '{input} トークンを送信、{output} を受信',
103
107
  'ta.chats.busyFilter': '進行中',
104
108
  'ta.chats.busyClear': 'すべての会話を表示',
@@ -73,6 +73,19 @@ exports.SETTINGS_JA = {
73
73
  'ta.settings.server': 'サービス',
74
74
  'ta.settings.version': 'バージョン',
75
75
  'ta.settings.files': '設定ファイル',
76
+ 'ta.storage.title': 'ストレージ',
77
+ 'ta.storage.hint': 'Ta がこのコンピュータに保存しているもの。保存期間や容量の上限を超えると、古いものから自動で消えます。',
78
+ 'ta.storage.total': '合計 {size}',
79
+ 'ta.storage.usage': '使用量 {size}',
80
+ 'ta.storage.keep': '{days} 日間保存',
81
+ 'ta.storage.keepAll': 'ずっと保存',
82
+ 'ta.storage.max': '最大 {size}',
83
+ 'ta.storage.maxNone': '容量の上限なし',
84
+ 'ta.storage.keepLabel': '保存期間',
85
+ 'ta.storage.maxLabel': '容量の上限',
86
+ 'ta.storage.clear': '消去',
87
+ 'ta.storage.clearConfirm': '「{name}」を消去しますか?',
88
+ 'ta.storage.freed': '{size} を空けました',
76
89
  'ta.settings.files.checking': '設定ファイルを確認しています…',
77
90
  'ta.settings.files.ok': '{count} 個の設定ファイルはすべて読み込めます',
78
91
  'ta.settings.files.problems': '{count} 個のファイルを読み込めず、その設定は無効です',
@@ -227,6 +240,8 @@ exports.SETTINGS_JA = {
227
240
  'ta.setting.retry.enabled': '失敗したリクエストを再試行',
228
241
  'ta.setting.retry.enabled.hint': 'レート制限またはモデルサービスのエラー時に再試行します。',
229
242
  'ta.setting.retry.maxRetries': '再試行回数',
243
+ 'ta.setting.retry.untilOnline': 'ネットワーク復帰後に続行',
244
+ 'ta.setting.retry.untilOnline.hint': '作業中にネットワークが切れても(蓋を閉じる、移動、一晩)、つながり次第続けます。',
230
245
  'ta.setting.codemode.mode': 'コードモード',
231
246
  'ta.setting.codemode.mode.hint': 'Ta がツールを呼び出す方法:スクリプトのみ、またはスクリプトと個別の直接呼び出しの両方。',
232
247
  'ta.setting.codemode.mode.only': 'スクリプトのみ',