cortico-world-agent-speed 0.2.0 → 0.2.2
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/CHANGELOG.md +64 -0
- package/LICENSE +0 -14
- package/README.md +29 -11
- package/THIRD_PARTY_NOTICES.md +69 -0
- package/activity.d.ts +15 -0
- package/activity.js +88 -3
- package/describe.json +806 -0
- package/dist/webui.css +2 -0
- package/dist/webui.css.map +7 -0
- package/dist/webui.js +2 -0
- package/dist/webui.js.map +7 -0
- package/host/app-store.cjs +68 -0
- package/host/cursor.cjs +67 -0
- package/host/electron-main.cjs +666 -0
- package/host/input-shape.cjs +63 -0
- package/host/mouse-lease.cjs +77 -0
- package/host/overlay.cjs +139 -0
- package/host/portrait.cjs +52 -0
- package/host/preload.cjs +60 -14
- package/host/renderer-gone.cjs +24 -0
- package/host/windows.cjs +251 -0
- package/package.json +27 -7
- package/scripts/build-webui.mjs +40 -0
- package/scripts/speech-bank/build.py +166 -0
- package/scripts/speech-bank/dicts.py +76 -0
- package/src/ENV_PROMPT.en.md +51 -0
- package/src/ENV_PROMPT.md +51 -0
- package/src/asr/address.ts +25 -0
- package/src/asr/hotkey.ts +335 -0
- package/src/asr/result.ts +51 -0
- package/src/asr/segmenter.ts +269 -0
- package/src/asr/sherpa.ts +280 -0
- package/src/asr/simplify.ts +38 -0
- package/src/asr/system-recognizer.ts +292 -0
- package/src/asr/system-sapi.ps1 +173 -0
- package/src/asr/transcription-api.ts +176 -0
- package/src/chat.ts +212 -0
- package/src/config.ts +481 -0
- package/src/cua/ENV_PROMPT.en.md +29 -0
- package/src/cua/ENV_PROMPT.md +29 -0
- package/src/cua/config.ts +88 -0
- package/src/cua/cua.ts +712 -0
- package/src/cua/engine/darwin.ts +410 -0
- package/src/cua/engine/display.ts +55 -0
- package/src/cua/engine/fail.ts +15 -0
- package/src/cua/engine/foreground.ts +8 -0
- package/src/cua/engine/image.ts +57 -0
- package/src/cua/engine/keys.ts +70 -0
- package/src/cua/engine/linux-keys.ts +29 -0
- package/src/cua/engine/linux.ts +343 -0
- package/src/cua/engine/mac-keys.ts +57 -0
- package/src/cua/engine/user-activity.ts +54 -0
- package/src/cua/engine/wait-idle.ts +31 -0
- package/src/cua/engine/win32.ts +299 -0
- package/src/cua/engine-child.ts +274 -0
- package/src/cua/engine-ipc.ts +140 -0
- package/src/cua/i18n/de.ts +53 -0
- package/src/cua/i18n/en.ts +63 -0
- package/src/cua/i18n/es-419.ts +53 -0
- package/src/cua/i18n/fr.ts +53 -0
- package/src/cua/i18n/index.ts +26 -0
- package/src/cua/i18n/it.ts +53 -0
- package/src/cua/i18n/ja.ts +53 -0
- package/src/cua/i18n/ko.ts +53 -0
- package/src/cua/i18n/pt-BR.ts +53 -0
- package/src/cua/i18n/ru.ts +59 -0
- package/src/cua/i18n/zh-Hant.ts +53 -0
- package/src/cua/i18n/zh.ts +59 -0
- package/src/cua/model-text.ts +252 -0
- package/src/cua/terminal.ts +31 -0
- package/src/cua/tools.ts +153 -0
- package/src/definition.ts +146 -0
- package/src/host-reason.ts +32 -0
- package/src/i18n/de.ts +409 -0
- package/src/i18n/en.ts +443 -0
- package/src/i18n/es-419.ts +409 -0
- package/src/i18n/fr.ts +409 -0
- package/src/i18n/index.ts +56 -0
- package/src/i18n/it.ts +409 -0
- package/src/i18n/ja.ts +409 -0
- package/src/i18n/ko.ts +409 -0
- package/src/i18n/pt-BR.ts +409 -0
- package/src/i18n/ru.ts +415 -0
- package/src/i18n/zh-Hant.ts +409 -0
- package/src/i18n/zh.ts +440 -0
- package/src/index.ts +15 -0
- package/src/model-text.ts +344 -0
- package/src/moves.ts +101 -0
- package/src/pack-import.ts +361 -0
- package/src/packs.ts +449 -0
- package/src/runtime/download.ts +29 -0
- package/src/runtime/store.ts +293 -0
- package/src/script.ts +202 -0
- package/src/self.ts +247 -0
- package/src/server.ts +479 -0
- package/src/speech/data/CMUDICT-LICENSE +33 -0
- package/src/speech/data/IPADIC-COPYING +71 -0
- package/src/speech/data/UNICODE-LICENSE +39 -0
- package/src/speech/data/en.tsv.gz +0 -0
- package/src/speech/data/ja-ipadic.tsv.gz +0 -0
- package/src/speech/data/ja-unihan.tsv.gz +0 -0
- package/src/speech/data/zh.json +1 -0
- package/src/speech/index.ts +204 -0
- package/src/speech/ipa.ts +83 -0
- package/src/speech/japanese.ts +105 -0
- package/src/speech/jukujikun.ts +22 -0
- package/src/speech/korean.ts +35 -0
- package/src/speech/lang.ts +151 -0
- package/src/speech/rules.ts +72 -0
- package/src/speech/syllable.ts +76 -0
- package/src/status.ts +164 -0
- package/src/tools.ts +110 -0
- package/src/webui/api-rows.css +2 -0
- package/src/webui/api-rows.ts +44 -0
- package/src/webui/client.ts +451 -0
- package/src/webui/dress-dialog.css +14 -0
- package/src/webui/dress-dialog.ts +117 -0
- package/src/webui/dress-panel.ts +160 -0
- package/src/webui/key-capture.ts +60 -0
- package/src/webui/shared/modal.css +13 -0
- package/src/webui/shared/modal.ts +77 -0
- package/src/webui/shared/problem.css +15 -0
- package/src/webui/shared/problem.ts +217 -0
- package/src/webui/shared/strings.ts +5 -0
- package/src/webui/style.css +50 -0
- package/src/window-host.ts +116 -0
- package/src/world.ts +2926 -0
- package/web/activity-motion.js +117 -0
- package/web/appearance.js +60 -0
- package/web/body-host.js +257 -0
- package/web/coo/coo.js +384 -0
- package/web/coo/figure.js +15 -0
- package/web/coo/figure.json +1224 -0
- package/web/dist/dress-dialog.css +1 -0
- package/web/dist/dress-dialog.js +1 -0
- package/web/drag-row.js +49 -0
- package/web/drag.js +149 -0
- package/web/dress.css +170 -0
- package/web/dress.html +37 -0
- package/web/dress.js +786 -0
- package/web/figure-frame.html +16 -0
- package/web/figure-frame.js +128 -0
- package/web/frame-loop.js +55 -0
- package/web/hints.js +77 -0
- package/web/i18n/de.js +170 -0
- package/web/i18n/en.js +177 -0
- package/web/i18n/es-419.js +170 -0
- package/web/i18n/fr.js +170 -0
- package/web/i18n/it.js +170 -0
- package/web/i18n/ja.js +170 -0
- package/web/i18n/ko.js +170 -0
- package/web/i18n/pt-BR.js +170 -0
- package/web/i18n/ru.js +170 -0
- package/web/i18n/zh-Hant.js +170 -0
- package/web/i18n/zh.js +175 -0
- package/web/i18n.js +54 -0
- package/{renderer/vendor → web}/kit/body.js +31 -58
- package/web/looks.js +70 -0
- package/web/mic-worklet.js +36 -0
- package/web/mic.js +117 -0
- package/web/motion-frames.js +80 -0
- package/web/motion-level.js +40 -0
- package/web/new-year-2027.svg +238 -0
- package/web/overlay.html +16 -0
- package/web/overlay.js +100 -0
- package/web/pet-app.js +3000 -0
- package/web/pet.css +642 -0
- package/web/pet.html +21 -0
- package/web/scale-slider.js +259 -0
- package/web/show-hide.js +49 -0
- package/web/sound.js +245 -0
- package/web/speech/zh.json +1 -0
- package/web/speech/zh.ogg +0 -0
- package/web/speech.js +197 -0
- package/web/stage.js +160 -0
- package/web/swap-motion.js +119 -0
- package/web/ui.js +195 -0
- package/host/launch.js +0 -187
- package/host/library.cjs +0 -638
- package/host/main.cjs +0 -389
- package/index.js +0 -93
- package/renderer/index.html +0 -22
- package/renderer/pet-sandbox.html +0 -11
- package/renderer/pet.css +0 -38
- package/renderer/pet.js +0 -251
- package/renderer/vendor/activity-motion.js +0 -101
- package/renderer/vendor/figure-frame.js +0 -115
- package/renderer/vendor/pack.css +0 -2
- /package/{renderer/vendor → web}/kit/rig.js +0 -0
package/src/status.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the bot is doing, for the status bubble above the pet. Core's run phase says when: a model request, a retry
|
|
3
|
+
* and a handoff show thinking, the end of a batch shows nothing. The main session's output stream says what: a tool
|
|
4
|
+
* call's arguments are read while they stream, so a file name can show before the call is written out. Which tools
|
|
5
|
+
* show what is the embedding app's choice (`DescribeTool`); without one, the pet's own tools show nothing and every
|
|
6
|
+
* other tool shows as busy.
|
|
7
|
+
*/
|
|
8
|
+
import type { RunPhase } from 'cortico/core/types.ts';
|
|
9
|
+
import type { StreamEvent } from 'cortico/protocol/open-responses/index.ts';
|
|
10
|
+
import { petText } from './i18n/index.ts';
|
|
11
|
+
|
|
12
|
+
export interface PetStatus {
|
|
13
|
+
/** Also the icon the bubble shows (`status_<kind>` in web/ui.js). */
|
|
14
|
+
kind: 'think' | 'read' | 'browse' | 'search' | 'write' | 'delete' | 'save' | 'look' | 'click' | 'scroll' | 'type' | 'wait' | 'alarm' | 'work';
|
|
15
|
+
text: string;
|
|
16
|
+
detail?: string;
|
|
17
|
+
count?: number;
|
|
18
|
+
/** Seconds the call lasts, from a DescribeTool; StatusTracker turns it into `endsAt` once the call runs. */
|
|
19
|
+
countdown?: number;
|
|
20
|
+
/** When the running call's countdown ends, in Date.now() milliseconds, the same however late a page connects. */
|
|
21
|
+
endsAt?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A call's arguments: the parsed object, or the JSON text streamed so far. */
|
|
25
|
+
export type ToolArgs = Record<string, unknown> | string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The status a tool call shows, from its name and its arguments so far; `done` once the arguments are complete.
|
|
29
|
+
* null shows nothing for it, undefined leaves it to the default (busy, or nothing for the pet's own tools).
|
|
30
|
+
*/
|
|
31
|
+
export type DescribeTool = (name: string, args: ToolArgs, done: boolean) => PetStatus | null | undefined;
|
|
32
|
+
|
|
33
|
+
const THINK: PetStatus = { kind: 'think', text: '' };
|
|
34
|
+
|
|
35
|
+
/** A string argument once its value is closed, even while the rest of the arguments (often a file's body) still streams. */
|
|
36
|
+
export function stringArg(args: ToolArgs, key: string): string | undefined {
|
|
37
|
+
if (typeof args !== 'string') return typeof args[key] === 'string' ? args[key] : undefined;
|
|
38
|
+
const match = new RegExp(`"${key}"\\s*:\\s*("(?:[^"\\\\]|\\\\.)*")`).exec(args);
|
|
39
|
+
if (!match) return undefined;
|
|
40
|
+
try { return JSON.parse(match[1]) as string; } catch { return undefined; }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A number argument once a delimiter follows it. */
|
|
44
|
+
export function numberArg(args: ToolArgs, key: string): number | undefined {
|
|
45
|
+
const value = typeof args === 'string'
|
|
46
|
+
? new RegExp(`"${key}"\\s*:\\s*(-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\\s*[,}]`).exec(args)?.[1]
|
|
47
|
+
: args[key];
|
|
48
|
+
return value !== undefined && Number.isFinite(Number(value)) && (typeof value === 'number' || typeof value === 'string') ? Number(value) : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const defaultStatus = (name: string, busy: string): PetStatus | null => (name.startsWith('pet_') ? null : { kind: 'work', text: busy });
|
|
52
|
+
|
|
53
|
+
/** `endsAt`: set from the status's countdown when the call starts running. */
|
|
54
|
+
interface Call { name: string; args: string; done: boolean; status: PetStatus | null; endsAt?: number }
|
|
55
|
+
|
|
56
|
+
export class StatusTracker {
|
|
57
|
+
private readonly calls = new Map<string, Call>();
|
|
58
|
+
private state: RunPhase['state'] = 'idle';
|
|
59
|
+
private round: number | undefined;
|
|
60
|
+
/** The tools running now, as RunPhase `running` names them, and how many times each name started this round. */
|
|
61
|
+
private running: readonly string[] = [];
|
|
62
|
+
private readonly started = new Map<string, number>();
|
|
63
|
+
private current: PetStatus | null = null;
|
|
64
|
+
|
|
65
|
+
/** `busy`: what a call without a description shows, in the app language at the time. */
|
|
66
|
+
constructor(private readonly changed: (status: PetStatus | null) => void, private readonly describe?: DescribeTool, private readonly busy: () => string = () => petText().busy) {}
|
|
67
|
+
|
|
68
|
+
get status(): PetStatus | null { return this.current; }
|
|
69
|
+
|
|
70
|
+
onPhase(phase: RunPhase): void {
|
|
71
|
+
this.state = phase.state;
|
|
72
|
+
switch (phase.state) {
|
|
73
|
+
case 'idle':
|
|
74
|
+
this.calls.clear();
|
|
75
|
+
this.started.clear();
|
|
76
|
+
this.running = [];
|
|
77
|
+
this.round = undefined;
|
|
78
|
+
this.set(null);
|
|
79
|
+
return;
|
|
80
|
+
case 'backoff':
|
|
81
|
+
case 'handoff':
|
|
82
|
+
this.noteRunning(phase.running);
|
|
83
|
+
this.set(THINK);
|
|
84
|
+
return;
|
|
85
|
+
default:
|
|
86
|
+
// a new round's request starts from thinking; the calls of the round before are done with
|
|
87
|
+
if (phase.round !== this.round) { this.round = phase.round; this.calls.clear(); this.started.clear(); }
|
|
88
|
+
this.noteRunning(phase.running);
|
|
89
|
+
this.update();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Counts the starts in `running`: a name listed more times than before started that many more calls. */
|
|
94
|
+
private noteRunning(running: readonly string[]): void {
|
|
95
|
+
for (const name of new Set(running)) {
|
|
96
|
+
const more = running.filter((n) => n === name).length - this.running.filter((n) => n === name).length;
|
|
97
|
+
if (more > 0) this.started.set(name, (this.started.get(name) ?? 0) + more);
|
|
98
|
+
}
|
|
99
|
+
this.running = running;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Tool calls and their arguments as the model writes them; item ids keep calls apart where output_index repeats. */
|
|
103
|
+
onEvent(event: StreamEvent): void {
|
|
104
|
+
if (event.type === 'response.output_item.added' || event.type === 'response.output_item.done') {
|
|
105
|
+
const item = event.item;
|
|
106
|
+
if (item?.type !== 'function_call') return;
|
|
107
|
+
const call = this.calls.get(item.id) ?? { name: item.name, args: '', done: false, status: null };
|
|
108
|
+
call.name = item.name;
|
|
109
|
+
call.args = item.arguments;
|
|
110
|
+
call.done = event.type === 'response.output_item.done';
|
|
111
|
+
call.status = this.describeCall(call);
|
|
112
|
+
this.calls.set(item.id, call);
|
|
113
|
+
} else if (event.type === 'response.function_call_arguments.delta') {
|
|
114
|
+
const call = this.calls.get(event.item_id);
|
|
115
|
+
if (!call) return;
|
|
116
|
+
call.args += event.delta;
|
|
117
|
+
call.status = this.describeCall(call);
|
|
118
|
+
} else return;
|
|
119
|
+
if (this.state === 'model' || this.state === 'tools') this.update();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Shows nothing until the next phase. */
|
|
123
|
+
clear(): void {
|
|
124
|
+
this.calls.clear();
|
|
125
|
+
this.round = undefined;
|
|
126
|
+
this.set(null);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private describeCall(call: Call): PetStatus | null {
|
|
130
|
+
const described = this.describe?.(call.name, call.args, call.done);
|
|
131
|
+
return described === undefined ? defaultStatus(call.name, this.busy()) : described;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The latest run of calls of one kind: its last wording, its first detail, and how many; and when the countdown of the
|
|
136
|
+
* call in it that runs now ends, the calls of one name running in the order they were written.
|
|
137
|
+
*/
|
|
138
|
+
private update(): void {
|
|
139
|
+
const calls = [...this.calls.values()];
|
|
140
|
+
const run: Call[] = [];
|
|
141
|
+
let last: PetStatus | null = null;
|
|
142
|
+
for (let i = calls.length - 1; i >= 0; i--) {
|
|
143
|
+
const s = calls[i].status;
|
|
144
|
+
if (!s) continue;
|
|
145
|
+
if (last && s.kind !== last.kind) break;
|
|
146
|
+
last ??= s;
|
|
147
|
+
run.unshift(calls[i]);
|
|
148
|
+
}
|
|
149
|
+
const lead = run[0]?.status;
|
|
150
|
+
if (!last || !lead) { this.set(calls.at(-1)?.done ? null : THINK); return; }
|
|
151
|
+
const runs = (c: Call) => this.running.includes(c.name) && calls.filter((o) => o.name === c.name).indexOf(c) === (this.started.get(c.name) ?? 0) - 1;
|
|
152
|
+
const counting = run.find((c) => c.status?.countdown !== undefined && runs(c));
|
|
153
|
+
if (counting) counting.endsAt ??= Date.now() + counting.status!.countdown! * 1000;
|
|
154
|
+
const endsAt = counting?.endsAt;
|
|
155
|
+
this.set({ kind: last.kind, text: last.text, ...(lead.detail ? { detail: lead.detail } : {}), ...(endsAt !== undefined ? { endsAt } : {}), ...(run.length > 1 ? { count: run.length } : {}) });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private set(status: PetStatus | null): void {
|
|
159
|
+
const c = this.current;
|
|
160
|
+
if (c?.kind === status?.kind && c?.text === status?.text && c?.detail === status?.detail && c?.endsAt === status?.endsAt && c?.count === status?.count) return;
|
|
161
|
+
this.current = status;
|
|
162
|
+
this.changed(status);
|
|
163
|
+
}
|
|
164
|
+
}
|
package/src/tools.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool declarations; `DesktopPetWorld.tools()` binds the handlers. Descriptions are English whatever the
|
|
3
|
+
* model-text language; the character caps on what the person reads follow the app language (`capFor`).
|
|
4
|
+
*/
|
|
5
|
+
import type { Language } from 'cortico/core/language.ts';
|
|
6
|
+
import type { ToolDef } from 'cortico/core/types.ts';
|
|
7
|
+
import { BUBBLE_SIZE_MAX, BUBBLE_SIZE_MIN, PET_ACTIONS, SCALE_MAX, SCALE_MIN, USER_MAX } from './config.ts';
|
|
8
|
+
import { capFor } from './i18n/index.ts';
|
|
9
|
+
import { MOVE_PARAMS_MAX } from './packs.ts';
|
|
10
|
+
|
|
11
|
+
/** Longest `speed_pet_ask` option, in characters as seen, for Chinese, Japanese and Korean. */
|
|
12
|
+
export const ASK_OPTION_MAX = 40;
|
|
13
|
+
|
|
14
|
+
/** The declarations with the caps of the app language `language`. */
|
|
15
|
+
export const petToolDecls = (language: Language = 'zh'): Array<Omit<ToolDef, 'handler'>> => [
|
|
16
|
+
{
|
|
17
|
+
name: 'speed_pet_say',
|
|
18
|
+
tags: ['speak'],
|
|
19
|
+
description: 'Say something in a speech bubble above the pet. Expressions and motions go into the script as markers: 【…】 plays them first and then starts a new bubble; <…> plays them when the typing reaches that point. The receipt says roughly how long it stays on screen; a non-empty script fails when the pet window is not connected.',
|
|
20
|
+
parameters: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
script: { type: 'string', description: 'What to say, with optional 【expression, motion】 and <expression> markers. One or two sentences per bubble. May be empty when images carry the message. Do not call this when you have nothing to say.' },
|
|
24
|
+
images: { type: 'array', items: { type: 'string' }, description: 'Images to show the person with this line, each given by the handle that starts a [blob …] line in your context. They appear on the chat page only, not in the bubble.' },
|
|
25
|
+
},
|
|
26
|
+
required: ['script'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'speed_pet_ask',
|
|
31
|
+
tags: ['speak'],
|
|
32
|
+
description: 'Show a question bubble with up to 3 options under it, plus by default a box for the person to write their own answer. Returns at once; the answer arrives later as an event, and so does closing the question unanswered. A new speed_pet_say or speed_pet_ask replaces a question not yet answered.',
|
|
33
|
+
parameters: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
question: { type: 'string', description: 'The question, one sentence.' },
|
|
37
|
+
options: { type: 'array', items: { type: 'string' }, maxItems: 3, description: `1–3 short options, at most ${capFor(ASK_OPTION_MAX, language)} characters each; longer ones are cut.` },
|
|
38
|
+
allowOwnAnswer: { type: 'boolean', description: 'Offer a box for writing an own answer; default true.' },
|
|
39
|
+
},
|
|
40
|
+
required: ['question', 'options'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'speed_pet_move_to',
|
|
45
|
+
tags: ['act'],
|
|
46
|
+
description: 'Go somewhere on the screen the pet is on: walk (or run) along its bottom edge to a position, or go to one of the targets the current figure has of its own, which the environment section lists when it has any. Returns on arrival or interruption, after 30 seconds at most.',
|
|
47
|
+
parameters: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
to: { description: 'Target: a number from 0 to 1 (a fraction of the width of the screen the pet is on, 0 leftmost, 1 rightmost), left / center / right / cursor (the horizontal position of the mouse pointer), or the id of one of the current figure\'s own targets.', anyOf: [{ type: 'number', minimum: 0, maximum: 1 }, { type: 'string' }] },
|
|
51
|
+
run: { type: 'boolean', description: 'true to run; walks by default.' },
|
|
52
|
+
params: { type: 'array', items: { type: 'number' }, maxItems: MOVE_PARAMS_MAX, description: 'Only for a figure\'s own target that takes numbers: them, in the order the environment section lists them.' },
|
|
53
|
+
},
|
|
54
|
+
required: ['to'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'speed_pet_set',
|
|
59
|
+
tags: ['act'],
|
|
60
|
+
description: "Change your own looks and habits. Depending on the person's settings, some items take effect at once and others are first asked of the person in a bubble, changing only if they agree, with the receipt coming after their answer; the environment section says which items are which, and the values to choose from. Give only the items to change.",
|
|
61
|
+
parameters: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
figure: { type: 'string', description: 'Figure: coo, or the id of an installed figure. Switching to a figure pack without a scheme puts on its first one. A figure goes on at the size it last had on screen, unless scale is given too.' },
|
|
65
|
+
scheme: { type: 'string', description: 'The dress of the current figure (or of the one being switched to): a preset id, or one option per axis joined with - in axis order (for Coo: palette-head-side-glasses-neck).' },
|
|
66
|
+
roam: { type: 'string', enum: ['free', 'calm', 'off'], description: 'Walking about: free walks often, calm mostly stays put, off does not wander.' },
|
|
67
|
+
snoreSeconds: { type: 'integer', minimum: 0, maximum: 3600, description: 'Seconds of snoring each time you fall asleep; 0 snores until you wake.' },
|
|
68
|
+
sound: { type: 'boolean', description: 'Sound effects on or off.' },
|
|
69
|
+
scale: { type: 'number', minimum: SCALE_MIN, maximum: SCALE_MAX, description: 'Size on screen, 1 being the default.' },
|
|
70
|
+
bubbleSize: { type: 'number', minimum: BUBBLE_SIZE_MIN, maximum: BUBBLE_SIZE_MAX, description: "Width, padding, corners and tail of the speech bubbles (yours and the person's), 1 being the default; the text keeps its size." },
|
|
71
|
+
fontSize: { type: 'number', minimum: BUBBLE_SIZE_MIN, maximum: BUBBLE_SIZE_MAX, description: 'Size of the text in the speech bubbles, 1 being the default; the bubbles keep their width.' },
|
|
72
|
+
theme: { type: 'string', enum: ['dark', 'light'], description: 'dark is night (light body), light is day (dark body).' },
|
|
73
|
+
hoverButtons: { type: 'array', items: { type: 'string', enum: [...PET_ACTIONS] }, maxItems: 6, description: 'The buttons beside you while the mouse pointer rests on you; your right-click menu shows the same ones, beside the settings, pause and quit the app provides. An empty list takes every hover button away, from the menu too.' },
|
|
74
|
+
user: { type: 'string', maxLength: capFor(USER_MAX, language), description: `What you call the person, at most ${capFor(USER_MAX, language)} characters.` },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'speed_pet_quiet',
|
|
80
|
+
tags: ['act'],
|
|
81
|
+
description: 'Keep quiet for a while: by default sound effects off and standing still, restored when the time is up; the settings stay as they are. If the person changes sound or walking themselves meanwhile, their choice holds and the quiet ends early. minutes 0 ends it now.',
|
|
82
|
+
parameters: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
minutes: { type: 'number', minimum: 0, maximum: 1440, description: 'Minutes of quiet.' },
|
|
86
|
+
sound: { type: 'boolean', description: 'Sound effects during the quiet; default false.' },
|
|
87
|
+
roam: { type: 'string', enum: ['off', 'calm'], description: 'Walking during the quiet; default off.' },
|
|
88
|
+
},
|
|
89
|
+
required: ['minutes'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'speed_pet_act',
|
|
94
|
+
tags: ['act'],
|
|
95
|
+
description: 'Play a sequence of expressions or motions without speaking (the current figure\'s vocabulary is in the environment section). Returns at once; words marked as held until the next action stay on.',
|
|
96
|
+
parameters: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {
|
|
99
|
+
actions: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 6, description: 'Expression or motion words, played in order.' },
|
|
100
|
+
},
|
|
101
|
+
required: ['actions'],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'speed_pet_see_self',
|
|
106
|
+
tags: ['read', 'snapshot'],
|
|
107
|
+
description: 'See yourself as you are drawn on screen at the moment of the call. Returns one picture of the body alone, the figure in its dress, pose and expression on a plain grey backdrop, without bubbles or the desktop, and a line naming the figure and its dress. Fails while the pet window is hidden or not connected: nothing is drawn then.',
|
|
108
|
+
parameters: { type: 'object', properties: {}, required: [] },
|
|
109
|
+
},
|
|
110
|
+
];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The voice panel's rows for the transcription service (engine `api`): address, model and API Key,
|
|
3
|
+
* each saved through the panel method `setApi` on the field's change event (Enter, or leaving it
|
|
4
|
+
* changed). The key is never sent back; its row shows whether one is saved.
|
|
5
|
+
*/
|
|
6
|
+
import type { WebUiInputOptions, WebUiPanelContext } from 'cortico/web/shared/client-panel.ts';
|
|
7
|
+
import type { PetText } from '../i18n/index.ts';
|
|
8
|
+
import './api-rows.css';
|
|
9
|
+
|
|
10
|
+
export interface ApiState { baseUrl: string; model: string; keySaved: boolean }
|
|
11
|
+
export interface ApiPatch { baseUrl?: string; model?: string; key?: string }
|
|
12
|
+
interface Row { row: HTMLElement; acts: HTMLElement; set(text: string, tone: 'on' | 'off' | 'busy' | 'bad', more?: string): void }
|
|
13
|
+
|
|
14
|
+
export function apiRows(ctx: WebUiPanelContext, t: PetText['panel'], statusRow: (name: string) => Row, save: (patch: ApiPatch, anchor: HTMLElement) => void) {
|
|
15
|
+
const { ui } = ctx;
|
|
16
|
+
const field = (row: Row, opts: Pick<WebUiInputOptions, 'type' | 'placeholder'>, change: (value: string) => void) => {
|
|
17
|
+
const input = ui.input({ ...opts, cls: 'pet-apifield', onChange: change });
|
|
18
|
+
row.acts.append(input);
|
|
19
|
+
return input;
|
|
20
|
+
};
|
|
21
|
+
const url = statusRow(t.apiUrl);
|
|
22
|
+
const urlInput = field(url, { placeholder: 'https://…/v1' }, (baseUrl) => save({ baseUrl }, urlInput));
|
|
23
|
+
const model = statusRow(t.apiModel);
|
|
24
|
+
const modelInput = field(model, {}, (value) => save({ model: value }, modelInput));
|
|
25
|
+
const key = statusRow(t.apiKey);
|
|
26
|
+
const keyInput = field(key, { type: 'password' }, (value) => {
|
|
27
|
+
if (!value.trim()) return;
|
|
28
|
+
keyInput.value = '';
|
|
29
|
+
save({ key: value }, keyInput);
|
|
30
|
+
});
|
|
31
|
+
keyInput.autocomplete = 'off';
|
|
32
|
+
const rows = [url.row, model.row, key.row];
|
|
33
|
+
return {
|
|
34
|
+
rows,
|
|
35
|
+
render(state: ApiState, shown: boolean) {
|
|
36
|
+
for (const row of rows) row.style.display = shown ? '' : 'none';
|
|
37
|
+
if (document.activeElement !== urlInput) urlInput.value = state.baseUrl;
|
|
38
|
+
if (document.activeElement !== modelInput) modelInput.value = state.model;
|
|
39
|
+
url.set('', state.baseUrl ? 'on' : 'off');
|
|
40
|
+
model.set('', state.model ? 'on' : 'off');
|
|
41
|
+
key.set(state.keySaved ? t.keySaved : t.keyMissing, state.keySaved ? 'on' : 'off');
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|