jg-agent-hq 13.2.1 → 13.3.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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/api/README.md +16 -0
- package/dist/actions/actions.d.ts +2 -1
- package/dist/actions/actions.js +2 -1
- package/dist/actions/events/events.js +44 -3
- package/dist/actions/live/live.js +1 -0
- package/dist/actions/types.d.ts +2 -0
- package/dist/contracts/actions/types.d.ts +11 -11
- package/dist/contracts/async-inputs/index.d.ts +2 -0
- package/dist/contracts/async-inputs/index.js +2 -0
- package/dist/contracts/async-inputs/types.d.ts +23 -0
- package/dist/contracts/async-inputs/types.js +23 -0
- package/dist/contracts/browser/types.d.ts +25 -10
- package/dist/contracts/evidence/types.d.ts +32 -2
- package/dist/contracts/evidence/types.js +2 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts/providers/types.d.ts +27 -27
- package/dist/contracts/skills/types.d.ts +1 -1
- package/dist/contracts/types.d.ts +231 -66
- package/dist/contracts/types.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +0 -1
- package/dist/providers/claude/control/control.d.ts +1 -1
- package/dist/providers/codex/events.js +2 -1
- package/dist/providers/codex/transformers.js +20 -1
- package/dist/providers/types.d.ts +2 -2
- package/dist/runtime/async-inputs/async-inputs.d.ts +16 -0
- package/dist/runtime/async-inputs/async-inputs.js +73 -0
- package/dist/runtime/async-inputs/index.d.ts +2 -0
- package/dist/runtime/async-inputs/index.js +2 -0
- package/dist/runtime/async-inputs/types.d.ts +18 -0
- package/dist/runtime/async-inputs/types.js +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/runtime.js +5 -1
- package/dist/runtime/types.d.ts +9 -0
- package/dist/sessions/evidence/utilities.js +1 -0
- package/docs/recovery.md +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 13.3.0
|
|
4
|
+
|
|
5
|
+
- Preserve explicit Codex asynchronous question metadata across live items, saved history, details and bounded evidence. Malformed or oversized question contracts remain explicitly unavailable instead of becoming ordinary messages or shortened choices.
|
|
6
|
+
- Add the trusted Node `observeAsyncInputs` subscription for complete controlled-session questions and recovery signals, with isolated synchronous listeners and shutdown cleanup. Hosts own durable resolution and bounded history catch-up.
|
|
7
|
+
- Keep asynchronous messages out of ordinary final-result capture, including oversized async text and structured-output turns. Preserve native approvals, storage schema 12.0.1 and existing action keys without migration or reset.
|
|
8
|
+
|
|
3
9
|
## 13.2.1
|
|
4
10
|
|
|
5
11
|
- Confirm a submitted or uncertain Claude steer from saved native input when its exact action UUID, session, workspace, turn and original-text fingerprint match. History, details, evidence and the existing turn-completion flush can resolve delivery even when Claude never echoes a live user-message replay, including after runtime restart.
|
package/README.md
CHANGED
|
@@ -75,6 +75,8 @@ Native execution settings, instructions, skills and tool permissions remain with
|
|
|
75
75
|
|
|
76
76
|
Approval reads return indexed, cursor-paginated pending, answered and expired metadata after reconnect or restart. Sensitive presentation is available only while the exact native request is live. Native permissions require explicit responses; unknown request kinds or scopes are denied. See [native replies and reconnect reads](api/README.md#thread-control-and-live-input).
|
|
77
77
|
|
|
78
|
+
Codex asynchronous questions retain their explicit `asyncInput` metadata through live items, saved history, details and evidence. They do not replace ordinary final results or create native approval requests. Trusted Node hosts use `hq.observeAsyncInputs(listener)` to enqueue complete controlled-session observations and recovery work independently of browser reads. Hosts own durable question resolution and explicit ordinary-message or exact-turn steer answers. See [async questions](api/README.md#async-questions).
|
|
79
|
+
|
|
78
80
|
Durable state includes `action.key`, which must stay private and accompany its SQLite database. Queued undelivered inputs and complete bounded final results are saved; ordinary input bodies and question answers are not.
|
|
79
81
|
|
|
80
82
|
Text and skill inputs, and steers, can attach up to 8 workspace files by path and media type, 16 MiB in all and 256 KiB per text file. The runtime verifies their content hashes again before queued delivery or steering. Capabilities publish `inputSchema.steerMediaTypes` separately from general attachment support: Claude steers accept images and labeled UTF-8 text, but reject PDFs before writing. Ordinary Claude turn-start document encoding is unchanged. Output schemas use native Codex turn parameters or Claude's structured-session flag; complete validated results and known token usage remain available on selected receipts after reconnect. Live previews stay bounded and explicitly mark truncation. See [file inputs and complete results](api/README.md#file-inputs-and-complete-results).
|
package/api/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Intentional Node API failures use `Exception` from `jg-exception`. The [error re
|
|
|
10
10
|
|
|
11
11
|
- Runtime: `createAgentHq`, `IAgentHq`, `IAgentHqOptions`, `IPreviousRuntimeCheck` and `IPreviousRuntimeOwner`; see [runtime lifecycle](#runtime-lifecycle).
|
|
12
12
|
- Local client: `requestAgentHq`, which sends one command to a running runtime over its socket.
|
|
13
|
+
- Async observations: `IAsyncInputSource`, `IAsyncInputEvent` and `IAsyncInputListener`, used by `IAgentHq.observeAsyncInputs`; see [async questions](#async-questions).
|
|
13
14
|
- Errors: `getErrorKind`, which reads an error's safe classification.
|
|
14
15
|
- Host storage: `openHostDatabase`, `IStorageDescriptor` and `IStorageMaintenanceOperation`; see [shared storage](#shared-storage).
|
|
15
16
|
- Snapshots: `restoreHqSnapshot`, `packHqSnapshot`, `unpackHqSnapshot`, `IHqSnapshotInspection`, `IHqRestoreOptions` and `IHqRestoreResult`; see [snapshot and restore](#snapshot-and-restore).
|
|
@@ -24,6 +25,7 @@ Intentional Node API failures use `Exception` from `jg-exception`. The [error re
|
|
|
24
25
|
- Sessions and history: `ThreadsPageSchema`, `IThreadsPage`, `ThreadSummarySchema`, `IThreadSummary`, `SessionTerminalSchema`, `ISessionTerminal`, `ActiveSessionsSchema`, `IActiveSessions`, `HistoryItemSchema`, `IHistoryItem`, `HistoryFileSchema`, `IHistoryFile`, `ItemDetailSchema`, `IItemDetail`, `ItemImageSchema`, `IItemImage`, `ItemImageMediaTypeSchema`, `IItemImageMediaType`, `LiveItemsSchema`, `NativeLineageSchema` and `INativeLineage`; see [session discovery](#session-discovery).
|
|
25
26
|
- Session states: `SessionStateSchema`, `ISessionState`, `SessionTransitionReasonSchema`, `ISessionTransitionReason`, `SessionTransitionSchema`, `ISessionTransition`, `SessionTransitionPageSchema`, `ObservationPaceSchema` and `IObservationPace`; see [session states](#session-states).
|
|
26
27
|
- Evidence: `EvidenceRequestSchema`, `IEvidenceRequest`, `EvidencePageSchema`, `IEvidencePage`, `EvidenceItemSchema`, `IEvidenceItem`, `HistoryProvenanceSchema` and `IHistoryProvenance`; see [bounded session evidence](#bounded-session-evidence).
|
|
28
|
+
- Async questions: `AsyncQuestionSchema`, `IAsyncQuestion`, `AsyncInputSchema`, `IAsyncInput` and `MAX_ASYNC_INPUT_BYTES`; see [async questions](#async-questions).
|
|
27
29
|
- Actions and replies: `ActionCommandSchema`, `IActionCommand`, `ActionEnvelopeSchema`, `IActionEnvelope`, `ActionReceiptSchema`, `IActionReceipt`, `ActionSummarySchema`, `IActionSummary`, `ActionWaitSchema`, `IActionWait`, `ACTION_PHASES`, `IActionPhase`, `ManagedThreadSchema`, `IManagedThread`, `PreparedInputSchema`, `IPreparedInput`, `NativeApprovalSchema`, `INativeApproval`, `NativeApprovalSummarySchema`, `INativeApprovalSummary`, `ApprovalPresentationSchema`, `IApprovalPresentation`, `NativeElicitationSchema` and `INativeElicitation`; see [thread control and live input](#thread-control-and-live-input).
|
|
28
30
|
- Skills: `SkillIdSchema`, `SkillSchema`, `ISkill`, `SkillPageSchema`, `ISkillPage`, `NativeSkillInputSchema`, `INativeSkillInput`, `MessageInputSchema` and `IMessageInput`; see [native skill catalog](#native-skill-catalog).
|
|
29
31
|
- Configuration: `TurnSettingsSchema`, `ITurnSettings`, `SessionSettingsSchema`, `ISessionSettings`, `ConfigurationRequestSchema`, `IConfigurationRequest`, `ConfigurationChoiceSchema`, `IConfigurationChoice`, `SessionConfigurationSchema` and `ISessionConfiguration`; see [native configuration](#native-configuration).
|
|
@@ -250,6 +252,18 @@ Selected history reads refresh only that file, retain incomplete tails, and dete
|
|
|
250
252
|
|
|
251
253
|
File timestamps and records do not prove that a native process is idle or a turn completed. Claude file-backed thread and turn states are therefore `unknown`, with no invented completion timestamp. Explicit native custom titles are preserved; a missing title remains null. A turn starts at a message the operator sends, including a slash command, except a message taken into a running turn, which belongs to it; task notifications, compaction summaries, local command output, interruption markers and `!` shell records belong to the turn before them. Grouping follows parent links and is not an authoritative execution boundary. A compaction starts a new chain whose first record names the record before it, so history reads on past the compaction to the start of the conversation.
|
|
252
254
|
|
|
255
|
+
## Async questions
|
|
256
|
+
|
|
257
|
+
An explicit Codex `agentMessage` with `delivery: 'async'` carries optional `asyncInput` on its normalized history item. The same metadata is available in live items, item details and every evidence fragment. Ordinary messages have no `asyncInput`; text or a `questions` field alone never establishes async semantics.
|
|
258
|
+
|
|
259
|
+
Available metadata is `{ delivery: 'async', state: 'available', questions }`. Each ordered question has a nonempty `title` and optional ordered string `options`. Question and choice strings retain their exact content, up to 8192 UTF-16 code units each, with at most 32 questions and 32 choices per question. The entire normalized `asyncInput` must fit `MAX_ASYNC_INPUT_BYTES` (32768 serialized UTF-8 bytes, including JSON escaping). Additive native fields are tolerated. Malformed contracts retain ordinary preview text and `{ delivery: 'async', state: 'unavailable', reason: 'invalid' }`; valid shapes over the byte budget use `reason: 'too-large'`. Choices are never shortened to fit a response. Evidence fitting accounts for metadata before selecting its text chunk; live memory accounting includes the complete serialized item, and saved/live reconciliation requires matching async metadata.
|
|
260
|
+
|
|
261
|
+
`hq.observeAsyncInputs(listener)` is a trusted in-process Node API, independent of IPC/browser readers. It returns an idempotent unsubscribe function. The listener synchronously enqueues bounded host work; it must not block, return asynchronous work or use observations as authority. An `item` event contains `source: { threadId, provider, nativeId, workspaceRoot }` and the complete normalized `item`. `threadId` names the managed record. Only completed items from controlled sessions with a validated source are emitted; partial updates and external sessions are excluded. Each listener receives its own copy.
|
|
262
|
+
|
|
263
|
+
A `recovery` event contains `provider`, nullable `source` and `reason`: `subscribed`, `output-gap`, `reconnect` or `listener-failed`. Subscription immediately requests catch-up for managed Codex sessions. A null source means recovery for that provider's relevant controlled sessions. Native connection/output loss requests catch-up, and successful reconnect requests it again. Listener exceptions cannot stop native execution or other subscriptions: recovery is attempted immediately and, if the listener still fails, before its next observation. There is no callback queue, replay log or persistent question store. Runtime shutdown releases all listeners; subscribing after shutdown retains none.
|
|
264
|
+
|
|
265
|
+
Hosts retain their own resolution metadata and recover missed questions through bounded authorized `items` pages, deduplicating by exact session/turn/item identity. A question can remain unresolved after its native turn finishes. It is separate from a blocking native `item/tool/requestUserInput` approval and is never answered with `native-reply`. Only explicit authenticated host input authorizes an ordinary message or exact-turn steer. Async messages are excluded from ordinary final-result capture before phase and size handling; an async-only turn retains the existing `missing-result` outcome.
|
|
266
|
+
|
|
253
267
|
## Thread control and live input
|
|
254
268
|
|
|
255
269
|
Send `{ kind: 'action', action: { id, runtimeEpoch, command } }`. Generate one UUID per user intent, take the epoch from `status` or the runtime's `runtimeEpoch`, and retain the complete envelope until its receipt can be read. The validated envelope is limited to `MAX_ACTION_BYTES`, 32,768 UTF-8 bytes of its JSON, which `jg-agent-hq/contracts` exports. It is recorded before native writes. Reusing the UUID with the identical envelope returns the saved receipt without dispatch; a changed envelope conflicts. This check also works for an original request read after restart. A new UUID with an expired epoch cannot execute.
|
|
@@ -467,6 +481,8 @@ Live reads accept `afterRevision`. A matching revision returns `unchanged: true`
|
|
|
467
481
|
|
|
468
482
|
The operation matrix describes the implemented native interfaces and their explicit unavailable surfaces. Executed qualification is narrower than every possible model, configuration and account state. Native versions below are observations, never admission rules.
|
|
469
483
|
|
|
484
|
+
On 2026-11-10, Linux with Node.js 24.15.0 and Codex 0.167.0 qualified the built public async-input API in an owned disposable workspace. Actual `request_user_input_async` emission retained the exact question choices and managed/native/turn/item identities, matched saved native history, and left the ordinary `ASYNC_QUALIFICATION_FINAL` result intact. Terminating only that runtime's owned Codex proxy produced output-gap/reconnect signals; bounded native history recovered the same question without inference or input replay. The owned session was deleted and the runtime closed. Fixture tests additionally cover invalid/oversized metadata, evidence fitting, observer isolation and shutdown; macOS and other CLI/model configurations require separate native evidence.
|
|
485
|
+
|
|
470
486
|
On 2026-11-07, Codex 0.167.0 consumed image and labeled text input through `turn/steer` in the running turn. Claude Code 2.1.319 with claude-opus-5-5 and normal `auto` permissions consumed text/PDF document blocks at turn start, and image plus labeled text blocks in the original running turn. A native PDF steer was dropped, so it is excluded from Claude's steer media list. The repaired runtime journey verified exact browser/action/source identity, original first-text hash, separate persisted prompt blocks, unchanged saved image bytes, live/history reconciliation, and provenance after restart without resending. The queued prompt's graph UUID differs from its input's source UUID. Its projection rebuild was also checked against the retained real transcript and an older cached index. These checks establish the observed native shapes and provider versions, without using an origin override or changing turn-start encoding.
|
|
471
487
|
|
|
472
488
|
| Area | Executed evidence | Boundary |
|
|
@@ -2,6 +2,7 @@ import type { IActionEnvelope, IActionReceipt, INativeApproval, INativeApprovalS
|
|
|
2
2
|
import type { createProviderRegistry } from '../providers/registry/index.js';
|
|
3
3
|
import type { createSkills } from '../skills/index.js';
|
|
4
4
|
import type { IStore } from '../store/index.js';
|
|
5
|
+
import type { createAsyncInputs } from '../runtime/async-inputs/index.js';
|
|
5
6
|
import { LiveItems } from './live/index.js';
|
|
6
7
|
import { ActionWaits, ChangeWaits } from './waits/index.js';
|
|
7
8
|
import type { IPollTopic } from './types.js';
|
|
@@ -9,7 +10,7 @@ import type { IPollTopic } from './types.js';
|
|
|
9
10
|
* Owns admitted native work across client disconnects, with durable delivery evidence.
|
|
10
11
|
* @returns The runtime-scoped action controller. Close must precede worker shutdown.
|
|
11
12
|
*/
|
|
12
|
-
export declare const createActions: (registry: ReturnType<typeof createProviderRegistry>, store: IStore, roots: string[], epoch: string, actionKey: Uint8Array, skills: ReturnType<typeof createSkills>, runBackground: (operation: () => Promise<void>) => Promise<void>, claudeTerminalOf: (nativeId: string) => ISessionTerminal | null) => {
|
|
13
|
+
export declare const createActions: (registry: ReturnType<typeof createProviderRegistry>, store: IStore, roots: string[], epoch: string, actionKey: Uint8Array, skills: ReturnType<typeof createSkills>, runBackground: (operation: () => Promise<void>) => Promise<void>, claudeTerminalOf: (nativeId: string) => ISessionTerminal | null, asyncInputs: ReturnType<typeof createAsyncInputs>) => {
|
|
13
14
|
live: LiveItems;
|
|
14
15
|
waits: ActionWaits;
|
|
15
16
|
polls: ChangeWaits<IPollTopic>;
|
package/dist/actions/actions.js
CHANGED
|
@@ -13,7 +13,7 @@ import { keepsSessions } from './utilities.js';
|
|
|
13
13
|
* Owns admitted native work across client disconnects, with durable delivery evidence.
|
|
14
14
|
* @returns The runtime-scoped action controller. Close must precede worker shutdown.
|
|
15
15
|
*/
|
|
16
|
-
export const createActions = (registry, store, roots, epoch, actionKey, skills, runBackground, claudeTerminalOf) => {
|
|
16
|
+
export const createActions = (registry, store, roots, epoch, actionKey, skills, runBackground, claudeTerminalOf, asyncInputs) => {
|
|
17
17
|
const admissions = new Set();
|
|
18
18
|
// native work the runtime owns, which close stops admitting and drains
|
|
19
19
|
const owned = createTaskRunner({ onError: (error) => events.failEvents(error) });
|
|
@@ -22,6 +22,7 @@ export const createActions = (registry, store, roots, epoch, actionKey, skills,
|
|
|
22
22
|
const polls = new ChangeWaits(MAX_CONNECTIONS);
|
|
23
23
|
const context = {
|
|
24
24
|
registry,
|
|
25
|
+
asyncInputs,
|
|
25
26
|
store,
|
|
26
27
|
roots,
|
|
27
28
|
epoch,
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { signHmac } from 'jg-crypto';
|
|
3
3
|
import { isException } from 'jg-exception';
|
|
4
4
|
import { delay } from 'jg-utilities';
|
|
5
|
-
import { MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE } from '../../contracts/index.js';
|
|
5
|
+
import { MAX_ITEM_TEXT_LENGTH, MAX_PAGE_SIZE, } from '../../contracts/index.js';
|
|
6
6
|
import { HQ_ERRORS, getErrorKind } from '../../errors/index.js';
|
|
7
7
|
import { capabilityUnavailable } from '../../providers/registry/index.js';
|
|
8
8
|
import { correlateEvidenceOrigins } from '../../sessions/index.js';
|
|
@@ -21,6 +21,34 @@ export const createEvents = (context, dispatcher, reconnect) => {
|
|
|
21
21
|
const eventCounts = new Map();
|
|
22
22
|
// providers whose connection reports the sessions other clients drive
|
|
23
23
|
const observingProviders = new Set();
|
|
24
|
+
/** Resolves event identity through the controlled record before exposing it to a trusted host. */
|
|
25
|
+
const observeAsyncInput = (provider, nativeId, item) => {
|
|
26
|
+
if (state.isClosing || !context.asyncInputs.hasListeners())
|
|
27
|
+
return;
|
|
28
|
+
enqueue(provider, async () => {
|
|
29
|
+
const thread = await store.call('reads', 'getThreadByNativeId', provider, nativeId);
|
|
30
|
+
if (!thread || !controlled.has(key(provider, nativeId)))
|
|
31
|
+
return;
|
|
32
|
+
if (thread.ownership !== 'managed' || thread.runtimeEpoch !== epoch) {
|
|
33
|
+
context.asyncInputs.emit({
|
|
34
|
+
kind: 'recovery',
|
|
35
|
+
provider,
|
|
36
|
+
source: null,
|
|
37
|
+
reason: 'output-gap',
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const source = {
|
|
42
|
+
threadId: thread.id,
|
|
43
|
+
provider,
|
|
44
|
+
nativeId,
|
|
45
|
+
workspaceRoot: thread.workspaceRoot,
|
|
46
|
+
};
|
|
47
|
+
context.asyncInputs.emit(item
|
|
48
|
+
? { kind: 'item', source, item }
|
|
49
|
+
: { kind: 'recovery', provider, source, reason: 'output-gap' });
|
|
50
|
+
});
|
|
51
|
+
};
|
|
24
52
|
/**
|
|
25
53
|
* Records native evidence, then wakes the receipt waits it can affect: a lost connection's on
|
|
26
54
|
* every receipt, and other evidence's on its thread's receipts.
|
|
@@ -293,6 +321,7 @@ export const createEvents = (context, dispatcher, reconnect) => {
|
|
|
293
321
|
resync(provider, nativeId, lost) {
|
|
294
322
|
if (state.isClosing)
|
|
295
323
|
return;
|
|
324
|
+
context.asyncInputs.emit({ kind: 'recovery', provider, source: null, reason: 'output-gap' });
|
|
296
325
|
const request = { lost, isLastAttempt: false, turnId: null };
|
|
297
326
|
// without a session, every session this runtime controls through the provider is read
|
|
298
327
|
if (nativeId === undefined) {
|
|
@@ -310,10 +339,14 @@ export const createEvents = (context, dispatcher, reconnect) => {
|
|
|
310
339
|
for (const replacedId of replacedIds ?? [])
|
|
311
340
|
live.replace(key(provider, nativeId), item.turnId, replacedId);
|
|
312
341
|
live.put(key(provider, nativeId), item, isComplete);
|
|
342
|
+
if (isComplete && item.asyncInput)
|
|
343
|
+
observeAsyncInput(provider, nativeId, item);
|
|
313
344
|
},
|
|
314
345
|
gap(provider, nativeId) {
|
|
315
|
-
if (controlled.has(key(provider, nativeId)))
|
|
346
|
+
if (controlled.has(key(provider, nativeId))) {
|
|
316
347
|
live.markGap(key(provider, nativeId));
|
|
348
|
+
observeAsyncInput(provider, nativeId);
|
|
349
|
+
}
|
|
317
350
|
},
|
|
318
351
|
background(provider, nativeId, count) {
|
|
319
352
|
if (controlled.has(key(provider, nativeId)))
|
|
@@ -419,6 +452,7 @@ export const createEvents = (context, dispatcher, reconnect) => {
|
|
|
419
452
|
unavailable(provider, nativeId) {
|
|
420
453
|
if (state.isClosing || context.blockedProviders.has(provider))
|
|
421
454
|
return;
|
|
455
|
+
context.asyncInputs.emit({ kind: 'recovery', provider, source: null, reason: 'output-gap' });
|
|
422
456
|
const canReconnect = provider === 'codex' && nativeId === undefined;
|
|
423
457
|
let reconnectable = [];
|
|
424
458
|
enqueue(provider, async () => {
|
|
@@ -444,8 +478,15 @@ export const createEvents = (context, dispatcher, reconnect) => {
|
|
|
444
478
|
const persisted = state.lane;
|
|
445
479
|
runOwned(async () => {
|
|
446
480
|
await persisted;
|
|
447
|
-
if (!state.isClosing && !state.isUnavailable && !context.blockedProviders.has(provider))
|
|
481
|
+
if (!state.isClosing && !state.isUnavailable && !context.blockedProviders.has(provider)) {
|
|
448
482
|
await reconnect(reconnectable);
|
|
483
|
+
context.asyncInputs.emit({
|
|
484
|
+
kind: 'recovery',
|
|
485
|
+
provider,
|
|
486
|
+
source: null,
|
|
487
|
+
reason: 'reconnect',
|
|
488
|
+
});
|
|
489
|
+
}
|
|
449
490
|
});
|
|
450
491
|
}
|
|
451
492
|
else
|
|
@@ -181,6 +181,7 @@ export class LiveItems {
|
|
|
181
181
|
entry.item.provenance.nativeInputSha256 === item.provenance.nativeInputSha256)) &&
|
|
182
182
|
entry.item.nativeType === item.nativeType &&
|
|
183
183
|
entry.item.kind === item.kind &&
|
|
184
|
+
JSON.stringify(entry.item.asyncInput) === JSON.stringify(item.asyncInput) &&
|
|
184
185
|
((entry.item.text === item.text && entry.item.isTruncated === item.isTruncated) ||
|
|
185
186
|
(item.outcome !== null && entry.item.outcome === item.outcome))) {
|
|
186
187
|
this.__bytes -= entry.bytes;
|
package/dist/actions/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { INativePrompt } from '../providers/index.js';
|
|
|
3
3
|
import type { createProviderRegistry } from '../providers/registry/index.js';
|
|
4
4
|
import type { createSkills } from '../skills/index.js';
|
|
5
5
|
import type { IStore } from '../store/index.js';
|
|
6
|
+
import type { createAsyncInputs } from '../runtime/async-inputs/index.js';
|
|
6
7
|
import type { LiveItems } from './live/index.js';
|
|
7
8
|
import type { ActionWaits, ChangeWaits } from './waits/index.js';
|
|
8
9
|
export type IPollTopic = {
|
|
@@ -19,6 +20,7 @@ export type IActionsState = {
|
|
|
19
20
|
};
|
|
20
21
|
export type IActionsContext = {
|
|
21
22
|
registry: ReturnType<typeof createProviderRegistry>;
|
|
23
|
+
asyncInputs: ReturnType<typeof createAsyncInputs>;
|
|
22
24
|
store: IStore;
|
|
23
25
|
roots: string[];
|
|
24
26
|
epoch: string;
|
|
@@ -549,9 +549,9 @@ export declare const ActionReceiptSchema: z.ZodObject<{
|
|
|
549
549
|
digest: z.ZodString;
|
|
550
550
|
runtimeEpoch: z.ZodUUID;
|
|
551
551
|
kind: z.ZodEnum<{
|
|
552
|
+
message: "message";
|
|
552
553
|
steer: "steer";
|
|
553
554
|
interrupt: "interrupt";
|
|
554
|
-
message: "message";
|
|
555
555
|
"thread-create": "thread-create";
|
|
556
556
|
"thread-adopt": "thread-adopt";
|
|
557
557
|
"thread-resume": "thread-resume";
|
|
@@ -664,14 +664,22 @@ export declare const ActionReceiptSchema: z.ZodObject<{
|
|
|
664
664
|
export type IActionReceipt = z.infer<typeof ActionReceiptSchema>;
|
|
665
665
|
export type IActionPhase = NonNullable<IActionReceipt['phase']>;
|
|
666
666
|
export declare const ActionSummarySchema: z.ZodObject<{
|
|
667
|
+
delivery: z.ZodEnum<{
|
|
668
|
+
failed: "failed";
|
|
669
|
+
uncertain: "uncertain";
|
|
670
|
+
queued: "queued";
|
|
671
|
+
submitted: "submitted";
|
|
672
|
+
acknowledged: "acknowledged";
|
|
673
|
+
canceled: "canceled";
|
|
674
|
+
}>;
|
|
667
675
|
provider: z.ZodNullable<z.ZodEnum<{
|
|
668
676
|
claude: "claude";
|
|
669
677
|
codex: "codex";
|
|
670
678
|
}>>;
|
|
671
679
|
kind: z.ZodEnum<{
|
|
680
|
+
message: "message";
|
|
672
681
|
steer: "steer";
|
|
673
682
|
interrupt: "interrupt";
|
|
674
|
-
message: "message";
|
|
675
683
|
"thread-create": "thread-create";
|
|
676
684
|
"thread-adopt": "thread-adopt";
|
|
677
685
|
"thread-resume": "thread-resume";
|
|
@@ -707,14 +715,6 @@ export declare const ActionSummarySchema: z.ZodObject<{
|
|
|
707
715
|
delete: "delete";
|
|
708
716
|
reply: "reply";
|
|
709
717
|
}>>;
|
|
710
|
-
delivery: z.ZodEnum<{
|
|
711
|
-
failed: "failed";
|
|
712
|
-
uncertain: "uncertain";
|
|
713
|
-
queued: "queued";
|
|
714
|
-
submitted: "submitted";
|
|
715
|
-
acknowledged: "acknowledged";
|
|
716
|
-
canceled: "canceled";
|
|
717
|
-
}>;
|
|
718
718
|
completion: z.ZodNullable<z.ZodEnum<{
|
|
719
719
|
completed: "completed";
|
|
720
720
|
failed: "failed";
|
|
@@ -735,9 +735,9 @@ export declare const ActionWaitSchema: z.ZodObject<{
|
|
|
735
735
|
digest: z.ZodString;
|
|
736
736
|
runtimeEpoch: z.ZodUUID;
|
|
737
737
|
kind: z.ZodEnum<{
|
|
738
|
+
message: "message";
|
|
738
739
|
steer: "steer";
|
|
739
740
|
interrupt: "interrupt";
|
|
740
|
-
message: "message";
|
|
741
741
|
"thread-create": "thread-create";
|
|
742
742
|
"thread-adopt": "thread-adopt";
|
|
743
743
|
"thread-resume": "thread-resume";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MAX_ASYNC_INPUT_BYTES = 32768;
|
|
3
|
+
export declare const AsyncQuestionSchema: z.ZodObject<{
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type IAsyncQuestion = z.infer<typeof AsyncQuestionSchema>;
|
|
8
|
+
export declare const AsyncInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
delivery: z.ZodLiteral<"async">;
|
|
10
|
+
state: z.ZodLiteral<"available">;
|
|
11
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
12
|
+
title: z.ZodString;
|
|
13
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
delivery: z.ZodLiteral<"async">;
|
|
17
|
+
state: z.ZodLiteral<"unavailable">;
|
|
18
|
+
reason: z.ZodEnum<{
|
|
19
|
+
invalid: "invalid";
|
|
20
|
+
"too-large": "too-large";
|
|
21
|
+
}>;
|
|
22
|
+
}, z.core.$strip>], "state">;
|
|
23
|
+
export type IAsyncInput = z.infer<typeof AsyncInputSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// complete structured presentation leaves room for identity and text within bounded responses
|
|
3
|
+
export const MAX_ASYNC_INPUT_BYTES = 32_768;
|
|
4
|
+
// native question positions and choices retain their original order and exact strings
|
|
5
|
+
export const AsyncQuestionSchema = z.object({
|
|
6
|
+
title: z.string().min(1).max(8192),
|
|
7
|
+
options: z.array(z.string().min(1).max(8192)).max(32).optional(),
|
|
8
|
+
});
|
|
9
|
+
// unavailable metadata preserves explicit async semantics without presenting a partial answer contract
|
|
10
|
+
export const AsyncInputSchema = z
|
|
11
|
+
.discriminatedUnion('state', [
|
|
12
|
+
z.object({
|
|
13
|
+
delivery: z.literal('async'),
|
|
14
|
+
state: z.literal('available'),
|
|
15
|
+
questions: z.array(AsyncQuestionSchema).min(1).max(32),
|
|
16
|
+
}),
|
|
17
|
+
z.object({
|
|
18
|
+
delivery: z.literal('async'),
|
|
19
|
+
state: z.literal('unavailable'),
|
|
20
|
+
reason: z.enum(['invalid', 'too-large']),
|
|
21
|
+
}),
|
|
22
|
+
])
|
|
23
|
+
.refine((input) => new TextEncoder().encode(JSON.stringify(input)).length <= MAX_ASYNC_INPUT_BYTES);
|
|
@@ -549,9 +549,9 @@ export declare const BrowserReceiptSchema: z.ZodObject<{
|
|
|
549
549
|
digest: z.ZodString;
|
|
550
550
|
runtimeEpoch: z.ZodUUID;
|
|
551
551
|
kind: z.ZodEnum<{
|
|
552
|
+
message: "message";
|
|
552
553
|
steer: "steer";
|
|
553
554
|
interrupt: "interrupt";
|
|
554
|
-
message: "message";
|
|
555
555
|
"thread-create": "thread-create";
|
|
556
556
|
"thread-adopt": "thread-adopt";
|
|
557
557
|
"thread-resume": "thread-resume";
|
|
@@ -803,6 +803,21 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
|
|
|
803
803
|
}, z.core.$strip>;
|
|
804
804
|
text: z.ZodString;
|
|
805
805
|
isTruncated: z.ZodBoolean;
|
|
806
|
+
asyncInput: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
807
|
+
delivery: z.ZodLiteral<"async">;
|
|
808
|
+
state: z.ZodLiteral<"available">;
|
|
809
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
810
|
+
title: z.ZodString;
|
|
811
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
812
|
+
}, z.core.$strip>>;
|
|
813
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
814
|
+
delivery: z.ZodLiteral<"async">;
|
|
815
|
+
state: z.ZodLiteral<"unavailable">;
|
|
816
|
+
reason: z.ZodEnum<{
|
|
817
|
+
invalid: "invalid";
|
|
818
|
+
"too-large": "too-large";
|
|
819
|
+
}>;
|
|
820
|
+
}, z.core.$strip>], "state">>;
|
|
806
821
|
callId: z.ZodNullable<z.ZodString>;
|
|
807
822
|
outcome: z.ZodNullable<z.ZodEnum<{
|
|
808
823
|
failed: "failed";
|
|
@@ -824,14 +839,22 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
|
|
|
824
839
|
}, z.core.$strip>;
|
|
825
840
|
actions: z.ZodObject<{
|
|
826
841
|
data: z.ZodArray<z.ZodObject<{
|
|
842
|
+
delivery: z.ZodEnum<{
|
|
843
|
+
failed: "failed";
|
|
844
|
+
uncertain: "uncertain";
|
|
845
|
+
queued: "queued";
|
|
846
|
+
submitted: "submitted";
|
|
847
|
+
acknowledged: "acknowledged";
|
|
848
|
+
canceled: "canceled";
|
|
849
|
+
}>;
|
|
827
850
|
provider: z.ZodNullable<z.ZodEnum<{
|
|
828
851
|
claude: "claude";
|
|
829
852
|
codex: "codex";
|
|
830
853
|
}>>;
|
|
831
854
|
kind: z.ZodEnum<{
|
|
855
|
+
message: "message";
|
|
832
856
|
steer: "steer";
|
|
833
857
|
interrupt: "interrupt";
|
|
834
|
-
message: "message";
|
|
835
858
|
"thread-create": "thread-create";
|
|
836
859
|
"thread-adopt": "thread-adopt";
|
|
837
860
|
"thread-resume": "thread-resume";
|
|
@@ -867,14 +890,6 @@ export declare const BrowserThreadDetailSchema: z.ZodObject<{
|
|
|
867
890
|
delete: "delete";
|
|
868
891
|
reply: "reply";
|
|
869
892
|
}>>;
|
|
870
|
-
delivery: z.ZodEnum<{
|
|
871
|
-
failed: "failed";
|
|
872
|
-
uncertain: "uncertain";
|
|
873
|
-
queued: "queued";
|
|
874
|
-
submitted: "submitted";
|
|
875
|
-
acknowledged: "acknowledged";
|
|
876
|
-
canceled: "canceled";
|
|
877
|
-
}>;
|
|
878
893
|
completion: z.ZodNullable<z.ZodEnum<{
|
|
879
894
|
completed: "completed";
|
|
880
895
|
failed: "failed";
|
|
@@ -100,10 +100,25 @@ export declare const EvidenceItemSchema: z.ZodObject<{
|
|
|
100
100
|
totalBytes: z.ZodNumber;
|
|
101
101
|
isComplete: z.ZodBoolean;
|
|
102
102
|
contentState: z.ZodEnum<{
|
|
103
|
-
unsupported: "unsupported";
|
|
104
103
|
available: "available";
|
|
104
|
+
unsupported: "unsupported";
|
|
105
105
|
"native-preview": "native-preview";
|
|
106
106
|
}>;
|
|
107
|
+
asyncInput: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
|
+
delivery: z.ZodLiteral<"async">;
|
|
109
|
+
state: z.ZodLiteral<"available">;
|
|
110
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
111
|
+
title: z.ZodString;
|
|
112
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
delivery: z.ZodLiteral<"async">;
|
|
116
|
+
state: z.ZodLiteral<"unavailable">;
|
|
117
|
+
reason: z.ZodEnum<{
|
|
118
|
+
invalid: "invalid";
|
|
119
|
+
"too-large": "too-large";
|
|
120
|
+
}>;
|
|
121
|
+
}, z.core.$strip>], "state">>;
|
|
107
122
|
}, z.core.$strip>;
|
|
108
123
|
export type IEvidenceItem = z.infer<typeof EvidenceItemSchema>;
|
|
109
124
|
export declare const EvidencePageSchema: z.ZodObject<{
|
|
@@ -154,10 +169,25 @@ export declare const EvidencePageSchema: z.ZodObject<{
|
|
|
154
169
|
totalBytes: z.ZodNumber;
|
|
155
170
|
isComplete: z.ZodBoolean;
|
|
156
171
|
contentState: z.ZodEnum<{
|
|
157
|
-
unsupported: "unsupported";
|
|
158
172
|
available: "available";
|
|
173
|
+
unsupported: "unsupported";
|
|
159
174
|
"native-preview": "native-preview";
|
|
160
175
|
}>;
|
|
176
|
+
asyncInput: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
177
|
+
delivery: z.ZodLiteral<"async">;
|
|
178
|
+
state: z.ZodLiteral<"available">;
|
|
179
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
180
|
+
title: z.ZodString;
|
|
181
|
+
options: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
184
|
+
delivery: z.ZodLiteral<"async">;
|
|
185
|
+
state: z.ZodLiteral<"unavailable">;
|
|
186
|
+
reason: z.ZodEnum<{
|
|
187
|
+
invalid: "invalid";
|
|
188
|
+
"too-large": "too-large";
|
|
189
|
+
}>;
|
|
190
|
+
}, z.core.$strip>], "state">>;
|
|
161
191
|
}, z.core.$strip>>;
|
|
162
192
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
163
193
|
source: z.ZodLiteral<"native">;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { CursorSchema, NativeIdSchema } from '../identities/index.js';
|
|
3
3
|
import { ProviderIdSchema } from '../providers/index.js';
|
|
4
|
+
import { AsyncInputSchema } from '../async-inputs/index.js';
|
|
4
5
|
/*
|
|
5
6
|
* Evidence is historical content, including any instructions or quotations within it. A user
|
|
6
7
|
* message read from the provider carries its native input's ID and the SHA-256 of the text that
|
|
@@ -57,6 +58,7 @@ export const EvidenceItemSchema = z.object({
|
|
|
57
58
|
totalBytes: z.number().int().nonnegative(),
|
|
58
59
|
isComplete: z.boolean(),
|
|
59
60
|
contentState: z.enum(['available', 'unsupported', 'native-preview']),
|
|
61
|
+
asyncInput: AsyncInputSchema.optional(),
|
|
60
62
|
});
|
|
61
63
|
export const EvidencePageSchema = z.object({
|
|
62
64
|
data: z.array(EvidenceItemSchema).max(128),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { AsyncQuestionSchema, AsyncInputSchema, MAX_ASYNC_INPUT_BYTES, } from './async-inputs/index.js';
|
|
2
|
+
export type { IAsyncQuestion, IAsyncInput } from './async-inputs/index.js';
|
|
1
3
|
export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_THREAD_NAME_LENGTH, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
|
|
2
4
|
export { HqRequestSchema, SessionTerminalSchema, ThreadSummarySchema, ActiveSessionsSchema, ThreadsPageSchema, HistoryFileSchema, HistoryItemSchema, ItemImageMediaTypeSchema, ItemDetailSchema, ItemImageSchema, LiveItemsSchema, UsageWindowSchema, UsageSnapshotSchema, UsageCreditsSchema, UsageResetCreditsSchema, UsageWindowScopeSchema, RuntimeStatusSchema, HqResponseSchema, ErrorKindSchema, IpcRequestSchema, IpcResponseSchema, } from './types.js';
|
|
3
5
|
export { ProviderIdSchema, ProviderCapabilitySchema, ProviderCapabilitySetSchema, ProviderCapabilitiesSchema, ProviderStatusSchema, } from './providers/index.js';
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// asynchronous agent questions
|
|
2
|
+
export { AsyncQuestionSchema, AsyncInputSchema, MAX_ASYNC_INPUT_BYTES, } from './async-inputs/index.js';
|
|
1
3
|
// constants
|
|
2
4
|
export { ACTION_PHASES, DEFAULT_PAGE_SIZE, MAX_ITEM_IMAGE_BYTES, MAX_ITEM_IMAGES, MAX_ITEM_TEXT_LENGTH, MAX_ACTION_BYTES, MAX_PAGE_SIZE, MAX_THREAD_NAME_LENGTH, MAX_WAIT_MS, MAX_WORKSPACE_ROOTS, PUBLIC_ERROR_CODES, PUBLIC_ERROR_MESSAGES, } from './constants.js';
|
|
3
5
|
// wire contracts
|