@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
@@ -6,6 +6,7 @@ import { OwnGestures } from '../device/own-gestures.js';
6
6
  import { useT } from '../i18n/use-t.js';
7
7
  import { ScreenUtil } from '../screen/screen-protocol.js';
8
8
  import { GameControl, GameControlUtil } from './game-control.js';
9
+ import { GameTarget } from './game-target.js';
9
10
  import { GameUtil } from './game-util.js';
10
11
  /**
11
12
  * The element of a game of a web extension (`ui.Game`, `ui.Game3D`): it fills its parent, starts the game
@@ -17,7 +18,7 @@ import { GameUtil } from './game-util.js';
17
18
  * It is a part of the screen (`game`, GameControl): Ta sees how it stands and taps, moves, presses keys and holds on it
18
19
  * for the user, by events on its canvas that no gesture of the shell starts from.
19
20
  */
20
- export function GameHost({ settings: store, start, title, screen, className, style }) {
21
+ export function GameHost({ settings: store, start, title, screen, targets, className, style }) {
21
22
  var _a;
22
23
  const t = useT();
23
24
  const settings = React.useSyncExternalStore(listener => store.subscribe(listener), () => store.state);
@@ -40,6 +41,9 @@ export function GameHost({ settings: store, start, title, screen, className, sty
40
41
  (_a = partId.current) !== null && _a !== void 0 ? _a : (partId.current = GameControlUtil.partId());
41
42
  part.current = GameControl.spec(partId.current, title || t('ta.game.label'), { point: t('ta.game.point'), move: t('ta.game.move'), key: t('ta.game.key'), hold: t('ta.game.hold') }, () => { var _a, _b, _c; return ({ started: !!runner.current, sleeping: (_a = runner.current) === null || _a === void 0 ? void 0 : _a.sleeping, error: errorOf.current, state: (_c = (_b = runner.current) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.call(_b) }); }, () => control.current);
42
43
  React.useEffect(() => screen === null || screen === void 0 ? void 0 : screen.register(() => part.current), [screen]);
44
+ const named = React.useRef(title);
45
+ named.current = title || t('ta.game.label');
46
+ React.useEffect(() => targets === null || targets === void 0 ? void 0 : targets.register(GameTarget.spec(partId.current, () => named.current, () => runner.current, () => control.current)), [targets]);
43
47
  React.useEffect(() => {
44
48
  const element = host.current;
45
49
  if (!element) {
@@ -1,3 +1,4 @@
1
+ import type { TargetObservation } from '@celljs/ta-protocol';
1
2
  import type * as PhaserModule from 'phaser';
2
3
  import type { Theme } from '../settings/settings-protocol.js';
3
4
  /**
@@ -43,6 +44,13 @@ export interface GameState {
43
44
  score?: number;
44
45
  over?: boolean;
45
46
  }
47
+ /**
48
+ * What is in a game now, for a program to play it frame by frame (docs/design/ta-reflex.md 4): its things as entities
49
+ * (`{ id, type, box }`, a box from 0 to 1 across and down the canvas, as the player sees it) and what else it says
50
+ * (`data`: the score, the round). A Phaser game sets a function giving it in its registry (GameUtil.OBSERVE_KEY), a
51
+ * 3D one returns it from `observe` of its loop. Read every frame while a program plays: cheap, no allocation it can spare.
52
+ */
53
+ export type GameObservation = Omit<TargetObservation, 't'>;
46
54
  /** A point of the canvas: `x` 0 at its left and 1 at its right, `y` 0 at its top and 1 at its bottom (GameControl). */
47
55
  export interface GamePoint {
48
56
  x: number;
@@ -1,4 +1,4 @@
1
- import type { GameConfig, GameEngine, GameInstance, GamePage, GameState } from './game-protocol.js';
1
+ import type { GameConfig, GameEngine, GameInstance, GameObservation, GamePage, GameState } from './game-protocol.js';
2
2
  /**
3
3
  * One game in an element of the page, from its start to its end: Phaser's Game made with the config of the
4
4
  * extension (GameUtil.config), asleep while the element is out of sight, destroyed with it.
@@ -12,15 +12,21 @@ export declare class GameRunner {
12
12
  readonly game: GameInstance;
13
13
  protected page?: GamePage;
14
14
  protected asleep: boolean;
15
+ protected paused: boolean;
15
16
  protected disposed: boolean;
16
17
  constructor(engine: GameEngine, config: GameConfig, element: HTMLElement, page: GamePage, fail?: (error: unknown) => void);
17
18
  /** Sets the page in the game's registry when it changed: scenes hear `changedata-page`. */
18
19
  setPage(page: GamePage): void;
19
20
  /** What the game set of its round in its registry (GameUtil.SCORE_KEY, GameUtil.OVER_KEY). */
20
21
  state(): GameState | undefined;
22
+ /** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
23
+ observe(): GameObservation | undefined;
21
24
  get sleeping(): boolean;
22
25
  /** Whether the element can be seen: the game sleeps while not. */
23
26
  setVisible(visible: boolean): void;
27
+ /** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
28
+ setPaused(paused: boolean): void;
29
+ protected apply(): void;
24
30
  /**
25
31
  * Destroys the game and takes its canvas out. Phaser destroys it at the end of its next frame: a loop
26
32
  * asleep is woken for it, and a game not booted yet is destroyed as it boots.
@@ -12,6 +12,7 @@ export class GameRunner {
12
12
  constructor(engine, config, element, page, fail) {
13
13
  this.element = element;
14
14
  this.asleep = false;
15
+ this.paused = false;
15
16
  this.disposed = false;
16
17
  this.game = new engine.Game(GameUtil.config(engine, config, element, fail));
17
18
  this.setPage(page);
@@ -29,6 +30,16 @@ export class GameRunner {
29
30
  const { registry } = this.game;
30
31
  return this.disposed ? undefined : GameControlUtil.state({ score: registry.get(GameUtil.SCORE_KEY), over: registry.get(GameUtil.OVER_KEY) });
31
32
  }
33
+ /** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
34
+ observe() {
35
+ const observe = this.disposed ? undefined : this.game.registry.get(GameUtil.OBSERVE_KEY);
36
+ try {
37
+ return typeof observe === 'function' ? observe() : undefined;
38
+ }
39
+ catch (_a) {
40
+ return undefined;
41
+ }
42
+ }
32
43
  get sleeping() {
33
44
  return this.asleep;
34
45
  }
@@ -38,8 +49,19 @@ export class GameRunner {
38
49
  return;
39
50
  }
40
51
  this.asleep = !visible;
52
+ this.apply();
53
+ }
54
+ /** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
55
+ setPaused(paused) {
56
+ if (this.disposed || paused === this.paused) {
57
+ return;
58
+ }
59
+ this.paused = paused;
60
+ this.apply();
61
+ }
62
+ apply() {
41
63
  const { loop, sound } = this.game;
42
- if (this.asleep) {
64
+ if (this.asleep || this.paused) {
43
65
  loop.sleep();
44
66
  sound === null || sound === void 0 ? void 0 : sound.pauseAll();
45
67
  }
@@ -58,7 +80,7 @@ export class GameRunner {
58
80
  }
59
81
  this.disposed = true;
60
82
  this.game.destroy(true);
61
- if (this.asleep && this.game.isRunning) {
83
+ if ((this.asleep || this.paused) && this.game.isRunning) {
62
84
  this.game.loop.wake();
63
85
  }
64
86
  }
@@ -0,0 +1,22 @@
1
+ import type { TargetAction } from '@celljs/ta-protocol';
2
+ import type { TargetSpec } from '../targets/targets-protocol.js';
3
+ import { type GameControl } from './game-control.js';
4
+ import type { GameObservation, GameState } from './game-protocol.js';
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
+ }
@@ -0,0 +1,84 @@
1
+ import { GameControlUtil } from './game-control.js';
2
+ const clamp = (value) => Math.min(1, Math.max(0, value));
3
+ /**
4
+ * A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
5
+ * and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
6
+ * by a timer, so that a program never waits on them.
7
+ */
8
+ export var GameTarget;
9
+ (function (GameTarget) {
10
+ GameTarget.HZ = 60;
11
+ function spec(id, title, runner, control) {
12
+ return {
13
+ id,
14
+ kind: 'game',
15
+ title,
16
+ tier: 'state',
17
+ actions: ['pointer', 'key'],
18
+ hz: GameTarget.HZ,
19
+ 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',
20
+ observe: () => observation(runner()),
21
+ act: actions => {
22
+ const hands = control();
23
+ if (hands && runner()) {
24
+ for (const action of actions) {
25
+ act(hands, action);
26
+ }
27
+ }
28
+ },
29
+ 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); },
30
+ 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); },
31
+ };
32
+ }
33
+ GameTarget.spec = spec;
34
+ function observation(runner) {
35
+ var _a, _b;
36
+ var _c;
37
+ const seen = (_a = runner === null || runner === void 0 ? void 0 : runner.observe) === null || _a === void 0 ? void 0 : _a.call(runner);
38
+ const state = (_b = runner === null || runner === void 0 ? void 0 : runner.state) === null || _b === void 0 ? void 0 : _b.call(runner);
39
+ const data = { ...(state !== null && state !== void 0 ? state : {}), ...((_c = seen === null || seen === void 0 ? void 0 : seen.data) !== null && _c !== void 0 ? _c : {}) };
40
+ return { ...((seen === null || seen === void 0 ? void 0 : seen.entities) ? { entities: seen.entities } : {}), ...(Object.keys(data).length ? { data } : {}) };
41
+ }
42
+ GameTarget.observation = observation;
43
+ /** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
44
+ function act(hands, action, later = (run, ms) => setTimeout(run, ms)) {
45
+ var _a, _b;
46
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
47
+ if (action.kind === 'pointer') {
48
+ if (action.dx !== undefined || action.dy !== undefined) {
49
+ hands.nudge((_c = action.dx) !== null && _c !== void 0 ? _c : 0, (_d = action.dy) !== null && _d !== void 0 ? _d : 0);
50
+ return;
51
+ }
52
+ const at = action.x === undefined && action.y === undefined
53
+ ? ((_e = hands.at) !== null && _e !== void 0 ? _e : { x: 0.5, y: 0.5 })
54
+ : { 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) };
55
+ const press = (_k = action.press) !== null && _k !== void 0 ? _k : 'click';
56
+ if (press === 'move') {
57
+ void hands.move(at);
58
+ }
59
+ else if (press === 'click') {
60
+ hands.pointerPress(at, true);
61
+ later(() => hands.pointerPress(at, false), GameControlUtil.TAP_MS);
62
+ }
63
+ else {
64
+ hands.pointerPress(at, press === 'down');
65
+ }
66
+ return;
67
+ }
68
+ if (action.kind === 'key') {
69
+ const key = GameControlUtil.key(action.key);
70
+ const press = (_l = action.press) !== null && _l !== void 0 ? _l : 'tap';
71
+ if (press === 'tap') {
72
+ hands.keyPress(key, true);
73
+ later(() => hands.keyPress(key, false), (_m = action.ms) !== null && _m !== void 0 ? _m : GameControlUtil.TAP_MS);
74
+ }
75
+ else {
76
+ hands.keyPress(key, press === 'down');
77
+ }
78
+ return;
79
+ }
80
+ throw new Error(`A game takes pointer and key actions, not ${action.kind}.`);
81
+ }
82
+ GameTarget.act = act;
83
+ })(GameTarget || (GameTarget = {}));
84
+ //# 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
@@ -31,6 +31,8 @@ export var GameUtil;
31
31
  /** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
32
32
  GameUtil.SCORE_KEY = 'score';
33
33
  GameUtil.OVER_KEY = 'over';
34
+ /** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
35
+ GameUtil.OBSERVE_KEY = 'observe';
34
36
  /**
35
37
  * Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
36
38
  * needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
@@ -1,15 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import type { TaScreen } from '../screen/screen-protocol.js';
3
3
  import type { TaSettings } from '../settings/settings-protocol.js';
4
+ import type { TaTargets } from '../targets/targets-protocol.js';
4
5
  import type { GameProps } from './game-protocol.js';
5
6
  import type { Game3DProps } from './game3d-protocol.js';
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;
@@ -4,7 +4,7 @@ import { Game3DEngineLoader, GameEngineLoader } from './game-loader.js';
4
4
  import { GameRunner } from './game-runner.js';
5
5
  import { Game3DRunner } from './game3d-runner.js';
6
6
  /** A game of a web extension on Phaser (`ui.Game`): GameRunner in a GameHost. */
7
- export function GameView({ settings, screen, config, onReady, title, className, style }) {
7
+ export function GameView({ settings, screen, targets, config, onReady, title, className, style, }) {
8
8
  const props = React.useRef({ config, onReady });
9
9
  props.current = { config, onReady };
10
10
  const start = React.useCallback(async (element, page, fail) => {
@@ -13,10 +13,10 @@ export function GameView({ settings, screen, config, onReady, title, className,
13
13
  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); });
14
14
  return runner;
15
15
  }, []);
16
- return React.createElement(GameHost, { settings: settings, start: start, title: title, screen: screen, className: className, style: style });
16
+ return React.createElement(GameHost, { settings: settings, start: start, title: title, screen: screen, targets: targets, className: className, style: style });
17
17
  }
18
18
  /** A 3D game of a web extension on Three.js (`ui.Game3D`): Game3DRunner in a GameHost. */
19
- export function Game3DView({ settings, screen, setup, onReady, title, className, style }) {
19
+ export function Game3DView({ settings, screen, targets, setup, onReady, title, className, style, }) {
20
20
  const props = React.useRef({ setup, onReady });
21
21
  props.current = { setup, onReady };
22
22
  const start = React.useCallback(async (element, page, fail) => {
@@ -26,6 +26,6 @@ export function Game3DView({ settings, screen, setup, onReady, title, className,
26
26
  (_b = (_a = props.current).onReady) === null || _b === void 0 ? void 0 : _b.call(_a, runner.context);
27
27
  return runner;
28
28
  }, []);
29
- return React.createElement(GameHost, { settings: settings, start: start, title: title, screen: screen, className: className, style: style });
29
+ return React.createElement(GameHost, { settings: settings, start: start, title: title, screen: screen, targets: targets, className: className, style: style });
30
30
  }
31
31
  //# 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.js';
2
+ import type { GameObservation, GamePage, GameState } from './game-protocol.js';
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.js';
2
+ import type { GameObservation, GamePage, GameState } from './game-protocol.js';
3
3
  import type { Game3DContext, Game3DEngine, Game3DLoop, Game3DProps } from './game3d-protocol.js';
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;
@@ -14,16 +14,19 @@ export class Game3DRunner {
14
14
  var _a;
15
15
  this.onError = onError;
16
16
  this.asleep = false;
17
+ this.paused = false;
17
18
  this.disposed = false;
18
19
  this.elapsed = 0;
19
20
  this.frame = (time) => {
20
21
  var _a;
21
- const seconds = this.last === undefined ? 0 : Math.min(MAX_STEP, Math.max(0, (time - this.last) / 1000));
22
+ const seconds = this.paused || this.last === undefined ? 0 : Math.min(MAX_STEP, Math.max(0, (time - this.last) / 1000));
22
23
  this.last = time;
23
24
  this.elapsed += seconds;
24
25
  const { context, loop } = this;
25
26
  try {
26
- (_a = loop.update) === null || _a === void 0 ? void 0 : _a.call(loop, seconds, this.elapsed);
27
+ if (!this.paused) {
28
+ (_a = loop.update) === null || _a === void 0 ? void 0 : _a.call(loop, seconds, this.elapsed);
29
+ }
27
30
  if (loop.render) {
28
31
  loop.render();
29
32
  }
@@ -71,6 +74,27 @@ export class Game3DRunner {
71
74
  return undefined;
72
75
  }
73
76
  }
77
+ /** What the game says is in it now (Game3DLoop.observe); nothing when that throws. */
78
+ observe() {
79
+ var _a, _b;
80
+ var _c;
81
+ if (this.disposed) {
82
+ return undefined;
83
+ }
84
+ try {
85
+ return (_c = (_b = (_a = this.loop).observe) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : undefined;
86
+ }
87
+ catch (_d) {
88
+ return undefined;
89
+ }
90
+ }
91
+ /** Waits for a slow player: its frames still drawn, its time stopped, till it goes on. */
92
+ setPaused(paused) {
93
+ if (!this.disposed && paused !== this.paused) {
94
+ this.paused = paused;
95
+ this.last = undefined;
96
+ }
97
+ }
74
98
  get sleeping() {
75
99
  return this.asleep;
76
100
  }
@@ -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;
@@ -64,6 +64,9 @@ export const CHAT_EN = {
64
64
  'ta.message.interrupted': 'Cut off before it was done: the service stopped, or the agent ended its turn with work not finished.',
65
65
  'ta.message.silent': 'Ended without a reply: the agent may have lost the connection to its model.',
66
66
  'ta.message.failedUnknown': 'The request failed, without saying why.',
67
+ 'ta.message.failed.network': 'The network dropped, the request did not get through',
68
+ 'ta.message.failed.rateLimit': 'The model provider is limiting requests',
69
+ 'ta.message.failed.overloaded': 'The model is too busy right now',
67
70
  'ta.message.resume': 'Continue',
68
71
  'ta.message.resumeText': 'Continue',
69
72
  'ta.message.thinking': 'Thinking',
@@ -97,6 +100,7 @@ export const CHAT_EN = {
97
100
  'ta.message.used': 'Used',
98
101
  'ta.message.modelSwitched': 'Switched to {model}',
99
102
  'ta.message.resumed': 'Carried on after Ta restarted',
103
+ 'ta.message.resumedOnline': 'Carried on once the network was back',
100
104
  'ta.message.usageTitle': '{input} tokens sent, {output} received',
101
105
  'ta.chats.busyFilter': 'Going on',
102
106
  '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;
@@ -71,6 +71,19 @@ export const SETTINGS_EN = {
71
71
  'ta.settings.server': 'Server',
72
72
  'ta.settings.version': 'Version',
73
73
  'ta.settings.files': 'Settings files',
74
+ 'ta.storage.title': 'Storage',
75
+ 'ta.storage.hint': 'What Ta keeps on this computer. Past the days or the size set, the oldest goes first, by itself.',
76
+ 'ta.storage.total': 'In all {size}',
77
+ 'ta.storage.usage': 'Takes {size}',
78
+ 'ta.storage.keep': 'Keep {days} days',
79
+ 'ta.storage.keepAll': 'Keep all',
80
+ 'ta.storage.max': 'Up to {size}',
81
+ 'ta.storage.maxNone': 'Any size',
82
+ 'ta.storage.keepLabel': 'Days kept',
83
+ 'ta.storage.maxLabel': 'Size limit',
84
+ 'ta.storage.clear': 'Clear',
85
+ 'ta.storage.clearConfirm': 'Clear “{name}”?',
86
+ 'ta.storage.freed': 'Freed {size}',
74
87
  'ta.settings.files.checking': 'Checking the files of settings…',
75
88
  'ta.settings.files.ok': '{count, plural, one {The # file of settings reads} other {All # files of settings read}}',
76
89
  'ta.settings.files.problems': '{count, plural, one {# file is left out: it does not read} other {# files are left out: they do not read}}',
@@ -225,6 +238,8 @@ export const SETTINGS_EN = {
225
238
  'ta.setting.retry.enabled': 'Retry failed requests',
226
239
  'ta.setting.retry.enabled.hint': 'On rate limits and errors of the provider.',
227
240
  'ta.setting.retry.maxRetries': 'Retries',
241
+ 'ta.setting.retry.untilOnline': 'Carry on once the network is back',
242
+ 'ta.setting.retry.untilOnline.hint': 'When the network drops mid-task (lid closed, a move, overnight), Ta goes on when it reconnects.',
228
243
  'ta.setting.codemode.mode': 'Code mode',
229
244
  'ta.setting.codemode.mode.hint': 'How Ta calls its tools: from scripts only, or also one by one.',
230
245
  'ta.setting.codemode.mode.only': 'Scripts only',
@@ -63,6 +63,9 @@ export const CHAT_JA = {
63
63
  'ta.message.interrupted': '途中で遮断されました:Ta サービスが停止したか、エージェントが作業を完了していません。',
64
64
  'ta.message.silent': '返信なしで終了しました。エージェントがモデルとの接続を失った可能性があります。',
65
65
  'ta.message.failedUnknown': 'リクエストが失敗しました。理由は説明されていません。',
66
+ 'ta.message.failed.network': 'ネットワークが切れて、リクエストが届きませんでした',
67
+ 'ta.message.failed.rateLimit': 'モデルのサービスがリクエストを制限しています',
68
+ 'ta.message.failed.overloaded': 'モデルが混み合っています',
66
69
  'ta.message.resume': '続行',
67
70
  'ta.message.resumeText': '続行',
68
71
  'ta.message.thinking': '思考中',
@@ -96,6 +99,7 @@ export const CHAT_JA = {
96
99
  'ta.message.used': '使用済み',
97
100
  'ta.message.modelSwitched': '{model} に切り替えました',
98
101
  'ta.message.resumed': 'Ta 再起動後に続行',
102
+ 'ta.message.resumedOnline': 'ネットワーク復帰後に続行',
99
103
  'ta.message.usageTitle': '{input} トークンを送信、{output} を受信',
100
104
  'ta.chats.busyFilter': '進行中',
101
105
  'ta.chats.busyClear': 'すべての会話を表示',
@@ -70,6 +70,19 @@ export const SETTINGS_JA = {
70
70
  'ta.settings.server': 'サービス',
71
71
  'ta.settings.version': 'バージョン',
72
72
  'ta.settings.files': '設定ファイル',
73
+ 'ta.storage.title': 'ストレージ',
74
+ 'ta.storage.hint': 'Ta がこのコンピュータに保存しているもの。保存期間や容量の上限を超えると、古いものから自動で消えます。',
75
+ 'ta.storage.total': '合計 {size}',
76
+ 'ta.storage.usage': '使用量 {size}',
77
+ 'ta.storage.keep': '{days} 日間保存',
78
+ 'ta.storage.keepAll': 'ずっと保存',
79
+ 'ta.storage.max': '最大 {size}',
80
+ 'ta.storage.maxNone': '容量の上限なし',
81
+ 'ta.storage.keepLabel': '保存期間',
82
+ 'ta.storage.maxLabel': '容量の上限',
83
+ 'ta.storage.clear': '消去',
84
+ 'ta.storage.clearConfirm': '「{name}」を消去しますか?',
85
+ 'ta.storage.freed': '{size} を空けました',
73
86
  'ta.settings.files.checking': '設定ファイルを確認しています…',
74
87
  'ta.settings.files.ok': '{count} 個の設定ファイルはすべて読み込めます',
75
88
  'ta.settings.files.problems': '{count} 個のファイルを読み込めず、その設定は無効です',
@@ -224,6 +237,8 @@ export const SETTINGS_JA = {
224
237
  'ta.setting.retry.enabled': '失敗したリクエストを再試行',
225
238
  'ta.setting.retry.enabled.hint': 'レート制限またはモデルサービスのエラー時に再試行します。',
226
239
  'ta.setting.retry.maxRetries': '再試行回数',
240
+ 'ta.setting.retry.untilOnline': 'ネットワーク復帰後に続行',
241
+ 'ta.setting.retry.untilOnline.hint': '作業中にネットワークが切れても(蓋を閉じる、移動、一晩)、つながり次第続けます。',
227
242
  'ta.setting.codemode.mode': 'コードモード',
228
243
  'ta.setting.codemode.mode.hint': 'Ta がツールを呼び出す方法:スクリプトのみ、またはスクリプトと個別の直接呼び出しの両方。',
229
244
  'ta.setting.codemode.mode.only': 'スクリプトのみ',