Expose reminder source types and verify received native input state
This commit is contained in:
1 parent
055150bf79
commit
ebdad79678
9 files changed
+21
-13
No files matched your search
@@ -86,7 +86,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
|
||||
| `system-prompt/change` | `emit` | [`packages/core/system-prompt/src/index.ts:37`](../packages/core/system-prompt/src/index.ts) | [`system-prompt`](../packages/core/system-prompt) (`emit`) | - |
|
||||
| `timeline/priority` | `emit` | [`packages/experimental/timeline/src/storage.ts:56`](../packages/experimental/timeline/src/storage.ts) | [`timeline`](../packages/experimental/timeline) (`emit`) | [`timeline`](../packages/experimental/timeline) |
|
||||
| `tools/change` | `emit` | [`packages/core/tools/src/events.ts:56`](../packages/core/tools/src/events.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`), [`tools`](../packages/core/tools) (`emit`) | `browser-use-runtime`, [`timeline`](../packages/experimental/timeline) |
|
||||
| `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` |
|
||||
| `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`cua`](../packages/experimental/cua), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` |
|
||||
| `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) |
|
||||
| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) |
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
| `system-prompt/change` | `emit` | [`packages/core/system-prompt/src/index.ts:37`](../packages/core/system-prompt/src/index.ts) | [`system-prompt`](../packages/core/system-prompt) (`emit`) | - |
|
||||
| `timeline/priority` | `emit` | [`packages/experimental/timeline/src/storage.ts:56`](../packages/experimental/timeline/src/storage.ts) | [`timeline`](../packages/experimental/timeline) (`emit`) | [`timeline`](../packages/experimental/timeline) |
|
||||
| `tools/change` | `emit` | [`packages/core/tools/src/events.ts:56`](../packages/core/tools/src/events.ts) | [`agent-preset-registry`](../packages/preset/agent-preset-registry) (`emit`), [`tools`](../packages/core/tools) (`emit`) | `browser-use-runtime`, [`timeline`](../packages/experimental/timeline) |
|
||||
| `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` |
|
||||
| `tools/execute` | `waterfall` | [`packages/core/tools/src/events.ts:29`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `browser-use-runtime`, `browser-use-stagehand-native`, `claude-code-mods`, `computer-use-cua-driver-native`, [`cua`](../packages/experimental/cua), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), `timeout-policy` |
|
||||
| `tools/post-execute` | `waterfall` | [`packages/core/tools/src/events.ts:41`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `claude-code-mods`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), [`repeat-tool-reminder`](../packages/guard/repeat-tool-reminder), [`spill-policy`](../packages/spill/spill-policy), [`tool-fs-search`](../packages/fs/tool-fs-search) |
|
||||
| `tools/pre-execute` | `waterfall` | [`packages/core/tools/src/events.ts:18`](../packages/core/tools/src/events.ts) | [`tools`](../packages/core/tools) (`waterfall`) | `auto-review`, [`hooks-claude-code`](../packages/experimental/hooks-claude-code), [`hooks-codex`](../packages/experimental/hooks-codex), `liveshare`, [`tool-jobs`](../packages/jobs/tool-jobs), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `tools/ptc-dispatch-log` | `waterfall` | [`packages/core/tool-executor-ptc/src/runtime-types.ts:46`](../packages/core/tool-executor-ptc/src/runtime-types.ts) | [`tool-executor-ptc`](../packages/core/tool-executor-ptc) (`waterfall`) | [`spill-policy`](../packages/spill/spill-policy) |
|
||||
|
||||
@@ -154,7 +154,7 @@ Host control over the dedicated `cua_run_code` environments; registered as `ctx.
|
||||
* Release one Agent's retained program environment with the dedicated runtime's owner release. The program
|
||||
* process exits, a program of that Agent that is still running fails as aborted, and the next `cua_run_code`
|
||||
* call starts a fresh process that re-creates the `cua` global. The Agent, its application grants and native
|
||||
* connection, and the desktop applications themselves are unaffected. The runtime rejects that Agent's
|
||||
* connection, and the desktop applications themselves are unaffected. Held input is released. The runtime rejects that Agent's
|
||||
* programs until the release settles, so the caller holds them back; after a failed release it rejects them
|
||||
* until a later release succeeds. Resolves when no environment exists.
|
||||
* @param agent - Agent whose `cua_run_code` state owner is released.
|
||||
|
||||
@@ -154,7 +154,7 @@ Host control over the dedicated `cua_run_code` environments; registered as `ctx.
|
||||
* Release one Agent's retained program environment with the dedicated runtime's owner release. The program
|
||||
* process exits, a program of that Agent that is still running fails as aborted, and the next `cua_run_code`
|
||||
* call starts a fresh process that re-creates the `cua` global. The Agent, its application grants and native
|
||||
* connection, and the desktop applications themselves are unaffected. The runtime rejects that Agent's
|
||||
* connection, and the desktop applications themselves are unaffected. Held input is released. The runtime rejects that Agent's
|
||||
* programs until the release settles, so the caller holds them back; after a failed release it rejects them
|
||||
* until a later release succeeds. Resolves when no environment exists.
|
||||
* @param agent - Agent whose `cua_run_code` state owner is released.
|
||||
|
||||
@@ -289,7 +289,14 @@ def check_mixed_input(call, owner, state_file, executable):
|
||||
call("sendKeyEvent", {**owner, "key": "a", "direction": "down"})
|
||||
call("toggleMouse", {**window, "mouseButton": "left", "direction": "down", "useSystemPointer": system})
|
||||
call("sendKeyEvent", {**owner, "key": "w", "direction": "down"})
|
||||
assert call("getHeldInputs", {}) == [
|
||||
{"kind": "key", "key": "a", "appHandle": owner["appHandle"], "mode": "application"},
|
||||
{"kind": "mouse", "button": "left", "appHandle": owner["appHandle"],
|
||||
"windowId": window["windowId"], "mode": "system" if system else "window"},
|
||||
{"kind": "key", "key": "w", "appHandle": owner["appHandle"], "mode": "application"},
|
||||
]
|
||||
call("releaseHeldInputs", {})
|
||||
assert call("getHeldInputs", {}) == []
|
||||
state = wait_for_state(state_file, lambda s: sum(e.get("sourcePid") == source_pid for e in s["events"][count:]) >= 6)
|
||||
events = [(e["type"], e.get("keyCode")) for e in state["events"][count:] if e.get("sourcePid") == source_pid]
|
||||
assert events == [(10, 0), (1, None), (10, 13), (11, 13), (2, None), (11, 0)], events
|
||||
|
||||
@@ -113,7 +113,7 @@ it.skipIf(process.platform !== 'darwin' || helperPath === undefined).each(['comp
|
||||
}
|
||||
await handle.agent.whenIdle()
|
||||
if (ending === 'completed') {
|
||||
expect((await received()).map(event => event.type)).toEqual([10, 1, 10])
|
||||
await expect.poll(async () => (await received()).map(event => event.type), { timeout: 30_000 }).toEqual([10, 1, 10])
|
||||
expect(JSON.stringify(handle.agent.session.snapshotEvents())).toContain('CUA inputs are still held')
|
||||
programs[3] = "await app.sendKeyEvent('w', 'up'); await win.toggleMouse('left', 'up'); await app.sendKeyEvent('a', 'up')"
|
||||
handle.agent.followup(createUserMessage({ content: [{ type: 'text', text: 'Release held input' }], source: { kind: 'user' } }))
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/** Native-owned held input, program-end reminders, and failure/cancellation cleanup. */
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import { emitAgentEvent, type Agent } from '@deepseek-ai/dsh-agent'
|
||||
import { createUserMessage, type ContextFormed } from '@deepseek-ai/dsh-llm'
|
||||
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools'
|
||||
import { z } from 'zod'
|
||||
import { NativeError, type NativeClient } from './native-client.ts'
|
||||
|
||||
declare module '@deepseek-ai/dsh-llm' {
|
||||
interface MessageSourceMap {
|
||||
'cua-held-inputs': { kind: 'cua-held-inputs' } & ContextFormed
|
||||
}
|
||||
}
|
||||
|
||||
const target = { appHandle: z.string(), mode: z.enum(['application', 'window', 'system']) }
|
||||
const heldInputs = z.array(z.discriminatedUnion('kind', [
|
||||
z.object({ ...target, kind: z.literal('key'), key: z.string() }),
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
/** Native application objects independent of evaluator ownership and persistence. */
|
||||
import type { Branded } from '@deepseek-ai/dsh-brand'
|
||||
import type { ContextFormed } from '@deepseek-ai/dsh-llm'
|
||||
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
|
||||
import type { z } from 'zod'
|
||||
import type { ActionResult, CapabilitiesResult, FoundAppsResult, HoverResult, SystemPointerRequest, ShowResult, WindowsResult } from './protocol.ts'
|
||||
|
||||
declare module '@deepseek-ai/dsh-llm' {
|
||||
interface MessageSourceMap {
|
||||
'cua-held-inputs': { kind: 'cua-held-inputs' } & ContextFormed
|
||||
}
|
||||
}
|
||||
|
||||
/** Helper-issued application selection; public app objects hold only this opaque handle. */
|
||||
export type CuaAppHandle = Branded<'CuaAppHandle'>
|
||||
/** Helper-issued accessibility observation identity. */
|
||||
|
||||
@@ -1050,7 +1050,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
|
||||
methods: [
|
||||
{
|
||||
signature: 'release(agent: Agent): Promise<void>',
|
||||
description: 'Release one Agent\'s retained program environment with the dedicated runtime\'s owner release. The program process exits, a program of that Agent that is still running fails as aborted, and the next `cua_run_code` call starts a fresh process that re-creates the `cua` global. The Agent, its application grants and native connection, and the desktop applications themselves are unaffected. The runtime rejects that Agent\'s programs until the release settles, so the caller holds them back; after a failed release it rejects them until a later release succeeds. Resolves when no environment exists.',
|
||||
description: 'Release one Agent\'s retained program environment with the dedicated runtime\'s owner release. The program process exits, a program of that Agent that is still running fails as aborted, and the next `cua_run_code` call starts a fresh process that re-creates the `cua` global. The Agent, its application grants and native connection, and the desktop applications themselves are unaffected. Held input is released. The runtime rejects that Agent\'s programs until the release settles, so the caller holds them back; after a failed release it rejects them until a later release succeeds. Resolves when no environment exists.',
|
||||
parameters: [{ name: 'agent', description: 'Agent whose `cua_run_code` state owner is released.' }],
|
||||
returns: 'Completion after the process has exited and its output has drained.',
|
||||
throws: ['When the process cleanup fails.'],
|
||||
|
||||
Reference in new issue
Block a user