nova-personal-agent-server 0.4.0 → 1.0.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/LICENSE +674 -201
- package/README.md +12 -2
- package/bin/nova-space-host.mjs +4 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/cli.js +71 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/client.js +340 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/crypto.js +167 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/live.js +169 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/mailbox.js +217 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/media.js +320 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/pairing.js +13 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/protocol.js +50 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/security.js +305 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/server.js +477 -0
- package/node_modules/@nova-personal-agent/relay/dist/src/source-address.js +58 -0
- package/node_modules/@nova-personal-agent/relay/package.json +1 -0
- package/package.json +13 -6
- package/runtime/dist/src/cascaded-text-provider.js +8 -3
- package/runtime/dist/src/composition/assembly.js +133 -35
- package/runtime/dist/src/composition/cascaded-realtime-assembly.js +114 -59
- package/runtime/dist/src/composition/production-composition.js +57 -21
- package/runtime/dist/src/composition/realtime-assembly.js +160 -52
- package/runtime/dist/src/composition/soul-context.js +22 -0
- package/runtime/dist/src/config/capability-registry.js +48 -3
- package/runtime/dist/src/config/cascaded-realtime-config.js +23 -10
- package/runtime/dist/src/config/config.js +541 -128
- package/runtime/dist/src/config/credential-rotation.js +26 -0
- package/runtime/dist/src/config/data-root.js +764 -0
- package/runtime/dist/src/config/diagnostics.js +3 -1
- package/runtime/dist/src/config/environment-contract.js +190 -188
- package/runtime/dist/src/config/model-routes.js +140 -0
- package/runtime/dist/src/config/voice-credentials.js +55 -0
- package/runtime/dist/src/connectors/composio/index.js +9 -0
- package/runtime/dist/src/connectors/feishu/index.js +258 -44
- package/runtime/dist/src/connectors/macos/mail.js +7 -3
- package/runtime/dist/src/connectors/macos/reader.js +3 -1
- package/runtime/dist/src/conversation-voice-provider.js +5 -2
- package/runtime/dist/src/core/causal-runtime.js +38 -3
- package/runtime/dist/src/core/context-view.js +7 -0
- package/runtime/dist/src/core/guards.js +32 -0
- package/runtime/dist/src/core/runtime.js +3 -0
- package/runtime/dist/src/core/schedule-tools.js +2 -2
- package/runtime/dist/src/core/source-processing-instructions.js +2 -2
- package/runtime/dist/src/core/source-processing-tools.js +3 -1
- package/runtime/dist/src/core/tool-schema.js +42 -7
- package/runtime/dist/src/desktop/desktop-camera.js +3 -5
- package/runtime/dist/src/desktop/desktop-control.js +41 -8
- package/runtime/dist/src/desktop/desktop-session.js +90 -19
- package/runtime/dist/src/desktop/desktop-wire.js +5 -7
- package/runtime/dist/src/desktop/startup-error.js +18 -16
- package/runtime/dist/src/desktop/workbench-acceptance.js +52 -14
- package/runtime/dist/src/desktop-entry.js +6 -2
- package/runtime/dist/src/desktop.js +5 -1
- package/runtime/dist/src/device/attempt.js +65 -0
- package/runtime/dist/src/device/authority.js +159 -0
- package/runtime/dist/src/device/gateway.js +87 -0
- package/runtime/dist/src/device/ledger.js +91 -0
- package/runtime/dist/src/device/ownership.js +92 -0
- package/runtime/dist/src/device/port.js +2 -0
- package/runtime/dist/src/device/schedule-ownership.js +103 -0
- package/runtime/dist/src/executors/acp/transport.js +2 -0
- package/runtime/dist/src/executors/browser.js +4 -3
- package/runtime/dist/src/executors/codex/adapter-project.js +58 -12
- package/runtime/dist/src/executors/codex/app-server-schema.js +12 -21
- package/runtime/dist/src/executors/codex/app-server-transport.js +32 -18
- package/runtime/dist/src/executors/codex/common.js +1 -1
- package/runtime/dist/src/executors/codex/contract.js +12 -16
- package/runtime/dist/src/executors/codex/credential-snapshot.js +1 -9
- package/runtime/dist/src/executors/codex/factory.js +54 -32
- package/runtime/dist/src/executors/codex/host-config.js +69 -20
- package/runtime/dist/src/executors/codex/launch-profile.js +3 -2
- package/runtime/dist/src/executors/codex/local-provider-credential.js +39 -0
- package/runtime/dist/src/executors/codex/process-owner.js +4 -6
- package/runtime/dist/src/executors/codex/production-host.js +33 -34
- package/runtime/dist/src/executors/codex/protocol.js +9 -14
- package/runtime/dist/src/executors/codex/session-title.js +6 -8
- package/runtime/dist/src/executors/codex/spawn-env.js +27 -6
- package/runtime/dist/src/executors/codex/turn-projection.js +12 -17
- package/runtime/dist/src/executors/codex/windows-guardian.js +4 -6
- package/runtime/dist/src/executors/coding/intake.js +12 -7
- package/runtime/dist/src/executors/computer-backend.js +18 -10
- package/runtime/dist/src/executors/computer-config.js +32 -0
- package/runtime/dist/src/executors/computer-device.js +68 -16
- package/runtime/dist/src/executors/computer-worker.js +18 -6
- package/runtime/dist/src/executors/computer.js +29 -56
- package/runtime/dist/src/executors/device-lock.js +14 -5
- package/runtime/dist/src/executors/gui-execution.js +2 -0
- package/runtime/dist/src/executors/index.js +0 -1
- package/runtime/dist/src/executors/mobile.js +9 -8
- package/runtime/dist/src/executors/native-process.js +4 -0
- package/runtime/dist/src/executors/search.js +3 -5
- package/runtime/dist/src/executors/task-resources.js +21 -0
- package/runtime/dist/src/executors/watcher.js +2 -4
- package/runtime/dist/src/experience/host.js +179 -0
- package/runtime/dist/src/index.js +2 -0
- package/runtime/dist/src/knowledge/assembly.js +3 -4
- package/runtime/dist/src/knowledge/embeddings.js +50 -34
- package/runtime/dist/src/knowledge/service.js +1 -0
- package/runtime/dist/src/knowledge/store-client.js +1 -6
- package/runtime/dist/src/knowledge/store-worker.js +1 -3
- package/runtime/dist/src/mem0/resource.js +25 -0
- package/runtime/dist/src/mem0/store-worker.js +234 -21
- package/runtime/dist/src/memory/consumer.js +31 -0
- package/runtime/dist/src/memory/engine-worker.js +210 -0
- package/runtime/dist/src/memory/entry.js +8 -1
- package/runtime/dist/src/memory/explicit-memory.js +20 -0
- package/runtime/dist/src/memory/factory.js +30 -15
- package/runtime/dist/src/memory/grounded-voicemem.js +10 -0
- package/runtime/dist/src/memory/ledger-recall-engine.js +86 -0
- package/runtime/dist/src/memory/prerecall-port.js +27 -0
- package/runtime/dist/src/memory/prerecall.js +1 -1
- package/runtime/dist/src/memory/production-engine.js +151 -0
- package/runtime/dist/src/memory/provenance.js +1 -0
- package/runtime/dist/src/memory/remote-personal-memory.js +3 -1
- package/runtime/dist/src/memory/retrieval.js +107 -22
- package/runtime/dist/src/memory/sensitivity.js +6 -2
- package/runtime/dist/src/memory/source-retrieval.js +11 -0
- package/runtime/dist/src/memory/tool-capabilities.js +46 -0
- package/runtime/dist/src/memory/voicemem-sdk/LICENSE +202 -0
- package/runtime/dist/src/memory/voicemem-sdk/NOTICE.md +97 -0
- package/runtime/dist/src/memory/voicemem-sdk/PATCH-NOTICE.md +23 -0
- package/runtime/dist/src/memory/voicemem-sdk/archive.js +12 -0
- package/runtime/dist/src/memory/voicemem-sdk/audio.js +111 -0
- package/runtime/dist/src/memory/voicemem-sdk/barge-in.js +59 -0
- package/runtime/dist/src/memory/voicemem-sdk/checkpoint.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/cleanup.js +139 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-asr.js +254 -0
- package/runtime/dist/src/memory/voicemem-sdk/dashscope-tts.js +247 -0
- package/runtime/dist/src/memory/voicemem-sdk/evaluation.js +330 -0
- package/runtime/dist/src/memory/voicemem-sdk/extraction.js +220 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune-data.js +115 -0
- package/runtime/dist/src/memory/voicemem-sdk/finetune.js +170 -0
- package/runtime/dist/src/memory/voicemem-sdk/grounded-reply-preferences.js +81 -0
- package/runtime/dist/src/memory/voicemem-sdk/index.js +22 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-embedding.js +164 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-runtime.js +53 -0
- package/runtime/dist/src/memory/voicemem-sdk/local-speaker.js +240 -0
- package/runtime/dist/src/memory/voicemem-sdk/memory.js +767 -0
- package/runtime/dist/src/memory/voicemem-sdk/model-json.js +14 -0
- package/runtime/dist/src/memory/voicemem-sdk/personamem.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/addenda.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/additive-extraction.js +478 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/index.js +32 -0
- package/runtime/dist/src/memory/voicemem-sdk/prompts/update-memory.js +152 -0
- package/runtime/dist/src/memory/voicemem-sdk/providers.js +325 -0
- package/runtime/dist/src/memory/voicemem-sdk/ranking.js +65 -0
- package/runtime/dist/src/memory/voicemem-sdk/reaction.js +33 -0
- package/runtime/dist/src/memory/voicemem-sdk/realtime.js +215 -0
- package/runtime/dist/src/memory/voicemem-sdk/reply.js +68 -0
- package/runtime/dist/src/memory/voicemem-sdk/routing.js +209 -0
- package/runtime/dist/src/memory/voicemem-sdk/slots.js +61 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-bindings.js +120 -0
- package/runtime/dist/src/memory/voicemem-sdk/speaker-profiles.js +327 -0
- package/runtime/dist/src/memory/voicemem-sdk/store.js +577 -0
- package/runtime/dist/src/memory/voicemem-sdk/stream.js +317 -0
- package/runtime/dist/src/memory/voicemem-sdk/subgraph.js +113 -0
- package/runtime/dist/src/memory/voicemem-sdk/summaries.js +56 -0
- package/runtime/dist/src/memory/voicemem-sdk/time.js +157 -0
- package/runtime/dist/src/memory/voicemem-sdk/types.js +2 -0
- package/runtime/dist/src/memory-ledger/store-client.js +235 -37
- package/runtime/dist/src/memory-ledger/store-worker.js +8 -5
- package/runtime/dist/src/memory-ledger/store.js +91 -1
- package/runtime/dist/src/memory-substrate/consolidation.js +23 -7
- package/runtime/dist/src/memory-substrate/diary.js +27 -0
- package/runtime/dist/src/memory-substrate/engine-outbox.js +107 -0
- package/runtime/dist/src/memory-substrate/explicit-memory.js +112 -0
- package/runtime/dist/src/memory-substrate/fact-fidelity.js +68 -0
- package/runtime/dist/src/memory-substrate/feishu-consent.js +41 -0
- package/runtime/dist/src/memory-substrate/file-authority.js +29 -6
- package/runtime/dist/src/memory-substrate/life-operations.js +35 -9
- package/runtime/dist/src/memory-substrate/markdown-repository.js +271 -65
- package/runtime/dist/src/memory-substrate/memory-documents.js +96 -0
- package/runtime/dist/src/memory-substrate/migration.js +2 -0
- package/runtime/dist/src/memory-substrate/purge.js +12 -2
- package/runtime/dist/src/memory-substrate/resource.js +514 -129
- package/runtime/dist/src/memory-substrate/retrieval.js +8 -5
- package/runtime/dist/src/memory-substrate/source-operations.js +9 -1
- package/runtime/dist/src/memory-substrate/source-processing.js +436 -40
- package/runtime/dist/src/memory-substrate/source-retrieval.js +28 -0
- package/runtime/dist/src/memory-substrate/source-state.js +8 -0
- package/runtime/dist/src/memory-substrate/space-source-input.js +90 -0
- package/runtime/dist/src/memory-substrate/store.js +125 -23
- package/runtime/dist/src/model/goal-checkin-writer.js +72 -0
- package/runtime/dist/src/model/goal-writer.js +80 -0
- package/runtime/dist/src/model/jev-client.js +24 -13
- package/runtime/dist/src/model/model-adapters.js +2 -3
- package/runtime/dist/src/model/model-catalog.js +80 -0
- package/runtime/dist/src/model/model-gateway.js +47 -18
- package/runtime/dist/src/model/model-purpose.js +3 -4
- package/runtime/dist/src/model/personal-writer.js +536 -44
- package/runtime/dist/src/model/proactivity.js +50 -6
- package/runtime/dist/src/model/responses-model-gateway.js +59 -0
- package/runtime/dist/src/model/task-verifier.js +3 -3
- package/runtime/dist/src/model/timeline-anchors.js +77 -0
- package/runtime/dist/src/model/timeline-perspective.js +13 -0
- package/runtime/dist/src/model/timeline-selection.js +182 -0
- package/runtime/dist/src/model/understanding-writer.js +27 -0
- package/runtime/dist/src/model/vision-capability.js +3 -1
- package/runtime/dist/src/model/workbench-writer.js +96 -0
- package/runtime/dist/src/news/feeds.js +6 -10
- package/runtime/dist/src/news/interests.js +23 -0
- package/runtime/dist/src/news/service.js +87 -31
- package/runtime/dist/src/news/sources.json +116 -0
- package/runtime/dist/src/notifications/adapters/space-relay.js +4 -0
- package/runtime/dist/src/notifications/content.js +41 -0
- package/runtime/dist/src/notifications/contracts.js +4 -2
- package/runtime/dist/src/notifications/feed.js +6 -2
- package/runtime/dist/src/notifications/service.js +27 -14
- package/runtime/dist/src/notifications/store.js +3 -1
- package/runtime/dist/src/personal-agent/app-context.js +39 -4
- package/runtime/dist/src/personal-agent/chat-failure.js +37 -0
- package/runtime/dist/src/personal-agent/computer-use/contract.js +42 -0
- package/runtime/dist/src/personal-agent/computer-use/session.js +280 -0
- package/runtime/dist/src/personal-agent/computer-use/skill.js +18 -0
- package/runtime/dist/src/personal-agent/computer-use/tools.js +15 -0
- package/runtime/dist/src/personal-agent/context-candidates.js +9 -13
- package/runtime/dist/src/personal-agent/context-dependencies.js +28 -0
- package/runtime/dist/src/personal-agent/contracts.js +24 -4
- package/runtime/dist/src/personal-agent/conversation-runtime.js +440 -42
- package/runtime/dist/src/personal-agent/conversation-tool-bridge.js +97 -0
- package/runtime/dist/src/personal-agent/conversation-tool-policy.js +22 -0
- package/runtime/dist/src/personal-agent/conversations.js +71 -15
- package/runtime/dist/src/personal-agent/daily-brief.js +5 -0
- package/runtime/dist/src/personal-agent/daily-workbench.js +558 -0
- package/runtime/dist/src/personal-agent/discovery-window.js +36 -0
- package/runtime/dist/src/personal-agent/goal-checkin.js +53 -0
- package/runtime/dist/src/personal-agent/host.js +2379 -223
- package/runtime/dist/src/personal-agent/identity-context.js +33 -0
- package/runtime/dist/src/personal-agent/life.js +129 -11
- package/runtime/dist/src/personal-agent/local-shell.js +181 -0
- package/runtime/dist/src/personal-agent/local-tools.js +234 -0
- package/runtime/dist/src/personal-agent/preferred-name-sync.js +35 -0
- package/runtime/dist/src/personal-agent/profile-warmup.js +100 -39
- package/runtime/dist/src/personal-agent/project-digests.js +7 -3
- package/runtime/dist/src/personal-agent/project-history.js +36 -0
- package/runtime/dist/src/personal-agent/reading-copies.js +183 -0
- package/runtime/dist/src/personal-agent/scheduled-tasks.js +50 -13
- package/runtime/dist/src/personal-agent/scheduled-tool-runtime.js +26 -10
- package/runtime/dist/src/personal-agent/source-processing-agent.js +239 -17
- package/runtime/dist/src/personal-agent/sources.js +9 -1
- package/runtime/dist/src/personal-agent/store.js +124 -14
- package/runtime/dist/src/personal-agent/task-loop.js +3 -0
- package/runtime/dist/src/personal-agent/tasks.js +16 -4
- package/runtime/dist/src/personal-agent/timeline-brief.js +462 -0
- package/runtime/dist/src/personal-agent/timeline-cache.js +191 -0
- package/runtime/dist/src/personal-agent/timeline-cluster.js +30 -0
- package/runtime/dist/src/personal-agent/timeline-inputs.js +47 -0
- package/runtime/dist/src/personal-agent/timeline-time.js +60 -0
- package/runtime/dist/src/personal-agent/understanding-products.js +49 -0
- package/runtime/dist/src/personal-agent/understanding.js +7 -22
- package/runtime/dist/src/personal-agent/workbench-context.js +17 -21
- package/runtime/dist/src/personal-agent/workbench-copy.js +124 -0
- package/runtime/dist/src/personal-agent/workbench-evidence.js +77 -0
- package/runtime/dist/src/personal-agent/workbench-instructions.js +21 -0
- package/runtime/dist/src/personal-agent/workbench-runtime.js +1006 -0
- package/runtime/dist/src/personal-agent/workbench-shell-class.js +304 -0
- package/runtime/dist/src/personal-agent/workbench-store.js +292 -0
- package/runtime/dist/src/personal-agent/workbench-temporal.js +66 -0
- package/runtime/dist/src/projects/project-native-resource.js +10 -8
- package/runtime/dist/src/projects/project-store.js +36 -4
- package/runtime/dist/src/realtime/bridge.js +77 -8
- package/runtime/dist/src/realtime/capabilities.js +19 -0
- package/runtime/dist/src/realtime/cascaded/adapter.js +180 -40
- package/runtime/dist/src/realtime/cascaded/ark-llm.js +150 -24
- package/runtime/dist/src/realtime/cascaded/chat-completions-llm.js +243 -83
- package/runtime/dist/src/realtime/cascaded/llm-stream-limits.js +18 -0
- package/runtime/dist/src/realtime/cascaded/llm.js +96 -0
- package/runtime/dist/src/realtime/cascaded/openai-compatible-speech.js +251 -0
- package/runtime/dist/src/realtime/cascaded/provider.js +8 -0
- package/runtime/dist/src/realtime/evidence.js +1 -1
- package/runtime/dist/src/realtime/frontend-instructions.js +76 -55
- package/runtime/dist/src/realtime/gemini.js +14 -3
- package/runtime/dist/src/realtime/host-delivery.js +37 -4
- package/runtime/dist/src/realtime/protocol.js +18 -3
- package/runtime/dist/src/realtime/provider-projection.js +4 -1
- package/runtime/dist/src/realtime/provider-session.js +73 -16
- package/runtime/dist/src/realtime/qwen-transport.js +35 -4
- package/runtime/dist/src/realtime/qwen.js +144 -9
- package/runtime/dist/src/realtime/service-state.js +0 -1
- package/runtime/dist/src/realtime/service.js +93 -7
- package/runtime/dist/src/realtime/session.js +39 -32
- package/runtime/dist/src/realtime/sglang-native.js +214 -0
- package/runtime/dist/src/realtime/system-prompts.en.js +14 -2
- package/runtime/dist/src/realtime/telemetry.js +6 -3
- package/runtime/dist/src/realtime/tool-continuations.js +84 -7
- package/runtime/dist/src/realtime/transport.js +17 -0
- package/runtime/dist/src/realtime/usage.js +33 -17
- package/runtime/dist/src/realtime/volcengine/ark.js +40 -15
- package/runtime/dist/src/realtime/volcengine/asr.js +2 -1
- package/runtime/dist/src/realtime/volcengine/silence-endpointing.js +1 -7
- package/runtime/dist/src/realtime/volcengine/tts.js +2 -1
- package/runtime/dist/src/server/aoq-chat-server.js +1 -1
- package/runtime/dist/src/server/client-server.js +21 -0
- package/runtime/dist/src/server-entry.js +3 -0
- package/runtime/dist/src/space-host/admin-socket.js +115 -0
- package/runtime/dist/src/space-host/audio-owner.js +44 -0
- package/runtime/dist/src/space-host/cli.js +195 -0
- package/runtime/dist/src/space-host/config.js +247 -0
- package/runtime/dist/src/space-host/context-input.js +12 -0
- package/runtime/dist/src/space-host/contracts.js +10 -0
- package/runtime/dist/src/space-host/host-admin.js +114 -0
- package/runtime/dist/src/space-host/key-delivery.js +28 -0
- package/runtime/dist/src/space-host/mobile-tools.js +9 -0
- package/runtime/dist/src/space-host/model-settings.js +213 -0
- package/runtime/dist/src/space-host/projection.js +37 -0
- package/runtime/dist/src/space-host/push.js +137 -0
- package/runtime/dist/src/space-host/relay-transport.js +55 -0
- package/runtime/dist/src/space-host/service.js +841 -0
- package/runtime/dist/src/space-host/voice-crypto.js +240 -0
- package/runtime/dist/src/space-host/voice.js +600 -0
- package/runtime/dist/src/space-host/windows-secret-key.js +82 -0
- package/runtime/dist/src/storage/private-database.js +7 -10
- package/runtime/dist/src/text/unicode-normalize.js +5 -1
- package/runtime/dist/src/understanding/candidates.js +8 -10
- package/runtime/dist/src/understanding/fixture.js +1 -1
- package/runtime/dist/src/understanding/pipeline.js +4 -4
- package/runtime/dist/src/usage/context.js +23 -0
- package/runtime/dist/src/usage/index.js +4 -0
- package/runtime/dist/src/usage/ledger-worker.js +90 -0
- package/runtime/dist/src/usage/ledger.js +74 -0
- package/runtime/dist/src/usage/model-call.js +63 -0
- package/runtime/dist/src/usage/pricing.js +68 -0
- package/runtime/dist/src/usage/summary.js +69 -0
- package/runtime/dist/src/voicemem/store-client.js +104 -21
- package/runtime/dist/src/voicemem/store-worker.js +5 -8
- package/runtime/dist/src/voicemem/versioned-memory.js +1 -1
- package/src/command.mjs +8 -1
- package/runtime/dist/src/executors/autoglm.js +0 -376
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
/** Optional, supervised phone executor. Device identity and credentials stay host-owned. */
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { access, mkdir, realpath } from 'node:fs/promises';
|
|
5
|
-
import { homedir } from 'node:os';
|
|
6
|
-
import { isAbsolute, join } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import { executorManifestSchema } from '../core/ports.js';
|
|
11
|
-
import { acquireDeviceLock, quarantineDeviceLock, recordDeviceProcess, releaseDeviceLock } from './device-lock.js';
|
|
12
|
-
const instructionSchema = z.string().trim().min(1).max(4000);
|
|
13
|
-
const requestSchema = z.object({ instruction: instructionSchema, run_id: z.string().uuid() }).strict();
|
|
14
|
-
const identifier = z.string().min(1).max(128);
|
|
15
|
-
const actionNames = ['Launch', 'Tap', 'Type', 'Type_Name', 'Swipe', 'Back', 'Home', 'Double Tap', 'Long Press'];
|
|
16
|
-
const terminalCodes = ['model_finished', 'model_failed', 'action_failed', 'step_limit', 'timeout', 'declined',
|
|
17
|
-
'screen_changed', 'needs_user_action', 'invalid_configuration', 'protocol_error'];
|
|
18
|
-
const envelope = { version: z.literal(1), taskId: identifier };
|
|
19
|
-
const messageSchema = z.discriminatedUnion('type', [
|
|
20
|
-
z.object({ ...envelope, type: z.literal('ready'), upstreamCommit: z.string().regex(/^[a-f0-9]{40}$/u) }).strict(),
|
|
21
|
-
z.object({ ...envelope, type: z.literal('progress'), step: z.number().int().nonnegative(),
|
|
22
|
-
phase: z.enum(['model', 'action', 'action_returned']), lastAction: z.string().max(40).optional() }).strict(),
|
|
23
|
-
z.object({ ...envelope, type: z.literal('approval'), requestId: identifier, step: z.number().int().positive(),
|
|
24
|
-
action: z.object({ _metadata: z.literal('do'), action: z.enum(actionNames) }).catchall(z.unknown()),
|
|
25
|
-
screenDigest: z.string().regex(/^[a-f0-9]{64}$/u), packageName: z.string().min(1).max(256) }).strict(),
|
|
26
|
-
z.object({ ...envelope, type: z.literal('terminal'), code: z.enum(terminalCodes), steps: z.number().int().nonnegative(),
|
|
27
|
-
message: z.string().max(2048).optional(), lastAction: z.string().max(40).optional() }).strict(),
|
|
28
|
-
]);
|
|
29
|
-
export const AUTOGLM_DESCRIPTOR = Object.freeze({ name: 'autoglm',
|
|
30
|
-
summary: 'Operates the configured phone (iOS by default) under user supervision. Every device action needs confirmation. Screenshots go to the configured model service.',
|
|
31
|
-
ownedChannels: Object.freeze(['autoglm']) });
|
|
32
|
-
/** Called only when `autoglm` is explicitly selected; no automatic install or device selection. */
|
|
33
|
-
export function loadAutoGlmConfig(env) {
|
|
34
|
-
const required = (key, limit = 4096) => {
|
|
35
|
-
const value = env[key]?.trim();
|
|
36
|
-
if (!value || value.length > limit || /[\x00-\x1f]/u.test(value))
|
|
37
|
-
throw new Error(`invalid_autoglm_configuration:${key}`);
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
40
|
-
const integer = (key, fallback, max) => {
|
|
41
|
-
const value = env[key] === undefined ? fallback : Number(env[key]);
|
|
42
|
-
if (!Number.isSafeInteger(value) || value < 1 || value > max)
|
|
43
|
-
throw new Error(`invalid_autoglm_configuration:${key}`);
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
46
|
-
const python = required('AUTOGLM_PYTHON');
|
|
47
|
-
const sourcePath = required('AUTOGLM_SOURCE_PATH');
|
|
48
|
-
if (!isAbsolute(python) || !isAbsolute(sourcePath))
|
|
49
|
-
throw new Error('invalid_autoglm_paths');
|
|
50
|
-
const baseUrl = required('AUTOGLM_BASE_URL', 2048);
|
|
51
|
-
const url = new URL(baseUrl);
|
|
52
|
-
if (url.username || url.password || url.hash || url.search || (url.protocol !== 'https:'
|
|
53
|
-
&& !(url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))))
|
|
54
|
-
throw new Error('invalid_autoglm_endpoint');
|
|
55
|
-
const deviceType = env.AUTOGLM_DEVICE_TYPE ?? 'ios';
|
|
56
|
-
if (deviceType !== 'ios' && deviceType !== 'ios-simulator' && deviceType !== 'android')
|
|
57
|
-
throw new Error('invalid_autoglm_device_type');
|
|
58
|
-
const wdaUrl = deviceType !== 'android' ? (env.AUTOGLM_WDA_URL ?? 'http://127.0.0.1:8100') : undefined;
|
|
59
|
-
if (wdaUrl !== undefined) {
|
|
60
|
-
const wda = new URL(wdaUrl);
|
|
61
|
-
if (deviceType === 'ios-simulator' && (wda.protocol !== 'http:' || !['localhost', '127.0.0.1', '[::1]'].includes(wda.hostname) || wda.pathname !== '/'))
|
|
62
|
-
throw new Error('invalid_autoglm_wda_endpoint');
|
|
63
|
-
if (wda.username || wda.password || wda.hash || wda.search || (wda.protocol !== 'https:'
|
|
64
|
-
&& !(wda.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(wda.hostname))))
|
|
65
|
-
throw new Error('invalid_autoglm_wda_endpoint');
|
|
66
|
-
}
|
|
67
|
-
const deviceId = required('AUTOGLM_DEVICE_ID');
|
|
68
|
-
if (deviceId.length > 128 || !/^[A-Za-z0-9_.:\-]+$/u.test(deviceId))
|
|
69
|
-
throw new Error('invalid_autoglm_device');
|
|
70
|
-
return { python, sourcePath, deviceId, deviceType, ...(wdaUrl === undefined ? {} : { wdaUrl }), baseUrl, model: required('AUTOGLM_MODEL', 200),
|
|
71
|
-
apiKey: required('AUTOGLM_API_KEY'),
|
|
72
|
-
maxSteps: integer('AUTOGLM_MAX_STEPS', 30, 100),
|
|
73
|
-
budgetMs: integer('AUTOGLM_TIMEOUT_SECONDS', 600, 1800) * 1000,
|
|
74
|
-
lockRoot: join(homedir(), '.nova-audio-agent', 'autoglm-devices') };
|
|
75
|
-
}
|
|
76
|
-
function handoff(code, outcome, extra = {}) {
|
|
77
|
-
return { outcome, trust: 'untrusted_external', content: { code, verified: false, effects: 'unknown', ...extra } };
|
|
78
|
-
}
|
|
79
|
-
export class AutoGlmExecutor {
|
|
80
|
-
config;
|
|
81
|
-
approvals;
|
|
82
|
-
bridgePath;
|
|
83
|
-
descriptor = AUTOGLM_DESCRIPTOR;
|
|
84
|
-
manifest;
|
|
85
|
-
#reservation = null;
|
|
86
|
-
#active = null;
|
|
87
|
-
#closed = false;
|
|
88
|
-
constructor(config, approvals, bridgePath = fileURLToPath(new URL('../../../scripts/autoglm-bridge.py', import.meta.url))
|
|
89
|
-
.replace(/([/\\])app\.asar([/\\])/u, '$1app.asar.unpacked$2')) {
|
|
90
|
-
this.config = config;
|
|
91
|
-
this.approvals = approvals;
|
|
92
|
-
this.bridgePath = bridgePath;
|
|
93
|
-
this.manifest = executorManifestSchema.parse({ name: 'autoglm', display_name: 'AutoGLM', roles: [], approvals: true,
|
|
94
|
-
model_visibility: 'hidden', probe_policy: 'none', ops: [{ name: 'run', description: 'Run a supervised phone task.',
|
|
95
|
-
params: { type: 'object', properties: { instruction: { type: 'string', minLength: 1, maxLength: 4000 }, run_id: { type: 'string' } },
|
|
96
|
-
required: ['instruction', 'run_id'], additionalProperties: false }, readonly: false, confirm: false,
|
|
97
|
-
deadline_budget: config.budgetMs / 1000 + 5, verifies: [], sensitive_params: ['instruction'], sync_result: false }],
|
|
98
|
-
policy: { channel: 'autoglm', priority: 50, wake: 'surrogate', typical_latency: 10, compress_watermark: 8000, progress_via_surrogate: true } });
|
|
99
|
-
}
|
|
100
|
-
controller(port) {
|
|
101
|
-
let delegateId = null;
|
|
102
|
-
return { descriptor: AUTOGLM_DESCRIPTOR, dispatch: async (request) => {
|
|
103
|
-
if (!request.stillWanted())
|
|
104
|
-
return { code: 'superseded', accepted: false, detail: {} };
|
|
105
|
-
if (this.#closed)
|
|
106
|
-
return { code: 'runtime_rejected', accepted: false, detail: {} };
|
|
107
|
-
if (this.#reservation !== null)
|
|
108
|
-
return { code: 'busy', accepted: true, detail: {} };
|
|
109
|
-
const instruction = instructionSchema.safeParse(request.instruction);
|
|
110
|
-
if (!instruction.success)
|
|
111
|
-
return { code: 'clarification_required', accepted: true, detail: {} };
|
|
112
|
-
const runId = randomUUID();
|
|
113
|
-
this.#reservation = runId;
|
|
114
|
-
try {
|
|
115
|
-
const admission = await port.dispatch({ channel: 'autoglm', op: 'run',
|
|
116
|
-
request: { instruction: instruction.data, run_id: runId }, origin_ref: request.origin_ref,
|
|
117
|
-
stillWanted: () => {
|
|
118
|
-
const wanted = this.#reservation === runId && !this.#closed && request.stillWanted();
|
|
119
|
-
if (!wanted && this.#reservation === runId && this.#active === null)
|
|
120
|
-
this.#reservation = null;
|
|
121
|
-
return wanted;
|
|
122
|
-
} });
|
|
123
|
-
if (!admission.accepted || admission.delegate_id === null) {
|
|
124
|
-
if (this.#reservation === runId)
|
|
125
|
-
this.#reservation = null;
|
|
126
|
-
return { code: 'runtime_rejected', accepted: false, detail: {} };
|
|
127
|
-
}
|
|
128
|
-
delegateId = admission.delegate_id;
|
|
129
|
-
return { code: 'delegated', accepted: true, delegate_id: delegateId, detail: { channel: 'autoglm', op: 'run' } };
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
if (this.#reservation === runId)
|
|
133
|
-
this.#reservation = null;
|
|
134
|
-
return { code: 'runtime_rejected', accepted: false, detail: {} };
|
|
135
|
-
}
|
|
136
|
-
}, cancel: async (request) => {
|
|
137
|
-
if (!request.stillWanted())
|
|
138
|
-
return { code: 'superseded', accepted: false, detail: {} };
|
|
139
|
-
if (this.#reservation === null)
|
|
140
|
-
return { code: 'not_running', accepted: true, detail: {} };
|
|
141
|
-
if (delegateId !== null)
|
|
142
|
-
port.cancelPendingDispatch?.(delegateId);
|
|
143
|
-
this.#active?.abort.abort();
|
|
144
|
-
await this.#active?.done;
|
|
145
|
-
if (this.#active === null)
|
|
146
|
-
this.#reservation = null;
|
|
147
|
-
delegateId = null;
|
|
148
|
-
return { code: 'accepted', accepted: true, detail: {} };
|
|
149
|
-
} };
|
|
150
|
-
}
|
|
151
|
-
admitRequest(op, request) {
|
|
152
|
-
const parsed = requestSchema.safeParse(request);
|
|
153
|
-
return op === 'run' && parsed.success && parsed.data.run_id === this.#reservation && !this.#closed
|
|
154
|
-
? { ok: true, request: parsed.data, sync_result: false } : { ok: false };
|
|
155
|
-
}
|
|
156
|
-
async dispatch(op, request, context) {
|
|
157
|
-
const admission = this.admitRequest(op, request);
|
|
158
|
-
if (!admission.ok || this.#active !== null)
|
|
159
|
-
return handoff('invalid_request', 'refused');
|
|
160
|
-
const abort = new AbortController();
|
|
161
|
-
const abortFromRuntime = () => abort.abort();
|
|
162
|
-
context.signal.addEventListener('abort', abortFromRuntime, { once: true });
|
|
163
|
-
if (context.signal.aborted)
|
|
164
|
-
abort.abort();
|
|
165
|
-
const done = this.#run(admission.request.instruction, admission.request.run_id, context, abort.signal)
|
|
166
|
-
.catch(() => handoff('bridge_failed', 'unknown'));
|
|
167
|
-
this.#active = { abort, done };
|
|
168
|
-
try {
|
|
169
|
-
return await done;
|
|
170
|
-
}
|
|
171
|
-
finally {
|
|
172
|
-
context.signal.removeEventListener('abort', abortFromRuntime);
|
|
173
|
-
this.#active = null;
|
|
174
|
-
this.#reservation = null;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async close() {
|
|
178
|
-
this.#closed = true;
|
|
179
|
-
this.#active?.abort.abort();
|
|
180
|
-
await this.#active?.done;
|
|
181
|
-
this.#reservation = null;
|
|
182
|
-
}
|
|
183
|
-
async #run(instruction, taskId, context, cancelled) {
|
|
184
|
-
if (process.platform === 'win32')
|
|
185
|
-
return handoff('unsupported_host', 'refused');
|
|
186
|
-
if (cancelled.aborted)
|
|
187
|
-
return handoff('cancelled', 'cancelled');
|
|
188
|
-
const { config } = this;
|
|
189
|
-
const budgetMs = Math.min(config.budgetMs, Math.max(0, ((context.delegate.deadline ?? Infinity) - context.clock.now()) * 1000));
|
|
190
|
-
if (budgetMs <= 0)
|
|
191
|
-
return handoff('timeout', 'unknown');
|
|
192
|
-
const deadlineSignal = AbortSignal.timeout(Math.floor(budgetMs));
|
|
193
|
-
const processStop = new AbortController();
|
|
194
|
-
const signal = AbortSignal.any([cancelled, deadlineSignal, processStop.signal]);
|
|
195
|
-
// Keep the venv executable path: resolving its symlink launches the base interpreter.
|
|
196
|
-
await access(config.python);
|
|
197
|
-
const python = config.python;
|
|
198
|
-
const sourcePath = await realpath(config.sourcePath);
|
|
199
|
-
await access(this.bridgePath);
|
|
200
|
-
await mkdir(config.lockRoot, { recursive: true, mode: 0o700 });
|
|
201
|
-
const acquired = await acquireDeviceLock(config.lockRoot, config.deviceType, config.deviceId, taskId);
|
|
202
|
-
if (!acquired.ok)
|
|
203
|
-
return handoff(acquired.reason, 'refused');
|
|
204
|
-
// ponytail: crash leaves a quarantine directory; manual recovery after checking the device/processes.
|
|
205
|
-
let treeGone = true;
|
|
206
|
-
const approval = this.approvals.forWork({ work_id: taskId, project: config.deviceType === 'android' ? 'Android' : 'iOS', title: 'AutoGLM 手机任务' });
|
|
207
|
-
let result = handoff('bridge_eof', 'unknown');
|
|
208
|
-
const observation = {};
|
|
209
|
-
// An approved write the bridge started but never acknowledged has an unconfirmed device effect.
|
|
210
|
-
const flight = { write: false };
|
|
211
|
-
try {
|
|
212
|
-
if (signal.aborted)
|
|
213
|
-
return handoff(cancelled.aborted ? 'cancelled' : 'timeout', cancelled.aborted ? 'cancelled' : 'unknown');
|
|
214
|
-
const child = spawn(python, [this.bridgePath], { shell: false, detached: true, stdio: ['pipe', 'pipe', 'pipe'],
|
|
215
|
-
env: { PATH: process.env.PATH ?? '/usr/bin:/bin', HOME: homedir(), LANG: 'en_US.UTF-8', PYTHONUNBUFFERED: '1',
|
|
216
|
-
...(config.deviceType === 'ios-simulator' && process.env.DEVELOPER_DIR ? { DEVELOPER_DIR: process.env.DEVELOPER_DIR } : {}),
|
|
217
|
-
PYTHONDONTWRITEBYTECODE: '1', AUTOGLM_API_KEY: config.apiKey, AUTOGLM_SOURCE_PATH: sourcePath } });
|
|
218
|
-
treeGone = child.pid === undefined;
|
|
219
|
-
if (child.pid !== undefined)
|
|
220
|
-
await recordDeviceProcess(acquired.lock, child.pid).catch(() => undefined);
|
|
221
|
-
let waitingForApproval = false, exited = false;
|
|
222
|
-
child.once('exit', () => {
|
|
223
|
-
exited = true;
|
|
224
|
-
if (waitingForApproval)
|
|
225
|
-
processStop.abort();
|
|
226
|
-
});
|
|
227
|
-
child.once('error', () => { exited = true; processStop.abort(); });
|
|
228
|
-
const exit = new Promise(resolve => { child.once('close', () => resolve()); child.once('error', () => resolve()); });
|
|
229
|
-
child.stdin.on('error', () => { child.stdout.destroy(new Error('bridge_input_failed')); });
|
|
230
|
-
child.stderr.on('data', () => { });
|
|
231
|
-
const terminate = () => {
|
|
232
|
-
approval.invalidate('autoglm_stopped');
|
|
233
|
-
if (child.pid !== undefined)
|
|
234
|
-
try {
|
|
235
|
-
process.kill(-child.pid, 'SIGTERM');
|
|
236
|
-
}
|
|
237
|
-
catch { /* already gone */ }
|
|
238
|
-
child.stdout.destroy(new Error('bridge_stopped'));
|
|
239
|
-
};
|
|
240
|
-
signal.addEventListener('abort', terminate, { once: true });
|
|
241
|
-
try {
|
|
242
|
-
if (signal.aborted)
|
|
243
|
-
terminate();
|
|
244
|
-
else {
|
|
245
|
-
child.stdin.write(`${JSON.stringify({ version: 1, type: 'start', taskId, instruction, deviceId: config.deviceId,
|
|
246
|
-
deviceType: config.deviceType, ...(config.wdaUrl === undefined ? {} : { wdaUrl: config.wdaUrl }),
|
|
247
|
-
maxSteps: config.maxSteps, budgetMs: Math.floor(budgetMs), baseUrl: config.baseUrl, model: config.model })}\n`);
|
|
248
|
-
result = await this.#read(child.stdout, async (value) => {
|
|
249
|
-
await new Promise((resolve, reject) => child.stdin.write(`${JSON.stringify(value)}\n`, error => error ? reject(error) : resolve()));
|
|
250
|
-
}, taskId, context, signal, approval, observation, flight, waiting => {
|
|
251
|
-
waitingForApproval = waiting;
|
|
252
|
-
if (waiting && exited)
|
|
253
|
-
processStop.abort();
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
catch {
|
|
258
|
-
result = handoff('bridge_protocol_failed', 'unknown');
|
|
259
|
-
}
|
|
260
|
-
finally {
|
|
261
|
-
signal.removeEventListener('abort', terminate);
|
|
262
|
-
terminate();
|
|
263
|
-
await Promise.race([exit, delay(250)]);
|
|
264
|
-
if (child.pid !== undefined) {
|
|
265
|
-
try {
|
|
266
|
-
process.kill(-child.pid, 'SIGKILL');
|
|
267
|
-
}
|
|
268
|
-
catch { /* already gone */ }
|
|
269
|
-
for (let retry = 0; retry < 20; retry += 1) {
|
|
270
|
-
try {
|
|
271
|
-
process.kill(-child.pid, 0);
|
|
272
|
-
}
|
|
273
|
-
catch (error) {
|
|
274
|
-
if (error.code === 'ESRCH')
|
|
275
|
-
treeGone = true;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
await delay(25);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
child.stdin.destroy();
|
|
282
|
-
child.stdout.destroy();
|
|
283
|
-
child.stderr.destroy();
|
|
284
|
-
}
|
|
285
|
-
if (!treeGone || flight.write) {
|
|
286
|
-
const unknown = handoff('cleanup_unknown', 'unknown', observation);
|
|
287
|
-
return { ...unknown, content: { ...unknown.content, cleanup_required: true, ...(cancelled.aborted ? { cancel_requested: true } : {}) } };
|
|
288
|
-
}
|
|
289
|
-
if (cancelled.aborted)
|
|
290
|
-
return handoff('cancelled', 'cancelled', observation);
|
|
291
|
-
if (deadlineSignal.aborted)
|
|
292
|
-
return handoff('timeout', 'unknown', observation);
|
|
293
|
-
return { ...result, content: { ...result.content, ...observation } };
|
|
294
|
-
}
|
|
295
|
-
finally {
|
|
296
|
-
approval.invalidate('autoglm_finished');
|
|
297
|
-
if (treeGone && !flight.write)
|
|
298
|
-
await releaseDeviceLock(acquired.lock);
|
|
299
|
-
else
|
|
300
|
-
await quarantineDeviceLock(acquired.lock, 'cleanup_unknown');
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
async #read(output, send, taskId, context, signal, approval, observation, flight, waiting) {
|
|
304
|
-
let buffer = Buffer.alloc(0), total = 0, ready = false, step = 0;
|
|
305
|
-
const seen = new Set();
|
|
306
|
-
for await (const chunk of output) {
|
|
307
|
-
total += chunk.length;
|
|
308
|
-
if (total > 1024 * 1024)
|
|
309
|
-
throw new Error('protocol_limit');
|
|
310
|
-
buffer = Buffer.concat([buffer, chunk]);
|
|
311
|
-
let end;
|
|
312
|
-
while ((end = buffer.indexOf(10)) !== -1) {
|
|
313
|
-
if (end > 65536 || signal.aborted)
|
|
314
|
-
throw new Error('protocol_limit');
|
|
315
|
-
const line = new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, end));
|
|
316
|
-
buffer = buffer.subarray(end + 1);
|
|
317
|
-
const message = messageSchema.parse(JSON.parse(line));
|
|
318
|
-
if (message.taskId !== taskId)
|
|
319
|
-
throw new Error('wrong_task');
|
|
320
|
-
if (message.type === 'ready') {
|
|
321
|
-
if (ready)
|
|
322
|
-
throw new Error('duplicate_ready');
|
|
323
|
-
ready = true;
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
// Startup refusals may precede readiness; never accept a successful unready terminal.
|
|
327
|
-
if (!ready && !(message.type === 'terminal' && message.code === 'invalid_configuration'))
|
|
328
|
-
throw new Error('not_ready');
|
|
329
|
-
if (message.type === 'terminal') {
|
|
330
|
-
const outcome = message.code === 'model_finished' ? 'ok' : message.code === 'timeout' ? 'unknown'
|
|
331
|
-
: ['declined', 'needs_user_action', 'invalid_configuration', 'screen_changed'].includes(message.code) ? 'refused' : 'failed';
|
|
332
|
-
return handoff(message.code, outcome, { steps: message.steps,
|
|
333
|
-
...(message.message === undefined ? {} : { message: message.message.replace(/[\x00-\x1f\x7f]/gu, ' ').slice(0, 2048) }),
|
|
334
|
-
...(message.lastAction === undefined ? {} : { last_action: message.lastAction }) });
|
|
335
|
-
}
|
|
336
|
-
if (message.step < step || message.step > this.config.maxSteps)
|
|
337
|
-
throw new Error('invalid_step');
|
|
338
|
-
step = message.step;
|
|
339
|
-
if (message.type === 'progress') {
|
|
340
|
-
if (message.phase === 'action')
|
|
341
|
-
flight.write = true;
|
|
342
|
-
if (message.phase === 'action_returned') {
|
|
343
|
-
flight.write = false;
|
|
344
|
-
observation.last_returned_step = step;
|
|
345
|
-
if (message.lastAction !== undefined)
|
|
346
|
-
observation.last_action = message.lastAction;
|
|
347
|
-
}
|
|
348
|
-
context.progress({ phase: 'working', internal_activity: step, elapsed: Math.max(0, context.clock.now() - context.delegate.dispatched_at), summary: null });
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
if (seen.has(message.requestId))
|
|
352
|
-
throw new Error('duplicate_approval');
|
|
353
|
-
seen.add(message.requestId);
|
|
354
|
-
const scope = `${message.packageName}: ${JSON.stringify(message.action)}`;
|
|
355
|
-
if (scope.length > 1024)
|
|
356
|
-
return handoff('approval_too_large', 'refused');
|
|
357
|
-
waiting(true);
|
|
358
|
-
const resolution = await approval.offer({ kind: 'permissions', local_detail: { kind: 'permissions', scope },
|
|
359
|
-
operation_summary: `AutoGLM 手机操作:${message.action.action}`,
|
|
360
|
-
allowed_decisions: ['accept', 'decline'], executorIdentity: { executor: 'autoglm', display_name: 'AutoGLM' } }, signal);
|
|
361
|
-
waiting(false);
|
|
362
|
-
if (signal.aborted)
|
|
363
|
-
throw new Error('stopped');
|
|
364
|
-
const decision = resolution === null ? 'decline' : approval.consume(resolution);
|
|
365
|
-
if (signal.aborted)
|
|
366
|
-
throw new Error('stopped');
|
|
367
|
-
await send({ version: 1, type: 'decision', taskId, requestId: message.requestId,
|
|
368
|
-
decision: decision === 'accept' ? 'accept' : 'decline' });
|
|
369
|
-
}
|
|
370
|
-
if (buffer.length > 65536)
|
|
371
|
-
throw new Error('protocol_limit');
|
|
372
|
-
}
|
|
373
|
-
return handoff('bridge_eof', 'unknown');
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
//# sourceMappingURL=autoglm.js.map
|