@omnivoice/page-agent 0.5.0 → 0.6.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/README.md +50 -0
- package/dist/esm/brain-extension-DDuKTYrJ.js +2192 -0
- package/dist/esm/brain-extension-DDuKTYrJ.js.map +1 -0
- package/dist/esm/debug-extension-D0P_sNkc.js +45 -0
- package/dist/esm/debug-extension-D0P_sNkc.js.map +1 -0
- package/dist/esm/page-agent.d.ts +126 -2
- package/dist/esm/page-agent.js +91 -4
- package/dist/esm/page-agent.js.map +1 -1
- package/dist/esm/profiler-CcdRV96d.js +203 -0
- package/dist/esm/profiler-CcdRV96d.js.map +1 -0
- package/dist/iife/page-agent.demo.js +63 -40
- package/package.json +4 -2
- package/server/agent-gateway.mjs +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnivoice/page-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "GUI agent for web applications - add intelligent automation to any webpage with a single script, with an optional realtime voice module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"test:consumer": "node scripts/verify-consumer.mjs",
|
|
66
66
|
"test:voice": "node --experimental-strip-types --no-warnings --test tests/voice/core.test.ts tests/voice/realtime-engine.test.ts && tsc -p tests/voice/tsconfig.json",
|
|
67
67
|
"test:voice-browser": "node --experimental-strip-types --no-warnings --test tests/voice/browser-audio.test.ts",
|
|
68
|
+
"test:brain": "node --experimental-strip-types --no-warnings --test tests/brain/policy.test.ts && tsc -p tests/brain/tsconfig.json",
|
|
69
|
+
"test:brain-e2e": "node --experimental-strip-types --no-warnings --test tests/brain/e2e.test.ts && tsc -p tests/brain/tsconfig.json",
|
|
68
70
|
"prepack": "node scripts/build-package.mjs && node scripts/verify-package.mjs",
|
|
69
71
|
"prepublishOnly": "node scripts/build-package.mjs && node scripts/verify-package.mjs --release",
|
|
70
72
|
"dev": "vite --host 127.0.0.1",
|
|
@@ -92,7 +94,7 @@
|
|
|
92
94
|
"test:vendor-wiring": "node scripts/verify-vendor-wiring.mjs",
|
|
93
95
|
"test:fork": "node scripts/verify-fork-customizations.mjs",
|
|
94
96
|
"test:vendor-bundle": "node scripts/verify-vendor-bundle.mjs",
|
|
95
|
-
"test:all": "npm run test:vendor-provenance && npm run test:vendor && npm run test:vendor-wiring && npm run test:vendor-bundle && npm run test:fork && npm run test:contract && npm run test:session && npm run test:surface && npm run test:guard && npm run test:routine && npm run test:runner && npm run test:compactor && npm run test:condition && npm run test:record && npm run test:espera && npm run test:chess && npm run test:schemas && npm run test:gateway && npm run test:voice",
|
|
97
|
+
"test:all": "npm run test:vendor-provenance && npm run test:vendor && npm run test:vendor-wiring && npm run test:vendor-bundle && npm run test:fork && npm run test:contract && npm run test:session && npm run test:surface && npm run test:guard && npm run test:routine && npm run test:runner && npm run test:compactor && npm run test:condition && npm run test:record && npm run test:espera && npm run test:chess && npm run test:schemas && npm run test:gateway && npm run test:voice && npm run test:brain && npm run build:package && npm run test:consumer && npm run test:voice-browser && npm run test:brain-e2e",
|
|
96
98
|
"test:gateway": "node scripts/verify-agent-gateway.mjs"
|
|
97
99
|
},
|
|
98
100
|
"dependencies": {
|
package/server/agent-gateway.mjs
CHANGED
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
* AGENT_VOICE_INPUT true/false — permite ditado no widget (default true)
|
|
17
17
|
* AGENT_VOICE_OUTPUT true/false — agente fala o resultado (default false)
|
|
18
18
|
* AGENT_VOICE_LANG Idioma da voz (default = AGENT_LANGUAGE)
|
|
19
|
+
* AGENT_INSTRUCTIONS Texto de instruções de sistema enviado ao widget em /config (opcional; até 8 KB).
|
|
20
|
+
* Serve p/ regras como somente-leitura ou antirrepetição. Campo `instructions` (string) no JSON.
|
|
21
|
+
* AGENT_BRAIN on/off — pede ao widget que ligue o segundo cérebro (default off). O gateway só
|
|
22
|
+
* repassa o sinal; quem o implementa é o widget. Campo `brain` no JSON.
|
|
23
|
+
* AGENT_DEBUG on/off — pede ao widget que registre o diagnóstico por passo (default off).
|
|
24
|
+
* Campo `debug` no JSON.
|
|
19
25
|
* AGENT_PORT Porta do gateway (default 8790)
|
|
20
26
|
* AGENT_HOST Bind (default 127.0.0.1 — local; use 0.0.0.0 só atrás de proxy seguro)
|
|
21
27
|
* AGENT_CONFIG Caminho p/ um agent.config.json com os mesmos campos (case-insensitive).
|
|
@@ -58,6 +64,9 @@ function envBool(v, def) {
|
|
|
58
64
|
return ['1', 'true', 'yes', 'on'].includes(String(v).toLowerCase())
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
// Limite do texto de instruções: vai em TODA resposta de /config e entra no prompt do modelo.
|
|
68
|
+
const MAX_INSTRUCTIONS_BYTES = 8 * 1024
|
|
69
|
+
|
|
61
70
|
const fileCfg = loadFileConfig()
|
|
62
71
|
const pick = (envKey, fileKey, def) => {
|
|
63
72
|
const fromEnv = process.env[envKey]
|
|
@@ -67,6 +76,23 @@ const pick = (envKey, fileKey, def) => {
|
|
|
67
76
|
return def
|
|
68
77
|
}
|
|
69
78
|
|
|
79
|
+
// Instruções de sistema opcionais. Só texto: um valor que não é string é ignorado com aviso, e o que
|
|
80
|
+
// passa do limite derruba o start (melhor falhar alto que cortar uma regra de segurança pela metade).
|
|
81
|
+
function readInstructions() {
|
|
82
|
+
const raw = pick('AGENT_INSTRUCTIONS', 'instructions', '')
|
|
83
|
+
if (typeof raw !== 'string') {
|
|
84
|
+
console.warn('[gateway] `instructions` deve ser texto; valor ignorado')
|
|
85
|
+
return ''
|
|
86
|
+
}
|
|
87
|
+
const text = raw.trim()
|
|
88
|
+
const bytes = Buffer.byteLength(text, 'utf8')
|
|
89
|
+
if (bytes > MAX_INSTRUCTIONS_BYTES) {
|
|
90
|
+
console.error(`[gateway] AGENT_INSTRUCTIONS tem ${bytes} bytes; o limite é ${MAX_INSTRUCTIONS_BYTES}`)
|
|
91
|
+
process.exit(1)
|
|
92
|
+
}
|
|
93
|
+
return text
|
|
94
|
+
}
|
|
95
|
+
|
|
70
96
|
const config = {
|
|
71
97
|
baseURL: String(pick('AGENT_BASE_URL', 'baseURL', '')).replace(/\/+$/, ''),
|
|
72
98
|
apiKey: String(pick('AGENT_API_KEY', 'apiKey', '')),
|
|
@@ -79,6 +105,9 @@ const config = {
|
|
|
79
105
|
lang: String(pick('AGENT_VOICE_LANG', 'voiceLang', '')) || undefined,
|
|
80
106
|
},
|
|
81
107
|
promptForNextTask: envBool(pick('AGENT_PROMPT_NEXT', 'promptForNextTask', 'true'), true),
|
|
108
|
+
instructions: readInstructions(),
|
|
109
|
+
brain: envBool(pick('AGENT_BRAIN', 'brain', 'false'), false),
|
|
110
|
+
debug: envBool(pick('AGENT_DEBUG', 'debug', 'false'), false),
|
|
82
111
|
port: Number(pick('AGENT_PORT', 'port', 8790)) || 8790,
|
|
83
112
|
host: String(pick('AGENT_HOST', 'host', '127.0.0.1')),
|
|
84
113
|
}
|
|
@@ -107,6 +136,9 @@ function publicConfig() {
|
|
|
107
136
|
output: config.voice.output,
|
|
108
137
|
...(config.voice.lang && { lang: config.voice.lang }),
|
|
109
138
|
},
|
|
139
|
+
brain: config.brain,
|
|
140
|
+
debug: config.debug,
|
|
141
|
+
...(config.instructions && { instructions: { system: config.instructions } }),
|
|
110
142
|
}
|
|
111
143
|
}
|
|
112
144
|
|
|
@@ -210,6 +242,7 @@ const server = createServer(async (req, res) => {
|
|
|
210
242
|
server.listen(config.port, config.host, () => {
|
|
211
243
|
console.log(`[gateway] agente ouvindo em http://${config.host}:${config.port}`)
|
|
212
244
|
console.log(`[gateway] model=${config.model} language=${config.language} voice=${JSON.stringify(config.voice)}`)
|
|
245
|
+
console.log(`[gateway] brain=${config.brain} debug=${config.debug} instructions=${config.instructions ? `${Buffer.byteLength(config.instructions, 'utf8')} bytes` : 'não'}`)
|
|
213
246
|
console.log(`[gateway] chave configurada: ${config.apiKey ? 'sim (mantida no servidor)' : 'NÃO — defina AGENT_API_KEY'}`)
|
|
214
247
|
console.log(`[gateway] upstream: ${config.baseURL || '(não definido)'}`)
|
|
215
248
|
})
|