@bitefoundry/retrieviewer 0.0.2 → 0.0.4
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/ASSET-PROVENANCE.md +6 -0
- package/ASSETS-LICENSE.md +2 -1
- package/ATTRIBUTION.md +6 -1
- package/COMFORT-ART.md +65 -0
- package/DESKTOP-PLATFORMS.md +75 -0
- package/INSTALLING.md +8 -5
- package/PLUGIN.md +13 -10
- package/PREREQUISITES.md +95 -0
- package/PUPPY-MEMORY.md +102 -1
- package/README.ko.md +110 -0
- package/README.md +119 -58
- package/RELEASING.md +27 -14
- package/THIRD-PARTY-NOTICES.md +5 -3
- package/braille.mjs +35 -9
- package/examples/live.mjs +2 -2
- package/integrations/desktop/platform.mjs +27 -0
- package/integrations/linux-overlay/README.md +83 -0
- package/integrations/linux-overlay/overlay.py +1094 -0
- package/integrations/macos-overlay/README.md +83 -0
- package/integrations/macos-overlay/overlay.jxa +639 -0
- package/integrations/opencode/runtime.mjs +4 -4
- package/integrations/opencode/tui.tsx +1 -1
- package/integrations/windows-overlay/Overlay.cs +4 -4
- package/integrations/windows-overlay/desktop.mjs +40 -8
- package/integrations/windows-overlay/protocol.mjs +11 -7
- package/integrations/windows-overlay/worker.mjs +13 -7
- package/package.json +41 -14
- package/puppy-comfort-sprites.mjs +25 -0
- package/puppy-companion-comfort-q5.bin.gz +0 -0
- package/puppy-companion-comfort.json +77 -0
- package/puppy-companion-life.mjs +49 -16
- package/puppy-companion-objects.mjs +12 -0
- package/puppy-frame-predictive.mjs +15 -9
- package/puppy-frame-store.mjs +2 -2
- package/puppy-paper-world.mjs +14 -0
- package/puppy-paper.mjs +65 -14
- package/retrieviewer-cli.mjs +10 -3
- package/retrieviewer-plugin.d.mts +1 -1
- package/retrieviewer-plugin.mjs +1 -1
- package/retrieviewer.d.mts +10 -4
- package/retrieviewer.mjs +20 -14
- package/locomotion-core.mjs +0 -21
- package/locomotion-puppy.animal +0 -0
- package/vendor/procedural-animals/package.json +0 -40
- package/vendor/procedural-animals/src/animal.js +0 -146
- package/vendor/procedural-animals/src/bake.js +0 -51
- package/vendor/procedural-animals/src/build.js +0 -81
- package/vendor/procedural-animals/src/core/build/coatKit.js +0 -121
- package/vendor/procedural-animals/src/core/build/featherCards.js +0 -189
- package/vendor/procedural-animals/src/core/build/finEdges.js +0 -85
- package/vendor/procedural-animals/src/core/build/furSlope.js +0 -115
- package/vendor/procedural-animals/src/core/build/mesh.js +0 -67
- package/vendor/procedural-animals/src/core/build/pipeline.js +0 -272
- package/vendor/procedural-animals/src/core/build/seams.js +0 -183
- package/vendor/procedural-animals/src/core/build/warp.js +0 -112
- package/vendor/procedural-animals/src/core/build/weights.js +0 -393
- package/vendor/procedural-animals/src/core/math/vec.js +0 -81
- package/vendor/procedural-animals/src/core/motion/actions.js +0 -800
- package/vendor/procedural-animals/src/core/motion/bird.js +0 -3063
- package/vendor/procedural-animals/src/core/motion/birdActions.js +0 -1059
- package/vendor/procedural-animals/src/core/motion/common.js +0 -158
- package/vendor/procedural-animals/src/core/motion/index.js +0 -22
- package/vendor/procedural-animals/src/core/motion/quadruped.js +0 -2875
- package/vendor/procedural-animals/src/core/motion/snake.js +0 -1594
- package/vendor/procedural-animals/src/core/motion/spider.js +0 -1810
- package/vendor/procedural-animals/src/core/motion/swimmer.js +0 -1047
- package/vendor/procedural-animals/src/core/motion/swimmerActions.js +0 -613
- package/vendor/procedural-animals/src/core/render/animalObject.js +0 -262
- package/vendor/procedural-animals/src/core/render/coatMaterial.js +0 -1301
- package/vendor/procedural-animals/src/core/render/dqs.js +0 -159
- package/vendor/procedural-animals/src/core/render/eyes.js +0 -676
- package/vendor/procedural-animals/src/core/render/membranes.js +0 -77
- package/vendor/procedural-animals/src/core/render/skeleton.js +0 -41
- package/vendor/procedural-animals/src/core/rig/bird.js +0 -327
- package/vendor/procedural-animals/src/core/rig/quadruped.js +0 -76
- package/vendor/procedural-animals/src/core/rig/rig.js +0 -79
- package/vendor/procedural-animals/src/core/rig/snake.js +0 -76
- package/vendor/procedural-animals/src/core/rig/spider.js +0 -110
- package/vendor/procedural-animals/src/core/rig/swimmer.js +0 -181
- package/vendor/procedural-animals/src/core/sdf/eyeSocket.js +0 -53
- package/vendor/procedural-animals/src/core/sdf/mesher.js +0 -238
- package/vendor/procedural-animals/src/core/sdf/sdf.js +0 -263
- package/vendor/procedural-animals/src/index.d.ts +0 -98
- package/vendor/procedural-animals/src/index.js +0 -29
- package/vendor/procedural-animals/src/registry.js +0 -48
- package/vendor/procedural-animals/src/species/bear/behaviour.js +0 -463
- package/vendor/procedural-animals/src/species/bear/claws.js +0 -147
- package/vendor/procedural-animals/src/species/bear/coat.js +0 -726
- package/vendor/procedural-animals/src/species/bear/index.js +0 -139
- package/vendor/procedural-animals/src/species/bear/motion.js +0 -112
- package/vendor/procedural-animals/src/species/bear/regions.js +0 -78
- package/vendor/procedural-animals/src/species/bear/rig.js +0 -112
- package/vendor/procedural-animals/src/species/bear/sculpt.js +0 -272
- package/vendor/procedural-animals/src/species/boar/behaviour.js +0 -335
- package/vendor/procedural-animals/src/species/boar/coat.js +0 -372
- package/vendor/procedural-animals/src/species/boar/index.js +0 -110
- package/vendor/procedural-animals/src/species/boar/motion.js +0 -85
- package/vendor/procedural-animals/src/species/boar/regions.js +0 -88
- package/vendor/procedural-animals/src/species/boar/rig.js +0 -111
- package/vendor/procedural-animals/src/species/boar/sculpt.js +0 -285
- package/vendor/procedural-animals/src/species/cat/behaviour.js +0 -559
- package/vendor/procedural-animals/src/species/cat/coat.js +0 -841
- package/vendor/procedural-animals/src/species/cat/index.js +0 -211
- package/vendor/procedural-animals/src/species/cat/motion.js +0 -101
- package/vendor/procedural-animals/src/species/cat/regions.js +0 -82
- package/vendor/procedural-animals/src/species/cat/rig.js +0 -100
- package/vendor/procedural-animals/src/species/cat/sculpt.js +0 -266
- package/vendor/procedural-animals/src/species/cat/whiskers.js +0 -110
- package/vendor/procedural-animals/src/species/cheetah/coat.js +0 -427
- package/vendor/procedural-animals/src/species/cheetah/index.js +0 -51
- package/vendor/procedural-animals/src/species/cheetah/joints.js +0 -3
- package/vendor/procedural-animals/src/species/cheetah/motion.js +0 -77
- package/vendor/procedural-animals/src/species/cheetah/regions.js +0 -95
- package/vendor/procedural-animals/src/species/cheetah/rig.js +0 -66
- package/vendor/procedural-animals/src/species/cheetah/sculpt.js +0 -158
- package/vendor/procedural-animals/src/species/chicken/coat.js +0 -313
- package/vendor/procedural-animals/src/species/chicken/coverts.js +0 -320
- package/vendor/procedural-animals/src/species/chicken/index.js +0 -110
- package/vendor/procedural-animals/src/species/chicken/motion.js +0 -177
- package/vendor/procedural-animals/src/species/chicken/regions.js +0 -66
- package/vendor/procedural-animals/src/species/chicken/rig.js +0 -144
- package/vendor/procedural-animals/src/species/chicken/sculpt.js +0 -389
- package/vendor/procedural-animals/src/species/chicken/wingLook.js +0 -66
- package/vendor/procedural-animals/src/species/chicken/wingStack.js +0 -124
- package/vendor/procedural-animals/src/species/cow/behaviour.js +0 -521
- package/vendor/procedural-animals/src/species/cow/coat.js +0 -465
- package/vendor/procedural-animals/src/species/cow/index.js +0 -118
- package/vendor/procedural-animals/src/species/cow/motion.js +0 -81
- package/vendor/procedural-animals/src/species/cow/regions.js +0 -98
- package/vendor/procedural-animals/src/species/cow/rig.js +0 -116
- package/vendor/procedural-animals/src/species/cow/sculpt.js +0 -339
- package/vendor/procedural-animals/src/species/crow/coat.js +0 -145
- package/vendor/procedural-animals/src/species/crow/index.js +0 -70
- package/vendor/procedural-animals/src/species/crow/joints.js +0 -3
- package/vendor/procedural-animals/src/species/crow/motion.js +0 -101
- package/vendor/procedural-animals/src/species/crow/regions.js +0 -50
- package/vendor/procedural-animals/src/species/crow/rig.js +0 -83
- package/vendor/procedural-animals/src/species/crow/sculpt.js +0 -118
- package/vendor/procedural-animals/src/species/deer/behaviour.js +0 -513
- package/vendor/procedural-animals/src/species/deer/coat.js +0 -391
- package/vendor/procedural-animals/src/species/deer/index.js +0 -106
- package/vendor/procedural-animals/src/species/deer/motion.js +0 -97
- package/vendor/procedural-animals/src/species/deer/regions.js +0 -60
- package/vendor/procedural-animals/src/species/deer/rig.js +0 -124
- package/vendor/procedural-animals/src/species/deer/sculpt.js +0 -297
- package/vendor/procedural-animals/src/species/dog/behaviour.js +0 -521
- package/vendor/procedural-animals/src/species/dog/coat.js +0 -495
- package/vendor/procedural-animals/src/species/dog/index.js +0 -144
- package/vendor/procedural-animals/src/species/dog/motion.js +0 -118
- package/vendor/procedural-animals/src/species/dog/regions.js +0 -61
- package/vendor/procedural-animals/src/species/dog/rig.js +0 -129
- package/vendor/procedural-animals/src/species/dog/sculpt.js +0 -246
- package/vendor/procedural-animals/src/species/eagle/coat.js +0 -250
- package/vendor/procedural-animals/src/species/eagle/index.js +0 -76
- package/vendor/procedural-animals/src/species/eagle/joints.js +0 -3
- package/vendor/procedural-animals/src/species/eagle/motion.js +0 -137
- package/vendor/procedural-animals/src/species/eagle/regions.js +0 -57
- package/vendor/procedural-animals/src/species/eagle/rig.js +0 -107
- package/vendor/procedural-animals/src/species/eagle/sculpt.js +0 -137
- package/vendor/procedural-animals/src/species/fish/coat.js +0 -271
- package/vendor/procedural-animals/src/species/fish/index.js +0 -88
- package/vendor/procedural-animals/src/species/fish/motion.js +0 -92
- package/vendor/procedural-animals/src/species/fish/regions.js +0 -27
- package/vendor/procedural-animals/src/species/fish/rig.js +0 -143
- package/vendor/procedural-animals/src/species/fish/sculpt.js +0 -214
- package/vendor/procedural-animals/src/species/fish/variants.js +0 -126
- package/vendor/procedural-animals/src/species/fox/behaviour.js +0 -314
- package/vendor/procedural-animals/src/species/fox/coat.js +0 -444
- package/vendor/procedural-animals/src/species/fox/index.js +0 -120
- package/vendor/procedural-animals/src/species/fox/motion.js +0 -81
- package/vendor/procedural-animals/src/species/fox/regions.js +0 -59
- package/vendor/procedural-animals/src/species/fox/rig.js +0 -91
- package/vendor/procedural-animals/src/species/fox/sculpt.js +0 -202
- package/vendor/procedural-animals/src/species/frog/behaviour.js +0 -590
- package/vendor/procedural-animals/src/species/frog/coat.js +0 -305
- package/vendor/procedural-animals/src/species/frog/index.js +0 -97
- package/vendor/procedural-animals/src/species/frog/motion.js +0 -69
- package/vendor/procedural-animals/src/species/frog/regions.js +0 -46
- package/vendor/procedural-animals/src/species/frog/rig.js +0 -156
- package/vendor/procedural-animals/src/species/frog/sculpt.js +0 -240
- package/vendor/procedural-animals/src/species/goat/behaviour.js +0 -509
- package/vendor/procedural-animals/src/species/goat/coat.js +0 -590
- package/vendor/procedural-animals/src/species/goat/index.js +0 -149
- package/vendor/procedural-animals/src/species/goat/motion.js +0 -95
- package/vendor/procedural-animals/src/species/goat/regions.js +0 -98
- package/vendor/procedural-animals/src/species/goat/rig.js +0 -181
- package/vendor/procedural-animals/src/species/goat/sculpt.js +0 -547
- package/vendor/procedural-animals/src/species/horse/coat.js +0 -361
- package/vendor/procedural-animals/src/species/horse/coatSeam.js +0 -122
- package/vendor/procedural-animals/src/species/horse/index.js +0 -80
- package/vendor/procedural-animals/src/species/horse/motion.js +0 -245
- package/vendor/procedural-animals/src/species/horse/regions.js +0 -60
- package/vendor/procedural-animals/src/species/horse/rig.js +0 -117
- package/vendor/procedural-animals/src/species/horse/sculpt.js +0 -316
- package/vendor/procedural-animals/src/species/horse/seamWeights.js +0 -272
- package/vendor/procedural-animals/src/species/lion/behaviour.js +0 -509
- package/vendor/procedural-animals/src/species/lion/coat.js +0 -1016
- package/vendor/procedural-animals/src/species/lion/index.js +0 -111
- package/vendor/procedural-animals/src/species/lion/motion.js +0 -87
- package/vendor/procedural-animals/src/species/lion/regions.js +0 -106
- package/vendor/procedural-animals/src/species/lion/rig.js +0 -110
- package/vendor/procedural-animals/src/species/lion/sculpt.js +0 -384
- package/vendor/procedural-animals/src/species/lion/whiskers.js +0 -132
- package/vendor/procedural-animals/src/species/pig/behaviour.js +0 -575
- package/vendor/procedural-animals/src/species/pig/coat.js +0 -730
- package/vendor/procedural-animals/src/species/pig/ears.js +0 -242
- package/vendor/procedural-animals/src/species/pig/index.js +0 -161
- package/vendor/procedural-animals/src/species/pig/motion.js +0 -105
- package/vendor/procedural-animals/src/species/pig/regions.js +0 -100
- package/vendor/procedural-animals/src/species/pig/rig.js +0 -152
- package/vendor/procedural-animals/src/species/pig/sculpt.js +0 -382
- package/vendor/procedural-animals/src/species/rabbit/behaviour.js +0 -605
- package/vendor/procedural-animals/src/species/rabbit/coat.js +0 -285
- package/vendor/procedural-animals/src/species/rabbit/index.js +0 -85
- package/vendor/procedural-animals/src/species/rabbit/motion.js +0 -85
- package/vendor/procedural-animals/src/species/rabbit/regions.js +0 -48
- package/vendor/procedural-animals/src/species/rabbit/rig.js +0 -99
- package/vendor/procedural-animals/src/species/rabbit/sculpt.js +0 -148
- package/vendor/procedural-animals/src/species/rat/behaviour.js +0 -539
- package/vendor/procedural-animals/src/species/rat/coat.js +0 -341
- package/vendor/procedural-animals/src/species/rat/index.js +0 -111
- package/vendor/procedural-animals/src/species/rat/motion.js +0 -90
- package/vendor/procedural-animals/src/species/rat/regions.js +0 -92
- package/vendor/procedural-animals/src/species/rat/rig.js +0 -112
- package/vendor/procedural-animals/src/species/rat/sculpt.js +0 -163
- package/vendor/procedural-animals/src/species/rat/whiskers.js +0 -119
- package/vendor/procedural-animals/src/species/shark/coat.js +0 -383
- package/vendor/procedural-animals/src/species/shark/index.js +0 -104
- package/vendor/procedural-animals/src/species/shark/motion.js +0 -69
- package/vendor/procedural-animals/src/species/shark/regions.js +0 -34
- package/vendor/procedural-animals/src/species/shark/rig.js +0 -194
- package/vendor/procedural-animals/src/species/shark/sculpt.js +0 -343
- package/vendor/procedural-animals/src/species/shark/variants.js +0 -105
- package/vendor/procedural-animals/src/species/sheep/behaviour.js +0 -522
- package/vendor/procedural-animals/src/species/sheep/coat.js +0 -529
- package/vendor/procedural-animals/src/species/sheep/index.js +0 -152
- package/vendor/procedural-animals/src/species/sheep/motion.js +0 -86
- package/vendor/procedural-animals/src/species/sheep/neck.js +0 -41
- package/vendor/procedural-animals/src/species/sheep/regions.js +0 -62
- package/vendor/procedural-animals/src/species/sheep/rig.js +0 -163
- package/vendor/procedural-animals/src/species/sheep/sculpt.js +0 -542
- package/vendor/procedural-animals/src/species/snake/coat.js +0 -315
- package/vendor/procedural-animals/src/species/snake/index.js +0 -73
- package/vendor/procedural-animals/src/species/snake/motion.js +0 -51
- package/vendor/procedural-animals/src/species/snake/regions.js +0 -51
- package/vendor/procedural-animals/src/species/snake/rig.js +0 -108
- package/vendor/procedural-animals/src/species/snake/sculpt.js +0 -122
- package/vendor/procedural-animals/src/species/spider/coat.js +0 -279
- package/vendor/procedural-animals/src/species/spider/index.js +0 -78
- package/vendor/procedural-animals/src/species/spider/motion.js +0 -72
- package/vendor/procedural-animals/src/species/spider/regions.js +0 -87
- package/vendor/procedural-animals/src/species/spider/rig.js +0 -118
- package/vendor/procedural-animals/src/species/spider/sculpt.js +0 -182
- package/vendor/procedural-animals/src/species/wolf/behaviour.js +0 -160
- package/vendor/procedural-animals/src/species/wolf/coat.js +0 -749
- package/vendor/procedural-animals/src/species/wolf/index.js +0 -107
- package/vendor/procedural-animals/src/species/wolf/motion.js +0 -80
- package/vendor/procedural-animals/src/species/wolf/regions.js +0 -57
- package/vendor/procedural-animals/src/species/wolf/rig.js +0 -87
- package/vendor/procedural-animals/src/species/wolf/sculpt.js +0 -339
- package/vendor/procedural-animals/src/worker.js +0 -29
|
@@ -43,7 +43,7 @@ export default Plugin.define({
|
|
|
43
43
|
commands:[{
|
|
44
44
|
id:'retrieviewer.pet',
|
|
45
45
|
title:'Retrieviewer pet',
|
|
46
|
-
description:'enable | disable | ball | treat | status',
|
|
46
|
+
description:'enable | disable | ball | treat | tug | status',
|
|
47
47
|
group:'Retrieviewer',
|
|
48
48
|
palette:true,
|
|
49
49
|
slash:{name:'retrieviewer',arguments:true},
|
|
@@ -111,10 +111,10 @@ sealed class Companion : ApplicationContext {
|
|
|
111
111
|
TargetItem target;Form pickerWindow;QuietWindow testTarget;readonly bool testMode;Rectangle canvas;int revision=0,cell=8;bool visible=false,paused=false,loaded=false,quitting=false,picking=false,announced=false;
|
|
112
112
|
Label status=new Label();Mutex mutex;
|
|
113
113
|
internal Companion(Mutex single,bool diagnostic){
|
|
114
|
-
mutex=single;testMode=diagnostic;bar.Text="Retrieviewer controls";bar.Size=new Size(
|
|
114
|
+
mutex=single;testMode=diagnostic;bar.Text="Retrieviewer controls";bar.Size=new Size(404,40);bar.BackColor=Color.FromArgb(28,30,34);bar.ForeColor=Color.White;
|
|
115
115
|
bar.Font=new Font("Segoe UI",9);bar.Controls.Add(MakeButton("공",8,()=>Interact("ball")));bar.Controls.Add(MakeButton("간식",52,()=>Interact("treat")));
|
|
116
|
-
bar.Controls.Add(MakeButton("
|
|
117
|
-
status.AutoSize=false;status.Location=new Point(
|
|
116
|
+
bar.Controls.Add(MakeButton("터그",102,()=>Interact("tug")));bar.Controls.Add(MakeButton("창",152,ChooseTarget));bar.Controls.Add(MakeButton("쉼",196,TogglePause));bar.Controls.Add(MakeButton("종료",240,Quit));
|
|
117
|
+
status.AutoSize=false;status.Location=new Point(290,12);status.Size=new Size(110,22);status.Text="준비 중";bar.Controls.Add(status);
|
|
118
118
|
ContextMenuStrip menu=new ContextMenuStrip();menu.Items.Add("다른 창 선택",null,(s,e)=>ChooseTarget());menu.Items.Add("숨기기 / 다시 표시",null,(s,e)=>TogglePause());menu.Items.Add("종료",null,(s,e)=>Quit());
|
|
119
119
|
tray.Icon=SystemIcons.Application;tray.Text="Retrieviewer · 창 선택";tray.ContextMenuStrip=menu;tray.Visible=true;tray.DoubleClick+=(s,e)=>ChooseTarget();
|
|
120
120
|
// Handles are created on the UI thread before the reader can signal EOF.
|
|
@@ -127,7 +127,7 @@ sealed class Companion : ApplicationContext {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
Button MakeButton(string title,int x,Action action){
|
|
130
|
-
Button b=new Button();b.Text=title;b.TabStop=false;b.Size=new Size(title=="간식"?46:40,28);b.Location=new Point(x,6);b.FlatStyle=FlatStyle.Flat;b.FlatAppearance.BorderSize=0;b.BackColor=Color.FromArgb(48,51,58);b.ForeColor=Color.White;b.Click+=(s,e)=>action();return b;
|
|
130
|
+
Button b=new Button();b.Text=title;b.TabStop=false;b.Size=new Size(title=="간식"||title=="터그"?46:40,28);b.Location=new Point(x,6);b.FlatStyle=FlatStyle.Flat;b.FlatAppearance.BorderSize=0;b.BackColor=Color.FromArgb(48,51,58);b.ForeColor=Color.White;b.Click+=(s,e)=>action();return b;
|
|
131
131
|
}
|
|
132
132
|
void ReadInput(){
|
|
133
133
|
try{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Explicit
|
|
1
|
+
// Explicit native companion launcher. Never imports the pet on help/status/stop.
|
|
2
2
|
import {spawn,execFile} from 'node:child_process';
|
|
3
3
|
import {promisify} from 'node:util';
|
|
4
4
|
import {readFile,mkdir,lstat,unlink,open,rename,readdir} from 'node:fs/promises';
|
|
@@ -7,6 +7,7 @@ import {join,dirname} from 'node:path';
|
|
|
7
7
|
import {fileURLToPath} from 'node:url';
|
|
8
8
|
import {createConnection} from 'node:net';
|
|
9
9
|
import {getConfigPaths} from '../../retrieviewer-config.mjs';
|
|
10
|
+
import {desktopPlatform,validControlAddress} from '../desktop/platform.mjs';
|
|
10
11
|
const exec=promisify(execFile);
|
|
11
12
|
const SOURCE=new URL('./Overlay.cs',import.meta.url);
|
|
12
13
|
export function desktopPaths(options={}){const root=join(getConfigPaths(options).root,'desktop');return {root,session:join(root,'session.json')};}
|
|
@@ -17,7 +18,7 @@ export async function prepareRoot(options={}){
|
|
|
17
18
|
export async function readSession(options={}){
|
|
18
19
|
const {root,session}=desktopPaths(options);await noLink(dirname(root));await noLink(root);await noLink(session);
|
|
19
20
|
let data;try{data=JSON.parse(await readFile(session,'utf8'));}catch(e){if(e.code==='ENOENT')return null;throw e;}
|
|
20
|
-
if(data?.owner!=='bitefoundry-retrieviewer-overlay-v1'||!Number.isInteger(data.pid)||data.pid<=0
|
|
21
|
+
if(data?.owner!=='bitefoundry-retrieviewer-overlay-v1'||!Number.isInteger(data.pid)||data.pid<=0||!validControlAddress(data.pipe)||!/^[a-f0-9]{64}$/.test(data.token))throw Error('Unrecognized desktop session; not modifying it');
|
|
21
22
|
return data;
|
|
22
23
|
}
|
|
23
24
|
export function requestSession(session,command){
|
|
@@ -30,21 +31,37 @@ export function requestSession(session,command){
|
|
|
30
31
|
socket.on('error',e=>finish(e));socket.on('end',()=>{if(!done)finish(Error('Desktop control closed without a response'));});
|
|
31
32
|
});
|
|
32
33
|
}
|
|
34
|
+
async function processAlive(pid){
|
|
35
|
+
try{process.kill(pid,0);}catch(error){if(error.code==='ESRCH')return false;throw error;}
|
|
36
|
+
if(process.platform==='linux')try{
|
|
37
|
+
// A container PID1 without a reaper can retain a dead detached worker as Z.
|
|
38
|
+
// kill(pid,0) alone treats it as alive, falsely making a successful stop fail.
|
|
39
|
+
const stat=await readFile('/proc/'+pid+'/stat','utf8'),state=stat.slice(stat.lastIndexOf(')')+2).charAt(0);
|
|
40
|
+
if(state==='Z'||state==='X')return false;
|
|
41
|
+
}catch(error){if(error.code==='ENOENT')return false;throw error;}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
33
44
|
export async function desktopStatus(options={}){
|
|
34
45
|
const session=await readSession(options);if(!session)return {running:false};
|
|
35
|
-
try{return await requestSession(session,'status');}catch(error){
|
|
46
|
+
try{return await requestSession(session,'status');}catch(error){const alive=await processAlive(session.pid);
|
|
36
47
|
return {running:alive,reachable:false,stale:!alive,pid:session.pid,reason:error.code??error.message};}
|
|
37
48
|
}
|
|
38
49
|
export async function stopDesktop(options={}){
|
|
39
50
|
const session=await readSession(options);if(!session)return {running:false,stopped:true};
|
|
40
51
|
const result=await desktopStatus(options);
|
|
41
|
-
if(result.stale){
|
|
52
|
+
if(result.stale){
|
|
53
|
+
if(session.pipe.startsWith('/tmp/')){
|
|
54
|
+
await noLink(session.pipe);
|
|
55
|
+
try{const entry=await lstat(session.pipe);if(!entry.isSocket()||(process.getuid&&entry.uid!==process.getuid()))throw Error('Refusing unowned/non-socket desktop endpoint');await unlink(session.pipe);}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
56
|
+
}
|
|
57
|
+
await unlink(desktopPaths(options).session);return {running:false,stopped:true,staleSessionRemoved:true};
|
|
58
|
+
}
|
|
42
59
|
if(result.reachable===false)throw Error('Desktop process is not responding; close it from its tray icon. No PID was killed.');
|
|
43
60
|
await requestSession(session,'stop');
|
|
44
61
|
// The stop response acknowledges the request, not native process termination.
|
|
45
62
|
// Wait before advertising success so a following cleanup cannot race an in-use exe.
|
|
46
63
|
for(let i=0;i<60;i++){
|
|
47
|
-
|
|
64
|
+
if(!await processAlive(session.pid))return {running:false,stopped:true};
|
|
48
65
|
await new Promise(resolve=>setTimeout(resolve,100));
|
|
49
66
|
}
|
|
50
67
|
throw Error('Desktop accepted stop but has not exited; cache preserved. Retry after it closes.');
|
|
@@ -53,7 +70,7 @@ export async function buildHelper(options={}){
|
|
|
53
70
|
if(process.platform!=='win32')throw Error('The transparent companion currently supports Windows only');
|
|
54
71
|
const {root}=await prepareRoot(options),source=await readFile(SOURCE),hash=createHash('sha256').update(source).digest('hex').slice(0,20);
|
|
55
72
|
const executable=join(root,`overlay-${hash}.exe`);await noLink(executable);
|
|
56
|
-
try{await lstat(executable);return executable;}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
73
|
+
try{if(!(await lstat(executable)).isFile())throw Error('Desktop helper cache is not a regular file');return executable;}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
57
74
|
const compiler=join(process.env.SystemRoot??'C:\\Windows','Microsoft.NET','Framework64','v4.0.30319','csc.exe');
|
|
58
75
|
const temporary=join(root,`build-${randomUUID()}.exe`);
|
|
59
76
|
try{
|
|
@@ -62,12 +79,27 @@ export async function buildHelper(options={}){
|
|
|
62
79
|
}catch(error){await unlink(temporary).catch(()=>{});throw Error('Windows overlay build failed: '+(error.stdout??error.message));}
|
|
63
80
|
return executable;
|
|
64
81
|
}
|
|
82
|
+
export async function desktopHelper(options={}){
|
|
83
|
+
const platform=desktopPlatform(options);
|
|
84
|
+
if(platform.helper==='windows')return {command:await buildHelper(options),args:[],mode:platform.id,fps:platform.fps};
|
|
85
|
+
if(platform.helper==='macos')return {command:'/usr/bin/osascript',args:['-l','JavaScript',fileURLToPath(new URL('../macos-overlay/overlay.jxa',import.meta.url))],mode:platform.id,fps:platform.fps};
|
|
86
|
+
// Use an existing system Python, including AlmaLinux8's3.6 platform interpreter.
|
|
87
|
+
// No Python package, compiled addon, native bundle, compiler, or package manager.
|
|
88
|
+
const candidates=[...(process.env.RETRIEVIEWER_PYTHON?[process.env.RETRIEVIEWER_PYTHON]:[]),'python3','/usr/libexec/platform-python'];
|
|
89
|
+
for(const command of candidates)try{
|
|
90
|
+
await exec(command,['-I','-c','import sys;sys.exit(0 if sys.version_info >= (3,6) else 1)'],{windowsHide:true,timeout:5000,maxBuffer:4096});
|
|
91
|
+
return {command,args:['-I',fileURLToPath(new URL('../linux-overlay/overlay.py',import.meta.url))],mode:platform.id,fps:platform.fps};
|
|
92
|
+
}catch{}
|
|
93
|
+
throw Error('Linux desktop needs system Python3.6+ (AlmaLinux8 platform-python is supported). No packages or system settings were installed.');
|
|
94
|
+
}
|
|
65
95
|
export async function startDesktop(options={}){
|
|
96
|
+
// Fail before creating any cache/session on unsupported desktops (e.g. Wayland).
|
|
97
|
+
desktopPlatform(options);
|
|
66
98
|
const status=await desktopStatus(options);if(status.running)return {...status,alreadyRunning:true};
|
|
67
99
|
if(status.stale)await stopDesktop(options);
|
|
68
|
-
const
|
|
100
|
+
const helper=await desktopHelper(options);
|
|
69
101
|
return new Promise((resolve,reject)=>{
|
|
70
|
-
const child=spawn(process.execPath,[fileURLToPath(new URL('./worker.mjs',import.meta.url)),
|
|
102
|
+
const child=spawn(process.execPath,[fileURLToPath(new URL('./worker.mjs',import.meta.url)),'--helper-spec',JSON.stringify(helper)],{detached:true,windowsHide:true,stdio:['ignore','ignore','ignore','ipc'],env:{...process.env,RETRIEVIEWER_HOME:getConfigPaths(options).root}});
|
|
71
103
|
let settled=false;const finish=(error,message)=>{if(settled)return;settled=true;clearTimeout(timer);if(child.connected)child.disconnect();child.unref();error?reject(error):resolve(message);};
|
|
72
104
|
const timer=setTimeout(()=>{if(child.connected)child.send({command:'abort'});finish(Error('Desktop startup timed out; no agent settings changed'));},20000);
|
|
73
105
|
child.on('error',error=>finish(error));child.on('message',message=>message.error?finish(Error(message.error)):finish(null,message));child.on('exit',code=>finish(Error('Desktop exited during startup ('+code+')')));
|
|
@@ -20,20 +20,24 @@ export function cropFrame(frame,revision){
|
|
|
20
20
|
|
|
21
21
|
// Request/ack rendering: never queue obsolete frames behind a slow native painter.
|
|
22
22
|
export function createFramePump({pet,send,now=()=>performance.now()}){
|
|
23
|
-
let viewport=null,inFlight=false,last=null,revision=0,paused=false,disposed=false;
|
|
23
|
+
let viewport=null,inFlight=false,last=null,lastFrame=null,revision=0,paused=false,disposed=false;
|
|
24
24
|
const alive=()=>{if(disposed)throw Error('Overlay pump is disposed');};
|
|
25
25
|
return {
|
|
26
|
-
viewport(message){alive();const next=viewportOf(message);revision=message.revision;viewport=next;last=null;},
|
|
27
|
-
pause(value){alive();paused=!!value;last=null;},
|
|
26
|
+
viewport(message){alive();const next=viewportOf(message);revision=message.revision;viewport=next;last=null;lastFrame=null;},
|
|
27
|
+
pause(value){alive();paused=!!value;last=null;lastFrame=null;},
|
|
28
28
|
ack(){alive();inFlight=false;},
|
|
29
29
|
tick(){
|
|
30
30
|
alive();if(inFlight||!viewport||paused)return false;
|
|
31
31
|
const t=now(),dt=last===null?0:Math.max(0,(t-last)/1000);last=t;
|
|
32
|
-
pet.step(dt);const frame=pet.frame(viewport);
|
|
33
|
-
|
|
32
|
+
pet.step(dt);const frame=cropFrame(pet.frame(viewport),revision);
|
|
33
|
+
// A held seat/down pose can be byte-identical for seconds. Advance the life
|
|
34
|
+
// clock normally but avoid JSON, IPC, bitmap allocation and native repaint.
|
|
35
|
+
if(lastFrame&&frame.x===lastFrame.x&&frame.y===lastFrame.y&&frame.columns===lastFrame.columns&&frame.rows===lastFrame.rows&&frame.text===lastFrame.text)return false;
|
|
36
|
+
inFlight=true;
|
|
37
|
+
try{send(frame);lastFrame=frame;}catch(error){inFlight=false;throw error;}return true;
|
|
34
38
|
},
|
|
35
|
-
interact(kind){alive();if(!['ball','treat'].includes(kind))throw Error('Invalid overlay interaction');
|
|
39
|
+
interact(kind){alive();if(!['ball','treat','tug'].includes(kind))throw Error('Invalid overlay interaction');const accepted=pet.interact(kind);if(accepted)lastFrame=null;return accepted;},
|
|
36
40
|
get hidden(){return !viewport||paused;},
|
|
37
|
-
dispose(){if(!disposed){disposed=true;viewport=null;pet.dispose();}},
|
|
41
|
+
dispose(){if(!disposed){disposed=true;viewport=lastFrame=null;pet.dispose();}},
|
|
38
42
|
};
|
|
39
43
|
}
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import {spawn} from 'node:child_process';
|
|
3
3
|
import {createServer} from 'node:net';
|
|
4
4
|
import {createInterface} from 'node:readline';
|
|
5
|
-
import {open,unlink,readFile} from 'node:fs/promises';
|
|
5
|
+
import {open,unlink,readFile,chmod} from 'node:fs/promises';
|
|
6
6
|
import {randomBytes,randomUUID} from 'node:crypto';
|
|
7
7
|
import {prepareRoot,noLink} from './desktop.mjs';
|
|
8
8
|
import {createFramePump} from './protocol.mjs';
|
|
9
|
+
import {controlAddress,parseHelperSpec} from '../desktop/platform.mjs';
|
|
9
10
|
|
|
10
11
|
let helper,pump,timer,server,session,paths,owned=false,stopping=false,frames=0,paintedFrames=0,visible=false,selected=false,pickerVisible=false,pendingViewport=null,lastInteraction=null;
|
|
12
|
+
let nativeError=null;
|
|
13
|
+
let nativeStderr='';
|
|
11
14
|
const sendParent=message=>{if(process.connected)process.send(message);};
|
|
12
15
|
async function stop(){
|
|
13
16
|
if(stopping)return;stopping=true;clearInterval(timer);pump?.dispose();
|
|
@@ -20,8 +23,9 @@ async function stop(){
|
|
|
20
23
|
}
|
|
21
24
|
process.on('SIGTERM',stop);process.on('SIGINT',stop);process.on('message',m=>{if(m?.command==='abort')stop();});
|
|
22
25
|
try{
|
|
26
|
+
const spec=parseHelperSpec(process.argv.slice(2));
|
|
23
27
|
paths=await prepareRoot();await noLink(paths.session);
|
|
24
|
-
session={owner:'bitefoundry-retrieviewer-overlay-v1',pid:process.pid,pipe:
|
|
28
|
+
session={owner:'bitefoundry-retrieviewer-overlay-v1',pid:process.pid,pipe:controlAddress({uuid:randomUUID()}),token:randomBytes(32).toString('hex')};
|
|
25
29
|
const record=await open(paths.session,'wx',0o600);owned=true;try{await record.writeFile(JSON.stringify(session)+'\n');}finally{await record.close();}
|
|
26
30
|
server=createServer(socket=>{
|
|
27
31
|
socket.setTimeout(1500,()=>socket.destroy());let body='';
|
|
@@ -34,16 +38,18 @@ try{
|
|
|
34
38
|
});
|
|
35
39
|
});
|
|
36
40
|
await new Promise((resolve,reject)=>{server.once('error',reject);server.listen(session.pipe,resolve);});
|
|
41
|
+
if(process.platform!=='win32')await chmod(session.pipe,0o600);
|
|
37
42
|
// GUI-subsystem exe: no console to hide. SW_HIDE here also hides its first UI.
|
|
38
|
-
helper=spawn(
|
|
39
|
-
helper.stdin.on('error',()=>stop());helper.stderr.
|
|
40
|
-
helper.once('exit',code=>{if(!stopping)sendParent({error:'
|
|
43
|
+
helper=spawn(spec.command,spec.args,{windowsHide:false,stdio:['pipe','pipe','pipe']});
|
|
44
|
+
helper.stdin.on('error',()=>stop());helper.stderr.setEncoding('utf8');helper.stderr.on('data',s=>{nativeStderr=(nativeStderr+s).slice(-4096);});helper.once('error',error=>{sendParent({error:error.message});stop();});
|
|
45
|
+
helper.once('exit',code=>{if(!stopping)sendParent({error:nativeError??('Desktop painter exited ('+code+')'+(nativeStderr?' — '+nativeStderr.trim():''))});stop();});
|
|
41
46
|
const write=message=>{if(!stopping&&!helper.stdin.destroyed)helper.stdin.write(JSON.stringify(message)+'\n');};
|
|
42
47
|
const reader=createInterface({input:helper.stdout});
|
|
43
48
|
reader.on('line',line=>{
|
|
44
49
|
if(line.length>100000)return stop();let m;try{m=JSON.parse(line);}catch{return stop();}
|
|
45
50
|
try{
|
|
46
|
-
if(m.type==='ready'){pickerVisible=m.pickerVisible===true;sendParent({running:true,windowPicker:pickerVisible,mode:
|
|
51
|
+
if(m.type==='ready'){pickerVisible=m.pickerVisible===true;sendParent({running:true,windowPicker:pickerVisible,mode:spec.mode,pid:process.pid});}
|
|
52
|
+
else if(m.type==='error'){nativeError=String(m.message??'Desktop painter failed');sendParent({error:nativeError});stop();}
|
|
47
53
|
else if(m.type==='picker')pickerVisible=m.visible===true;
|
|
48
54
|
else if(m.type==='viewport'){pendingViewport=m;visible=m.visible;selected=m.selected===true;pump?.viewport(m);}
|
|
49
55
|
else if(m.type==='ack'){frames++;if(m.painted)paintedFrames++;pump?.ack();}
|
|
@@ -55,6 +61,6 @@ try{
|
|
|
55
61
|
const {createPet}=await import('../../retrieviewer.mjs');const pet=await createPet();
|
|
56
62
|
if(stopping)pet.dispose();else{
|
|
57
63
|
pump=createFramePump({pet,send:write});if(pendingViewport)pump.viewport(pendingViewport);
|
|
58
|
-
write({type:'loaded'});timer=setInterval(()=>{try{pump.tick();}catch(error){write({type:'error',message:error.message});stop();}},1000/
|
|
64
|
+
write({type:'loaded'});timer=setInterval(()=>{try{pump.tick();}catch(error){write({type:'error',message:error.message});stop();}},1000/spec.fps);
|
|
59
65
|
}
|
|
60
66
|
}catch(error){sendParent({error:error.message});await stop();}
|
package/package.json
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitefoundry/retrieviewer",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A fluffy Braille desktop
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "A fluffy Braille desktop pet for Windows and Linux X11, with experimental macOS support and an embeddable TUI engine.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
-
"homepage": "https://github.
|
|
7
|
-
"
|
|
6
|
+
"homepage": "https://bitefoundry.github.io/retrieviewer/",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/BiteFoundry/retrieviewer.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/BiteFoundry/retrieviewer/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"tui",
|
|
16
|
+
"braille",
|
|
17
|
+
"pet",
|
|
18
|
+
"retriever",
|
|
19
|
+
"opencode",
|
|
20
|
+
"desktop-pet",
|
|
21
|
+
"windows",
|
|
22
|
+
"linux",
|
|
23
|
+
"macos",
|
|
24
|
+
"overlay"
|
|
25
|
+
],
|
|
8
26
|
"publishConfig": {
|
|
9
27
|
"access": "public",
|
|
10
28
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -56,18 +74,25 @@
|
|
|
56
74
|
"integrations/windows-overlay/desktop.mjs",
|
|
57
75
|
"integrations/windows-overlay/worker.mjs",
|
|
58
76
|
"integrations/windows-overlay/Overlay.cs",
|
|
77
|
+
"integrations/desktop/platform.mjs",
|
|
78
|
+
"integrations/linux-overlay/overlay.py",
|
|
79
|
+
"integrations/linux-overlay/README.md",
|
|
80
|
+
"integrations/macos-overlay/overlay.jxa",
|
|
81
|
+
"integrations/macos-overlay/README.md",
|
|
82
|
+
"DESKTOP-PLATFORMS.md",
|
|
59
83
|
"WINDOWS-COMPANION.md",
|
|
60
84
|
"INSTALLING.md",
|
|
85
|
+
"PREREQUISITES.md",
|
|
86
|
+
"README.ko.md",
|
|
61
87
|
"PLUGIN.md",
|
|
62
88
|
"EMBEDDING.md",
|
|
63
89
|
"PUPPY-MEMORY.md",
|
|
64
90
|
"PUPPY-Q5-COMPARISON.md",
|
|
91
|
+
"COMFORT-ART.md",
|
|
65
92
|
"examples/embed.mjs",
|
|
66
93
|
"examples/live.mjs",
|
|
67
94
|
"examples/plugin.mjs",
|
|
68
95
|
"examples/bridge.py",
|
|
69
|
-
"locomotion-core.mjs",
|
|
70
|
-
"locomotion-puppy.animal",
|
|
71
96
|
"braille.mjs",
|
|
72
97
|
"puppy-frame-store.mjs",
|
|
73
98
|
"puppy-frame-predictive.mjs",
|
|
@@ -85,6 +110,7 @@
|
|
|
85
110
|
"puppy-companion-life.mjs",
|
|
86
111
|
"puppy-companion-objects.mjs",
|
|
87
112
|
"puppy-companion-sprites.mjs",
|
|
113
|
+
"puppy-comfort-sprites.mjs",
|
|
88
114
|
"puppy-mouth-anchor.mjs",
|
|
89
115
|
"puppy-mouth-anchor.json",
|
|
90
116
|
"puppy-clean.mjs",
|
|
@@ -110,24 +136,25 @@
|
|
|
110
136
|
"puppy-paper-actions-v9.json",
|
|
111
137
|
"puppy-companion-interactions-v3-q5.bin.gz",
|
|
112
138
|
"puppy-companion-interactions-v3.json",
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"vendor/procedural-animals/
|
|
139
|
+
"puppy-companion-comfort-q5.bin.gz",
|
|
140
|
+
"puppy-companion-comfort.json",
|
|
141
|
+
"vendor/procedural-animals/LICENSE"
|
|
116
142
|
],
|
|
117
143
|
"scripts": {
|
|
118
|
-
"start": "node
|
|
119
|
-
"
|
|
120
|
-
"pet": "node puppy-terminal.mjs",
|
|
144
|
+
"start": "node tools/preview-site.mjs",
|
|
145
|
+
"build:site": "node tools/build-site.mjs",
|
|
121
146
|
"pet:companion": "node examples/live.mjs",
|
|
122
147
|
"pet:desktop": "node retrieviewer-cli.mjs desktop",
|
|
123
148
|
"test": "node --test \"*.test.mjs\"",
|
|
124
|
-
"test:locomotion": "node check-locomotion.mjs",
|
|
125
149
|
"test:package": "node check-pet-package.mjs",
|
|
126
150
|
"release:check": "node tools/check-release.mjs",
|
|
127
151
|
"prepublishOnly": "npm run release:check"
|
|
128
152
|
},
|
|
129
153
|
"dependencies": {
|
|
130
|
-
"jsonc-parser": "3.3.1"
|
|
154
|
+
"jsonc-parser": "3.3.1"
|
|
155
|
+
},
|
|
156
|
+
"devDependencies": {
|
|
157
|
+
"playwright": "1.64.1",
|
|
131
158
|
"three": "0.186.1"
|
|
132
159
|
}
|
|
133
160
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {grayFrameReader,isGrayFrameSource} from './puppy-frame-store.mjs';
|
|
2
|
+
|
|
3
|
+
// A handful of authored keys, not an expanded 30fps film or a live image morph.
|
|
4
|
+
// First/last keys are the exact shared seated source; all keys use one scale.
|
|
5
|
+
export function comfortFrameIndex(progress,info){
|
|
6
|
+
if(!Number.isFinite(progress)||progress<0||progress>1)throw Error('Invalid comfort progress');
|
|
7
|
+
const seconds=progress*6;
|
|
8
|
+
if(seconds<.12||progress===1)return 0;
|
|
9
|
+
if(seconds<.65)return seconds<.3?1:2;
|
|
10
|
+
if(seconds>5.15)return seconds<5.45?7:seconds<5.8?8:0;
|
|
11
|
+
const loop=[3,4,3,5,3,6,3,5,3,4,3,6];
|
|
12
|
+
return loop[Math.floor((seconds-.65)/.28)%loop.length];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createComfortSpriteSampler(bytes,info){
|
|
16
|
+
if(!isGrayFrameSource(bytes)||info?.version!==1||info.width!==320||info.height!==320||info.frames!==9)throw Error('Invalid comfort sprites');
|
|
17
|
+
const frames=grayFrameReader(bytes,320,320,info.frames);let rgba=null;
|
|
18
|
+
return pose=>{
|
|
19
|
+
if(pose?.clip!=='tug')throw Error('Invalid comfort clip');
|
|
20
|
+
if(!rgba){rgba=new Uint8ClampedArray(320*320*4);for(let i=3;i<rgba.length;i+=4)rgba[i]=255;}
|
|
21
|
+
const index=comfortFrameIndex(pose.progress,info),frame=frames.getFrame(index);
|
|
22
|
+
for(let i=0,j=0;i<frame.length;i++,j+=4)rgba[j]=rgba[j+1]=rgba[j+2]=frame[i];
|
|
23
|
+
return rgba;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"width": 320,
|
|
4
|
+
"height": 320,
|
|
5
|
+
"frames": 9,
|
|
6
|
+
"clips": [
|
|
7
|
+
"tug"
|
|
8
|
+
],
|
|
9
|
+
"gzipBytes": 103549,
|
|
10
|
+
"residentPixelBytes": 291337,
|
|
11
|
+
"sourceSheetSha256": "10fde9dacca5cb45acd68f387e7ed3bcf88cd72cf0f9c4220d31d819db91731e",
|
|
12
|
+
"neutralSha256": "19f89a8bcb5a937e528593a8f36db846a0d45a5ee398f1b0873c056e5be2fa0a",
|
|
13
|
+
"encodedSha256": "e046e214da585ffda65e8d2c1a86c589af589325b792634f128ab8b71f6dbf3a",
|
|
14
|
+
"method": "Built-in imagegen authored tug keys. One fixed scale, ground/center translation only. Exact existing Q5 seat first/last. No expanded tween film or live body deformation.",
|
|
15
|
+
"registration": {
|
|
16
|
+
"sheetSize": [
|
|
17
|
+
1774,
|
|
18
|
+
887
|
|
19
|
+
],
|
|
20
|
+
"targetBounds": [
|
|
21
|
+
41,
|
|
22
|
+
92,
|
|
23
|
+
231,
|
|
24
|
+
301
|
|
25
|
+
],
|
|
26
|
+
"registration": [
|
|
27
|
+
{
|
|
28
|
+
"cell": 0,
|
|
29
|
+
"scale": 0.5663956639566395,
|
|
30
|
+
"dx": 32,
|
|
31
|
+
"dy": 69
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"cell": 1,
|
|
35
|
+
"scale": 0.5663956639566395,
|
|
36
|
+
"dx": 39,
|
|
37
|
+
"dy": 69
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"cell": 2,
|
|
41
|
+
"scale": 0.5663956639566395,
|
|
42
|
+
"dx": 39,
|
|
43
|
+
"dy": 69
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"cell": 3,
|
|
47
|
+
"scale": 0.5663956639566395,
|
|
48
|
+
"dx": 35,
|
|
49
|
+
"dy": 68
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"cell": 4,
|
|
53
|
+
"scale": 0.5663956639566395,
|
|
54
|
+
"dx": 33,
|
|
55
|
+
"dy": 74
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"cell": 5,
|
|
59
|
+
"scale": 0.5663956639566395,
|
|
60
|
+
"dx": 39,
|
|
61
|
+
"dy": 74
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"cell": 6,
|
|
65
|
+
"scale": 0.5663956639566395,
|
|
66
|
+
"dx": 39,
|
|
67
|
+
"dy": 74
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"cell": 7,
|
|
71
|
+
"scale": 0.5663956639566395,
|
|
72
|
+
"dx": 36,
|
|
73
|
+
"dy": 74
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}
|
package/puppy-companion-life.mjs
CHANGED
|
@@ -11,16 +11,18 @@ const BALL_TARGET={x:0,z:-4};
|
|
|
11
11
|
const OFFER={x:0,z:.3};
|
|
12
12
|
// Hand-fed treat marker, relative to the puppy's current root (no travel for treats).
|
|
13
13
|
const TREAT_OFFSET={z:.08,height:.25};
|
|
14
|
-
const COOLDOWN={ball:6,treat:15};
|
|
14
|
+
const COOLDOWN={ball:6,treat:15,tug:20};
|
|
15
15
|
const FLIGHT=.65,BALL_PEAK=.75,CARRY_HEIGHT=.19,SETTLE_FALLBACK=.6,MAX_DT=.25,ARRIVE=.05;
|
|
16
16
|
const LABEL={
|
|
17
17
|
start:'기다리는 중',pause:'잠시 느긋하게 둘러보는 중',lie:'엎드리는 중',rest:'엎드려 쉬는 중',recover:'앉아서 기운 차리는 중',
|
|
18
18
|
sit:'앉는 중',watch:'앉아서 지켜보는 중',look:'고개를 돌려 살피는 중',observe:'가만히 주변 관찰 중',
|
|
19
19
|
stroll:'옆으로 살짝 걸어가는 중',sniff:'잠깐 멈춰 주변을 살피는 중',dash:'저 멀리 달려가는 중',far:'멀리서 둘러보는 중',home:'제자리로 돌아오는 중',
|
|
20
|
+
patrol:'주변을 왕복 산책하는 중',scan:'양쪽을 번갈아 살피는 중',roll:'느긋하게 뒹구는 중',play:'신나서 한 바퀴 도는 중',checkin:'가까이 와서 함께 쉬는 중',
|
|
21
|
+
belly:'배를 보이고 발라당 쉬는 중',sleep:'새근새근 잠자는 중',tug:'장난감을 물고 당기는 중',
|
|
20
22
|
fetch:'공을 쫓아가는 중',pickup:'공을 무는 중',carry:'공을 물고 돌아오는 중',drop:'공을 내려놓는 중',offer:'공을 내려놓고 기다리는 중',
|
|
21
23
|
treatSit:'간식 앞에 앉는 중',chew:'간식 먹는 중'
|
|
22
24
|
};
|
|
23
|
-
const PENDING_LABEL={treat:'곧 간식'};
|
|
25
|
+
const PENDING_LABEL={treat:'곧 간식',tug:'곧 터그놀이'};
|
|
24
26
|
// Baked interaction clips, played only while holding at the shared seated endpoint.
|
|
25
27
|
const GESTURE={'ball-pickup':1.4,'ball-drop':1.2,'treat-eat':2.4};
|
|
26
28
|
const clamp=(v,a,b)=>Math.min(b,Math.max(a,v));
|
|
@@ -38,7 +40,8 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
38
40
|
|
|
39
41
|
const rand=mulberry32(seed),range=(a,b)=>a+(b-a)*rand(),side=()=>rand()<.5?'left':'right';
|
|
40
42
|
const needs={energy,social:.5,curiosity:.5};
|
|
41
|
-
const cooldowns={ball:0,treat:0};
|
|
43
|
+
const cooldowns={ball:0,treat:0,tug:0};
|
|
44
|
+
const episodeCooldowns={roll:0,play:0,belly:0,sleep:0};
|
|
42
45
|
let clock=0,decisions=0,lastEpisode=null;
|
|
43
46
|
let queue=[],hold=0,holdIntent=null,waiting=null,gesture=null;
|
|
44
47
|
let intent='start',label=LABEL.start,pending=null,active=null,ball=null,treat=null;
|
|
@@ -51,25 +54,44 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
51
54
|
// Treats accept any seat variant at the front-seated endpoint: the hand comes to the puppy.
|
|
52
55
|
const seatedAnyVariant=()=>{const s=actor.sample(clock);return actor.state==='idle'&&s.seatProgress===1&&s.view==='approach';};
|
|
53
56
|
const fx=fn=>({fx:fn});
|
|
54
|
-
const home=()=>cmd('go',[HOME.x,HOME.z],'home');
|
|
57
|
+
const home=()=>cmd('go',[HOME.x,HOME.z],'home',()=>{const s=actor.sample(clock);return Math.hypot(s.x-HOME.x,s.z-HOME.z)>ARRIVE;});
|
|
58
|
+
const sit=step=>cmd('sit',[],step,()=>!seatedAnyVariant());
|
|
59
|
+
const lie=()=>cmd('lie',[],'lie',()=>actor.state!=='down');
|
|
60
|
+
const walkTo=x=>cmd('walk',()=>{const dx=x-actor.sample(clock).x;return [dx<0?'left':'right',Math.abs(dx)];},'patrol',()=>Math.abs(x-actor.sample(clock).x)>.002);
|
|
55
61
|
|
|
56
62
|
// Each episode is a short coherent plan; a pause always leads in so autonomy never stalls.
|
|
57
63
|
const EPISODES={
|
|
58
|
-
rest:()=>[
|
|
59
|
-
watch:()=>[
|
|
60
|
-
observe:()=>[cmd('look',[side()],'look'),wait(range(3,9),'observe'),fx(()=>{needs.curiosity-=.15;})],
|
|
64
|
+
rest:()=>[lie(),wait(range(10,18),'rest'),sit('recover'),wait(range(3,6),'recover')],
|
|
65
|
+
watch:()=>[sit('sit'),cmd('look',[side()],'look'),wait(range(3,9),'watch'),fx(()=>{needs.social-=.3;needs.curiosity+=.1;})],
|
|
66
|
+
observe:()=>[sit('sit'),cmd('look',[side()],'look'),wait(range(3,9),'observe'),fx(()=>{needs.curiosity-=.15;})],
|
|
61
67
|
stroll:()=>[cmd('walk',[side(),range(.08,.18)],'stroll'),wait(range(2,4),'sniff'),home(),fx(()=>{needs.energy-=.08;needs.curiosity-=.2;})],
|
|
62
|
-
dash:()=>[cmd('go',[(rand()*2-1)*.18,-range(3,8)],'dash'),wait(range(1.5,3),'far'),home(),fx(()=>{needs.energy-=.3;needs.curiosity-=.4;})]
|
|
68
|
+
dash:()=>[cmd('go',[(rand()*2-1)*.18,-range(3,8)],'dash'),wait(range(1.5,3),'far'),home(),fx(()=>{needs.energy-=.3;needs.curiosity-=.4;})],
|
|
69
|
+
scan:()=>[sit('sit'),cmd('look',['left'],'scan'),wait(range(.5,1.5),'scan'),cmd('look',['right'],'scan'),wait(range(2,4),'observe'),fx(()=>{needs.curiosity-=.25;})],
|
|
70
|
+
patrol:()=>{const x=actor.sample(clock).x,d=range(.16,.3)*(rand()<.5?-1:1);return [walkTo(x+d),wait(range(.6,1.2),'sniff'),walkTo(x-d),wait(range(.6,1.2),'sniff'),walkTo(x),wait(range(1,3),'observe'),fx(()=>{needs.energy-=.1;needs.curiosity-=.25;})];},
|
|
71
|
+
roll:()=>[lie(),wait(range(.7,1.5),'rest'),cmd('roll',[],'roll'),wait(range(2,5),'watch'),fx(()=>{needs.energy-=.08;needs.curiosity-=.15;})],
|
|
72
|
+
checkin:()=>[home(),sit('sit'),cmd('look',[side()],'look'),wait(range(5,10),'checkin'),fx(()=>{needs.social-=.4;})],
|
|
73
|
+
play:()=>[cmd('spin',[],'play'),wait(range(1,2),'pause'),sit('sit'),wait(range(2,4),'watch'),fx(()=>{needs.energy-=.12;needs.curiosity-=.2;})],
|
|
74
|
+
belly:()=>[cmd('belly',[range(5,9)],'belly'),wait(range(2,4),'watch'),fx(()=>{needs.energy+=.08;needs.curiosity-=.15;})],
|
|
75
|
+
sleep:()=>[cmd('sleep',[range(22,38)],'sleep'),wait(range(2,4),'recover'),fx(()=>{needs.energy+=.3;})],
|
|
63
76
|
};
|
|
64
77
|
const weights=()=>{
|
|
65
78
|
const {energy:e,social:s,curiosity:c}=needs;
|
|
66
|
-
return {rest:e<.35?6:(1-e)*1.2,watch:.8+s,observe:.6+c*.6,stroll:1.2*c*e,dash:e>.55?1.2*e*c:0
|
|
79
|
+
return {rest:e<.35?6:(1-e)*1.2,watch:.8+s,observe:.6+c*.6,stroll:1.2*c*e,dash:e>.55?1.2*e*c:0,
|
|
80
|
+
scan:.35+c*.4,patrol:e>.25?.7*c*e:0,checkin:.25+s*.7,
|
|
81
|
+
roll:episodeCooldowns.roll===0&&e>.45?.35*e:0,
|
|
82
|
+
play:episodeCooldowns.play===0&&e>.6&&typeof actor.spin==='function'?.25*e*c:0,
|
|
83
|
+
belly:episodeCooldowns.belly===0&&typeof actor.belly==='function'?.35:0,
|
|
84
|
+
sleep:episodeCooldowns.sleep===0&&typeof actor.sleep==='function'?(e<.4?3:.2):0};
|
|
67
85
|
};
|
|
68
86
|
function decide(){
|
|
69
87
|
const w=weights();if(lastEpisode)w[lastEpisode]=0;
|
|
70
88
|
const kinds=Object.keys(w),total=kinds.reduce((sum,k)=>sum+w[k],0);
|
|
71
89
|
let pick=rand()*total,kind=kinds.find(k=>(pick-=w[k])<0)??'observe';
|
|
72
90
|
lastEpisode=kind;decisions++;
|
|
91
|
+
if(kind==='roll')episodeCooldowns.roll=90;
|
|
92
|
+
if(kind==='play')episodeCooldowns.play=120;
|
|
93
|
+
if(kind==='belly')episodeCooldowns.belly=80;
|
|
94
|
+
if(kind==='sleep')episodeCooldowns.sleep=100;
|
|
73
95
|
queue=[wait(range(3,9),'pause'),...EPISODES[kind]()];
|
|
74
96
|
}
|
|
75
97
|
|
|
@@ -88,15 +110,18 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
88
110
|
fx(()=>{treat=true;}),cmd('sit',[],'treatSit',()=>!seatedAnyVariant()),
|
|
89
111
|
play('treat-eat','chew'),fx(()=>{treat=null;needs.energy+=.25;needs.social-=.3;})
|
|
90
112
|
];
|
|
113
|
+
const TUG_STEPS=()=>[
|
|
114
|
+
cmd('sit',[],'tug',unseated),cmd('tug',[6],'tug'),wait(.5,'watch'),fx(()=>{needs.energy-=.12;needs.social-=.4;})
|
|
115
|
+
];
|
|
91
116
|
|
|
92
117
|
function startInteraction(){
|
|
93
118
|
active=pending;pending=null;decisions++;hold=0;
|
|
94
|
-
queue=active==='ball'?BALL_STEPS():TREAT_STEPS();
|
|
119
|
+
queue=active==='ball'?BALL_STEPS():active==='tug'?TUG_STEPS():TREAT_STEPS();
|
|
95
120
|
}
|
|
96
121
|
function finishInteraction(){cooldowns[active]=COOLDOWN[active];active=null;}
|
|
97
122
|
|
|
98
123
|
function drift(dt){
|
|
99
|
-
const resting=holdIntent==='rest'||holdIntent==='recover';
|
|
124
|
+
const resting=holdIntent==='rest'||holdIntent==='recover'||actor.state==='sleep'||intent==='belly';
|
|
100
125
|
needs.energy+=resting?.04*dt:-.004*dt;
|
|
101
126
|
if(!active){needs.curiosity+=.01*dt;needs.social+=.008*dt;}
|
|
102
127
|
for(const k in needs)needs[k]=clamp(needs[k],0,1);
|
|
@@ -106,6 +131,7 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
106
131
|
if(typeof dt!=='number'||!Number.isFinite(dt)||dt<0)throw RangeError('dt must be a finite non-negative number');
|
|
107
132
|
dt=Math.min(dt,MAX_DT);clock+=dt;
|
|
108
133
|
for(const k in cooldowns)cooldowns[k]=Math.max(0,cooldowns[k]-dt);
|
|
134
|
+
for(const k in episodeCooldowns)episodeCooldowns[k]=Math.max(0,episodeCooldowns[k]-dt);
|
|
109
135
|
drift(dt);
|
|
110
136
|
const safe=SAFE.has(actor.state);
|
|
111
137
|
if(waiting){
|
|
@@ -133,15 +159,21 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
133
159
|
if(step.when&&!step.when())continue;
|
|
134
160
|
intent=step.intent;label=step.label;
|
|
135
161
|
if(step.hold!==undefined){hold=step.hold;holdIntent=step.intent;if(step.gesture)gesture={clip:step.gesture,duration:step.hold,elapsed:0};return;}
|
|
136
|
-
if(actor[step.cmd](...step.args)!==false)waiting={age:0,left:false};
|
|
162
|
+
if(actor[step.cmd](...(typeof step.args==='function'?step.args():step.args))!==false)waiting={age:0,left:false};
|
|
137
163
|
return;
|
|
138
164
|
}
|
|
139
165
|
}
|
|
140
166
|
|
|
141
167
|
function interact(kind){
|
|
142
|
-
if(
|
|
168
|
+
if(!['ball','treat','tug'].includes(kind))return false;
|
|
169
|
+
if(kind==='tug'&&typeof actor.tug!=='function')return false;
|
|
143
170
|
if(pending||active||cooldowns[kind]>0)return false;
|
|
144
|
-
if(kind==='treat'){
|
|
171
|
+
if(kind==='treat'||kind==='tug'){
|
|
172
|
+
pending=kind;
|
|
173
|
+
// The pet wakes through its authored recovery, not after a long sleep timer.
|
|
174
|
+
if(['sleep','belly'].includes(actor.sample(clock).state))actor.sit();
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
145
177
|
// Ball: launch now and drop obsolete controller plans; the actor's own state is left to chase.
|
|
146
178
|
active='ball';decisions++;ball={mode:'flight',start:clock};
|
|
147
179
|
queue=BALL_STEPS();hold=0;holdIntent=null;gesture=null;waiting=null;
|
|
@@ -172,8 +204,9 @@ export function createCompanionLife(actor,{seed=731,energy=.8}={}){
|
|
|
172
204
|
get report(){
|
|
173
205
|
const interaction=active??pending;
|
|
174
206
|
return {
|
|
175
|
-
intent,label:pending?`${label} · ${PENDING_LABEL[pending]}`:label,interaction,busy:interaction!==null,
|
|
176
|
-
ball:ballReport(),treat:treatReport(),
|
|
207
|
+
intent,label:pending?`${label} · ${PENDING_LABEL[pending]}`:label,episode:lastEpisode,interaction,busy:interaction!==null,
|
|
208
|
+
ball:ballReport(),treat:treatReport(),tug:actor.state==='tug'?{progress:actor.sample(clock).comfortPose?.progress??0,grip:1}:null,
|
|
209
|
+
snore:actor.state==='sleep'?((clock%3.6)/3.6):null,energy:needs.energy,decisions,cooldowns:{...cooldowns},
|
|
177
210
|
// Local hold clock only: progress freezes between updates; null outside the stationary hold.
|
|
178
211
|
gesture:gesture&&SAFE.has(actor.state)?{clip:gesture.clip,progress:clamp(gesture.elapsed/gesture.duration,0,1)}:null
|
|
179
212
|
};
|
|
@@ -7,6 +7,18 @@ export function paintCompanionObjects(pixels,width,height,projection,report,stat
|
|
|
7
7
|
// Interaction drawings already include the toy/food. Never paint a second
|
|
8
8
|
// floating ball over the baked mouth, or a biscuit through the puppy's chest.
|
|
9
9
|
if(report.gesture)return pixels;
|
|
10
|
+
// A quiet, tiny rising "z" suggests snoring. The sleeping dog itself remains
|
|
11
|
+
// the original eyes-closed source pose: no chest/body zoom or squashing.
|
|
12
|
+
if(Number.isFinite(report.snore)&&state.state==='sleep'){
|
|
13
|
+
const placement=projection.placement(state.x,state.z),side=height*placement.size,sideX=side/placement.pixelAspect;
|
|
14
|
+
const left=width*placement.x-sideX/2,top=height*placement.y-300/320*side;
|
|
15
|
+
const cycle=report.snore,tone=Math.round(140*Math.sin(Math.PI*cycle)),unit=Math.max(1,Math.round(side/160));
|
|
16
|
+
const cx=Math.round(left+220/320*sideX),cy=Math.round(top+(210-16*cycle)/320*side);
|
|
17
|
+
if(tone>12)for(const [gx,gy] of [[0,0],[1,0],[2,0],[1,1],[0,2],[1,2],[2,2]])for(let dy=0;dy<unit;dy++)for(let dx=0;dx<unit;dx++){
|
|
18
|
+
const x=cx+gx*unit+dx,y=cy+gy*unit+dy;if(x<0||x>=width||y<0||y>=height)continue;
|
|
19
|
+
const j=(y*width+x)*4;pixels[j]=pixels[j+1]=pixels[j+2]=Math.max(pixels[j],tone);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
10
22
|
if(report.ball?.carried){if(mouth&&[mouth.x,mouth.y,mouth.rx,mouth.ry].every(Number.isFinite)&&mouth.rx>0&&mouth.ry>0)objects.push({kind:'ball',screen:mouth});}
|
|
11
23
|
else if(report.ball)objects.push({...report.ball,radius:.035,kind:'ball'});
|
|
12
24
|
if(report.treat)objects.push({...report.treat,height:report.treat.height??.018,radius:.022,kind:'treat'});
|