cortico-world-agent-speed 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/activity.js +44 -0
- package/index.js +127 -0
- package/package.json +12 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zoefix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Speed World for Coopanion / Cortico
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Cortico World that reads the local Agent Speed activity snapshot and sends activity changes through the standard World event mechanism. No modified Coopanion host is required. The bot decides how to react; an event does not guarantee a particular animation or response.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- macOS or Windows, with Agent Speed and Coopanion running under the same user account.
|
|
8
|
+
- An Agent Speed desktop build that supports **Settings → General → Share activity with local extensions**. This feature is not present in older desktop releases; installing this World alone cannot add it. Use a desktop version containing the feature and enable the setting. If no such version has been published yet, a build containing the feature is required.
|
|
9
|
+
- A Cortico-compatible host supporting World extension API 6 and a configured model if you want the bot to respond to events.
|
|
10
|
+
|
|
11
|
+
## Install and enable
|
|
12
|
+
|
|
13
|
+
This package has not necessarily been published; the npm and market steps below work only after `cortico-world-agent-speed` is actually published to the npm registry configured in the host. No publication is performed by this repository.
|
|
14
|
+
|
|
15
|
+
1. Open Agent Speed, enable **Settings → General → Share activity with local extensions**, and keep Agent Speed running.
|
|
16
|
+
2. In the Coopanion/Cortico console, open **Extensions → World**, search for `cortico-world-agent-speed`, and install it. If search has not indexed it yet, use manual npm installation and enter the same package name. Alternatively, use **manual install → local directory** and select this plugin directory.
|
|
17
|
+
3. Restart the Coo process from the Extensions page so the package is loaded. In **Modules**, find **Agent Speed** and enable the World.
|
|
18
|
+
4. Generate activity in an agent monitored by Agent Speed. The World reads the snapshot while enabled. If sharing is disabled, the app is closed, or the snapshot is stale or incomplete, activity may be unavailable rather than idle.
|
|
19
|
+
|
|
20
|
+
The official market searches the configured npm registry for packages with the `cortico-world` keyword. Its separate [official index](https://github.com/Pal-AI-Lab/cortico-extensions) supplies tags and other listing details; it is refreshed on a schedule. After publication, a `[sync] cortico-world-agent-speed` issue in that index repository can request an immediate refresh. A package can be manually installed by name without waiting for market search indexing. Network access and registry configuration still apply.
|
|
21
|
+
|
|
22
|
+
## Privacy and model cost
|
|
23
|
+
|
|
24
|
+
The snapshot is local to your account. It contains aggregate generating and tool-running agent counts, output speed, completeness and a timestamp, including connected remote sources; it does not contain session text. The World sends activity-state events to Cortico, so the configured model provider may receive those event descriptions as part of the conversation. Events can wake the bot and cause model calls and token charges; the amount depends on activity, host behavior and provider pricing. Disable the World to stop its events, or turn off activity sharing in Agent Speed to stop publishing the snapshot.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT; see [LICENSE](LICENSE).
|
package/activity.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// A snapshot is a heartbeat, not an event. Sampling the same file twice must not
|
|
2
|
+
// confirm a transition. Silence, clock skew and incomplete remote data are not idle.
|
|
3
|
+
const TTL_MS = 5000;
|
|
4
|
+
const HOLD_MS = 1200;
|
|
5
|
+
|
|
6
|
+
export function createActivityTracker() {
|
|
7
|
+
let busy = false;
|
|
8
|
+
let state = 'unknown';
|
|
9
|
+
let since = null;
|
|
10
|
+
let candidate = null;
|
|
11
|
+
let previous = -Infinity;
|
|
12
|
+
|
|
13
|
+
return (s, now) => {
|
|
14
|
+
const count = n => Number.isSafeInteger(n) && n >= 0;
|
|
15
|
+
if (s?.version !== 1 || !count(s.updatedAtMs) || s.updatedAtMs > now ||
|
|
16
|
+
now - s.updatedAtMs > TTL_MS || !count(s.generating) || !count(s.tools) ||
|
|
17
|
+
!Number.isFinite(s.outputPerSecond) || s.outputPerSecond < 0 || typeof s.complete !== 'boolean') {
|
|
18
|
+
busy = false;
|
|
19
|
+
since = candidate = null;
|
|
20
|
+
previous = -Infinity;
|
|
21
|
+
return state = 'unknown';
|
|
22
|
+
}
|
|
23
|
+
if (s.updatedAtMs <= previous) return state;
|
|
24
|
+
previous = s.updatedAtMs;
|
|
25
|
+
const desired = s.generating ? (s.outputPerSecond >= (state === 'fast' ? 65 : 80) ? 'fast' : 'working')
|
|
26
|
+
: s.tools ? 'tools' : s.complete ? 'idle' : 'unknown';
|
|
27
|
+
if (desired !== candidate) {
|
|
28
|
+
candidate = desired;
|
|
29
|
+
since = previous;
|
|
30
|
+
}
|
|
31
|
+
if (desired === 'unknown') {
|
|
32
|
+
busy = false;
|
|
33
|
+
return state = 'unknown';
|
|
34
|
+
}
|
|
35
|
+
if (desired === 'idle') {
|
|
36
|
+
if (busy && previous - since < HOLD_MS) return state;
|
|
37
|
+
const next = busy ? 'settled' : 'idle';
|
|
38
|
+
busy = false;
|
|
39
|
+
return state = next;
|
|
40
|
+
}
|
|
41
|
+
busy = true;
|
|
42
|
+
return state = desired === 'fast' && previous - since < HOLD_MS ? 'working' : desired;
|
|
43
|
+
};
|
|
44
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { isAbsolute, join } from 'node:path';
|
|
4
|
+
import { createActivityTracker } from './activity.js';
|
|
5
|
+
|
|
6
|
+
const ID = 'agent-speed';
|
|
7
|
+
const POLL_MS = 1000;
|
|
8
|
+
const WAKE_INTERVAL_MS = 30_000;
|
|
9
|
+
const FRESH_MS = 5_000;
|
|
10
|
+
const EVENT_TYPE = 'agent-speed.activity';
|
|
11
|
+
|
|
12
|
+
function defaultSnapshotPath() {
|
|
13
|
+
if (process.platform === 'darwin') {
|
|
14
|
+
return join(homedir(), 'Library', 'Application Support', 'AgentSpeed', 'activity-v1.json');
|
|
15
|
+
}
|
|
16
|
+
if (process.platform === 'win32') {
|
|
17
|
+
const directory = process.env.LOCALAPPDATA;
|
|
18
|
+
return join(directory && isAbsolute(directory) ? directory : join(homedir(), 'AppData', 'Local'), 'AgentSpeed', 'activity-v1.json');
|
|
19
|
+
}
|
|
20
|
+
throw new Error('Agent Speed activity snapshots are supported on macOS and Windows only.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The World suggests an action through the ordinary event stream. The Bot owns
|
|
24
|
+
// the decision and the desktop-pet World owns the action vocabulary.
|
|
25
|
+
export function createAgentSpeedDefinition({ snapshotPath } = {}) {
|
|
26
|
+
return {
|
|
27
|
+
id: ID,
|
|
28
|
+
label: 'Agent Speed',
|
|
29
|
+
defaults: () => ({ enabled: false }),
|
|
30
|
+
describe: {
|
|
31
|
+
tools: [],
|
|
32
|
+
events: [{ type: EVENT_TYPE, description: 'A recent Agent Speed activity change suggesting a silent pet action.', trigger: 'debounce', tags: ['snapshot'] }],
|
|
33
|
+
},
|
|
34
|
+
create() {
|
|
35
|
+
let generation = 0;
|
|
36
|
+
let timer;
|
|
37
|
+
let tracker;
|
|
38
|
+
let candidate = null;
|
|
39
|
+
let snapshotTime = 0;
|
|
40
|
+
let settledTime = 0;
|
|
41
|
+
let lastQueued = null;
|
|
42
|
+
let lastWake = -Infinity;
|
|
43
|
+
let ticket = 0;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
id: ID,
|
|
47
|
+
envPromptVars: () => null,
|
|
48
|
+
tools: () => [],
|
|
49
|
+
async start(host) {
|
|
50
|
+
const path = snapshotPath ?? defaultSnapshotPath();
|
|
51
|
+
const current = ++generation;
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
tracker = createActivityTracker();
|
|
54
|
+
candidate = lastQueued = null;
|
|
55
|
+
snapshotTime = settledTime = 0;
|
|
56
|
+
lastWake = -Infinity;
|
|
57
|
+
ticket++;
|
|
58
|
+
|
|
59
|
+
const poll = async () => {
|
|
60
|
+
let snapshot = null;
|
|
61
|
+
try {
|
|
62
|
+
snapshot = JSON.parse(await readFile(path, 'utf8'));
|
|
63
|
+
} catch {
|
|
64
|
+
// Missing, unreadable and malformed snapshots all mean unknown.
|
|
65
|
+
}
|
|
66
|
+
if (current !== generation) return;
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
const state = tracker(snapshot, now);
|
|
69
|
+
snapshotTime = state === 'unknown' ? 0 : snapshot.updatedAtMs;
|
|
70
|
+
if (state === 'settled') {
|
|
71
|
+
candidate = 'settled';
|
|
72
|
+
settledTime = now;
|
|
73
|
+
} else if (state === 'idle' && candidate === 'settled' && now - settledTime <= FRESH_MS) {
|
|
74
|
+
// Keep a newly confirmed completion briefly across idle heartbeats.
|
|
75
|
+
} else {
|
|
76
|
+
candidate = state === 'working' || state === 'fast' || state === 'tools' ? state : null;
|
|
77
|
+
}
|
|
78
|
+
// An idle or unavailable interval ends the previous activity episode.
|
|
79
|
+
if (!candidate) lastQueued = null;
|
|
80
|
+
|
|
81
|
+
if (candidate && candidate !== lastQueued && performance.now() - lastWake >= WAKE_INTERVAL_MS) {
|
|
82
|
+
lastWake = performance.now();
|
|
83
|
+
lastQueued = candidate;
|
|
84
|
+
const queued = ++ticket;
|
|
85
|
+
host.pushDeferred({
|
|
86
|
+
type: EVENT_TYPE,
|
|
87
|
+
tags: ['snapshot'],
|
|
88
|
+
render: () => {
|
|
89
|
+
const age = Date.now() - snapshotTime;
|
|
90
|
+
if (current !== generation || queued !== ticket || !candidate || age < 0 || age > FRESH_MS ||
|
|
91
|
+
(candidate === 'settled' && Date.now() - settledTime > FRESH_MS)) return null;
|
|
92
|
+
lastQueued = candidate;
|
|
93
|
+
const descriptions = {
|
|
94
|
+
working: 'The agent is generating output.',
|
|
95
|
+
fast: 'The agent is generating output quickly.',
|
|
96
|
+
tools: 'The agent is using tools.',
|
|
97
|
+
settled: 'The agent has finished its activity and is now idle.',
|
|
98
|
+
};
|
|
99
|
+
return `[Agent Speed] ${descriptions[candidate]} If appropriate, use pet_act for a silent action matching this activity; choose from your current figure's vocabulary. Do not speak merely because of this update.`;
|
|
100
|
+
},
|
|
101
|
+
}, { trigger: 'debounce' });
|
|
102
|
+
}
|
|
103
|
+
if (current === generation) {
|
|
104
|
+
timer = setTimeout(() => {
|
|
105
|
+
poll().catch((error) => {
|
|
106
|
+
if (current !== generation) return;
|
|
107
|
+
generation++;
|
|
108
|
+
host.log.error({ err: error }, 'Agent Speed polling failed');
|
|
109
|
+
});
|
|
110
|
+
}, POLL_MS);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
await poll();
|
|
114
|
+
},
|
|
115
|
+
async stop() {
|
|
116
|
+
generation++;
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
timer = undefined;
|
|
119
|
+
candidate = null;
|
|
120
|
+
tracker = undefined;
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default createAgentSpeedDefinition();
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-agent-speed",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Agent Speed activity events for Cortico and Coopanion",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"exports": "./index.js",
|
|
8
|
+
"files": ["index.js", "activity.js", "README.md", "LICENSE"],
|
|
9
|
+
"keywords": ["cortico-world", "cortico", "agent-speed"],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"os": ["darwin", "win32"],
|
|
12
|
+
"engines": { "node": ">=22" },
|
|
13
|
+
"cortico": { "kind": "world", "api": 6, "displayName": "Agent Speed", "tags": ["apps", "external-setup", "experimental"] }
|
|
14
|
+
}
|